starknet 3.5.1 → 3.8.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 (84) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/__tests__/account.test.ts +38 -20
  3. package/__tests__/accountContract.test.ts +0 -31
  4. package/__tests__/constancts.ts +2 -0
  5. package/__tests__/contract.test.ts +14 -21
  6. package/__tests__/provider.test.ts +8 -0
  7. package/account/default.d.ts +14 -1
  8. package/account/default.js +78 -14
  9. package/account/interface.d.ts +14 -0
  10. package/contract/default.d.ts +13 -3
  11. package/contract/default.js +36 -25
  12. package/contract/interface.d.ts +21 -3
  13. package/dist/account/default.d.ts +8 -2
  14. package/dist/account/default.js +57 -11
  15. package/dist/account/interface.d.ts +13 -1
  16. package/dist/contract/default.d.ts +7 -4
  17. package/dist/contract/default.js +27 -24
  18. package/dist/contract/interface.d.ts +9 -4
  19. package/dist/provider/default.d.ts +11 -4
  20. package/dist/provider/default.js +34 -30
  21. package/dist/provider/utils.d.ts +1 -2
  22. package/dist/provider/utils.js +7 -8
  23. package/dist/signer/index.d.ts +1 -0
  24. package/dist/signer/index.js +1 -0
  25. package/dist/signer/ledger.d.ts +12 -0
  26. package/dist/signer/ledger.js +138 -0
  27. package/dist/types/api.d.ts +60 -3
  28. package/package.json +5 -2
  29. package/provider/default.d.ts +13 -3
  30. package/provider/default.js +49 -42
  31. package/provider/utils.d.ts +1 -2
  32. package/provider/utils.js +7 -8
  33. package/signer/index.d.ts +1 -0
  34. package/signer/index.js +1 -0
  35. package/signer/ledger.d.ts +15 -0
  36. package/signer/ledger.js +243 -0
  37. package/src/account/default.ts +40 -6
  38. package/src/account/interface.ts +15 -0
  39. package/src/contract/default.ts +37 -34
  40. package/src/contract/interface.ts +21 -3
  41. package/src/provider/default.ts +31 -23
  42. package/src/provider/utils.ts +7 -8
  43. package/src/signer/index.ts +1 -0
  44. package/src/signer/ledger.ts +81 -0
  45. package/src/types/api.ts +65 -4
  46. package/tsconfig.json +1 -10
  47. package/types/api.d.ts +60 -3
  48. package/www/README.md +41 -0
  49. package/www/babel.config.js +3 -0
  50. package/www/code-examples/account.js +62 -0
  51. package/www/code-examples/amm.js +49 -0
  52. package/www/code-examples/erc20.js +10 -0
  53. package/www/code-examples/package-lock.json +336 -0
  54. package/www/code-examples/package.json +15 -0
  55. package/www/docs/API/_category_.json +5 -0
  56. package/www/docs/API/account.md +11 -0
  57. package/www/docs/API/contract.md +14 -0
  58. package/www/docs/API/index.md +4 -0
  59. package/www/docs/API/provider.md +10 -0
  60. package/www/docs/API/signer.md +8 -0
  61. package/www/docusaurus.config.js +131 -0
  62. package/www/guides/account.md +60 -0
  63. package/www/guides/cra.md +3 -0
  64. package/www/guides/erc20.md +88 -0
  65. package/www/guides/intro.md +20 -0
  66. package/www/package-lock.json +22285 -0
  67. package/www/package.json +43 -0
  68. package/www/sidebars.js +31 -0
  69. package/www/src/components/HomepageFeatures/index.tsx +67 -0
  70. package/www/src/components/HomepageFeatures/styles.module.css +10 -0
  71. package/www/src/css/custom.css +39 -0
  72. package/www/src/pages/index.module.css +23 -0
  73. package/www/src/pages/index.tsx +40 -0
  74. package/www/src/pages/markdown-page.md +7 -0
  75. package/www/static/.nojekyll +0 -0
  76. package/www/static/img/docusaurus.png +0 -0
  77. package/www/static/img/favicon.ico +0 -0
  78. package/www/static/img/logo.svg +17 -0
  79. package/www/static/img/starknet-1.png +0 -0
  80. package/www/static/img/starknet-2.png +0 -0
  81. package/www/static/img/starknet-3.png +0 -0
  82. package/www/static/img/tutorial/docsVersionDropdown.png +0 -0
  83. package/www/static/img/tutorial/localeDropdown.png +0 -0
  84. package/www/tsconfig.json +8 -0
