starknet 3.12.3 → 3.13.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 (51) hide show
  1. package/.github/workflows/pr.yml +3 -0
  2. package/.github/workflows/release.yml +4 -0
  3. package/CHANGELOG.md +26 -0
  4. package/__mocks__/Account.json +25468 -0
  5. package/__tests__/account.test.ts +102 -65
  6. package/__tests__/contract.test.ts +23 -65
  7. package/__tests__/fixtures.ts +21 -1
  8. package/__tests__/provider.test.ts +20 -1
  9. package/account/index.js +10 -6
  10. package/contract/default.js +20 -21
  11. package/contract/index.js +10 -6
  12. package/dist/account/index.js +5 -1
  13. package/dist/contract/default.js +18 -18
  14. package/dist/contract/index.js +5 -1
  15. package/dist/index.js +5 -1
  16. package/dist/provider/default.d.ts +1 -1
  17. package/dist/provider/default.js +8 -6
  18. package/dist/provider/index.js +5 -1
  19. package/dist/provider/interface.d.ts +1 -1
  20. package/dist/provider/utils.js +5 -5
  21. package/dist/signer/index.js +5 -1
  22. package/dist/types/api.d.ts +1 -1
  23. package/dist/types/index.js +5 -1
  24. package/dist/utils/ellipticCurve.js +1 -1
  25. package/dist/utils/encode.js +1 -1
  26. package/dist/utils/hash.js +1 -1
  27. package/dist/utils/number.js +8 -4
  28. package/dist/utils/shortString.js +2 -2
  29. package/dist/utils/typedData/index.js +8 -4
  30. package/index.js +10 -6
  31. package/package.json +30 -28
  32. package/provider/default.d.ts +1 -1
  33. package/provider/default.js +9 -10
  34. package/provider/index.js +10 -6
  35. package/provider/interface.d.ts +1 -1
  36. package/provider/utils.js +5 -5
  37. package/signer/index.js +10 -6
  38. package/src/provider/default.ts +4 -2
  39. package/src/provider/interface.ts +1 -1
  40. package/src/types/api.ts +1 -1
  41. package/types/api.d.ts +1 -1
  42. package/types/index.js +10 -6
  43. package/utils/ellipticCurve.js +1 -1
  44. package/utils/encode.js +1 -1
  45. package/utils/hash.js +1 -1
  46. package/utils/number.js +13 -9
  47. package/utils/shortString.js +2 -2
  48. package/utils/typedData/index.js +15 -13
  49. package/www/guides/account.md +21 -7
  50. package/www/guides/erc20.md +15 -27
  51. package/__tests__/accountContract.test.ts +0 -110
