starknet 3.18.2 → 4.0.1

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 (165) hide show
  1. package/CHANGELOG.md +70 -0
  2. package/README.md +1 -2
  3. package/__tests__/account.test.ts +11 -56
  4. package/__tests__/contract.test.ts +11 -49
  5. package/__tests__/defaultProvider.test.ts +321 -0
  6. package/__tests__/fixtures.ts +32 -11
  7. package/__tests__/jest.setup.ts +2 -3
  8. package/__tests__/rpcProvider.test.ts +17 -0
  9. package/__tests__/sequencerProvider.test.ts +45 -0
  10. package/account/default.d.ts +54 -77
  11. package/account/default.js +271 -596
  12. package/account/index.js +18 -31
  13. package/account/interface.d.ts +66 -95
  14. package/account/interface.js +20 -30
  15. package/constants.d.ts +17 -19
  16. package/constants.js +2038 -2059
  17. package/contract/contractFactory.d.ts +25 -29
  18. package/contract/contractFactory.js +94 -210
  19. package/contract/default.d.ts +117 -146
  20. package/contract/default.js +582 -776
  21. package/contract/index.js +19 -32
  22. package/contract/interface.d.ts +72 -92
  23. package/contract/interface.js +6 -5
  24. package/dist/account/default.d.ts +5 -9
  25. package/dist/account/default.js +35 -169
  26. package/dist/account/interface.d.ts +3 -15
  27. package/dist/contract/contractFactory.js +4 -4
  28. package/dist/contract/default.d.ts +3 -3
  29. package/dist/contract/default.js +3 -2
  30. package/dist/contract/interface.d.ts +2 -2
  31. package/dist/provider/default.d.ts +18 -134
  32. package/dist/provider/default.js +47 -411
  33. package/dist/provider/index.d.ts +2 -0
  34. package/dist/provider/index.js +2 -0
  35. package/dist/provider/interface.d.ts +45 -50
  36. package/dist/provider/rpc.d.ts +57 -0
  37. package/dist/provider/rpc.js +364 -0
  38. package/dist/provider/sequencer.d.ts +66 -0
  39. package/dist/provider/sequencer.js +444 -0
  40. package/dist/types/account.d.ts +2 -3
  41. package/dist/types/api/index.d.ts +16 -0
  42. package/dist/types/api/index.js +18 -0
  43. package/dist/types/api/rpc.d.ts +221 -0
  44. package/dist/types/{api.js → api/rpc.js} +0 -0
  45. package/dist/types/api/sequencer.d.ts +289 -0
  46. package/dist/types/api/sequencer.js +2 -0
  47. package/dist/types/index.d.ts +3 -1
  48. package/dist/types/index.js +15 -1
  49. package/dist/types/lib.d.ts +3 -1
  50. package/dist/types/provider.d.ts +86 -0
  51. package/dist/types/provider.js +2 -0
  52. package/dist/utils/fetchPonyfill.d.ts +2 -0
  53. package/dist/utils/fetchPonyfill.js +6 -0
  54. package/dist/utils/provider.d.ts +4 -0
  55. package/dist/utils/provider.js +38 -0
  56. package/dist/utils/responseParser/index.d.ts +11 -0
  57. package/dist/utils/responseParser/index.js +9 -0
  58. package/dist/utils/responseParser/rpc.d.ts +13 -0
  59. package/dist/utils/responseParser/rpc.js +96 -0
  60. package/dist/utils/responseParser/sequencer.d.ts +13 -0
  61. package/dist/utils/responseParser/sequencer.js +124 -0
  62. package/index.js +42 -75
  63. package/package.json +2 -3
  64. package/provider/default.d.ts +21 -175
  65. package/provider/default.js +139 -704
  66. package/provider/errors.d.ts +4 -4
  67. package/provider/errors.js +30 -40
  68. package/provider/index.d.ts +2 -0
  69. package/provider/index.js +22 -33
  70. package/provider/interface.d.ts +104 -131
  71. package/provider/interface.js +6 -5
  72. package/provider/rpc.d.ts +57 -0
  73. package/provider/rpc.js +364 -0
  74. package/provider/sequencer.d.ts +66 -0
  75. package/provider/sequencer.js +444 -0
  76. package/provider/utils.d.ts +7 -9
  77. package/provider/utils.js +39 -44
  78. package/signer/default.d.ts +5 -9
  79. package/signer/default.js +72 -177
  80. package/signer/index.js +18 -31
  81. package/signer/interface.d.ts +29 -33
  82. package/signer/interface.js +6 -5
  83. package/src/account/default.ts +26 -146
  84. package/src/account/interface.ts +5 -20
  85. package/src/contract/contractFactory.ts +3 -6
  86. package/src/contract/default.ts +6 -4
  87. package/src/contract/interface.ts +2 -2
  88. package/src/provider/default.ts +63 -395
  89. package/src/provider/index.ts +2 -0
  90. package/src/provider/interface.ts +68 -63
  91. package/src/provider/rpc.ts +299 -0
  92. package/src/provider/sequencer.ts +385 -0
  93. package/src/types/account.ts +2 -3
  94. package/src/types/api/index.ts +17 -0
  95. package/src/types/api/rpc.ts +247 -0
  96. package/src/types/api/sequencer.ts +331 -0
  97. package/src/types/index.ts +3 -1
  98. package/src/types/lib.ts +3 -1
  99. package/src/types/provider.ts +108 -0
  100. package/src/utils/fetchPonyfill.ts +4 -0
  101. package/src/utils/provider.ts +28 -0
  102. package/src/utils/responseParser/index.ts +28 -0
  103. package/src/utils/responseParser/rpc.ts +93 -0
  104. package/src/utils/responseParser/sequencer.ts +127 -0
  105. package/types/account.d.ts +5 -7
  106. package/types/account.js +2 -2
  107. package/types/api/index.d.ts +16 -0
  108. package/types/api/index.js +18 -0
  109. package/types/api/rpc.d.ts +221 -0
  110. package/types/api/rpc.js +2 -0
  111. package/types/api/sequencer.d.ts +289 -0
  112. package/types/api/sequencer.js +2 -0
  113. package/types/contract.d.ts +1 -1
  114. package/types/contract.js +2 -2
  115. package/types/index.d.ts +3 -1
  116. package/types/index.js +35 -34
  117. package/types/lib.d.ts +36 -41
  118. package/types/lib.js +2 -2
  119. package/types/provider.d.ts +86 -0
  120. package/types/provider.js +2 -0
  121. package/types/signer.d.ts +2 -2
  122. package/types/signer.js +2 -2
  123. package/utils/address.js +26 -37
  124. package/utils/ellipticCurve.d.ts +1 -6
  125. package/utils/ellipticCurve.js +73 -137
  126. package/utils/encode.js +49 -85
  127. package/utils/fetchPonyfill.d.ts +2 -0
  128. package/utils/fetchPonyfill.js +6 -0
  129. package/utils/hash.d.ts +4 -31
  130. package/utils/hash.js +76 -141
  131. package/utils/json.d.ts +13 -45
  132. package/utils/json.js +15 -22
  133. package/utils/number.d.ts +2 -9
  134. package/utils/number.js +47 -81
  135. package/utils/provider.d.ts +4 -0
  136. package/utils/provider.js +38 -0
  137. package/utils/responseParser/index.d.ts +11 -0
  138. package/utils/responseParser/index.js +9 -0
  139. package/utils/responseParser/rpc.d.ts +13 -0
  140. package/utils/responseParser/rpc.js +96 -0
  141. package/utils/responseParser/sequencer.d.ts +13 -0
  142. package/utils/responseParser/sequencer.js +124 -0
  143. package/utils/shortString.js +13 -21
  144. package/utils/stark.d.ts +0 -1
  145. package/utils/stark.js +59 -93
  146. package/utils/transaction.d.ts +3 -6
  147. package/utils/transaction.js +50 -81
  148. package/utils/typedData/index.d.ts +3 -15
  149. package/utils/typedData/index.js +109 -175
  150. package/utils/typedData/types.d.ts +9 -9
  151. package/utils/typedData/types.js +2 -2
  152. package/utils/typedData/utils.js +6 -6
  153. package/utils/uint256.d.ts +5 -5
  154. package/utils/uint256.js +16 -26
  155. package/www/docs/API/account.md +3 -4
  156. package/www/docs/API/contract.md +2 -2
  157. package/www/docs/API/contractFactory.md +2 -2
  158. package/www/docs/API/provider.md +185 -74
  159. package/www/guides/account.md +1 -8
  160. package/www/guides/erc20.md +3 -0
  161. package/__tests__/provider.test.ts +0 -168
  162. package/dist/types/api.d.ts +0 -261
  163. package/src/types/api.ts +0 -303
  164. package/types/api.d.ts +0 -287
  165. package/types/api.js +0 -2
