starknet 6.6.0 → 6.6.6

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.
@@ -10644,7 +10644,7 @@ var starknet = (() => {
10644
10644
  return typeof data === "function";
10645
10645
  }
10646
10646
  function isNonEmptyString(data) {
10647
- return isString(data) && data !== "";
10647
+ return isString2(data) && data !== "";
10648
10648
  }
10649
10649
  function isDate(data) {
10650
10650
  return isInstanceStrict(data, Date) && isInteger2(data.getTime());
@@ -10652,7 +10652,7 @@ var starknet = (() => {
10652
10652
  function isEmptyString(data) {
10653
10653
  return data === "" || data instanceof String && data.toString() === "";
10654
10654
  }
10655
- function isString(data) {
10655
+ function isString2(data) {
10656
10656
  return typeof data === "string" || data instanceof String;
10657
10657
  }
10658
10658
  function isObject2(data) {
@@ -10693,7 +10693,7 @@ var starknet = (() => {
10693
10693
  exports.isNonEmptyString = isNonEmptyString;
10694
10694
  exports.isDate = isDate;
10695
10695
  exports.isEmptyString = isEmptyString;
10696
- exports.isString = isString;
10696
+ exports.isString = isString2;
10697
10697
  exports.isObject = isObject2;
10698
10698
  exports.validate = validate;
10699
10699
  }
@@ -12681,6 +12681,8 @@ var starknet = (() => {
12681
12681
  CairoOptionVariant: () => CairoOptionVariant,
12682
12682
  CairoResult: () => CairoResult,
12683
12683
  CairoResultVariant: () => CairoResultVariant,
12684
+ CairoUint256: () => CairoUint256,
12685
+ CairoUint512: () => CairoUint512,
12684
12686
  CallData: () => CallData,
12685
12687
  Contract: () => Contract,
12686
12688
  ContractFactory: () => ContractFactory,
@@ -12697,6 +12699,7 @@ var starknet = (() => {
12697
12699
  RPC: () => api_exports,
12698
12700
  RPC06: () => rpc_0_6_exports,
12699
12701
  RPC07: () => rpc_0_7_exports,
12702
+ ReceiptTx: () => ReceiptTx,
12700
12703
  RpcChannel: () => RpcChannel2,
12701
12704
  RpcProvider: () => RpcProvider2,
12702
12705
  SIMULATION_FLAG: () => SIMULATION_FLAG,
@@ -12707,6 +12710,16 @@ var starknet = (() => {
12707
12710
  TransactionStatus: () => TransactionStatus,
12708
12711
  TransactionType: () => TransactionType,
12709
12712
  TypedDataRevision: () => TypedDataRevision,
12713
+ UINT_128_MAX: () => UINT_128_MAX,
12714
+ UINT_128_MIN: () => UINT_128_MIN,
12715
+ UINT_256_HIGH_MAX: () => UINT_256_HIGH_MAX,
12716
+ UINT_256_HIGH_MIN: () => UINT_256_HIGH_MIN,
12717
+ UINT_256_LOW_MAX: () => UINT_256_LOW_MAX,
12718
+ UINT_256_LOW_MIN: () => UINT_256_LOW_MIN,
12719
+ UINT_256_MAX: () => UINT_256_MAX,
12720
+ UINT_256_MIN: () => UINT_256_MIN,
12721
+ UINT_512_MAX: () => UINT_512_MAX,
12722
+ UINT_512_MIN: () => UINT_512_MIN,
12710
12723
  Uint: () => Uint,
12711
12724
  ValidateType: () => ValidateType,
12712
12725
  WalletAccount: () => WalletAccount,
@@ -12774,6 +12787,10 @@ var starknet = (() => {
12774
12787
  MASK_250: () => MASK_250,
12775
12788
  MAX_STORAGE_ITEM_SIZE: () => MAX_STORAGE_ITEM_SIZE,
12776
12789
  NetworkName: () => NetworkName,
12790
+ PRIME: () => PRIME,
12791
+ RANGE_FELT: () => RANGE_FELT,
12792
+ RANGE_I128: () => RANGE_I128,
12793
+ RANGE_U128: () => RANGE_U128,
12777
12794
  RPC_DEFAULT_VERSION: () => RPC_DEFAULT_VERSION,
12778
12795
  RPC_NODES: () => RPC_NODES,
12779
12796
  StarknetChainId: () => StarknetChainId,
@@ -13239,8 +13256,13 @@ var starknet = (() => {
13239
13256
  var ZERO = 0n;
13240
13257
  var MASK_250 = 2n ** 250n - 1n;
13241
13258
  var API_VERSION = ZERO;
13259
+ var PRIME = 2n ** 251n + 17n * 2n ** 192n + 1n;
13242
13260
  var MAX_STORAGE_ITEM_SIZE = 256n;
13243
13261
  var ADDR_BOUND = 2n ** 251n - MAX_STORAGE_ITEM_SIZE;
13262
+ var range = (min, max) => ({ min, max });
13263
+ var RANGE_FELT = range(ZERO, PRIME - 1n);
13264
+ var RANGE_I128 = range(-(2n ** 127n), 2n ** 127n - 1n);
13265
+ var RANGE_U128 = range(ZERO, 2n ** 128n - 1n);
13244
13266
  var BaseUrl = /* @__PURE__ */ ((BaseUrl2) => {
13245
13267
  BaseUrl2["SN_MAIN"] = "https://alpha-mainnet.starknet.io";
13246
13268
  BaseUrl2["SN_GOERLI"] = "https://alpha4.starknet.io";
@@ -13375,11 +13397,13 @@ var starknet = (() => {
13375
13397
  Uint2["u64"] = "core::integer::u64";
13376
13398
  Uint2["u128"] = "core::integer::u128";
13377
13399
  Uint2["u256"] = "core::integer::u256";
13400
+ Uint2["u512"] = "core::integer::u512";
13378
13401
  return Uint2;
13379
13402
  })(Uint || {});
13380
13403
  var Literal = /* @__PURE__ */ ((Literal2) => {
13381
13404
  Literal2["ClassHash"] = "core::starknet::class_hash::ClassHash";
13382
13405
  Literal2["ContractAddress"] = "core::starknet::contract_address::ContractAddress";
13406
+ Literal2["Secp256k1Point"] = "core::starknet::secp256k1::Secp256k1Point";
13383
13407
  return Literal2;
13384
13408
  })(Literal || {});
13385
13409
 
@@ -13462,7 +13486,9 @@ var starknet = (() => {
13462
13486
  hexToBytes: () => hexToBytes2,
13463
13487
  hexToDecimalString: () => hexToDecimalString,
13464
13488
  isBigInt: () => isBigInt,
13489
+ isBoolean: () => isBoolean,
13465
13490
  isHex: () => isHex,
13491
+ isNumber: () => isNumber,
13466
13492
  isStringWholeNumber: () => isStringWholeNumber,
13467
13493
  toBigInt: () => toBigInt,
13468
13494
  toCairoBool: () => toCairoBool,
@@ -13781,6 +13807,12 @@ var starknet = (() => {
13781
13807
  const bigIntNum = BigInt(number3);
13782
13808
  return bigIntNum + bigIntNum * BigInt(percent) / 100n;
13783
13809
  }
13810
+ function isNumber(value) {
13811
+ return typeof value === "number";
13812
+ }
13813
+ function isBoolean(value) {
13814
+ return typeof value === "boolean";
13815
+ }
13784
13816
 
13785
13817
  // src/utils/selector.ts
13786
13818
  var selector_exports = {};
@@ -16148,6 +16180,7 @@ var starknet = (() => {
16148
16180
  isLongText: () => isLongText,
16149
16181
  isShortString: () => isShortString,
16150
16182
  isShortText: () => isShortText,
16183
+ isString: () => isString,
16151
16184
  isText: () => isText,
16152
16185
  splitLongString: () => splitLongString
16153
16186
  });
@@ -16160,8 +16193,11 @@ var starknet = (() => {
16160
16193
  function isDecimalString(str) {
16161
16194
  return /^[0-9]*$/i.test(str);
16162
16195
  }
16196
+ function isString(value) {
16197
+ return typeof value === "string";
16198
+ }
16163
16199
  function isText(val) {
16164
- return typeof val === "string" && !isHex(val) && !isStringWholeNumber(val);
16200
+ return isString(val) && !isHex(val) && !isStringWholeNumber(val);
16165
16201
  }
16166
16202
  var isShortText = (val) => isText(val) && isShortString(val);
16167
16203
  var isLongText = (val) => isText(val) && !isShortString(val);
@@ -16234,34 +16270,38 @@ var starknet = (() => {
16234
16270
  isTypeNamedTuple: () => isTypeNamedTuple,
16235
16271
  isTypeOption: () => isTypeOption,
16236
16272
  isTypeResult: () => isTypeResult,
16273
+ isTypeSecp256k1Point: () => isTypeSecp256k1Point,
16237
16274
  isTypeStruct: () => isTypeStruct,
16238
16275
  isTypeTuple: () => isTypeTuple,
16239
16276
  isTypeUint: () => isTypeUint,
16240
16277
  isTypeUint256: () => isTypeUint256,
16241
16278
  tuple: () => tuple,
16242
- uint256: () => uint256
16279
+ uint256: () => uint256,
16280
+ uint512: () => uint512
16243
16281
  });
16244
16282
 
16245
16283
  // src/utils/cairoDataTypes/felt.ts
16246
16284
  function CairoFelt(it) {
16247
- if (isBigInt(it) || typeof it === "number" && Number.isInteger(it)) {
16285
+ if (isBigInt(it) || Number.isInteger(it)) {
16248
16286
  return it.toString();
16249
16287
  }
16250
- if (isText(it)) {
16251
- if (!isShortString(it))
16252
- throw new Error(
16253
- `${it} is a long string > 31 chars, felt can store short strings, split it to array of short strings`
16254
- );
16255
- const encoded = encodeShortString(it);
16256
- return BigInt(encoded).toString();
16257
- }
16258
- if (typeof it === "string" && isHex(it)) {
16259
- return BigInt(it).toString();
16260
- }
16261
- if (typeof it === "string" && isStringWholeNumber(it)) {
16262
- return it;
16288
+ if (isString(it)) {
16289
+ if (isHex(it)) {
16290
+ return BigInt(it).toString();
16291
+ }
16292
+ if (isText(it)) {
16293
+ if (!isShortString(it)) {
16294
+ throw new Error(
16295
+ `${it} is a long string > 31 chars. Please split it into an array of short strings.`
16296
+ );
16297
+ }
16298
+ return BigInt(encodeShortString(it)).toString();
16299
+ }
16300
+ if (isStringWholeNumber(it)) {
16301
+ return it;
16302
+ }
16263
16303
  }
16264
- if (typeof it === "boolean") {
16304
+ if (isBoolean(it)) {
16265
16305
  return `${+it}`;
16266
16306
  }
16267
16307
  throw new Error(`${it} can't be computed by felt()`);
@@ -16372,6 +16412,130 @@ var starknet = (() => {
16372
16412
  }
16373
16413
  };
16374
16414
 
16415
+ // src/utils/cairoDataTypes/uint512.ts
16416
+ var UINT_512_MAX = (1n << 512n) - 1n;
16417
+ var UINT_512_MIN = 0n;
16418
+ var UINT_128_MIN = 0n;
16419
+ var CairoUint512 = class _CairoUint512 {
16420
+ limb0;
16421
+ limb1;
16422
+ limb2;
16423
+ limb3;
16424
+ static abiSelector = "core::integer::u512";
16425
+ constructor(...arr) {
16426
+ if (typeof arr[0] === "object" && arr.length === 1 && "limb0" in arr[0] && "limb1" in arr[0] && "limb2" in arr[0] && "limb3" in arr[0]) {
16427
+ const props = _CairoUint512.validateProps(
16428
+ arr[0].limb0,
16429
+ arr[0].limb1,
16430
+ arr[0].limb2,
16431
+ arr[0].limb3
16432
+ );
16433
+ this.limb0 = props.limb0;
16434
+ this.limb1 = props.limb1;
16435
+ this.limb2 = props.limb2;
16436
+ this.limb3 = props.limb3;
16437
+ } else if (arr.length === 1) {
16438
+ const bigInt = _CairoUint512.validate(arr[0]);
16439
+ this.limb0 = bigInt & UINT_128_MAX;
16440
+ this.limb1 = (bigInt & UINT_128_MAX << 128n) >> 128n;
16441
+ this.limb2 = (bigInt & UINT_128_MAX << 256n) >> 256n;
16442
+ this.limb3 = bigInt >> 384n;
16443
+ } else if (arr.length === 4) {
16444
+ const props = _CairoUint512.validateProps(arr[0], arr[1], arr[2], arr[3]);
16445
+ this.limb0 = props.limb0;
16446
+ this.limb1 = props.limb1;
16447
+ this.limb2 = props.limb2;
16448
+ this.limb3 = props.limb3;
16449
+ } else {
16450
+ throw Error("Incorrect Uint512 constructor parameters");
16451
+ }
16452
+ }
16453
+ /**
16454
+ * Validate if BigNumberish can be represented as Uint512
16455
+ */
16456
+ static validate(bigNumberish) {
16457
+ const bigInt = BigInt(bigNumberish);
16458
+ if (bigInt < UINT_512_MIN)
16459
+ throw Error("bigNumberish is smaller than UINT_512_MIN.");
16460
+ if (bigInt > UINT_512_MAX)
16461
+ throw Error("bigNumberish is bigger than UINT_512_MAX.");
16462
+ return bigInt;
16463
+ }
16464
+ /**
16465
+ * Validate if limbs can be represented as Uint512
16466
+ */
16467
+ static validateProps(limb0, limb1, limb2, limb3) {
16468
+ const l0 = BigInt(limb0);
16469
+ const l1 = BigInt(limb1);
16470
+ const l2 = BigInt(limb2);
16471
+ const l3 = BigInt(limb3);
16472
+ [l0, l1, l2, l3].forEach((value, index) => {
16473
+ if (value < UINT_128_MIN || value > UINT_128_MAX) {
16474
+ throw Error(`limb${index} is not in the range of a u128 number`);
16475
+ }
16476
+ });
16477
+ return { limb0: l0, limb1: l1, limb2: l2, limb3: l3 };
16478
+ }
16479
+ /**
16480
+ * Check if BigNumberish can be represented as Uint512
16481
+ */
16482
+ static is(bigNumberish) {
16483
+ try {
16484
+ _CairoUint512.validate(bigNumberish);
16485
+ } catch (error2) {
16486
+ return false;
16487
+ }
16488
+ return true;
16489
+ }
16490
+ /**
16491
+ * Check if provided abi type is this data type
16492
+ */
16493
+ static isAbiType(abiType) {
16494
+ return abiType === _CairoUint512.abiSelector;
16495
+ }
16496
+ /**
16497
+ * Return bigint representation
16498
+ */
16499
+ toBigInt() {
16500
+ return (this.limb3 << 384n) + (this.limb2 << 256n) + (this.limb1 << 128n) + this.limb0;
16501
+ }
16502
+ /**
16503
+ * Return Uint512 structure with HexString props
16504
+ * limbx: HexString
16505
+ */
16506
+ toUint512HexString() {
16507
+ return {
16508
+ limb0: addHexPrefix(this.limb0.toString(16)),
16509
+ limb1: addHexPrefix(this.limb1.toString(16)),
16510
+ limb2: addHexPrefix(this.limb2.toString(16)),
16511
+ limb3: addHexPrefix(this.limb3.toString(16))
16512
+ };
16513
+ }
16514
+ /**
16515
+ * Return Uint512 structure with DecimalString props
16516
+ * limbx DecString
16517
+ */
16518
+ toUint512DecimalString() {
16519
+ return {
16520
+ limb0: this.limb0.toString(10),
16521
+ limb1: this.limb1.toString(10),
16522
+ limb2: this.limb2.toString(10),
16523
+ limb3: this.limb3.toString(10)
16524
+ };
16525
+ }
16526
+ /**
16527
+ * Return api requests representation witch is felt array
16528
+ */
16529
+ toApiRequest() {
16530
+ return [
16531
+ CairoFelt(this.limb0),
16532
+ CairoFelt(this.limb1),
16533
+ CairoFelt(this.limb2),
16534
+ CairoFelt(this.limb3)
16535
+ ];
16536
+ }
16537
+ };
16538
+
16375
16539
  // src/utils/calldata/cairo.ts
16376
16540
  var isLen = (name) => /_len$/.test(name);
16377
16541
  var isTypeFelt = (type) => type === "felt" || type === "core::felt252";
@@ -16390,6 +16554,7 @@ var starknet = (() => {
16390
16554
  var isTypeEthAddress = (type) => type === "core::starknet::eth_address::EthAddress";
16391
16555
  var isTypeBytes31 = (type) => type === "core::bytes_31::bytes31";
16392
16556
  var isTypeByteArray = (type) => type === "core::byte_array::ByteArray";
16557
+ var isTypeSecp256k1Point = (type) => type === "core::starknet::secp256k1::Secp256k1Point";
16393
16558
  var isCairo1Type = (type) => type.includes("::");
16394
16559
  var getArrayType = (type) => {
16395
16560
  if (isCairo1Type(type)) {
@@ -16423,6 +16588,9 @@ var starknet = (() => {
16423
16588
  var uint256 = (it) => {
16424
16589
  return new CairoUint256(it).toUint256DecimalString();
16425
16590
  };
16591
+ var uint512 = (it) => {
16592
+ return new CairoUint512(it).toUint512DecimalString();
16593
+ };
16426
16594
  var tuple = (...args) => ({ ...args });
16427
16595
  function felt(it) {
16428
16596
  return CairoFelt(it);
@@ -16827,6 +16995,11 @@ var starknet = (() => {
16827
16995
  `Your object includes the property : ${key}, containing an Uint256 object without the 'low' and 'high' keys.`
16828
16996
  );
16829
16997
  }
16998
+ function errorU512(key) {
16999
+ return Error(
17000
+ `Your object includes the property : ${key}, containing an Uint512 object without the 'limb0' to 'limb3' keys.`
17001
+ );
17002
+ }
16830
17003
  function orderPropsByAbi(unorderedObject, abiOfObject, structs, enums) {
16831
17004
  const orderInput = (unorderedItem, abiType) => {
16832
17005
  if (isTypeArray(abiType)) {
@@ -16845,6 +17018,9 @@ var starknet = (() => {
16845
17018
  if (isTypeByteArray(abiType)) {
16846
17019
  return unorderedItem;
16847
17020
  }
17021
+ if (isTypeSecp256k1Point(abiType)) {
17022
+ return unorderedItem;
17023
+ }
16848
17024
  if (CairoUint256.isAbiType(abiType)) {
16849
17025
  const u256 = unorderedItem;
16850
17026
  if (typeof u256 !== "object") {
@@ -16855,6 +17031,16 @@ var starknet = (() => {
16855
17031
  }
16856
17032
  return { low: u256.low, high: u256.high };
16857
17033
  }
17034
+ if (CairoUint512.isAbiType(abiType)) {
17035
+ const u512 = unorderedItem;
17036
+ if (typeof u512 !== "object") {
17037
+ return u512;
17038
+ }
17039
+ if (!["limb0", "limb1", "limb2", "limb3"].every((key) => key in u512)) {
17040
+ throw errorU512(abiType);
17041
+ }
17042
+ return { limb0: u512.limb0, limb1: u512.limb1, limb2: u512.limb2, limb3: u512.limb3 };
17043
+ }
16858
17044
  if (isTypeStruct(abiType, structs)) {
16859
17045
  const abiOfStruct = structs[abiType].members;
16860
17046
  return orderStruct(unorderedItem, abiOfStruct);
@@ -16879,7 +17065,7 @@ var starknet = (() => {
16879
17065
  };
16880
17066
  function orderArray(myArray, abiParam) {
16881
17067
  const typeInArray = getArrayType(abiParam);
16882
- if (typeof myArray === "string") {
17068
+ if (isString(myArray)) {
16883
17069
  return myArray;
16884
17070
  }
16885
17071
  return myArray.map((myElem) => orderInput(myElem, typeInArray));
@@ -16970,8 +17156,21 @@ var starknet = (() => {
16970
17156
  switch (true) {
16971
17157
  case CairoUint256.isAbiType(type):
16972
17158
  return new CairoUint256(val).toApiRequest();
17159
+ case CairoUint512.isAbiType(type):
17160
+ return new CairoUint512(val).toApiRequest();
16973
17161
  case isTypeBytes31(type):
16974
17162
  return encodeShortString(val.toString());
17163
+ case isTypeSecp256k1Point(type): {
17164
+ const pubKeyETH = removeHexPrefix(toHex(val)).padStart(128, "0");
17165
+ const pubKeyETHy = uint256(addHexPrefix(pubKeyETH.slice(-64)));
17166
+ const pubKeyETHx = uint256(addHexPrefix(pubKeyETH.slice(0, -64)));
17167
+ return [
17168
+ felt(pubKeyETHx.low),
17169
+ felt(pubKeyETHx.high),
17170
+ felt(pubKeyETHy.low),
17171
+ felt(pubKeyETHy.high)
17172
+ ];
17173
+ }
16975
17174
  default:
16976
17175
  return felt(val);
16977
17176
  }
@@ -17018,6 +17217,9 @@ var starknet = (() => {
17018
17217
  if (CairoUint256.isAbiType(type)) {
17019
17218
  return new CairoUint256(element).toApiRequest();
17020
17219
  }
17220
+ if (CairoUint512.isAbiType(type)) {
17221
+ return new CairoUint512(element).toApiRequest();
17222
+ }
17021
17223
  if (type === "core::starknet::eth_address::EthAddress")
17022
17224
  return parseBaseTypes(type, element);
17023
17225
  if (type === "core::byte_array::ByteArray")
@@ -17038,6 +17240,9 @@ var starknet = (() => {
17038
17240
  if (CairoUint256.isAbiType(type)) {
17039
17241
  return new CairoUint256(element).toApiRequest();
17040
17242
  }
17243
+ if (CairoUint512.isAbiType(type)) {
17244
+ return new CairoUint512(element).toApiRequest();
17245
+ }
17041
17246
  if (isTypeEnum(type, enums)) {
17042
17247
  const { variants } = enums[type];
17043
17248
  if (isTypeOption(type)) {
@@ -17130,13 +17335,13 @@ var starknet = (() => {
17130
17335
  if (!Array.isArray(value) && !isText(value)) {
17131
17336
  throw Error(`ABI expected parameter ${name} to be array or long string, got ${value}`);
17132
17337
  }
17133
- if (typeof value === "string") {
17338
+ if (isString(value)) {
17134
17339
  value = splitLongString(value);
17135
17340
  }
17136
17341
  return parseCalldataValue(value, input.type, structs, enums);
17137
17342
  case type === "core::starknet::eth_address::EthAddress":
17138
17343
  return parseBaseTypes(type, value);
17139
- case (isTypeStruct(type, structs) || isTypeTuple(type) || CairoUint256.isAbiType(type)):
17344
+ case (isTypeStruct(type, structs) || isTypeTuple(type) || CairoUint256.isAbiType(type) || CairoUint256.isAbiType(type)):
17140
17345
  return parseCalldataValue(value, type, structs, enums);
17141
17346
  case isTypeEnum(type, enums):
17142
17347
  return parseCalldataValue(
@@ -17161,12 +17366,25 @@ var starknet = (() => {
17161
17366
  const low = it.next().value;
17162
17367
  const high = it.next().value;
17163
17368
  return new CairoUint256(low, high).toBigInt();
17369
+ case CairoUint512.isAbiType(type):
17370
+ const limb0 = it.next().value;
17371
+ const limb1 = it.next().value;
17372
+ const limb2 = it.next().value;
17373
+ const limb3 = it.next().value;
17374
+ return new CairoUint512(limb0, limb1, limb2, limb3).toBigInt();
17164
17375
  case type === "core::starknet::eth_address::EthAddress":
17165
17376
  temp = it.next().value;
17166
17377
  return BigInt(temp);
17167
17378
  case type === "core::bytes_31::bytes31":
17168
17379
  temp = it.next().value;
17169
17380
  return decodeShortString(temp);
17381
+ case isTypeSecp256k1Point(type):
17382
+ const xLow = removeHexPrefix(it.next().value).padStart(32, "0");
17383
+ const xHigh = removeHexPrefix(it.next().value).padStart(32, "0");
17384
+ const yLow = removeHexPrefix(it.next().value).padStart(32, "0");
17385
+ const yHigh = removeHexPrefix(it.next().value).padStart(32, "0");
17386
+ const pubK = BigInt(addHexPrefix(xHigh + xLow + yHigh + yLow));
17387
+ return pubK;
17170
17388
  default:
17171
17389
  temp = it.next().value;
17172
17390
  return BigInt(temp);
@@ -17181,6 +17399,13 @@ var starknet = (() => {
17181
17399
  const high = responseIterator.next().value;
17182
17400
  return new CairoUint256(low, high).toBigInt();
17183
17401
  }
17402
+ if (CairoUint512.isAbiType(element.type)) {
17403
+ const limb0 = responseIterator.next().value;
17404
+ const limb1 = responseIterator.next().value;
17405
+ const limb2 = responseIterator.next().value;
17406
+ const limb3 = responseIterator.next().value;
17407
+ return new CairoUint512(limb0, limb1, limb2, limb3).toBigInt();
17408
+ }
17184
17409
  if (isTypeByteArray(element.type)) {
17185
17410
  const parsedBytes31Arr = [];
17186
17411
  const bytes31ArrLen = BigInt(responseIterator.next().value);
@@ -17304,10 +17529,10 @@ var starknet = (() => {
17304
17529
  // src/utils/calldata/validate.ts
17305
17530
  var validateFelt = (parameter, input) => {
17306
17531
  assert(
17307
- typeof parameter === "string" || typeof parameter === "number" || typeof parameter === "bigint",
17532
+ isString(parameter) || isNumber(parameter) || isBigInt(parameter),
17308
17533
  `Validate: arg ${input.name} should be a felt typed as (String, Number or BigInt)`
17309
17534
  );
17310
- if (typeof parameter === "string" && !isHex(parameter))
17535
+ if (isString(parameter) && !isHex(parameter))
17311
17536
  return;
17312
17537
  const param = BigInt(parameter.toString(10));
17313
17538
  assert(
@@ -17317,27 +17542,37 @@ var starknet = (() => {
17317
17542
  );
17318
17543
  };
17319
17544
  var validateBytes31 = (parameter, input) => {
17320
- assert(typeof parameter === "string", `Validate: arg ${input.name} should be a string.`);
17545
+ assert(isString(parameter), `Validate: arg ${input.name} should be a string.`);
17321
17546
  assert(
17322
17547
  parameter.length < 32,
17323
17548
  `Validate: arg ${input.name} cairo typed ${input.type} should be a string of less than 32 characters.`
17324
17549
  );
17325
17550
  };
17326
17551
  var validateByteArray = (parameter, input) => {
17327
- assert(typeof parameter === "string", `Validate: arg ${input.name} should be a string.`);
17552
+ assert(isString(parameter), `Validate: arg ${input.name} should be a string.`);
17328
17553
  };
17329
17554
  var validateUint = (parameter, input) => {
17330
- if (typeof parameter === "number") {
17555
+ if (isNumber(parameter)) {
17331
17556
  assert(
17332
17557
  parameter <= Number.MAX_SAFE_INTEGER,
17333
17558
  `Validation: Parameter is to large to be typed as Number use (BigInt or String)`
17334
17559
  );
17335
17560
  }
17336
17561
  assert(
17337
- typeof parameter === "string" || typeof parameter === "number" || typeof parameter === "bigint" || typeof parameter === "object" && "low" in parameter && "high" in parameter,
17562
+ isString(parameter) || isNumber(parameter) || isBigInt(parameter) || typeof parameter === "object" && "low" in parameter && "high" in parameter || typeof parameter === "object" && ["limb0", "limb1", "limb2", "limb3"].every((key) => key in parameter),
17338
17563
  `Validate: arg ${input.name} of cairo type ${input.type} should be type (String, Number or BigInt), but is ${typeof parameter} ${parameter}.`
17339
17564
  );
17340
- const param = typeof parameter === "object" ? new CairoUint256(parameter).toBigInt() : toBigInt(parameter);
17565
+ let param;
17566
+ switch (input.type) {
17567
+ case "core::integer::u256" /* u256 */:
17568
+ param = new CairoUint256(parameter).toBigInt();
17569
+ break;
17570
+ case "core::integer::u512" /* u512 */:
17571
+ param = new CairoUint512(parameter).toBigInt();
17572
+ break;
17573
+ default:
17574
+ param = toBigInt(parameter);
17575
+ }
17341
17576
  switch (input.type) {
17342
17577
  case "core::integer::u8" /* u8 */:
17343
17578
  assert(
@@ -17375,6 +17610,9 @@ var starknet = (() => {
17375
17610
  `Validate: arg ${input.name} is ${input.type} 0 - 2^256-1`
17376
17611
  );
17377
17612
  break;
17613
+ case "core::integer::u512" /* u512 */:
17614
+ assert(CairoUint512.is(param), `Validate: arg ${input.name} is ${input.type} 0 - 2^512-1`);
17615
+ break;
17378
17616
  case "core::starknet::class_hash::ClassHash" /* ClassHash */:
17379
17617
  assert(
17380
17618
  // from : https://github.com/starkware-libs/starknet-specs/blob/29bab650be6b1847c92d4461d4c33008b5e50b1a/api/starknet_api_openrpc.json#L1670
@@ -17389,18 +17627,25 @@ var starknet = (() => {
17389
17627
  `Validate: arg ${input.name} cairo typed ${input.type} should be in range [0, 2^252-1]`
17390
17628
  );
17391
17629
  break;
17630
+ case "core::starknet::secp256k1::Secp256k1Point" /* Secp256k1Point */: {
17631
+ assert(
17632
+ param >= 0n && param <= 2n ** 512n - 1n,
17633
+ `Validate: arg ${input.name} must be ${input.type} : a 512 bits number.`
17634
+ );
17635
+ break;
17636
+ }
17392
17637
  default:
17393
17638
  break;
17394
17639
  }
17395
17640
  };
17396
17641
  var validateBool = (parameter, input) => {
17397
17642
  assert(
17398
- typeof parameter === "boolean",
17643
+ isBoolean(parameter),
17399
17644
  `Validate: arg ${input.name} of cairo type ${input.type} should be type (Boolean)`
17400
17645
  );
17401
17646
  };
17402
17647
  var validateStruct = (parameter, input, structs) => {
17403
- if (input.type === "core::integer::u256" /* u256 */) {
17648
+ if (input.type === "core::integer::u256" /* u256 */ || input.type === "core::integer::u512" /* u512 */) {
17404
17649
  validateUint(parameter, input);
17405
17650
  return;
17406
17651
  }
@@ -17481,7 +17726,7 @@ var starknet = (() => {
17481
17726
  parameter.forEach((it) => validateEnum(it, { name: input.name, type: baseType }));
17482
17727
  break;
17483
17728
  case (isTypeUint(baseType) || isTypeLiteral(baseType)):
17484
- parameter.forEach((param) => validateUint(param, input));
17729
+ parameter.forEach((param) => validateUint(param, { name: "", type: baseType }));
17485
17730
  break;
17486
17731
  case isTypeBool(baseType):
17487
17732
  parameter.forEach((param) => validateBool(param, input));
@@ -18090,7 +18335,7 @@ var starknet = (() => {
18090
18335
  return INTEGER_REGEX.test(value);
18091
18336
  }
18092
18337
  var INTEGER_REGEX = /^-?[0-9]+$/;
18093
- function isNumber(value) {
18338
+ function isNumber2(value) {
18094
18339
  return NUMBER_REGEX.test(value);
18095
18340
  }
18096
18341
  var NUMBER_REGEX = /^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/;
@@ -18149,7 +18394,7 @@ var starknet = (() => {
18149
18394
  // type information
18150
18395
  isLosslessNumber = true;
18151
18396
  constructor(value) {
18152
- if (!isNumber(value)) {
18397
+ if (!isNumber2(value)) {
18153
18398
  throw new Error('Invalid number (value: "' + value + '")');
18154
18399
  }
18155
18400
  this.value = value;
@@ -18539,7 +18784,7 @@ var starknet = (() => {
18539
18784
  const stringifier = numberStringifiers.find((item) => item.test(value2));
18540
18785
  if (stringifier) {
18541
18786
  const str = stringifier.stringify(value2);
18542
- if (typeof str !== "string" || !isNumber(str)) {
18787
+ if (typeof str !== "string" || !isNumber2(str)) {
18543
18788
  throw new Error(`Invalid JSON number: output of a number stringifier must be a string containing a JSON number (output: ${str})`);
18544
18789
  }
18545
18790
  return str;
@@ -18696,7 +18941,7 @@ var starknet = (() => {
18696
18941
  return addHexPrefix(esm_exports.keccak(utf8ToArray(serializedJson)).toString(16));
18697
18942
  }
18698
18943
  function computeLegacyContractClassHash(contract) {
18699
- const compiledContract = typeof contract === "string" ? parse2(contract) : contract;
18944
+ const compiledContract = isString(contract) ? parse2(contract) : contract;
18700
18945
  const apiVersion = toHex(API_VERSION);
18701
18946
  const externalEntryPointsHash = computeHashOnElements3(
18702
18947
  compiledContract.entry_points_by_type.EXTERNAL.flatMap((e) => [e.selector, e.offset])
@@ -18792,7 +19037,7 @@ var starknet = (() => {
18792
19037
  );
18793
19038
  }
18794
19039
  function computeContractClassHash(contract) {
18795
- const compiledContract = typeof contract === "string" ? parse2(contract) : contract;
19040
+ const compiledContract = isString(contract) ? parse2(contract) : contract;
18796
19041
  if ("sierra_program" in compiledContract) {
18797
19042
  return computeSierraContractClassHash(compiledContract);
18798
19043
  }
@@ -22983,7 +23228,7 @@ var starknet = (() => {
22983
23228
 
22984
23229
  // src/utils/stark.ts
22985
23230
  function compressProgram(jsonProgram) {
22986
- const stringified = typeof jsonProgram === "string" ? jsonProgram : stringify2(jsonProgram);
23231
+ const stringified = isString(jsonProgram) ? jsonProgram : stringify2(jsonProgram);
22987
23232
  const compressedProgram = gzip_1(stringified);
22988
23233
  return btoaUniversal(compressedProgram);
22989
23234
  }
@@ -23023,7 +23268,7 @@ var starknet = (() => {
23023
23268
  return addPercent(estimatedFee, overhead);
23024
23269
  }
23025
23270
  function estimateFeeToBounds(estimate, amountOverhead = 50 /* L1_BOUND_MAX_AMOUNT */, priceOverhead = 50 /* L1_BOUND_MAX_PRICE_PER_UNIT */) {
23026
- if (typeof estimate === "bigint") {
23271
+ if (isBigInt(estimate)) {
23027
23272
  return {
23028
23273
  l2_gas: { max_amount: "0x0", max_price_per_unit: "0x0" },
23029
23274
  l1_gas: { max_amount: "0x0", max_price_per_unit: "0x0" }
@@ -23091,7 +23336,7 @@ var starknet = (() => {
23091
23336
 
23092
23337
  // src/utils/contract.ts
23093
23338
  function isSierra(contract) {
23094
- const compiledContract = typeof contract === "string" ? parse2(contract) : contract;
23339
+ const compiledContract = isString(contract) ? parse2(contract) : contract;
23095
23340
  return "sierra_program" in compiledContract;
23096
23341
  }
23097
23342
  function extractContractHashes(payload) {
@@ -23315,7 +23560,7 @@ var starknet = (() => {
23315
23560
  return result;
23316
23561
  }
23317
23562
  function parseContract(contract) {
23318
- const parsedContract = typeof contract === "string" ? parse2(contract) : contract;
23563
+ const parsedContract = isString(contract) ? parse2(contract) : contract;
23319
23564
  if (!isSierra(contract)) {
23320
23565
  return {
23321
23566
  ...parsedContract,
@@ -23332,7 +23577,7 @@ var starknet = (() => {
23332
23577
  return nodes[randIdx];
23333
23578
  };
23334
23579
  function formatHash(hashValue) {
23335
- if (typeof hashValue === "string")
23580
+ if (isString(hashValue))
23336
23581
  return hashValue;
23337
23582
  return toHex(hashValue);
23338
23583
  }
@@ -23349,14 +23594,16 @@ var starknet = (() => {
23349
23594
  number = null;
23350
23595
  tag = null;
23351
23596
  setIdentifier(__identifier) {
23352
- if (typeof __identifier === "string" && isHex(__identifier)) {
23353
- this.hash = __identifier;
23354
- } else if (typeof __identifier === "bigint") {
23597
+ if (isString(__identifier)) {
23598
+ if (isHex(__identifier)) {
23599
+ this.hash = __identifier;
23600
+ } else if (validBlockTags.includes(__identifier)) {
23601
+ this.tag = __identifier;
23602
+ }
23603
+ } else if (isBigInt(__identifier)) {
23355
23604
  this.hash = toHex(__identifier);
23356
- } else if (typeof __identifier === "number") {
23605
+ } else if (isNumber(__identifier)) {
23357
23606
  this.number = __identifier;
23358
- } else if (typeof __identifier === "string" && validBlockTags.includes(__identifier)) {
23359
- this.tag = __identifier;
23360
23607
  } else {
23361
23608
  this.tag = "pending" /* pending */;
23362
23609
  }
@@ -24605,7 +24852,7 @@ var starknet = (() => {
24605
24852
  return { status: "PENDING", ...res };
24606
24853
  }
24607
24854
  parseTransactionReceipt(res) {
24608
- if ("actual_fee" in res && typeof res.actual_fee === "string") {
24855
+ if ("actual_fee" in res && isString(res.actual_fee)) {
24609
24856
  return {
24610
24857
  ...res,
24611
24858
  actual_fee: {
@@ -24649,11 +24896,59 @@ var starknet = (() => {
24649
24896
  parseContractClassResponse(res) {
24650
24897
  return {
24651
24898
  ...res,
24652
- abi: typeof res.abi === "string" ? JSON.parse(res.abi) : res.abi
24899
+ abi: isString(res.abi) ? JSON.parse(res.abi) : res.abi
24653
24900
  };
24654
24901
  }
24655
24902
  };
24656
24903
 
24904
+ // src/utils/transactionReceipt.ts
24905
+ var ReceiptTx = class _ReceiptTx {
24906
+ statusReceipt;
24907
+ value;
24908
+ constructor(receipt) {
24909
+ [this.statusReceipt, this.value] = _ReceiptTx.isSuccess(receipt) ? ["success", receipt] : _ReceiptTx.isReverted(receipt) ? ["reverted", receipt] : _ReceiptTx.isRejected(receipt) ? ["rejected", receipt] : ["error", new Error("Unknown response type")];
24910
+ for (const [key] of Object.entries(this)) {
24911
+ Object.defineProperty(this, key, {
24912
+ enumerable: false
24913
+ });
24914
+ }
24915
+ for (const [key, value] of Object.entries(receipt)) {
24916
+ Object.defineProperty(this, key, {
24917
+ enumerable: true,
24918
+ writable: false,
24919
+ value
24920
+ });
24921
+ }
24922
+ }
24923
+ match(callbacks) {
24924
+ if (this.statusReceipt in callbacks) {
24925
+ return callbacks[this.statusReceipt](this.value);
24926
+ }
24927
+ return callbacks._();
24928
+ }
24929
+ isSuccess() {
24930
+ return this.statusReceipt === "success";
24931
+ }
24932
+ isReverted() {
24933
+ return this.statusReceipt === "reverted";
24934
+ }
24935
+ isRejected() {
24936
+ return this.statusReceipt === "rejected";
24937
+ }
24938
+ isError() {
24939
+ return this.statusReceipt === "error";
24940
+ }
24941
+ static isSuccess(transactionReceipt) {
24942
+ return transactionReceipt.execution_status === "SUCCEEDED" /* SUCCEEDED */;
24943
+ }
24944
+ static isReverted(transactionReceipt) {
24945
+ return transactionReceipt.execution_status === "REVERTED" /* REVERTED */;
24946
+ }
24947
+ static isRejected(transactionReceipt) {
24948
+ return transactionReceipt.status === "REJECTED" /* REJECTED */;
24949
+ }
24950
+ };
24951
+
24657
24952
  // src/provider/rpc.ts
24658
24953
  var RpcProvider = class {
24659
24954
  responseParser;
@@ -24738,7 +25033,9 @@ var starknet = (() => {
24738
25033
  return this.channel.getTransactionByBlockIdAndIndex(blockIdentifier, index);
24739
25034
  }
24740
25035
  async getTransactionReceipt(txHash) {
24741
- return this.channel.getTransactionReceipt(txHash).then(this.responseParser.parseTransactionReceipt);
25036
+ const txReceiptWoHelper = await this.channel.getTransactionReceipt(txHash);
25037
+ const txReceiptWoHelperModified = this.responseParser.parseTransactionReceipt(txReceiptWoHelper);
25038
+ return new ReceiptTx(txReceiptWoHelperModified);
24742
25039
  }
24743
25040
  async getTransactionTrace(txHash) {
24744
25041
  return this.channel.getTransactionTrace(txHash);
@@ -24760,7 +25057,11 @@ var starknet = (() => {
24760
25057
  return this.channel.simulateTransaction(invocations, options).then((r) => this.responseParser.parseSimulateTransactionResponse(r));
24761
25058
  }
24762
25059
  async waitForTransaction(txHash, options) {
24763
- return this.channel.waitForTransaction(txHash, options);
25060
+ const receiptWoHelper = await this.channel.waitForTransaction(
25061
+ txHash,
25062
+ options
25063
+ );
25064
+ return new ReceiptTx(receiptWoHelper);
24764
25065
  }
24765
25066
  async getStorageAt(contractAddress, key, blockIdentifier) {
24766
25067
  return this.channel.getStorageAt(contractAddress, key, blockIdentifier);
@@ -25686,6 +25987,10 @@ var starknet = (() => {
25686
25987
  presetTypes: {}
25687
25988
  }
25688
25989
  };
25990
+ function assertRange(data, type, { min, max }) {
25991
+ const value = BigInt(data);
25992
+ assert(value >= min && value <= max, `${value} (${type}) is out of bounds [${min}, ${max}]`);
25993
+ }
25689
25994
  function identifyRevision({ types, domain }) {
25690
25995
  if (revisionConfiguration["1" /* Active */].domain in types && domain.revision === "1" /* Active */)
25691
25996
  return "1" /* Active */;
@@ -25697,7 +26002,7 @@ var starknet = (() => {
25697
26002
  try {
25698
26003
  return toHex(value);
25699
26004
  } catch (e) {
25700
- if (typeof value === "string") {
26005
+ if (isString(value)) {
25701
26006
  return toHex(encodeShortString(value));
25702
26007
  }
25703
26008
  throw new Error(`Invalid BigNumberish: ${value}`);
@@ -25848,15 +26153,41 @@ var starknet = (() => {
25848
26153
  }
25849
26154
  return [type, getHex(data)];
25850
26155
  }
26156
+ case "i128": {
26157
+ if (revision === "1" /* Active */) {
26158
+ const value = BigInt(data);
26159
+ assertRange(value, type, RANGE_I128);
26160
+ return [type, getHex(value < 0n ? PRIME + value : value)];
26161
+ }
26162
+ return [type, getHex(data)];
26163
+ }
26164
+ case "timestamp":
26165
+ case "u128": {
26166
+ if (revision === "1" /* Active */) {
26167
+ assertRange(data, type, RANGE_U128);
26168
+ }
26169
+ return [type, getHex(data)];
26170
+ }
25851
26171
  case "felt":
25852
- case "bool":
25853
- case "u128":
25854
- case "i128":
25855
- case "ContractAddress":
26172
+ case "shortstring": {
26173
+ if (revision === "1" /* Active */) {
26174
+ assertRange(getHex(data), type, RANGE_FELT);
26175
+ }
26176
+ return [type, getHex(data)];
26177
+ }
25856
26178
  case "ClassHash":
25857
- case "timestamp":
25858
- case "shortstring":
26179
+ case "ContractAddress": {
26180
+ if (revision === "1" /* Active */) {
26181
+ assertRange(data, type, RANGE_FELT);
26182
+ }
26183
+ return [type, getHex(data)];
26184
+ }
26185
+ case "bool": {
26186
+ if (revision === "1" /* Active */) {
26187
+ assert(typeof data === "boolean", `Type mismatch for ${type} ${data}`);
26188
+ }
25859
26189
  return [type, getHex(data)];
26190
+ }
25860
26191
  default: {
25861
26192
  if (revision === "1" /* Active */) {
25862
26193
  throw new Error(`Unsupported type: ${type}`);
@@ -26082,19 +26413,48 @@ var starknet = (() => {
26082
26413
  return sanitizeHex(buf2hex(secp256k1.utils.randomPrivateKey()));
26083
26414
  }
26084
26415
 
26416
+ // src/utils/uint256.ts
26417
+ var uint256_exports = {};
26418
+ __export(uint256_exports, {
26419
+ UINT_128_MAX: () => UINT_128_MAX,
26420
+ UINT_256_MAX: () => UINT_256_MAX,
26421
+ bnToUint256: () => bnToUint256,
26422
+ isUint256: () => isUint256,
26423
+ uint256ToBN: () => uint256ToBN
26424
+ });
26425
+ function uint256ToBN(uint2562) {
26426
+ return new CairoUint256(uint2562).toBigInt();
26427
+ }
26428
+ function isUint256(bn) {
26429
+ return CairoUint256.is(bn);
26430
+ }
26431
+ function bnToUint256(bn) {
26432
+ return new CairoUint256(bn).toUint256HexString();
26433
+ }
26434
+
26085
26435
  // src/signer/ethSigner.ts
26086
26436
  var EthSigner = class {
26087
26437
  pk;
26088
- // hex string without 0x and odd number of characters
26438
+ // hex string without 0x and with an odd number of characters
26089
26439
  constructor(pk = ethRandomPrivateKey()) {
26090
- this.pk = pk instanceof Uint8Array ? removeHexPrefix(sanitizeHex(buf2hex(pk))) : removeHexPrefix(sanitizeHex(toHex(pk)));
26440
+ this.pk = pk instanceof Uint8Array ? buf2hex(pk).padStart(64, "0") : removeHexPrefix(toHex(pk)).padStart(64, "0");
26091
26441
  }
26442
+ /**
26443
+ * provides the Ethereum full public key (without parity prefix)
26444
+ * @returns an hex string : 64 first characters are Point X coordinate. 64 last characters are Point Y coordinate.
26445
+ */
26092
26446
  async getPubKey() {
26093
- return addHexPrefix(buf2hex(secp256k1.getPublicKey(this.pk)));
26447
+ return addHexPrefix(
26448
+ buf2hex(secp256k1.getPublicKey(this.pk, false)).padStart(130, "0").slice(2)
26449
+ );
26094
26450
  }
26095
26451
  async signMessage(typedData, accountAddress) {
26096
26452
  const msgHash = getMessageHash(typedData, accountAddress);
26097
- return secp256k1.sign(removeHexPrefix(sanitizeHex(msgHash)), this.pk);
26453
+ const signature = secp256k1.sign(
26454
+ removeHexPrefix(sanitizeHex(msgHash)),
26455
+ this.pk
26456
+ );
26457
+ return this.formatEthSignature(signature);
26098
26458
  }
26099
26459
  async signTransaction(transactions, details) {
26100
26460
  const compiledCalldata = getExecuteCalldata(transactions, details.cairoVersion);
@@ -26120,7 +26480,11 @@ var starknet = (() => {
26120
26480
  } else {
26121
26481
  throw Error("unsupported signTransaction version");
26122
26482
  }
26123
- return secp256k1.sign(removeHexPrefix(sanitizeHex(msgHash)), this.pk);
26483
+ const signature = secp256k1.sign(
26484
+ removeHexPrefix(sanitizeHex(msgHash)),
26485
+ this.pk
26486
+ );
26487
+ return this.formatEthSignature(signature);
26124
26488
  }
26125
26489
  async signDeployAccountTransaction(details) {
26126
26490
  const compiledConstructorCalldata = CallData.compile(details.constructorCalldata);
@@ -26146,7 +26510,11 @@ var starknet = (() => {
26146
26510
  } else {
26147
26511
  throw Error("unsupported signDeployAccountTransaction version");
26148
26512
  }
26149
- return secp256k1.sign(removeHexPrefix(sanitizeHex(msgHash)), this.pk);
26513
+ const signature = secp256k1.sign(
26514
+ removeHexPrefix(sanitizeHex(msgHash)),
26515
+ this.pk
26516
+ );
26517
+ return this.formatEthSignature(signature);
26150
26518
  }
26151
26519
  async signDeclareTransaction(details) {
26152
26520
  let msgHash;
@@ -26167,7 +26535,27 @@ var starknet = (() => {
26167
26535
  } else {
26168
26536
  throw Error("unsupported signDeclareTransaction version");
26169
26537
  }
26170
- return secp256k1.sign(removeHexPrefix(sanitizeHex(msgHash)), this.pk);
26538
+ const signature = secp256k1.sign(
26539
+ removeHexPrefix(sanitizeHex(msgHash)),
26540
+ this.pk
26541
+ );
26542
+ return this.formatEthSignature(signature);
26543
+ }
26544
+ /**
26545
+ * Serialize the signature in conformity with starknet::eth_signature::Signature
26546
+ * @param ethSignature secp256k1 signature from Noble curves library
26547
+ * @return an array of felts, representing a Cairo Eth Signature.
26548
+ */
26549
+ formatEthSignature(ethSignature) {
26550
+ const r = bnToUint256(ethSignature.r);
26551
+ const s = bnToUint256(ethSignature.s);
26552
+ return [
26553
+ toHex(r.low),
26554
+ toHex(r.high),
26555
+ toHex(s.low),
26556
+ toHex(s.high),
26557
+ toHex(ethSignature.recovery)
26558
+ ];
26171
26559
  }
26172
26560
  };
26173
26561
 
@@ -26203,7 +26591,7 @@ var starknet = (() => {
26203
26591
  constructor(providerOrOptions, address, pkOrSigner, cairoVersion, transactionVersion = "0x2" /* V2 */) {
26204
26592
  super(providerOrOptions);
26205
26593
  this.address = address.toLowerCase();
26206
- this.signer = typeof pkOrSigner === "string" || pkOrSigner instanceof Uint8Array ? new Signer(pkOrSigner) : pkOrSigner;
26594
+ this.signer = isString(pkOrSigner) || pkOrSigner instanceof Uint8Array ? new Signer(pkOrSigner) : pkOrSigner;
26207
26595
  if (cairoVersion) {
26208
26596
  this.cairoVersion = cairoVersion.toString();
26209
26597
  }
@@ -26344,7 +26732,7 @@ var starknet = (() => {
26344
26732
  return this.estimateInvokeFee(calls, details);
26345
26733
  }
26346
26734
  async estimateFeeBulk(invocations, details = {}) {
26347
- const { nonce, blockIdentifier, version } = details;
26735
+ const { nonce, blockIdentifier, version, skipValidate } = details;
26348
26736
  const accountInvocations = await this.accountInvocationsFactory(invocations, {
26349
26737
  ...v3Details(details),
26350
26738
  versions: [
@@ -26357,11 +26745,12 @@ var starknet = (() => {
26357
26745
  // sierra
26358
26746
  ],
26359
26747
  nonce,
26360
- blockIdentifier
26748
+ blockIdentifier,
26749
+ skipValidate
26361
26750
  });
26362
26751
  return super.getEstimateFeeBulk(accountInvocations, {
26363
26752
  blockIdentifier,
26364
- skipValidate: details.skipValidate
26753
+ skipValidate
26365
26754
  });
26366
26755
  }
26367
26756
  async simulateTransaction(invocations, details = {}) {
@@ -27365,25 +27754,6 @@ var starknet = (() => {
27365
27754
  // ethers.js' getDeployTransaction can't be supported as it requires the account or signer to return a signed transaction which is not possible with the current implementation
27366
27755
  };
27367
27756
 
27368
- // src/utils/uint256.ts
27369
- var uint256_exports = {};
27370
- __export(uint256_exports, {
27371
- UINT_128_MAX: () => UINT_128_MAX,
27372
- UINT_256_MAX: () => UINT_256_MAX,
27373
- bnToUint256: () => bnToUint256,
27374
- isUint256: () => isUint256,
27375
- uint256ToBN: () => uint256ToBN
27376
- });
27377
- function uint256ToBN(uint2562) {
27378
- return new CairoUint256(uint2562).toBigInt();
27379
- }
27380
- function isUint256(bn) {
27381
- return CairoUint256.is(bn);
27382
- }
27383
- function bnToUint256(bn) {
27384
- return new CairoUint256(bn).toUint256HexString();
27385
- }
27386
-
27387
27757
  // src/utils/address.ts
27388
27758
  function addAddressPadding(address) {
27389
27759
  return addHexPrefix(removeHexPrefix(toHex(address)).padStart(64, "0"));