starknet 3.6.0 → 3.9.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.
Files changed (52) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/README.md +18 -53
  3. package/__tests__/utils/utils.test.ts +10 -0
  4. package/account/default.d.ts +13 -2
  5. package/account/default.js +53 -33
  6. package/contract/default.d.ts +12 -2
  7. package/contract/default.js +27 -20
  8. package/contract/interface.d.ts +21 -3
  9. package/dist/account/default.d.ts +7 -2
  10. package/dist/account/default.js +41 -28
  11. package/dist/contract/default.d.ts +6 -3
  12. package/dist/contract/default.js +23 -20
  13. package/dist/contract/interface.d.ts +9 -4
  14. package/dist/provider/default.d.ts +2 -2
  15. package/dist/provider/default.js +18 -19
  16. package/dist/provider/utils.d.ts +1 -2
  17. package/dist/provider/utils.js +7 -8
  18. package/dist/signer/default.js +1 -1
  19. package/dist/types/api.d.ts +4 -1
  20. package/dist/types/lib.d.ts +1 -0
  21. package/dist/utils/hash.d.ts +2 -1
  22. package/dist/utils/hash.js +5 -3
  23. package/dist/utils/stark.d.ts +3 -0
  24. package/dist/utils/stark.js +8 -1
  25. package/dist/utils/typedData/index.d.ts +2 -2
  26. package/dist/utils/typedData/types.d.ts +3 -3
  27. package/dist/utils/typedData/utils.d.ts +1 -1
  28. package/package.json +1 -1
  29. package/provider/default.d.ts +4 -2
  30. package/provider/default.js +30 -27
  31. package/provider/utils.d.ts +1 -2
  32. package/provider/utils.js +7 -8
  33. package/signer/default.js +2 -1
  34. package/src/account/default.ts +35 -12
  35. package/src/contract/default.ts +32 -19
  36. package/src/contract/interface.ts +21 -3
  37. package/src/provider/default.ts +18 -12
  38. package/src/provider/utils.ts +7 -8
  39. package/src/signer/default.ts +2 -1
  40. package/src/types/api.ts +4 -1
  41. package/src/types/lib.ts +1 -0
  42. package/src/utils/hash.ts +4 -2
  43. package/src/utils/stark.ts +8 -1
  44. package/types/api.d.ts +4 -1
  45. package/types/lib.d.ts +1 -0
  46. package/utils/hash.d.ts +3 -1
  47. package/utils/hash.js +9 -2
  48. package/utils/stark.d.ts +4 -0
  49. package/utils/stark.js +13 -1
  50. package/utils/typedData/index.d.ts +2 -2
  51. package/utils/typedData/types.d.ts +3 -3
  52. package/utils/typedData/utils.d.ts +1 -1
