starknet 4.10.0 → 4.12.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 +32 -0
- package/__tests__/account.test.ts +42 -0
- package/__tests__/defaultProvider.test.ts +22 -12
- package/__tests__/fixtures.ts +3 -1
- package/__tests__/rpcProvider.test.ts +6 -4
- package/account/default.js +3 -3
- package/dist/account/default.js +3 -3
- package/dist/provider/default.d.ts +4 -2
- package/dist/provider/default.js +13 -2
- package/dist/provider/interface.d.ts +18 -3
- package/dist/provider/rpc.d.ts +13 -9
- package/dist/provider/rpc.js +63 -29
- package/dist/provider/sequencer.d.ts +2 -0
- package/dist/provider/sequencer.js +15 -0
- package/dist/types/api/openrpc.d.ts +147 -98
- package/dist/types/api/openrpc.js +22 -4
- package/dist/types/lib.d.ts +9 -2
- package/dist/types/lib.js +6 -0
- package/package.json +1 -1
- package/provider/default.d.ts +4 -2
- package/provider/default.js +13 -2
- package/provider/interface.d.ts +18 -3
- package/provider/rpc.d.ts +13 -9
- package/provider/rpc.js +63 -29
- package/provider/sequencer.d.ts +2 -0
- package/provider/sequencer.js +15 -0
- package/src/account/default.ts +8 -4
- package/src/provider/default.ts +21 -3
- package/src/provider/interface.ts +26 -2
- package/src/provider/rpc.ts +70 -42
- package/src/provider/sequencer.ts +11 -0
- package/src/types/api/openrpc.ts +193 -105
- package/src/types/api/rpc.ts +0 -1
- package/src/types/lib.ts +10 -2
- package/types/api/openrpc.d.ts +147 -98
- package/types/api/openrpc.js +22 -4
- package/types/lib.d.ts +9 -2
- package/types/lib.js +6 -0
- package/__tests__/udc.test.ts +0 -41
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,35 @@
|
|
|
1
|
+
# [4.12.0](https://github.com/0xs34n/starknet.js/compare/v4.11.0...v4.12.0) (2022-11-17)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
- **tests:** refactor udc tests ([01a6eef](https://github.com/0xs34n/starknet.js/commit/01a6eef11b2f32e05d2aea4ab185536e3fdb1a71))
|
|
6
|
+
- use method name similar to gateway endpoint ([79641b3](https://github.com/0xs34n/starknet.js/commit/79641b3076412d71fa4e5ccbdb018c4f3ecab938))
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- create getClass RPC alias ([1003534](https://github.com/0xs34n/starknet.js/commit/10035341dd26e23b59d3dd764936a7d8eaa3f3b0))
|
|
11
|
+
|
|
12
|
+
# [4.11.0](https://github.com/0xs34n/starknet.js/compare/v4.10.0...v4.11.0) (2022-11-14)
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
- change txn version for estimate fee apis to be feeTransactionVersion ([4d255c5](https://github.com/0xs34n/starknet.js/commit/4d255c5cf4adceb16a7f9ac61904a6e5d8020cbd))
|
|
17
|
+
- lib FunctionAbiType and EventAbi shallow ([7088dc6](https://github.com/0xs34n/starknet.js/commit/7088dc6828f9f4fd29922323e63183a2e11f7340))
|
|
18
|
+
- remove deprecated function ([0a9f84f](https://github.com/0xs34n/starknet.js/commit/0a9f84f86aabaa49ab78faa3331cac0ca98ace61))
|
|
19
|
+
- removed fixed params swap ([57c01f6](https://github.com/0xs34n/starknet.js/commit/57c01f6418771d8ceaa3f393d54cad8bfff94b56))
|
|
20
|
+
- rpcProvider tests ([4b0fd20](https://github.com/0xs34n/starknet.js/commit/4b0fd20a8ce235e0e069521f7dca50a4696120a4))
|
|
21
|
+
|
|
22
|
+
### Features
|
|
23
|
+
|
|
24
|
+
- fill in sequencer class methods ([83c0a29](https://github.com/0xs34n/starknet.js/commit/83c0a296bced3128a0ca9dd5246b376816a0be63))
|
|
25
|
+
- implement rpc-0.2.1rc1 types ([2b1b71e](https://github.com/0xs34n/starknet.js/commit/2b1b71ebedfa709aab4fa652bd98a8efc2d3e39a))
|
|
26
|
+
- rpc 0.2.0 plane implementation ([35a880c](https://github.com/0xs34n/starknet.js/commit/35a880ce4f8438e78143f7c0997ccfe6de680d80))
|
|
27
|
+
- rpc 0.2.0 type implementation ([866dda7](https://github.com/0xs34n/starknet.js/commit/866dda76fc35ef656a9e21b8b8674f73729c9a50))
|
|
28
|
+
- rpc 0.2.0 types spec ([25b2d29](https://github.com/0xs34n/starknet.js/commit/25b2d293a1a570b6fc68ea3877bfe6c3e898e3a6))
|
|
29
|
+
- rpc 0.2.1 ([ed17f63](https://github.com/0xs34n/starknet.js/commit/ed17f6380d2b1ab1432d5426c7395ab18c6dc793))
|
|
30
|
+
- rpc v0.2 endpoint, default identifiers, getClassHashAt flip parameters ([f0a0d6c](https://github.com/0xs34n/starknet.js/commit/f0a0d6c49e33442b603dcc9c9c119867c1ed32cc))
|
|
31
|
+
- rpc0.2.1 definition migration comlete ([35c5a06](https://github.com/0xs34n/starknet.js/commit/35c5a0645dafe061080c2c2ced6a9a4a9882207c))
|
|
32
|
+
|
|
1
33
|
# [4.10.0](https://github.com/0xs34n/starknet.js/compare/v4.9.0...v4.10.0) (2022-11-10)
|
|
2
34
|
|
|
3
35
|
### Bug Fixes
|
|
@@ -2,10 +2,15 @@ import { isBN } from 'bn.js';
|
|
|
2
2
|
|
|
3
3
|
import typedDataExample from '../__mocks__/typedDataExample.json';
|
|
4
4
|
import { Account, Contract, Provider, number, stark } from '../src';
|
|
5
|
+
import { feeTransactionVersion } from '../src/utils/hash';
|
|
5
6
|
import { toBN } from '../src/utils/number';
|
|
7
|
+
import { encodeShortString } from '../src/utils/shortString';
|
|
8
|
+
import { randomAddress } from '../src/utils/stark';
|
|
6
9
|
import {
|
|
10
|
+
IS_DEVNET,
|
|
7
11
|
compiledErc20,
|
|
8
12
|
compiledTestDapp,
|
|
13
|
+
erc20ClassHash,
|
|
9
14
|
getERC20DeployPayload,
|
|
10
15
|
getTestAccount,
|
|
11
16
|
getTestProvider,
|
|
@@ -43,12 +48,15 @@ describe('deploy and test Wallet', () => {
|
|
|
43
48
|
});
|
|
44
49
|
|
|
45
50
|
test('estimate fee', async () => {
|
|
51
|
+
const innerInvokeEstFeeSpy = jest.spyOn(account.signer, 'signTransaction');
|
|
46
52
|
const { overall_fee } = await account.estimateInvokeFee({
|
|
47
53
|
contractAddress: erc20Address,
|
|
48
54
|
entrypoint: 'transfer',
|
|
49
55
|
calldata: [erc20.address, '10', '0'],
|
|
50
56
|
});
|
|
51
57
|
expect(isBN(overall_fee)).toBe(true);
|
|
58
|
+
expect(innerInvokeEstFeeSpy.mock.calls[0][1].version).toBe(feeTransactionVersion);
|
|
59
|
+
innerInvokeEstFeeSpy.mockClear();
|
|
52
60
|
});
|
|
53
61
|
|
|
54
62
|
test('read balance of wallet', async () => {
|
|
@@ -155,4 +163,38 @@ describe('deploy and test Wallet', () => {
|
|
|
155
163
|
expect(declareTx.class_hash).toBeDefined();
|
|
156
164
|
});
|
|
157
165
|
});
|
|
166
|
+
|
|
167
|
+
describe('Declare and UDC Deploy Flow', () => {
|
|
168
|
+
test('ERC20 Declare', async () => {
|
|
169
|
+
const declareTx = await account.declare({
|
|
170
|
+
classHash: erc20ClassHash,
|
|
171
|
+
contract: compiledErc20,
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
await provider.waitForTransaction(declareTx.transaction_hash);
|
|
175
|
+
|
|
176
|
+
expect(declareTx).toHaveProperty('class_hash');
|
|
177
|
+
expect(declareTx.class_hash).toEqual(erc20ClassHash);
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
test('UDC Deploy', async () => {
|
|
181
|
+
const salt = randomAddress(); // use random salt
|
|
182
|
+
|
|
183
|
+
const deployment = await account.deploy({
|
|
184
|
+
classHash: erc20ClassHash,
|
|
185
|
+
constructorCalldata: [
|
|
186
|
+
encodeShortString('Token'),
|
|
187
|
+
encodeShortString('ERC20'),
|
|
188
|
+
account.address,
|
|
189
|
+
],
|
|
190
|
+
salt,
|
|
191
|
+
unique: true, // Using true here so as not to clash with normal erc20 deploy in account and provider test
|
|
192
|
+
isDevnet: IS_DEVNET,
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
await provider.waitForTransaction(deployment.transaction_hash);
|
|
196
|
+
|
|
197
|
+
expect(deployment).toHaveProperty('transaction_hash');
|
|
198
|
+
});
|
|
199
|
+
});
|
|
158
200
|
});
|
|
@@ -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,31 +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
|
+
// TODO see if feasible to split
|
|
90
|
+
describe('GetClassByHash', () => {
|
|
91
|
+
test('responses', async () => {
|
|
92
|
+
const classResponse = await testProvider.getClassByHash(erc20ClassHash);
|
|
93
|
+
expect(classResponse).toHaveProperty('program');
|
|
94
|
+
expect(classResponse).toHaveProperty('entry_points_by_type');
|
|
95
|
+
expect(classResponse).toHaveProperty('abi');
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
|
|
89
99
|
describe('getStorageAt', () => {
|
|
90
100
|
test('with "key" type of number', () => {
|
|
91
|
-
return expect(testProvider.getStorageAt(
|
|
101
|
+
return expect(testProvider.getStorageAt(erc20ContractAddress, 0)).resolves.not.toThrow();
|
|
92
102
|
});
|
|
93
103
|
|
|
94
104
|
test('"key" type of string', () => {
|
|
95
105
|
return expect(
|
|
96
|
-
testProvider.getStorageAt(
|
|
106
|
+
testProvider.getStorageAt(erc20ContractAddress, '0x0')
|
|
97
107
|
).resolves.not.toThrow();
|
|
98
108
|
});
|
|
99
109
|
|
|
100
110
|
test('with "key" type of BN', () => {
|
|
101
111
|
return expect(
|
|
102
|
-
testProvider.getStorageAt(
|
|
112
|
+
testProvider.getStorageAt(erc20ContractAddress, toBN('0x0'))
|
|
103
113
|
).resolves.not.toThrow();
|
|
104
114
|
});
|
|
105
115
|
});
|
|
@@ -123,7 +133,7 @@ describe('defaultProvider', () => {
|
|
|
123
133
|
test('callContract()', () => {
|
|
124
134
|
return expect(
|
|
125
135
|
testProvider.callContract({
|
|
126
|
-
contractAddress:
|
|
136
|
+
contractAddress: erc20ContractAddress,
|
|
127
137
|
entrypoint: 'balanceOf',
|
|
128
138
|
calldata: compileCalldata({
|
|
129
139
|
user: '0x9ff64f4ab0e1fe88df4465ade98d1ea99d5732761c39279b8e1374fa943e9b',
|
|
@@ -136,7 +146,7 @@ describe('defaultProvider', () => {
|
|
|
136
146
|
return expect(
|
|
137
147
|
testProvider
|
|
138
148
|
.callContract({
|
|
139
|
-
contractAddress:
|
|
149
|
+
contractAddress: erc20ContractAddress,
|
|
140
150
|
entrypoint: 'balanceOf',
|
|
141
151
|
calldata: compileCalldata({
|
|
142
152
|
user: wallet,
|
|
@@ -151,7 +161,7 @@ describe('defaultProvider', () => {
|
|
|
151
161
|
test('callContract() - gateway error', async () => {
|
|
152
162
|
return expect(
|
|
153
163
|
testProvider.callContract({
|
|
154
|
-
contractAddress:
|
|
164
|
+
contractAddress: erc20ContractAddress,
|
|
155
165
|
entrypoint: 'non_existent_entrypoint',
|
|
156
166
|
calldata: compileCalldata({
|
|
157
167
|
user: '0xdeadbeef',
|
package/__tests__/fixtures.ts
CHANGED
|
@@ -31,7 +31,7 @@ const IS_SEQUENCER_DEVNET = !BASE_URL.includes('starknet.io');
|
|
|
31
31
|
export const IS_SEQUENCER_GOERLI = BASE_URL === 'https://alpha4-2.starknet.io';
|
|
32
32
|
export const IS_DEVNET = IS_SEQUENCER ? IS_SEQUENCER_DEVNET : IS_RPC_DEVNET;
|
|
33
33
|
|
|
34
|
-
export const getTestProvider = () => {
|
|
34
|
+
export const getTestProvider = (): ProviderInterface => {
|
|
35
35
|
const provider = RPC_URL
|
|
36
36
|
? new RpcProvider({ nodeUrl: RPC_URL })
|
|
37
37
|
: new SequencerProvider({ baseUrl: BASE_URL });
|
|
@@ -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,
|
|
@@ -23,7 +23,9 @@ describeIfRpc('RPCProvider', () => {
|
|
|
23
23
|
|
|
24
24
|
test('getChainId', async () => {
|
|
25
25
|
const chainId = await rpcProvider.getChainId();
|
|
26
|
-
expect(
|
|
26
|
+
expect([StarknetChainId.TESTNET2, StarknetChainId.MAINNET, StarknetChainId.TESTNET]).toContain(
|
|
27
|
+
chainId
|
|
28
|
+
);
|
|
27
29
|
});
|
|
28
30
|
|
|
29
31
|
test('getPendingTransactions', async () => {
|
|
@@ -107,7 +109,7 @@ describeIfRpc('RPCProvider', () => {
|
|
|
107
109
|
});
|
|
108
110
|
|
|
109
111
|
test('getClassHashAt', async () => {
|
|
110
|
-
const classHash = await rpcProvider.getClassHashAt(
|
|
112
|
+
const classHash = await rpcProvider.getClassHashAt(contract_address);
|
|
111
113
|
expect(typeof classHash).toBe('string');
|
|
112
114
|
});
|
|
113
115
|
|
|
@@ -116,9 +118,9 @@ describeIfRpc('RPCProvider', () => {
|
|
|
116
118
|
});
|
|
117
119
|
});
|
|
118
120
|
|
|
119
|
-
test('getClass classHash
|
|
121
|
+
test('getClass classHash 0x03fcbf77b28c96f4f2fb5bd2d176ab083a12a5e123adeb0de955d7ee228c9854', async () => {
|
|
120
122
|
const contractClass = await rpcProvider.getClass(
|
|
121
|
-
'
|
|
123
|
+
'0x03fcbf77b28c96f4f2fb5bd2d176ab083a12a5e123adeb0de955d7ee228c9854'
|
|
122
124
|
);
|
|
123
125
|
expect(contractClass).toHaveProperty('program');
|
|
124
126
|
expect(contractClass).toHaveProperty('entry_points_by_type');
|
package/account/default.js
CHANGED
|
@@ -138,7 +138,7 @@ var Account = /** @class */ (function (_super) {
|
|
|
138
138
|
_e.label = 3;
|
|
139
139
|
case 3:
|
|
140
140
|
nonce = _c.apply(void 0, [_d]);
|
|
141
|
-
version = (0, number_1.toBN)(hash_1.
|
|
141
|
+
version = (0, number_1.toBN)(hash_1.feeTransactionVersion);
|
|
142
142
|
return [4 /*yield*/, this.getChainId()];
|
|
143
143
|
case 4:
|
|
144
144
|
chainId = _e.sent();
|
|
@@ -180,7 +180,7 @@ var Account = /** @class */ (function (_super) {
|
|
|
180
180
|
_f.label = 3;
|
|
181
181
|
case 3:
|
|
182
182
|
nonce = _d.apply(void 0, [_e]);
|
|
183
|
-
version = (0, number_1.toBN)(hash_1.
|
|
183
|
+
version = (0, number_1.toBN)(hash_1.feeTransactionVersion);
|
|
184
184
|
return [4 /*yield*/, this.getChainId()];
|
|
185
185
|
case 4:
|
|
186
186
|
chainId = _f.sent();
|
|
@@ -222,7 +222,7 @@ var Account = /** @class */ (function (_super) {
|
|
|
222
222
|
_h.label = 3;
|
|
223
223
|
case 3:
|
|
224
224
|
nonce = _f.apply(void 0, [_g]);
|
|
225
|
-
version = (0, number_1.toBN)(hash_1.
|
|
225
|
+
version = (0, number_1.toBN)(hash_1.feeTransactionVersion);
|
|
226
226
|
return [4 /*yield*/, this.getChainId()];
|
|
227
227
|
case 4:
|
|
228
228
|
chainId = _h.sent();
|
package/dist/account/default.js
CHANGED
|
@@ -138,7 +138,7 @@ var Account = /** @class */ (function (_super) {
|
|
|
138
138
|
_e.label = 3;
|
|
139
139
|
case 3:
|
|
140
140
|
nonce = _c.apply(void 0, [_d]);
|
|
141
|
-
version = (0, number_1.toBN)(hash_1.
|
|
141
|
+
version = (0, number_1.toBN)(hash_1.feeTransactionVersion);
|
|
142
142
|
return [4 /*yield*/, this.getChainId()];
|
|
143
143
|
case 4:
|
|
144
144
|
chainId = _e.sent();
|
|
@@ -180,7 +180,7 @@ var Account = /** @class */ (function (_super) {
|
|
|
180
180
|
_f.label = 3;
|
|
181
181
|
case 3:
|
|
182
182
|
nonce = _d.apply(void 0, [_e]);
|
|
183
|
-
version = (0, number_1.toBN)(hash_1.
|
|
183
|
+
version = (0, number_1.toBN)(hash_1.feeTransactionVersion);
|
|
184
184
|
return [4 /*yield*/, this.getChainId()];
|
|
185
185
|
case 4:
|
|
186
186
|
chainId = _f.sent();
|
|
@@ -222,7 +222,7 @@ var Account = /** @class */ (function (_super) {
|
|
|
222
222
|
_h.label = 3;
|
|
223
223
|
case 3:
|
|
224
224
|
nonce = _f.apply(void 0, [_g]);
|
|
225
|
-
version = (0, number_1.toBN)(hash_1.
|
|
225
|
+
version = (0, number_1.toBN)(hash_1.feeTransactionVersion);
|
|
226
226
|
return [4 /*yield*/, this.getChainId()];
|
|
227
227
|
case 4:
|
|
228
228
|
chainId = _h.sent();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { StarknetChainId } from '../constants';
|
|
2
2
|
import { Call, CallContractResponse, ContractClass, DeclareContractResponse, DeployContractPayload, DeployContractResponse, EstimateFeeResponse, GetBlockResponse, GetCodeResponse, GetTransactionReceiptResponse, GetTransactionResponse, Invocation, InvocationsDetailsWithNonce, InvokeFunctionResponse } from '../types';
|
|
3
|
-
import { DeclareContractTransaction, DeployAccountContractTransaction } from '../types/lib';
|
|
3
|
+
import { DeclareContractTransaction, DeployAccountContractTransaction, InvocationsDetails } from '../types/lib';
|
|
4
4
|
import { BigNumberish } from '../utils/number';
|
|
5
5
|
import { ProviderInterface } from './interface';
|
|
6
6
|
import { RpcProviderOptions } from './rpc';
|
|
@@ -17,6 +17,8 @@ export declare class Provider implements ProviderInterface {
|
|
|
17
17
|
getChainId(): Promise<StarknetChainId>;
|
|
18
18
|
getBlock(blockIdentifier?: BlockIdentifier): Promise<GetBlockResponse>;
|
|
19
19
|
getClassAt(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<ContractClass>;
|
|
20
|
+
getClassHashAt(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<string>;
|
|
21
|
+
getClassByHash(classHash: string): Promise<ContractClass>;
|
|
20
22
|
getEstimateFee(invocationWithTxType: Invocation, invocationDetails: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier): Promise<EstimateFeeResponse>;
|
|
21
23
|
getInvokeEstimateFee(invocationWithTxType: Invocation, invocationDetails: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier): Promise<EstimateFeeResponse>;
|
|
22
24
|
getNonce(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<BigNumberish>;
|
|
@@ -25,7 +27,7 @@ export declare class Provider implements ProviderInterface {
|
|
|
25
27
|
getTransactionReceipt(txHash: BigNumberish): Promise<GetTransactionReceiptResponse>;
|
|
26
28
|
callContract(request: Call, blockIdentifier?: BlockIdentifier): Promise<CallContractResponse>;
|
|
27
29
|
invokeFunction(functionInvocation: Invocation, details: InvocationsDetailsWithNonce): Promise<InvokeFunctionResponse>;
|
|
28
|
-
deployContract(payload: DeployContractPayload): Promise<DeployContractResponse>;
|
|
30
|
+
deployContract(payload: DeployContractPayload, details: InvocationsDetails): Promise<DeployContractResponse>;
|
|
29
31
|
deployAccountContract(payload: DeployAccountContractTransaction, details: InvocationsDetailsWithNonce): Promise<DeployContractResponse>;
|
|
30
32
|
declareContract(transaction: DeclareContractTransaction, details: InvocationsDetailsWithNonce): Promise<DeclareContractResponse>;
|
|
31
33
|
getDeclareEstimateFee(transaction: DeclareContractTransaction, details: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier): Promise<EstimateFeeResponse>;
|
package/dist/provider/default.js
CHANGED
|
@@ -84,6 +84,17 @@ var Provider = /** @class */ (function () {
|
|
|
84
84
|
});
|
|
85
85
|
});
|
|
86
86
|
};
|
|
87
|
+
Provider.prototype.getClassHashAt = function (contractAddress, blockIdentifier) {
|
|
88
|
+
if (blockIdentifier === void 0) { blockIdentifier = 'pending'; }
|
|
89
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
90
|
+
return __generator(this, function (_a) {
|
|
91
|
+
return [2 /*return*/, this.provider.getClassHashAt(contractAddress, blockIdentifier)];
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
Provider.prototype.getClassByHash = function (classHash) {
|
|
96
|
+
return this.provider.getClassByHash(classHash);
|
|
97
|
+
};
|
|
87
98
|
Provider.prototype.getEstimateFee = function (invocationWithTxType, invocationDetails, blockIdentifier) {
|
|
88
99
|
if (blockIdentifier === void 0) { blockIdentifier = 'pending'; }
|
|
89
100
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -144,10 +155,10 @@ var Provider = /** @class */ (function () {
|
|
|
144
155
|
});
|
|
145
156
|
});
|
|
146
157
|
};
|
|
147
|
-
Provider.prototype.deployContract = function (payload) {
|
|
158
|
+
Provider.prototype.deployContract = function (payload, details) {
|
|
148
159
|
return __awaiter(this, void 0, void 0, function () {
|
|
149
160
|
return __generator(this, function (_a) {
|
|
150
|
-
return [2 /*return*/, this.provider.deployContract(payload)];
|
|
161
|
+
return [2 /*return*/, this.provider.deployContract(payload, details)];
|
|
151
162
|
});
|
|
152
163
|
});
|
|
153
164
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { StarknetChainId } from '../constants';
|
|
2
2
|
import type { Call, CallContractResponse, ContractClass, DeclareContractResponse, DeployContractPayload, DeployContractResponse, EstimateFeeResponse, GetBlockResponse, GetCodeResponse, GetTransactionReceiptResponse, GetTransactionResponse, Invocation, InvocationsDetailsWithNonce, InvokeFunctionResponse } from '../types';
|
|
3
|
-
import { DeclareContractTransaction, DeployAccountContractPayload, DeployAccountContractTransaction } from '../types/lib';
|
|
3
|
+
import { DeclareContractTransaction, DeployAccountContractPayload, DeployAccountContractTransaction, InvocationsDetails } from '../types/lib';
|
|
4
4
|
import type { BigNumberish } from '../utils/number';
|
|
5
5
|
import { BlockIdentifier } from './utils';
|
|
6
6
|
export declare abstract class ProviderInterface {
|
|
@@ -38,6 +38,21 @@ export declare abstract class ProviderInterface {
|
|
|
38
38
|
* @returns Contract class of compiled contract
|
|
39
39
|
*/
|
|
40
40
|
abstract getClassAt(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<ContractClass>;
|
|
41
|
+
/**
|
|
42
|
+
* Returns the class hash deployed under the given address.
|
|
43
|
+
*
|
|
44
|
+
* @param contractAddress - contract address
|
|
45
|
+
* @param blockIdentifier - block identifier
|
|
46
|
+
* @returns Class hash
|
|
47
|
+
*/
|
|
48
|
+
abstract getClassHashAt(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<string>;
|
|
49
|
+
/**
|
|
50
|
+
* Returns the contract class deployed under the given class hash.
|
|
51
|
+
*
|
|
52
|
+
* @param classHash - class hash
|
|
53
|
+
* @returns Contract class of compiled contract
|
|
54
|
+
*/
|
|
55
|
+
abstract getClassByHash(classHash: string): Promise<ContractClass>;
|
|
41
56
|
/**
|
|
42
57
|
* Gets the nonce of a contract with respect to a specific block
|
|
43
58
|
*
|
|
@@ -53,7 +68,7 @@ export declare abstract class ProviderInterface {
|
|
|
53
68
|
* @param blockIdentifier - block identifier
|
|
54
69
|
* @returns the value of the storage variable
|
|
55
70
|
*/
|
|
56
|
-
abstract getStorageAt(contractAddress: string, key: BigNumberish, blockIdentifier
|
|
71
|
+
abstract getStorageAt(contractAddress: string, key: BigNumberish, blockIdentifier?: BlockIdentifier): Promise<BigNumberish>;
|
|
57
72
|
/**
|
|
58
73
|
* Gets the transaction information from a tx id.
|
|
59
74
|
*
|
|
@@ -77,7 +92,7 @@ export declare abstract class ProviderInterface {
|
|
|
77
92
|
* - address salt
|
|
78
93
|
* @returns a confirmation of sending a transaction on the starknet contract
|
|
79
94
|
*/
|
|
80
|
-
abstract deployContract(payload: DeployContractPayload): Promise<DeployContractResponse>;
|
|
95
|
+
abstract deployContract(payload: DeployContractPayload, details?: InvocationsDetails): Promise<DeployContractResponse>;
|
|
81
96
|
/**
|
|
82
97
|
* Deploys a given compiled Account contract (json) to starknet
|
|
83
98
|
*
|
package/dist/provider/rpc.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { StarknetChainId } from '../constants';
|
|
2
|
-
import { Call, CallContractResponse, DeclareContractResponse, DeployContractPayload, DeployContractResponse, EstimateFeeResponse, GetBlockResponse, GetCodeResponse,
|
|
2
|
+
import { Call, CallContractResponse, DeclareContractResponse, DeployContractPayload, DeployContractResponse, EstimateFeeResponse, GetBlockResponse, GetCodeResponse, GetTransactionResponse, Invocation, InvocationsDetailsWithNonce, InvokeFunctionResponse } from '../types';
|
|
3
3
|
import { RPC } from '../types/api';
|
|
4
|
-
import { DeclareContractTransaction,
|
|
4
|
+
import { DeclareContractTransaction, DeployAccountContractTransaction, InvocationsDetails } from '../types/lib';
|
|
5
5
|
import { BigNumberish } from '../utils/number';
|
|
6
6
|
import { ProviderInterface } from './interface';
|
|
7
7
|
import { BlockIdentifier } from './utils';
|
|
@@ -25,17 +25,18 @@ export declare class RpcProvider implements ProviderInterface {
|
|
|
25
25
|
getBlockHashAndNumber(): Promise<RPC.BlockHashAndNumber>;
|
|
26
26
|
getBlockWithTxHashes(blockIdentifier?: BlockIdentifier): Promise<RPC.GetBlockWithTxHashesResponse>;
|
|
27
27
|
getBlockWithTxs(blockIdentifier?: BlockIdentifier): Promise<RPC.GetBlockWithTxs>;
|
|
28
|
-
getClassHashAt(
|
|
28
|
+
getClassHashAt(contractAddress: RPC.ContractAddress, blockIdentifier?: BlockIdentifier): Promise<RPC.Felt>;
|
|
29
29
|
getNonce(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<RPC.Nonce>;
|
|
30
30
|
getPendingTransactions(): Promise<RPC.PendingTransactions>;
|
|
31
31
|
getProtocolVersion(): Promise<Error>;
|
|
32
|
-
getStateUpdate(blockIdentifier
|
|
32
|
+
getStateUpdate(blockIdentifier?: BlockIdentifier): Promise<RPC.StateUpdate>;
|
|
33
33
|
getStorageAt(contractAddress: string, key: BigNumberish, blockIdentifier?: BlockIdentifier): Promise<BigNumberish>;
|
|
34
34
|
getTransaction(txHash: string): Promise<GetTransactionResponse>;
|
|
35
35
|
getTransactionByHash(txHash: string): Promise<RPC.GetTransactionByHashResponse>;
|
|
36
36
|
getTransactionByBlockIdAndIndex(blockIdentifier: BlockIdentifier, index: number): Promise<RPC.GetTransactionByBlockIdAndIndex>;
|
|
37
|
-
getTransactionReceipt(txHash: string): Promise<
|
|
38
|
-
|
|
37
|
+
getTransactionReceipt(txHash: string): Promise<RPC.TransactionReceipt>;
|
|
38
|
+
getClassByHash(classHash: RPC.Felt): Promise<RPC.ContractClass>;
|
|
39
|
+
getClass(classHash: RPC.Felt, blockIdentifier?: BlockIdentifier): Promise<RPC.ContractClass>;
|
|
39
40
|
getClassAt(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<RPC.ContractClass>;
|
|
40
41
|
getCode(_contractAddress: string, _blockIdentifier?: BlockIdentifier): Promise<GetCodeResponse>;
|
|
41
42
|
getEstimateFee(invocation: Invocation, invocationDetails: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier): Promise<EstimateFeeResponse>;
|
|
@@ -43,8 +44,11 @@ export declare class RpcProvider implements ProviderInterface {
|
|
|
43
44
|
getDeclareEstimateFee({ senderAddress, contractDefinition, signature }: DeclareContractTransaction, details: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier): Promise<EstimateFeeResponse>;
|
|
44
45
|
getDeployAccountEstimateFee({ classHash, constructorCalldata, addressSalt, signature }: DeployAccountContractTransaction, details: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier): Promise<EstimateFeeResponse>;
|
|
45
46
|
declareContract({ contractDefinition, signature, senderAddress }: DeclareContractTransaction, details: InvocationsDetailsWithNonce): Promise<DeclareContractResponse>;
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
/**
|
|
48
|
+
* @deprecated This method wont be supported soon, use Account.deploy instead
|
|
49
|
+
*/
|
|
50
|
+
deployContract({ contract, constructorCalldata, addressSalt }: DeployContractPayload, details?: InvocationsDetails): Promise<DeployContractResponse>;
|
|
51
|
+
deployAccountContract({ classHash, constructorCalldata, addressSalt, signature }: DeployAccountContractTransaction, details: InvocationsDetailsWithNonce): Promise<DeployContractResponse>;
|
|
48
52
|
invokeFunction(functionInvocation: Invocation, details: InvocationsDetailsWithNonce): Promise<InvokeFunctionResponse>;
|
|
49
53
|
callContract(call: Call, blockIdentifier?: BlockIdentifier): Promise<CallContractResponse>;
|
|
50
54
|
traceTransaction(transactionHash: RPC.TransactionHash): Promise<RPC.Trace>;
|
|
@@ -57,7 +61,7 @@ export declare class RpcProvider implements ProviderInterface {
|
|
|
57
61
|
* @param blockIdentifier
|
|
58
62
|
* @returns Number of transactions
|
|
59
63
|
*/
|
|
60
|
-
getTransactionCount(blockIdentifier
|
|
64
|
+
getTransactionCount(blockIdentifier?: BlockIdentifier): Promise<RPC.GetTransactionCountResponse>;
|
|
61
65
|
/**
|
|
62
66
|
* Gets the latest block number
|
|
63
67
|
*
|