@aztec/aztec.js 0.7.10 → 0.8.4

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 (133) hide show
  1. package/README.md +25 -23
  2. package/dest/abis/ecdsa_account_contract.json +20 -8
  3. package/dest/abis/schnorr_account_contract.json +20 -8
  4. package/dest/abis/schnorr_single_key_account_contract.json +19 -7
  5. package/dest/account/defaults/default_entrypoint.js +3 -3
  6. package/dest/account/index.d.ts +33 -11
  7. package/dest/account/index.d.ts.map +1 -1
  8. package/dest/account/index.js +40 -18
  9. package/dest/account/manager/index.d.ts +8 -8
  10. package/dest/account/manager/index.d.ts.map +1 -1
  11. package/dest/account/manager/index.js +12 -12
  12. package/dest/{utils/account.d.ts → account/utils.d.ts} +10 -10
  13. package/dest/account/utils.d.ts.map +1 -0
  14. package/dest/account/utils.js +40 -0
  15. package/dest/contract/base_contract_interaction.d.ts +5 -5
  16. package/dest/contract/base_contract_interaction.d.ts.map +1 -1
  17. package/dest/contract/base_contract_interaction.js +6 -6
  18. package/dest/contract/contract.d.ts +1 -1
  19. package/dest/contract/contract.js +1 -1
  20. package/dest/contract/contract_base.d.ts +3 -3
  21. package/dest/contract/contract_base.d.ts.map +1 -1
  22. package/dest/contract/contract_base.js +2 -2
  23. package/dest/contract/contract_function_interaction.d.ts +2 -2
  24. package/dest/contract/contract_function_interaction.d.ts.map +1 -1
  25. package/dest/contract/index.d.ts +37 -0
  26. package/dest/contract/index.d.ts.map +1 -1
  27. package/dest/contract/index.js +38 -1
  28. package/dest/contract/sent_tx.d.ts +6 -6
  29. package/dest/contract/sent_tx.d.ts.map +1 -1
  30. package/dest/contract/sent_tx.js +9 -9
  31. package/dest/contract_deployer/contract_deployer.d.ts +4 -4
  32. package/dest/contract_deployer/contract_deployer.d.ts.map +1 -1
  33. package/dest/contract_deployer/contract_deployer.js +5 -5
  34. package/dest/contract_deployer/deploy_method.d.ts +5 -5
  35. package/dest/contract_deployer/deploy_method.d.ts.map +1 -1
  36. package/dest/contract_deployer/deploy_method.js +7 -7
  37. package/dest/contract_deployer/deploy_sent_tx.d.ts +2 -2
  38. package/dest/contract_deployer/deploy_sent_tx.d.ts.map +1 -1
  39. package/dest/contract_deployer/deploy_sent_tx.js +3 -3
  40. package/dest/index.d.ts +2 -2
  41. package/dest/index.d.ts.map +1 -1
  42. package/dest/index.js +3 -3
  43. package/dest/pxe_client.d.ts +4 -0
  44. package/dest/pxe_client.d.ts.map +1 -0
  45. package/dest/pxe_client.js +20 -0
  46. package/dest/sandbox/index.d.ts +8 -8
  47. package/dest/sandbox/index.d.ts.map +1 -1
  48. package/dest/sandbox/index.js +13 -13
  49. package/dest/utils/abi_types.d.ts +9 -1
  50. package/dest/utils/abi_types.d.ts.map +1 -1
  51. package/dest/utils/authwit.d.ts +12 -0
  52. package/dest/utils/authwit.d.ts.map +1 -0
  53. package/dest/utils/authwit.js +20 -0
  54. package/dest/utils/cheat_codes.d.ts +8 -8
  55. package/dest/utils/cheat_codes.d.ts.map +1 -1
  56. package/dest/utils/cheat_codes.js +11 -11
  57. package/dest/utils/index.d.ts +1 -1
  58. package/dest/utils/index.d.ts.map +1 -1
  59. package/dest/utils/index.js +2 -2
  60. package/dest/utils/l1_contracts.d.ts +1 -30
  61. package/dest/utils/l1_contracts.d.ts.map +1 -1
  62. package/dest/utils/l1_contracts.js +5 -6
  63. package/dest/utils/l2_contracts.d.ts +3 -3
  64. package/dest/utils/l2_contracts.d.ts.map +1 -1
  65. package/dest/utils/l2_contracts.js +4 -4
  66. package/dest/wallet/account_wallet.d.ts +2 -2
  67. package/dest/wallet/account_wallet.d.ts.map +1 -1
  68. package/dest/wallet/account_wallet.js +4 -4
  69. package/dest/wallet/base_wallet.d.ts +7 -5
  70. package/dest/wallet/base_wallet.d.ts.map +1 -1
  71. package/dest/wallet/base_wallet.js +35 -29
  72. package/dest/wallet/index.d.ts +2 -2
  73. package/dest/wallet/index.d.ts.map +1 -1
  74. package/dest/wallet/signerless_wallet.js +1 -1
  75. package/package.json +69 -6
  76. package/src/abis/ecdsa_account_contract.json +20 -8
  77. package/src/abis/schnorr_account_contract.json +20 -8
  78. package/src/abis/schnorr_single_key_account_contract.json +19 -7
  79. package/src/account/defaults/default_entrypoint.ts +2 -2
  80. package/src/account/index.ts +40 -18
  81. package/src/account/manager/index.ts +11 -11
  82. package/src/{utils/account.ts → account/utils.ts} +12 -12
  83. package/src/contract/base_contract_interaction.ts +7 -7
  84. package/src/contract/contract.ts +1 -1
  85. package/src/contract/contract_base.ts +2 -2
  86. package/src/contract/contract_function_interaction.ts +2 -2
  87. package/src/contract/index.ts +37 -0
  88. package/src/contract/sent_tx.ts +9 -9
  89. package/src/contract_deployer/contract_deployer.ts +4 -4
  90. package/src/contract_deployer/deploy_method.ts +8 -8
  91. package/src/contract_deployer/deploy_sent_tx.ts +4 -4
  92. package/src/index.ts +4 -2
  93. package/src/{aztec_rpc_client.ts → pxe_client.ts} +5 -3
  94. package/src/sandbox/index.ts +12 -12
  95. package/src/utils/abi_types.ts +7 -1
  96. package/src/utils/authwit.ts +24 -0
  97. package/src/utils/cheat_codes.ts +10 -10
  98. package/src/utils/index.ts +1 -1
  99. package/src/utils/l1_contracts.ts +5 -44
  100. package/src/utils/l2_contracts.ts +4 -4
  101. package/src/wallet/account_wallet.ts +4 -4
  102. package/src/wallet/base_wallet.ts +42 -28
  103. package/src/wallet/index.ts +2 -2
  104. package/src/wallet/signerless_wallet.ts +1 -1
  105. package/.eslintrc.cjs +0 -1
  106. package/.tsbuildinfo +0 -1
  107. package/dest/aztec_rpc_client.d.ts +0 -4
  108. package/dest/aztec_rpc_client.d.ts.map +0 -1
  109. package/dest/aztec_rpc_client.js +0 -19
  110. package/dest/contract/checker.test.d.ts +0 -2
  111. package/dest/contract/checker.test.d.ts.map +0 -1
  112. package/dest/contract/checker.test.js +0 -169
  113. package/dest/contract/contract.test.d.ts +0 -2
  114. package/dest/contract/contract.test.d.ts.map +0 -1
  115. package/dest/contract/contract.test.js +0 -147
  116. package/dest/contract/sent_tx.test.d.ts +0 -2
  117. package/dest/contract/sent_tx.test.d.ts.map +0 -1
  118. package/dest/contract/sent_tx.test.js +0 -42
  119. package/dest/contract_deployer/contract_deployer.test.d.ts +0 -2
  120. package/dest/contract_deployer/contract_deployer.test.d.ts.map +0 -1
  121. package/dest/contract_deployer/contract_deployer.test.js +0 -46
  122. package/dest/main.js +0 -2
  123. package/dest/main.js.LICENSE.txt +0 -10
  124. package/dest/utils/account.d.ts.map +0 -1
  125. package/dest/utils/account.js +0 -40
  126. package/package.local.json +0 -5
  127. package/src/contract/checker.test.ts +0 -178
  128. package/src/contract/contract.test.ts +0 -172
  129. package/src/contract/sent_tx.test.ts +0 -52
  130. package/src/contract_deployer/contract_deployer.test.ts +0 -55
  131. package/tsconfig.dest.json +0 -15
  132. package/tsconfig.json +0 -20
  133. package/webpack.config.js +0 -74
