@aztec/accounts 4.0.0-nightly.20250907 → 4.0.0-nightly.20260107

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.
Files changed (122) hide show
  1. package/README.md +1 -1
  2. package/artifacts/EcdsaKAccount.json +3187 -3625
  3. package/artifacts/EcdsaRAccount.json +3196 -3634
  4. package/artifacts/SchnorrAccount.json +3233 -3844
  5. package/artifacts/SchnorrSingleKeyAccount.json +2550 -2633
  6. package/artifacts/SimulatedAccount.json +2118 -2344
  7. package/dest/defaults/account_contract.d.ts +4 -4
  8. package/dest/defaults/account_contract.d.ts.map +1 -1
  9. package/dest/defaults/account_contract.js +2 -2
  10. package/dest/defaults/account_interface.d.ts +8 -8
  11. package/dest/defaults/account_interface.d.ts.map +1 -1
  12. package/dest/defaults/account_interface.js +6 -7
  13. package/dest/defaults/index.d.ts +2 -2
  14. package/dest/defaults/index.js +1 -1
  15. package/dest/ecdsa/ecdsa_k/account_contract.d.ts +1 -1
  16. package/dest/ecdsa/ecdsa_k/account_contract.d.ts.map +1 -1
  17. package/dest/ecdsa/ecdsa_k/account_contract.js +1 -1
  18. package/dest/ecdsa/ecdsa_k/index.d.ts +1 -23
  19. package/dest/ecdsa/ecdsa_k/index.d.ts.map +1 -1
  20. package/dest/ecdsa/ecdsa_k/index.js +1 -22
  21. package/dest/ecdsa/ecdsa_k/lazy.d.ts +1 -23
  22. package/dest/ecdsa/ecdsa_k/lazy.d.ts.map +1 -1
  23. package/dest/ecdsa/ecdsa_k/lazy.js +5 -26
  24. package/dest/ecdsa/ecdsa_r/account_contract.d.ts +1 -1
  25. package/dest/ecdsa/ecdsa_r/account_contract.d.ts.map +1 -1
  26. package/dest/ecdsa/ecdsa_r/account_contract.js +1 -1
  27. package/dest/ecdsa/ecdsa_r/index.d.ts +1 -23
  28. package/dest/ecdsa/ecdsa_r/index.d.ts.map +1 -1
  29. package/dest/ecdsa/ecdsa_r/index.js +1 -22
  30. package/dest/ecdsa/ecdsa_r/lazy.d.ts +1 -23
  31. package/dest/ecdsa/ecdsa_r/lazy.d.ts.map +1 -1
  32. package/dest/ecdsa/ecdsa_r/lazy.js +5 -26
  33. package/dest/ecdsa/index.d.ts +1 -1
  34. package/dest/ecdsa/lazy.d.ts +1 -1
  35. package/dest/ecdsa/ssh_ecdsa_r/account_contract.d.ts +1 -1
  36. package/dest/ecdsa/ssh_ecdsa_r/account_contract.d.ts.map +1 -1
  37. package/dest/ecdsa/ssh_ecdsa_r/account_contract.js +1 -1
  38. package/dest/ecdsa/ssh_ecdsa_r/index.d.ts +2 -24
  39. package/dest/ecdsa/ssh_ecdsa_r/index.d.ts.map +1 -1
  40. package/dest/ecdsa/ssh_ecdsa_r/index.js +3 -24
  41. package/dest/ecdsa/ssh_ecdsa_r/lazy.d.ts +2 -24
  42. package/dest/ecdsa/ssh_ecdsa_r/lazy.d.ts.map +1 -1
  43. package/dest/ecdsa/ssh_ecdsa_r/lazy.js +3 -24
  44. package/dest/schnorr/account_contract.d.ts +3 -2
  45. package/dest/schnorr/account_contract.d.ts.map +1 -1
  46. package/dest/schnorr/account_contract.js +1 -1
  47. package/dest/schnorr/index.d.ts +4 -38
  48. package/dest/schnorr/index.d.ts.map +1 -1
  49. package/dest/schnorr/index.js +1 -32
  50. package/dest/schnorr/lazy.d.ts +4 -38
  51. package/dest/schnorr/lazy.d.ts.map +1 -1
  52. package/dest/schnorr/lazy.js +5 -36
  53. package/dest/single_key/account_contract.d.ts +2 -2
  54. package/dest/single_key/account_contract.d.ts.map +1 -1
  55. package/dest/single_key/account_contract.js +1 -1
  56. package/dest/single_key/index.d.ts +2 -21
  57. package/dest/single_key/index.d.ts.map +1 -1
  58. package/dest/single_key/index.js +1 -23
  59. package/dest/single_key/lazy.d.ts +2 -21
  60. package/dest/single_key/lazy.d.ts.map +1 -1
  61. package/dest/single_key/lazy.js +5 -27
  62. package/dest/stub/account_contract.d.ts +29 -0
  63. package/dest/stub/account_contract.d.ts.map +1 -0
  64. package/dest/stub/account_contract.js +30 -0
  65. package/dest/stub/index.d.ts +21 -0
  66. package/dest/stub/index.d.ts.map +1 -0
  67. package/dest/stub/index.js +29 -0
  68. package/dest/stub/lazy.d.ts +23 -0
  69. package/dest/stub/lazy.d.ts.map +1 -0
  70. package/dest/stub/lazy.js +35 -0
  71. package/dest/testing/configuration.d.ts +5 -4
  72. package/dest/testing/configuration.d.ts.map +1 -1
  73. package/dest/testing/configuration.js +1 -1
  74. package/dest/testing/index.d.ts +6 -36
  75. package/dest/testing/index.d.ts.map +1 -1
  76. package/dest/testing/index.js +19 -35
  77. package/dest/testing/lazy.d.ts +5 -28
  78. package/dest/testing/lazy.d.ts.map +1 -1
  79. package/dest/testing/lazy.js +19 -30
  80. package/dest/utils/index.d.ts +1 -1
  81. package/dest/utils/ssh_agent.d.ts +1 -1
  82. package/package.json +13 -10
  83. package/src/defaults/account_contract.ts +4 -4
  84. package/src/defaults/account_interface.ts +13 -14
  85. package/src/defaults/index.ts +1 -1
  86. package/src/ecdsa/ecdsa_k/account_contract.ts +2 -2
  87. package/src/ecdsa/ecdsa_k/index.ts +0 -32
  88. package/src/ecdsa/ecdsa_k/lazy.ts +4 -36
  89. package/src/ecdsa/ecdsa_r/account_contract.ts +2 -2
  90. package/src/ecdsa/ecdsa_r/index.ts +0 -32
  91. package/src/ecdsa/ecdsa_r/lazy.ts +4 -36
  92. package/src/ecdsa/ssh_ecdsa_r/account_contract.ts +2 -2
  93. package/src/ecdsa/ssh_ecdsa_r/index.ts +2 -35
  94. package/src/ecdsa/ssh_ecdsa_r/lazy.ts +2 -35
  95. package/src/schnorr/account_contract.ts +3 -2
  96. package/src/schnorr/index.ts +9 -56
  97. package/src/schnorr/lazy.ts +13 -60
  98. package/src/single_key/account_contract.ts +3 -2
  99. package/src/single_key/index.ts +1 -32
  100. package/src/single_key/lazy.ts +5 -36
  101. package/src/stub/account_contract.ts +39 -0
  102. package/src/stub/index.ts +41 -0
  103. package/src/stub/lazy.ts +49 -0
  104. package/src/testing/configuration.ts +2 -1
  105. package/src/testing/index.ts +20 -57
  106. package/src/testing/lazy.ts +18 -50
  107. package/dest/copy_cat/base.d.ts +0 -18
  108. package/dest/copy_cat/base.d.ts.map +0 -1
  109. package/dest/copy_cat/base.js +0 -28
  110. package/dest/copy_cat/index.d.ts +0 -10
  111. package/dest/copy_cat/index.d.ts.map +0 -1
  112. package/dest/copy_cat/index.js +0 -31
  113. package/dest/copy_cat/lazy.d.ts +0 -9
  114. package/dest/copy_cat/lazy.d.ts.map +0 -1
  115. package/dest/copy_cat/lazy.js +0 -29
  116. package/dest/testing/create_account.d.ts +0 -43
  117. package/dest/testing/create_account.d.ts.map +0 -1
  118. package/dest/testing/create_account.js +0 -61
  119. package/src/copy_cat/base.ts +0 -47
  120. package/src/copy_cat/index.ts +0 -44
  121. package/src/copy_cat/lazy.ts +0 -40
  122. package/src/testing/create_account.ts +0 -111
@@ -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
- }
@@ -1,47 +0,0 @@
1
- import {
2
- type AccountInterface,
3
- AccountWalletWithSecretKey,
4
- type ContractArtifact,
5
- Fr,
6
- type PXE,
7
- TxExecutionRequest,
8
- } from '@aztec/aztec.js';
9
- import type { CompleteAddress, ContractInstanceWithAddress } from '@aztec/stdlib/contract';
10
- import type { SimulationOverrides, TxSimulationResult } from '@aztec/stdlib/tx';
11
-
12
- /**
13
- * An AccountWallet that copies the address of another account, and then
14
- * uses the simulation overrides feature to execute different contract code under
15
- * the copied address. This is used to bypass authwit verification entirely
16
- * (`is_valid` always returns `true`)
17
- */
18
- export abstract class CopyCatAccountWalletBase extends AccountWalletWithSecretKey {
19
- constructor(
20
- pxe: PXE,
21
- account: AccountInterface,
22
- private originalAddress: CompleteAddress,
23
- private artifact: ContractArtifact,
24
- private instance: ContractInstanceWithAddress,
25
- ) {
26
- super(pxe, account, Fr.ZERO, Fr.ZERO);
27
- }
28
-
29
- override getCompleteAddress(): CompleteAddress {
30
- return this.originalAddress;
31
- }
32
-
33
- override simulateTx(
34
- txRequest: TxExecutionRequest,
35
- simulatePublic: boolean,
36
- _skipTxValidation?: boolean,
37
- _skipFeeEnforcement?: boolean,
38
- _overrides?: SimulationOverrides,
39
- ): Promise<TxSimulationResult> {
40
- const contractOverrides = {
41
- [this.originalAddress.address.toString()]: { instance: this.instance, artifact: this.artifact },
42
- };
43
- return this.pxe.simulateTx(txRequest, simulatePublic, true, true, {
44
- contracts: contractOverrides,
45
- });
46
- }
47
- }
@@ -1,44 +0,0 @@
1
- import { DefaultAccountInterface } from '@aztec/accounts/defaults';
2
- import {
3
- AccountWallet,
4
- AuthWitness,
5
- Fr,
6
- type NoirCompiledContract,
7
- type PXE,
8
- getContractInstanceFromInstantiationParams,
9
- loadContractArtifact,
10
- } from '@aztec/aztec.js';
11
-
12
- import SimulatedAccountContractJson from '../../artifacts/SimulatedAccount.json' with { type: 'json' };
13
- import { CopyCatAccountWalletBase } from './base.js';
14
-
15
- export const SimulatedAccountContractArtifact = loadContractArtifact(
16
- SimulatedAccountContractJson as NoirCompiledContract,
17
- );
18
-
19
- /**
20
- * A CopyCatAccountWallet that loads the contract artifact eagerly.
21
- */
22
- export class CopyCatAccountWallet extends CopyCatAccountWalletBase {
23
- static async create(pxe: PXE, originalAccount: AccountWallet): Promise<CopyCatAccountWallet> {
24
- const simulatedAuthWitnessProvider = {
25
- /**
26
- * A copycat wallet always returns an empty authwitness, since it doesn't
27
- * perform any verification whatsoever
28
- * @param messageHash - The outer hash of the message for which the auth witness is created
29
- */
30
- createAuthWit(messageHash: Fr): Promise<AuthWitness> {
31
- return Promise.resolve(new AuthWitness(messageHash, []));
32
- },
33
- };
34
- const nodeInfo = await pxe.getNodeInfo();
35
- const originalAddress = originalAccount.getCompleteAddress();
36
- const { contractInstance } = await pxe.getContractMetadata(originalAddress.address);
37
- if (!contractInstance) {
38
- throw new Error(`No contract instance found for address: ${originalAddress.address}`);
39
- }
40
- const accountInterface = new DefaultAccountInterface(simulatedAuthWitnessProvider, originalAddress, nodeInfo);
41
- const instance = await getContractInstanceFromInstantiationParams(SimulatedAccountContractArtifact, {});
42
- return new CopyCatAccountWallet(pxe, accountInterface, originalAddress, SimulatedAccountContractArtifact, instance);
43
- }
44
- }
@@ -1,40 +0,0 @@
1
- import { DefaultAccountInterface } from '@aztec/accounts/defaults';
2
- import {
3
- AccountWallet,
4
- AuthWitness,
5
- Fr,
6
- type PXE,
7
- getContractInstanceFromInstantiationParams,
8
- loadContractArtifact,
9
- } from '@aztec/aztec.js';
10
-
11
- import { CopyCatAccountWalletBase } from './base.js';
12
-
13
- /**
14
- * A CopyCatAccountWallet that loads the contract artifact lazily.
15
- */
16
- export class CopyCatAccountWallet extends CopyCatAccountWalletBase {
17
- static async create(pxe: PXE, originalAccount: AccountWallet): Promise<CopyCatAccountWallet> {
18
- const simulatedAuthWitnessProvider = {
19
- /**
20
- * A copycat wallet always returns an empty authwitness, since it doesn't
21
- * perform any verification whatsoever
22
- * @param messageHash - The outer hash of the message for which the auth witness is created
23
- */
24
- createAuthWit(messageHash: Fr): Promise<AuthWitness> {
25
- return Promise.resolve(new AuthWitness(messageHash, []));
26
- },
27
- };
28
- const nodeInfo = await pxe.getNodeInfo();
29
- const originalAddress = originalAccount.getCompleteAddress();
30
- const { contractInstance } = await pxe.getContractMetadata(originalAddress.address);
31
- if (!contractInstance) {
32
- throw new Error(`No contract instance found for address: ${originalAddress.address}`);
33
- }
34
- const accountInterface = new DefaultAccountInterface(simulatedAuthWitnessProvider, originalAddress, nodeInfo);
35
- const { default: simulatedAccountContractJson } = await import('../../artifacts/SimulatedAccount.json');
36
- const simulatedAccountContractArtifact = loadContractArtifact(simulatedAccountContractJson);
37
- const instance = await getContractInstanceFromInstantiationParams(simulatedAccountContractArtifact, {});
38
- return new CopyCatAccountWallet(pxe, accountInterface, originalAddress, simulatedAccountContractArtifact, instance);
39
- }
40
- }
@@ -1,111 +0,0 @@
1
- import {
2
- type AccountManager,
3
- FeeJuicePaymentMethod,
4
- type PXE,
5
- type WaitForProvenOpts,
6
- type WaitOpts,
7
- waitForProven,
8
- } from '@aztec/aztec.js';
9
- import { Fr } from '@aztec/foundation/fields';
10
- import { deriveSigningKey } from '@aztec/stdlib/keys';
11
-
12
- import { getSchnorrAccount, getSchnorrAccountContractAddress } from '../schnorr/index.js';
13
- import type { InitialAccountData } from './configuration.js';
14
-
15
- /**
16
- * Generate a fixed amount of random schnorr account contract instance.
17
- */
18
- export async function generateSchnorrAccounts(numberOfAccounts: number) {
19
- const secrets = Array.from({ length: numberOfAccounts }, () => Fr.random());
20
- return await Promise.all(
21
- secrets.map(async secret => {
22
- const salt = Fr.random();
23
- return {
24
- secret,
25
- signingKey: deriveSigningKey(secret),
26
- salt,
27
- address: await getSchnorrAccountContractAddress(secret, salt),
28
- };
29
- }),
30
- );
31
- }
32
-
33
- /**
34
- * Data for deploying funded account.
35
- */
36
- type DeployAccountData = Pick<InitialAccountData, 'secret' | 'salt'> & {
37
- /**
38
- * An optional signingKey if it's not derived from the secret.
39
- */
40
- signingKey?: InitialAccountData['signingKey'];
41
- };
42
-
43
- /**
44
- * Deploy schnorr account contract.
45
- * It will pay for the fee for the deployment itself. So it must be funded with the prefilled public data.
46
- */
47
- export async function deployFundedSchnorrAccount(
48
- pxe: PXE,
49
- account: DeployAccountData,
50
- opts: WaitOpts & {
51
- /**
52
- * Whether or not to skip publishing the contract class.
53
- */
54
- skipClassPublication?: boolean;
55
- } = { interval: 0.1, skipClassPublication: false },
56
- waitForProvenOptions?: WaitForProvenOpts,
57
- ): Promise<AccountManager> {
58
- const signingKey = account.signingKey ?? deriveSigningKey(account.secret);
59
- const accountManager = await getSchnorrAccount(pxe, account.secret, signingKey, account.salt);
60
-
61
- // Pay the fee by the account itself.
62
- // This only works when the world state is prefilled with the balance for the account in test environment.
63
- const paymentMethod = new FeeJuicePaymentMethod(accountManager.getAddress());
64
-
65
- const receipt = await accountManager
66
- .deploy({
67
- skipClassPublication: opts.skipClassPublication,
68
- skipInstancePublication: true,
69
- fee: { paymentMethod },
70
- })
71
- .wait(opts);
72
-
73
- if (waitForProvenOptions !== undefined) {
74
- await waitForProven(pxe, receipt, waitForProvenOptions);
75
- }
76
-
77
- return accountManager;
78
- }
79
-
80
- /**
81
- * Deploy schnorr account contracts.
82
- * They will pay for the fees for the deployment themselves. So they must be funded with the prefilled public data.
83
- */
84
- export async function deployFundedSchnorrAccounts(
85
- pxe: PXE,
86
- accounts: DeployAccountData[],
87
- opts: WaitOpts & {
88
- /**
89
- * Whether or not to skip publishing the contract class.
90
- */
91
- skipClassPublication?: boolean;
92
- } = { interval: 0.1, skipClassPublication: false },
93
- waitForProvenOptions?: WaitForProvenOpts,
94
- ): Promise<AccountManager[]> {
95
- const accountManagers: AccountManager[] = [];
96
- // Serial due to https://github.com/AztecProtocol/aztec-packages/issues/12045
97
- for (let i = 0; i < accounts.length; i++) {
98
- accountManagers.push(
99
- await deployFundedSchnorrAccount(
100
- pxe,
101
- accounts[i],
102
- {
103
- ...opts,
104
- skipClassPublication: i !== 0 || opts.skipClassPublication, // Publish the contract class at most once.
105
- },
106
- waitForProvenOptions,
107
- ),
108
- );
109
- }
110
- return accountManagers;
111
- }