starknet 4.15.0 → 4.16.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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,24 @@
1
+ # [4.16.0](https://github.com/0xs34n/starknet.js/compare/v4.15.1...v4.16.0) (2022-12-12)
2
+
3
+ ### Bug Fixes
4
+
5
+ - blockIdentifier null on call from constructed function ([c88fbf0](https://github.com/0xs34n/starknet.js/commit/c88fbf0cdfc57e1150275a34c15900d6c81802d3))
6
+ - default pathfinder does't have pending block ([4619188](https://github.com/0xs34n/starknet.js/commit/4619188e21e5cc9a811c59bcf2923c4382661635))
7
+ - sequencer defaults, remove defaultProvider default blockIdentifier, spelling, class ([555a9a3](https://github.com/0xs34n/starknet.js/commit/555a9a3982bc1a742776119df5dee5d701209a0d))
8
+
9
+ ### Features
10
+
11
+ - multi deploy reimplemented ([10e609a](https://github.com/0xs34n/starknet.js/commit/10e609a1af584df65942477b264ad7809b5c70c9))
12
+ - return precalculated address from deploy ([5e40224](https://github.com/0xs34n/starknet.js/commit/5e402246841bdf9117a9ee96799833fc6f68d16b))
13
+
14
+ ## [4.15.1](https://github.com/0xs34n/starknet.js/compare/v4.15.0...v4.15.1) (2022-12-07)
15
+
16
+ ### Bug Fixes
17
+
18
+ - add testnet 2 compatibility to test ([b83f35b](https://github.com/0xs34n/starknet.js/commit/b83f35bbfc0c2a6c84318a473ca816cc053f5806))
19
+ - delete only on test ([e13db57](https://github.com/0xs34n/starknet.js/commit/e13db577b7d40073707d78e57f63e65b6472c446))
20
+ - lib chainid test ([e820572](https://github.com/0xs34n/starknet.js/commit/e820572a9eafe732dae3d1bbde5f63279c000be7))
21
+
1
22
  # [4.15.0](https://github.com/0xs34n/starknet.js/compare/v4.14.0...v4.15.0) (2022-12-05)
2
23
 
3
24
  ### Bug Fixes
@@ -1,9 +1,11 @@
1
1
  import { isBN } from 'bn.js';
2
2
 
3
3
  import typedDataExample from '../__mocks__/typedDataExample.json';
4
- import { Account, Contract, DeployContractPayload, Provider, number, stark } from '../src';
5
- import { feeTransactionVersion } from '../src/utils/hash';
6
- import { hexToDecimalString, toBN } from '../src/utils/number';
4
+ import { Account, Contract, Provider, number, stark } from '../src';
5
+ import { getKeyPair, sign } from '../src/utils/ellipticCurve';
6
+ import { parseUDCEvent } from '../src/utils/events';
7
+ import { feeTransactionVersion, pedersen } from '../src/utils/hash';
8
+ import { cleanHex, hexToDecimalString, toBN } from '../src/utils/number';
7
9
  import { encodeShortString } from '../src/utils/shortString';
8
10
  import { randomAddress } from '../src/utils/stark';
9
11
  import {
@@ -169,14 +171,30 @@ describe('deploy and test Wallet', () => {
169
171
 
170
172
  test('Get the stark name of the account and account from stark name (using starknet.id)', async () => {
171
173
  // Deploy naming contract
172
- const namingPlayLoad: DeployContractPayload = { contract: compiledNamingContract };
173
- const namingResponse = await provider.deployContract(namingPlayLoad);
174
- const namingAddress = namingResponse.contract_address;
174
+ const namingResponse = await account.declareDeploy({
175
+ contract: compiledNamingContract,
176
+ classHash: '0x3f2f8c80ab2d404bcfb4182e8528708e4efa2c646dd711bdd7b721ecc6111f7',
177
+ });
178
+ const namingAddress = namingResponse.deploy.contract_address;
175
179
 
176
180
  // Deploy Starknet id contract
177
- const idPlayLoad: DeployContractPayload = { contract: compiledStarknetId };
178
- const idResponse = await provider.deployContract(idPlayLoad);
179
- const idAddress = idResponse.contract_address;
181
+ const idResponse = await account.declareDeploy({
182
+ contract: compiledStarknetId,
183
+ classHash: '0x1eb5a8308760d82321cb3ee8967581bb1d38348c7d2f082a07580040c52217c',
184
+ });
185
+ const idAddress = idResponse.deploy.contract_address;
186
+
187
+ // Create signature from private key
188
+ const whitelistingPublicKey =
189
+ '1893860513534673656759973582609638731665558071107553163765293299136715951024';
190
+ const whitelistingPrivateKey =
191
+ '301579081698031303837612923223391524790804435085778862878979120159194507372';
192
+ const hashed = pedersen([
193
+ pedersen([toBN('18925'), toBN('1922775124')]),
194
+ toBN(hexToDecimalString(account.address)),
195
+ ]);
196
+ const keyPair = getKeyPair(toBN(whitelistingPrivateKey));
197
+ const signed = sign(keyPair, hashed);
180
198
 
181
199
  const { transaction_hash } = await account.execute([
182
200
  {
@@ -186,7 +204,7 @@ describe('deploy and test Wallet', () => {
186
204
  idAddress, // starknetid_contract_addr
187
205
  '0', // pricing_contract_addr
188
206
  account.address, // admin
189
- '1576987121283045618657875225183003300580199140020787494777499595331436496159', // whitelisting_key
207
+ whitelistingPublicKey, // whitelisting_key
190
208
  '0', // l1_contract
191
209
  ],
192
210
  },
@@ -200,11 +218,11 @@ describe('deploy and test Wallet', () => {
200
218
  entrypoint: 'whitelisted_mint',
201
219
  calldata: [
202
220
  '18925', // Domain encoded "ben"
203
- '1697380617', // Expiry
221
+ '1922775124', // Expiry
204
222
  '1', // Starknet id linked
205
223
  account.address, // receiver_address
206
- '1249449923402095645023546949816521361907869702415870903008894560968474148064', // sig 0 for whitelist
207
- '543901326374961504443808953662149863005450004831659662383974986108355067943', // sig 1 for whitelist
224
+ signed[0], // sig 0 for whitelist
225
+ signed[1], // sig 1 for whitelist
208
226
  ],
209
227
  },
210
228
  {
@@ -261,7 +279,7 @@ describe('deploy and test Wallet', () => {
261
279
  expect(deployResponse.salt).toBeDefined();
262
280
  });
263
281
 
264
- test('UDC Deploy', async () => {
282
+ test('UDC Deploy unique', async () => {
265
283
  const salt = randomAddress(); // use random salt
266
284
 
267
285
  const deployment = await account.deploy({
@@ -272,12 +290,54 @@ describe('deploy and test Wallet', () => {
272
290
  account.address,
273
291
  ],
274
292
  salt,
275
- unique: true, // Using true here so as not to clash with normal erc20 deploy in account and provider test
293
+ unique: true,
276
294
  });
295
+ expect(deployment).toHaveProperty('transaction_hash');
277
296
 
278
- await provider.waitForTransaction(deployment.transaction_hash);
297
+ // check pre-calculated address
298
+ const txReceipt = await provider.waitForTransaction(deployment.transaction_hash);
299
+ const udcEvent = parseUDCEvent(txReceipt);
300
+ expect(cleanHex(deployment.contract_address[0])).toBe(cleanHex(udcEvent.contract_address));
301
+ });
302
+
303
+ test('UDC Deploy non-unique', async () => {
304
+ const salt = randomAddress(); // use random salt
279
305
 
306
+ const deployment = await account.deploy({
307
+ classHash: erc20ClassHash,
308
+ constructorCalldata: [
309
+ encodeShortString('Token'),
310
+ encodeShortString('ERC20'),
311
+ account.address,
312
+ ],
313
+ salt,
314
+ unique: false,
315
+ });
280
316
  expect(deployment).toHaveProperty('transaction_hash');
317
+
318
+ // check pre-calculated address
319
+ const txReceipt = await provider.waitForTransaction(deployment.transaction_hash);
320
+ const udcEvent = parseUDCEvent(txReceipt);
321
+ expect(cleanHex(deployment.contract_address[0])).toBe(cleanHex(udcEvent.contract_address));
322
+ });
323
+
324
+ test('UDC multi Deploy', async () => {
325
+ const deployments = await account.deploy([
326
+ {
327
+ classHash: '0x04367b26fbb92235e8d1137d19c080e6e650a6889ded726d00658411cc1046f5',
328
+ },
329
+ {
330
+ classHash: erc20ClassHash,
331
+ constructorCalldata: [
332
+ encodeShortString('Token'),
333
+ encodeShortString('ERC20'),
334
+ account.address,
335
+ ],
336
+ },
337
+ ]);
338
+ expect(deployments).toHaveProperty('transaction_hash');
339
+ expect(deployments.contract_address[0]).toBeDefined();
340
+ expect(deployments.contract_address[1]).toBeDefined();
281
341
  });
282
342
  });
283
343
  });
@@ -13,227 +13,225 @@ import {
13
13
  getTestProvider,
14
14
  } from './fixtures';
15
15
 
16
- const provider = getTestProvider();
17
-
18
- describe('class Contract {}', () => {
16
+ describe('contract module', () => {
17
+ let erc20Address: string;
18
+ const provider = getTestProvider();
19
19
  const wallet = stark.randomAddress();
20
20
  const account = getTestAccount(provider);
21
+ const constructorCalldata = [encodeShortString('Token'), encodeShortString('ERC20'), wallet];
22
+ const classHash = '0x54328a1075b8820eb43caf0caa233923148c983742402dcfc38541dd843d01a';
21
23
 
22
- describe('Basic Interaction', () => {
23
- let erc20Contract: Contract;
24
- let multicallContract: Contract;
24
+ describe('class Contract {}', () => {
25
+ describe('Basic Interaction', () => {
26
+ let erc20Contract: Contract;
27
+ let multicallContract: Contract;
25
28
 
26
- beforeAll(async () => {
27
- const { deploy } = await account.declareDeploy({
28
- contract: compiledErc20,
29
- classHash: '0x54328a1075b8820eb43caf0caa233923148c983742402dcfc38541dd843d01a',
30
- constructorCalldata: [encodeShortString('Token'), encodeShortString('ERC20'), wallet],
31
- });
29
+ beforeAll(async () => {
30
+ const { deploy } = await account.declareDeploy({
31
+ contract: compiledErc20,
32
+ classHash: '0x54328a1075b8820eb43caf0caa233923148c983742402dcfc38541dd843d01a',
33
+ constructorCalldata: [encodeShortString('Token'), encodeShortString('ERC20'), wallet],
34
+ });
32
35
 
33
- erc20Contract = new Contract(compiledErc20.abi, deploy.contract_address!, provider);
36
+ erc20Contract = new Contract(compiledErc20.abi, deploy.contract_address!, provider);
34
37
 
35
- const { deploy: multicallDeploy } = await account.declareDeploy({
36
- contract: compiledMulticall,
37
- classHash: '0x06f94f3229a8d9c1d51cb84f1f5ec306c8552a805e307540727dda53c4936b43',
38
+ const { deploy: multicallDeploy } = await account.declareDeploy({
39
+ contract: compiledMulticall,
40
+ classHash: '0x06f94f3229a8d9c1d51cb84f1f5ec306c8552a805e307540727dda53c4936b43',
41
+ });
42
+
43
+ multicallContract = new Contract(
44
+ compiledMulticall.abi,
45
+ multicallDeploy.contract_address!,
46
+ provider
47
+ );
38
48
  });
39
49
 
40
- multicallContract = new Contract(
41
- compiledMulticall.abi,
42
- multicallDeploy.contract_address!,
43
- provider
44
- );
45
- });
50
+ test('populate transaction for initial balance of that account', async () => {
51
+ const res = await erc20Contract.populateTransaction.balanceOf(wallet);
52
+ expect(res).toHaveProperty('contractAddress');
53
+ expect(res).toHaveProperty('entrypoint');
54
+ expect(res).toHaveProperty('calldata');
55
+ });
46
56
 
47
- test('populate transaction for initial balance of that account', async () => {
48
- const res = await erc20Contract.populateTransaction.balanceOf(wallet);
49
- expect(res).toHaveProperty('contractAddress');
50
- expect(res).toHaveProperty('entrypoint');
51
- expect(res).toHaveProperty('calldata');
52
- });
57
+ test('estimate gas fee for `mint` should fail when connected to the provider', async () => {
58
+ expect(erc20Contract.estimateFee.mint(wallet, ['10', '0'])).rejects.toThrow();
59
+ });
53
60
 
54
- test('estimate gas fee for `mint` should fail when connected to the provider', async () => {
55
- expect(erc20Contract.estimateFee.mint(wallet, ['10', '0'])).rejects.toThrow();
61
+ test('read initial balance of that account', async () => {
62
+ const result = await erc20Contract.balanceOf(wallet);
63
+ const [res] = result;
64
+ expect(res.low).toStrictEqual(toBN(1000));
65
+ expect(res).toStrictEqual(result.balance);
66
+ });
67
+
68
+ test('read balance in a multicall', async () => {
69
+ const args1 = { user: wallet };
70
+ const args2 = {};
71
+ const calls = [
72
+ erc20Contract.address,
73
+ getSelectorFromName('balanceOf'),
74
+ Object.keys(args1).length,
75
+ ...compileCalldata(args1),
76
+
77
+ erc20Contract.address,
78
+ getSelectorFromName('decimals'),
79
+ Object.keys(args2).length,
80
+ ...compileCalldata(args2),
81
+ ];
82
+ const result = await multicallContract.aggregate(calls);
83
+ const [block_number, res] = result;
84
+ expect(isBN(block_number));
85
+ expect(Array.isArray(res));
86
+ (res as BigNumberish[]).forEach((el) => expect(isBN(el)));
87
+ expect(block_number).toStrictEqual(result.block_number);
88
+ expect(res).toStrictEqual(result.result);
89
+ });
56
90
  });
57
91
 
58
- test('read initial balance of that account', async () => {
59
- const result = await erc20Contract.balanceOf(wallet);
60
- const [res] = result;
61
- expect(res.low).toStrictEqual(toBN(1000));
62
- expect(res).toStrictEqual(result.balance);
63
- });
92
+ describe('Type Transformation', () => {
93
+ let typeTransformedContract: Contract;
64
94
 
65
- test('read balance in a multicall', async () => {
66
- const args1 = { user: wallet };
67
- const args2 = {};
68
- const calls = [
69
- erc20Contract.address,
70
- getSelectorFromName('balanceOf'),
71
- Object.keys(args1).length,
72
- ...compileCalldata(args1),
73
-
74
- erc20Contract.address,
75
- getSelectorFromName('decimals'),
76
- Object.keys(args2).length,
77
- ...compileCalldata(args2),
78
- ];
79
- const result = await multicallContract.aggregate(calls);
80
- const [block_number, res] = result;
81
- expect(isBN(block_number));
82
- expect(Array.isArray(res));
83
- (res as BigNumberish[]).forEach((el) => expect(isBN(el)));
84
- expect(block_number).toStrictEqual(result.block_number);
85
- expect(res).toStrictEqual(result.result);
86
- });
87
- });
88
-
89
- describe('Type Transformation', () => {
90
- let typeTransformedContract: Contract;
95
+ beforeAll(async () => {
96
+ const { deploy } = await account.declareDeploy({
97
+ contract: compiledTypeTransformation,
98
+ classHash: '0x022a0e662b13d18a2aaa3ee54ae290de6569621b549022c18169c6e7893809ea',
99
+ });
91
100
 
92
- beforeAll(async () => {
93
- const { deploy } = await account.declareDeploy({
94
- contract: compiledTypeTransformation,
95
- classHash: '0x022a0e662b13d18a2aaa3ee54ae290de6569621b549022c18169c6e7893809ea',
101
+ typeTransformedContract = new Contract(
102
+ compiledTypeTransformation.abi,
103
+ deploy.contract_address!,
104
+ provider
105
+ );
96
106
  });
97
107
 
98
- typeTransformedContract = new Contract(
99
- compiledTypeTransformation.abi,
100
- deploy.contract_address!,
101
- provider
102
- );
103
- });
104
-
105
- describe('Request Type Transformation', () => {
106
- test('Parsing the felt in request', async () => {
107
- return expect(typeTransformedContract.request_felt(3)).resolves.not.toThrow();
108
- });
108
+ describe('Request Type Transformation', () => {
109
+ test('Parsing the felt in request', async () => {
110
+ return expect(typeTransformedContract.request_felt(3)).resolves.not.toThrow();
111
+ });
109
112
 
110
- test('Parsing the array of felt in request', async () => {
111
- return expect(
112
- typeTransformedContract.request_array_of_felts([1, 2])
113
- ).resolves.not.toThrow();
114
- });
113
+ test('Parsing the array of felt in request', async () => {
114
+ return expect(
115
+ typeTransformedContract.request_array_of_felts([1, 2])
116
+ ).resolves.not.toThrow();
117
+ });
115
118
 
116
- test('Parsing the struct in request', async () => {
117
- return expect(
118
- typeTransformedContract.request_struct({ x: 1, y: 2 })
119
- ).resolves.not.toThrow();
120
- });
119
+ test('Parsing the struct in request', async () => {
120
+ return expect(
121
+ typeTransformedContract.request_struct({ x: 1, y: 2 })
122
+ ).resolves.not.toThrow();
123
+ });
121
124
 
122
- test('Parsing the array of structs in request', async () => {
123
- return expect(
124
- typeTransformedContract.request_array_of_structs([{ x: 1, y: 2 }])
125
- ).resolves.not.toThrow();
126
- });
125
+ test('Parsing the array of structs in request', async () => {
126
+ return expect(
127
+ typeTransformedContract.request_array_of_structs([{ x: 1, y: 2 }])
128
+ ).resolves.not.toThrow();
129
+ });
127
130
 
128
- test('Parsing the nested structs in request', async () => {
129
- return expect(
130
- typeTransformedContract.request_nested_structs({
131
- p1: { x: 1, y: 2 },
132
- p2: { x: 3, y: 4 },
133
- extra: 5,
134
- })
135
- ).resolves.not.toThrow();
136
- });
131
+ test('Parsing the nested structs in request', async () => {
132
+ return expect(
133
+ typeTransformedContract.request_nested_structs({
134
+ p1: { x: 1, y: 2 },
135
+ p2: { x: 3, y: 4 },
136
+ extra: 5,
137
+ })
138
+ ).resolves.not.toThrow();
139
+ });
137
140
 
138
- test('Parsing the tuple in request', async () => {
139
- return expect(typeTransformedContract.request_tuple([1, 2])).resolves.not.toThrow();
140
- });
141
+ test('Parsing the tuple in request', async () => {
142
+ return expect(typeTransformedContract.request_tuple([1, 2])).resolves.not.toThrow();
143
+ });
141
144
 
142
- test('Parsing the multiple types in request', async () => {
143
- return expect(
144
- typeTransformedContract.request_mixed_types(2, { x: 1, y: 2 }, [1])
145
- ).resolves.not.toThrow();
145
+ test('Parsing the multiple types in request', async () => {
146
+ return expect(
147
+ typeTransformedContract.request_mixed_types(2, { x: 1, y: 2 }, [1])
148
+ ).resolves.not.toThrow();
149
+ });
146
150
  });
147
- });
148
151
 
149
- describe('Response Type Transformation', () => {
150
- test('Parsing the felt in response', async () => {
151
- const { res } = await typeTransformedContract.get_felt();
152
- expect(res).toStrictEqual(toBN(4));
153
- });
152
+ describe('Response Type Transformation', () => {
153
+ test('Parsing the felt in response', async () => {
154
+ const { res } = await typeTransformedContract.get_felt();
155
+ expect(res).toStrictEqual(toBN(4));
156
+ });
154
157
 
155
- test('Parsing the array of felt in response', async () => {
156
- const result = await typeTransformedContract.get_array_of_felts();
157
- const [res] = result;
158
- expect(res).toStrictEqual([toBN(4), toBN(5)]);
159
- expect(res).toStrictEqual(result.res);
160
- });
158
+ test('Parsing the array of felt in response', async () => {
159
+ const result = await typeTransformedContract.get_array_of_felts();
160
+ const [res] = result;
161
+ expect(res).toStrictEqual([toBN(4), toBN(5)]);
162
+ expect(res).toStrictEqual(result.res);
163
+ });
161
164
 
162
- test('Parsing the array of structs in response', async () => {
163
- const result = await typeTransformedContract.get_struct();
164
- const [res] = result;
165
- expect(res).toStrictEqual({ x: toBN(1), y: toBN(2) });
166
- expect(res).toStrictEqual(result.res);
167
- });
165
+ test('Parsing the array of structs in response', async () => {
166
+ const result = await typeTransformedContract.get_struct();
167
+ const [res] = result;
168
+ expect(res).toStrictEqual({ x: toBN(1), y: toBN(2) });
169
+ expect(res).toStrictEqual(result.res);
170
+ });
168
171
 
169
- test('Parsing the array of structs in response', async () => {
170
- const result = await typeTransformedContract.get_array_of_structs();
171
- const [res] = result;
172
- expect(res).toStrictEqual([{ x: toBN(1), y: toBN(2) }]);
173
- expect(res).toStrictEqual(result.res);
174
- });
172
+ test('Parsing the array of structs in response', async () => {
173
+ const result = await typeTransformedContract.get_array_of_structs();
174
+ const [res] = result;
175
+ expect(res).toStrictEqual([{ x: toBN(1), y: toBN(2) }]);
176
+ expect(res).toStrictEqual(result.res);
177
+ });
175
178
 
176
- test('Parsing the nested structs in response', async () => {
177
- const result = await typeTransformedContract.get_nested_structs();
178
- const [res] = result;
179
- expect(res).toStrictEqual({
180
- p1: { x: toBN(1), y: toBN(2) },
181
- p2: { x: toBN(3), y: toBN(4) },
182
- extra: toBN(5),
179
+ test('Parsing the nested structs in response', async () => {
180
+ const result = await typeTransformedContract.get_nested_structs();
181
+ const [res] = result;
182
+ expect(res).toStrictEqual({
183
+ p1: { x: toBN(1), y: toBN(2) },
184
+ p2: { x: toBN(3), y: toBN(4) },
185
+ extra: toBN(5),
186
+ });
187
+ expect(res).toStrictEqual(result.res);
183
188
  });
184
- expect(res).toStrictEqual(result.res);
185
- });
186
189
 
187
- test('Parsing the tuple in response', async () => {
188
- const result = await typeTransformedContract.get_tuple();
189
- const [res] = result;
190
- expect(res).toStrictEqual([toBN(1), toBN(2), toBN(3)]);
191
- expect(res).toStrictEqual(result.res);
192
- });
190
+ test('Parsing the tuple in response', async () => {
191
+ const result = await typeTransformedContract.get_tuple();
192
+ const [res] = result;
193
+ expect(res).toStrictEqual([toBN(1), toBN(2), toBN(3)]);
194
+ expect(res).toStrictEqual(result.res);
195
+ });
193
196
 
194
- test('Parsing the multiple types in response', async () => {
195
- const result = await typeTransformedContract.get_mixed_types();
196
- const [tuple, number, array, point] = result;
197
- expect(tuple).toStrictEqual([toBN(1), toBN(2)]);
198
- expect(number).toStrictEqual(toBN(3));
199
- expect(array).toStrictEqual([toBN(4)]);
200
- expect(point).toStrictEqual({ x: toBN(1), y: toBN(2) });
201
- expect(tuple).toStrictEqual(result.tuple);
202
- expect(number).toStrictEqual(result.number);
203
- expect(array).toStrictEqual(result.array);
204
- expect(point).toStrictEqual(result.point);
197
+ test('Parsing the multiple types in response', async () => {
198
+ const result = await typeTransformedContract.get_mixed_types();
199
+ const [tuple, number, array, point] = result;
200
+ expect(tuple).toStrictEqual([toBN(1), toBN(2)]);
201
+ expect(number).toStrictEqual(toBN(3));
202
+ expect(array).toStrictEqual([toBN(4)]);
203
+ expect(point).toStrictEqual({ x: toBN(1), y: toBN(2) });
204
+ expect(tuple).toStrictEqual(result.tuple);
205
+ expect(number).toStrictEqual(result.number);
206
+ expect(array).toStrictEqual(result.array);
207
+ expect(point).toStrictEqual(result.point);
208
+ });
205
209
  });
206
210
  });
207
211
  });
208
- });
209
212
 
210
- describe('class ContractFactory {}', () => {
211
- let erc20Address: string;
212
- const wallet = stark.randomAddress();
213
- const account = getTestAccount(provider);
214
- const constructorCalldata = [encodeShortString('Token'), encodeShortString('ERC20'), wallet];
215
- const classHash = '0x54328a1075b8820eb43caf0caa233923148c983742402dcfc38541dd843d01a';
216
-
217
- beforeAll(async () => {
218
- await account.declareDeploy({
219
- contract: compiledErc20,
220
- classHash: '0x54328a1075b8820eb43caf0caa233923148c983742402dcfc38541dd843d01a',
221
- constructorCalldata,
213
+ describe('class ContractFactory {}', () => {
214
+ beforeAll(async () => {
215
+ await account.declareDeploy({
216
+ contract: compiledErc20,
217
+ classHash: '0x54328a1075b8820eb43caf0caa233923148c983742402dcfc38541dd843d01a',
218
+ constructorCalldata,
219
+ });
220
+ });
221
+ test('deployment of new contract', async () => {
222
+ const factory = new ContractFactory(compiledErc20, classHash, account);
223
+ const erc20 = await factory.deploy(constructorCalldata);
224
+ expect(erc20 instanceof Contract);
225
+ });
226
+ test('wait for deployment transaction', async () => {
227
+ const factory = new ContractFactory(compiledErc20, classHash, account);
228
+ const contract = await factory.deploy(constructorCalldata);
229
+ expect(contract.deployed()).resolves.not.toThrow();
230
+ });
231
+ test('attach new contract', async () => {
232
+ const factory = new ContractFactory(compiledErc20, classHash, account);
233
+ const erc20 = factory.attach(erc20Address);
234
+ expect(erc20 instanceof Contract);
222
235
  });
223
- });
224
- test('deployment of new contract', async () => {
225
- const factory = new ContractFactory(compiledErc20, classHash, account);
226
- const erc20 = await factory.deploy(constructorCalldata);
227
- expect(erc20 instanceof Contract);
228
- });
229
- test('wait for deployment transaction', async () => {
230
- const factory = new ContractFactory(compiledErc20, classHash, account);
231
- const contract = await factory.deploy(constructorCalldata);
232
- expect(contract.deployed()).resolves.not.toThrow();
233
- });
234
- test('attach new contract', async () => {
235
- const factory = new ContractFactory(compiledErc20, classHash, account);
236
- const erc20 = factory.attach(erc20Address);
237
- expect(erc20 instanceof Contract);
238
236
  });
239
237
  });