-
Notifications
You must be signed in to change notification settings - Fork 615
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 1 commit
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -82,6 +82,11 @@ export type SendInteractionOptionsWithoutWait = RequestInteractionOptions & { | |||||
| from: AztecAddress; | ||||||
| /** The fee options for the transaction. */ | ||||||
| fee?: InteractionFeeOptions; | ||||||
| /** | ||||||
| * Additional addresses whose private state should be accessible during execution, | ||||||
|
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.
Suggested change
|
||||||
| * beyond the sender's | ||||||
|
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. Think it would be useful to have here an example of why you would want this. |
||||||
| */ | ||||||
| additionalScopes?: AztecAddress[]; | ||||||
| }; | ||||||
|
|
||||||
| /** | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -71,12 +71,13 @@ export class Bot extends BaseBot { | |
|
|
||
| const batch = new BatchCall(wallet, calls); | ||
| const opts = await this.getSendMethodOpts(batch); | ||
| const additionalScopes = isStandardTokenContract(token) ? undefined : [token.address]; | ||
|
Collaborator
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. Why does the non standard token need additional scopes? |
||
|
|
||
| this.log.verbose(`Simulating transaction with ${calls.length}`, logCtx); | ||
| await batch.simulate({ from: this.defaultAccountAddress }); | ||
| await batch.simulate({ from: this.defaultAccountAddress, additionalScopes }); | ||
|
|
||
| this.log.verbose(`Sending transaction`, logCtx); | ||
| return batch.send({ ...opts, wait: NO_WAIT }); | ||
| return batch.send({ ...opts, additionalScopes, wait: NO_WAIT }); | ||
| } | ||
|
|
||
| public async getBalances() { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -89,7 +89,11 @@ 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, | ||
| additionalScopes: [bobsAddress], | ||
|
Collaborator
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 +104,7 @@ describe('e2e_fees account_init', () => { | |
| const paymentMethod = new FeeJuicePaymentMethodWithClaim(bobsAddress, claim); | ||
| const tx = await bobsDeployMethod.send({ | ||
| from: AztecAddress.ZERO, | ||
| additionalScopes: [bobsAddress], | ||
| fee: { paymentMethod }, | ||
| wait: { returnReceipt: true }, | ||
| }); | ||
|
|
@@ -120,6 +125,7 @@ describe('e2e_fees account_init', () => { | |
| const paymentMethod = new PrivateFeePaymentMethod(bananaFPC.address, bobsAddress, wallet, gasSettings); | ||
| const tx = await bobsDeployMethod.send({ | ||
| from: AztecAddress.ZERO, | ||
| additionalScopes: [bobsAddress], | ||
| fee: { paymentMethod }, | ||
| wait: { returnReceipt: true }, | ||
| }); | ||
|
|
@@ -149,6 +155,7 @@ describe('e2e_fees account_init', () => { | |
| const paymentMethod = new PublicFeePaymentMethod(bananaFPC.address, bobsAddress, wallet, gasSettings); | ||
| const tx = await bobsDeployMethod.send({ | ||
| from: AztecAddress.ZERO, | ||
| additionalScopes: [bobsAddress], | ||
| skipInstancePublication: false, | ||
| fee: { paymentMethod }, | ||
| wait: { returnReceipt: true }, | ||
|
|
@@ -187,6 +194,7 @@ describe('e2e_fees account_init', () => { | |
| bobsSigningPubKey.y, | ||
| ).send({ | ||
| from: aliceAddress, | ||
| 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