starknet 3.18.0 → 3.19.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 +65 -0
- package/README.md +1 -0
- package/__mocks__/typedDataStructArrayExample.json +44 -0
- 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__/rpcProvider.test.ts +17 -0
- package/__tests__/sequencerProvider.test.ts +45 -0
- package/__tests__/utils/typedData.test.ts +24 -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 -410
- 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 +443 -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/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/dist/utils/typedData/index.js +14 -0
- package/index.js +42 -75
- package/package.json +1 -1
- package/provider/default.d.ts +21 -175
- package/provider/default.js +139 -703
- 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 +443 -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 -394
- package/src/provider/index.ts +2 -0
- package/src/provider/interface.ts +68 -63
- package/src/provider/rpc.ts +300 -0
- package/src/provider/sequencer.ts +384 -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/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/src/utils/typedData/index.ts +18 -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/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 -157
- 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,68 @@
|
|
|
1
|
+
# [3.19.0](https://github.com/0xs34n/starknet.js/compare/v3.18.2...v3.19.0) (2022-07-25)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
- account tests ([cc3f362](https://github.com/0xs34n/starknet.js/commit/cc3f362fffc157cb97e0fa2b8ff3a3db7dcf5985))
|
|
6
|
+
- add invoke warning ([34db683](https://github.com/0xs34n/starknet.js/commit/34db683267b639adbd37eb097573eb7210cb4a58))
|
|
7
|
+
- call contract latest block ([1476461](https://github.com/0xs34n/starknet.js/commit/1476461aeff6885b5185f45c5f8633f8c60cbfca))
|
|
8
|
+
- ci ([808e1f7](https://github.com/0xs34n/starknet.js/commit/808e1f7a837e014d3c3781973b434df646c207b4))
|
|
9
|
+
- ci ([6337feb](https://github.com/0xs34n/starknet.js/commit/6337febc9f6f6359f70d66be039779371f3186ff))
|
|
10
|
+
- contract tests ([ffb6a12](https://github.com/0xs34n/starknet.js/commit/ffb6a12dec4c27f9b570fcc2016fb3c17f5dcfb4))
|
|
11
|
+
- default provider tests ([2fac438](https://github.com/0xs34n/starknet.js/commit/2fac43876375a3d83818e152f4be5c3f219e8aff))
|
|
12
|
+
- invoke response type ([bdeb96b](https://github.com/0xs34n/starknet.js/commit/bdeb96b896c96f7f7778fd38e697bf368f2a8510))
|
|
13
|
+
- no secrets in matrix ([5ff7a26](https://github.com/0xs34n/starknet.js/commit/5ff7a2610c1c3f67ecb0a2b8d32e7c8c61017354))
|
|
14
|
+
- nonce issue on test runs ([bed6fbf](https://github.com/0xs34n/starknet.js/commit/bed6fbf74b6446e18ea63444ddefaa782a7ffdf4))
|
|
15
|
+
- pending getBlock test ([a9ea023](https://github.com/0xs34n/starknet.js/commit/a9ea023249c33369ed04b3f548bf98947240ff9e))
|
|
16
|
+
- provider ([32f9072](https://github.com/0xs34n/starknet.js/commit/32f90724894eccd1b0154842180da38bcf6411fe))
|
|
17
|
+
- provider tests ([79eb5ba](https://github.com/0xs34n/starknet.js/commit/79eb5bac4c03b64b6f3a2f3b59a1fea7bb930ce8))
|
|
18
|
+
- provider tests ([255fd3c](https://github.com/0xs34n/starknet.js/commit/255fd3cb68f0edc7794f77623389f94ac341880a))
|
|
19
|
+
- remove account test from contract tests ([d444e7f](https://github.com/0xs34n/starknet.js/commit/d444e7fb5f55a7a384dcc43a9ea0f1d09438364a))
|
|
20
|
+
- remove comment ([591caf6](https://github.com/0xs34n/starknet.js/commit/591caf6e7983ecf009a95ab3f9e1b86335fe1a23))
|
|
21
|
+
- remove hardcoded url ([c8f3377](https://github.com/0xs34n/starknet.js/commit/c8f3377d52f605dd03ab20879a5c7fd53aafe819))
|
|
22
|
+
- remove test only ([5add341](https://github.com/0xs34n/starknet.js/commit/5add341257f8d6b355a367e977b125f9642f7630))
|
|
23
|
+
- rename gateway to sequencer ([b7291e6](https://github.com/0xs34n/starknet.js/commit/b7291e654732bd5f57b2d477b20a5467dfc9854b))
|
|
24
|
+
- rename rpc provider ([fee4fb3](https://github.com/0xs34n/starknet.js/commit/fee4fb3e36e9d824f0956174a9278f6131b3ba3e))
|
|
25
|
+
- revert default block to pending ([28beff7](https://github.com/0xs34n/starknet.js/commit/28beff76107f762478e70974389eb75202a65d42))
|
|
26
|
+
- rpc provider account tests ([b2fc530](https://github.com/0xs34n/starknet.js/commit/b2fc53004a1e52149b3fa4e7357c3ade1d01cd4a))
|
|
27
|
+
- rpc provider tests ([12db930](https://github.com/0xs34n/starknet.js/commit/12db930b1babf3e3de035426c8c449bfb448951c))
|
|
28
|
+
- rpc provider waitForTransaction ([9e708ba](https://github.com/0xs34n/starknet.js/commit/9e708ba72ea350ae4866e5cff9519a89201b5b01))
|
|
29
|
+
- run only devnet on pr ([613084b](https://github.com/0xs34n/starknet.js/commit/613084b32f93540e5f11938196d7b2c003f12bbf))
|
|
30
|
+
- seperate types and fix fees ([577a836](https://github.com/0xs34n/starknet.js/commit/577a836b48a4567d63f0138163d016422256d221))
|
|
31
|
+
- set rpc url in pr workflow ([89ec3c1](https://github.com/0xs34n/starknet.js/commit/89ec3c1edfd6947404d009420305d7bb210c6cd3))
|
|
32
|
+
- test account ([ac8210a](https://github.com/0xs34n/starknet.js/commit/ac8210a6bbb159a17ab548a12f7a20823e55814a))
|
|
33
|
+
- tests should wait for build ([af8c5c7](https://github.com/0xs34n/starknet.js/commit/af8c5c779370e170de4785902e1e9ac282f2bfec))
|
|
34
|
+
- update jsdocs ([2c08e5d](https://github.com/0xs34n/starknet.js/commit/2c08e5d8fe80469ba41222767193823b3d516536))
|
|
35
|
+
- use rpc conditionally ([7023068](https://github.com/0xs34n/starknet.js/commit/70230682343b682df50da21cb9e7a7f54490091c))
|
|
36
|
+
- waitForTransaction ([4f0c00b](https://github.com/0xs34n/starknet.js/commit/4f0c00b568a174db51ecef918d8a8878254daba5))
|
|
37
|
+
- www/docs/API/contract.md ([3ca4a51](https://github.com/0xs34n/starknet.js/commit/3ca4a513950f4aa27ac447835fcefcebbece083b))
|
|
38
|
+
- www/docs/API/provider.md ([d73e826](https://github.com/0xs34n/starknet.js/commit/d73e8264527a5af21e1d8e7a7c1f3aa8b8c92fb8))
|
|
39
|
+
|
|
40
|
+
### Features
|
|
41
|
+
|
|
42
|
+
- adapt abstract provider interface to RPC provider ([b217b3b](https://github.com/0xs34n/starknet.js/commit/b217b3bd1e40c60427636ccad03583e901f6ba58))
|
|
43
|
+
- add account rpc tests ([fc3b484](https://github.com/0xs34n/starknet.js/commit/fc3b4846486e63f2ff5eaba78844235091f2d49e))
|
|
44
|
+
- add gateway provider class ([dad1eea](https://github.com/0xs34n/starknet.js/commit/dad1eea9caafc71c940262ee13dd75817996abfd))
|
|
45
|
+
- add provider utils ([4df4ae7](https://github.com/0xs34n/starknet.js/commit/4df4ae7e8b8111669e2bc20e30c2c89af9c50a4f))
|
|
46
|
+
- add rpc provider ([315bb74](https://github.com/0xs34n/starknet.js/commit/315bb747f26ba19556841a326484a7dbfa1a2857))
|
|
47
|
+
- change estimate fee response on rpc provider ([942f4f2](https://github.com/0xs34n/starknet.js/commit/942f4f2508fab697e796ee9f691341b86ccd34be))
|
|
48
|
+
- change provider keys to snake case ([2ee4b0b](https://github.com/0xs34n/starknet.js/commit/2ee4b0bf0892a3bd54e6d188990f979298814551))
|
|
49
|
+
- getStorageAt block param ([d89bf30](https://github.com/0xs34n/starknet.js/commit/d89bf307796e69627ffd91ebd97c787e4a7a77e7))
|
|
50
|
+
- implement new interface on account class ([b202f37](https://github.com/0xs34n/starknet.js/commit/b202f37ab72fd310a8c99b28863f38b8d142d2a7))
|
|
51
|
+
- implement new interface on contract class ([e942a9d](https://github.com/0xs34n/starknet.js/commit/e942a9d88479d88b82a3dbc05ec2f60ab9ad1f19))
|
|
52
|
+
- use shared describe block for providers ([b525a60](https://github.com/0xs34n/starknet.js/commit/b525a60eb77647962f4509bb02f64bb66071c9c2))
|
|
53
|
+
|
|
54
|
+
## [3.18.2](https://github.com/0xs34n/starknet.js/compare/v3.18.1...v3.18.2) (2022-07-25)
|
|
55
|
+
|
|
56
|
+
### Bug Fixes
|
|
57
|
+
|
|
58
|
+
- release to [@next](https://github.com/next) ([12e37ce](https://github.com/0xs34n/starknet.js/commit/12e37cef78bc0e9d97d25c44d0dcf576969cb182))
|
|
59
|
+
|
|
60
|
+
## [3.18.1](https://github.com/0xs34n/starknet.js/compare/v3.18.0...v3.18.1) (2022-07-23)
|
|
61
|
+
|
|
62
|
+
### Bug Fixes
|
|
63
|
+
|
|
64
|
+
- struct array hashing ([e1f82df](https://github.com/0xs34n/starknet.js/commit/e1f82dfd575be4c84b291c33f8169bf367493603))
|
|
65
|
+
|
|
1
66
|
# [3.18.0](https://github.com/0xs34n/starknet.js/compare/v3.17.0...v3.18.0) (2022-07-23)
|
|
2
67
|
|
|
3
68
|
### Features
|
package/README.md
CHANGED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"types": {
|
|
3
|
+
"StarkNetDomain": [
|
|
4
|
+
{ "name": "name", "type": "felt" },
|
|
5
|
+
{ "name": "version", "type": "felt" },
|
|
6
|
+
{ "name": "chainId", "type": "felt" }
|
|
7
|
+
],
|
|
8
|
+
"Person": [
|
|
9
|
+
{ "name": "name", "type": "felt" },
|
|
10
|
+
{ "name": "wallet", "type": "felt" }
|
|
11
|
+
],
|
|
12
|
+
"Post": [
|
|
13
|
+
{ "name": "title", "type": "felt" },
|
|
14
|
+
{ "name": "content", "type": "felt" }
|
|
15
|
+
],
|
|
16
|
+
"Mail": [
|
|
17
|
+
{ "name": "from", "type": "Person" },
|
|
18
|
+
{ "name": "to", "type": "Person" },
|
|
19
|
+
{ "name": "posts_len", "type": "felt" },
|
|
20
|
+
{ "name": "posts", "type": "Post*" }
|
|
21
|
+
]
|
|
22
|
+
},
|
|
23
|
+
"primaryType": "Mail",
|
|
24
|
+
"domain": {
|
|
25
|
+
"name": "StarkNet Mail",
|
|
26
|
+
"version": "1",
|
|
27
|
+
"chainId": 1
|
|
28
|
+
},
|
|
29
|
+
"message": {
|
|
30
|
+
"from": {
|
|
31
|
+
"name": "Cow",
|
|
32
|
+
"wallet": "0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826"
|
|
33
|
+
},
|
|
34
|
+
"to": {
|
|
35
|
+
"name": "Bob",
|
|
36
|
+
"wallet": "0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB"
|
|
37
|
+
},
|
|
38
|
+
"posts_len": 2,
|
|
39
|
+
"posts": [
|
|
40
|
+
{ "title": "Greeting", "content": "Hello, Bob!" },
|
|
41
|
+
{ "title": "Farewell", "content": "Goodbye, Bob!" }
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -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);
|