starknet 4.4.2 → 4.6.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 +26 -0
- package/README.md +3 -1
- package/__tests__/defaultProvider.test.ts +7 -9
- package/__tests__/rpcProvider.test.ts +107 -12
- package/__tests__/utils/utils.test.ts +17 -0
- package/account/default.js +13 -7
- package/dist/account/default.js +13 -7
- package/dist/provider/default.d.ts +1 -0
- package/dist/provider/default.js +7 -0
- package/dist/provider/interface.d.ts +6 -0
- package/dist/provider/rpc.d.ts +12 -2
- package/dist/provider/rpc.js +126 -70
- package/dist/provider/sequencer.d.ts +1 -0
- package/dist/provider/sequencer.js +9 -1
- package/dist/provider/utils.d.ts +11 -35
- package/dist/provider/utils.js +52 -63
- package/dist/types/api/openrpc.d.ts +392 -32
- package/dist/types/api/openrpc.js +21 -3
- package/dist/types/api/rpc.d.ts +74 -107
- package/dist/utils/responseParser/rpc.d.ts +7 -4
- package/dist/utils/responseParser/rpc.js +1 -1
- package/package.json +4 -1
- package/provider/default.d.ts +1 -0
- package/provider/default.js +7 -0
- package/provider/interface.d.ts +6 -0
- package/provider/rpc.d.ts +12 -2
- package/provider/rpc.js +126 -70
- package/provider/sequencer.d.ts +1 -0
- package/provider/sequencer.js +9 -1
- package/provider/utils.d.ts +11 -35
- package/provider/utils.js +52 -63
- package/src/account/default.ts +4 -2
- package/src/provider/default.ts +4 -0
- package/src/provider/interface.ts +7 -0
- package/src/provider/rpc.ts +90 -54
- package/src/provider/sequencer.ts +7 -2
- package/src/provider/utils.ts +43 -56
- package/src/types/api/openrpc.ts +371 -41
- package/src/types/api/rpc.ts +71 -125
- package/src/utils/responseParser/rpc.ts +9 -5
- package/types/api/openrpc.d.ts +392 -32
- package/types/api/openrpc.js +21 -3
- package/types/api/rpc.d.ts +74 -107
- package/utils/responseParser/rpc.d.ts +7 -4
- package/utils/responseParser/rpc.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,29 @@
|
|
|
1
|
+
# [4.6.0](https://github.com/0xs34n/starknet.js/compare/v4.5.0...v4.6.0) (2022-09-15)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
- add test getTransactionCount [skip ci] ([342755a](https://github.com/0xs34n/starknet.js/commit/342755aa99dda016d7aa394a0023b3f2e5d5e963))
|
|
6
|
+
- estimateFee and call block id ([ef1645f](https://github.com/0xs34n/starknet.js/commit/ef1645f740e7c29edea6b091bec9949ec713953f))
|
|
7
|
+
- rpc test update, comepleted rpc to openrpc mapping, rpc provider methods ([8b41e0f](https://github.com/0xs34n/starknet.js/commit/8b41e0fcf36b34b20dfaba356cfc0131f02d7d69))
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
- new Block utility object, rpc fetch clenup, open rpc fetch api ([0d381c8](https://github.com/0xs34n/starknet.js/commit/0d381c89fe655b2628f02e67095ef03cb1721398))
|
|
12
|
+
- read, write and trace api ([d488ab2](https://github.com/0xs34n/starknet.js/commit/d488ab2513b88fdeb4e27b6ec2b7226ffd359445))
|
|
13
|
+
- retry rpc wait for transaction 200 times instead of 100 ([3bc9118](https://github.com/0xs34n/starknet.js/commit/3bc9118cae86fba21e1c85667079079662ba0b7b))
|
|
14
|
+
- updated rpc tests with new methods ([e369d95](https://github.com/0xs34n/starknet.js/commit/e369d95d72f3b39b3e8b8baa99867b94c1d5d1c1))
|
|
15
|
+
|
|
16
|
+
# [4.5.0](https://github.com/0xs34n/starknet.js/compare/v4.4.2...v4.5.0) (2022-09-09)
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
- prevent undefined rpc chainId in account ([9f69229](https://github.com/0xs34n/starknet.js/commit/9f69229fcb5205bb3fd1fcc7eb7c627faa300561))
|
|
21
|
+
- repair chain fix ([d7758a6](https://github.com/0xs34n/starknet.js/commit/d7758a6d180cd1af89f8aefb37bce077b92c5fd5))
|
|
22
|
+
|
|
23
|
+
### Features
|
|
24
|
+
|
|
25
|
+
- optional abi field for deploy and declare rpc transactions ([ce62648](https://github.com/0xs34n/starknet.js/commit/ce626481cb6bc3dea77963482820ae6f50c82566))
|
|
26
|
+
|
|
1
27
|
## [4.4.2](https://github.com/0xs34n/starknet.js/compare/v4.4.1...v4.4.2) (2022-09-07)
|
|
2
28
|
|
|
3
29
|
### Bug Fixes
|
package/README.md
CHANGED
|
@@ -139,10 +139,11 @@ describe('defaultProvider', () => {
|
|
|
139
139
|
|
|
140
140
|
describeIfNotDevnet('Provider', () => {
|
|
141
141
|
const provider = getTestProvider();
|
|
142
|
+
let latestBlock;
|
|
142
143
|
describe(`Provider methods if not devnet`, () => {
|
|
143
144
|
describe('getBlock', () => {
|
|
144
|
-
test('pending', async () => {
|
|
145
|
-
|
|
145
|
+
test('getBlock by tag pending', async () => {
|
|
146
|
+
latestBlock = await provider.getBlock();
|
|
146
147
|
expect(latestBlock).toHaveProperty('block_hash');
|
|
147
148
|
expect(latestBlock).toHaveProperty('parent_hash');
|
|
148
149
|
expect(latestBlock).toHaveProperty('block_number');
|
|
@@ -153,11 +154,8 @@ describe('defaultProvider', () => {
|
|
|
153
154
|
expect(Array.isArray(latestBlock.transactions)).toBe(true);
|
|
154
155
|
});
|
|
155
156
|
|
|
156
|
-
test('
|
|
157
|
-
const block = await provider.getBlock(
|
|
158
|
-
'0x8a30a1212d142cb0053fe9921e1dbf64f651d328565bd2e7ac24059c270f43'
|
|
159
|
-
);
|
|
160
|
-
|
|
157
|
+
test('getBlock by Hash', async () => {
|
|
158
|
+
const block = await provider.getBlock(latestBlock.block_hash);
|
|
161
159
|
expect(block).toHaveProperty('block_hash');
|
|
162
160
|
expect(block).toHaveProperty('parent_hash');
|
|
163
161
|
expect(block).toHaveProperty('block_number');
|
|
@@ -168,8 +166,8 @@ describe('defaultProvider', () => {
|
|
|
168
166
|
expect(Array.isArray(block.transactions)).toBe(true);
|
|
169
167
|
});
|
|
170
168
|
|
|
171
|
-
test('
|
|
172
|
-
const block = await provider.getBlock(
|
|
169
|
+
test('getBlock by Number', async () => {
|
|
170
|
+
const block = await provider.getBlock(latestBlock.block_number);
|
|
173
171
|
expect(block).toHaveProperty('block_hash');
|
|
174
172
|
expect(block).toHaveProperty('parent_hash');
|
|
175
173
|
expect(block).toHaveProperty('block_number');
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Account, RpcProvider, ec } from '../src';
|
|
1
|
+
import { Account, GetBlockResponse, RpcProvider, ec } from '../src';
|
|
2
2
|
import {
|
|
3
|
+
compiledErc20,
|
|
3
4
|
compiledOpenZeppelinAccount,
|
|
4
5
|
describeIfRpc,
|
|
5
6
|
getTestAccount,
|
|
@@ -20,21 +21,115 @@ describeIfRpc('RPCProvider', () => {
|
|
|
20
21
|
accountPublicKey = ec.getStarkKey(accountKeyPair);
|
|
21
22
|
});
|
|
22
23
|
|
|
24
|
+
test('getChainId', async () => {
|
|
25
|
+
const chainId = await rpcProvider.getChainId();
|
|
26
|
+
expect(chainId).toBe('0x534e5f474f45524c49');
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
test('getPendingTransactions', async () => {
|
|
30
|
+
const transactions = await rpcProvider.getPendingTransactions();
|
|
31
|
+
expect(Array.isArray(transactions)).toBe(true);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
test('getTransactionCount', async () => {
|
|
35
|
+
const count = await rpcProvider.getTransactionCount('latest');
|
|
36
|
+
expect(typeof count).toBe('number');
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
test('getBlockHashAndNumber', async () => {
|
|
40
|
+
const blockHashAndNumber = await rpcProvider.getBlockHashAndNumber();
|
|
41
|
+
expect(blockHashAndNumber).toHaveProperty('block_hash');
|
|
42
|
+
expect(blockHashAndNumber).toHaveProperty('block_number');
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
test('getStateUpdate', async () => {
|
|
46
|
+
const stateUpdate = await rpcProvider.getStateUpdate('latest');
|
|
47
|
+
expect(stateUpdate).toHaveProperty('block_hash');
|
|
48
|
+
expect(stateUpdate).toHaveProperty('new_root');
|
|
49
|
+
expect(stateUpdate).toHaveProperty('old_root');
|
|
50
|
+
expect(stateUpdate).toHaveProperty('state_diff');
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
xtest('getProtocolVersion', async () => {
|
|
54
|
+
await rpcProvider.getProtocolVersion();
|
|
55
|
+
});
|
|
56
|
+
|
|
23
57
|
describe('RPC methods', () => {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
58
|
+
let latestBlock: GetBlockResponse;
|
|
59
|
+
|
|
60
|
+
beforeAll(async () => {
|
|
61
|
+
latestBlock = await rpcProvider.getBlock('latest');
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
test('getBlockWithTxHashes', async () => {
|
|
65
|
+
const blockResponse = await rpcProvider.getBlockWithTxHashes(latestBlock.block_number);
|
|
66
|
+
expect(blockResponse).toHaveProperty('transactions');
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test('getBlockWithTxs', async () => {
|
|
70
|
+
const blockResponse = await rpcProvider.getBlockWithTxs(latestBlock.block_number);
|
|
71
|
+
expect(blockResponse).toHaveProperty('transactions');
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
test('getTransactionByBlockIdAndIndex', async () => {
|
|
75
|
+
const transaction = await rpcProvider.getTransactionByBlockIdAndIndex(
|
|
76
|
+
latestBlock.block_number,
|
|
77
|
+
0
|
|
78
|
+
);
|
|
79
|
+
expect(transaction).toHaveProperty('transaction_hash');
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
xtest('traceBlockTransactions', async () => {
|
|
83
|
+
await rpcProvider.traceBlockTransactions(latestBlock.block_hash);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
describe('deploy contract related tests', () => {
|
|
87
|
+
let contract_address;
|
|
88
|
+
let transaction_hash;
|
|
89
|
+
|
|
90
|
+
beforeAll(async () => {
|
|
91
|
+
({ contract_address, transaction_hash } = await rpcProvider.deployContract({
|
|
92
|
+
contract: compiledOpenZeppelinAccount,
|
|
93
|
+
constructorCalldata: [accountPublicKey],
|
|
94
|
+
addressSalt: accountPublicKey,
|
|
95
|
+
}));
|
|
96
|
+
await rpcProvider.waitForTransaction(transaction_hash);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
test('deployContract result', () => {
|
|
100
|
+
expect(contract_address).toBeTruthy();
|
|
101
|
+
expect(transaction_hash).toBeTruthy();
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
test('getTransactionByHash', async () => {
|
|
105
|
+
const transaction = await rpcProvider.getTransactionByHash(transaction_hash);
|
|
106
|
+
expect(transaction).toHaveProperty('transaction_hash');
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
test('getClassHashAt', async () => {
|
|
110
|
+
const classHash = await rpcProvider.getClassHashAt('latest', contract_address);
|
|
111
|
+
expect(typeof classHash).toBe('string');
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
xtest('traceTransaction', async () => {
|
|
115
|
+
await rpcProvider.traceTransaction(transaction_hash);
|
|
116
|
+
});
|
|
27
117
|
});
|
|
28
118
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
119
|
+
describe('declare contract related tests', () => {
|
|
120
|
+
let class_hash;
|
|
121
|
+
|
|
122
|
+
beforeAll(async () => {
|
|
123
|
+
({ class_hash } = await rpcProvider.declareContract({
|
|
124
|
+
contract: compiledErc20,
|
|
125
|
+
}));
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
test('getClass', async () => {
|
|
129
|
+
const contractClass = await rpcProvider.getClass(class_hash);
|
|
130
|
+
expect(contractClass).toHaveProperty('program');
|
|
131
|
+
expect(contractClass).toHaveProperty('entry_points_by_type');
|
|
34
132
|
});
|
|
35
|
-
await rpcProvider.waitForTransaction(transaction_hash);
|
|
36
|
-
expect(contract_address).toBeTruthy();
|
|
37
|
-
expect(transaction_hash).toBeTruthy();
|
|
38
133
|
});
|
|
39
134
|
|
|
40
135
|
test.todo('getEstimateFee');
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
|
|
3
3
|
import { constants, hash, json, number, stark } from '../../src';
|
|
4
|
+
import { Block } from '../../src/provider/utils';
|
|
4
5
|
import { pedersen } from '../../src/utils/hash';
|
|
5
6
|
|
|
6
7
|
const { IS_BROWSER } = constants;
|
|
@@ -112,3 +113,19 @@ describe('calculateContractAddressFromHash()', () => {
|
|
|
112
113
|
);
|
|
113
114
|
});
|
|
114
115
|
});
|
|
116
|
+
|
|
117
|
+
describe('new Block()', () => {
|
|
118
|
+
test('Block identifier and queryIdentifier', () => {
|
|
119
|
+
const blockA = new Block(0);
|
|
120
|
+
expect(blockA.identifier).toMatchObject({ block_number: 0 });
|
|
121
|
+
expect(blockA.queryIdentifier).toBe('blockNumber=0');
|
|
122
|
+
|
|
123
|
+
const blockB = new Block('latest');
|
|
124
|
+
expect(blockB.identifier).toBe('latest');
|
|
125
|
+
expect(blockB.queryIdentifier).toBe('blockNumber=latest');
|
|
126
|
+
|
|
127
|
+
const blockC = new Block('0x01');
|
|
128
|
+
expect(blockC.identifier).toMatchObject({ block_hash: '0x01' });
|
|
129
|
+
expect(blockC.queryIdentifier).toBe('blockHash=0x01');
|
|
130
|
+
});
|
|
131
|
+
});
|
package/account/default.js
CHANGED
|
@@ -99,7 +99,7 @@ var Account = /** @class */ (function (_super) {
|
|
|
99
99
|
Account.prototype.estimateFee = function (calls, _a) {
|
|
100
100
|
var _b = _a === void 0 ? {} : _a, providedNonce = _b.nonce, blockIdentifier = _b.blockIdentifier;
|
|
101
101
|
return __awaiter(this, void 0, void 0, function () {
|
|
102
|
-
var transactions, nonce, _c, version, signerDetails, signature, calldata, response, suggestedMaxFee;
|
|
102
|
+
var transactions, nonce, _c, version, chainId, signerDetails, signature, calldata, response, suggestedMaxFee;
|
|
103
103
|
return __generator(this, function (_d) {
|
|
104
104
|
switch (_d.label) {
|
|
105
105
|
case 0:
|
|
@@ -114,19 +114,22 @@ var Account = /** @class */ (function (_super) {
|
|
|
114
114
|
case 3:
|
|
115
115
|
nonce = _c;
|
|
116
116
|
version = (0, number_1.toBN)(hash_1.feeTransactionVersion);
|
|
117
|
+
return [4 /*yield*/, this.getChainId()];
|
|
118
|
+
case 4:
|
|
119
|
+
chainId = _d.sent();
|
|
117
120
|
signerDetails = {
|
|
118
121
|
walletAddress: this.address,
|
|
119
122
|
nonce: (0, number_1.toBN)(nonce),
|
|
120
123
|
maxFee: constants_1.ZERO,
|
|
121
124
|
version: version,
|
|
122
|
-
chainId:
|
|
125
|
+
chainId: chainId,
|
|
123
126
|
};
|
|
124
127
|
return [4 /*yield*/, this.signer.signTransaction(transactions, signerDetails)];
|
|
125
|
-
case
|
|
128
|
+
case 5:
|
|
126
129
|
signature = _d.sent();
|
|
127
130
|
calldata = (0, transaction_1.fromCallsToExecuteCalldataWithNonce)(transactions, nonce);
|
|
128
131
|
return [4 /*yield*/, _super.prototype.getEstimateFee.call(this, { contractAddress: this.address, entrypoint: '__execute__', calldata: calldata, signature: signature }, blockIdentifier, { version: version })];
|
|
129
|
-
case
|
|
132
|
+
case 6:
|
|
130
133
|
response = _d.sent();
|
|
131
134
|
suggestedMaxFee = (0, stark_1.estimatedFeeToMaxFee)(response.overall_fee);
|
|
132
135
|
return [2 /*return*/, __assign(__assign({}, response), { suggestedMaxFee: suggestedMaxFee })];
|
|
@@ -149,7 +152,7 @@ var Account = /** @class */ (function (_super) {
|
|
|
149
152
|
if (abis === void 0) { abis = undefined; }
|
|
150
153
|
if (transactionsDetail === void 0) { transactionsDetail = {}; }
|
|
151
154
|
return __awaiter(this, void 0, void 0, function () {
|
|
152
|
-
var transactions, nonce, _b, _c, maxFee, suggestedMaxFee, version, signerDetails, signature, calldata;
|
|
155
|
+
var transactions, nonce, _b, _c, maxFee, suggestedMaxFee, version, chainId, signerDetails, signature, calldata;
|
|
153
156
|
return __generator(this, function (_d) {
|
|
154
157
|
switch (_d.label) {
|
|
155
158
|
case 0:
|
|
@@ -175,15 +178,18 @@ var Account = /** @class */ (function (_super) {
|
|
|
175
178
|
_d.label = 6;
|
|
176
179
|
case 6:
|
|
177
180
|
version = (0, number_1.toBN)(hash_1.transactionVersion);
|
|
181
|
+
return [4 /*yield*/, this.getChainId()];
|
|
182
|
+
case 7:
|
|
183
|
+
chainId = _d.sent();
|
|
178
184
|
signerDetails = {
|
|
179
185
|
walletAddress: this.address,
|
|
180
186
|
nonce: nonce,
|
|
181
187
|
maxFee: maxFee,
|
|
182
188
|
version: version,
|
|
183
|
-
chainId:
|
|
189
|
+
chainId: chainId,
|
|
184
190
|
};
|
|
185
191
|
return [4 /*yield*/, this.signer.signTransaction(transactions, signerDetails, abis)];
|
|
186
|
-
case
|
|
192
|
+
case 8:
|
|
187
193
|
signature = _d.sent();
|
|
188
194
|
calldata = (0, transaction_1.fromCallsToExecuteCalldataWithNonce)(transactions, nonce);
|
|
189
195
|
return [2 /*return*/, this.invokeFunction({ contractAddress: this.address, entrypoint: '__execute__', calldata: calldata, signature: signature }, {
|
package/dist/account/default.js
CHANGED
|
@@ -99,7 +99,7 @@ var Account = /** @class */ (function (_super) {
|
|
|
99
99
|
Account.prototype.estimateFee = function (calls, _a) {
|
|
100
100
|
var _b = _a === void 0 ? {} : _a, providedNonce = _b.nonce, blockIdentifier = _b.blockIdentifier;
|
|
101
101
|
return __awaiter(this, void 0, void 0, function () {
|
|
102
|
-
var transactions, nonce, _c, version, signerDetails, signature, calldata, response, suggestedMaxFee;
|
|
102
|
+
var transactions, nonce, _c, version, chainId, signerDetails, signature, calldata, response, suggestedMaxFee;
|
|
103
103
|
return __generator(this, function (_d) {
|
|
104
104
|
switch (_d.label) {
|
|
105
105
|
case 0:
|
|
@@ -114,19 +114,22 @@ var Account = /** @class */ (function (_super) {
|
|
|
114
114
|
case 3:
|
|
115
115
|
nonce = _c;
|
|
116
116
|
version = (0, number_1.toBN)(hash_1.feeTransactionVersion);
|
|
117
|
+
return [4 /*yield*/, this.getChainId()];
|
|
118
|
+
case 4:
|
|
119
|
+
chainId = _d.sent();
|
|
117
120
|
signerDetails = {
|
|
118
121
|
walletAddress: this.address,
|
|
119
122
|
nonce: (0, number_1.toBN)(nonce),
|
|
120
123
|
maxFee: constants_1.ZERO,
|
|
121
124
|
version: version,
|
|
122
|
-
chainId:
|
|
125
|
+
chainId: chainId,
|
|
123
126
|
};
|
|
124
127
|
return [4 /*yield*/, this.signer.signTransaction(transactions, signerDetails)];
|
|
125
|
-
case
|
|
128
|
+
case 5:
|
|
126
129
|
signature = _d.sent();
|
|
127
130
|
calldata = (0, transaction_1.fromCallsToExecuteCalldataWithNonce)(transactions, nonce);
|
|
128
131
|
return [4 /*yield*/, _super.prototype.getEstimateFee.call(this, { contractAddress: this.address, entrypoint: '__execute__', calldata: calldata, signature: signature }, blockIdentifier, { version: version })];
|
|
129
|
-
case
|
|
132
|
+
case 6:
|
|
130
133
|
response = _d.sent();
|
|
131
134
|
suggestedMaxFee = (0, stark_1.estimatedFeeToMaxFee)(response.overall_fee);
|
|
132
135
|
return [2 /*return*/, __assign(__assign({}, response), { suggestedMaxFee: suggestedMaxFee })];
|
|
@@ -149,7 +152,7 @@ var Account = /** @class */ (function (_super) {
|
|
|
149
152
|
if (abis === void 0) { abis = undefined; }
|
|
150
153
|
if (transactionsDetail === void 0) { transactionsDetail = {}; }
|
|
151
154
|
return __awaiter(this, void 0, void 0, function () {
|
|
152
|
-
var transactions, nonce, _b, _c, maxFee, suggestedMaxFee, version, signerDetails, signature, calldata;
|
|
155
|
+
var transactions, nonce, _b, _c, maxFee, suggestedMaxFee, version, chainId, signerDetails, signature, calldata;
|
|
153
156
|
return __generator(this, function (_d) {
|
|
154
157
|
switch (_d.label) {
|
|
155
158
|
case 0:
|
|
@@ -175,15 +178,18 @@ var Account = /** @class */ (function (_super) {
|
|
|
175
178
|
_d.label = 6;
|
|
176
179
|
case 6:
|
|
177
180
|
version = (0, number_1.toBN)(hash_1.transactionVersion);
|
|
181
|
+
return [4 /*yield*/, this.getChainId()];
|
|
182
|
+
case 7:
|
|
183
|
+
chainId = _d.sent();
|
|
178
184
|
signerDetails = {
|
|
179
185
|
walletAddress: this.address,
|
|
180
186
|
nonce: nonce,
|
|
181
187
|
maxFee: maxFee,
|
|
182
188
|
version: version,
|
|
183
|
-
chainId:
|
|
189
|
+
chainId: chainId,
|
|
184
190
|
};
|
|
185
191
|
return [4 /*yield*/, this.signer.signTransaction(transactions, signerDetails, abis)];
|
|
186
|
-
case
|
|
192
|
+
case 8:
|
|
187
193
|
signature = _d.sent();
|
|
188
194
|
calldata = (0, transaction_1.fromCallsToExecuteCalldataWithNonce)(transactions, nonce);
|
|
189
195
|
return [2 /*return*/, this.invokeFunction({ contractAddress: this.address, entrypoint: '__execute__', calldata: calldata, signature: signature }, {
|
|
@@ -13,6 +13,7 @@ export declare class Provider implements ProviderInterface {
|
|
|
13
13
|
private provider;
|
|
14
14
|
constructor(providerOrOptions?: ProviderOptions | ProviderInterface);
|
|
15
15
|
get chainId(): StarknetChainId;
|
|
16
|
+
getChainId(): Promise<StarknetChainId>;
|
|
16
17
|
getBlock(blockIdentifier?: BlockIdentifier): Promise<GetBlockResponse>;
|
|
17
18
|
getClassAt(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<ContractClass>;
|
|
18
19
|
getEstimateFee(invocation: Invocation, blockIdentifier?: BlockIdentifier, invocationDetails?: InvocationsDetails): Promise<EstimateFeeResponse>;
|
package/dist/provider/default.js
CHANGED
|
@@ -61,6 +61,13 @@ var Provider = /** @class */ (function () {
|
|
|
61
61
|
enumerable: false,
|
|
62
62
|
configurable: true
|
|
63
63
|
});
|
|
64
|
+
Provider.prototype.getChainId = function () {
|
|
65
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
66
|
+
return __generator(this, function (_a) {
|
|
67
|
+
return [2 /*return*/, this.provider.getChainId()];
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
};
|
|
64
71
|
Provider.prototype.getBlock = function (blockIdentifier) {
|
|
65
72
|
if (blockIdentifier === void 0) { blockIdentifier = 'pending'; }
|
|
66
73
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -4,6 +4,12 @@ import type { BigNumberish } from '../utils/number';
|
|
|
4
4
|
import { BlockIdentifier } from './utils';
|
|
5
5
|
export declare abstract class ProviderInterface {
|
|
6
6
|
abstract chainId: StarknetChainId;
|
|
7
|
+
/**
|
|
8
|
+
* Gets the Starknet chain Id
|
|
9
|
+
*
|
|
10
|
+
* @returns the chain Id
|
|
11
|
+
*/
|
|
12
|
+
abstract getChainId(): Promise<StarknetChainId>;
|
|
7
13
|
/**
|
|
8
14
|
* Calls a function on the StarkNet contract.
|
|
9
15
|
*
|
package/dist/provider/rpc.d.ts
CHANGED
|
@@ -12,24 +12,34 @@ export declare class RpcProvider implements ProviderInterface {
|
|
|
12
12
|
chainId: StarknetChainId;
|
|
13
13
|
private responseParser;
|
|
14
14
|
constructor(optionsOrProvider: RpcProviderOptions);
|
|
15
|
+
fetch(method: any, params: any): Promise<any>;
|
|
16
|
+
protected errorHandler(error: any): void;
|
|
15
17
|
protected fetchEndpoint<T extends keyof RPC.Methods>(method: T, request?: RPC.Methods[T]['REQUEST']): Promise<RPC.Methods[T]['RESPONSE']>;
|
|
16
|
-
getChainId(): Promise<
|
|
18
|
+
getChainId(): Promise<any>;
|
|
17
19
|
getBlock(blockIdentifier?: BlockIdentifier): Promise<GetBlockResponse>;
|
|
20
|
+
getBlockHashAndNumber(): Promise<RPC.BlockHashAndNumber>;
|
|
18
21
|
getBlockWithTxHashes(blockIdentifier?: BlockIdentifier): Promise<RPC.GetBlockWithTxHashesResponse>;
|
|
19
22
|
getBlockWithTxs(blockIdentifier?: BlockIdentifier): Promise<RPC.GetBlockWithTxs>;
|
|
23
|
+
getClassHashAt(blockIdentifier: BlockIdentifier, contractAddress: RPC.ContractAddress): Promise<RPC.Felt>;
|
|
20
24
|
getNonce(contractAddress: string): Promise<any>;
|
|
25
|
+
getPendingTransactions(): Promise<RPC.PendingTransactions>;
|
|
26
|
+
getProtocolVersion(): Promise<Error>;
|
|
27
|
+
getStateUpdate(blockIdentifier: BlockIdentifier): Promise<RPC.StateUpdate>;
|
|
21
28
|
getStorageAt(contractAddress: string, key: BigNumberish, blockIdentifier?: BlockIdentifier): Promise<BigNumberish>;
|
|
22
29
|
getTransaction(txHash: BigNumberish): Promise<GetTransactionResponse>;
|
|
23
30
|
getTransactionByHash(txHash: BigNumberish): Promise<RPC.GetTransactionByHashResponse>;
|
|
24
31
|
getTransactionByBlockIdAndIndex(blockIdentifier: BlockIdentifier, index: number): Promise<RPC.GetTransactionByBlockIdAndIndex>;
|
|
25
32
|
getTransactionReceipt(txHash: BigNumberish): Promise<GetTransactionReceiptResponse>;
|
|
33
|
+
getClass(classHash: RPC.Felt): Promise<RPC.ContractClass>;
|
|
26
34
|
getClassAt(contractAddress: string, blockIdentifier: BlockIdentifier): Promise<any>;
|
|
35
|
+
getCode(_contractAddress: string, _blockIdentifier?: BlockIdentifier): Promise<GetCodeResponse>;
|
|
27
36
|
getEstimateFee(invocation: Invocation, blockIdentifier?: BlockIdentifier, invocationDetails?: InvocationsDetails): Promise<EstimateFeeResponse>;
|
|
28
37
|
declareContract({ contract, version, }: DeclareContractPayload): Promise<DeclareContractResponse>;
|
|
29
38
|
deployContract({ contract, constructorCalldata, addressSalt, }: DeployContractPayload): Promise<DeployContractResponse>;
|
|
30
39
|
invokeFunction(functionInvocation: Invocation, details: InvocationsDetails): Promise<InvokeFunctionResponse>;
|
|
31
40
|
callContract(call: Call, blockIdentifier?: BlockIdentifier): Promise<CallContractResponse>;
|
|
32
|
-
|
|
41
|
+
traceTransaction(transactionHash: RPC.TransactionHash): Promise<RPC.Trace>;
|
|
42
|
+
traceBlockTransactions(blockHash: RPC.BlockHash): Promise<RPC.Traces>;
|
|
33
43
|
waitForTransaction(txHash: BigNumberish, retryInterval?: number): Promise<void>;
|
|
34
44
|
/**
|
|
35
45
|
* Gets the transaction count from a block.
|