@aztec/aztec.js 0.8.9 → 0.8.11

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 (79) hide show
  1. package/README.md +3 -3
  2. package/dest/account/contract/base_account_contract.d.ts +4 -4
  3. package/dest/account/contract/base_account_contract.d.ts.map +1 -1
  4. package/dest/account/contract/base_account_contract.js +5 -5
  5. package/dest/account/contract/ecdsa_account_contract.js +3 -3
  6. package/dest/account/contract/index.d.ts +4 -4
  7. package/dest/account/contract/index.d.ts.map +1 -1
  8. package/dest/account/contract/schnorr_account_contract.js +3 -3
  9. package/dest/account/contract/single_key_account_contract.js +3 -3
  10. package/dest/account/defaults/default_entrypoint.js +1 -1
  11. package/dest/account/manager/index.js +3 -3
  12. package/dest/{abis → artifacts}/ecdsa_account_contract.json +4 -3
  13. package/dest/{abis → artifacts}/schnorr_account_contract.json +4 -3
  14. package/dest/{abis → artifacts}/schnorr_single_key_account_contract.json +4 -3
  15. package/dest/contract/checker.d.ts +5 -5
  16. package/dest/contract/checker.d.ts.map +1 -1
  17. package/dest/contract/checker.js +9 -9
  18. package/dest/contract/contract.d.ts +7 -7
  19. package/dest/contract/contract.d.ts.map +1 -1
  20. package/dest/contract/contract.js +10 -10
  21. package/dest/contract/contract_base.d.ts +3 -3
  22. package/dest/contract/contract_base.d.ts.map +1 -1
  23. package/dest/contract/contract_base.js +5 -5
  24. package/dest/contract/contract_function_interaction.d.ts +3 -3
  25. package/dest/contract/contract_function_interaction.d.ts.map +1 -1
  26. package/dest/contract/contract_function_interaction.js +1 -1
  27. package/dest/contract/index.d.ts +3 -3
  28. package/dest/contract/index.js +3 -3
  29. package/dest/contract/sent_tx.d.ts +7 -1
  30. package/dest/contract/sent_tx.d.ts.map +1 -1
  31. package/dest/contract/sent_tx.js +10 -1
  32. package/dest/contract_deployer/contract_deployer.d.ts +3 -3
  33. package/dest/contract_deployer/contract_deployer.d.ts.map +1 -1
  34. package/dest/contract_deployer/contract_deployer.js +4 -4
  35. package/dest/contract_deployer/deploy_method.d.ts +4 -4
  36. package/dest/contract_deployer/deploy_method.d.ts.map +1 -1
  37. package/dest/contract_deployer/deploy_method.js +12 -12
  38. package/dest/contract_deployer/deploy_sent_tx.d.ts +12 -4
  39. package/dest/contract_deployer/deploy_sent_tx.d.ts.map +1 -1
  40. package/dest/contract_deployer/deploy_sent_tx.js +9 -4
  41. package/dest/index.d.ts +2 -2
  42. package/dest/index.d.ts.map +1 -1
  43. package/dest/index.js +4 -2
  44. package/dest/pxe_client.d.ts.map +1 -1
  45. package/dest/pxe_client.js +6 -3
  46. package/dest/sandbox/index.d.ts +1 -0
  47. package/dest/sandbox/index.d.ts.map +1 -1
  48. package/dest/sandbox/index.js +3 -3
  49. package/dest/utils/authwit.d.ts.map +1 -1
  50. package/dest/utils/authwit.js +3 -1
  51. package/dest/wallet/base_wallet.d.ts +2 -2
  52. package/dest/wallet/base_wallet.d.ts.map +1 -1
  53. package/dest/wallet/base_wallet.js +3 -3
  54. package/package.json +5 -5
  55. package/src/account/contract/base_account_contract.ts +4 -4
  56. package/src/account/contract/ecdsa_account_contract.ts +3 -3
  57. package/src/account/contract/index.ts +4 -4
  58. package/src/account/contract/schnorr_account_contract.ts +3 -3
  59. package/src/account/contract/single_key_account_contract.ts +3 -3
  60. package/src/account/defaults/default_entrypoint.ts +2 -2
  61. package/src/account/manager/index.ts +2 -2
  62. package/src/{abis → artifacts}/ecdsa_account_contract.json +4 -3
  63. package/src/{abis → artifacts}/schnorr_account_contract.json +4 -3
  64. package/src/{abis → artifacts}/schnorr_single_key_account_contract.json +4 -3
  65. package/src/contract/checker.ts +9 -9
  66. package/src/contract/contract.ts +10 -10
  67. package/src/contract/contract_base.ts +4 -4
  68. package/src/contract/contract_function_interaction.ts +2 -2
  69. package/src/contract/index.ts +3 -3
  70. package/src/contract/sent_tx.ts +11 -1
  71. package/src/contract_deployer/contract_deployer.ts +3 -3
  72. package/src/contract_deployer/deploy_method.ts +17 -12
  73. package/src/contract_deployer/deploy_sent_tx.ts +13 -4
  74. package/src/index.ts +4 -1
  75. package/src/pxe_client.ts +14 -1
  76. package/src/sandbox/index.ts +2 -2
  77. package/src/utils/authwit.ts +2 -0
  78. package/src/wallet/account_wallet.ts +2 -2
  79. package/src/wallet/base_wallet.ts +4 -3