package/CHANGELOG.md CHANGED
@@ -1,3 +1,38 @@
1
+ # [3.9.0](https://github.com/seanjameshan/starknet.js/compare/v3.8.0...v3.9.0) (2022-04-08)
2
+
3
+ ### Bug Fixes
4
+
5
+ - **account:** adding overhead on estimateFee for maxFee ([ec52f61](https://github.com/seanjameshan/starknet.js/commit/ec52f61aed9a8755491a4b7de73517b075785479))
6
+ - **contract:** override object when invoking a function ([c605151](https://github.com/seanjameshan/starknet.js/commit/c605151c03b544bf62ff9ab2e314e49de3cd562a))
7
+ - estimatedFeeToMaxFee with integers only ([71d19a7](https://github.com/seanjameshan/starknet.js/commit/71d19a7db01630ca0dba55011ff440243d7db992))
8
+ - rename txVersion to version ([2ae36b2](https://github.com/seanjameshan/starknet.js/commit/2ae36b2c075dbee4710abe47770af35478ceba4e))
9
+ - **utils:** remove check for the BN ([50a7951](https://github.com/seanjameshan/starknet.js/commit/50a79514343e303c397358efdba978fec5f93f48))
10
+
11
+ ### Features
12
+
13
+ - **account:** adding new transaction version for fee estimation ([2f7cb3f](https://github.com/seanjameshan/starknet.js/commit/2f7cb3fe85c973bcff3e39db333a9ed969c550b1))
14
+
15
+ # [3.8.0](https://github.com/seanjameshan/starknet.js/compare/v3.7.0...v3.8.0) (2022-04-04)
16
+
17
+ ### Bug Fixes
18
+
19
+ - getBlock should not default to pending block ([7a641b5](https://github.com/seanjameshan/starknet.js/commit/7a641b55c3c762dada70814bf509b147f0cd315e))
20
+
21
+ ### Features
22
+
23
+ - complete interface ([39d2f05](https://github.com/seanjameshan/starknet.js/commit/39d2f0574691e4b37a6050831b4e548b07a8e3e3))
24
+ - default estimateFee to pending block ([719dda5](https://github.com/seanjameshan/starknet.js/commit/719dda5f33a2bed353bd1bf311a2baf3110d1654))
25
+ - default to pending block ([d3c1bdc](https://github.com/seanjameshan/starknet.js/commit/d3c1bdcdca996bce273673cf9c8220156e965863))
26
+ - pending as success ([9e79288](https://github.com/seanjameshan/starknet.js/commit/9e7928845cc1e7088ba9a8dc9ba8fb9311970440))
27
+
28
+ # [3.7.0](https://github.com/seanjameshan/starknet.js/compare/v3.6.0...v3.7.0) (2022-03-24)
29
+
30
+ ### Features
31
+
32
+ - **Account:** account constructor should take a KeyPair or a Signer as parameter ([ea6ae40](https://github.com/seanjameshan/starknet.js/commit/ea6ae40225d33e293b9d2de7c8509e87fb7a651e))
33
+ - add BigInt support within BigNumberish ([e42427a](https://github.com/seanjameshan/starknet.js/commit/e42427afa9a57673576da68cfbbee1356ffb5c0d))
34
+ - using typeguard to narrow variable's type in Account's constructor ([ed048f3](https://github.com/seanjameshan/starknet.js/commit/ed048f355bee815cc9b2ccc984db900059fa2303))
35
+
1
36
  # [3.6.0](https://github.com/seanjameshan/starknet.js/compare/v3.5.1...v3.6.0) (2022-03-24)
2
37
 
3
38
  ### Bug Fixes
package/README.md CHANGED
@@ -40,62 +40,19 @@ Install starknet with `npm`
40
40
 
41
41
  ```bash
42
42
  $ npm install starknet
43
- # or
43
+ # or for pre-release features:
44
44
  $ npm install starknet@next
45
45
  ```
46
46
 
47
- Import `starknet` and use the [API](https://www.starknetjs.com/modules.html)
48
-
49
- The following code is used to build a [simple AMM example](https://starkfin.netlify.app/) from the [cairo docs](https://www.cairo-lang.org/docs/hello_starknet/amm.html)
50
-
51
- ```javascript
52
- import { defaultProvider, stark } from 'starknet';
53
- const { getSelectorFromName } = stark;
54
-
55
- const CONTRACT_ADDRESS =
56
- "0x03e19baa6cb2078631bcdb34844f3f7879449a544c9ce722681a54af08cff4b9";
57
-
58
- /**
59
- * invokeFunction() example
60
- **/
61
-
62
- /** Reset the liquidity pool **/
63
- const addTokenResponse = await defaultProvider.invokeFunction(
64
- {
65
- contractAddress: CONTRACT_ADDRESS,
66
- entrypoint: "init_pool",
67
- calldata: ["1000000", "1000000"],
68
- },
69
- abi // for displaying purposes only (default implementation has no display/ui)
70
- );
71
- console.log(addTokenResponse);
72
-
73
- /**
74
- * callContract() example
75
- **/
76
-
77
- /** Get the balance of the liquidity pool of token A **/
78
- const poolBalanceTokenA = await defaultProvider.callContract({
79
- contractAddress: CONTRACT_ADDRESS,
80
- entrypoint: "get_pool_token_balance",
81
- calldata: ["1"],
82
- });
83
- const balanceA = poolBalanceTokenA.result[0];
84
- console.log('token a liquidity pool balance: ', parseInt(balanceA, 16));
85
-
86
- /** Get the balance of the liquidity pool of token B **/
87
- const poolBalanceTokenB = await defaultProvider.callContract({
88
- contractAddress: CONTRACT_ADDRESS,
89
- entrypoint: "get_pool_token_balance",
90
- calldata: ["2"],
91
- });
92
- const balanceB = poolBalanceTokenB.result[0];
93
- console.log('token b liquidity pool balance: ', parseInt(balanceB, 16));
94
- ```
47
+ Import `starknet` and use the [API](https://www.starknetjs.com/docs/API/)
48
+
49
+ Please refer to the following code example [here](https://github.com/0xs34n/starknet.js-workshop/blob/main/index.js)
50
+
51
+ Guides can be found [here](https://www.starknetjs.com/guides/intro)
95
52
 
96
53
  ## 🌐 API
97
54
 
98
- [Click Here](https://www.starknetjs.com/modules.html)
55
+ [Click Here](https://www.starknetjs.com/docs/API/)
99
56
 
100
57
  ## 🚀 Powered by Starknet.js
101
58
 
@@ -105,11 +62,19 @@ console.log('token b liquidity pool balance: ', parseInt(balanceB, 16));
105
62
 
106
63
  ## ✏️ Contributing
107
64
 
108
- If you consider to contribute to this project please read [CONTRIBUTING.md](https://github.com/seanjameshan/starknet.js/blob/main/CONTRIBUTING.md) first.
65
+ If you consider to contribute to this project please read [CONTRIBUTING.md](https://github.com/0xs34n/starknet.js/blob/main/CONTRIBUTING.md) first.
109
66
 
110
67
  ## ❤️ Special Thanks
111
68
 
112
- Special thanks to all the [contributors](https://github.com/seanjameshan/starknet.js/graphs/contributors), especially to Janek ([@janek26](https://github.com/janek26)) from [Argent](https://github.com/argentlabs) for driving the development of Starknet.js.
69
+ Special thanks to all the [contributors](https://github.com/0xs34n/starknet.js/graphs/contributors), especially to:
70
+
71
+ Janek ([@janek26](https://github.com/janek26)) and Axel ([@delaaxe](https://github.com/delaaxe)) from [Argent](https://github.com/argentlabs)
72
+
73
+ Miljan ([@MilGard91](https://github.com/MilGard91)) from [Shard Labs](https://shardlabs.io/)
74
+
75
+ Dhruv ([@dhruvkelawala](https://github.com/dhruvkelawala)) from [Jedi Swap](https://twitter.com/jediswap)
76
+
77
+ and of course the [StarkWare](https://starkware.co/) team for their dedicated support!
113
78
 
114
79
  This library would not be possible without these rockstars.
115
80
 
@@ -117,4 +82,4 @@ This library would not be possible without these rockstars.
117
82
 
118
83
  Copyright (c) 2022 0xs34n
119
84
 
120
- Licensed under the [MIT license](https://github.com/seanjameshan/starknet.js/blob/main/LICENSE).
85
+ Licensed under the [MIT license](https://github.com/0xs34n/starknet.js/blob/main/LICENSE).
@@ -77,3 +77,13 @@ describe('computeHashOnElements()', () => {
77
77
  );
78
78
  });
79
79
  });
80
+ describe('estimatedFeeToMaxFee()', () => {
81
+ test('should return maxFee for 0', () => {
82
+ const res = stark.estimatedFeeToMaxFee(0, 0.15).toNumber();
83
+ expect(res).toBe(0);
84
+ });
85
+ test('should return maxFee for 10_000', () => {
86
+ const res = stark.estimatedFeeToMaxFee(10_000, 0.15).toNumber();
87
+ expect(res).toBe(11_500);
88
+ });
89
+ });
@@ -1,4 +1,6 @@
1
1
  import { Provider } from '../provider';
2
+ import { BlockIdentifier } from '../provider/utils';
3
+ import { SignerInterface } from '../signer';
2
4
  import {
3
5
  Abi,
4
6
  AddTransactionResponse,
@@ -15,9 +17,18 @@ import { AccountInterface } from './interface';
15
17
  export declare class Account extends Provider implements AccountInterface {
16
18
  address: string;
17
19
  private signer;
18
- constructor(provider: Provider, address: string, keyPair: KeyPair);
20
+ constructor(provider: Provider, address: string, keyPairOrSigner: KeyPair | SignerInterface);
19
21
  getNonce(): Promise<string>;
20
- estimateFee(calls: Call | Call[]): Promise<EstimateFeeResponse>;
22
+ estimateFee(
23
+ calls: Call | Call[],
24
+ {
25
+ nonce: providedNonce,
26
+ blockIdentifier,
27
+ }?: {
28
+ nonce?: BigNumberish;
29
+ blockIdentifier?: BlockIdentifier;
30
+ }
31
+ ): Promise<EstimateFeeResponse>;
21
32
  /**
22
33
  * Invoke execute function in account contract
23
34
  *
@@ -207,9 +207,10 @@ var transaction_1 = require('../utils/transaction');
207
207
  var typedData_1 = require('../utils/typedData');
208
208
  var Account = /** @class */ (function (_super) {
209
209
  __extends(Account, _super);
210
- function Account(provider, address, keyPair) {
210
+ function Account(provider, address, keyPairOrSigner) {
211
211
  var _this = _super.call(this, provider) || this;
212
- _this.signer = new signer_1.Signer(keyPair);
212
+ _this.signer =
213
+ 'getPubKey' in keyPairOrSigner ? keyPairOrSigner : new signer_1.Signer(keyPairOrSigner);
213
214
  _this.address = address;
214
215
  return _this;
215
216
  }
@@ -233,24 +234,37 @@ var Account = /** @class */ (function (_super) {
233
234
  });
234
235
  });
235
236
  };
236
- Account.prototype.estimateFee = function (calls) {
237
+ Account.prototype.estimateFee = function (calls, _a) {
238
+ var _b = _a === void 0 ? {} : _a,
239
+ providedNonce = _b.nonce,
240
+ _c = _b.blockIdentifier,
241
+ blockIdentifier = _c === void 0 ? 'pending' : _c;
237
242
  return __awaiter(this, void 0, void 0, function () {
238
- var transactions, nonce, signerDetails, signature, calldata;
239
- return __generator(this, function (_a) {
240
- switch (_a.label) {
243
+ var transactions, nonce, _d, version, signerDetails, signature, calldata;
244
+ return __generator(this, function (_e) {
245
+ switch (_e.label) {
241
246
  case 0:
242
247
  transactions = Array.isArray(calls) ? calls : [calls];
243
- return [4 /*yield*/, this.getNonce()];
248
+ if (!(providedNonce !== null && providedNonce !== void 0)) return [3 /*break*/, 1];
249
+ _d = providedNonce;
250
+ return [3 /*break*/, 3];
244
251
  case 1:
245
- nonce = _a.sent();
252
+ return [4 /*yield*/, this.getNonce()];
253
+ case 2:
254
+ _d = _e.sent();
255
+ _e.label = 3;
256
+ case 3:
257
+ nonce = _d;
258
+ version = (0, number_1.toBN)(hash_1.feeTransactionVersion);
246
259
  signerDetails = {
247
260
  walletAddress: this.address,
248
261
  nonce: (0, number_1.toBN)(nonce),
249
262
  maxFee: (0, number_1.toBN)('0'),
263
+ version: version,
250
264
  };
251
265
  return [4 /*yield*/, this.signer.signTransaction(transactions, signerDetails)];
252
- case 2:
253
- signature = _a.sent();
266
+ case 4:
267
+ signature = _e.sent();
254
268
  calldata = __spreadArray(
255
269
  __spreadArray(
256
270
  [],
@@ -262,12 +276,17 @@ var Account = /** @class */ (function (_super) {
262
276
  );
263
277
  return [
264
278
  2 /*return*/,
265
- this.fetchEndpoint('estimate_fee', undefined, {
266
- contract_address: this.address,
267
- entry_point_selector: (0, hash_1.getSelectorFromName)('__execute__'),
268
- calldata: calldata,
269
- signature: (0, number_1.bigNumberishArrayToDecimalStringArray)(signature),
270
- }),
279
+ this.fetchEndpoint(
280
+ 'estimate_fee',
281
+ { blockIdentifier: blockIdentifier },
282
+ {
283
+ contract_address: this.address,
284
+ entry_point_selector: (0, hash_1.getSelectorFromName)('__execute__'),
285
+ calldata: calldata,
286
+ version: (0, number_1.toHex)(version),
287
+ signature: (0, number_1.bigNumberishArrayToDecimalStringArray)(signature),
288
+ }
289
+ ),
271
290
  ];
272
291
  }
273
292
  });
@@ -282,7 +301,7 @@ var Account = /** @class */ (function (_super) {
282
301
  * @returns a confirmation of invoking a function on the starknet contract
283
302
  */
284
303
  Account.prototype.execute = function (calls, abis, transactionsDetail) {
285
- var _a, _b;
304
+ var _a;
286
305
  if (abis === void 0) {
287
306
  abis = undefined;
288
307
  }
@@ -290,42 +309,43 @@ var Account = /** @class */ (function (_super) {
290
309
  transactionsDetail = {};
291
310
  }
292
311
  return __awaiter(this, void 0, void 0, function () {
293
- var transactions, nonce, _c, _d, maxFee, _e, signerDetails, signature, calldata;
294
- return __generator(this, function (_f) {
295
- switch (_f.label) {
312
+ var transactions, nonce, _b, _c, maxFee, estimatedFee, signerDetails, signature, calldata;
313
+ return __generator(this, function (_d) {
314
+ switch (_d.label) {
296
315
  case 0:
297
316
  transactions = Array.isArray(calls) ? calls : [calls];
298
- _c = number_1.toBN;
317
+ _b = number_1.toBN;
299
318
  if (!((_a = transactionsDetail.nonce) !== null && _a !== void 0))
300
319
  return [3 /*break*/, 1];
301
- _d = _a;
320
+ _c = _a;
302
321
  return [3 /*break*/, 3];
303
322
  case 1:
304
323
  return [4 /*yield*/, this.getNonce()];
305
324
  case 2:
306
- _d = _f.sent();
307
- _f.label = 3;
325
+ _c = _d.sent();
326
+ _d.label = 3;
308
327
  case 3:
309
- nonce = _c.apply(void 0, [_d]);
310
- if (!((_b = transactionsDetail.maxFee) !== null && _b !== void 0))
311
- return [3 /*break*/, 4];
312
- _e = _b;
328
+ nonce = _b.apply(void 0, [_c]);
329
+ maxFee = '0';
330
+ if (!transactionsDetail.maxFee) return [3 /*break*/, 4];
331
+ maxFee = transactionsDetail.maxFee;
313
332
  return [3 /*break*/, 6];
314
333
  case 4:
315
- return [4 /*yield*/, this.estimateFee(transactions)];
334
+ return [4 /*yield*/, this.estimateFee(transactions, { nonce: nonce })];
316
335
  case 5:
317
- _e = _f.sent().amount;
318
- _f.label = 6;
336
+ estimatedFee = _d.sent().amount;
337
+ maxFee = (0, stark_1.estimatedFeeToMaxFee)(estimatedFee).toString();
338
+ _d.label = 6;
319
339
  case 6:
320
- maxFee = _e;
321
340
  signerDetails = {
322
341
  walletAddress: this.address,
323
342
  nonce: nonce,
324
343
  maxFee: maxFee,
344
+ version: (0, number_1.toBN)(hash_1.transactionVersion),
325
345
  };
326
346
  return [4 /*yield*/, this.signer.signTransaction(transactions, signerDetails, abis)];
327
347
  case 7:
328
- signature = _f.sent();
348
+ signature = _d.sent();
329
349
  calldata = __spreadArray(
330
350
  __spreadArray(
331
351
  [],
@@ -1,5 +1,6 @@
1
1
  import { AccountInterface } from '../account';
2
2
  import { ProviderInterface } from '../provider';
3
+ import { BlockIdentifier } from '../provider/utils';
3
4
  import {
4
5
  Abi,
5
6
  AbiEntry,
@@ -9,6 +10,7 @@ import {
9
10
  Calldata,
10
11
  ContractFunction,
11
12
  Invocation,
13
+ Overrides,
12
14
  ParsedStruct,
13
15
  Result,
14
16
  StructAbi,
@@ -136,8 +138,16 @@ export declare class Contract implements ContractInterface {
136
138
  * @return - parsed response corresponding to the abi
137
139
  */
138
140
  protected parseResponse(method: string, response: string[]): Result;
139
- invoke(method: string, args?: Array<any>): Promise<AddTransactionResponse>;
140
- call(method: string, args?: Array<any>): Promise<Result>;
141
+ invoke(method: string, args?: Array<any>, options?: Overrides): Promise<AddTransactionResponse>;
142
+ call(
143
+ method: string,
144
+ args?: Array<any>,
145
+ {
146
+ blockIdentifier,
147
+ }?: {
148
+ blockIdentifier?: BlockIdentifier;
149
+ }
150
+ ): Promise<Result>;
141
151
  estimate(method: string, args?: Array<any>): Promise<import('../types').EstimateFeeResponse>;
142
152
  populate(method: string, args?: Array<any>): Invocation;
143
153
  }
@@ -224,8 +224,20 @@ function buildInvoke(contract, functionAbi) {
224
224
  args[_i] = arguments[_i];
225
225
  }
226
226
  return __awaiter(this, void 0, void 0, function () {
227
+ var inputs, inputsLength, options;
227
228
  return __generator(this, function (_a) {
228
- return [2 /*return*/, contract.invoke(functionAbi.name, args)];
229
+ inputs = functionAbi.inputs;
230
+ inputsLength = inputs.reduce(function (acc, input) {
231
+ if (!/_len$/.test(input.name)) {
232
+ return acc + 1;
233
+ }
234
+ return acc;
235
+ }, 0);
236
+ options = {};
237
+ if (inputsLength + 1 === args.length && typeof args[args.length - 1] === 'object') {
238
+ Object.assign(options, args.pop());
239
+ }
240
+ return [2 /*return*/, contract.invoke(functionAbi.name, args, options)];
229
241
  });
230
242
  });
231
243
  };
@@ -705,10 +717,13 @@ var Contract = /** @class */ (function () {
705
717
  return acc;
706
718
  }, []);
707
719
  };
708
- Contract.prototype.invoke = function (method, args) {
720
+ Contract.prototype.invoke = function (method, args, options) {
709
721
  if (args === void 0) {
710
722
  args = [];
711
723
  }
724
+ if (options === void 0) {
725
+ options = {};
726
+ }
712
727
  // ensure contract is connected
713
728
  (0, minimalistic_assert_1.default)(
714
729
  this.address !== null,
@@ -725,10 +740,6 @@ var Contract = /** @class */ (function () {
725
740
  }
726
741
  return acc;
727
742
  }, 0);
728
- var overrides = {};
729
- if (args.length === inputsLength + 1 && Array.isArray(args[args.length - 1])) {
730
- Object.assign(overrides, args.pop());
731
- }
732
743
  if (args.length !== inputsLength) {
733
744
  throw Error(
734
745
  'Invalid number of arguments, expected ' +
@@ -746,22 +757,25 @@ var Contract = /** @class */ (function () {
746
757
  };
747
758
  if ('execute' in this.providerOrAccount) {
748
759
  return this.providerOrAccount.execute(invocation, undefined, {
749
- maxFee: overrides.maxFee,
750
- nonce: overrides.nonce,
760
+ maxFee: options.maxFee,
761
+ nonce: options.nonce,
751
762
  });
752
763
  }
753
764
  return this.providerOrAccount.invokeFunction(
754
- __assign(__assign({}, invocation), { signature: overrides.signature || [] })
765
+ __assign(__assign({}, invocation), { signature: options.signature || [] })
755
766
  );
756
767
  };
757
- Contract.prototype.call = function (method, args) {
768
+ Contract.prototype.call = function (method, args, _a) {
758
769
  if (args === void 0) {
759
770
  args = [];
760
771
  }
772
+ var _b = _a === void 0 ? {} : _a,
773
+ _c = _b.blockIdentifier,
774
+ blockIdentifier = _c === void 0 ? 'pending' : _c;
761
775
  return __awaiter(this, void 0, void 0, function () {
762
- var inputs, inputsLength, options, calldata;
776
+ var inputs, calldata;
763
777
  var _this = this;
764
- return __generator(this, function (_a) {
778
+ return __generator(this, function (_d) {
765
779
  // ensure contract is connected
766
780
  (0,
767
781
  minimalistic_assert_1.default)(this.address !== null, 'contract isnt connected to an address');
@@ -770,13 +784,6 @@ var Contract = /** @class */ (function () {
770
784
  inputs = this.abi.find(function (abi) {
771
785
  return abi.name === method;
772
786
  }).inputs;
773
- inputsLength = inputs.length;
774
- options = {
775
- blockIdentifier: null,
776
- };
777
- if (args.length === inputsLength + 1 && typeof args[args.length - 1] === 'object') {
778
- Object.assign(options, args.pop());
779
- }
780
787
  calldata = this.compileCalldata(args, inputs);
781
788
  return [
782
789
  2 /*return*/,
@@ -787,7 +794,7 @@ var Contract = /** @class */ (function () {
787
794
  calldata: calldata,
788
795
  entrypoint: method,
789
796
  },
790
- options
797
+ { blockIdentifier: blockIdentifier }
791
798
  )
792
799
  .then(function (x) {
793
800
  return _this.parseResponse(method, x.result);
@@ -1,11 +1,13 @@
1
1
  import { AccountInterface } from '../account';
2
2
  import { ProviderInterface } from '../provider';
3
+ import { BlockIdentifier } from '../provider/utils';
3
4
  import {
4
5
  Abi,
5
6
  AddTransactionResponse,
6
7
  AsyncContractFunction,
7
8
  ContractFunction,
8
9
  Invocation,
10
+ Overrides,
9
11
  Result,
10
12
  } from '../types';
11
13
  export declare abstract class ContractInterface {
@@ -52,7 +54,13 @@ export declare abstract class ContractInterface {
52
54
  * @param args Array of the arguments for the call
53
55
  * @returns Result of the call as an array with key value pars
54
56
  */
55
- abstract call(method: string, args?: Array<any>): Promise<Result>;
57
+ abstract call(
58
+ method: string,
59
+ args?: Array<any>,
60
+ options?: {
61
+ blockIdentifier?: BlockIdentifier;
62
+ }
63
+ ): Promise<Result>;
56
64
  /**
57
65
  * Invokes a method on a contract
58
66
  *
@@ -60,14 +68,24 @@ export declare abstract class ContractInterface {
60
68
  * @param args Array of the arguments for the invoke
61
69
  * @returns Add Transaction Response
62
70
  */
63
- abstract invoke(method: string, args?: Array<any>): Promise<AddTransactionResponse>;
71
+ abstract invoke(
72
+ method: string,
73
+ args?: Array<any>,
74
+ options?: Overrides
75
+ ): Promise<AddTransactionResponse>;
64
76
  /**
65
77
  * Calls a method on a contract
66
78
  *
67
79
  * @param method name of the method
68
80
  * @param args Array of the arguments for the call
69
81
  */
70
- abstract estimate(method: string, args?: Array<any>): Promise<any>;
82
+ abstract estimate(
83
+ method: string,
84
+ args?: Array<any>,
85
+ options?: {
86
+ blockIdentifier?: BlockIdentifier;
87
+ }
88
+ ): Promise<any>;
71
89
  /**
72
90
  * Calls a method on a contract
73
91
  *
@@ -1,4 +1,6 @@
1
1
  import { Provider } from '../provider';
2
+ import { BlockIdentifier } from '../provider/utils';
3
+ import { SignerInterface } from '../signer';
2
4
  import { Abi, AddTransactionResponse, Call, EstimateFeeResponse, InvocationsDetails, KeyPair, Signature, Transaction } from '../types';
3
5
  import { BigNumberish } from '../utils/number';
4
6
  import { TypedData } from '../utils/typedData';
@@ -6,9 +8,12 @@ import { AccountInterface } from './interface';
6
8
  export declare class Account extends Provider implements AccountInterface {
7
9
  address: string;
8
10
  private signer;
9
- constructor(provider: Provider, address: string, keyPair: KeyPair);
11
+ constructor(provider: Provider, address: string, keyPairOrSigner: KeyPair | SignerInterface);
10
12
  getNonce(): Promise<string>;
11
- estimateFee(calls: Call | Call[]): Promise<EstimateFeeResponse>;
13
+ estimateFee(calls: Call | Call[], { nonce: providedNonce, blockIdentifier, }?: {
14
+ nonce?: BigNumberish;
15
+ blockIdentifier?: BlockIdentifier;
16
+ }): Promise<EstimateFeeResponse>;
12
17
  /**
13
18
  * Invoke execute function in account contract
14
19
  *