starknet 3.11.0 → 3.12.2
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/.releaserc +1 -1
- package/CHANGELOG.md +23 -0
- package/README.md +2 -0
- package/__tests__/jest.setup.ts +23 -4
- package/account/default.d.ts +5 -3
- package/account/default.js +37 -6
- package/account/interface.d.ts +2 -2
- package/contract/default.d.ts +1 -1
- package/dist/account/default.d.ts +6 -3
- package/dist/account/default.js +23 -6
- package/dist/account/interface.d.ts +3 -2
- package/dist/contract/default.d.ts +1 -1
- package/dist/provider/default.js +27 -43
- package/dist/provider/utils.js +2 -2
- package/dist/types/account.d.ts +5 -0
- package/dist/types/account.js +2 -0
- package/dist/types/lib.d.ts +1 -1
- package/dist/utils/stark.js +1 -1
- package/package.json +5 -4
- package/provider/default.js +35 -55
- package/provider/utils.js +2 -2
- package/src/account/default.ts +14 -6
- package/src/account/interface.ts +2 -2
- package/src/provider/default.ts +20 -29
- package/src/provider/utils.ts +2 -2
- package/src/types/account.ts +7 -0
- package/src/types/lib.ts +1 -1
- package/src/utils/stark.ts +1 -1
- package/types/account.d.ts +6 -0
- package/types/account.js +2 -0
- package/types/lib.d.ts +1 -1
- package/utils/stark.js +1 -1
package/.releaserc
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,26 @@
|
|
|
1
|
+
## [3.12.2](https://github.com/0xs34n/starknet.js/compare/v3.12.1...v3.12.2) (2022-05-30)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
- allow starknet.js in service workers ([7a500d1](https://github.com/0xs34n/starknet.js/commit/7a500d198cffed43f98a669edac2dbb215884a3b))
|
|
6
|
+
- updated powered by starknet list ([aa36463](https://github.com/0xs34n/starknet.js/commit/aa36463e1adb281f79bf8462b2f0063801457782))
|
|
7
|
+
|
|
8
|
+
## [3.12.1](https://github.com/0xs34n/starknet.js/compare/v3.12.0...v3.12.1) (2022-05-24)
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
- update repo url ([c1312c0](https://github.com/0xs34n/starknet.js/commit/c1312c0e00e3387a49d1d7edc33e584687d607ea))
|
|
13
|
+
|
|
14
|
+
# [3.12.0](https://github.com/seanjameshan/starknet.js/compare/v3.11.0...v3.12.0) (2022-05-24)
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
|
|
18
|
+
- always default to latest block ([dafc575](https://github.com/seanjameshan/starknet.js/commit/dafc57550b9b175b79ec2fd728504ee14a992620))
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
- add suggestedMaxFee ([8977772](https://github.com/seanjameshan/starknet.js/commit/8977772763ecd895006c00c9cbe1397429a19b6f))
|
|
23
|
+
|
|
1
24
|
# [3.11.0](https://github.com/seanjameshan/starknet.js/compare/v3.10.3...v3.11.0) (2022-05-11)
|
|
2
25
|
|
|
3
26
|
### Bug Fixes
|
package/README.md
CHANGED
|
@@ -57,8 +57,10 @@ Guides can be found [here](https://www.starknetjs.com/guides/intro)
|
|
|
57
57
|
## 🚀 Powered by Starknet.js
|
|
58
58
|
|
|
59
59
|
- [Argent X - the first StarkNet wallet](https://github.com/argentlabs/argent-x)
|
|
60
|
+
- [Braavos - your new wallet on top of StarkNet](https://chrome.google.com/webstore/detail/braavos-wallet/jnlgamecbpmbajjfhmmmlhejkemejdma)
|
|
60
61
|
- [React + Starknet.js boilerplate](https://github.com/fracek/starknet-react-example)
|
|
61
62
|
- [AMM Demo](https://www.starknetswap.com/)
|
|
63
|
+
- [mySwap - the first DeFi app to launch on StarkNet](myswap.xyz)
|
|
62
64
|
|
|
63
65
|
## ✏️ Contributing
|
|
64
66
|
|
package/__tests__/jest.setup.ts
CHANGED
|
@@ -1,9 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
import { register } from 'fetch-intercept';
|
|
3
3
|
|
|
4
4
|
jest.setTimeout(50 * 60 * 1000);
|
|
5
5
|
|
|
6
6
|
if (process.env.DEBUG === 'true') {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
register({
|
|
8
|
+
request(url, config) {
|
|
9
|
+
console.log('[fetch.request]', [url, config]);
|
|
10
|
+
return [url, config];
|
|
11
|
+
},
|
|
12
|
+
|
|
13
|
+
requestError(error) {
|
|
14
|
+
console.log('[fetch.requestError]', error);
|
|
15
|
+
return Promise.reject(error);
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
response(response) {
|
|
19
|
+
console.log('[fetch.response]', response);
|
|
20
|
+
return response;
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
responseError(error) {
|
|
24
|
+
console.log('[fetch.responseError]', error);
|
|
25
|
+
return Promise.reject(error);
|
|
26
|
+
},
|
|
27
|
+
});
|
|
9
28
|
}
|
package/account/default.d.ts
CHANGED
|
@@ -5,12 +5,12 @@ import {
|
|
|
5
5
|
Abi,
|
|
6
6
|
AddTransactionResponse,
|
|
7
7
|
Call,
|
|
8
|
-
EstimateFeeResponse,
|
|
9
8
|
InvocationsDetails,
|
|
10
9
|
KeyPair,
|
|
11
10
|
Signature,
|
|
12
11
|
Transaction,
|
|
13
12
|
} from '../types';
|
|
13
|
+
import { EstimateFee } from '../types/account';
|
|
14
14
|
import { BigNumberish } from '../utils/number';
|
|
15
15
|
import { TypedData } from '../utils/typedData';
|
|
16
16
|
import { AccountInterface } from './interface';
|
|
@@ -32,13 +32,15 @@ export declare class Account extends Provider implements AccountInterface {
|
|
|
32
32
|
nonce?: BigNumberish;
|
|
33
33
|
blockIdentifier?: BlockIdentifier;
|
|
34
34
|
}
|
|
35
|
-
): Promise<
|
|
35
|
+
): Promise<EstimateFee>;
|
|
36
36
|
/**
|
|
37
37
|
* Invoke execute function in account contract
|
|
38
38
|
*
|
|
39
39
|
* [Reference](https://github.com/starkware-libs/cairo-lang/blob/f464ec4797361b6be8989e36e02ec690e74ef285/src/starkware/starknet/services/api/gateway/gateway_client.py#L13-L17)
|
|
40
40
|
*
|
|
41
|
-
* @param
|
|
41
|
+
* @param calls - one or more calls to be executed
|
|
42
|
+
* @param abis - one or more abis which can be used to display the calls
|
|
43
|
+
* @param transactionsDetail - optional transaction details
|
|
42
44
|
* @returns a confirmation of invoking a function on the starknet contract
|
|
43
45
|
*/
|
|
44
46
|
execute(
|
package/account/default.js
CHANGED
|
@@ -24,6 +24,20 @@ var __extends =
|
|
|
24
24
|
d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __());
|
|
25
25
|
};
|
|
26
26
|
})();
|
|
27
|
+
var __assign =
|
|
28
|
+
(this && this.__assign) ||
|
|
29
|
+
function () {
|
|
30
|
+
__assign =
|
|
31
|
+
Object.assign ||
|
|
32
|
+
function (t) {
|
|
33
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
34
|
+
s = arguments[i];
|
|
35
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
36
|
+
}
|
|
37
|
+
return t;
|
|
38
|
+
};
|
|
39
|
+
return __assign.apply(this, arguments);
|
|
40
|
+
};
|
|
27
41
|
var __awaiter =
|
|
28
42
|
(this && this.__awaiter) ||
|
|
29
43
|
function (thisArg, _arguments, P, generator) {
|
|
@@ -242,7 +256,15 @@ var Account = /** @class */ (function (_super) {
|
|
|
242
256
|
_c = _b.blockIdentifier,
|
|
243
257
|
blockIdentifier = _c === void 0 ? 'pending' : _c;
|
|
244
258
|
return __awaiter(this, void 0, void 0, function () {
|
|
245
|
-
var transactions,
|
|
259
|
+
var transactions,
|
|
260
|
+
nonce,
|
|
261
|
+
_d,
|
|
262
|
+
version,
|
|
263
|
+
signerDetails,
|
|
264
|
+
signature,
|
|
265
|
+
calldata,
|
|
266
|
+
fetchedEstimate,
|
|
267
|
+
suggestedMaxFee;
|
|
246
268
|
return __generator(this, function (_e) {
|
|
247
269
|
switch (_e.label) {
|
|
248
270
|
case 0:
|
|
@@ -270,7 +292,7 @@ var Account = /** @class */ (function (_super) {
|
|
|
270
292
|
signature = _e.sent();
|
|
271
293
|
calldata = (0, transaction_1.fromCallsToExecuteCalldataWithNonce)(transactions, nonce);
|
|
272
294
|
return [
|
|
273
|
-
|
|
295
|
+
4 /*yield*/,
|
|
274
296
|
this.fetchEndpoint(
|
|
275
297
|
'estimate_fee',
|
|
276
298
|
{ blockIdentifier: blockIdentifier },
|
|
@@ -283,6 +305,13 @@ var Account = /** @class */ (function (_super) {
|
|
|
283
305
|
}
|
|
284
306
|
),
|
|
285
307
|
];
|
|
308
|
+
case 5:
|
|
309
|
+
fetchedEstimate = _e.sent();
|
|
310
|
+
suggestedMaxFee = (0, stark_1.estimatedFeeToMaxFee)(fetchedEstimate.amount);
|
|
311
|
+
return [
|
|
312
|
+
2 /*return*/,
|
|
313
|
+
__assign(__assign({}, fetchedEstimate), { suggestedMaxFee: suggestedMaxFee }),
|
|
314
|
+
];
|
|
286
315
|
}
|
|
287
316
|
});
|
|
288
317
|
});
|
|
@@ -292,7 +321,9 @@ var Account = /** @class */ (function (_super) {
|
|
|
292
321
|
*
|
|
293
322
|
* [Reference](https://github.com/starkware-libs/cairo-lang/blob/f464ec4797361b6be8989e36e02ec690e74ef285/src/starkware/starknet/services/api/gateway/gateway_client.py#L13-L17)
|
|
294
323
|
*
|
|
295
|
-
* @param
|
|
324
|
+
* @param calls - one or more calls to be executed
|
|
325
|
+
* @param abis - one or more abis which can be used to display the calls
|
|
326
|
+
* @param transactionsDetail - optional transaction details
|
|
296
327
|
* @returns a confirmation of invoking a function on the starknet contract
|
|
297
328
|
*/
|
|
298
329
|
Account.prototype.execute = function (calls, abis, transactionsDetail) {
|
|
@@ -304,7 +335,7 @@ var Account = /** @class */ (function (_super) {
|
|
|
304
335
|
transactionsDetail = {};
|
|
305
336
|
}
|
|
306
337
|
return __awaiter(this, void 0, void 0, function () {
|
|
307
|
-
var transactions, nonce, _b, _c, maxFee,
|
|
338
|
+
var transactions, nonce, _b, _c, maxFee, suggestedMaxFee, signerDetails, signature, calldata;
|
|
308
339
|
return __generator(this, function (_d) {
|
|
309
340
|
switch (_d.label) {
|
|
310
341
|
case 0:
|
|
@@ -329,8 +360,8 @@ var Account = /** @class */ (function (_super) {
|
|
|
329
360
|
case 4:
|
|
330
361
|
return [4 /*yield*/, this.estimateFee(transactions, { nonce: nonce })];
|
|
331
362
|
case 5:
|
|
332
|
-
|
|
333
|
-
maxFee =
|
|
363
|
+
suggestedMaxFee = _d.sent().suggestedMaxFee;
|
|
364
|
+
maxFee = suggestedMaxFee.toString();
|
|
334
365
|
_d.label = 6;
|
|
335
366
|
case 6:
|
|
336
367
|
signerDetails = {
|
package/account/interface.d.ts
CHANGED
|
@@ -5,11 +5,11 @@ import {
|
|
|
5
5
|
AddTransactionResponse,
|
|
6
6
|
Call,
|
|
7
7
|
DeployContractPayload,
|
|
8
|
-
EstimateFeeResponse,
|
|
9
8
|
Invocation,
|
|
10
9
|
InvocationsDetails,
|
|
11
10
|
Signature,
|
|
12
11
|
} from '../types';
|
|
12
|
+
import { EstimateFee } from '../types/account';
|
|
13
13
|
import { BigNumberish } from '../utils/number';
|
|
14
14
|
import { TypedData } from '../utils/typedData/types';
|
|
15
15
|
export declare abstract class AccountInterface extends ProviderInterface {
|
|
@@ -40,7 +40,7 @@ export declare abstract class AccountInterface extends ProviderInterface {
|
|
|
40
40
|
*
|
|
41
41
|
* @returns response from addTransaction
|
|
42
42
|
*/
|
|
43
|
-
abstract estimateFee(invocation: Invocation): Promise<
|
|
43
|
+
abstract estimateFee(invocation: Invocation): Promise<EstimateFee>;
|
|
44
44
|
/**
|
|
45
45
|
* Invoke execute function in account contract
|
|
46
46
|
*
|
package/contract/default.d.ts
CHANGED
|
@@ -148,6 +148,6 @@ export declare class Contract implements ContractInterface {
|
|
|
148
148
|
blockIdentifier?: BlockIdentifier;
|
|
149
149
|
}
|
|
150
150
|
): Promise<Result>;
|
|
151
|
-
estimate(method: string, args?: Array<any>): Promise<import('../types').
|
|
151
|
+
estimate(method: string, args?: Array<any>): Promise<import('../types/account').EstimateFee>;
|
|
152
152
|
populate(method: string, args?: Array<any>): Invocation;
|
|
153
153
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Provider, ProviderInterface } from '../provider';
|
|
2
2
|
import { BlockIdentifier } from '../provider/utils';
|
|
3
3
|
import { SignerInterface } from '../signer';
|
|
4
|
-
import { Abi, AddTransactionResponse, Call,
|
|
4
|
+
import { Abi, AddTransactionResponse, Call, InvocationsDetails, KeyPair, Signature, Transaction } from '../types';
|
|
5
|
+
import { EstimateFee } from '../types/account';
|
|
5
6
|
import { BigNumberish } from '../utils/number';
|
|
6
7
|
import { TypedData } from '../utils/typedData';
|
|
7
8
|
import { AccountInterface } from './interface';
|
|
@@ -13,13 +14,15 @@ export declare class Account extends Provider implements AccountInterface {
|
|
|
13
14
|
estimateFee(calls: Call | Call[], { nonce: providedNonce, blockIdentifier, }?: {
|
|
14
15
|
nonce?: BigNumberish;
|
|
15
16
|
blockIdentifier?: BlockIdentifier;
|
|
16
|
-
}): Promise<
|
|
17
|
+
}): Promise<EstimateFee>;
|
|
17
18
|
/**
|
|
18
19
|
* Invoke execute function in account contract
|
|
19
20
|
*
|
|
20
21
|
* [Reference](https://github.com/starkware-libs/cairo-lang/blob/f464ec4797361b6be8989e36e02ec690e74ef285/src/starkware/starknet/services/api/gateway/gateway_client.py#L13-L17)
|
|
21
22
|
*
|
|
22
|
-
* @param
|
|
23
|
+
* @param calls - one or more calls to be executed
|
|
24
|
+
* @param abis - one or more abis which can be used to display the calls
|
|
25
|
+
* @param transactionsDetail - optional transaction details
|
|
23
26
|
* @returns a confirmation of invoking a function on the starknet contract
|
|
24
27
|
*/
|
|
25
28
|
execute(calls: Call | Call[], abis?: Abi[] | undefined, transactionsDetail?: InvocationsDetails): Promise<AddTransactionResponse>;
|
package/dist/account/default.js
CHANGED
|
@@ -14,6 +14,17 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
14
14
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
15
|
};
|
|
16
16
|
})();
|
|
17
|
+
var __assign = (this && this.__assign) || function () {
|
|
18
|
+
__assign = Object.assign || function(t) {
|
|
19
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
+
s = arguments[i];
|
|
21
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
+
t[p] = s[p];
|
|
23
|
+
}
|
|
24
|
+
return t;
|
|
25
|
+
};
|
|
26
|
+
return __assign.apply(this, arguments);
|
|
27
|
+
};
|
|
17
28
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
29
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
30
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -119,7 +130,7 @@ var Account = /** @class */ (function (_super) {
|
|
|
119
130
|
Account.prototype.estimateFee = function (calls, _a) {
|
|
120
131
|
var _b = _a === void 0 ? {} : _a, providedNonce = _b.nonce, _c = _b.blockIdentifier, blockIdentifier = _c === void 0 ? 'pending' : _c;
|
|
121
132
|
return __awaiter(this, void 0, void 0, function () {
|
|
122
|
-
var transactions, nonce, _d, version, signerDetails, signature, calldata;
|
|
133
|
+
var transactions, nonce, _d, version, signerDetails, signature, calldata, fetchedEstimate, suggestedMaxFee;
|
|
123
134
|
return __generator(this, function (_e) {
|
|
124
135
|
switch (_e.label) {
|
|
125
136
|
case 0:
|
|
@@ -145,13 +156,17 @@ var Account = /** @class */ (function (_super) {
|
|
|
145
156
|
case 4:
|
|
146
157
|
signature = _e.sent();
|
|
147
158
|
calldata = (0, transaction_1.fromCallsToExecuteCalldataWithNonce)(transactions, nonce);
|
|
148
|
-
return [
|
|
159
|
+
return [4 /*yield*/, this.fetchEndpoint('estimate_fee', { blockIdentifier: blockIdentifier }, {
|
|
149
160
|
contract_address: this.address,
|
|
150
161
|
entry_point_selector: (0, hash_1.getSelectorFromName)('__execute__'),
|
|
151
162
|
calldata: calldata,
|
|
152
163
|
version: (0, number_1.toHex)(version),
|
|
153
164
|
signature: (0, number_1.bigNumberishArrayToDecimalStringArray)(signature),
|
|
154
165
|
})];
|
|
166
|
+
case 5:
|
|
167
|
+
fetchedEstimate = _e.sent();
|
|
168
|
+
suggestedMaxFee = (0, stark_1.estimatedFeeToMaxFee)(fetchedEstimate.amount);
|
|
169
|
+
return [2 /*return*/, __assign(__assign({}, fetchedEstimate), { suggestedMaxFee: suggestedMaxFee })];
|
|
155
170
|
}
|
|
156
171
|
});
|
|
157
172
|
});
|
|
@@ -161,7 +176,9 @@ var Account = /** @class */ (function (_super) {
|
|
|
161
176
|
*
|
|
162
177
|
* [Reference](https://github.com/starkware-libs/cairo-lang/blob/f464ec4797361b6be8989e36e02ec690e74ef285/src/starkware/starknet/services/api/gateway/gateway_client.py#L13-L17)
|
|
163
178
|
*
|
|
164
|
-
* @param
|
|
179
|
+
* @param calls - one or more calls to be executed
|
|
180
|
+
* @param abis - one or more abis which can be used to display the calls
|
|
181
|
+
* @param transactionsDetail - optional transaction details
|
|
165
182
|
* @returns a confirmation of invoking a function on the starknet contract
|
|
166
183
|
*/
|
|
167
184
|
Account.prototype.execute = function (calls, abis, transactionsDetail) {
|
|
@@ -169,7 +186,7 @@ var Account = /** @class */ (function (_super) {
|
|
|
169
186
|
if (abis === void 0) { abis = undefined; }
|
|
170
187
|
if (transactionsDetail === void 0) { transactionsDetail = {}; }
|
|
171
188
|
return __awaiter(this, void 0, void 0, function () {
|
|
172
|
-
var transactions, nonce, _b, _c, maxFee,
|
|
189
|
+
var transactions, nonce, _b, _c, maxFee, suggestedMaxFee, signerDetails, signature, calldata;
|
|
173
190
|
return __generator(this, function (_d) {
|
|
174
191
|
switch (_d.label) {
|
|
175
192
|
case 0:
|
|
@@ -190,8 +207,8 @@ var Account = /** @class */ (function (_super) {
|
|
|
190
207
|
return [3 /*break*/, 6];
|
|
191
208
|
case 4: return [4 /*yield*/, this.estimateFee(transactions, { nonce: nonce })];
|
|
192
209
|
case 5:
|
|
193
|
-
|
|
194
|
-
maxFee =
|
|
210
|
+
suggestedMaxFee = (_d.sent()).suggestedMaxFee;
|
|
211
|
+
maxFee = suggestedMaxFee.toString();
|
|
195
212
|
_d.label = 6;
|
|
196
213
|
case 6:
|
|
197
214
|
signerDetails = {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ProviderInterface } from '../provider';
|
|
2
2
|
import { SignerInterface } from '../signer';
|
|
3
|
-
import { Abi, AddTransactionResponse, Call, DeployContractPayload,
|
|
3
|
+
import { Abi, AddTransactionResponse, Call, DeployContractPayload, Invocation, InvocationsDetails, Signature } from '../types';
|
|
4
|
+
import { EstimateFee } from '../types/account';
|
|
4
5
|
import { BigNumberish } from '../utils/number';
|
|
5
6
|
import { TypedData } from '../utils/typedData/types';
|
|
6
7
|
export declare abstract class AccountInterface extends ProviderInterface {
|
|
@@ -28,7 +29,7 @@ export declare abstract class AccountInterface extends ProviderInterface {
|
|
|
28
29
|
*
|
|
29
30
|
* @returns response from addTransaction
|
|
30
31
|
*/
|
|
31
|
-
abstract estimateFee(invocation: Invocation): Promise<
|
|
32
|
+
abstract estimateFee(invocation: Invocation): Promise<EstimateFee>;
|
|
32
33
|
/**
|
|
33
34
|
* Invoke execute function in account contract
|
|
34
35
|
*
|
|
@@ -119,6 +119,6 @@ export declare class Contract implements ContractInterface {
|
|
|
119
119
|
call(method: string, args?: Array<any>, { blockIdentifier, }?: {
|
|
120
120
|
blockIdentifier?: BlockIdentifier;
|
|
121
121
|
}): Promise<Result>;
|
|
122
|
-
estimate(method: string, args?: Array<any>): Promise<import("../types").
|
|
122
|
+
estimate(method: string, args?: Array<any>): Promise<import("../types/account").EstimateFee>;
|
|
123
123
|
populate(method: string, args?: Array<any>): Invocation;
|
|
124
124
|
}
|
package/dist/provider/default.js
CHANGED
|
@@ -67,7 +67,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
67
67
|
};
|
|
68
68
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
69
69
|
exports.Provider = void 0;
|
|
70
|
-
var
|
|
70
|
+
var cross_fetch_1 = __importDefault(require("cross-fetch"));
|
|
71
71
|
var url_join_1 = __importDefault(require("url-join"));
|
|
72
72
|
var constants_1 = require("../constants");
|
|
73
73
|
var hash_1 = require("../utils/hash");
|
|
@@ -164,9 +164,8 @@ var Provider = /** @class */ (function () {
|
|
|
164
164
|
};
|
|
165
165
|
// typesafe fetch
|
|
166
166
|
Provider.prototype.fetchEndpoint = function (endpoint) {
|
|
167
|
-
var _a;
|
|
168
167
|
// typescript type magiuc to create a nice fitting function interface
|
|
169
|
-
var
|
|
168
|
+
var _a = []; // when both query and request are needed, we cant omit anything
|
|
170
169
|
for (
|
|
171
170
|
// typescript type magiuc to create a nice fitting function interface
|
|
172
171
|
var _i = 1 // when both query and request are needed, we cant omit anything
|
|
@@ -178,50 +177,35 @@ var Provider = /** @class */ (function () {
|
|
|
178
177
|
_i++ // when both query and request are needed, we cant omit anything
|
|
179
178
|
) {
|
|
180
179
|
// typescript type magiuc to create a nice fitting function interface
|
|
181
|
-
|
|
180
|
+
_a[_i - 1] = arguments[_i]; // when both query and request are needed, we cant omit anything
|
|
182
181
|
}
|
|
183
182
|
// typescript type magiuc to create a nice fitting function interface
|
|
184
|
-
var
|
|
183
|
+
var _b = __read(_a, 2), query = _b[0], request = _b[1]; // when both query and request are needed, we cant omit anything
|
|
185
184
|
return __awaiter(this, void 0, void 0, function () {
|
|
186
|
-
var baseUrl, method, queryString, headers,
|
|
187
|
-
return __generator(this, function (
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
}
|
|
208
|
-
: axios_1.default.defaults.transformResponse,
|
|
209
|
-
url: (0, url_join_1.default)(baseUrl, endpoint, queryString),
|
|
210
|
-
data: (0, json_1.stringify)(request),
|
|
211
|
-
headers: headers,
|
|
212
|
-
})];
|
|
213
|
-
case 2:
|
|
214
|
-
data = (_d.sent()).data;
|
|
215
|
-
return [2 /*return*/, data];
|
|
216
|
-
case 3:
|
|
217
|
-
error_1 = _d.sent();
|
|
218
|
-
data = (_a = error_1 === null || error_1 === void 0 ? void 0 : error_1.response) === null || _a === void 0 ? void 0 : _a.data;
|
|
219
|
-
if (data === null || data === void 0 ? void 0 : data.message) {
|
|
220
|
-
throw new Error(data.code + ": " + data.message);
|
|
185
|
+
var baseUrl, method, queryString, headers, url;
|
|
186
|
+
return __generator(this, function (_c) {
|
|
187
|
+
baseUrl = this.getFetchUrl(endpoint);
|
|
188
|
+
method = this.getFetchMethod(endpoint);
|
|
189
|
+
queryString = this.getQueryString(query);
|
|
190
|
+
headers = this.getHeaders(method);
|
|
191
|
+
url = (0, url_join_1.default)(baseUrl, endpoint, queryString);
|
|
192
|
+
return [2 /*return*/, (0, cross_fetch_1.default)(url, {
|
|
193
|
+
method: method,
|
|
194
|
+
body: (0, json_1.stringify)(request),
|
|
195
|
+
headers: headers,
|
|
196
|
+
})
|
|
197
|
+
.then(function (res) { return res.text(); })
|
|
198
|
+
.then(function (res) {
|
|
199
|
+
if (endpoint === 'estimate_fee') {
|
|
200
|
+
return (0, json_1.parse)(res, function (_, v) {
|
|
201
|
+
if (v && typeof v === 'bigint') {
|
|
202
|
+
return (0, number_1.toBN)(v.toString());
|
|
203
|
+
}
|
|
204
|
+
return v;
|
|
205
|
+
});
|
|
221
206
|
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
}
|
|
207
|
+
return (0, json_1.parse)(res);
|
|
208
|
+
})];
|
|
225
209
|
});
|
|
226
210
|
});
|
|
227
211
|
};
|
package/dist/provider/utils.js
CHANGED
|
@@ -36,8 +36,8 @@ exports.txIdentifier = txIdentifier;
|
|
|
36
36
|
* @returns block identifier object
|
|
37
37
|
*/
|
|
38
38
|
function getBlockIdentifier(blockIdentifier) {
|
|
39
|
-
if (blockIdentifier === null) {
|
|
40
|
-
return { type: 'BLOCK_NUMBER', data:
|
|
39
|
+
if (blockIdentifier === null || blockIdentifier === 'latest') {
|
|
40
|
+
return { type: 'BLOCK_NUMBER', data: 'latest' }; // default to latest block
|
|
41
41
|
}
|
|
42
42
|
if (blockIdentifier === 'pending') {
|
|
43
43
|
return { type: 'BLOCK_NUMBER', data: 'pending' };
|
package/dist/types/lib.d.ts
CHANGED
|
@@ -47,7 +47,7 @@ export declare type StructAbi = {
|
|
|
47
47
|
export declare type Abi = Array<FunctionAbi | StructAbi>;
|
|
48
48
|
export declare type EntryPointsByType = object;
|
|
49
49
|
export declare type Program = Record<any, any>;
|
|
50
|
-
export declare type BlockNumber = 'pending' | null | number;
|
|
50
|
+
export declare type BlockNumber = 'pending' | 'latest' | null | number;
|
|
51
51
|
export declare type CompiledContract = {
|
|
52
52
|
abi: Abi;
|
|
53
53
|
entry_points_by_type: EntryPointsByType;
|
package/dist/utils/stark.js
CHANGED
|
@@ -83,7 +83,7 @@ function compileCalldata(args) {
|
|
|
83
83
|
}
|
|
84
84
|
exports.compileCalldata = compileCalldata;
|
|
85
85
|
function estimatedFeeToMaxFee(estimatedFee, overhead) {
|
|
86
|
-
if (overhead === void 0) { overhead = 0.
|
|
86
|
+
if (overhead === void 0) { overhead = 0.5; }
|
|
87
87
|
// BN can only handle Integers, so we need to do all calulations with integers
|
|
88
88
|
var overHeadPercent = Math.round((1 + overhead) * 100);
|
|
89
89
|
return (0, number_1.toBN)(estimatedFee).mul((0, number_1.toBN)(overHeadPercent)).div((0, number_1.toBN)(100));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "starknet",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.12.2",
|
|
4
4
|
"description": "JavaScript library for StarkNet",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -44,7 +44,6 @@
|
|
|
44
44
|
"@types/url-join": "^4.0.1",
|
|
45
45
|
"@typescript-eslint/eslint-plugin": "^5.0.0",
|
|
46
46
|
"@typescript-eslint/parser": "^5.0.0",
|
|
47
|
-
"axios-logger": "^2.6.0",
|
|
48
47
|
"eslint": "^7.32.0",
|
|
49
48
|
"eslint-config-airbnb-base": "^14.2.1",
|
|
50
49
|
"eslint-config-airbnb-typescript": "^14.0.1",
|
|
@@ -58,14 +57,16 @@
|
|
|
58
57
|
"prettier": "^2.4.1",
|
|
59
58
|
"prettier-plugin-import-sort": "^0.0.7",
|
|
60
59
|
"typedoc": "^0.22.6",
|
|
61
|
-
"typescript": "^4.4.4"
|
|
60
|
+
"typescript": "^4.4.4",
|
|
61
|
+
"whatwg-fetch": "^3.6.2"
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
64
|
"@ethersproject/bytes": "^5.6.1",
|
|
65
|
-
"axios": "^0.23.0",
|
|
66
65
|
"bn.js": "^5.2.0",
|
|
66
|
+
"cross-fetch": "^3.1.5",
|
|
67
67
|
"elliptic": "^6.5.4",
|
|
68
68
|
"ethereum-cryptography": "^0.2.0",
|
|
69
|
+
"fetch-intercept": "^2.4.0",
|
|
69
70
|
"hash.js": "^1.1.7",
|
|
70
71
|
"json-bigint": "^1.0.0",
|
|
71
72
|
"minimalistic-assert": "^1.0.1",
|
package/provider/default.js
CHANGED
|
@@ -173,7 +173,7 @@ var __importDefault =
|
|
|
173
173
|
};
|
|
174
174
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
175
175
|
exports.Provider = void 0;
|
|
176
|
-
var
|
|
176
|
+
var cross_fetch_1 = __importDefault(require('cross-fetch'));
|
|
177
177
|
var url_join_1 = __importDefault(require('url-join'));
|
|
178
178
|
var constants_1 = require('../constants');
|
|
179
179
|
var hash_1 = require('../utils/hash');
|
|
@@ -281,9 +281,8 @@ var Provider = /** @class */ (function () {
|
|
|
281
281
|
};
|
|
282
282
|
// typesafe fetch
|
|
283
283
|
Provider.prototype.fetchEndpoint = function (endpoint) {
|
|
284
|
-
var _a;
|
|
285
284
|
// typescript type magiuc to create a nice fitting function interface
|
|
286
|
-
var
|
|
285
|
+
var _a = []; // when both query and request are needed, we cant omit anything
|
|
287
286
|
for (
|
|
288
287
|
// typescript type magiuc to create a nice fitting function interface
|
|
289
288
|
var _i = 1; // when both query and request are needed, we cant omit anything
|
|
@@ -293,61 +292,42 @@ var Provider = /** @class */ (function () {
|
|
|
293
292
|
_i++ // when both query and request are needed, we cant omit anything
|
|
294
293
|
) {
|
|
295
294
|
// typescript type magiuc to create a nice fitting function interface
|
|
296
|
-
|
|
295
|
+
_a[_i - 1] = arguments[_i]; // when both query and request are needed, we cant omit anything
|
|
297
296
|
}
|
|
298
297
|
// typescript type magiuc to create a nice fitting function interface
|
|
299
|
-
var
|
|
300
|
-
query =
|
|
301
|
-
request =
|
|
298
|
+
var _b = __read(_a, 2),
|
|
299
|
+
query = _b[0],
|
|
300
|
+
request = _b[1]; // when both query and request are needed, we cant omit anything
|
|
302
301
|
return __awaiter(this, void 0, void 0, function () {
|
|
303
|
-
var baseUrl, method, queryString, headers,
|
|
304
|
-
return __generator(this, function (
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
}),
|
|
333
|
-
];
|
|
334
|
-
case 2:
|
|
335
|
-
data = _d.sent().data;
|
|
336
|
-
return [2 /*return*/, data];
|
|
337
|
-
case 3:
|
|
338
|
-
error_1 = _d.sent();
|
|
339
|
-
data =
|
|
340
|
-
(_a = error_1 === null || error_1 === void 0 ? void 0 : error_1.response) === null ||
|
|
341
|
-
_a === void 0
|
|
342
|
-
? void 0
|
|
343
|
-
: _a.data;
|
|
344
|
-
if (data === null || data === void 0 ? void 0 : data.message) {
|
|
345
|
-
throw new Error(data.code + ': ' + data.message);
|
|
346
|
-
}
|
|
347
|
-
throw error_1;
|
|
348
|
-
case 4:
|
|
349
|
-
return [2 /*return*/];
|
|
350
|
-
}
|
|
302
|
+
var baseUrl, method, queryString, headers, url;
|
|
303
|
+
return __generator(this, function (_c) {
|
|
304
|
+
baseUrl = this.getFetchUrl(endpoint);
|
|
305
|
+
method = this.getFetchMethod(endpoint);
|
|
306
|
+
queryString = this.getQueryString(query);
|
|
307
|
+
headers = this.getHeaders(method);
|
|
308
|
+
url = (0, url_join_1.default)(baseUrl, endpoint, queryString);
|
|
309
|
+
return [
|
|
310
|
+
2 /*return*/,
|
|
311
|
+
(0, cross_fetch_1.default)(url, {
|
|
312
|
+
method: method,
|
|
313
|
+
body: (0, json_1.stringify)(request),
|
|
314
|
+
headers: headers,
|
|
315
|
+
})
|
|
316
|
+
.then(function (res) {
|
|
317
|
+
return res.text();
|
|
318
|
+
})
|
|
319
|
+
.then(function (res) {
|
|
320
|
+
if (endpoint === 'estimate_fee') {
|
|
321
|
+
return (0, json_1.parse)(res, function (_, v) {
|
|
322
|
+
if (v && typeof v === 'bigint') {
|
|
323
|
+
return (0, number_1.toBN)(v.toString());
|
|
324
|
+
}
|
|
325
|
+
return v;
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
return (0, json_1.parse)(res);
|
|
329
|
+
}),
|
|
330
|
+
];
|
|
351
331
|
});
|
|
352
332
|
});
|
|
353
333
|
};
|
package/provider/utils.js
CHANGED
|
@@ -39,8 +39,8 @@ exports.txIdentifier = txIdentifier;
|
|
|
39
39
|
* @returns block identifier object
|
|
40
40
|
*/
|
|
41
41
|
function getBlockIdentifier(blockIdentifier) {
|
|
42
|
-
if (blockIdentifier === null) {
|
|
43
|
-
return { type: 'BLOCK_NUMBER', data:
|
|
42
|
+
if (blockIdentifier === null || blockIdentifier === 'latest') {
|
|
43
|
+
return { type: 'BLOCK_NUMBER', data: 'latest' }; // default to latest block
|
|
44
44
|
}
|
|
45
45
|
if (blockIdentifier === 'pending') {
|
|
46
46
|
return { type: 'BLOCK_NUMBER', data: 'pending' };
|
package/src/account/default.ts
CHANGED
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
Abi,
|
|
9
9
|
AddTransactionResponse,
|
|
10
10
|
Call,
|
|
11
|
-
EstimateFeeResponse,
|
|
12
11
|
InvocationsDetails,
|
|
13
12
|
InvocationsSignerDetails,
|
|
14
13
|
InvokeFunctionTransaction,
|
|
@@ -16,6 +15,7 @@ import {
|
|
|
16
15
|
Signature,
|
|
17
16
|
Transaction,
|
|
18
17
|
} from '../types';
|
|
18
|
+
import { EstimateFee } from '../types/account';
|
|
19
19
|
import { sign } from '../utils/ellipticCurve';
|
|
20
20
|
import {
|
|
21
21
|
computeHashOnElements,
|
|
@@ -60,7 +60,7 @@ export class Account extends Provider implements AccountInterface {
|
|
|
60
60
|
nonce: providedNonce,
|
|
61
61
|
blockIdentifier = 'pending',
|
|
62
62
|
}: { nonce?: BigNumberish; blockIdentifier?: BlockIdentifier } = {}
|
|
63
|
-
): Promise<
|
|
63
|
+
): Promise<EstimateFee> {
|
|
64
64
|
const transactions = Array.isArray(calls) ? calls : [calls];
|
|
65
65
|
const nonce = providedNonce ?? (await this.getNonce());
|
|
66
66
|
const version = toBN(feeTransactionVersion);
|
|
@@ -76,7 +76,7 @@ export class Account extends Provider implements AccountInterface {
|
|
|
76
76
|
const signature = await this.signer.signTransaction(transactions, signerDetails);
|
|
77
77
|
|
|
78
78
|
const calldata = fromCallsToExecuteCalldataWithNonce(transactions, nonce);
|
|
79
|
-
|
|
79
|
+
const fetchedEstimate = await this.fetchEndpoint(
|
|
80
80
|
'estimate_fee',
|
|
81
81
|
{ blockIdentifier },
|
|
82
82
|
{
|
|
@@ -87,6 +87,12 @@ export class Account extends Provider implements AccountInterface {
|
|
|
87
87
|
signature: bigNumberishArrayToDecimalStringArray(signature),
|
|
88
88
|
}
|
|
89
89
|
);
|
|
90
|
+
const suggestedMaxFee = estimatedFeeToMaxFee(fetchedEstimate.amount);
|
|
91
|
+
|
|
92
|
+
return {
|
|
93
|
+
...fetchedEstimate,
|
|
94
|
+
suggestedMaxFee,
|
|
95
|
+
};
|
|
90
96
|
}
|
|
91
97
|
|
|
92
98
|
/**
|
|
@@ -94,7 +100,9 @@ export class Account extends Provider implements AccountInterface {
|
|
|
94
100
|
*
|
|
95
101
|
* [Reference](https://github.com/starkware-libs/cairo-lang/blob/f464ec4797361b6be8989e36e02ec690e74ef285/src/starkware/starknet/services/api/gateway/gateway_client.py#L13-L17)
|
|
96
102
|
*
|
|
97
|
-
* @param
|
|
103
|
+
* @param calls - one or more calls to be executed
|
|
104
|
+
* @param abis - one or more abis which can be used to display the calls
|
|
105
|
+
* @param transactionsDetail - optional transaction details
|
|
98
106
|
* @returns a confirmation of invoking a function on the starknet contract
|
|
99
107
|
*/
|
|
100
108
|
public async execute(
|
|
@@ -108,8 +116,8 @@ export class Account extends Provider implements AccountInterface {
|
|
|
108
116
|
if (transactionsDetail.maxFee || transactionsDetail.maxFee === 0) {
|
|
109
117
|
maxFee = transactionsDetail.maxFee;
|
|
110
118
|
} else {
|
|
111
|
-
const
|
|
112
|
-
maxFee =
|
|
119
|
+
const { suggestedMaxFee } = await this.estimateFee(transactions, { nonce });
|
|
120
|
+
maxFee = suggestedMaxFee.toString();
|
|
113
121
|
}
|
|
114
122
|
|
|
115
123
|
const signerDetails: InvocationsSignerDetails = {
|
package/src/account/interface.ts
CHANGED
|
@@ -5,11 +5,11 @@ import {
|
|
|
5
5
|
AddTransactionResponse,
|
|
6
6
|
Call,
|
|
7
7
|
DeployContractPayload,
|
|
8
|
-
EstimateFeeResponse,
|
|
9
8
|
Invocation,
|
|
10
9
|
InvocationsDetails,
|
|
11
10
|
Signature,
|
|
12
11
|
} from '../types';
|
|
12
|
+
import { EstimateFee } from '../types/account';
|
|
13
13
|
import { BigNumberish } from '../utils/number';
|
|
14
14
|
import { TypedData } from '../utils/typedData/types';
|
|
15
15
|
|
|
@@ -44,7 +44,7 @@ export abstract class AccountInterface extends ProviderInterface {
|
|
|
44
44
|
*
|
|
45
45
|
* @returns response from addTransaction
|
|
46
46
|
*/
|
|
47
|
-
public abstract estimateFee(invocation: Invocation): Promise<
|
|
47
|
+
public abstract estimateFee(invocation: Invocation): Promise<EstimateFee>;
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
50
|
* Invoke execute function in account contract
|
package/src/provider/default.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import fetch from 'cross-fetch';
|
|
2
2
|
import urljoin from 'url-join';
|
|
3
3
|
|
|
4
4
|
import { StarknetChainId } from '../constants';
|
|
@@ -10,7 +10,6 @@ import {
|
|
|
10
10
|
CompiledContract,
|
|
11
11
|
DeployContractPayload,
|
|
12
12
|
Endpoints,
|
|
13
|
-
EstimateFeeResponse,
|
|
14
13
|
GetBlockResponse,
|
|
15
14
|
GetCodeResponse,
|
|
16
15
|
GetContractAddressesResponse,
|
|
@@ -125,7 +124,7 @@ export class Provider implements ProviderInterface {
|
|
|
125
124
|
return `?${queryString}`;
|
|
126
125
|
}
|
|
127
126
|
|
|
128
|
-
private getHeaders(method: 'POST' | 'GET'):
|
|
127
|
+
private getHeaders(method: 'POST' | 'GET'): Record<string, string> | undefined {
|
|
129
128
|
if (method === 'POST') {
|
|
130
129
|
return {
|
|
131
130
|
'Content-Type': 'application/json',
|
|
@@ -150,33 +149,25 @@ export class Provider implements ProviderInterface {
|
|
|
150
149
|
const method = this.getFetchMethod(endpoint);
|
|
151
150
|
const queryString = this.getQueryString(query);
|
|
152
151
|
const headers = this.getHeaders(method);
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
152
|
+
const url = urljoin(baseUrl, endpoint, queryString);
|
|
153
|
+
|
|
154
|
+
return fetch(url, {
|
|
155
|
+
method,
|
|
156
|
+
body: stringify(request),
|
|
157
|
+
headers,
|
|
158
|
+
})
|
|
159
|
+
.then((res) => res.text())
|
|
160
|
+
.then((res) => {
|
|
161
|
+
if (endpoint === 'estimate_fee') {
|
|
162
|
+
return parse(res, (_, v) => {
|
|
163
|
+
if (v && typeof v === 'bigint') {
|
|
164
|
+
return toBN(v.toString());
|
|
165
|
+
}
|
|
166
|
+
return v;
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
return parse(res) as Endpoints[T]['RESPONSE'];
|
|
171
170
|
});
|
|
172
|
-
return data;
|
|
173
|
-
} catch (error: any) {
|
|
174
|
-
const data = error?.response?.data;
|
|
175
|
-
if (data?.message) {
|
|
176
|
-
throw new Error(`${data.code}: ${data.message}`);
|
|
177
|
-
}
|
|
178
|
-
throw error;
|
|
179
|
-
}
|
|
180
171
|
}
|
|
181
172
|
|
|
182
173
|
/**
|
package/src/provider/utils.ts
CHANGED
|
@@ -43,8 +43,8 @@ type BlockIdentifierObject =
|
|
|
43
43
|
* @returns block identifier object
|
|
44
44
|
*/
|
|
45
45
|
export function getBlockIdentifier(blockIdentifier: BlockIdentifier): BlockIdentifierObject {
|
|
46
|
-
if (blockIdentifier === null) {
|
|
47
|
-
return { type: 'BLOCK_NUMBER', data:
|
|
46
|
+
if (blockIdentifier === null || blockIdentifier === 'latest') {
|
|
47
|
+
return { type: 'BLOCK_NUMBER', data: 'latest' }; // default to latest block
|
|
48
48
|
}
|
|
49
49
|
if (blockIdentifier === 'pending') {
|
|
50
50
|
return { type: 'BLOCK_NUMBER', data: 'pending' };
|
package/src/types/lib.ts
CHANGED
|
@@ -60,7 +60,7 @@ export type Abi = Array<FunctionAbi | StructAbi>;
|
|
|
60
60
|
|
|
61
61
|
export type EntryPointsByType = object;
|
|
62
62
|
export type Program = Record<any, any>;
|
|
63
|
-
export type BlockNumber = 'pending' | null | number;
|
|
63
|
+
export type BlockNumber = 'pending' | 'latest' | null | number;
|
|
64
64
|
|
|
65
65
|
export type CompiledContract = {
|
|
66
66
|
abi: Abi;
|
package/src/utils/stark.ts
CHANGED
|
@@ -50,7 +50,7 @@ export function compileCalldata(args: RawArgs): Calldata {
|
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
export function estimatedFeeToMaxFee(estimatedFee: BigNumberish, overhead: number = 0.
|
|
53
|
+
export function estimatedFeeToMaxFee(estimatedFee: BigNumberish, overhead: number = 0.5): BN {
|
|
54
54
|
// BN can only handle Integers, so we need to do all calulations with integers
|
|
55
55
|
const overHeadPercent = Math.round((1 + overhead) * 100);
|
|
56
56
|
return toBN(estimatedFee).mul(toBN(overHeadPercent)).div(toBN(100));
|
package/types/account.js
ADDED
package/types/lib.d.ts
CHANGED
|
@@ -54,7 +54,7 @@ export declare type StructAbi = {
|
|
|
54
54
|
export declare type Abi = Array<FunctionAbi | StructAbi>;
|
|
55
55
|
export declare type EntryPointsByType = object;
|
|
56
56
|
export declare type Program = Record<any, any>;
|
|
57
|
-
export declare type BlockNumber = 'pending' | null | number;
|
|
57
|
+
export declare type BlockNumber = 'pending' | 'latest' | null | number;
|
|
58
58
|
export declare type CompiledContract = {
|
|
59
59
|
abi: Abi;
|
|
60
60
|
entry_points_by_type: EntryPointsByType;
|
package/utils/stark.js
CHANGED
|
@@ -114,7 +114,7 @@ function compileCalldata(args) {
|
|
|
114
114
|
exports.compileCalldata = compileCalldata;
|
|
115
115
|
function estimatedFeeToMaxFee(estimatedFee, overhead) {
|
|
116
116
|
if (overhead === void 0) {
|
|
117
|
-
overhead = 0.
|
|
117
|
+
overhead = 0.5;
|
|
118
118
|
}
|
|
119
119
|
// BN can only handle Integers, so we need to do all calulations with integers
|
|
120
120
|
var overHeadPercent = Math.round((1 + overhead) * 100);
|