@@ -10,12 +10,12 @@
10
10
  * or can be queried via `view()`.
11
11
  *
12
12
  * ```ts
13
- * const contract = await Contract.deploy(wallet, MyContractAbi, [...constructorArgs]).send().deployed();
13
+ * const contract = await Contract.deploy(wallet, MyContractArtifact, [...constructorArgs]).send().deployed();
14
14
  * console.log(`Contract deployed at ${contract.address}`);
15
15
  * ```
16
16
  *
17
17
  * ```ts
18
- * const contract = await Contract.at(address, MyContractAbi, wallet);
18
+ * const contract = await Contract.at(address, MyContractArtifact, wallet);
19
19
  * await contract.methods.mint(1000, owner).send().wait();
20
20
  * console.log(`Total supply is now ${await contract.methods.totalSupply().view()}`);
21
21
  * ```
@@ -27,7 +27,7 @@
27
27
  *
28
28
  * The result of `send`ing a transaction is a {@link SentTx} object, from which you can get the
29
29
  * transaction hash, or simply `wait` until the transaction is mined and the local PXE Service
30
- * has synchronised its changes.
30
+ * has synchronized its changes.
31
31
  *
32
32
  * @remarks If you are using typescript, consider using the
33
33
  * {@link https://docs.aztec.network/dev_docs/contracts/compiling#typescript-interfaces | autogenerated type-safe interfaces}
@@ -1,6 +1,6 @@
1
1
  import { FieldsOf } from '@aztec/circuits.js';
2
2
  import { retryUntil } from '@aztec/foundation/retry';
3
- import { PXE, TxHash, TxReceipt, TxStatus } from '@aztec/types';
3
+ import { GetUnencryptedLogsResponse, PXE, TxHash, TxReceipt, TxStatus } from '@aztec/types';
4
4
 
5
5
  import every from 'lodash.every';
6
6
 
@@ -80,6 +80,16 @@ export class SentTx {
80
80
  return receipt.status === TxStatus.MINED;
81
81
  }
82
82
 
83
+ /**
84
+ * Gets unencrypted logs emitted by this tx.
85
+ * @remarks This function will wait for the tx to be mined if it hasn't been already.
86
+ * @returns The requested logs.
87
+ */
88
+ public async getUnencryptedLogs(): Promise<GetUnencryptedLogsResponse> {
89
+ await this.wait();
90
+ return this.pxe.getUnencryptedLogs({ txHash: await this.getTxHash() });
91
+ }
92
+
83
93
  protected async waitForReceipt(opts?: WaitOpts): Promise<TxReceipt> {
84
94
  const txHash = await this.getTxHash();
85
95
  return await retryUntil(
@@ -1,4 +1,4 @@
1
- import { ContractAbi } from '@aztec/foundation/abi';
1
+ import { ContractArtifact } from '@aztec/foundation/abi';
2
2
  import { Point } from '@aztec/foundation/fields';
3
3
  import { PXE, PublicKey } from '@aztec/types';
4
4
 
@@ -9,7 +9,7 @@ import { DeployMethod } from './deploy_method.js';
9
9
  * @remarks Keeping this around even though we have Aztec.nr contract types because it can be useful for non-TS users.
10
10
  */
11
11
  export class ContractDeployer {
12
- constructor(private abi: ContractAbi, private pxe: PXE, private publicKey?: PublicKey) {}
12
+ constructor(private artifact: ContractArtifact, private pxe: PXE, private publicKey?: PublicKey) {}
13
13
 
14
14
  /**
15
15
  * Deploy a contract using the provided ABI and constructor arguments.
@@ -21,6 +21,6 @@ export class ContractDeployer {
21
21
  * @returns A DeployMethod instance configured with the ABI, PXE, and constructor arguments.
22
22
  */
23
23
  public deploy(...args: any[]) {
24
- return new DeployMethod(this.publicKey ?? Point.ZERO, this.pxe, this.abi, args);
24
+ return new DeployMethod(this.publicKey ?? Point.ZERO, this.pxe, this.artifact, args);
25
25
  }
26
26
  }
@@ -5,7 +5,7 @@ import {
5
5
  TxContext,
6
6
  getContractDeploymentInfo,
7
7
  } from '@aztec/circuits.js';
8
- import { ContractAbi, FunctionAbi, encodeArguments } from '@aztec/foundation/abi';
8
+ import { ContractArtifact, FunctionArtifact, encodeArguments } from '@aztec/foundation/abi';
9
9
  import { EthAddress } from '@aztec/foundation/eth-address';
10
10
  import { Fr } from '@aztec/foundation/fields';
11
11
  import { PXE, PackedArguments, PublicKey, Tx, TxExecutionRequest } from '@aztec/types';
@@ -38,13 +38,18 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
38
38
  public completeAddress?: CompleteAddress = undefined;
39
39
 
40
40
  /** Constructor function to call. */
41
- private constructorAbi: FunctionAbi;
42
-
43
- constructor(private publicKey: PublicKey, protected pxe: PXE, private abi: ContractAbi, private args: any[] = []) {
41
+ private constructorArtifact: FunctionArtifact;
42
+
43
+ constructor(
44
+ private publicKey: PublicKey,
45
+ protected pxe: PXE,
46
+ private artifact: ContractArtifact,
47
+ private args: any[] = [],
48
+ ) {
44
49
  super(pxe);
45
- const constructorAbi = abi.functions.find(f => f.name === 'constructor');
46
- if (!constructorAbi) throw new Error('Cannot find constructor in the ABI.');
47
- this.constructorAbi = constructorAbi;
50
+ const constructorArtifact = artifact.functions.find(f => f.name === 'constructor');
51
+ if (!constructorArtifact) throw new Error('Cannot find constructor in the artifact.');
52
+ this.constructorArtifact = constructorArtifact;
48
53
  }
49
54
 
50
55
  /**
@@ -63,7 +68,7 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
63
68
  const { chainId, protocolVersion } = await this.pxe.getNodeInfo();
64
69
 
65
70
  const { completeAddress, constructorHash, functionTreeRoot } = await getContractDeploymentInfo(
66
- this.abi,
71
+ this.artifact,
67
72
  this.args,
68
73
  contractAddressSalt,
69
74
  this.publicKey,
@@ -85,8 +90,8 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
85
90
  new Fr(chainId),
86
91
  new Fr(protocolVersion),
87
92
  );
88
- const args = encodeArguments(this.constructorAbi, this.args);
89
- const functionData = FunctionData.fromAbi(this.constructorAbi);
93
+ const args = encodeArguments(this.constructorArtifact, this.args);
94
+ const functionData = FunctionData.fromAbi(this.constructorArtifact);
90
95
  const execution = { args, functionData, to: completeAddress.address };
91
96
  const packedArguments = await PackedArguments.fromArgs(execution.args);
92
97
 
@@ -103,7 +108,7 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
103
108
  this.completeAddress = completeAddress;
104
109
 
105
110
  // TODO: Should we add the contracts to the DB here, or once the tx has been sent or mined?
106
- await this.pxe.addContracts([{ abi: this.abi, completeAddress, portalContract }]);
111
+ await this.pxe.addContracts([{ artifact: this.artifact, completeAddress, portalContract }]);
107
112
 
108
113
  return this.txRequest;
109
114
  }
@@ -118,7 +123,7 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
118
123
  */
119
124
  public send(options: DeployOptions = {}): DeploySentTx<TContract> {
120
125
  const txHashPromise = super.send(options).getTxHash();
121
- return new DeploySentTx(this.abi, this.pxe, txHashPromise);
126
+ return new DeploySentTx(this.artifact, this.pxe, txHashPromise, this.completeAddress);
122
127
  }
123
128
 
124
129
  /**
@@ -1,5 +1,5 @@
1
- import { FieldsOf } from '@aztec/circuits.js';
2
- import { ContractAbi } from '@aztec/foundation/abi';
1
+ import { CompleteAddress, FieldsOf } from '@aztec/circuits.js';
2
+ import { ContractArtifact } from '@aztec/foundation/abi';
3
3
  import { TxHash, TxReceipt } from '@aztec/types';
4
4
 
5
5
  import { AztecAddress, Contract, ContractBase, PXE, SentTx, WaitOpts, Wallet } from '../index.js';
@@ -20,7 +20,16 @@ export type DeployTxReceipt<TContract extends ContractBase = Contract> = FieldsO
20
20
  * A contract deployment transaction sent to the network, extending SentTx with methods to create a contract instance.
21
21
  */
22
22
  export class DeploySentTx<TContract extends Contract = Contract> extends SentTx {
23
- constructor(private abi: ContractAbi, wallet: PXE | Wallet, txHashPromise: Promise<TxHash>) {
23
+ constructor(
24
+ private artifact: ContractArtifact,
25
+ wallet: PXE | Wallet,
26
+ txHashPromise: Promise<TxHash>,
27
+
28
+ /**
29
+ * The complete address of the deployed contract
30
+ */
31
+ public completeContractAddress?: CompleteAddress,
32
+ ) {
24
33
  super(wallet, txHashPromise);
25
34
  }
26
35
 
@@ -50,6 +59,6 @@ export class DeploySentTx<TContract extends Contract = Contract> extends SentTx
50
59
  const contractWallet = wallet ?? (isWallet(this.pxe) && this.pxe);
51
60
  if (!contractWallet) throw new Error(`A wallet is required for creating a contract instance`);
52
61
  if (!address) throw new Error(`Contract address is missing from transaction receipt`);
53
- return Contract.at(address, this.abi, contractWallet) as Promise<TContract>;
62
+ return Contract.at(address, this.artifact, contractWallet) as Promise<TContract>;
54
63
  }
55
64
  }
package/src/index.ts CHANGED
@@ -7,7 +7,9 @@ export * from './contract_deployer/deploy_method.js';
7
7
  export * from './sandbox/index.js';
8
8
  export * from './wallet/index.js';
9
9
 
10
- export { AztecAddress, EthAddress, Point, Fr, GrumpkinScalar } from '@aztec/circuits.js';
10
+ // TODO https://github.com/AztecProtocol/aztec-packages/issues/2632 --> FunctionSelector might not need to be exposed
11
+ // here once the issue is resolved.
12
+ export { AztecAddress, EthAddress, Point, Fr, FunctionSelector, GrumpkinScalar } from '@aztec/circuits.js';
11
13
  export {
12
14
  PXE,
13
15
  ContractData,
@@ -15,6 +17,7 @@ export {
15
17
  DeployedContract,
16
18
  FunctionCall,
17
19
  L2BlockL2Logs,
20
+ LogFilter,
18
21
  UnencryptedL2Log,
19
22
  NodeInfo,
20
23
  NotePreimage,
package/src/pxe_client.ts CHANGED
@@ -1,11 +1,21 @@
1
- import { AztecAddress, CompleteAddress, EthAddress, Fr, GrumpkinScalar, Point } from '@aztec/circuits.js';
1
+ import {
2
+ AztecAddress,
3
+ CompleteAddress,
4
+ EthAddress,
5
+ Fr,
6
+ FunctionSelector,
7
+ GrumpkinScalar,
8
+ Point,
9
+ } from '@aztec/circuits.js';
2
10
  import { createJsonRpcClient, makeFetch } from '@aztec/foundation/json-rpc/client';
3
11
  import {
4
12
  AuthWitness,
5
13
  ContractData,
6
14
  ExtendedContractData,
15
+ ExtendedUnencryptedL2Log,
7
16
  L2BlockL2Logs,
8
17
  L2Tx,
18
+ LogId,
9
19
  NotePreimage,
10
20
  PXE,
11
21
  Tx,
@@ -21,10 +31,12 @@ export const createPXEClient = (url: string, fetch = makeFetch([1, 2, 3], true))
21
31
  url,
22
32
  {
23
33
  CompleteAddress,
34
+ FunctionSelector,
24
35
  AztecAddress,
25
36
  TxExecutionRequest,
26
37
  ContractData,
27
38
  ExtendedContractData,
39
+ ExtendedUnencryptedL2Log,
28
40
  TxHash,
29
41
  EthAddress,
30
42
  Point,
@@ -33,6 +45,7 @@ export const createPXEClient = (url: string, fetch = makeFetch([1, 2, 3], true))
33
45
  NotePreimage,
34
46
  AuthWitness,
35
47
  L2Tx,
48
+ LogId,
36
49
  },
37
50
  { Tx, TxReceipt, L2BlockL2Logs },
38
51
  false,
@@ -3,7 +3,7 @@ import { sleep } from '@aztec/foundation/sleep';
3
3
 
4
4
  import zip from 'lodash.zip';
5
5
 
6
- import SchnorrAccountContractAbi from '../abis/schnorr_account_contract.json' assert { type: 'json' };
6
+ import SchnorrAccountContractArtifact from '../artifacts/schnorr_account_contract.json' assert { type: 'json' };
7
7
  import { AccountWalletWithPrivateKey, PXE, createPXEClient, getSchnorrAccount } from '../index.js';
8
8
 
9
9
  export const INITIAL_SANDBOX_ENCRYPTION_KEYS = [
@@ -16,7 +16,7 @@ export const INITIAL_SANDBOX_SIGNING_KEYS = INITIAL_SANDBOX_ENCRYPTION_KEYS;
16
16
 
17
17
  export const INITIAL_SANDBOX_SALTS = [Fr.ZERO, Fr.ZERO, Fr.ZERO];
18
18
 
19
- export const INITIAL_SANDBOX_ACCOUNT_CONTRACT_ABI = SchnorrAccountContractAbi;
19
+ export const INITIAL_SANDBOX_ACCOUNT_CONTRACT_ABI = SchnorrAccountContractArtifact;
20
20
 
21
21
  export const { PXE_URL = 'http://localhost:8080' } = process.env;
22
22
 
@@ -2,6 +2,7 @@ import { AztecAddress, CircuitsWasm, GeneratorIndex } from '@aztec/circuits.js';
2
2
  import { pedersenPlookupCompressWithHashIndex } from '@aztec/circuits.js/barretenberg';
3
3
  import { FunctionCall, PackedArguments } from '@aztec/types';
4
4
 
5
+ // docs:start:authwit_computeAuthWitMessageHash
5
6
  /**
6
7
  * Compute an authentication witness message hash from a caller and a request
7
8
  * H(caller: AztecAddress, target: AztecAddress, selector: Field, args_hash: Field)
@@ -22,3 +23,4 @@ export const computeAuthWitMessageHash = async (caller: AztecAddress, request: F
22
23
  GeneratorIndex.SIGNATURE_PAYLOAD,
23
24
  );
24
25
  };
26
+ // docs:end:authwit_computeAuthWitMessageHash
@@ -1,5 +1,5 @@
1
1
  import { Fr, GrumpkinPrivateKey } from '@aztec/circuits.js';
2
- import { ABIParameterVisibility, FunctionAbiHeader, FunctionType } from '@aztec/foundation/abi';
2
+ import { ABIParameterVisibility, FunctionAbi, FunctionType } from '@aztec/foundation/abi';
3
3
  import { AuthWitness, FunctionCall, PXE, TxExecutionRequest } from '@aztec/types';
4
4
 
5
5
  import { AccountInterface } from '../account/interface.js';
@@ -47,7 +47,7 @@ export class AccountWallet extends BaseWallet {
47
47
  return this.getCompleteAddress().address;
48
48
  }
49
49
 
50
- private getSetIsValidStorageAbi(): FunctionAbiHeader {
50
+ private getSetIsValidStorageAbi(): FunctionAbi {
51
51
  return {
52
52
  name: 'set_is_valid_storage',
53
53
  functionType: 'open' as FunctionType,
@@ -5,8 +5,9 @@ import {
5
5
  DeployedContract,
6
6
  ExtendedContractData,
7
7
  FunctionCall,
8
- L2BlockL2Logs,
8
+ GetUnencryptedLogsResponse,
9
9
  L2Tx,
10
+ LogFilter,
10
11
  NodeInfo,
11
12
  NotePreimage,
12
13
  PXE,
@@ -96,8 +97,8 @@ export abstract class BaseWallet implements Wallet {
96
97
  getContractData(contractAddress: AztecAddress): Promise<ContractData | undefined> {
97
98
  return this.pxe.getContractData(contractAddress);
98
99
  }
99
- getUnencryptedLogs(from: number, limit: number): Promise<L2BlockL2Logs[]> {
100
- return this.pxe.getUnencryptedLogs(from, limit);
100
+ getUnencryptedLogs(filter: LogFilter): Promise<GetUnencryptedLogsResponse> {
101
+ return this.pxe.getUnencryptedLogs(filter);
101
102
  }
102
103
  getBlockNumber(): Promise<number> {
103
104
  return this.pxe.getBlockNumber();