starknet 2.7.1 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/.eslintrc +3 -1
  2. package/CHANGELOG.md +47 -0
  3. package/CONTRIBUTING.md +1 -1
  4. package/README.md +18 -16
  5. package/__mocks__/typedDataExample.json +35 -0
  6. package/__tests__/account.test.ts +52 -87
  7. package/__tests__/accountContract.test.ts +160 -0
  8. package/__tests__/contract.test.ts +3 -1
  9. package/__tests__/jest.setup.ts +9 -0
  10. package/__tests__/provider.test.ts +16 -33
  11. package/__tests__/utils/address.test.ts +16 -0
  12. package/__tests__/utils/typedData.test.ts +1 -36
  13. package/account/default.d.ts +66 -0
  14. package/account/default.js +440 -0
  15. package/account/index.d.ts +2 -0
  16. package/account/index.js +27 -0
  17. package/account/interface.d.ts +83 -0
  18. package/account/interface.js +37 -0
  19. package/constants.d.ts +2 -0
  20. package/constants.js +4 -0
  21. package/contract.d.ts +6 -6
  22. package/contract.js +16 -14
  23. package/dist/account/default.d.ts +55 -0
  24. package/dist/account/default.js +272 -0
  25. package/dist/account/index.d.ts +2 -0
  26. package/dist/account/index.js +14 -0
  27. package/dist/account/interface.d.ts +69 -0
  28. package/dist/account/interface.js +27 -0
  29. package/dist/constants.d.ts +2 -0
  30. package/dist/constants.js +3 -1
  31. package/dist/contract.d.ts +6 -6
  32. package/dist/contract.js +9 -12
  33. package/dist/index.d.ts +2 -1
  34. package/dist/index.js +2 -1
  35. package/dist/provider/default.d.ts +27 -16
  36. package/dist/provider/default.js +157 -100
  37. package/dist/provider/interface.d.ts +29 -32
  38. package/dist/provider/utils.d.ts +21 -5
  39. package/dist/provider/utils.js +53 -10
  40. package/dist/signer/default.d.ts +7 -31
  41. package/dist/signer/default.js +25 -121
  42. package/dist/signer/index.d.ts +1 -1
  43. package/dist/signer/index.js +1 -1
  44. package/dist/signer/interface.d.ts +17 -18
  45. package/dist/signer/interface.js +2 -20
  46. package/dist/{types.d.ts → types/api.d.ts} +72 -41
  47. package/dist/{types.js → types/api.js} +0 -0
  48. package/dist/types/index.d.ts +3 -0
  49. package/dist/types/index.js +15 -0
  50. package/dist/types/lib.d.ts +57 -0
  51. package/dist/types/lib.js +2 -0
  52. package/dist/types/signer.d.ts +4 -0
  53. package/dist/types/signer.js +2 -0
  54. package/dist/utils/address.d.ts +2 -0
  55. package/dist/utils/address.js +22 -0
  56. package/dist/utils/number.d.ts +1 -0
  57. package/dist/utils/number.js +5 -1
  58. package/index.d.ts +2 -1
  59. package/index.js +2 -1
  60. package/package.json +8 -2
  61. package/provider/default.d.ts +45 -36
  62. package/provider/default.js +216 -201
  63. package/provider/interface.d.ts +36 -49
  64. package/provider/utils.d.ts +23 -8
  65. package/provider/utils.js +57 -11
  66. package/signer/default.d.ts +11 -31
  67. package/signer/default.js +52 -169
  68. package/signer/index.d.ts +1 -1
  69. package/signer/index.js +1 -1
  70. package/signer/interface.d.ts +21 -18
  71. package/signer/interface.js +3 -32
  72. package/src/account/default.ts +152 -0
  73. package/src/account/index.ts +2 -0
  74. package/src/account/interface.ts +91 -0
  75. package/src/constants.ts +2 -0
  76. package/src/contract.ts +17 -18
  77. package/src/index.ts +2 -1
  78. package/src/provider/default.ts +141 -110
  79. package/src/provider/interface.ts +36 -52
  80. package/src/provider/utils.ts +60 -13
  81. package/src/signer/default.ts +33 -76
  82. package/src/signer/index.ts +1 -1
  83. package/src/signer/interface.ts +21 -20
  84. package/src/types/api.ts +165 -0
  85. package/src/types/index.ts +3 -0
  86. package/src/types/lib.ts +73 -0
  87. package/src/types/signer.ts +5 -0
  88. package/src/utils/address.ts +23 -0
  89. package/src/utils/number.ts +4 -0
  90. package/types/api.d.ts +152 -0
  91. package/{types.js → types/api.js} +0 -0
  92. package/types/index.d.ts +3 -0
  93. package/types/index.js +28 -0
  94. package/types/lib.d.ts +64 -0
  95. package/types/lib.js +2 -0
  96. package/types/signer.d.ts +4 -0
  97. package/types/signer.js +2 -0
  98. package/utils/address.d.ts +2 -0
  99. package/utils/address.js +22 -0
  100. package/utils/number.d.ts +3 -0
  101. package/utils/number.js +8 -1
  102. package/__tests__/signer.test.ts +0 -119
  103. package/src/types.ts +0 -131
  104. package/types.d.ts +0 -116
