starknet 5.14.0 → 5.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -55,19 +55,25 @@ __export(src_exports, {
55
55
  buildUrl: () => buildUrl,
56
56
  cairo: () => cairo_exports,
57
57
  constants: () => constants_exports,
58
+ contractClassResponseToLegacyCompiledContract: () => contractClassResponseToLegacyCompiledContract,
58
59
  defaultProvider: () => defaultProvider,
59
60
  ec: () => ec_exports,
60
61
  encode: () => encode_exports,
62
+ extractContractHashes: () => extractContractHashes,
61
63
  fixProto: () => fixProto,
62
64
  fixStack: () => fixStack,
63
65
  getCalldata: () => getCalldata,
64
66
  getChecksumAddress: () => getChecksumAddress,
65
67
  hash: () => hash_exports,
68
+ isSierra: () => isSierra,
66
69
  isUrl: () => isUrl,
67
70
  json: () => json_exports,
68
71
  merkle: () => merkle_exports,
69
72
  num: () => num_exports,
70
73
  number: () => number,
74
+ parseUDCEvent: () => parseUDCEvent,
75
+ provider: () => provider_exports,
76
+ selector: () => selector_exports,
71
77
  shortString: () => shortString_exports,
72
78
  splitArgsAndOptions: () => splitArgsAndOptions,
73
79
  stark: () => stark_exports,
@@ -2400,6 +2406,13 @@ function hexToBytes(value) {
2400
2406
  }
2401
2407
 
2402
2408
  // src/utils/selector.ts
2409
+ var selector_exports = {};
2410
+ __export(selector_exports, {
2411
+ getSelector: () => getSelector,
2412
+ getSelectorFromName: () => getSelectorFromName,
2413
+ keccakBn: () => keccakBn,
2414
+ starknetKeccak: () => starknetKeccak
2415
+ });
2403
2416
  var import_micro_starknet = require("micro-starknet");
2404
2417
  function keccakBn(value) {
2405
2418
  const hexWithoutPrefix = removeHexPrefix(toHex(BigInt(value)));
@@ -3616,34 +3629,6 @@ function computeContractClassHash(contract) {
3616
3629
  return computeLegacyContractClassHash(compiledContract);
3617
3630
  }
3618
3631
 
3619
- // src/utils/contract.ts
3620
- function isSierra(contract) {
3621
- const compiledContract = typeof contract === "string" ? parse2(contract) : contract;
3622
- return "sierra_program" in compiledContract;
3623
- }
3624
- function extractContractHashes(payload) {
3625
- const response = { ...payload };
3626
- if (isSierra(payload.contract)) {
3627
- if (!payload.compiledClassHash && payload.casm) {
3628
- response.compiledClassHash = computeCompiledClassHash(payload.casm);
3629
- }
3630
- if (!response.compiledClassHash)
3631
- throw new Error(
3632
- "Extract compiledClassHash failed, provide (CairoAssembly).casm file or compiledClassHash"
3633
- );
3634
- }
3635
- response.classHash = payload.classHash ?? computeContractClassHash(payload.contract);
3636
- if (!response.classHash)
3637
- throw new Error("Extract classHash failed, provide (CompiledContract).json file or classHash");
3638
- return response;
3639
- }
3640
-
3641
- // src/utils/fetchPonyfill.ts
3642
- var import_isomorphic_fetch = __toESM(require("isomorphic-fetch"));
3643
- var fetchPonyfill_default = typeof window !== "undefined" && window.fetch || // use buildin fetch in browser if available
3644
- typeof global !== "undefined" && global.fetch || // use buildin fetch in node, react-native and service worker if available
3645
- import_isomorphic_fetch.default;
3646
-
3647
3632
  // src/utils/stark.ts
3648
3633
  var stark_exports = {};
3649
3634
  __export(stark_exports, {
@@ -3700,7 +3685,48 @@ function estimatedFeeToMaxFee(estimatedFee, overhead = 0.5) {
3700
3685
  return toBigInt(estimatedFee) * toBigInt(overHeadPercent) / 100n;
3701
3686
  }
3702
3687
 
3688
+ // src/utils/contract.ts
3689
+ function isSierra(contract) {
3690
+ const compiledContract = typeof contract === "string" ? parse2(contract) : contract;
3691
+ return "sierra_program" in compiledContract;
3692
+ }
3693
+ function extractContractHashes(payload) {
3694
+ const response = { ...payload };
3695
+ if (isSierra(payload.contract)) {
3696
+ if (!payload.compiledClassHash && payload.casm) {
3697
+ response.compiledClassHash = computeCompiledClassHash(payload.casm);
3698
+ }
3699
+ if (!response.compiledClassHash)
3700
+ throw new Error(
3701
+ "Extract compiledClassHash failed, provide (CairoAssembly).casm file or compiledClassHash"
3702
+ );
3703
+ }
3704
+ response.classHash = payload.classHash ?? computeContractClassHash(payload.contract);
3705
+ if (!response.classHash)
3706
+ throw new Error("Extract classHash failed, provide (CompiledContract).json file or classHash");
3707
+ return response;
3708
+ }
3709
+ function contractClassResponseToLegacyCompiledContract(ccr) {
3710
+ if (isSierra(ccr)) {
3711
+ throw Error("ContractClassResponse need to be LegacyContractClass (cairo0 response class)");
3712
+ }
3713
+ const contract = ccr;
3714
+ return { ...contract, program: decompressProgram(contract.program) };
3715
+ }
3716
+
3717
+ // src/utils/fetchPonyfill.ts
3718
+ var import_isomorphic_fetch = __toESM(require("isomorphic-fetch"));
3719
+ var fetchPonyfill_default = typeof window !== "undefined" && window.fetch || // use buildin fetch in browser if available
3720
+ typeof global !== "undefined" && global.fetch || // use buildin fetch in node, react-native and service worker if available
3721
+ import_isomorphic_fetch.default;
3722
+
3703
3723
  // src/utils/provider.ts
3724
+ var provider_exports = {};
3725
+ __export(provider_exports, {
3726
+ createSierraContractClass: () => createSierraContractClass,
3727
+ parseContract: () => parseContract,
3728
+ wait: () => wait
3729
+ });
3704
3730
  function wait(delay) {
3705
3731
  return new Promise((res) => {
3706
3732
  setTimeout(res, delay);
@@ -3719,7 +3745,6 @@ function parseContract(contract) {
3719
3745
  if (!isSierra(contract)) {
3720
3746
  return {
3721
3747
  ...parsedContract,
3722
- // TODO: Why do we gzip program object?
3723
3748
  ..."program" in parsedContract && { program: compressProgram(parsedContract.program) }
3724
3749
  };
3725
3750
  }
@@ -4211,14 +4236,13 @@ var RpcProvider = class {
4211
4236
  }
4212
4237
  async declareContract({ contract, signature, senderAddress, compiledClassHash }, details) {
4213
4238
  if (!isSierra(contract)) {
4214
- const legacyContract = contract;
4215
4239
  return this.fetchEndpoint("starknet_addDeclareTransaction", {
4216
4240
  declare_transaction: {
4217
4241
  type: RPC.TransactionType.DECLARE,
4218
4242
  contract_class: {
4219
- program: legacyContract.program,
4220
- entry_points_by_type: legacyContract.entry_points_by_type,
4221
- abi: legacyContract.abi
4243
+ program: contract.program,
4244
+ entry_points_by_type: contract.entry_points_by_type,
4245
+ abi: contract.abi
4222
4246
  },
4223
4247
  version: toHex(transactionVersion),
4224
4248
  max_fee: toHex(details.maxFee || 0),
@@ -4228,15 +4252,14 @@ var RpcProvider = class {
4228
4252
  }
4229
4253
  });
4230
4254
  }
4231
- const sierraContract = contract;
4232
4255
  return this.fetchEndpoint("starknet_addDeclareTransaction", {
4233
4256
  declare_transaction: {
4234
4257
  type: RPC.TransactionType.DECLARE,
4235
4258
  contract_class: {
4236
- sierra_program: decompressProgram(sierraContract.sierra_program),
4237
- contract_class_version: sierraContract.contract_class_version,
4238
- entry_points_by_type: sierraContract.entry_points_by_type,
4239
- abi: sierraContract.abi
4259
+ sierra_program: decompressProgram(contract.sierra_program),
4260
+ contract_class_version: contract.contract_class_version,
4261
+ entry_points_by_type: contract.entry_points_by_type,
4262
+ abi: contract.abi
4240
4263
  },
4241
4264
  compiled_class_hash: compiledClassHash || "",
4242
4265
  version: toHex(transactionVersion_2),
@@ -6410,19 +6433,25 @@ var number = num_exports;
6410
6433
  buildUrl,
6411
6434
  cairo,
6412
6435
  constants,
6436
+ contractClassResponseToLegacyCompiledContract,
6413
6437
  defaultProvider,
6414
6438
  ec,
6415
6439
  encode,
6440
+ extractContractHashes,
6416
6441
  fixProto,
6417
6442
  fixStack,
6418
6443
  getCalldata,
6419
6444
  getChecksumAddress,
6420
6445
  hash,
6446
+ isSierra,
6421
6447
  isUrl,
6422
6448
  json,
6423
6449
  merkle,
6424
6450
  num,
6425
6451
  number,
6452
+ parseUDCEvent,
6453
+ provider,
6454
+ selector,
6426
6455
  shortString,
6427
6456
  splitArgsAndOptions,
6428
6457
  stark,