@aztec/aztec.js 0.83.1 → 0.84.0-alpha-testnet.0
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/api/deployment.d.ts +1 -1
- package/dest/api/deployment.d.ts.map +1 -1
- package/dest/api/deployment.js +1 -1
- package/dest/contract/base_contract_interaction.d.ts +1 -1
- package/dest/contract/base_contract_interaction.js +1 -1
- package/dest/contract/batch_call.d.ts +1 -1
- package/dest/contract/batch_call.js +10 -10
- package/dest/contract/contract_function_interaction.d.ts +1 -1
- package/dest/contract/contract_function_interaction.js +7 -7
- package/dest/deployment/broadcast_function.d.ts +2 -2
- package/dest/deployment/broadcast_function.d.ts.map +1 -1
- package/dest/deployment/broadcast_function.js +12 -12
- package/dest/wallet/account_wallet.js +2 -2
- package/dest/wallet/base_wallet.d.ts +1 -1
- package/dest/wallet/base_wallet.d.ts.map +1 -1
- package/dest/wallet/base_wallet.js +2 -2
- package/dest/wallet/wallet.d.ts +1 -1
- package/dest/wallet/wallet.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/api/deployment.ts +1 -1
- package/src/contract/base_contract_interaction.ts +1 -1
- package/src/contract/batch_call.ts +12 -12
- package/src/contract/contract_function_interaction.ts +7 -7
- package/src/deployment/broadcast_function.ts +13 -13
- package/src/wallet/account_wallet.ts +2 -2
- package/src/wallet/base_wallet.ts +2 -2
- package/src/wallet/wallet.ts +1 -1
package/dest/api/deployment.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { registerContractClass } from '../deployment/register_class.js';
|
|
2
|
-
export { broadcastPrivateFunction,
|
|
2
|
+
export { broadcastPrivateFunction, broadcastUtilityFunction } from '../deployment/broadcast_function.js';
|
|
3
3
|
export { deployInstance } from '../deployment/deploy_instance.js';
|
|
4
4
|
export { ContractDeployer } from '../deployment/contract_deployer.js';
|
|
5
5
|
//# sourceMappingURL=deployment.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deployment.d.ts","sourceRoot":"","sources":["../../src/api/deployment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAE,wBAAwB,EAAE,
|
|
1
|
+
{"version":3,"file":"deployment.d.ts","sourceRoot":"","sources":["../../src/api/deployment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AACzG,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC"}
|
package/dest/api/deployment.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { registerContractClass } from '../deployment/register_class.js';
|
|
2
|
-
export { broadcastPrivateFunction,
|
|
2
|
+
export { broadcastPrivateFunction, broadcastUtilityFunction } from '../deployment/broadcast_function.js';
|
|
3
3
|
export { deployInstance } from '../deployment/deploy_instance.js';
|
|
4
4
|
export { ContractDeployer } from '../deployment/contract_deployer.js';
|
|
@@ -46,7 +46,7 @@ export declare abstract class BaseContractInteraction {
|
|
|
46
46
|
prove(options?: SendMethodOptions): Promise<ProvenTx>;
|
|
47
47
|
/**
|
|
48
48
|
* Sends a transaction to the contract function with the specified options.
|
|
49
|
-
* This function throws an error if called on
|
|
49
|
+
* This function throws an error if called on a utility function.
|
|
50
50
|
* It creates and signs the transaction if necessary, and returns a SentTx instance,
|
|
51
51
|
* which can be used to track the transaction status, receipt, and events.
|
|
52
52
|
* @param options - An optional object containing 'from' property representing
|
|
@@ -42,7 +42,7 @@ import { SentTx } from './sent_tx.js';
|
|
|
42
42
|
// docs:start:send
|
|
43
43
|
/**
|
|
44
44
|
* Sends a transaction to the contract function with the specified options.
|
|
45
|
-
* This function throws an error if called on
|
|
45
|
+
* This function throws an error if called on a utility function.
|
|
46
46
|
* It creates and signs the transaction if necessary, and returns a SentTx instance,
|
|
47
47
|
* which can be used to track the transaction status, receipt, and events.
|
|
48
48
|
* @param options - An optional object containing 'from' property representing
|
|
@@ -24,7 +24,7 @@ export declare class BatchCall extends BaseContractInteraction {
|
|
|
24
24
|
* Simulate a transaction and get its return values
|
|
25
25
|
* Differs from prove in a few important ways:
|
|
26
26
|
* 1. It returns the values of the function execution
|
|
27
|
-
* 2. It supports `
|
|
27
|
+
* 2. It supports `utility`, `private` and `public` functions
|
|
28
28
|
*
|
|
29
29
|
* @param options - An optional object containing additional configuration for the transaction.
|
|
30
30
|
* @returns The result of the transaction as returned by the contract function.
|
|
@@ -36,15 +36,15 @@ import { BaseContractInteraction } from './base_contract_interaction.js';
|
|
|
36
36
|
* Simulate a transaction and get its return values
|
|
37
37
|
* Differs from prove in a few important ways:
|
|
38
38
|
* 1. It returns the values of the function execution
|
|
39
|
-
* 2. It supports `
|
|
39
|
+
* 2. It supports `utility`, `private` and `public` functions
|
|
40
40
|
*
|
|
41
41
|
* @param options - An optional object containing additional configuration for the transaction.
|
|
42
42
|
* @returns The result of the transaction as returned by the contract function.
|
|
43
43
|
*/ async simulate(options = {}) {
|
|
44
|
-
const { indexedExecutionPayloads,
|
|
44
|
+
const { indexedExecutionPayloads, utility } = (await this.getRequests()).reduce((acc, current, index)=>{
|
|
45
45
|
const call = current.calls[0];
|
|
46
|
-
if (call.type === FunctionType.
|
|
47
|
-
acc.
|
|
46
|
+
if (call.type === FunctionType.UTILITY) {
|
|
47
|
+
acc.utility.push([
|
|
48
48
|
call,
|
|
49
49
|
index
|
|
50
50
|
]);
|
|
@@ -58,7 +58,7 @@ import { BaseContractInteraction } from './base_contract_interaction.js';
|
|
|
58
58
|
return acc;
|
|
59
59
|
}, {
|
|
60
60
|
indexedExecutionPayloads: [],
|
|
61
|
-
|
|
61
|
+
utility: [],
|
|
62
62
|
publicIndex: 0,
|
|
63
63
|
privateIndex: 0
|
|
64
64
|
});
|
|
@@ -71,16 +71,16 @@ import { BaseContractInteraction } from './base_contract_interaction.js';
|
|
|
71
71
|
nonce,
|
|
72
72
|
cancellable
|
|
73
73
|
});
|
|
74
|
-
const
|
|
75
|
-
await this.wallet.
|
|
74
|
+
const utilityCalls = utility.map(async ([call, index])=>[
|
|
75
|
+
await this.wallet.simulateUtility(call.name, call.args, call.to, options?.authWitnesses, options?.from),
|
|
76
76
|
index
|
|
77
77
|
]);
|
|
78
|
-
const [
|
|
79
|
-
Promise.all(
|
|
78
|
+
const [utilityResults, simulatedTx] = await Promise.all([
|
|
79
|
+
Promise.all(utilityCalls),
|
|
80
80
|
this.wallet.simulateTx(txRequest, true, options?.from, options?.skipTxValidation)
|
|
81
81
|
]);
|
|
82
82
|
const results = [];
|
|
83
|
-
|
|
83
|
+
utilityResults.forEach(([result, index])=>{
|
|
84
84
|
results[index] = result;
|
|
85
85
|
});
|
|
86
86
|
indexedExecutionPayloads.forEach(([request, callIndex, resultIndex])=>{
|
|
@@ -34,7 +34,7 @@ export declare class ContractFunctionInteraction extends BaseContractInteraction
|
|
|
34
34
|
* Simulate a transaction and get its return values
|
|
35
35
|
* Differs from prove in a few important ways:
|
|
36
36
|
* 1. It returns the values of the function execution
|
|
37
|
-
* 2. It supports `
|
|
37
|
+
* 2. It supports `utility`, `private` and `public` functions
|
|
38
38
|
*
|
|
39
39
|
* @param options - An optional object containing additional configuration for the transaction.
|
|
40
40
|
* @returns The result of the transaction as returned by the contract function.
|
|
@@ -23,8 +23,8 @@ import { BaseContractInteraction } from './base_contract_interaction.js';
|
|
|
23
23
|
* @returns A Promise that resolves to a transaction instance.
|
|
24
24
|
*/ async create(options = {}) {
|
|
25
25
|
// docs:end:create
|
|
26
|
-
if (this.functionDao.functionType === FunctionType.
|
|
27
|
-
throw new Error("Can't call `create` on
|
|
26
|
+
if (this.functionDao.functionType === FunctionType.UTILITY) {
|
|
27
|
+
throw new Error("Can't call `create` on a utility function.");
|
|
28
28
|
}
|
|
29
29
|
const requestWithoutFee = await this.request(options);
|
|
30
30
|
const { fee: userFee, nonce, cancellable } = options;
|
|
@@ -65,14 +65,14 @@ import { BaseContractInteraction } from './base_contract_interaction.js';
|
|
|
65
65
|
* Simulate a transaction and get its return values
|
|
66
66
|
* Differs from prove in a few important ways:
|
|
67
67
|
* 1. It returns the values of the function execution
|
|
68
|
-
* 2. It supports `
|
|
68
|
+
* 2. It supports `utility`, `private` and `public` functions
|
|
69
69
|
*
|
|
70
70
|
* @param options - An optional object containing additional configuration for the transaction.
|
|
71
71
|
* @returns The result of the transaction as returned by the contract function.
|
|
72
72
|
*/ async simulate(options = {}) {
|
|
73
73
|
// docs:end:simulate
|
|
74
|
-
if (this.functionDao.functionType == FunctionType.
|
|
75
|
-
return this.wallet.
|
|
74
|
+
if (this.functionDao.functionType == FunctionType.UTILITY) {
|
|
75
|
+
return this.wallet.simulateUtility(this.functionDao.name, this.args, this.contractAddress, options.authWitnesses ?? [], options?.from);
|
|
76
76
|
}
|
|
77
77
|
const txRequest = await this.create(options);
|
|
78
78
|
const simulatedTx = await this.wallet.simulateTx(txRequest, true, options.from, options.skipTxValidation, options.skipFeeEnforcement ?? true);
|
|
@@ -100,8 +100,8 @@ import { BaseContractInteraction } from './base_contract_interaction.js';
|
|
|
100
100
|
*/ async profile(options = {
|
|
101
101
|
profileMode: 'gates'
|
|
102
102
|
}) {
|
|
103
|
-
if (this.functionDao.functionType == FunctionType.
|
|
104
|
-
throw new Error("Can't profile
|
|
103
|
+
if (this.functionDao.functionType == FunctionType.UTILITY) {
|
|
104
|
+
throw new Error("Can't profile a utility function.");
|
|
105
105
|
}
|
|
106
106
|
const { authWitnesses, capsules, fee } = options;
|
|
107
107
|
const txRequest = await this.create({
|
|
@@ -12,7 +12,7 @@ import type { Wallet } from '../wallet/index.js';
|
|
|
12
12
|
*/
|
|
13
13
|
export declare function broadcastPrivateFunction(wallet: Wallet, artifact: ContractArtifact, selector: FunctionSelector): Promise<ContractFunctionInteraction>;
|
|
14
14
|
/**
|
|
15
|
-
* Sets up a call to broadcast
|
|
15
|
+
* Sets up a call to broadcast a utility function's bytecode via the ClassRegisterer contract.
|
|
16
16
|
* Note that this is not required for users to call the function, but is rather a convenience to make
|
|
17
17
|
* this code publicly available so dapps or wallets do not need to redistribute it.
|
|
18
18
|
* @param wallet - Wallet to send the transaction.
|
|
@@ -20,5 +20,5 @@ export declare function broadcastPrivateFunction(wallet: Wallet, artifact: Contr
|
|
|
20
20
|
* @param selector - Selector of the function to be broadcast.
|
|
21
21
|
* @returns A ContractFunctionInteraction object that can be used to send the transaction.
|
|
22
22
|
*/
|
|
23
|
-
export declare function
|
|
23
|
+
export declare function broadcastUtilityFunction(wallet: Wallet, artifact: ContractArtifact, selector: FunctionSelector): Promise<ContractFunctionInteraction>;
|
|
24
24
|
//# sourceMappingURL=broadcast_function.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"broadcast_function.d.ts","sourceRoot":"","sources":["../../src/deployment/broadcast_function.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,KAAK,gBAAgB,EAAE,gBAAgB,EAAgC,MAAM,mBAAmB,CAAC;AAS1G,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,8CAA8C,CAAC;AAEhG,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD;;;;;;;;GAQG;AACH,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,gBAAgB,EAC1B,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,2BAA2B,CAAC,CAoDtC;AAED;;;;;;;;GAQG;AACH,wBAAsB,
|
|
1
|
+
{"version":3,"file":"broadcast_function.d.ts","sourceRoot":"","sources":["../../src/deployment/broadcast_function.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,KAAK,gBAAgB,EAAE,gBAAgB,EAAgC,MAAM,mBAAmB,CAAC;AAS1G,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,8CAA8C,CAAC;AAEhG,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD;;;;;;;;GAQG;AACH,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,gBAAgB,EAC1B,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,2BAA2B,CAAC,CAoDtC;AAED;;;;;;;;GAQG;AACH,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,gBAAgB,EAC1B,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,2BAA2B,CAAC,CA8CtC"}
|
|
@@ -3,7 +3,7 @@ import { padArrayEnd } from '@aztec/foundation/collection';
|
|
|
3
3
|
import { Fr } from '@aztec/foundation/fields';
|
|
4
4
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
5
5
|
import { FunctionSelector, FunctionType, bufferAsFields } from '@aztec/stdlib/abi';
|
|
6
|
-
import { computeVerificationKeyHash, createPrivateFunctionMembershipProof,
|
|
6
|
+
import { computeVerificationKeyHash, createPrivateFunctionMembershipProof, createUtilityFunctionMembershipProof, getContractClassFromArtifact } from '@aztec/stdlib/contract';
|
|
7
7
|
import { Capsule } from '@aztec/stdlib/tx';
|
|
8
8
|
import { getRegistererContract } from '../contract/protocol_contracts.js';
|
|
9
9
|
/**
|
|
@@ -25,11 +25,11 @@ import { getRegistererContract } from '../contract/protocol_contracts.js';
|
|
|
25
25
|
if (!privateFunctionArtifact) {
|
|
26
26
|
throw new Error(`Private function with selector ${selector.toString()} not found`);
|
|
27
27
|
}
|
|
28
|
-
const { artifactTreeSiblingPath, artifactTreeLeafIndex, artifactMetadataHash, functionMetadataHash,
|
|
28
|
+
const { artifactTreeSiblingPath, artifactTreeLeafIndex, artifactMetadataHash, functionMetadataHash, utilityFunctionsTreeRoot, privateFunctionTreeSiblingPath, privateFunctionTreeLeafIndex } = await createPrivateFunctionMembershipProof(selector, artifact);
|
|
29
29
|
const vkHash = await computeVerificationKeyHash(privateFunctionArtifact);
|
|
30
30
|
const registerer = await getRegistererContract(wallet);
|
|
31
31
|
const bytecode = bufferAsFields(privateFunctionArtifact.bytecode, MAX_PACKED_BYTECODE_SIZE_PER_PRIVATE_FUNCTION_IN_FIELDS);
|
|
32
|
-
return registerer.methods.broadcast_private_function(contractClass.id, artifactMetadataHash,
|
|
32
|
+
return registerer.methods.broadcast_private_function(contractClass.id, artifactMetadataHash, utilityFunctionsTreeRoot, privateFunctionTreeSiblingPath, privateFunctionTreeLeafIndex, padArrayEnd(artifactTreeSiblingPath, Fr.ZERO, ARTIFACT_FUNCTION_TREE_MAX_HEIGHT), artifactTreeLeafIndex, // eslint-disable-next-line camelcase
|
|
33
33
|
{
|
|
34
34
|
selector,
|
|
35
35
|
metadata_hash: functionMetadataHash,
|
|
@@ -41,27 +41,27 @@ import { getRegistererContract } from '../contract/protocol_contracts.js';
|
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
43
|
/**
|
|
44
|
-
* Sets up a call to broadcast
|
|
44
|
+
* Sets up a call to broadcast a utility function's bytecode via the ClassRegisterer contract.
|
|
45
45
|
* Note that this is not required for users to call the function, but is rather a convenience to make
|
|
46
46
|
* this code publicly available so dapps or wallets do not need to redistribute it.
|
|
47
47
|
* @param wallet - Wallet to send the transaction.
|
|
48
48
|
* @param artifact - Contract artifact that contains the function to be broadcast.
|
|
49
49
|
* @param selector - Selector of the function to be broadcast.
|
|
50
50
|
* @returns A ContractFunctionInteraction object that can be used to send the transaction.
|
|
51
|
-
*/ export async function
|
|
51
|
+
*/ export async function broadcastUtilityFunction(wallet, artifact, selector) {
|
|
52
52
|
const contractClass = await getContractClassFromArtifact(artifact);
|
|
53
|
-
const
|
|
54
|
-
const
|
|
53
|
+
const utilityFunctions = artifact.functions.filter((fn)=>fn.functionType === FunctionType.UTILITY);
|
|
54
|
+
const utilityFunctionsAndSelectors = await Promise.all(utilityFunctions.map(async (fn)=>({
|
|
55
55
|
f: fn,
|
|
56
56
|
selector: await FunctionSelector.fromNameAndParameters(fn.name, fn.parameters)
|
|
57
57
|
})));
|
|
58
|
-
const
|
|
59
|
-
if (!
|
|
60
|
-
throw new Error(`
|
|
58
|
+
const utilityFunctionArtifact = utilityFunctionsAndSelectors.find((fn)=>selector.equals(fn.selector))?.f;
|
|
59
|
+
if (!utilityFunctionArtifact) {
|
|
60
|
+
throw new Error(`Utility function with selector ${selector.toString()} not found`);
|
|
61
61
|
}
|
|
62
|
-
const { artifactMetadataHash, artifactTreeLeafIndex, artifactTreeSiblingPath, functionMetadataHash, privateFunctionsArtifactTreeRoot } = await
|
|
62
|
+
const { artifactMetadataHash, artifactTreeLeafIndex, artifactTreeSiblingPath, functionMetadataHash, privateFunctionsArtifactTreeRoot } = await createUtilityFunctionMembershipProof(selector, artifact);
|
|
63
63
|
const registerer = await getRegistererContract(wallet);
|
|
64
|
-
const bytecode = bufferAsFields(
|
|
64
|
+
const bytecode = bufferAsFields(utilityFunctionArtifact.bytecode, MAX_PACKED_BYTECODE_SIZE_PER_PRIVATE_FUNCTION_IN_FIELDS);
|
|
65
65
|
return registerer.methods.broadcast_unconstrained_function(contractClass.id, artifactMetadataHash, privateFunctionsArtifactTreeRoot, padArrayEnd(artifactTreeSiblingPath, Fr.ZERO, ARTIFACT_FUNCTION_TREE_MAX_HEIGHT), artifactTreeLeafIndex, // eslint-disable-next-line camelcase
|
|
66
66
|
{
|
|
67
67
|
selector,
|
|
@@ -166,7 +166,7 @@ import { BaseWallet } from './base_wallet.js';
|
|
|
166
166
|
return {
|
|
167
167
|
name: 'lookup_validity',
|
|
168
168
|
isInitializer: false,
|
|
169
|
-
functionType: FunctionType.
|
|
169
|
+
functionType: FunctionType.UTILITY,
|
|
170
170
|
isInternal: false,
|
|
171
171
|
isStatic: false,
|
|
172
172
|
parameters: [
|
|
@@ -190,7 +190,7 @@ import { BaseWallet } from './base_wallet.js';
|
|
|
190
190
|
return {
|
|
191
191
|
name: 'unconstrained_is_consumable',
|
|
192
192
|
isInitializer: false,
|
|
193
|
-
functionType: FunctionType.
|
|
193
|
+
functionType: FunctionType.UTILITY,
|
|
194
194
|
isInternal: false,
|
|
195
195
|
isStatic: false,
|
|
196
196
|
parameters: [
|
|
@@ -38,7 +38,7 @@ export declare abstract class BaseWallet implements Wallet {
|
|
|
38
38
|
simulateTx(txRequest: TxExecutionRequest, simulatePublic: boolean, msgSender?: AztecAddress, skipTxValidation?: boolean, skipFeeEnforcement?: boolean): Promise<TxSimulationResult>;
|
|
39
39
|
sendTx(tx: Tx): Promise<TxHash>;
|
|
40
40
|
getCurrentBaseFees(): Promise<GasFees>;
|
|
41
|
-
|
|
41
|
+
simulateUtility(functionName: string, args: any[], to: AztecAddress, authwits?: AuthWitness[], from?: AztecAddress | undefined): Promise<AbiDecoded>;
|
|
42
42
|
getNodeInfo(): Promise<NodeInfo>;
|
|
43
43
|
getPXEInfo(): Promise<PXEInfo>;
|
|
44
44
|
getContractClassMetadata(id: Fr, includeArtifact?: boolean): Promise<ContractClassMetadata>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base_wallet.d.ts","sourceRoot":"","sources":["../../src/wallet/base_wallet.ts"],"names":[],"mappings":";;AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACpF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,2BAA2B,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACrG,OAAO,K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AO,CAAC,qBAAqB,CAAC;IAGlG,mBAAmB,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAIrE,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;IAIhD,gBAAgB,CAAC,CAAC,EAChB,eAAe,EAAE,YAAY,EAC7B,KAAK,EAAE,uBAAuB,EAC9B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,UAAU,GAAE,YAAY,EAAwC,GAC/D,OAAO,CAAC,CAAC,EAAE,CAAC;IAGf,eAAe,CAAC,CAAC,EAAE,KAAK,EAAE,uBAAuB,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC;CAG9F"}
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
getCurrentBaseFees() {
|
|
42
42
|
return this.pxe.getCurrentBaseFees();
|
|
43
43
|
}
|
|
44
|
-
|
|
45
|
-
return this.pxe.
|
|
44
|
+
simulateUtility(functionName, args, to, authwits, from) {
|
|
45
|
+
return this.pxe.simulateUtility(functionName, args, to, authwits, from);
|
|
46
46
|
}
|
|
47
47
|
getNodeInfo() {
|
|
48
48
|
return this.pxe.getNodeInfo();
|
package/dest/wallet/wallet.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type { IntentAction, IntentInnerHash } from '../utils/authwit.js';
|
|
|
5
5
|
/**
|
|
6
6
|
* The wallet interface.
|
|
7
7
|
*/
|
|
8
|
-
export type Wallet = AccountInterface & Pick<PXE, 'simulateTx' | '
|
|
8
|
+
export type Wallet = AccountInterface & Pick<PXE, 'simulateTx' | 'simulateUtility' | 'profileTx' | 'sendTx' | 'getContractClassMetadata' | 'getContractMetadata' | 'registerContract' | 'registerContractClass' | 'proveTx' | 'getNodeInfo' | 'getPXEInfo' | 'getCurrentBaseFees' | 'updateContract' | 'registerSender' | 'getSenders' | 'removeSender' | 'getTxReceipt' | 'getPrivateEvents' | 'getPublicEvents'> & {
|
|
9
9
|
createAuthWit(intent: IntentInnerHash | IntentAction): Promise<AuthWitness>;
|
|
10
10
|
};
|
|
11
11
|
//# sourceMappingURL=wallet.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../src/wallet/wallet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAC;AAE3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEzE;;GAEG;AACH,MAAM,MAAM,MAAM,GAAG,gBAAgB,GACnC,IAAI,CACF,GAAG,EACD,YAAY,GACZ,
|
|
1
|
+
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../src/wallet/wallet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAC;AAE3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEzE;;GAEG;AACH,MAAM,MAAM,MAAM,GAAG,gBAAgB,GACnC,IAAI,CACF,GAAG,EACD,YAAY,GACZ,iBAAiB,GACjB,WAAW,GACX,QAAQ,GACR,0BAA0B,GAC1B,qBAAqB,GACrB,kBAAkB,GAClB,uBAAuB,GACvB,SAAS,GACT,aAAa,GACb,YAAY,GACZ,oBAAoB,GACpB,gBAAgB,GAChB,gBAAgB,GAChB,YAAY,GACZ,cAAc,GACd,cAAc,GACd,kBAAkB,GAClB,iBAAiB,CACpB,GAAG;IACF,aAAa,CAAC,MAAM,EAAE,eAAe,GAAG,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;CAC7E,CAAC"}
|
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": "0.
|
|
4
|
+
"version": "0.84.0-alpha-testnet.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": "./dest/index.js",
|
|
@@ -80,13 +80,13 @@
|
|
|
80
80
|
]
|
|
81
81
|
},
|
|
82
82
|
"dependencies": {
|
|
83
|
-
"@aztec/constants": "0.
|
|
84
|
-
"@aztec/entrypoints": "0.
|
|
85
|
-
"@aztec/ethereum": "0.
|
|
86
|
-
"@aztec/foundation": "0.
|
|
87
|
-
"@aztec/l1-artifacts": "0.
|
|
88
|
-
"@aztec/protocol-contracts": "0.
|
|
89
|
-
"@aztec/stdlib": "0.
|
|
83
|
+
"@aztec/constants": "0.84.0-alpha-testnet.0",
|
|
84
|
+
"@aztec/entrypoints": "0.84.0-alpha-testnet.0",
|
|
85
|
+
"@aztec/ethereum": "0.84.0-alpha-testnet.0",
|
|
86
|
+
"@aztec/foundation": "0.84.0-alpha-testnet.0",
|
|
87
|
+
"@aztec/l1-artifacts": "0.84.0-alpha-testnet.0",
|
|
88
|
+
"@aztec/protocol-contracts": "0.84.0-alpha-testnet.0",
|
|
89
|
+
"@aztec/stdlib": "0.84.0-alpha-testnet.0",
|
|
90
90
|
"axios": "^1.7.2",
|
|
91
91
|
"tslib": "^2.4.0",
|
|
92
92
|
"viem": "2.23.7"
|
package/src/api/deployment.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { registerContractClass } from '../deployment/register_class.js';
|
|
2
|
-
export { broadcastPrivateFunction,
|
|
2
|
+
export { broadcastPrivateFunction, broadcastUtilityFunction } from '../deployment/broadcast_function.js';
|
|
3
3
|
export { deployInstance } from '../deployment/deploy_instance.js';
|
|
4
4
|
export { ContractDeployer } from '../deployment/contract_deployer.js';
|
|
@@ -68,7 +68,7 @@ export abstract class BaseContractInteraction {
|
|
|
68
68
|
// docs:start:send
|
|
69
69
|
/**
|
|
70
70
|
* Sends a transaction to the contract function with the specified options.
|
|
71
|
-
* This function throws an error if called on
|
|
71
|
+
* This function throws an error if called on a utility function.
|
|
72
72
|
* It creates and signs the transaction if necessary, and returns a SentTx instance,
|
|
73
73
|
* which can be used to track the transaction status, receipt, and events.
|
|
74
74
|
* @param options - An optional object containing 'from' property representing
|
|
@@ -47,26 +47,26 @@ export class BatchCall extends BaseContractInteraction {
|
|
|
47
47
|
* Simulate a transaction and get its return values
|
|
48
48
|
* Differs from prove in a few important ways:
|
|
49
49
|
* 1. It returns the values of the function execution
|
|
50
|
-
* 2. It supports `
|
|
50
|
+
* 2. It supports `utility`, `private` and `public` functions
|
|
51
51
|
*
|
|
52
52
|
* @param options - An optional object containing additional configuration for the transaction.
|
|
53
53
|
* @returns The result of the transaction as returned by the contract function.
|
|
54
54
|
*/
|
|
55
55
|
public async simulate(options: SimulateMethodOptions = {}): Promise<any> {
|
|
56
|
-
const { indexedExecutionPayloads,
|
|
56
|
+
const { indexedExecutionPayloads, utility } = (await this.getRequests()).reduce<{
|
|
57
57
|
/** Keep track of the number of private calls to retrieve the return values */
|
|
58
58
|
privateIndex: 0;
|
|
59
59
|
/** Keep track of the number of public calls to retrieve the return values */
|
|
60
60
|
publicIndex: 0;
|
|
61
61
|
/** The public and private function execution requests in the batch */
|
|
62
62
|
indexedExecutionPayloads: [ExecutionPayload, number, number][];
|
|
63
|
-
/** The
|
|
64
|
-
|
|
63
|
+
/** The utility function calls in the batch. */
|
|
64
|
+
utility: [FunctionCall, number][];
|
|
65
65
|
}>(
|
|
66
66
|
(acc, current, index) => {
|
|
67
67
|
const call = current.calls[0];
|
|
68
|
-
if (call.type === FunctionType.
|
|
69
|
-
acc.
|
|
68
|
+
if (call.type === FunctionType.UTILITY) {
|
|
69
|
+
acc.utility.push([call, index]);
|
|
70
70
|
} else {
|
|
71
71
|
acc.indexedExecutionPayloads.push([
|
|
72
72
|
current,
|
|
@@ -76,7 +76,7 @@ export class BatchCall extends BaseContractInteraction {
|
|
|
76
76
|
}
|
|
77
77
|
return acc;
|
|
78
78
|
},
|
|
79
|
-
{ indexedExecutionPayloads: [],
|
|
79
|
+
{ indexedExecutionPayloads: [], utility: [], publicIndex: 0, privateIndex: 0 },
|
|
80
80
|
);
|
|
81
81
|
|
|
82
82
|
const payloads = indexedExecutionPayloads.map(([request]) => request);
|
|
@@ -91,22 +91,22 @@ export class BatchCall extends BaseContractInteraction {
|
|
|
91
91
|
const fee = await this.getFeeOptions(requestWithoutFee, userFee, {});
|
|
92
92
|
const txRequest = await this.wallet.createTxExecutionRequest(requestWithoutFee, fee, { nonce, cancellable });
|
|
93
93
|
|
|
94
|
-
const
|
|
94
|
+
const utilityCalls = utility.map(
|
|
95
95
|
async ([call, index]) =>
|
|
96
96
|
[
|
|
97
|
-
await this.wallet.
|
|
97
|
+
await this.wallet.simulateUtility(call.name, call.args, call.to, options?.authWitnesses, options?.from),
|
|
98
98
|
index,
|
|
99
99
|
] as const,
|
|
100
100
|
);
|
|
101
101
|
|
|
102
|
-
const [
|
|
103
|
-
Promise.all(
|
|
102
|
+
const [utilityResults, simulatedTx] = await Promise.all([
|
|
103
|
+
Promise.all(utilityCalls),
|
|
104
104
|
this.wallet.simulateTx(txRequest, true, options?.from, options?.skipTxValidation),
|
|
105
105
|
]);
|
|
106
106
|
|
|
107
107
|
const results: any[] = [];
|
|
108
108
|
|
|
109
|
-
|
|
109
|
+
utilityResults.forEach(([result, index]) => {
|
|
110
110
|
results[index] = result;
|
|
111
111
|
});
|
|
112
112
|
indexedExecutionPayloads.forEach(([request, callIndex, resultIndex]) => {
|
|
@@ -42,8 +42,8 @@ export class ContractFunctionInteraction extends BaseContractInteraction {
|
|
|
42
42
|
*/
|
|
43
43
|
public override async create(options: SendMethodOptions = {}): Promise<TxExecutionRequest> {
|
|
44
44
|
// docs:end:create
|
|
45
|
-
if (this.functionDao.functionType === FunctionType.
|
|
46
|
-
throw new Error("Can't call `create` on
|
|
45
|
+
if (this.functionDao.functionType === FunctionType.UTILITY) {
|
|
46
|
+
throw new Error("Can't call `create` on a utility function.");
|
|
47
47
|
}
|
|
48
48
|
const requestWithoutFee = await this.request(options);
|
|
49
49
|
|
|
@@ -88,15 +88,15 @@ export class ContractFunctionInteraction extends BaseContractInteraction {
|
|
|
88
88
|
* Simulate a transaction and get its return values
|
|
89
89
|
* Differs from prove in a few important ways:
|
|
90
90
|
* 1. It returns the values of the function execution
|
|
91
|
-
* 2. It supports `
|
|
91
|
+
* 2. It supports `utility`, `private` and `public` functions
|
|
92
92
|
*
|
|
93
93
|
* @param options - An optional object containing additional configuration for the transaction.
|
|
94
94
|
* @returns The result of the transaction as returned by the contract function.
|
|
95
95
|
*/
|
|
96
96
|
public async simulate(options: SimulateMethodOptions = {}): Promise<any> {
|
|
97
97
|
// docs:end:simulate
|
|
98
|
-
if (this.functionDao.functionType == FunctionType.
|
|
99
|
-
return this.wallet.
|
|
98
|
+
if (this.functionDao.functionType == FunctionType.UTILITY) {
|
|
99
|
+
return this.wallet.simulateUtility(
|
|
100
100
|
this.functionDao.name,
|
|
101
101
|
this.args,
|
|
102
102
|
this.contractAddress,
|
|
@@ -139,8 +139,8 @@ export class ContractFunctionInteraction extends BaseContractInteraction {
|
|
|
139
139
|
* @returns An object containing the function return value and profile result.
|
|
140
140
|
*/
|
|
141
141
|
public async profile(options: ProfileMethodOptions = { profileMode: 'gates' }): Promise<TxProfileResult> {
|
|
142
|
-
if (this.functionDao.functionType == FunctionType.
|
|
143
|
-
throw new Error("Can't profile
|
|
142
|
+
if (this.functionDao.functionType == FunctionType.UTILITY) {
|
|
143
|
+
throw new Error("Can't profile a utility function.");
|
|
144
144
|
}
|
|
145
145
|
const { authWitnesses, capsules, fee } = options;
|
|
146
146
|
|
|
@@ -10,7 +10,7 @@ import { type ContractArtifact, FunctionSelector, FunctionType, bufferAsFields }
|
|
|
10
10
|
import {
|
|
11
11
|
computeVerificationKeyHash,
|
|
12
12
|
createPrivateFunctionMembershipProof,
|
|
13
|
-
|
|
13
|
+
createUtilityFunctionMembershipProof,
|
|
14
14
|
getContractClassFromArtifact,
|
|
15
15
|
} from '@aztec/stdlib/contract';
|
|
16
16
|
import { Capsule } from '@aztec/stdlib/tx';
|
|
@@ -51,7 +51,7 @@ export async function broadcastPrivateFunction(
|
|
|
51
51
|
artifactTreeLeafIndex,
|
|
52
52
|
artifactMetadataHash,
|
|
53
53
|
functionMetadataHash,
|
|
54
|
-
|
|
54
|
+
utilityFunctionsTreeRoot,
|
|
55
55
|
privateFunctionTreeSiblingPath,
|
|
56
56
|
privateFunctionTreeLeafIndex,
|
|
57
57
|
} = await createPrivateFunctionMembershipProof(selector, artifact);
|
|
@@ -67,7 +67,7 @@ export async function broadcastPrivateFunction(
|
|
|
67
67
|
.broadcast_private_function(
|
|
68
68
|
contractClass.id,
|
|
69
69
|
artifactMetadataHash,
|
|
70
|
-
|
|
70
|
+
utilityFunctionsTreeRoot,
|
|
71
71
|
privateFunctionTreeSiblingPath,
|
|
72
72
|
privateFunctionTreeLeafIndex,
|
|
73
73
|
padArrayEnd(artifactTreeSiblingPath, Fr.ZERO, ARTIFACT_FUNCTION_TREE_MAX_HEIGHT),
|
|
@@ -87,7 +87,7 @@ export async function broadcastPrivateFunction(
|
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
/**
|
|
90
|
-
* Sets up a call to broadcast
|
|
90
|
+
* Sets up a call to broadcast a utility function's bytecode via the ClassRegisterer contract.
|
|
91
91
|
* Note that this is not required for users to call the function, but is rather a convenience to make
|
|
92
92
|
* this code publicly available so dapps or wallets do not need to redistribute it.
|
|
93
93
|
* @param wallet - Wallet to send the transaction.
|
|
@@ -95,22 +95,22 @@ export async function broadcastPrivateFunction(
|
|
|
95
95
|
* @param selector - Selector of the function to be broadcast.
|
|
96
96
|
* @returns A ContractFunctionInteraction object that can be used to send the transaction.
|
|
97
97
|
*/
|
|
98
|
-
export async function
|
|
98
|
+
export async function broadcastUtilityFunction(
|
|
99
99
|
wallet: Wallet,
|
|
100
100
|
artifact: ContractArtifact,
|
|
101
101
|
selector: FunctionSelector,
|
|
102
102
|
): Promise<ContractFunctionInteraction> {
|
|
103
103
|
const contractClass = await getContractClassFromArtifact(artifact);
|
|
104
|
-
const
|
|
105
|
-
const
|
|
106
|
-
|
|
104
|
+
const utilityFunctions = artifact.functions.filter(fn => fn.functionType === FunctionType.UTILITY);
|
|
105
|
+
const utilityFunctionsAndSelectors = await Promise.all(
|
|
106
|
+
utilityFunctions.map(async fn => ({
|
|
107
107
|
f: fn,
|
|
108
108
|
selector: await FunctionSelector.fromNameAndParameters(fn.name, fn.parameters),
|
|
109
109
|
})),
|
|
110
110
|
);
|
|
111
|
-
const
|
|
112
|
-
if (!
|
|
113
|
-
throw new Error(`
|
|
111
|
+
const utilityFunctionArtifact = utilityFunctionsAndSelectors.find(fn => selector.equals(fn.selector))?.f;
|
|
112
|
+
if (!utilityFunctionArtifact) {
|
|
113
|
+
throw new Error(`Utility function with selector ${selector.toString()} not found`);
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
const {
|
|
@@ -119,11 +119,11 @@ export async function broadcastUnconstrainedFunction(
|
|
|
119
119
|
artifactTreeSiblingPath,
|
|
120
120
|
functionMetadataHash,
|
|
121
121
|
privateFunctionsArtifactTreeRoot,
|
|
122
|
-
} = await
|
|
122
|
+
} = await createUtilityFunctionMembershipProof(selector, artifact);
|
|
123
123
|
|
|
124
124
|
const registerer = await getRegistererContract(wallet);
|
|
125
125
|
const bytecode = bufferAsFields(
|
|
126
|
-
|
|
126
|
+
utilityFunctionArtifact.bytecode,
|
|
127
127
|
MAX_PACKED_BYTECODE_SIZE_PER_PRIVATE_FUNCTION_IN_FIELDS,
|
|
128
128
|
);
|
|
129
129
|
return registerer.methods
|
|
@@ -208,7 +208,7 @@ export class AccountWallet extends BaseWallet {
|
|
|
208
208
|
return {
|
|
209
209
|
name: 'lookup_validity',
|
|
210
210
|
isInitializer: false,
|
|
211
|
-
functionType: FunctionType.
|
|
211
|
+
functionType: FunctionType.UTILITY,
|
|
212
212
|
isInternal: false,
|
|
213
213
|
isStatic: false,
|
|
214
214
|
parameters: [{ name: 'message_hash', type: { kind: 'field' }, visibility: 'private' as ABIParameterVisibility }],
|
|
@@ -221,7 +221,7 @@ export class AccountWallet extends BaseWallet {
|
|
|
221
221
|
return {
|
|
222
222
|
name: 'unconstrained_is_consumable',
|
|
223
223
|
isInitializer: false,
|
|
224
|
-
functionType: FunctionType.
|
|
224
|
+
functionType: FunctionType.UTILITY,
|
|
225
225
|
isInternal: false,
|
|
226
226
|
isStatic: false,
|
|
227
227
|
parameters: [
|
|
@@ -97,14 +97,14 @@ export abstract class BaseWallet implements Wallet {
|
|
|
97
97
|
getCurrentBaseFees(): Promise<GasFees> {
|
|
98
98
|
return this.pxe.getCurrentBaseFees();
|
|
99
99
|
}
|
|
100
|
-
|
|
100
|
+
simulateUtility(
|
|
101
101
|
functionName: string,
|
|
102
102
|
args: any[],
|
|
103
103
|
to: AztecAddress,
|
|
104
104
|
authwits?: AuthWitness[],
|
|
105
105
|
from?: AztecAddress | undefined,
|
|
106
106
|
): Promise<AbiDecoded> {
|
|
107
|
-
return this.pxe.
|
|
107
|
+
return this.pxe.simulateUtility(functionName, args, to, authwits, from);
|
|
108
108
|
}
|
|
109
109
|
getNodeInfo(): Promise<NodeInfo> {
|
|
110
110
|
return this.pxe.getNodeInfo();
|