@@ -144,6 +144,28 @@ var __generator =
144
144
  return { value: op[0] ? op[1] : void 0, done: true };
145
145
  }
146
146
  };
147
+ var __read =
148
+ (this && this.__read) ||
149
+ function (o, n) {
150
+ var m = typeof Symbol === 'function' && o[Symbol.iterator];
151
+ if (!m) return o;
152
+ var i = m.call(o),
153
+ r,
154
+ ar = [],
155
+ e;
156
+ try {
157
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
158
+ } catch (error) {
159
+ e = { error: error };
160
+ } finally {
161
+ try {
162
+ if (r && !r.done && (m = i['return'])) m.call(i);
163
+ } finally {
164
+ if (e) throw e.error;
165
+ }
166
+ }
167
+ return ar;
168
+ };
147
169
  var __importDefault =
148
170
  (this && this.__importDefault) ||
149
171
  function (mod) {
@@ -162,6 +184,19 @@ function wait(delay) {
162
184
  return setTimeout(res, delay);
163
185
  });
164
186
  }
187
+ function isEmptyQueryObject(obj) {
188
+ return (
189
+ obj === undefined ||
190
+ Object.keys(obj).length === 0 ||
191
+ (Object.keys(obj).length === 1 &&
192
+ Object.entries(obj).every(function (_a) {
193
+ var _b = __read(_a, 2),
194
+ k = _b[0],
195
+ v = _b[1];
196
+ return k === 'blockIdentifier' && v === null;
197
+ }))
198
+ );
199
+ }
165
200
  var Provider = /** @class */ (function () {
166
201
  function Provider(optionsOrProvider) {
167
202
  if (optionsOrProvider === void 0) {
@@ -190,6 +225,83 @@ var Provider = /** @class */ (function () {
190
225
  return 'https://alpha4.starknet.io';
191
226
  }
192
227
  };
228
+ Provider.prototype.getFetchUrl = function (endpoint) {
229
+ var gatewayUrlEndpoints = ['add_transaction'];
230
+ return gatewayUrlEndpoints.includes(endpoint) ? this.gatewayUrl : this.feederGatewayUrl;
231
+ };
232
+ Provider.prototype.getFetchMethod = function (endpoint) {
233
+ var postMethodEndpoints = ['add_transaction', 'call_contract'];
234
+ return postMethodEndpoints.includes(endpoint) ? 'POST' : 'GET';
235
+ };
236
+ Provider.prototype.getQueryString = function (query) {
237
+ if (isEmptyQueryObject(query)) {
238
+ return '';
239
+ }
240
+ var queryString = Object.entries(query)
241
+ .map(function (_a) {
242
+ var _b = __read(_a, 2),
243
+ key = _b[0],
244
+ value = _b[1];
245
+ if (key === 'blockIdentifier') {
246
+ return '' + (0, utils_1.getFormattedBlockIdentifier)(value);
247
+ }
248
+ return key + '=' + value;
249
+ })
250
+ .join('&');
251
+ return '?' + queryString;
252
+ };
253
+ Provider.prototype.getHeaders = function (method) {
254
+ if (method === 'POST') {
255
+ return {
256
+ 'Content-Type': 'application/json',
257
+ };
258
+ }
259
+ return undefined;
260
+ };
261
+ // typesafe fetch
262
+ Provider.prototype.fetchEndpoint = function (endpoint) {
263
+ // typescript type magiuc to create a nice fitting function interface
264
+ var _a = []; // when both query and request are needed, we cant omit anything
265
+ for (
266
+ // typescript type magiuc to create a nice fitting function interface
267
+ var _i = 1; // when both query and request are needed, we cant omit anything
268
+ // typescript type magiuc to create a nice fitting function interface
269
+ _i < arguments.length; // when both query and request are needed, we cant omit anything
270
+ // typescript type magiuc to create a nice fitting function interface
271
+ _i++ // when both query and request are needed, we cant omit anything
272
+ ) {
273
+ // typescript type magiuc to create a nice fitting function interface
274
+ _a[_i - 1] = arguments[_i]; // when both query and request are needed, we cant omit anything
275
+ }
276
+ // typescript type magiuc to create a nice fitting function interface
277
+ var _b = __read(_a, 2),
278
+ query = _b[0],
279
+ request = _b[1]; // when both query and request are needed, we cant omit anything
280
+ return __awaiter(this, void 0, void 0, function () {
281
+ var baseUrl, method, queryString, headers, data;
282
+ return __generator(this, function (_c) {
283
+ switch (_c.label) {
284
+ case 0:
285
+ baseUrl = this.getFetchUrl(endpoint);
286
+ method = this.getFetchMethod(endpoint);
287
+ queryString = this.getQueryString(query);
288
+ headers = this.getHeaders(method);
289
+ return [
290
+ 4 /*yield*/,
291
+ axios_1.default.request({
292
+ method: method,
293
+ url: (0, url_join_1.default)(baseUrl, endpoint, queryString),
294
+ data: (0, json_1.stringify)(request),
295
+ headers: headers,
296
+ }),
297
+ ];
298
+ case 1:
299
+ data = _c.sent().data;
300
+ return [2 /*return*/, data];
301
+ }
302
+ });
303
+ });
304
+ };
193
305
  /**
194
306
  * Gets the smart contract address on the goerli testnet.
195
307
  *
@@ -198,20 +310,8 @@ var Provider = /** @class */ (function () {
198
310
  */
199
311
  Provider.prototype.getContractAddresses = function () {
200
312
  return __awaiter(this, void 0, void 0, function () {
201
- var data;
202
313
  return __generator(this, function (_a) {
203
- switch (_a.label) {
204
- case 0:
205
- return [
206
- 4 /*yield*/,
207
- axios_1.default.get(
208
- (0, url_join_1.default)(this.feederGatewayUrl, 'get_contract_addresses')
209
- ),
210
- ];
211
- case 1:
212
- data = _a.sent().data;
213
- return [2 /*return*/, data];
214
- }
314
+ return [2 /*return*/, this.fetchEndpoint('get_contract_addresses')];
215
315
  });
216
316
  });
217
317
  };
@@ -225,34 +325,31 @@ var Provider = /** @class */ (function () {
225
325
  * @param blockNumber
226
326
  * @returns the result of the function on the smart contract.
227
327
  */
228
- Provider.prototype.callContract = function (invokeTransaction, blockHash, blockNumber) {
229
- if (blockNumber === void 0) {
230
- blockNumber = null;
328
+ Provider.prototype.callContract = function (_a, blockIdentifier) {
329
+ var contractAddress = _a.contractAddress,
330
+ entrypoint = _a.entrypoint,
331
+ _b = _a.calldata,
332
+ calldata = _b === void 0 ? [] : _b;
333
+ if (blockIdentifier === void 0) {
334
+ blockIdentifier = null;
231
335
  }
232
336
  return __awaiter(this, void 0, void 0, function () {
233
- var formattedBlockIdentifier, data;
234
- return __generator(this, function (_a) {
235
- switch (_a.label) {
236
- case 0:
237
- formattedBlockIdentifier = (0, utils_1.getFormattedBlockIdentifier)(
238
- blockHash,
239
- blockNumber
240
- );
241
- return [
242
- 4 /*yield*/,
243
- axios_1.default.post(
244
- (0, url_join_1.default)(
245
- this.feederGatewayUrl,
246
- 'call_contract',
247
- formattedBlockIdentifier
248
- ),
249
- __assign({ signature: [], calldata: [] }, invokeTransaction)
250
- ),
251
- ];
252
- case 1:
253
- data = _a.sent().data;
254
- return [2 /*return*/, data];
255
- }
337
+ return __generator(this, function (_c) {
338
+ return [
339
+ 2 /*return*/,
340
+ this.fetchEndpoint(
341
+ 'call_contract',
342
+ {
343
+ blockIdentifier: blockIdentifier,
344
+ },
345
+ {
346
+ signature: [],
347
+ contract_address: contractAddress,
348
+ entry_point_selector: (0, stark_1.getSelectorFromName)(entrypoint),
349
+ calldata: calldata,
350
+ }
351
+ ),
352
+ ];
256
353
  });
257
354
  });
258
355
  };
@@ -265,33 +362,16 @@ var Provider = /** @class */ (function () {
265
362
  * @param blockNumber
266
363
  * @returns the block object { block_number, previous_block_number, state_root, status, timestamp, transaction_receipts, transactions }
267
364
  */
268
- Provider.prototype.getBlock = function (blockHash, blockNumber) {
269
- if (blockNumber === void 0) {
270
- blockNumber = null;
365
+ Provider.prototype.getBlock = function (blockIdentifier) {
366
+ if (blockIdentifier === void 0) {
367
+ blockIdentifier = null;
271
368
  }
272
369
  return __awaiter(this, void 0, void 0, function () {
273
- var formattedBlockIdentifier, data;
274
370
  return __generator(this, function (_a) {
275
- switch (_a.label) {
276
- case 0:
277
- formattedBlockIdentifier = (0, utils_1.getFormattedBlockIdentifier)(
278
- blockHash,
279
- blockNumber
280
- );
281
- return [
282
- 4 /*yield*/,
283
- axios_1.default.get(
284
- (0, url_join_1.default)(
285
- this.feederGatewayUrl,
286
- 'get_block',
287
- formattedBlockIdentifier
288
- )
289
- ),
290
- ];
291
- case 1:
292
- data = _a.sent().data;
293
- return [2 /*return*/, data];
294
- }
371
+ return [
372
+ 2 /*return*/,
373
+ this.fetchEndpoint('get_block', { blockIdentifier: blockIdentifier }),
374
+ ];
295
375
  });
296
376
  });
297
377
  };
@@ -305,33 +385,19 @@ var Provider = /** @class */ (function () {
305
385
  * @param blockNumber
306
386
  * @returns Bytecode and ABI of compiled contract
307
387
  */
308
- Provider.prototype.getCode = function (contractAddress, blockHash, blockNumber) {
309
- if (blockNumber === void 0) {
310
- blockNumber = null;
388
+ Provider.prototype.getCode = function (contractAddress, blockIdentifier) {
389
+ if (blockIdentifier === void 0) {
390
+ blockIdentifier = null;
311
391
  }
312
392
  return __awaiter(this, void 0, void 0, function () {
313
- var formattedBlockIdentifier, data;
314
393
  return __generator(this, function (_a) {
315
- switch (_a.label) {
316
- case 0:
317
- formattedBlockIdentifier = (0, utils_1.getFormattedBlockIdentifier)(
318
- blockHash,
319
- blockNumber
320
- );
321
- return [
322
- 4 /*yield*/,
323
- axios_1.default.get(
324
- (0, url_join_1.default)(
325
- this.feederGatewayUrl,
326
- 'get_code',
327
- '?contractAddress=' + contractAddress + '&' + formattedBlockIdentifier
328
- )
329
- ),
330
- ];
331
- case 1:
332
- data = _a.sent().data;
333
- return [2 /*return*/, data];
334
- }
394
+ return [
395
+ 2 /*return*/,
396
+ this.fetchEndpoint('get_code', {
397
+ blockIdentifier: blockIdentifier,
398
+ contractAddress: contractAddress,
399
+ }),
400
+ ];
335
401
  });
336
402
  });
337
403
  };
@@ -347,38 +413,20 @@ var Provider = /** @class */ (function () {
347
413
  * @param blockNumber
348
414
  * @returns the value of the storage variable
349
415
  */
350
- Provider.prototype.getStorageAt = function (contractAddress, key, blockHash, blockNumber) {
351
- if (blockNumber === void 0) {
352
- blockNumber = null;
416
+ Provider.prototype.getStorageAt = function (contractAddress, key, blockIdentifier) {
417
+ if (blockIdentifier === void 0) {
418
+ blockIdentifier = null;
353
419
  }
354
420
  return __awaiter(this, void 0, void 0, function () {
355
- var formattedBlockIdentifier, data;
356
421
  return __generator(this, function (_a) {
357
- switch (_a.label) {
358
- case 0:
359
- formattedBlockIdentifier = (0, utils_1.getFormattedBlockIdentifier)(
360
- blockHash,
361
- blockNumber
362
- );
363
- return [
364
- 4 /*yield*/,
365
- axios_1.default.get(
366
- (0, url_join_1.default)(
367
- this.feederGatewayUrl,
368
- 'get_storage_at',
369
- '?contractAddress=' +
370
- contractAddress +
371
- '&key=' +
372
- key +
373
- '&' +
374
- formattedBlockIdentifier
375
- )
376
- ),
377
- ];
378
- case 1:
379
- data = _a.sent().data;
380
- return [2 /*return*/, data];
381
- }
422
+ return [
423
+ 2 /*return*/,
424
+ this.fetchEndpoint('get_storage_at', {
425
+ blockIdentifier: blockIdentifier,
426
+ contractAddress: contractAddress,
427
+ key: key,
428
+ }),
429
+ ];
382
430
  });
383
431
  });
384
432
  };
@@ -392,100 +440,67 @@ var Provider = /** @class */ (function () {
392
440
  */
393
441
  Provider.prototype.getTransactionStatus = function (txHash) {
394
442
  return __awaiter(this, void 0, void 0, function () {
395
- var txHashBn, data;
443
+ var txHashHex;
396
444
  return __generator(this, function (_a) {
397
- switch (_a.label) {
398
- case 0:
399
- txHashBn = (0, number_1.toBN)(txHash);
400
- return [
401
- 4 /*yield*/,
402
- axios_1.default.get(
403
- (0, url_join_1.default)(
404
- this.feederGatewayUrl,
405
- 'get_transaction_status',
406
- '?transactionHash=' + (0, number_1.toHex)(txHashBn)
407
- )
408
- ),
409
- ];
410
- case 1:
411
- data = _a.sent().data;
412
- return [2 /*return*/, data];
413
- }
445
+ txHashHex = (0, number_1.toHex)((0, number_1.toBN)(txHash));
446
+ return [
447
+ 2 /*return*/,
448
+ this.fetchEndpoint('get_transaction_status', { transactionHash: txHashHex }),
449
+ ];
414
450
  });
415
451
  });
416
452
  };
417
453
  /**
418
- * Gets the transaction information from a tx id.
454
+ * Gets the transaction receipt from a tx hash or tx id.
419
455
  *
420
- * [Reference](https://github.com/starkware-libs/cairo-lang/blob/f464ec4797361b6be8989e36e02ec690e74ef285/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L54-L58)
456
+ * [Reference] (https://github.com/starkware-libs/cairo-lang/blob/master/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L104-L111)
421
457
  *
422
458
  * @param txHash
423
- * @returns the transacton object { transaction_id, status, transaction, block_number?, block_number?, transaction_index?, transaction_failure_reason? }
459
+ * @param txId
460
+ * @returns the transaction receipt object
424
461
  */
425
- Provider.prototype.getTransaction = function (txHash) {
462
+ Provider.prototype.getTransactionReceipt = function (_a) {
463
+ var txHash = _a.txHash,
464
+ txId = _a.txId;
426
465
  return __awaiter(this, void 0, void 0, function () {
427
- var txHashBn, data;
428
- return __generator(this, function (_a) {
429
- switch (_a.label) {
466
+ var data;
467
+ return __generator(this, function (_b) {
468
+ switch (_b.label) {
430
469
  case 0:
431
- txHashBn = (0, number_1.toBN)(txHash);
432
470
  return [
433
471
  4 /*yield*/,
434
472
  axios_1.default.get(
435
473
  (0, url_join_1.default)(
436
474
  this.feederGatewayUrl,
437
- 'get_transaction',
438
- '?transactionHash=' + (0, number_1.toHex)(txHashBn)
475
+ 'get_transaction_receipt',
476
+ '?' + (0, utils_1.txIdentifier)(txHash, txId)
439
477
  )
440
478
  ),
441
479
  ];
442
480
  case 1:
443
- data = _a.sent().data;
481
+ data = _b.sent().data;
444
482
  return [2 /*return*/, data];
445
483
  }
446
484
  });
447
485
  });
448
486
  };
449
487
  /**
450
- * Invoke a function on the starknet contract
488
+ * Gets the transaction information from a tx id.
451
489
  *
452
- * [Reference](https://github.com/starkware-libs/cairo-lang/blob/f464ec4797361b6be8989e36e02ec690e74ef285/src/starkware/starknet/services/api/gateway/gateway_client.py#L13-L17)
490
+ * [Reference](https://github.com/starkware-libs/cairo-lang/blob/f464ec4797361b6be8989e36e02ec690e74ef285/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L54-L58)
453
491
  *
454
- * @param transaction - transaction to be invoked
455
- * @returns a confirmation of invoking a function on the starknet contract
492
+ * @param txHash
493
+ * @returns the transacton object { transaction_id, status, transaction, block_number?, block_number?, transaction_index?, transaction_failure_reason? }
456
494
  */
457
- Provider.prototype.addTransaction = function (transaction) {
495
+ Provider.prototype.getTransaction = function (txHash) {
458
496
  return __awaiter(this, void 0, void 0, function () {
459
- var signature, contract_address_salt, data;
497
+ var txHashHex;
460
498
  return __generator(this, function (_a) {
461
- switch (_a.label) {
462
- case 0:
463
- signature =
464
- transaction.type === 'INVOKE_FUNCTION' &&
465
- (0, stark_1.formatSignature)(transaction.signature);
466
- contract_address_salt =
467
- transaction.type === 'DEPLOY' &&
468
- (0, number_1.toHex)((0, number_1.toBN)(transaction.contract_address_salt));
469
- return [
470
- 4 /*yield*/,
471
- axios_1.default.post(
472
- (0, url_join_1.default)(this.gatewayUrl, 'add_transaction'),
473
- (0, json_1.stringify)(
474
- __assign(
475
- __assign(
476
- __assign({}, transaction),
477
- Array.isArray(signature) && { signature: signature }
478
- ),
479
- contract_address_salt && { contract_address_salt: contract_address_salt }
480
- )
481
- ),
482
- { headers: { 'Content-Type': 'application/json' } }
483
- ),
484
- ];
485
- case 1:
486
- data = _a.sent().data;
487
- return [2 /*return*/, data];
488
- }
499
+ txHashHex = (0, number_1.toHex)((0, number_1.toBN)(txHash));
500
+ return [
501
+ 2 /*return*/,
502
+ this.fetchEndpoint('get_transaction', { transactionHash: txHashHex }),
503
+ ];
489
504
  });
490
505
  });
491
506
  };
@@ -496,26 +511,26 @@ var Provider = /** @class */ (function () {
496
511
  * @param address - (optional, defaults to a random address) the address where the contract should be deployed (alpha)
497
512
  * @returns a confirmation of sending a transaction on the starknet contract
498
513
  */
499
- Provider.prototype.deployContract = function (contract, constructorCalldata, addressSalt) {
500
- if (constructorCalldata === void 0) {
501
- constructorCalldata = [];
502
- }
503
- if (addressSalt === void 0) {
504
- addressSalt = (0, stark_1.randomAddress)();
505
- }
506
- var parsedContract = typeof contract === 'string' ? (0, json_1.parse)(contract) : contract;
514
+ Provider.prototype.deployContract = function (payload, _abi) {
515
+ var _a, _b;
516
+ var parsedContract =
517
+ typeof payload.contract === 'string' ? (0, json_1.parse)(payload.contract) : payload.contract;
507
518
  var contractDefinition = __assign(__assign({}, parsedContract), {
508
519
  program: (0, stark_1.compressProgram)(parsedContract.program),
509
520
  });
510
- return this.addTransaction({
521
+ return this.fetchEndpoint('add_transaction', undefined, {
511
522
  type: 'DEPLOY',
512
- contract_address_salt: addressSalt,
513
- constructor_calldata: constructorCalldata,
523
+ contract_address_salt:
524
+ (_a = payload.addressSalt) !== null && _a !== void 0 ? _a : (0, stark_1.randomAddress)(),
525
+ constructor_calldata: (0, number_1.bigNumberishArrayToDecimalStringArray)(
526
+ (_b = payload.constructorCalldata) !== null && _b !== void 0 ? _b : []
527
+ ),
514
528
  contract_definition: contractDefinition,
515
529
  });
516
530
  };
517
531
  /**
518
532
  * Invokes a function on starknet
533
+ * @deprecated This method wont be supported as soon as fees are mandatory
519
534
  *
520
535
  * @param contractAddress - target contract address for invoke
521
536
  * @param entrypointSelector - target entrypoint selector for
@@ -523,18 +538,18 @@ var Provider = /** @class */ (function () {
523
538
  * @param signature - (optional) signature to send along
524
539
  * @returns response from addTransaction
525
540
  */
526
- Provider.prototype.invokeFunction = function (
527
- contractAddress,
528
- entrypointSelector,
529
- calldata,
530
- signature
531
- ) {
532
- return this.addTransaction({
541
+ Provider.prototype.invokeFunction = function (invocation, _abi) {
542
+ var _a, _b;
543
+ return this.fetchEndpoint('add_transaction', undefined, {
533
544
  type: 'INVOKE_FUNCTION',
534
- contract_address: contractAddress,
535
- entry_point_selector: entrypointSelector,
536
- calldata: calldata,
537
- signature: signature,
545
+ contract_address: invocation.contractAddress,
546
+ entry_point_selector: (0, stark_1.getSelectorFromName)(invocation.entrypoint),
547
+ calldata: (0, number_1.bigNumberishArrayToDecimalStringArray)(
548
+ (_a = invocation.calldata) !== null && _a !== void 0 ? _a : []
549
+ ),
550
+ signature: (0, number_1.bigNumberishArrayToDecimalStringArray)(
551
+ (_b = invocation.signature) !== null && _b !== void 0 ? _b : []
552
+ ),
538
553
  });
539
554
  };
540
555
  Provider.prototype.waitForTx = function (txHash, retryInterval) {