@aztec/aztec.js 0.7.5 → 0.7.7
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/.tsbuildinfo +1 -1
- package/dest/abis/ecdsa_account_contract.json +30 -23
- package/dest/abis/schnorr_account_contract.json +30 -23
- package/dest/abis/schnorr_single_key_account_contract.json +30 -23
- package/dest/account/contract/ecdsa_account_contract.js +1 -1
- package/dest/account/contract/schnorr_account_contract.js +1 -1
- package/dest/account/contract/single_key_account_contract.js +1 -1
- package/dest/account/defaults/default_entrypoint.d.ts.map +1 -1
- package/dest/account/defaults/default_entrypoint.js +30 -23
- package/dest/account/defaults/entrypoint_payload.d.ts +14 -8
- package/dest/account/defaults/entrypoint_payload.d.ts.map +1 -1
- package/dest/account/defaults/entrypoint_payload.js +21 -19
- package/dest/contract/checker.js +2 -2
- package/dest/contract/checker.test.js +2 -1
- package/dest/main.js +1 -1
- package/dest/sandbox/index.d.ts +7 -0
- package/dest/sandbox/index.d.ts.map +1 -1
- package/dest/wallet/base_wallet.d.ts +1 -0
- package/dest/wallet/base_wallet.d.ts.map +1 -1
- package/dest/wallet/base_wallet.js +4 -1
- package/package.json +4 -4
- package/src/abis/ecdsa_account_contract.json +30 -23
- package/src/abis/schnorr_account_contract.json +30 -23
- package/src/abis/schnorr_single_key_account_contract.json +30 -23
- package/src/account/contract/ecdsa_account_contract.ts +1 -1
- package/src/account/contract/schnorr_account_contract.ts +1 -1
- package/src/account/contract/single_key_account_contract.ts +1 -1
- package/src/account/defaults/default_entrypoint.ts +30 -23
- package/src/account/defaults/entrypoint_payload.ts +40 -31
- package/src/contract/checker.test.ts +1 -0
- package/src/contract/checker.ts +1 -1
- package/src/wallet/base_wallet.ts +3 -0
|
@@ -3,23 +3,30 @@ import { pedersenPlookupCompressWithHashIndex } from '@aztec/circuits.js/barrete
|
|
|
3
3
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
4
4
|
import { FunctionCall, PackedArguments, emptyFunctionCall } from '@aztec/types';
|
|
5
5
|
|
|
6
|
-
import partition from 'lodash.partition';
|
|
7
|
-
|
|
8
6
|
// These must match the values defined in yarn-project/aztec-nr/aztec/src/entrypoint.nr
|
|
9
|
-
export const
|
|
10
|
-
export const ACCOUNT_MAX_PUBLIC_CALLS = 2;
|
|
7
|
+
export const ACCOUNT_MAX_CALLS = 4;
|
|
11
8
|
|
|
12
|
-
/** Encoded
|
|
13
|
-
export type
|
|
9
|
+
/** Encoded function call for account contract entrypoint */
|
|
10
|
+
export type EntrypointFunctionCall = {
|
|
11
|
+
// eslint-disable-next-line camelcase
|
|
12
|
+
/** Arguments hash for the call */
|
|
13
|
+
args_hash: Fr;
|
|
14
14
|
// eslint-disable-next-line camelcase
|
|
15
|
-
/**
|
|
16
|
-
|
|
15
|
+
/** Selector of the function to call */
|
|
16
|
+
function_selector: Fr;
|
|
17
17
|
// eslint-disable-next-line camelcase
|
|
18
|
-
/**
|
|
19
|
-
|
|
18
|
+
/** Address of the contract to call */
|
|
19
|
+
target_address: Fr;
|
|
20
|
+
// eslint-disable-next-line camelcase
|
|
21
|
+
/** Whether the function is public or private */
|
|
22
|
+
is_public: boolean;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/** Encoded payload for the account contract entrypoint */
|
|
26
|
+
export type EntrypointPayload = {
|
|
20
27
|
// eslint-disable-next-line camelcase
|
|
21
|
-
/**
|
|
22
|
-
|
|
28
|
+
/** Encoded function calls to execute */
|
|
29
|
+
function_calls: EntrypointFunctionCall[];
|
|
23
30
|
/** A nonce for replay protection */
|
|
24
31
|
nonce: Fr;
|
|
25
32
|
};
|
|
@@ -33,28 +40,27 @@ export async function buildPayload(calls: FunctionCall[]): Promise<{
|
|
|
33
40
|
}> {
|
|
34
41
|
const nonce = Fr.random();
|
|
35
42
|
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
const paddedCalls = [
|
|
39
|
-
...padArrayEnd(privateCalls, emptyFunctionCall(), ACCOUNT_MAX_PRIVATE_CALLS),
|
|
40
|
-
...padArrayEnd(publicCalls, emptyFunctionCall(), ACCOUNT_MAX_PUBLIC_CALLS),
|
|
41
|
-
];
|
|
42
|
-
|
|
43
|
-
const packedArguments = [];
|
|
44
|
-
const wasm = await CircuitsWasm.get();
|
|
45
|
-
|
|
43
|
+
const paddedCalls = padArrayEnd(calls, emptyFunctionCall(), ACCOUNT_MAX_CALLS);
|
|
44
|
+
const packedArguments: PackedArguments[] = [];
|
|
46
45
|
for (const call of paddedCalls) {
|
|
47
|
-
packedArguments.push(await PackedArguments.fromArgs(call.args
|
|
46
|
+
packedArguments.push(await PackedArguments.fromArgs(call.args));
|
|
48
47
|
}
|
|
49
48
|
|
|
49
|
+
const formattedCalls: EntrypointFunctionCall[] = paddedCalls.map((call, index) => ({
|
|
50
|
+
// eslint-disable-next-line camelcase
|
|
51
|
+
args_hash: packedArguments[index].hash,
|
|
52
|
+
// eslint-disable-next-line camelcase
|
|
53
|
+
function_selector: call.functionData.selector.toField(),
|
|
54
|
+
// eslint-disable-next-line camelcase
|
|
55
|
+
target_address: call.to.toField(),
|
|
56
|
+
// eslint-disable-next-line camelcase
|
|
57
|
+
is_public: !call.functionData.isPrivate,
|
|
58
|
+
}));
|
|
59
|
+
|
|
50
60
|
return {
|
|
51
61
|
payload: {
|
|
52
62
|
// eslint-disable-next-line camelcase
|
|
53
|
-
|
|
54
|
-
// eslint-disable-next-line camelcase
|
|
55
|
-
flattened_selectors: paddedCalls.map(call => call.functionData.selector.toField()),
|
|
56
|
-
// eslint-disable-next-line camelcase
|
|
57
|
-
flattened_targets: paddedCalls.map(call => call.to.toField()),
|
|
63
|
+
function_calls: formattedCalls,
|
|
58
64
|
nonce,
|
|
59
65
|
},
|
|
60
66
|
packedArguments,
|
|
@@ -73,9 +79,12 @@ export async function hashPayload(payload: EntrypointPayload) {
|
|
|
73
79
|
/** Flattens an entrypoint payload */
|
|
74
80
|
export function flattenPayload(payload: EntrypointPayload) {
|
|
75
81
|
return [
|
|
76
|
-
...payload.
|
|
77
|
-
|
|
78
|
-
|
|
82
|
+
...payload.function_calls.flatMap(call => [
|
|
83
|
+
call.args_hash,
|
|
84
|
+
call.function_selector,
|
|
85
|
+
call.target_address,
|
|
86
|
+
new Fr(call.is_public),
|
|
87
|
+
]),
|
|
79
88
|
payload.nonce,
|
|
80
89
|
];
|
|
81
90
|
}
|
package/src/contract/checker.ts
CHANGED
|
@@ -66,7 +66,7 @@ function abiParameterTypeChecker(type: ABIType): boolean {
|
|
|
66
66
|
case 'array':
|
|
67
67
|
return checkAttributes(type, { length: 'number', type: 'object' }) && abiParameterTypeChecker(type.type);
|
|
68
68
|
case 'struct':
|
|
69
|
-
return checkAttributes(type, { fields: 'object' }) && checkStruct(type);
|
|
69
|
+
return checkAttributes(type, { fields: 'object', path: 'string' }) && checkStruct(type);
|
|
70
70
|
default:
|
|
71
71
|
throw new Error('ABI function parameter has an unrecognised type');
|
|
72
72
|
}
|
|
@@ -70,6 +70,9 @@ export abstract class BaseWallet implements Wallet {
|
|
|
70
70
|
getPublicStorageAt(contract: AztecAddress, storageSlot: Fr): Promise<any> {
|
|
71
71
|
return this.rpc.getPublicStorageAt(contract, storageSlot);
|
|
72
72
|
}
|
|
73
|
+
getNoteNonces(contract: AztecAddress, storageSlot: Fr, preimage: NotePreimage, txHash: TxHash): Promise<Fr[]> {
|
|
74
|
+
return this.rpc.getNoteNonces(contract, storageSlot, preimage, txHash);
|
|
75
|
+
}
|
|
73
76
|
viewTx(functionName: string, args: any[], to: AztecAddress, from?: AztecAddress | undefined): Promise<any> {
|
|
74
77
|
return this.rpc.viewTx(functionName, args, to, from);
|
|
75
78
|
}
|