@@ -1,9 +1,9 @@
1
1
  import { CustomError } from 'ts-custom-error';
2
2
  export declare class GatewayError extends CustomError {
3
- errorCode: string;
4
- constructor(message: string, errorCode: string);
3
+ errorCode: string;
4
+ constructor(message: string, errorCode: string);
5
5
  }
6
6
  export declare class HttpError extends CustomError {
7
- errorCode: number;
8
- constructor(message: string, errorCode: number);
7
+ errorCode: number;
8
+ constructor(message: string, errorCode: number);
9
9
  }
@@ -1,50 +1,40 @@
1
- 'use strict';
2
- var __extends =
3
- (this && this.__extends) ||
4
- (function () {
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
5
3
  var extendStatics = function (d, b) {
6
- extendStatics =
7
- Object.setPrototypeOf ||
8
- ({ __proto__: [] } instanceof Array &&
9
- function (d, b) {
10
- d.__proto__ = b;
11
- }) ||
12
- function (d, b) {
13
- for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
14
- };
15
- return extendStatics(d, b);
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
16
8
  };
17
9
  return function (d, b) {
18
- if (typeof b !== 'function' && b !== null)
19
- throw new TypeError('Class extends value ' + String(b) + ' is not a constructor or null');
20
- extendStatics(d, b);
21
- function __() {
22
- this.constructor = d;
23
- }
24
- d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __());
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
25
15
  };
26
- })();
27
- Object.defineProperty(exports, '__esModule', { value: true });
16
+ })();
17
+ Object.defineProperty(exports, "__esModule", { value: true });
28
18
  exports.HttpError = exports.GatewayError = void 0;
