Skip to content

feat: jit spend permissions #1611

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Apr 25, 2025
Merged

feat: jit spend permissions #1611

merged 13 commits into from
Apr 25, 2025

Conversation

stephancill
Copy link
Contributor

@stephancill stephancill commented Apr 23, 2025

Summary

Implements behavior to request spend permissions from the global wallet at transaction time

  • Adds dynamicSpendLimits config in SDK constructor
  • Handles insufficient balance errors thrown by sub account client in SCWSigner with handleInsufficientBalanceError
  • Adds optional parentAddress arg to createSubAccountSigner
  • Helpers for creating spend permission request messages

How did you test your changes?

  • Added tests
  • Manual testing on /auto-sub-accounts

@cb-heimdall
Copy link
Collaborator

cb-heimdall commented Apr 23, 2025

✅ Heimdall Review Status

Requirement Status More Info
Reviews 1/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 0
Sum 1

@stephancill stephancill force-pushed the feat/jit-spend-permissions branch from c2348c8 to df64701 Compare April 24, 2025 15:47
@stephancill stephancill marked this pull request as ready for review April 24, 2025 18:00
@stephancill stephancill force-pushed the feat/jit-spend-permissions branch from faeda99 to a193064 Compare April 24, 2025 19:59
@stephancill stephancill force-pushed the feat/jit-spend-permissions branch 2 times, most recently from d48cc89 to 2375f21 Compare April 24, 2025 20:10
@stephancill stephancill force-pushed the feat/jit-spend-permissions branch from 2375f21 to 8bf75cf Compare April 24, 2025 20:16
Comment on lines 355 to 367
export function createWalletSendCallsRequest({
to,
data,
value,
from,
chainId,
}: {
to: Address;
data: Hex;
value: Hex;
from: Address;
chainId: Hex;
}) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been changed to accept an array of calls instead of a single call in #1612

* feat: paymaster urls in config

* fix: capabilties arg in createWalletSendCallsRequest

* fix: createWalletSendCallsRequest chainId type
const { request: subAccountRequest } = await createSubAccountSigner({
address: subAccount.address,
owner: ownerAccount.account,
client: client,
factory: subAccount.factory,
factoryData: subAccount.factoryData,
parentAddress: globalAccountAddress,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: we should standardize naming for the global account. No strong preference global, parent, universal are all good with me

capabilities: Record<string, unknown>
) {
// Modify request to include auto sub account capabilities
const modifiedRequest = { ...request };

if (capabilities && ['wallet_sendCalls', 'wallet_connect'].includes(request.method)) {
if (capabilities && request.method.startsWith('wallet_')) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would still prefer tighter restriction here, non blocker for this PR thoooo

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually leaning towards removing this conditional from here entirely because it it's kinda outside of the scope of the function

},
{
isRed: false,
info: 'Continue in Popup',
Copy link
Contributor

@fan-zhang-sv fan-zhang-sv Apr 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

non blocker: have we finalized on the "continue in popup" messaging

cb-jake
cb-jake previously approved these changes Apr 25, 2025
fan-zhang-sv
fan-zhang-sv previously approved these changes Apr 25, 2025
* fix: account ordering for wallet_addSubAccount

* feat: signer selector on /auto-sub-account page

* fix: convert errors thrown by viem

* fix: handle errors from other versions of viem
@cb-jake cb-jake dismissed stale reviews from fan-zhang-sv and themself via 68db706 April 25, 2025 19:30
* feat: sub accounts data suffix support

* fix: capabilities type

* fix: tests
@stephancill stephancill enabled auto-merge (squash) April 25, 2025 21:06
@stephancill stephancill merged commit cbd7148 into master Apr 25, 2025
8 checks passed
@stephancill stephancill deleted the feat/jit-spend-permissions branch April 25, 2025 21:17
@cb-heimdall
Copy link
Collaborator

Review Error for cb-jake @ 2025-04-25 21:18:20 UTC
User failed mfa authentication, public email is not set on your github profile. see go/mfa-help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants