@aztec/aztec.js 0.35.1 → 0.37.0

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 (83) hide show
  1. package/dest/account/contract.d.ts +3 -1
  2. package/dest/account/contract.d.ts.map +1 -1
  3. package/dest/account/contract.js +1 -1
  4. package/dest/account/interface.d.ts +2 -0
  5. package/dest/account/interface.d.ts.map +1 -1
  6. package/dest/account/interface.js +1 -1
  7. package/dest/account_manager/deploy_account_method.d.ts +2 -2
  8. package/dest/account_manager/deploy_account_method.d.ts.map +1 -1
  9. package/dest/account_manager/deploy_account_method.js +3 -3
  10. package/dest/account_manager/deploy_account_sent_tx.d.ts.map +1 -1
  11. package/dest/account_manager/deploy_account_sent_tx.js +1 -1
  12. package/dest/account_manager/index.d.ts +9 -9
  13. package/dest/account_manager/index.d.ts.map +1 -1
  14. package/dest/account_manager/index.js +15 -18
  15. package/dest/api/abi.d.ts +1 -1
  16. package/dest/api/abi.d.ts.map +1 -1
  17. package/dest/api/abi.js +2 -2
  18. package/dest/api/wallet.d.ts +1 -1
  19. package/dest/api/wallet.d.ts.map +1 -1
  20. package/dest/api/wallet.js +2 -2
  21. package/dest/contract/contract.d.ts +4 -5
  22. package/dest/contract/contract.d.ts.map +1 -1
  23. package/dest/contract/contract.js +7 -8
  24. package/dest/contract/contract_base.d.ts +2 -30
  25. package/dest/contract/contract_base.d.ts.map +1 -1
  26. package/dest/contract/contract_base.js +2 -2
  27. package/dest/contract/contract_function_interaction.d.ts +0 -1
  28. package/dest/contract/contract_function_interaction.d.ts.map +1 -1
  29. package/dest/contract/contract_function_interaction.js +11 -13
  30. package/dest/contract/deploy_method.d.ts +6 -9
  31. package/dest/contract/deploy_method.d.ts.map +1 -1
  32. package/dest/contract/deploy_method.js +6 -7
  33. package/dest/contract/deploy_sent_tx.d.ts.map +1 -1
  34. package/dest/contract/deploy_sent_tx.js +1 -1
  35. package/dest/deployment/contract_deployer.d.ts +3 -3
  36. package/dest/deployment/contract_deployer.d.ts.map +1 -1
  37. package/dest/deployment/contract_deployer.js +5 -5
  38. package/dest/deployment/deploy_instance.d.ts.map +1 -1
  39. package/dest/deployment/deploy_instance.js +3 -3
  40. package/dest/entrypoint/default_entrypoint.js +4 -3
  41. package/dest/entrypoint/default_multi_call_entrypoint.js +5 -5
  42. package/dest/fee/private_fee_payment_method.js +3 -3
  43. package/dest/index.d.ts +3 -2
  44. package/dest/index.d.ts.map +1 -1
  45. package/dest/index.js +4 -3
  46. package/dest/wallet/account_wallet.d.ts +1 -0
  47. package/dest/wallet/account_wallet.d.ts.map +1 -1
  48. package/dest/wallet/account_wallet.js +4 -1
  49. package/dest/wallet/account_wallet_with_private_key.d.ts +5 -5
  50. package/dest/wallet/account_wallet_with_private_key.d.ts.map +1 -1
  51. package/dest/wallet/account_wallet_with_private_key.js +6 -6
  52. package/dest/wallet/base_wallet.d.ts +4 -2
  53. package/dest/wallet/base_wallet.d.ts.map +1 -1
  54. package/dest/wallet/base_wallet.js +6 -3
  55. package/dest/wallet/index.d.ts.map +1 -1
  56. package/dest/wallet/index.js +6 -2
  57. package/dest/wallet/signerless_wallet.d.ts +1 -0
  58. package/dest/wallet/signerless_wallet.d.ts.map +1 -1
  59. package/dest/wallet/signerless_wallet.js +4 -1
  60. package/package.json +15 -7
  61. package/src/account/contract.ts +3 -1
  62. package/src/account/interface.ts +3 -0
  63. package/src/account_manager/deploy_account_method.ts +4 -5
  64. package/src/account_manager/deploy_account_sent_tx.ts +1 -1
  65. package/src/account_manager/index.ts +18 -26
  66. package/src/api/abi.ts +1 -1
  67. package/src/api/wallet.ts +7 -1
  68. package/src/contract/contract.ts +7 -9
  69. package/src/contract/contract_base.ts +8 -30
  70. package/src/contract/contract_function_interaction.ts +10 -13
  71. package/src/contract/deploy_method.ts +8 -12
  72. package/src/contract/deploy_sent_tx.ts +1 -1
  73. package/src/deployment/contract_deployer.ts +3 -4
  74. package/src/deployment/deploy_instance.ts +1 -2
  75. package/src/entrypoint/default_entrypoint.ts +2 -2
  76. package/src/entrypoint/default_multi_call_entrypoint.ts +4 -4
  77. package/src/fee/private_fee_payment_method.ts +2 -2
  78. package/src/index.ts +9 -2
  79. package/src/wallet/account_wallet.ts +5 -1
  80. package/src/wallet/account_wallet_with_private_key.ts +5 -5
  81. package/src/wallet/base_wallet.ts +8 -9
  82. package/src/wallet/index.ts +5 -1
  83. package/src/wallet/signerless_wallet.ts +4 -0
