starknet 4.10.0 → 4.11.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 +21 -0
- package/__tests__/account.test.ts +4 -0
- package/__tests__/defaultProvider.test.ts +12 -0
- package/__tests__/fixtures.ts +1 -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 +12 -9
- package/dist/provider/rpc.js +56 -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 +12 -9
- package/provider/rpc.js +56 -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 +66 -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/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
# [4.11.0](https://github.com/0xs34n/starknet.js/compare/v4.10.0...v4.11.0) (2022-11-14)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
- change txn version for estimate fee apis to be feeTransactionVersion ([4d255c5](https://github.com/0xs34n/starknet.js/commit/4d255c5cf4adceb16a7f9ac61904a6e5d8020cbd))
|
|
6
|
+
- lib FunctionAbiType and EventAbi shallow ([7088dc6](https://github.com/0xs34n/starknet.js/commit/7088dc6828f9f4fd29922323e63183a2e11f7340))
|
|
7
|
+
- remove deprecated function ([0a9f84f](https://github.com/0xs34n/starknet.js/commit/0a9f84f86aabaa49ab78faa3331cac0ca98ace61))
|
|
8
|
+
- removed fixed params swap ([57c01f6](https://github.com/0xs34n/starknet.js/commit/57c01f6418771d8ceaa3f393d54cad8bfff94b56))
|
|
9
|
+
- rpcProvider tests ([4b0fd20](https://github.com/0xs34n/starknet.js/commit/4b0fd20a8ce235e0e069521f7dca50a4696120a4))
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
- fill in sequencer class methods ([83c0a29](https://github.com/0xs34n/starknet.js/commit/83c0a296bced3128a0ca9dd5246b376816a0be63))
|
|
14
|
+
- implement rpc-0.2.1rc1 types ([2b1b71e](https://github.com/0xs34n/starknet.js/commit/2b1b71ebedfa709aab4fa652bd98a8efc2d3e39a))
|
|
15
|
+
- rpc 0.2.0 plane implementation ([35a880c](https://github.com/0xs34n/starknet.js/commit/35a880ce4f8438e78143f7c0997ccfe6de680d80))
|
|
16
|
+
- rpc 0.2.0 type implementation ([866dda7](https://github.com/0xs34n/starknet.js/commit/866dda76fc35ef656a9e21b8b8674f73729c9a50))
|
|
17
|
+
- rpc 0.2.0 types spec ([25b2d29](https://github.com/0xs34n/starknet.js/commit/25b2d293a1a570b6fc68ea3877bfe6c3e898e3a6))
|
|
18
|
+
- rpc 0.2.1 ([ed17f63](https://github.com/0xs34n/starknet.js/commit/ed17f6380d2b1ab1432d5426c7395ab18c6dc793))
|
|
19
|
+
- rpc v0.2 endpoint, default identifiers, getClassHashAt flip parameters ([f0a0d6c](https://github.com/0xs34n/starknet.js/commit/f0a0d6c49e33442b603dcc9c9c119867c1ed32cc))
|
|
20
|
+
- rpc0.2.1 definition migration comlete ([35c5a06](https://github.com/0xs34n/starknet.js/commit/35c5a0645dafe061080c2c2ced6a9a4a9882207c))
|
|
21
|
+
|
|
1
22
|
# [4.10.0](https://github.com/0xs34n/starknet.js/compare/v4.9.0...v4.10.0) (2022-11-10)
|
|
2
23
|
|
|
3
24
|
### Bug Fixes
|
|
@@ -2,6 +2,7 @@ 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';
|
|
6
7
|
import {
|
|
7
8
|
compiledErc20,
|
|
@@ -43,12 +44,15 @@ describe('deploy and test Wallet', () => {
|
|
|
43
44
|
});
|
|
44
45
|
|
|
45
46
|
test('estimate fee', async () => {
|
|
47
|
+
const innerInvokeEstFeeSpy = jest.spyOn(account.signer, 'signTransaction');
|
|
46
48
|
const { overall_fee } = await account.estimateInvokeFee({
|
|
47
49
|
contractAddress: erc20Address,
|
|
48
50
|
entrypoint: 'transfer',
|
|
49
51
|
calldata: [erc20.address, '10', '0'],
|
|
50
52
|
});
|
|
51
53
|
expect(isBN(overall_fee)).toBe(true);
|
|
54
|
+
expect(innerInvokeEstFeeSpy.mock.calls[0][1].version).toBe(feeTransactionVersion);
|
|
55
|
+
innerInvokeEstFeeSpy.mockClear();
|
|
52
56
|
});
|
|
53
57
|
|
|
54
58
|
test('read balance of wallet', async () => {
|
|
@@ -86,6 +86,18 @@ describe('defaultProvider', () => {
|
|
|
86
86
|
expect(classResponse).toHaveProperty('entry_points_by_type');
|
|
87
87
|
});
|
|
88
88
|
|
|
89
|
+
// TODO see if feasible to split
|
|
90
|
+
describe('getClassHashAt & GetClass', () => {
|
|
91
|
+
test('responses', async () => {
|
|
92
|
+
const classHash = await testProvider.getClassHashAt(exampleContractAddress);
|
|
93
|
+
expect(typeof classHash).toBe('string');
|
|
94
|
+
|
|
95
|
+
const classResponse = await testProvider.getClass(classHash);
|
|
96
|
+
expect(classResponse).toHaveProperty('program');
|
|
97
|
+
expect(classResponse).toHaveProperty('entry_points_by_type');
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
|
|
89
101
|
describe('getStorageAt', () => {
|
|
90
102
|
test('with "key" type of number', () => {
|
|
91
103
|
return expect(testProvider.getStorageAt(exampleContractAddress, 0)).resolves.not.toThrow();
|
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 });
|
|
@@ -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
|
+
getClass(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.getClass = function (classHash) {
|
|
96
|
+
return this.provider.getClass(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 getClass(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,17 @@ 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
|
-
getClass(classHash: RPC.Felt): Promise<RPC.ContractClass>;
|
|
37
|
+
getTransactionReceipt(txHash: string): Promise<RPC.TransactionReceipt>;
|
|
38
|
+
getClass(classHash: RPC.Felt, blockIdentifier?: BlockIdentifier): Promise<RPC.ContractClass>;
|
|
39
39
|
getClassAt(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<RPC.ContractClass>;
|
|
40
40
|
getCode(_contractAddress: string, _blockIdentifier?: BlockIdentifier): Promise<GetCodeResponse>;
|
|
41
41
|
getEstimateFee(invocation: Invocation, invocationDetails: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier): Promise<EstimateFeeResponse>;
|
|
@@ -43,8 +43,11 @@ export declare class RpcProvider implements ProviderInterface {
|
|
|
43
43
|
getDeclareEstimateFee({ senderAddress, contractDefinition, signature }: DeclareContractTransaction, details: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier): Promise<EstimateFeeResponse>;
|
|
44
44
|
getDeployAccountEstimateFee({ classHash, constructorCalldata, addressSalt, signature }: DeployAccountContractTransaction, details: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier): Promise<EstimateFeeResponse>;
|
|
45
45
|
declareContract({ contractDefinition, signature, senderAddress }: DeclareContractTransaction, details: InvocationsDetailsWithNonce): Promise<DeclareContractResponse>;
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
/**
|
|
47
|
+
* @deprecated This method wont be supported soon, use Account.deploy instead
|
|
48
|
+
*/
|
|
49
|
+
deployContract({ contract, constructorCalldata, addressSalt }: DeployContractPayload, details?: InvocationsDetails): Promise<DeployContractResponse>;
|
|
50
|
+
deployAccountContract({ classHash, constructorCalldata, addressSalt, signature }: DeployAccountContractTransaction, details: InvocationsDetailsWithNonce): Promise<DeployContractResponse>;
|
|
48
51
|
invokeFunction(functionInvocation: Invocation, details: InvocationsDetailsWithNonce): Promise<InvokeFunctionResponse>;
|
|
49
52
|
callContract(call: Call, blockIdentifier?: BlockIdentifier): Promise<CallContractResponse>;
|
|
50
53
|
traceTransaction(transactionHash: RPC.TransactionHash): Promise<RPC.Trace>;
|
|
@@ -57,7 +60,7 @@ export declare class RpcProvider implements ProviderInterface {
|
|
|
57
60
|
* @param blockIdentifier
|
|
58
61
|
* @returns Number of transactions
|
|
59
62
|
*/
|
|
60
|
-
getTransactionCount(blockIdentifier
|
|
63
|
+
getTransactionCount(blockIdentifier?: BlockIdentifier): Promise<RPC.GetTransactionCountResponse>;
|
|
61
64
|
/**
|
|
62
65
|
* Gets the latest block number
|
|
63
66
|
*
|
package/dist/provider/rpc.js
CHANGED
|
@@ -72,7 +72,7 @@ var RpcProvider = /** @class */ (function () {
|
|
|
72
72
|
});
|
|
73
73
|
}
|
|
74
74
|
RpcProvider.prototype.fetch = function (method, params) {
|
|
75
|
-
return (0, fetchPonyfill_1.default)(this.nodeUrl, {
|
|
75
|
+
return (0, fetchPonyfill_1.default)("".concat(this.nodeUrl, "/rpc/v0.2"), {
|
|
76
76
|
method: 'POST',
|
|
77
77
|
body: (0, json_1.stringify)({ method: method, jsonrpc: '2.0', params: params, id: 0 }),
|
|
78
78
|
headers: this.headers,
|
|
@@ -153,7 +153,8 @@ var RpcProvider = /** @class */ (function () {
|
|
|
153
153
|
});
|
|
154
154
|
});
|
|
155
155
|
};
|
|
156
|
-
RpcProvider.prototype.getClassHashAt = function (
|
|
156
|
+
RpcProvider.prototype.getClassHashAt = function (contractAddress, blockIdentifier) {
|
|
157
|
+
if (blockIdentifier === void 0) { blockIdentifier = 'pending'; }
|
|
157
158
|
return __awaiter(this, void 0, void 0, function () {
|
|
158
159
|
var block_id;
|
|
159
160
|
return __generator(this, function (_a) {
|
|
@@ -193,6 +194,7 @@ var RpcProvider = /** @class */ (function () {
|
|
|
193
194
|
});
|
|
194
195
|
};
|
|
195
196
|
RpcProvider.prototype.getStateUpdate = function (blockIdentifier) {
|
|
197
|
+
if (blockIdentifier === void 0) { blockIdentifier = 'pending'; }
|
|
196
198
|
return __awaiter(this, void 0, void 0, function () {
|
|
197
199
|
var block_id;
|
|
198
200
|
return __generator(this, function (_a) {
|
|
@@ -247,10 +249,13 @@ var RpcProvider = /** @class */ (function () {
|
|
|
247
249
|
});
|
|
248
250
|
});
|
|
249
251
|
};
|
|
250
|
-
RpcProvider.prototype.getClass = function (classHash) {
|
|
252
|
+
RpcProvider.prototype.getClass = function (classHash, blockIdentifier) {
|
|
253
|
+
if (blockIdentifier === void 0) { blockIdentifier = 'pending'; }
|
|
251
254
|
return __awaiter(this, void 0, void 0, function () {
|
|
255
|
+
var block_id;
|
|
252
256
|
return __generator(this, function (_a) {
|
|
253
|
-
|
|
257
|
+
block_id = new utils_1.Block(blockIdentifier).identifier;
|
|
258
|
+
return [2 /*return*/, this.fetchEndpoint('starknet_getClass', { class_hash: classHash, block_id: block_id })];
|
|
254
259
|
});
|
|
255
260
|
});
|
|
256
261
|
};
|
|
@@ -270,7 +275,7 @@ var RpcProvider = /** @class */ (function () {
|
|
|
270
275
|
RpcProvider.prototype.getCode = function (_contractAddress, _blockIdentifier) {
|
|
271
276
|
return __awaiter(this, void 0, void 0, function () {
|
|
272
277
|
return __generator(this, function (_a) {
|
|
273
|
-
throw new Error('RPC
|
|
278
|
+
throw new Error('RPC does not implement getCode function');
|
|
274
279
|
});
|
|
275
280
|
});
|
|
276
281
|
};
|
|
@@ -359,46 +364,61 @@ var RpcProvider = /** @class */ (function () {
|
|
|
359
364
|
return __awaiter(this, void 0, void 0, function () {
|
|
360
365
|
return __generator(this, function (_b) {
|
|
361
366
|
return [2 /*return*/, this.fetchEndpoint('starknet_addDeclareTransaction', {
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
367
|
+
declare_transaction: {
|
|
368
|
+
contract_class: {
|
|
369
|
+
program: contractDefinition.program,
|
|
370
|
+
entry_points_by_type: contractDefinition.entry_points_by_type,
|
|
371
|
+
abi: contractDefinition.abi, // rpc 2.0
|
|
372
|
+
},
|
|
373
|
+
type: 'DECLARE',
|
|
374
|
+
version: (0, number_1.toHex)((0, number_1.toBN)(details.version || 0)),
|
|
375
|
+
max_fee: (0, number_1.toHex)((0, number_1.toBN)(details.maxFee || 0)),
|
|
376
|
+
signature: (0, number_1.bigNumberishArrayToHexadecimalStringArray)(signature || []),
|
|
377
|
+
sender_address: senderAddress,
|
|
378
|
+
nonce: (0, number_1.toHex)((0, number_1.toBN)(details.nonce)),
|
|
366
379
|
},
|
|
367
|
-
version: (0, number_1.toHex)((0, number_1.toBN)(details.version || 0)),
|
|
368
|
-
max_fee: (0, number_1.toHex)((0, number_1.toBN)(details.maxFee || 0)),
|
|
369
|
-
signature: (0, number_1.bigNumberishArrayToHexadecimalStringArray)(signature || []),
|
|
370
|
-
sender_address: senderAddress,
|
|
371
|
-
nonce: (0, number_1.toHex)((0, number_1.toBN)(details.nonce)),
|
|
372
380
|
})];
|
|
373
381
|
});
|
|
374
382
|
});
|
|
375
383
|
};
|
|
376
|
-
|
|
384
|
+
/**
|
|
385
|
+
* @deprecated This method wont be supported soon, use Account.deploy instead
|
|
386
|
+
*/
|
|
387
|
+
RpcProvider.prototype.deployContract = function (_a, details) {
|
|
377
388
|
var contract = _a.contract, constructorCalldata = _a.constructorCalldata, addressSalt = _a.addressSalt;
|
|
378
389
|
return __awaiter(this, void 0, void 0, function () {
|
|
379
390
|
var contractDefinition;
|
|
380
391
|
return __generator(this, function (_b) {
|
|
381
392
|
contractDefinition = (0, provider_1.parseContract)(contract);
|
|
382
393
|
return [2 /*return*/, this.fetchEndpoint('starknet_addDeployTransaction', {
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
394
|
+
deploy_transaction: {
|
|
395
|
+
contract_address_salt: addressSalt !== null && addressSalt !== void 0 ? addressSalt : (0, stark_1.randomAddress)(),
|
|
396
|
+
constructor_calldata: (0, number_1.bigNumberishArrayToHexadecimalStringArray)(constructorCalldata !== null && constructorCalldata !== void 0 ? constructorCalldata : []),
|
|
397
|
+
contract_class: {
|
|
398
|
+
program: contractDefinition.program,
|
|
399
|
+
entry_points_by_type: contractDefinition.entry_points_by_type,
|
|
400
|
+
abi: contractDefinition.abi,
|
|
401
|
+
},
|
|
402
|
+
type: 'DEPLOY',
|
|
403
|
+
version: (0, number_1.toHex)((0, number_1.toBN)((details === null || details === void 0 ? void 0 : details.version) || 0)),
|
|
389
404
|
},
|
|
390
405
|
})];
|
|
391
406
|
});
|
|
392
407
|
});
|
|
393
408
|
};
|
|
394
|
-
RpcProvider.prototype.deployAccountContract = function (_a) {
|
|
395
|
-
var classHash = _a.classHash, constructorCalldata = _a.constructorCalldata, addressSalt = _a.addressSalt;
|
|
409
|
+
RpcProvider.prototype.deployAccountContract = function (_a, details) {
|
|
410
|
+
var classHash = _a.classHash, constructorCalldata = _a.constructorCalldata, addressSalt = _a.addressSalt, signature = _a.signature;
|
|
396
411
|
return __awaiter(this, void 0, void 0, function () {
|
|
397
412
|
return __generator(this, function (_b) {
|
|
398
413
|
return [2 /*return*/, this.fetchEndpoint('starknet_addDeployAccountTransaction', {
|
|
399
414
|
constructor_calldata: (0, number_1.bigNumberishArrayToHexadecimalStringArray)(constructorCalldata || []),
|
|
400
415
|
class_hash: (0, number_1.toHex)((0, number_1.toBN)(classHash)),
|
|
401
416
|
contract_address_salt: (0, number_1.toHex)((0, number_1.toBN)(addressSalt || 0)),
|
|
417
|
+
type: 'DEPLOY',
|
|
418
|
+
max_fee: (0, number_1.toHex)((0, number_1.toBN)(details.maxFee || 0)),
|
|
419
|
+
version: (0, number_1.toHex)((0, number_1.toBN)(details.version || 0)),
|
|
420
|
+
signature: (0, number_1.bigNumberishArrayToHexadecimalStringArray)(signature || []),
|
|
421
|
+
nonce: (0, number_1.toHex)((0, number_1.toBN)(details.nonce)),
|
|
402
422
|
})];
|
|
403
423
|
});
|
|
404
424
|
});
|
|
@@ -407,13 +427,15 @@ var RpcProvider = /** @class */ (function () {
|
|
|
407
427
|
return __awaiter(this, void 0, void 0, function () {
|
|
408
428
|
return __generator(this, function (_a) {
|
|
409
429
|
return [2 /*return*/, this.fetchEndpoint('starknet_addInvokeTransaction', {
|
|
410
|
-
|
|
411
|
-
|
|
430
|
+
invoke_transaction: {
|
|
431
|
+
sender_address: functionInvocation.contractAddress,
|
|
412
432
|
calldata: (0, provider_1.parseCalldata)(functionInvocation.calldata),
|
|
433
|
+
type: 'INVOKE',
|
|
434
|
+
max_fee: (0, number_1.toHex)((0, number_1.toBN)(details.maxFee || 0)),
|
|
435
|
+
version: (0, number_1.toHex)((0, number_1.toBN)(details.version || 0)),
|
|
436
|
+
signature: (0, number_1.bigNumberishArrayToHexadecimalStringArray)(functionInvocation.signature || []),
|
|
437
|
+
nonce: (0, number_1.toHex)((0, number_1.toBN)(details.nonce)),
|
|
413
438
|
},
|
|
414
|
-
signature: (0, number_1.bigNumberishArrayToHexadecimalStringArray)(functionInvocation.signature || []),
|
|
415
|
-
max_fee: (0, number_1.toHex)((0, number_1.toBN)(details.maxFee || 0)),
|
|
416
|
-
version: (0, number_1.toHex)((0, number_1.toBN)(details.version || 0)),
|
|
417
439
|
})];
|
|
418
440
|
});
|
|
419
441
|
});
|
|
@@ -459,7 +481,7 @@ var RpcProvider = /** @class */ (function () {
|
|
|
459
481
|
RpcProvider.prototype.waitForTransaction = function (txHash, retryInterval) {
|
|
460
482
|
if (retryInterval === void 0) { retryInterval = 8000; }
|
|
461
483
|
return __awaiter(this, void 0, void 0, function () {
|
|
462
|
-
var retries, onchain, successStates, errorStates, res, message, error, error_2;
|
|
484
|
+
var retries, onchain, successStates, errorStates, res, error, message, error, error_2;
|
|
463
485
|
return __generator(this, function (_a) {
|
|
464
486
|
switch (_a.label) {
|
|
465
487
|
case 0:
|
|
@@ -481,6 +503,10 @@ var RpcProvider = /** @class */ (function () {
|
|
|
481
503
|
return [4 /*yield*/, this.getTransactionReceipt(txHash)];
|
|
482
504
|
case 4:
|
|
483
505
|
res = _a.sent();
|
|
506
|
+
if (!('status' in res)) {
|
|
507
|
+
error = new Error('pending transaction');
|
|
508
|
+
throw error;
|
|
509
|
+
}
|
|
484
510
|
if (res.status && successStates.includes(res.status)) {
|
|
485
511
|
onchain = true;
|
|
486
512
|
}
|
|
@@ -519,6 +545,7 @@ var RpcProvider = /** @class */ (function () {
|
|
|
519
545
|
* @returns Number of transactions
|
|
520
546
|
*/
|
|
521
547
|
RpcProvider.prototype.getTransactionCount = function (blockIdentifier) {
|
|
548
|
+
if (blockIdentifier === void 0) { blockIdentifier = 'pending'; }
|
|
522
549
|
return __awaiter(this, void 0, void 0, function () {
|
|
523
550
|
var block_id;
|
|
524
551
|
return __generator(this, function (_a) {
|
|
@@ -38,6 +38,8 @@ export declare class SequencerProvider implements ProviderInterface {
|
|
|
38
38
|
getTransaction(txHash: BigNumberish): Promise<GetTransactionResponse>;
|
|
39
39
|
getTransactionReceipt(txHash: BigNumberish): Promise<GetTransactionReceiptResponse>;
|
|
40
40
|
getClassAt(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<ContractClass>;
|
|
41
|
+
getClassHashAt(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<string>;
|
|
42
|
+
getClass(classHash: string): Promise<ContractClass>;
|
|
41
43
|
invokeFunction(functionInvocation: Invocation, details: InvocationsDetailsWithNonce): Promise<InvokeFunctionResponse>;
|
|
42
44
|
deployContract({ contract, constructorCalldata, addressSalt, }: DeployContractPayload): Promise<DeployContractResponse>;
|
|
43
45
|
deployAccountContract({ classHash, constructorCalldata, addressSalt, signature }: DeployAccountContractTransaction, details: InvocationsDetailsWithNonce): Promise<DeployContractResponse>;
|
|
@@ -326,6 +326,21 @@ var SequencerProvider = /** @class */ (function () {
|
|
|
326
326
|
});
|
|
327
327
|
});
|
|
328
328
|
};
|
|
329
|
+
SequencerProvider.prototype.getClassHashAt = function (contractAddress, blockIdentifier) {
|
|
330
|
+
if (blockIdentifier === void 0) { blockIdentifier = 'pending'; }
|
|
331
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
332
|
+
return __generator(this, function (_a) {
|
|
333
|
+
return [2 /*return*/, this.fetchEndpoint('get_class_hash_at', { blockIdentifier: blockIdentifier, contractAddress: contractAddress })];
|
|
334
|
+
});
|
|
335
|
+
});
|
|
336
|
+
};
|
|
337
|
+
SequencerProvider.prototype.getClass = function (classHash) {
|
|
338
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
339
|
+
return __generator(this, function (_a) {
|
|
340
|
+
return [2 /*return*/, this.fetchEndpoint('get_class_by_hash', { classHash: classHash }).then(provider_1.parseContract)];
|
|
341
|
+
});
|
|
342
|
+
});
|
|
343
|
+
};
|
|
329
344
|
SequencerProvider.prototype.invokeFunction = function (functionInvocation, details) {
|
|
330
345
|
var _a, _b;
|
|
331
346
|
return __awaiter(this, void 0, void 0, function () {
|