-
Notifications
You must be signed in to change notification settings - Fork 595
feat: add optional additional scopes to wallet transaction API #20487
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
Changes from all commits
79d75ae
f9bdde3
36301c1
2a114c8
0547234
316e967
10683f0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -79,6 +79,8 @@ export async function createAccount( | |
| skipInstancePublication: !publicDeploy, | ||
| skipInitialization, | ||
| from, | ||
| // The account constructor initializes storage vars that need the contract's own nullifier key, so we need to add it to scopes. | ||
| additionalScopes: [address], | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would put here a comment regarding why we need to add the additional scope |
||
| fee: { paymentMethod, gasSettings }, | ||
| }; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,7 +30,11 @@ describe('docs_examples', () => { | |
| const prefundedAccount = await wallet.createSchnorrAccount(accountData.secret, accountData.salt); | ||
| const newAccountManager = await wallet.createSchnorrAccount(secretKey, Fr.random(), signingPrivateKey); | ||
| const newAccountDeployMethod = await newAccountManager.getDeployMethod(); | ||
| await newAccountDeployMethod.send({ from: prefundedAccount.address }); | ||
| await newAccountDeployMethod.send({ | ||
| from: prefundedAccount.address, | ||
| // The account constructor initializes storage vars that need the contract's own nullifier key, so we need to add it to scopes. | ||
| additionalScopes: [newAccountManager.address], | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would put here a comment regarding why we need to add the additional scope |
||
| }); | ||
| const newAccountAddress = newAccountManager.address; | ||
| const defaultAccountAddress = prefundedAccount.address; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -145,7 +145,8 @@ describe('e2e_local_network_example', () => { | |
| return await Promise.all( | ||
| accountManagers.map(async x => { | ||
| const deployMethod = await x.getDeployMethod(); | ||
| await deployMethod.send({ from: fundedAccount }); | ||
| // The account constructor initializes storage vars that need the contract's own nullifier key, so we need to add it to scopes. | ||
| await deployMethod.send({ from: fundedAccount, additionalScopes: [x.address] }); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would put here a comment regarding why we need to add the additional scope |
||
| return x; | ||
| }), | ||
| ); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -89,7 +89,12 @@ describe('e2e_fees account_init', () => { | |
| const [bobsInitialGas] = await t.getGasBalanceFn(bobsAddress); | ||
| expect(bobsInitialGas).toEqual(mintAmount); | ||
|
|
||
| const tx = await bobsDeployMethod.send({ from: AztecAddress.ZERO, wait: { returnReceipt: true } }); | ||
| const tx = await bobsDeployMethod.send({ | ||
| from: AztecAddress.ZERO, | ||
| // The account constructor initializes storage vars that need the contract's own nullifier key, so we need to add it to scopes. | ||
| additionalScopes: [bobsAddress], | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the only thing that worries me. It makes 100% total sense that account contract self-deployments need this, but for such a common operation it's getting very verbose. Maybe we should consider this a higher level abstraction and provide some sane defaults |
||
| wait: { returnReceipt: true }, | ||
| }); | ||
|
|
||
| expect(tx.transactionFee!).toBeGreaterThan(0n); | ||
| await expect(t.getGasBalanceFn(bobsAddress)).resolves.toEqual([bobsInitialGas - tx.transactionFee!]); | ||
|
|
@@ -100,6 +105,8 @@ describe('e2e_fees account_init', () => { | |
| const paymentMethod = new FeeJuicePaymentMethodWithClaim(bobsAddress, claim); | ||
| const tx = await bobsDeployMethod.send({ | ||
| from: AztecAddress.ZERO, | ||
| // The account constructor initializes storage vars that need the contract's own nullifier key, so we need to add it to scopes. | ||
| additionalScopes: [bobsAddress], | ||
| fee: { paymentMethod }, | ||
| wait: { returnReceipt: true }, | ||
| }); | ||
|
|
@@ -120,6 +127,8 @@ describe('e2e_fees account_init', () => { | |
| const paymentMethod = new PrivateFeePaymentMethod(bananaFPC.address, bobsAddress, wallet, gasSettings); | ||
| const tx = await bobsDeployMethod.send({ | ||
| from: AztecAddress.ZERO, | ||
| // The account constructor initializes storage vars that need the contract's own nullifier key, so we need to add it to scopes. | ||
| additionalScopes: [bobsAddress], | ||
| fee: { paymentMethod }, | ||
| wait: { returnReceipt: true }, | ||
| }); | ||
|
|
@@ -149,6 +158,8 @@ describe('e2e_fees account_init', () => { | |
| const paymentMethod = new PublicFeePaymentMethod(bananaFPC.address, bobsAddress, wallet, gasSettings); | ||
| const tx = await bobsDeployMethod.send({ | ||
| from: AztecAddress.ZERO, | ||
| // The account constructor initializes storage vars that need the contract's own nullifier key, so we need to add it to scopes. | ||
| additionalScopes: [bobsAddress], | ||
| skipInstancePublication: false, | ||
| fee: { paymentMethod }, | ||
| wait: { returnReceipt: true }, | ||
|
|
@@ -187,6 +198,8 @@ describe('e2e_fees account_init', () => { | |
| bobsSigningPubKey.y, | ||
| ).send({ | ||
| from: aliceAddress, | ||
| // The account constructor initializes storage vars that need the contract's own nullifier key, so we need to add it to scopes. | ||
| additionalScopes: [bobsAddress], | ||
| contractAddressSalt: bobsInstance.salt, | ||
| skipClassPublication: true, | ||
| skipInstancePublication: true, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We had to make these changes when we introduced scopes, because there was no way to inject multiple scopes. Since now there is, we can revert the change we made