starknet 4.5.0 → 4.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.
@@ -1,110 +1,68 @@
1
- import { StarknetChainId } from '../../constants';
2
- import { BlockIdentifier } from '../../provider/utils';
3
- import { Status } from '../lib';
4
- import { OPENRPC } from './openrpc';
1
+ import { ADDRESS, FELT, OPENRPC } from './openrpc';
5
2
  export declare namespace RPC {
6
- export type Response = {
3
+ type Response = {
7
4
  id: number;
8
- result: any;
9
5
  jsonrpc: string;
6
+ result?: any;
10
7
  error?: {
11
8
  code: string;
12
9
  message: string;
13
10
  };
14
11
  };
15
- export type AddTransactionResponse = {
16
- transaction_hash: string;
17
- };
18
- export type GetClassResponse = {
19
- program: string;
20
- entry_point_by_type: any;
21
- };
22
- export type DeclareResponse = {
23
- transaction_hash: string;
24
- class_hash: string;
25
- };
26
- export type EstimateFeeResponse = {
27
- overall_fee: number;
28
- gas_consumed: number;
29
- gas_price: number;
30
- };
31
- export type GetBlockWithTxHashesResponse = OPENRPC.GetBlockWithTxHashesResponse;
32
- export type GetBlockWithTxs = OPENRPC.GetBlockWithTxs;
33
- export type GetStorageAtResponse = OPENRPC.GetStorageAtResponse;
34
- export type GetTransactionReceiptResponse = {
35
- txn_hash: string;
36
- actual_fee: string;
37
- status: Status;
38
- status_data: string;
39
- messages_sent: Array<MessageToL1>;
40
- l1_origin_message: MessageToL2;
41
- events: Array<StarknetEvent>;
42
- };
43
- interface CommonTransactionProperties {
44
- txn_hash: string;
45
- max_fee: string;
46
- version: string;
47
- nonce: string;
48
- signature: Array<string>;
49
- }
50
- export interface InvokeTransactionResponse extends CommonTransactionProperties {
51
- contract_address?: string;
52
- entry_point_selector?: string;
53
- calldata?: Array<string>;
54
- }
55
- export interface DeclareTransactionResponse extends CommonTransactionProperties {
56
- contract_class?: GetClassResponse;
57
- sender_address?: string;
58
- }
59
- export type GetTransactionByHashResponse = OPENRPC.GetTransactionByHashResponse;
60
- export type GetTransactionByBlockIdAndIndex = OPENRPC.GetTransactionByBlockIdAndIndex;
61
- export type GetTransactionCountResponse = number;
62
- export type GetBlockNumberResponse = number;
63
- export type GetSyncingStatsResponse = {
64
- starting_block_hash: string;
65
- starting_block_num: string;
66
- current_block_hash: string;
67
- current_block_num: string;
68
- highest_block_hash: string;
69
- highest_block_num: string;
70
- } | boolean;
71
- export type EventFilter = {
72
- fromBlock: BlockIdentifier;
73
- toBlock: BlockIdentifier;
74
- address: string;
75
- keys: string[];
76
- page_size: number;
77
- page_number: number;
78
- };
79
- export type GetEventsResponse = {
80
- events: StarknetEmittedEvent[];
81
- page_number: number;
82
- is_last_page: number;
83
- };
84
- export type DeployContractResponse = {
85
- transaction_hash: string;
86
- contract_address: string;
87
- };
88
- export type StarknetEvent = {
89
- from_address: string;
90
- keys: string[];
91
- data: string[];
92
- };
93
- export type StarknetEmittedEvent = {
94
- event: StarknetEvent;
95
- block_hash: string;
96
- block_number: number;
97
- transaction_hash: string;
98
- };
99
- export type MessageToL1 = {
100
- to_address: string;
101
- payload: string[];
102
- };
103
- export type MessageToL2 = {
104
- from_address: string;
105
- payload: string[];
106
- };
107
- export type Methods = {
12
+ type ChainId = OPENRPC.ChainId;
13
+ type ContractAddress = ADDRESS;
14
+ type Felt = FELT;
15
+ type ContractClass = OPENRPC.ContractClass;
16
+ type StateUpdate = OPENRPC.StateUpdate;
17
+ type Transaction = OPENRPC.Transaction;
18
+ type PendingTransactions = OPENRPC.PendingTransactions;
19
+ type TransactionHash = OPENRPC.TransactionHash;
20
+ type Trace = OPENRPC.Trace;
21
+ type Traces = OPENRPC.Traces;
22
+ type BlockHash = OPENRPC.BlockHash;
23
+ type BlockHashAndNumber = OPENRPC.BlockHashAndNumber;
24
+ type GetClassResponse = OPENRPC.ContractClass;
25
+ type EstimateFeeResponse = OPENRPC.EstimatedFee;
26
+ type GetBlockWithTxHashesResponse = OPENRPC.BlockWithTxHashes;
27
+ type GetBlockWithTxs = OPENRPC.BlockWithTxs;
28
+ type GetStorageAtResponse = OPENRPC.Storage;
29
+ type TransactionReceipt = OPENRPC.TransactionReceipt;
30
+ type GetTransactionByHashResponse = OPENRPC.Transaction;
31
+ type GetTransactionByBlockIdAndIndex = OPENRPC.Transaction;
32
+ type GetTransactionCountResponse = number;
33
+ type GetBlockNumberResponse = OPENRPC.BlockNumber;
34
+ type GetSyncingStatsResponse = OPENRPC.SyncingStatus;
35
+ type EventFilter = OPENRPC.EventFilter;
36
+ type GetEventsResponse = OPENRPC.Events;
37
+ type InvokedTransaction = OPENRPC.InvokedTransaction;
38
+ type DeclaredTransaction = OPENRPC.DeclaredTransaction;
39
+ type DeployedTransaction = OPENRPC.DeployedTransaction;
40
+ type Methods = {
41
+ starknet_pendingTransactions: {
42
+ QUERY: never;
43
+ REQUEST: any[];
44
+ RESPONSE: PendingTransactions;
45
+ };
46
+ starknet_blockHashAndNumber: {
47
+ QUERY: never;
48
+ REQUEST: any[];
49
+ RESPONSE: BlockHashAndNumber;
50
+ };
51
+ starknet_getClassHashAt: {
52
+ QUERY: never;
53
+ REQUEST: any[];
54
+ RESPONSE: Felt;
55
+ };
56
+ starknet_getStateUpdate: {
57
+ QUERY: never;
58
+ REQUEST: any[];
59
+ RESPONSE: OPENRPC.StateUpdate;
60
+ };
61
+ starknet_getClass: {
62
+ QUERY: never;
63
+ REQUEST: any[];
64
+ RESPONSE: OPENRPC.ContractClass;
65
+ };
108
66
  starknet_getBlockWithTxHashes: {
109
67
  QUERY: never;
110
68
  REQUEST: any[];
@@ -118,7 +76,7 @@ export declare namespace RPC {
118
76
  starknet_getNonce: {
119
77
  QUERY: never;
120
78
  REQUEST: any[];
121
- RESPONSE: string;
79
+ RESPONSE: OPENRPC.Nonce;
122
80
  };
123
81
  starknet_getStorageAt: {
124
82
  QUERY: never;
@@ -138,7 +96,7 @@ export declare namespace RPC {
138
96
  starknet_getTransactionReceipt: {
139
97
  QUERY: never;
140
98
  REQUEST: any[];
141
- RESPONSE: GetTransactionReceiptResponse;
99
+ RESPONSE: TransactionReceipt;
142
100
  };
143
101
  starknet_getBlockTransactionCount: {
144
102
  QUERY: never;
@@ -153,7 +111,7 @@ export declare namespace RPC {
153
111
  starknet_estimateFee: {
154
112
  QUERY: never;
155
113
  REQUEST: any[];
156
- RESPONSE: EstimateFeeResponse;
114
+ RESPONSE: OPENRPC.EstimatedFee;
157
115
  };
158
116
  starknet_blockNumber: {
159
117
  QUERY: never;
@@ -163,7 +121,7 @@ export declare namespace RPC {
163
121
  starknet_chainId: {
164
122
  QUERY: never;
165
123
  REQUEST: any[];
166
- RESPONSE: StarknetChainId;
124
+ RESPONSE: OPENRPC.ChainId;
167
125
  };
168
126
  starknet_syncing: {
169
127
  QUERY: never;
@@ -178,23 +136,32 @@ export declare namespace RPC {
178
136
  starknet_addInvokeTransaction: {
179
137
  QUERY: never;
180
138
  REQUEST: any[];
181
- RESPONSE: AddTransactionResponse;
139
+ RESPONSE: OPENRPC.InvokedTransaction;
182
140
  };
183
141
  starknet_addDeployTransaction: {
184
142
  QUERY: never;
185
143
  REQUEST: any[];
186
- RESPONSE: DeployContractResponse;
144
+ RESPONSE: OPENRPC.DeployedTransaction;
187
145
  };
188
146
  starknet_addDeclareTransaction: {
189
147
  QUERY: never;
190
148
  REQUEST: any[];
191
- RESPONSE: DeclareResponse;
149
+ RESPONSE: OPENRPC.DeclaredTransaction;
192
150
  };
193
151
  starknet_getClassAt: {
194
152
  QUERY: never;
195
153
  REQUEST: any[];
196
154
  RESPONSE: any;
197
155
  };
156
+ starknet_traceTransaction: {
157
+ QUERY: never;
158
+ REQUEST: any[];
159
+ RESPONSE: any;
160
+ };
161
+ starknet_traceBlockTransactions: {
162
+ QUERY: never;
163
+ REQUEST: any[];
164
+ RESPONSE: any;
165
+ };
198
166
  };
199
- export {};
200
167
  }
@@ -11,14 +11,17 @@ declare type RpcGetBlockResponse = RPC.GetBlockWithTxHashesResponse & {
11
11
  declare type GetTransactionByHashResponse = RPC.GetTransactionByHashResponse & {
12
12
  [key: string]: any;
13
13
  };
14
+ declare type TransactionReceipt = RPC.TransactionReceipt & {
15
+ [key: string]: any;
16
+ };
14
17
  export declare class RPCResponseParser extends ResponseParser {
15
18
  parseGetBlockResponse(res: RpcGetBlockResponse): GetBlockResponse;
16
19
  parseGetTransactionResponse(res: GetTransactionByHashResponse): GetTransactionResponse;
17
- parseGetTransactionReceiptResponse(res: RPC.GetTransactionReceiptResponse): GetTransactionReceiptResponse;
20
+ parseGetTransactionReceiptResponse(res: TransactionReceipt): GetTransactionReceiptResponse;
18
21
  parseFeeEstimateResponse(res: RPC.EstimateFeeResponse): EstimateFeeResponse;
19
22
  parseCallContractResponse(res: Array<string>): CallContractResponse;
20
- parseInvokeFunctionResponse(res: RPC.AddTransactionResponse): InvokeFunctionResponse;
21
- parseDeployContractResponse(res: RPC.DeployContractResponse): DeployContractResponse;
22
- parseDeclareContractResponse(res: RPC.DeclareResponse): DeclareContractResponse;
23
+ parseInvokeFunctionResponse(res: RPC.InvokedTransaction): InvokeFunctionResponse;
24
+ parseDeployContractResponse(res: RPC.DeployedTransaction): DeployContractResponse;
25
+ parseDeclareContractResponse(res: RPC.DeclaredTransaction): DeclareContractResponse;
23
26
  }
24
27
  export {};
@@ -48,7 +48,7 @@ var RPCResponseParser = /** @class */ (function (_super) {
48
48
  };
49
49
  RPCResponseParser.prototype.parseGetTransactionReceiptResponse = function (res) {
50
50
  return {
51
- transaction_hash: res.txn_hash,
51
+ transaction_hash: res.transaction_hash,
52
52
  actual_fee: res.actual_fee,
53
53
  status: res.status,
54
54
  status_data: res.status_data,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "starknet",
3
- "version": "4.5.0",
3
+ "version": "4.6.0",
4
4
  "description": "JavaScript library for StarkNet",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/provider/rpc.d.ts CHANGED
@@ -12,24 +12,34 @@ export declare class RpcProvider implements ProviderInterface {
12
12
  chainId: StarknetChainId;
13
13
  private responseParser;
14
14
  constructor(optionsOrProvider: RpcProviderOptions);
15
+ fetch(method: any, params: any): Promise<any>;
16
+ protected errorHandler(error: any): void;
15
17
  protected fetchEndpoint<T extends keyof RPC.Methods>(method: T, request?: RPC.Methods[T]['REQUEST']): Promise<RPC.Methods[T]['RESPONSE']>;
16
- getChainId(): Promise<StarknetChainId>;
18
+ getChainId(): Promise<any>;
17
19
  getBlock(blockIdentifier?: BlockIdentifier): Promise<GetBlockResponse>;
20
+ getBlockHashAndNumber(): Promise<RPC.BlockHashAndNumber>;
18
21
  getBlockWithTxHashes(blockIdentifier?: BlockIdentifier): Promise<RPC.GetBlockWithTxHashesResponse>;
19
22
  getBlockWithTxs(blockIdentifier?: BlockIdentifier): Promise<RPC.GetBlockWithTxs>;
23
+ getClassHashAt(blockIdentifier: BlockIdentifier, contractAddress: RPC.ContractAddress): Promise<RPC.Felt>;
20
24
  getNonce(contractAddress: string): Promise<any>;
25
+ getPendingTransactions(): Promise<RPC.PendingTransactions>;
26
+ getProtocolVersion(): Promise<Error>;
27
+ getStateUpdate(blockIdentifier: BlockIdentifier): Promise<RPC.StateUpdate>;
21
28
  getStorageAt(contractAddress: string, key: BigNumberish, blockIdentifier?: BlockIdentifier): Promise<BigNumberish>;
22
29
  getTransaction(txHash: BigNumberish): Promise<GetTransactionResponse>;
23
30
  getTransactionByHash(txHash: BigNumberish): Promise<RPC.GetTransactionByHashResponse>;
24
31
  getTransactionByBlockIdAndIndex(blockIdentifier: BlockIdentifier, index: number): Promise<RPC.GetTransactionByBlockIdAndIndex>;
25
32
  getTransactionReceipt(txHash: BigNumberish): Promise<GetTransactionReceiptResponse>;
33
+ getClass(classHash: RPC.Felt): Promise<RPC.ContractClass>;
26
34
  getClassAt(contractAddress: string, blockIdentifier: BlockIdentifier): Promise<any>;
35
+ getCode(_contractAddress: string, _blockIdentifier?: BlockIdentifier): Promise<GetCodeResponse>;
27
36
  getEstimateFee(invocation: Invocation, blockIdentifier?: BlockIdentifier, invocationDetails?: InvocationsDetails): Promise<EstimateFeeResponse>;
28
37
  declareContract({ contract, version, }: DeclareContractPayload): Promise<DeclareContractResponse>;
29
38
  deployContract({ contract, constructorCalldata, addressSalt, }: DeployContractPayload): Promise<DeployContractResponse>;
30
39
  invokeFunction(functionInvocation: Invocation, details: InvocationsDetails): Promise<InvokeFunctionResponse>;
31
40
  callContract(call: Call, blockIdentifier?: BlockIdentifier): Promise<CallContractResponse>;
32
- getCode(_contractAddress: string, _blockIdentifier?: BlockIdentifier): Promise<GetCodeResponse>;
41
+ traceTransaction(transactionHash: RPC.TransactionHash): Promise<RPC.Trace>;
42
+ traceBlockTransactions(blockHash: RPC.BlockHash): Promise<RPC.Traces>;
33
43
  waitForTransaction(txHash: BigNumberish, retryInterval?: number): Promise<void>;
34
44
  /**
35
45
  * Gets the transaction count from a block.
package/provider/rpc.js CHANGED
@@ -58,54 +58,45 @@ var RpcProvider = /** @class */ (function () {
58
58
  _this.chainId = chainId;
59
59
  });
60
60
  }
61
+ RpcProvider.prototype.fetch = function (method, params) {
62
+ return (0, fetchPonyfill_1.default)(this.nodeUrl, {
63
+ method: 'POST',
64
+ body: (0, json_1.stringify)({ method: method, jsonrpc: '2.0', params: params, id: 0 }),
65
+ headers: { 'Content-Type': 'application/json' },
66
+ });
67
+ };
68
+ RpcProvider.prototype.errorHandler = function (error) {
69
+ if (error) {
70
+ var code = error.code, message = error.message;
71
+ throw new Error("".concat(code, ": ").concat(message));
72
+ }
73
+ };
61
74
  RpcProvider.prototype.fetchEndpoint = function (method, request) {
62
75
  var _a;
63
76
  return __awaiter(this, void 0, void 0, function () {
64
- var requestData, rawResult, _b, error, result, code, message, error_1, data;
77
+ var rawResult, _b, error, result, error_1;
65
78
  return __generator(this, function (_c) {
66
79
  switch (_c.label) {
67
80
  case 0:
68
- requestData = {
69
- method: method,
70
- jsonrpc: '2.0',
71
- params: request,
72
- id: 0,
73
- };
74
- _c.label = 1;
81
+ _c.trys.push([0, 3, , 4]);
82
+ return [4 /*yield*/, this.fetch(method, request)];
75
83
  case 1:
76
- _c.trys.push([1, 4, , 5]);
77
- return [4 /*yield*/, (0, fetchPonyfill_1.default)(this.nodeUrl, {
78
- method: 'POST',
79
- body: (0, json_1.stringify)(requestData),
80
- headers: {
81
- 'Content-Type': 'application/json',
82
- },
83
- })];
84
- case 2:
85
84
  rawResult = _c.sent();
86
85
  return [4 /*yield*/, rawResult.json()];
87
- case 3:
86
+ case 2:
88
87
  _b = _c.sent(), error = _b.error, result = _b.result;
89
- if (error) {
90
- code = error.code, message = error.message;
91
- throw new Error("".concat(code, ": ").concat(message));
92
- }
93
- else {
94
- return [2 /*return*/, result];
95
- }
96
- return [3 /*break*/, 5];
97
- case 4:
88
+ this.errorHandler(error);
89
+ return [2 /*return*/, result];
90
+ case 3:
98
91
  error_1 = _c.sent();
99
- data = (_a = error_1 === null || error_1 === void 0 ? void 0 : error_1.response) === null || _a === void 0 ? void 0 : _a.data;
100
- if (data === null || data === void 0 ? void 0 : data.message) {
101
- throw new Error("".concat(data.code, ": ").concat(data.message));
102
- }
92
+ this.errorHandler((_a = error_1 === null || error_1 === void 0 ? void 0 : error_1.response) === null || _a === void 0 ? void 0 : _a.data);
103
93
  throw error_1;
104
- case 5: return [2 /*return*/];
94
+ case 4: return [2 /*return*/];
105
95
  }
106
96
  });
107
97
  });
108
98
  };
99
+ // Methods from Interface
109
100
  RpcProvider.prototype.getChainId = function () {
110
101
  return __awaiter(this, void 0, void 0, function () {
111
102
  return __generator(this, function (_a) {
@@ -113,7 +104,7 @@ var RpcProvider = /** @class */ (function () {
113
104
  });
114
105
  });
115
106
  };
116
- // Common Interface
107
+ // Methods from Interface
117
108
  RpcProvider.prototype.getBlock = function (blockIdentifier) {
118
109
  if (blockIdentifier === void 0) { blockIdentifier = 'pending'; }
119
110
  return __awaiter(this, void 0, void 0, function () {
@@ -122,25 +113,39 @@ var RpcProvider = /** @class */ (function () {
122
113
  });
123
114
  });
124
115
  };
116
+ RpcProvider.prototype.getBlockHashAndNumber = function () {
117
+ return __awaiter(this, void 0, void 0, function () {
118
+ return __generator(this, function (_a) {
119
+ return [2 /*return*/, this.fetchEndpoint('starknet_blockHashAndNumber')];
120
+ });
121
+ });
122
+ };
125
123
  RpcProvider.prototype.getBlockWithTxHashes = function (blockIdentifier) {
126
124
  if (blockIdentifier === void 0) { blockIdentifier = 'pending'; }
127
125
  return __awaiter(this, void 0, void 0, function () {
128
- var blockIdentifierGetter;
126
+ var block;
129
127
  return __generator(this, function (_a) {
130
- blockIdentifierGetter = new utils_1.BlockIdentifierClass(blockIdentifier);
131
- return [2 /*return*/, this.fetchEndpoint('starknet_getBlockWithTxHashes', [
132
- blockIdentifierGetter.getIdentifier(),
133
- ])];
128
+ block = new utils_1.Block(blockIdentifier);
129
+ return [2 /*return*/, this.fetchEndpoint('starknet_getBlockWithTxHashes', [block.identifier])];
134
130
  });
135
131
  });
136
132
  };
137
133
  RpcProvider.prototype.getBlockWithTxs = function (blockIdentifier) {
138
134
  if (blockIdentifier === void 0) { blockIdentifier = 'pending'; }
139
135
  return __awaiter(this, void 0, void 0, function () {
140
- var blockIdentifierGetter;
136
+ var block;
137
+ return __generator(this, function (_a) {
138
+ block = new utils_1.Block(blockIdentifier);
139
+ return [2 /*return*/, this.fetchEndpoint('starknet_getBlockWithTxs', [block.identifier])];
140
+ });
141
+ });
142
+ };
143
+ RpcProvider.prototype.getClassHashAt = function (blockIdentifier, contractAddress) {
144
+ return __awaiter(this, void 0, void 0, function () {
145
+ var block;
141
146
  return __generator(this, function (_a) {
142
- blockIdentifierGetter = new utils_1.BlockIdentifierClass(blockIdentifier);
143
- return [2 /*return*/, this.fetchEndpoint('starknet_getBlockWithTxs', [blockIdentifierGetter.getIdentifier()])];
147
+ block = new utils_1.Block(blockIdentifier);
148
+ return [2 /*return*/, this.fetchEndpoint('starknet_getClassHashAt', [block.identifier, contractAddress])];
144
149
  });
145
150
  });
146
151
  };
@@ -151,22 +156,45 @@ var RpcProvider = /** @class */ (function () {
151
156
  });
152
157
  });
153
158
  };
159
+ RpcProvider.prototype.getPendingTransactions = function () {
160
+ return __awaiter(this, void 0, void 0, function () {
161
+ return __generator(this, function (_a) {
162
+ return [2 /*return*/, this.fetchEndpoint('starknet_pendingTransactions')];
163
+ });
164
+ });
165
+ };
166
+ RpcProvider.prototype.getProtocolVersion = function () {
167
+ return __awaiter(this, void 0, void 0, function () {
168
+ return __generator(this, function (_a) {
169
+ throw new Error('Pathfinder does not implement this rpc 0.1.0 method');
170
+ });
171
+ });
172
+ };
173
+ RpcProvider.prototype.getStateUpdate = function (blockIdentifier) {
174
+ return __awaiter(this, void 0, void 0, function () {
175
+ var block;
176
+ return __generator(this, function (_a) {
177
+ block = new utils_1.Block(blockIdentifier);
178
+ return [2 /*return*/, this.fetchEndpoint('starknet_getStateUpdate', [block.identifier])];
179
+ });
180
+ });
181
+ };
154
182
  RpcProvider.prototype.getStorageAt = function (contractAddress, key, blockIdentifier) {
155
183
  if (blockIdentifier === void 0) { blockIdentifier = 'pending'; }
156
184
  return __awaiter(this, void 0, void 0, function () {
157
- var parsedKey, blockIdentifierGetter;
185
+ var parsedKey, block;
158
186
  return __generator(this, function (_a) {
159
187
  parsedKey = (0, number_1.toHex)((0, number_1.toBN)(key));
160
- blockIdentifierGetter = new utils_1.BlockIdentifierClass(blockIdentifier);
188
+ block = new utils_1.Block(blockIdentifier);
161
189
  return [2 /*return*/, this.fetchEndpoint('starknet_getStorageAt', [
162
190
  contractAddress,
163
191
  parsedKey,
164
- blockIdentifierGetter.getIdentifier(),
192
+ block.identifier,
165
193
  ])];
166
194
  });
167
195
  });
168
196
  };
169
- // common interface
197
+ // Methods from Interface
170
198
  RpcProvider.prototype.getTransaction = function (txHash) {
171
199
  return __awaiter(this, void 0, void 0, function () {
172
200
  return __generator(this, function (_a) {
@@ -183,8 +211,13 @@ var RpcProvider = /** @class */ (function () {
183
211
  };
184
212
  RpcProvider.prototype.getTransactionByBlockIdAndIndex = function (blockIdentifier, index) {
185
213
  return __awaiter(this, void 0, void 0, function () {
214
+ var block;
186
215
  return __generator(this, function (_a) {
187
- return [2 /*return*/, this.fetchEndpoint('starknet_getTransactionByHash', [blockIdentifier, index])];
216
+ block = new utils_1.Block(blockIdentifier);
217
+ return [2 /*return*/, this.fetchEndpoint('starknet_getTransactionByBlockIdAndIndex', [
218
+ block.identifier,
219
+ index,
220
+ ])];
188
221
  });
189
222
  });
190
223
  };
@@ -195,15 +228,26 @@ var RpcProvider = /** @class */ (function () {
195
228
  });
196
229
  });
197
230
  };
231
+ RpcProvider.prototype.getClass = function (classHash) {
232
+ return __awaiter(this, void 0, void 0, function () {
233
+ return __generator(this, function (_a) {
234
+ return [2 /*return*/, this.fetchEndpoint('starknet_getClass', [classHash])];
235
+ });
236
+ });
237
+ };
198
238
  RpcProvider.prototype.getClassAt = function (contractAddress, blockIdentifier) {
199
239
  return __awaiter(this, void 0, void 0, function () {
200
- var blockIdentifierGetter;
240
+ var block;
201
241
  return __generator(this, function (_a) {
202
- blockIdentifierGetter = new utils_1.BlockIdentifierClass(blockIdentifier);
203
- return [2 /*return*/, this.fetchEndpoint('starknet_getClassAt', [
204
- blockIdentifierGetter.getIdentifier(),
205
- contractAddress,
206
- ])];
242
+ block = new utils_1.Block(blockIdentifier);
243
+ return [2 /*return*/, this.fetchEndpoint('starknet_getClassAt', [block.identifier, contractAddress])];
244
+ });
245
+ });
246
+ };
247
+ RpcProvider.prototype.getCode = function (_contractAddress, _blockIdentifier) {
248
+ return __awaiter(this, void 0, void 0, function () {
249
+ return __generator(this, function (_a) {
250
+ throw new Error('RPC 0.1.0 does not implement getCode function');
207
251
  });
208
252
  });
209
253
  };
@@ -211,7 +255,9 @@ var RpcProvider = /** @class */ (function () {
211
255
  if (blockIdentifier === void 0) { blockIdentifier = 'pending'; }
212
256
  if (invocationDetails === void 0) { invocationDetails = {}; }
213
257
  return __awaiter(this, void 0, void 0, function () {
258
+ var block_id;
214
259
  return __generator(this, function (_a) {
260
+ block_id = new utils_1.Block(blockIdentifier).identifier;
215
261
  return [2 /*return*/, this.fetchEndpoint('starknet_estimateFee', [
216
262
  {
217
263
  contract_address: invocation.contractAddress,
@@ -220,7 +266,7 @@ var RpcProvider = /** @class */ (function () {
220
266
  signature: (0, number_1.bigNumberishArrayToHexadecimalStringArray)(invocation.signature || []),
221
267
  version: (0, number_1.toHex)((0, number_1.toBN)((invocationDetails === null || invocationDetails === void 0 ? void 0 : invocationDetails.version) || 0)),
222
268
  },
223
- blockIdentifier,
269
+ block_id,
224
270
  ]).then(this.responseParser.parseFeeEstimateResponse)];
225
271
  });
226
272
  });
@@ -276,20 +322,23 @@ var RpcProvider = /** @class */ (function () {
276
322
  });
277
323
  });
278
324
  };
325
+ // Methods from Interface
279
326
  RpcProvider.prototype.callContract = function (call, blockIdentifier) {
280
327
  if (blockIdentifier === void 0) { blockIdentifier = 'pending'; }
281
328
  return __awaiter(this, void 0, void 0, function () {
282
- var result;
329
+ var block_id, result;
283
330
  return __generator(this, function (_a) {
284
331
  switch (_a.label) {
285
- case 0: return [4 /*yield*/, this.fetchEndpoint('starknet_call', [
286
- {
287
- contract_address: call.contractAddress,
288
- entry_point_selector: (0, hash_1.getSelectorFromName)(call.entrypoint),
289
- calldata: (0, provider_1.parseCalldata)(call.calldata),
290
- },
291
- blockIdentifier,
292
- ])];
332
+ case 0:
333
+ block_id = new utils_1.Block(blockIdentifier).identifier;
334
+ return [4 /*yield*/, this.fetchEndpoint('starknet_call', [
335
+ {
336
+ contract_address: call.contractAddress,
337
+ entry_point_selector: (0, hash_1.getSelectorFromName)(call.entrypoint),
338
+ calldata: (0, provider_1.parseCalldata)(call.calldata),
339
+ },
340
+ block_id,
341
+ ])];
293
342
  case 1:
294
343
  result = _a.sent();
295
344
  return [2 /*return*/, this.responseParser.parseCallContractResponse(result)];
@@ -297,10 +346,17 @@ var RpcProvider = /** @class */ (function () {
297
346
  });
298
347
  });
299
348
  };
300
- RpcProvider.prototype.getCode = function (_contractAddress, _blockIdentifier) {
349
+ RpcProvider.prototype.traceTransaction = function (transactionHash) {
301
350
  return __awaiter(this, void 0, void 0, function () {
302
351
  return __generator(this, function (_a) {
303
- throw new Error('RPC 0.1.0 does not implement getCode function');
352
+ return [2 /*return*/, this.fetchEndpoint('starknet_traceTransaction', [transactionHash])];
353
+ });
354
+ });
355
+ };
356
+ RpcProvider.prototype.traceBlockTransactions = function (blockHash) {
357
+ return __awaiter(this, void 0, void 0, function () {
358
+ return __generator(this, function (_a) {
359
+ return [2 /*return*/, this.fetchEndpoint('starknet_traceBlockTransactions', [blockHash])];
304
360
  });
305
361
  });
306
362
  };
@@ -312,7 +368,7 @@ var RpcProvider = /** @class */ (function () {
312
368
  switch (_a.label) {
313
369
  case 0:
314
370
  onchain = false;
315
- retries = 100;
371
+ retries = 200;
316
372
  _a.label = 1;
317
373
  case 1:
318
374
  if (!!onchain) return [3 /*break*/, 7];
@@ -368,12 +424,10 @@ var RpcProvider = /** @class */ (function () {
368
424
  */
369
425
  RpcProvider.prototype.getTransactionCount = function (blockIdentifier) {
370
426
  return __awaiter(this, void 0, void 0, function () {
371
- var blockIdentifierGetter;
427
+ var block;
372
428
  return __generator(this, function (_a) {
373
- blockIdentifierGetter = new utils_1.BlockIdentifierClass(blockIdentifier);
374
- return [2 /*return*/, this.fetchEndpoint('starknet_getBlockTransactionCount', [
375
- blockIdentifierGetter.getIdentifier(),
376
- ])];
429
+ block = new utils_1.Block(blockIdentifier);
430
+ return [2 /*return*/, this.fetchEndpoint('starknet_getBlockTransactionCount', [block.identifier])];
377
431
  });
378
432
  });
379
433
  };
@@ -134,7 +134,8 @@ var SequencerProvider = /** @class */ (function () {
134
134
  .map(function (_a) {
135
135
  var _b = __read(_a, 2), key = _b[0], value = _b[1];
136
136
  if (key === 'blockIdentifier') {
137
- return "".concat((0, utils_1.getFormattedBlockIdentifier)(value));
137
+ var block = new utils_1.Block(value);
138
+ return "".concat(block.queryIdentifier);
138
139
  }
139
140
  return "".concat(key, "=").concat(value);
140
141
  })