@@ -0,0 +1,138 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ exports.LedgerBlindSigner = void 0;
43
+ var hw_app_eth_1 = __importDefault(require("@ledgerhq/hw-app-eth"));
44
+ var hw_transport_webhid_1 = __importDefault(require("@ledgerhq/hw-transport-webhid"));
45
+ var encode_1 = require("../utils/encode");
46
+ var hash_1 = require("../utils/hash");
47
+ var typedData_1 = require("../utils/typedData");
48
+ function hexZeroPad(hash, length) {
49
+ var value = hash;
50
+ if (value.length > 2 * length + 2) {
51
+ throw new Error('value out of range');
52
+ }
53
+ while (value.length < 2 * length + 2) {
54
+ value = "0x0" + value.substring(2);
55
+ }
56
+ return value;
57
+ }
58
+ var LedgerBlindSigner = /** @class */ (function () {
59
+ function LedgerBlindSigner() {
60
+ this.derivationPath = "/2645'/579218131'/1148870696'/0'/0'/0";
61
+ }
62
+ LedgerBlindSigner.prototype.getEthApp = function () {
63
+ return __awaiter(this, void 0, void 0, function () {
64
+ var _a, _b;
65
+ return __generator(this, function (_c) {
66
+ switch (_c.label) {
67
+ case 0:
68
+ if (!!this.transport) return [3 /*break*/, 4];
69
+ _c.label = 1;
70
+ case 1:
71
+ _c.trys.push([1, 3, , 4]);
72
+ _a = this;
73
+ return [4 /*yield*/, hw_transport_webhid_1.default.create()];
74
+ case 2:
75
+ _a.transport = _c.sent();
76
+ return [3 /*break*/, 4];
77
+ case 3:
78
+ _b = _c.sent();
79
+ throw new Error('Device connection error');
80
+ case 4: return [2 /*return*/, new hw_app_eth_1.default(this.transport)];
81
+ }
82
+ });
83
+ });
84
+ };
85
+ LedgerBlindSigner.prototype.getPubKey = function () {
86
+ return __awaiter(this, void 0, void 0, function () {
87
+ var eth, response, starkPub;
88
+ return __generator(this, function (_a) {
89
+ switch (_a.label) {
90
+ case 0: return [4 /*yield*/, this.getEthApp()];
91
+ case 1:
92
+ eth = _a.sent();
93
+ return [4 /*yield*/, eth.starkGetPublicKey(this.derivationPath)];
94
+ case 2:
95
+ response = _a.sent();
96
+ starkPub = "0x" + response.slice(1, 1 + 32).toString('hex');
97
+ return [2 /*return*/, starkPub];
98
+ }
99
+ });
100
+ });
101
+ };
102
+ LedgerBlindSigner.prototype.signTransaction = function (transactions, transactionsDetail) {
103
+ return __awaiter(this, void 0, void 0, function () {
104
+ var msgHash;
105
+ return __generator(this, function (_a) {
106
+ msgHash = (0, hash_1.hashMulticall)(transactionsDetail.walletAddress, transactions, transactionsDetail.nonce.toString(), transactionsDetail.maxFee.toString());
107
+ return [2 /*return*/, this.sign(msgHash)];
108
+ });
109
+ });
110
+ };
111
+ LedgerBlindSigner.prototype.signMessage = function (typedData, accountAddress) {
112
+ return __awaiter(this, void 0, void 0, function () {
113
+ var msgHash;
114
+ return __generator(this, function (_a) {
115
+ msgHash = (0, typedData_1.getMessageHash)(typedData, accountAddress);
116
+ return [2 /*return*/, this.sign(msgHash)];
117
+ });
118
+ });
119
+ };
120
+ LedgerBlindSigner.prototype.sign = function (msgHash) {
121
+ return __awaiter(this, void 0, void 0, function () {
122
+ var eth, _a, r, s;
123
+ return __generator(this, function (_b) {
124
+ switch (_b.label) {
125
+ case 0: return [4 /*yield*/, this.getEthApp()];
126
+ case 1:
127
+ eth = _b.sent();
128
+ return [4 /*yield*/, eth.starkUnsafeSign(this.derivationPath, hexZeroPad(msgHash, 32))];
129
+ case 2:
130
+ _a = (_b.sent()), r = _a.r, s = _a.s;
131
+ return [2 /*return*/, [(0, encode_1.addHexPrefix)(r), (0, encode_1.addHexPrefix)(s)]];
132
+ }
133
+ });
134
+ });
135
+ };
136
+ return LedgerBlindSigner;
137
+ }());
138
+ exports.LedgerBlindSigner = LedgerBlindSigner;
@@ -26,6 +26,13 @@ export declare type Endpoints = {
26
26
  REQUEST: never;
27
27
  RESPONSE: GetTransactionStatusResponse;
28
28
  };