@@ -1,4 +1,4 @@
1
- import { type FunctionCall, type PublicKey, type Tx, type TxExecutionRequest } from '@aztec/circuit-types';
1
+ import { type FunctionCall, type Tx, type TxExecutionRequest } from '@aztec/circuit-types';
2
2
  import {
3
3
  AztecAddress,
4
4
  computePartialAddress,
@@ -6,7 +6,6 @@ import {
6
6
  getContractInstanceFromDeployParams,
7
7
  } from '@aztec/circuits.js';
8
8
  import { type ContractArtifact, type FunctionArtifact, getInitializer } from '@aztec/foundation/abi';
9
- import { type EthAddress } from '@aztec/foundation/eth-address';
10
9
  import { type Fr } from '@aztec/foundation/fields';
11
10
  import { createDebugLogger } from '@aztec/foundation/log';
12
11
  import { type ContractInstanceWithAddress } from '@aztec/types/contracts';
@@ -23,11 +22,9 @@ import { DeploySentTx } from './deploy_sent_tx.js';
23
22
 
24
23
  /**
25
24
  * Options for deploying a contract on the Aztec network.
26
- * Allows specifying a portal contract, contract address salt, and additional send method options.
25
+ * Allows specifying a contract address salt, and additional send method options.
27
26
  */
28
27
  export type DeployOptions = {
29
- /** The Ethereum address of the Portal contract. */
30
- portalContract?: EthAddress;
31
28
  /** An optional salt value used to deterministically calculate the contract address. */
32
29
  contractAddressSalt?: Fr;
33
30
  /** Set to true to *not* include the sender in the address computation. */
@@ -59,7 +56,7 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
59
56
  private log = createDebugLogger('aztec:js:deploy_method');
60
57
 
61
58
  constructor(
62
- private publicKey: PublicKey,
59
+ private publicKeysHash: Fr,
63
60
  protected wallet: Wallet,
64
61
  private artifact: ContractArtifact,
65
62
  private postDeployCtor: (address: AztecAddress, wallet: Wallet) => Promise<TContract>,
@@ -76,7 +73,7 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
76
73
  * the transaction for deployment. The resulting signed transaction can be
77
74
  * later sent using the `send()` method.
78
75
  *
79
- * @param options - An object containing optional deployment settings, including portalContract, contractAddressSalt, and from.
76
+ * @param options - An object containing optional deployment settings, contractAddressSalt, and from.
80
77
  * @returns A Promise resolving to an object containing the signed transaction data and other relevant information.
81
78
  */
82
79
  public async create(options: DeployOptions = {}): Promise<TxExecutionRequest> {
@@ -186,10 +183,10 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
186
183
  * This function extends the 'send' method from the ContractFunctionInteraction class,
187
184
  * allowing us to send a transaction specifically for contract deployment.
188
185
  *
189
- * @param options - An object containing various deployment options such as portalContract, contractAddressSalt, and from.
186
+ * @param options - An object containing various deployment options such as contractAddressSalt and from.
190
187
  * @returns A SentTx object that returns the receipt and the deployed contract instance.
191
188
  */
192
- public send(options: DeployOptions = {}): DeploySentTx<TContract> {
189
+ public override send(options: DeployOptions = {}): DeploySentTx<TContract> {
193
190
  const txHashPromise = super.send(options).getTxHash();
194
191
  const instance = this.getInstance(options);
195
192
  this.log.debug(
@@ -209,8 +206,7 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
209
206
  this.instance = getContractInstanceFromDeployParams(this.artifact, {
210
207
  constructorArgs: this.args,
211
208
  salt: options.contractAddressSalt,
212
- portalAddress: options.portalContract,
213
- publicKey: this.publicKey,
209
+ publicKeysHash: this.publicKeysHash,
214
210
  constructorArtifact: this.constructorArtifact,
215
211
  deployer: options.universalDeploy ? AztecAddress.ZERO : this.wallet.getAddress(),
216
212
  });
@@ -223,7 +219,7 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
223
219
  * @param options - Deployment options.
224
220
  * @returns The proven tx.
225
221
  */
226
- public prove(options: DeployOptions): Promise<Tx> {
222
+ public override prove(options: DeployOptions): Promise<Tx> {
227
223
  return super.prove(options);
228
224
  }
229
225
 
@@ -53,7 +53,7 @@ export class DeploySentTx<TContract extends Contract = Contract> extends SentTx
53
53
  * @param opts - Options for configuring the waiting for the tx to be mined.
54
54
  * @returns The transaction receipt with the deployed contract instance.
55
55
  */
56
- public async wait(opts?: DeployedWaitOpts): Promise<DeployTxReceipt<TContract>> {
56
+ public override async wait(opts?: DeployedWaitOpts): Promise<DeployTxReceipt<TContract>> {
57
57
  const receipt = await super.wait(opts);
58
58
  const contract = await this.getContractObject(opts?.wallet);
59
59
  return { ...receipt, contract };
@@ -1,7 +1,6 @@
1
- import { type PublicKey } from '@aztec/circuit-types';
2
1
  import { type AztecAddress } from '@aztec/circuits.js';
3
2
  import { type ContractArtifact } from '@aztec/foundation/abi';
4
- import { Point } from '@aztec/foundation/fields';
3
+ import { Fr } from '@aztec/foundation/fields';
5
4
 
6
5
  import { type Wallet } from '../account/wallet.js';
7
6
  import { DeployMethod } from '../contract/deploy_method.js';
@@ -15,7 +14,7 @@ export class ContractDeployer {
15
14
  constructor(
16
15
  private artifact: ContractArtifact,
17
16
  private wallet: Wallet,
18
- private publicKey?: PublicKey,
17
+ private publicKeysHash?: Fr,
19
18
  private constructorName?: string,
20
19
  ) {}
21
20
 
@@ -31,7 +30,7 @@ export class ContractDeployer {
31
30
  public deploy(...args: any[]) {
32
31
  const postDeployCtor = (address: AztecAddress, wallet: Wallet) => Contract.at(address, this.artifact, wallet);
33
32
  return new DeployMethod(
34
- this.publicKey ?? Point.ZERO,
33
+ this.publicKeysHash ?? Fr.ZERO,
35
34
  this.wallet,
36
35
  this.artifact,
37
36
  postDeployCtor,
@@ -11,7 +11,7 @@ import { getDeployerContract } from './protocol_contracts.js';
11
11
  */
12
12
  export function deployInstance(wallet: Wallet, instance: ContractInstanceWithAddress): ContractFunctionInteraction {
13
13
  const deployerContract = getDeployerContract(wallet);
14
- const { salt, contractClassId, portalContractAddress, publicKeysHash, deployer } = instance;
14
+ const { salt, contractClassId, publicKeysHash, deployer } = instance;
15
15
  const isUniversalDeploy = deployer.isZero();
16
16
  if (!isUniversalDeploy && !wallet.getAddress().equals(deployer)) {
17
17
  throw new Error(
@@ -22,7 +22,6 @@ export function deployInstance(wallet: Wallet, instance: ContractInstanceWithAdd
22
22
  salt,
23
23
  contractClassId,
24
24
  instance.initializationHash,
25
- portalContractAddress,
26
25
  publicKeysHash,
27
26
  isUniversalDeploy,
28
27
  );
@@ -18,7 +18,8 @@ export class DefaultEntrypoint implements EntrypointInterface {
18
18
 
19
19
  const call = calls[0];
20
20
  const entrypointPackedValues = PackedValues.fromValues(call.args);
21
- const txContext = TxContext.empty(this.chainId, this.protocolVersion);
21
+ const gasSettings = exec.fee?.gasSettings ?? GasSettings.default();
22
+ const txContext = new TxContext(this.chainId, this.protocolVersion, gasSettings);
22
23
  return Promise.resolve(
23
24
  new TxExecutionRequest(
24
25
  call.to,
@@ -27,7 +28,6 @@ export class DefaultEntrypoint implements EntrypointInterface {
27
28
  txContext,
28
29
  [...packedArguments, entrypointPackedValues],
29
30
  authWitnesses,
30
- exec.fee?.gasSettings ?? GasSettings.default(),
31
31
  ),
32
32
  );
33
33
  }
@@ -19,15 +19,15 @@ export class DefaultMultiCallEntrypoint implements EntrypointInterface {
19
19
  const payload = EntrypointPayload.fromAppExecution(calls);
20
20
  const abi = this.getEntrypointAbi();
21
21
  const entrypointPackedArgs = PackedValues.fromValues(encodeArguments(abi, [payload]));
22
+ const gasSettings = executions.fee?.gasSettings ?? GasSettings.default();
22
23
 
23
24
  const txRequest = TxExecutionRequest.from({
24
- argsHash: entrypointPackedArgs.hash,
25
+ firstCallArgsHash: entrypointPackedArgs.hash,
25
26
  origin: this.address,
26
27
  functionData: FunctionData.fromAbi(abi),
27
- txContext: TxContext.empty(this.chainId, this.version),
28
- packedArguments: [...payload.packedArguments, ...packedArguments, entrypointPackedArgs],
28
+ txContext: new TxContext(this.chainId, this.version, gasSettings),
29
+ argsOfCalls: [...payload.packedArguments, ...packedArguments, entrypointPackedArgs],
29
30
  authWitnesses,
30
- gasSettings: executions.fee?.gasSettings ?? GasSettings.default(),
31
31
  });
32
32
 
33
33
  return Promise.resolve(txRequest);
@@ -1,6 +1,6 @@
1
1
  import { type FunctionCall } from '@aztec/circuit-types';
2
2
  import { FunctionData, type GasSettings } from '@aztec/circuits.js';
3
- import { computeMessageSecretHash } from '@aztec/circuits.js/hash';
3
+ import { computeSecretHash } from '@aztec/circuits.js/hash';
4
4
  import { FunctionSelector } from '@aztec/foundation/abi';
5
5
  import { type AztecAddress } from '@aztec/foundation/aztec-address';
6
6
  import { Fr } from '@aztec/foundation/fields';
@@ -71,7 +71,7 @@ export class PrivateFeePaymentMethod implements FeePaymentMethod {
71
71
  );
72
72
  await this.wallet.createAuthWit(messageHash);
73
73
 
74
- const secretHashForRebate = computeMessageSecretHash(this.rebateSecret);
74
+ const secretHashForRebate = computeSecretHash(this.rebateSecret);
75
75
 
76
76
  return [
77
77
  {
package/src/index.ts CHANGED
@@ -58,7 +58,7 @@ export { AuthWitnessProvider } from './account/index.js';
58
58
  export { AccountContract } from './account/index.js';
59
59
  export { AccountManager } from './account_manager/index.js';
60
60
 
61
- export { AccountWalletWithPrivateKey, AccountWallet, Wallet, SignerlessWallet } from './wallet/index.js';
61
+ export { AccountWalletWithSecretKey, AccountWallet, Wallet, SignerlessWallet } from './wallet/index.js';
62
62
 
63
63
  // // TODO https://github.com/AztecProtocol/aztec-packages/issues/2632 --> FunctionSelector might not need to be exposed
64
64
  // // here once the issue is resolved.
@@ -75,7 +75,14 @@ export {
75
75
  INITIAL_L2_BLOCK_NUM,
76
76
  } from '@aztec/circuits.js';
77
77
 
78
- export { computeMessageSecretHash } from '@aztec/circuits.js/hash';
78
+ export { computeSecretHash } from '@aztec/circuits.js/hash';
79
+
80
+ export {
81
+ computeAppNullifierSecretKey,
82
+ deriveKeys,
83
+ deriveMasterIncomingViewingSecretKey,
84
+ deriveMasterNullifierSecretKey,
85
+ } from '@aztec/circuits.js/keys';
79
86
 
80
87
  export { Grumpkin, Schnorr } from '@aztec/circuits.js/barretenberg';
81
88
 
@@ -16,6 +16,10 @@ export class AccountWallet extends BaseWallet {
16
16
  super(pxe);
17
17
  }
18
18
 
19
+ getPublicKeysHash(): Fr {
20
+ return this.account.getPublicKeysHash();
21
+ }
22
+
19
23
  createTxExecutionRequest(exec: ExecutionRequestInit): Promise<TxExecutionRequest> {
20
24
  return this.account.createTxExecutionRequest(exec);
21
25
  }
@@ -196,7 +200,7 @@ export class AccountWallet extends BaseWallet {
196
200
  }
197
201
 
198
202
  /** Returns the address of the account that implements this wallet. */
199
- public getAddress() {
203
+ public override getAddress() {
200
204
  return this.getCompleteAddress().address;
201
205
  }
202
206
 
@@ -1,5 +1,5 @@
1
1
  import { type PXE } from '@aztec/circuit-types';
2
- import { type GrumpkinPrivateKey } from '@aztec/circuits.js';
2
+ import { type Fr } from '@aztec/circuits.js';
3
3
 
4
4
  import { type Salt } from '../account/index.js';
5
5
  import { type AccountInterface } from '../account/interface.js';
@@ -10,11 +10,11 @@ import { AccountWallet } from './account_wallet.js';
10
10
  * implementing the wallet interface but useful for testing purposes or exporting
11
11
  * an account to another pxe.
12
12
  */
13
- export class AccountWalletWithPrivateKey extends AccountWallet {
13
+ export class AccountWalletWithSecretKey extends AccountWallet {
14
14
  constructor(
15
15
  pxe: PXE,
16
16
  account: AccountInterface,
17
- private encryptionPrivateKey: GrumpkinPrivateKey,
17
+ private secretKey: Fr,
18
18
  /** Deployment salt for this account contract. */
19
19
  public readonly salt: Salt,
20
20
  ) {
@@ -22,7 +22,7 @@ export class AccountWalletWithPrivateKey extends AccountWallet {
22
22
  }
23
23
 
24
24
  /** Returns the encryption private key associated with this account. */
25
- public getEncryptionPrivateKey() {
26
- return this.encryptionPrivateKey;
25
+ public getSecretKey() {
26
+ return this.secretKey;
27
27
  }
28
28
  }
@@ -15,13 +15,7 @@ import {
15
15
  type TxHash,
16
16
  type TxReceipt,
17
17
  } from '@aztec/circuit-types';
18
- import {
19
- type AztecAddress,
20
- type CompleteAddress,
21
- type Fr,
22
- type GrumpkinPrivateKey,
23
- type PartialAddress,
24
- } from '@aztec/circuits.js';
18
+ import { type AztecAddress, type CompleteAddress, type Fr, type PartialAddress } from '@aztec/circuits.js';
25
19
  import { type ContractArtifact } from '@aztec/foundation/abi';
26
20
  import { type ContractClassWithId, type ContractInstanceWithAddress } from '@aztec/types/contracts';
27
21
  import { type NodeInfo } from '@aztec/types/interfaces';
@@ -38,6 +32,8 @@ export abstract class BaseWallet implements Wallet {
38
32
 
39
33
  abstract getCompleteAddress(): CompleteAddress;
40
34
 
35
+ abstract getPublicKeysHash(): Fr;
36
+
41
37
  abstract getChainId(): Fr;
42
38
 
43
39
  abstract getVersion(): Fr;
@@ -72,8 +68,8 @@ export abstract class BaseWallet implements Wallet {
72
68
  addCapsule(capsule: Fr[]): Promise<void> {
73
69
  return this.pxe.addCapsule(capsule);
74
70
  }
75
- registerAccount(privKey: GrumpkinPrivateKey, partialAddress: PartialAddress): Promise<CompleteAddress> {
76
- return this.pxe.registerAccount(privKey, partialAddress);
71
+ registerAccount(secretKey: Fr, partialAddress: PartialAddress): Promise<CompleteAddress> {
72
+ return this.pxe.registerAccount(secretKey, partialAddress);
77
73
  }
78
74
  registerRecipient(account: CompleteAddress): Promise<void> {
79
75
  return this.pxe.registerRecipient(account);
@@ -84,6 +80,9 @@ export abstract class BaseWallet implements Wallet {
84
80
  getRegisteredAccount(address: AztecAddress): Promise<CompleteAddress | undefined> {
85
81
  return this.pxe.getRegisteredAccount(address);
86
82
  }
83
+ getRegisteredAccountPublicKeysHash(address: AztecAddress): Promise<Fr | undefined> {
84
+ return this.pxe.getRegisteredAccountPublicKeysHash(address);
85
+ }
87
86
  getRecipients(): Promise<CompleteAddress[]> {
88
87
  return this.pxe.getRecipients();
89
88
  }
@@ -25,7 +25,11 @@ export async function getWallet(
25
25
  if (!completeAddress) {
26
26
  throw new Error(`Account ${address} not found`);
27
27
  }
28
+ const publicKeysHash = await pxe.getRegisteredAccountPublicKeysHash(address);
29
+ if (!publicKeysHash) {
30
+ throw new Error(`Public keys hash for account ${address} not found`);
31
+ }
28
32
  const nodeInfo = await pxe.getNodeInfo();
29
- const entrypoint = accountContract.getInterface(completeAddress, nodeInfo);
33
+ const entrypoint = accountContract.getInterface(completeAddress, publicKeysHash, nodeInfo);
30
34
  return new AccountWallet(pxe, entrypoint);
31
35
  }
@@ -31,6 +31,10 @@ export class SignerlessWallet extends BaseWallet {
31
31
  throw new Error('Method not implemented.');
32
32
  }
33
33
 
34
+ getPublicKeysHash(): Fr {
35
+ throw new Error('Method not implemented.');
36
+ }
37
+
34
38
  getCompleteAddress(): CompleteAddress {
35
39
  throw new Error('Method not implemented.');
36
40
  }