@aztec/wallets 0.0.1-commit.b33fc05d0 → 0.0.1-commit.b6e433891

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,14 +1,15 @@
1
1
  import { type Account } from '@aztec/aztec.js/account';
2
- import type { Aliased } from '@aztec/aztec.js/wallet';
2
+ import { type InteractionWaitOptions, type SendReturn } from '@aztec/aztec.js/contracts';
3
+ import type { Aliased, SendOptions } from '@aztec/aztec.js/wallet';
3
4
  import { AccountManager } from '@aztec/aztec.js/wallet';
4
5
  import { Fq, Fr } from '@aztec/foundation/curves/bn254';
5
6
  import type { Logger } from '@aztec/foundation/log';
6
- import type { AccessScopes, PXEConfig, PXECreationOptions } from '@aztec/pxe/client/lazy';
7
+ import type { PXEConfig, PXECreationOptions } from '@aztec/pxe/client/lazy';
7
8
  import type { PXE } from '@aztec/pxe/server';
8
9
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
9
10
  import type { AztecNode } from '@aztec/stdlib/interfaces/client';
10
11
  import { ExecutionPayload, type TxSimulationResult } from '@aztec/stdlib/tx';
11
- import { BaseWallet, type FeeOptions } from '@aztec/wallet-sdk/base-wallet';
12
+ import { BaseWallet, type SimulateViaEntrypointOptions } from '@aztec/wallet-sdk/base-wallet';
12
13
  import type { AccountContractsProvider } from './account-contract-providers/types.js';
13
14
  import { type AccountType, WalletDB } from './wallet_db.js';