29
+ get_transaction_trace: {
30
+ QUERY: {
31
+ transactionHash: string;
32
+ };
33
+ REQUEST: never;
34
+ RESPONSE: GetTransactionTraceResponse;
35
+ };
29
36
  get_storage_at: {
30
37
  QUERY: {
31
38
  contractAddress: string;
@@ -58,8 +65,10 @@ export declare type Endpoints = {
58
65
  RESPONSE: CallContractResponse;
59
66
  };
60
67
  estimate_fee: {
61
- QUERY: never;
62
- REQUEST: Transaction;
68
+ QUERY: {
69
+ blockIdentifier: BlockIdentifier;
70
+ };
71
+ REQUEST: CallContractTransaction;
63
72
  RESPONSE: EstimateFeeResponse;
64
73
  };
65
74
  };
@@ -82,6 +91,31 @@ export declare type InvokeFunctionTransaction = {
82
91
  entry_point_selector: string;
83
92
  calldata?: RawCalldata;
84
93
  nonce?: BigNumberish;
94
+ max_fee?: BigNumberish;
95
+ };
96
+ export declare type InvokeFunctionTrace = {
97
+ caller_address: string;
98
+ contract_address: string;
99
+ code_address: string;
100
+ selector: string;
101
+ calldata: RawCalldata;
102
+ result: Array<any>;
103
+ execution_resources: ExecutionResources;
104
+ internal_call: Array<InvokeFunctionTrace>;
105
+ events: Array<any>;
106
+ messages: Array<any>;
107
+ };
108
+ export declare type ExecutionResources = {
109
+ n_steps: number;
110
+ builtin_instance_counter: {
111
+ pedersen_builtin: number;
112
+ range_check_builtin: number;
113
+ bitwise_builtin: number;
114
+ output_builtin: number;
115
+ ecdsa_builtin: number;
116
+ ec_op_builtin: number;
117
+ };
118
+ n_memory_holes: number;
85
119
  };
86
120
  export declare type CallContractTransaction = Omit<InvokeFunctionTransaction, 'type' | 'entry_point_type' | 'nonce'>;
87
121
  export declare type Transaction = DeployTransaction | InvokeFunctionTransaction;
@@ -126,6 +160,21 @@ export declare type GetTransactionStatusResponse = {
126
160
  error_message: string;
127
161
  };
128
162
  };
