starknet 3.18.2 → 4.0.1
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 +70 -0
- package/README.md +1 -2
- package/__tests__/account.test.ts +11 -56
- package/__tests__/contract.test.ts +11 -49
- package/__tests__/defaultProvider.test.ts +321 -0
- package/__tests__/fixtures.ts +32 -11
- package/__tests__/jest.setup.ts +2 -3
- package/__tests__/rpcProvider.test.ts +17 -0
- package/__tests__/sequencerProvider.test.ts +45 -0
- package/account/default.d.ts +54 -77
- package/account/default.js +271 -596
- package/account/index.js +18 -31
- package/account/interface.d.ts +66 -95
- package/account/interface.js +20 -30
- package/constants.d.ts +17 -19
- package/constants.js +2038 -2059
- package/contract/contractFactory.d.ts +25 -29
- package/contract/contractFactory.js +94 -210
- package/contract/default.d.ts +117 -146
- package/contract/default.js +582 -776
- package/contract/index.js +19 -32
- package/contract/interface.d.ts +72 -92
- package/contract/interface.js +6 -5
- package/dist/account/default.d.ts +5 -9
- package/dist/account/default.js +35 -169
- package/dist/account/interface.d.ts +3 -15
- package/dist/contract/contractFactory.js +4 -4
- package/dist/contract/default.d.ts +3 -3
- package/dist/contract/default.js +3 -2
- package/dist/contract/interface.d.ts +2 -2
- package/dist/provider/default.d.ts +18 -134
- package/dist/provider/default.js +47 -411
- package/dist/provider/index.d.ts +2 -0
- package/dist/provider/index.js +2 -0
- package/dist/provider/interface.d.ts +45 -50
- package/dist/provider/rpc.d.ts +57 -0
- package/dist/provider/rpc.js +364 -0
- package/dist/provider/sequencer.d.ts +66 -0
- package/dist/provider/sequencer.js +444 -0
- package/dist/types/account.d.ts +2 -3
- package/dist/types/api/index.d.ts +16 -0
- package/dist/types/api/index.js +18 -0
- package/dist/types/api/rpc.d.ts +221 -0
- package/dist/types/{api.js → api/rpc.js} +0 -0
- package/dist/types/api/sequencer.d.ts +289 -0
- package/dist/types/api/sequencer.js +2 -0
- package/dist/types/index.d.ts +3 -1
- package/dist/types/index.js +15 -1
- package/dist/types/lib.d.ts +3 -1
- package/dist/types/provider.d.ts +86 -0
- package/dist/types/provider.js +2 -0
- package/dist/utils/fetchPonyfill.d.ts +2 -0
- package/dist/utils/fetchPonyfill.js +6 -0
- package/dist/utils/provider.d.ts +4 -0
- package/dist/utils/provider.js +38 -0
- package/dist/utils/responseParser/index.d.ts +11 -0
- package/dist/utils/responseParser/index.js +9 -0
- package/dist/utils/responseParser/rpc.d.ts +13 -0
- package/dist/utils/responseParser/rpc.js +96 -0
- package/dist/utils/responseParser/sequencer.d.ts +13 -0
- package/dist/utils/responseParser/sequencer.js +124 -0
- package/index.js +42 -75
- package/package.json +2 -3
- package/provider/default.d.ts +21 -175
- package/provider/default.js +139 -704
- package/provider/errors.d.ts +4 -4
- package/provider/errors.js +30 -40
- package/provider/index.d.ts +2 -0
- package/provider/index.js +22 -33
- package/provider/interface.d.ts +104 -131
- package/provider/interface.js +6 -5
- package/provider/rpc.d.ts +57 -0
- package/provider/rpc.js +364 -0
- package/provider/sequencer.d.ts +66 -0
- package/provider/sequencer.js +444 -0
- package/provider/utils.d.ts +7 -9
- package/provider/utils.js +39 -44
- package/signer/default.d.ts +5 -9
- package/signer/default.js +72 -177
- package/signer/index.js +18 -31
- package/signer/interface.d.ts +29 -33
- package/signer/interface.js +6 -5
- package/src/account/default.ts +26 -146
- package/src/account/interface.ts +5 -20
- package/src/contract/contractFactory.ts +3 -6
- package/src/contract/default.ts +6 -4
- package/src/contract/interface.ts +2 -2
- package/src/provider/default.ts +63 -395
- package/src/provider/index.ts +2 -0
- package/src/provider/interface.ts +68 -63
- package/src/provider/rpc.ts +299 -0
- package/src/provider/sequencer.ts +385 -0
- package/src/types/account.ts +2 -3
- package/src/types/api/index.ts +17 -0
- package/src/types/api/rpc.ts +247 -0
- package/src/types/api/sequencer.ts +331 -0
- package/src/types/index.ts +3 -1
- package/src/types/lib.ts +3 -1
- package/src/types/provider.ts +108 -0
- package/src/utils/fetchPonyfill.ts +4 -0
- package/src/utils/provider.ts +28 -0
- package/src/utils/responseParser/index.ts +28 -0
- package/src/utils/responseParser/rpc.ts +93 -0
- package/src/utils/responseParser/sequencer.ts +127 -0
- package/types/account.d.ts +5 -7
- package/types/account.js +2 -2
- package/types/api/index.d.ts +16 -0
- package/types/api/index.js +18 -0
- package/types/api/rpc.d.ts +221 -0
- package/types/api/rpc.js +2 -0
- package/types/api/sequencer.d.ts +289 -0
- package/types/api/sequencer.js +2 -0
- package/types/contract.d.ts +1 -1
- package/types/contract.js +2 -2
- package/types/index.d.ts +3 -1
- package/types/index.js +35 -34
- package/types/lib.d.ts +36 -41
- package/types/lib.js +2 -2
- package/types/provider.d.ts +86 -0
- package/types/provider.js +2 -0
- package/types/signer.d.ts +2 -2
- package/types/signer.js +2 -2
- package/utils/address.js +26 -37
- package/utils/ellipticCurve.d.ts +1 -6
- package/utils/ellipticCurve.js +73 -137
- package/utils/encode.js +49 -85
- package/utils/fetchPonyfill.d.ts +2 -0
- package/utils/fetchPonyfill.js +6 -0
- package/utils/hash.d.ts +4 -31
- package/utils/hash.js +76 -141
- package/utils/json.d.ts +13 -45
- package/utils/json.js +15 -22
- package/utils/number.d.ts +2 -9
- package/utils/number.js +47 -81
- package/utils/provider.d.ts +4 -0
- package/utils/provider.js +38 -0
- package/utils/responseParser/index.d.ts +11 -0
- package/utils/responseParser/index.js +9 -0
- package/utils/responseParser/rpc.d.ts +13 -0
- package/utils/responseParser/rpc.js +96 -0
- package/utils/responseParser/sequencer.d.ts +13 -0
- package/utils/responseParser/sequencer.js +124 -0
- package/utils/shortString.js +13 -21
- package/utils/stark.d.ts +0 -1
- package/utils/stark.js +59 -93
- package/utils/transaction.d.ts +3 -6
- package/utils/transaction.js +50 -81
- package/utils/typedData/index.d.ts +3 -15
- package/utils/typedData/index.js +109 -175
- package/utils/typedData/types.d.ts +9 -9
- package/utils/typedData/types.js +2 -2
- package/utils/typedData/utils.js +6 -6
- package/utils/uint256.d.ts +5 -5
- package/utils/uint256.js +16 -26
- package/www/docs/API/account.md +3 -4
- package/www/docs/API/contract.md +2 -2
- package/www/docs/API/contractFactory.md +2 -2
- package/www/docs/API/provider.md +185 -74
- package/www/guides/account.md +1 -8
- package/www/guides/erc20.md +3 -0
- package/__tests__/provider.test.ts +0 -168
- package/dist/types/api.d.ts +0 -261
- package/src/types/api.ts +0 -303
- package/types/api.d.ts +0 -287
- package/types/api.js +0 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,73 @@
|
|
|
1
|
+
## [4.0.1](https://github.com/0xs34n/starknet.js/compare/v4.0.0...v4.0.1) (2022-08-03)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
- use custom fetch ponyfill ([16e9a53](https://github.com/0xs34n/starknet.js/commit/16e9a530d62942da75ed1bc30d0048a35f9f0152))
|
|
6
|
+
- use isomorphic-unfetch ([aa7af66](https://github.com/0xs34n/starknet.js/commit/aa7af6622d918ad0d17fe28bf1e73635895537c5))
|
|
7
|
+
|
|
8
|
+
# [4.0.0](https://github.com/0xs34n/starknet.js/compare/v3.19.0...v4.0.0) (2022-07-27)
|
|
9
|
+
|
|
10
|
+
### Documentation
|
|
11
|
+
|
|
12
|
+
- v4 ([9e300a9](https://github.com/0xs34n/starknet.js/commit/9e300a98e587fc702ee3ef98441c457fe87e6c1e))
|
|
13
|
+
|
|
14
|
+
### BREAKING CHANGES
|
|
15
|
+
|
|
16
|
+
- new provider and signer interfaces
|
|
17
|
+
|
|
18
|
+
# [3.19.0](https://github.com/0xs34n/starknet.js/compare/v3.18.2...v3.19.0) (2022-07-25)
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
- account tests ([cc3f362](https://github.com/0xs34n/starknet.js/commit/cc3f362fffc157cb97e0fa2b8ff3a3db7dcf5985))
|
|
23
|
+
- add invoke warning ([34db683](https://github.com/0xs34n/starknet.js/commit/34db683267b639adbd37eb097573eb7210cb4a58))
|
|
24
|
+
- call contract latest block ([1476461](https://github.com/0xs34n/starknet.js/commit/1476461aeff6885b5185f45c5f8633f8c60cbfca))
|
|
25
|
+
- ci ([808e1f7](https://github.com/0xs34n/starknet.js/commit/808e1f7a837e014d3c3781973b434df646c207b4))
|
|
26
|
+
- ci ([6337feb](https://github.com/0xs34n/starknet.js/commit/6337febc9f6f6359f70d66be039779371f3186ff))
|
|
27
|
+
- contract tests ([ffb6a12](https://github.com/0xs34n/starknet.js/commit/ffb6a12dec4c27f9b570fcc2016fb3c17f5dcfb4))
|
|
28
|
+
- default provider tests ([2fac438](https://github.com/0xs34n/starknet.js/commit/2fac43876375a3d83818e152f4be5c3f219e8aff))
|
|
29
|
+
- invoke response type ([bdeb96b](https://github.com/0xs34n/starknet.js/commit/bdeb96b896c96f7f7778fd38e697bf368f2a8510))
|
|
30
|
+
- no secrets in matrix ([5ff7a26](https://github.com/0xs34n/starknet.js/commit/5ff7a2610c1c3f67ecb0a2b8d32e7c8c61017354))
|
|
31
|
+
- nonce issue on test runs ([bed6fbf](https://github.com/0xs34n/starknet.js/commit/bed6fbf74b6446e18ea63444ddefaa782a7ffdf4))
|
|
32
|
+
- pending getBlock test ([a9ea023](https://github.com/0xs34n/starknet.js/commit/a9ea023249c33369ed04b3f548bf98947240ff9e))
|
|
33
|
+
- provider ([32f9072](https://github.com/0xs34n/starknet.js/commit/32f90724894eccd1b0154842180da38bcf6411fe))
|
|
34
|
+
- provider tests ([79eb5ba](https://github.com/0xs34n/starknet.js/commit/79eb5bac4c03b64b6f3a2f3b59a1fea7bb930ce8))
|
|
35
|
+
- provider tests ([255fd3c](https://github.com/0xs34n/starknet.js/commit/255fd3cb68f0edc7794f77623389f94ac341880a))
|
|
36
|
+
- remove account test from contract tests ([d444e7f](https://github.com/0xs34n/starknet.js/commit/d444e7fb5f55a7a384dcc43a9ea0f1d09438364a))
|
|
37
|
+
- remove comment ([591caf6](https://github.com/0xs34n/starknet.js/commit/591caf6e7983ecf009a95ab3f9e1b86335fe1a23))
|
|
38
|
+
- remove hardcoded url ([c8f3377](https://github.com/0xs34n/starknet.js/commit/c8f3377d52f605dd03ab20879a5c7fd53aafe819))
|
|
39
|
+
- remove test only ([5add341](https://github.com/0xs34n/starknet.js/commit/5add341257f8d6b355a367e977b125f9642f7630))
|
|
40
|
+
- rename gateway to sequencer ([b7291e6](https://github.com/0xs34n/starknet.js/commit/b7291e654732bd5f57b2d477b20a5467dfc9854b))
|
|
41
|
+
- rename rpc provider ([fee4fb3](https://github.com/0xs34n/starknet.js/commit/fee4fb3e36e9d824f0956174a9278f6131b3ba3e))
|
|
42
|
+
- revert default block to pending ([28beff7](https://github.com/0xs34n/starknet.js/commit/28beff76107f762478e70974389eb75202a65d42))
|
|
43
|
+
- rpc provider account tests ([b2fc530](https://github.com/0xs34n/starknet.js/commit/b2fc53004a1e52149b3fa4e7357c3ade1d01cd4a))
|
|
44
|
+
- rpc provider tests ([12db930](https://github.com/0xs34n/starknet.js/commit/12db930b1babf3e3de035426c8c449bfb448951c))
|
|
45
|
+
- rpc provider waitForTransaction ([9e708ba](https://github.com/0xs34n/starknet.js/commit/9e708ba72ea350ae4866e5cff9519a89201b5b01))
|
|
46
|
+
- run only devnet on pr ([613084b](https://github.com/0xs34n/starknet.js/commit/613084b32f93540e5f11938196d7b2c003f12bbf))
|
|
47
|
+
- seperate types and fix fees ([577a836](https://github.com/0xs34n/starknet.js/commit/577a836b48a4567d63f0138163d016422256d221))
|
|
48
|
+
- set rpc url in pr workflow ([89ec3c1](https://github.com/0xs34n/starknet.js/commit/89ec3c1edfd6947404d009420305d7bb210c6cd3))
|
|
49
|
+
- test account ([ac8210a](https://github.com/0xs34n/starknet.js/commit/ac8210a6bbb159a17ab548a12f7a20823e55814a))
|
|
50
|
+
- tests should wait for build ([af8c5c7](https://github.com/0xs34n/starknet.js/commit/af8c5c779370e170de4785902e1e9ac282f2bfec))
|
|
51
|
+
- update jsdocs ([2c08e5d](https://github.com/0xs34n/starknet.js/commit/2c08e5d8fe80469ba41222767193823b3d516536))
|
|
52
|
+
- use rpc conditionally ([7023068](https://github.com/0xs34n/starknet.js/commit/70230682343b682df50da21cb9e7a7f54490091c))
|
|
53
|
+
- waitForTransaction ([4f0c00b](https://github.com/0xs34n/starknet.js/commit/4f0c00b568a174db51ecef918d8a8878254daba5))
|
|
54
|
+
- www/docs/API/contract.md ([3ca4a51](https://github.com/0xs34n/starknet.js/commit/3ca4a513950f4aa27ac447835fcefcebbece083b))
|
|
55
|
+
- www/docs/API/provider.md ([d73e826](https://github.com/0xs34n/starknet.js/commit/d73e8264527a5af21e1d8e7a7c1f3aa8b8c92fb8))
|
|
56
|
+
|
|
57
|
+
### Features
|
|
58
|
+
|
|
59
|
+
- adapt abstract provider interface to RPC provider ([b217b3b](https://github.com/0xs34n/starknet.js/commit/b217b3bd1e40c60427636ccad03583e901f6ba58))
|
|
60
|
+
- add account rpc tests ([fc3b484](https://github.com/0xs34n/starknet.js/commit/fc3b4846486e63f2ff5eaba78844235091f2d49e))
|
|
61
|
+
- add gateway provider class ([dad1eea](https://github.com/0xs34n/starknet.js/commit/dad1eea9caafc71c940262ee13dd75817996abfd))
|
|
62
|
+
- add provider utils ([4df4ae7](https://github.com/0xs34n/starknet.js/commit/4df4ae7e8b8111669e2bc20e30c2c89af9c50a4f))
|
|
63
|
+
- add rpc provider ([315bb74](https://github.com/0xs34n/starknet.js/commit/315bb747f26ba19556841a326484a7dbfa1a2857))
|
|
64
|
+
- change estimate fee response on rpc provider ([942f4f2](https://github.com/0xs34n/starknet.js/commit/942f4f2508fab697e796ee9f691341b86ccd34be))
|
|
65
|
+
- change provider keys to snake case ([2ee4b0b](https://github.com/0xs34n/starknet.js/commit/2ee4b0bf0892a3bd54e6d188990f979298814551))
|
|
66
|
+
- getStorageAt block param ([d89bf30](https://github.com/0xs34n/starknet.js/commit/d89bf307796e69627ffd91ebd97c787e4a7a77e7))
|
|
67
|
+
- implement new interface on account class ([b202f37](https://github.com/0xs34n/starknet.js/commit/b202f37ab72fd310a8c99b28863f38b8d142d2a7))
|
|
68
|
+
- implement new interface on contract class ([e942a9d](https://github.com/0xs34n/starknet.js/commit/e942a9d88479d88b82a3dbc05ec2f60ab9ad1f19))
|
|
69
|
+
- use shared describe block for providers ([b525a60](https://github.com/0xs34n/starknet.js/commit/b525a60eb77647962f4509bb02f64bb66071c9c2))
|
|
70
|
+
|
|
1
71
|
## [3.18.2](https://github.com/0xs34n/starknet.js/compare/v3.18.1...v3.18.2) (2022-07-25)
|
|
2
72
|
|
|
3
73
|
### Bug Fixes
|
package/README.md
CHANGED
|
@@ -40,7 +40,7 @@ Install starknet with `npm`
|
|
|
40
40
|
|
|
41
41
|
```bash
|
|
42
42
|
$ npm install starknet
|
|
43
|
-
# or for
|
|
43
|
+
# or for starknet.js v4:
|
|
44
44
|
$ npm install starknet@next
|
|
45
45
|
```
|
|
46
46
|
|
|
@@ -85,4 +85,3 @@ This library would not be possible without these rockstars.
|
|
|
85
85
|
Copyright (c) 2022 0xs34n
|
|
86
86
|
|
|
87
87
|
Licensed under the [MIT license](https://github.com/0xs34n/starknet.js/blob/main/LICENSE).
|
|
88
|
-
|
|
@@ -1,19 +1,13 @@
|
|
|
1
1
|
import { isBN } from 'bn.js';
|
|
2
2
|
|
|
3
3
|
import typedDataExample from '../__mocks__/typedDataExample.json';
|
|
4
|
-
import { Account, Contract, Provider,
|
|
4
|
+
import { Account, Contract, Provider, number, stark } from '../src';
|
|
5
5
|
import { toBN } from '../src/utils/number';
|
|
6
|
-
import {
|
|
7
|
-
compiledErc20,
|
|
8
|
-
compiledOpenZeppelinAccount,
|
|
9
|
-
compiledTestDapp,
|
|
10
|
-
getTestAccount,
|
|
11
|
-
getTestProvider,
|
|
12
|
-
} from './fixtures';
|
|
6
|
+
import { compiledErc20, compiledTestDapp, getTestAccount, getTestProvider } from './fixtures';
|
|
13
7
|
|
|
14
8
|
describe('deploy and test Wallet', () => {
|
|
15
|
-
const account = getTestAccount();
|
|
16
9
|
const provider = getTestProvider();
|
|
10
|
+
const account = getTestAccount(provider);
|
|
17
11
|
let erc20: Contract;
|
|
18
12
|
let erc20Address: string;
|
|
19
13
|
let dapp: Contract;
|
|
@@ -25,9 +19,8 @@ describe('deploy and test Wallet', () => {
|
|
|
25
19
|
contract: compiledErc20,
|
|
26
20
|
});
|
|
27
21
|
|
|
28
|
-
erc20Address = erc20Response.
|
|
22
|
+
erc20Address = erc20Response.contract_address;
|
|
29
23
|
erc20 = new Contract(compiledErc20.abi, erc20Address, provider);
|
|
30
|
-
expect(erc20Response.code).toBe('TRANSACTION_RECEIVED');
|
|
31
24
|
|
|
32
25
|
await provider.waitForTransaction(erc20Response.transaction_hash);
|
|
33
26
|
|
|
@@ -37,8 +30,6 @@ describe('deploy and test Wallet', () => {
|
|
|
37
30
|
calldata: [account.address, '1000'],
|
|
38
31
|
});
|
|
39
32
|
|
|
40
|
-
expect(mintResponse.code).toBe('TRANSACTION_RECEIVED');
|
|
41
|
-
|
|
42
33
|
await provider.waitForTransaction(mintResponse.transaction_hash);
|
|
43
34
|
|
|
44
35
|
const x = await erc20.balance_of(account.address);
|
|
@@ -48,20 +39,18 @@ describe('deploy and test Wallet', () => {
|
|
|
48
39
|
const dappResponse = await provider.deployContract({
|
|
49
40
|
contract: compiledTestDapp,
|
|
50
41
|
});
|
|
51
|
-
dapp = new Contract(compiledTestDapp.abi, dappResponse.
|
|
52
|
-
expect(dappResponse.code).toBe('TRANSACTION_RECEIVED');
|
|
42
|
+
dapp = new Contract(compiledTestDapp.abi, dappResponse.contract_address!, provider);
|
|
53
43
|
|
|
54
44
|
await provider.waitForTransaction(dappResponse.transaction_hash);
|
|
55
45
|
});
|
|
56
46
|
|
|
57
47
|
test('estimate fee', async () => {
|
|
58
|
-
const {
|
|
48
|
+
const { overall_fee } = await account.estimateFee({
|
|
59
49
|
contractAddress: erc20Address,
|
|
60
50
|
entrypoint: 'transfer',
|
|
61
51
|
calldata: [erc20.address, '10'],
|
|
62
52
|
});
|
|
63
|
-
expect(isBN(
|
|
64
|
-
expect(typeof unit).toBe('string');
|
|
53
|
+
expect(isBN(overall_fee)).toBe(true);
|
|
65
54
|
});
|
|
66
55
|
|
|
67
56
|
test('read balance of wallet', async () => {
|
|
@@ -71,13 +60,12 @@ describe('deploy and test Wallet', () => {
|
|
|
71
60
|
});
|
|
72
61
|
|
|
73
62
|
test('execute by wallet owner', async () => {
|
|
74
|
-
const {
|
|
63
|
+
const { transaction_hash } = await account.execute({
|
|
75
64
|
contractAddress: erc20Address,
|
|
76
65
|
entrypoint: 'transfer',
|
|
77
66
|
calldata: [erc20.address, '10'],
|
|
78
67
|
});
|
|
79
68
|
|
|
80
|
-
expect(code).toBe('TRANSACTION_RECEIVED');
|
|
81
69
|
await provider.waitForTransaction(transaction_hash);
|
|
82
70
|
});
|
|
83
71
|
|
|
@@ -93,7 +81,7 @@ describe('deploy and test Wallet', () => {
|
|
|
93
81
|
entrypoint: 'get_nonce',
|
|
94
82
|
});
|
|
95
83
|
const nonce = toBN(result[0]).toNumber();
|
|
96
|
-
const {
|
|
84
|
+
const { transaction_hash } = await account.execute(
|
|
97
85
|
{
|
|
98
86
|
contractAddress: erc20Address,
|
|
99
87
|
entrypoint: 'transfer',
|
|
@@ -103,12 +91,11 @@ describe('deploy and test Wallet', () => {
|
|
|
103
91
|
{ nonce }
|
|
104
92
|
);
|
|
105
93
|
|
|
106
|
-
expect(code).toBe('TRANSACTION_RECEIVED');
|
|
107
94
|
await provider.waitForTransaction(transaction_hash);
|
|
108
95
|
});
|
|
109
96
|
|
|
110
97
|
test('execute multiple transactions', async () => {
|
|
111
|
-
const {
|
|
98
|
+
const { transaction_hash } = await account.execute([
|
|
112
99
|
{
|
|
113
100
|
contractAddress: dapp.address,
|
|
114
101
|
entrypoint: 'set_number',
|
|
@@ -121,7 +108,6 @@ describe('deploy and test Wallet', () => {
|
|
|
121
108
|
},
|
|
122
109
|
]);
|
|
123
110
|
|
|
124
|
-
expect(code).toBe('TRANSACTION_RECEIVED');
|
|
125
111
|
await provider.waitForTransaction(transaction_hash);
|
|
126
112
|
|
|
127
113
|
const response = await dapp.get_number(account.address);
|
|
@@ -140,34 +126,6 @@ describe('deploy and test Wallet', () => {
|
|
|
140
126
|
expect(await account.verifyMessage(typedDataExample, signature)).toBe(true);
|
|
141
127
|
});
|
|
142
128
|
|
|
143
|
-
describe('new deployed account', () => {
|
|
144
|
-
let newAccount: Account;
|
|
145
|
-
|
|
146
|
-
beforeAll(async () => {
|
|
147
|
-
const starkKeyPair = ec.genKeyPair();
|
|
148
|
-
const starkKeyPub = ec.getStarkKey(starkKeyPair);
|
|
149
|
-
|
|
150
|
-
const accountResponse = await provider.deployContract({
|
|
151
|
-
contract: compiledOpenZeppelinAccount,
|
|
152
|
-
constructorCalldata: [starkKeyPub],
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
await provider.waitForTransaction(accountResponse.transaction_hash);
|
|
156
|
-
|
|
157
|
-
newAccount = new Account(provider, accountResponse.address!, starkKeyPair);
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
test('read nonce', async () => {
|
|
161
|
-
const { result } = await account.callContract({
|
|
162
|
-
contractAddress: newAccount.address,
|
|
163
|
-
entrypoint: 'get_nonce',
|
|
164
|
-
});
|
|
165
|
-
const nonce = result[0];
|
|
166
|
-
|
|
167
|
-
expect(number.toBN(nonce).toString()).toStrictEqual(number.toBN(0).toString());
|
|
168
|
-
});
|
|
169
|
-
});
|
|
170
|
-
|
|
171
129
|
describe('Contract interaction with Account', () => {
|
|
172
130
|
const wallet = stark.randomAddress();
|
|
173
131
|
|
|
@@ -178,8 +136,6 @@ describe('deploy and test Wallet', () => {
|
|
|
178
136
|
calldata: [wallet, '1000'],
|
|
179
137
|
});
|
|
180
138
|
|
|
181
|
-
expect(mintResponse.code).toBe('TRANSACTION_RECEIVED');
|
|
182
|
-
|
|
183
139
|
await provider.waitForTransaction(mintResponse.transaction_hash);
|
|
184
140
|
});
|
|
185
141
|
|
|
@@ -191,8 +147,7 @@ describe('deploy and test Wallet', () => {
|
|
|
191
147
|
|
|
192
148
|
test('estimate gas fee for `mint`', async () => {
|
|
193
149
|
const res = await erc20.estimateFee.mint(wallet, '10');
|
|
194
|
-
expect(res).toHaveProperty('
|
|
195
|
-
expect(res).toHaveProperty('unit');
|
|
150
|
+
expect(res).toHaveProperty('overall_fee');
|
|
196
151
|
});
|
|
197
152
|
});
|
|
198
153
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isBN } from 'bn.js';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { Contract, ContractFactory, stark } from '../src';
|
|
4
4
|
import { getSelectorFromName } from '../src/utils/hash';
|
|
5
5
|
import { BigNumberish, toBN } from '../src/utils/number';
|
|
6
6
|
import { compileCalldata } from '../src/utils/stark';
|
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
compiledErc20,
|
|
9
9
|
compiledMulticall,
|
|
10
10
|
compiledTypeTransformation,
|
|
11
|
-
getTestAccount,
|
|
12
11
|
getTestProvider,
|
|
13
12
|
} from './fixtures';
|
|
14
13
|
|
|
@@ -22,26 +21,20 @@ describe('class Contract {}', () => {
|
|
|
22
21
|
let contract: Contract;
|
|
23
22
|
|
|
24
23
|
beforeAll(async () => {
|
|
25
|
-
const {
|
|
24
|
+
const { transaction_hash, contract_address } = await provider.deployContract({
|
|
26
25
|
contract: compiledErc20,
|
|
27
26
|
});
|
|
28
|
-
erc20 = new Contract(compiledErc20.abi,
|
|
29
|
-
expect(code).toBe('TRANSACTION_RECEIVED');
|
|
27
|
+
erc20 = new Contract(compiledErc20.abi, contract_address!, provider);
|
|
30
28
|
await provider.waitForTransaction(transaction_hash);
|
|
31
29
|
// Deploy Multicall
|
|
32
30
|
|
|
33
|
-
const {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
} = await provider.deployContract({
|
|
38
|
-
contract: compiledMulticall,
|
|
39
|
-
});
|
|
31
|
+
const { transaction_hash: m_transaction_hash, contract_address: multicallAddress } =
|
|
32
|
+
await provider.deployContract({
|
|
33
|
+
contract: compiledMulticall,
|
|
34
|
+
});
|
|
40
35
|
|
|
41
36
|
contract = new Contract(compiledMulticall.abi, multicallAddress!, provider);
|
|
42
37
|
|
|
43
|
-
expect(m_code).toBe('TRANSACTION_RECEIVED');
|
|
44
|
-
|
|
45
38
|
await provider.waitForTransaction(m_transaction_hash);
|
|
46
39
|
});
|
|
47
40
|
|
|
@@ -92,11 +85,10 @@ describe('class Contract {}', () => {
|
|
|
92
85
|
let contract: Contract;
|
|
93
86
|
|
|
94
87
|
beforeAll(async () => {
|
|
95
|
-
const {
|
|
88
|
+
const { transaction_hash, contract_address } = await provider.deployContract({
|
|
96
89
|
contract: compiledTypeTransformation,
|
|
97
90
|
});
|
|
98
|
-
contract = new Contract(compiledTypeTransformation.abi,
|
|
99
|
-
expect(code).toBe('TRANSACTION_RECEIVED');
|
|
91
|
+
contract = new Contract(compiledTypeTransformation.abi, contract_address!, provider);
|
|
100
92
|
await provider.waitForTransaction(transaction_hash);
|
|
101
93
|
});
|
|
102
94
|
|
|
@@ -195,46 +187,16 @@ describe('class Contract {}', () => {
|
|
|
195
187
|
});
|
|
196
188
|
});
|
|
197
189
|
});
|
|
198
|
-
|
|
199
|
-
describe('Contract interaction with Account', () => {
|
|
200
|
-
const account = getTestAccount();
|
|
201
|
-
let erc20: Contract;
|
|
202
|
-
let erc20Address: string;
|
|
203
|
-
|
|
204
|
-
beforeAll(async () => {
|
|
205
|
-
const erc20Response = await provider.deployContract({
|
|
206
|
-
contract: compiledErc20,
|
|
207
|
-
});
|
|
208
|
-
erc20Address = erc20Response.address!;
|
|
209
|
-
erc20 = new Contract(compiledErc20.abi, erc20Address, provider);
|
|
210
|
-
expect(erc20Response.code).toBe('TRANSACTION_RECEIVED');
|
|
211
|
-
await provider.waitForTransaction(erc20Response.transaction_hash);
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
test('read balance of wallet', async () => {
|
|
215
|
-
const result = await erc20.balance_of(account.address);
|
|
216
|
-
const [res] = result;
|
|
217
|
-
expect(res).toStrictEqual(toBN(0));
|
|
218
|
-
expect(res).toStrictEqual(result.res);
|
|
219
|
-
});
|
|
220
|
-
|
|
221
|
-
test('change from provider to account', async () => {
|
|
222
|
-
expect(erc20.providerOrAccount instanceof Provider);
|
|
223
|
-
erc20.connect(account);
|
|
224
|
-
expect(erc20.providerOrAccount instanceof Account);
|
|
225
|
-
});
|
|
226
|
-
});
|
|
227
190
|
});
|
|
228
191
|
|
|
229
192
|
describe('class ContractFactory {}', () => {
|
|
230
193
|
let erc20Address: string;
|
|
231
194
|
beforeAll(async () => {
|
|
232
|
-
const {
|
|
195
|
+
const { transaction_hash, contract_address } = await provider.deployContract({
|
|
233
196
|
contract: compiledErc20,
|
|
234
197
|
});
|
|
235
|
-
expect(code).toBe('TRANSACTION_RECEIVED');
|
|
236
198
|
await provider.waitForTransaction(transaction_hash);
|
|
237
|
-
erc20Address =
|
|
199
|
+
erc20Address = contract_address;
|
|
238
200
|
});
|
|
239
201
|
test('deployment of new contract', async () => {
|
|
240
202
|
const factory = new ContractFactory(compiledErc20, provider);
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BlockNumber,
|
|
3
|
+
DeclareContractResponse,
|
|
4
|
+
DeployContractResponse,
|
|
5
|
+
GetBlockResponse,
|
|
6
|
+
stark,
|
|
7
|
+
} from '../src';
|
|
8
|
+
import { toBN } from '../src/utils/number';
|
|
9
|
+
import {
|
|
10
|
+
compiledErc20,
|
|
11
|
+
compiledOpenZeppelinAccount,
|
|
12
|
+
describeIfNotDevnet,
|
|
13
|
+
getTestProvider,
|
|
14
|
+
} from './fixtures';
|
|
15
|
+
|
|
16
|
+
const { compileCalldata } = stark;
|
|
17
|
+
|
|
18
|
+
const testProvider = getTestProvider();
|
|
19
|
+
|
|
20
|
+
describe('defaultProvider', () => {
|
|
21
|
+
let exampleTransactionHash: string;
|
|
22
|
+
let exampleContractAddress: string;
|
|
23
|
+
|
|
24
|
+
let exampleBlock: GetBlockResponse;
|
|
25
|
+
let exampleBlockNumber: BlockNumber;
|
|
26
|
+
let exampleBlockHash: string;
|
|
27
|
+
|
|
28
|
+
beforeAll(async () => {
|
|
29
|
+
const { transaction_hash, contract_address } = await testProvider.deployContract({
|
|
30
|
+
contract: compiledErc20,
|
|
31
|
+
});
|
|
32
|
+
await testProvider.waitForTransaction(transaction_hash);
|
|
33
|
+
exampleTransactionHash = transaction_hash;
|
|
34
|
+
exampleContractAddress = contract_address;
|
|
35
|
+
|
|
36
|
+
exampleBlock = await testProvider.getBlock('latest');
|
|
37
|
+
exampleBlockHash = exampleBlock.block_hash;
|
|
38
|
+
exampleBlockNumber = exampleBlock.block_number;
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
describe('endpoints', () => {
|
|
42
|
+
test(`getBlock(blockHash=undefined, blockNumber=${exampleBlockNumber})`, () => {
|
|
43
|
+
return expect(testProvider.getBlock(exampleBlockNumber)).resolves.not.toThrow();
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
test(`getBlock(blockHash=${exampleBlockHash}, blockNumber=undefined)`, () => {
|
|
47
|
+
return expect(testProvider.getBlock(exampleBlockHash)).resolves.not.toThrow();
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
test('getBlock(blockIdentifier=latest)', async () => {
|
|
51
|
+
expect(exampleBlock).not.toBeNull();
|
|
52
|
+
|
|
53
|
+
const { block_number, accepted_time } = exampleBlock;
|
|
54
|
+
|
|
55
|
+
expect(typeof block_number).toEqual('number');
|
|
56
|
+
|
|
57
|
+
return expect(typeof accepted_time).toEqual('number');
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
test('getBlock() -> { blockNumber }', async () => {
|
|
61
|
+
const block = await testProvider.getBlock();
|
|
62
|
+
return expect(block).toHaveProperty('block_number');
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
describe('getStorageAt', () => {
|
|
66
|
+
test('with "key" type of number', () => {
|
|
67
|
+
return expect(testProvider.getStorageAt(exampleContractAddress, 0)).resolves.not.toThrow();
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
test('"key" type of string', () => {
|
|
71
|
+
return expect(
|
|
72
|
+
testProvider.getStorageAt(exampleContractAddress, '0x0')
|
|
73
|
+
).resolves.not.toThrow();
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
test('with "key" type of BN', () => {
|
|
77
|
+
return expect(
|
|
78
|
+
testProvider.getStorageAt(exampleContractAddress, toBN('0x0'))
|
|
79
|
+
).resolves.not.toThrow();
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
test('getTransaction() - successful transaction', async () => {
|
|
84
|
+
const transaction = await testProvider.getTransaction(exampleTransactionHash);
|
|
85
|
+
|
|
86
|
+
expect(transaction).toHaveProperty('transaction_hash');
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
test('getTransactionReceipt() - successful transaction', async () => {
|
|
90
|
+
const transactionReceipt = await testProvider.getTransactionReceipt(exampleTransactionHash);
|
|
91
|
+
|
|
92
|
+
return expect(transactionReceipt).toHaveProperty('actual_fee');
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
test('callContract()', () => {
|
|
96
|
+
return expect(
|
|
97
|
+
testProvider.callContract({
|
|
98
|
+
contractAddress: exampleContractAddress,
|
|
99
|
+
entrypoint: 'balance_of',
|
|
100
|
+
calldata: compileCalldata({
|
|
101
|
+
user: '0x9ff64f4ab0e1fe88df4465ade98d1ea99d5732761c39279b8e1374fa943e9b',
|
|
102
|
+
}),
|
|
103
|
+
})
|
|
104
|
+
).resolves.not.toThrow();
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
test('callContract() - gateway error', async () => {
|
|
108
|
+
return expect(
|
|
109
|
+
testProvider.callContract({
|
|
110
|
+
contractAddress: exampleContractAddress,
|
|
111
|
+
entrypoint: 'non_existent_entrypoint',
|
|
112
|
+
calldata: compileCalldata({
|
|
113
|
+
user: '0xdeadbeef',
|
|
114
|
+
}),
|
|
115
|
+
})
|
|
116
|
+
).rejects.toThrowError();
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
describe('addTransaction()', () => {
|
|
121
|
+
test('declareContract()', async () => {
|
|
122
|
+
const response = await testProvider.declareContract({
|
|
123
|
+
contract: compiledErc20,
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
expect(response.transaction_hash).toBeDefined();
|
|
127
|
+
expect(response.class_hash).toBeDefined();
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
test('deployContract()', async () => {
|
|
131
|
+
const response = await testProvider.deployContract({
|
|
132
|
+
contract: compiledOpenZeppelinAccount,
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
expect(response.transaction_hash).toBeDefined();
|
|
136
|
+
expect(response.contract_address).toBeDefined();
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
describeIfNotDevnet('Provider', () => {
|
|
141
|
+
const provider = getTestProvider();
|
|
142
|
+
describe(`Provider methods`, () => {
|
|
143
|
+
describe('getBlock', () => {
|
|
144
|
+
test('pending', async () => {
|
|
145
|
+
const latestBlock = await provider.getBlock();
|
|
146
|
+
expect(latestBlock).toHaveProperty('block_hash');
|
|
147
|
+
expect(latestBlock).toHaveProperty('parent_hash');
|
|
148
|
+
expect(latestBlock).toHaveProperty('block_number');
|
|
149
|
+
expect(latestBlock).toHaveProperty('status');
|
|
150
|
+
expect(latestBlock).toHaveProperty('sequencer');
|
|
151
|
+
expect(latestBlock).toHaveProperty('new_root');
|
|
152
|
+
expect(latestBlock).toHaveProperty('old_root');
|
|
153
|
+
expect(latestBlock).toHaveProperty('accepted_time');
|
|
154
|
+
expect(latestBlock).toHaveProperty('gas_price');
|
|
155
|
+
expect(latestBlock).toHaveProperty('transactions');
|
|
156
|
+
expect(Array.isArray(latestBlock.transactions)).toBe(true);
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
test('Block Hash 0x8a30a1212d142cb0053fe9921e1dbf64f651d328565bd2e7ac24059c270f43', async () => {
|
|
160
|
+
const block = await provider.getBlock(
|
|
161
|
+
'0x8a30a1212d142cb0053fe9921e1dbf64f651d328565bd2e7ac24059c270f43'
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
expect(block).toHaveProperty('block_hash');
|
|
165
|
+
expect(block).toHaveProperty('parent_hash');
|
|
166
|
+
expect(block).toHaveProperty('block_number');
|
|
167
|
+
expect(block).toHaveProperty('status');
|
|
168
|
+
expect(block).toHaveProperty('sequencer');
|
|
169
|
+
expect(block).toHaveProperty('new_root');
|
|
170
|
+
expect(block).toHaveProperty('old_root');
|
|
171
|
+
expect(block).toHaveProperty('accepted_time');
|
|
172
|
+
expect(block).toHaveProperty('gas_price');
|
|
173
|
+
expect(block).toHaveProperty('transactions');
|
|
174
|
+
expect(Array.isArray(block.transactions)).toBe(true);
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
test('Block Number 102634', async () => {
|
|
178
|
+
const block = await provider.getBlock(102634);
|
|
179
|
+
expect(block).toHaveProperty('block_hash');
|
|
180
|
+
expect(block).toHaveProperty('parent_hash');
|
|
181
|
+
expect(block).toHaveProperty('block_number');
|
|
182
|
+
expect(block).toHaveProperty('status');
|
|
183
|
+
expect(block).toHaveProperty('sequencer');
|
|
184
|
+
expect(block).toHaveProperty('new_root');
|
|
185
|
+
expect(block).toHaveProperty('old_root');
|
|
186
|
+
expect(block).toHaveProperty('accepted_time');
|
|
187
|
+
expect(block).toHaveProperty('gas_price');
|
|
188
|
+
expect(block).toHaveProperty('transactions');
|
|
189
|
+
expect(Array.isArray(block.transactions)).toBe(true);
|
|
190
|
+
});
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
describe('getStorageAt', () => {
|
|
194
|
+
test('pending', async () => {
|
|
195
|
+
const storage = await provider.getStorageAt(
|
|
196
|
+
'0x01d1f307c073bb786a66e6e042ec2a9bdc385a3373bb3738d95b966d5ce56166',
|
|
197
|
+
0
|
|
198
|
+
);
|
|
199
|
+
expect(typeof storage).toBe('string');
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
test('Block Hash 0x7104702055c2a5773a870ceada9552ec659d69c18053b14078983f07527dea8', async () => {
|
|
203
|
+
const storage = await provider.getStorageAt(
|
|
204
|
+
'0x01d1f307c073bb786a66e6e042ec2a9bdc385a3373bb3738d95b966d5ce56166',
|
|
205
|
+
0,
|
|
206
|
+
'0x7225762c7ff5e7e5f0867f0a8e73594df4f44f05a65375339a76398e8ae3e64'
|
|
207
|
+
);
|
|
208
|
+
expect(typeof storage).toBe('string');
|
|
209
|
+
});
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
describe('getTransaction', () => {
|
|
213
|
+
test('Deploy Transaction Hash 0x37013e1cb9c133e6fe51b4b371b76b317a480f56d80576730754c1662582348', async () => {
|
|
214
|
+
const transaction = await provider.getTransaction(
|
|
215
|
+
'0x37013e1cb9c133e6fe51b4b371b76b317a480f56d80576730754c1662582348'
|
|
216
|
+
);
|
|
217
|
+
|
|
218
|
+
expect(transaction.transaction_hash).toBeTruthy();
|
|
219
|
+
expect(transaction.contract_address).toBeTruthy();
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
test('Invoke Transaction Hash 0x2a56c636f45761c99a67ecdf0f185a6d5fe5239924ed9a4886fddbfaf3227b', async () => {
|
|
223
|
+
const transaction = await provider.getTransaction(
|
|
224
|
+
'0x2a56c636f45761c99a67ecdf0f185a6d5fe5239924ed9a4886fddbfaf3227b'
|
|
225
|
+
);
|
|
226
|
+
|
|
227
|
+
expect(transaction.transaction_hash).toBeTruthy();
|
|
228
|
+
expect(transaction.contract_address).toBeTruthy();
|
|
229
|
+
expect(Array.isArray(transaction.calldata)).toBe(true);
|
|
230
|
+
expect(transaction.entry_point_selector).toBeTruthy();
|
|
231
|
+
expect(Array.isArray(transaction.signature)).toBe(true);
|
|
232
|
+
expect(transaction.max_fee).toBeTruthy();
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
test('Declare Transaction Hash 0x79b130f2e808db6ab4b83f0182f016a128d73752b849e5b0221c2b3a35a87ea', async () => {
|
|
236
|
+
const transaction = await provider.getTransaction(
|
|
237
|
+
'0x79b130f2e808db6ab4b83f0182f016a128d73752b849e5b0221c2b3a35a87ea'
|
|
238
|
+
);
|
|
239
|
+
|
|
240
|
+
expect(transaction.max_fee).toBeTruthy();
|
|
241
|
+
expect(transaction.transaction_hash).toBeTruthy();
|
|
242
|
+
expect(transaction).toHaveProperty('nonce');
|
|
243
|
+
expect(transaction).toHaveProperty('sender_address');
|
|
244
|
+
expect(transaction).toHaveProperty('version');
|
|
245
|
+
});
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
describe('getTransactionReceipt', () => {
|
|
249
|
+
test('Transaction Hash 0x37013e1cb9c133e6fe51b4b371b76b317a480f56d80576730754c1662582348', async () => {
|
|
250
|
+
const receipt = await provider.getTransactionReceipt(
|
|
251
|
+
'0x37013e1cb9c133e6fe51b4b371b76b317a480f56d80576730754c1662582348'
|
|
252
|
+
);
|
|
253
|
+
|
|
254
|
+
expect(receipt).toHaveProperty('transaction_hash');
|
|
255
|
+
expect(receipt).toHaveProperty('status');
|
|
256
|
+
expect(receipt).toHaveProperty('status_data');
|
|
257
|
+
expect(receipt).toHaveProperty('messages_sent');
|
|
258
|
+
expect(receipt).toHaveProperty('l1_origin_message');
|
|
259
|
+
expect(receipt).toHaveProperty('events');
|
|
260
|
+
});
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
describe('Contract methods', () => {
|
|
264
|
+
let contractAddress: string;
|
|
265
|
+
let deployResponse: DeployContractResponse;
|
|
266
|
+
let declareResponse: DeclareContractResponse;
|
|
267
|
+
|
|
268
|
+
beforeAll(async () => {
|
|
269
|
+
deployResponse = await provider.deployContract({ contract: compiledErc20 });
|
|
270
|
+
contractAddress = deployResponse.contract_address;
|
|
271
|
+
declareResponse = await provider.declareContract({ contract: compiledErc20 });
|
|
272
|
+
await Promise.all([
|
|
273
|
+
provider.waitForTransaction(deployResponse.transaction_hash),
|
|
274
|
+
provider.waitForTransaction(declareResponse.transaction_hash),
|
|
275
|
+
]);
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
describe('deployContract', () => {
|
|
279
|
+
test('response', () => {
|
|
280
|
+
expect(deployResponse.contract_address).toBeTruthy();
|
|
281
|
+
expect(deployResponse.transaction_hash).toBeTruthy();
|
|
282
|
+
});
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
describe('declareContract', () => {
|
|
286
|
+
test('response', async () => {
|
|
287
|
+
expect(declareResponse.class_hash).toBeTruthy();
|
|
288
|
+
expect(declareResponse.transaction_hash).toBeTruthy();
|
|
289
|
+
});
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
describe('getClassAt', () => {
|
|
293
|
+
test('response', async () => {
|
|
294
|
+
const classResponse = await provider.getClassAt(contractAddress);
|
|
295
|
+
|
|
296
|
+
expect(classResponse).toHaveProperty('program');
|
|
297
|
+
expect(classResponse).toHaveProperty('entry_points_by_type');
|
|
298
|
+
});
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
describe('callContract', () => {
|
|
302
|
+
test('result', () => {
|
|
303
|
+
return expect(
|
|
304
|
+
provider
|
|
305
|
+
.callContract({
|
|
306
|
+
contractAddress: deployResponse.contract_address,
|
|
307
|
+
entrypoint: 'balance_of',
|
|
308
|
+
calldata: compileCalldata({
|
|
309
|
+
user: '0x9ff64f4ab0e1fe88df4465ade98d1ea99d5732761c39279b8e1374fa943e9b',
|
|
310
|
+
}),
|
|
311
|
+
})
|
|
312
|
+
.then((res) => {
|
|
313
|
+
expect(Array.isArray(res.result)).toBe(true);
|
|
314
|
+
})
|
|
315
|
+
).resolves.not.toThrow();
|
|
316
|
+
});
|
|
317
|
+
});
|
|
318
|
+
});
|
|
319
|
+
});
|
|
320
|
+
});
|
|
321
|
+
});
|