@@ -1,10 +0,0 @@
1
- /*!
2
- * The buffer module from node.js, for the browser.
3
- *
4
- * @author Feross Aboukhadijeh <https://feross.org>
5
- * @license MIT
6
- */
7
-
8
- /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
9
-
10
- /*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
@@ -1 +0,0 @@
1
- {"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../../src/utils/account.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAkB,MAAM,oBAAoB,CAAC;AACrE,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAGxC,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5D;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,QAAQ,GAAG,OAAO,CAAC,aAAa,CAAC,CAEnE;AAED;;;;GAIG;AACH,wBAAsB,eAAe,CAAC,GAAG,EAAE,QAAQ,GAAG,OAAO,CAAC,eAAe,CAAC,CAI7E;AAED;;;;;GAKG;AACH,wBAAsB,cAAc,CAAC,GAAG,EAAE,QAAQ,EAAE,gBAAgB,SAAI,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CAclG"}
@@ -1,40 +0,0 @@
1
- import { CompleteAddress, GrumpkinScalar } from '@aztec/circuits.js';
2
- import { getSchnorrAccount } from '../index.js';
3
- /**
4
- * Deploys and registers a new account using random private keys and returns the associated wallet. Useful for testing.
5
- * @param rpc - RPC client.
6
- * @returns - A wallet for a fresh account.
7
- */
8
- export function createAccount(rpc) {
9
- return getSchnorrAccount(rpc, GrumpkinScalar.random(), GrumpkinScalar.random()).waitDeploy();
10
- }
11
- /**
12
- * Creates a random address and registers it as a recipient on the RPC server. Useful for testing.
13
- * @param rpc - RPC client.
14
- * @returns Complete address of the registered recipient.
15
- */
16
- export async function createRecipient(rpc) {
17
- const completeAddress = await CompleteAddress.random();
18
- await rpc.registerRecipient(completeAddress);
19
- return completeAddress;
20
- }
21
- /**
22
- * Creates a given number of random accounts using the Schnorr account wallet.
23
- * @param rpc - RPC interface.
24
- * @param numberOfAccounts - How many accounts to create.
25
- * @returns The created account wallets.
26
- */
27
- export async function createAccounts(rpc, numberOfAccounts = 1) {
28
- const accounts = [];
29
- // Prepare deployments
30
- for (let i = 0; i < numberOfAccounts; ++i) {
31
- const account = getSchnorrAccount(rpc, GrumpkinScalar.random(), GrumpkinScalar.random());
32
- await account.getDeployMethod().then(d => d.simulate({ contractAddressSalt: account.salt }));
33
- accounts.push(account);
34
- }
35
- // Send them and await them to be mined
36
- const txs = await Promise.all(accounts.map(account => account.deploy()));
37
- await Promise.all(txs.map(tx => tx.wait({ interval: 0.1 })));
38
- return Promise.all(accounts.map(account => account.getWallet()));
39
- }
40
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYWNjb3VudC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlscy9hY2NvdW50LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxlQUFlLEVBQUUsY0FBYyxFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFHckUsT0FBTyxFQUFFLGlCQUFpQixFQUFFLE1BQU0sYUFBYSxDQUFDO0FBR2hEOzs7O0dBSUc7QUFDSCxNQUFNLFVBQVUsYUFBYSxDQUFDLEdBQWE7SUFDekMsT0FBTyxpQkFBaUIsQ0FBQyxHQUFHLEVBQUUsY0FBYyxDQUFDLE1BQU0sRUFBRSxFQUFFLGNBQWMsQ0FBQyxNQUFNLEVBQUUsQ0FBQyxDQUFDLFVBQVUsRUFBRSxDQUFDO0FBQy9GLENBQUM7QUFFRDs7OztHQUlHO0FBQ0gsTUFBTSxDQUFDLEtBQUssVUFBVSxlQUFlLENBQUMsR0FBYTtJQUNqRCxNQUFNLGVBQWUsR0FBRyxNQUFNLGVBQWUsQ0FBQyxNQUFNLEVBQUUsQ0FBQztJQUN2RCxNQUFNLEdBQUcsQ0FBQyxpQkFBaUIsQ0FBQyxlQUFlLENBQUMsQ0FBQztJQUM3QyxPQUFPLGVBQWUsQ0FBQztBQUN6QixDQUFDO0FBRUQ7Ozs7O0dBS0c7QUFDSCxNQUFNLENBQUMsS0FBSyxVQUFVLGNBQWMsQ0FBQyxHQUFhLEVBQUUsZ0JBQWdCLEdBQUcsQ0FBQztJQUN0RSxNQUFNLFFBQVEsR0FBRyxFQUFFLENBQUM7SUFFcEIsc0JBQXNCO0lBQ3RCLEtBQUssSUFBSSxDQUFDLEdBQUcsQ0FBQyxFQUFFLENBQUMsR0FBRyxnQkFBZ0IsRUFBRSxFQUFFLENBQUMsRUFBRTtRQUN6QyxNQUFNLE9BQU8sR0FBRyxpQkFBaUIsQ0FBQyxHQUFHLEVBQUUsY0FBYyxDQUFDLE1BQU0sRUFBRSxFQUFFLGNBQWMsQ0FBQyxNQUFNLEVBQUUsQ0FBQyxDQUFDO1FBQ3pGLE1BQU0sT0FBTyxDQUFDLGVBQWUsRUFBRSxDQUFDLElBQUksQ0FBQyxDQUFDLENBQUMsRUFBRSxDQUFDLENBQUMsQ0FBQyxRQUFRLENBQUMsRUFBRSxtQkFBbUIsRUFBRSxPQUFPLENBQUMsSUFBSSxFQUFFLENBQUMsQ0FBQyxDQUFDO1FBQzdGLFFBQVEsQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDLENBQUM7S0FDeEI7SUFFRCx1Q0FBdUM7SUFDdkMsTUFBTSxHQUFHLEdBQUcsTUFBTSxPQUFPLENBQUMsR0FBRyxDQUFDLFFBQVEsQ0FBQyxHQUFHLENBQUMsT0FBTyxDQUFDLEVBQUUsQ0FBQyxPQUFPLENBQUMsTUFBTSxFQUFFLENBQUMsQ0FBQyxDQUFDO0lBQ3pFLE1BQU0sT0FBTyxDQUFDLEdBQUcsQ0FBQyxHQUFHLENBQUMsR0FBRyxDQUFDLEVBQUUsQ0FBQyxFQUFFLENBQUMsRUFBRSxDQUFDLElBQUksQ0FBQyxFQUFFLFFBQVEsRUFBRSxHQUFHLEVBQUUsQ0FBQyxDQUFDLENBQUMsQ0FBQztJQUM3RCxPQUFPLE9BQU8sQ0FBQyxHQUFHLENBQUMsUUFBUSxDQUFDLEdBQUcsQ0FBQyxPQUFPLENBQUMsRUFBRSxDQUFDLE9BQU8sQ0FBQyxTQUFTLEVBQUUsQ0FBQyxDQUFDLENBQUM7QUFDbkUsQ0FBQyJ9
@@ -1,5 +0,0 @@
1
- {
2
- "scripts": {
3
- "build": "yarn clean && tsc -b && webpack"
4
- }
5
- }
@@ -1,178 +0,0 @@
1
- import { abiChecker } from './checker.js';
2
-
3
- describe('abiChecker', () => {
4
- let abi: any;
5
-
6
- it('should throw an error if it has no functions', () => {
7
- abi = {
8
- name: 'TEST_ABI',
9
- };
10
- expect(() => abiChecker(abi)).toThrowError('ABI has no functions');
11
- abi = {
12
- name: 'TEST_ABI',
13
- functions: [],
14
- };
15
- expect(() => abiChecker(abi)).toThrowError('ABI has no functions');
16
- });
17
-
18
- it('should error if ABI has no names', () => {
19
- abi = {
20
- name: 'TEST_ABI',
21
- functions: [{ bytecode: '0af', parameters: [{ type: { kind: 'test' } }] }],
22
- };
23
- expect(() => abiChecker(abi)).toThrowError('ABI function has no name');
24
- });
25
-
26
- it('should error if ABI function has unrecognised type', () => {
27
- abi = {
28
- name: 'TEST_ABI',
29
- functions: [
30
- {
31
- name: 'Function name',
32
- bytecode: '0af',
33
- parameters: [{ type: { kind: 'test' } }],
34
- },
35
- ],
36
- };
37
- expect(() => abiChecker(abi)).toThrowError('ABI function parameter has an unrecognised type');
38
- });
39
-
40
- it('should error if integer is incorrectly formed', () => {
41
- abi = {
42
- name: 'TEST_ABI',
43
- functions: [
44
- {
45
- name: 'constructor',
46
- bytecode: '0af',
47
- parameters: [{ type: { kind: 'integer', sign: 5 } }],
48
- },
49
- ],
50
- };
51
- expect(() => abiChecker(abi)).toThrowError('Unrecognised attribute on type integer');
52
- });
53
-
54
- it('should error if string is incorrectly formed', () => {
55
- abi = {
56
- name: 'TEST_ABI',
57
- functions: [
58
- {
59
- name: 'constructor',
60
- bytecode: '0af',
61
- parameters: [{ type: { kind: 'string', sign: 5, additionalParam: true } }],
62
- },
63
- ],
64
- };
65
- expect(() => abiChecker(abi)).toThrowError('Unrecognised attribute on type string');
66
- });
67
-
68
- it('should error if struct is incorrectly formed', () => {
69
- abi = {
70
- name: 'TEST_ABI',
71
- functions: [
72
- {
73
- name: 'constructor',
74
- bytecode: '0af',
75
- parameters: [
76
- {
77
- type: {
78
- kind: 'struct',
79
- },
80
- },
81
- ],
82
- },
83
- ],
84
- };
85
- expect(() => abiChecker(abi)).toThrowError('Unrecognised attribute on type struct');
86
- });
87
-
88
- it('should error if array is incorrectly formed', () => {
89
- abi = {
90
- name: 'TEST_ABI',
91
- functions: [
92
- {
93
- name: 'constructor',
94
- bytecode: '0af',
95
- parameters: [
96
- {
97
- type: {
98
- kind: 'array',
99
- length: 5,
100
- type: {
101
- kind: 'array',
102
- length: '5',
103
- type: {
104
- sign: 'value',
105
- width: 5,
106
- kind: 'integer',
107
- },
108
- },
109
- },
110
- },
111
- ],
112
- },
113
- ],
114
- };
115
- expect(() => abiChecker(abi)).toThrowError('ABI function parameter has an incorrectly formed array');
116
- });
117
-
118
- it('valid matrix should pass checker', () => {
119
- abi = {
120
- name: 'TEST_ABI',
121
- functions: [
122
- {
123
- name: 'constructor',
124
- bytecode: '0af',
125
- parameters: [
126
- {
127
- type: {
128
- kind: 'array',
129
- length: 5,
130
- type: {
131
- kind: 'array',
132
- length: 5,
133
- type: {
134
- sign: 'value',
135
- width: 5,
136
- kind: 'integer',
137
- },
138
- },
139
- },
140
- },
141
- ],
142
- },
143
- ],
144
- };
145
- expect(abiChecker(abi)).toBe(true);
146
- });
147
-
148
- it('valid struct should pass checker', () => {
149
- abi = {
150
- name: 'TEST_ABI',
151
- functions: [
152
- {
153
- name: 'constructor',
154
- bytecode: '0af',
155
- parameters: [
156
- {
157
- type: {
158
- kind: 'struct',
159
- path: 'mystruct',
160
- fields: [
161
- {
162
- name: 'name',
163
- type: {
164
- sign: 'value',
165
- width: 5,
166
- kind: 'integer',
167
- },
168
- },
169
- ],
170
- },
171
- },
172
- ],
173
- },
174
- ],
175
- };
176
- expect(abiChecker(abi)).toBe(true);
177
- });
178
- });
@@ -1,172 +0,0 @@
1
- import { AztecAddress, CompleteAddress, EthAddress } from '@aztec/circuits.js';
2
- import { ABIParameterVisibility, ContractAbi, FunctionType } from '@aztec/foundation/abi';
3
- import {
4
- DeployedContract,
5
- ExtendedContractData,
6
- NodeInfo,
7
- Tx,
8
- TxExecutionRequest,
9
- TxHash,
10
- TxReceipt,
11
- randomContractAbi,
12
- randomDeployedContract,
13
- } from '@aztec/types';
14
-
15
- import { MockProxy, mock } from 'jest-mock-extended';
16
-
17
- import { Wallet } from '../wallet/index.js';
18
- import { Contract } from './contract.js';
19
-
20
- describe('Contract Class', () => {
21
- let wallet: MockProxy<Wallet>;
22
- let resolvedExtendedContractData: ExtendedContractData;
23
- let contractAddress: AztecAddress;
24
- let account: CompleteAddress;
25
-
26
- const mockTx = { type: 'Tx' } as any as Tx;
27
- const mockTxRequest = { type: 'TxRequest' } as any as TxExecutionRequest;
28
- const mockTxHash = { type: 'TxHash' } as any as TxHash;
29
- const mockTxReceipt = { type: 'TxReceipt' } as any as TxReceipt;
30
- const mockViewResultValue = 1;
31
- const mockNodeInfo: NodeInfo = {
32
- sandboxVersion: 'vx.x.x',
33
- compatibleNargoVersion: 'vx.x.x-aztec.x',
34
- protocolVersion: 1,
35
- chainId: 2,
36
- rollupAddress: EthAddress.random(),
37
- };
38
-
39
- const defaultAbi: ContractAbi = {
40
- name: 'FooContract',
41
- functions: [
42
- {
43
- name: 'bar',
44
- functionType: FunctionType.SECRET,
45
- isInternal: false,
46
- parameters: [
47
- {
48
- name: 'value',
49
- type: {
50
- kind: 'field',
51
- },
52
- visibility: ABIParameterVisibility.PUBLIC,
53
- },
54
- {
55
- name: 'value',
56
- type: {
57
- kind: 'field',
58
- },
59
- visibility: ABIParameterVisibility.SECRET,
60
- },
61
- ],
62
- returnTypes: [],
63
- bytecode: '0af',
64
- },
65
- {
66
- name: 'baz',
67
- functionType: FunctionType.OPEN,
68
- isInternal: false,
69
- parameters: [],
70
- returnTypes: [],
71
- bytecode: '0be',
72
- },
73
- {
74
- name: 'qux',
75
- functionType: FunctionType.UNCONSTRAINED,
76
- isInternal: false,
77
- parameters: [
78
- {
79
- name: 'value',
80
- type: {
81
- kind: 'field',
82
- },
83
- visibility: ABIParameterVisibility.PUBLIC,
84
- },
85
- ],
86
- returnTypes: [
87
- {
88
- kind: 'integer',
89
- sign: '',
90
- width: 32,
91
- },
92
- ],
93
- bytecode: '0cd',
94
- },
95
- ],
96
- };
97
-
98
- beforeEach(async () => {
99
- resolvedExtendedContractData = ExtendedContractData.random();
100
- contractAddress = resolvedExtendedContractData.contractData.contractAddress;
101
- account = await CompleteAddress.random();
102
-
103
- wallet = mock<Wallet>();
104
- wallet.createTxExecutionRequest.mockResolvedValue(mockTxRequest);
105
- wallet.getExtendedContractData.mockResolvedValue(resolvedExtendedContractData);
106
- wallet.sendTx.mockResolvedValue(mockTxHash);
107
- wallet.viewTx.mockResolvedValue(mockViewResultValue);
108
- wallet.getTxReceipt.mockResolvedValue(mockTxReceipt);
109
- wallet.getNodeInfo.mockResolvedValue(mockNodeInfo);
110
- wallet.simulateTx.mockResolvedValue(mockTx);
111
- wallet.getRegisteredAccounts.mockResolvedValue([account]);
112
- });
113
-
114
- it('should create and send a contract method tx', async () => {
115
- const fooContract = await Contract.at(contractAddress, defaultAbi, wallet);
116
- const param0 = 12;
117
- const param1 = 345n;
118
- const sentTx = fooContract.methods.bar(param0, param1).send();
119
- const txHash = await sentTx.getTxHash();
120
- const receipt = await sentTx.getReceipt();
121
-
122
- expect(txHash).toBe(mockTxHash);
123
- expect(receipt).toBe(mockTxReceipt);
124
- expect(wallet.createTxExecutionRequest).toHaveBeenCalledTimes(1);
125
- expect(wallet.sendTx).toHaveBeenCalledTimes(1);
126
- expect(wallet.sendTx).toHaveBeenCalledWith(mockTx);
127
- });
128
-
129
- it('should call view on an unconstrained function', async () => {
130
- const fooContract = await Contract.at(contractAddress, defaultAbi, wallet);
131
- const result = await fooContract.methods.qux(123n).view({
132
- from: account.address,
133
- });
134
- expect(wallet.viewTx).toHaveBeenCalledTimes(1);
135
- expect(wallet.viewTx).toHaveBeenCalledWith('qux', [123n], contractAddress, account.address);
136
- expect(result).toBe(mockViewResultValue);
137
- });
138
-
139
- it('should not call create on an unconstrained function', async () => {
140
- const fooContract = await Contract.at(contractAddress, defaultAbi, wallet);
141
- await expect(fooContract.methods.qux().create()).rejects.toThrow();
142
- });
143
-
144
- it('should not call view on a secret or open function', async () => {
145
- const fooContract = await Contract.at(contractAddress, defaultAbi, wallet);
146
- expect(() => fooContract.methods.bar().view()).toThrow();
147
- expect(() => fooContract.methods.baz().view()).toThrow();
148
- });
149
-
150
- it('should add contract and dependencies to aztec rpc', async () => {
151
- const entry: DeployedContract = {
152
- abi: randomContractAbi(),
153
- completeAddress: resolvedExtendedContractData.getCompleteAddress(),
154
- portalContract: EthAddress.random(),
155
- };
156
- const contract = await Contract.at(entry.completeAddress.address, entry.abi, wallet);
157
-
158
- {
159
- await contract.attach(entry.portalContract);
160
- expect(wallet.addContracts).toHaveBeenCalledTimes(1);
161
- expect(wallet.addContracts).toHaveBeenCalledWith([entry]);
162
- wallet.addContracts.mockClear();
163
- }
164
-
165
- {
166
- const dependencies = [await randomDeployedContract(), await randomDeployedContract()];
167
- await contract.attach(entry.portalContract, dependencies);
168
- expect(wallet.addContracts).toHaveBeenCalledTimes(1);
169
- expect(wallet.addContracts).toHaveBeenCalledWith([entry, ...dependencies]);
170
- }
171
- });
172
- });
@@ -1,52 +0,0 @@
1
- import { AztecRPC, TxHash, TxReceipt, TxStatus } from '@aztec/types';
2
-
3
- import { MockProxy, mock } from 'jest-mock-extended';
4
-
5
- import { SentTx } from './sent_tx.js';
6
-
7
- describe('SentTx', () => {
8
- let rpc: MockProxy<AztecRPC>;
9
- let txHashPromise: Promise<TxHash>;
10
-
11
- let sentTx: SentTx;
12
-
13
- beforeEach(() => {
14
- rpc = mock();
15
- txHashPromise = Promise.resolve(TxHash.fromBigInt(1n));
16
- sentTx = new SentTx(rpc, txHashPromise);
17
- });
18
-
19
- describe('wait', () => {
20
- let txReceipt: TxReceipt;
21
- beforeEach(() => {
22
- txReceipt = { status: TxStatus.MINED, blockNumber: 20 } as TxReceipt;
23
- rpc.getTxReceipt.mockResolvedValue(txReceipt);
24
- });
25
-
26
- it('waits for all notes accounts to be synced', async () => {
27
- rpc.getSyncStatus
28
- .mockResolvedValueOnce({ blocks: 25, notes: { '0x1': 19, '0x2': 20 } })
29
- .mockResolvedValueOnce({ blocks: 25, notes: { '0x1': 20, '0x2': 20 } });
30
-
31
- const actual = await sentTx.wait({ timeout: 1, interval: 0.4 });
32
- expect(actual).toEqual(txReceipt);
33
- });
34
-
35
- it('fails if an account is not synced', async () => {
36
- rpc.getSyncStatus.mockResolvedValue({ blocks: 25, notes: { '0x1': 19, '0x2': 20 } });
37
- await expect(sentTx.wait({ timeout: 1, interval: 0.4 })).rejects.toThrowError(/timeout/i);
38
- });
39
-
40
- it('does not wait for notes sync', async () => {
41
- rpc.getSyncStatus.mockResolvedValue({ blocks: 19, notes: { '0x1': 19, '0x2': 19 } });
42
- const actual = await sentTx.wait({ timeout: 1, interval: 0.4, waitForNotesSync: false });
43
- expect(actual).toEqual(txReceipt);
44
- });
45
-
46
- it('throws if tx is dropped', async () => {
47
- rpc.getTxReceipt.mockResolvedValue({ ...txReceipt, status: TxStatus.DROPPED } as TxReceipt);
48
- rpc.getSyncStatus.mockResolvedValue({ blocks: 19, notes: { '0x1': 19, '0x2': 19 } });
49
- await expect(sentTx.wait({ timeout: 1, interval: 0.4 })).rejects.toThrowError(/dropped/);
50
- });
51
- });
52
- });
@@ -1,55 +0,0 @@
1
- import { EthAddress, Fr, Point } from '@aztec/circuits.js';
2
- import { ContractAbi, FunctionType } from '@aztec/foundation/abi';
3
- import { AztecRPC, PublicKey, Tx, TxHash, TxReceipt } from '@aztec/types';
4
-
5
- import { MockProxy, mock } from 'jest-mock-extended';
6
-
7
- import { ContractDeployer } from './contract_deployer.js';
8
-
9
- describe.skip('Contract Deployer', () => {
10
- let arc: MockProxy<AztecRPC>;
11
-
12
- const abi: ContractAbi = {
13
- name: 'MyContract',
14
- functions: [
15
- {
16
- name: 'constructor',
17
- functionType: FunctionType.SECRET,
18
- isInternal: false,
19
- parameters: [],
20
- returnTypes: [],
21
- bytecode: '0af',
22
- },
23
- ],
24
- };
25
-
26
- const publicKey: PublicKey = Point.random();
27
- const portalContract = EthAddress.random();
28
- const contractAddressSalt = Fr.random();
29
- const args = [12, 345n];
30
-
31
- const mockTx = { type: 'Tx' } as any as Tx;
32
- const mockTxHash = { type: 'TxHash' } as any as TxHash;
33
- const mockTxReceipt = { type: 'TxReceipt' } as any as TxReceipt;
34
-
35
- beforeEach(() => {
36
- arc = mock<AztecRPC>();
37
- arc.sendTx.mockResolvedValue(mockTxHash);
38
- arc.getTxReceipt.mockResolvedValue(mockTxReceipt);
39
- });
40
-
41
- it('should create and send a contract deployment tx', async () => {
42
- const deployer = new ContractDeployer(abi, arc, publicKey);
43
- const sentTx = deployer.deploy(args[0], args[1]).send({
44
- portalContract,
45
- contractAddressSalt,
46
- });
47
- const txHash = await sentTx.getTxHash();
48
- const receipt = await sentTx.getReceipt();
49
-
50
- expect(txHash).toBe(mockTxHash);
51
- expect(receipt).toBe(mockTxReceipt);
52
- expect(arc.sendTx).toHaveBeenCalledTimes(1);
53
- expect(arc.sendTx).toHaveBeenCalledWith(mockTx);
54
- });
55
- });
@@ -1,15 +0,0 @@
1
- {
2
- "extends": ".",
3
- "references": [
4
- {
5
- "path": "../circuits.js/tsconfig.dest.json"
6
- },
7
- {
8
- "path": "../foundation/tsconfig.dest.json"
9
- },
10
- {
11
- "path": "../types/tsconfig.dest.json"
12
- }
13
- ],
14
- "exclude": ["src/**/*.test.ts"]
15
- }
package/tsconfig.json DELETED
@@ -1,20 +0,0 @@
1
- {
2
- "extends": "..",
3
- "compilerOptions": {
4
- "outDir": "dest",
5
- "rootDir": "src",
6
- "tsBuildInfoFile": ".tsbuildinfo"
7
- },
8
- "references": [
9
- {
10
- "path": "../circuits.js"
11
- },
12
- {
13
- "path": "../foundation"
14
- },
15
- {
16
- "path": "../types"
17
- }
18
- ],
19
- "include": ["src", "src/**/*.json"]
20
- }
package/webpack.config.js DELETED
@@ -1,74 +0,0 @@
1
- // import CopyWebpackPlugin from 'copy-webpack-plugin';
2
- import { createRequire } from 'module';
3
- import { dirname, resolve } from 'path';
4
- import path from 'path';
5
- import ResolveTypeScriptPlugin from 'resolve-typescript-plugin';
6
- import { fileURLToPath } from 'url';
7
- import webpack from 'webpack';
8
-
9
- const require = createRequire(import.meta.url);
10
-
11
- export default {
12
- target: 'web',
13
- mode: 'production',
14
- devtool: false,
15
- entry: {
16
- main: './src/index.ts',
17
- },
18
- module: {
19
- rules: [
20
- {
21
- test: /\.tsx?$/,
22
- use: [
23
- {
24
- loader: 'ts-loader',
25
- options: {
26
- configFile: 'tsconfig.dest.json',
27
- },
28
- },
29
- ],
30
- },
31
- ],
32
- },
33
- output: {
34
- path: resolve(dirname(fileURLToPath(import.meta.url)), './dest'),
35
- filename: 'main.js',
36
- library: {
37
- type: 'module',
38
- },
39
- chunkFormat: 'module',
40
- },
41
- experiments: {
42
- outputModule: true,
43
- },
44
- plugins: [
45
- new webpack.DefinePlugin({
46
- 'process.env': {
47
- NODE_ENV: JSON.stringify('production'),
48
- },
49
- }),
50
- new webpack.ProvidePlugin({ Buffer: ['buffer', 'Buffer'] }),
51
- ],
52
- resolve: {
53
- plugins: [new ResolveTypeScriptPlugin()],
54
- alias: {
55
- // All node specific code, wherever it's located, should be imported as below.
56
- // Provides a clean and simple way to always strip out the node code for the web build.
57
- './node/index.js': false,
58
- },
59
- fallback: {
60
- crypto: false,
61
- os: false,
62
- fs: false,
63
- path: false,
64
- url: false,
65
- worker_threads: false,
66
- events: require.resolve('events/'),
67
- buffer: require.resolve('buffer/'),
68
- util: require.resolve('util/'),
69
- stream: require.resolve('stream-browserify'),
70
- string_decoder: require.resolve('string_decoder/'),
71
- tty: require.resolve('tty-browserify'),
72
- },
73
- },
74
- };