starknet 4.11.0 → 4.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.
- package/.eslintrc +1 -0
- package/CHANGELOG.md +25 -0
- package/__tests__/account.test.ts +36 -0
- package/__tests__/defaultProvider.test.ts +15 -17
- package/__tests__/fixtures.ts +2 -0
- package/dist/index.d.ts +2683 -24
- package/dist/index.global.js +22994 -0
- package/dist/index.global.js.map +1 -0
- package/dist/index.js +4713 -53
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +4655 -0
- package/dist/index.mjs.map +1 -0
- package/index.d.ts +2683 -24
- package/index.global.js +22994 -0
- package/index.global.js.map +1 -0
- package/index.js +4713 -53
- package/index.js.map +1 -0
- package/index.mjs +4655 -0
- package/index.mjs.map +1 -0
- package/package.json +8 -2
- package/src/account/default.ts +43 -8
- package/src/account/interface.ts +25 -2
- package/src/constants.ts +0 -1
- package/src/provider/default.ts +5 -2
- package/src/provider/interface.ts +3 -1
- package/src/provider/rpc.ts +8 -4
- package/src/provider/sequencer.ts +5 -2
- package/src/types/lib.ts +1 -1
- package/src/types/provider.ts +5 -0
- package/src/utils/ellipticCurve.ts +3 -1
- package/src/utils/fetchPonyfill.ts +3 -2
- package/src/utils/hash.ts +3 -2
- package/src/utils/number.ts +2 -2
- package/tsup.config.ts +10 -0
- package/__tests__/udc.test.ts +0 -41
- package/account/default.d.ts +0 -30
- package/account/default.js +0 -526
- package/account/index.d.ts +0 -2
- package/account/index.js +0 -18
- package/account/interface.d.ts +0 -161
- package/account/interface.js +0 -27
- package/constants.d.ts +0 -36
- package/constants.js +0 -2067
- package/contract/contractFactory.d.ts +0 -31
- package/contract/contractFactory.js +0 -102
- package/contract/default.d.ts +0 -108
- package/contract/default.js +0 -640
- package/contract/index.d.ts +0 -3
- package/contract/index.js +0 -19
- package/contract/interface.d.ts +0 -80
- package/contract/interface.js +0 -9
- package/dist/account/default.d.ts +0 -30
- package/dist/account/default.js +0 -526
- package/dist/account/index.d.ts +0 -2
- package/dist/account/index.js +0 -18
- package/dist/account/interface.d.ts +0 -161
- package/dist/account/interface.js +0 -27
- package/dist/constants.d.ts +0 -36
- package/dist/constants.js +0 -2067
- package/dist/contract/contractFactory.d.ts +0 -31
- package/dist/contract/contractFactory.js +0 -102
- package/dist/contract/default.d.ts +0 -108
- package/dist/contract/default.js +0 -640
- package/dist/contract/index.d.ts +0 -3
- package/dist/contract/index.js +0 -19
- package/dist/contract/interface.d.ts +0 -80
- package/dist/contract/interface.js +0 -9
- package/dist/provider/default.d.ts +0 -37
- package/dist/provider/default.js +0 -207
- package/dist/provider/errors.d.ts +0 -9
- package/dist/provider/errors.js +0 -40
- package/dist/provider/index.d.ts +0 -7
- package/dist/provider/index.js +0 -24
- package/dist/provider/interface.d.ts +0 -203
- package/dist/provider/interface.js +0 -9
- package/dist/provider/rpc.d.ts +0 -85
- package/dist/provider/rpc.js +0 -598
- package/dist/provider/sequencer.d.ts +0 -79
- package/dist/provider/sequencer.js +0 -575
- package/dist/provider/utils.d.ts +0 -30
- package/dist/provider/utils.js +0 -84
- package/dist/signer/default.d.ts +0 -13
- package/dist/signer/default.js +0 -102
- package/dist/signer/index.d.ts +0 -2
- package/dist/signer/index.js +0 -18
- package/dist/signer/interface.d.ts +0 -60
- package/dist/signer/interface.js +0 -9
- package/dist/types/account.d.ts +0 -11
- package/dist/types/account.js +0 -2
- package/dist/types/api/index.d.ts +0 -10
- package/dist/types/api/index.js +0 -18
- package/dist/types/api/openrpc.d.ts +0 -572
- package/dist/types/api/openrpc.js +0 -45
- package/dist/types/api/rpc.d.ts +0 -43
- package/dist/types/api/rpc.js +0 -2
- package/dist/types/api/sequencer.d.ts +0 -320
- package/dist/types/api/sequencer.js +0 -2
- package/dist/types/contract.d.ts +0 -5
- package/dist/types/contract.js +0 -2
- package/dist/types/index.d.ts +0 -7
- package/dist/types/index.js +0 -35
- package/dist/types/lib.d.ts +0 -120
- package/dist/types/lib.js +0 -8
- package/dist/types/provider.d.ts +0 -99
- package/dist/types/provider.js +0 -2
- package/dist/types/signer.d.ts +0 -19
- package/dist/types/signer.js +0 -2
- package/dist/utils/address.d.ts +0 -5
- package/dist/utils/address.js +0 -41
- package/dist/utils/ellipticCurve.d.ts +0 -29
- package/dist/utils/ellipticCurve.js +0 -132
- package/dist/utils/encode.d.ts +0 -15
- package/dist/utils/encode.js +0 -96
- package/dist/utils/fetchPonyfill.d.ts +0 -2
- package/dist/utils/fetchPonyfill.js +0 -6
- package/dist/utils/hash.d.ts +0 -37
- package/dist/utils/hash.js +0 -162
- package/dist/utils/json.d.ts +0 -16
- package/dist/utils/json.js +0 -19
- package/dist/utils/merkle.d.ts +0 -10
- package/dist/utils/merkle.js +0 -89
- package/dist/utils/number.d.ts +0 -16
- package/dist/utils/number.js +0 -112
- package/dist/utils/provider.d.ts +0 -4
- package/dist/utils/provider.js +0 -38
- package/dist/utils/responseParser/index.d.ts +0 -11
- package/dist/utils/responseParser/index.js +0 -9
- package/dist/utils/responseParser/rpc.d.ts +0 -20
- package/dist/utils/responseParser/rpc.js +0 -44
- package/dist/utils/responseParser/sequencer.d.ts +0 -17
- package/dist/utils/responseParser/sequencer.js +0 -99
- package/dist/utils/shortString.d.ts +0 -4
- package/dist/utils/shortString.js +0 -26
- package/dist/utils/stark.d.ts +0 -16
- package/dist/utils/stark.js +0 -91
- package/dist/utils/transaction.d.ts +0 -20
- package/dist/utils/transaction.js +0 -79
- package/dist/utils/typedData/index.d.ts +0 -72
- package/dist/utils/typedData/index.js +0 -239
- package/dist/utils/typedData/types.d.ts +0 -32
- package/dist/utils/typedData/types.js +0 -2
- package/dist/utils/typedData/utils.d.ts +0 -8
- package/dist/utils/typedData/utils.js +0 -16
- package/dist/utils/uint256.d.ts +0 -11
- package/dist/utils/uint256.js +0 -28
- package/dist/utils/url.d.ts +0 -7
- package/dist/utils/url.js +0 -49
- package/provider/default.d.ts +0 -37
- package/provider/default.js +0 -207
- package/provider/errors.d.ts +0 -9
- package/provider/errors.js +0 -40
- package/provider/index.d.ts +0 -7
- package/provider/index.js +0 -24
- package/provider/interface.d.ts +0 -203
- package/provider/interface.js +0 -9
- package/provider/rpc.d.ts +0 -85
- package/provider/rpc.js +0 -598
- package/provider/sequencer.d.ts +0 -79
- package/provider/sequencer.js +0 -575
- package/provider/utils.d.ts +0 -30
- package/provider/utils.js +0 -84
- package/signer/default.d.ts +0 -13
- package/signer/default.js +0 -102
- package/signer/index.d.ts +0 -2
- package/signer/index.js +0 -18
- package/signer/interface.d.ts +0 -60
- package/signer/interface.js +0 -9
- package/types/account.d.ts +0 -11
- package/types/account.js +0 -2
- package/types/api/index.d.ts +0 -10
- package/types/api/index.js +0 -18
- package/types/api/openrpc.d.ts +0 -572
- package/types/api/openrpc.js +0 -45
- package/types/api/rpc.d.ts +0 -43
- package/types/api/rpc.js +0 -2
- package/types/api/sequencer.d.ts +0 -320
- package/types/api/sequencer.js +0 -2
- package/types/contract.d.ts +0 -5
- package/types/contract.js +0 -2
- package/types/index.d.ts +0 -7
- package/types/index.js +0 -35
- package/types/lib.d.ts +0 -120
- package/types/lib.js +0 -8
- package/types/provider.d.ts +0 -99
- package/types/provider.js +0 -2
- package/types/signer.d.ts +0 -19
- package/types/signer.js +0 -2
- package/utils/address.d.ts +0 -5
- package/utils/address.js +0 -41
- package/utils/ellipticCurve.d.ts +0 -29
- package/utils/ellipticCurve.js +0 -132
- package/utils/encode.d.ts +0 -15
- package/utils/encode.js +0 -96
- package/utils/fetchPonyfill.d.ts +0 -2
- package/utils/fetchPonyfill.js +0 -6
- package/utils/hash.d.ts +0 -37
- package/utils/hash.js +0 -162
- package/utils/json.d.ts +0 -16
- package/utils/json.js +0 -19
- package/utils/merkle.d.ts +0 -10
- package/utils/merkle.js +0 -89
- package/utils/number.d.ts +0 -16
- package/utils/number.js +0 -112
- package/utils/provider.d.ts +0 -4
- package/utils/provider.js +0 -38
- package/utils/responseParser/index.d.ts +0 -11
- package/utils/responseParser/index.js +0 -9
- package/utils/responseParser/rpc.d.ts +0 -20
- package/utils/responseParser/rpc.js +0 -44
- package/utils/responseParser/sequencer.d.ts +0 -17
- package/utils/responseParser/sequencer.js +0 -99
- package/utils/shortString.d.ts +0 -4
- package/utils/shortString.js +0 -26
- package/utils/stark.d.ts +0 -16
- package/utils/stark.js +0 -91
- package/utils/transaction.d.ts +0 -20
- package/utils/transaction.js +0 -79
- package/utils/typedData/index.d.ts +0 -72
- package/utils/typedData/index.js +0 -239
- package/utils/typedData/types.d.ts +0 -32
- package/utils/typedData/types.js +0 -2
- package/utils/typedData/utils.d.ts +0 -8
- package/utils/typedData/utils.js +0 -16
- package/utils/uint256.d.ts +0 -11
- package/utils/uint256.js +0 -28
- package/utils/url.d.ts +0 -7
- package/utils/url.js +0 -49
package/.eslintrc
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,28 @@
|
|
|
1
|
+
# [4.13.0](https://github.com/0xs34n/starknet.js/compare/v4.12.0...v4.13.0) (2022-11-22)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
- add estimateDeployFee ([3bc11be](https://github.com/0xs34n/starknet.js/commit/3bc11bef0d744303a1288eb997fbfca32c7523ab))
|
|
6
|
+
- adjust fetch parameter types ([dfe876a](https://github.com/0xs34n/starknet.js/commit/dfe876ad9fd59a4351671df5fc0705b3f980ce75))
|
|
7
|
+
- anotate deprecate all providers deployContract ([65eed1f](https://github.com/0xs34n/starknet.js/commit/65eed1f671b41393b3ae33ae1aaa7a9ae0fbc013))
|
|
8
|
+
- restore rpc node url to provided one ([2e1d87a](https://github.com/0xs34n/starknet.js/commit/2e1d87a6d9fc9a1fe9b493ffd8153eb2342ffdfc))
|
|
9
|
+
- transaction v1 getInvokeEstimateFee ([cb4ede3](https://github.com/0xs34n/starknet.js/commit/cb4ede3b5b586ebf69768d4e4a8b36c739f6715f))
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
- update devnet ([0dbe9f7](https://github.com/0xs34n/starknet.js/commit/0dbe9f72fdad96250850599ed90495a5c2975f60))
|
|
14
|
+
|
|
15
|
+
# [4.12.0](https://github.com/0xs34n/starknet.js/compare/v4.11.0...v4.12.0) (2022-11-17)
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
- **tests:** refactor udc tests ([01a6eef](https://github.com/0xs34n/starknet.js/commit/01a6eef11b2f32e05d2aea4ab185536e3fdb1a71))
|
|
20
|
+
- use method name similar to gateway endpoint ([79641b3](https://github.com/0xs34n/starknet.js/commit/79641b3076412d71fa4e5ccbdb018c4f3ecab938))
|
|
21
|
+
|
|
22
|
+
### Features
|
|
23
|
+
|
|
24
|
+
- create getClass RPC alias ([1003534](https://github.com/0xs34n/starknet.js/commit/10035341dd26e23b59d3dd764936a7d8eaa3f3b0))
|
|
25
|
+
|
|
1
26
|
# [4.11.0](https://github.com/0xs34n/starknet.js/compare/v4.10.0...v4.11.0) (2022-11-14)
|
|
2
27
|
|
|
3
28
|
### Bug Fixes
|
|
@@ -4,9 +4,12 @@ import typedDataExample from '../__mocks__/typedDataExample.json';
|
|
|
4
4
|
import { Account, Contract, Provider, number, stark } from '../src';
|
|
5
5
|
import { feeTransactionVersion } from '../src/utils/hash';
|
|
6
6
|
import { toBN } from '../src/utils/number';
|
|
7
|
+
import { encodeShortString } from '../src/utils/shortString';
|
|
8
|
+
import { randomAddress } from '../src/utils/stark';
|
|
7
9
|
import {
|
|
8
10
|
compiledErc20,
|
|
9
11
|
compiledTestDapp,
|
|
12
|
+
erc20ClassHash,
|
|
10
13
|
getERC20DeployPayload,
|
|
11
14
|
getTestAccount,
|
|
12
15
|
getTestProvider,
|
|
@@ -159,4 +162,37 @@ describe('deploy and test Wallet', () => {
|
|
|
159
162
|
expect(declareTx.class_hash).toBeDefined();
|
|
160
163
|
});
|
|
161
164
|
});
|
|
165
|
+
|
|
166
|
+
describe('Declare and UDC Deploy Flow', () => {
|
|
167
|
+
test('ERC20 Declare', async () => {
|
|
168
|
+
const declareTx = await account.declare({
|
|
169
|
+
classHash: erc20ClassHash,
|
|
170
|
+
contract: compiledErc20,
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
await provider.waitForTransaction(declareTx.transaction_hash);
|
|
174
|
+
|
|
175
|
+
expect(declareTx).toHaveProperty('class_hash');
|
|
176
|
+
expect(declareTx.class_hash).toEqual(erc20ClassHash);
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
test('UDC Deploy', async () => {
|
|
180
|
+
const salt = randomAddress(); // use random salt
|
|
181
|
+
|
|
182
|
+
const deployment = await account.deploy({
|
|
183
|
+
classHash: erc20ClassHash,
|
|
184
|
+
constructorCalldata: [
|
|
185
|
+
encodeShortString('Token'),
|
|
186
|
+
encodeShortString('ERC20'),
|
|
187
|
+
account.address,
|
|
188
|
+
],
|
|
189
|
+
salt,
|
|
190
|
+
unique: true, // Using true here so as not to clash with normal erc20 deploy in account and provider test
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
await provider.waitForTransaction(deployment.transaction_hash);
|
|
194
|
+
|
|
195
|
+
expect(deployment).toHaveProperty('transaction_hash');
|
|
196
|
+
});
|
|
197
|
+
});
|
|
162
198
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BlockNumber, GetBlockResponse, stark } from '../src';
|
|
2
2
|
import { toBN } from '../src/utils/number';
|
|
3
|
-
import { getERC20DeployPayload, getTestProvider } from './fixtures';
|
|
3
|
+
import { erc20ClassHash, getERC20DeployPayload, getTestProvider } from './fixtures';
|
|
4
4
|
|
|
5
5
|
const { compileCalldata } = stark;
|
|
6
6
|
|
|
@@ -8,7 +8,7 @@ const testProvider = getTestProvider();
|
|
|
8
8
|
|
|
9
9
|
describe('defaultProvider', () => {
|
|
10
10
|
let exampleTransactionHash: string;
|
|
11
|
-
let
|
|
11
|
+
let erc20ContractAddress: string;
|
|
12
12
|
|
|
13
13
|
let exampleBlock: GetBlockResponse;
|
|
14
14
|
let exampleBlockNumber: BlockNumber;
|
|
@@ -23,7 +23,7 @@ describe('defaultProvider', () => {
|
|
|
23
23
|
);
|
|
24
24
|
await testProvider.waitForTransaction(transaction_hash);
|
|
25
25
|
exampleTransactionHash = transaction_hash;
|
|
26
|
-
|
|
26
|
+
erc20ContractAddress = contract_address;
|
|
27
27
|
|
|
28
28
|
exampleBlock = await testProvider.getBlock('latest');
|
|
29
29
|
exampleBlockHash = exampleBlock.block_hash;
|
|
@@ -32,7 +32,7 @@ describe('defaultProvider', () => {
|
|
|
32
32
|
|
|
33
33
|
describe('endpoints', () => {
|
|
34
34
|
test('deployContract()', () => {
|
|
35
|
-
expect(
|
|
35
|
+
expect(erc20ContractAddress).toBeTruthy();
|
|
36
36
|
expect(exampleTransactionHash).toBeTruthy();
|
|
37
37
|
});
|
|
38
38
|
|
|
@@ -75,43 +75,41 @@ describe('defaultProvider', () => {
|
|
|
75
75
|
});
|
|
76
76
|
|
|
77
77
|
test('getNonce()', async () => {
|
|
78
|
-
const nonce = await testProvider.getNonce(
|
|
78
|
+
const nonce = await testProvider.getNonce(erc20ContractAddress);
|
|
79
79
|
return expect(nonce).toEqual('0x0');
|
|
80
80
|
});
|
|
81
81
|
|
|
82
82
|
test('getClassAt(contractAddress, blockNumber="latest")', async () => {
|
|
83
|
-
const classResponse = await testProvider.getClassAt(
|
|
83
|
+
const classResponse = await testProvider.getClassAt(erc20ContractAddress);
|
|
84
84
|
|
|
85
85
|
expect(classResponse).toHaveProperty('program');
|
|
86
86
|
expect(classResponse).toHaveProperty('entry_points_by_type');
|
|
87
87
|
});
|
|
88
88
|
|
|
89
89
|
// TODO see if feasible to split
|
|
90
|
-
describe('
|
|
90
|
+
describe('GetClassByHash', () => {
|
|
91
91
|
test('responses', async () => {
|
|
92
|
-
const
|
|
93
|
-
expect(typeof classHash).toBe('string');
|
|
94
|
-
|
|
95
|
-
const classResponse = await testProvider.getClass(classHash);
|
|
92
|
+
const classResponse = await testProvider.getClassByHash(erc20ClassHash);
|
|
96
93
|
expect(classResponse).toHaveProperty('program');
|
|
97
94
|
expect(classResponse).toHaveProperty('entry_points_by_type');
|
|
95
|
+
expect(classResponse).toHaveProperty('abi');
|
|
98
96
|
});
|
|
99
97
|
});
|
|
100
98
|
|
|
101
99
|
describe('getStorageAt', () => {
|
|
102
100
|
test('with "key" type of number', () => {
|
|
103
|
-
return expect(testProvider.getStorageAt(
|
|
101
|
+
return expect(testProvider.getStorageAt(erc20ContractAddress, 0)).resolves.not.toThrow();
|
|
104
102
|
});
|
|
105
103
|
|
|
106
104
|
test('"key" type of string', () => {
|
|
107
105
|
return expect(
|
|
108
|
-
testProvider.getStorageAt(
|
|
106
|
+
testProvider.getStorageAt(erc20ContractAddress, '0x0')
|
|
109
107
|
).resolves.not.toThrow();
|
|
110
108
|
});
|
|
111
109
|
|
|
112
110
|
test('with "key" type of BN', () => {
|
|
113
111
|
return expect(
|
|
114
|
-
testProvider.getStorageAt(
|
|
112
|
+
testProvider.getStorageAt(erc20ContractAddress, toBN('0x0'))
|
|
115
113
|
).resolves.not.toThrow();
|
|
116
114
|
});
|
|
117
115
|
});
|
|
@@ -135,7 +133,7 @@ describe('defaultProvider', () => {
|
|
|
135
133
|
test('callContract()', () => {
|
|
136
134
|
return expect(
|
|
137
135
|
testProvider.callContract({
|
|
138
|
-
contractAddress:
|
|
136
|
+
contractAddress: erc20ContractAddress,
|
|
139
137
|
entrypoint: 'balanceOf',
|
|
140
138
|
calldata: compileCalldata({
|
|
141
139
|
user: '0x9ff64f4ab0e1fe88df4465ade98d1ea99d5732761c39279b8e1374fa943e9b',
|
|
@@ -148,7 +146,7 @@ describe('defaultProvider', () => {
|
|
|
148
146
|
return expect(
|
|
149
147
|
testProvider
|
|
150
148
|
.callContract({
|
|
151
|
-
contractAddress:
|
|
149
|
+
contractAddress: erc20ContractAddress,
|
|
152
150
|
entrypoint: 'balanceOf',
|
|
153
151
|
calldata: compileCalldata({
|
|
154
152
|
user: wallet,
|
|
@@ -163,7 +161,7 @@ describe('defaultProvider', () => {
|
|
|
163
161
|
test('callContract() - gateway error', async () => {
|
|
164
162
|
return expect(
|
|
165
163
|
testProvider.callContract({
|
|
166
|
-
contractAddress:
|
|
164
|
+
contractAddress: erc20ContractAddress,
|
|
167
165
|
entrypoint: 'non_existent_entrypoint',
|
|
168
166
|
calldata: compileCalldata({
|
|
169
167
|
user: '0xdeadbeef',
|
package/__tests__/fixtures.ts
CHANGED
|
@@ -73,6 +73,8 @@ export const describeIfSequencer = describeIf(IS_DEVNET);
|
|
|
73
73
|
export const describeIfRpc = describeIf(IS_RPC);
|
|
74
74
|
export const describeIfNotDevnet = describeIf(!IS_DEVNET);
|
|
75
75
|
|
|
76
|
+
export const erc20ClassHash = '0x54328a1075b8820eb43caf0caa233923148c983742402dcfc38541dd843d01a';
|
|
77
|
+
|
|
76
78
|
export const getERC20DeployPayload = (recipient: string): DeployContractPayload => {
|
|
77
79
|
return {
|
|
78
80
|
contract: compiledErc20,
|