@aztec/accounts 0.0.0-test.0 → 0.0.1-commit.03f7ef2
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 +4967 -3959
- package/artifacts/EcdsaRAccount.json +5259 -4251
- package/artifacts/SchnorrAccount.json +5271 -4131
- package/artifacts/SchnorrSingleKeyAccount.json +3162 -2408
- package/artifacts/SimulatedAccount.d.json.ts +3 -0
- package/artifacts/SimulatedAccount.json +4635 -0
- package/dest/defaults/account_contract.d.ts +10 -5
- package/dest/defaults/account_contract.d.ts.map +1 -1
- package/dest/defaults/account_contract.js +2 -2
- package/dest/defaults/account_interface.d.ts +8 -7
- package/dest/defaults/account_interface.d.ts.map +1 -1
- package/dest/defaults/account_interface.js +6 -7
- package/dest/defaults/index.d.ts +2 -2
- package/dest/defaults/index.js +1 -1
- package/dest/ecdsa/ecdsa_k/account_contract.d.ts +5 -4
- package/dest/ecdsa/ecdsa_k/account_contract.d.ts.map +1 -1
- package/dest/ecdsa/ecdsa_k/account_contract.js +9 -6
- package/dest/ecdsa/ecdsa_k/index.d.ts +1 -25
- package/dest/ecdsa/ecdsa_k/index.d.ts.map +1 -1
- package/dest/ecdsa/ecdsa_k/index.js +2 -23
- package/dest/ecdsa/ecdsa_k/lazy.d.ts +1 -25
- 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 +19 -0
- package/dest/ecdsa/ecdsa_r/account_contract.d.ts.map +1 -0
- package/dest/ecdsa/ecdsa_r/account_contract.js +41 -0
- package/dest/ecdsa/ecdsa_r/index.d.ts +19 -0
- package/dest/ecdsa/ecdsa_r/index.d.ts.map +1 -0
- package/dest/ecdsa/ecdsa_r/index.js +23 -0
- package/dest/ecdsa/ecdsa_r/lazy.d.ts +23 -0
- package/dest/ecdsa/ecdsa_r/lazy.d.ts.map +1 -0
- package/dest/ecdsa/ecdsa_r/lazy.js +31 -0
- package/dest/ecdsa/index.d.ts +2 -1
- package/dest/ecdsa/index.d.ts.map +1 -1
- package/dest/ecdsa/index.js +1 -0
- package/dest/ecdsa/lazy.d.ts +2 -1
- package/dest/ecdsa/lazy.d.ts.map +1 -1
- package/dest/ecdsa/lazy.js +1 -0
- package/dest/ecdsa/ssh_ecdsa_r/account_contract.d.ts +5 -4
- package/dest/ecdsa/ssh_ecdsa_r/account_contract.d.ts.map +1 -1
- package/dest/ecdsa/ssh_ecdsa_r/account_contract.js +9 -6
- package/dest/ecdsa/ssh_ecdsa_r/index.d.ts +2 -27
- package/dest/ecdsa/ssh_ecdsa_r/index.d.ts.map +1 -1
- package/dest/ecdsa/ssh_ecdsa_r/index.js +3 -28
- package/dest/ecdsa/ssh_ecdsa_r/lazy.d.ts +2 -30
- package/dest/ecdsa/ssh_ecdsa_r/lazy.d.ts.map +1 -1
- package/dest/ecdsa/ssh_ecdsa_r/lazy.js +3 -38
- package/dest/schnorr/account_contract.d.ts +7 -3
- package/dest/schnorr/account_contract.d.ts.map +1 -1
- package/dest/schnorr/account_contract.js +9 -6
- package/dest/schnorr/index.d.ts +4 -38
- package/dest/schnorr/index.d.ts.map +1 -1
- package/dest/schnorr/index.js +2 -33
- 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 +3 -3
- package/dest/single_key/account_contract.d.ts.map +1 -1
- package/dest/single_key/account_contract.js +2 -2
- 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 +2 -24
- 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 +21 -0
- package/dest/stub/index.d.ts.map +1 -0
- package/dest/stub/index.js +29 -0
- package/dest/stub/lazy.d.ts +23 -0
- package/dest/stub/lazy.d.ts.map +1 -0
- package/dest/stub/lazy.js +35 -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 -30
- package/dest/testing/index.d.ts.map +1 -1
- package/dest/testing/index.js +18 -30
- 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 +2 -5
- package/dest/utils/ssh_agent.d.ts.map +1 -1
- package/package.json +26 -20
- package/src/defaults/account_contract.ts +13 -5
- package/src/defaults/account_interface.ts +16 -12
- package/src/defaults/index.ts +1 -1
- package/src/ecdsa/ecdsa_k/account_contract.ts +7 -4
- package/src/ecdsa/ecdsa_k/index.ts +1 -33
- package/src/ecdsa/ecdsa_k/lazy.ts +4 -36
- package/src/ecdsa/ecdsa_r/account_contract.ts +42 -0
- package/src/ecdsa/ecdsa_r/index.ts +31 -0
- package/src/ecdsa/ecdsa_r/lazy.ts +39 -0
- package/src/ecdsa/index.ts +1 -0
- package/src/ecdsa/lazy.ts +1 -0
- package/src/ecdsa/ssh_ecdsa_r/account_contract.ts +7 -4
- package/src/ecdsa/ssh_ecdsa_r/index.ts +3 -42
- package/src/ecdsa/ssh_ecdsa_r/lazy.ts +3 -53
- package/src/schnorr/account_contract.ts +5 -4
- package/src/schnorr/index.ts +10 -57
- package/src/schnorr/lazy.ts +13 -60
- package/src/single_key/account_contract.ts +8 -4
- package/src/single_key/index.ts +2 -33
- package/src/single_key/lazy.ts +5 -36
- package/src/stub/account_contract.ts +39 -0
- package/src/stub/index.ts +41 -0
- package/src/stub/lazy.ts +49 -0
- package/src/testing/configuration.ts +2 -1
- package/src/testing/index.ts +19 -51
- package/src/testing/lazy.ts +18 -50
- package/dest/dapp/dapp_interface.d.ts +0 -10
- package/dest/dapp/dapp_interface.d.ts.map +0 -1
- package/dest/dapp/dapp_interface.js +0 -16
- package/dest/dapp/index.d.ts +0 -2
- package/dest/dapp/index.d.ts.map +0 -1
- package/dest/dapp/index.js +0 -1
- 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 -58
- package/src/dapp/dapp_interface.ts +0 -38
- package/src/dapp/index.ts +0 -1
- package/src/testing/create_account.ts +0 -93
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,45 +42,19 @@ export function getInitialTestAccounts(): Promise<InitialAccountData[]> {
|
|
|
48
42
|
}
|
|
49
43
|
|
|
50
44
|
/**
|
|
51
|
-
*
|
|
52
|
-
* @param pxe - PXE instance.
|
|
53
|
-
* @returns A set of AccountWallet implementations for each of the initial accounts.
|
|
45
|
+
* Generate a fixed amount of random schnorr account contract instance.
|
|
54
46
|
*/
|
|
55
|
-
export function
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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
|
+
};
|
|
65
58
|
}),
|
|
66
59
|
);
|
|
67
60
|
}
|
|
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';
|
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
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { type AccountWallet, type AuthWitnessProvider, AztecAddress, CompleteAddress, type NodeInfo } from '@aztec/aztec.js';
|
|
2
|
-
import { DefaultAccountInterface } from '../defaults/account_interface.js';
|
|
3
|
-
/**
|
|
4
|
-
* Default implementation for an account interface that uses a dapp entrypoint.
|
|
5
|
-
*/
|
|
6
|
-
export declare class DefaultDappInterface extends DefaultAccountInterface {
|
|
7
|
-
constructor(authWitnessProvider: AuthWitnessProvider, userAddress: CompleteAddress, dappAddress: AztecAddress, nodeInfo: Pick<NodeInfo, 'l1ChainId' | 'protocolVersion'>);
|
|
8
|
-
static createFromUserWallet(wallet: AccountWallet, dappAddress: AztecAddress): DefaultDappInterface;
|
|
9
|
-
}
|
|
10
|
-
//# sourceMappingURL=dapp_interface.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dapp_interface.d.ts","sourceRoot":"","sources":["../../src/dapp/dapp_interface.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,YAAY,EACZ,eAAe,EACf,KAAK,QAAQ,EACd,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAE3E;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,uBAAuB;gBAE7D,mBAAmB,EAAE,mBAAmB,EACxC,WAAW,EAAE,eAAe,EAC5B,WAAW,EAAE,YAAY,EACzB,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,WAAW,GAAG,iBAAiB,CAAC;IAY3D,MAAM,CAAC,oBAAoB,CAAC,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,YAAY,GAAG,oBAAoB;CAMpG"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { DefaultDappEntrypoint } from '@aztec/entrypoints/dapp';
|
|
2
|
-
import { DefaultAccountInterface } from '../defaults/account_interface.js';
|
|
3
|
-
/**
|
|
4
|
-
* Default implementation for an account interface that uses a dapp entrypoint.
|
|
5
|
-
*/ export class DefaultDappInterface extends DefaultAccountInterface {
|
|
6
|
-
constructor(authWitnessProvider, userAddress, dappAddress, nodeInfo){
|
|
7
|
-
super(authWitnessProvider, userAddress, nodeInfo);
|
|
8
|
-
this.entrypoint = new DefaultDappEntrypoint(userAddress.address, authWitnessProvider, dappAddress, nodeInfo.l1ChainId, nodeInfo.protocolVersion);
|
|
9
|
-
}
|
|
10
|
-
static createFromUserWallet(wallet, dappAddress) {
|
|
11
|
-
return new DefaultDappInterface(wallet, wallet.getCompleteAddress(), dappAddress, {
|
|
12
|
-
l1ChainId: wallet.getChainId().toNumber(),
|
|
13
|
-
protocolVersion: wallet.getVersion().toNumber()
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
}
|
package/dest/dapp/index.d.ts
DELETED
package/dest/dapp/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/dapp/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC"}
|
package/dest/dapp/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './dapp_interface.js';
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { type AccountManager, type PXE, 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 registering contract class.
|
|
29
|
-
*/
|
|
30
|
-
skipClassRegistration?: boolean;
|
|
31
|
-
}): 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 registering contract class.
|
|
39
|
-
*/
|
|
40
|
-
skipClassRegistration?: boolean;
|
|
41
|
-
}): 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,EAAE,KAAK,cAAc,EAAyB,KAAK,GAAG,EAAE,KAAK,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AACtG,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,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACiB,GAClD,OAAO,CAAC,cAAc,CAAC,CAiBzB;AAED;;;GAGG;AACH,wBAAsB,2BAA2B,CAC/C,GAAG,EAAE,GAAG,EACR,QAAQ,EAAE,iBAAiB,EAAE,EAC7B,IAAI,GAAE,QAAQ,GAAG;IACf;;OAEG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACiB,GAClD,OAAO,CAAC,cAAc,EAAE,CAAC,CAY3B"}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { FeeJuicePaymentMethod } 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
|
-
skipClassRegistration: false
|
|
27
|
-
}) {
|
|
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
|
-
await accountManager.deploy({
|
|
34
|
-
skipClassRegistration: opts.skipClassRegistration,
|
|
35
|
-
skipPublicDeployment: true,
|
|
36
|
-
fee: {
|
|
37
|
-
paymentMethod
|
|
38
|
-
}
|
|
39
|
-
}).wait(opts);
|
|
40
|
-
return accountManager;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Deploy schnorr account contracts.
|
|
44
|
-
* They will pay for the fees for the deployment themselves. So they must be funded with the prefilled public data.
|
|
45
|
-
*/ export async function deployFundedSchnorrAccounts(pxe, accounts, opts = {
|
|
46
|
-
interval: 0.1,
|
|
47
|
-
skipClassRegistration: false
|
|
48
|
-
}) {
|
|
49
|
-
const accountManagers = [];
|
|
50
|
-
// Serial due to https://github.com/AztecProtocol/aztec-packages/issues/12045
|
|
51
|
-
for(let i = 0; i < accounts.length; i++){
|
|
52
|
-
accountManagers.push(await deployFundedSchnorrAccount(pxe, accounts[i], {
|
|
53
|
-
...opts,
|
|
54
|
-
skipClassRegistration: i !== 0 || opts.skipClassRegistration
|
|
55
|
-
}));
|
|
56
|
-
}
|
|
57
|
-
return accountManagers;
|
|
58
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type AccountWallet,
|
|
3
|
-
type AuthWitnessProvider,
|
|
4
|
-
AztecAddress,
|
|
5
|
-
CompleteAddress,
|
|
6
|
-
type NodeInfo,
|
|
7
|
-
} from '@aztec/aztec.js';
|
|
8
|
-
import { DefaultDappEntrypoint } from '@aztec/entrypoints/dapp';
|
|
9
|
-
|
|
10
|
-
import { DefaultAccountInterface } from '../defaults/account_interface.js';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Default implementation for an account interface that uses a dapp entrypoint.
|
|
14
|
-
*/
|
|
15
|
-
export class DefaultDappInterface extends DefaultAccountInterface {
|
|
16
|
-
constructor(
|
|
17
|
-
authWitnessProvider: AuthWitnessProvider,
|
|
18
|
-
userAddress: CompleteAddress,
|
|
19
|
-
dappAddress: AztecAddress,
|
|
20
|
-
nodeInfo: Pick<NodeInfo, 'l1ChainId' | 'protocolVersion'>,
|
|
21
|
-
) {
|
|
22
|
-
super(authWitnessProvider, userAddress, nodeInfo);
|
|
23
|
-
this.entrypoint = new DefaultDappEntrypoint(
|
|
24
|
-
userAddress.address,
|
|
25
|
-
authWitnessProvider,
|
|
26
|
-
dappAddress,
|
|
27
|
-
nodeInfo.l1ChainId,
|
|
28
|
-
nodeInfo.protocolVersion,
|
|
29
|
-
);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
static createFromUserWallet(wallet: AccountWallet, dappAddress: AztecAddress): DefaultDappInterface {
|
|
33
|
-
return new DefaultDappInterface(wallet, wallet.getCompleteAddress(), dappAddress, {
|
|
34
|
-
l1ChainId: wallet.getChainId().toNumber(),
|
|
35
|
-
protocolVersion: wallet.getVersion().toNumber(),
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
}
|
package/src/dapp/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './dapp_interface.js';
|
|
@@ -1,93 +0,0 @@
|
|
|
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';
|
|
4
|
-
|
|
5
|
-
import { getSchnorrAccount, getSchnorrAccountContractAddress } from '../schnorr/index.js';
|
|
6
|
-
import type { InitialAccountData } from './configuration.js';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Generate a fixed amount of random schnorr account contract instance.
|
|
10
|
-
*/
|
|
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
|
-
);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Data for deploying funded account.
|
|
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(
|
|
41
|
-
pxe: PXE,
|
|
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);
|
|
52
|
-
|
|
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());
|
|
56
|
-
|
|
57
|
-
await accountManager
|
|
58
|
-
.deploy({
|
|
59
|
-
skipClassRegistration: opts.skipClassRegistration,
|
|
60
|
-
skipPublicDeployment: true,
|
|
61
|
-
fee: { paymentMethod },
|
|
62
|
-
})
|
|
63
|
-
.wait(opts);
|
|
64
|
-
|
|
65
|
-
return accountManager;
|
|
66
|
-
}
|
|
67
|
-
|
|
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;
|
|
93
|
-
}
|