@aztec/wallets 4.1.0-nightly.20260317 → 4.1.0-rc.3
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.
|
@@ -34,7 +34,7 @@ export declare class EmbeddedWallet extends BaseWallet {
|
|
|
34
34
|
* This allows kernelless simulation with contract overrides, skipping expensive
|
|
35
35
|
* private kernel circuit execution.
|
|
36
36
|
*/
|
|
37
|
-
protected simulateViaEntrypoint(executionPayload: ExecutionPayload, from: AztecAddress, feeOptions: FeeOptions, scopes: AccessScopes,
|
|
37
|
+
protected simulateViaEntrypoint(executionPayload: ExecutionPayload, from: AztecAddress, feeOptions: FeeOptions, scopes: AccessScopes, _skipTxValidation?: boolean, _skipFeeEnforcement?: boolean): Promise<TxSimulationResult>;
|
|
38
38
|
private getFakeAccountDataFor;
|
|
39
39
|
protected createAccountInternal(type: AccountType, secret: Fr, salt: Fr, signingKey: Buffer): Promise<AccountManager>;
|
|
40
40
|
createAndStoreAccount(alias: string, type: AccountType, secret: Fr, salt: Fr, signingKey: Buffer): Promise<AccountManager>;
|
|
@@ -44,4 +44,4 @@ export declare class EmbeddedWallet extends BaseWallet {
|
|
|
44
44
|
setMinFeePadding(value?: number): void;
|
|
45
45
|
stop(): Promise<void>;
|
|
46
46
|
}
|
|
47
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
47
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZW1iZWRkZWRfd2FsbGV0LmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvZW1iZWRkZWQvZW1iZWRkZWRfd2FsbGV0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxLQUFLLE9BQU8sRUFBcUIsTUFBTSx5QkFBeUIsQ0FBQztBQUMxRSxPQUFPLEtBQUssRUFBRSxPQUFPLEVBQUUsTUFBTSx3QkFBd0Is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BAAkB,CAAC,CA4B7B;YAEa,qBAAqB;IAoCnC,UAAgB,qBAAqB,CACnC,IAAI,EAAE,WAAW,EACjB,MAAM,EAAE,EAAE,EACV,IAAI,EAAE,EAAE,EACR,UAAU,EAAE,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,IAAI,kBAEH;CACF"}
|
|
@@ -45,23 +45,8 @@ export class EmbeddedWallet extends BaseWallet {
|
|
|
45
45
|
* Simulates calls via a stub account entrypoint, bypassing real account authorization.
|
|
46
46
|
* This allows kernelless simulation with contract overrides, skipping expensive
|
|
47
47
|
* private kernel circuit execution.
|
|
48
|
-
*/ async simulateViaEntrypoint(executionPayload, from, feeOptions, scopes,
|
|
49
|
-
|
|
50
|
-
let fromAccount;
|
|
51
|
-
if (!from.equals(AztecAddress.ZERO)) {
|
|
52
|
-
const { account, instance, artifact } = await this.getFakeAccountDataFor(from);
|
|
53
|
-
fromAccount = account;
|
|
54
|
-
overrides = {
|
|
55
|
-
contracts: {
|
|
56
|
-
[from.toString()]: {
|
|
57
|
-
instance,
|
|
58
|
-
artifact
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
} else {
|
|
63
|
-
fromAccount = await this.getAccountFromAddress(from);
|
|
64
|
-
}
|
|
48
|
+
*/ async simulateViaEntrypoint(executionPayload, from, feeOptions, scopes, _skipTxValidation, _skipFeeEnforcement) {
|
|
49
|
+
const { account: fromAccount, instance, artifact } = await this.getFakeAccountDataFor(from);
|
|
65
50
|
const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
|
|
66
51
|
const executionOptions = {
|
|
67
52
|
txNonce: Fr.random(),
|
|
@@ -76,32 +61,53 @@ export class EmbeddedWallet extends BaseWallet {
|
|
|
76
61
|
const txRequest = await fromAccount.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, chainInfo, executionOptions);
|
|
77
62
|
return this.pxe.simulateTx(txRequest, {
|
|
78
63
|
simulatePublic: true,
|
|
79
|
-
skipFeeEnforcement,
|
|
80
|
-
skipTxValidation,
|
|
81
|
-
overrides
|
|
64
|
+
skipFeeEnforcement: true,
|
|
65
|
+
skipTxValidation: true,
|
|
66
|
+
overrides: {
|
|
67
|
+
contracts: {
|
|
68
|
+
[from.toString()]: {
|
|
69
|
+
instance,
|
|
70
|
+
artifact
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
},
|
|
82
74
|
scopes
|
|
83
75
|
});
|
|
84
76
|
}
|
|
85
77
|
async getFakeAccountDataFor(address) {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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
|
+
};
|
|
94
110
|
}
|
|
95
|
-
const stubAccount = await this.accountContracts.createStubAccount(originalAddress);
|
|
96
|
-
const stubArtifact = await this.accountContracts.getStubAccountContractArtifact();
|
|
97
|
-
const instance = await getContractInstanceFromInstantiationParams(stubArtifact, {
|
|
98
|
-
salt: Fr.random()
|
|
99
|
-
});
|
|
100
|
-
return {
|
|
101
|
-
account: stubAccount,
|
|
102
|
-
instance,
|
|
103
|
-
artifact: stubArtifact
|
|
104
|
-
};
|
|
105
111
|
}
|
|
106
112
|
async createAccountInternal(type, secret, salt, signingKey) {
|
|
107
113
|
let contract;
|
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.1.0-
|
|
4
|
+
"version": "4.1.0-rc.3",
|
|
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.1.0-
|
|
31
|
-
"@aztec/aztec.js": "4.1.0-
|
|
32
|
-
"@aztec/entrypoints": "4.1.0-
|
|
33
|
-
"@aztec/foundation": "4.1.0-
|
|
34
|
-
"@aztec/kv-store": "4.1.0-
|
|
35
|
-
"@aztec/protocol-contracts": "4.1.0-
|
|
36
|
-
"@aztec/pxe": "4.1.0-
|
|
37
|
-
"@aztec/stdlib": "4.1.0-
|
|
38
|
-
"@aztec/wallet-sdk": "4.1.0-
|
|
30
|
+
"@aztec/accounts": "4.1.0-rc.3",
|
|
31
|
+
"@aztec/aztec.js": "4.1.0-rc.3",
|
|
32
|
+
"@aztec/entrypoints": "4.1.0-rc.3",
|
|
33
|
+
"@aztec/foundation": "4.1.0-rc.3",
|
|
34
|
+
"@aztec/kv-store": "4.1.0-rc.3",
|
|
35
|
+
"@aztec/protocol-contracts": "4.1.0-rc.3",
|
|
36
|
+
"@aztec/pxe": "4.1.0-rc.3",
|
|
37
|
+
"@aztec/stdlib": "4.1.0-rc.3",
|
|
38
|
+
"@aztec/wallet-sdk": "4.1.0-rc.3"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@jest/globals": "^30.0.0",
|
|
@@ -10,12 +10,7 @@ import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
|
10
10
|
import { getContractInstanceFromInstantiationParams } from '@aztec/stdlib/contract';
|
|
11
11
|
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
12
12
|
import { deriveSigningKey } from '@aztec/stdlib/keys';
|
|
13
|
-
import {
|
|
14
|
-
ExecutionPayload,
|
|
15
|
-
SimulationOverrides,
|
|
16
|
-
type TxSimulationResult,
|
|
17
|
-
mergeExecutionPayloads,
|
|
18
|
-
} from '@aztec/stdlib/tx';
|
|
13
|
+
import { ExecutionPayload, type TxSimulationResult, mergeExecutionPayloads } from '@aztec/stdlib/tx';
|
|
19
14
|
import { BaseWallet, type FeeOptions } from '@aztec/wallet-sdk/base-wallet';
|
|
20
15
|
|
|
21
16
|
import type { AccountContractsProvider } from './account-contract-providers/types.js';
|
|
@@ -89,20 +84,10 @@ export class EmbeddedWallet extends BaseWallet {
|
|
|
89
84
|
from: AztecAddress,
|
|
90
85
|
feeOptions: FeeOptions,
|
|
91
86
|
scopes: AccessScopes,
|
|
92
|
-
|
|
93
|
-
|
|
87
|
+
_skipTxValidation?: boolean,
|
|
88
|
+
_skipFeeEnforcement?: boolean,
|
|
94
89
|
): Promise<TxSimulationResult> {
|
|
95
|
-
|
|
96
|
-
let fromAccount: Account;
|
|
97
|
-
if (!from.equals(AztecAddress.ZERO)) {
|
|
98
|
-
const { account, instance, artifact } = await this.getFakeAccountDataFor(from);
|
|
99
|
-
fromAccount = account;
|
|
100
|
-
overrides = {
|
|
101
|
-
contracts: { [from.toString()]: { instance, artifact } },
|
|
102
|
-
};
|
|
103
|
-
} else {
|
|
104
|
-
fromAccount = await this.getAccountFromAddress(from);
|
|
105
|
-
}
|
|
90
|
+
const { account: fromAccount, instance, artifact } = await this.getFakeAccountDataFor(from);
|
|
106
91
|
|
|
107
92
|
const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
|
|
108
93
|
const executionOptions: DefaultAccountEntrypointOptions = {
|
|
@@ -122,33 +107,49 @@ export class EmbeddedWallet extends BaseWallet {
|
|
|
122
107
|
);
|
|
123
108
|
return this.pxe.simulateTx(txRequest, {
|
|
124
109
|
simulatePublic: true,
|
|
125
|
-
skipFeeEnforcement,
|
|
126
|
-
skipTxValidation,
|
|
127
|
-
overrides
|
|
110
|
+
skipFeeEnforcement: true,
|
|
111
|
+
skipTxValidation: true,
|
|
112
|
+
overrides: {
|
|
113
|
+
contracts: { [from.toString()]: { instance, artifact } },
|
|
114
|
+
},
|
|
128
115
|
scopes,
|
|
129
116
|
});
|
|
130
117
|
}
|
|
131
118
|
|
|
132
119
|
private async getFakeAccountDataFor(address: AztecAddress) {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
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
|
+
};
|
|
141
152
|
}
|
|
142
|
-
const stubAccount = await this.accountContracts.createStubAccount(originalAddress);
|
|
143
|
-
const stubArtifact = await this.accountContracts.getStubAccountContractArtifact();
|
|
144
|
-
const instance = await getContractInstanceFromInstantiationParams(stubArtifact, {
|
|
145
|
-
salt: Fr.random(),
|
|
146
|
-
});
|
|
147
|
-
return {
|
|
148
|
-
account: stubAccount,
|
|
149
|
-
instance,
|
|
150
|
-
artifact: stubArtifact,
|
|
151
|
-
};
|
|
152
153
|
}
|
|
153
154
|
|
|
154
155
|
protected async createAccountInternal(
|