@aztec/accounts 0.76.4 → 0.77.0-testnet-ignition.21
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 +11 -8
- package/artifacts/EcdsaKAccount.d.json.ts +1 -1
- package/artifacts/EcdsaKAccount.json +850 -690
- package/artifacts/EcdsaRAccount.d.json.ts +1 -1
- package/artifacts/EcdsaRAccount.json +684 -524
- package/artifacts/SchnorrAccount.d.json.ts +1 -1
- package/artifacts/SchnorrAccount.json +692 -459
- package/artifacts/SchnorrSingleKeyAccount.d.json.ts +1 -1
- package/artifacts/SchnorrSingleKeyAccount.json +227 -301
- package/dest/dapp/dapp_interface.d.ts +1 -2
- package/dest/dapp/dapp_interface.d.ts.map +1 -1
- package/dest/dapp/dapp_interface.js +3 -5
- package/dest/dapp/index.js +0 -1
- package/dest/defaults/account_contract.d.ts +5 -7
- package/dest/defaults/account_contract.d.ts.map +1 -1
- package/dest/defaults/account_contract.js +2 -9
- package/dest/defaults/account_interface.d.ts +8 -4
- package/dest/defaults/account_interface.d.ts.map +1 -1
- package/dest/defaults/account_interface.js +8 -5
- package/dest/defaults/index.js +1 -3
- package/dest/ecdsa/ecdsa_k/account_contract.d.ts +5 -3
- package/dest/ecdsa/ecdsa_k/account_contract.d.ts.map +1 -1
- package/dest/ecdsa/ecdsa_k/account_contract.js +19 -14
- package/dest/ecdsa/ecdsa_k/index.d.ts +15 -5
- package/dest/ecdsa/ecdsa_k/index.d.ts.map +1 -1
- package/dest/ecdsa/ecdsa_k/index.js +21 -10
- package/dest/ecdsa/ecdsa_k/lazy.d.ts +47 -0
- package/dest/ecdsa/ecdsa_k/lazy.d.ts.map +1 -0
- package/dest/ecdsa/ecdsa_k/lazy.js +52 -0
- package/dest/ecdsa/index.js +0 -1
- package/dest/ecdsa/lazy.d.ts +3 -0
- package/dest/ecdsa/lazy.d.ts.map +1 -0
- package/dest/ecdsa/lazy.js +2 -0
- package/dest/ecdsa/ssh_ecdsa_r/account_contract.d.ts +5 -3
- package/dest/ecdsa/ssh_ecdsa_r/account_contract.d.ts.map +1 -1
- package/dest/ecdsa/ssh_ecdsa_r/account_contract.js +55 -51
- package/dest/ecdsa/ssh_ecdsa_r/index.d.ts +18 -5
- package/dest/ecdsa/ssh_ecdsa_r/index.d.ts.map +1 -1
- package/dest/ecdsa/ssh_ecdsa_r/index.js +24 -10
- package/dest/ecdsa/ssh_ecdsa_r/lazy.d.ts +49 -0
- package/dest/ecdsa/ssh_ecdsa_r/lazy.d.ts.map +1 -0
- package/dest/ecdsa/ssh_ecdsa_r/lazy.js +57 -0
- package/dest/schnorr/account_contract.d.ts +13 -4
- package/dest/schnorr/account_contract.d.ts.map +1 -1
- package/dest/schnorr/account_contract.js +18 -14
- package/dest/schnorr/index.d.ts +32 -6
- package/dest/schnorr/index.d.ts.map +1 -1
- package/dest/schnorr/index.js +43 -10
- package/dest/schnorr/lazy.d.ts +61 -0
- package/dest/schnorr/lazy.d.ts.map +1 -0
- package/dest/schnorr/lazy.js +74 -0
- package/dest/single_key/account_contract.d.ts +6 -3
- package/dest/single_key/account_contract.d.ts.map +1 -1
- package/dest/single_key/account_contract.js +17 -13
- package/dest/single_key/index.d.ts +16 -8
- package/dest/single_key/index.d.ts.map +1 -1
- package/dest/single_key/index.js +23 -13
- package/dest/single_key/lazy.d.ts +43 -0
- package/dest/single_key/lazy.d.ts.map +1 -0
- package/dest/single_key/lazy.js +53 -0
- package/dest/testing/configuration.d.ts +23 -24
- package/dest/testing/configuration.d.ts.map +1 -1
- package/dest/testing/configuration.js +8 -79
- package/dest/testing/create_account.d.ts +38 -15
- package/dest/testing/create_account.d.ts.map +1 -1
- package/dest/testing/create_account.js +53 -49
- package/dest/testing/index.d.ts +28 -4
- package/dest/testing/index.d.ts.map +1 -1
- package/dest/testing/index.js +42 -6
- package/dest/testing/lazy.d.ts +34 -0
- package/dest/testing/lazy.d.ts.map +1 -0
- package/dest/testing/lazy.js +46 -0
- package/dest/utils/index.js +0 -1
- package/dest/utils/ssh_agent.js +75 -31
- package/package.json +12 -10
- package/src/dapp/dapp_interface.ts +7 -2
- package/src/defaults/account_contract.ts +5 -9
- package/src/defaults/account_interface.ts +8 -4
- package/src/ecdsa/ecdsa_k/account_contract.ts +9 -8
- package/src/ecdsa/ecdsa_k/index.ts +25 -5
- package/src/ecdsa/ecdsa_k/lazy.ts +71 -0
- package/src/ecdsa/lazy.ts +2 -0
- package/src/ecdsa/ssh_ecdsa_r/account_contract.ts +9 -8
- package/src/ecdsa/ssh_ecdsa_r/index.ts +29 -5
- package/src/ecdsa/ssh_ecdsa_r/lazy.ts +78 -0
- package/src/schnorr/account_contract.ts +10 -9
- package/src/schnorr/index.ts +56 -7
- package/src/schnorr/lazy.ts +107 -0
- package/src/single_key/account_contract.ts +9 -8
- package/src/single_key/index.ts +29 -11
- package/src/single_key/lazy.ts +71 -0
- package/src/testing/configuration.ts +21 -103
- package/src/testing/create_account.ts +79 -57
- package/src/testing/index.ts +85 -4
- package/src/testing/lazy.ts +86 -0
- package/dest/ecdsa/ecdsa_k/artifact.d.ts +0 -3
- package/dest/ecdsa/ecdsa_k/artifact.d.ts.map +0 -1
- package/dest/ecdsa/ecdsa_k/artifact.js +0 -4
- package/dest/ecdsa/ssh_ecdsa_r/artifact.d.ts +0 -2
- package/dest/ecdsa/ssh_ecdsa_r/artifact.d.ts.map +0 -1
- package/dest/ecdsa/ssh_ecdsa_r/artifact.js +0 -4
- package/dest/schnorr/artifact.d.ts +0 -2
- package/dest/schnorr/artifact.d.ts.map +0 -1
- package/dest/schnorr/artifact.js +0 -4
- package/dest/single_key/artifact.d.ts +0 -2
- package/dest/single_key/artifact.d.ts.map +0 -1
- package/dest/single_key/artifact.js +0 -4
- package/src/ecdsa/ecdsa_k/artifact.ts +0 -7
- package/src/ecdsa/ssh_ecdsa_r/artifact.ts +0 -5
- package/src/schnorr/artifact.ts +0 -5
- package/src/single_key/artifact.ts +0 -7
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `@aztec/accounts/single_key` export provides a testing account contract implementation that uses a single Grumpkin key for both authentication and encryption.
|
|
3
|
+
* It is not recommended to use this account type in production.
|
|
4
|
+
*
|
|
5
|
+
* @packageDocumentation
|
|
6
|
+
*/
|
|
7
|
+
import type { AztecAddress, Fr, GrumpkinScalar } from '@aztec/aztec.js';
|
|
8
|
+
import { AccountManager, type Salt } from '@aztec/aztec.js/account';
|
|
9
|
+
import { type AccountWallet, getWallet } from '@aztec/aztec.js/wallet';
|
|
10
|
+
import type { ContractArtifact } from '@aztec/stdlib/abi';
|
|
11
|
+
import { loadContractArtifact } from '@aztec/stdlib/abi';
|
|
12
|
+
import type { PXE } from '@aztec/stdlib/interfaces/client';
|
|
13
|
+
import { deriveMasterIncomingViewingSecretKey } from '@aztec/stdlib/keys';
|
|
14
|
+
|
|
15
|
+
import { SingleKeyBaseAccountContract } from './account_contract.js';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Lazily loads the contract artifact
|
|
19
|
+
* @returns The contract artifact for the single key account contract
|
|
20
|
+
*/
|
|
21
|
+
export async function getSingleKeyAccountContractArtifact() {
|
|
22
|
+
// Cannot assert this import as it's incompatible with browsers
|
|
23
|
+
// https://caniuse.com/mdn-javascript_statements_import_import_assertions_type_json
|
|
24
|
+
// Use the new "with" syntax once supported by firefox
|
|
25
|
+
// https://caniuse.com/mdn-javascript_statements_import_import_attributes_type_json
|
|
26
|
+
// In the meantime, this lazy import is INCOMPATIBLE WITH NODEJS
|
|
27
|
+
const { default: schnorrAccountContractJson } = await import('../../artifacts/SchnorrAccount.json');
|
|
28
|
+
return loadContractArtifact(schnorrAccountContractJson);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Account contract that authenticates transactions using Schnorr signatures verified against
|
|
33
|
+
* the note encryption key, relying on a single private key for both encryption and authentication.
|
|
34
|
+
* Lazily loads the contract artifact
|
|
35
|
+
*/
|
|
36
|
+
export class SingleKeyAccountContract extends SingleKeyBaseAccountContract {
|
|
37
|
+
constructor(signingPrivateKey: GrumpkinScalar) {
|
|
38
|
+
super(signingPrivateKey);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
override getContractArtifact(): Promise<ContractArtifact> {
|
|
42
|
+
return getSingleKeyAccountContractArtifact();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Creates an Account that uses the same Grumpkin key for encryption and authentication.
|
|
48
|
+
* @param pxe - An PXE server instance.
|
|
49
|
+
* @param secretKey - Secret key used to derive all the keystore keys (in this case also used to get signing key).
|
|
50
|
+
* @param salt - Deployment salt.
|
|
51
|
+
* @returns An account manager initialized with the account contract and its deployment params
|
|
52
|
+
*/
|
|
53
|
+
export function getUnsafeSchnorrAccount(pxe: PXE, secretKey: Fr, salt?: Salt) {
|
|
54
|
+
const encryptionPrivateKey = deriveMasterIncomingViewingSecretKey(secretKey);
|
|
55
|
+
return AccountManager.create(pxe, secretKey, new SingleKeyAccountContract(encryptionPrivateKey), salt);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Gets a wallet for an already registered account using Schnorr signatures with a single key for encryption and authentication.
|
|
60
|
+
* @param pxe - An PXE server instance.
|
|
61
|
+
* @param address - Address for the account.
|
|
62
|
+
* @param signingPrivateKey - Grumpkin key used for note encryption and signing transactions.
|
|
63
|
+
* @returns A wallet for this account that can be used to interact with a contract instance.
|
|
64
|
+
*/
|
|
65
|
+
export function getUnsafeSchnorrWallet(
|
|
66
|
+
pxe: PXE,
|
|
67
|
+
address: AztecAddress,
|
|
68
|
+
signingPrivateKey: GrumpkinScalar,
|
|
69
|
+
): Promise<AccountWallet> {
|
|
70
|
+
return getWallet(pxe, address, new SingleKeyAccountContract(signingPrivateKey));
|
|
71
|
+
}
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { type AccountWalletWithSecretKey, SignerlessWallet } from '@aztec/aztec.js/wallet';
|
|
5
|
-
import { type PXE } from '@aztec/circuit-types';
|
|
6
|
-
import { deriveMasterIncomingViewingSecretKey, deriveSigningKey } from '@aztec/circuits.js/keys';
|
|
7
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
8
|
-
|
|
9
|
-
import { SchnorrAccountContractArtifact, getSchnorrAccount } from '../schnorr/index.js';
|
|
1
|
+
import { Fr, GrumpkinScalar } from '@aztec/foundation/fields';
|
|
2
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
|
+
import { deriveMasterIncomingViewingSecretKey } from '@aztec/stdlib/keys';
|
|
10
4
|
|
|
11
5
|
export const INITIAL_TEST_SECRET_KEYS = [
|
|
12
6
|
Fr.fromHexString('2153536ff6628eee01cf4024889ff977a18d9fa61d0e414422f7681cf085c281'),
|
|
@@ -23,99 +17,23 @@ export const INITIAL_TEST_SIGNING_KEYS = INITIAL_TEST_ENCRYPTION_KEYS;
|
|
|
23
17
|
export const INITIAL_TEST_ACCOUNT_SALTS = [Fr.ZERO, Fr.ZERO, Fr.ZERO];
|
|
24
18
|
|
|
25
19
|
/**
|
|
26
|
-
*
|
|
27
|
-
* @param pxe - PXE instance.
|
|
28
|
-
* @returns A set of AccountWallet implementations for each of the initial accounts.
|
|
29
|
-
*/
|
|
30
|
-
export function getInitialTestAccountsWallets(pxe: PXE): Promise<AccountWalletWithSecretKey[]> {
|
|
31
|
-
return Promise.all(
|
|
32
|
-
INITIAL_TEST_SECRET_KEYS.map(async (encryptionKey, i) => {
|
|
33
|
-
const account = await getSchnorrAccount(
|
|
34
|
-
pxe,
|
|
35
|
-
encryptionKey!,
|
|
36
|
-
INITIAL_TEST_SIGNING_KEYS[i]!,
|
|
37
|
-
INITIAL_TEST_ACCOUNT_SALTS[i],
|
|
38
|
-
);
|
|
39
|
-
return account.getWallet();
|
|
40
|
-
}),
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Queries a PXE for it's registered accounts and returns wallets for those accounts using keys in the initial test accounts.
|
|
46
|
-
* @param pxe - PXE instance.
|
|
47
|
-
* @returns A set of AccountWallet implementations for each of the initial accounts.
|
|
48
|
-
*/
|
|
49
|
-
export async function getDeployedTestAccountsWallets(pxe: PXE): Promise<AccountWalletWithSecretKey[]> {
|
|
50
|
-
const registeredAccounts = await pxe.getRegisteredAccounts();
|
|
51
|
-
const publicKeys = await Promise.all(
|
|
52
|
-
INITIAL_TEST_SECRET_KEYS.map(async initialSecretKey => {
|
|
53
|
-
const initialEncryptionKey = deriveMasterIncomingViewingSecretKey(initialSecretKey);
|
|
54
|
-
const publicKey = await generatePublicKey(initialEncryptionKey);
|
|
55
|
-
return { sk: initialSecretKey, pk: publicKey };
|
|
56
|
-
}),
|
|
57
|
-
);
|
|
58
|
-
return Promise.all(
|
|
59
|
-
publicKeys
|
|
60
|
-
.filter(keyPairs => {
|
|
61
|
-
return (
|
|
62
|
-
registeredAccounts.find(registered =>
|
|
63
|
-
registered.publicKeys.masterIncomingViewingPublicKey.equals(keyPairs.pk),
|
|
64
|
-
) != undefined
|
|
65
|
-
);
|
|
66
|
-
})
|
|
67
|
-
.map(async keyPairs => {
|
|
68
|
-
const signingKey = deriveSigningKey(keyPairs.sk);
|
|
69
|
-
// TODO(#5726): use actual salt here instead of hardcoding Fr.ZERO
|
|
70
|
-
const account = await getSchnorrAccount(pxe, keyPairs.sk, signingKey, Fr.ZERO);
|
|
71
|
-
return account.getWallet();
|
|
72
|
-
}),
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Deploys the initial set of schnorr signature accounts to the test environment
|
|
78
|
-
* @param pxe - PXE instance.
|
|
79
|
-
* @returns The set of deployed Account objects and associated private encryption keys
|
|
20
|
+
* Data for generating an initial account.
|
|
80
21
|
*/
|
|
81
|
-
export
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
const deployWallet = new SignerlessWallet(pxe, new DefaultMultiCallEntrypoint(chainId, protocolVersion));
|
|
99
|
-
await (await registerContractClass(deployWallet, SchnorrAccountContractArtifact)).send().wait();
|
|
100
|
-
// Attempt to get as much parallelism as possible
|
|
101
|
-
const deployTxs = await Promise.all(
|
|
102
|
-
accounts.map(async x => {
|
|
103
|
-
const deployMethod = await x.account.getDeployMethod();
|
|
104
|
-
const tx = await deployMethod.prove({
|
|
105
|
-
contractAddressSalt: new Fr(x.account.salt),
|
|
106
|
-
universalDeploy: true,
|
|
107
|
-
});
|
|
108
|
-
return tx;
|
|
109
|
-
}),
|
|
110
|
-
);
|
|
111
|
-
// Send tx together to try and get them in the same rollup
|
|
112
|
-
const sentTxs = deployTxs.map(tx => {
|
|
113
|
-
return tx.send();
|
|
114
|
-
});
|
|
115
|
-
await Promise.all(
|
|
116
|
-
sentTxs.map(tx => {
|
|
117
|
-
return tx.wait();
|
|
118
|
-
}),
|
|
119
|
-
);
|
|
120
|
-
return accounts;
|
|
22
|
+
export interface InitialAccountData {
|
|
23
|
+
/**
|
|
24
|
+
* Secret to derive the keys for the account.
|
|
25
|
+
*/
|
|
26
|
+
secret: Fr;
|
|
27
|
+
/**
|
|
28
|
+
* Signing key od the account.
|
|
29
|
+
*/
|
|
30
|
+
signingKey: GrumpkinScalar;
|
|
31
|
+
/**
|
|
32
|
+
* Contract address salt.
|
|
33
|
+
*/
|
|
34
|
+
salt: Fr;
|
|
35
|
+
/**
|
|
36
|
+
* Address of the schnorr account contract.
|
|
37
|
+
*/
|
|
38
|
+
address: AztecAddress;
|
|
121
39
|
}
|
|
@@ -1,71 +1,93 @@
|
|
|
1
|
-
import { type WaitOpts } from '@aztec/aztec.js';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { Fr, deriveSigningKey } from '@aztec/circuits.js';
|
|
1
|
+
import { type AccountManager, FeeJuicePaymentMethod, type PXE, type WaitOpts } from '@aztec/aztec.js';
|
|
2
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
3
|
+
import { deriveSigningKey } from '@aztec/stdlib/keys';
|
|
5
4
|
|
|
6
|
-
import { getSchnorrAccount } from '../schnorr/index.js';
|
|
5
|
+
import { getSchnorrAccount, getSchnorrAccountContractAddress } from '../schnorr/index.js';
|
|
6
|
+
import type { InitialAccountData } from './configuration.js';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
10
|
-
* @param pxe - PXE.
|
|
11
|
-
* @returns - A wallet for a fresh account.
|
|
9
|
+
* Generate a fixed amount of random schnorr account contract instance.
|
|
12
10
|
*/
|
|
13
|
-
export async function
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
export async function generateSchnorrAccounts(numberOfAccounts: number) {
|
|
12
|
+
const secrets = Array.from({ length: numberOfAccounts }, () => Fr.random());
|
|
13
|
+
return await Promise.all(
|
|
14
|
+
secrets.map(async secret => {
|
|
15
|
+
const salt = Fr.random();
|
|
16
|
+
return {
|
|
17
|
+
secret,
|
|
18
|
+
signingKey: deriveSigningKey(secret),
|
|
19
|
+
salt,
|
|
20
|
+
address: await getSchnorrAccountContractAddress(secret, salt),
|
|
21
|
+
};
|
|
22
|
+
}),
|
|
23
|
+
);
|
|
18
24
|
}
|
|
19
25
|
|
|
20
26
|
/**
|
|
21
|
-
*
|
|
22
|
-
* @param pxe - PXE.
|
|
23
|
-
* @param numberOfAccounts - How many accounts to create.
|
|
24
|
-
* @param secrets - Optional array of secrets to use for the accounts. If empty, random secrets will be generated.
|
|
25
|
-
* @throws If the secrets array is not empty and does not have the same length as the number of accounts.
|
|
26
|
-
* @returns The created account wallets.
|
|
27
|
+
* Data for deploying funded account.
|
|
27
28
|
*/
|
|
28
|
-
|
|
29
|
+
type DeployAccountData = Pick<InitialAccountData, 'secret' | 'salt'> & {
|
|
30
|
+
/**
|
|
31
|
+
* An optional signingKey if it's not derived from the secret.
|
|
32
|
+
*/
|
|
33
|
+
signingKey?: InitialAccountData['signingKey'];
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Deploy schnorr account contract.
|
|
38
|
+
* It will pay for the fee for the deployment itself. So it must be funded with the prefilled public data.
|
|
39
|
+
*/
|
|
40
|
+
export async function deployFundedSchnorrAccount(
|
|
29
41
|
pxe: PXE,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
42
|
+
account: DeployAccountData,
|
|
43
|
+
opts: WaitOpts & {
|
|
44
|
+
/**
|
|
45
|
+
* Whether or not to skip registering contract class.
|
|
46
|
+
*/
|
|
47
|
+
skipClassRegistration?: boolean;
|
|
48
|
+
} = { interval: 0.1, skipClassRegistration: false },
|
|
49
|
+
): Promise<AccountManager> {
|
|
50
|
+
const signingKey = account.signingKey ?? deriveSigningKey(account.secret);
|
|
51
|
+
const accountManager = await getSchnorrAccount(pxe, account.secret, signingKey, account.salt);
|
|
39
52
|
|
|
40
|
-
//
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const signingKey = deriveSigningKey(secret);
|
|
44
|
-
const account = await getSchnorrAccount(pxe, secret, signingKey);
|
|
53
|
+
// Pay the fee by the account itself.
|
|
54
|
+
// This only works when the world state is prefilled with the balance for the account in test environment.
|
|
55
|
+
const paymentMethod = new FeeJuicePaymentMethod(accountManager.getAddress());
|
|
45
56
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
skipClassRegistration = false;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
57
|
+
await accountManager
|
|
58
|
+
.deploy({
|
|
59
|
+
skipClassRegistration: opts.skipClassRegistration,
|
|
60
|
+
skipPublicDeployment: true,
|
|
61
|
+
fee: { paymentMethod },
|
|
62
|
+
})
|
|
63
|
+
.wait(opts);
|
|
56
64
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
contractAddressSalt: new Fr(account.salt),
|
|
60
|
-
skipClassRegistration,
|
|
61
|
-
skipPublicDeployment: true,
|
|
62
|
-
universalDeploy: true,
|
|
63
|
-
});
|
|
64
|
-
return { account, provenTx };
|
|
65
|
-
}),
|
|
66
|
-
);
|
|
65
|
+
return accountManager;
|
|
66
|
+
}
|
|
67
67
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
/**
|
|
69
|
+
* Deploy schnorr account contracts.
|
|
70
|
+
* They will pay for the fees for the deployment themselves. So they must be funded with the prefilled public data.
|
|
71
|
+
*/
|
|
72
|
+
export async function deployFundedSchnorrAccounts(
|
|
73
|
+
pxe: PXE,
|
|
74
|
+
accounts: DeployAccountData[],
|
|
75
|
+
opts: WaitOpts & {
|
|
76
|
+
/**
|
|
77
|
+
* Whether or not to skip registering contract class.
|
|
78
|
+
*/
|
|
79
|
+
skipClassRegistration?: boolean;
|
|
80
|
+
} = { interval: 0.1, skipClassRegistration: false },
|
|
81
|
+
): Promise<AccountManager[]> {
|
|
82
|
+
const accountManagers: AccountManager[] = [];
|
|
83
|
+
// Serial due to https://github.com/AztecProtocol/aztec-packages/issues/12045
|
|
84
|
+
for (let i = 0; i < accounts.length; i++) {
|
|
85
|
+
accountManagers.push(
|
|
86
|
+
await deployFundedSchnorrAccount(pxe, accounts[i], {
|
|
87
|
+
...opts,
|
|
88
|
+
skipClassRegistration: i !== 0 || opts.skipClassRegistration, // Register the contract class at most once.
|
|
89
|
+
}),
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
return accountManagers;
|
|
71
93
|
}
|
package/src/testing/index.ts
CHANGED
|
@@ -1,11 +1,92 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The `@aztec/accounts/testing` export provides utility methods for testing, in particular in a Sandbox environment.
|
|
3
3
|
*
|
|
4
|
-
* Use
|
|
5
|
-
* or use {@link getInitialTestAccountsWallets} to obtain a list of wallets for the Sandbox pre-seeded accounts.
|
|
4
|
+
* Use {@link getInitialTestAccountsWallets} to obtain a list of wallets for the Sandbox pre-seeded accounts.
|
|
6
5
|
*
|
|
7
6
|
* @packageDocumentation
|
|
8
7
|
*/
|
|
8
|
+
import type { PXE } from '@aztec/aztec.js';
|
|
9
|
+
import type { AccountWalletWithSecretKey } from '@aztec/aztec.js/wallet';
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
import {
|
|
12
|
+
getSchnorrAccount,
|
|
13
|
+
getSchnorrAccountContractAddress,
|
|
14
|
+
getSchnorrWalletWithSecretKey,
|
|
15
|
+
} from '../schnorr/index.js';
|
|
16
|
+
import type { InitialAccountData } from './configuration.js';
|
|
17
|
+
import {
|
|
18
|
+
INITIAL_TEST_ACCOUNT_SALTS,
|
|
19
|
+
INITIAL_TEST_ENCRYPTION_KEYS,
|
|
20
|
+
INITIAL_TEST_SECRET_KEYS,
|
|
21
|
+
INITIAL_TEST_SIGNING_KEYS,
|
|
22
|
+
} from './configuration.js';
|
|
23
|
+
|
|
24
|
+
export {
|
|
25
|
+
type InitialAccountData,
|
|
26
|
+
INITIAL_TEST_ACCOUNT_SALTS,
|
|
27
|
+
INITIAL_TEST_ENCRYPTION_KEYS,
|
|
28
|
+
INITIAL_TEST_SECRET_KEYS,
|
|
29
|
+
INITIAL_TEST_SIGNING_KEYS,
|
|
30
|
+
} from './configuration.js';
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Gets the basic information for initial test accounts.
|
|
34
|
+
*/
|
|
35
|
+
export function getInitialTestAccounts(): Promise<InitialAccountData[]> {
|
|
36
|
+
return Promise.all(
|
|
37
|
+
INITIAL_TEST_SECRET_KEYS.map(async (secret, i) => ({
|
|
38
|
+
secret,
|
|
39
|
+
signingKey: INITIAL_TEST_ENCRYPTION_KEYS[i],
|
|
40
|
+
salt: INITIAL_TEST_ACCOUNT_SALTS[i],
|
|
41
|
+
address: await getSchnorrAccountContractAddress(
|
|
42
|
+
secret,
|
|
43
|
+
INITIAL_TEST_ACCOUNT_SALTS[i],
|
|
44
|
+
INITIAL_TEST_SIGNING_KEYS[i],
|
|
45
|
+
),
|
|
46
|
+
})),
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Gets a collection of wallets for the Aztec accounts that are initially stored in the test environment.
|
|
52
|
+
* @param pxe - PXE instance.
|
|
53
|
+
* @returns A set of AccountWallet implementations for each of the initial accounts.
|
|
54
|
+
*/
|
|
55
|
+
export function getInitialTestAccountsWallets(pxe: PXE): Promise<AccountWalletWithSecretKey[]> {
|
|
56
|
+
return Promise.all(
|
|
57
|
+
INITIAL_TEST_SECRET_KEYS.map(async (encryptionKey, i) => {
|
|
58
|
+
const account = await getSchnorrAccount(
|
|
59
|
+
pxe,
|
|
60
|
+
encryptionKey!,
|
|
61
|
+
INITIAL_TEST_SIGNING_KEYS[i]!,
|
|
62
|
+
INITIAL_TEST_ACCOUNT_SALTS[i],
|
|
63
|
+
);
|
|
64
|
+
return account.getWallet();
|
|
65
|
+
}),
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Queries a PXE for it's registered accounts.
|
|
71
|
+
* @param pxe - PXE instance.
|
|
72
|
+
* @returns A set of key data for each of the initial accounts.
|
|
73
|
+
*/
|
|
74
|
+
export async function getDeployedTestAccounts(pxe: PXE): Promise<InitialAccountData[]> {
|
|
75
|
+
const registeredAccounts = await pxe.getRegisteredAccounts();
|
|
76
|
+
const testAccounts = await getInitialTestAccounts();
|
|
77
|
+
return testAccounts.filter(t => registeredAccounts.some(r => r.address.equals(t.address)));
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Queries a PXE for it's registered accounts and returns wallets for those accounts using keys in the initial test accounts.
|
|
82
|
+
* @param pxe - PXE instance.
|
|
83
|
+
* @returns A set of AccountWallet implementations for each of the initial accounts.
|
|
84
|
+
*/
|
|
85
|
+
export async function getDeployedTestAccountsWallets(pxe: PXE): Promise<AccountWalletWithSecretKey[]> {
|
|
86
|
+
const testAccounts = await getDeployedTestAccounts(pxe);
|
|
87
|
+
return Promise.all(
|
|
88
|
+
testAccounts.map(({ secret, signingKey, salt }) => getSchnorrWalletWithSecretKey(pxe, secret, signingKey, salt)),
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export { deployFundedSchnorrAccount, deployFundedSchnorrAccounts, generateSchnorrAccounts } from './create_account.js';
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `@aztec/accounts/testing/lazy` export provides utility methods for testing, in particular in a Sandbox environment.
|
|
3
|
+
*
|
|
4
|
+
* Use {@link getInitialTestAccountsWallets} to obtain a list of wallets for the Sandbox pre-seeded accounts.
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
import type { PXE } from '@aztec/aztec.js';
|
|
9
|
+
import type { AccountWalletWithSecretKey } from '@aztec/aztec.js/wallet';
|
|
10
|
+
|
|
11
|
+
import { getSchnorrAccount, getSchnorrAccountContractAddress, getSchnorrWalletWithSecretKey } from '../schnorr/lazy.js';
|
|
12
|
+
import {
|
|
13
|
+
INITIAL_TEST_ACCOUNT_SALTS,
|
|
14
|
+
INITIAL_TEST_ENCRYPTION_KEYS,
|
|
15
|
+
INITIAL_TEST_SECRET_KEYS,
|
|
16
|
+
INITIAL_TEST_SIGNING_KEYS,
|
|
17
|
+
type InitialAccountData,
|
|
18
|
+
} from './configuration.js';
|
|
19
|
+
|
|
20
|
+
export {
|
|
21
|
+
type InitialAccountData,
|
|
22
|
+
INITIAL_TEST_ACCOUNT_SALTS,
|
|
23
|
+
INITIAL_TEST_ENCRYPTION_KEYS,
|
|
24
|
+
INITIAL_TEST_SECRET_KEYS,
|
|
25
|
+
INITIAL_TEST_SIGNING_KEYS,
|
|
26
|
+
} from './configuration.js';
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Gets the basic information for initial test accounts.
|
|
30
|
+
*/
|
|
31
|
+
export function getInitialTestAccounts(): Promise<InitialAccountData[]> {
|
|
32
|
+
return Promise.all(
|
|
33
|
+
INITIAL_TEST_SECRET_KEYS.map(async (secret, i) => ({
|
|
34
|
+
secret,
|
|
35
|
+
signingKey: INITIAL_TEST_ENCRYPTION_KEYS[i],
|
|
36
|
+
salt: INITIAL_TEST_ACCOUNT_SALTS[i],
|
|
37
|
+
address: await getSchnorrAccountContractAddress(
|
|
38
|
+
secret,
|
|
39
|
+
INITIAL_TEST_ACCOUNT_SALTS[i],
|
|
40
|
+
INITIAL_TEST_SIGNING_KEYS[i],
|
|
41
|
+
),
|
|
42
|
+
})),
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Gets a collection of wallets for the Aztec accounts that are initially stored in the test environment.
|
|
48
|
+
* @param pxe - PXE instance.
|
|
49
|
+
* @returns A set of AccountWallet implementations for each of the initial accounts.
|
|
50
|
+
*/
|
|
51
|
+
export function getInitialTestAccountsWallets(pxe: PXE): Promise<AccountWalletWithSecretKey[]> {
|
|
52
|
+
return Promise.all(
|
|
53
|
+
INITIAL_TEST_SECRET_KEYS.map(async (encryptionKey, i) => {
|
|
54
|
+
const account = await getSchnorrAccount(
|
|
55
|
+
pxe,
|
|
56
|
+
encryptionKey!,
|
|
57
|
+
INITIAL_TEST_SIGNING_KEYS[i]!,
|
|
58
|
+
INITIAL_TEST_ACCOUNT_SALTS[i],
|
|
59
|
+
);
|
|
60
|
+
return account.getWallet();
|
|
61
|
+
}),
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Queries a PXE for it's registered accounts.
|
|
67
|
+
* @param pxe - PXE instance.
|
|
68
|
+
* @returns A set of key data for each of the initial accounts.
|
|
69
|
+
*/
|
|
70
|
+
export async function getDeployedTestAccounts(pxe: PXE): Promise<InitialAccountData[]> {
|
|
71
|
+
const registeredAccounts = await pxe.getRegisteredAccounts();
|
|
72
|
+
const testAccounts = await getInitialTestAccounts();
|
|
73
|
+
return testAccounts.filter(t => registeredAccounts.some(r => r.address.equals(t.address)));
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Queries a PXE for it's registered accounts and returns wallets for those accounts using keys in the initial test accounts.
|
|
78
|
+
* @param pxe - PXE instance.
|
|
79
|
+
* @returns A set of AccountWallet implementations for each of the initial accounts.
|
|
80
|
+
*/
|
|
81
|
+
export async function getDeployedTestAccountsWallets(pxe: PXE): Promise<AccountWalletWithSecretKey[]> {
|
|
82
|
+
const testAccounts = await getDeployedTestAccounts(pxe);
|
|
83
|
+
return Promise.all(
|
|
84
|
+
testAccounts.map(({ secret, signingKey, salt }) => getSchnorrWalletWithSecretKey(pxe, secret, signingKey, salt)),
|
|
85
|
+
);
|
|
86
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"artifact.d.ts","sourceRoot":"","sources":["../../../src/ecdsa/ecdsa_k/artifact.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAmD,MAAM,iBAAiB,CAAC;AAIzG,eAAO,MAAM,6BAA6B,EAAE,gBAE3C,CAAC"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { loadContractArtifact } from '@aztec/aztec.js';
|
|
2
|
-
import EcdsaKAccountContractJson from '../../../artifacts/EcdsaKAccount.json' assert { type: 'json' };
|
|
3
|
-
export const EcdsaKAccountContractArtifact = loadContractArtifact(EcdsaKAccountContractJson);
|
|
4
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXJ0aWZhY3QuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvZWNkc2EvZWNkc2Ffay9hcnRpZmFjdC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQW9ELG9CQUFvQixFQUFFLE1BQU0saUJBQWlCLENBQUM7QUFFekcsT0FBTyx5QkFBeUIsTUFBTSx1Q0FBdUMsQ0FBQyxTQUFTLElBQUksRUFBRSxNQUFNLEVBQUUsQ0FBQztBQUV0RyxNQUFNLENBQUMsTUFBTSw2QkFBNkIsR0FBcUIsb0JBQW9CLENBQ2pGLHlCQUFpRCxDQUNsRCxDQUFDIn0=
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"artifact.d.ts","sourceRoot":"","sources":["../../../src/ecdsa/ssh_ecdsa_r/artifact.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,6BAA6B,4CAA0E,CAAC"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { loadContractArtifact } from '@aztec/aztec.js';
|
|
2
|
-
import EcdsaRAccountContractJson from '../../../artifacts/EcdsaRAccount.json' assert { type: 'json' };
|
|
3
|
-
export const EcdsaRAccountContractArtifact = loadContractArtifact(EcdsaRAccountContractJson);
|
|
4
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXJ0aWZhY3QuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvZWNkc2Evc3NoX2VjZHNhX3IvYXJ0aWZhY3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUE2QixvQkFBb0IsRUFBRSxNQUFNLGlCQUFpQixDQUFDO0FBRWxGLE9BQU8seUJBQXlCLE1BQU0sdUNBQXVDLENBQUMsU0FBUyxJQUFJLEVBQUUsTUFBTSxFQUFFLENBQUM7QUFFdEcsTUFBTSxDQUFDLE1BQU0sNkJBQTZCLEdBQUcsb0JBQW9CLENBQUMseUJBQWlELENBQUMsQ0FBQyJ9
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"artifact.d.ts","sourceRoot":"","sources":["../../src/schnorr/artifact.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,8BAA8B,4CAA2E,CAAC"}
|
package/dest/schnorr/artifact.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { loadContractArtifact } from '@aztec/aztec.js';
|
|
2
|
-
import SchnorrAccountContractJson from '../../artifacts/SchnorrAccount.json' assert { type: 'json' };
|
|
3
|
-
export const SchnorrAccountContractArtifact = loadContractArtifact(SchnorrAccountContractJson);
|
|
4
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXJ0aWZhY3QuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvc2Nobm9yci9hcnRpZmFjdC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQTZCLG9CQUFvQixFQUFFLE1BQU0saUJBQWlCLENBQUM7QUFFbEYsT0FBTywwQkFBMEIsTUFBTSxxQ0FBcUMsQ0FBQyxTQUFTLElBQUksRUFBRSxNQUFNLEVBQUUsQ0FBQztBQUVyRyxNQUFNLENBQUMsTUFBTSw4QkFBOEIsR0FBRyxvQkFBb0IsQ0FBQywwQkFBa0QsQ0FBQyxDQUFDIn0=
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"artifact.d.ts","sourceRoot":"","sources":["../../src/single_key/artifact.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,uCAAuC,4CAEnD,CAAC"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { loadContractArtifact } from '@aztec/aztec.js';
|
|
2
|
-
import SchnorrSingleKeyAccountContractJson from '../../artifacts/SchnorrSingleKeyAccount.json' assert { type: 'json' };
|
|
3
|
-
export const SchnorrSingleKeyAccountContractArtifact = loadContractArtifact(SchnorrSingleKeyAccountContractJson);
|
|
4
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXJ0aWZhY3QuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvc2luZ2xlX2tleS9hcnRpZmFjdC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQTZCLG9CQUFvQixFQUFFLE1BQU0saUJBQWlCLENBQUM7QUFFbEYsT0FBTyxtQ0FBbUMsTUFBTSw4Q0FBOEMsQ0FBQyxTQUFTLElBQUksRUFBRSxNQUFNLEVBQUUsQ0FBQztBQUV2SCxNQUFNLENBQUMsTUFBTSx1Q0FBdUMsR0FBRyxvQkFBb0IsQ0FDekUsbUNBQTJELENBQzVELENBQUMifQ==
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { type ContractArtifact, type NoirCompiledContract, loadContractArtifact } from '@aztec/aztec.js';
|
|
2
|
-
|
|
3
|
-
import EcdsaKAccountContractJson from '../../../artifacts/EcdsaKAccount.json' assert { type: 'json' };
|
|
4
|
-
|
|
5
|
-
export const EcdsaKAccountContractArtifact: ContractArtifact = loadContractArtifact(
|
|
6
|
-
EcdsaKAccountContractJson as NoirCompiledContract,
|
|
7
|
-
);
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { type NoirCompiledContract, loadContractArtifact } from '@aztec/aztec.js';
|
|
2
|
-
|
|
3
|
-
import EcdsaRAccountContractJson from '../../../artifacts/EcdsaRAccount.json' assert { type: 'json' };
|
|
4
|
-
|
|
5
|
-
export const EcdsaRAccountContractArtifact = loadContractArtifact(EcdsaRAccountContractJson as NoirCompiledContract);
|
package/src/schnorr/artifact.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { type NoirCompiledContract, loadContractArtifact } from '@aztec/aztec.js';
|
|
2
|
-
|
|
3
|
-
import SchnorrAccountContractJson from '../../artifacts/SchnorrAccount.json' assert { type: 'json' };
|
|
4
|
-
|
|
5
|
-
export const SchnorrAccountContractArtifact = loadContractArtifact(SchnorrAccountContractJson as NoirCompiledContract);
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { type NoirCompiledContract, loadContractArtifact } from '@aztec/aztec.js';
|
|
2
|
-
|
|
3
|
-
import SchnorrSingleKeyAccountContractJson from '../../artifacts/SchnorrSingleKeyAccount.json' assert { type: 'json' };
|
|
4
|
-
|
|
5
|
-
export const SchnorrSingleKeyAccountContractArtifact = loadContractArtifact(
|
|
6
|
-
SchnorrSingleKeyAccountContractJson as NoirCompiledContract,
|
|
7
|
-
);
|