Repository navigation
feat(staking): authorize a wallet to transfer stake in - #885
adamsoffer wants to merge 5 commits into
Conversation
From 30 November the BondingManager only accepts transferBond into another account once that account has authorized the caller. The transfer dialog now explains an UNAUTHORIZED_BONDER refusal before signing and offers the fix: the receiving wallet signs setThirdPartyBonderAuthorization, then the transfer is picked back up from the sending wallet with its receiver and amount kept. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Authorized wallets: a wallet's menu lists the wallets that can transfer stake into it, each with a way to remove it. It reads Delegator.thirdPartyBonders, and isn't offered while the subgraph doesn't have the field or the list is empty. Pool claim warning: the protocol holds a claim on the claiming wallet and its own orchestrator, not the pool's. The warning now follows that: none for an unbonded wallet, and otherwise only when the wallet's orchestrator is active, hasn't called reward this round and the wallet hasn't claimed this round. The warning and the error name that orchestrator. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…menu Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| description = action.authorized | ||
| ? `Lets ${bonderName} transfer stake into this wallet. That's all it allows: it can't move stake out of this wallet or act for it.` | ||
| : `Stops ${bonderName} from transferring stake into this wallet. Stake already here isn't affected.`; |
There was a problem hiding this comment.
Maybe drop "That's all it allows", since it reads as a guarantee. Something like:
Lets X transfer stake into this wallet. It can't move stake out or act for it. Only authorize a wallet you control.
| destOrch.lastRewardRound !== protocol.currentRound ? ( | ||
| // The pool's stake can't move until its orchestrator has | ||
| // called reward this round (ILLEGAL_CLAIM_EARNINGS). | ||
| {claimIsHeld ? ( |
There was a problem hiding this comment.
This notice only renders in the pooled branch. A non-pooled claimStake goes through the L2Migrator into bondForWithHint, which is held on the wallet's own orchestrator too, so in the !pooled branch the user only finds out from a failed signature. Rendering the notice whenever claimIsHeld is true would cover both.
There was a problem hiding this comment.
Not in this PR. I'll take it in a follow-up.
| const account = position.account; | ||
| const saved = list.some((w) => w.address === account.address); | ||
| // Offered only once some wallet has been authorized. | ||
| const { data: bonders } = useThirdPartyBonders( |
There was a problem hiding this comment.
"Manage authorized wallets" is only reachable here (needs a position) and from DelegationActions (needs a delegate). A wallet with no stake that authorizes a sender and then abandons the transfer has no way to see or revoke the authorization. Could it go in the wallet settings or switcher menu too?
There was a problem hiding this comment.
Done in 9475c85. "Manage authorized wallets" is also in the connected wallet's menu and the portfolio switcher, so a wallet with nothing delegated can revoke.
|
|
||
| const BONDERS = /* GraphQL */ ` | ||
| query ThirdPartyBonders($id: ID!) { | ||
| delegator(id: $id) { |
There was a problem hiding this comment.
This depends on how we settle livepeer/subgraph#280, see my comment there. With the current Delegator link it works for unstaked wallets, since the grant creates a Delegator. If we switch to delegator: String!, Delegator.thirdPartyBonders goes away and the catch at L48 silently turns that into an empty list. The query would then need to be thirdPartyBonderAuthorizations(where: { delegator: $addr }).
There was a problem hiding this comment.
Switched in 9475c85 to thirdPartyBonderAuthorizations(where: { delegator: $delegator }). It works on the current #280 preview and should work with delegator: String! too. The catch now only covers a subgraph without thirdPartyBonderAuthorizations; any other error shows as an error rather than an empty list.
| const [picked, setPicked] = useState<Recipient | null>(null); | ||
| const [picked, setPicked] = useState<Recipient | null>( | ||
| action.kind === "transfer" && action.to | ||
| ? { address: action.to.toLowerCase() } |
There was a problem hiding this comment.
Nit: the resumed transfer starts from { address } only, so the recipient's ENS name and label are dropped. The ENS re-resolution in run() (if (picked?.ens)) is then skipped, and the vouch text shows the address. Carrying the original Recipient in then would keep it.
There was a problem hiding this comment.
Done in 9475c85. then carries the whole Recipient, so the ENS name is re-resolved before signing and the label is kept.
| {bonders && bonders.length === 0 ? ( | ||
| <p className="text-ui-body text-muted-foreground"> | ||
| No wallets are authorized now. | ||
| </p> | ||
| ) : ( | ||
| <ul className="flex flex-col divide-y divide-hairline rounded-lg border border-hairline"> | ||
| {(bonders ?? []).map((b) => ( |
There was a problem hiding this comment.
Nit: while loading, or after the query fails, bonders is undefined, so this renders an empty bordered list with no text. A skeleton on isLoading and a message on isError would help.
There was a problem hiding this comment.
Done in 9475c85: a skeleton while loading, and a message with "Try again" on error.
| </DialogBody> | ||
| <DialogFooter> | ||
| {finished || proposed ? ( | ||
| {next && !proposed && (finished || alreadyDone) ? ( |
There was a problem hiding this comment.
Nit: when an authorization started from a transfer finishes, this replaces the Done button, so the only way out without switching wallets is the close icon. Maybe show Done next to Continue transfer.
There was a problem hiding this comment.
Done in 9475c85. Done sits next to Continue transfer.
| query ThirdPartyBonders($id: ID!) { | ||
| delegator(id: $id) { | ||
| thirdPartyBonders( | ||
| first: 100 |
There was a problem hiding this comment.
Nit: no paging, so past 100 authorizations the oldest silently drop out and can't be revoked here. Unlikely in practice, but paging or a "showing 100" note would make it explicit.
There was a problem hiding this comment.
Done in 9475c85. It now pages through all of them.
| const unauthorized = | ||
| Boolean(receiver) && | ||
| !pendingDelegator && | ||
| isUnauthorizedBonder(simulation.error); |
There was a problem hiding this comment.
Nit: the simulation only runs once amountWei > 0n, so the unauthorized notice only shows after an amount is typed. A direct isThirdPartyBonderAuthorized(receiver, signer) read would show it as soon as the receiver is picked.
There was a problem hiding this comment.
Done in 9475c85, with the simulation instead of a direct read: before an amount is typed it simulates the smallest transfer. A direct read would also warn before enforcement, while transfers still work.
There was a problem hiding this comment.
Looks good overall. None of this blocks merging, so we can handle it in follow-ups. Details inline.
One general point: a wallet still gives up that round's rewards if it withdraws fees, delegates more, unbonds or moves stake before its orchestrator calls reward. The protocol allows this, but the explorer could warn about it. claimHeld already has the check.
- Reach Manage authorized wallets from the wallet menu and switcher, so a wallet with nothing delegated can revoke too - List authorizations by the granting wallet's address, in full - Show an unauthorized receiver as soon as it's picked - Keep the recipient's ENS name and label when a transfer is resumed - Offer Done beside Continue transfer, and loading and error states in the list - Don't describe an authorization as a guarantee Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks for the review. The inline comments are addressed in 9475c85, except the non-pooled claim notice. That one and your general point about warning before reward is called will come in a follow-up. |
There was a problem hiding this comment.
🟡 Changes recommended
An already-revoked authorization leaves the removal dialog with a permanently disabled Remove button instead of a Done action, preventing normal dismissal.
1 open issue
What changed in this PR
Updates staking flows for BondingManager’s third-party authorization requirement, allowing receiving wallets to authorize incoming stake transfers and manage existing permissions.
Changes:
- Adds authorization warnings, receiver-signed authorization, and transfer continuation with preserved inputs.
- Adds authorized-wallet listing and removal across account, portfolio, and wallet menus.
- Corrects pool-claim warnings to check the claiming wallet’s own orchestrator.
| File | Description |
|---|---|
lib/subgraph/authorizations.ts |
Fetches all authorized wallets with older-subgraph fallback. |
lib/subgraph/authorizations.test.ts |
Tests listing, ordering, and error handling. |
lib/staking/claim-hold.ts |
Defines claim-hold checks and warning messages. |
lib/staking/claim-hold.test.ts |
Tests claim-hold conditions and messages. |
lib/staking/authorization.ts |
Detects unauthorized transfers and formats warnings. |
lib/staking/authorization.test.ts |
Tests authorization error detection and messaging. |
lib/hooks/queries.ts |
Adds the authorized-wallet query hook. |
lib/abis/BondingManager.ts |
Adds authorization methods and event definitions. |
components/staking/staking.tsx |
Adds authorization flows and corrects pool-claim warnings. |
components/staking/authorized-wallets.tsx |
Adds the authorized-wallet list and removal action. |
components/shell/wallet-button.tsx |
Exposes authorization management in the portfolio switcher. |
components/shell/connected-pill.tsx |
Exposes authorization management for the connected wallet. |
components/portfolio/positions.tsx |
Adds authorization management to position menus. |
components/portfolio/position-header.tsx |
Adds authorization management to account actions. |
Review effort: Balanced
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🔵 Needs a closer look
Mock-only coverage leaves the asset-moving authorization and transfer flow insufficiently verified; authorization enforcement, revocation, transfer resumption, and pool claims need validation on an upgraded BondingManager fork.
No open issues 🎉
1 resolved since last review
Review effort: Balanced

As of 30 November, the BondingManager will only accepts
transferBond()(andbondForWithHint()) into another account once that account has authorized the caller (forum post). This makes Transfer stake work under that rule, and fixes the pool claim warning.What changes
1. A clear warning when a transfer isn't authorized. The Transfer stake dialog already simulates the transfer before signing. When the simulation reverts with
UNAUTHORIZED_BONDER, the dialog now says: "<receiver>hasn't authorized this wallet to transfer stake into it. Connect<receiver>, authorize this wallet, then try again." It is driven by the simulation, so it shows for fresh and unbonded receivers too, and shows nothing until enforcement is live. It shows as soon as the receiver is picked, before an amount is typed. The "orchestrator hasn't called reward yet" transfer warning is untouched.2. Authorizing from the warning. The warning has an "Authorize from
<receiver>" action. It opens a new step that the receiving wallet signs,setThirdPartyBonderAuthorization(<sender>, true), using the existing connect/switch-account gate. Once it confirms, "Continue transfer" goes back to the sending wallet with the receiver (its ENS name and label included) and amount still filled in, and Done closes it instead. If the chain already shows the authorization, nothing is signed and the dialog goes straight to "Continue transfer". The same step revokes withfalse.3. Listing and revoking authorized wallets. A wallet's actions menu (account page and portfolio table), the connected wallet's menu and the portfolio switcher get "Manage authorized wallets": the wallets that can transfer stake into it, each with Remove. The last two make it reachable for a wallet with nothing delegated. It reads
thirdPartyBonderAuthorizations(where: { delegator }), in full. The item only appears when the list isn't empty. A subgraph without the entity (before livepeer/subgraph#280 is released) reads as an empty list, so this can merge ahead of it.4. Pool claim warning (existing bug). Only affects delegators claiming stake from the 2022 move to Arbitrum through their old orchestrator's pool. The protocol holds that claim on the claiming wallet's own orchestrator, not the pool's, so the warning now checks that one and names it (
claimHeld()inlib/staking/claim-hold.ts). It's in this PR because pool claims usetransferBond, the call the upgrade changes.The ABI gains
setThirdPartyBonderAuthorization,isThirdPartyBonderAuthorizedand theThirdPartyBonderAuthorizationevent.Screenshots
Taken from the app running against the repo's mock subgraph, with a mocked wallet and chain that revert like the enforced BondingManager. The wallets and orchestrators shown are mock data.
Transfer stake: refused, authorized, then allowed (items 1 and 2)
Authorized wallets (item 3)
Pool claim warning (item 4)
The wallet's own orchestrator (0xb291…) hasn't called reward this round; the pool's (0xba15…) has. Before this change, no warning showed here.
Testing
UNAUTHORIZED_BONDERdetection and message,claimHeld(), and listing authorizations.isThirdPartyBonderAuthorizedwas called against the BondingManager proxy on Arbitrum to confirm the ABI.UNAUTHORIZED_BONDERwarning, connecting the receiver, signing the authorization, continuing the transfer with the receiver and amount kept, listing and removing authorizations, and the pool claim warning.UNAUTHORIZED_BONDERcan't be produced on mainnet before enforcement. Worth a check on a fork or right after the upgrade.Note on the subgraph
The #280 preview deployment doesn't have
Delegator.shares, whichnextqueries, so the subgraph released fornextneeds both.🤖 Generated with Claude Code