@aztec/wallets 4.2.0-nightly.20260408 → 4.2.0-nightly.20260409
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.
|
@@ -8,7 +8,7 @@ import type { PXEConfig, PXECreationOptions } from '@aztec/pxe/client/lazy';
|
|
|
8
8
|
import type { PXE } from '@aztec/pxe/server';
|
|
9
9
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
10
10
|
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
11
|
-
import { ExecutionPayload, type TxSimulationResult } from '@aztec/stdlib/tx';
|
|
11
|
+
import { type ContractOverrides, ExecutionPayload, type TxSimulationResult } from '@aztec/stdlib/tx';
|
|
12
12
|
import { BaseWallet, type SimulateViaEntrypointOptions } from '@aztec/wallet-sdk/base-wallet';
|
|
13
13
|
import type { AccountContractsProvider } from './account-contract-providers/types.js';
|
|
14
14
|
import { type AccountType, WalletDB } from './wallet_db.js';
|
|
@@ -37,13 +37,16 @@ export declare class EmbeddedWallet extends BaseWallet {
|
|
|
37
37
|
* the necessary authwitnesses.
|
|
38
38
|
*/
|
|
39
39
|
sendTx<W extends InteractionWaitOptions = undefined>(executionPayload: ExecutionPayload, opts: SendOptions<W>): Promise<SendReturn<W>>;
|
|
40
|
+
/**
|
|
41
|
+
* Builds contract overrides for all provided addresses by replacing their account contracts with stub implementations.
|
|
42
|
+
*/
|
|
43
|
+
protected buildAccountOverrides(addresses: AztecAddress[]): Promise<ContractOverrides>;
|
|
40
44
|
/**
|
|
41
45
|
* Simulates calls via a stub account entrypoint, bypassing real account authorization.
|
|
42
46
|
* This allows kernelless simulation with contract overrides, skipping expensive
|
|
43
47
|
* private kernel circuit execution.
|
|
44
48
|
*/
|
|
45
49
|
protected simulateViaEntrypoint(executionPayload: ExecutionPayload, opts: SimulateViaEntrypointOptions): Promise<TxSimulationResult>;
|
|
46
|
-
private getFakeAccountDataFor;
|
|
47
50
|
protected createAccountInternal(type: AccountType, secret: Fr, salt: Fr, signingKey: Buffer): Promise<AccountManager>;
|
|
48
51
|
createAndStoreAccount(alias: string, type: AccountType, secret: Fr, salt: Fr, signingKey: Buffer): Promise<AccountManager>;
|
|
49
52
|
createSchnorrAccount(secret: Fr, salt: Fr, signingKey?: Fq, alias?: string): Promise<AccountManager>;
|
|
@@ -53,4 +56,4 @@ export declare class EmbeddedWallet extends BaseWallet {
|
|
|
53
56
|
setEstimatedGasPadding(value?: number): void;
|
|
54
57
|
stop(): Promise<void>;
|
|
55
58
|
}
|
|
56
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
59
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZW1iZWRkZWRfd2FsbGV0LmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvZW1iZWRkZWQvZW1iZWRkZWRfd2FsbGV0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxLQUFLLE9BQU8sRUFBVyxNQUFNLHlCQUF5QixDQUFDO0FBRWhFLE9BQU8sRUFBRSxLQUFLLHNCQUFzQixFQUFFLEtBQUssVUFBVSxFQUErQixNQUFNLDJCQUEyQixDQUFDO0FBQ3RILE9BQU8sS0FBSyxFQUFFLE9BQU8sRUFBRSxXQUFXLEVBQUUsTUFBTSx3QkFBd0IsQ0FBQztBQUNuRSxPQUFPLEVBQUUsY0FBYyxFQUFFLE1BQU0sd0JBQXdCLENBQUM7QUFHeEQsT0FBTyxFQUFFLEVBQUUsRUFBRSxFQUFFLEVBQUUsTUFBTSxnQ0FBZ0MsQ0FBQztBQUN4RCxPQUFPLEtBQUssRUFBRSxNQUFNLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQUNwRCxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsa0JBQWtCLEVBQUUsTUFBTSx3QkFBd0IsQ0FBQztBQUM1RSxPQUFPLEtBQUss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MAAM,GACjB,OAAO,CAAC,cAAc,CAAC,CAiCzB;IAEK,qBAAqB,CACzB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,WAAW,EACjB,MAAM,EAAE,EAAE,EACV,IAAI,EAAE,EAAE,EACR,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,cAAc,CAAC,CAIzB;IAED,oBAAoB,CAAC,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,UAAU,CAAC,EAAE,EAAE,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAGnG;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,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"}
|
|
@@ -7,7 +7,7 @@ import { Fq, Fr } from '@aztec/foundation/curves/bn254';
|
|
|
7
7
|
import { getContractInstanceFromInstantiationParams } from '@aztec/stdlib/contract';
|
|
8
8
|
import { GasSettings } from '@aztec/stdlib/gas';
|
|
9
9
|
import { deriveSigningKey } from '@aztec/stdlib/keys';
|
|
10
|
-
import { collectOffchainEffects, mergeExecutionPayloads } from '@aztec/stdlib/tx';
|
|
10
|
+
import { SimulationOverrides, TxStatus, collectOffchainEffects, mergeExecutionPayloads } from '@aztec/stdlib/tx';
|
|
11
11
|
import { BaseWallet } from '@aztec/wallet-sdk/base-wallet';
|
|
12
12
|
const DEFAULT_ESTIMATED_GAS_PADDING = 0.1;
|
|
13
13
|
export class EmbeddedWallet extends BaseWallet {
|
|
@@ -48,7 +48,12 @@ export class EmbeddedWallet extends BaseWallet {
|
|
|
48
48
|
* estimates actual gas usage and captures call authorization requests to generate
|
|
49
49
|
* the necessary authwitnesses.
|
|
50
50
|
*/ async sendTx(executionPayload, opts) {
|
|
51
|
-
const feeOptions = await this.
|
|
51
|
+
const feeOptions = await this.completeFeeOptions({
|
|
52
|
+
from: opts.from,
|
|
53
|
+
feePayer: executionPayload.feePayer,
|
|
54
|
+
gasSettings: opts.fee?.gasSettings,
|
|
55
|
+
forEstimation: true
|
|
56
|
+
});
|
|
52
57
|
// Simulate the transaction first to estimate gas and capture required
|
|
53
58
|
// private authwitnesses based on offchain effects.
|
|
54
59
|
const simulationResult = await this.simulateViaEntrypoint(executionPayload, {
|
|
@@ -83,6 +88,17 @@ export class EmbeddedWallet extends BaseWallet {
|
|
|
83
88
|
gasLimits: opts.fee?.gasSettings?.gasLimits ?? estimated.gasLimits,
|
|
84
89
|
teardownGasLimits: opts.fee?.gasSettings?.teardownGasLimits ?? estimated.teardownGasLimits
|
|
85
90
|
});
|
|
91
|
+
const waitOpts = typeof opts.wait === 'object' ? opts.wait : {};
|
|
92
|
+
if (!waitOpts?.waitForStatus) {
|
|
93
|
+
// Default to PROPOSED so the wait returns as soon as the tx lands in a proposed L2 block,
|
|
94
|
+
// rather than waiting until the end of the slot for the checkpoint to be published to L1.
|
|
95
|
+
// This is what makes MBPS (Multiple Blocks Per Slot) actually improve UX: with CHECKPOINTED
|
|
96
|
+
// we'd block until L1 inclusion regardless of how early in the slot the tx was sequenced.
|
|
97
|
+
// The tradeoff is a weaker guarantee — a proposed block only becomes canonical once it (or
|
|
98
|
+
// a later block in the same slot) is checkpointed, so a tx could be re-orged out if the
|
|
99
|
+
// proposer fails to publish to L1 (which should be rare, since they'd get slashed for it).
|
|
100
|
+
waitOpts.waitForStatus = TxStatus.PROPOSED;
|
|
101
|
+
}
|
|
86
102
|
return super.sendTx(executionPayload, {
|
|
87
103
|
...opts,
|
|
88
104
|
fee: {
|
|
@@ -92,6 +108,31 @@ export class EmbeddedWallet extends BaseWallet {
|
|
|
92
108
|
});
|
|
93
109
|
}
|
|
94
110
|
/**
|
|
111
|
+
* Builds contract overrides for all provided addresses by replacing their account contracts with stub implementations.
|
|
112
|
+
*/ async buildAccountOverrides(addresses) {
|
|
113
|
+
const accounts = await this.getAccounts();
|
|
114
|
+
const contracts = {};
|
|
115
|
+
const stubArtifact = await this.accountContracts.getStubAccountContractArtifact();
|
|
116
|
+
const filtered = accounts.filter((acc)=>addresses.some((addr)=>addr.equals(acc.item)));
|
|
117
|
+
for (const account of filtered){
|
|
118
|
+
const address = account.item;
|
|
119
|
+
const originalAccount = await this.getAccountFromAddress(address);
|
|
120
|
+
const completeAddress = originalAccount.getCompleteAddress();
|
|
121
|
+
const contractInstance = await this.pxe.getContractInstance(completeAddress.address);
|
|
122
|
+
if (!contractInstance) {
|
|
123
|
+
throw new Error(`No contract instance found for address: ${completeAddress.address} during account override building. This is a bug!`);
|
|
124
|
+
}
|
|
125
|
+
const stubInstance = await getContractInstanceFromInstantiationParams(stubArtifact, {
|
|
126
|
+
salt: Fr.random()
|
|
127
|
+
});
|
|
128
|
+
contracts[address.toString()] = {
|
|
129
|
+
instance: stubInstance,
|
|
130
|
+
artifact: stubArtifact
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
return contracts;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
95
136
|
* Simulates calls via a stub account entrypoint, bypassing real account authorization.
|
|
96
137
|
* This allows kernelless simulation with contract overrides, skipping expensive
|
|
97
138
|
* private kernel circuit execution.
|
|
@@ -103,21 +144,16 @@ export class EmbeddedWallet extends BaseWallet {
|
|
|
103
144
|
executionPayload
|
|
104
145
|
]) : executionPayload;
|
|
105
146
|
const chainInfo = await this.getChainInfo();
|
|
106
|
-
|
|
147
|
+
const accountOverrides = await this.buildAccountOverrides(this.scopesFrom(from, opts.additionalScopes));
|
|
148
|
+
const overrides = new SimulationOverrides(accountOverrides);
|
|
107
149
|
let txRequest;
|
|
108
150
|
if (from === NO_FROM) {
|
|
109
151
|
const entrypoint = new DefaultEntrypoint();
|
|
110
152
|
txRequest = await entrypoint.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, chainInfo);
|
|
111
153
|
} else {
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
[from.toString()]: {
|
|
116
|
-
instance,
|
|
117
|
-
artifact
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
};
|
|
154
|
+
const originalAccount = await this.getAccountFromAddress(from);
|
|
155
|
+
const completeAddress = originalAccount.getCompleteAddress();
|
|
156
|
+
const account = await this.accountContracts.createStubAccount(completeAddress);
|
|
121
157
|
const executionOptions = {
|
|
122
158
|
txNonce: Fr.random(),
|
|
123
159
|
cancellable: this.cancellableTransactions,
|
|
@@ -134,24 +170,6 @@ export class EmbeddedWallet extends BaseWallet {
|
|
|
134
170
|
scopes
|
|
135
171
|
});
|
|
136
172
|
}
|
|
137
|
-
async getFakeAccountDataFor(address) {
|
|
138
|
-
const originalAccount = await this.getAccountFromAddress(address);
|
|
139
|
-
const originalAddress = originalAccount.getCompleteAddress();
|
|
140
|
-
const contractInstance = await this.pxe.getContractInstance(originalAddress.address);
|
|
141
|
-
if (!contractInstance) {
|
|
142
|
-
throw new Error(`No contract instance found for address: ${originalAddress.address}`);
|
|
143
|
-
}
|
|
144
|
-
const stubAccount = await this.accountContracts.createStubAccount(originalAddress);
|
|
145
|
-
const stubArtifact = await this.accountContracts.getStubAccountContractArtifact();
|
|
146
|
-
const instance = await getContractInstanceFromInstantiationParams(stubArtifact, {
|
|
147
|
-
salt: Fr.random()
|
|
148
|
-
});
|
|
149
|
-
return {
|
|
150
|
-
account: stubAccount,
|
|
151
|
-
instance,
|
|
152
|
-
artifact: stubArtifact
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
173
|
async createAccountInternal(type, secret, salt, signingKey) {
|
|
156
174
|
let contract;
|
|
157
175
|
switch(type){
|
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": "4.2.0-nightly.
|
|
4
|
+
"version": "4.2.0-nightly.20260409",
|
|
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": "4.2.0-nightly.
|
|
31
|
-
"@aztec/aztec.js": "4.2.0-nightly.
|
|
32
|
-
"@aztec/entrypoints": "4.2.0-nightly.
|
|
33
|
-
"@aztec/foundation": "4.2.0-nightly.
|
|
34
|
-
"@aztec/kv-store": "4.2.0-nightly.
|
|
35
|
-
"@aztec/protocol-contracts": "4.2.0-nightly.
|
|
36
|
-
"@aztec/pxe": "4.2.0-nightly.
|
|
37
|
-
"@aztec/stdlib": "4.2.0-nightly.
|
|
38
|
-
"@aztec/wallet-sdk": "4.2.0-nightly.
|
|
30
|
+
"@aztec/accounts": "4.2.0-nightly.20260409",
|
|
31
|
+
"@aztec/aztec.js": "4.2.0-nightly.20260409",
|
|
32
|
+
"@aztec/entrypoints": "4.2.0-nightly.20260409",
|
|
33
|
+
"@aztec/foundation": "4.2.0-nightly.20260409",
|
|
34
|
+
"@aztec/kv-store": "4.2.0-nightly.20260409",
|
|
35
|
+
"@aztec/protocol-contracts": "4.2.0-nightly.20260409",
|
|
36
|
+
"@aztec/pxe": "4.2.0-nightly.20260409",
|
|
37
|
+
"@aztec/stdlib": "4.2.0-nightly.20260409",
|
|
38
|
+
"@aztec/wallet-sdk": "4.2.0-nightly.20260409"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@jest/globals": "^30.0.0",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Account, NO_FROM } from '@aztec/aztec.js/account';
|
|
2
2
|
import { CallAuthorizationRequest } from '@aztec/aztec.js/authorization';
|
|
3
|
-
import { type InteractionWaitOptions, type SendReturn, getGasLimits } from '@aztec/aztec.js/contracts';
|
|
3
|
+
import { type InteractionWaitOptions, type SendReturn, type WaitOpts, getGasLimits } from '@aztec/aztec.js/contracts';
|
|
4
4
|
import type { Aliased, SendOptions } from '@aztec/aztec.js/wallet';
|
|
5
5
|
import { AccountManager } from '@aztec/aztec.js/wallet';
|
|
6
6
|
import type { DefaultAccountEntrypointOptions } from '@aztec/entrypoints/account';
|
|
@@ -15,10 +15,12 @@ import { GasSettings } from '@aztec/stdlib/gas';
|
|
|
15
15
|
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
16
16
|
import { deriveSigningKey } from '@aztec/stdlib/keys';
|
|
17
17
|
import {
|
|
18
|
+
type ContractOverrides,
|
|
18
19
|
ExecutionPayload,
|
|
19
20
|
SimulationOverrides,
|
|
20
21
|
type TxExecutionRequest,
|
|
21
22
|
type TxSimulationResult,
|
|
23
|
+
TxStatus,
|
|
22
24
|
collectOffchainEffects,
|
|
23
25
|
mergeExecutionPayloads,
|
|
24
26
|
} from '@aztec/stdlib/tx';
|
|
@@ -94,11 +96,12 @@ export class EmbeddedWallet extends BaseWallet {
|
|
|
94
96
|
executionPayload: ExecutionPayload,
|
|
95
97
|
opts: SendOptions<W>,
|
|
96
98
|
): Promise<SendReturn<W>> {
|
|
97
|
-
const feeOptions = await this.
|
|
98
|
-
opts.from,
|
|
99
|
-
executionPayload.feePayer,
|
|
100
|
-
opts.fee?.gasSettings,
|
|
101
|
-
|
|
99
|
+
const feeOptions = await this.completeFeeOptions({
|
|
100
|
+
from: opts.from,
|
|
101
|
+
feePayer: executionPayload.feePayer,
|
|
102
|
+
gasSettings: opts.fee?.gasSettings,
|
|
103
|
+
forEstimation: true,
|
|
104
|
+
});
|
|
102
105
|
|
|
103
106
|
// Simulate the transaction first to estimate gas and capture required
|
|
104
107
|
// private authwitnesses based on offchain effects.
|
|
@@ -139,12 +142,59 @@ export class EmbeddedWallet extends BaseWallet {
|
|
|
139
142
|
gasLimits: opts.fee?.gasSettings?.gasLimits ?? estimated.gasLimits,
|
|
140
143
|
teardownGasLimits: opts.fee?.gasSettings?.teardownGasLimits ?? estimated.teardownGasLimits,
|
|
141
144
|
});
|
|
145
|
+
const waitOpts: WaitOpts = typeof opts.wait === 'object' ? opts.wait : {};
|
|
146
|
+
|
|
147
|
+
if (!waitOpts?.waitForStatus) {
|
|
148
|
+
// Default to PROPOSED so the wait returns as soon as the tx lands in a proposed L2 block,
|
|
149
|
+
// rather than waiting until the end of the slot for the checkpoint to be published to L1.
|
|
150
|
+
// This is what makes MBPS (Multiple Blocks Per Slot) actually improve UX: with CHECKPOINTED
|
|
151
|
+
// we'd block until L1 inclusion regardless of how early in the slot the tx was sequenced.
|
|
152
|
+
// The tradeoff is a weaker guarantee — a proposed block only becomes canonical once it (or
|
|
153
|
+
// a later block in the same slot) is checkpointed, so a tx could be re-orged out if the
|
|
154
|
+
// proposer fails to publish to L1 (which should be rare, since they'd get slashed for it).
|
|
155
|
+
waitOpts!.waitForStatus = TxStatus.PROPOSED;
|
|
156
|
+
}
|
|
142
157
|
return super.sendTx(executionPayload, {
|
|
143
158
|
...opts,
|
|
144
159
|
fee: { ...opts.fee, gasSettings },
|
|
145
160
|
});
|
|
146
161
|
}
|
|
147
162
|
|
|
163
|
+
/**
|
|
164
|
+
* Builds contract overrides for all provided addresses by replacing their account contracts with stub implementations.
|
|
165
|
+
*/
|
|
166
|
+
protected async buildAccountOverrides(addresses: AztecAddress[]): Promise<ContractOverrides> {
|
|
167
|
+
const accounts = await this.getAccounts();
|
|
168
|
+
const contracts: ContractOverrides = {};
|
|
169
|
+
|
|
170
|
+
const stubArtifact = await this.accountContracts.getStubAccountContractArtifact();
|
|
171
|
+
|
|
172
|
+
const filtered = accounts.filter(acc => addresses.some(addr => addr.equals(acc.item)));
|
|
173
|
+
|
|
174
|
+
for (const account of filtered) {
|
|
175
|
+
const address = account.item;
|
|
176
|
+
const originalAccount = await this.getAccountFromAddress(address);
|
|
177
|
+
const completeAddress = originalAccount.getCompleteAddress();
|
|
178
|
+
const contractInstance = await this.pxe.getContractInstance(completeAddress.address);
|
|
179
|
+
if (!contractInstance) {
|
|
180
|
+
throw new Error(
|
|
181
|
+
`No contract instance found for address: ${completeAddress.address} during account override building. This is a bug!`,
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
const stubInstance = await getContractInstanceFromInstantiationParams(stubArtifact, {
|
|
186
|
+
salt: Fr.random(),
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
contracts[address.toString()] = {
|
|
190
|
+
instance: stubInstance,
|
|
191
|
+
artifact: stubArtifact,
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
return contracts;
|
|
196
|
+
}
|
|
197
|
+
|
|
148
198
|
/**
|
|
149
199
|
* Simulates calls via a stub account entrypoint, bypassing real account authorization.
|
|
150
200
|
* This allows kernelless simulation with contract overrides, skipping expensive
|
|
@@ -162,16 +212,17 @@ export class EmbeddedWallet extends BaseWallet {
|
|
|
162
212
|
: executionPayload;
|
|
163
213
|
const chainInfo = await this.getChainInfo();
|
|
164
214
|
|
|
165
|
-
|
|
215
|
+
const accountOverrides = await this.buildAccountOverrides(this.scopesFrom(from, opts.additionalScopes));
|
|
216
|
+
const overrides = new SimulationOverrides(accountOverrides);
|
|
217
|
+
|
|
166
218
|
let txRequest: TxExecutionRequest;
|
|
167
219
|
if (from === NO_FROM) {
|
|
168
220
|
const entrypoint = new DefaultEntrypoint();
|
|
169
221
|
txRequest = await entrypoint.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, chainInfo);
|
|
170
222
|
} else {
|
|
171
|
-
const
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
};
|
|
223
|
+
const originalAccount = await this.getAccountFromAddress(from);
|
|
224
|
+
const completeAddress = originalAccount.getCompleteAddress();
|
|
225
|
+
const account = await this.accountContracts.createStubAccount(completeAddress);
|
|
175
226
|
const executionOptions: DefaultAccountEntrypointOptions = {
|
|
176
227
|
txNonce: Fr.random(),
|
|
177
228
|
cancellable: this.cancellableTransactions,
|
|
@@ -195,25 +246,6 @@ export class EmbeddedWallet extends BaseWallet {
|
|
|
195
246
|
});
|
|
196
247
|
}
|
|
197
248
|
|
|
198
|
-
private async getFakeAccountDataFor(address: AztecAddress) {
|
|
199
|
-
const originalAccount = await this.getAccountFromAddress(address);
|
|
200
|
-
const originalAddress = originalAccount.getCompleteAddress();
|
|
201
|
-
const contractInstance = await this.pxe.getContractInstance(originalAddress.address);
|
|
202
|
-
if (!contractInstance) {
|
|
203
|
-
throw new Error(`No contract instance found for address: ${originalAddress.address}`);
|
|
204
|
-
}
|
|
205
|
-
const stubAccount = await this.accountContracts.createStubAccount(originalAddress);
|
|
206
|
-
const stubArtifact = await this.accountContracts.getStubAccountContractArtifact();
|
|
207
|
-
const instance = await getContractInstanceFromInstantiationParams(stubArtifact, {
|
|
208
|
-
salt: Fr.random(),
|
|
209
|
-
});
|
|
210
|
-
return {
|
|
211
|
-
account: stubAccount,
|
|
212
|
-
instance,
|
|
213
|
-
artifact: stubArtifact,
|
|
214
|
-
};
|
|
215
|
-
}
|
|
216
|
-
|
|
217
249
|
protected async createAccountInternal(
|
|
218
250
|
type: AccountType,
|
|
219
251
|
secret: Fr,
|