starknet 4.10.0 → 4.12.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,6 +1,6 @@
1
1
  import { StarknetChainId } from '../constants';
2
2
  import type { Call, CallContractResponse, ContractClass, DeclareContractResponse, DeployContractPayload, DeployContractResponse, EstimateFeeResponse, GetBlockResponse, GetCodeResponse, GetTransactionReceiptResponse, GetTransactionResponse, Invocation, InvocationsDetailsWithNonce, InvokeFunctionResponse } from '../types';
3
- import { DeclareContractTransaction, DeployAccountContractPayload, DeployAccountContractTransaction } from '../types/lib';
3
+ import { DeclareContractTransaction, DeployAccountContractPayload, DeployAccountContractTransaction, InvocationsDetails } from '../types/lib';
4
4
  import type { BigNumberish } from '../utils/number';
5
5
  import { BlockIdentifier } from './utils';
6
6
  export declare abstract class ProviderInterface {
@@ -38,6 +38,21 @@ export declare abstract class ProviderInterface {
38
38
  * @returns Contract class of compiled contract
39
39
  */
40
40
  abstract getClassAt(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<ContractClass>;
41
+ /**
42
+ * Returns the class hash deployed under the given address.
43
+ *
44
+ * @param contractAddress - contract address
45
+ * @param blockIdentifier - block identifier
46
+ * @returns Class hash
47
+ */
48
+ abstract getClassHashAt(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<string>;
49
+ /**
50
+ * Returns the contract class deployed under the given class hash.
51
+ *
52
+ * @param classHash - class hash
53
+ * @returns Contract class of compiled contract
54
+ */
55
+ abstract getClassByHash(classHash: string): Promise<ContractClass>;
41
56
  /**
42
57
  * Gets the nonce of a contract with respect to a specific block
43
58
  *
@@ -53,7 +68,7 @@ export declare abstract class ProviderInterface {
53
68
  * @param blockIdentifier - block identifier
54
69
  * @returns the value of the storage variable
55
70
  */
56
- abstract getStorageAt(contractAddress: string, key: BigNumberish, blockIdentifier: BlockIdentifier): Promise<BigNumberish>;
71
+ abstract getStorageAt(contractAddress: string, key: BigNumberish, blockIdentifier?: BlockIdentifier): Promise<BigNumberish>;
57
72
  /**
58
73
  * Gets the transaction information from a tx id.
59
74
  *
@@ -77,7 +92,7 @@ export declare abstract class ProviderInterface {
77
92
  * - address salt
78
93
  * @returns a confirmation of sending a transaction on the starknet contract
79
94
  */
80
- abstract deployContract(payload: DeployContractPayload): Promise<DeployContractResponse>;
95
+ abstract deployContract(payload: DeployContractPayload, details?: InvocationsDetails): Promise<DeployContractResponse>;
81
96
  /**
82
97
  * Deploys a given compiled Account contract (json) to starknet
83
98
  *
package/provider/rpc.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { StarknetChainId } from '../constants';
2
- import { Call, CallContractResponse, DeclareContractResponse, DeployContractPayload, DeployContractResponse, EstimateFeeResponse, GetBlockResponse, GetCodeResponse, GetTransactionReceiptResponse, GetTransactionResponse, Invocation, InvocationsDetailsWithNonce, InvokeFunctionResponse } from '../types';
2
+ import { Call, CallContractResponse, DeclareContractResponse, DeployContractPayload, DeployContractResponse, EstimateFeeResponse, GetBlockResponse, GetCodeResponse, GetTransactionResponse, Invocation, InvocationsDetailsWithNonce, InvokeFunctionResponse } from '../types';
3
3
  import { RPC } from '../types/api';
4
- import { DeclareContractTransaction, DeployAccountContractPayload, DeployAccountContractTransaction } from '../types/lib';
4
+ import { DeclareContractTransaction, DeployAccountContractTransaction, InvocationsDetails } from '../types/lib';
5
5
  import { BigNumberish } from '../utils/number';
6
6
  import { ProviderInterface } from './interface';
7
7
  import { BlockIdentifier } from './utils';
@@ -25,17 +25,18 @@ export declare class RpcProvider implements ProviderInterface {
25
25
  getBlockHashAndNumber(): Promise<RPC.BlockHashAndNumber>;
26
26
  getBlockWithTxHashes(blockIdentifier?: BlockIdentifier): Promise<RPC.GetBlockWithTxHashesResponse>;
27
27
  getBlockWithTxs(blockIdentifier?: BlockIdentifier): Promise<RPC.GetBlockWithTxs>;
28
- getClassHashAt(blockIdentifier: BlockIdentifier, contractAddress: RPC.ContractAddress): Promise<RPC.Felt>;
28
+ getClassHashAt(contractAddress: RPC.ContractAddress, blockIdentifier?: BlockIdentifier): Promise<RPC.Felt>;
29
29
  getNonce(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<RPC.Nonce>;
30
30
  getPendingTransactions(): Promise<RPC.PendingTransactions>;
31
31
  getProtocolVersion(): Promise<Error>;
32
- getStateUpdate(blockIdentifier: BlockIdentifier): Promise<RPC.StateUpdate>;
32
+ getStateUpdate(blockIdentifier?: BlockIdentifier): Promise<RPC.StateUpdate>;
33
33
  getStorageAt(contractAddress: string, key: BigNumberish, blockIdentifier?: BlockIdentifier): Promise<BigNumberish>;
34
34
  getTransaction(txHash: string): Promise<GetTransactionResponse>;
35
35
  getTransactionByHash(txHash: string): Promise<RPC.GetTransactionByHashResponse>;
36
36
  getTransactionByBlockIdAndIndex(blockIdentifier: BlockIdentifier, index: number): Promise<RPC.GetTransactionByBlockIdAndIndex>;
37
- getTransactionReceipt(txHash: string): Promise<GetTransactionReceiptResponse>;
38
- getClass(classHash: RPC.Felt): Promise<RPC.ContractClass>;
37
+ getTransactionReceipt(txHash: string): Promise<RPC.TransactionReceipt>;
38
+ getClassByHash(classHash: RPC.Felt): Promise<RPC.ContractClass>;
39
+ getClass(classHash: RPC.Felt, blockIdentifier?: BlockIdentifier): Promise<RPC.ContractClass>;
39
40
  getClassAt(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<RPC.ContractClass>;
40
41
  getCode(_contractAddress: string, _blockIdentifier?: BlockIdentifier): Promise<GetCodeResponse>;
41
42
  getEstimateFee(invocation: Invocation, invocationDetails: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier): Promise<EstimateFeeResponse>;
@@ -43,8 +44,11 @@ export declare class RpcProvider implements ProviderInterface {
43
44
  getDeclareEstimateFee({ senderAddress, contractDefinition, signature }: DeclareContractTransaction, details: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier): Promise<EstimateFeeResponse>;
44
45
  getDeployAccountEstimateFee({ classHash, constructorCalldata, addressSalt, signature }: DeployAccountContractTransaction, details: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier): Promise<EstimateFeeResponse>;
45
46
  declareContract({ contractDefinition, signature, senderAddress }: DeclareContractTransaction, details: InvocationsDetailsWithNonce): Promise<DeclareContractResponse>;
46
- deployContract({ contract, constructorCalldata, addressSalt, }: DeployContractPayload): Promise<DeployContractResponse>;
47
- deployAccountContract({ classHash, constructorCalldata, addressSalt, }: DeployAccountContractPayload): Promise<DeployContractResponse>;
47
+ /**
48
+ * @deprecated This method wont be supported soon, use Account.deploy instead
49
+ */
50
+ deployContract({ contract, constructorCalldata, addressSalt }: DeployContractPayload, details?: InvocationsDetails): Promise<DeployContractResponse>;
51
+ deployAccountContract({ classHash, constructorCalldata, addressSalt, signature }: DeployAccountContractTransaction, details: InvocationsDetailsWithNonce): Promise<DeployContractResponse>;
48
52
  invokeFunction(functionInvocation: Invocation, details: InvocationsDetailsWithNonce): Promise<InvokeFunctionResponse>;
49
53
  callContract(call: Call, blockIdentifier?: BlockIdentifier): Promise<CallContractResponse>;
50
54
  traceTransaction(transactionHash: RPC.TransactionHash): Promise<RPC.Trace>;
@@ -57,7 +61,7 @@ export declare class RpcProvider implements ProviderInterface {
57
61
  * @param blockIdentifier
58
62
  * @returns Number of transactions
59
63
  */
60
- getTransactionCount(blockIdentifier: BlockIdentifier): Promise<RPC.GetTransactionCountResponse>;
64
+ getTransactionCount(blockIdentifier?: BlockIdentifier): Promise<RPC.GetTransactionCountResponse>;
61
65
  /**
62
66
  * Gets the latest block number
63
67
  *
package/provider/rpc.js CHANGED
@@ -72,7 +72,7 @@ var RpcProvider = /** @class */ (function () {
72
72
  });
73
73
  }
74
74
  RpcProvider.prototype.fetch = function (method, params) {
75
- return (0, fetchPonyfill_1.default)(this.nodeUrl, {
75
+ return (0, fetchPonyfill_1.default)("".concat(this.nodeUrl, "/rpc/v0.2"), {
76
76
  method: 'POST',
77
77
  body: (0, json_1.stringify)({ method: method, jsonrpc: '2.0', params: params, id: 0 }),
78
78
  headers: this.headers,
@@ -153,7 +153,8 @@ var RpcProvider = /** @class */ (function () {
153
153
  });
154
154
  });
155
155
  };
156
- RpcProvider.prototype.getClassHashAt = function (blockIdentifier, contractAddress) {
156
+ RpcProvider.prototype.getClassHashAt = function (contractAddress, blockIdentifier) {
157
+ if (blockIdentifier === void 0) { blockIdentifier = 'pending'; }
157
158
  return __awaiter(this, void 0, void 0, function () {
158
159
  var block_id;
159
160
  return __generator(this, function (_a) {
@@ -193,6 +194,7 @@ var RpcProvider = /** @class */ (function () {
193
194
  });
194
195
  };
195
196
  RpcProvider.prototype.getStateUpdate = function (blockIdentifier) {
197
+ if (blockIdentifier === void 0) { blockIdentifier = 'pending'; }
196
198
  return __awaiter(this, void 0, void 0, function () {
197
199
  var block_id;
198
200
  return __generator(this, function (_a) {
@@ -247,10 +249,20 @@ var RpcProvider = /** @class */ (function () {
247
249
  });
248
250
  });
249
251
  };
250
- RpcProvider.prototype.getClass = function (classHash) {
252
+ RpcProvider.prototype.getClassByHash = function (classHash) {
251
253
  return __awaiter(this, void 0, void 0, function () {
252
254
  return __generator(this, function (_a) {
253
- return [2 /*return*/, this.fetchEndpoint('starknet_getClass', { class_hash: classHash })];
255
+ return [2 /*return*/, this.getClass(classHash)];
256
+ });
257
+ });
258
+ };
259
+ RpcProvider.prototype.getClass = function (classHash, blockIdentifier) {
260
+ if (blockIdentifier === void 0) { blockIdentifier = 'pending'; }
261
+ return __awaiter(this, void 0, void 0, function () {
262
+ var block_id;
263
+ return __generator(this, function (_a) {
264
+ block_id = new utils_1.Block(blockIdentifier).identifier;
265
+ return [2 /*return*/, this.fetchEndpoint('starknet_getClass', { class_hash: classHash, block_id: block_id })];
254
266
  });
255
267
  });
256
268
  };
@@ -270,7 +282,7 @@ var RpcProvider = /** @class */ (function () {
270
282
  RpcProvider.prototype.getCode = function (_contractAddress, _blockIdentifier) {
271
283
  return __awaiter(this, void 0, void 0, function () {
272
284
  return __generator(this, function (_a) {
273
- throw new Error('RPC 0.1.0 does not implement getCode function');
285
+ throw new Error('RPC does not implement getCode function');
274
286
  });
275
287
  });
276
288
  };
@@ -359,46 +371,61 @@ var RpcProvider = /** @class */ (function () {
359
371
  return __awaiter(this, void 0, void 0, function () {
360
372
  return __generator(this, function (_b) {
361
373
  return [2 /*return*/, this.fetchEndpoint('starknet_addDeclareTransaction', {
362
- contract_class: {
363
- program: contractDefinition.program,
364
- entry_points_by_type: contractDefinition.entry_points_by_type,
365
- abi: contractDefinition.abi, // rpc 2.0
374
+ declare_transaction: {
375
+ contract_class: {
376
+ program: contractDefinition.program,
377
+ entry_points_by_type: contractDefinition.entry_points_by_type,
378
+ abi: contractDefinition.abi, // rpc 2.0
379
+ },
380
+ type: 'DECLARE',
381
+ version: (0, number_1.toHex)((0, number_1.toBN)(details.version || 0)),
382
+ max_fee: (0, number_1.toHex)((0, number_1.toBN)(details.maxFee || 0)),
383
+ signature: (0, number_1.bigNumberishArrayToHexadecimalStringArray)(signature || []),
384
+ sender_address: senderAddress,
385
+ nonce: (0, number_1.toHex)((0, number_1.toBN)(details.nonce)),
366
386
  },
367
- version: (0, number_1.toHex)((0, number_1.toBN)(details.version || 0)),
368
- max_fee: (0, number_1.toHex)((0, number_1.toBN)(details.maxFee || 0)),
369
- signature: (0, number_1.bigNumberishArrayToHexadecimalStringArray)(signature || []),
370
- sender_address: senderAddress,
371
- nonce: (0, number_1.toHex)((0, number_1.toBN)(details.nonce)),
372
387
  })];
373
388
  });
374
389
  });
375
390
  };
376
- RpcProvider.prototype.deployContract = function (_a) {
391
+ /**
392
+ * @deprecated This method wont be supported soon, use Account.deploy instead
393
+ */
394
+ RpcProvider.prototype.deployContract = function (_a, details) {
377
395
  var contract = _a.contract, constructorCalldata = _a.constructorCalldata, addressSalt = _a.addressSalt;
378
396
  return __awaiter(this, void 0, void 0, function () {
379
397
  var contractDefinition;
380
398
  return __generator(this, function (_b) {
381
399
  contractDefinition = (0, provider_1.parseContract)(contract);
382
400
  return [2 /*return*/, this.fetchEndpoint('starknet_addDeployTransaction', {
383
- contract_address_salt: addressSalt !== null && addressSalt !== void 0 ? addressSalt : (0, stark_1.randomAddress)(),
384
- constructor_calldata: (0, number_1.bigNumberishArrayToHexadecimalStringArray)(constructorCalldata !== null && constructorCalldata !== void 0 ? constructorCalldata : []),
385
- contract_definition: {
386
- program: contractDefinition.program,
387
- entry_points_by_type: contractDefinition.entry_points_by_type,
388
- abi: contractDefinition.abi, // rpc 2.0
401
+ deploy_transaction: {
402
+ contract_address_salt: addressSalt !== null && addressSalt !== void 0 ? addressSalt : (0, stark_1.randomAddress)(),
403
+ constructor_calldata: (0, number_1.bigNumberishArrayToHexadecimalStringArray)(constructorCalldata !== null && constructorCalldata !== void 0 ? constructorCalldata : []),
404
+ contract_class: {
405
+ program: contractDefinition.program,
406
+ entry_points_by_type: contractDefinition.entry_points_by_type,
407
+ abi: contractDefinition.abi,
408
+ },
409
+ type: 'DEPLOY',
410
+ version: (0, number_1.toHex)((0, number_1.toBN)((details === null || details === void 0 ? void 0 : details.version) || 0)),
389
411
  },
390
412
  })];
391
413
  });
392
414
  });
393
415
  };
394
- RpcProvider.prototype.deployAccountContract = function (_a) {
395
- var classHash = _a.classHash, constructorCalldata = _a.constructorCalldata, addressSalt = _a.addressSalt;
416
+ RpcProvider.prototype.deployAccountContract = function (_a, details) {
417
+ var classHash = _a.classHash, constructorCalldata = _a.constructorCalldata, addressSalt = _a.addressSalt, signature = _a.signature;
396
418
  return __awaiter(this, void 0, void 0, function () {
397
419
  return __generator(this, function (_b) {
398
420
  return [2 /*return*/, this.fetchEndpoint('starknet_addDeployAccountTransaction', {
399
421
  constructor_calldata: (0, number_1.bigNumberishArrayToHexadecimalStringArray)(constructorCalldata || []),
400
422
  class_hash: (0, number_1.toHex)((0, number_1.toBN)(classHash)),
401
423
  contract_address_salt: (0, number_1.toHex)((0, number_1.toBN)(addressSalt || 0)),
424
+ type: 'DEPLOY',
425
+ max_fee: (0, number_1.toHex)((0, number_1.toBN)(details.maxFee || 0)),
426
+ version: (0, number_1.toHex)((0, number_1.toBN)(details.version || 0)),
427
+ signature: (0, number_1.bigNumberishArrayToHexadecimalStringArray)(signature || []),
428
+ nonce: (0, number_1.toHex)((0, number_1.toBN)(details.nonce)),
402
429
  })];
403
430
  });
404
431
  });
@@ -407,13 +434,15 @@ var RpcProvider = /** @class */ (function () {
407
434
  return __awaiter(this, void 0, void 0, function () {
408
435
  return __generator(this, function (_a) {
409
436
  return [2 /*return*/, this.fetchEndpoint('starknet_addInvokeTransaction', {
410
- function_invocation: {
411
- contract_address: functionInvocation.contractAddress,
437
+ invoke_transaction: {
438
+ sender_address: functionInvocation.contractAddress,
412
439
  calldata: (0, provider_1.parseCalldata)(functionInvocation.calldata),
440
+ type: 'INVOKE',
441
+ max_fee: (0, number_1.toHex)((0, number_1.toBN)(details.maxFee || 0)),
442
+ version: (0, number_1.toHex)((0, number_1.toBN)(details.version || 0)),
443
+ signature: (0, number_1.bigNumberishArrayToHexadecimalStringArray)(functionInvocation.signature || []),
444
+ nonce: (0, number_1.toHex)((0, number_1.toBN)(details.nonce)),
413
445
  },
414
- signature: (0, number_1.bigNumberishArrayToHexadecimalStringArray)(functionInvocation.signature || []),
415
- max_fee: (0, number_1.toHex)((0, number_1.toBN)(details.maxFee || 0)),
416
- version: (0, number_1.toHex)((0, number_1.toBN)(details.version || 0)),
417
446
  })];
418
447
  });
419
448
  });
@@ -459,7 +488,7 @@ var RpcProvider = /** @class */ (function () {
459
488
  RpcProvider.prototype.waitForTransaction = function (txHash, retryInterval) {
460
489
  if (retryInterval === void 0) { retryInterval = 8000; }
461
490
  return __awaiter(this, void 0, void 0, function () {
462
- var retries, onchain, successStates, errorStates, res, message, error, error_2;
491
+ var retries, onchain, successStates, errorStates, res, error, message, error, error_2;
463
492
  return __generator(this, function (_a) {
464
493
  switch (_a.label) {
465
494
  case 0:
@@ -481,6 +510,10 @@ var RpcProvider = /** @class */ (function () {
481
510
  return [4 /*yield*/, this.getTransactionReceipt(txHash)];
482
511
  case 4:
483
512
  res = _a.sent();
513
+ if (!('status' in res)) {
514
+ error = new Error('pending transaction');
515
+ throw error;
516
+ }
484
517
  if (res.status && successStates.includes(res.status)) {
485
518
  onchain = true;
486
519
  }
@@ -519,6 +552,7 @@ var RpcProvider = /** @class */ (function () {
519
552
  * @returns Number of transactions
520
553
  */
521
554
  RpcProvider.prototype.getTransactionCount = function (blockIdentifier) {
555
+ if (blockIdentifier === void 0) { blockIdentifier = 'pending'; }
522
556
  return __awaiter(this, void 0, void 0, function () {
523
557
  var block_id;
524
558
  return __generator(this, function (_a) {
@@ -38,6 +38,8 @@ export declare class SequencerProvider implements ProviderInterface {
38
38
  getTransaction(txHash: BigNumberish): Promise<GetTransactionResponse>;
39
39
  getTransactionReceipt(txHash: BigNumberish): Promise<GetTransactionReceiptResponse>;
40
40
  getClassAt(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<ContractClass>;
41
+ getClassHashAt(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<string>;
42
+ getClassByHash(classHash: string): Promise<ContractClass>;
41
43
  invokeFunction(functionInvocation: Invocation, details: InvocationsDetailsWithNonce): Promise<InvokeFunctionResponse>;
42
44
  deployContract({ contract, constructorCalldata, addressSalt, }: DeployContractPayload): Promise<DeployContractResponse>;
43
45
  deployAccountContract({ classHash, constructorCalldata, addressSalt, signature }: DeployAccountContractTransaction, details: InvocationsDetailsWithNonce): Promise<DeployContractResponse>;
@@ -326,6 +326,21 @@ var SequencerProvider = /** @class */ (function () {
326
326
  });
327
327
  });
328
328
  };
329
+ SequencerProvider.prototype.getClassHashAt = function (contractAddress, blockIdentifier) {
330
+ if (blockIdentifier === void 0) { blockIdentifier = 'pending'; }
331
+ return __awaiter(this, void 0, void 0, function () {
332
+ return __generator(this, function (_a) {
333
+ return [2 /*return*/, this.fetchEndpoint('get_class_hash_at', { blockIdentifier: blockIdentifier, contractAddress: contractAddress })];
334
+ });
335
+ });
336
+ };
337
+ SequencerProvider.prototype.getClassByHash = function (classHash) {
338
+ return __awaiter(this, void 0, void 0, function () {
339
+ return __generator(this, function (_a) {
340
+ return [2 /*return*/, this.fetchEndpoint('get_class_by_hash', { classHash: classHash }).then(provider_1.parseContract)];
341
+ });
342
+ });
343
+ };
329
344
  SequencerProvider.prototype.invokeFunction = function (functionInvocation, details) {
330
345
  var _a, _b;
331
346
  return __awaiter(this, void 0, void 0, function () {
@@ -22,7 +22,11 @@ import {
22
22
  DeployAccountContractPayload,
23
23
  UniversalDeployerContractPayload,
24
24
  } from '../types/lib';
25
- import { calculateContractAddressFromHash, transactionVersion } from '../utils/hash';
25
+ import {
26
+ calculateContractAddressFromHash,
27
+ feeTransactionVersion,
28
+ transactionVersion,
29
+ } from '../utils/hash';
26
30
  import { BigNumberish, toBN, toCairoBool } from '../utils/number';
27
31
  import { parseContract } from '../utils/provider';
28
32
  import { compileCalldata, estimatedFeeToMaxFee } from '../utils/stark';
@@ -63,7 +67,7 @@ export class Account extends Provider implements AccountInterface {
63
67
  ): Promise<EstimateFee> {
64
68
  const transactions = Array.isArray(calls) ? calls : [calls];
65
69
  const nonce = toBN(providedNonce ?? (await this.getNonce()));
66
- const version = toBN(transactionVersion);
70
+ const version = toBN(feeTransactionVersion);
67
71
  const chainId = await this.getChainId();
68
72
 
69
73
  const signerDetails: InvocationsSignerDetails = {
@@ -96,7 +100,7 @@ export class Account extends Provider implements AccountInterface {
96
100
  { blockIdentifier, nonce: providedNonce }: EstimateFeeDetails = {}
97
101
  ): Promise<EstimateFee> {
98
102
  const nonce = toBN(providedNonce ?? (await this.getNonce()));
99
- const version = toBN(transactionVersion);
103
+ const version = toBN(feeTransactionVersion);
100
104
  const chainId = await this.getChainId();
101
105
  const contractDefinition = parseContract(contract);
102
106
 
@@ -132,7 +136,7 @@ export class Account extends Provider implements AccountInterface {
132
136
  { blockIdentifier, nonce: providedNonce }: EstimateFeeDetails = {}
133
137
  ): Promise<EstimateFee> {
134
138
  const nonce = toBN(providedNonce ?? (await this.getNonce()));
135
- const version = toBN(transactionVersion);
139
+ const version = toBN(feeTransactionVersion);
136
140
  const chainId = await this.getChainId();
137
141
  const contractAddress =
138
142
  providedContractAddress ??
@@ -15,7 +15,11 @@ import {
15
15
  InvocationsDetailsWithNonce,
16
16
  InvokeFunctionResponse,
17
17
  } from '../types';
18
- import { DeclareContractTransaction, DeployAccountContractTransaction } from '../types/lib';
18
+ import {
19
+ DeclareContractTransaction,
20
+ DeployAccountContractTransaction,
21
+ InvocationsDetails,
22
+ } from '../types/lib';
19
23
  import { BigNumberish } from '../utils/number';
20
24
  import { ProviderInterface } from './interface';
21
25
  import { RpcProvider, RpcProviderOptions } from './rpc';
@@ -61,6 +65,17 @@ export class Provider implements ProviderInterface {
61
65
  return this.provider.getClassAt(contractAddress, blockIdentifier);
62
66
  }
63
67
 
68
+ public async getClassHashAt(
69
+ contractAddress: string,
70
+ blockIdentifier: BlockIdentifier = 'pending'
71
+ ): Promise<string> {
72
+ return this.provider.getClassHashAt(contractAddress, blockIdentifier);
73
+ }
74
+
75
+ public getClassByHash(classHash: string): Promise<ContractClass> {
76
+ return this.provider.getClassByHash(classHash);
77
+ }
78
+
64
79
  public async getEstimateFee(
65
80
  invocationWithTxType: Invocation,
66
81
  invocationDetails: InvocationsDetailsWithNonce,
@@ -118,8 +133,11 @@ export class Provider implements ProviderInterface {
118
133
  return this.provider.invokeFunction(functionInvocation, details);
119
134
  }
120
135
 
121
- public async deployContract(payload: DeployContractPayload): Promise<DeployContractResponse> {
122
- return this.provider.deployContract(payload);
136
+ public async deployContract(
137
+ payload: DeployContractPayload,
138
+ details: InvocationsDetails
139
+ ): Promise<DeployContractResponse> {
140
+ return this.provider.deployContract(payload, details);
123
141
  }
124
142
 
125
143
  public async deployAccountContract(
@@ -19,6 +19,7 @@ import {
19
19
  DeclareContractTransaction,
20
20
  DeployAccountContractPayload,
21
21
  DeployAccountContractTransaction,
22
+ InvocationsDetails,
22
23
  } from '../types/lib';
23
24
  import type { BigNumberish } from '../utils/number';
24
25
  import { BlockIdentifier } from './utils';
@@ -73,6 +74,26 @@ export abstract class ProviderInterface {
73
74
  blockIdentifier?: BlockIdentifier
74
75
  ): Promise<ContractClass>;
75
76
 
77
+ /**
78
+ * Returns the class hash deployed under the given address.
79
+ *
80
+ * @param contractAddress - contract address
81
+ * @param blockIdentifier - block identifier
82
+ * @returns Class hash
83
+ */
84
+ public abstract getClassHashAt(
85
+ contractAddress: string,
86
+ blockIdentifier?: BlockIdentifier
87
+ ): Promise<string>;
88
+
89
+ /**
90
+ * Returns the contract class deployed under the given class hash.
91
+ *
92
+ * @param classHash - class hash
93
+ * @returns Contract class of compiled contract
94
+ */
95
+ public abstract getClassByHash(classHash: string): Promise<ContractClass>;
96
+
76
97
  /**
77
98
  * Gets the nonce of a contract with respect to a specific block
78
99
  *
@@ -95,7 +116,7 @@ export abstract class ProviderInterface {
95
116
  public abstract getStorageAt(
96
117
  contractAddress: string,
97
118
  key: BigNumberish,
98
- blockIdentifier: BlockIdentifier
119
+ blockIdentifier?: BlockIdentifier
99
120
  ): Promise<BigNumberish>;
100
121
 
101
122
  /**
@@ -125,7 +146,10 @@ export abstract class ProviderInterface {
125
146
  * - address salt
126
147
  * @returns a confirmation of sending a transaction on the starknet contract
127
148
  */
128
- public abstract deployContract(payload: DeployContractPayload): Promise<DeployContractResponse>;
149
+ public abstract deployContract(
150
+ payload: DeployContractPayload,
151
+ details?: InvocationsDetails
152
+ ): Promise<DeployContractResponse>;
129
153
 
130
154
  /**
131
155
  * Deploys a given compiled Account contract (json) to starknet