starknet 5.13.2 → 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.
@@ -637,19 +637,25 @@ var starknet = (() => {
637
637
  buildUrl: () => buildUrl,
638
638
  cairo: () => cairo_exports,
639
639
  constants: () => constants_exports,
640
+ contractClassResponseToLegacyCompiledContract: () => contractClassResponseToLegacyCompiledContract,
640
641
  defaultProvider: () => defaultProvider,
641
642
  ec: () => ec_exports,
642
643
  encode: () => encode_exports,
644
+ extractContractHashes: () => extractContractHashes,
643
645
  fixProto: () => fixProto,
644
646
  fixStack: () => fixStack,
645
647
  getCalldata: () => getCalldata,
646
648
  getChecksumAddress: () => getChecksumAddress,
647
649
  hash: () => hash_exports,
650
+ isSierra: () => isSierra,
648
651
  isUrl: () => isUrl,
649
652
  json: () => json_exports,
650
653
  merkle: () => merkle_exports,
651
654
  num: () => num_exports,
652
655
  number: () => number2,
656
+ parseUDCEvent: () => parseUDCEvent,
657
+ provider: () => provider_exports,
658
+ selector: () => selector_exports,
653
659
  shortString: () => shortString_exports,
654
660
  splitArgsAndOptions: () => splitArgsAndOptions,
655
661
  stark: () => stark_exports,
@@ -3185,6 +3191,15 @@ var starknet = (() => {
3185
3191
  return hexToBytes(adaptedValue);
3186
3192
  }
3187
3193
 
3194
+ // src/utils/selector.ts
3195
+ var selector_exports = {};
3196
+ __export(selector_exports, {
3197
+ getSelector: () => getSelector,
3198
+ getSelectorFromName: () => getSelectorFromName,
3199
+ keccakBn: () => keccakBn,
3200
+ starknetKeccak: () => starknetKeccak
3201
+ });
3202
+
3188
3203
  // node_modules/micro-starknet/lib/esm/index.js
3189
3204
  var esm_exports = {};
3190
3205
  __export(esm_exports, {
@@ -5613,6 +5628,7 @@ var starknet = (() => {
5613
5628
  Uint: () => Uint,
5614
5629
  felt: () => felt,
5615
5630
  getArrayType: () => getArrayType,
5631
+ isCairo1Abi: () => isCairo1Abi,
5616
5632
  isCairo1Type: () => isCairo1Type,
5617
5633
  isLen: () => isLen,
5618
5634
  isTypeArray: () => isTypeArray,
@@ -5682,6 +5698,19 @@ var starknet = (() => {
5682
5698
  }
5683
5699
  return type.replace("*", "");
5684
5700
  };
5701
+ function isCairo1Abi(abi) {
5702
+ const firstFunction = abi.find((entry) => entry.type === "function");
5703
+ if (!firstFunction) {
5704
+ throw new Error(`Error in ABI. No function in ABI.`);
5705
+ }
5706
+ if (firstFunction.inputs.length) {
5707
+ return isCairo1Type(firstFunction.inputs[0].type);
5708
+ }
5709
+ if (firstFunction.outputs.length) {
5710
+ return isCairo1Type(firstFunction.outputs[0].type);
5711
+ }
5712
+ throw new Error(`Error in ABI. No input/output in function ${firstFunction.name}`);
5713
+ }
5685
5714
  var uint256 = (it) => {
5686
5715
  const bn = BigInt(it);
5687
5716
  if (!isUint256(bn))
@@ -7387,34 +7416,6 @@ var starknet = (() => {
7387
7416
  return computeLegacyContractClassHash(compiledContract);
7388
7417
  }
7389
7418
 
7390
- // src/utils/contract.ts
7391
- function isSierra(contract) {
7392
- const compiledContract = typeof contract === "string" ? parse2(contract) : contract;
7393
- return "sierra_program" in compiledContract;
7394
- }
7395
- function extractContractHashes(payload) {
7396
- const response = { ...payload };
7397
- if (isSierra(payload.contract)) {
7398
- if (!payload.compiledClassHash && payload.casm) {
7399
- response.compiledClassHash = computeCompiledClassHash(payload.casm);
7400
- }
7401
- if (!response.compiledClassHash)
7402
- throw new Error(
7403
- "Extract compiledClassHash failed, provide (CairoAssembly).casm file or compiledClassHash"
7404
- );
7405
- }
7406
- response.classHash = payload.classHash ?? computeContractClassHash(payload.contract);
7407
- if (!response.classHash)
7408
- throw new Error("Extract classHash failed, provide (CompiledContract).json file or classHash");
7409
- return response;
7410
- }
7411
-
7412
- // src/utils/fetchPonyfill.ts
7413
- var import_isomorphic_fetch = __toESM(require_fetch_npm_browserify());
7414
- var fetchPonyfill_default = typeof window !== "undefined" && window.fetch || // use buildin fetch in browser if available
7415
- typeof global !== "undefined" && global.fetch || // use buildin fetch in node, react-native and service worker if available
7416
- import_isomorphic_fetch.default;
7417
-
7418
7419
  // src/utils/stark.ts
7419
7420
  var stark_exports = {};
7420
7421
  __export(stark_exports, {
@@ -11634,7 +11635,48 @@ var starknet = (() => {
11634
11635
  return toBigInt(estimatedFee) * toBigInt(overHeadPercent) / 100n;
11635
11636
  }
11636
11637
 
11638
+ // src/utils/contract.ts
11639
+ function isSierra(contract) {
11640
+ const compiledContract = typeof contract === "string" ? parse2(contract) : contract;
11641
+ return "sierra_program" in compiledContract;
11642
+ }
11643
+ function extractContractHashes(payload) {
11644
+ const response = { ...payload };
11645
+ if (isSierra(payload.contract)) {
11646
+ if (!payload.compiledClassHash && payload.casm) {
11647
+ response.compiledClassHash = computeCompiledClassHash(payload.casm);
11648
+ }
11649
+ if (!response.compiledClassHash)
11650
+ throw new Error(
11651
+ "Extract compiledClassHash failed, provide (CairoAssembly).casm file or compiledClassHash"
11652
+ );
11653
+ }
11654
+ response.classHash = payload.classHash ?? computeContractClassHash(payload.contract);
11655
+ if (!response.classHash)
11656
+ throw new Error("Extract classHash failed, provide (CompiledContract).json file or classHash");
11657
+ return response;
11658
+ }
11659
+ function contractClassResponseToLegacyCompiledContract(ccr) {
11660
+ if (isSierra(ccr)) {
11661
+ throw Error("ContractClassResponse need to be LegacyContractClass (cairo0 response class)");
11662
+ }
11663
+ const contract = ccr;
11664
+ return { ...contract, program: decompressProgram(contract.program) };
11665
+ }
11666
+
11667
+ // src/utils/fetchPonyfill.ts
11668
+ var import_isomorphic_fetch = __toESM(require_fetch_npm_browserify());
11669
+ var fetchPonyfill_default = typeof window !== "undefined" && window.fetch || // use buildin fetch in browser if available
11670
+ typeof global !== "undefined" && global.fetch || // use buildin fetch in node, react-native and service worker if available
11671
+ import_isomorphic_fetch.default;
11672
+
11637
11673
  // src/utils/provider.ts
11674
+ var provider_exports = {};
11675
+ __export(provider_exports, {
11676
+ createSierraContractClass: () => createSierraContractClass,
11677
+ parseContract: () => parseContract,
11678
+ wait: () => wait
11679
+ });
11638
11680
  function wait(delay) {
11639
11681
  return new Promise((res) => {
11640
11682
  setTimeout(res, delay);
@@ -11653,7 +11695,6 @@ var starknet = (() => {
11653
11695
  if (!isSierra(contract)) {
11654
11696
  return {
11655
11697
  ...parsedContract,
11656
- // TODO: Why do we gzip program object?
11657
11698
  ..."program" in parsedContract && { program: compressProgram(parsedContract.program) }
11658
11699
  };
11659
11700
  }
@@ -12145,14 +12186,13 @@ var starknet = (() => {
12145
12186
  }
12146
12187
  async declareContract({ contract, signature, senderAddress, compiledClassHash }, details) {
12147
12188
  if (!isSierra(contract)) {
12148
- const legacyContract = contract;
12149
12189
  return this.fetchEndpoint("starknet_addDeclareTransaction", {
12150
12190
  declare_transaction: {
12151
12191
  type: RPC.TransactionType.DECLARE,
12152
12192
  contract_class: {
12153
- program: legacyContract.program,
12154
- entry_points_by_type: legacyContract.entry_points_by_type,
12155
- abi: legacyContract.abi
12193
+ program: contract.program,
12194
+ entry_points_by_type: contract.entry_points_by_type,
12195
+ abi: contract.abi
12156
12196
  },
12157
12197
  version: toHex(transactionVersion),
12158
12198
  max_fee: toHex(details.maxFee || 0),
@@ -12162,15 +12202,14 @@ var starknet = (() => {
12162
12202
  }
12163
12203
  });
12164
12204
  }
12165
- const sierraContract = contract;
12166
12205
  return this.fetchEndpoint("starknet_addDeclareTransaction", {
12167
12206
  declare_transaction: {
12168
12207
  type: RPC.TransactionType.DECLARE,
12169
12208
  contract_class: {
12170
- sierra_program: decompressProgram(sierraContract.sierra_program),
12171
- contract_class_version: sierraContract.contract_class_version,
12172
- entry_points_by_type: sierraContract.entry_points_by_type,
12173
- abi: sierraContract.abi
12209
+ sierra_program: decompressProgram(contract.sierra_program),
12210
+ contract_class_version: contract.contract_class_version,
12211
+ entry_points_by_type: contract.entry_points_by_type,
12212
+ abi: contract.abi
12174
12213
  },
12175
12214
  compiled_class_hash: compiledClassHash || "",
12176
12215
  version: toHex(transactionVersion_2),
@@ -14211,6 +14250,9 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
14211
14250
  calldata
14212
14251
  };
14213
14252
  }
14253
+ isCairo1() {
14254
+ return cairo_exports.isCairo1Abi(this.abi);
14255
+ }
14214
14256
  };
14215
14257
 
14216
14258
  // src/contract/interface.ts