starknet 2.5.0 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ # [2.6.0](https://github.com/seanjameshan/starknet.js/compare/v2.5.0...v2.6.0) (2021-12-29)
2
+
3
+ ### Bug Fixes
4
+
5
+ - correct network name ([66e14c9](https://github.com/seanjameshan/starknet.js/commit/66e14c926f015a2dfbd50d3e54ba4e008fb43aa8))
6
+ - network name ([965f215](https://github.com/seanjameshan/starknet.js/commit/965f21580ef68bf84c105e93bfb3b98f75b31f93))
7
+
8
+ ### Features
9
+
10
+ - introduce blockNumber ([657dac1](https://github.com/seanjameshan/starknet.js/commit/657dac1d77e840a7fc663d3a180515443a7e834f))
11
+
1
12
  # [2.5.0](https://github.com/seanjameshan/starknet.js/compare/v2.4.0...v2.5.0) (2021-12-13)
2
13
 
3
14
  ### Bug Fixes
@@ -16,7 +16,7 @@ describe('defaultProvider', () => {
16
16
  test('getBlock()', () => {
17
17
  return expect(defaultProvider.getBlock(870)).resolves.not.toThrow();
18
18
  });
19
- test('getBlock(blockId=null)', () => {
19
+ test('getBlock(blockNumber=null)', () => {
20
20
  return expect(defaultProvider.getBlock()).resolves.not.toThrow();
21
21
  });
22
22
  test('getCode()', () => {
@@ -27,7 +27,7 @@ describe('defaultProvider', () => {
27
27
  )
28
28
  ).resolves.not.toThrow();
29
29
  });
30
- test('getCode(blockId=null)', () => {
30
+ test('getCode(blockNumber=null)', () => {
31
31
  return expect(
32
32
  defaultProvider.getCode('0x163a1542a64402ffc93e39a4962eec51ce126f2e634631d3f1f6770a76e3a61')
33
33
  ).resolves.not.toThrow();
@@ -41,7 +41,7 @@ describe('defaultProvider', () => {
41
41
  )
42
42
  ).resolves.not.toThrow();
43
43
  });
44
- test('getStorageAt(blockId=null)', () => {
44
+ test('getStorageAt(blockNumber=null)', () => {
45
45
  return expect(
46
46
  defaultProvider.getStorageAt(
47
47
  '0x163a1542a64402ffc93e39a4962eec51ce126f2e634631d3f1f6770a76e3a61',
@@ -1,7 +1,7 @@
1
- import { AddTransactionResponse, CallContractResponse, CallContractTransaction, CompiledContract, GetBlockResponse, GetCodeResponse, GetContractAddressesResponse, GetTransactionResponse, GetTransactionStatusResponse, Signature, Transaction } from '../types';
1
+ import { AddTransactionResponse, BlockNumber, CallContractResponse, CallContractTransaction, CompiledContract, GetBlockResponse, GetCodeResponse, GetContractAddressesResponse, GetTransactionResponse, GetTransactionStatusResponse, Signature, Transaction } from '../types';
2
2
  import { BigNumberish } from '../utils/number';
3
3
  import { ProviderInterface } from './interface';
4
- declare type NetworkName = 'mainnet-alpha' | 'georli-alpha';
4
+ declare type NetworkName = 'mainnet-alpha' | 'goerli-alpha';
5
5
  declare type ProviderOptions = {
6
6
  network: NetworkName;
7
7
  } | {
@@ -26,29 +26,29 @@ export declare class Provider implements ProviderInterface {
26
26
  * [Reference](https://github.com/starkware-libs/cairo-lang/blob/f464ec4797361b6be8989e36e02ec690e74ef285/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L17-L25)
27
27
  *
28
28
  * @param invokeTransaction - transaction to be invoked
29
- * @param blockId
29
+ * @param blockNumber
30
30
  * @returns the result of the function on the smart contract.
31
31
  */
32
- callContract(invokeTransaction: CallContractTransaction, blockId?: number): Promise<CallContractResponse>;
32
+ callContract(invokeTransaction: CallContractTransaction, blockNumber?: BlockNumber): Promise<CallContractResponse>;
33
33
  /**
34
34
  * Gets the block information from a block ID.
35
35
  *
36
36
  * [Reference](https://github.com/starkware-libs/cairo-lang/blob/f464ec4797361b6be8989e36e02ec690e74ef285/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L27-L31)
37
37
  *
38
- * @param blockId
39
- * @returns the block object { block_id, previous_block_id, state_root, status, timestamp, transaction_receipts, transactions }
38
+ * @param blockNumber
39
+ * @returns the block object { block_number, previous_block_number, state_root, status, timestamp, transaction_receipts, transactions }
40
40
  */
41
- getBlock(blockId?: number): Promise<GetBlockResponse>;
41
+ getBlock(blockNumber?: BlockNumber): Promise<GetBlockResponse>;
42
42
  /**
43
43
  * Gets the code of the deployed contract.
44
44
  *
45
45
  * [Reference](https://github.com/starkware-libs/cairo-lang/blob/f464ec4797361b6be8989e36e02ec690e74ef285/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L33-L36)
46
46
  *
47
47
  * @param contractAddress
48
- * @param blockId
48
+ * @param blockNumber
49
49
  * @returns Bytecode and ABI of compiled contract
50
50
  */
51
- getCode(contractAddress: string, blockId?: number): Promise<GetCodeResponse>;
51
+ getCode(contractAddress: string, blockNumber?: BlockNumber): Promise<GetCodeResponse>;
52
52
  /**
53
53
  * Gets the contract's storage variable at a specific key.
54
54
  *
@@ -56,17 +56,17 @@ export declare class Provider implements ProviderInterface {
56
56
  *
57
57
  * @param contractAddress
58
58
  * @param key - from getStorageVarAddress('<STORAGE_VARIABLE_NAME>') (WIP)
59
- * @param blockId
59
+ * @param blockNumber
60
60
  * @returns the value of the storage variable
61
61
  */
62
- getStorageAt(contractAddress: string, key: number, blockId?: number): Promise<object>;
62
+ getStorageAt(contractAddress: string, key: number, blockNumber?: BlockNumber): Promise<object>;
63
63
  /**
64
64
  * Gets the status of a transaction.
65
65
  *
66
66
  * [Reference](https://github.com/starkware-libs/cairo-lang/blob/f464ec4797361b6be8989e36e02ec690e74ef285/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L48-L52)
67
67
  *
68
68
  * @param txHash
69
- * @returns the transaction status object { block_id, tx_status: NOT_RECEIVED | RECEIVED | PENDING | REJECTED | ACCEPTED_ONCHAIN }
69
+ * @returns the transaction status object { block_number, tx_status: NOT_RECEIVED | RECEIVED | PENDING | REJECTED | ACCEPTED_ONCHAIN }
70
70
  */
71
71
  getTransactionStatus(txHash: BigNumberish): Promise<GetTransactionStatusResponse>;
72
72
  /**
@@ -75,7 +75,7 @@ export declare class Provider implements ProviderInterface {
75
75
  * [Reference](https://github.com/starkware-libs/cairo-lang/blob/f464ec4797361b6be8989e36e02ec690e74ef285/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L54-L58)
76
76
  *
77
77
  * @param txHash
78
- * @returns the transacton object { transaction_id, status, transaction, block_id?, block_number?, transaction_index?, transaction_failure_reason? }
78
+ * @returns the transacton object { transaction_id, status, transaction, block_number?, block_number?, transaction_index?, transaction_failure_reason? }
79
79
  */
80
80
  getTransaction(txHash: BigNumberish): Promise<GetTransactionResponse>;
81
81
  /**
@@ -61,7 +61,7 @@ function wait(delay) {
61
61
  }
62
62
  var Provider = /** @class */ (function () {
63
63
  function Provider(optionsOrProvider) {
64
- if (optionsOrProvider === void 0) { optionsOrProvider = { network: 'georli-alpha' }; }
64
+ if (optionsOrProvider === void 0) { optionsOrProvider = { network: 'goerli-alpha' }; }
65
65
  if (optionsOrProvider instanceof Provider) {
66
66
  this.baseUrl = optionsOrProvider.baseUrl;
67
67
  this.feederGatewayUrl = optionsOrProvider.feederGatewayUrl;
@@ -80,7 +80,7 @@ var Provider = /** @class */ (function () {
80
80
  switch (name) {
81
81
  case 'mainnet-alpha':
82
82
  return 'https://alpha-mainnet.starknet.io';
83
- case 'georli-alpha':
83
+ case 'goerli-alpha':
84
84
  default:
85
85
  return 'https://alpha4.starknet.io';
86
86
  }
@@ -110,15 +110,16 @@ var Provider = /** @class */ (function () {
110
110
  * [Reference](https://github.com/starkware-libs/cairo-lang/blob/f464ec4797361b6be8989e36e02ec690e74ef285/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L17-L25)
111
111
  *
112
112
  * @param invokeTransaction - transaction to be invoked
113
- * @param blockId
113
+ * @param blockNumber
114
114
  * @returns the result of the function on the smart contract.
115
115
  */
116
- Provider.prototype.callContract = function (invokeTransaction, blockId) {
116
+ Provider.prototype.callContract = function (invokeTransaction, blockNumber) {
117
+ if (blockNumber === void 0) { blockNumber = null; }
117
118
  return __awaiter(this, void 0, void 0, function () {
118
119
  var data;
119
120
  return __generator(this, function (_a) {
120
121
  switch (_a.label) {
121
- case 0: return [4 /*yield*/, axios_1.default.post((0, url_join_1.default)(this.feederGatewayUrl, 'call_contract', "?blockId=" + (blockId !== null && blockId !== void 0 ? blockId : 'null')), __assign({ signature: [], calldata: [] }, invokeTransaction))];
122
+ case 0: return [4 /*yield*/, axios_1.default.post((0, url_join_1.default)(this.feederGatewayUrl, 'call_contract', "?blockNumber=" + blockNumber), __assign({ signature: [], calldata: [] }, invokeTransaction))];
122
123
  case 1:
123
124
  data = (_a.sent()).data;
124
125
  return [2 /*return*/, data];
@@ -131,15 +132,16 @@ var Provider = /** @class */ (function () {
131
132
  *
132
133
  * [Reference](https://github.com/starkware-libs/cairo-lang/blob/f464ec4797361b6be8989e36e02ec690e74ef285/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L27-L31)
133
134
  *
134
- * @param blockId
135
- * @returns the block object { block_id, previous_block_id, state_root, status, timestamp, transaction_receipts, transactions }
135
+ * @param blockNumber
136
+ * @returns the block object { block_number, previous_block_number, state_root, status, timestamp, transaction_receipts, transactions }
136
137
  */
137
- Provider.prototype.getBlock = function (blockId) {
138
+ Provider.prototype.getBlock = function (blockNumber) {
139
+ if (blockNumber === void 0) { blockNumber = null; }
138
140
  return __awaiter(this, void 0, void 0, function () {
139
141
  var data;
140
142
  return __generator(this, function (_a) {
141
143
  switch (_a.label) {
142
- case 0: return [4 /*yield*/, axios_1.default.get((0, url_join_1.default)(this.feederGatewayUrl, 'get_block', "?blockId=" + (blockId !== null && blockId !== void 0 ? blockId : 'null')))];
144
+ case 0: return [4 /*yield*/, axios_1.default.get((0, url_join_1.default)(this.feederGatewayUrl, 'get_block', "?blockNumber=" + blockNumber))];
143
145
  case 1:
144
146
  data = (_a.sent()).data;
145
147
  return [2 /*return*/, data];
@@ -153,15 +155,16 @@ var Provider = /** @class */ (function () {
153
155
  * [Reference](https://github.com/starkware-libs/cairo-lang/blob/f464ec4797361b6be8989e36e02ec690e74ef285/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L33-L36)
154
156
  *
155
157
  * @param contractAddress
156
- * @param blockId
158
+ * @param blockNumber
157
159
  * @returns Bytecode and ABI of compiled contract
158
160
  */
159
- Provider.prototype.getCode = function (contractAddress, blockId) {
161
+ Provider.prototype.getCode = function (contractAddress, blockNumber) {
162
+ if (blockNumber === void 0) { blockNumber = null; }
160
163
  return __awaiter(this, void 0, void 0, function () {
161
164
  var data;
162
165
  return __generator(this, function (_a) {
163
166
  switch (_a.label) {
164
- case 0: return [4 /*yield*/, axios_1.default.get((0, url_join_1.default)(this.feederGatewayUrl, 'get_code', "?contractAddress=" + contractAddress + "&blockId=" + (blockId !== null && blockId !== void 0 ? blockId : 'null')))];
167
+ case 0: return [4 /*yield*/, axios_1.default.get((0, url_join_1.default)(this.feederGatewayUrl, 'get_code', "?contractAddress=" + contractAddress + "&blockNumber=" + blockNumber))];
165
168
  case 1:
166
169
  data = (_a.sent()).data;
167
170
  return [2 /*return*/, data];
@@ -177,15 +180,16 @@ var Provider = /** @class */ (function () {
177
180
  *
178
181
  * @param contractAddress
179
182
  * @param key - from getStorageVarAddress('<STORAGE_VARIABLE_NAME>') (WIP)
180
- * @param blockId
183
+ * @param blockNumber
181
184
  * @returns the value of the storage variable
182
185
  */
183
- Provider.prototype.getStorageAt = function (contractAddress, key, blockId) {
186
+ Provider.prototype.getStorageAt = function (contractAddress, key, blockNumber) {
187
+ if (blockNumber === void 0) { blockNumber = null; }
184
188
  return __awaiter(this, void 0, void 0, function () {
185
189
  var data;
186
190
  return __generator(this, function (_a) {
187
191
  switch (_a.label) {
188
- case 0: return [4 /*yield*/, axios_1.default.get((0, url_join_1.default)(this.feederGatewayUrl, 'get_storage_at', "?contractAddress=" + contractAddress + "&key=" + key + "&blockId=" + (blockId !== null && blockId !== void 0 ? blockId : 'null')))];
192
+ case 0: return [4 /*yield*/, axios_1.default.get((0, url_join_1.default)(this.feederGatewayUrl, 'get_storage_at', "?contractAddress=" + contractAddress + "&key=" + key + "&blockNumber=" + blockNumber))];
189
193
  case 1:
190
194
  data = (_a.sent()).data;
191
195
  return [2 /*return*/, data];
@@ -199,7 +203,7 @@ var Provider = /** @class */ (function () {
199
203
  * [Reference](https://github.com/starkware-libs/cairo-lang/blob/f464ec4797361b6be8989e36e02ec690e74ef285/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L48-L52)
200
204
  *
201
205
  * @param txHash
202
- * @returns the transaction status object { block_id, tx_status: NOT_RECEIVED | RECEIVED | PENDING | REJECTED | ACCEPTED_ONCHAIN }
206
+ * @returns the transaction status object { block_number, tx_status: NOT_RECEIVED | RECEIVED | PENDING | REJECTED | ACCEPTED_ONCHAIN }
203
207
  */
204
208
  Provider.prototype.getTransactionStatus = function (txHash) {
205
209
  return __awaiter(this, void 0, void 0, function () {
@@ -222,7 +226,7 @@ var Provider = /** @class */ (function () {
222
226
  * [Reference](https://github.com/starkware-libs/cairo-lang/blob/f464ec4797361b6be8989e36e02ec690e74ef285/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L54-L58)
223
227
  *
224
228
  * @param txHash
225
- * @returns the transacton object { transaction_id, status, transaction, block_id?, block_number?, transaction_index?, transaction_failure_reason? }
229
+ * @returns the transacton object { transaction_id, status, transaction, block_number?, block_number?, transaction_index?, transaction_failure_reason? }
226
230
  */
227
231
  Provider.prototype.getTransaction = function (txHash) {
228
232
  return __awaiter(this, void 0, void 0, function () {
@@ -1,4 +1,4 @@
1
- import type { AddTransactionResponse, CallContractResponse, CallContractTransaction, CompiledContract, GetBlockResponse, GetCodeResponse, GetContractAddressesResponse, GetTransactionResponse, GetTransactionStatusResponse, Signature, Transaction } from '../types';
1
+ import type { AddTransactionResponse, BlockNumber, CallContractResponse, CallContractTransaction, CompiledContract, GetBlockResponse, GetCodeResponse, GetContractAddressesResponse, GetTransactionResponse, GetTransactionStatusResponse, Signature, Transaction } from '../types';
2
2
  import type { BigNumberish } from '../utils/number';
3
3
  export declare abstract class ProviderInterface {
4
4
  abstract baseUrl: string;
@@ -17,29 +17,29 @@ export declare abstract class ProviderInterface {
17
17
  * [Reference](https://github.com/starkware-libs/cairo-lang/blob/f464ec4797361b6be8989e36e02ec690e74ef285/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L17-L25)
18
18
  *
19
19
  * @param invokeTransaction - transaction to be invoked
20
- * @param blockId
20
+ * @param blockNumber
21
21
  * @returns the result of the function on the smart contract.
22
22
  */
23
- abstract callContract(invokeTransaction: CallContractTransaction, blockId?: number): Promise<CallContractResponse>;
23
+ abstract callContract(invokeTransaction: CallContractTransaction, blockNumber?: BlockNumber): Promise<CallContractResponse>;
24
24
  /**
25
25
  * Gets the block information from a block ID.
26
26
  *
27
27
  * [Reference](https://github.com/starkware-libs/cairo-lang/blob/f464ec4797361b6be8989e36e02ec690e74ef285/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L27-L31)
28
28
  *
29
- * @param blockId
30
- * @returns the block object { block_id, previous_block_id, state_root, status, timestamp, transaction_receipts, transactions }
29
+ * @param blockNumber
30
+ * @returns the block object { block_number, previous_block_number, state_root, status, timestamp, transaction_receipts, transactions }
31
31
  */
32
- abstract getBlock(blockId?: number): Promise<GetBlockResponse>;
32
+ abstract getBlock(blockNumber?: BlockNumber): Promise<GetBlockResponse>;
33
33
  /**
34
34
  * Gets the code of the deployed contract.
35
35
  *
36
36
  * [Reference](https://github.com/starkware-libs/cairo-lang/blob/f464ec4797361b6be8989e36e02ec690e74ef285/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L33-L36)
37
37
  *
38
38
  * @param contractAddress
39
- * @param blockId
39
+ * @param blockNumber
40
40
  * @returns Bytecode and ABI of compiled contract
41
41
  */
42
- abstract getCode(contractAddress: string, blockId?: number): Promise<GetCodeResponse>;
42
+ abstract getCode(contractAddress: string, blockNumber?: BlockNumber): Promise<GetCodeResponse>;
43
43
  /**
44
44
  * Gets the contract's storage variable at a specific key.
45
45
  *
@@ -47,17 +47,17 @@ export declare abstract class ProviderInterface {
47
47
  *
48
48
  * @param contractAddress
49
49
  * @param key - from getStorageVarAddress('<STORAGE_VARIABLE_NAME>') (WIP)
50
- * @param blockId
50
+ * @param blockNumber
51
51
  * @returns the value of the storage variable
52
52
  */
53
- abstract getStorageAt(contractAddress: string, key: number, blockId?: number): Promise<object>;
53
+ abstract getStorageAt(contractAddress: string, key: number, blockNumber?: BlockNumber): Promise<object>;
54
54
  /**
55
55
  * Gets the status of a transaction.
56
56
  *
57
57
  * [Reference](https://github.com/starkware-libs/cairo-lang/blob/f464ec4797361b6be8989e36e02ec690e74ef285/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L48-L52)
58
58
  *
59
59
  * @param txHash
60
- * @returns the transaction status object { block_id, tx_status: NOT_RECEIVED | RECEIVED | PENDING | REJECTED | ACCEPTED_ONCHAIN }
60
+ * @returns the transaction status object { block_number, tx_status: NOT_RECEIVED | RECEIVED | PENDING | REJECTED | ACCEPTED_ONCHAIN }
61
61
  */
62
62
  abstract getTransactionStatus(txHash: BigNumberish): Promise<GetTransactionStatusResponse>;
63
63
  /**
@@ -66,7 +66,7 @@ export declare abstract class ProviderInterface {
66
66
  * [Reference](https://github.com/starkware-libs/cairo-lang/blob/f464ec4797361b6be8989e36e02ec690e74ef285/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L54-L58)
67
67
  *
68
68
  * @param txHash
69
- * @returns the transacton object { transaction_id, status, transaction, block_id?, block_number?, transaction_index?, transaction_failure_reason? }
69
+ * @returns the transacton object { transaction_id, status, transaction, block_number?, block_number?, transaction_index?, transaction_failure_reason? }
70
70
  */
71
71
  abstract getTransaction(txHash: BigNumberish): Promise<GetTransactionResponse>;
72
72
  /**
package/dist/types.d.ts CHANGED
@@ -33,6 +33,7 @@ export declare type StructAbi = {
33
33
  export declare type Abi = FunctionAbi | StructAbi;
34
34
  export declare type EntryPointsByType = object;
35
35
  export declare type Program = object;
36
+ export declare type BlockNumber = 'pending' | null | number;
36
37
  export declare type CompiledContract = {
37
38
  abi: Abi[];
38
39
  entry_points_by_type: EntryPointsByType;
@@ -77,7 +78,7 @@ export declare type GetBlockResponse = {
77
78
  payload: string[];
78
79
  from_address: string;
79
80
  }[];
80
- block_number: number;
81
+ block_number: BlockNumber;
81
82
  status: Status;
82
83
  transaction_index: number;
83
84
  };
@@ -97,7 +98,7 @@ export declare type GetTransactionResponse = {
97
98
  status: Status;
98
99
  transaction: Transaction;
99
100
  block_hash: string;
100
- block_number: number;
101
+ block_number: BlockNumber;
101
102
  transaction_index: number;
102
103
  transaction_hash: string;
103
104
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "starknet",
3
- "version": "2.5.0",
3
+ "version": "2.6.0",
4
4
  "description": "JavaScript library for StarkNet",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  AddTransactionResponse,
3
+ BlockNumber,
3
4
  CallContractResponse,
4
5
  CallContractTransaction,
5
6
  CompiledContract,
@@ -13,7 +14,7 @@ import {
13
14
  } from '../types';
14
15
  import { BigNumberish } from '../utils/number';
15
16
  import { ProviderInterface } from './interface';
16
- declare type NetworkName = 'mainnet-alpha' | 'georli-alpha';
17
+ declare type NetworkName = 'mainnet-alpha' | 'goerli-alpha';
17
18
  declare type ProviderOptions =
18
19
  | {
19
20
  network: NetworkName;
@@ -42,32 +43,32 @@ export declare class Provider implements ProviderInterface {
42
43
  * [Reference](https://github.com/starkware-libs/cairo-lang/blob/f464ec4797361b6be8989e36e02ec690e74ef285/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L17-L25)
43
44
  *
44
45
  * @param invokeTransaction - transaction to be invoked
45
- * @param blockId
46
+ * @param blockNumber
46
47
  * @returns the result of the function on the smart contract.
47
48
  */
48
49
  callContract(
49
50
  invokeTransaction: CallContractTransaction,
50
- blockId?: number
51
+ blockNumber?: BlockNumber
51
52
  ): Promise<CallContractResponse>;
52
53
  /**
53
54
  * Gets the block information from a block ID.
54
55
  *
55
56
  * [Reference](https://github.com/starkware-libs/cairo-lang/blob/f464ec4797361b6be8989e36e02ec690e74ef285/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L27-L31)
56
57
  *
57
- * @param blockId
58
- * @returns the block object { block_id, previous_block_id, state_root, status, timestamp, transaction_receipts, transactions }
58
+ * @param blockNumber
59
+ * @returns the block object { block_number, previous_block_number, state_root, status, timestamp, transaction_receipts, transactions }
59
60
  */
60
- getBlock(blockId?: number): Promise<GetBlockResponse>;
61
+ getBlock(blockNumber?: BlockNumber): Promise<GetBlockResponse>;
61
62
  /**
62
63
  * Gets the code of the deployed contract.
63
64
  *
64
65
  * [Reference](https://github.com/starkware-libs/cairo-lang/blob/f464ec4797361b6be8989e36e02ec690e74ef285/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L33-L36)
65
66
  *
66
67
  * @param contractAddress
67
- * @param blockId
68
+ * @param blockNumber
68
69
  * @returns Bytecode and ABI of compiled contract
69
70
  */
70
- getCode(contractAddress: string, blockId?: number): Promise<GetCodeResponse>;
71
+ getCode(contractAddress: string, blockNumber?: BlockNumber): Promise<GetCodeResponse>;
71
72
  /**
72
73
  * Gets the contract's storage variable at a specific key.
73
74
  *
@@ -75,17 +76,17 @@ export declare class Provider implements ProviderInterface {
75
76
  *
76
77
  * @param contractAddress
77
78
  * @param key - from getStorageVarAddress('<STORAGE_VARIABLE_NAME>') (WIP)
78
- * @param blockId
79
+ * @param blockNumber
79
80
  * @returns the value of the storage variable
80
81
  */
81
- getStorageAt(contractAddress: string, key: number, blockId?: number): Promise<object>;
82
+ getStorageAt(contractAddress: string, key: number, blockNumber?: BlockNumber): Promise<object>;
82
83
  /**
83
84
  * Gets the status of a transaction.
84
85
  *
85
86
  * [Reference](https://github.com/starkware-libs/cairo-lang/blob/f464ec4797361b6be8989e36e02ec690e74ef285/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L48-L52)
86
87
  *
87
88
  * @param txHash
88
- * @returns the transaction status object { block_id, tx_status: NOT_RECEIVED | RECEIVED | PENDING | REJECTED | ACCEPTED_ONCHAIN }
89
+ * @returns the transaction status object { block_number, tx_status: NOT_RECEIVED | RECEIVED | PENDING | REJECTED | ACCEPTED_ONCHAIN }
89
90
  */
90
91
  getTransactionStatus(txHash: BigNumberish): Promise<GetTransactionStatusResponse>;
91
92
  /**
@@ -94,7 +95,7 @@ export declare class Provider implements ProviderInterface {
94
95
  * [Reference](https://github.com/starkware-libs/cairo-lang/blob/f464ec4797361b6be8989e36e02ec690e74ef285/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L54-L58)
95
96
  *
96
97
  * @param txHash
97
- * @returns the transacton object { transaction_id, status, transaction, block_id?, block_number?, transaction_index?, transaction_failure_reason? }
98
+ * @returns the transacton object { transaction_id, status, transaction, block_number?, block_number?, transaction_index?, transaction_failure_reason? }
98
99
  */
99
100
  getTransaction(txHash: BigNumberish): Promise<GetTransactionResponse>;
100
101
  /**
@@ -164,7 +164,7 @@ function wait(delay) {
164
164
  var Provider = /** @class */ (function () {
165
165
  function Provider(optionsOrProvider) {
166
166
  if (optionsOrProvider === void 0) {
167
- optionsOrProvider = { network: 'georli-alpha' };
167
+ optionsOrProvider = { network: 'goerli-alpha' };
168
168
  }
169
169
  if (optionsOrProvider instanceof Provider) {
170
170
  this.baseUrl = optionsOrProvider.baseUrl;
@@ -184,7 +184,7 @@ var Provider = /** @class */ (function () {
184
184
  switch (name) {
185
185
  case 'mainnet-alpha':
186
186
  return 'https://alpha-mainnet.starknet.io';
187
- case 'georli-alpha':
187
+ case 'goerli-alpha':
188
188
  default:
189
189
  return 'https://alpha4.starknet.io';
190
190
  }
@@ -220,10 +220,13 @@ var Provider = /** @class */ (function () {
220
220
  * [Reference](https://github.com/starkware-libs/cairo-lang/blob/f464ec4797361b6be8989e36e02ec690e74ef285/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L17-L25)
221
221
  *
222
222
  * @param invokeTransaction - transaction to be invoked
223
- * @param blockId
223
+ * @param blockNumber
224
224
  * @returns the result of the function on the smart contract.
225
225
  */
226
- Provider.prototype.callContract = function (invokeTransaction, blockId) {
226
+ Provider.prototype.callContract = function (invokeTransaction, blockNumber) {
227
+ if (blockNumber === void 0) {
228
+ blockNumber = null;
229
+ }
227
230
  return __awaiter(this, void 0, void 0, function () {
228
231
  var data;
229
232
  return __generator(this, function (_a) {
@@ -235,7 +238,7 @@ var Provider = /** @class */ (function () {
235
238
  (0, url_join_1.default)(
236
239
  this.feederGatewayUrl,
237
240
  'call_contract',
238
- '?blockId=' + (blockId !== null && blockId !== void 0 ? blockId : 'null')
241
+ '?blockNumber=' + blockNumber
239
242
  ),
240
243
  __assign({ signature: [], calldata: [] }, invokeTransaction)
241
244
  ),
@@ -252,10 +255,13 @@ var Provider = /** @class */ (function () {
252
255
  *
253
256
  * [Reference](https://github.com/starkware-libs/cairo-lang/blob/f464ec4797361b6be8989e36e02ec690e74ef285/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L27-L31)
254
257
  *
255
- * @param blockId
256
- * @returns the block object { block_id, previous_block_id, state_root, status, timestamp, transaction_receipts, transactions }
258
+ * @param blockNumber
259
+ * @returns the block object { block_number, previous_block_number, state_root, status, timestamp, transaction_receipts, transactions }
257
260
  */
258
- Provider.prototype.getBlock = function (blockId) {
261
+ Provider.prototype.getBlock = function (blockNumber) {
262
+ if (blockNumber === void 0) {
263
+ blockNumber = null;
264
+ }
259
265
  return __awaiter(this, void 0, void 0, function () {
260
266
  var data;
261
267
  return __generator(this, function (_a) {
@@ -267,7 +273,7 @@ var Provider = /** @class */ (function () {
267
273
  (0, url_join_1.default)(
268
274
  this.feederGatewayUrl,
269
275
  'get_block',
270
- '?blockId=' + (blockId !== null && blockId !== void 0 ? blockId : 'null')
276
+ '?blockNumber=' + blockNumber
271
277
  )
272
278
  ),
273
279
  ];
@@ -284,10 +290,13 @@ var Provider = /** @class */ (function () {
284
290
  * [Reference](https://github.com/starkware-libs/cairo-lang/blob/f464ec4797361b6be8989e36e02ec690e74ef285/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L33-L36)
285
291
  *
286
292
  * @param contractAddress
287
- * @param blockId
293
+ * @param blockNumber
288
294
  * @returns Bytecode and ABI of compiled contract
289
295
  */
290
- Provider.prototype.getCode = function (contractAddress, blockId) {
296
+ Provider.prototype.getCode = function (contractAddress, blockNumber) {
297
+ if (blockNumber === void 0) {
298
+ blockNumber = null;
299
+ }
291
300
  return __awaiter(this, void 0, void 0, function () {
292
301
  var data;
293
302
  return __generator(this, function (_a) {
@@ -299,10 +308,7 @@ var Provider = /** @class */ (function () {
299
308
  (0, url_join_1.default)(
300
309
  this.feederGatewayUrl,
301
310
  'get_code',
302
- '?contractAddress=' +
303
- contractAddress +
304
- '&blockId=' +
305
- (blockId !== null && blockId !== void 0 ? blockId : 'null')
311
+ '?contractAddress=' + contractAddress + '&blockNumber=' + blockNumber
306
312
  )
307
313
  ),
308
314
  ];
@@ -321,10 +327,13 @@ var Provider = /** @class */ (function () {
321
327
  *
322
328
  * @param contractAddress
323
329
  * @param key - from getStorageVarAddress('<STORAGE_VARIABLE_NAME>') (WIP)
324
- * @param blockId
330
+ * @param blockNumber
325
331
  * @returns the value of the storage variable
326
332
  */
327
- Provider.prototype.getStorageAt = function (contractAddress, key, blockId) {
333
+ Provider.prototype.getStorageAt = function (contractAddress, key, blockNumber) {
334
+ if (blockNumber === void 0) {
335
+ blockNumber = null;
336
+ }
328
337
  return __awaiter(this, void 0, void 0, function () {
329
338
  var data;
330
339
  return __generator(this, function (_a) {
@@ -340,8 +349,8 @@ var Provider = /** @class */ (function () {
340
349
  contractAddress +
341
350
  '&key=' +
342
351
  key +
343
- '&blockId=' +
344
- (blockId !== null && blockId !== void 0 ? blockId : 'null')
352
+ '&blockNumber=' +
353
+ blockNumber
345
354
  )
346
355
  ),
347
356
  ];
@@ -358,7 +367,7 @@ var Provider = /** @class */ (function () {
358
367
  * [Reference](https://github.com/starkware-libs/cairo-lang/blob/f464ec4797361b6be8989e36e02ec690e74ef285/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L48-L52)
359
368
  *
360
369
  * @param txHash
361
- * @returns the transaction status object { block_id, tx_status: NOT_RECEIVED | RECEIVED | PENDING | REJECTED | ACCEPTED_ONCHAIN }
370
+ * @returns the transaction status object { block_number, tx_status: NOT_RECEIVED | RECEIVED | PENDING | REJECTED | ACCEPTED_ONCHAIN }
362
371
  */
363
372
  Provider.prototype.getTransactionStatus = function (txHash) {
364
373
  return __awaiter(this, void 0, void 0, function () {
@@ -390,7 +399,7 @@ var Provider = /** @class */ (function () {
390
399
  * [Reference](https://github.com/starkware-libs/cairo-lang/blob/f464ec4797361b6be8989e36e02ec690e74ef285/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L54-L58)
391
400
  *
392
401
  * @param txHash
393
- * @returns the transacton object { transaction_id, status, transaction, block_id?, block_number?, transaction_index?, transaction_failure_reason? }
402
+ * @returns the transacton object { transaction_id, status, transaction, block_number?, block_number?, transaction_index?, transaction_failure_reason? }
394
403
  */
395
404
  Provider.prototype.getTransaction = function (txHash) {
396
405
  return __awaiter(this, void 0, void 0, function () {
@@ -1,5 +1,6 @@
1
1
  import type {
2
2
  AddTransactionResponse,
3
+ BlockNumber,
3
4
  CallContractResponse,
4
5
  CallContractTransaction,
5
6
  CompiledContract,
@@ -29,32 +30,32 @@ export declare abstract class ProviderInterface {
29
30
  * [Reference](https://github.com/starkware-libs/cairo-lang/blob/f464ec4797361b6be8989e36e02ec690e74ef285/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L17-L25)
30
31
  *
31
32
  * @param invokeTransaction - transaction to be invoked
32
- * @param blockId
33
+ * @param blockNumber
33
34
  * @returns the result of the function on the smart contract.
34
35
  */
35
36
  abstract callContract(
36
37
  invokeTransaction: CallContractTransaction,
37
- blockId?: number
38
+ blockNumber?: BlockNumber
38
39
  ): Promise<CallContractResponse>;
39
40
  /**
40
41
  * Gets the block information from a block ID.
41
42
  *
42
43
  * [Reference](https://github.com/starkware-libs/cairo-lang/blob/f464ec4797361b6be8989e36e02ec690e74ef285/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L27-L31)
43
44
  *
44
- * @param blockId
45
- * @returns the block object { block_id, previous_block_id, state_root, status, timestamp, transaction_receipts, transactions }
45
+ * @param blockNumber
46
+ * @returns the block object { block_number, previous_block_number, state_root, status, timestamp, transaction_receipts, transactions }
46
47
  */
47
- abstract getBlock(blockId?: number): Promise<GetBlockResponse>;
48
+ abstract getBlock(blockNumber?: BlockNumber): Promise<GetBlockResponse>;
48
49
  /**
49
50
  * Gets the code of the deployed contract.
50
51
  *
51
52
  * [Reference](https://github.com/starkware-libs/cairo-lang/blob/f464ec4797361b6be8989e36e02ec690e74ef285/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L33-L36)
52
53
  *
53
54
  * @param contractAddress
54
- * @param blockId
55
+ * @param blockNumber
55
56
  * @returns Bytecode and ABI of compiled contract
56
57
  */
57
- abstract getCode(contractAddress: string, blockId?: number): Promise<GetCodeResponse>;
58
+ abstract getCode(contractAddress: string, blockNumber?: BlockNumber): Promise<GetCodeResponse>;
58
59
  /**
59
60
  * Gets the contract's storage variable at a specific key.
60
61
  *
@@ -62,17 +63,21 @@ export declare abstract class ProviderInterface {
62
63
  *
63
64
  * @param contractAddress
64
65
  * @param key - from getStorageVarAddress('<STORAGE_VARIABLE_NAME>') (WIP)
65
- * @param blockId
66
+ * @param blockNumber
66
67
  * @returns the value of the storage variable
67
68
  */
68
- abstract getStorageAt(contractAddress: string, key: number, blockId?: number): Promise<object>;
69
+ abstract getStorageAt(
70
+ contractAddress: string,
71
+ key: number,
72
+ blockNumber?: BlockNumber
73
+ ): Promise<object>;
69
74
  /**
70
75
  * Gets the status of a transaction.
71
76
  *
72
77
  * [Reference](https://github.com/starkware-libs/cairo-lang/blob/f464ec4797361b6be8989e36e02ec690e74ef285/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L48-L52)
73
78
  *
74
79
  * @param txHash
75
- * @returns the transaction status object { block_id, tx_status: NOT_RECEIVED | RECEIVED | PENDING | REJECTED | ACCEPTED_ONCHAIN }
80
+ * @returns the transaction status object { block_number, tx_status: NOT_RECEIVED | RECEIVED | PENDING | REJECTED | ACCEPTED_ONCHAIN }
76
81
  */
77
82
  abstract getTransactionStatus(txHash: BigNumberish): Promise<GetTransactionStatusResponse>;
78
83
  /**
@@ -81,7 +86,7 @@ export declare abstract class ProviderInterface {
81
86
  * [Reference](https://github.com/starkware-libs/cairo-lang/blob/f464ec4797361b6be8989e36e02ec690e74ef285/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L54-L58)
82
87
  *
83
88
  * @param txHash
84
- * @returns the transacton object { transaction_id, status, transaction, block_id?, block_number?, transaction_index?, transaction_failure_reason? }
89
+ * @returns the transacton object { transaction_id, status, transaction, block_number?, block_number?, transaction_index?, transaction_failure_reason? }
85
90
  */
86
91
  abstract getTransaction(txHash: BigNumberish): Promise<GetTransactionResponse>;
87
92
  /**
@@ -3,6 +3,7 @@ import urljoin from 'url-join';
3
3
 
4
4
  import {
5
5
  AddTransactionResponse,
6
+ BlockNumber,
6
7
  CallContractResponse,
7
8
  CallContractTransaction,
8
9
  CompiledContract,
@@ -19,7 +20,7 @@ import { BigNumberish, toBN, toHex } from '../utils/number';
19
20
  import { compressProgram, formatSignature, randomAddress } from '../utils/stark';
20
21
  import { ProviderInterface } from './interface';
21
22
 
22
- type NetworkName = 'mainnet-alpha' | 'georli-alpha';
23
+ type NetworkName = 'mainnet-alpha' | 'goerli-alpha';
23
24
 
24
25
  type ProviderOptions =
25
26
  | {
@@ -40,7 +41,7 @@ export class Provider implements ProviderInterface {
40
41
 
41
42
  public gatewayUrl: string;
42
43
 
43
- constructor(optionsOrProvider: ProviderOptions | Provider = { network: 'georli-alpha' }) {
44
+ constructor(optionsOrProvider: ProviderOptions | Provider = { network: 'goerli-alpha' }) {
44
45
  if (optionsOrProvider instanceof Provider) {
45
46
  this.baseUrl = optionsOrProvider.baseUrl;
46
47
  this.feederGatewayUrl = optionsOrProvider.feederGatewayUrl;
@@ -60,7 +61,7 @@ export class Provider implements ProviderInterface {
60
61
  switch (name) {
61
62
  case 'mainnet-alpha':
62
63
  return 'https://alpha-mainnet.starknet.io';
63
- case 'georli-alpha':
64
+ case 'goerli-alpha':
64
65
  default:
65
66
  return 'https://alpha4.starknet.io';
66
67
  }
@@ -85,15 +86,15 @@ export class Provider implements ProviderInterface {
85
86
  * [Reference](https://github.com/starkware-libs/cairo-lang/blob/f464ec4797361b6be8989e36e02ec690e74ef285/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L17-L25)
86
87
  *
87
88
  * @param invokeTransaction - transaction to be invoked
88
- * @param blockId
89
+ * @param blockNumber
89
90
  * @returns the result of the function on the smart contract.
90
91
  */
91
92
  public async callContract(
92
93
  invokeTransaction: CallContractTransaction,
93
- blockId?: number
94
+ blockNumber: BlockNumber = null
94
95
  ): Promise<CallContractResponse> {
95
96
  const { data } = await axios.post<CallContractResponse>(
96
- urljoin(this.feederGatewayUrl, 'call_contract', `?blockId=${blockId ?? 'null'}`),
97
+ urljoin(this.feederGatewayUrl, 'call_contract', `?blockNumber=${blockNumber}`),
97
98
  {
98
99
  signature: [],
99
100
  calldata: [],
@@ -108,12 +109,12 @@ export class Provider implements ProviderInterface {
108
109
  *
109
110
  * [Reference](https://github.com/starkware-libs/cairo-lang/blob/f464ec4797361b6be8989e36e02ec690e74ef285/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L27-L31)
110
111
  *
111
- * @param blockId
112
- * @returns the block object { block_id, previous_block_id, state_root, status, timestamp, transaction_receipts, transactions }
112
+ * @param blockNumber
113
+ * @returns the block object { block_number, previous_block_number, state_root, status, timestamp, transaction_receipts, transactions }
113
114
  */
114
- public async getBlock(blockId?: number): Promise<GetBlockResponse> {
115
+ public async getBlock(blockNumber: BlockNumber = null): Promise<GetBlockResponse> {
115
116
  const { data } = await axios.get<GetBlockResponse>(
116
- urljoin(this.feederGatewayUrl, 'get_block', `?blockId=${blockId ?? 'null'}`)
117
+ urljoin(this.feederGatewayUrl, 'get_block', `?blockNumber=${blockNumber}`)
117
118
  );
118
119
  return data;
119
120
  }
@@ -124,15 +125,18 @@ export class Provider implements ProviderInterface {
124
125
  * [Reference](https://github.com/starkware-libs/cairo-lang/blob/f464ec4797361b6be8989e36e02ec690e74ef285/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L33-L36)
125
126
  *
126
127
  * @param contractAddress
127
- * @param blockId
128
+ * @param blockNumber
128
129
  * @returns Bytecode and ABI of compiled contract
129
130
  */
130
- public async getCode(contractAddress: string, blockId?: number): Promise<GetCodeResponse> {
131
+ public async getCode(
132
+ contractAddress: string,
133
+ blockNumber: BlockNumber = null
134
+ ): Promise<GetCodeResponse> {
131
135
  const { data } = await axios.get<GetCodeResponse>(
132
136
  urljoin(
133
137
  this.feederGatewayUrl,
134
138
  'get_code',
135
- `?contractAddress=${contractAddress}&blockId=${blockId ?? 'null'}`
139
+ `?contractAddress=${contractAddress}&blockNumber=${blockNumber}`
136
140
  )
137
141
  );
138
142
  return data;
@@ -146,19 +150,19 @@ export class Provider implements ProviderInterface {
146
150
  *
147
151
  * @param contractAddress
148
152
  * @param key - from getStorageVarAddress('<STORAGE_VARIABLE_NAME>') (WIP)
149
- * @param blockId
153
+ * @param blockNumber
150
154
  * @returns the value of the storage variable
151
155
  */
152
156
  public async getStorageAt(
153
157
  contractAddress: string,
154
158
  key: number,
155
- blockId?: number
159
+ blockNumber: BlockNumber = null
156
160
  ): Promise<object> {
157
161
  const { data } = await axios.get<object>(
158
162
  urljoin(
159
163
  this.feederGatewayUrl,
160
164
  'get_storage_at',
161
- `?contractAddress=${contractAddress}&key=${key}&blockId=${blockId ?? 'null'}`
165
+ `?contractAddress=${contractAddress}&key=${key}&blockNumber=${blockNumber}`
162
166
  )
163
167
  );
164
168
  return data;
@@ -170,7 +174,7 @@ export class Provider implements ProviderInterface {
170
174
  * [Reference](https://github.com/starkware-libs/cairo-lang/blob/f464ec4797361b6be8989e36e02ec690e74ef285/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L48-L52)
171
175
  *
172
176
  * @param txHash
173
- * @returns the transaction status object { block_id, tx_status: NOT_RECEIVED | RECEIVED | PENDING | REJECTED | ACCEPTED_ONCHAIN }
177
+ * @returns the transaction status object { block_number, tx_status: NOT_RECEIVED | RECEIVED | PENDING | REJECTED | ACCEPTED_ONCHAIN }
174
178
  */
175
179
  public async getTransactionStatus(txHash: BigNumberish): Promise<GetTransactionStatusResponse> {
176
180
  const txHashBn = toBN(txHash);
@@ -190,7 +194,7 @@ export class Provider implements ProviderInterface {
190
194
  * [Reference](https://github.com/starkware-libs/cairo-lang/blob/f464ec4797361b6be8989e36e02ec690e74ef285/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L54-L58)
191
195
  *
192
196
  * @param txHash
193
- * @returns the transacton object { transaction_id, status, transaction, block_id?, block_number?, transaction_index?, transaction_failure_reason? }
197
+ * @returns the transacton object { transaction_id, status, transaction, block_number?, block_number?, transaction_index?, transaction_failure_reason? }
194
198
  */
195
199
  public async getTransaction(txHash: BigNumberish): Promise<GetTransactionResponse> {
196
200
  const txHashBn = toBN(txHash);
@@ -1,5 +1,6 @@
1
1
  import type {
2
2
  AddTransactionResponse,
3
+ BlockNumber,
3
4
  CallContractResponse,
4
5
  CallContractTransaction,
5
6
  CompiledContract,
@@ -34,12 +35,12 @@ export abstract class ProviderInterface {
34
35
  * [Reference](https://github.com/starkware-libs/cairo-lang/blob/f464ec4797361b6be8989e36e02ec690e74ef285/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L17-L25)
35
36
  *
36
37
  * @param invokeTransaction - transaction to be invoked
37
- * @param blockId
38
+ * @param blockNumber
38
39
  * @returns the result of the function on the smart contract.
39
40
  */
40
41
  public abstract callContract(
41
42
  invokeTransaction: CallContractTransaction,
42
- blockId?: number
43
+ blockNumber?: BlockNumber
43
44
  ): Promise<CallContractResponse>;
44
45
 
45
46
  /**
@@ -47,10 +48,10 @@ export abstract class ProviderInterface {
47
48
  *
48
49
  * [Reference](https://github.com/starkware-libs/cairo-lang/blob/f464ec4797361b6be8989e36e02ec690e74ef285/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L27-L31)
49
50
  *
50
- * @param blockId
51
- * @returns the block object { block_id, previous_block_id, state_root, status, timestamp, transaction_receipts, transactions }
51
+ * @param blockNumber
52
+ * @returns the block object { block_number, previous_block_number, state_root, status, timestamp, transaction_receipts, transactions }
52
53
  */
53
- public abstract getBlock(blockId?: number): Promise<GetBlockResponse>;
54
+ public abstract getBlock(blockNumber?: BlockNumber): Promise<GetBlockResponse>;
54
55
 
55
56
  /**
56
57
  * Gets the code of the deployed contract.
@@ -58,10 +59,13 @@ export abstract class ProviderInterface {
58
59
  * [Reference](https://github.com/starkware-libs/cairo-lang/blob/f464ec4797361b6be8989e36e02ec690e74ef285/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L33-L36)
59
60
  *
60
61
  * @param contractAddress
61
- * @param blockId
62
+ * @param blockNumber
62
63
  * @returns Bytecode and ABI of compiled contract
63
64
  */
64
- public abstract getCode(contractAddress: string, blockId?: number): Promise<GetCodeResponse>;
65
+ public abstract getCode(
66
+ contractAddress: string,
67
+ blockNumber?: BlockNumber
68
+ ): Promise<GetCodeResponse>;
65
69
 
66
70
  // TODO: add proper type
67
71
  /**
@@ -71,13 +75,13 @@ export abstract class ProviderInterface {
71
75
  *
72
76
  * @param contractAddress
73
77
  * @param key - from getStorageVarAddress('<STORAGE_VARIABLE_NAME>') (WIP)
74
- * @param blockId
78
+ * @param blockNumber
75
79
  * @returns the value of the storage variable
76
80
  */
77
81
  public abstract getStorageAt(
78
82
  contractAddress: string,
79
83
  key: number,
80
- blockId?: number
84
+ blockNumber?: BlockNumber
81
85
  ): Promise<object>;
82
86
 
83
87
  /**
@@ -86,7 +90,7 @@ export abstract class ProviderInterface {
86
90
  * [Reference](https://github.com/starkware-libs/cairo-lang/blob/f464ec4797361b6be8989e36e02ec690e74ef285/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L48-L52)
87
91
  *
88
92
  * @param txHash
89
- * @returns the transaction status object { block_id, tx_status: NOT_RECEIVED | RECEIVED | PENDING | REJECTED | ACCEPTED_ONCHAIN }
93
+ * @returns the transaction status object { block_number, tx_status: NOT_RECEIVED | RECEIVED | PENDING | REJECTED | ACCEPTED_ONCHAIN }
90
94
  */
91
95
  public abstract getTransactionStatus(txHash: BigNumberish): Promise<GetTransactionStatusResponse>;
92
96
 
@@ -96,7 +100,7 @@ export abstract class ProviderInterface {
96
100
  * [Reference](https://github.com/starkware-libs/cairo-lang/blob/f464ec4797361b6be8989e36e02ec690e74ef285/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L54-L58)
97
101
  *
98
102
  * @param txHash
99
- * @returns the transacton object { transaction_id, status, transaction, block_id?, block_number?, transaction_index?, transaction_failure_reason? }
103
+ * @returns the transacton object { transaction_id, status, transaction, block_number?, block_number?, transaction_index?, transaction_failure_reason? }
100
104
  */
101
105
  public abstract getTransaction(txHash: BigNumberish): Promise<GetTransactionResponse>;
102
106
 
package/src/types.ts CHANGED
@@ -43,6 +43,7 @@ export type Abi = FunctionAbi | StructAbi;
43
43
 
44
44
  export type EntryPointsByType = object;
45
45
  export type Program = object;
46
+ export type BlockNumber = 'pending' | null | number;
46
47
 
47
48
  export type CompiledContract = {
48
49
  abi: Abi[];
@@ -95,7 +96,7 @@ export type GetBlockResponse = {
95
96
  payload: string[];
96
97
  from_address: string;
97
98
  }[];
98
- block_number: number;
99
+ block_number: BlockNumber;
99
100
  status: Status;
100
101
  transaction_index: number;
101
102
  };
@@ -118,7 +119,7 @@ export type GetTransactionResponse = {
118
119
  status: Status;
119
120
  transaction: Transaction;
120
121
  block_hash: string;
121
- block_number: number;
122
+ block_number: BlockNumber;
122
123
  transaction_index: number;
123
124
  transaction_hash: string;
124
125
  };
package/types.d.ts CHANGED
@@ -40,6 +40,7 @@ export declare type StructAbi = {
40
40
  export declare type Abi = FunctionAbi | StructAbi;
41
41
  export declare type EntryPointsByType = object;
42
42
  export declare type Program = object;
43
+ export declare type BlockNumber = 'pending' | null | number;
43
44
  export declare type CompiledContract = {
44
45
  abi: Abi[];
45
46
  entry_points_by_type: EntryPointsByType;
@@ -84,7 +85,7 @@ export declare type GetBlockResponse = {
84
85
  payload: string[];
85
86
  from_address: string;
86
87
  }[];
87
- block_number: number;
88
+ block_number: BlockNumber;
88
89
  status: Status;
89
90
  transaction_index: number;
90
91
  };
@@ -104,7 +105,7 @@ export declare type GetTransactionResponse = {
104
105
  status: Status;
105
106
  transaction: Transaction;
106
107
  block_hash: string;
107
- block_number: number;
108
+ block_number: BlockNumber;
108
109
  transaction_index: number;
109
110
  transaction_hash: string;
110
111
  };