@aztec/accounts 0.0.1-fake-ceab37513c → 0.0.6-commit.a2d1860fe9
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 +1 -1
- package/artifacts/EcdsaKAccount.json +3320 -3683
- package/artifacts/EcdsaRAccount.json +3320 -3683
- package/artifacts/SchnorrAccount.json +3370 -3898
- package/artifacts/SchnorrSingleKeyAccount.json +2275 -2325
- package/artifacts/SimulatedAccount.json +2074 -2292
- package/dest/defaults/account_contract.d.ts +4 -4
- package/dest/defaults/account_contract.d.ts.map +1 -1
- package/dest/defaults/account_contract.js +5 -3
- package/dest/defaults/index.d.ts +2 -3
- package/dest/defaults/index.d.ts.map +1 -1
- package/dest/defaults/index.js +2 -3
- package/dest/ecdsa/ecdsa_k/account_contract.d.ts +1 -1
- package/dest/ecdsa/ecdsa_k/account_contract.d.ts.map +1 -1
- package/dest/ecdsa/ecdsa_k/account_contract.js +1 -1
- package/dest/ecdsa/ecdsa_k/index.d.ts +1 -23
- package/dest/ecdsa/ecdsa_k/index.d.ts.map +1 -1
- package/dest/ecdsa/ecdsa_k/index.js +1 -22
- package/dest/ecdsa/ecdsa_k/lazy.d.ts +1 -23
- package/dest/ecdsa/ecdsa_k/lazy.d.ts.map +1 -1
- package/dest/ecdsa/ecdsa_k/lazy.js +5 -26
- package/dest/ecdsa/ecdsa_r/account_contract.d.ts +1 -1
- package/dest/ecdsa/ecdsa_r/account_contract.d.ts.map +1 -1
- package/dest/ecdsa/ecdsa_r/account_contract.js +1 -1
- package/dest/ecdsa/ecdsa_r/index.d.ts +1 -23
- package/dest/ecdsa/ecdsa_r/index.d.ts.map +1 -1
- package/dest/ecdsa/ecdsa_r/index.js +1 -22
- package/dest/ecdsa/ecdsa_r/lazy.d.ts +1 -23
- package/dest/ecdsa/ecdsa_r/lazy.d.ts.map +1 -1
- package/dest/ecdsa/ecdsa_r/lazy.js +5 -26
- package/dest/ecdsa/index.d.ts +1 -1
- package/dest/ecdsa/lazy.d.ts +1 -1
- package/dest/ecdsa/ssh_ecdsa_r/account_contract.d.ts +1 -1
- package/dest/ecdsa/ssh_ecdsa_r/account_contract.d.ts.map +1 -1
- package/dest/ecdsa/ssh_ecdsa_r/account_contract.js +1 -1
- package/dest/ecdsa/ssh_ecdsa_r/index.d.ts +2 -24
- package/dest/ecdsa/ssh_ecdsa_r/index.d.ts.map +1 -1
- package/dest/ecdsa/ssh_ecdsa_r/index.js +3 -24
- package/dest/ecdsa/ssh_ecdsa_r/lazy.d.ts +2 -24
- package/dest/ecdsa/ssh_ecdsa_r/lazy.d.ts.map +1 -1
- package/dest/ecdsa/ssh_ecdsa_r/lazy.js +3 -24
- package/dest/schnorr/account_contract.d.ts +3 -2
- package/dest/schnorr/account_contract.d.ts.map +1 -1
- package/dest/schnorr/account_contract.js +1 -1
- package/dest/schnorr/index.d.ts +4 -38
- package/dest/schnorr/index.d.ts.map +1 -1
- package/dest/schnorr/index.js +1 -32
- package/dest/schnorr/lazy.d.ts +4 -38
- package/dest/schnorr/lazy.d.ts.map +1 -1
- package/dest/schnorr/lazy.js +5 -36
- package/dest/single_key/account_contract.d.ts +2 -2
- package/dest/single_key/account_contract.d.ts.map +1 -1
- package/dest/single_key/account_contract.js +1 -1
- package/dest/single_key/index.d.ts +2 -21
- package/dest/single_key/index.d.ts.map +1 -1
- package/dest/single_key/index.js +1 -23
- package/dest/single_key/lazy.d.ts +2 -21
- package/dest/single_key/lazy.d.ts.map +1 -1
- package/dest/single_key/lazy.js +5 -27
- package/dest/stub/account_contract.d.ts +29 -0
- package/dest/stub/account_contract.d.ts.map +1 -0
- package/dest/stub/account_contract.js +30 -0
- package/dest/stub/index.d.ts +20 -0
- package/dest/stub/index.d.ts.map +1 -0
- package/dest/stub/index.js +28 -0
- package/dest/stub/lazy.d.ts +25 -0
- package/dest/stub/lazy.d.ts.map +1 -0
- package/dest/stub/lazy.js +37 -0
- package/dest/testing/configuration.d.ts +5 -4
- package/dest/testing/configuration.d.ts.map +1 -1
- package/dest/testing/configuration.js +1 -1
- package/dest/testing/index.d.ts +6 -36
- package/dest/testing/index.d.ts.map +1 -1
- package/dest/testing/index.js +19 -35
- package/dest/testing/lazy.d.ts +5 -28
- package/dest/testing/lazy.d.ts.map +1 -1
- package/dest/testing/lazy.js +19 -30
- package/dest/utils/index.d.ts +1 -1
- package/dest/utils/ssh_agent.d.ts +1 -1
- package/package.json +12 -9
- package/src/defaults/account_contract.ts +10 -6
- package/src/defaults/index.ts +1 -2
- package/src/ecdsa/ecdsa_k/account_contract.ts +2 -2
- package/src/ecdsa/ecdsa_k/index.ts +0 -32
- package/src/ecdsa/ecdsa_k/lazy.ts +4 -36
- package/src/ecdsa/ecdsa_r/account_contract.ts +2 -2
- package/src/ecdsa/ecdsa_r/index.ts +0 -32
- package/src/ecdsa/ecdsa_r/lazy.ts +4 -36
- package/src/ecdsa/ssh_ecdsa_r/account_contract.ts +2 -2
- package/src/ecdsa/ssh_ecdsa_r/index.ts +2 -35
- package/src/ecdsa/ssh_ecdsa_r/lazy.ts +2 -35
- package/src/schnorr/account_contract.ts +3 -2
- package/src/schnorr/index.ts +9 -56
- package/src/schnorr/lazy.ts +13 -60
- package/src/single_key/account_contract.ts +3 -2
- package/src/single_key/index.ts +1 -32
- package/src/single_key/lazy.ts +5 -36
- package/src/stub/account_contract.ts +39 -0
- package/src/stub/index.ts +40 -0
- package/src/stub/lazy.ts +51 -0
- package/src/testing/configuration.ts +2 -1
- package/src/testing/index.ts +20 -57
- package/src/testing/lazy.ts +18 -50
- package/dest/copy_cat/base.d.ts +0 -18
- package/dest/copy_cat/base.d.ts.map +0 -1
- package/dest/copy_cat/base.js +0 -28
- package/dest/copy_cat/index.d.ts +0 -10
- package/dest/copy_cat/index.d.ts.map +0 -1
- package/dest/copy_cat/index.js +0 -31
- package/dest/copy_cat/lazy.d.ts +0 -9
- package/dest/copy_cat/lazy.d.ts.map +0 -1
- package/dest/copy_cat/lazy.js +0 -29
- package/dest/defaults/account_interface.d.ts +0 -28
- package/dest/defaults/account_interface.d.ts.map +0 -1
- package/dest/defaults/account_interface.js +0 -37
- package/dest/testing/create_account.d.ts +0 -43
- package/dest/testing/create_account.d.ts.map +0 -1
- package/dest/testing/create_account.js +0 -61
- package/src/copy_cat/base.ts +0 -47
- package/src/copy_cat/index.ts +0 -44
- package/src/copy_cat/lazy.ts +0 -40
- package/src/defaults/account_interface.ts +0 -64
- package/src/testing/create_account.ts +0 -111
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { BaseAccount } from '@aztec/aztec.js/account';
|
|
2
|
+
import type { CompleteAddress } from '@aztec/aztec.js/addresses';
|
|
3
|
+
import { DefaultAccountEntrypoint } from '@aztec/entrypoints/account';
|
|
4
|
+
import type { ContractArtifact } from '@aztec/stdlib/abi';
|
|
5
|
+
import { loadContractArtifact } from '@aztec/stdlib/abi';
|
|
6
|
+
import type { NoirCompiledContract } from '@aztec/stdlib/noir';
|
|
7
|
+
|
|
8
|
+
import SimulatedAccountContract from '../../artifacts/SimulatedAccount.json' with { type: 'json' };
|
|
9
|
+
import { StubBaseAccountContract } from './account_contract.js';
|
|
10
|
+
|
|
11
|
+
export const StubAccountContractArtifact = loadContractArtifact(SimulatedAccountContract as NoirCompiledContract);
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Stub account contract
|
|
15
|
+
* Eagerly loads the contract artifact
|
|
16
|
+
*/
|
|
17
|
+
export class StubAccountContract extends StubBaseAccountContract {
|
|
18
|
+
constructor() {
|
|
19
|
+
super();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
override getContractArtifact(): Promise<ContractArtifact> {
|
|
23
|
+
return Promise.resolve(StubAccountContractArtifact);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Creates a stub account that impersonates the one with the provided originalAddress.
|
|
29
|
+
* @param originalAddress - The address of the account to stub
|
|
30
|
+
* @returns A stub account that can be used for kernelless simulations
|
|
31
|
+
*/
|
|
32
|
+
export function createStubAccount(originalAddress: CompleteAddress) {
|
|
33
|
+
const accountContract = new StubAccountContract();
|
|
34
|
+
const authWitnessProvider = accountContract.getAuthWitnessProvider(originalAddress);
|
|
35
|
+
return new BaseAccount(
|
|
36
|
+
new DefaultAccountEntrypoint(originalAddress.address, authWitnessProvider),
|
|
37
|
+
authWitnessProvider,
|
|
38
|
+
originalAddress,
|
|
39
|
+
);
|
|
40
|
+
}
|
package/src/stub/lazy.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { BaseAccount } from '@aztec/aztec.js/account';
|
|
2
|
+
import type { CompleteAddress } from '@aztec/aztec.js/addresses';
|
|
3
|
+
import { DefaultAccountEntrypoint } from '@aztec/entrypoints/account';
|
|
4
|
+
import type { ContractArtifact } from '@aztec/stdlib/abi';
|
|
5
|
+
import { loadContractArtifact } from '@aztec/stdlib/abi';
|
|
6
|
+
|
|
7
|
+
import { StubBaseAccountContract } from './account_contract.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Lazily loads the contract artifact
|
|
11
|
+
* @returns The contract artifact for the Stub account contract
|
|
12
|
+
*/
|
|
13
|
+
export async function getStubAccountContractArtifact() {
|
|
14
|
+
// Cannot assert this import as it's incompatible with bundlers like vite
|
|
15
|
+
// https://github.com/vitejs/vite/issues/19095#issuecomment-2566074352
|
|
16
|
+
// Even if now supported by al major browsers, the MIME type is replaced with
|
|
17
|
+
// "text/javascript"
|
|
18
|
+
// In the meantime, this lazy import is INCOMPATIBLE WITH NODEJS
|
|
19
|
+
const { default: StubAccountContractJson } = await import('../../artifacts/SimulatedAccount.json');
|
|
20
|
+
return loadContractArtifact(StubAccountContractJson);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Account contract that authenticates transactions using Stub signatures
|
|
25
|
+
* verified against a Grumpkin public key stored in an immutable encrypted note.
|
|
26
|
+
* Lazily loads the contract artifact
|
|
27
|
+
*/
|
|
28
|
+
export class StubAccountContract extends StubBaseAccountContract {
|
|
29
|
+
constructor() {
|
|
30
|
+
super();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
override getContractArtifact(): Promise<ContractArtifact> {
|
|
34
|
+
return getStubAccountContractArtifact();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Creates a stub account that impersonates the one with the provided originalAddress.
|
|
40
|
+
* @param originalAddress - The address of the account to stub
|
|
41
|
+
* @returns A stub account that can be used for kernelless simulations
|
|
42
|
+
*/
|
|
43
|
+
export function createStubAccount(originalAddress: CompleteAddress) {
|
|
44
|
+
const accountContract = new StubAccountContract();
|
|
45
|
+
const authWitnessProvider = accountContract.getAuthWitnessProvider(originalAddress);
|
|
46
|
+
return new BaseAccount(
|
|
47
|
+
new DefaultAccountEntrypoint(originalAddress.address, authWitnessProvider),
|
|
48
|
+
authWitnessProvider,
|
|
49
|
+
originalAddress,
|
|
50
|
+
);
|
|
51
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Fr
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import { GrumpkinScalar } from '@aztec/foundation/curves/grumpkin';
|
|
2
3
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
4
|
import { deriveMasterIncomingViewingSecretKey } from '@aztec/stdlib/keys';
|
|
4
5
|
|
package/src/testing/index.ts
CHANGED
|
@@ -1,38 +1,32 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The `@aztec/accounts/testing` export provides utility methods for testing, in particular in a
|
|
3
|
-
*
|
|
4
|
-
* Use {@link getInitialTestAccountsWallets} to obtain a list of wallets for the Sandbox pre-seeded accounts.
|
|
2
|
+
* The `@aztec/accounts/testing` export provides utility methods for testing, in particular in a local network environment.
|
|
5
3
|
*
|
|
6
4
|
* @packageDocumentation
|
|
7
5
|
*/
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
6
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
7
|
+
import { deriveSigningKey } from '@aztec/stdlib/keys';
|
|
10
8
|
|
|
11
|
-
import {
|
|
12
|
-
getSchnorrAccount,
|
|
13
|
-
getSchnorrAccountContractAddress,
|
|
14
|
-
getSchnorrWalletWithSecretKey,
|
|
15
|
-
} from '../schnorr/index.js';
|
|
16
|
-
import type { InitialAccountData } from './configuration.js';
|
|
9
|
+
import { getSchnorrAccountContractAddress } from '../schnorr/index.js';
|
|
17
10
|
import {
|
|
18
11
|
INITIAL_TEST_ACCOUNT_SALTS,
|
|
19
12
|
INITIAL_TEST_ENCRYPTION_KEYS,
|
|
20
13
|
INITIAL_TEST_SECRET_KEYS,
|
|
21
14
|
INITIAL_TEST_SIGNING_KEYS,
|
|
15
|
+
type InitialAccountData,
|
|
22
16
|
} from './configuration.js';
|
|
23
17
|
|
|
24
18
|
export {
|
|
25
|
-
type InitialAccountData,
|
|
26
19
|
INITIAL_TEST_ACCOUNT_SALTS,
|
|
27
20
|
INITIAL_TEST_ENCRYPTION_KEYS,
|
|
28
21
|
INITIAL_TEST_SECRET_KEYS,
|
|
29
22
|
INITIAL_TEST_SIGNING_KEYS,
|
|
23
|
+
type InitialAccountData,
|
|
30
24
|
} from './configuration.js';
|
|
31
25
|
|
|
32
26
|
/**
|
|
33
27
|
* Gets the basic information for initial test accounts.
|
|
34
28
|
*/
|
|
35
|
-
export function
|
|
29
|
+
export function getInitialTestAccountsData(): Promise<InitialAccountData[]> {
|
|
36
30
|
return Promise.all(
|
|
37
31
|
INITIAL_TEST_SECRET_KEYS.map(async (secret, i) => ({
|
|
38
32
|
secret,
|
|
@@ -48,50 +42,19 @@ export function getInitialTestAccounts(): Promise<InitialAccountData[]> {
|
|
|
48
42
|
}
|
|
49
43
|
|
|
50
44
|
/**
|
|
51
|
-
*
|
|
52
|
-
* @param pxe - PXE instance.
|
|
53
|
-
* @returns A set of AccountManager implementations for each of the initial accounts.
|
|
54
|
-
*/
|
|
55
|
-
export function getInitialTestAccountsManagers(pxe: PXE): Promise<AccountManager[]> {
|
|
56
|
-
return Promise.all(
|
|
57
|
-
INITIAL_TEST_SECRET_KEYS.map((encryptionKey, i) =>
|
|
58
|
-
getSchnorrAccount(pxe, encryptionKey!, INITIAL_TEST_SIGNING_KEYS[i]!, INITIAL_TEST_ACCOUNT_SALTS[i]),
|
|
59
|
-
),
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Gets a collection of wallets for the Aztec accounts that are initially stored in the test environment.
|
|
65
|
-
* @param pxe - PXE instance.
|
|
66
|
-
* @returns A set of AccountWallet implementations for each of the initial accounts.
|
|
67
|
-
*/
|
|
68
|
-
export async function getInitialTestAccountsWallets(pxe: PXE): Promise<AccountWalletWithSecretKey[]> {
|
|
69
|
-
return Promise.all(
|
|
70
|
-
(await Promise.all(await getInitialTestAccountsManagers(pxe))).map(accountManager => accountManager.getWallet()),
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Queries a PXE for it's registered accounts.
|
|
76
|
-
* @param pxe - PXE instance.
|
|
77
|
-
* @returns A set of key data for each of the initial accounts.
|
|
78
|
-
*/
|
|
79
|
-
export async function getDeployedTestAccounts(pxe: PXE): Promise<InitialAccountData[]> {
|
|
80
|
-
const registeredAccounts = await pxe.getRegisteredAccounts();
|
|
81
|
-
const testAccounts = await getInitialTestAccounts();
|
|
82
|
-
return testAccounts.filter(t => registeredAccounts.some(r => r.address.equals(t.address)));
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Queries a PXE for it's registered accounts and returns wallets for those accounts using keys in the initial test accounts.
|
|
87
|
-
* @param pxe - PXE instance.
|
|
88
|
-
* @returns A set of AccountWallet implementations for each of the initial accounts.
|
|
45
|
+
* Generate a fixed amount of random schnorr account contract instance.
|
|
89
46
|
*/
|
|
90
|
-
export async function
|
|
91
|
-
const
|
|
92
|
-
return Promise.all(
|
|
93
|
-
|
|
47
|
+
export async function generateSchnorrAccounts(numberOfAccounts: number): Promise<Promise<InitialAccountData[]>> {
|
|
48
|
+
const secrets = Array.from({ length: numberOfAccounts }, () => Fr.random());
|
|
49
|
+
return await Promise.all(
|
|
50
|
+
secrets.map(async secret => {
|
|
51
|
+
const salt = Fr.random();
|
|
52
|
+
return {
|
|
53
|
+
secret,
|
|
54
|
+
signingKey: deriveSigningKey(secret),
|
|
55
|
+
salt,
|
|
56
|
+
address: await getSchnorrAccountContractAddress(secret, salt),
|
|
57
|
+
};
|
|
58
|
+
}),
|
|
94
59
|
);
|
|
95
60
|
}
|
|
96
|
-
|
|
97
|
-
export { deployFundedSchnorrAccount, deployFundedSchnorrAccounts, generateSchnorrAccounts } from './create_account.js';
|
package/src/testing/lazy.ts
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The `@aztec/accounts/testing/lazy` export provides utility methods for testing, in particular in a
|
|
3
|
-
*
|
|
4
|
-
* Use {@link getInitialTestAccountsWallets} to obtain a list of wallets for the Sandbox pre-seeded accounts.
|
|
2
|
+
* The `@aztec/accounts/testing/lazy` export provides utility methods for testing, in particular in a local network environment.
|
|
5
3
|
*
|
|
6
4
|
* @packageDocumentation
|
|
7
5
|
*/
|
|
8
|
-
import
|
|
9
|
-
import
|
|
6
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
7
|
+
import { deriveSigningKey } from '@aztec/stdlib/keys';
|
|
10
8
|
|
|
11
|
-
import {
|
|
9
|
+
import { getSchnorrAccountContractAddress } from '../schnorr/lazy.js';
|
|
12
10
|
import {
|
|
13
11
|
INITIAL_TEST_ACCOUNT_SALTS,
|
|
14
12
|
INITIAL_TEST_ENCRYPTION_KEYS,
|
|
@@ -17,18 +15,12 @@ import {
|
|
|
17
15
|
type InitialAccountData,
|
|
18
16
|
} from './configuration.js';
|
|
19
17
|
|
|
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';
|
|
18
|
+
export { INITIAL_TEST_ACCOUNT_SALTS, INITIAL_TEST_SECRET_KEYS } from './configuration.js';
|
|
27
19
|
|
|
28
20
|
/**
|
|
29
21
|
* Gets the basic information for initial test accounts.
|
|
30
22
|
*/
|
|
31
|
-
export function
|
|
23
|
+
export function getInitialTestAccountsData(): Promise<InitialAccountData[]> {
|
|
32
24
|
return Promise.all(
|
|
33
25
|
INITIAL_TEST_SECRET_KEYS.map(async (secret, i) => ({
|
|
34
26
|
secret,
|
|
@@ -44,43 +36,19 @@ export function getInitialTestAccounts(): Promise<InitialAccountData[]> {
|
|
|
44
36
|
}
|
|
45
37
|
|
|
46
38
|
/**
|
|
47
|
-
*
|
|
48
|
-
* @param pxe - PXE instance.
|
|
49
|
-
* @returns A set of AccountWallet implementations for each of the initial accounts.
|
|
39
|
+
* Generate a fixed amount of random schnorr account contract instance.
|
|
50
40
|
*/
|
|
51
|
-
export function
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
41
|
+
export async function generateSchnorrAccounts(numberOfAccounts: number): Promise<InitialAccountData[]> {
|
|
42
|
+
const secrets = Array.from({ length: numberOfAccounts }, () => Fr.random());
|
|
43
|
+
return await Promise.all(
|
|
44
|
+
secrets.map(async secret => {
|
|
45
|
+
const salt = Fr.random();
|
|
46
|
+
return {
|
|
47
|
+
secret,
|
|
48
|
+
signingKey: deriveSigningKey(secret),
|
|
49
|
+
salt,
|
|
50
|
+
address: await getSchnorrAccountContractAddress(secret, salt),
|
|
51
|
+
};
|
|
61
52
|
}),
|
|
62
53
|
);
|
|
63
54
|
}
|
|
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
|
-
}
|
package/dest/copy_cat/base.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { type AccountInterface, AccountWalletWithSecretKey, type ContractArtifact, type PXE, TxExecutionRequest } from '@aztec/aztec.js';
|
|
2
|
-
import type { CompleteAddress, ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
3
|
-
import type { SimulationOverrides, TxSimulationResult } from '@aztec/stdlib/tx';
|
|
4
|
-
/**
|
|
5
|
-
* An AccountWallet that copies the address of another account, and then
|
|
6
|
-
* uses the simulation overrides feature to execute different contract code under
|
|
7
|
-
* the copied address. This is used to bypass authwit verification entirely
|
|
8
|
-
* (`is_valid` always returns `true`)
|
|
9
|
-
*/
|
|
10
|
-
export declare abstract class CopyCatAccountWalletBase extends AccountWalletWithSecretKey {
|
|
11
|
-
private originalAddress;
|
|
12
|
-
private artifact;
|
|
13
|
-
private instance;
|
|
14
|
-
constructor(pxe: PXE, account: AccountInterface, originalAddress: CompleteAddress, artifact: ContractArtifact, instance: ContractInstanceWithAddress);
|
|
15
|
-
getCompleteAddress(): CompleteAddress;
|
|
16
|
-
simulateTx(txRequest: TxExecutionRequest, simulatePublic: boolean, _skipTxValidation?: boolean, _skipFeeEnforcement?: boolean, _overrides?: SimulationOverrides): Promise<TxSimulationResult>;
|
|
17
|
-
}
|
|
18
|
-
//# sourceMappingURL=base.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/copy_cat/base.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,gBAAgB,EACrB,0BAA0B,EAC1B,KAAK,gBAAgB,EAErB,KAAK,GAAG,EACR,kBAAkB,EACnB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,eAAe,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAC3F,OAAO,KAAK,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEhF;;;;;GAKG;AACH,8BAAsB,wBAAyB,SAAQ,0BAA0B;IAI7E,OAAO,CAAC,eAAe;IACvB,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,QAAQ;gBAJhB,GAAG,EAAE,GAAG,EACR,OAAO,EAAE,gBAAgB,EACjB,eAAe,EAAE,eAAe,EAChC,QAAQ,EAAE,gBAAgB,EAC1B,QAAQ,EAAE,2BAA2B;IAKtC,kBAAkB,IAAI,eAAe;IAIrC,UAAU,CACjB,SAAS,EAAE,kBAAkB,EAC7B,cAAc,EAAE,OAAO,EACvB,iBAAiB,CAAC,EAAE,OAAO,EAC3B,mBAAmB,CAAC,EAAE,OAAO,EAC7B,UAAU,CAAC,EAAE,mBAAmB,GAC/B,OAAO,CAAC,kBAAkB,CAAC;CAQ/B"}
|
package/dest/copy_cat/base.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { AccountWalletWithSecretKey, Fr } from '@aztec/aztec.js';
|
|
2
|
-
/**
|
|
3
|
-
* An AccountWallet that copies the address of another account, and then
|
|
4
|
-
* uses the simulation overrides feature to execute different contract code under
|
|
5
|
-
* the copied address. This is used to bypass authwit verification entirely
|
|
6
|
-
* (`is_valid` always returns `true`)
|
|
7
|
-
*/ export class CopyCatAccountWalletBase extends AccountWalletWithSecretKey {
|
|
8
|
-
originalAddress;
|
|
9
|
-
artifact;
|
|
10
|
-
instance;
|
|
11
|
-
constructor(pxe, account, originalAddress, artifact, instance){
|
|
12
|
-
super(pxe, account, Fr.ZERO, Fr.ZERO), this.originalAddress = originalAddress, this.artifact = artifact, this.instance = instance;
|
|
13
|
-
}
|
|
14
|
-
getCompleteAddress() {
|
|
15
|
-
return this.originalAddress;
|
|
16
|
-
}
|
|
17
|
-
simulateTx(txRequest, simulatePublic, _skipTxValidation, _skipFeeEnforcement, _overrides) {
|
|
18
|
-
const contractOverrides = {
|
|
19
|
-
[this.originalAddress.address.toString()]: {
|
|
20
|
-
instance: this.instance,
|
|
21
|
-
artifact: this.artifact
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
return this.pxe.simulateTx(txRequest, simulatePublic, true, true, {
|
|
25
|
-
contracts: contractOverrides
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
}
|
package/dest/copy_cat/index.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { AccountWallet, type PXE } from '@aztec/aztec.js';
|
|
2
|
-
import { CopyCatAccountWalletBase } from './base.js';
|
|
3
|
-
export declare const SimulatedAccountContractArtifact: import("@aztec/aztec.js").ContractArtifact;
|
|
4
|
-
/**
|
|
5
|
-
* A CopyCatAccountWallet that loads the contract artifact eagerly.
|
|
6
|
-
*/
|
|
7
|
-
export declare class CopyCatAccountWallet extends CopyCatAccountWalletBase {
|
|
8
|
-
static create(pxe: PXE, originalAccount: AccountWallet): Promise<CopyCatAccountWallet>;
|
|
9
|
-
}
|
|
10
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/copy_cat/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EAIb,KAAK,GAAG,EAGT,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AAErD,eAAO,MAAM,gCAAgC,4CAE5C,CAAC;AAEF;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,wBAAwB;WACnD,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,eAAe,EAAE,aAAa,GAAG,OAAO,CAAC,oBAAoB,CAAC;CAqB7F"}
|
package/dest/copy_cat/index.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { DefaultAccountInterface } from '@aztec/accounts/defaults';
|
|
2
|
-
import { AuthWitness, getContractInstanceFromInstantiationParams, loadContractArtifact } from '@aztec/aztec.js';
|
|
3
|
-
import SimulatedAccountContractJson from '../../artifacts/SimulatedAccount.json' with {
|
|
4
|
-
type: 'json'
|
|
5
|
-
};
|
|
6
|
-
import { CopyCatAccountWalletBase } from './base.js';
|
|
7
|
-
export const SimulatedAccountContractArtifact = loadContractArtifact(SimulatedAccountContractJson);
|
|
8
|
-
/**
|
|
9
|
-
* A CopyCatAccountWallet that loads the contract artifact eagerly.
|
|
10
|
-
*/ export class CopyCatAccountWallet extends CopyCatAccountWalletBase {
|
|
11
|
-
static async create(pxe, originalAccount) {
|
|
12
|
-
const simulatedAuthWitnessProvider = {
|
|
13
|
-
/**
|
|
14
|
-
* A copycat wallet always returns an empty authwitness, since it doesn't
|
|
15
|
-
* perform any verification whatsoever
|
|
16
|
-
* @param messageHash - The outer hash of the message for which the auth witness is created
|
|
17
|
-
*/ createAuthWit (messageHash) {
|
|
18
|
-
return Promise.resolve(new AuthWitness(messageHash, []));
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
const nodeInfo = await pxe.getNodeInfo();
|
|
22
|
-
const originalAddress = originalAccount.getCompleteAddress();
|
|
23
|
-
const { contractInstance } = await pxe.getContractMetadata(originalAddress.address);
|
|
24
|
-
if (!contractInstance) {
|
|
25
|
-
throw new Error(`No contract instance found for address: ${originalAddress.address}`);
|
|
26
|
-
}
|
|
27
|
-
const accountInterface = new DefaultAccountInterface(simulatedAuthWitnessProvider, originalAddress, nodeInfo);
|
|
28
|
-
const instance = await getContractInstanceFromInstantiationParams(SimulatedAccountContractArtifact, {});
|
|
29
|
-
return new CopyCatAccountWallet(pxe, accountInterface, originalAddress, SimulatedAccountContractArtifact, instance);
|
|
30
|
-
}
|
|
31
|
-
}
|
package/dest/copy_cat/lazy.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { AccountWallet, type PXE } from '@aztec/aztec.js';
|
|
2
|
-
import { CopyCatAccountWalletBase } from './base.js';
|
|
3
|
-
/**
|
|
4
|
-
* A CopyCatAccountWallet that loads the contract artifact lazily.
|
|
5
|
-
*/
|
|
6
|
-
export declare class CopyCatAccountWallet extends CopyCatAccountWalletBase {
|
|
7
|
-
static create(pxe: PXE, originalAccount: AccountWallet): Promise<CopyCatAccountWallet>;
|
|
8
|
-
}
|
|
9
|
-
//# sourceMappingURL=lazy.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lazy.d.ts","sourceRoot":"","sources":["../../src/copy_cat/lazy.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EAGb,KAAK,GAAG,EAGT,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AAErD;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,wBAAwB;WACnD,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,eAAe,EAAE,aAAa,GAAG,OAAO,CAAC,oBAAoB,CAAC;CAuB7F"}
|
package/dest/copy_cat/lazy.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { DefaultAccountInterface } from '@aztec/accounts/defaults';
|
|
2
|
-
import { AuthWitness, getContractInstanceFromInstantiationParams, loadContractArtifact } from '@aztec/aztec.js';
|
|
3
|
-
import { CopyCatAccountWalletBase } from './base.js';
|
|
4
|
-
/**
|
|
5
|
-
* A CopyCatAccountWallet that loads the contract artifact lazily.
|
|
6
|
-
*/ export class CopyCatAccountWallet extends CopyCatAccountWalletBase {
|
|
7
|
-
static async create(pxe, originalAccount) {
|
|
8
|
-
const simulatedAuthWitnessProvider = {
|
|
9
|
-
/**
|
|
10
|
-
* A copycat wallet always returns an empty authwitness, since it doesn't
|
|
11
|
-
* perform any verification whatsoever
|
|
12
|
-
* @param messageHash - The outer hash of the message for which the auth witness is created
|
|
13
|
-
*/ createAuthWit (messageHash) {
|
|
14
|
-
return Promise.resolve(new AuthWitness(messageHash, []));
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
const nodeInfo = await pxe.getNodeInfo();
|
|
18
|
-
const originalAddress = originalAccount.getCompleteAddress();
|
|
19
|
-
const { contractInstance } = await pxe.getContractMetadata(originalAddress.address);
|
|
20
|
-
if (!contractInstance) {
|
|
21
|
-
throw new Error(`No contract instance found for address: ${originalAddress.address}`);
|
|
22
|
-
}
|
|
23
|
-
const accountInterface = new DefaultAccountInterface(simulatedAuthWitnessProvider, originalAddress, nodeInfo);
|
|
24
|
-
const { default: simulatedAccountContractJson } = await import('../../artifacts/SimulatedAccount.json');
|
|
25
|
-
const simulatedAccountContractArtifact = loadContractArtifact(simulatedAccountContractJson);
|
|
26
|
-
const instance = await getContractInstanceFromInstantiationParams(simulatedAccountContractArtifact, {});
|
|
27
|
-
return new CopyCatAccountWallet(pxe, accountInterface, originalAddress, simulatedAccountContractArtifact, instance);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { AccountInterface, AuthWitnessProvider } from '@aztec/aztec.js/account';
|
|
2
|
-
import type { EntrypointInterface, FeeOptions, TxExecutionOptions } from '@aztec/entrypoints/interfaces';
|
|
3
|
-
import type { ExecutionPayload } from '@aztec/entrypoints/payload';
|
|
4
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
5
|
-
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
6
|
-
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
7
|
-
import { CompleteAddress } from '@aztec/stdlib/contract';
|
|
8
|
-
import type { NodeInfo } from '@aztec/stdlib/contract';
|
|
9
|
-
import type { TxExecutionRequest } from '@aztec/stdlib/tx';
|
|
10
|
-
/**
|
|
11
|
-
* Default implementation for an account interface. Requires that the account uses the default
|
|
12
|
-
* entrypoint signature, which accept an AppPayload and a FeePayload as defined in noir-libs/aztec-noir/src/entrypoint module
|
|
13
|
-
*/
|
|
14
|
-
export declare class DefaultAccountInterface implements AccountInterface {
|
|
15
|
-
private authWitnessProvider;
|
|
16
|
-
private address;
|
|
17
|
-
protected entrypoint: EntrypointInterface;
|
|
18
|
-
private chainId;
|
|
19
|
-
private version;
|
|
20
|
-
constructor(authWitnessProvider: AuthWitnessProvider, address: CompleteAddress, nodeInfo: Pick<NodeInfo, 'l1ChainId' | 'rollupVersion'>);
|
|
21
|
-
createTxExecutionRequest(exec: ExecutionPayload, fee: FeeOptions, options: TxExecutionOptions): Promise<TxExecutionRequest>;
|
|
22
|
-
createAuthWit(messageHash: Fr): Promise<AuthWitness>;
|
|
23
|
-
getCompleteAddress(): CompleteAddress;
|
|
24
|
-
getAddress(): AztecAddress;
|
|
25
|
-
getChainId(): Fr;
|
|
26
|
-
getVersion(): Fr;
|
|
27
|
-
}
|
|
28
|
-
//# sourceMappingURL=account_interface.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"account_interface.d.ts","sourceRoot":"","sources":["../../src/defaults/account_interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAErF,OAAO,KAAK,EAAE,mBAAmB,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACzG,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAE3D;;;GAGG;AACH,qBAAa,uBAAwB,YAAW,gBAAgB;IAO5D,OAAO,CAAC,mBAAmB;IAC3B,OAAO,CAAC,OAAO;IAPjB,SAAS,CAAC,UAAU,EAAE,mBAAmB,CAAC;IAE1C,OAAO,CAAC,OAAO,CAAK;IACpB,OAAO,CAAC,OAAO,CAAK;gBAGV,mBAAmB,EAAE,mBAAmB,EACxC,OAAO,EAAE,eAAe,EAChC,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,WAAW,GAAG,eAAe,CAAC;IAYzD,wBAAwB,CACtB,IAAI,EAAE,gBAAgB,EACtB,GAAG,EAAE,UAAU,EACf,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,kBAAkB,CAAC;IAI9B,aAAa,CAAC,WAAW,EAAE,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC;IAIpD,kBAAkB,IAAI,eAAe;IAIrC,UAAU,IAAI,YAAY;IAI1B,UAAU,IAAI,EAAE;IAIhB,UAAU,IAAI,EAAE;CAGjB"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { DefaultAccountEntrypoint } from '@aztec/entrypoints/account';
|
|
2
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
3
|
-
/**
|
|
4
|
-
* Default implementation for an account interface. Requires that the account uses the default
|
|
5
|
-
* entrypoint signature, which accept an AppPayload and a FeePayload as defined in noir-libs/aztec-noir/src/entrypoint module
|
|
6
|
-
*/ export class DefaultAccountInterface {
|
|
7
|
-
authWitnessProvider;
|
|
8
|
-
address;
|
|
9
|
-
entrypoint;
|
|
10
|
-
chainId;
|
|
11
|
-
version;
|
|
12
|
-
constructor(authWitnessProvider, address, nodeInfo){
|
|
13
|
-
this.authWitnessProvider = authWitnessProvider;
|
|
14
|
-
this.address = address;
|
|
15
|
-
this.entrypoint = new DefaultAccountEntrypoint(address.address, authWitnessProvider, nodeInfo.l1ChainId, nodeInfo.rollupVersion);
|
|
16
|
-
this.chainId = new Fr(nodeInfo.l1ChainId);
|
|
17
|
-
this.version = new Fr(nodeInfo.rollupVersion);
|
|
18
|
-
}
|
|
19
|
-
createTxExecutionRequest(exec, fee, options) {
|
|
20
|
-
return this.entrypoint.createTxExecutionRequest(exec, fee, options);
|
|
21
|
-
}
|
|
22
|
-
createAuthWit(messageHash) {
|
|
23
|
-
return this.authWitnessProvider.createAuthWit(messageHash);
|
|
24
|
-
}
|
|
25
|
-
getCompleteAddress() {
|
|
26
|
-
return this.address;
|
|
27
|
-
}
|
|
28
|
-
getAddress() {
|
|
29
|
-
return this.address.address;
|
|
30
|
-
}
|
|
31
|
-
getChainId() {
|
|
32
|
-
return this.chainId;
|
|
33
|
-
}
|
|
34
|
-
getVersion() {
|
|
35
|
-
return this.version;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { type AccountManager, type PXE, type WaitForProvenOpts, type WaitOpts } from '@aztec/aztec.js';
|
|
2
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
3
|
-
import type { InitialAccountData } from './configuration.js';
|
|
4
|
-
/**
|
|
5
|
-
* Generate a fixed amount of random schnorr account contract instance.
|
|
6
|
-
*/
|
|
7
|
-
export declare function generateSchnorrAccounts(numberOfAccounts: number): Promise<{
|
|
8
|
-
secret: Fr;
|
|
9
|
-
signingKey: import("@aztec/aztec.js").Fq;
|
|
10
|
-
salt: Fr;
|
|
11
|
-
address: import("@aztec/aztec.js").AztecAddress;
|
|
12
|
-
}[]>;
|
|
13
|
-
/**
|
|
14
|
-
* Data for deploying funded account.
|
|
15
|
-
*/
|
|
16
|
-
type DeployAccountData = Pick<InitialAccountData, 'secret' | 'salt'> & {
|
|
17
|
-
/**
|
|
18
|
-
* An optional signingKey if it's not derived from the secret.
|
|
19
|
-
*/
|
|
20
|
-
signingKey?: InitialAccountData['signingKey'];
|
|
21
|
-
};
|
|
22
|
-
/**
|
|
23
|
-
* Deploy schnorr account contract.
|
|
24
|
-
* It will pay for the fee for the deployment itself. So it must be funded with the prefilled public data.
|
|
25
|
-
*/
|
|
26
|
-
export declare function deployFundedSchnorrAccount(pxe: PXE, account: DeployAccountData, opts?: WaitOpts & {
|
|
27
|
-
/**
|
|
28
|
-
* Whether or not to skip publishing the contract class.
|
|
29
|
-
*/
|
|
30
|
-
skipClassPublication?: boolean;
|
|
31
|
-
}, waitForProvenOptions?: WaitForProvenOpts): Promise<AccountManager>;
|
|
32
|
-
/**
|
|
33
|
-
* Deploy schnorr account contracts.
|
|
34
|
-
* They will pay for the fees for the deployment themselves. So they must be funded with the prefilled public data.
|
|
35
|
-
*/
|
|
36
|
-
export declare function deployFundedSchnorrAccounts(pxe: PXE, accounts: DeployAccountData[], opts?: WaitOpts & {
|
|
37
|
-
/**
|
|
38
|
-
* Whether or not to skip publishing the contract class.
|
|
39
|
-
*/
|
|
40
|
-
skipClassPublication?: boolean;
|
|
41
|
-
}, waitForProvenOptions?: WaitForProvenOpts): Promise<AccountManager[]>;
|
|
42
|
-
export {};
|
|
43
|
-
//# sourceMappingURL=create_account.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create_account.d.ts","sourceRoot":"","sources":["../../src/testing/create_account.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,cAAc,EAEnB,KAAK,GAAG,EACR,KAAK,iBAAiB,EACtB,KAAK,QAAQ,EAEd,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAI9C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE7D;;GAEG;AACH,wBAAsB,uBAAuB,CAAC,gBAAgB,EAAE,MAAM;;;;;KAarE;AAED;;GAEG;AACH,KAAK,iBAAiB,GAAG,IAAI,CAAC,kBAAkB,EAAE,QAAQ,GAAG,MAAM,CAAC,GAAG;IACrE;;OAEG;IACH,UAAU,CAAC,EAAE,kBAAkB,CAAC,YAAY,CAAC,CAAC;CAC/C,CAAC;AAEF;;;GAGG;AACH,wBAAsB,0BAA0B,CAC9C,GAAG,EAAE,GAAG,EACR,OAAO,EAAE,iBAAiB,EAC1B,IAAI,GAAE,QAAQ,GAAG;IACf;;OAEG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;CACiB,EAClD,oBAAoB,CAAC,EAAE,iBAAiB,GACvC,OAAO,CAAC,cAAc,CAAC,CAqBzB;AAED;;;GAGG;AACH,wBAAsB,2BAA2B,CAC/C,GAAG,EAAE,GAAG,EACR,QAAQ,EAAE,iBAAiB,EAAE,EAC7B,IAAI,GAAE,QAAQ,GAAG;IACf;;OAEG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;CACiB,EAClD,oBAAoB,CAAC,EAAE,iBAAiB,GACvC,OAAO,CAAC,cAAc,EAAE,CAAC,CAiB3B"}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { FeeJuicePaymentMethod, waitForProven } from '@aztec/aztec.js';
|
|
2
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
3
|
-
import { deriveSigningKey } from '@aztec/stdlib/keys';
|
|
4
|
-
import { getSchnorrAccount, getSchnorrAccountContractAddress } from '../schnorr/index.js';
|
|
5
|
-
/**
|
|
6
|
-
* Generate a fixed amount of random schnorr account contract instance.
|
|
7
|
-
*/ export async function generateSchnorrAccounts(numberOfAccounts) {
|
|
8
|
-
const secrets = Array.from({
|
|
9
|
-
length: numberOfAccounts
|
|
10
|
-
}, ()=>Fr.random());
|
|
11
|
-
return await Promise.all(secrets.map(async (secret)=>{
|
|
12
|
-
const salt = Fr.random();
|
|
13
|
-
return {
|
|
14
|
-
secret,
|
|
15
|
-
signingKey: deriveSigningKey(secret),
|
|
16
|
-
salt,
|
|
17
|
-
address: await getSchnorrAccountContractAddress(secret, salt)
|
|
18
|
-
};
|
|
19
|
-
}));
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Deploy schnorr account contract.
|
|
23
|
-
* It will pay for the fee for the deployment itself. So it must be funded with the prefilled public data.
|
|
24
|
-
*/ export async function deployFundedSchnorrAccount(pxe, account, opts = {
|
|
25
|
-
interval: 0.1,
|
|
26
|
-
skipClassPublication: false
|
|
27
|
-
}, waitForProvenOptions) {
|
|
28
|
-
const signingKey = account.signingKey ?? deriveSigningKey(account.secret);
|
|
29
|
-
const accountManager = await getSchnorrAccount(pxe, account.secret, signingKey, account.salt);
|
|
30
|
-
// Pay the fee by the account itself.
|
|
31
|
-
// This only works when the world state is prefilled with the balance for the account in test environment.
|
|
32
|
-
const paymentMethod = new FeeJuicePaymentMethod(accountManager.getAddress());
|
|
33
|
-
const receipt = await accountManager.deploy({
|
|
34
|
-
skipClassPublication: opts.skipClassPublication,
|
|
35
|
-
skipInstancePublication: true,
|
|
36
|
-
fee: {
|
|
37
|
-
paymentMethod
|
|
38
|
-
}
|
|
39
|
-
}).wait(opts);
|
|
40
|
-
if (waitForProvenOptions !== undefined) {
|
|
41
|
-
await waitForProven(pxe, receipt, waitForProvenOptions);
|
|
42
|
-
}
|
|
43
|
-
return accountManager;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Deploy schnorr account contracts.
|
|
47
|
-
* They will pay for the fees for the deployment themselves. So they must be funded with the prefilled public data.
|
|
48
|
-
*/ export async function deployFundedSchnorrAccounts(pxe, accounts, opts = {
|
|
49
|
-
interval: 0.1,
|
|
50
|
-
skipClassPublication: false
|
|
51
|
-
}, waitForProvenOptions) {
|
|
52
|
-
const accountManagers = [];
|
|
53
|
-
// Serial due to https://github.com/AztecProtocol/aztec-packages/issues/12045
|
|
54
|
-
for(let i = 0; i < accounts.length; i++){
|
|
55
|
-
accountManagers.push(await deployFundedSchnorrAccount(pxe, accounts[i], {
|
|
56
|
-
...opts,
|
|
57
|
-
skipClassPublication: i !== 0 || opts.skipClassPublication
|
|
58
|
-
}, waitForProvenOptions));
|
|
59
|
-
}
|
|
60
|
-
return accountManagers;
|
|
61
|
-
}
|