@@ -75,7 +75,7 @@ export declare abstract class ProviderInterface {
75
75
  */
76
76
  abstract getStorageAt(
77
77
  contractAddress: string,
78
- key: number,
78
+ key: BigNumberish,
79
79
  blockIdentifier?: BlockIdentifier
80
80
  ): Promise<object>;
81
81
  /**
package/provider/utils.js CHANGED
@@ -26,10 +26,10 @@ exports.formatHash = formatHash;
26
26
  */
27
27
  function txIdentifier(txHash, txId) {
28
28
  if (!txHash) {
29
- return 'transactionId=' + JSON.stringify(txId);
29
+ return 'transactionId='.concat(JSON.stringify(txId));
30
30
  }
31
31
  var hashString = formatHash(txHash);
32
- return 'transactionHash=' + hashString;
32
+ return 'transactionHash='.concat(hashString);
33
33
  }
34
34
  exports.txIdentifier = txIdentifier;
35
35
  /**
@@ -55,7 +55,7 @@ function getBlockIdentifier(blockIdentifier) {
55
55
  return { type: 'BLOCK_NUMBER', data: parseInt(blockIdentifier, 10) };
56
56
  }
57
57
  if (typeof blockIdentifier === 'string') {
58
- throw new Error('Invalid block identifier: ' + blockIdentifier);
58
+ throw new Error('Invalid block identifier: '.concat(blockIdentifier));
59
59
  }
60
60
  return { type: 'BLOCK_HASH', data: blockIdentifier };
61
61
  }
@@ -77,8 +77,8 @@ function getFormattedBlockIdentifier(blockIdentifier) {
77
77
  return '';
78
78
  }
79
79
  if (blockIdentifierObject.type === 'BLOCK_NUMBER') {
80
- return 'blockNumber=' + blockIdentifierObject.data;
80
+ return 'blockNumber='.concat(blockIdentifierObject.data);
81
81
  }
82
- return 'blockHash=' + (0, number_1.toHex)((0, number_1.toBN)(blockIdentifierObject.data));
82
+ return 'blockHash='.concat((0, number_1.toHex)((0, number_1.toBN)(blockIdentifierObject.data)));
83
83
  }
84
84
  exports.getFormattedBlockIdentifier = getFormattedBlockIdentifier;
package/signer/index.js CHANGED
@@ -4,12 +4,16 @@ var __createBinding =
4
4
  (Object.create
5
5
  ? function (o, m, k, k2) {
6
6
  if (k2 === undefined) k2 = k;
7
- Object.defineProperty(o, k2, {
8
- enumerable: true,
9
- get: function () {
10
- return m[k];
11
- },
12
- });
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ('get' in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = {
10
+ enumerable: true,
11
+ get: function () {
12
+ return m[k];
13
+ },
14
+ };
15
+ }
16
+ Object.defineProperty(o, k2, desc);
13
17
  }
14
18
  : function (o, m, k, k2) {
15
19
  if (k2 === undefined) k2 = k;
@@ -31,7 +31,9 @@ type NetworkName = 'mainnet-alpha' | 'goerli-alpha';
31
31
  type ProviderOptions = { network: NetworkName } | { baseUrl: string };
32
32
 
33
33
  function wait(delay: number) {
34
- return new Promise((res) => setTimeout(res, delay));
34
+ return new Promise((res) => {
35
+ setTimeout(res, delay);
36
+ });
35
37
  }
36
38
 
37
39
  function isEmptyQueryObject(obj?: Record<any, any>): obj is undefined {
@@ -250,7 +252,7 @@ export class Provider implements ProviderInterface {
250
252
  */
251
253
  public async getStorageAt(
252
254
  contractAddress: string,
253
- key: number,
255
+ key: BigNumberish,
254
256
  blockIdentifier: BlockIdentifier = 'pending'
255
257
  ): Promise<object> {
256
258
  return this.fetchEndpoint('get_storage_at', { blockIdentifier, contractAddress, key });
@@ -85,7 +85,7 @@ export abstract class ProviderInterface {
85
85
  */
86
86
  public abstract getStorageAt(
87
87
  contractAddress: string,
88
- key: number,
88
+ key: BigNumberish,
89
89
  blockIdentifier?: BlockIdentifier
90
90
  ): Promise<object>;
91
91
 
package/src/types/api.ts CHANGED
@@ -55,7 +55,7 @@ export type Endpoints = {
55
55
  get_storage_at: {
56
56
  QUERY: {
57
57
  contractAddress: string;
58
- key: number;
58
+ key: BigNumberish;
59
59
  blockIdentifier: BlockIdentifier;
60
60
  };
61
61
  REQUEST: never;
package/types/api.d.ts CHANGED
@@ -54,7 +54,7 @@ export declare type Endpoints = {
54
54
  get_storage_at: {
55
55
  QUERY: {
56
56
  contractAddress: string;
57
- key: number;
57
+ key: BigNumberish;
58
58
  blockIdentifier: BlockIdentifier;
59
59
  };
60
60
  REQUEST: never;
package/types/index.js CHANGED
@@ -4,12 +4,16 @@ var __createBinding =
4
4
  (Object.create
5
5
  ? function (o, m, k, k2) {
6
6
  if (k2 === undefined) k2 = k;
7
- Object.defineProperty(o, k2, {
8
- enumerable: true,
9
- get: function () {
10
- return m[k];
11
- },
12
- });
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ('get' in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = {
10
+ enumerable: true,
11
+ get: function () {
12
+ return m[k];
13
+ },
14
+ };
15
+ }
16
+ Object.defineProperty(o, k2, desc);
13
17
  }
14
18
  : function (o, m, k, k2) {
15
19
  if (k2 === undefined) k2 = k;
@@ -68,7 +68,7 @@ function fixMessage(msg) {
68
68
  }
69
69
  (0, minimalistic_assert_1.default)(pureHex.length === 63);
70
70
  // In this case delta will be 4 so we perform a shift-left of 4 bits by adding a ZERO_BN.
71
- return pureHex + '0';
71
+ return ''.concat(pureHex, '0');
72
72
  }
73
73
  exports.genKeyPair = exports.ec.genKeyPair.bind(exports.ec);
74
74
  function getKeyPair(pk) {
package/utils/encode.js CHANGED
@@ -76,7 +76,7 @@ function removeHexPrefix(hex) {
76
76
  }
77
77
  exports.removeHexPrefix = removeHexPrefix;
78
78
  function addHexPrefix(hex) {
79
- return '0x' + removeHexPrefix(hex);
79
+ return '0x'.concat(removeHexPrefix(hex));
80
80
  }
81
81
  exports.addHexPrefix = addHexPrefix;
82
82
  function padString(str, length, left, padding) {
package/utils/hash.js CHANGED
@@ -97,7 +97,7 @@ function pedersen(input) {
97
97
  (0, minimalistic_assert_1.default)(
98
98
  x.gte(constants_1.ZERO) &&
99
99
  x.lt((0, number_1.toBN)((0, encode_1.addHexPrefix)(constants_1.FIELD_PRIME))),
100
- 'Invalid input: ' + input[i]
100
+ 'Invalid input: '.concat(input[i])
101
101
  );
102
102
  for (var j = 0; j < 252; j += 1) {
103
103
  var pt = constantPoints[2 + i * 252 + j];
package/utils/number.js CHANGED
@@ -4,12 +4,16 @@ var __createBinding =
4
4
  (Object.create
5
5
  ? function (o, m, k, k2) {
6
6
  if (k2 === undefined) k2 = k;
7
- Object.defineProperty(o, k2, {
8
- enumerable: true,
9
- get: function () {
10
- return m[k];
11
- },
12
- });
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ('get' in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = {
10
+ enumerable: true,
11
+ get: function () {
12
+ return m[k];
13
+ },
14
+ };
15
+ }
16
+ Object.defineProperty(o, k2, desc);
13
17
  }
14
18
  : function (o, m, k, k2) {
15
19
  if (k2 === undefined) k2 = k;
@@ -68,7 +72,7 @@ function toHex(number) {
68
72
  }
69
73
  exports.toHex = toHex;
70
74
  function hexToDecimalString(hex) {
71
- return toBN('0x' + hex.replace(/^0x/, '')).toString();
75
+ return toBN('0x'.concat(hex.replace(/^0x/, ''))).toString();
72
76
  }
73
77
  exports.hexToDecimalString = hexToDecimalString;
74
78
  function toFelt(num) {
@@ -88,11 +92,11 @@ function assertInRange(input, lowerBound, upperBound, inputName) {
88
92
  if (inputName === void 0) {
89
93
  inputName = '';
90
94
  }
91
- var messageSuffix = inputName === '' ? 'invalid length' : 'invalid ' + inputName + ' length';
95
+ var messageSuffix = inputName === '' ? 'invalid length' : 'invalid '.concat(inputName, ' length');
92
96
  var inputBn = toBN(input);
93
97
  (0, minimalistic_assert_1.default)(
94
98
  inputBn.gte(toBN(lowerBound)) && inputBn.lt(toBN(upperBound)),
95
- 'Message not signable, ' + messageSuffix + '.'
99
+ 'Message not signable, '.concat(messageSuffix, '.')
96
100
  );
97
101
  }
98
102
  exports.assertInRange = assertInRange;
@@ -17,8 +17,8 @@ function isShortString(str) {
17
17
  }
18
18
  exports.isShortString = isShortString;
19
19
  function encodeShortString(str) {
20
- if (!isASCII(str)) throw new Error(str + ' is not an ASCII string');
21
- if (!isShortString(str)) throw new Error(str + ' is too long');
20
+ if (!isASCII(str)) throw new Error(''.concat(str, ' is not an ASCII string'));
21
+ if (!isShortString(str)) throw new Error(''.concat(str, ' is too long'));
22
22
  return (0, encode_1.addHexPrefix)(
23
23
  str.replace(/./g, function (char) {
24
24
  return char.charCodeAt(0).toString(16);
@@ -4,12 +4,16 @@ var __createBinding =
4
4
  (Object.create
5
5
  ? function (o, m, k, k2) {
6
6
  if (k2 === undefined) k2 = k;
7
- Object.defineProperty(o, k2, {
8
- enumerable: true,
9
- get: function () {
10
- return m[k];
11
- },
12
- });
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ('get' in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = {
10
+ enumerable: true,
11
+ get: function () {
12
+ return m[k];
13
+ },
14
+ };
15
+ }
16
+ Object.defineProperty(o, k2, desc);
13
17
  }
14
18
  : function (o, m, k, k2) {
15
19
  if (k2 === undefined) k2 = k;
@@ -76,7 +80,7 @@ function getHex(value) {
76
80
  if (typeof value === 'string') {
77
81
  return (0, number_1.toHex)((0, number_1.toBN)((0, shortString_1.encodeShortString)(value)));
78
82
  }
79
- throw new Error('Invalid BigNumberish: ' + value);
83
+ throw new Error('Invalid BigNumberish: '.concat(value));
80
84
  }
81
85
  }
82
86
  /**
@@ -135,12 +139,10 @@ var encodeType = function (typedData, type) {
135
139
  var types = __spreadArray([primary], __read(dependencies.sort()), false);
136
140
  return types
137
141
  .map(function (dependency) {
138
- return (
139
- dependency +
140
- '(' +
142
+ return ''.concat(dependency, '(').concat(
141
143
  typedData.types[dependency].map(function (t) {
142
- return t.name + ':' + t.type;
143
- }) +
144
+ return ''.concat(t.name, ':').concat(t.type);
145
+ }),
144
146
  ')'
145
147
  );
146
148
  })
@@ -193,7 +195,7 @@ var encodeData = function (typedData, type, data) {
193
195
  ts = _b[0],
194
196
  vs = _b[1];
195
197
  if (data[field.name] === undefined || data[field.name] === null) {
196
- throw new Error("Cannot encode data: missing data for '" + field.name + "'");
198
+ throw new Error("Cannot encode data: missing data for '".concat(field.name, "'"));
197
199
  }
198
200
  var value = data[field.name];
199
201
  var _c = __read(encodeValue(typedData, field.type, value), 2),
@@ -14,7 +14,15 @@ Install the latest version of starknet with `npm install starknet@next`
14
14
 
15
15
  ```javascript
16
16
  import fs from "fs";
17
- import * as starknet from "starknet";
17
+ import fs from "fs";
18
+ import {
19
+ Account,
20
+ Contract,
21
+ defaultProvider,
22
+ ec,
23
+ json,
24
+ number,
25
+ } from "starknet";
18
26
  ```
19
27
 
20
28
  ## Generate random key pair.
@@ -44,17 +52,23 @@ const accountResponse = await defaultProvider.deployContract({
44
52
 
45
53
  Wait for the deployment transaction to be accepted and assign the address of the deployed account to the Account object.
46
54
 
47
- Use your new account object to sign transactions, messages or verify signatures!
48
-
49
55
  ```javascript
50
56
  await defaultProvider.waitForTransaction(accountResponse.transaction_hash);
51
57
  const accountContract = new Contract(
52
58
  compiledArgentAccount.abi,
53
59
  accountResponse.address
54
60
  );
55
- const { transaction_hash: initializeTxHash } = await accountContract.initialize(
56
- starkKeyPub,
57
- "0"
61
+ const initializeResponse = await accountContract.initialize(starkKeyPub, "0");
62
+
63
+ await defaultProvider.waitForTransaction(initializeResponse.transaction_hash);
64
+ ```
65
+
66
+ Once account contract is initialized [Account](../docs/API/account.md) instance can be created. Use your new account instance to sign transactions, messages or verify signatures!
67
+
68
+ ```js
69
+ const account = new Account(
70
+ defaultProvider,
71
+ accountResponse.address,
72
+ starkKeyPair
58
73
  );
59
- await defaultProvider.waitForTransaction(initializeTxHash);
60
74
  ```
@@ -4,7 +4,7 @@ sidebar_position: 3
4
4
 
5
5
  # Deploy an ERC20 Contract
6
6
 
7
- Dpeploy the contract and wait for deployment transaction to be accepted on StarkNet
7
+ Deploy the contract and wait for deployment transaction to be accepted on StarkNet
8
8
 
9
9
  ```javascript
10
10
  const compiledErc20 = json.parse(
@@ -26,9 +26,11 @@ const erc20 = new Contract(compiledErc20.abi, erc20Address);
26
26
 
27
27
  ## Mint tokens to an account address
28
28
 
29
+ Make sure you created the `Account` instance following the [Creating an Account](./account.md) guide.
30
+
29
31
  ```javascript
30
32
  const { transaction_hash: mintTxHash } = await erc20.mint(
31
- accountContract.address,
33
+ account.address,
32
34
  "1000"
33
35
  );
34
36
  console.log(`Waiting for Tx to be Accepted on Starknet - Minting...`);
@@ -38,11 +40,11 @@ await defaultProvider.waitForTransaction(mintTxHash);
38
40
  ## Check balance after mint
39
41
 
40
42
  ```javascript
41
- console.log(`Calling StarkNet for accountContract balance...`);
42
- const balanceBeforeTransfer = await erc20.balance_of(accountContract.address);
43
+ console.log(`Calling StarkNet for account balance...`);
44
+ const balanceBeforeTransfer = await erc20.balance_of(account.address);
43
45
 
44
46
  console.log(
45
- `accountContract Address ${accountContract.address} has a balance of:`,
47
+ `account Address ${account.address} has a balance of:`,
46
48
  number.toBN(balanceBeforeTransfer.res, 16).toString()
47
49
  );
48
50
  ```
@@ -50,30 +52,16 @@ console.log(
50
52
  ## Transfer tokens
51
53
 
52
54
  ```javascript
53
- // Get the nonce of the account and prepare transfer tx
54
- console.log(`Calling StarkNet for accountContract nonce...`);
55
- const nonce = (await accountContract.call("get_nonce")).nonce.toString();
56
- const calls = [
55
+ // Execute tx transfer of 10 tokens
56
+ console.log(`Invoke Tx - Transfer 10 tokens back to erc20 contract...`);
57
+ const { transaction_hash: transferTxHash } = await account.execute(
57
58
  {
58
59
  contractAddress: erc20Address,
59
60
  entrypoint: "transfer",
60
61
  calldata: [erc20Address, "10"],
61
62
  },
62
- ];
63
- const msgHash = hash.hashMulticall(accountContract.address, calls, nonce, "0");
64
-
65
- const { callArray, calldata } = transformCallsToMulticallArrays(calls);
66
-
67
- // sign tx to transfer 10 tokens
68
- const signature = ec.sign(starkKeyPair, msgHash);
69
-
70
- // Execute tx transfer of 10 tokens
71
- console.log(`Invoke Tx - Transfer 10 tokens back to erc20 contract...`);
72
- const { transaction_hash: transferTxHash } = await accountContract.__execute__(
73
- callArray,
74
- calldata,
75
- nonce,
76
- signature
63
+ undefined,
64
+ { maxFee: "0" }
77
65
  );
78
66
 
79
67
  // Wait for the invoke transaction to be accepted on StarkNet
@@ -85,11 +73,11 @@ await defaultProvider.waitForTransaction(transferTxHash);
85
73
 
86
74
  ```javascript
87
75
  // Check balance after transfer - should be 990
88
- console.log(`Calling StarkNet for accountContract balance...`);
89
- const balanceAfterTransfer = await erc20.balance_of(accountContract.address);
76
+ console.log(`Calling StarkNet for account balance...`);
77
+ const balanceAfterTransfer = await erc20.balance_of(account.address);
90
78
 
91
79
  console.log(
92
- `accountContract Address ${accountContract.address} has a balance of:`,
80
+ `account Address ${account.address} has a balance of:`,
93
81
  number.toBN(balanceAfterTransfer.res, 16).toString()
94
82
  );
95
83
  ```
@@ -1,110 +0,0 @@
1
- import { Contract, defaultProvider, ec, hash, number, stark } from '../src';
2
- import { StarknetChainId } from '../src/constants';
3
- import {
4
- calculcateTransactionHash,
5
- getSelectorFromName,
6
- transactionVersion,
7
- } from '../src/utils/hash';
8
- import { fromCallsToExecuteCalldataWithNonce } from '../src/utils/transaction';
9
- import { compiledArgentAccount, compiledErc20 } from './fixtures';
10
-
11
- describe('getStarkAccountFromPrivateKey()', () => {
12
- test('it works with valid privateKey', () => {
13
- const privateKey = '0xb696427c0d79c5d28a1fa6f748bae1b98b3f4b86bd1a2505bab144673c856fa9';
14
-
15
- const starkKeyPair = ec.getKeyPair(privateKey);
16
- const starkKey = ec.getStarkKey(starkKeyPair);
17
-
18
- expect(starkKey).toBe('0x060d46f8d7ef3d83ed05f3ed9beb91e22f9529289b9d863683fd71eafaf28035');
19
- });
20
- test('it works with valid privateKey', () => {
21
- const privateKey = '0x5f65099e269b080000000000000000000000000000000000000000000000000';
22
-
23
- const starkKeyPair = ec.getKeyPair(privateKey);
24
- const starkKey = ec.getStarkKey(starkKeyPair);
25
-
26
- expect(starkKey).toBe('0xf321e59b257a577836d8313150aabd21f412491358c329966218df76bab591');
27
- });
28
- });
29
-
30
- test('build tx', async () => {
31
- const privateKey = '0x1B69B4BE052FAB1';
32
- const keyPair = ec.getKeyPair(privateKey);
33
- const address = ec.getStarkKey(keyPair);
34
-
35
- expect(address).toBe('0x04024999b9574cb7623679ce049a609db62a95098982c5b28ac61abdebd1c82b');
36
-
37
- const selector = hash.getSelectorFromName('transfer');
38
-
39
- expect(selector).toMatchInlineSnapshot(
40
- `"0x83afd3f4caedc6eebf44246fe54e38c95e3179a5ec9ea81740eca5b482d12e"`
41
- );
42
-
43
- const calls = [{ contractAddress: '1', entrypoint: 'transfer', calldata: ['6', '7'] }];
44
- const calldata = fromCallsToExecuteCalldataWithNonce(calls, 0);
45
-
46
- const msgHash = calculcateTransactionHash(
47
- address,
48
- transactionVersion,
49
- getSelectorFromName('__execute__'),
50
- calldata,
51
- 0,
52
- StarknetChainId.TESTNET
53
- );
54
- expect(number.toBN(msgHash).toString()).toMatchInlineSnapshot(
55
- `"235855380881994314533025886817815774848495061484535023348790852315407085619"`
56
- );
57
-
58
- const [r, s] = ec.sign(keyPair, msgHash);
59
- expect(r.toString()).toMatchInlineSnapshot(
60
- `"181489288548431284937202760565682158657883789985879744111612429574110648095"`
61
- );
62
- expect(s.toString()).toMatchInlineSnapshot(
63
- `"2055384802167699202203509702082340762385659879831017273872106910763470114538"`
64
- );
65
- });
66
-
67
- describe('deploy and test Wallet', () => {
68
- const privateKey = stark.randomAddress();
69
-
70
- const starkKeyPair = ec.getKeyPair(privateKey);
71
- const starkKeyPub = ec.getStarkKey(starkKeyPair);
72
- let accountContract: Contract;
73
- let erc20: Contract;
74
- let erc20Address: string;
75
-
76
- beforeAll(async () => {
77
- const accountResponse = await defaultProvider.deployContract({
78
- contract: compiledArgentAccount,
79
- addressSalt: starkKeyPub,
80
- });
81
- accountContract = new Contract(compiledArgentAccount.abi, accountResponse.address);
82
- expect(accountResponse.code).toBe('TRANSACTION_RECEIVED');
83
-
84
- const initializeResponse = await accountContract.initialize(starkKeyPub, '0');
85
- expect(initializeResponse.code).toBe('TRANSACTION_RECEIVED');
86
-
87
- const erc20Response = await defaultProvider.deployContract({
88
- contract: compiledErc20,
89
- });
90
- erc20Address = erc20Response.address;
91
- erc20 = new Contract(compiledErc20.abi, erc20Address);
92
- expect(erc20Response.code).toBe('TRANSACTION_RECEIVED');
93
-
94
- const mintResponse = await erc20.mint(accountContract.address, '1000');
95
- expect(mintResponse.code).toBe('TRANSACTION_RECEIVED');
96
- await defaultProvider.waitForTransaction(mintResponse.transaction_hash);
97
- });
98
-
99
- test('read nonce', async () => {
100
- const { nonce } = await accountContract.get_nonce();
101
-
102
- expect(number.toBN(nonce as string).toString()).toStrictEqual(number.toBN(0).toString());
103
- });
104
-
105
- test('read balance of wallet', async () => {
106
- const { res } = await erc20.balance_of(accountContract.address);
107
-
108
- expect(res).toStrictEqual(number.toBN(1000));
109
- });
110
- });