@aztec/aztec.js 3.0.0-nightly.20251024 → 3.0.0-nightly.20251025
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.
- package/dest/contract/batch_call.d.ts +3 -8
- package/dest/contract/batch_call.d.ts.map +1 -1
- package/dest/contract/batch_call.js +29 -27
- package/dest/wallet/wallet.d.ts +10 -1
- package/dest/wallet/wallet.d.ts.map +1 -1
- package/dest/wallet/wallet.js +13 -0
- package/package.json +8 -8
- package/src/contract/batch_call.ts +37 -33
- package/src/wallet/wallet.ts +6 -1
|
@@ -4,13 +4,8 @@ import { BaseContractInteraction } from './base_contract_interaction.js';
|
|
|
4
4
|
import { type RequestInteractionOptions, type SimulateInteractionOptions } from './interaction_options.js';
|
|
5
5
|
/** A batch of function calls to be sent as a single transaction through a wallet. */
|
|
6
6
|
export declare class BatchCall extends BaseContractInteraction {
|
|
7
|
-
protected interactions: BaseContractInteraction[];
|
|
8
|
-
constructor(wallet: Wallet, interactions: BaseContractInteraction[]);
|
|
9
|
-
/**
|
|
10
|
-
* Creates a new instance with no actual calls. Useful for triggering a no-op.
|
|
11
|
-
* @param wallet - The wallet to use for sending the batch call.
|
|
12
|
-
*/
|
|
13
|
-
static empty(wallet: Wallet): BatchCall;
|
|
7
|
+
protected interactions: (BaseContractInteraction | ExecutionPayload)[];
|
|
8
|
+
constructor(wallet: Wallet, interactions: (BaseContractInteraction | ExecutionPayload)[]);
|
|
14
9
|
/**
|
|
15
10
|
* Returns an execution request that represents this operation.
|
|
16
11
|
* @param options - An optional object containing additional configuration for the request generation.
|
|
@@ -27,6 +22,6 @@ export declare class BatchCall extends BaseContractInteraction {
|
|
|
27
22
|
* @returns The result of the transaction as returned by the contract function.
|
|
28
23
|
*/
|
|
29
24
|
simulate(options: SimulateInteractionOptions): Promise<any>;
|
|
30
|
-
protected
|
|
25
|
+
protected getExecutionPayloads(): Promise<ExecutionPayload[]>;
|
|
31
26
|
}
|
|
32
27
|
//# sourceMappingURL=batch_call.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"batch_call.d.ts","sourceRoot":"","sources":["../../src/contract/batch_call.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAA0B,MAAM,4BAA4B,CAAC;AAGtF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,EACL,KAAK,yBAAyB,EAC9B,KAAK,0BAA0B,EAEhC,MAAM,0BAA0B,CAAC;AAElC,qFAAqF;AACrF,qBAAa,SAAU,SAAQ,uBAAuB;IAGlD,SAAS,CAAC,YAAY,EAAE,uBAAuB,EAAE;
|
|
1
|
+
{"version":3,"file":"batch_call.d.ts","sourceRoot":"","sources":["../../src/contract/batch_call.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAA0B,MAAM,4BAA4B,CAAC;AAGtF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,EACL,KAAK,yBAAyB,EAC9B,KAAK,0BAA0B,EAEhC,MAAM,0BAA0B,CAAC;AAElC,qFAAqF;AACrF,qBAAa,SAAU,SAAQ,uBAAuB;IAGlD,SAAS,CAAC,YAAY,EAAE,CAAC,uBAAuB,GAAG,gBAAgB,CAAC,EAAE;gBADtE,MAAM,EAAE,MAAM,EACJ,YAAY,EAAE,CAAC,uBAAuB,GAAG,gBAAgB,CAAC,EAAE;IAKxE;;;;OAIG;IACU,OAAO,CAAC,OAAO,GAAE,yBAA8B,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAWxF;;;;;;;;OAQG;IACU,QAAQ,CAAC,OAAO,EAAE,0BAA0B,GAAG,OAAO,CAAC,GAAG,CAAC;cA8ExD,oBAAoB,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;CAGpE"}
|
|
@@ -8,17 +8,11 @@ import { toSimulateOptions } from './interaction_options.js';
|
|
|
8
8
|
super(wallet), this.interactions = interactions;
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
|
-
* Creates a new instance with no actual calls. Useful for triggering a no-op.
|
|
12
|
-
* @param wallet - The wallet to use for sending the batch call.
|
|
13
|
-
*/ static empty(wallet) {
|
|
14
|
-
return new BatchCall(wallet, []);
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
11
|
* Returns an execution request that represents this operation.
|
|
18
12
|
* @param options - An optional object containing additional configuration for the request generation.
|
|
19
13
|
* @returns An execution payload wrapped in promise.
|
|
20
14
|
*/ async request(options = {}) {
|
|
21
|
-
const requests = await this.
|
|
15
|
+
const requests = await this.getExecutionPayloads();
|
|
22
16
|
const feeExecutionPayload = options.fee?.paymentMethod ? await options.fee.paymentMethod.getExecutionPayload() : undefined;
|
|
23
17
|
const finalExecutionPayload = feeExecutionPayload ? mergeExecutionPayloads([
|
|
24
18
|
feeExecutionPayload,
|
|
@@ -37,7 +31,7 @@ import { toSimulateOptions } from './interaction_options.js';
|
|
|
37
31
|
* @param options - An optional object containing additional configuration for the transaction.
|
|
38
32
|
* @returns The result of the transaction as returned by the contract function.
|
|
39
33
|
*/ async simulate(options) {
|
|
40
|
-
const { indexedExecutionPayloads, utility } = (await this.
|
|
34
|
+
const { indexedExecutionPayloads, utility } = (await this.getExecutionPayloads()).reduce((acc, current, index)=>{
|
|
41
35
|
const call = current.calls[0];
|
|
42
36
|
if (call.type === FunctionType.UTILITY) {
|
|
43
37
|
acc.utility.push([
|
|
@@ -61,29 +55,37 @@ import { toSimulateOptions } from './interaction_options.js';
|
|
|
61
55
|
const payloads = indexedExecutionPayloads.map(([request])=>request);
|
|
62
56
|
const combinedPayload = mergeExecutionPayloads(payloads);
|
|
63
57
|
const executionPayload = new ExecutionPayload(combinedPayload.calls, combinedPayload.authWitnesses.concat(options.authWitnesses ?? []), combinedPayload.capsules.concat(options.capsules ?? []), combinedPayload.extraHashedArgs);
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
58
|
+
const utilityBatchPromise = utility.length > 0 ? this.wallet.batch(utility.map(([call])=>({
|
|
59
|
+
name: 'simulateUtility',
|
|
60
|
+
args: [
|
|
61
|
+
call.name,
|
|
62
|
+
call.args,
|
|
63
|
+
call.to,
|
|
64
|
+
options?.authWitnesses
|
|
65
|
+
]
|
|
66
|
+
}))) : Promise.resolve([]);
|
|
67
|
+
const [utilityBatchResults, simulatedTx] = await Promise.all([
|
|
68
|
+
utilityBatchPromise,
|
|
69
|
+
indexedExecutionPayloads.length > 0 ? this.wallet.simulateTx(executionPayload, await toSimulateOptions(options)) : Promise.resolve()
|
|
71
70
|
]);
|
|
72
71
|
const results = [];
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
indexedExecutionPayloads.forEach(([request, callIndex, resultIndex])=>{
|
|
77
|
-
const call = request.calls[0];
|
|
78
|
-
// As account entrypoints are private, for private functions we retrieve the return values from the first nested call
|
|
79
|
-
// since we're interested in the first set of values AFTER the account entrypoint
|
|
80
|
-
// For public functions we retrieve the first values directly from the public output.
|
|
81
|
-
const rawReturnValues = call.type == FunctionType.PRIVATE ? simulatedTx.getPrivateReturnValues()?.nested?.[resultIndex].values : simulatedTx.getPublicReturnValues()?.[resultIndex].values;
|
|
82
|
-
results[callIndex] = rawReturnValues ? decodeFromAbi(call.returnTypes, rawReturnValues) : [];
|
|
72
|
+
utilityBatchResults.forEach((wrappedResult, utilityIndex)=>{
|
|
73
|
+
const [, originalIndex] = utility[utilityIndex];
|
|
74
|
+
results[originalIndex] = wrappedResult.result.result;
|
|
83
75
|
});
|
|
76
|
+
if (simulatedTx) {
|
|
77
|
+
indexedExecutionPayloads.forEach(([request, callIndex, resultIndex])=>{
|
|
78
|
+
const call = request.calls[0];
|
|
79
|
+
// As account entrypoints are private, for private functions we retrieve the return values from the first nested call
|
|
80
|
+
// since we're interested in the first set of values AFTER the account entrypoint
|
|
81
|
+
// For public functions we retrieve the first values directly from the public output.
|
|
82
|
+
const rawReturnValues = call.type == FunctionType.PRIVATE ? simulatedTx.getPrivateReturnValues()?.nested?.[resultIndex].values : simulatedTx.getPublicReturnValues()?.[resultIndex].values;
|
|
83
|
+
results[callIndex] = rawReturnValues ? decodeFromAbi(call.returnTypes, rawReturnValues) : [];
|
|
84
|
+
});
|
|
85
|
+
}
|
|
84
86
|
return results;
|
|
85
87
|
}
|
|
86
|
-
async
|
|
87
|
-
return await Promise.all(this.interactions.map((i)=>i.request()));
|
|
88
|
+
async getExecutionPayloads() {
|
|
89
|
+
return await Promise.all(this.interactions.map((i)=>i instanceof ExecutionPayload ? i : i.request()));
|
|
88
90
|
}
|
|
89
91
|
}
|
package/dest/wallet/wallet.d.ts
CHANGED
|
@@ -70,7 +70,7 @@ export type SendOptions = Omit<SendInteractionOptions, 'fee'> & {
|
|
|
70
70
|
/**
|
|
71
71
|
* Helper type that represents all methods that can be batched.
|
|
72
72
|
*/
|
|
73
|
-
export type BatchableMethods = Pick<Wallet, 'registerContract' | 'sendTx' | 'registerSender'>;
|
|
73
|
+
export type BatchableMethods = Pick<Wallet, 'registerContract' | 'sendTx' | 'registerSender' | 'simulateUtility'>;
|
|
74
74
|
/**
|
|
75
75
|
* From the batchable methods, we create a type that represents a method call with its name and arguments.
|
|
76
76
|
* This is what the wallet will accept as arguments to the `batch` method.
|
|
@@ -2275,6 +2275,15 @@ export declare const BatchedMethodSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
2275
2275
|
capsules?: string[] | undefined;
|
|
2276
2276
|
from?: any;
|
|
2277
2277
|
}];
|
|
2278
|
+
}>, z.ZodObject<{
|
|
2279
|
+
name: z.ZodLiteral<"simulateUtility">;
|
|
2280
|
+
args: z.ZodTuple<[z.ZodString, z.ZodArray<z.ZodAny, "many">, ZodFor<AztecAddress>, import("@aztec/foundation/schemas").ZodNullableOptional<z.ZodArray<z.ZodType<AuthWitness, any, string>, "many">>], null>;
|
|
2281
|
+
}, "strip", z.ZodTypeAny, {
|
|
2282
|
+
name: "simulateUtility";
|
|
2283
|
+
args: [string, any[], AztecAddress, AuthWitness[] | undefined];
|
|
2284
|
+
}, {
|
|
2285
|
+
name: "simulateUtility";
|
|
2286
|
+
args: [string, any[], any, string[] | undefined];
|
|
2278
2287
|
}>]>;
|
|
2279
2288
|
export declare const ContractMetadataSchema: z.ZodObject<{
|
|
2280
2289
|
contractInstance: z.ZodUnion<[z.ZodIntersection<z.ZodObject<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../src/wallet/wallet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAEL,KAAK,gBAAgB,EAErB,KAAK,uBAAuB,EAE5B,YAAY,EACb,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EACL,KAAK,qBAAqB,EAE1B,KAAK,2BAA2B,EAEhC,KAAK,yBAAyB,EAC9B,KAAK,gBAAgB,EACtB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAoB,KAAK,YAAY,EAAE,KAAK,MAAM,EAAqB,MAAM,uBAAuB,CAAC;AAC5G,OAAO,EACL,OAAO,EACP,YAAY,EACZ,MAAM,EACN,eAAe,EACf,SAAS,EACT,k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chema = z.union([
|
|
|
121
121
|
ExecutionPayloadSchema,
|
|
122
122
|
SendOptionsSchema
|
|
123
123
|
])
|
|
124
|
+
}),
|
|
125
|
+
z.object({
|
|
126
|
+
name: z.literal('simulateUtility'),
|
|
127
|
+
args: z.tuple([
|
|
128
|
+
z.string(),
|
|
129
|
+
z.array(z.any()),
|
|
130
|
+
schemas.AztecAddress,
|
|
131
|
+
optional(z.array(AuthWitness.schema))
|
|
132
|
+
])
|
|
124
133
|
})
|
|
125
134
|
]);
|
|
126
135
|
export const ContractMetadataSchema = z.object({
|
|
@@ -184,6 +193,10 @@ export const WalletSchema = {
|
|
|
184
193
|
z.object({
|
|
185
194
|
name: z.literal('sendTx'),
|
|
186
195
|
result: TxHash.schema
|
|
196
|
+
}),
|
|
197
|
+
z.object({
|
|
198
|
+
name: z.literal('simulateUtility'),
|
|
199
|
+
result: UtilitySimulationResult.schema
|
|
187
200
|
})
|
|
188
201
|
])))
|
|
189
202
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/aztec.js",
|
|
3
3
|
"homepage": "https://github.com/AztecProtocol/aztec-packages/tree/master/yarn-project/aztec.js",
|
|
4
|
-
"version": "3.0.0-nightly.
|
|
4
|
+
"version": "3.0.0-nightly.20251025",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
"./abi": "./dest/api/abi.js",
|
|
@@ -84,13 +84,13 @@
|
|
|
84
84
|
]
|
|
85
85
|
},
|
|
86
86
|
"dependencies": {
|
|
87
|
-
"@aztec/constants": "3.0.0-nightly.
|
|
88
|
-
"@aztec/entrypoints": "3.0.0-nightly.
|
|
89
|
-
"@aztec/ethereum": "3.0.0-nightly.
|
|
90
|
-
"@aztec/foundation": "3.0.0-nightly.
|
|
91
|
-
"@aztec/l1-artifacts": "3.0.0-nightly.
|
|
92
|
-
"@aztec/protocol-contracts": "3.0.0-nightly.
|
|
93
|
-
"@aztec/stdlib": "3.0.0-nightly.
|
|
87
|
+
"@aztec/constants": "3.0.0-nightly.20251025",
|
|
88
|
+
"@aztec/entrypoints": "3.0.0-nightly.20251025",
|
|
89
|
+
"@aztec/ethereum": "3.0.0-nightly.20251025",
|
|
90
|
+
"@aztec/foundation": "3.0.0-nightly.20251025",
|
|
91
|
+
"@aztec/l1-artifacts": "3.0.0-nightly.20251025",
|
|
92
|
+
"@aztec/protocol-contracts": "3.0.0-nightly.20251025",
|
|
93
|
+
"@aztec/stdlib": "3.0.0-nightly.20251025",
|
|
94
94
|
"axios": "^1.12.0",
|
|
95
95
|
"tslib": "^2.4.0",
|
|
96
96
|
"viem": "npm:@spalladino/viem@2.38.2-eip7594.0",
|
|
@@ -13,26 +13,18 @@ import {
|
|
|
13
13
|
export class BatchCall extends BaseContractInteraction {
|
|
14
14
|
constructor(
|
|
15
15
|
wallet: Wallet,
|
|
16
|
-
protected interactions: BaseContractInteraction[],
|
|
16
|
+
protected interactions: (BaseContractInteraction | ExecutionPayload)[],
|
|
17
17
|
) {
|
|
18
18
|
super(wallet);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
/**
|
|
22
|
-
* Creates a new instance with no actual calls. Useful for triggering a no-op.
|
|
23
|
-
* @param wallet - The wallet to use for sending the batch call.
|
|
24
|
-
*/
|
|
25
|
-
public static empty(wallet: Wallet) {
|
|
26
|
-
return new BatchCall(wallet, []);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
21
|
/**
|
|
30
22
|
* Returns an execution request that represents this operation.
|
|
31
23
|
* @param options - An optional object containing additional configuration for the request generation.
|
|
32
24
|
* @returns An execution payload wrapped in promise.
|
|
33
25
|
*/
|
|
34
26
|
public async request(options: RequestInteractionOptions = {}): Promise<ExecutionPayload> {
|
|
35
|
-
const requests = await this.
|
|
27
|
+
const requests = await this.getExecutionPayloads();
|
|
36
28
|
const feeExecutionPayload = options.fee?.paymentMethod
|
|
37
29
|
? await options.fee.paymentMethod.getExecutionPayload()
|
|
38
30
|
: undefined;
|
|
@@ -52,7 +44,7 @@ export class BatchCall extends BaseContractInteraction {
|
|
|
52
44
|
* @returns The result of the transaction as returned by the contract function.
|
|
53
45
|
*/
|
|
54
46
|
public async simulate(options: SimulateInteractionOptions): Promise<any> {
|
|
55
|
-
const { indexedExecutionPayloads, utility } = (await this.
|
|
47
|
+
const { indexedExecutionPayloads, utility } = (await this.getExecutionPayloads()).reduce<{
|
|
56
48
|
/** Keep track of the number of private calls to retrieve the return values */
|
|
57
49
|
privateIndex: 0;
|
|
58
50
|
/** Keep track of the number of public calls to retrieve the return values */
|
|
@@ -87,37 +79,49 @@ export class BatchCall extends BaseContractInteraction {
|
|
|
87
79
|
combinedPayload.extraHashedArgs,
|
|
88
80
|
);
|
|
89
81
|
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
82
|
+
const utilityBatchPromise =
|
|
83
|
+
utility.length > 0
|
|
84
|
+
? this.wallet.batch(
|
|
85
|
+
utility.map(([call]) => ({
|
|
86
|
+
name: 'simulateUtility' as const,
|
|
87
|
+
args: [call.name, call.args, call.to, options?.authWitnesses] as const,
|
|
88
|
+
})),
|
|
89
|
+
)
|
|
90
|
+
: Promise.resolve([]);
|
|
94
91
|
|
|
95
|
-
const [
|
|
96
|
-
|
|
97
|
-
|
|
92
|
+
const [utilityBatchResults, simulatedTx] = await Promise.all([
|
|
93
|
+
utilityBatchPromise,
|
|
94
|
+
indexedExecutionPayloads.length > 0
|
|
95
|
+
? this.wallet.simulateTx(executionPayload, await toSimulateOptions(options))
|
|
96
|
+
: Promise.resolve(),
|
|
98
97
|
]);
|
|
99
98
|
|
|
100
99
|
const results: any[] = [];
|
|
101
100
|
|
|
102
|
-
|
|
103
|
-
|
|
101
|
+
utilityBatchResults.forEach((wrappedResult, utilityIndex) => {
|
|
102
|
+
const [, originalIndex] = utility[utilityIndex];
|
|
103
|
+
results[originalIndex] = wrappedResult.result.result;
|
|
104
104
|
});
|
|
105
|
-
indexedExecutionPayloads.forEach(([request, callIndex, resultIndex]) => {
|
|
106
|
-
const call = request.calls[0];
|
|
107
|
-
// As account entrypoints are private, for private functions we retrieve the return values from the first nested call
|
|
108
|
-
// since we're interested in the first set of values AFTER the account entrypoint
|
|
109
|
-
// For public functions we retrieve the first values directly from the public output.
|
|
110
|
-
const rawReturnValues =
|
|
111
|
-
call.type == FunctionType.PRIVATE
|
|
112
|
-
? simulatedTx.getPrivateReturnValues()?.nested?.[resultIndex].values
|
|
113
|
-
: simulatedTx.getPublicReturnValues()?.[resultIndex].values;
|
|
114
105
|
|
|
115
|
-
|
|
116
|
-
|
|
106
|
+
if (simulatedTx) {
|
|
107
|
+
indexedExecutionPayloads.forEach(([request, callIndex, resultIndex]) => {
|
|
108
|
+
const call = request.calls[0];
|
|
109
|
+
// As account entrypoints are private, for private functions we retrieve the return values from the first nested call
|
|
110
|
+
// since we're interested in the first set of values AFTER the account entrypoint
|
|
111
|
+
// For public functions we retrieve the first values directly from the public output.
|
|
112
|
+
const rawReturnValues =
|
|
113
|
+
call.type == FunctionType.PRIVATE
|
|
114
|
+
? simulatedTx.getPrivateReturnValues()?.nested?.[resultIndex].values
|
|
115
|
+
: simulatedTx.getPublicReturnValues()?.[resultIndex].values;
|
|
116
|
+
|
|
117
|
+
results[callIndex] = rawReturnValues ? decodeFromAbi(call.returnTypes, rawReturnValues) : [];
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
|
|
117
121
|
return results;
|
|
118
122
|
}
|
|
119
123
|
|
|
120
|
-
protected async
|
|
121
|
-
return await Promise.all(this.interactions.map(i => i.request()));
|
|
124
|
+
protected async getExecutionPayloads(): Promise<ExecutionPayload[]> {
|
|
125
|
+
return await Promise.all(this.interactions.map(i => (i instanceof ExecutionPayload ? i : i.request())));
|
|
122
126
|
}
|
|
123
127
|
}
|
package/src/wallet/wallet.ts
CHANGED
|
@@ -107,7 +107,7 @@ export type SendOptions = Omit<SendInteractionOptions, 'fee'> & {
|
|
|
107
107
|
/**
|
|
108
108
|
* Helper type that represents all methods that can be batched.
|
|
109
109
|
*/
|
|
110
|
-
export type BatchableMethods = Pick<Wallet, 'registerContract' | 'sendTx' | 'registerSender'>;
|
|
110
|
+
export type BatchableMethods = Pick<Wallet, 'registerContract' | 'sendTx' | 'registerSender' | 'simulateUtility'>;
|
|
111
111
|
|
|
112
112
|
/**
|
|
113
113
|
* From the batchable methods, we create a type that represents a method call with its name and arguments.
|
|
@@ -288,6 +288,10 @@ export const BatchedMethodSchema = z.union([
|
|
|
288
288
|
name: z.literal('sendTx'),
|
|
289
289
|
args: z.tuple([ExecutionPayloadSchema, SendOptionsSchema]),
|
|
290
290
|
}),
|
|
291
|
+
z.object({
|
|
292
|
+
name: z.literal('simulateUtility'),
|
|
293
|
+
args: z.tuple([z.string(), z.array(z.any()), schemas.AztecAddress, optional(z.array(AuthWitness.schema))]),
|
|
294
|
+
}),
|
|
291
295
|
]);
|
|
292
296
|
|
|
293
297
|
export const ContractMetadataSchema = z.object({
|
|
@@ -351,6 +355,7 @@ export const WalletSchema: ApiSchemaFor<Wallet> = {
|
|
|
351
355
|
z.object({ name: z.literal('registerSender'), result: schemas.AztecAddress }),
|
|
352
356
|
z.object({ name: z.literal('registerContract'), result: ContractInstanceWithAddressSchema }),
|
|
353
357
|
z.object({ name: z.literal('sendTx'), result: TxHash.schema }),
|
|
358
|
+
z.object({ name: z.literal('simulateUtility'), result: UtilitySimulationResult.schema }),
|
|
354
359
|
]),
|
|
355
360
|
),
|
|
356
361
|
),
|