163
+ export declare type GetTransactionTraceResponse = {
164
+ function_invocation: {
165
+ caller_address: string;
166
+ contract_address: string;
167
+ code_address: string;
168
+ selector: string;
169
+ calldata: RawArgs;
170
+ result: Array<any>;
171
+ execution_resources: any;
172
+ internal_call: Array<any>;
173
+ events: Array<any>;
174
+ messages: Array<any>;
175
+ };
176
+ signature: Signature;
177
+ };
129
178
  export declare type GetTransactionResponse = {
130
179
  status: Status;
131
180
  transaction: Transaction;
@@ -148,7 +197,10 @@ export declare type TransactionReceipt = {
148
197
  l2_to_l1_messages: string[];
149
198
  events: string[];
150
199
  };
151
- export declare type EstimateFeeResponse = {};
200
+ export declare type EstimateFeeResponse = {
201
+ amount: number;
202
+ unit: string;
203
+ };
152
204
  export declare type RawArgs = {
153
205
  [inputName: string]: string | string[] | {
154
206
  type: 'struct';
@@ -156,3 +208,8 @@ export declare type RawArgs = {
156
208
  };
157
209
  };
158
210
  export declare type Calldata = string[];
211
+ export declare type Overrides = {
212
+ maxFee?: BigNumberish;
213
+ nonce?: BigNumberish;
214
+ signature?: Signature;
215
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "starknet",
3
- "version": "3.5.1",
3
+ "version": "3.8.0",
4
4
  "description": "JavaScript library for StarkNet",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -11,7 +11,7 @@
11
11
  "test": "jest",
12
12
  "posttest": "npm run format",
13
13
  "test:watch": "jest --watch",
14
- "docs": "typedoc",
14
+ "docs": "cd www && npm run start",
15
15
  "format": "prettier --loglevel warn --write \"**/*.{ts,js,md,yml,json}\"",
16
16
  "lint": "eslint . --cache --fix --ext .ts"
17
17
  },
@@ -61,6 +61,9 @@
61
61
  "typescript": "^4.4.4"
62
62
  },
63
63
  "dependencies": {
64
+ "@ledgerhq/hw-app-eth": "^6.26.0",
65
+ "@ledgerhq/hw-transport": "^6.24.1",
66
+ "@ledgerhq/hw-transport-webhid": "^6.24.1",
64
67
  "axios": "^0.23.0",
65
68
  "bn.js": "^5.2.0",
66
69
  "elliptic": "^6.5.4",
@@ -10,6 +10,7 @@ import {
10
10
  GetContractAddressesResponse,
11
11
  GetTransactionResponse,
12
12
  GetTransactionStatusResponse,
13
+ GetTransactionTraceResponse,
13
14
  Invocation,
14
15
  TransactionReceipt,
15
16
  } from '../types';
@@ -65,8 +66,10 @@ export declare class Provider implements ProviderInterface {
65
66
  */
66
67
  callContract(
67
68
  { contractAddress, entrypoint, calldata }: Call,
68
- options?: {
69
- blockIdentifier: BlockIdentifier;
69
+ {
70
+ blockIdentifier,
71
+ }?: {
72
+ blockIdentifier?: BlockIdentifier;
70
73
  }
71
74
  ): Promise<CallContractResponse>;
72
75
  /**
@@ -140,6 +143,14 @@ export declare class Provider implements ProviderInterface {
140
143
  * @returns the transacton object { transaction_id, status, transaction, block_number?, block_number?, transaction_index?, transaction_failure_reason? }
141
144
  */
142
145
  getTransaction(txHash: BigNumberish): Promise<GetTransactionResponse>;
146
+ /**
147
+ * Gets the transaction trace from a tx id.
148
+ *
149
+ *
150
+ * @param txHash
151
+ * @returns the transaction trace
152
+ */
153
+ getTransactionTrace(txHash: BigNumberish): Promise<GetTransactionTraceResponse>;
143
154
  /**
144
155
  * Deploys a given compiled contract (json) to starknet
145
156
  *
@@ -157,7 +168,6 @@ export declare class Provider implements ProviderInterface {
157
168
  * @returns response from addTransaction
158
169
  */
159
170
  invokeFunction(invocation: Invocation, _abi?: Abi): Promise<AddTransactionResponse>;
160
- estimateFee(invocation: Invocation): Promise<any>;
161
171
  waitForTransaction(txHash: BigNumberish, retryInterval?: number): Promise<void>;
162
172
  /**
163
173
  * @deprecated use `waitForTransaction` instead
@@ -343,24 +343,28 @@ var Provider = /** @class */ (function () {
343
343
  * @param blockNumber
344
344
  * @returns the result of the function on the smart contract.
345
345
  */
346
- Provider.prototype.callContract = function (_a, options) {
346
+ Provider.prototype.callContract = function (_a, _b) {
347
347
  var contractAddress = _a.contractAddress,
348
348
  entrypoint = _a.entrypoint,
349
- _b = _a.calldata,
350
- calldata = _b === void 0 ? [] : _b;
351
- if (options === void 0) {
352
- options = { blockIdentifier: null };
353
- }
349
+ _c = _a.calldata,
350
+ calldata = _c === void 0 ? [] : _c;
351
+ var _d = _b === void 0 ? {} : _b,
352
+ _e = _d.blockIdentifier,
353
+ blockIdentifier = _e === void 0 ? 'pending' : _e;
354
354
  return __awaiter(this, void 0, void 0, function () {
355
- return __generator(this, function (_c) {
355
+ return __generator(this, function (_f) {
356
356
  return [
357
357
  2 /*return*/,
358
- this.fetchEndpoint('call_contract', options, {
359
- signature: [],
360
- contract_address: contractAddress,
361
- entry_point_selector: (0, hash_1.getSelectorFromName)(entrypoint),
362
- calldata: calldata,
363
- }),
358
+ this.fetchEndpoint(
359
+ 'call_contract',
360
+ { blockIdentifier: blockIdentifier },
361
+ {
362
+ signature: [],
363
+ contract_address: contractAddress,
364
+ entry_point_selector: (0, hash_1.getSelectorFromName)(entrypoint),
365
+ calldata: calldata,
366
+ }
367
+ ),
364
368
  ];
365
369
  });
366
370
  });
@@ -399,7 +403,7 @@ var Provider = /** @class */ (function () {
399
403
  */
400
404
  Provider.prototype.getCode = function (contractAddress, blockIdentifier) {
401
405
  if (blockIdentifier === void 0) {
402
- blockIdentifier = null;
406
+ blockIdentifier = 'pending';
403
407
  }
404
408
  return __awaiter(this, void 0, void 0, function () {
405
409
  return __generator(this, function (_a) {
@@ -427,7 +431,7 @@ var Provider = /** @class */ (function () {
427
431
  */
428
432
  Provider.prototype.getStorageAt = function (contractAddress, key, blockIdentifier) {
429
433
  if (blockIdentifier === void 0) {
430
- blockIdentifier = null;
434
+ blockIdentifier = 'pending';
431
435
  }
432
436
  return __awaiter(this, void 0, void 0, function () {
433
437
  return __generator(this, function (_a) {
@@ -516,6 +520,25 @@ var Provider = /** @class */ (function () {
516
520
  });
517
521
  });
518
522
  };
523
+ /**
524
+ * Gets the transaction trace from a tx id.
525
+ *
526
+ *
527
+ * @param txHash
528
+ * @returns the transaction trace
529
+ */
530
+ Provider.prototype.getTransactionTrace = function (txHash) {
531
+ return __awaiter(this, void 0, void 0, function () {
532
+ var txHashHex;
533
+ return __generator(this, function (_a) {
534
+ txHashHex = (0, number_1.toHex)((0, number_1.toBN)(txHash));
535
+ return [
536
+ 2 /*return*/,
537
+ this.fetchEndpoint('get_transaction_trace', { transactionHash: txHashHex }),
538
+ ];
539
+ });
540
+ });
541
+ };
519
542
  /**
520
543
  * Deploys a given compiled contract (json) to starknet
521
544
  *
@@ -562,48 +585,32 @@ var Provider = /** @class */ (function () {
562
585
  ),
563
586
  });
564
587
  };
565
- Provider.prototype.estimateFee = function (invocation) {
566
- var _a, _b;
567
- return this.fetchEndpoint('estimate_fee', undefined, {
568
- // TODO: change the TYPE of the call
569
- type: 'INVOKE_FUNCTION',
570
- contract_address: invocation.contractAddress,
571
- entry_point_selector: (0, hash_1.getSelectorFromName)(invocation.entrypoint),
572
- calldata: (0, number_1.bigNumberishArrayToDecimalStringArray)(
573
- (_a = invocation.calldata) !== null && _a !== void 0 ? _a : []
574
- ),
575
- signature: (0, number_1.bigNumberishArrayToDecimalStringArray)(
576
- (_b = invocation.signature) !== null && _b !== void 0 ? _b : []
577
- ),
578
- });
579
- };
580
588
  Provider.prototype.waitForTransaction = function (txHash, retryInterval) {
581
589
  if (retryInterval === void 0) {
582
590
  retryInterval = 8000;
583
591
  }
584
592
  return __awaiter(this, void 0, void 0, function () {
585
- var onchain, res, message, error;
593
+ var onchain, res, successStates, errorStates, message, error;
586
594
  return __generator(this, function (_a) {
587
595
  switch (_a.label) {
588
596
  case 0:
589
597
  onchain = false;
590
- return [4 /*yield*/, wait(retryInterval)];
598
+ _a.label = 1;
591
599
  case 1:
592
- _a.sent();
593
- _a.label = 2;
594
- case 2:
595
- if (!!onchain) return [3 /*break*/, 5];
600
+ if (!!onchain) return [3 /*break*/, 4];
596
601
  // eslint-disable-next-line no-await-in-loop
597
602
  return [4 /*yield*/, wait(retryInterval)];
598
- case 3:
603
+ case 2:
599
604
  // eslint-disable-next-line no-await-in-loop
600
605
  _a.sent();
601
606
  return [4 /*yield*/, this.getTransactionStatus(txHash)];
602
- case 4:
607
+ case 3:
603
608
  res = _a.sent();
604
- if (res.tx_status === 'ACCEPTED_ON_L1' || res.tx_status === 'ACCEPTED_ON_L2') {
609
+ successStates = ['ACCEPTED_ON_L1', 'ACCEPTED_ON_L2', 'PENDING'];
610
+ errorStates = ['REJECTED', 'NOT_RECEIVED'];
611
+ if (successStates.includes(res.tx_status)) {
605
612
  onchain = true;
606
- } else if (res.tx_status === 'REJECTED' || res.tx_status === 'NOT_RECEIVED') {
613
+ } else if (errorStates.includes(res.tx_status)) {
607
614
  message = res.tx_failure_reason
608
615
  ? res.tx_status +
609
616
  ': ' +
@@ -615,8 +622,8 @@ var Provider = /** @class */ (function () {
615
622
  error.response = res;
616
623
  throw error;
617
624
  }
618
- return [3 /*break*/, 2];
619
- case 5:
625
+ return [3 /*break*/, 1];
626
+ case 4:
620
627
  return [2 /*return*/];
621
628
  }
622
629
  });
@@ -37,8 +37,7 @@ export declare function getBlockIdentifier(blockIdentifier: BlockIdentifier): Bl
37
37
  *
38
38
  * [Reference](https://github.com/starkware-libs/cairo-lang/blob/fc97bdd8322a7df043c87c371634b26c15ed6cee/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L164-L173)
39
39
  *
40
- * @param blockNumber
41
- * @param blockHash
40
+ * @param blockIdentifier
42
41
  * @returns block identifier for API request
43
42
  */
44
43
  export declare function getFormattedBlockIdentifier(blockIdentifier?: BlockIdentifier): string;
package/provider/utils.js CHANGED
@@ -39,6 +39,12 @@ 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: null };
44
+ }
45
+ if (blockIdentifier === 'pending') {
46
+ return { type: 'BLOCK_NUMBER', data: 'pending' };
47
+ }
42
48
  if (typeof blockIdentifier === 'number') {
43
49
  return { type: 'BLOCK_NUMBER', data: blockIdentifier };
44
50
  }
@@ -48,12 +54,6 @@ function getBlockIdentifier(blockIdentifier) {
48
54
  if (typeof blockIdentifier === 'string' && !Number.isNaN(parseInt(blockIdentifier, 10))) {
49
55
  return { type: 'BLOCK_NUMBER', data: parseInt(blockIdentifier, 10) };
50
56
  }
51
- if (blockIdentifier === null) {
52
- return { type: 'BLOCK_NUMBER', data: null };
53
- }
54
- if (blockIdentifier === 'pending') {
55
- return { type: 'BLOCK_NUMBER', data: 'pending' };
56
- }
57
57
  if (typeof blockIdentifier === 'string') {
58
58
  throw new Error('Invalid block identifier: ' + blockIdentifier);
59
59
  }
@@ -65,8 +65,7 @@ exports.getBlockIdentifier = getBlockIdentifier;
65
65
  *
66
66
  * [Reference](https://github.com/starkware-libs/cairo-lang/blob/fc97bdd8322a7df043c87c371634b26c15ed6cee/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L164-L173)
67
67
  *
68
- * @param blockNumber
69
- * @param blockHash
68
+ * @param blockIdentifier
70
69
  * @returns block identifier for API request
71
70
  */
72
71
  function getFormattedBlockIdentifier(blockIdentifier) {
package/signer/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './interface';
2
2
  export * from './default';
3
+ export * from './ledger';
package/signer/index.js CHANGED
@@ -25,3 +25,4 @@ var __exportStar =
25
25
  Object.defineProperty(exports, '__esModule', { value: true });
26
26
  __exportStar(require('./interface'), exports);
27
27
  __exportStar(require('./default'), exports);
28
+ __exportStar(require('./ledger'), exports);
@@ -0,0 +1,15 @@
1
+ import { Invocation, InvocationsSignerDetails, Signature } from '../types';
2
+ import { TypedData } from '../utils/typedData';
3
+ import { SignerInterface } from './interface';
4
+ export declare class LedgerBlindSigner implements SignerInterface {
5
+ derivationPath: string;
6
+ private transport;
7
+ private getEthApp;
8
+ getPubKey(): Promise<string>;
9
+ signTransaction(
10
+ transactions: Invocation[],
11
+ transactionsDetail: InvocationsSignerDetails
12
+ ): Promise<Signature>;
13
+ signMessage(typedData: TypedData, accountAddress: string): Promise<Signature>;
14
+ protected sign(msgHash: string): Promise<Signature>;
15
+ }