@aztec/aztec.js 0.1.0-alpha26 → 0.1.0-alpha29
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/README.md +2 -2
- package/dest/abis/ecdsa_account_contract.json +53 -50
- package/dest/abis/schnorr_single_key_account_contract.json +5 -3
- package/dest/account_impl/account_collection.d.ts +0 -6
- package/dest/account_impl/account_collection.d.ts.map +1 -1
- package/dest/account_impl/account_collection.js +1 -7
- package/dest/account_impl/entrypoint_payload.d.ts.map +1 -1
- package/dest/account_impl/entrypoint_payload.js +4 -3
- package/dest/account_impl/index.d.ts +10 -1
- package/dest/account_impl/index.d.ts.map +1 -1
- package/dest/account_impl/single_key_account_contract.d.ts +2 -3
- package/dest/account_impl/single_key_account_contract.d.ts.map +1 -1
- package/dest/account_impl/single_key_account_contract.js +5 -6
- package/dest/account_impl/stored_key_account_contract.d.ts +2 -3
- package/dest/account_impl/stored_key_account_contract.d.ts.map +1 -1
- package/dest/account_impl/stored_key_account_contract.js +3 -4
- package/dest/aztec_rpc_client/aztec_rpc_client.d.ts +2 -1
- package/dest/aztec_rpc_client/aztec_rpc_client.d.ts.map +1 -1
- package/dest/aztec_rpc_client/aztec_rpc_client.js +5 -3
- package/dest/aztec_rpc_client/wallet.d.ts +7 -7
- package/dest/aztec_rpc_client/wallet.d.ts.map +1 -1
- package/dest/aztec_rpc_client/wallet.js +8 -5
- package/dest/contract/contract.d.ts +8 -54
- package/dest/contract/contract.d.ts.map +1 -1
- package/dest/contract/contract.js +13 -53
- package/dest/contract/contract.test.js +12 -8
- package/dest/contract/contract_base.d.ts +64 -0
- package/dest/contract/contract_base.d.ts.map +1 -0
- package/dest/contract/contract_base.js +60 -0
- package/dest/contract/contract_function_interaction.d.ts +7 -0
- package/dest/contract/contract_function_interaction.d.ts.map +1 -1
- package/dest/contract/contract_function_interaction.js +15 -4
- package/dest/contract/index.d.ts +1 -0
- package/dest/contract/index.d.ts.map +1 -1
- package/dest/contract/index.js +2 -1
- package/dest/contract/sent_tx.d.ts +19 -5
- package/dest/contract/sent_tx.d.ts.map +1 -1
- package/dest/contract/sent_tx.js +24 -7
- package/dest/contract_deployer/contract_deployer.d.ts +2 -1
- package/dest/contract_deployer/contract_deployer.d.ts.map +1 -1
- package/dest/contract_deployer/contract_deployer.js +2 -2
- package/dest/contract_deployer/contract_deployer.test.js +3 -3
- package/dest/contract_deployer/deploy_method.d.ts +7 -5
- package/dest/contract_deployer/deploy_method.d.ts.map +1 -1
- package/dest/contract_deployer/deploy_method.js +8 -5
- package/dest/contract_deployer/deploy_sent_tx.d.ts +35 -0
- package/dest/contract_deployer/deploy_sent_tx.d.ts.map +1 -0
- package/dest/contract_deployer/deploy_sent_tx.js +39 -0
- package/dest/index.d.ts +2 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +3 -1
- package/dest/main.js +2 -0
- package/dest/main.js.LICENSE.txt +12 -0
- package/dest/utils/account.d.ts +3 -4
- package/dest/utils/account.d.ts.map +1 -1
- package/dest/utils/account.js +4 -5
- package/dest/utils/pub_key.d.ts +2 -3
- package/dest/utils/pub_key.d.ts.map +1 -1
- package/dest/utils/pub_key.js +2 -3
- package/package.json +8 -5
- package/package.local.json +5 -0
- package/src/abis/ecdsa_account_contract.json +53 -50
- package/src/abis/schnorr_single_key_account_contract.json +5 -3
- package/src/account_impl/account_collection.ts +0 -6
- package/src/account_impl/entrypoint_payload.ts +3 -2
- package/src/account_impl/index.ts +11 -1
- package/src/account_impl/single_key_account_contract.ts +12 -6
- package/src/account_impl/stored_key_account_contract.ts +4 -5
- package/src/aztec_rpc_client/aztec_rpc_client.ts +5 -2
- package/src/aztec_rpc_client/wallet.ts +11 -8
- package/src/contract/contract.test.ts +12 -9
- package/src/contract/contract.ts +13 -66
- package/src/contract/contract_base.ts +77 -0
- package/src/contract/contract_function_interaction.ts +17 -9
- package/src/contract/index.ts +1 -0
- package/src/contract/sent_tx.ts +37 -8
- package/src/contract_deployer/contract_deployer.test.ts +2 -2
- package/src/contract_deployer/contract_deployer.ts +1 -1
- package/src/contract_deployer/deploy_method.ts +10 -8
- package/src/contract_deployer/deploy_sent_tx.ts +55 -0
- package/src/index.ts +21 -1
- package/src/utils/account.ts +5 -6
- package/src/utils/pub_key.ts +3 -4
- package/tsconfig.dest.json +15 -0
- package/webpack.config.js +74 -0
- package/dest/abis/schnorr_account_contract.json +0 -96
- package/src/abis/schnorr_account_contract.json +0 -96
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* The buffer module from node.js, for the browser.
|
|
3
|
+
*
|
|
4
|
+
* @author Feross Aboukhadijeh <https://feross.org>
|
|
5
|
+
* @license MIT
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
9
|
+
|
|
10
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
11
|
+
|
|
12
|
+
/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
package/dest/utils/account.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import { Fr } from '@aztec/circuits.js';
|
|
1
|
+
import { Fr, PrivateKey } from '@aztec/circuits.js';
|
|
3
2
|
import { ContractAbi } from '@aztec/foundation/abi';
|
|
4
3
|
import { AztecRPC } from '@aztec/types';
|
|
5
4
|
import { AccountWallet, Wallet } from '../aztec_rpc_client/wallet.js';
|
|
@@ -7,12 +6,12 @@ import { AccountWallet, Wallet } from '../aztec_rpc_client/wallet.js';
|
|
|
7
6
|
* Creates an Aztec Account.
|
|
8
7
|
* @returns The account's address & public key.
|
|
9
8
|
*/
|
|
10
|
-
export declare function createAccounts(aztecRpcClient: AztecRPC, accountContractAbi: ContractAbi, privateKey?:
|
|
9
|
+
export declare function createAccounts(aztecRpcClient: AztecRPC, accountContractAbi: ContractAbi, privateKey?: PrivateKey, salt?: Fr, numberOfAccounts?: number, logger?: import("@aztec/foundation/log").DebugLogger): Promise<Wallet>;
|
|
11
10
|
/**
|
|
12
11
|
* Gets the Aztec accounts that are stored in an Aztec RPC instance.
|
|
13
12
|
* @param aztecRpcClient - An instance of the Aztec RPC interface.
|
|
14
13
|
* @param numberOfAccounts - The number of accounts to fetch.
|
|
15
14
|
* @returns An AccountWallet implementation that includes all the accounts found.
|
|
16
15
|
*/
|
|
17
|
-
export declare function getAccountWallet(aztecRpcClient: AztecRPC, accountContractAbi: ContractAbi, privateKey:
|
|
16
|
+
export declare function getAccountWallet(aztecRpcClient: AztecRPC, accountContractAbi: ContractAbi, privateKey: PrivateKey, salt: Fr): Promise<AccountWallet>;
|
|
18
17
|
//# sourceMappingURL=account.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../../src/utils/account.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../../src/utils/account.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,UAAU,EAA6B,MAAM,oBAAoB,CAAC;AAE/E,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,EAAE,QAAQ,EAAY,MAAM,cAAc,CAAC;AAElD,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AAGtE;;;GAGG;AACH,wBAAsB,cAAc,CAClC,cAAc,EAAE,QAAQ,EACxB,kBAAkB,EAAE,WAAW,EAC/B,UAAU,CAAC,EAAE,UAAU,EACvB,IAAI,KAAc,EAClB,gBAAgB,SAAI,EACpB,MAAM,8CAA+C,GACpD,OAAO,CAAC,MAAM,CAAC,CA6BjB;AAED;;;;;GAKG;AACH,wBAAsB,gBAAgB,CACpC,cAAc,EAAE,QAAQ,EACxB,kBAAkB,EAAE,WAAW,EAC/B,UAAU,EAAE,UAAU,EACtB,IAAI,EAAE,EAAE,0BAYT"}
|
package/dest/utils/account.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { Fr, getContractDeploymentInfo } from '@aztec/circuits.js';
|
|
1
|
+
import { Fr, PrivateKey, getContractDeploymentInfo } from '@aztec/circuits.js';
|
|
2
2
|
import { Schnorr } from '@aztec/circuits.js/barretenberg';
|
|
3
|
-
import { randomBytes } from '@aztec/foundation/crypto';
|
|
4
3
|
import { createDebugLogger } from '@aztec/foundation/log';
|
|
5
4
|
import { TxStatus } from '@aztec/types';
|
|
6
5
|
import { AccountWallet } from '../aztec_rpc_client/wallet.js';
|
|
@@ -13,13 +12,13 @@ export async function createAccounts(aztecRpcClient, accountContractAbi, private
|
|
|
13
12
|
const accountImpls = new AccountCollection();
|
|
14
13
|
for (let i = 0; i < numberOfAccounts; ++i) {
|
|
15
14
|
// TODO(#662): Let the aztec rpc server generate the keypair rather than hardcoding the private key
|
|
16
|
-
const privKey = i == 0 && privateKey ? privateKey :
|
|
15
|
+
const privKey = i == 0 && privateKey ? privateKey : PrivateKey.random();
|
|
17
16
|
const publicKey = await generatePublicKey(privKey);
|
|
18
17
|
const deploymentInfo = await getContractDeploymentInfo(accountContractAbi, [], salt, publicKey);
|
|
19
18
|
await aztecRpcClient.addAccount(privKey, deploymentInfo.address, deploymentInfo.partialAddress);
|
|
20
19
|
const contractDeployer = new ContractDeployer(accountContractAbi, aztecRpcClient, publicKey);
|
|
21
20
|
const tx = contractDeployer.deploy().send({ contractAddressSalt: salt });
|
|
22
|
-
await tx.isMined(
|
|
21
|
+
await tx.isMined({ interval: 0.5 });
|
|
23
22
|
const receipt = await tx.getReceipt();
|
|
24
23
|
if (receipt.status !== TxStatus.MINED) {
|
|
25
24
|
throw new Error(`Deployment tx not mined (status is ${receipt.status})`);
|
|
@@ -47,4 +46,4 @@ export async function getAccountWallet(aztecRpcClient, accountContractAbi, priva
|
|
|
47
46
|
accountCollection.registerAccount(address, new SingleKeyAccountContract(address, deploymentInfo.partialAddress, privateKey, await Schnorr.new()));
|
|
48
47
|
return new AccountWallet(aztecRpcClient, accountCollection);
|
|
49
48
|
}
|
|
50
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
49
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYWNjb3VudC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlscy9hY2NvdW50LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxFQUFFLEVBQUUsVUFBVSxFQUFFLHlCQUF5QixFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFDL0UsT0FBTyxFQUFFLE9BQU8sRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBRTFELE9BQU8sRUFBRSxpQkFBaUIsRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBQzFELE9BQU8sRUFBWSxRQUFRLEVBQUUsTUFBTSxjQUFjLENBQUM7QUFFbEQsT0FBTyxFQUFFLGFBQWEsRUFBVSxNQUFNLCtCQUErQixDQUFDO0FBQ3RFLE9BQU8sRUFBRSxpQkFBaUIsRUFBRSxnQkFBZ0IsRUFBRSx3QkFBd0IsRUFBRSxpQkFBaUIsRUFBRSxNQUFNLGFBQWEsQ0FBQztBQUUvRzs7O0dBR0c7QUFDSCxNQUFNLENBQUMsS0FBSyxVQUFVLGNBQWMsQ0FDbEMsY0FBd0IsRUFDeEIsa0JBQStCLEVBQy9CLFVBQXVCLEVBQ3ZCLElBQUksR0FBRyxFQUFFLENBQUMsTUFBTSxFQUFFLEVBQ2xCLGdCQUFnQixHQUFHLENBQUMsRUFDcEIsTUFBTSxHQUFHLGlCQUFpQixDQUFDLHlCQUF5QixDQUFDO0lBRXJELE1BQU0sWUFBWSxHQUFHLElBQUksaUJBQWlCLEVBQUUsQ0FBQztJQUU3QyxLQUFLLElBQUksQ0FBQyxHQUFHLENBQUMsRUFBRSxDQUFDLEdBQUcsZ0JBQWdCLEVBQUUsRUFBRSxDQUFDLEVBQUU7UUFDekMsbUdBQW1HO1FBQ25HLE1BQU0sT0FBTyxHQUFHLENBQUMsSUFBSSxDQUFDLElBQUksVUFBVSxDQUFDLENBQUMsQ0FBQyxVQUFVLENBQUMsQ0FBQyxDQUFDLFVBQVUsQ0FBQyxNQUFNLEVBQUUsQ0FBQztRQUN4RSxNQUFNLFNBQVMsR0FBRyxNQUFNLGlCQUFpQixDQUFDLE9BQU8sQ0FBQyxDQUFDO1FBQ25E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
|
package/dest/utils/pub_key.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
import { Point } from '../index.js';
|
|
1
|
+
import { PrivateKey, PublicKey } from '@aztec/circuits.js';
|
|
3
2
|
/**
|
|
4
3
|
* Method for generating a public grumpkin key from a private key.
|
|
5
4
|
* @param privateKey - The private key.
|
|
6
5
|
* @returns The generated public key.
|
|
7
6
|
*/
|
|
8
|
-
export declare function generatePublicKey(privateKey:
|
|
7
|
+
export declare function generatePublicKey(privateKey: PrivateKey): Promise<PublicKey>;
|
|
9
8
|
//# sourceMappingURL=pub_key.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pub_key.d.ts","sourceRoot":"","sources":["../../src/utils/pub_key.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pub_key.d.ts","sourceRoot":"","sources":["../../src/utils/pub_key.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAG3D;;;;GAIG;AACH,wBAAsB,iBAAiB,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC,CAGlF"}
|
package/dest/utils/pub_key.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Grumpkin } from '@aztec/circuits.js/barretenberg';
|
|
2
|
-
import { Point } from '../index.js';
|
|
3
2
|
/**
|
|
4
3
|
* Method for generating a public grumpkin key from a private key.
|
|
5
4
|
* @param privateKey - The private key.
|
|
@@ -7,6 +6,6 @@ import { Point } from '../index.js';
|
|
|
7
6
|
*/
|
|
8
7
|
export async function generatePublicKey(privateKey) {
|
|
9
8
|
const grumpkin = await Grumpkin.new();
|
|
10
|
-
return
|
|
9
|
+
return grumpkin.mul(grumpkin.generator(), privateKey);
|
|
11
10
|
}
|
|
12
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
11
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHViX2tleS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlscy9wdWJfa2V5LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sRUFBRSxRQUFRLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUUzRDs7OztHQUlHO0FBQ0gsTUFBTSxDQUFDLEtBQUssVUFBVSxpQkFBaUIsQ0FBQyxVQUFzQjtJQUM1RCxNQUFNLFFBQVEsR0FBRyxNQUFNLFFBQVEsQ0FBQyxHQUFHLEVBQUUsQ0FBQztJQUN0QyxPQUFPLFFBQVEsQ0FBQyxHQUFHLENBQUMsUUFBUSxDQUFDLFNBQVMsRUFBRSxFQUFFLFVBQVUsQ0FBQyxDQUFDO0FBQ3hELENBQUMifQ==
|
package/package.json
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/aztec.js",
|
|
3
|
-
"version": "0.1.0-
|
|
4
|
-
"exports":
|
|
3
|
+
"version": "0.1.0-alpha29",
|
|
4
|
+
"exports": {
|
|
5
|
+
"node": "./dest/index.js",
|
|
6
|
+
"default": "./dest/main.js"
|
|
7
|
+
},
|
|
5
8
|
"type": "module",
|
|
6
9
|
"dependencies": {
|
|
7
|
-
"@aztec/circuits.js": "0.1.0-
|
|
8
|
-
"@aztec/foundation": "0.1.0-
|
|
9
|
-
"@aztec/types": "0.1.0-
|
|
10
|
+
"@aztec/circuits.js": "0.1.0-alpha29",
|
|
11
|
+
"@aztec/foundation": "0.1.0-alpha29",
|
|
12
|
+
"@aztec/types": "0.1.0-alpha29",
|
|
10
13
|
"lodash.partition": "^4.6.0",
|
|
11
14
|
"tslib": "^2.4.0"
|
|
12
15
|
}
|
|
@@ -1,9 +1,58 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "EcdsaAccount",
|
|
3
3
|
"functions": [
|
|
4
|
+
{
|
|
5
|
+
"name": "compute_note_hash_and_nullifier",
|
|
6
|
+
"functionType": "unconstrained",
|
|
7
|
+
"isInternal": false,
|
|
8
|
+
"parameters": [
|
|
9
|
+
{
|
|
10
|
+
"name": "contract_address",
|
|
11
|
+
"type": {
|
|
12
|
+
"kind": "field"
|
|
13
|
+
},
|
|
14
|
+
"visibility": "private"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"name": "nonce",
|
|
18
|
+
"type": {
|
|
19
|
+
"kind": "field"
|
|
20
|
+
},
|
|
21
|
+
"visibility": "private"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"name": "storage_slot",
|
|
25
|
+
"type": {
|
|
26
|
+
"kind": "field"
|
|
27
|
+
},
|
|
28
|
+
"visibility": "private"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"name": "preimage",
|
|
32
|
+
"type": {
|
|
33
|
+
"kind": "array",
|
|
34
|
+
"length": 5,
|
|
35
|
+
"type": {
|
|
36
|
+
"kind": "field"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"visibility": "private"
|
|
40
|
+
}
|
|
41
|
+
],
|
|
42
|
+
"returnTypes": [
|
|
43
|
+
{
|
|
44
|
+
"kind": "array",
|
|
45
|
+
"length": 4,
|
|
46
|
+
"type": {
|
|
47
|
+
"kind": "field"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
]
|
|
51
|
+
},
|
|
4
52
|
{
|
|
5
53
|
"name": "constructor",
|
|
6
54
|
"functionType": "secret",
|
|
55
|
+
"isInternal": false,
|
|
7
56
|
"parameters": [
|
|
8
57
|
{
|
|
9
58
|
"name": "signing_pub_key_x",
|
|
@@ -37,6 +86,7 @@
|
|
|
37
86
|
{
|
|
38
87
|
"name": "entrypoint",
|
|
39
88
|
"functionType": "secret",
|
|
89
|
+
"isInternal": false,
|
|
40
90
|
"parameters": [
|
|
41
91
|
{
|
|
42
92
|
"name": "payload",
|
|
@@ -47,7 +97,7 @@
|
|
|
47
97
|
"name": "flattened_args_hashes",
|
|
48
98
|
"type": {
|
|
49
99
|
"kind": "array",
|
|
50
|
-
"length":
|
|
100
|
+
"length": 4,
|
|
51
101
|
"type": {
|
|
52
102
|
"kind": "field"
|
|
53
103
|
}
|
|
@@ -57,7 +107,7 @@
|
|
|
57
107
|
"name": "flattened_selectors",
|
|
58
108
|
"type": {
|
|
59
109
|
"kind": "array",
|
|
60
|
-
"length":
|
|
110
|
+
"length": 4,
|
|
61
111
|
"type": {
|
|
62
112
|
"kind": "field"
|
|
63
113
|
}
|
|
@@ -67,7 +117,7 @@
|
|
|
67
117
|
"name": "flattened_targets",
|
|
68
118
|
"type": {
|
|
69
119
|
"kind": "array",
|
|
70
|
-
"length":
|
|
120
|
+
"length": 4,
|
|
71
121
|
"type": {
|
|
72
122
|
"kind": "field"
|
|
73
123
|
}
|
|
@@ -98,53 +148,6 @@
|
|
|
98
148
|
}
|
|
99
149
|
],
|
|
100
150
|
"returnTypes": []
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
"name": "stev",
|
|
104
|
-
"functionType": "unconstrained",
|
|
105
|
-
"parameters": [
|
|
106
|
-
{
|
|
107
|
-
"name": "contract_address",
|
|
108
|
-
"type": {
|
|
109
|
-
"kind": "field"
|
|
110
|
-
},
|
|
111
|
-
"visibility": "private"
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
"name": "nonce",
|
|
115
|
-
"type": {
|
|
116
|
-
"kind": "field"
|
|
117
|
-
},
|
|
118
|
-
"visibility": "private"
|
|
119
|
-
},
|
|
120
|
-
{
|
|
121
|
-
"name": "storage_slot",
|
|
122
|
-
"type": {
|
|
123
|
-
"kind": "field"
|
|
124
|
-
},
|
|
125
|
-
"visibility": "private"
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
"name": "preimage",
|
|
129
|
-
"type": {
|
|
130
|
-
"kind": "array",
|
|
131
|
-
"length": 5,
|
|
132
|
-
"type": {
|
|
133
|
-
"kind": "field"
|
|
134
|
-
}
|
|
135
|
-
},
|
|
136
|
-
"visibility": "private"
|
|
137
|
-
}
|
|
138
|
-
],
|
|
139
|
-
"returnTypes": [
|
|
140
|
-
{
|
|
141
|
-
"kind": "array",
|
|
142
|
-
"length": 4,
|
|
143
|
-
"type": {
|
|
144
|
-
"kind": "field"
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
]
|
|
148
151
|
}
|
|
149
152
|
]
|
|
150
153
|
}
|
|
@@ -4,12 +4,14 @@
|
|
|
4
4
|
{
|
|
5
5
|
"name": "constructor",
|
|
6
6
|
"functionType": "secret",
|
|
7
|
+
"isInternal": false,
|
|
7
8
|
"parameters": [],
|
|
8
9
|
"returnTypes": []
|
|
9
10
|
},
|
|
10
11
|
{
|
|
11
12
|
"name": "entrypoint",
|
|
12
13
|
"functionType": "secret",
|
|
14
|
+
"isInternal": false,
|
|
13
15
|
"parameters": [
|
|
14
16
|
{
|
|
15
17
|
"name": "payload",
|
|
@@ -20,7 +22,7 @@
|
|
|
20
22
|
"name": "flattened_args_hashes",
|
|
21
23
|
"type": {
|
|
22
24
|
"kind": "array",
|
|
23
|
-
"length":
|
|
25
|
+
"length": 4,
|
|
24
26
|
"type": {
|
|
25
27
|
"kind": "field"
|
|
26
28
|
}
|
|
@@ -30,7 +32,7 @@
|
|
|
30
32
|
"name": "flattened_selectors",
|
|
31
33
|
"type": {
|
|
32
34
|
"kind": "array",
|
|
33
|
-
"length":
|
|
35
|
+
"length": 4,
|
|
34
36
|
"type": {
|
|
35
37
|
"kind": "field"
|
|
36
38
|
}
|
|
@@ -40,7 +42,7 @@
|
|
|
40
42
|
"name": "flattened_targets",
|
|
41
43
|
"type": {
|
|
42
44
|
"kind": "array",
|
|
43
|
-
"length":
|
|
45
|
+
"length": 4,
|
|
44
46
|
"type": {
|
|
45
47
|
"kind": "field"
|
|
46
48
|
}
|
|
@@ -23,12 +23,6 @@ export class AccountCollection implements AccountImplementation {
|
|
|
23
23
|
return AztecAddress.fromString(this.accounts.keys().next().value as string);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
/**
|
|
27
|
-
* Uses a registered account implementation to generate an authenticated request
|
|
28
|
-
* @param executions - The execution intent to be authenticated.
|
|
29
|
-
* @param txContext - The tx context under with the execution is to be made.
|
|
30
|
-
* @returns - The authenticated transaction execution request.
|
|
31
|
-
*/
|
|
32
26
|
public createAuthenticatedTxRequest(
|
|
33
27
|
executions: ExecutionRequest[],
|
|
34
28
|
txContext: TxContext,
|
|
@@ -3,8 +3,9 @@ import { padArrayEnd } from '@aztec/foundation/collection';
|
|
|
3
3
|
import { sha256 } from '@aztec/foundation/crypto';
|
|
4
4
|
import { ExecutionRequest, PackedArguments, emptyExecutionRequest } from '@aztec/types';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
const
|
|
6
|
+
// These must match the values defined in yarn-project/noir-libs/noir-aztec/src/entrypoint.nr
|
|
7
|
+
const ACCOUNT_MAX_PRIVATE_CALLS = 2;
|
|
8
|
+
const ACCOUNT_MAX_PUBLIC_CALLS = 2;
|
|
8
9
|
|
|
9
10
|
/** Encoded payload for the account contract entrypoint */
|
|
10
11
|
export type EntrypointPayload = {
|
|
@@ -7,7 +7,17 @@ export * from './account_collection.js';
|
|
|
7
7
|
|
|
8
8
|
/** Represents an implementation for a user account contract. Knows how to encode and sign a tx for that particular implementation. */
|
|
9
9
|
export interface AccountImplementation {
|
|
10
|
+
/**
|
|
11
|
+
* Returns the address for the account contract used by this implementation.
|
|
12
|
+
* @returns The address.
|
|
13
|
+
*/
|
|
10
14
|
getAddress(): AztecAddress;
|
|
11
|
-
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Generates an authenticated request out of set of intents
|
|
18
|
+
* @param executions - The execution intent to be authenticated.
|
|
19
|
+
* @param txContext - The tx context under with the execution is to be made.
|
|
20
|
+
* @returns The authenticated transaction execution request.
|
|
21
|
+
*/
|
|
12
22
|
createAuthenticatedTxRequest(executions: ExecutionRequest[], txContext: TxContext): Promise<TxExecutionRequest>;
|
|
13
23
|
}
|
|
@@ -1,11 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
AztecAddress,
|
|
3
|
+
CircuitsWasm,
|
|
4
|
+
FunctionData,
|
|
5
|
+
PartialContractAddress,
|
|
6
|
+
PrivateKey,
|
|
7
|
+
TxContext,
|
|
8
|
+
} from '@aztec/circuits.js';
|
|
2
9
|
import { Signer } from '@aztec/circuits.js/barretenberg';
|
|
3
|
-
import { ContractAbi, encodeArguments
|
|
10
|
+
import { ContractAbi, encodeArguments } from '@aztec/foundation/abi';
|
|
4
11
|
import { ExecutionRequest, PackedArguments, TxExecutionRequest } from '@aztec/types';
|
|
5
12
|
|
|
6
13
|
import partition from 'lodash.partition';
|
|
7
14
|
|
|
8
|
-
import SchnorrSingleKeyAccountContractAbi from '../abis/
|
|
15
|
+
import SchnorrSingleKeyAccountContractAbi from '../abis/schnorr_single_key_account_contract.json' assert { type: 'json' };
|
|
9
16
|
import { generatePublicKey } from '../index.js';
|
|
10
17
|
import { buildPayload, hashPayload } from './entrypoint_payload.js';
|
|
11
18
|
import { AccountImplementation } from './index.js';
|
|
@@ -19,7 +26,7 @@ export class SingleKeyAccountContract implements AccountImplementation {
|
|
|
19
26
|
constructor(
|
|
20
27
|
private address: AztecAddress,
|
|
21
28
|
private partialContractAddress: PartialContractAddress,
|
|
22
|
-
private privateKey:
|
|
29
|
+
private privateKey: PrivateKey,
|
|
23
30
|
private signer: Signer,
|
|
24
31
|
) {}
|
|
25
32
|
|
|
@@ -43,12 +50,11 @@ export class SingleKeyAccountContract implements AccountImplementation {
|
|
|
43
50
|
const publicKey = await generatePublicKey(this.privateKey);
|
|
44
51
|
const args = [payload, publicKey.toBuffer(), signature, this.partialContractAddress];
|
|
45
52
|
const abi = this.getEntrypointAbi();
|
|
46
|
-
const selector = generateFunctionSelector(abi.name, abi.parameters);
|
|
47
53
|
const packedArgs = await PackedArguments.fromArgs(encodeArguments(abi, args), wasm);
|
|
48
54
|
const txRequest = TxExecutionRequest.from({
|
|
49
55
|
argsHash: packedArgs.hash,
|
|
50
56
|
origin: this.address,
|
|
51
|
-
functionData:
|
|
57
|
+
functionData: FunctionData.fromAbi(abi),
|
|
52
58
|
txContext,
|
|
53
59
|
packedArguments: [...callsPackedArguments, packedArgs],
|
|
54
60
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { AztecAddress, CircuitsWasm, FunctionData, TxContext } from '@aztec/circuits.js';
|
|
1
|
+
import { AztecAddress, CircuitsWasm, FunctionData, PrivateKey, TxContext } from '@aztec/circuits.js';
|
|
2
2
|
import { Signer } from '@aztec/circuits.js/barretenberg';
|
|
3
|
-
import { ContractAbi, encodeArguments
|
|
3
|
+
import { ContractAbi, encodeArguments } from '@aztec/foundation/abi';
|
|
4
4
|
import { DebugLogger, createDebugLogger } from '@aztec/foundation/log';
|
|
5
5
|
import { ExecutionRequest, PackedArguments, TxExecutionRequest } from '@aztec/types';
|
|
6
6
|
|
|
@@ -17,7 +17,7 @@ import { AccountImplementation } from './index.js';
|
|
|
17
17
|
export class StoredKeyAccountContract implements AccountImplementation {
|
|
18
18
|
private log: DebugLogger;
|
|
19
19
|
|
|
20
|
-
constructor(private address: AztecAddress, private privateKey:
|
|
20
|
+
constructor(private address: AztecAddress, private privateKey: PrivateKey, private signer: Signer) {
|
|
21
21
|
this.log = createDebugLogger('aztec:client:accounts:stored_key');
|
|
22
22
|
}
|
|
23
23
|
|
|
@@ -41,12 +41,11 @@ export class StoredKeyAccountContract implements AccountImplementation {
|
|
|
41
41
|
|
|
42
42
|
const args = [payload, signature];
|
|
43
43
|
const abi = this.getEntrypointAbi();
|
|
44
|
-
const selector = generateFunctionSelector(abi.name, abi.parameters);
|
|
45
44
|
const packedArgs = await PackedArguments.fromArgs(encodeArguments(abi, args), wasm);
|
|
46
45
|
const txRequest = TxExecutionRequest.from({
|
|
47
46
|
argsHash: packedArgs.hash,
|
|
48
47
|
origin: this.address,
|
|
49
|
-
functionData:
|
|
48
|
+
functionData: FunctionData.fromAbi(abi),
|
|
50
49
|
txContext,
|
|
51
50
|
packedArguments: [...callsPackedArguments, packedArgs],
|
|
52
51
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AztecAddress, EthAddress, Fr, Point } from '@aztec/circuits.js';
|
|
2
|
-
import { createJsonRpcClient, defaultFetch } from '@aztec/foundation/json-rpc';
|
|
1
|
+
import { AztecAddress, EthAddress, Fr, Point, PrivateKey } from '@aztec/circuits.js';
|
|
2
|
+
import { createJsonRpcClient, defaultFetch } from '@aztec/foundation/json-rpc/client';
|
|
3
3
|
import {
|
|
4
4
|
AztecRPC,
|
|
5
5
|
ContractData,
|
|
@@ -11,6 +11,8 @@ import {
|
|
|
11
11
|
TxReceipt,
|
|
12
12
|
} from '@aztec/types';
|
|
13
13
|
|
|
14
|
+
export { mustSucceedFetch } from '@aztec/foundation/json-rpc/client';
|
|
15
|
+
|
|
14
16
|
export const createAztecRpcClient = (url: string, fetch = defaultFetch): AztecRPC =>
|
|
15
17
|
createJsonRpcClient<AztecRPC>(
|
|
16
18
|
url,
|
|
@@ -22,6 +24,7 @@ export const createAztecRpcClient = (url: string, fetch = defaultFetch): AztecRP
|
|
|
22
24
|
TxHash,
|
|
23
25
|
EthAddress,
|
|
24
26
|
Point,
|
|
27
|
+
PrivateKey,
|
|
25
28
|
Fr,
|
|
26
29
|
},
|
|
27
30
|
{ Tx, ContractDeploymentTx, TxReceipt },
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AztecAddress, Fr, PartialContractAddress,
|
|
1
|
+
import { AztecAddress, Fr, PartialContractAddress, PrivateKey, PublicKey, TxContext } from '@aztec/circuits.js';
|
|
2
2
|
import {
|
|
3
3
|
AztecRPC,
|
|
4
4
|
ContractData,
|
|
@@ -30,7 +30,7 @@ export abstract class BaseWallet implements Wallet {
|
|
|
30
30
|
executions: ExecutionRequest[],
|
|
31
31
|
txContext: TxContext,
|
|
32
32
|
): Promise<TxExecutionRequest>;
|
|
33
|
-
addAccount(privKey:
|
|
33
|
+
addAccount(privKey: PrivateKey, address: AztecAddress, partialContractAddress: Fr): Promise<AztecAddress> {
|
|
34
34
|
return this.rpc.addAccount(privKey, address, partialContractAddress);
|
|
35
35
|
}
|
|
36
36
|
addPublicKeyAndPartialAddress(
|
|
@@ -43,7 +43,7 @@ export abstract class BaseWallet implements Wallet {
|
|
|
43
43
|
getAccounts(): Promise<AztecAddress[]> {
|
|
44
44
|
return this.rpc.getAccounts();
|
|
45
45
|
}
|
|
46
|
-
getPublicKey(address: AztecAddress): Promise<
|
|
46
|
+
getPublicKey(address: AztecAddress): Promise<PublicKey> {
|
|
47
47
|
return this.rpc.getPublicKey(address);
|
|
48
48
|
}
|
|
49
49
|
addContracts(contracts: DeployedContract[]): Promise<void> {
|
|
@@ -61,8 +61,8 @@ export abstract class BaseWallet implements Wallet {
|
|
|
61
61
|
getTxReceipt(txHash: TxHash): Promise<TxReceipt> {
|
|
62
62
|
return this.rpc.getTxReceipt(txHash);
|
|
63
63
|
}
|
|
64
|
-
|
|
65
|
-
return this.rpc.
|
|
64
|
+
getPreimagesAt(contract: AztecAddress, storageSlot: Fr): Promise<any> {
|
|
65
|
+
return this.rpc.getPreimagesAt(contract, storageSlot);
|
|
66
66
|
}
|
|
67
67
|
getPublicStorageAt(contract: AztecAddress, storageSlot: Fr): Promise<any> {
|
|
68
68
|
return this.rpc.getPublicStorageAt(contract, storageSlot);
|
|
@@ -76,8 +76,8 @@ export abstract class BaseWallet implements Wallet {
|
|
|
76
76
|
getContractInfo(contractAddress: AztecAddress): Promise<ContractData | undefined> {
|
|
77
77
|
return this.rpc.getContractInfo(contractAddress);
|
|
78
78
|
}
|
|
79
|
-
getUnencryptedLogs(from: number,
|
|
80
|
-
return this.rpc.getUnencryptedLogs(from,
|
|
79
|
+
getUnencryptedLogs(from: number, limit: number): Promise<L2BlockL2Logs[]> {
|
|
80
|
+
return this.rpc.getUnencryptedLogs(from, limit);
|
|
81
81
|
}
|
|
82
82
|
getBlockNum(): Promise<number> {
|
|
83
83
|
return this.rpc.getBlockNum();
|
|
@@ -85,9 +85,12 @@ export abstract class BaseWallet implements Wallet {
|
|
|
85
85
|
getNodeInfo(): Promise<NodeInfo> {
|
|
86
86
|
return this.rpc.getNodeInfo();
|
|
87
87
|
}
|
|
88
|
-
getPublicKeyAndPartialAddress(address: AztecAddress): Promise<[
|
|
88
|
+
getPublicKeyAndPartialAddress(address: AztecAddress): Promise<[PublicKey, PartialContractAddress]> {
|
|
89
89
|
return this.rpc.getPublicKeyAndPartialAddress(address);
|
|
90
90
|
}
|
|
91
|
+
isSynchronised() {
|
|
92
|
+
return this.rpc.isSynchronised();
|
|
93
|
+
}
|
|
91
94
|
isAccountSynchronised(account: AztecAddress) {
|
|
92
95
|
return this.rpc.isAccountSynchronised(account);
|
|
93
96
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { AztecAddress, EthAddress } from '@aztec/circuits.js';
|
|
2
2
|
import { ABIParameterVisibility, ContractAbi, FunctionType } from '@aztec/foundation/abi';
|
|
3
3
|
import { randomBytes } from '@aztec/foundation/crypto';
|
|
4
|
-
import { DeployedContract, NodeInfo, Tx, TxHash, TxReceipt } from '@aztec/types';
|
|
5
|
-
import { TxExecutionRequest } from '@aztec/types';
|
|
4
|
+
import { DeployedContract, NodeInfo, Tx, TxExecutionRequest, TxHash, TxReceipt } from '@aztec/types';
|
|
6
5
|
|
|
7
6
|
import { MockProxy, mock } from 'jest-mock-extended';
|
|
8
7
|
|
|
@@ -28,6 +27,7 @@ describe('Contract Class', () => {
|
|
|
28
27
|
{
|
|
29
28
|
name: 'bar',
|
|
30
29
|
functionType: FunctionType.SECRET,
|
|
30
|
+
isInternal: false,
|
|
31
31
|
parameters: [
|
|
32
32
|
{
|
|
33
33
|
name: 'value',
|
|
@@ -50,6 +50,7 @@ describe('Contract Class', () => {
|
|
|
50
50
|
{
|
|
51
51
|
name: 'baz',
|
|
52
52
|
functionType: FunctionType.OPEN,
|
|
53
|
+
isInternal: false,
|
|
53
54
|
parameters: [],
|
|
54
55
|
returnTypes: [],
|
|
55
56
|
bytecode: '0be',
|
|
@@ -57,6 +58,7 @@ describe('Contract Class', () => {
|
|
|
57
58
|
{
|
|
58
59
|
name: 'qux',
|
|
59
60
|
functionType: FunctionType.UNCONSTRAINED,
|
|
61
|
+
isInternal: false,
|
|
60
62
|
parameters: [
|
|
61
63
|
{
|
|
62
64
|
name: 'value',
|
|
@@ -92,6 +94,7 @@ describe('Contract Class', () => {
|
|
|
92
94
|
beforeEach(() => {
|
|
93
95
|
wallet = mock<Wallet>();
|
|
94
96
|
wallet.createAuthenticatedTxRequest.mockResolvedValue(mockTxRequest);
|
|
97
|
+
wallet.isContractDeployed.mockResolvedValue(true);
|
|
95
98
|
wallet.sendTx.mockResolvedValue(mockTxHash);
|
|
96
99
|
wallet.viewTx.mockResolvedValue(mockViewResultValue);
|
|
97
100
|
wallet.getTxReceipt.mockResolvedValue(mockTxReceipt);
|
|
@@ -100,7 +103,7 @@ describe('Contract Class', () => {
|
|
|
100
103
|
});
|
|
101
104
|
|
|
102
105
|
it('should create and send a contract method tx', async () => {
|
|
103
|
-
const fooContract =
|
|
106
|
+
const fooContract = await Contract.create(contractAddress, defaultAbi, wallet);
|
|
104
107
|
const param0 = 12;
|
|
105
108
|
const param1 = 345n;
|
|
106
109
|
const sentTx = fooContract.methods.bar(param0, param1).send({
|
|
@@ -117,7 +120,7 @@ describe('Contract Class', () => {
|
|
|
117
120
|
});
|
|
118
121
|
|
|
119
122
|
it('should call view on an unconstrained function', async () => {
|
|
120
|
-
const fooContract =
|
|
123
|
+
const fooContract = await Contract.create(contractAddress, defaultAbi, wallet);
|
|
121
124
|
const result = await fooContract.methods.qux(123n).view({
|
|
122
125
|
from: account,
|
|
123
126
|
});
|
|
@@ -126,8 +129,8 @@ describe('Contract Class', () => {
|
|
|
126
129
|
expect(result).toBe(mockViewResultValue);
|
|
127
130
|
});
|
|
128
131
|
|
|
129
|
-
it('should not call send on an unconstrained function', () => {
|
|
130
|
-
const fooContract =
|
|
132
|
+
it('should not call send on an unconstrained function', async () => {
|
|
133
|
+
const fooContract = await Contract.create(contractAddress, defaultAbi, wallet);
|
|
131
134
|
expect(() =>
|
|
132
135
|
fooContract.methods.qux().send({
|
|
133
136
|
origin: account,
|
|
@@ -135,15 +138,15 @@ describe('Contract Class', () => {
|
|
|
135
138
|
).toThrow();
|
|
136
139
|
});
|
|
137
140
|
|
|
138
|
-
it('should not call view on a secret or open function', () => {
|
|
139
|
-
const fooContract =
|
|
141
|
+
it('should not call view on a secret or open function', async () => {
|
|
142
|
+
const fooContract = await Contract.create(contractAddress, defaultAbi, wallet);
|
|
140
143
|
expect(() => fooContract.methods.bar().view()).toThrow();
|
|
141
144
|
expect(() => fooContract.methods.baz().view()).toThrow();
|
|
142
145
|
});
|
|
143
146
|
|
|
144
147
|
it('should add contract and dependencies to aztec rpc', async () => {
|
|
145
148
|
const entry = randomDeployContract();
|
|
146
|
-
const contract =
|
|
149
|
+
const contract = await Contract.create(entry.address, entry.abi, wallet);
|
|
147
150
|
|
|
148
151
|
{
|
|
149
152
|
await contract.attach(entry.portalContract);
|