29
19
  /* eslint-disable max-classes-per-file */
30
- var ts_custom_error_1 = require('ts-custom-error');
20
+ var ts_custom_error_1 = require("ts-custom-error");
31
21
  var GatewayError = /** @class */ (function (_super) {
32
- __extends(GatewayError, _super);
33
- function GatewayError(message, errorCode) {
34
- var _this = _super.call(this, message) || this;
35
- _this.errorCode = errorCode;
36
- return _this;
37
- }
38
- return GatewayError;
39
- })(ts_custom_error_1.CustomError);
22
+ __extends(GatewayError, _super);
23
+ function GatewayError(message, errorCode) {
24
+ var _this = _super.call(this, message) || this;
25
+ _this.errorCode = errorCode;
26
+ return _this;
27
+ }
28
+ return GatewayError;
29
+ }(ts_custom_error_1.CustomError));
40
30
  exports.GatewayError = GatewayError;
41
31
  var HttpError = /** @class */ (function (_super) {
42
- __extends(HttpError, _super);
43
- function HttpError(message, errorCode) {
44
- var _this = _super.call(this, message) || this;
45
- _this.errorCode = errorCode;
46
- return _this;
47
- }
48
- return HttpError;
49
- })(ts_custom_error_1.CustomError);
32
+ __extends(HttpError, _super);
33
+ function HttpError(message, errorCode) {
34
+ var _this = _super.call(this, message) || this;
35
+ _this.errorCode = errorCode;
36
+ return _this;
37
+ }
38
+ return HttpError;
39
+ }(ts_custom_error_1.CustomError));
50
40
  exports.HttpError = HttpError;
@@ -1,5 +1,7 @@
1
1
  import { Provider } from './default';
2
2
  export * from './default';
3
3
  export * from './errors';
4
+ export * from './sequencer';
4
5
  export * from './interface';
6
+ export * from './rpc';
5
7
  export declare const defaultProvider: Provider;