14
15
  export type EmbeddedWalletOptions = {
@@ -24,17 +25,24 @@ export type EmbeddedWalletOptions = {
24
25
  export declare class EmbeddedWallet extends BaseWallet {
25
26
  protected walletDB: WalletDB;
26
27
  protected accountContracts: AccountContractsProvider;
28
+ protected estimatedGasPadding: number;
27
29
  constructor(pxe: PXE, aztecNode: AztecNode, walletDB: WalletDB, accountContracts: AccountContractsProvider, log?: Logger);
28
30
  protected getAccountFromAddress(address: AztecAddress): Promise<Account>;
29
31
  getAccounts(): Promise<Aliased<AztecAddress>[]>;
30
32
  registerSender(address: AztecAddress, alias: string): Promise<AztecAddress>;
31
33
  getAddressBook(): Promise<Aliased<AztecAddress>[]>;
34
+ /**
35
+ * Overrides the base sendTx to add a pre-simulation step before the actual send. The simulation
36
+ * estimates actual gas usage and captures call authorization requests to generate
37
+ * the necessary authwitnesses.
38
+ */
39
+ sendTx<W extends InteractionWaitOptions = undefined>(executionPayload: ExecutionPayload, opts: SendOptions<W>): Promise<SendReturn<W>>;
32
40
  /**
33
41
  * Simulates calls via a stub account entrypoint, bypassing real account authorization.
34
42
  * This allows kernelless simulation with contract overrides, skipping expensive
35
43
  * private kernel circuit execution.
36
44
  */
37
- protected simulateViaEntrypoint(executionPayload: ExecutionPayload, from: AztecAddress, feeOptions: FeeOptions, scopes: AccessScopes, _skipTxValidation?: boolean, _skipFeeEnforcement?: boolean): Promise<TxSimulationResult>;
45
+ protected simulateViaEntrypoint(executionPayload: ExecutionPayload, opts: SimulateViaEntrypointOptions): Promise<TxSimulationResult>;
38
46
  private getFakeAccountDataFor;
39
47
  protected createAccountInternal(type: AccountType, secret: Fr, salt: Fr, signingKey: Buffer): Promise<AccountManager>;
40
48
  createAndStoreAccount(alias: string, type: AccountType, secret: Fr, salt: Fr, signingKey: Buffer): Promise<AccountManager>;
@@ -42,6 +50,7 @@ export declare class EmbeddedWallet extends BaseWallet {
42
50
  createECDSARAccount(secret: Fr, salt: Fr, signingKey: Buffer, alias?: string): Promise<AccountManager>;
43
51
  createECDSAKAccount(secret: Fr, salt: Fr, signingKey: Buffer, alias?: string): Promise<AccountManager>;
44
52
  setMinFeePadding(value?: number): void;
53
+ setEstimatedGasPadding(value?: number): void;
45
54
  stop(): Promise<void>;
46
55
  }
47
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZW1iZWRkZWRfd2FsbGV0LmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvZW1iZWRkZWQvZW1iZWRkZWRfd2FsbGV0LnRzIl0sIm5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UAAU,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAErG;IAED,mBAAmB,CAAC,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAErG;IAED,gBAAgB,CAAC,KAAK,CAAC,EAAE,MAAM,QAE9B;IAED,sBAAsB,CAAC,KAAK,CAAC,EAAE,MAAM,QAEpC;IAED,IAAI,kBAEH;CACF"}
@@ -1,16 +1,21 @@
1
1
  import { SignerlessAccount } from '@aztec/aztec.js/account';
2
+ import { CallAuthorizationRequest } from '@aztec/aztec.js/authorization';
3
+ import { getGasLimits } from '@aztec/aztec.js/contracts';
2
4
  import { AccountManager } from '@aztec/aztec.js/wallet';
3
5
  import { Fq, Fr } from '@aztec/foundation/curves/bn254';
4
6
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
5
7
  import { getContractInstanceFromInstantiationParams } from '@aztec/stdlib/contract';
8
+ import { GasSettings } from '@aztec/stdlib/gas';
6
9
  import { deriveSigningKey } from '@aztec/stdlib/keys';
7
- import { mergeExecutionPayloads } from '@aztec/stdlib/tx';
10
+ import { collectOffchainEffects, mergeExecutionPayloads } from '@aztec/stdlib/tx';
8
11
  import { BaseWallet } from '@aztec/wallet-sdk/base-wallet';
12
+ const DEFAULT_ESTIMATED_GAS_PADDING = 0.1;
9
13
  export class EmbeddedWallet extends BaseWallet {
10
14
  walletDB;
11
15
  accountContracts;
16
+ estimatedGasPadding;
12
17
  constructor(pxe, aztecNode, walletDB, accountContracts, log){
13
- super(pxe, aztecNode, log), this.walletDB = walletDB, this.accountContracts = accountContracts;
18
+ super(pxe, aztecNode, log), this.walletDB = walletDB, this.accountContracts = accountContracts, this.estimatedGasPadding = DEFAULT_ESTIMATED_GAS_PADDING;
14
19
  }
15
20
  async getAccountFromAddress(address) {
16
21
  if (address.equals(AztecAddress.ZERO)) {
@@ -42,11 +47,75 @@ export class EmbeddedWallet extends BaseWallet {
42
47
  return storedSenders;
43
48
  }
44
49
  /**
50
+ * Overrides the base sendTx to add a pre-simulation step before the actual send. The simulation
51
+ * estimates actual gas usage and captures call authorization requests to generate
52
+ * the necessary authwitnesses.
53
+ */ async sendTx(executionPayload, opts) {
54
+ const feeOptions = await this.completeFeeOptionsForEstimation(opts.from, executionPayload.feePayer, opts.fee?.gasSettings);
55
+ // Simulate the transaction first to estimate gas and capture required
56
+ // private authwitnesses based on offchain effects.
57
+ const simulationResult = await this.simulateViaEntrypoint(executionPayload, {
58
+ from: opts.from,
59
+ feeOptions,
60
+ scopes: this.scopesFrom(opts.from, opts.additionalScopes),
61
+ skipTxValidation: true
62
+ });
63
+ const offchainEffects = collectOffchainEffects(simulationResult.privateExecutionResult);
64
+ const authWitnesses = await Promise.all(offchainEffects.map(async (effect)=>{
65
+ try {
66
+ const authRequest = await CallAuthorizationRequest.fromFields(effect.data);
67
+ return this.createAuthWit(opts.from, {
68
+ consumer: effect.contractAddress,
69
+ innerHash: authRequest.innerHash
70
+ });
71
+ } catch {
72
+ return undefined;
73
+ }
74
+ }));
75
+ for (const authwit of authWitnesses){
76
+ if (authwit) {
77
+ executionPayload.authWitnesses.push(authwit);
78
+ }
79
+ }
80
+ const estimated = getGasLimits(simulationResult, this.estimatedGasPadding);
81
+ this.log.verbose(`Estimated gas limits for tx: DA=${estimated.gasLimits.daGas} L2=${estimated.gasLimits.l2Gas} teardownDA=${estimated.teardownGasLimits.daGas} teardownL2=${estimated.teardownGasLimits.l2Gas}`);
82
+ const gasSettings = GasSettings.from({
83
+ ...opts.fee?.gasSettings,
84
+ maxFeesPerGas: feeOptions.gasSettings.maxFeesPerGas,
85
+ maxPriorityFeesPerGas: feeOptions.gasSettings.maxPriorityFeesPerGas,
86
+ gasLimits: opts.fee?.gasSettings?.gasLimits ?? estimated.gasLimits,
87
+ teardownGasLimits: opts.fee?.gasSettings?.teardownGasLimits ?? estimated.teardownGasLimits
88
+ });
89
+ return super.sendTx(executionPayload, {
90
+ ...opts,
91
+ fee: {
92
+ ...opts.fee,
93
+ gasSettings
94
+ }
95
+ });
96
+ }
97
+ /**
45
98
  * Simulates calls via a stub account entrypoint, bypassing real account authorization.
46
99
  * This allows kernelless simulation with contract overrides, skipping expensive
47
100
  * private kernel circuit execution.
48
- */ async simulateViaEntrypoint(executionPayload, from, feeOptions, scopes, _skipTxValidation, _skipFeeEnforcement) {
49
- const { account: fromAccount, instance, artifact } = await this.getFakeAccountDataFor(from);
101
+ */ async simulateViaEntrypoint(executionPayload, opts) {
102
+ const { from, feeOptions, scopes, skipTxValidation, skipFeeEnforcement } = opts;
103
+ let overrides;
104
+ let fromAccount;
105
+ if (!from.equals(AztecAddress.ZERO)) {
106
+ const { account, instance, artifact } = await this.getFakeAccountDataFor(from);
107
+ fromAccount = account;
108
+ overrides = {
109
+ contracts: {
110
+ [from.toString()]: {
111
+ instance,
112
+ artifact
113
+ }
114
+ }
115
+ };
116
+ } else {
117
+ fromAccount = await this.getAccountFromAddress(from);
118
+ }
50
119
  const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
51
120
  const executionOptions = {
52
121
  txNonce: Fr.random(),
@@ -61,53 +130,32 @@ export class EmbeddedWallet extends BaseWallet {
61
130
  const txRequest = await fromAccount.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, chainInfo, executionOptions);
62
131
  return this.pxe.simulateTx(txRequest, {
63
132
  simulatePublic: true,
64
- skipFeeEnforcement: true,
65
- skipTxValidation: true,
66
- overrides: {
67
- contracts: {
68
- [from.toString()]: {
69
- instance,
70
- artifact
71
- }
72
- }
73
- },
133
+ skipFeeEnforcement,
134
+ skipTxValidation,
135
+ overrides,
74
136
  scopes
75
137
  });
76
138
  }
77
139
  async getFakeAccountDataFor(address) {
78
- // While we have the convention of "Zero address means no auth", and also
79
- // we don't have a way to trigger kernelless simulations without overrides,
80
- // we need to explicitly handle the zero address case here by
81
- // returning the actual multicall contract instead of trying to create a stub account for it.
82
- if (!address.equals(AztecAddress.ZERO)) {
83
- const originalAccount = await this.getAccountFromAddress(address);
84
- if (originalAccount instanceof SignerlessAccount) {
85
- throw new Error(`Cannot create fake account data for SignerlessAccount at address: ${address}`);
86
- }
87
- const originalAddress = originalAccount.getCompleteAddress();
88
- const contractInstance = await this.pxe.getContractInstance(originalAddress.address);
89
- if (!contractInstance) {
90
- throw new Error(`No contract instance found for address: ${originalAddress.address}`);
91
- }
92
- const stubAccount = await this.accountContracts.createStubAccount(originalAddress);
93
- const stubArtifact = await this.accountContracts.getStubAccountContractArtifact();
94
- const instance = await getContractInstanceFromInstantiationParams(stubArtifact, {
95
- salt: Fr.random()
96
- });
97
- return {
98
- account: stubAccount,
99
- instance,
100
- artifact: stubArtifact
101
- };
102
- } else {
103
- const { instance, artifact } = await this.accountContracts.getMulticallContract();
104
- const account = new SignerlessAccount();
105
- return {
106
- instance,
107
- account,
108
- artifact
109
- };
140
+ const originalAccount = await this.getAccountFromAddress(address);
141
+ if (originalAccount instanceof SignerlessAccount) {
142
+ throw new Error(`Cannot create fake account data for SignerlessAccount at address: ${address}`);
110
143
  }
144
+ const originalAddress = originalAccount.getCompleteAddress();
145
+ const contractInstance = await this.pxe.getContractInstance(originalAddress.address);
146
+ if (!contractInstance) {
147
+ throw new Error(`No contract instance found for address: ${originalAddress.address}`);
148
+ }
149
+ const stubAccount = await this.accountContracts.createStubAccount(originalAddress);
150
+ const stubArtifact = await this.accountContracts.getStubAccountContractArtifact();
151
+ const instance = await getContractInstanceFromInstantiationParams(stubArtifact, {
152
+ salt: Fr.random()
153
+ });
154
+ return {
155
+ account: stubAccount,
156
+ instance,
157
+ artifact: stubArtifact
158
+ };
111
159
  }
112
160
  async createAccountInternal(type, secret, salt, signingKey) {
113
161
  let contract;
@@ -165,6 +213,9 @@ export class EmbeddedWallet extends BaseWallet {
165
213
  setMinFeePadding(value) {
166
214
  this.minFeePadding = value ?? 0.5;
167
215
  }
216
+ setEstimatedGasPadding(value) {
217
+ this.estimatedGasPadding = value ?? DEFAULT_ESTIMATED_GAS_PADDING;
218
+ }
168
219
  stop() {
169
220
  return this.pxe.stop();
170
221
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@aztec/wallets",
3
3
  "homepage": "https://github.com/AztecProtocol/aztec-packages/tree/master/yarn-project/wallets",
4
- "version": "0.0.1-commit.b33fc05d0",
4
+ "version": "0.0.1-commit.b6e433891",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  "./embedded": {
@@ -27,15 +27,15 @@
27
27
  "../package.common.json"
28
28
  ],
29
29
  "dependencies": {
30
- "@aztec/accounts": "0.0.1-commit.b33fc05d0",
31
- "@aztec/aztec.js": "0.0.1-commit.b33fc05d0",
32
- "@aztec/entrypoints": "0.0.1-commit.b33fc05d0",
33
- "@aztec/foundation": "0.0.1-commit.b33fc05d0",
34
- "@aztec/kv-store": "0.0.1-commit.b33fc05d0",
35
- "@aztec/protocol-contracts": "0.0.1-commit.b33fc05d0",
36
- "@aztec/pxe": "0.0.1-commit.b33fc05d0",
37
- "@aztec/stdlib": "0.0.1-commit.b33fc05d0",
38
- "@aztec/wallet-sdk": "0.0.1-commit.b33fc05d0"
30
+ "@aztec/accounts": "0.0.1-commit.b6e433891",
31
+ "@aztec/aztec.js": "0.0.1-commit.b6e433891",
32
+ "@aztec/entrypoints": "0.0.1-commit.b6e433891",
33
+ "@aztec/foundation": "0.0.1-commit.b6e433891",
34
+ "@aztec/kv-store": "0.0.1-commit.b6e433891",
35
+ "@aztec/protocol-contracts": "0.0.1-commit.b6e433891",
36
+ "@aztec/pxe": "0.0.1-commit.b6e433891",
37
+ "@aztec/stdlib": "0.0.1-commit.b6e433891",
38
+ "@aztec/wallet-sdk": "0.0.1-commit.b6e433891"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@jest/globals": "^30.0.0",
@@ -1,17 +1,26 @@
1
1
  import { type Account, SignerlessAccount } from '@aztec/aztec.js/account';
2
- import type { Aliased } from '@aztec/aztec.js/wallet';
2
+ import { CallAuthorizationRequest } from '@aztec/aztec.js/authorization';
3
+ import { type InteractionWaitOptions, type SendReturn, getGasLimits } from '@aztec/aztec.js/contracts';
4
+ import type { Aliased, SendOptions } from '@aztec/aztec.js/wallet';
3
5
  import { AccountManager } from '@aztec/aztec.js/wallet';
4
6
  import type { DefaultAccountEntrypointOptions } from '@aztec/entrypoints/account';
5
7
  import { Fq, Fr } from '@aztec/foundation/curves/bn254';
6
8
  import type { Logger } from '@aztec/foundation/log';
7
- import type { AccessScopes, PXEConfig, PXECreationOptions } from '@aztec/pxe/client/lazy';
9
+ import type { PXEConfig, PXECreationOptions } from '@aztec/pxe/client/lazy';
8
10
  import type { PXE } from '@aztec/pxe/server';
9
11
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
10
12
  import { getContractInstanceFromInstantiationParams } from '@aztec/stdlib/contract';
13
+ import { GasSettings } from '@aztec/stdlib/gas';
11
14
  import type { AztecNode } from '@aztec/stdlib/interfaces/client';
12
15
  import { deriveSigningKey } from '@aztec/stdlib/keys';
13
- import { ExecutionPayload, type TxSimulationResult, mergeExecutionPayloads } from '@aztec/stdlib/tx';
14
- import { BaseWallet, type FeeOptions } from '@aztec/wallet-sdk/base-wallet';
16
+ import {
17
+ ExecutionPayload,
18
+ SimulationOverrides,
19
+ type TxSimulationResult,
20
+ collectOffchainEffects,
21
+ mergeExecutionPayloads,
22
+ } from '@aztec/stdlib/tx';
23
+ import { BaseWallet, type SimulateViaEntrypointOptions } from '@aztec/wallet-sdk/base-wallet';
15
24
 
16
25
  import type { AccountContractsProvider } from './account-contract-providers/types.js';
17
26
  import { type AccountType, WalletDB } from './wallet_db.js';
@@ -27,7 +36,11 @@ export type EmbeddedWalletOptions = {
27
36
  pxeOptions?: PXECreationOptions;
28
37
  };
29
38
 
39
+ const DEFAULT_ESTIMATED_GAS_PADDING = 0.1;
40
+
30
41
  export class EmbeddedWallet extends BaseWallet {
42
+ protected estimatedGasPadding = DEFAULT_ESTIMATED_GAS_PADDING;
43
+
31
44
  constructor(
32
45
  pxe: PXE,
33
46
  aztecNode: AztecNode,
@@ -74,6 +87,66 @@ export class EmbeddedWallet extends BaseWallet {
74
87
  return storedSenders;
75
88
  }
76
89
 
90
+ /**
91
+ * Overrides the base sendTx to add a pre-simulation step before the actual send. The simulation
92
+ * estimates actual gas usage and captures call authorization requests to generate
93
+ * the necessary authwitnesses.
94
+ */
95
+ public override async sendTx<W extends InteractionWaitOptions = undefined>(
96
+ executionPayload: ExecutionPayload,
97
+ opts: SendOptions<W>,
98
+ ): Promise<SendReturn<W>> {
99
+ const feeOptions = await this.completeFeeOptionsForEstimation(
100
+ opts.from,
101
+ executionPayload.feePayer,
102
+ opts.fee?.gasSettings,
103
+ );
104
+
105
+ // Simulate the transaction first to estimate gas and capture required
106
+ // private authwitnesses based on offchain effects.
107
+ const simulationResult = await this.simulateViaEntrypoint(executionPayload, {
108
+ from: opts.from,
109
+ feeOptions,
110
+ scopes: this.scopesFrom(opts.from, opts.additionalScopes),
111
+ skipTxValidation: true,
112
+ });
113
+
114
+ const offchainEffects = collectOffchainEffects(simulationResult.privateExecutionResult);
115
+ const authWitnesses = await Promise.all(
116
+ offchainEffects.map(async effect => {
117
+ try {
118
+ const authRequest = await CallAuthorizationRequest.fromFields(effect.data);
119
+ return this.createAuthWit(opts.from, {
120
+ consumer: effect.contractAddress,
121
+ innerHash: authRequest.innerHash,
122
+ });
123
+ } catch {
124
+ return undefined;
125
+ }
126
+ }),
127
+ );
128
+ for (const authwit of authWitnesses) {
129
+ if (authwit) {
130
+ executionPayload.authWitnesses.push(authwit);
131
+ }
132
+ }
133
+ const estimated = getGasLimits(simulationResult, this.estimatedGasPadding);
134
+ this.log.verbose(
135
+ `Estimated gas limits for tx: DA=${estimated.gasLimits.daGas} L2=${estimated.gasLimits.l2Gas} teardownDA=${estimated.teardownGasLimits.daGas} teardownL2=${estimated.teardownGasLimits.l2Gas}`,
136
+ );
137
+ const gasSettings = GasSettings.from({
138
+ ...opts.fee?.gasSettings,
139
+ maxFeesPerGas: feeOptions.gasSettings.maxFeesPerGas,
140
+ maxPriorityFeesPerGas: feeOptions.gasSettings.maxPriorityFeesPerGas,
141
+ gasLimits: opts.fee?.gasSettings?.gasLimits ?? estimated.gasLimits,
142
+ teardownGasLimits: opts.fee?.gasSettings?.teardownGasLimits ?? estimated.teardownGasLimits,
143
+ });
144
+ return super.sendTx(executionPayload, {
145
+ ...opts,
146
+ fee: { ...opts.fee, gasSettings },
147
+ });
148
+ }
149
+
77
150
  /**
78
151
  * Simulates calls via a stub account entrypoint, bypassing real account authorization.
79
152
  * This allows kernelless simulation with contract overrides, skipping expensive
@@ -81,13 +154,21 @@ export class EmbeddedWallet extends BaseWallet {
81
154
  */
82
155
  protected override async simulateViaEntrypoint(
83
156
  executionPayload: ExecutionPayload,
84
- from: AztecAddress,
85
- feeOptions: FeeOptions,
86
- scopes: AccessScopes,
87
- _skipTxValidation?: boolean,
88
- _skipFeeEnforcement?: boolean,
157
+ opts: SimulateViaEntrypointOptions,
89
158
  ): Promise<TxSimulationResult> {
90
- const { account: fromAccount, instance, artifact } = await this.getFakeAccountDataFor(from);
159
+ const { from, feeOptions, scopes, skipTxValidation, skipFeeEnforcement } = opts;
160
+
161
+ let overrides: SimulationOverrides | undefined;
162
+ let fromAccount: Account;
163
+ if (!from.equals(AztecAddress.ZERO)) {
164
+ const { account, instance, artifact } = await this.getFakeAccountDataFor(from);
165
+ fromAccount = account;
166
+ overrides = {
167
+ contracts: { [from.toString()]: { instance, artifact } },
168
+ };
169
+ } else {
170
+ fromAccount = await this.getAccountFromAddress(from);
171
+ }
91
172
 
92
173
  const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
93
174
  const executionOptions: DefaultAccountEntrypointOptions = {
@@ -107,49 +188,33 @@ export class EmbeddedWallet extends BaseWallet {
107
188
  );
108
189
  return this.pxe.simulateTx(txRequest, {
109
190
  simulatePublic: true,
110
- skipFeeEnforcement: true,
111
- skipTxValidation: true,
112
- overrides: {
113
- contracts: { [from.toString()]: { instance, artifact } },
114
- },
191
+ skipFeeEnforcement,
192
+ skipTxValidation,
193
+ overrides,
115
194
  scopes,
116
195
  });
117
196
  }
118
197
 
119
198
  private async getFakeAccountDataFor(address: AztecAddress) {
120
- // While we have the convention of "Zero address means no auth", and also
121
- // we don't have a way to trigger kernelless simulations without overrides,
122
- // we need to explicitly handle the zero address case here by
123
- // returning the actual multicall contract instead of trying to create a stub account for it.
124
- if (!address.equals(AztecAddress.ZERO)) {
125
- const originalAccount = await this.getAccountFromAddress(address);
126
- if (originalAccount instanceof SignerlessAccount) {
127
- throw new Error(`Cannot create fake account data for SignerlessAccount at address: ${address}`);
128
- }
129
- const originalAddress = (originalAccount as Account).getCompleteAddress();
130
- const contractInstance = await this.pxe.getContractInstance(originalAddress.address);
131
- if (!contractInstance) {
132
- throw new Error(`No contract instance found for address: ${originalAddress.address}`);
133
- }
134
- const stubAccount = await this.accountContracts.createStubAccount(originalAddress);
135
- const stubArtifact = await this.accountContracts.getStubAccountContractArtifact();
136
- const instance = await getContractInstanceFromInstantiationParams(stubArtifact, {
137
- salt: Fr.random(),
138
- });
139
- return {
140
- account: stubAccount,
141
- instance,
142
- artifact: stubArtifact,
143
- };
144
- } else {
145
- const { instance, artifact } = await this.accountContracts.getMulticallContract();
146
- const account = new SignerlessAccount();
147
- return {
148
- instance,
149
- account,
150
- artifact,
151
- };
199
+ const originalAccount = await this.getAccountFromAddress(address);
200
+ if (originalAccount instanceof SignerlessAccount) {
201
+ throw new Error(`Cannot create fake account data for SignerlessAccount at address: ${address}`);
202
+ }
203
+ const originalAddress = (originalAccount as Account).getCompleteAddress();
204
+ const contractInstance = await this.pxe.getContractInstance(originalAddress.address);
205
+ if (!contractInstance) {
206
+ throw new Error(`No contract instance found for address: ${originalAddress.address}`);
152
207
  }
208
+ const stubAccount = await this.accountContracts.createStubAccount(originalAddress);
209
+ const stubArtifact = await this.accountContracts.getStubAccountContractArtifact();
210
+ const instance = await getContractInstanceFromInstantiationParams(stubArtifact, {
211
+ salt: Fr.random(),
212
+ });
213
+ return {
214
+ account: stubAccount,
215
+ instance,
216
+ artifact: stubArtifact,
217
+ };
153
218
  }
154
219
 
155
220
  protected async createAccountInternal(
@@ -221,6 +286,10 @@ export class EmbeddedWallet extends BaseWallet {
221
286
  this.minFeePadding = value ?? 0.5;
222
287
  }
223
288
 
289
+ setEstimatedGasPadding(value?: number) {
290
+ this.estimatedGasPadding = value ?? DEFAULT_ESTIMATED_GAS_PADDING;
291
+ }
292
+
224
293
  stop() {
225
294
  return this.pxe.stop();
226
295
  }