@aztec/aztec.js 0.7.10 → 0.8.4
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/README.md +25 -23
- package/dest/abis/ecdsa_account_contract.json +20 -8
- package/dest/abis/schnorr_account_contract.json +20 -8
- package/dest/abis/schnorr_single_key_account_contract.json +19 -7
- package/dest/account/defaults/default_entrypoint.js +3 -3
- package/dest/account/index.d.ts +33 -11
- package/dest/account/index.d.ts.map +1 -1
- package/dest/account/index.js +40 -18
- package/dest/account/manager/index.d.ts +8 -8
- package/dest/account/manager/index.d.ts.map +1 -1
- package/dest/account/manager/index.js +12 -12
- package/dest/{utils/account.d.ts → account/utils.d.ts} +10 -10
- package/dest/account/utils.d.ts.map +1 -0
- package/dest/account/utils.js +40 -0
- package/dest/contract/base_contract_interaction.d.ts +5 -5
- package/dest/contract/base_contract_interaction.d.ts.map +1 -1
- package/dest/contract/base_contract_interaction.js +6 -6
- package/dest/contract/contract.d.ts +1 -1
- package/dest/contract/contract.js +1 -1
- package/dest/contract/contract_base.d.ts +3 -3
- package/dest/contract/contract_base.d.ts.map +1 -1
- package/dest/contract/contract_base.js +2 -2
- package/dest/contract/contract_function_interaction.d.ts +2 -2
- package/dest/contract/contract_function_interaction.d.ts.map +1 -1
- package/dest/contract/index.d.ts +37 -0
- package/dest/contract/index.d.ts.map +1 -1
- package/dest/contract/index.js +38 -1
- package/dest/contract/sent_tx.d.ts +6 -6
- package/dest/contract/sent_tx.d.ts.map +1 -1
- package/dest/contract/sent_tx.js +9 -9
- package/dest/contract_deployer/contract_deployer.d.ts +4 -4
- package/dest/contract_deployer/contract_deployer.d.ts.map +1 -1
- package/dest/contract_deployer/contract_deployer.js +5 -5
- package/dest/contract_deployer/deploy_method.d.ts +5 -5
- package/dest/contract_deployer/deploy_method.d.ts.map +1 -1
- package/dest/contract_deployer/deploy_method.js +7 -7
- package/dest/contract_deployer/deploy_sent_tx.d.ts +2 -2
- package/dest/contract_deployer/deploy_sent_tx.d.ts.map +1 -1
- package/dest/contract_deployer/deploy_sent_tx.js +3 -3
- package/dest/index.d.ts +2 -2
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +3 -3
- package/dest/pxe_client.d.ts +4 -0
- package/dest/pxe_client.d.ts.map +1 -0
- package/dest/pxe_client.js +20 -0
- package/dest/sandbox/index.d.ts +8 -8
- package/dest/sandbox/index.d.ts.map +1 -1
- package/dest/sandbox/index.js +13 -13
- package/dest/utils/abi_types.d.ts +9 -1
- package/dest/utils/abi_types.d.ts.map +1 -1
- package/dest/utils/authwit.d.ts +12 -0
- package/dest/utils/authwit.d.ts.map +1 -0
- package/dest/utils/authwit.js +20 -0
- package/dest/utils/cheat_codes.d.ts +8 -8
- package/dest/utils/cheat_codes.d.ts.map +1 -1
- package/dest/utils/cheat_codes.js +11 -11
- package/dest/utils/index.d.ts +1 -1
- package/dest/utils/index.d.ts.map +1 -1
- package/dest/utils/index.js +2 -2
- package/dest/utils/l1_contracts.d.ts +1 -30
- package/dest/utils/l1_contracts.d.ts.map +1 -1
- package/dest/utils/l1_contracts.js +5 -6
- package/dest/utils/l2_contracts.d.ts +3 -3
- package/dest/utils/l2_contracts.d.ts.map +1 -1
- package/dest/utils/l2_contracts.js +4 -4
- package/dest/wallet/account_wallet.d.ts +2 -2
- package/dest/wallet/account_wallet.d.ts.map +1 -1
- package/dest/wallet/account_wallet.js +4 -4
- package/dest/wallet/base_wallet.d.ts +7 -5
- package/dest/wallet/base_wallet.d.ts.map +1 -1
- package/dest/wallet/base_wallet.js +35 -29
- package/dest/wallet/index.d.ts +2 -2
- package/dest/wallet/index.d.ts.map +1 -1
- package/dest/wallet/signerless_wallet.js +1 -1
- package/package.json +69 -6
- package/src/abis/ecdsa_account_contract.json +20 -8
- package/src/abis/schnorr_account_contract.json +20 -8
- package/src/abis/schnorr_single_key_account_contract.json +19 -7
- package/src/account/defaults/default_entrypoint.ts +2 -2
- package/src/account/index.ts +40 -18
- package/src/account/manager/index.ts +11 -11
- package/src/{utils/account.ts → account/utils.ts} +12 -12
- package/src/contract/base_contract_interaction.ts +7 -7
- package/src/contract/contract.ts +1 -1
- package/src/contract/contract_base.ts +2 -2
- package/src/contract/contract_function_interaction.ts +2 -2
- package/src/contract/index.ts +37 -0
- package/src/contract/sent_tx.ts +9 -9
- package/src/contract_deployer/contract_deployer.ts +4 -4
- package/src/contract_deployer/deploy_method.ts +8 -8
- package/src/contract_deployer/deploy_sent_tx.ts +4 -4
- package/src/index.ts +4 -2
- package/src/{aztec_rpc_client.ts → pxe_client.ts} +5 -3
- package/src/sandbox/index.ts +12 -12
- package/src/utils/abi_types.ts +7 -1
- package/src/utils/authwit.ts +24 -0
- package/src/utils/cheat_codes.ts +10 -10
- package/src/utils/index.ts +1 -1
- package/src/utils/l1_contracts.ts +5 -44
- package/src/utils/l2_contracts.ts +4 -4
- package/src/wallet/account_wallet.ts +4 -4
- package/src/wallet/base_wallet.ts +42 -28
- package/src/wallet/index.ts +2 -2
- package/src/wallet/signerless_wallet.ts +1 -1
- package/.eslintrc.cjs +0 -1
- package/.tsbuildinfo +0 -1
- package/dest/aztec_rpc_client.d.ts +0 -4
- package/dest/aztec_rpc_client.d.ts.map +0 -1
- package/dest/aztec_rpc_client.js +0 -19
- package/dest/contract/checker.test.d.ts +0 -2
- package/dest/contract/checker.test.d.ts.map +0 -1
- package/dest/contract/checker.test.js +0 -169
- package/dest/contract/contract.test.d.ts +0 -2
- package/dest/contract/contract.test.d.ts.map +0 -1
- package/dest/contract/contract.test.js +0 -147
- package/dest/contract/sent_tx.test.d.ts +0 -2
- package/dest/contract/sent_tx.test.d.ts.map +0 -1
- package/dest/contract/sent_tx.test.js +0 -42
- package/dest/contract_deployer/contract_deployer.test.d.ts +0 -2
- package/dest/contract_deployer/contract_deployer.test.d.ts.map +0 -1
- package/dest/contract_deployer/contract_deployer.test.js +0 -46
- package/dest/main.js +0 -2
- package/dest/main.js.LICENSE.txt +0 -10
- package/dest/utils/account.d.ts.map +0 -1
- package/dest/utils/account.js +0 -40
- package/package.local.json +0 -5
- package/src/contract/checker.test.ts +0 -178
- package/src/contract/contract.test.ts +0 -172
- package/src/contract/sent_tx.test.ts +0 -52
- package/src/contract_deployer/contract_deployer.test.ts +0 -55
- package/tsconfig.dest.json +0 -15
- package/tsconfig.json +0 -20
- package/webpack.config.js +0 -74
package/src/sandbox/index.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { sleep } from '@aztec/foundation/sleep';
|
|
|
4
4
|
import zip from 'lodash.zip';
|
|
5
5
|
|
|
6
6
|
import SchnorrAccountContractAbi from '../abis/schnorr_account_contract.json' assert { type: 'json' };
|
|
7
|
-
import { AccountWallet,
|
|
7
|
+
import { AccountWallet, PXE, createPXEClient, getSchnorrAccount } from '../index.js';
|
|
8
8
|
|
|
9
9
|
export const INITIAL_SANDBOX_ENCRYPTION_KEYS = [
|
|
10
10
|
GrumpkinScalar.fromString('2153536ff6628eee01cf4024889ff977a18d9fa61d0e414422f7681cf085c281'),
|
|
@@ -18,29 +18,29 @@ export const INITIAL_SANDBOX_SALTS = [Fr.ZERO, Fr.ZERO, Fr.ZERO];
|
|
|
18
18
|
|
|
19
19
|
export const INITIAL_SANDBOX_ACCOUNT_CONTRACT_ABI = SchnorrAccountContractAbi;
|
|
20
20
|
|
|
21
|
-
export const {
|
|
21
|
+
export const { PXE_URL = 'http://localhost:8080' } = process.env;
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* Gets a collection of wallets for the Aztec accounts that are initially stored in the sandbox.
|
|
25
|
-
* @param
|
|
25
|
+
* @param pxe - PXE instance.
|
|
26
26
|
* @returns A set of AccountWallet implementations for each of the initial accounts.
|
|
27
27
|
*/
|
|
28
|
-
export function getSandboxAccountsWallets(
|
|
28
|
+
export function getSandboxAccountsWallets(pxe: PXE): Promise<AccountWallet[]> {
|
|
29
29
|
return Promise.all(
|
|
30
30
|
zip(INITIAL_SANDBOX_ENCRYPTION_KEYS, INITIAL_SANDBOX_SIGNING_KEYS, INITIAL_SANDBOX_SALTS).map(
|
|
31
|
-
([encryptionKey, signingKey, salt]) => getSchnorrAccount(
|
|
31
|
+
([encryptionKey, signingKey, salt]) => getSchnorrAccount(pxe, encryptionKey!, signingKey!, salt).getWallet(),
|
|
32
32
|
),
|
|
33
33
|
);
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
37
|
* Deploys the initial set of schnorr signature accounts to the sandbox
|
|
38
|
-
* @param
|
|
38
|
+
* @param pxe - PXE instance.
|
|
39
39
|
* @returns The set of deployed Account objects and associated private encryption keys
|
|
40
40
|
*/
|
|
41
|
-
export async function deployInitialSandboxAccounts(
|
|
41
|
+
export async function deployInitialSandboxAccounts(pxe: PXE) {
|
|
42
42
|
const accounts = INITIAL_SANDBOX_ENCRYPTION_KEYS.map((privateKey, i) => {
|
|
43
|
-
const account = getSchnorrAccount(
|
|
43
|
+
const account = getSchnorrAccount(pxe, privateKey, INITIAL_SANDBOX_SIGNING_KEYS[i], INITIAL_SANDBOX_SALTS[i]);
|
|
44
44
|
return {
|
|
45
45
|
account,
|
|
46
46
|
privateKey,
|
|
@@ -70,13 +70,13 @@ export async function deployInitialSandboxAccounts(aztecRpc: AztecRPC) {
|
|
|
70
70
|
|
|
71
71
|
/**
|
|
72
72
|
* Function to wait until the sandbox becomes ready for use.
|
|
73
|
-
* @param
|
|
73
|
+
* @param pxe - The pxe client connected to the sandbox.
|
|
74
74
|
*/
|
|
75
|
-
export async function waitForSandbox(
|
|
76
|
-
|
|
75
|
+
export async function waitForSandbox(pxe?: PXE) {
|
|
76
|
+
pxe = pxe ?? createPXEClient(PXE_URL);
|
|
77
77
|
while (true) {
|
|
78
78
|
try {
|
|
79
|
-
await
|
|
79
|
+
await pxe.getNodeInfo();
|
|
80
80
|
break;
|
|
81
81
|
} catch (err) {
|
|
82
82
|
await sleep(1000);
|
package/src/utils/abi_types.ts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import { Fr } from '@aztec/circuits.js';
|
|
1
|
+
import { AztecAddress, EthAddress, Fr } from '@aztec/circuits.js';
|
|
2
2
|
|
|
3
3
|
/** Any type that can be converted into a field for a contract call. */
|
|
4
4
|
export type FieldLike = Fr | Buffer | bigint | number | { /** Converts to field */ toField: () => Fr };
|
|
5
|
+
|
|
6
|
+
/** Any type that can be converted into an EthereumAddress Aztec.nr struct. */
|
|
7
|
+
export type EthAddressLike = { /** Wrapped address */ address: FieldLike } | EthAddress;
|
|
8
|
+
|
|
9
|
+
/** Any type that can be converted into an EthereumAddress Aztec.nr struct. */
|
|
10
|
+
export type AztecAddressLike = { /** Wrapped address */ address: FieldLike } | AztecAddress;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { AztecAddress, CircuitsWasm, GeneratorIndex } from '@aztec/circuits.js';
|
|
2
|
+
import { pedersenPlookupCompressWithHashIndex } from '@aztec/circuits.js/barretenberg';
|
|
3
|
+
import { FunctionCall, PackedArguments } from '@aztec/types';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Compute an authentication witness message hash from a caller and a request
|
|
7
|
+
* H(caller: AztecAddress, target: AztecAddress, selector: Field, args_hash: Field)
|
|
8
|
+
* @param caller - The caller approved to make the call
|
|
9
|
+
* @param request - The request to be made (function call)
|
|
10
|
+
* @returns The message hash for the witness
|
|
11
|
+
*/
|
|
12
|
+
export const computeAuthWitMessageHash = async (caller: AztecAddress, request: FunctionCall) => {
|
|
13
|
+
const wasm = await CircuitsWasm.get();
|
|
14
|
+
return pedersenPlookupCompressWithHashIndex(
|
|
15
|
+
wasm,
|
|
16
|
+
[
|
|
17
|
+
caller.toField(),
|
|
18
|
+
request.to.toField(),
|
|
19
|
+
request.functionData.selector.toField(),
|
|
20
|
+
(await PackedArguments.fromArgs(request.args, wasm)).hash,
|
|
21
|
+
].map(fr => fr.toBuffer()),
|
|
22
|
+
GeneratorIndex.SIGNATURE_PAYLOAD,
|
|
23
|
+
);
|
|
24
|
+
};
|
package/src/utils/cheat_codes.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { pedersenPlookupCommitInputs } from '@aztec/circuits.js/barretenberg';
|
|
|
3
3
|
import { toBigIntBE, toHex } from '@aztec/foundation/bigint-buffer';
|
|
4
4
|
import { keccak } from '@aztec/foundation/crypto';
|
|
5
5
|
import { createDebugLogger } from '@aztec/foundation/log';
|
|
6
|
-
import {
|
|
6
|
+
import { NotePreimage, PXE } from '@aztec/types';
|
|
7
7
|
|
|
8
8
|
import fs from 'fs';
|
|
9
9
|
|
|
@@ -22,9 +22,9 @@ export class CheatCodes {
|
|
|
22
22
|
public aztec: AztecCheatCodes,
|
|
23
23
|
) {}
|
|
24
24
|
|
|
25
|
-
static async create(rpcUrl: string,
|
|
25
|
+
static async create(rpcUrl: string, pxe: PXE): Promise<CheatCodes> {
|
|
26
26
|
const ethCheatCodes = new EthCheatCodes(rpcUrl);
|
|
27
|
-
const aztecCheatCodes = new AztecCheatCodes(
|
|
27
|
+
const aztecCheatCodes = new AztecCheatCodes(pxe, await CircuitsWasm.get(), ethCheatCodes);
|
|
28
28
|
return new CheatCodes(ethCheatCodes, aztecCheatCodes);
|
|
29
29
|
}
|
|
30
30
|
}
|
|
@@ -35,7 +35,7 @@ export class CheatCodes {
|
|
|
35
35
|
export class EthCheatCodes {
|
|
36
36
|
constructor(
|
|
37
37
|
/**
|
|
38
|
-
* The RPC
|
|
38
|
+
* The RPC URL to use for interacting with the chain
|
|
39
39
|
*/
|
|
40
40
|
public rpcUrl: string,
|
|
41
41
|
/**
|
|
@@ -209,9 +209,9 @@ export class EthCheatCodes {
|
|
|
209
209
|
export class AztecCheatCodes {
|
|
210
210
|
constructor(
|
|
211
211
|
/**
|
|
212
|
-
* The
|
|
212
|
+
* The PXE Service to use for interacting with the chain
|
|
213
213
|
*/
|
|
214
|
-
public
|
|
214
|
+
public pxe: PXE,
|
|
215
215
|
/**
|
|
216
216
|
* The circuits wasm module used for pedersen hashing
|
|
217
217
|
*/
|
|
@@ -248,7 +248,7 @@ export class AztecCheatCodes {
|
|
|
248
248
|
* @returns The current block number
|
|
249
249
|
*/
|
|
250
250
|
public async blockNumber(): Promise<number> {
|
|
251
|
-
return await this.
|
|
251
|
+
return await this.pxe.getBlockNumber();
|
|
252
252
|
}
|
|
253
253
|
|
|
254
254
|
/**
|
|
@@ -257,7 +257,7 @@ export class AztecCheatCodes {
|
|
|
257
257
|
* @param to - The timestamp to set the next block to (must be greater than current time)
|
|
258
258
|
*/
|
|
259
259
|
public async warp(to: number): Promise<void> {
|
|
260
|
-
const rollupContract = (await this.
|
|
260
|
+
const rollupContract = (await this.pxe.getNodeInfo()).l1ContractAddresses.rollupAddress;
|
|
261
261
|
await this.eth.setNextBlockTimestamp(to);
|
|
262
262
|
// also store this time on the rollup contract (slot 1 tracks `lastBlockTs`).
|
|
263
263
|
// This is because when the sequencer executes public functions, it uses the timestamp stored in the rollup contract.
|
|
@@ -273,7 +273,7 @@ export class AztecCheatCodes {
|
|
|
273
273
|
* @returns The value stored at the given slot
|
|
274
274
|
*/
|
|
275
275
|
public async loadPublic(who: AztecAddress, slot: Fr | bigint): Promise<Fr> {
|
|
276
|
-
const storageValue = await this.
|
|
276
|
+
const storageValue = await this.pxe.getPublicStorageAt(who, new Fr(slot));
|
|
277
277
|
if (storageValue === undefined) {
|
|
278
278
|
throw new Error(`Storage slot ${slot} not found`);
|
|
279
279
|
}
|
|
@@ -288,6 +288,6 @@ export class AztecCheatCodes {
|
|
|
288
288
|
* @returns The notes stored at the given slot
|
|
289
289
|
*/
|
|
290
290
|
public loadPrivate(owner: AztecAddress, contract: AztecAddress, slot: Fr | bigint): Promise<NotePreimage[]> {
|
|
291
|
-
return this.
|
|
291
|
+
return this.pxe.getPrivateStorageAt(owner, contract, new Fr(slot));
|
|
292
292
|
}
|
|
293
293
|
}
|
package/src/utils/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export * from './secrets.js';
|
|
2
|
-
export * from './account.js';
|
|
3
2
|
export * from './pub_key.js';
|
|
4
3
|
export * from './l1_contracts.js';
|
|
5
4
|
export * from './l2_contracts.js';
|
|
6
5
|
export * from './abi_types.js';
|
|
7
6
|
export * from './cheat_codes.js';
|
|
7
|
+
export * from './authwit.js';
|
|
@@ -1,50 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { L1ContractAddresses } from '@aztec/ethereum';
|
|
2
2
|
import { retryUntil } from '@aztec/foundation/retry';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
* A dictionary of the Aztec-deployed L1 contracts.
|
|
6
|
-
*/
|
|
7
|
-
export type L1ContractAddresses = {
|
|
8
|
-
/**
|
|
9
|
-
* Address fo the main Aztec rollup contract.
|
|
10
|
-
*/
|
|
11
|
-
rollup: EthAddress;
|
|
12
|
-
/**
|
|
13
|
-
* Address of the contract that emits events on public contract deployment.
|
|
14
|
-
*/
|
|
15
|
-
contractDeploymentEmitter: EthAddress;
|
|
16
|
-
/**
|
|
17
|
-
* Address of the L1/L2 messaging inbox contract.
|
|
18
|
-
*/
|
|
19
|
-
inbox: EthAddress;
|
|
20
|
-
/**
|
|
21
|
-
* Address of the L1/L2 messaging outbox contract.
|
|
22
|
-
*/
|
|
23
|
-
outbox: EthAddress;
|
|
24
|
-
/**
|
|
25
|
-
* Address of the decoder helper contract
|
|
26
|
-
*/
|
|
27
|
-
decoderHelper?: EthAddress;
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Registry Address.
|
|
31
|
-
*/
|
|
32
|
-
registry: EthAddress;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* string dictionary of aztec contract addresses that we receive over http.
|
|
37
|
-
*/
|
|
38
|
-
type L1ContractAddressesResp = {
|
|
39
|
-
[K in keyof L1ContractAddresses]: string;
|
|
40
|
-
};
|
|
4
|
+
import { createPXEClient } from '../pxe_client.js';
|
|
41
5
|
|
|
42
6
|
export const getL1ContractAddresses = async (url: string): Promise<L1ContractAddresses> => {
|
|
43
|
-
const
|
|
7
|
+
const pxeClient = createPXEClient(url);
|
|
44
8
|
const response = await retryUntil(
|
|
45
9
|
async () => {
|
|
46
10
|
try {
|
|
47
|
-
return (await
|
|
11
|
+
return (await pxeClient.getNodeInfo()).l1ContractAddresses;
|
|
48
12
|
} catch (err) {
|
|
49
13
|
// do nothing
|
|
50
14
|
}
|
|
@@ -53,8 +17,5 @@ export const getL1ContractAddresses = async (url: string): Promise<L1ContractAdd
|
|
|
53
17
|
120,
|
|
54
18
|
1,
|
|
55
19
|
);
|
|
56
|
-
|
|
57
|
-
Object.entries(response).map(([key, value]) => [key, EthAddress.fromString(value)]),
|
|
58
|
-
);
|
|
59
|
-
return result as L1ContractAddresses;
|
|
20
|
+
return response;
|
|
60
21
|
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { AztecAddress } from '@aztec/foundation/aztec-address';
|
|
2
|
-
import {
|
|
2
|
+
import { PXE } from '@aztec/types';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Checks whether a give contract is deployed on the network.
|
|
6
|
-
* @param
|
|
6
|
+
* @param pxe - The PXE to use to obtain the information.
|
|
7
7
|
* @param contractAddress - The address of the contract to check.
|
|
8
8
|
* @returns A flag indicating whether the contract is deployed.
|
|
9
9
|
*/
|
|
10
|
-
export async function isContractDeployed(
|
|
11
|
-
return !!(await
|
|
10
|
+
export async function isContractDeployed(pxe: PXE, contractAddress: AztecAddress): Promise<boolean> {
|
|
11
|
+
return !!(await pxe.getContractData(contractAddress));
|
|
12
12
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Fr } from '@aztec/circuits.js';
|
|
2
2
|
import { ABIParameterVisibility, FunctionAbiHeader, FunctionType } from '@aztec/foundation/abi';
|
|
3
|
-
import { AuthWitness,
|
|
3
|
+
import { AuthWitness, FunctionCall, PXE, TxExecutionRequest } from '@aztec/types';
|
|
4
4
|
|
|
5
5
|
import { AccountInterface } from '../account/interface.js';
|
|
6
6
|
import { ContractFunctionInteraction } from '../index.js';
|
|
@@ -10,8 +10,8 @@ import { BaseWallet } from './base_wallet.js';
|
|
|
10
10
|
* A wallet implementation that forwards authentication requests to a provided account.
|
|
11
11
|
*/
|
|
12
12
|
export class AccountWallet extends BaseWallet {
|
|
13
|
-
constructor(
|
|
14
|
-
super(
|
|
13
|
+
constructor(pxe: PXE, protected account: AccountInterface) {
|
|
14
|
+
super(pxe);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
createTxExecutionRequest(execs: FunctionCall[]): Promise<TxExecutionRequest> {
|
|
@@ -21,7 +21,7 @@ export class AccountWallet extends BaseWallet {
|
|
|
21
21
|
async createAuthWitness(message: Fr | Buffer): Promise<AuthWitness> {
|
|
22
22
|
message = Buffer.isBuffer(message) ? Fr.fromBuffer(message) : message;
|
|
23
23
|
const witness = await this.account.createAuthWitness(message);
|
|
24
|
-
await this.
|
|
24
|
+
await this.pxe.addAuthWitness(witness);
|
|
25
25
|
return witness;
|
|
26
26
|
}
|
|
27
27
|
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { AztecAddress, Fr, GrumpkinPrivateKey, PartialAddress } from '@aztec/circuits.js';
|
|
2
2
|
import {
|
|
3
3
|
AuthWitness,
|
|
4
|
-
AztecRPC,
|
|
5
4
|
ContractData,
|
|
6
5
|
DeployedContract,
|
|
7
6
|
ExtendedContractData,
|
|
8
7
|
FunctionCall,
|
|
9
8
|
L2BlockL2Logs,
|
|
9
|
+
L2Tx,
|
|
10
10
|
NodeInfo,
|
|
11
11
|
NotePreimage,
|
|
12
|
+
PXE,
|
|
12
13
|
SyncStatus,
|
|
13
14
|
Tx,
|
|
14
15
|
TxExecutionRequest,
|
|
@@ -23,7 +24,7 @@ import { Wallet } from './index.js';
|
|
|
23
24
|
* A base class for Wallet implementations
|
|
24
25
|
*/
|
|
25
26
|
export abstract class BaseWallet implements Wallet {
|
|
26
|
-
constructor(protected readonly
|
|
27
|
+
constructor(protected readonly pxe: PXE) {}
|
|
27
28
|
|
|
28
29
|
abstract getCompleteAddress(): CompleteAddress;
|
|
29
30
|
|
|
@@ -32,75 +33,88 @@ export abstract class BaseWallet implements Wallet {
|
|
|
32
33
|
abstract createAuthWitness(message: Fr): Promise<AuthWitness>;
|
|
33
34
|
|
|
34
35
|
registerAccount(privKey: GrumpkinPrivateKey, partialAddress: PartialAddress): Promise<void> {
|
|
35
|
-
return this.
|
|
36
|
+
return this.pxe.registerAccount(privKey, partialAddress);
|
|
36
37
|
}
|
|
37
38
|
registerRecipient(account: CompleteAddress): Promise<void> {
|
|
38
|
-
return this.
|
|
39
|
+
return this.pxe.registerRecipient(account);
|
|
39
40
|
}
|
|
40
41
|
getRegisteredAccounts(): Promise<CompleteAddress[]> {
|
|
41
|
-
return this.
|
|
42
|
+
return this.pxe.getRegisteredAccounts();
|
|
42
43
|
}
|
|
43
44
|
getRegisteredAccount(address: AztecAddress): Promise<CompleteAddress | undefined> {
|
|
44
|
-
return this.
|
|
45
|
+
return this.pxe.getRegisteredAccount(address);
|
|
45
46
|
}
|
|
46
47
|
getRecipients(): Promise<CompleteAddress[]> {
|
|
47
|
-
return this.
|
|
48
|
+
return this.pxe.getRecipients();
|
|
48
49
|
}
|
|
49
50
|
getRecipient(address: AztecAddress): Promise<CompleteAddress | undefined> {
|
|
50
|
-
return this.
|
|
51
|
+
return this.pxe.getRecipient(address);
|
|
51
52
|
}
|
|
52
53
|
addContracts(contracts: DeployedContract[]): Promise<void> {
|
|
53
|
-
return this.
|
|
54
|
+
return this.pxe.addContracts(contracts);
|
|
54
55
|
}
|
|
55
56
|
getContracts(): Promise<AztecAddress[]> {
|
|
56
|
-
return this.
|
|
57
|
+
return this.pxe.getContracts();
|
|
57
58
|
}
|
|
58
59
|
simulateTx(txRequest: TxExecutionRequest, simulatePublic: boolean): Promise<Tx> {
|
|
59
|
-
return this.
|
|
60
|
+
return this.pxe.simulateTx(txRequest, simulatePublic);
|
|
60
61
|
}
|
|
61
62
|
sendTx(tx: Tx): Promise<TxHash> {
|
|
62
|
-
return this.
|
|
63
|
+
return this.pxe.sendTx(tx);
|
|
64
|
+
}
|
|
65
|
+
getTx(txHash: TxHash): Promise<L2Tx | undefined> {
|
|
66
|
+
return this.pxe.getTx(txHash);
|
|
63
67
|
}
|
|
64
68
|
getTxReceipt(txHash: TxHash): Promise<TxReceipt> {
|
|
65
|
-
return this.
|
|
69
|
+
return this.pxe.getTxReceipt(txHash);
|
|
66
70
|
}
|
|
67
71
|
getPrivateStorageAt(owner: AztecAddress, contract: AztecAddress, storageSlot: Fr): Promise<NotePreimage[]> {
|
|
68
|
-
return this.
|
|
72
|
+
return this.pxe.getPrivateStorageAt(owner, contract, storageSlot);
|
|
69
73
|
}
|
|
70
74
|
getPublicStorageAt(contract: AztecAddress, storageSlot: Fr): Promise<any> {
|
|
71
|
-
return this.
|
|
75
|
+
return this.pxe.getPublicStorageAt(contract, storageSlot);
|
|
76
|
+
}
|
|
77
|
+
addNote(
|
|
78
|
+
account: AztecAddress,
|
|
79
|
+
contract: AztecAddress,
|
|
80
|
+
storageSlot: Fr,
|
|
81
|
+
preimage: NotePreimage,
|
|
82
|
+
txHash: TxHash,
|
|
83
|
+
nonce?: Fr,
|
|
84
|
+
): Promise<void> {
|
|
85
|
+
return this.pxe.addNote(account, contract, storageSlot, preimage, txHash, nonce);
|
|
72
86
|
}
|
|
73
87
|
getNoteNonces(contract: AztecAddress, storageSlot: Fr, preimage: NotePreimage, txHash: TxHash): Promise<Fr[]> {
|
|
74
|
-
return this.
|
|
88
|
+
return this.pxe.getNoteNonces(contract, storageSlot, preimage, txHash);
|
|
75
89
|
}
|
|
76
90
|
viewTx(functionName: string, args: any[], to: AztecAddress, from?: AztecAddress | undefined): Promise<any> {
|
|
77
|
-
return this.
|
|
91
|
+
return this.pxe.viewTx(functionName, args, to, from);
|
|
78
92
|
}
|
|
79
93
|
getExtendedContractData(contractAddress: AztecAddress): Promise<ExtendedContractData | undefined> {
|
|
80
|
-
return this.
|
|
94
|
+
return this.pxe.getExtendedContractData(contractAddress);
|
|
81
95
|
}
|
|
82
96
|
getContractData(contractAddress: AztecAddress): Promise<ContractData | undefined> {
|
|
83
|
-
return this.
|
|
97
|
+
return this.pxe.getContractData(contractAddress);
|
|
84
98
|
}
|
|
85
99
|
getUnencryptedLogs(from: number, limit: number): Promise<L2BlockL2Logs[]> {
|
|
86
|
-
return this.
|
|
100
|
+
return this.pxe.getUnencryptedLogs(from, limit);
|
|
87
101
|
}
|
|
88
102
|
getBlockNumber(): Promise<number> {
|
|
89
|
-
return this.
|
|
103
|
+
return this.pxe.getBlockNumber();
|
|
90
104
|
}
|
|
91
105
|
getNodeInfo(): Promise<NodeInfo> {
|
|
92
|
-
return this.
|
|
106
|
+
return this.pxe.getNodeInfo();
|
|
93
107
|
}
|
|
94
|
-
|
|
95
|
-
return this.
|
|
108
|
+
isGlobalStateSynchronized() {
|
|
109
|
+
return this.pxe.isGlobalStateSynchronized();
|
|
96
110
|
}
|
|
97
|
-
|
|
98
|
-
return this.
|
|
111
|
+
isAccountStateSynchronized(account: AztecAddress) {
|
|
112
|
+
return this.pxe.isAccountStateSynchronized(account);
|
|
99
113
|
}
|
|
100
114
|
getSyncStatus(): Promise<SyncStatus> {
|
|
101
|
-
return this.
|
|
115
|
+
return this.pxe.getSyncStatus();
|
|
102
116
|
}
|
|
103
117
|
addAuthWitness(authWitness: AuthWitness) {
|
|
104
|
-
return this.
|
|
118
|
+
return this.pxe.addAuthWitness(authWitness);
|
|
105
119
|
}
|
|
106
120
|
}
|
package/src/wallet/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AccountInterface,
|
|
1
|
+
import { AccountInterface, PXE } from '../index.js';
|
|
2
2
|
|
|
3
3
|
export * from './base_wallet.js';
|
|
4
4
|
export * from './account_wallet.js';
|
|
@@ -7,4 +7,4 @@ export * from './signerless_wallet.js';
|
|
|
7
7
|
/**
|
|
8
8
|
* The wallet interface.
|
|
9
9
|
*/
|
|
10
|
-
export type Wallet = AccountInterface &
|
|
10
|
+
export type Wallet = AccountInterface & PXE;
|
|
@@ -15,7 +15,7 @@ export class SignerlessWallet extends BaseWallet {
|
|
|
15
15
|
const [execution] = executions;
|
|
16
16
|
const wasm = await CircuitsWasm.get();
|
|
17
17
|
const packedArguments = await PackedArguments.fromArgs(execution.args, wasm);
|
|
18
|
-
const { chainId, protocolVersion } = await this.
|
|
18
|
+
const { chainId, protocolVersion } = await this.pxe.getNodeInfo();
|
|
19
19
|
const txContext = TxContext.empty(chainId, protocolVersion);
|
|
20
20
|
return Promise.resolve(
|
|
21
21
|
new TxExecutionRequest(
|
package/.eslintrc.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = require('@aztec/foundation/eslint');
|