package/provider/index.js CHANGED
@@ -1,35 +1,24 @@
1
- 'use strict';
2
- var __createBinding =
3
- (this && this.__createBinding) ||
4
- (Object.create
5
- ? function (o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- var desc = Object.getOwnPropertyDescriptor(m, k);
8
- if (!desc || ('get' in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
- desc = {
10
- enumerable: true,
11
- get: function () {
12
- return m[k];
13
- },
14
- };
15
- }
16
- Object.defineProperty(o, k2, desc);
17
- }
18
- : function (o, m, k, k2) {
19
- if (k2 === undefined) k2 = k;
20
- o[k2] = m[k];
21
- });
22
- var __exportStar =
23
- (this && this.__exportStar) ||
24
- function (m, exports) {
25
- for (var p in m)
26
- if (p !== 'default' && !Object.prototype.hasOwnProperty.call(exports, p))
27
- __createBinding(exports, m, p);
28
- };
29
- Object.defineProperty(exports, '__esModule', { value: true });
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
30
17
  exports.defaultProvider = void 0;
31
- var default_1 = require('./default');
32
- __exportStar(require('./default'), exports);
33
- __exportStar(require('./errors'), exports);
34
- __exportStar(require('./interface'), exports);
18
+ var default_1 = require("./default");
19
+ __exportStar(require("./default"), exports);
20
+ __exportStar(require("./errors"), exports);
21
+ __exportStar(require("./sequencer"), exports);
22
+ __exportStar(require("./interface"), exports);
23
+ __exportStar(require("./rpc"), exports);
35
24
  exports.defaultProvider = new default_1.Provider();
@@ -1,136 +1,109 @@
1
1
  import { StarknetChainId } from '../constants';
2
- import type {
3
- AddTransactionResponse,
4
- Call,
5
- CallContractResponse,
6
- DeployContractPayload,
7
- GetBlockResponse,
8
- GetCodeResponse,
9
- GetContractAddressesResponse,
10
- GetTransactionResponse,
11
- GetTransactionStatusResponse,
12
- Invocation,
13
- TransactionReceiptResponse,
14
- } from '../types';
2
+ import type { BlockTag, Call, CallContractResponse, ContractClass, DeclareContractPayload, DeclareContractResponse, DeployContractPayload, DeployContractResponse, EstimateFeeResponse, GetBlockResponse, GetTransactionReceiptResponse, GetTransactionResponse, Invocation, InvocationsDetails, InvokeFunctionResponse } from '../types';
15
3
  import type { BigNumberish } from '../utils/number';
16
4
  import { BlockIdentifier } from './utils';
17
5
  export declare abstract class ProviderInterface {
18
- abstract baseUrl: string;
19
- abstract feederGatewayUrl: string;
20
- abstract gatewayUrl: string;
21
- abstract chainId: StarknetChainId;
22
- /**
23
- * Gets the smart contract address on the goerli testnet.
24
- *
25
- * [Reference](https://github.com/starkware-libs/cairo-lang/blob/f464ec4797361b6be8989e36e02ec690e74ef285/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L13-L15)
26
- * @returns starknet smart contract addresses
27
- */
28
- abstract getContractAddresses(): Promise<GetContractAddressesResponse>;
29
- /**
30
- * Calls a function on the StarkNet contract.
31
- *
32
- * [Reference](https://github.com/starkware-libs/cairo-lang/blob/fc97bdd8322a7df043c87c371634b26c15ed6cee/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L25-L39)
33
- *
34
- * @param invokeTransaction transaction to be invoked
35
- * @param blockIdentifier block identifier
36
- * @returns the result of the function on the smart contract.
37
- */
38
- abstract callContract(
39
- invokeTransaction: Call,
40
- options: {
41
- blockIdentifier: BlockIdentifier;
42
- }
43
- ): Promise<CallContractResponse>;
44
- /**
45
- * Gets the block information
46
- *
47
- * [Reference](https://github.com/starkware-libs/cairo-lang/blob/fc97bdd8322a7df043c87c371634b26c15ed6cee/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L41-L53)
48
- *
49
- * @param blockIdentifier block identifier
50
- * @returns the block object { block_number, previous_block_number, state_root, status, timestamp, transaction_receipts, transactions }
51
- */
52
- abstract getBlock(blockIdentifier?: BlockIdentifier): Promise<GetBlockResponse>;
53
- /**
54
- * Gets the code of the deployed contract.
55
- *
56
- * [Reference](https://github.com/starkware-libs/cairo-lang/blob/fc97bdd8322a7df043c87c371634b26c15ed6cee/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L55-L68)
57
- *
58
- * @param contractAddress - contract address
59
- * @param blockIdentifier - block identifier
60
- * @returns Bytecode and ABI of compiled contract
61
- */
62
- abstract getCode(
63
- contractAddress: string,
64
- blockIdentifier?: BlockIdentifier
65
- ): Promise<GetCodeResponse>;
66
- /**
67
- * Gets the contract's storage variable at a specific key.
68
- *
69
- * [Reference](https://github.com/starkware-libs/cairo-lang/blob/fc97bdd8322a7df043c87c371634b26c15ed6cee/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L70-L85)
70
- *
71
- * @param contractAddress
72
- * @param key - from getStorageVarAddress('<STORAGE_VARIABLE_NAME>') (WIP)
73
- * @param blockIdentifier - block identifier
74
- * @returns the value of the storage variable
75
- */
76
- abstract getStorageAt(
77
- contractAddress: string,
78
- key: BigNumberish,
79
- blockIdentifier?: BlockIdentifier
80
- ): Promise<object>;
81
- /**
82
- * Gets the status of a transaction.
83
- *
84
- * [Reference](https://github.com/starkware-libs/cairo-lang/blob/f464ec4797361b6be8989e36e02ec690e74ef285/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L48-L52)
85
- *
86
- * @param txHash
87
- * @returns the transaction status object { block_number, tx_status: NOT_RECEIVED | RECEIVED | PENDING | REJECTED | ACCEPTED_ONCHAIN }
88
- */
89
- abstract getTransactionStatus(txHash: BigNumberish): Promise<GetTransactionStatusResponse>;
90
- /**
91
- * Gets the transaction information from a tx id.
92
- *
93
- * [Reference](https://github.com/starkware-libs/cairo-lang/blob/f464ec4797361b6be8989e36e02ec690e74ef285/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L54-L58)
94
- *
95
- * @param txHash
96
- * @returns the transacton object { transaction_id, status, transaction, block_number?, block_number?, transaction_index?, transaction_failure_reason? }
97
- */
98
- abstract getTransaction(txHash: BigNumberish): Promise<GetTransactionResponse>;
99
- /**
100
- * Gets the transaction receipt from a tx hash.
101
- *
102
- * [Reference] (https://github.com/starkware-libs/cairo-lang/blob/167b28bcd940fd25ea3816204fa882a0b0a49603/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L183)
103
- *
104
- * @param txHash
105
- * @returns the transaction receipt object
106
- */
107
- abstract getTransactionReceipt(txHash: BigNumberish): Promise<TransactionReceiptResponse>;
108
- /**
109
- * Deploys a given compiled contract (json) to starknet
110
- *
111
- * @param payload payload to be deployed containing:
112
- * - compiled contract code
113
- * - constructor calldata
114
- * - address salt
115
- * @returns a confirmation of sending a transaction on the starknet contract
116
- */
117
- abstract deployContract(payload: DeployContractPayload): Promise<AddTransactionResponse>;
118
- /**
119
- * Invokes a function on starknet
120
- * @deprecated This method wont be supported as soon as fees are mandatory
121
- *
122
- * @param invocation the invocation object containing:
123
- * - contractAddress - the address of the contract
124
- * - entrypoint - the entrypoint of the contract
125
- * - calldata - (defaults to []) the calldata
126
- * - signature - (defaults to []) the signature
127
- *
128
- * @returns response from addTransaction
129
- */
130
- abstract invokeFunction(invocation: Invocation): Promise<AddTransactionResponse>;
131
- abstract waitForTransaction(txHash: BigNumberish, retryInterval?: number): Promise<void>;
132
- /**
133
- * @deprecated use `waitForTransaction` instead
134
- */
135
- abstract waitForTransaction(txHash: BigNumberish, retryInterval?: number): Promise<void>;
6
+ abstract chainId: StarknetChainId;
7
+ /**
8
+ * Calls a function on the StarkNet contract.
9
+ *
10
+ * @param call transaction to be called
11
+ * @param blockIdentifier block identifier
12
+ * @returns the result of the function on the smart contract.
13
+ */
14
+ abstract callContract(call: Call, blockIdentifier?: BlockIdentifier): Promise<CallContractResponse>;
15
+ /**
16
+ * Gets the block information
17
+ *
18
+ * @param blockIdentifier block identifier
19
+ * @returns the block object
20
+ */
21
+ abstract getBlock(blockIdentifier: BlockIdentifier): Promise<GetBlockResponse>;
22
+ /**
23
+ * Gets the contract class of the deployed contract.
24
+ *
25
+ * @param contractAddress - contract address
26
+ * @param blockIdentifier - block identifier
27
+ * @returns Contract class of compiled contract
28
+ */
29
+ abstract getClassAt(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<ContractClass>;
30
+ /**
31
+ * Gets the contract's storage variable at a specific key.
32
+ *
33
+ * @param contractAddress
34
+ * @param key - from getStorageVarAddress('<STORAGE_VARIABLE_NAME>') (WIP)
35
+ * @param blockHashOrTag - block hash or tag (pending, latest)
36
+ * @returns the value of the storage variable
37
+ */
38
+ abstract getStorageAt(contractAddress: string, key: BigNumberish, blockHashOrTag?: BlockTag | BigNumberish): Promise<BigNumberish>;
39
+ /**
40
+ * Gets the transaction information from a tx id.
41
+ *
42
+ * @param txHash
43
+ * @returns the transacton object { transaction_id, status, transaction, block_number?, block_number?, transaction_index?, transaction_failure_reason? }
44
+ */
45
+ abstract getTransaction(transactionHash: BigNumberish): Promise<GetTransactionResponse>;
46
+ /**
47
+ * Gets the transaction receipt from a tx hash.
48
+ *
49
+ * @param txHash
50
+ * @returns the transaction receipt object
51
+ */
52
+ abstract getTransactionReceipt(transactionHash: BigNumberish): Promise<GetTransactionReceiptResponse>;
53
+ /**
54
+ * Deploys a given compiled contract (json) to starknet
55
+ *
56
+ * @param payload payload to be deployed containing:
57
+ * - compiled contract code
58
+ * - constructor calldata
59
+ * - address salt
60
+ * @returns a confirmation of sending a transaction on the starknet contract
61
+ */
62
+ abstract deployContract(payload: DeployContractPayload): Promise<DeployContractResponse>;
63
+ /**
64
+ * Declares a given compiled contract (json) to starknet
65
+ *
66
+ * @param payload payload to be deployed containing:
67
+ * - compiled contract code
68
+ * - optional version
69
+ * @returns a confirmation of sending a transaction on the starknet contract
70
+ */
71
+ abstract declareContract(payload: DeclareContractPayload): Promise<DeclareContractResponse>;
72
+ /**
73
+ * Invokes a function on starknet
74
+ * @deprecated This method wont be supported as soon as fees are mandatory
75
+ *
76
+ * @param invocation the invocation object containing:
77
+ * - contractAddress - the address of the contract
78
+ * - entrypoint - the entrypoint of the contract
79
+ * - calldata - (defaults to []) the calldata
80
+ * - signature - (defaults to []) the signature
81
+ * @param details - optional details containing:
82
+ * - nonce - optional nonce
83
+ * - version - optional version
84
+ * - maxFee - optional maxFee
85
+ * @returns response from addTransaction
86
+ */
87
+ abstract invokeFunction(invocation: Invocation, details?: InvocationsDetails): Promise<InvokeFunctionResponse>;
88
+ /**
89
+ * Estimates the fee for a given transaction
90
+ *
91
+ * @param invocation the invocation object containing:
92
+ * - contractAddress - the address of the contract
93
+ * - entrypoint - the entrypoint of the contract
94
+ * - calldata - (defaults to []) the calldata
95
+ * - signature - (defaults to []) the signature
96
+ * @param blockIdentifier - block identifier
97
+ * @param details - optional details containing:
98
+ * - nonce - optional nonce
99
+ * - version - optional version
100
+ * @returns the estimated fee
101
+ */
102
+ abstract getEstimateFee(invocation: Invocation, blockIdentifier: BlockIdentifier, details?: InvocationsDetails): Promise<EstimateFeeResponse>;
103
+ /**
104
+ * Wait for the transaction to be accepted
105
+ * @param txHash - transaction hash
106
+ * @param retryInterval - retry interval
107
+ */
108
+ abstract waitForTransaction(txHash: BigNumberish, retryInterval?: number): Promise<void>;
136
109
  }
@@ -1,8 +1,9 @@
1
- 'use strict';
2
- Object.defineProperty(exports, '__esModule', { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ProviderInterface = void 0;
4
4
  var ProviderInterface = /** @class */ (function () {
5
- function ProviderInterface() {}
6
- return ProviderInterface;
7
- })();
5
+ function ProviderInterface() {
6
+ }
7
+ return ProviderInterface;
8
+ }());
8
9
  exports.ProviderInterface = ProviderInterface;
@@ -0,0 +1,57 @@
1
+ import { StarknetChainId } from '../constants';
2
+ import { BlockTag, Call, CallContractResponse, DeclareContractPayload, DeclareContractResponse, DeployContractPayload, DeployContractResponse, EstimateFeeResponse, GetBlockResponse, GetTransactionReceiptResponse, GetTransactionResponse, Invocation, InvocationsDetails, InvokeFunctionResponse } from '../types';
3
+ import { RPC } from '../types/api';
4
+ import { BigNumberish } from '../utils/number';
5
+ import { ProviderInterface } from './interface';
6
+ import { BlockIdentifier } from './utils';
7
+ export declare type RpcProviderOptions = {
8
+ nodeUrl: string;
9
+ };
10
+ export declare class RpcProvider implements ProviderInterface {
11
+ nodeUrl: string;
12
+ chainId: StarknetChainId;
13
+ private responseParser;
14
+ constructor(optionsOrProvider: RpcProviderOptions);
15
+ protected fetchEndpoint<T extends keyof RPC.Methods>(method: T, request?: RPC.Methods[T]['REQUEST']): Promise<RPC.Methods[T]['RESPONSE']>;
16
+ getChainId(): Promise<StarknetChainId>;
17
+ getBlock(blockIdentifier?: BlockIdentifier): Promise<GetBlockResponse>;
18
+ getStorageAt(contractAddress: string, key: BigNumberish, blockHashOrTag?: BlockTag | BigNumberish): Promise<BigNumberish>;
19
+ getTransaction(txHash: BigNumberish): Promise<GetTransactionResponse>;
20
+ getTransactionReceipt(txHash: BigNumberish): Promise<GetTransactionReceiptResponse>;
21
+ getClassAt(contractAddress: string, _blockIdentifier?: BlockIdentifier): Promise<any>;
22
+ getEstimateFee(invocation: Invocation, blockIdentifier?: BlockIdentifier, invocationDetails?: InvocationsDetails): Promise<EstimateFeeResponse>;
23
+ declareContract({ contract, version, }: DeclareContractPayload): Promise<DeclareContractResponse>;
24
+ deployContract({ contract, constructorCalldata, addressSalt, }: DeployContractPayload): Promise<DeployContractResponse>;
25
+ invokeFunction(functionInvocation: Invocation, details: InvocationsDetails): Promise<InvokeFunctionResponse>;
26
+ callContract(call: Call, blockIdentifier?: BlockIdentifier): Promise<CallContractResponse>;
27
+ waitForTransaction(txHash: BigNumberish, retryInterval?: number): Promise<void>;
28
+ /**
29
+ * Gets the transaction count from a block.
30
+ *
31
+ *
32
+ * @param blockIdentifier
33
+ * @returns Number of transactions
34
+ */
35
+ getTransactionCount(blockIdentifier: BlockIdentifier): Promise<RPC.GetTransactionCountResponse>;
36
+ /**
37
+ * Gets the latest block number
38
+ *
39
+ *
40
+ * @returns Number of the latest block
41
+ */
42
+ getBlockNumber(): Promise<RPC.GetBlockNumberResponse>;
43
+ /**
44
+ * Gets syncing status of the node
45
+ *
46
+ *
47
+ * @returns Object with the stats data
48
+ */
49
+ getSyncingStats(): Promise<RPC.GetSyncingStatsResponse>;
50
+ /**
51
+ * Gets all the events filtered
52
+ *
53
+ *
54
+ * @returns events and the pagination of the events
55
+ */
56
+ getEvents(eventFilter: RPC.EventFilter): Promise<RPC.GetEventsResponse>;
57
+ }