starknet 11.9.1 → 11.9.3

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.mjs CHANGED
@@ -840,17 +840,21 @@ function tryToBigInt(value) {
840
840
  return value ? BigInt(value) : void 0;
841
841
  }
842
842
  function toHex(value) {
843
- return addHexPrefix(toBigInt(value).toString(16));
843
+ const bn = toBigInt(value);
844
+ if (bn < 0n) {
845
+ throw new Error(`Invalid input: ${bn} is negative, a hex-string cannot hold a sign`);
846
+ }
847
+ return addHexPrefix(bn.toString(16));
844
848
  }
845
849
  var toHexString = toHex;
846
850
  function cleanHex(hex) {
847
851
  return toHex(hex);
848
852
  }
849
853
  function toStorageKey(number) {
850
- return addHexPrefix(toBigInt(number).toString(16).padStart(64, "0"));
854
+ return addHexPrefix(removeHexPrefix(toHex(number)).padStart(64, "0"));
851
855
  }
852
856
  function toHex64(number) {
853
- const res = addHexPrefix(toBigInt(number).toString(16).padStart(64, "0"));
857
+ const res = addHexPrefix(removeHexPrefix(toHex(number)).padStart(64, "0"));
854
858
  if (res.length !== 66) throw TypeError("number is too big for hex 0x(64) representation");
855
859
  return res;
856
860
  }
@@ -16013,14 +16017,16 @@ function identifyRevision({ types, domain }) {
16013
16017
  return void 0;
16014
16018
  }
16015
16019
  function getHex(value) {
16020
+ let bn;
16016
16021
  try {
16017
- return toHex(value);
16022
+ bn = toBigInt(value);
16018
16023
  } catch (e) {
16019
16024
  if (isString(value)) {
16020
16025
  return toHex(CairoBytes31.fromText(value).toBigInt());
16021
16026
  }
16022
16027
  throw new Error(`Invalid BigNumberish: ${value}`);
16023
16028
  }
16029
+ return toHex(bn);
16024
16030
  }
16025
16031
  function validateTypedData(data) {
16026
16032
  const typedData = data;
@@ -18103,8 +18109,15 @@ var RpcProvider = class {
18103
18109
  }
18104
18110
  if (isSierra(contractClass)) {
18105
18111
  if (compiler) {
18106
- const abiTest = getAbiContractVersion(contractClass.abi);
18107
- return { cairo: "1", compiler: abiTest.compiler };
18112
+ try {
18113
+ const program = contractClass.sierra_program;
18114
+ const firstFelt = BigInt(program[0]);
18115
+ if (firstFelt === utf8ToBigInt("0.1.0")) return { cairo: "1", compiler: "1" };
18116
+ const compilerMajor = BigInt(program[3]);
18117
+ if (firstFelt === 1n && compilerMajor === 1n) return { cairo: "1", compiler: "1" };
18118
+ if (firstFelt === 1n && compilerMajor === 2n) return { cairo: "1", compiler: "2" };
18119
+ } catch {
18120
+ }
18108
18121
  }
18109
18122
  return { cairo: "1", compiler: void 0 };
18110
18123
  }