Skip to content

Commit e2e575a

Browse files
authored
feat(bounty): don't require the caller's personal wallet for MANAGED payout/cancel (#680)
Mirror the hackathon use-publish-winners flow: the backend now signs select_winners / cancel with the on-chain event manager (the org treasury or owner that published), so a connected wallet is only needed for EXTERNAL signing. Stop blocking MANAGED on a personal wallet and send ownerAddress as an optional hint. Pairs with boundless-nestjs#392.
1 parent 6f4b86f commit e2e575a

2 files changed

Lines changed: 23 additions & 18 deletions

File tree

hooks/use-bounty-cancel.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,19 +77,21 @@ export const useBountyCancel = ({
7777

7878
const cancel = async (): Promise<void> => {
7979
if (!organizationId || !bountyId) return;
80-
if (!ownerAddress) {
81-
toast.error(
82-
isExternal
83-
? 'Connect a wallet to sign the cancellation.'
84-
: 'Please connect your wallet first'
85-
);
80+
// EXTERNAL is signed by the connected wallet; MANAGED is signed server-side
81+
// by the on-chain event manager (the treasury/owner that published), so no
82+
// connected wallet is needed. ownerAddress is a hint the backend may use as
83+
// a fallback.
84+
if (isExternal && !ownerAddress) {
85+
toast.error('Connect a wallet to sign the cancellation.');
8686
return;
8787
}
8888

89-
const body: CancelBountyEscrowRequest = {
90-
ownerAddress,
89+
// ownerAddress is optional on the backend (boundless-nestjs#392); until
90+
// codegen picks that up the generated type marks it required, so cast.
91+
const body = {
9192
fundingMode,
92-
};
93+
...(ownerAddress ? { ownerAddress } : {}),
94+
} as CancelBountyEscrowRequest;
9395

9496
finalizedRef.current = false;
9597
toast.info('Submitting cancellation…');

hooks/use-bounty-payout.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,20 +72,23 @@ export const useBountyPayout = ({
7272
selections: BountyWinnerSelection[]
7373
): Promise<void> => {
7474
if (!organizationId || !bountyId || selections.length === 0) return;
75-
if (!ownerAddress) {
76-
toast.error(
77-
isExternal
78-
? 'Connect a wallet to sign the payout.'
79-
: 'Please connect your wallet first'
80-
);
75+
// EXTERNAL is signed by the connected wallet, so it's required there.
76+
// MANAGED is signed server-side by the on-chain event manager (the treasury
77+
// / owner that published) — no connected wallet needed. ownerAddress is a
78+
// hint only; the backend resolves and signs with the real manager.
79+
if (isExternal && !ownerAddress) {
80+
toast.error('Connect a wallet to sign the payout.');
8181
return;
8282
}
8383

84-
const body: SelectBountyWinnersRequest = {
85-
ownerAddress,
84+
// ownerAddress is optional on the backend (it resolves the manager); until
85+
// codegen picks that up (boundless-nestjs#392) the generated type still
86+
// marks it required, so cast.
87+
const body = {
8688
selections,
8789
fundingMode,
88-
};
90+
...(ownerAddress ? { ownerAddress } : {}),
91+
} as SelectBountyWinnersRequest;
8992

9093
finalizedRef.current = false;
9194
toast.info('Submitting winner selection…');

0 commit comments

Comments
 (0)