starknet 8.1.1 → 8.2.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.
package/dist/index.js CHANGED
@@ -31,19 +31,33 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
31
31
  // src/index.ts
32
32
  var index_exports = {};
33
33
  __export(index_exports, {
34
+ AbiParser1: () => AbiParser1,
35
+ AbiParser2: () => AbiParser2,
36
+ AbiParserInterface: () => AbiParserInterface,
34
37
  Account: () => Account,
35
38
  AccountInterface: () => AccountInterface,
36
39
  BatchClient: () => BatchClient,
37
40
  BlockStatus: () => BlockStatus,
38
41
  BlockTag: () => BlockTag,
42
+ CairoByteArray: () => CairoByteArray,
39
43
  CairoCustomEnum: () => CairoCustomEnum,
40
44
  CairoFixedArray: () => CairoFixedArray,
45
+ CairoInt128: () => CairoInt128,
46
+ CairoInt16: () => CairoInt16,
47
+ CairoInt32: () => CairoInt32,
48
+ CairoInt64: () => CairoInt64,
49
+ CairoInt8: () => CairoInt8,
41
50
  CairoOption: () => CairoOption,
42
51
  CairoOptionVariant: () => CairoOptionVariant,
43
52
  CairoResult: () => CairoResult,
44
53
  CairoResultVariant: () => CairoResultVariant,
54
+ CairoUint128: () => CairoUint128,
55
+ CairoUint16: () => CairoUint16,
45
56
  CairoUint256: () => CairoUint256,
46
57
  CairoUint512: () => CairoUint512,
58
+ CairoUint64: () => CairoUint64,
59
+ CairoUint8: () => CairoUint8,
60
+ CairoUint96: () => CairoUint96,
47
61
  CallData: () => CallData,
48
62
  Contract: () => Contract,
49
63
  ContractInterface: () => ContractInterface,
@@ -59,6 +73,7 @@ __export(index_exports, {
59
73
  ETransactionVersion3: () => ETransactionVersion3,
60
74
  EntryPointType: () => EntryPointType,
61
75
  EthSigner: () => EthSigner,
76
+ Int: () => Int,
62
77
  LedgerSigner: () => LedgerSigner111,
63
78
  LedgerSigner111: () => LedgerSigner111,
64
79
  LedgerSigner221: () => LedgerSigner221,
@@ -112,6 +127,8 @@ __export(index_exports, {
112
127
  config: () => config,
113
128
  constants: () => constants_exports,
114
129
  contractClassResponseToLegacyCompiledContract: () => contractClassResponseToLegacyCompiledContract,
130
+ createAbiParser: () => createAbiParser,
131
+ createTransactionReceipt: () => createTransactionReceipt,
115
132
  defaultDeployer: () => defaultDeployer,
116
133
  defaultPaymaster: () => defaultPaymaster,
117
134
  defaultProvider: () => defaultProvider,
@@ -120,6 +137,8 @@ __export(index_exports, {
120
137
  eth: () => eth_exports,
121
138
  events: () => events_exports,
122
139
  extractContractHashes: () => extractContractHashes,
140
+ fastParsingStrategy: () => fastParsingStrategy,
141
+ getAbiVersion: () => getAbiVersion,
123
142
  getChecksumAddress: () => getChecksumAddress,
124
143
  getGasPrices: () => getGasPrices,
125
144
  getLedgerPathBuffer: () => getLedgerPathBuffer111,
@@ -127,7 +146,9 @@ __export(index_exports, {
127
146
  getLedgerPathBuffer221: () => getLedgerPathBuffer221,
128
147
  getTipStatsFromBlocks: () => getTipStatsFromBlocks,
129
148
  hash: () => hash_exports,
149
+ hdParsingStrategy: () => hdParsingStrategy,
130
150
  isAccount: () => isAccount,
151
+ isNoConstructorValid: () => isNoConstructorValid,
131
152
  isPendingBlock: () => isPendingBlock,
132
153
  isPendingStateUpdate: () => isPendingStateUpdate,
133
154
  isPendingTransaction: () => isPendingTransaction,
@@ -186,7 +207,16 @@ __export(constants_exports, {
186
207
  PRIME: () => PRIME,
187
208
  RANGE_FELT: () => RANGE_FELT,
188
209
  RANGE_I128: () => RANGE_I128,
210
+ RANGE_I16: () => RANGE_I16,
211
+ RANGE_I32: () => RANGE_I32,
212
+ RANGE_I64: () => RANGE_I64,
213
+ RANGE_I8: () => RANGE_I8,
189
214
  RANGE_U128: () => RANGE_U128,
215
+ RANGE_U16: () => RANGE_U16,
216
+ RANGE_U32: () => RANGE_U32,
217
+ RANGE_U64: () => RANGE_U64,
218
+ RANGE_U8: () => RANGE_U8,
219
+ RANGE_U96: () => RANGE_U96,
190
220
  RPC_DEFAULT_NODES: () => RPC_DEFAULT_NODES,
191
221
  SNIP9_V1_INTERFACE_ID: () => SNIP9_V1_INTERFACE_ID,
192
222
  SNIP9_V2_INTERFACE_ID: () => SNIP9_V2_INTERFACE_ID,
@@ -230,16 +260,22 @@ __export(encode_exports, {
230
260
  addHexPrefix: () => addHexPrefix,
231
261
  arrayBufferToString: () => arrayBufferToString,
232
262
  atobUniversal: () => atobUniversal,
263
+ bigIntToUint8Array: () => bigIntToUint8Array,
233
264
  btoaUniversal: () => btoaUniversal,
234
265
  buf2hex: () => buf2hex,
235
266
  calcByteLength: () => calcByteLength,
236
267
  concatenateArrayBuffer: () => concatenateArrayBuffer,
268
+ hexStringToUint8Array: () => hexStringToUint8Array,
237
269
  padLeft: () => padLeft,
238
270
  pascalToSnake: () => pascalToSnake,
239
271
  removeHexPrefix: () => removeHexPrefix,
240
272
  sanitizeBytes: () => sanitizeBytes,
241
273
  sanitizeHex: () => sanitizeHex,
242
- utf8ToArray: () => utf8ToArray
274
+ stringToUint8Array: () => stringToUint8Array,
275
+ uint8ArrayToBigInt: () => uint8ArrayToBigInt,
276
+ utf8ToArray: () => utf8ToArray,
277
+ utf8ToBigInt: () => utf8ToBigInt,
278
+ utf8ToUint8Array: () => utf8ToUint8Array
243
279
  });
244
280
  var import_base = require("@scure/base");
245
281
  var IS_BROWSER = typeof window !== "undefined";
@@ -247,9 +283,13 @@ var STRING_ZERO = "0";
247
283
  function arrayBufferToString(array) {
248
284
  return new Uint8Array(array).reduce((data, byte) => data + String.fromCharCode(byte), "");
249
285
  }
250
- function utf8ToArray(str) {
286
+ function utf8ToUint8Array(str) {
251
287
  return new TextEncoder().encode(str);
252
288
  }
289
+ var utf8ToArray = utf8ToUint8Array;
290
+ function utf8ToBigInt(str) {
291
+ return uint8ArrayToBigInt(utf8ToUint8Array(str));
292
+ }
253
293
  function atobUniversal(a) {
254
294
  return import_base.base64.decode(a);
255
295
  }
@@ -301,6 +341,61 @@ function concatenateArrayBuffer(uint8arrays) {
301
341
  });
302
342
  return result;
303
343
  }
344
+ function hexStringToUint8Array(hex) {
345
+ const cleanHex2 = hex.startsWith("0x") ? hex.slice(2) : hex;
346
+ if (cleanHex2.length > 0 && !/^[0-9a-fA-F]+$/.test(cleanHex2)) {
347
+ throw new Error(`Invalid hex string: "${hex}" contains non-hexadecimal characters`);
348
+ }
349
+ const paddedHex = cleanHex2.length % 2 !== 0 ? `0${cleanHex2}` : cleanHex2;
350
+ const bytes = new Uint8Array(paddedHex.length / 2);
351
+ for (let i = 0; i < paddedHex.length; i += 2) {
352
+ bytes[i / 2] = parseInt(paddedHex.substring(i, i + 2), 16);
353
+ }
354
+ return bytes;
355
+ }
356
+ function isHexString(hex) {
357
+ return /^0[xX][0-9a-fA-F]*$/.test(hex);
358
+ }
359
+ function isDecimalString(str) {
360
+ return /^[0-9]+$/.test(str);
361
+ }
362
+ function stringToUint8Array(str) {
363
+ if (isHexString(str)) {
364
+ return hexStringToUint8Array(str);
365
+ }
366
+ if (isDecimalString(str)) {
367
+ const value = BigInt(str);
368
+ return bigIntToUint8Array(value);
369
+ }
370
+ return utf8ToUint8Array(str);
371
+ }
372
+ function bigIntToUint8Array(value) {
373
+ if (value < 0n) {
374
+ throw new Error(`Cannot convert negative bigint ${value} to Uint8Array`);
375
+ }
376
+ if (value === 0n) {
377
+ return new Uint8Array([0]);
378
+ }
379
+ let hex = value.toString(16);
380
+ if (hex.length % 2 !== 0) {
381
+ hex = `0${hex}`;
382
+ }
383
+ const bytes = new Uint8Array(hex.length / 2);
384
+ for (let i = 0; i < hex.length; i += 2) {
385
+ bytes[i / 2] = parseInt(hex.substring(i, i + 2), 16);
386
+ }
387
+ return bytes;
388
+ }
389
+ function uint8ArrayToBigInt(data) {
390
+ if (!data || data.length === 0) {
391
+ return 0n;
392
+ }
393
+ let hex = "0x";
394
+ for (let i = 0; i < data.length; i += 1) {
395
+ hex += data[i].toString(16).padStart(2, "0");
396
+ }
397
+ return BigInt(hex);
398
+ }
304
399
 
305
400
  // src/global/constants.ts
306
401
  var TEXT_TO_FELT_MAX_LEN = 31;
@@ -313,8 +408,17 @@ var MAX_STORAGE_ITEM_SIZE = 256n;
313
408
  var ADDR_BOUND = 2n ** 251n - MAX_STORAGE_ITEM_SIZE;
314
409
  var range = (min, max) => ({ min, max });
315
410
  var RANGE_FELT = range(ZERO, PRIME - 1n);
316
- var RANGE_I128 = range(-(2n ** 127n), 2n ** 127n - 1n);
411
+ var RANGE_U8 = range(ZERO, 2n ** 8n - 1n);
412
+ var RANGE_U16 = range(ZERO, 2n ** 16n - 1n);
413
+ var RANGE_U32 = range(ZERO, 2n ** 32n - 1n);
414
+ var RANGE_U64 = range(ZERO, 2n ** 64n - 1n);
415
+ var RANGE_U96 = range(ZERO, 2n ** 96n - 1n);
317
416
  var RANGE_U128 = range(ZERO, 2n ** 128n - 1n);
417
+ var RANGE_I8 = range(-(2n ** 7n), 2n ** 7n - 1n);
418
+ var RANGE_I16 = range(-(2n ** 15n), 2n ** 15n - 1n);
419
+ var RANGE_I32 = range(-(2n ** 31n), 2n ** 31n - 1n);
420
+ var RANGE_I64 = range(-(2n ** 63n), 2n ** 63n - 1n);
421
+ var RANGE_I128 = range(-(2n ** 127n), 2n ** 127n - 1n);
318
422
  var LegacyUDC = {
319
423
  ADDRESS: "0x041a78e741e5af2fec34b695679bc6891742439f7afb8484ecd7766661ad02bf",
320
424
  ENTRYPOINT: "deployContract"
@@ -381,7 +485,8 @@ var DEFAULT_GLOBAL_CONFIG = {
381
485
  },
382
486
  defaultTipType: "recommendedTip",
383
487
  fetch: void 0,
384
- websocket: void 0
488
+ websocket: void 0,
489
+ buffer: void 0
385
490
  };
386
491
  var RPC_DEFAULT_NODES = {
387
492
  SN_MAIN: [`https://starknet-mainnet.public.blastapi.io/rpc/`],
@@ -399,7 +504,10 @@ var SYSTEM_MESSAGES = {
399
504
  unsupportedSpecVersion: "The connected node specification version is not supported by this library",
400
505
  maxFeeInV3: "maxFee is not supported in V3 transactions, use resourceBounds instead",
401
506
  declareNonSierra: "Declaring non Sierra (Cairo0)contract using RPC 0.8+",
402
- unsupportedMethodForRpcVersion: "Unsupported method for RPC version"
507
+ unsupportedMethodForRpcVersion: "Unsupported method for RPC version",
508
+ txEvictedFromMempool: "Transaction TTL, evicted from the mempool, try to increase the tip",
509
+ consensusFailed: "Consensus failed to finalize the block proposal",
510
+ txFailsBlockBuildingValidation: "Transaction fails block building validation"
403
511
  };
404
512
 
405
513
  // src/global/config.ts
@@ -622,12 +730,20 @@ var Uint = {
622
730
  u16: "core::integer::u16",
623
731
  u32: "core::integer::u32",
624
732
  u64: "core::integer::u64",
733
+ u96: "core::integer::u96",
625
734
  u128: "core::integer::u128",
626
735
  u256: "core::integer::u256",
627
736
  // This one is struct
628
737
  u512: "core::integer::u512"
629
738
  // This one is struct
630
739
  };
740
+ var Int = {
741
+ i8: "core::integer::i8",
742
+ i16: "core::integer::i16",
743
+ i32: "core::integer::i32",
744
+ i64: "core::integer::i64",
745
+ i128: "core::integer::i128"
746
+ };
631
747
  var Literal = {
632
748
  ClassHash: "core::starknet::class_hash::ClassHash",
633
749
  ContractAddress: "core::starknet::contract_address::ContractAddress",
@@ -811,10 +927,12 @@ __export(num_exports, {
811
927
  getDecimalString: () => getDecimalString,
812
928
  getHexString: () => getHexString,
813
929
  getHexStringArray: () => getHexStringArray,
930
+ getNext: () => getNext,
814
931
  hexToBytes: () => hexToBytes,
815
932
  hexToDecimalString: () => hexToDecimalString,
816
933
  isBigNumberish: () => isBigNumberish,
817
934
  isHex: () => isHex,
935
+ isHexString: () => isHexString2,
818
936
  isStringWholeNumber: () => isStringWholeNumber,
819
937
  stringToSha256ToArrayBuff4: () => stringToSha256ToArrayBuff4,
820
938
  toBigInt: () => toBigInt,
@@ -844,14 +962,21 @@ function isBigInt(value) {
844
962
  function isString(value) {
845
963
  return typeof value === "string";
846
964
  }
965
+ function isBuffer(obj) {
966
+ return typeof Buffer !== "undefined" && obj instanceof Buffer;
967
+ }
847
968
  function isObject(item) {
848
969
  return !!item && typeof item === "object" && !Array.isArray(item);
849
970
  }
971
+ function isInteger2(value) {
972
+ return Number.isInteger(value);
973
+ }
850
974
 
851
975
  // src/utils/num.ts
852
976
  function isHex(hex) {
853
977
  return /^0[xX][0-9a-fA-F]*$/.test(hex);
854
978
  }
979
+ var isHexString2 = isHex;
855
980
  function toBigInt(value) {
856
981
  return BigInt(value);
857
982
  }
@@ -939,6 +1064,11 @@ function stringToSha256ToArrayBuff4(str) {
939
1064
  function isBigNumberish(input) {
940
1065
  return isNumber(input) || isBigInt(input) || isString(input) && (isHex(input) || isStringWholeNumber(input));
941
1066
  }
1067
+ function getNext(iterator) {
1068
+ const it = iterator.next();
1069
+ if (it.done) throw new Error("Unexpected end of response");
1070
+ return it.value;
1071
+ }
942
1072
 
943
1073
  // src/utils/hash/selector.ts
944
1074
  var selector_exports = {};
@@ -1004,7 +1134,7 @@ __export(shortString_exports, {
1004
1134
  decodeShortString: () => decodeShortString,
1005
1135
  encodeShortString: () => encodeShortString,
1006
1136
  isASCII: () => isASCII,
1007
- isDecimalString: () => isDecimalString,
1137
+ isDecimalString: () => isDecimalString2,
1008
1138
  isLongText: () => isLongText,
1009
1139
  isShortString: () => isShortString,
1010
1140
  isShortText: () => isShortText,
@@ -1017,7 +1147,7 @@ function isASCII(str) {
1017
1147
  function isShortString(str) {
1018
1148
  return str.length <= TEXT_TO_FELT_MAX_LEN;
1019
1149
  }
1020
- function isDecimalString(str) {
1150
+ function isDecimalString2(str) {
1021
1151
  return /^[0-9]*$/i.test(str);
1022
1152
  }
1023
1153
  function isText(val) {
@@ -1039,7 +1169,7 @@ function decodeShortString(str) {
1039
1169
  if (isHex(str)) {
1040
1170
  return removeHexPrefix(str).replace(/.{2}/g, (hex) => String.fromCharCode(parseInt(hex, 16)));
1041
1171
  }
1042
- if (isDecimalString(str)) {
1172
+ if (isDecimalString2(str)) {
1043
1173
  return decodeShortString("0X".concat(BigInt(str).toString(16)));
1044
1174
  }
1045
1175
  throw new Error(`${str} is not Hex or decimal`);
@@ -1081,12 +1211,11 @@ __export(cairo_exports, {
1081
1211
  isLen: () => isLen,
1082
1212
  isTypeArray: () => isTypeArray,
1083
1213
  isTypeBool: () => isTypeBool,
1084
- isTypeByteArray: () => isTypeByteArray,
1085
- isTypeBytes31: () => isTypeBytes31,
1086
1214
  isTypeContractAddress: () => isTypeContractAddress,
1087
1215
  isTypeEnum: () => isTypeEnum,
1088
1216
  isTypeEthAddress: () => isTypeEthAddress,
1089
1217
  isTypeFelt: () => isTypeFelt,
1218
+ isTypeInt: () => isTypeInt,
1090
1219
  isTypeLiteral: () => isTypeLiteral,
1091
1220
  isTypeNamedTuple: () => isTypeNamedTuple,
1092
1221
  isTypeNonZero: () => isTypeNonZero,
@@ -1103,6 +1232,16 @@ __export(cairo_exports, {
1103
1232
  uint512: () => uint512
1104
1233
  });
1105
1234
 
1235
+ // src/utils/helpers.ts
1236
+ function addCompiledFlag(compiled) {
1237
+ Object.defineProperty(compiled, "__compiled__", {
1238
+ enumerable: false,
1239
+ writable: false,
1240
+ value: true
1241
+ });
1242
+ return compiled;
1243
+ }
1244
+
1106
1245
  // src/utils/cairoDataTypes/felt.ts
1107
1246
  function CairoFelt(it) {
1108
1247
  if (isBigInt(it) || Number.isInteger(it)) {
@@ -1129,6 +1268,69 @@ function CairoFelt(it) {
1129
1268
  }
1130
1269
  throw new Error(`${it} can't be computed by felt()`);
1131
1270
  }
1271
+ var CairoFelt252 = class _CairoFelt252 {
1272
+ /**
1273
+ * byte representation of the felt252
1274
+ */
1275
+ data;
1276
+ static abiSelector = "core::felt252";
1277
+ constructor(data) {
1278
+ _CairoFelt252.validate(data);
1279
+ this.data = _CairoFelt252.__processData(data);
1280
+ }
1281
+ static __processData(data) {
1282
+ if (isString(data)) {
1283
+ return stringToUint8Array(data);
1284
+ }
1285
+ if (isBigInt(data)) {
1286
+ return bigIntToUint8Array(data);
1287
+ }
1288
+ if (Number.isInteger(data)) {
1289
+ return bigIntToUint8Array(BigInt(data));
1290
+ }
1291
+ if (isBoolean(data)) {
1292
+ return bigIntToUint8Array(BigInt(data ? 1 : 0));
1293
+ }
1294
+ throw new Error(`${data} can't be computed by felt()`);
1295
+ }
1296
+ toBigInt() {
1297
+ return uint8ArrayToBigInt(this.data);
1298
+ }
1299
+ decodeUtf8() {
1300
+ return new TextDecoder().decode(this.data);
1301
+ }
1302
+ toHexString() {
1303
+ return addHexPrefix(this.toBigInt().toString(16));
1304
+ }
1305
+ toApiRequest() {
1306
+ return addCompiledFlag([this.toHexString()]);
1307
+ }
1308
+ static validate(data) {
1309
+ assert(data !== null, "null value is not allowed for felt252");
1310
+ assert(data !== void 0, "undefined value is not allowed for felt252");
1311
+ assert(
1312
+ isString(data) || isNumber(data) || isBigInt(data) || isBoolean(data),
1313
+ `Unsupported data type '${typeof data}' for felt252. Expected string, number, bigint, or boolean`
1314
+ );
1315
+ const value = _CairoFelt252.__processData(data);
1316
+ const bn = uint8ArrayToBigInt(value);
1317
+ assert(bn >= 0n && bn < PRIME, `Value ${value} is out of felt252 range [0, ${PRIME})`);
1318
+ }
1319
+ static is(data) {
1320
+ try {
1321
+ _CairoFelt252.validate(data);
1322
+ return true;
1323
+ } catch {
1324
+ return false;
1325
+ }
1326
+ }
1327
+ static isAbiType(abiType) {
1328
+ return abiType === _CairoFelt252.abiSelector;
1329
+ }
1330
+ static factoryFromApiResponse(responseIterator) {
1331
+ return new _CairoFelt252(getNext(responseIterator));
1332
+ }
1333
+ };
1132
1334
 
1133
1335
  // src/utils/cairoDataTypes/uint256.ts
1134
1336
  var UINT_128_MAX = (1n << 128n) - 1n;
@@ -1140,11 +1342,16 @@ var UINT_256_LOW_MIN = 0n;
1140
1342
  var UINT_256_HIGH_MIN = 0n;
1141
1343
  var CairoUint256 = class _CairoUint256 {
1142
1344
  low;
1345
+ // TODO should be u128
1143
1346
  high;
1347
+ // TODO should be u128
1144
1348
  static abiSelector = "core::integer::u256";
1145
1349
  constructor(...arr) {
1146
1350
  if (isObject(arr[0]) && arr.length === 1 && "low" in arr[0] && "high" in arr[0]) {
1147
- const props = _CairoUint256.validateProps(arr[0].low, arr[0].high);
1351
+ const props = _CairoUint256.validateProps(
1352
+ arr[0].low,
1353
+ arr[0].high
1354
+ );
1148
1355
  this.low = props.low;
1149
1356
  this.high = props.high;
1150
1357
  } else if (arr.length === 1) {
@@ -1163,9 +1370,15 @@ var CairoUint256 = class _CairoUint256 {
1163
1370
  * Validate if BigNumberish can be represented as Unit256
1164
1371
  */
1165
1372
  static validate(bigNumberish) {
1373
+ assert(bigNumberish !== null, "null value is not allowed for u256");
1374
+ assert(bigNumberish !== void 0, "undefined value is not allowed for u256");
1375
+ assert(
1376
+ isBigNumberish(bigNumberish) || isObject(bigNumberish),
1377
+ `Unsupported data type '${typeof bigNumberish}' for u256. Expected string, number, bigint, or Uint256 object`
1378
+ );
1166
1379
  const bigInt = BigInt(bigNumberish);
1167
- if (bigInt < UINT_256_MIN) throw Error("bigNumberish is smaller than UINT_256_MIN");
1168
- if (bigInt > UINT_256_MAX) throw new Error("bigNumberish is bigger than UINT_256_MAX");
1380
+ assert(bigInt >= UINT_256_MIN, "bigNumberish is smaller than UINT_256_MIN");
1381
+ assert(bigInt <= UINT_256_MAX, "bigNumberish is bigger than UINT_256_MAX");
1169
1382
  return bigInt;
1170
1383
  }
1171
1384
  /**
@@ -1174,12 +1387,14 @@ var CairoUint256 = class _CairoUint256 {
1174
1387
  static validateProps(low, high) {
1175
1388
  const bigIntLow = BigInt(low);
1176
1389
  const bigIntHigh = BigInt(high);
1177
- if (bigIntLow < UINT_256_LOW_MIN || bigIntLow > UINT_256_LOW_MAX) {
1178
- throw new Error("low is out of range UINT_256_LOW_MIN - UINT_256_LOW_MAX");
1179
- }
1180
- if (bigIntHigh < UINT_256_HIGH_MIN || bigIntHigh > UINT_256_HIGH_MAX) {
1181
- throw new Error("high is out of range UINT_256_HIGH_MIN - UINT_256_HIGH_MAX");
1182
- }
1390
+ assert(
1391
+ bigIntLow >= UINT_256_LOW_MIN && bigIntLow <= UINT_256_LOW_MAX,
1392
+ "low is out of range UINT_256_LOW_MIN - UINT_256_LOW_MAX"
1393
+ );
1394
+ assert(
1395
+ bigIntHigh >= UINT_256_HIGH_MIN && bigIntHigh <= UINT_256_HIGH_MAX,
1396
+ "high is out of range UINT_256_HIGH_MIN - UINT_256_HIGH_MAX"
1397
+ );
1183
1398
  return { low: bigIntLow, high: bigIntHigh };
1184
1399
  }
1185
1400
  /**
@@ -1199,6 +1414,11 @@ var CairoUint256 = class _CairoUint256 {
1199
1414
  static isAbiType(abiType) {
1200
1415
  return abiType === _CairoUint256.abiSelector;
1201
1416
  }
1417
+ static factoryFromApiResponse(responseIterator) {
1418
+ const low = getNext(responseIterator);
1419
+ const high = getNext(responseIterator);
1420
+ return new _CairoUint256(low, high);
1421
+ }
1202
1422
  /**
1203
1423
  * Return bigint representation
1204
1424
  */
@@ -1239,9 +1459,13 @@ var UINT_512_MIN = 0n;
1239
1459
  var UINT_128_MIN = 0n;
1240
1460
  var CairoUint512 = class _CairoUint512 {
1241
1461
  limb0;
1462
+ // TODO should be u128
1242
1463
  limb1;
1464
+ // TODO should be u128
1243
1465
  limb2;
1466
+ // TODO should be u128
1244
1467
  limb3;
1468
+ // TODO should be u128
1245
1469
  static abiSelector = "core::integer::u512";
1246
1470
  constructor(...arr) {
1247
1471
  if (isObject(arr[0]) && arr.length === 1 && "limb0" in arr[0] && "limb1" in arr[0] && "limb2" in arr[0] && "limb3" in arr[0]) {
@@ -1275,9 +1499,15 @@ var CairoUint512 = class _CairoUint512 {
1275
1499
  * Validate if BigNumberish can be represented as Uint512
1276
1500
  */
1277
1501
  static validate(bigNumberish) {
1502
+ assert(bigNumberish !== null, "null value is not allowed for u512");
1503
+ assert(bigNumberish !== void 0, "undefined value is not allowed for u512");
1504
+ assert(
1505
+ isBigNumberish(bigNumberish) || isObject(bigNumberish),
1506
+ `Unsupported data type '${typeof bigNumberish}' for u512. Expected string, number, bigint, or Uint512 object`
1507
+ );
1278
1508
  const bigInt = BigInt(bigNumberish);
1279
- if (bigInt < UINT_512_MIN) throw Error("bigNumberish is smaller than UINT_512_MIN.");
1280
- if (bigInt > UINT_512_MAX) throw Error("bigNumberish is bigger than UINT_512_MAX.");
1509
+ assert(bigInt >= UINT_512_MIN, "bigNumberish is smaller than UINT_512_MIN.");
1510
+ assert(bigInt <= UINT_512_MAX, "bigNumberish is bigger than UINT_512_MAX.");
1281
1511
  return bigInt;
1282
1512
  }
1283
1513
  /**
@@ -1289,9 +1519,10 @@ var CairoUint512 = class _CairoUint512 {
1289
1519
  const l2 = BigInt(limb2);
1290
1520
  const l3 = BigInt(limb3);
1291
1521
  [l0, l1, l2, l3].forEach((value, index) => {
1292
- if (value < UINT_128_MIN || value > UINT_128_MAX) {
1293
- throw Error(`limb${index} is not in the range of a u128 number`);
1294
- }
1522
+ assert(
1523
+ value >= UINT_128_MIN && value <= UINT_128_MAX,
1524
+ `limb${index} is not in the range of a u128 number`
1525
+ );
1295
1526
  });
1296
1527
  return { limb0: l0, limb1: l1, limb2: l2, limb3: l3 };
1297
1528
  }
@@ -1312,6 +1543,13 @@ var CairoUint512 = class _CairoUint512 {
1312
1543
  static isAbiType(abiType) {
1313
1544
  return abiType === _CairoUint512.abiSelector;
1314
1545
  }
1546
+ static factoryFromApiResponse(responseIterator) {
1547
+ const limb0 = getNext(responseIterator);
1548
+ const limb1 = getNext(responseIterator);
1549
+ const limb2 = getNext(responseIterator);
1550
+ const limb3 = getNext(responseIterator);
1551
+ return new _CairoUint512(limb0, limb1, limb2, limb3);
1552
+ }
1315
1553
  /**
1316
1554
  * Return bigint representation
1317
1555
  */
@@ -1366,13 +1604,12 @@ var isTypeEnum = (type, enums) => type in enums;
1366
1604
  var isTypeOption = (type) => type.startsWith("core::option::Option::");
1367
1605
  var isTypeResult = (type) => type.startsWith("core::result::Result::");
1368
1606
  var isTypeUint = (type) => Object.values(Uint).includes(type);
1607
+ var isTypeInt = (type) => Object.values(Int).includes(type);
1369
1608
  var isTypeUint256 = (type) => CairoUint256.isAbiType(type);
1370
1609
  var isTypeLiteral = (type) => Object.values(Literal).includes(type);
1371
1610
  var isTypeBool = (type) => type === "core::bool";
1372
1611
  var isTypeContractAddress = (type) => type === Literal.ContractAddress;
1373
1612
  var isTypeEthAddress = (type) => type === ETH_ADDRESS;
1374
- var isTypeBytes31 = (type) => type === "core::bytes_31::bytes31";
1375
- var isTypeByteArray = (type) => type === "core::byte_array::ByteArray";
1376
1613
  var isTypeU96 = (type) => type === "core::internal::bounded_int::BoundedInt::<0, 79228162514264337593543950335>";
1377
1614
  var isTypeSecp256k1Point = (type) => type === Literal.Secp256k1Point;
1378
1615
  var isCairo1Type = (type) => type.includes("::");
@@ -1627,15 +1864,1348 @@ function formatter(data, type, sameType) {
1627
1864
  guard.unknown(data, type, key);
1628
1865
  return acc;
1629
1866
  },
1630
- {}
1631
- );
1632
- }
1867
+ {}
1868
+ );
1869
+ }
1870
+
1871
+ // src/utils/calldata/parser/interface.ts
1872
+ var AbiParserInterface = class {
1873
+ };
1874
+
1875
+ // src/utils/cairoDataTypes/bytes31.ts
1876
+ var CairoBytes31 = class _CairoBytes31 {
1877
+ static MAX_BYTE_SIZE = 31;
1878
+ data;
1879
+ static abiSelector = "core::bytes_31::bytes31";
1880
+ constructor(data) {
1881
+ _CairoBytes31.validate(data);
1882
+ this.data = _CairoBytes31.__processData(data);
1883
+ }
1884
+ static __processData(data) {
1885
+ if (isString(data)) {
1886
+ return stringToUint8Array(data);
1887
+ }
1888
+ if (isBuffer(data)) {
1889
+ return new Uint8Array(data);
1890
+ }
1891
+ if (data instanceof Uint8Array) {
1892
+ return new Uint8Array(data);
1893
+ }
1894
+ throw new Error("Invalid input type for CairoBytes31. Expected string, Buffer, or Uint8Array");
1895
+ }
1896
+ toApiRequest() {
1897
+ return addCompiledFlag([this.toHexString()]);
1898
+ }
1899
+ toBigInt() {
1900
+ return uint8ArrayToBigInt(this.data);
1901
+ }
1902
+ decodeUtf8() {
1903
+ return new TextDecoder().decode(this.data);
1904
+ }
1905
+ toHexString() {
1906
+ return addHexPrefix(this.toBigInt().toString(16));
1907
+ }
1908
+ static validate(data) {
1909
+ const byteLength = _CairoBytes31.__processData(data).length;
1910
+ assert(
1911
+ byteLength <= this.MAX_BYTE_SIZE,
1912
+ `Data is too long: ${byteLength} bytes (max ${this.MAX_BYTE_SIZE} bytes)`
1913
+ );
1914
+ }
1915
+ static is(data) {
1916
+ try {
1917
+ _CairoBytes31.validate(data);
1918
+ return true;
1919
+ } catch {
1920
+ return false;
1921
+ }
1922
+ }
1923
+ /**
1924
+ * Check if provided abi type is this data type
1925
+ */
1926
+ static isAbiType(abiType) {
1927
+ return abiType === _CairoBytes31.abiSelector;
1928
+ }
1929
+ static factoryFromApiResponse(responseIterator) {
1930
+ return new _CairoBytes31(getNext(responseIterator));
1931
+ }
1932
+ };
1933
+
1934
+ // src/utils/errors/rpc.ts
1935
+ var errorCodes = {
1936
+ FAILED_TO_RECEIVE_TXN: 1,
1937
+ NO_TRACE_AVAILABLE: 10,
1938
+ CONTRACT_NOT_FOUND: 20,
1939
+ ENTRYPOINT_NOT_FOUND: 21,
1940
+ BLOCK_NOT_FOUND: 24,
1941
+ INVALID_TXN_INDEX: 27,
1942
+ CLASS_HASH_NOT_FOUND: 28,
1943
+ TXN_HASH_NOT_FOUND: 29,
1944
+ PAGE_SIZE_TOO_BIG: 31,
1945
+ NO_BLOCKS: 32,
1946
+ INVALID_CONTINUATION_TOKEN: 33,
1947
+ TOO_MANY_KEYS_IN_FILTER: 34,
1948
+ CONTRACT_ERROR: 40,
1949
+ TRANSACTION_EXECUTION_ERROR: 41,
1950
+ STORAGE_PROOF_NOT_SUPPORTED: 42,
1951
+ CLASS_ALREADY_DECLARED: 51,
1952
+ INVALID_TRANSACTION_NONCE: 52,
1953
+ INSUFFICIENT_RESOURCES_FOR_VALIDATE: 53,
1954
+ INSUFFICIENT_ACCOUNT_BALANCE: 54,
1955
+ VALIDATION_FAILURE: 55,
1956
+ COMPILATION_FAILED: 56,
1957
+ CONTRACT_CLASS_SIZE_IS_TOO_LARGE: 57,
1958
+ NON_ACCOUNT: 58,
1959
+ DUPLICATE_TX: 59,
1960
+ COMPILED_CLASS_HASH_MISMATCH: 60,
1961
+ UNSUPPORTED_TX_VERSION: 61,
1962
+ UNSUPPORTED_CONTRACT_CLASS_VERSION: 62,
1963
+ UNEXPECTED_ERROR: 63,
1964
+ INVALID_SUBSCRIPTION_ID: 66,
1965
+ TOO_MANY_ADDRESSES_IN_FILTER: 67,
1966
+ TOO_MANY_BLOCKS_BACK: 68,
1967
+ COMPILATION_ERROR: 100,
1968
+ INVALID_ADDRESS: 150,
1969
+ TOKEN_NOT_SUPPORTED: 151,
1970
+ INVALID_SIGNATURE: 153,
1971
+ MAX_AMOUNT_TOO_LOW: 154,
1972
+ CLASS_HASH_NOT_SUPPORTED: 155,
1973
+ PAYMASTER_TRANSACTION_EXECUTION_ERROR: 156,
1974
+ INVALID_TIME_BOUNDS: 157,
1975
+ INVALID_DEPLOYMENT_DATA: 158,
1976
+ INVALID_CLASS_HASH: 159,
1977
+ INVALID_ID: 160,
1978
+ UNKNOWN_ERROR: 163
1979
+ };
1980
+ var rpc_default = errorCodes;
1981
+
1982
+ // src/utils/errors/index.ts
1983
+ function fixStack(target, fn = target.constructor) {
1984
+ const { captureStackTrace } = Error;
1985
+ captureStackTrace && captureStackTrace(target, fn);
1986
+ }
1987
+ function fixProto(target, prototype) {
1988
+ const { setPrototypeOf } = Object;
1989
+ setPrototypeOf ? setPrototypeOf(target, prototype) : target.__proto__ = prototype;
1990
+ }
1991
+ var CustomError = class extends Error {
1992
+ name;
1993
+ constructor(message) {
1994
+ super(message);
1995
+ Object.defineProperty(this, "name", {
1996
+ value: new.target.name,
1997
+ enumerable: false,
1998
+ configurable: true
1999
+ });
2000
+ fixProto(this, new.target.prototype);
2001
+ fixStack(this);
2002
+ }
2003
+ };
2004
+ var LibraryError = class extends CustomError {
2005
+ };
2006
+ var RpcError = class extends LibraryError {
2007
+ constructor(baseError, method, params) {
2008
+ super(`RPC: ${method} with params ${stringify2(params, null, 2)}
2009
+
2010
+ ${baseError.code}: ${baseError.message}: ${stringify2(baseError.data)}`);
2011
+ this.baseError = baseError;
2012
+ this.request = { method, params };
2013
+ }
2014
+ request;
2015
+ get code() {
2016
+ return this.baseError.code;
2017
+ }
2018
+ /**
2019
+ * Verifies the underlying RPC error, also serves as a type guard for the _baseError_ property
2020
+ * @example
2021
+ * ```typescript
2022
+ * SomeError.isType('UNEXPECTED_ERROR');
2023
+ * ```
2024
+ */
2025
+ isType(typeName) {
2026
+ return rpc_default[typeName] === this.code;
2027
+ }
2028
+ };
2029
+ var TimeoutError = class extends LibraryError {
2030
+ constructor(message) {
2031
+ super(message);
2032
+ this.name = "TimeoutError";
2033
+ }
2034
+ };
2035
+ var WebSocketNotConnectedError = class extends LibraryError {
2036
+ constructor(message) {
2037
+ super(message);
2038
+ this.name = "WebSocketNotConnectedError";
2039
+ }
2040
+ };
2041
+
2042
+ // src/utils/connect/buffer.ts
2043
+ var buffer_default = config.get("buffer") || typeof Buffer !== "undefined" && Buffer || typeof globalThis !== "undefined" && globalThis.Buffer || typeof window !== "undefined" && window.Buffer || typeof global !== "undefined" && global.Buffer || class {
2044
+ constructor() {
2045
+ throw new LibraryError(
2046
+ `Buffer not detected, use 'config.set("buffer", YourBufferPolyfill)' or polyfill or Node.js environment for Buffer support`
2047
+ );
2048
+ }
2049
+ static from(_data) {
2050
+ throw new LibraryError(
2051
+ `Buffer not detected, use 'config.set("buffer", YourBufferPolyfill)' or polyfill or Node.js environment for Buffer support`
2052
+ );
2053
+ }
2054
+ static isBuffer(obj) {
2055
+ const BufferImpl = config.get("buffer") || typeof Buffer !== "undefined" && Buffer;
2056
+ return BufferImpl && BufferImpl.isBuffer && BufferImpl.isBuffer(obj);
2057
+ }
2058
+ };
2059
+
2060
+ // src/utils/cairoDataTypes/uint32.ts
2061
+ var CairoUint32 = class _CairoUint32 {
2062
+ data;
2063
+ static abiSelector = "core::u32::u32";
2064
+ constructor(data) {
2065
+ _CairoUint32.validate(data);
2066
+ this.data = _CairoUint32.__processData(data);
2067
+ }
2068
+ static __processData(data) {
2069
+ if (isString(data) && isText(data)) {
2070
+ return utf8ToBigInt(data);
2071
+ }
2072
+ return BigInt(data);
2073
+ }
2074
+ toApiRequest() {
2075
+ return addCompiledFlag([this.toHexString()]);
2076
+ }
2077
+ toBigInt() {
2078
+ return this.data;
2079
+ }
2080
+ decodeUtf8() {
2081
+ return new TextDecoder().decode(bigIntToUint8Array(this.data));
2082
+ }
2083
+ toHexString() {
2084
+ return addHexPrefix(this.toBigInt().toString(16));
2085
+ }
2086
+ static validate(data) {
2087
+ assert(data !== null && data !== void 0, "Invalid input: null or undefined");
2088
+ assert(!isObject(data) && !Array.isArray(data), "Invalid input: objects are not supported");
2089
+ assert(
2090
+ !isNumber(data) || Number.isInteger(data),
2091
+ "Invalid input: decimal numbers are not supported, only integers"
2092
+ );
2093
+ const value = _CairoUint32.__processData(data);
2094
+ assert(value >= 0n && value <= 2n ** 32n - 1n, "Value is out of u32 range [0, 2^32)");
2095
+ }
2096
+ static is(data) {
2097
+ try {
2098
+ _CairoUint32.validate(data);
2099
+ return true;
2100
+ } catch {
2101
+ return false;
2102
+ }
2103
+ }
2104
+ /**
2105
+ * Check if provided abi type is this data type
2106
+ */
2107
+ static isAbiType(abiType) {
2108
+ return abiType === _CairoUint32.abiSelector;
2109
+ }
2110
+ static factoryFromApiResponse(responseIterator) {
2111
+ return new _CairoUint32(getNext(responseIterator));
2112
+ }
2113
+ };
2114
+
2115
+ // src/utils/cairoDataTypes/byteArray.ts
2116
+ var CairoByteArray = class _CairoByteArray {
2117
+ /**
2118
+ * entire dataset
2119
+ */
2120
+ data = [];
2121
+ /**
2122
+ * cairo specific implementation helper
2123
+ */
2124
+ pending_word;
2125
+ // felt
2126
+ /**
2127
+ * cairo specific implementation helper
2128
+ */
2129
+ pending_word_len;
2130
+ // u32
2131
+ static abiSelector = "core::byte_array::ByteArray";
2132
+ constructor(...arr) {
2133
+ if (arr.length === 3) {
2134
+ const [dataArg, pendingWord, pendingWordLen] = arr;
2135
+ assert(
2136
+ Array.isArray(dataArg) && pendingWord instanceof CairoFelt252 && pendingWordLen instanceof CairoUint32,
2137
+ "Invalid constructor parameters. Expected (CairoBytes31[], CairoFelt252, CairoUint32)"
2138
+ );
2139
+ this.data = dataArg;
2140
+ this.pending_word = pendingWord;
2141
+ this.pending_word_len = pendingWordLen;
2142
+ return;
2143
+ }
2144
+ const inData = arr[0];
2145
+ _CairoByteArray.validate(inData);
2146
+ const { data, pending_word, pending_word_len } = _CairoByteArray.__processData(inData);
2147
+ this.data = data;
2148
+ this.pending_word = pending_word;
2149
+ this.pending_word_len = pending_word_len;
2150
+ }
2151
+ static __processData(inData) {
2152
+ let fullData;
2153
+ if (inData instanceof Uint8Array) {
2154
+ fullData = inData;
2155
+ } else if (isBuffer(inData)) {
2156
+ fullData = new Uint8Array(inData);
2157
+ } else if (isString(inData)) {
2158
+ fullData = stringToUint8Array(inData);
2159
+ } else if (isBigInt(inData)) {
2160
+ fullData = bigIntToUint8Array(inData);
2161
+ } else if (isInteger2(inData)) {
2162
+ fullData = bigIntToUint8Array(BigInt(inData));
2163
+ } else {
2164
+ throw new Error("Invalid input type. Expected Uint8Array, Buffer, string, number, or bigint");
2165
+ }
2166
+ const CHUNK_SIZE = CairoBytes31.MAX_BYTE_SIZE;
2167
+ const completeChunks = Math.floor(fullData.length / CHUNK_SIZE);
2168
+ const remainderLength = fullData.length % CHUNK_SIZE;
2169
+ const data = [];
2170
+ let pending_word;
2171
+ let pending_word_len;
2172
+ for (let i = 0; i < completeChunks; i += 1) {
2173
+ const chunkStart = i * CHUNK_SIZE;
2174
+ const chunkEnd = chunkStart + CHUNK_SIZE;
2175
+ const chunk = fullData.slice(chunkStart, chunkEnd);
2176
+ data.push(new CairoBytes31(chunk));
2177
+ }
2178
+ if (remainderLength > 0) {
2179
+ const remainder = fullData.slice(completeChunks * CHUNK_SIZE);
2180
+ let hex = "0x";
2181
+ for (let i = 0; i < remainder.length; i += 1) {
2182
+ hex += remainder[i].toString(16).padStart(2, "0");
2183
+ }
2184
+ pending_word = new CairoFelt252(hex);
2185
+ pending_word_len = new CairoUint32(remainderLength);
2186
+ } else {
2187
+ pending_word = new CairoFelt252(0);
2188
+ pending_word_len = new CairoUint32(0);
2189
+ }
2190
+ return { data, pending_word, pending_word_len };
2191
+ }
2192
+ toApiRequest() {
2193
+ this.assertInitialized();
2194
+ return addCompiledFlag([
2195
+ addHexPrefix(this.data.length.toString(16)),
2196
+ ...this.data.flatMap((bytes31) => bytes31.toApiRequest()),
2197
+ ...this.pending_word.toApiRequest(),
2198
+ ...this.pending_word_len.toApiRequest()
2199
+ ]);
2200
+ }
2201
+ decodeUtf8() {
2202
+ const allBytes = this.reconstructBytes();
2203
+ const fullBytes = new Uint8Array(allBytes);
2204
+ return new TextDecoder().decode(fullBytes);
2205
+ }
2206
+ toBigInt() {
2207
+ const allBytes = this.reconstructBytes();
2208
+ if (allBytes.length === 0) {
2209
+ return 0n;
2210
+ }
2211
+ let result = 0n;
2212
+ allBytes.forEach((byte) => {
2213
+ result = result * 256n + BigInt(byte);
2214
+ });
2215
+ return result;
2216
+ }
2217
+ toHexString() {
2218
+ return addHexPrefix(this.toBigInt().toString(16));
2219
+ }
2220
+ toBuffer() {
2221
+ this.assertInitialized();
2222
+ const allBytes = [];
2223
+ this.data.forEach((chunk) => {
2224
+ const chunkBytes = chunk.data;
2225
+ for (let i = 0; i < chunkBytes.length; i += 1) {
2226
+ allBytes.push(chunkBytes[i]);
2227
+ }
2228
+ });
2229
+ const pendingLen = Number(this.pending_word_len.toBigInt());
2230
+ if (pendingLen > 0) {
2231
+ const hex = this.pending_word.toHexString();
2232
+ const hexWithoutPrefix = hex.startsWith("0x") ? hex.slice(2) : hex;
2233
+ const paddedHex = hexWithoutPrefix.length % 2 === 0 ? hexWithoutPrefix : `0${hexWithoutPrefix}`;
2234
+ for (let i = 0; i < pendingLen; i += 1) {
2235
+ const byteHex = paddedHex.slice(i * 2, i * 2 + 2);
2236
+ if (byteHex.length >= 2) {
2237
+ const byteValue = parseInt(byteHex, 16);
2238
+ if (!Number.isNaN(byteValue)) {
2239
+ allBytes.push(byteValue);
2240
+ }
2241
+ }
2242
+ }
2243
+ }
2244
+ return buffer_default.from(allBytes);
2245
+ }
2246
+ static validate(data) {
2247
+ assert(data !== null && data !== void 0, "Invalid input: null or undefined");
2248
+ assert(
2249
+ !Array.isArray(data) || data instanceof Uint8Array,
2250
+ "Invalid input: arrays are not supported, use Uint8Array"
2251
+ );
2252
+ assert(
2253
+ typeof data !== "object" || isBuffer(data) || data instanceof Uint8Array,
2254
+ "Invalid input for CairoByteArray: objects are not supported"
2255
+ );
2256
+ assert(
2257
+ !isNumber(data) || Number.isInteger(data),
2258
+ "Invalid input for CairoByteArray: decimal numbers are not supported, only integers"
2259
+ );
2260
+ assert(
2261
+ !isNumber(data) || data >= 0,
2262
+ "Invalid input for CairoByteArray: negative numbers are not supported"
2263
+ );
2264
+ assert(
2265
+ !isBigInt(data) || data >= 0n,
2266
+ "Invalid input for CairoByteArray: negative bigints are not supported"
2267
+ );
2268
+ assert(
2269
+ data instanceof Uint8Array || isBuffer(data) || isString(data) || isNumber(data) || isBigInt(data),
2270
+ "Invalid input type. Expected Uint8Array, Buffer, string, number, or bigint"
2271
+ );
2272
+ }
2273
+ /**
2274
+ * Check if the provided data is a valid CairoByteArray
2275
+ *
2276
+ * @param data - The data to check
2277
+ * @returns True if the data is a valid CairoByteArray, false otherwise
2278
+ */
2279
+ static is(data) {
2280
+ try {
2281
+ _CairoByteArray.validate(data);
2282
+ return true;
2283
+ } catch {
2284
+ return false;
2285
+ }
2286
+ }
2287
+ /**
2288
+ * Check if provided abi type is this data type
2289
+ */
2290
+ static isAbiType(abiType) {
2291
+ return abiType === _CairoByteArray.abiSelector;
2292
+ }
2293
+ /**
2294
+ * Private helper to check if the CairoByteArray is properly initialized
2295
+ */
2296
+ assertInitialized() {
2297
+ assert(
2298
+ this.data && this.pending_word !== void 0 && this.pending_word_len !== void 0,
2299
+ "CairoByteArray is not properly initialized"
2300
+ );
2301
+ }
2302
+ /**
2303
+ * Private helper to reconstruct the full byte sequence from chunks and pending word
2304
+ */
2305
+ reconstructBytes() {
2306
+ this.assertInitialized();
2307
+ const allBytes = [];
2308
+ this.data.forEach((chunk) => {
2309
+ const chunkBytes = chunk.data;
2310
+ for (let i = 0; i < chunkBytes.length; i += 1) {
2311
+ allBytes.push(chunkBytes[i]);
2312
+ }
2313
+ });
2314
+ const pendingLen = Number(this.pending_word_len.toBigInt());
2315
+ if (pendingLen > 0) {
2316
+ const hex = this.pending_word.toHexString();
2317
+ const hexWithoutPrefix = hex.startsWith("0x") ? hex.slice(2) : hex;
2318
+ const paddedHex = hexWithoutPrefix.length % 2 === 0 ? hexWithoutPrefix : `0${hexWithoutPrefix}`;
2319
+ for (let i = 0; i < pendingLen; i += 1) {
2320
+ const byteHex = paddedHex.slice(i * 2, i * 2 + 2);
2321
+ if (byteHex.length < 2) {
2322
+ allBytes.push(0);
2323
+ } else {
2324
+ const byteValue = parseInt(byteHex, 16);
2325
+ if (Number.isNaN(byteValue)) {
2326
+ throw new Error(`Invalid hex byte: ${byteHex}`);
2327
+ }
2328
+ allBytes.push(byteValue);
2329
+ }
2330
+ }
2331
+ }
2332
+ return allBytes;
2333
+ }
2334
+ static factoryFromApiResponse(responseIterator) {
2335
+ const data = Array.from(
2336
+ { length: Number(getNext(responseIterator)) },
2337
+ () => CairoBytes31.factoryFromApiResponse(responseIterator)
2338
+ );
2339
+ const pending_word = CairoFelt252.factoryFromApiResponse(responseIterator);
2340
+ const pending_word_len = CairoUint32.factoryFromApiResponse(responseIterator);
2341
+ return new _CairoByteArray(data, pending_word, pending_word_len);
2342
+ }
2343
+ };
2344
+
2345
+ // src/utils/cairoDataTypes/uint8.ts
2346
+ var CairoUint8 = class _CairoUint8 {
2347
+ data;
2348
+ static abiSelector = "core::integer::u8";
2349
+ constructor(data) {
2350
+ _CairoUint8.validate(data);
2351
+ this.data = _CairoUint8.__processData(data);
2352
+ }
2353
+ static __processData(data) {
2354
+ if (isString(data) && isText(data)) {
2355
+ return utf8ToBigInt(data);
2356
+ }
2357
+ return BigInt(data);
2358
+ }
2359
+ toApiRequest() {
2360
+ return addCompiledFlag([this.toHexString()]);
2361
+ }
2362
+ toBigInt() {
2363
+ return this.data;
2364
+ }
2365
+ decodeUtf8() {
2366
+ return new TextDecoder().decode(bigIntToUint8Array(this.data));
2367
+ }
2368
+ toHexString() {
2369
+ return addHexPrefix(this.toBigInt().toString(16));
2370
+ }
2371
+ static validate(data) {
2372
+ assert(data !== null && data !== void 0, "Invalid input: null or undefined");
2373
+ assert(!isObject(data) && !Array.isArray(data), "Invalid input: objects are not supported");
2374
+ assert(
2375
+ !isNumber(data) || Number.isInteger(data),
2376
+ "Invalid input: decimal numbers are not supported, only integers"
2377
+ );
2378
+ const value = _CairoUint8.__processData(data);
2379
+ assert(
2380
+ value >= RANGE_U8.min && value <= RANGE_U8.max,
2381
+ `Value is out of u8 range [${RANGE_U8.min}, ${RANGE_U8.max}]`
2382
+ );
2383
+ }
2384
+ static is(data) {
2385
+ try {
2386
+ _CairoUint8.validate(data);
2387
+ return true;
2388
+ } catch {
2389
+ return false;
2390
+ }
2391
+ }
2392
+ /**
2393
+ * Check if provided abi type is this data type
2394
+ */
2395
+ static isAbiType(abiType) {
2396
+ return abiType === _CairoUint8.abiSelector;
2397
+ }
2398
+ static factoryFromApiResponse(responseIterator) {
2399
+ return new _CairoUint8(getNext(responseIterator));
2400
+ }
2401
+ };
2402
+
2403
+ // src/utils/cairoDataTypes/uint16.ts
2404
+ var CairoUint16 = class _CairoUint16 {
2405
+ data;
2406
+ static abiSelector = "core::integer::u16";
2407
+ constructor(data) {
2408
+ _CairoUint16.validate(data);
2409
+ this.data = _CairoUint16.__processData(data);
2410
+ }
2411
+ static __processData(data) {
2412
+ if (isString(data) && isText(data)) {
2413
+ return utf8ToBigInt(data);
2414
+ }
2415
+ return BigInt(data);
2416
+ }
2417
+ toApiRequest() {
2418
+ return addCompiledFlag([this.toHexString()]);
2419
+ }
2420
+ toBigInt() {
2421
+ return this.data;
2422
+ }
2423
+ decodeUtf8() {
2424
+ return new TextDecoder().decode(bigIntToUint8Array(this.data));
2425
+ }
2426
+ toHexString() {
2427
+ return addHexPrefix(this.toBigInt().toString(16));
2428
+ }
2429
+ static validate(data) {
2430
+ assert(data !== null && data !== void 0, "Invalid input: null or undefined");
2431
+ assert(!isObject(data) && !Array.isArray(data), "Invalid input: objects are not supported");
2432
+ assert(
2433
+ !isNumber(data) || Number.isInteger(data),
2434
+ "Invalid input: decimal numbers are not supported, only integers"
2435
+ );
2436
+ const value = _CairoUint16.__processData(data);
2437
+ assert(
2438
+ value >= RANGE_U16.min && value <= RANGE_U16.max,
2439
+ `Value is out of u16 range [${RANGE_U16.min}, ${RANGE_U16.max}]`
2440
+ );
2441
+ }
2442
+ static is(data) {
2443
+ try {
2444
+ _CairoUint16.validate(data);
2445
+ return true;
2446
+ } catch {
2447
+ return false;
2448
+ }
2449
+ }
2450
+ /**
2451
+ * Check if provided abi type is this data type
2452
+ */
2453
+ static isAbiType(abiType) {
2454
+ return abiType === _CairoUint16.abiSelector;
2455
+ }
2456
+ static factoryFromApiResponse(responseIterator) {
2457
+ return new _CairoUint16(getNext(responseIterator));
2458
+ }
2459
+ };
2460
+
2461
+ // src/utils/cairoDataTypes/uint64.ts
2462
+ var CairoUint64 = class _CairoUint64 {
2463
+ data;
2464
+ static abiSelector = "core::integer::u64";
2465
+ constructor(data) {
2466
+ _CairoUint64.validate(data);
2467
+ this.data = _CairoUint64.__processData(data);
2468
+ }
2469
+ static __processData(data) {
2470
+ if (isString(data) && isText(data)) {
2471
+ return utf8ToBigInt(data);
2472
+ }
2473
+ return BigInt(data);
2474
+ }
2475
+ toApiRequest() {
2476
+ return addCompiledFlag([this.toHexString()]);
2477
+ }
2478
+ toBigInt() {
2479
+ return this.data;
2480
+ }
2481
+ decodeUtf8() {
2482
+ return new TextDecoder().decode(bigIntToUint8Array(this.data));
2483
+ }
2484
+ toHexString() {
2485
+ return addHexPrefix(this.toBigInt().toString(16));
2486
+ }
2487
+ static validate(data) {
2488
+ assert(data !== null && data !== void 0, "Invalid input: null or undefined");
2489
+ assert(!isObject(data) && !Array.isArray(data), "Invalid input: objects are not supported");
2490
+ assert(
2491
+ !isNumber(data) || Number.isInteger(data),
2492
+ "Invalid input: decimal numbers are not supported, only integers"
2493
+ );
2494
+ const value = _CairoUint64.__processData(data);
2495
+ assert(
2496
+ value >= RANGE_U64.min && value <= RANGE_U64.max,
2497
+ `Value is out of u64 range [${RANGE_U64.min}, ${RANGE_U64.max}]`
2498
+ );
2499
+ }
2500
+ static is(data) {
2501
+ try {
2502
+ _CairoUint64.validate(data);
2503
+ return true;
2504
+ } catch {
2505
+ return false;
2506
+ }
2507
+ }
2508
+ /**
2509
+ * Check if provided abi type is this data type
2510
+ */
2511
+ static isAbiType(abiType) {
2512
+ return abiType === _CairoUint64.abiSelector;
2513
+ }
2514
+ static factoryFromApiResponse(responseIterator) {
2515
+ return new _CairoUint64(getNext(responseIterator));
2516
+ }
2517
+ };
2518
+
2519
+ // src/utils/cairoDataTypes/uint96.ts
2520
+ var CairoUint96 = class _CairoUint96 {
2521
+ data;
2522
+ static abiSelector = "core::integer::u96";
2523
+ constructor(data) {
2524
+ _CairoUint96.validate(data);
2525
+ this.data = _CairoUint96.__processData(data);
2526
+ }
2527
+ static __processData(data) {
2528
+ if (isString(data) && isText(data)) {
2529
+ return utf8ToBigInt(data);
2530
+ }
2531
+ return BigInt(data);
2532
+ }
2533
+ toApiRequest() {
2534
+ return addCompiledFlag([this.toHexString()]);
2535
+ }
2536
+ toBigInt() {
2537
+ return this.data;
2538
+ }
2539
+ decodeUtf8() {
2540
+ return new TextDecoder().decode(bigIntToUint8Array(this.data));
2541
+ }
2542
+ toHexString() {
2543
+ return addHexPrefix(this.toBigInt().toString(16));
2544
+ }
2545
+ static validate(data) {
2546
+ assert(data !== null && data !== void 0, "Invalid input: null or undefined");
2547
+ assert(!isObject(data) && !Array.isArray(data), "Invalid input: objects are not supported");
2548
+ assert(
2549
+ !isNumber(data) || Number.isInteger(data),
2550
+ "Invalid input: decimal numbers are not supported, only integers"
2551
+ );
2552
+ const value = _CairoUint96.__processData(data);
2553
+ assert(
2554
+ value >= RANGE_U96.min && value <= RANGE_U96.max,
2555
+ `Value is out of u96 range [${RANGE_U96.min}, ${RANGE_U96.max}]`
2556
+ );
2557
+ }
2558
+ static is(data) {
2559
+ try {
2560
+ _CairoUint96.validate(data);
2561
+ return true;
2562
+ } catch {
2563
+ return false;
2564
+ }
2565
+ }
2566
+ /**
2567
+ * Check if provided abi type is this data type
2568
+ */
2569
+ static isAbiType(abiType) {
2570
+ return abiType === _CairoUint96.abiSelector;
2571
+ }
2572
+ static factoryFromApiResponse(responseIterator) {
2573
+ return new _CairoUint96(getNext(responseIterator));
2574
+ }
2575
+ };
2576
+
2577
+ // src/utils/cairoDataTypes/uint128.ts
2578
+ var CairoUint128 = class _CairoUint128 {
2579
+ data;
2580
+ static abiSelector = "core::integer::u128";
2581
+ constructor(data) {
2582
+ _CairoUint128.validate(data);
2583
+ this.data = _CairoUint128.__processData(data);
2584
+ }
2585
+ static __processData(data) {
2586
+ if (isString(data) && isText(data)) {
2587
+ return utf8ToBigInt(data);
2588
+ }
2589
+ return BigInt(data);
2590
+ }
2591
+ toApiRequest() {
2592
+ return addCompiledFlag([this.toHexString()]);
2593
+ }
2594
+ toBigInt() {
2595
+ return this.data;
2596
+ }
2597
+ decodeUtf8() {
2598
+ return new TextDecoder().decode(bigIntToUint8Array(this.data));
2599
+ }
2600
+ toHexString() {
2601
+ return addHexPrefix(this.toBigInt().toString(16));
2602
+ }
2603
+ static validate(data) {
2604
+ assert(data !== null && data !== void 0, "Invalid input: null or undefined");
2605
+ assert(!isObject(data) && !Array.isArray(data), "Invalid input: objects are not supported");
2606
+ assert(
2607
+ !isNumber(data) || Number.isInteger(data),
2608
+ "Invalid input: decimal numbers are not supported, only integers"
2609
+ );
2610
+ const value = _CairoUint128.__processData(data);
2611
+ assert(
2612
+ value >= RANGE_U128.min && value <= RANGE_U128.max,
2613
+ `Value is out of u128 range [${RANGE_U128.min}, ${RANGE_U128.max}]`
2614
+ );
2615
+ }
2616
+ static is(data) {
2617
+ try {
2618
+ _CairoUint128.validate(data);
2619
+ return true;
2620
+ } catch {
2621
+ return false;
2622
+ }
2623
+ }
2624
+ /**
2625
+ * Check if provided abi type is this data type
2626
+ */
2627
+ static isAbiType(abiType) {
2628
+ return abiType === _CairoUint128.abiSelector;
2629
+ }
2630
+ static factoryFromApiResponse(responseIterator) {
2631
+ return new _CairoUint128(getNext(responseIterator));
2632
+ }
2633
+ };
2634
+
2635
+ // src/utils/cairoDataTypes/int8.ts
2636
+ var CairoInt8 = class _CairoInt8 {
2637
+ data;
2638
+ static abiSelector = "core::integer::i8";
2639
+ constructor(data) {
2640
+ _CairoInt8.validate(data);
2641
+ this.data = _CairoInt8.__processData(data);
2642
+ }
2643
+ static __processData(data) {
2644
+ if (isString(data) && isText(data)) {
2645
+ return utf8ToBigInt(data);
2646
+ }
2647
+ return BigInt(data);
2648
+ }
2649
+ toApiRequest() {
2650
+ return addCompiledFlag([this.toHexString()]);
2651
+ }
2652
+ toBigInt() {
2653
+ return this.data;
2654
+ }
2655
+ decodeUtf8() {
2656
+ return new TextDecoder().decode(
2657
+ bigIntToUint8Array(this.data >= 0n ? this.data : 256n + this.data)
2658
+ );
2659
+ }
2660
+ /**
2661
+ * For negative values field element representation as positive hex string.
2662
+ * @returns cairo field arithmetic hex string
2663
+ */
2664
+ toHexString() {
2665
+ const value = this.toBigInt();
2666
+ if (value < 0n) {
2667
+ const fieldElement = PRIME + value;
2668
+ return addHexPrefix(fieldElement.toString(16));
2669
+ }
2670
+ return addHexPrefix(value.toString(16));
2671
+ }
2672
+ static validate(data) {
2673
+ assert(data !== null && data !== void 0, "Invalid input: null or undefined");
2674
+ assert(!isObject(data) && !Array.isArray(data), "Invalid input: objects are not supported");
2675
+ assert(
2676
+ !isNumber(data) || Number.isInteger(data),
2677
+ "Invalid input: decimal numbers are not supported, only integers"
2678
+ );
2679
+ const value = _CairoInt8.__processData(data);
2680
+ assert(
2681
+ value >= RANGE_I8.min && value <= RANGE_I8.max,
2682
+ `Value is out of i8 range [${RANGE_I8.min}, ${RANGE_I8.max}]`
2683
+ );
2684
+ }
2685
+ static is(data) {
2686
+ try {
2687
+ _CairoInt8.validate(data);
2688
+ return true;
2689
+ } catch {
2690
+ return false;
2691
+ }
2692
+ }
2693
+ /**
2694
+ * Check if provided abi type is this data type
2695
+ */
2696
+ static isAbiType(abiType) {
2697
+ return abiType === _CairoInt8.abiSelector;
2698
+ }
2699
+ static factoryFromApiResponse(responseIterator) {
2700
+ const response = getNext(responseIterator);
2701
+ const value = BigInt(response);
2702
+ const signedValue = value > PRIME / 2n ? value - PRIME : value;
2703
+ return new _CairoInt8(signedValue);
2704
+ }
2705
+ };
2706
+
2707
+ // src/utils/cairoDataTypes/int16.ts
2708
+ var CairoInt16 = class _CairoInt16 {
2709
+ data;
2710
+ static abiSelector = "core::integer::i16";
2711
+ constructor(data) {
2712
+ _CairoInt16.validate(data);
2713
+ this.data = _CairoInt16.__processData(data);
2714
+ }
2715
+ static __processData(data) {
2716
+ if (isString(data) && isText(data)) {
2717
+ return utf8ToBigInt(data);
2718
+ }
2719
+ return BigInt(data);
2720
+ }
2721
+ toApiRequest() {
2722
+ return addCompiledFlag([this.toHexString()]);
2723
+ }
2724
+ toBigInt() {
2725
+ return this.data;
2726
+ }
2727
+ decodeUtf8() {
2728
+ return new TextDecoder().decode(
2729
+ bigIntToUint8Array(this.data >= 0n ? this.data : 65536n + this.data)
2730
+ );
2731
+ }
2732
+ /**
2733
+ * For negative values field element representation as positive hex string.
2734
+ * @returns cairo field arithmetic hex string
2735
+ */
2736
+ toHexString() {
2737
+ const value = this.toBigInt();
2738
+ if (value < 0n) {
2739
+ const fieldElement = PRIME + value;
2740
+ return addHexPrefix(fieldElement.toString(16));
2741
+ }
2742
+ return addHexPrefix(value.toString(16));
2743
+ }
2744
+ static validate(data) {
2745
+ assert(data !== null && data !== void 0, "Invalid input: null or undefined");
2746
+ assert(!isObject(data) && !Array.isArray(data), "Invalid input: objects are not supported");
2747
+ assert(
2748
+ !isNumber(data) || Number.isInteger(data),
2749
+ "Invalid input: decimal numbers are not supported, only integers"
2750
+ );
2751
+ const value = _CairoInt16.__processData(data);
2752
+ assert(
2753
+ value >= RANGE_I16.min && value <= RANGE_I16.max,
2754
+ `Value is out of i16 range [${RANGE_I16.min}, ${RANGE_I16.max}]`
2755
+ );
2756
+ }
2757
+ static is(data) {
2758
+ try {
2759
+ _CairoInt16.validate(data);
2760
+ return true;
2761
+ } catch {
2762
+ return false;
2763
+ }
2764
+ }
2765
+ /**
2766
+ * Check if provided abi type is this data type
2767
+ */
2768
+ static isAbiType(abiType) {
2769
+ return abiType === _CairoInt16.abiSelector;
2770
+ }
2771
+ static factoryFromApiResponse(responseIterator) {
2772
+ const response = getNext(responseIterator);
2773
+ const value = BigInt(response);
2774
+ const signedValue = value > PRIME / 2n ? value - PRIME : value;
2775
+ return new _CairoInt16(signedValue);
2776
+ }
2777
+ };
2778
+
2779
+ // src/utils/cairoDataTypes/int32.ts
2780
+ var CairoInt32 = class _CairoInt32 {
2781
+ data;
2782
+ static abiSelector = "core::integer::i32";
2783
+ constructor(data) {
2784
+ _CairoInt32.validate(data);
2785
+ this.data = _CairoInt32.__processData(data);
2786
+ }
2787
+ static __processData(data) {
2788
+ if (isString(data) && isText(data)) {
2789
+ return utf8ToBigInt(data);
2790
+ }
2791
+ return BigInt(data);
2792
+ }
2793
+ toApiRequest() {
2794
+ return addCompiledFlag([this.toHexString()]);
2795
+ }
2796
+ toBigInt() {
2797
+ return this.data;
2798
+ }
2799
+ decodeUtf8() {
2800
+ return new TextDecoder().decode(
2801
+ bigIntToUint8Array(this.data >= 0n ? this.data : 4294967296n + this.data)
2802
+ );
2803
+ }
2804
+ /**
2805
+ * For negative values field element representation as positive hex string.
2806
+ * @returns cairo field arithmetic hex string
2807
+ */
2808
+ toHexString() {
2809
+ const value = this.toBigInt();
2810
+ if (value < 0n) {
2811
+ const fieldElement = PRIME + value;
2812
+ return addHexPrefix(fieldElement.toString(16));
2813
+ }
2814
+ return addHexPrefix(value.toString(16));
2815
+ }
2816
+ static validate(data) {
2817
+ assert(data !== null && data !== void 0, "Invalid input: null or undefined");
2818
+ assert(!isObject(data) && !Array.isArray(data), "Invalid input: objects are not supported");
2819
+ assert(
2820
+ !isNumber(data) || Number.isInteger(data),
2821
+ "Invalid input: decimal numbers are not supported, only integers"
2822
+ );
2823
+ const value = _CairoInt32.__processData(data);
2824
+ assert(
2825
+ value >= RANGE_I32.min && value <= RANGE_I32.max,
2826
+ `Value is out of i32 range [${RANGE_I32.min}, ${RANGE_I32.max}]`
2827
+ );
2828
+ }
2829
+ static is(data) {
2830
+ try {
2831
+ _CairoInt32.validate(data);
2832
+ return true;
2833
+ } catch {
2834
+ return false;
2835
+ }
2836
+ }
2837
+ /**
2838
+ * Check if provided abi type is this data type
2839
+ */
2840
+ static isAbiType(abiType) {
2841
+ return abiType === _CairoInt32.abiSelector;
2842
+ }
2843
+ static factoryFromApiResponse(responseIterator) {
2844
+ const response = getNext(responseIterator);
2845
+ const value = BigInt(response);
2846
+ const signedValue = value > PRIME / 2n ? value - PRIME : value;
2847
+ return new _CairoInt32(signedValue);
2848
+ }
2849
+ };
2850
+
2851
+ // src/utils/cairoDataTypes/int64.ts
2852
+ var CairoInt64 = class _CairoInt64 {
2853
+ data;
2854
+ static abiSelector = "core::integer::i64";
2855
+ constructor(data) {
2856
+ _CairoInt64.validate(data);
2857
+ this.data = _CairoInt64.__processData(data);
2858
+ }
2859
+ static __processData(data) {
2860
+ if (isString(data) && isText(data)) {
2861
+ return utf8ToBigInt(data);
2862
+ }
2863
+ return BigInt(data);
2864
+ }
2865
+ toApiRequest() {
2866
+ return addCompiledFlag([this.toHexString()]);
2867
+ }
2868
+ toBigInt() {
2869
+ return this.data;
2870
+ }
2871
+ decodeUtf8() {
2872
+ return new TextDecoder().decode(
2873
+ bigIntToUint8Array(this.data >= 0n ? this.data : 2n ** 64n + this.data)
2874
+ );
2875
+ }
2876
+ /**
2877
+ * For negative values field element representation as positive hex string.
2878
+ * @returns cairo field arithmetic hex string
2879
+ */
2880
+ toHexString() {
2881
+ const value = this.toBigInt();
2882
+ if (value < 0n) {
2883
+ const fieldElement = PRIME + value;
2884
+ return addHexPrefix(fieldElement.toString(16));
2885
+ }
2886
+ return addHexPrefix(value.toString(16));
2887
+ }
2888
+ static validate(data) {
2889
+ assert(data !== null && data !== void 0, "Invalid input: null or undefined");
2890
+ assert(!isObject(data) && !Array.isArray(data), "Invalid input: objects are not supported");
2891
+ assert(
2892
+ !isNumber(data) || Number.isInteger(data),
2893
+ "Invalid input: decimal numbers are not supported, only integers"
2894
+ );
2895
+ const value = _CairoInt64.__processData(data);
2896
+ assert(
2897
+ value >= RANGE_I64.min && value <= RANGE_I64.max,
2898
+ `Value is out of i64 range [${RANGE_I64.min}, ${RANGE_I64.max}]`
2899
+ );
2900
+ }
2901
+ static is(data) {
2902
+ try {
2903
+ _CairoInt64.validate(data);
2904
+ return true;
2905
+ } catch {
2906
+ return false;
2907
+ }
2908
+ }
2909
+ /**
2910
+ * Check if provided abi type is this data type
2911
+ */
2912
+ static isAbiType(abiType) {
2913
+ return abiType === _CairoInt64.abiSelector;
2914
+ }
2915
+ static factoryFromApiResponse(responseIterator) {
2916
+ const response = getNext(responseIterator);
2917
+ const value = BigInt(response);
2918
+ const signedValue = value > PRIME / 2n ? value - PRIME : value;
2919
+ return new _CairoInt64(signedValue);
2920
+ }
2921
+ };
2922
+
2923
+ // src/utils/cairoDataTypes/int128.ts
2924
+ var CairoInt128 = class _CairoInt128 {
2925
+ data;
2926
+ static abiSelector = "core::integer::i128";
2927
+ constructor(data) {
2928
+ _CairoInt128.validate(data);
2929
+ this.data = _CairoInt128.__processData(data);
2930
+ }
2931
+ static __processData(data) {
2932
+ if (isString(data) && isText(data)) {
2933
+ return utf8ToBigInt(data);
2934
+ }
2935
+ return BigInt(data);
2936
+ }
2937
+ toApiRequest() {
2938
+ return addCompiledFlag([this.toHexString()]);
2939
+ }
2940
+ toBigInt() {
2941
+ return this.data;
2942
+ }
2943
+ decodeUtf8() {
2944
+ return new TextDecoder().decode(
2945
+ bigIntToUint8Array(this.data >= 0n ? this.data : 2n ** 128n + this.data)
2946
+ );
2947
+ }
2948
+ /**
2949
+ * For negative values field element representation as positive hex string.
2950
+ * @returns cairo field arithmetic hex string
2951
+ */
2952
+ toHexString() {
2953
+ const value = this.toBigInt();
2954
+ if (value < 0n) {
2955
+ const fieldElement = PRIME + value;
2956
+ return addHexPrefix(fieldElement.toString(16));
2957
+ }
2958
+ return addHexPrefix(value.toString(16));
2959
+ }
2960
+ static validate(data) {
2961
+ assert(data !== null && data !== void 0, "Invalid input: null or undefined");
2962
+ assert(!isObject(data) && !Array.isArray(data), "Invalid input: objects are not supported");
2963
+ assert(
2964
+ !isNumber(data) || Number.isInteger(data),
2965
+ "Invalid input: decimal numbers are not supported, only integers"
2966
+ );
2967
+ const value = _CairoInt128.__processData(data);
2968
+ assert(
2969
+ value >= RANGE_I128.min && value <= RANGE_I128.max,
2970
+ `Value is out of i128 range [${RANGE_I128.min}, ${RANGE_I128.max}]`
2971
+ );
2972
+ }
2973
+ static is(data) {
2974
+ try {
2975
+ _CairoInt128.validate(data);
2976
+ return true;
2977
+ } catch {
2978
+ return false;
2979
+ }
2980
+ }
2981
+ /**
2982
+ * Check if provided abi type is this data type
2983
+ */
2984
+ static isAbiType(abiType) {
2985
+ return abiType === _CairoInt128.abiSelector;
2986
+ }
2987
+ static factoryFromApiResponse(responseIterator) {
2988
+ const response = getNext(responseIterator);
2989
+ const value = BigInt(response);
2990
+ const signedValue = value > PRIME / 2n ? value - PRIME : value;
2991
+ return new _CairoInt128(signedValue);
2992
+ }
2993
+ };
2994
+
2995
+ // src/utils/calldata/parser/parsingStrategy.ts
2996
+ var hdParsingStrategy = {
2997
+ // TODO: provjeri svi request parseri stvaraju array, dali je to ok sa requstParserom
2998
+ request: {
2999
+ [CairoBytes31.abiSelector]: (val) => {
3000
+ return new CairoBytes31(val).toApiRequest();
3001
+ },
3002
+ [CairoByteArray.abiSelector]: (val) => {
3003
+ return new CairoByteArray(val).toApiRequest();
3004
+ },
3005
+ [CairoFelt252.abiSelector]: (val) => {
3006
+ return new CairoFelt252(val).toApiRequest();
3007
+ },
3008
+ [CairoUint256.abiSelector]: (val) => {
3009
+ return new CairoUint256(val).toApiRequest();
3010
+ },
3011
+ [CairoUint512.abiSelector]: (val) => {
3012
+ return new CairoUint512(val).toApiRequest();
3013
+ },
3014
+ [CairoUint8.abiSelector]: (val) => {
3015
+ return new CairoUint8(val).toApiRequest();
3016
+ },
3017
+ [CairoUint16.abiSelector]: (val) => {
3018
+ return new CairoUint16(val).toApiRequest();
3019
+ },
3020
+ [CairoUint64.abiSelector]: (val) => {
3021
+ return new CairoUint64(val).toApiRequest();
3022
+ },
3023
+ [CairoUint96.abiSelector]: (val) => {
3024
+ return new CairoUint96(val).toApiRequest();
3025
+ },
3026
+ [CairoUint128.abiSelector]: (val) => {
3027
+ return new CairoUint128(val).toApiRequest();
3028
+ },
3029
+ [CairoInt8.abiSelector]: (val) => {
3030
+ return new CairoInt8(val).toApiRequest();
3031
+ },
3032
+ [CairoInt16.abiSelector]: (val) => {
3033
+ return new CairoInt16(val).toApiRequest();
3034
+ },
3035
+ [CairoInt32.abiSelector]: (val) => {
3036
+ return new CairoInt32(val).toApiRequest();
3037
+ },
3038
+ [CairoInt64.abiSelector]: (val) => {
3039
+ return new CairoInt64(val).toApiRequest();
3040
+ },
3041
+ [CairoInt128.abiSelector]: (val) => {
3042
+ return new CairoInt128(val).toApiRequest();
3043
+ }
3044
+ },
3045
+ response: {
3046
+ [CairoBytes31.abiSelector]: (responseIterator) => {
3047
+ return CairoBytes31.factoryFromApiResponse(responseIterator).decodeUtf8();
3048
+ },
3049
+ [CairoByteArray.abiSelector]: (responseIterator) => {
3050
+ return CairoByteArray.factoryFromApiResponse(responseIterator).decodeUtf8();
3051
+ },
3052
+ [CairoFelt252.abiSelector]: (responseIterator) => {
3053
+ return CairoFelt252.factoryFromApiResponse(responseIterator).toBigInt();
3054
+ },
3055
+ [CairoUint256.abiSelector]: (responseIterator) => {
3056
+ return CairoUint256.factoryFromApiResponse(responseIterator).toBigInt();
3057
+ },
3058
+ [CairoUint512.abiSelector]: (responseIterator) => {
3059
+ return CairoUint512.factoryFromApiResponse(responseIterator).toBigInt();
3060
+ },
3061
+ [CairoUint8.abiSelector]: (responseIterator) => {
3062
+ return CairoUint8.factoryFromApiResponse(responseIterator).toBigInt();
3063
+ },
3064
+ [CairoUint16.abiSelector]: (responseIterator) => {
3065
+ return CairoUint16.factoryFromApiResponse(responseIterator).toBigInt();
3066
+ },
3067
+ [CairoUint64.abiSelector]: (responseIterator) => {
3068
+ return CairoUint64.factoryFromApiResponse(responseIterator).toBigInt();
3069
+ },
3070
+ [CairoUint96.abiSelector]: (responseIterator) => {
3071
+ return CairoUint96.factoryFromApiResponse(responseIterator).toBigInt();
3072
+ },
3073
+ [CairoUint128.abiSelector]: (responseIterator) => {
3074
+ return CairoUint128.factoryFromApiResponse(responseIterator).toBigInt();
3075
+ },
3076
+ [CairoInt8.abiSelector]: (responseIterator) => {
3077
+ return CairoInt8.factoryFromApiResponse(responseIterator).toBigInt();
3078
+ },
3079
+ [CairoInt16.abiSelector]: (responseIterator) => {
3080
+ return CairoInt16.factoryFromApiResponse(responseIterator).toBigInt();
3081
+ },
3082
+ [CairoInt32.abiSelector]: (responseIterator) => {
3083
+ return CairoInt32.factoryFromApiResponse(responseIterator).toBigInt();
3084
+ },
3085
+ [CairoInt64.abiSelector]: (responseIterator) => {
3086
+ return CairoInt64.factoryFromApiResponse(responseIterator).toBigInt();
3087
+ },
3088
+ [CairoInt128.abiSelector]: (responseIterator) => {
3089
+ return CairoInt128.factoryFromApiResponse(responseIterator).toBigInt();
3090
+ }
3091
+ }
3092
+ };
3093
+ var fastParsingStrategy = {
3094
+ request: {
3095
+ [CairoBytes31.abiSelector]: (val) => {
3096
+ return new CairoBytes31(val).toApiRequest();
3097
+ },
3098
+ [CairoByteArray.abiSelector]: (val) => {
3099
+ return new CairoByteArray(val).toApiRequest();
3100
+ },
3101
+ [CairoFelt252.abiSelector]: (val) => {
3102
+ return felt(val);
3103
+ },
3104
+ [CairoUint256.abiSelector]: (val) => {
3105
+ return new CairoUint256(val).toApiRequest();
3106
+ },
3107
+ [CairoUint512.abiSelector]: (val) => {
3108
+ return new CairoUint512(val).toApiRequest();
3109
+ },
3110
+ [CairoUint8.abiSelector]: (val) => {
3111
+ return felt(val);
3112
+ },
3113
+ [CairoUint16.abiSelector]: (val) => {
3114
+ return felt(val);
3115
+ },
3116
+ [CairoUint64.abiSelector]: (val) => {
3117
+ return felt(val);
3118
+ },
3119
+ [CairoUint96.abiSelector]: (val) => {
3120
+ return felt(val);
3121
+ },
3122
+ [CairoUint128.abiSelector]: (val) => {
3123
+ return felt(val);
3124
+ },
3125
+ [CairoInt8.abiSelector]: (val) => {
3126
+ return new CairoInt8(val).toApiRequest();
3127
+ },
3128
+ [CairoInt16.abiSelector]: (val) => {
3129
+ return new CairoInt16(val).toApiRequest();
3130
+ },
3131
+ [CairoInt32.abiSelector]: (val) => {
3132
+ return new CairoInt32(val).toApiRequest();
3133
+ },
3134
+ [CairoInt64.abiSelector]: (val) => {
3135
+ return new CairoInt64(val).toApiRequest();
3136
+ },
3137
+ [CairoInt128.abiSelector]: (val) => {
3138
+ return new CairoInt128(val).toApiRequest();
3139
+ }
3140
+ },
3141
+ response: {
3142
+ [CairoBytes31.abiSelector]: (responseIterator) => {
3143
+ return CairoBytes31.factoryFromApiResponse(responseIterator).decodeUtf8();
3144
+ },
3145
+ [CairoByteArray.abiSelector]: (responseIterator) => {
3146
+ return CairoByteArray.factoryFromApiResponse(responseIterator).decodeUtf8();
3147
+ },
3148
+ [CairoFelt252.abiSelector]: (responseIterator) => {
3149
+ return BigInt(getNext(responseIterator));
3150
+ },
3151
+ [CairoUint256.abiSelector]: (responseIterator) => {
3152
+ return CairoUint256.factoryFromApiResponse(responseIterator).toBigInt();
3153
+ },
3154
+ [CairoUint512.abiSelector]: (responseIterator) => {
3155
+ return CairoUint512.factoryFromApiResponse(responseIterator).toBigInt();
3156
+ },
3157
+ [CairoUint8.abiSelector]: (responseIterator) => {
3158
+ return BigInt(getNext(responseIterator));
3159
+ },
3160
+ [CairoUint16.abiSelector]: (responseIterator) => {
3161
+ return BigInt(getNext(responseIterator));
3162
+ },
3163
+ [CairoUint64.abiSelector]: (responseIterator) => {
3164
+ return BigInt(getNext(responseIterator));
3165
+ },
3166
+ [CairoUint96.abiSelector]: (responseIterator) => {
3167
+ return BigInt(getNext(responseIterator));
3168
+ },
3169
+ [CairoUint128.abiSelector]: (responseIterator) => {
3170
+ return BigInt(getNext(responseIterator));
3171
+ },
3172
+ [CairoInt8.abiSelector]: (responseIterator) => {
3173
+ return BigInt(getNext(responseIterator));
3174
+ },
3175
+ [CairoInt16.abiSelector]: (responseIterator) => {
3176
+ return BigInt(getNext(responseIterator));
3177
+ },
3178
+ [CairoInt32.abiSelector]: (responseIterator) => {
3179
+ return BigInt(getNext(responseIterator));
3180
+ },
3181
+ [CairoInt64.abiSelector]: (responseIterator) => {
3182
+ return BigInt(getNext(responseIterator));
3183
+ },
3184
+ [CairoInt128.abiSelector]: (responseIterator) => {
3185
+ return BigInt(getNext(responseIterator));
3186
+ }
3187
+ }
3188
+ };
1633
3189
 
1634
3190
  // src/utils/calldata/parser/parser-0-1.1.0.ts
1635
3191
  var AbiParser1 = class {
1636
3192
  abi;
1637
- constructor(abi) {
3193
+ parsingStrategy;
3194
+ constructor(abi, parsingStrategy) {
1638
3195
  this.abi = abi;
3196
+ this.parsingStrategy = parsingStrategy || fastParsingStrategy;
3197
+ }
3198
+ getRequestParser(abiType) {
3199
+ if (this.parsingStrategy.request[abiType]) {
3200
+ return this.parsingStrategy.request[abiType];
3201
+ }
3202
+ throw new Error(`Parser for ${abiType} not found`);
3203
+ }
3204
+ getResponseParser(abiType) {
3205
+ if (this.parsingStrategy.response[abiType]) {
3206
+ return this.parsingStrategy.response[abiType];
3207
+ }
3208
+ throw new Error(`Parser for ${abiType} not found`);
1639
3209
  }
1640
3210
  /**
1641
3211
  * abi method inputs length without '_len' inputs
@@ -1666,8 +3236,22 @@ var AbiParser1 = class {
1666
3236
  // src/utils/calldata/parser/parser-2.0.0.ts
1667
3237
  var AbiParser2 = class {
1668
3238
  abi;
1669
- constructor(abi) {
3239
+ parsingStrategy;
3240
+ constructor(abi, parsingStrategy) {
1670
3241
  this.abi = abi;
3242
+ this.parsingStrategy = parsingStrategy || fastParsingStrategy;
3243
+ }
3244
+ getRequestParser(abiType) {
3245
+ if (this.parsingStrategy.request[abiType]) {
3246
+ return this.parsingStrategy.request[abiType];
3247
+ }
3248
+ throw new Error(`Parser for ${abiType} not found`);
3249
+ }
3250
+ getResponseParser(abiType) {
3251
+ if (this.parsingStrategy.response[abiType]) {
3252
+ return this.parsingStrategy.response[abiType];
3253
+ }
3254
+ throw new Error(`Parser for ${abiType} not found`);
1671
3255
  }
1672
3256
  /**
1673
3257
  * abi method inputs length
@@ -1700,13 +3284,13 @@ var AbiParser2 = class {
1700
3284
  };
1701
3285
 
1702
3286
  // src/utils/calldata/parser/index.ts
1703
- function createAbiParser(abi) {
3287
+ function createAbiParser(abi, parsingStrategy) {
1704
3288
  const version = getAbiVersion(abi);
1705
3289
  if (version === 0 || version === 1) {
1706
- return new AbiParser1(abi);
3290
+ return new AbiParser1(abi, parsingStrategy);
1707
3291
  }
1708
3292
  if (version === 2) {
1709
- return new AbiParser2(abi);
3293
+ return new AbiParser2(abi, parsingStrategy);
1710
3294
  }
1711
3295
  throw Error(`Unsupported ABI version ${version}`);
1712
3296
  }
@@ -1833,16 +3417,17 @@ var CairoFixedArray = class _CairoFixedArray {
1833
3417
  `The type ${arrayType} do not includes any content type. Needs [type; length].`
1834
3418
  );
1835
3419
  }
3420
+ let arraySize;
1836
3421
  try {
1837
- _CairoFixedArray.getFixedArraySize(arrayType);
3422
+ arraySize = _CairoFixedArray.getFixedArraySize(arrayType);
1838
3423
  } catch {
1839
3424
  throw new Error(
1840
3425
  `The type ${arrayType} type do not includes any length. Needs [type; length].`
1841
3426
  );
1842
3427
  }
1843
3428
  assert(
1844
- _CairoFixedArray.getFixedArraySize(arrayType) === content.length,
1845
- `The ABI type ${arrayType} is expecting ${_CairoFixedArray.getFixedArraySize(arrayType)} items. ${content.length} items provided.`
3429
+ arraySize === content.length,
3430
+ `The ABI type ${arrayType} is expecting ${arraySize} items. ${content.length} items provided.`
1846
3431
  );
1847
3432
  this.content = content;
1848
3433
  this.arrayType = arrayType;
@@ -1939,6 +3524,7 @@ var CairoFixedArray = class _CairoFixedArray {
1939
3524
  }
1940
3525
  /**
1941
3526
  * Checks if the given Cairo type is a fixed-array type.
3527
+ * structure: [string; number]
1942
3528
  *
1943
3529
  * @param {string} type - The type to check.
1944
3530
  * @returns - `true` if the type is a fixed array type, `false` otherwise.
@@ -1983,7 +3569,7 @@ function orderPropsByAbi(unorderedObject, abiOfObject, structs, enums) {
1983
3569
  if (isTypeNonZero(abiType)) {
1984
3570
  return unorderedItem;
1985
3571
  }
1986
- if (isTypeByteArray(abiType)) {
3572
+ if (CairoByteArray.isAbiType(abiType)) {
1987
3573
  return unorderedItem;
1988
3574
  }
1989
3575
  if (isTypeU96(abiType)) {
@@ -2141,14 +3727,38 @@ function orderPropsByAbi(unorderedObject, abiOfObject, structs, enums) {
2141
3727
  }
2142
3728
 
2143
3729
  // src/utils/calldata/requestParser.ts
2144
- function parseBaseTypes(type, val) {
3730
+ function parseBaseTypes({
3731
+ type,
3732
+ val,
3733
+ parser
3734
+ }) {
2145
3735
  switch (true) {
2146
3736
  case CairoUint256.isAbiType(type):
2147
- return new CairoUint256(val).toApiRequest();
3737
+ return parser.getRequestParser(type)(val);
2148
3738
  case CairoUint512.isAbiType(type):
2149
- return new CairoUint512(val).toApiRequest();
2150
- case isTypeBytes31(type):
2151
- return encodeShortString(val.toString());
3739
+ return parser.getRequestParser(type)(val);
3740
+ case CairoUint8.isAbiType(type):
3741
+ return parser.getRequestParser(type)(val);
3742
+ case CairoUint16.isAbiType(type):
3743
+ return parser.getRequestParser(type)(val);
3744
+ case CairoUint64.isAbiType(type):
3745
+ return parser.getRequestParser(type)(val);
3746
+ case CairoUint96.isAbiType(type):
3747
+ return parser.getRequestParser(type)(val);
3748
+ case CairoUint128.isAbiType(type):
3749
+ return parser.getRequestParser(type)(val);
3750
+ case CairoInt8.isAbiType(type):
3751
+ return parser.getRequestParser(type)(val);
3752
+ case CairoInt16.isAbiType(type):
3753
+ return parser.getRequestParser(type)(val);
3754
+ case CairoInt32.isAbiType(type):
3755
+ return parser.getRequestParser(type)(val);
3756
+ case CairoInt64.isAbiType(type):
3757
+ return parser.getRequestParser(type)(val);
3758
+ case CairoInt128.isAbiType(type):
3759
+ return parser.getRequestParser(type)(val);
3760
+ case CairoBytes31.isAbiType(type):
3761
+ return parser.getRequestParser(type)(val);
2152
3762
  case isTypeSecp256k1Point(type): {
2153
3763
  const pubKeyETH = removeHexPrefix(toHex(val)).padStart(128, "0");
2154
3764
  const pubKeyETHy = uint256(addHexPrefix(pubKeyETH.slice(-64)));
@@ -2161,7 +3771,7 @@ function parseBaseTypes(type, val) {
2161
3771
  ];
2162
3772
  }
2163
3773
  default:
2164
- return felt(val);
3774
+ return parser.getRequestParser(CairoFelt252.abiSelector)(val);
2165
3775
  }
2166
3776
  }
2167
3777
  function parseTuple(element, typeStr) {
@@ -2181,16 +3791,13 @@ function parseTuple(element, typeStr) {
2181
3791
  };
2182
3792
  });
2183
3793
  }
2184
- function parseByteArray(element) {
2185
- const myByteArray = byteArrayFromString(element);
2186
- return [
2187
- myByteArray.data.length.toString(),
2188
- ...myByteArray.data.map((bn) => bn.toString()),
2189
- myByteArray.pending_word.toString(),
2190
- myByteArray.pending_word_len.toString()
2191
- ];
2192
- }
2193
- function parseCalldataValue(element, type, structs, enums) {
3794
+ function parseCalldataValue({
3795
+ element,
3796
+ type,
3797
+ structs,
3798
+ enums,
3799
+ parser
3800
+ }) {
2194
3801
  if (element === void 0) {
2195
3802
  throw Error(`Missing parameter for type ${type}`);
2196
3803
  }
@@ -2210,7 +3817,9 @@ function parseCalldataValue(element, type, structs, enums) {
2210
3817
  throw new Error(`ABI type ${type}: not an Array representing a cairo.fixedArray() provided.`);
2211
3818
  }
2212
3819
  return values.reduce((acc, it) => {
2213
- return acc.concat(parseCalldataValue(it, arrayType, structs, enums));
3820
+ return acc.concat(
3821
+ parseCalldataValue({ element: it, type: arrayType, structs, enums, parser })
3822
+ );
2214
3823
  }, []);
2215
3824
  }
2216
3825
  if (Array.isArray(element)) {
@@ -2218,37 +3827,51 @@ function parseCalldataValue(element, type, structs, enums) {
2218
3827
  result.push(felt(element.length));
2219
3828
  const arrayType = getArrayType(type);
2220
3829
  return element.reduce((acc, it) => {
2221
- return acc.concat(parseCalldataValue(it, arrayType, structs, enums));
3830
+ return acc.concat(
3831
+ parseCalldataValue({ element: it, type: arrayType, structs, enums, parser })
3832
+ );
2222
3833
  }, result);
2223
3834
  }
3835
+ if (CairoUint256.isAbiType(type)) {
3836
+ return parser.getRequestParser(type)(element);
3837
+ }
3838
+ if (CairoUint512.isAbiType(type)) {
3839
+ return parser.getRequestParser(type)(element);
3840
+ }
2224
3841
  if (structs[type] && structs[type].members.length) {
2225
- if (CairoUint256.isAbiType(type)) {
2226
- return new CairoUint256(element).toApiRequest();
3842
+ if (isTypeEthAddress(type)) {
3843
+ return parseBaseTypes({ type, val: element, parser });
2227
3844
  }
2228
- if (CairoUint512.isAbiType(type)) {
2229
- return new CairoUint512(element).toApiRequest();
3845
+ if (CairoByteArray.isAbiType(type)) {
3846
+ return parser.getRequestParser(type)(element);
2230
3847
  }
2231
- if (isTypeEthAddress(type)) return parseBaseTypes(type, element);
2232
- if (isTypeByteArray(type)) return parseByteArray(element);
2233
3848
  const { members } = structs[type];
2234
3849
  const subElement = element;
2235
3850
  return members.reduce((acc, it) => {
2236
- return acc.concat(parseCalldataValue(subElement[it.name], it.type, structs, enums));
3851
+ return acc.concat(
3852
+ parseCalldataValue({
3853
+ element: subElement[it.name],
3854
+ type: it.type,
3855
+ structs,
3856
+ enums,
3857
+ parser
3858
+ })
3859
+ );
2237
3860
  }, []);
2238
3861
  }
2239
3862
  if (isTypeTuple(type)) {
2240
3863
  const tupled = parseTuple(element, type);
2241
3864
  return tupled.reduce((acc, it) => {
2242
- const parsedData = parseCalldataValue(it.element, it.type, structs, enums);
3865
+ const parsedData = parseCalldataValue({
3866
+ element: it.element,
3867
+ type: it.type,
3868
+ structs,
3869
+ enums,
3870
+ parser
3871
+ });
2243
3872
  return acc.concat(parsedData);
2244
3873
  }, []);
2245
3874
  }
2246
- if (CairoUint256.isAbiType(type)) {
2247
- return new CairoUint256(element).toApiRequest();
2248
- }
2249
- if (CairoUint512.isAbiType(type)) {
2250
- return new CairoUint512(element).toApiRequest();
2251
- }
2252
3875
  if (isTypeEnum(type, enums)) {
2253
3876
  const { variants } = enums[type];
2254
3877
  if (isTypeOption(type)) {
@@ -2262,12 +3885,13 @@ function parseCalldataValue(element, type, structs, enums) {
2262
3885
  if (typeVariantSome === "()") {
2263
3886
  return CairoOptionVariant.Some.toString();
2264
3887
  }
2265
- const parsedParameter2 = parseCalldataValue(
2266
- myOption.unwrap(),
2267
- typeVariantSome,
3888
+ const parsedParameter2 = parseCalldataValue({
3889
+ element: myOption.unwrap(),
3890
+ type: typeVariantSome,
2268
3891
  structs,
2269
- enums
2270
- );
3892
+ enums,
3893
+ parser
3894
+ });
2271
3895
  if (Array.isArray(parsedParameter2)) {
2272
3896
  return [CairoOptionVariant.Some.toString(), ...parsedParameter2];
2273
3897
  }
@@ -2286,12 +3910,13 @@ function parseCalldataValue(element, type, structs, enums) {
2286
3910
  if (typeVariantOk === "()") {
2287
3911
  return CairoResultVariant.Ok.toString();
2288
3912
  }
2289
- const parsedParameter3 = parseCalldataValue(
2290
- myResult.unwrap(),
2291
- typeVariantOk,
3913
+ const parsedParameter3 = parseCalldataValue({
3914
+ element: myResult.unwrap(),
3915
+ type: typeVariantOk,
2292
3916
  structs,
2293
- enums
2294
- );
3917
+ enums,
3918
+ parser
3919
+ });
2295
3920
  if (Array.isArray(parsedParameter3)) {
2296
3921
  return [CairoResultVariant.Ok.toString(), ...parsedParameter3];
2297
3922
  }
@@ -2305,7 +3930,13 @@ function parseCalldataValue(element, type, structs, enums) {
2305
3930
  if (typeVariantErr === "()") {
2306
3931
  return CairoResultVariant.Err.toString();
2307
3932
  }
2308
- const parsedParameter2 = parseCalldataValue(myResult.unwrap(), typeVariantErr, structs, enums);
3933
+ const parsedParameter2 = parseCalldataValue({
3934
+ element: myResult.unwrap(),
3935
+ type: typeVariantErr,
3936
+ structs,
3937
+ enums,
3938
+ parser
3939
+ });
2309
3940
  if (Array.isArray(parsedParameter2)) {
2310
3941
  return [CairoResultVariant.Err.toString(), ...parsedParameter2];
2311
3942
  }
@@ -2322,21 +3953,33 @@ function parseCalldataValue(element, type, structs, enums) {
2322
3953
  if (typeActiveVariant === "()") {
2323
3954
  return numActiveVariant.toString();
2324
3955
  }
2325
- const parsedParameter = parseCalldataValue(myEnum.unwrap(), typeActiveVariant, structs, enums);
3956
+ const parsedParameter = parseCalldataValue({
3957
+ element: myEnum.unwrap(),
3958
+ type: typeActiveVariant,
3959
+ structs,
3960
+ enums,
3961
+ parser
3962
+ });
2326
3963
  if (Array.isArray(parsedParameter)) {
2327
3964
  return [numActiveVariant.toString(), ...parsedParameter];
2328
3965
  }
2329
3966
  return [numActiveVariant.toString(), parsedParameter];
2330
3967
  }
2331
3968
  if (isTypeNonZero(type)) {
2332
- return parseBaseTypes(getArrayType(type), element);
3969
+ return parseBaseTypes({ type: getArrayType(type), val: element, parser });
2333
3970
  }
2334
3971
  if (typeof element === "object") {
2335
3972
  throw Error(`Parameter ${element} do not align with abi parameter ${type}`);
2336
3973
  }
2337
- return parseBaseTypes(type, element);
3974
+ return parseBaseTypes({ type, val: element, parser });
2338
3975
  }
2339
- function parseCalldataField(argsIterator, input, structs, enums) {
3976
+ function parseCalldataField({
3977
+ argsIterator,
3978
+ input,
3979
+ structs,
3980
+ enums,
3981
+ parser
3982
+ }) {
2340
3983
  const { name, type } = input;
2341
3984
  let { value } = argsIterator.next();
2342
3985
  switch (true) {
@@ -2345,7 +3988,7 @@ function parseCalldataField(argsIterator, input, structs, enums) {
2345
3988
  if (!Array.isArray(value) && !(typeof value === "object")) {
2346
3989
  throw Error(`ABI expected parameter ${name} to be an array or an object, got ${value}`);
2347
3990
  }
2348
- return parseCalldataValue(value, input.type, structs, enums);
3991
+ return parseCalldataValue({ element: value, type: input.type, structs, enums, parser });
2349
3992
  // Normal Array
2350
3993
  case isTypeArray(type):
2351
3994
  if (!Array.isArray(value) && !isText(value)) {
@@ -2354,51 +3997,71 @@ function parseCalldataField(argsIterator, input, structs, enums) {
2354
3997
  if (isString(value)) {
2355
3998
  value = splitLongString(value);
2356
3999
  }
2357
- return parseCalldataValue(value, input.type, structs, enums);
4000
+ return parseCalldataValue({ element: value, type: input.type, structs, enums, parser });
2358
4001
  case isTypeNonZero(type):
2359
- return parseBaseTypes(getArrayType(type), value);
4002
+ return parseBaseTypes({ type: getArrayType(type), val: value, parser });
2360
4003
  case isTypeEthAddress(type):
2361
- return parseBaseTypes(type, value);
4004
+ return parseBaseTypes({ type, val: value, parser });
2362
4005
  // Struct or Tuple
2363
4006
  case (isTypeStruct(type, structs) || isTypeTuple(type) || CairoUint256.isAbiType(type)):
2364
- return parseCalldataValue(value, type, structs, enums);
4007
+ return parseCalldataValue({
4008
+ element: value,
4009
+ type,
4010
+ structs,
4011
+ enums,
4012
+ parser
4013
+ });
2365
4014
  // Enums
2366
4015
  case isTypeEnum(type, enums):
2367
- return parseCalldataValue(
2368
- value,
4016
+ return parseCalldataValue({
4017
+ element: value,
2369
4018
  type,
2370
4019
  structs,
2371
- enums
2372
- );
4020
+ enums,
4021
+ parser
4022
+ });
2373
4023
  // Felt or unhandled
2374
4024
  default:
2375
- return parseBaseTypes(type, value);
4025
+ return parseBaseTypes({ type, val: value, parser });
2376
4026
  }
2377
4027
  }
2378
4028
 
2379
4029
  // src/utils/calldata/responseParser.ts
2380
- function parseBaseTypes2(type, it) {
4030
+ function parseBaseTypes2(type, it, parser) {
2381
4031
  let temp;
2382
4032
  switch (true) {
2383
4033
  case isTypeBool(type):
2384
4034
  temp = it.next().value;
2385
4035
  return Boolean(BigInt(temp));
2386
4036
  case CairoUint256.isAbiType(type):
2387
- const low = it.next().value;
2388
- const high = it.next().value;
2389
- return new CairoUint256(low, high).toBigInt();
4037
+ return parser.getResponseParser(type)(it);
2390
4038
  case CairoUint512.isAbiType(type):
2391
- const limb0 = it.next().value;
2392
- const limb1 = it.next().value;
2393
- const limb2 = it.next().value;
2394
- const limb3 = it.next().value;
2395
- return new CairoUint512(limb0, limb1, limb2, limb3).toBigInt();
4039
+ return parser.getResponseParser(type)(it);
4040
+ case CairoUint8.isAbiType(type):
4041
+ return parser.getResponseParser(type)(it);
4042
+ case CairoUint16.isAbiType(type):
4043
+ return parser.getResponseParser(type)(it);
4044
+ case CairoUint64.isAbiType(type):
4045
+ return parser.getResponseParser(type)(it);
4046
+ case CairoUint96.isAbiType(type):
4047
+ return parser.getResponseParser(type)(it);
4048
+ case CairoUint128.isAbiType(type):
4049
+ return parser.getResponseParser(type)(it);
4050
+ case CairoInt8.isAbiType(type):
4051
+ return parser.getResponseParser(type)(it);
4052
+ case CairoInt16.isAbiType(type):
4053
+ return parser.getResponseParser(type)(it);
4054
+ case CairoInt32.isAbiType(type):
4055
+ return parser.getResponseParser(type)(it);
4056
+ case CairoInt64.isAbiType(type):
4057
+ return parser.getResponseParser(type)(it);
4058
+ case CairoInt128.isAbiType(type):
4059
+ return parser.getResponseParser(type)(it);
2396
4060
  case isTypeEthAddress(type):
2397
4061
  temp = it.next().value;
2398
4062
  return BigInt(temp);
2399
- case isTypeBytes31(type):
2400
- temp = it.next().value;
2401
- return decodeShortString(temp);
4063
+ case CairoBytes31.isAbiType(type):
4064
+ return parser.getResponseParser(type)(it);
2402
4065
  case isTypeSecp256k1Point(type):
2403
4066
  const xLow = removeHexPrefix(it.next().value).padStart(32, "0");
2404
4067
  const xHigh = removeHexPrefix(it.next().value).padStart(32, "0");
@@ -2407,47 +4070,28 @@ function parseBaseTypes2(type, it) {
2407
4070
  const pubK = BigInt(addHexPrefix(xHigh + xLow + yHigh + yLow));
2408
4071
  return pubK;
2409
4072
  default:
2410
- temp = it.next().value;
2411
- return BigInt(temp);
4073
+ return parser.getResponseParser(CairoFelt252.abiSelector)(it);
2412
4074
  }
2413
4075
  }
2414
- function parseResponseValue(responseIterator, element, structs, enums) {
4076
+ function parseResponseValue(responseIterator, element, parser, structs, enums) {
2415
4077
  if (element.type === "()") {
2416
4078
  return {};
2417
4079
  }
2418
4080
  if (CairoUint256.isAbiType(element.type)) {
2419
- const low = responseIterator.next().value;
2420
- const high = responseIterator.next().value;
2421
- return new CairoUint256(low, high).toBigInt();
4081
+ return parser.getResponseParser(element.type)(responseIterator);
2422
4082
  }
2423
4083
  if (CairoUint512.isAbiType(element.type)) {
2424
- const limb0 = responseIterator.next().value;
2425
- const limb1 = responseIterator.next().value;
2426
- const limb2 = responseIterator.next().value;
2427
- const limb3 = responseIterator.next().value;
2428
- return new CairoUint512(limb0, limb1, limb2, limb3).toBigInt();
2429
- }
2430
- if (isTypeByteArray(element.type)) {
2431
- const parsedBytes31Arr = [];
2432
- const bytes31ArrLen = BigInt(responseIterator.next().value);
2433
- while (parsedBytes31Arr.length < bytes31ArrLen) {
2434
- parsedBytes31Arr.push(toHex(responseIterator.next().value));
2435
- }
2436
- const pending_word = toHex(responseIterator.next().value);
2437
- const pending_word_len = BigInt(responseIterator.next().value);
2438
- const myByteArray = {
2439
- data: parsedBytes31Arr,
2440
- pending_word,
2441
- pending_word_len
2442
- };
2443
- return stringFromByteArray(myByteArray);
4084
+ return parser.getResponseParser(element.type)(responseIterator);
4085
+ }
4086
+ if (CairoByteArray.isAbiType(element.type)) {
4087
+ return parser.getResponseParser(element.type)(responseIterator);
2444
4088
  }
2445
4089
  if (CairoFixedArray.isTypeFixedArray(element.type)) {
2446
4090
  const parsedDataArr = [];
2447
4091
  const el = { name: "", type: CairoFixedArray.getFixedArrayType(element.type) };
2448
4092
  const arraySize = CairoFixedArray.getFixedArraySize(element.type);
2449
4093
  while (parsedDataArr.length < arraySize) {
2450
- parsedDataArr.push(parseResponseValue(responseIterator, el, structs, enums));
4094
+ parsedDataArr.push(parseResponseValue(responseIterator, el, parser, structs, enums));
2451
4095
  }
2452
4096
  return parsedDataArr;
2453
4097
  }
@@ -2456,20 +4100,20 @@ function parseResponseValue(responseIterator, element, structs, enums) {
2456
4100
  const el = { name: "", type: getArrayType(element.type) };
2457
4101
  const len = BigInt(responseIterator.next().value);
2458
4102
  while (parsedDataArr.length < len) {
2459
- parsedDataArr.push(parseResponseValue(responseIterator, el, structs, enums));
4103
+ parsedDataArr.push(parseResponseValue(responseIterator, el, parser, structs, enums));
2460
4104
  }
2461
4105
  return parsedDataArr;
2462
4106
  }
2463
4107
  if (isTypeNonZero(element.type)) {
2464
4108
  const el = { name: "", type: getArrayType(element.type) };
2465
- return parseResponseValue(responseIterator, el, structs, enums);
4109
+ return parseResponseValue(responseIterator, el, parser, structs, enums);
2466
4110
  }
2467
4111
  if (structs && element.type in structs && structs[element.type]) {
2468
4112
  if (isTypeEthAddress(element.type)) {
2469
- return parseBaseTypes2(element.type, responseIterator);
4113
+ return parseBaseTypes2(element.type, responseIterator, parser);
2470
4114
  }
2471
4115
  return structs[element.type].members.reduce((acc, el) => {
2472
- acc[el.name] = parseResponseValue(responseIterator, el, structs, enums);
4116
+ acc[el.name] = parseResponseValue(responseIterator, el, parser, structs, enums);
2473
4117
  return acc;
2474
4118
  }, {});
2475
4119
  }
@@ -2480,6 +4124,7 @@ function parseResponseValue(responseIterator, element, structs, enums) {
2480
4124
  acc[variant.name] = parseResponseValue(
2481
4125
  responseIterator,
2482
4126
  { name: "", type: variant.type },
4127
+ parser,
2483
4128
  structs,
2484
4129
  enums
2485
4130
  );
@@ -2510,7 +4155,7 @@ function parseResponseValue(responseIterator, element, structs, enums) {
2510
4155
  const name = it?.name ? it.name : idx;
2511
4156
  const type = it?.type ? it.type : it;
2512
4157
  const el = { name, type };
2513
- acc[name] = parseResponseValue(responseIterator, el, structs, enums);
4158
+ acc[name] = parseResponseValue(responseIterator, el, parser, structs, enums);
2514
4159
  return acc;
2515
4160
  }, {});
2516
4161
  }
@@ -2519,13 +4164,20 @@ function parseResponseValue(responseIterator, element, structs, enums) {
2519
4164
  const el = { name: "", type: getArrayType(element.type) };
2520
4165
  const len = BigInt(responseIterator.next().value);
2521
4166
  while (parsedDataArr.length < len) {
2522
- parsedDataArr.push(parseResponseValue(responseIterator, el, structs, enums));
4167
+ parsedDataArr.push(parseResponseValue(responseIterator, el, parser, structs, enums));
2523
4168
  }
2524
4169
  return parsedDataArr;
2525
4170
  }
2526
- return parseBaseTypes2(element.type, responseIterator);
4171
+ return parseBaseTypes2(element.type, responseIterator, parser);
2527
4172
  }
2528
- function responseParser(responseIterator, output, structs, enums, parsedResult) {
4173
+ function responseParser({
4174
+ responseIterator,
4175
+ output,
4176
+ structs,
4177
+ enums,
4178
+ parsedResult,
4179
+ parser
4180
+ }) {
2529
4181
  const { name, type } = output;
2530
4182
  let temp;
2531
4183
  switch (true) {
@@ -2533,14 +4185,14 @@ function responseParser(responseIterator, output, structs, enums, parsedResult)
2533
4185
  temp = responseIterator.next().value;
2534
4186
  return BigInt(temp);
2535
4187
  case (structs && type in structs || isTypeTuple(type)):
2536
- return parseResponseValue(responseIterator, output, structs, enums);
4188
+ return parseResponseValue(responseIterator, output, parser, structs, enums);
2537
4189
  case (enums && isTypeEnum(type, enums)):
2538
- return parseResponseValue(responseIterator, output, structs, enums);
4190
+ return parseResponseValue(responseIterator, output, parser, structs, enums);
2539
4191
  case CairoFixedArray.isTypeFixedArray(type):
2540
- return parseResponseValue(responseIterator, output, structs, enums);
4192
+ return parseResponseValue(responseIterator, output, parser, structs, enums);
2541
4193
  case isTypeArray(type):
2542
4194
  if (isCairo1Type(type)) {
2543
- return parseResponseValue(responseIterator, output, structs, enums);
4195
+ return parseResponseValue(responseIterator, output, parser, structs, enums);
2544
4196
  }
2545
4197
  const parsedDataArr = [];
2546
4198
  if (parsedResult && parsedResult[`${name}_len`]) {
@@ -2550,6 +4202,7 @@ function responseParser(responseIterator, output, structs, enums, parsedResult)
2550
4202
  parseResponseValue(
2551
4203
  responseIterator,
2552
4204
  { name, type: output.type.replace("*", "") },
4205
+ parser,
2553
4206
  structs,
2554
4207
  enums
2555
4208
  )
@@ -2558,9 +4211,9 @@ function responseParser(responseIterator, output, structs, enums, parsedResult)
2558
4211
  }
2559
4212
  return parsedDataArr;
2560
4213
  case isTypeNonZero(type):
2561
- return parseResponseValue(responseIterator, output, structs, enums);
4214
+ return parseResponseValue(responseIterator, output, parser, structs, enums);
2562
4215
  default:
2563
- return parseBaseTypes2(type, responseIterator);
4216
+ return parseBaseTypes2(type, responseIterator, parser);
2564
4217
  }
2565
4218
  }
2566
4219
 
@@ -2578,16 +4231,6 @@ var validateFelt = (parameter, input) => {
2578
4231
  `Validate: arg ${input.name} cairo typed ${input.type} should be in range [0, 2^252-1]`
2579
4232
  );
2580
4233
  };
2581
- var validateBytes31 = (parameter, input) => {
2582
- assert(isString(parameter), `Validate: arg ${input.name} should be a string.`);
2583
- assert(
2584
- parameter.length < 32,
2585
- `Validate: arg ${input.name} cairo typed ${input.type} should be a string of less than 32 characters.`
2586
- );
2587
- };
2588
- var validateByteArray = (parameter, input) => {
2589
- assert(isString(parameter), `Validate: arg ${input.name} should be a string.`);
2590
- };
2591
4234
  var validateUint = (parameter, input) => {
2592
4235
  if (isNumber(parameter)) {
2593
4236
  assert(
@@ -2839,8 +4482,8 @@ function validateFields(abiMethod, args, structs, enums) {
2839
4482
  case isTypeFelt(input.type):
2840
4483
  validateFelt(parameter, input);
2841
4484
  break;
2842
- case isTypeBytes31(input.type):
2843
- validateBytes31(parameter, input);
4485
+ case CairoBytes31.isAbiType(input.type):
4486
+ CairoBytes31.validate(parameter);
2844
4487
  break;
2845
4488
  case (isTypeUint(input.type) || isTypeLiteral(input.type)):
2846
4489
  validateUint(parameter, input);
@@ -2848,8 +4491,23 @@ function validateFields(abiMethod, args, structs, enums) {
2848
4491
  case isTypeBool(input.type):
2849
4492
  validateBool(parameter, input);
2850
4493
  break;
2851
- case isTypeByteArray(input.type):
2852
- validateByteArray(parameter, input);
4494
+ case CairoByteArray.isAbiType(input.type):
4495
+ CairoByteArray.validate(parameter);
4496
+ break;
4497
+ case CairoInt8.isAbiType(input.type):
4498
+ CairoInt8.validate(parameter);
4499
+ break;
4500
+ case CairoInt16.isAbiType(input.type):
4501
+ CairoInt16.validate(parameter);
4502
+ break;
4503
+ case CairoInt32.isAbiType(input.type):
4504
+ CairoInt32.validate(parameter);
4505
+ break;
4506
+ case CairoInt64.isAbiType(input.type):
4507
+ CairoInt64.validate(parameter);
4508
+ break;
4509
+ case CairoInt128.isAbiType(input.type):
4510
+ CairoInt128.validate(parameter);
2853
4511
  break;
2854
4512
  case (isTypeArray(input.type) || CairoFixedArray.isTypeFixedArray(input.type)):
2855
4513
  validateArray(parameter, input, structs, enums);
@@ -2881,10 +4539,10 @@ var CallData = class _CallData {
2881
4539
  parser;
2882
4540
  structs;
2883
4541
  enums;
2884
- constructor(abi) {
4542
+ constructor(abi, parsingStrategy) {
2885
4543
  this.structs = _CallData.getAbiStruct(abi);
2886
4544
  this.enums = _CallData.getAbiEnum(abi);
2887
- this.parser = createAbiParser(abi);
4545
+ this.parser = createAbiParser(abi, parsingStrategy);
2888
4546
  this.abi = this.parser.getLegacyFormat();
2889
4547
  }
2890
4548
  /**
@@ -2953,7 +4611,15 @@ var CallData = class _CallData {
2953
4611
  }
2954
4612
  const argsIterator = args[Symbol.iterator]();
2955
4613
  const callArray = abiMethod.inputs.reduce(
2956
- (acc, input) => isLen(input.name) && !isCairo1Type(input.type) ? acc : acc.concat(parseCalldataField(argsIterator, input, this.structs, this.enums)),
4614
+ (acc, input) => isLen(input.name) && !isCairo1Type(input.type) ? acc : acc.concat(
4615
+ parseCalldataField({
4616
+ argsIterator,
4617
+ input,
4618
+ structs: this.structs,
4619
+ enums: this.enums,
4620
+ parser: this.parser
4621
+ })
4622
+ ),
2957
4623
  []
2958
4624
  );
2959
4625
  Object.defineProperty(callArray, "__compiled__", {
@@ -3040,7 +4706,14 @@ var CallData = class _CallData {
3040
4706
  const responseIterator = response.flat()[Symbol.iterator]();
3041
4707
  const parsed = outputs.flat().reduce((acc, output, idx) => {
3042
4708
  const propName = output.name ?? idx;
3043
- acc[propName] = responseParser(responseIterator, output, this.structs, this.enums, acc);
4709
+ acc[propName] = responseParser({
4710
+ responseIterator,
4711
+ output,
4712
+ structs: this.structs,
4713
+ enums: this.enums,
4714
+ parsedResult: acc,
4715
+ parser: this.parser
4716
+ });
3044
4717
  if (acc[propName] && acc[`${propName}_len`]) {
3045
4718
  delete acc[`${propName}_len`];
3046
4719
  }
@@ -3120,12 +4793,13 @@ var CallData = class _CallData {
3120
4793
  const typeCairoArray = Array.isArray(typeCairo) ? typeCairo : [typeCairo];
3121
4794
  const responseIterator = response.flat()[Symbol.iterator]();
3122
4795
  const decodedArray = typeCairoArray.map(
3123
- (typeParam) => responseParser(
4796
+ (typeParam) => responseParser({
3124
4797
  responseIterator,
3125
- { name: "", type: typeParam },
3126
- this.structs,
3127
- this.enums
3128
- )
4798
+ output: { name: "", type: typeParam },
4799
+ parser: this.parser,
4800
+ structs: this.structs,
4801
+ enums: this.enums
4802
+ })
3129
4803
  );
3130
4804
  return decodedArray.length === 1 ? decodedArray[0] : decodedArray;
3131
4805
  }
@@ -3593,7 +5267,7 @@ __export(stark_exports, {
3593
5267
  intDAM: () => intDAM,
3594
5268
  randomAddress: () => randomAddress,
3595
5269
  resourceBoundsToBigInt: () => resourceBoundsToBigInt,
3596
- resourceBoundsToEstimateFee: () => resourceBoundsToEstimateFee,
5270
+ resourceBoundsToEstimateFeeResponse: () => resourceBoundsToEstimateFeeResponse,
3597
5271
  resourceBoundsToHexString: () => resourceBoundsToHexString,
3598
5272
  signatureToDecimalArray: () => signatureToDecimalArray,
3599
5273
  signatureToHexArray: () => signatureToHexArray,
@@ -3601,7 +5275,8 @@ __export(stark_exports, {
3601
5275
  toOverheadOverallFee: () => toOverheadOverallFee,
3602
5276
  toOverheadResourceBounds: () => toOverheadResourceBounds,
3603
5277
  toTransactionVersion: () => toTransactionVersion,
3604
- v3Details: () => v3Details
5278
+ v3Details: () => v3Details,
5279
+ zeroResourceBounds: () => zeroResourceBounds
3605
5280
  });
3606
5281
  var import_starknet4 = require("@scure/starknet");
3607
5282
  var import_pako = require("pako");
@@ -3637,26 +5312,44 @@ function signatureToDecimalArray(sig) {
3637
5312
  function signatureToHexArray(sig) {
3638
5313
  return bigNumberishArrayToHexadecimalStringArray(formatSignature(sig));
3639
5314
  }
5315
+ function zeroResourceBounds() {
5316
+ return toOverheadResourceBounds(ZeroFeeEstimate(), false);
5317
+ }
3640
5318
  function toOverheadResourceBounds(estimate, overhead = config.get("resourceBoundsOverhead")) {
3641
5319
  return {
3642
5320
  l2_gas: {
3643
- max_amount: addPercent(estimate.l2_gas_consumed, overhead.l2_gas.max_amount),
3644
- max_price_per_unit: addPercent(estimate.l2_gas_price, overhead.l2_gas.max_price_per_unit)
5321
+ max_amount: addPercent(
5322
+ estimate.l2_gas_consumed,
5323
+ overhead !== false ? overhead.l2_gas.max_amount : 0
5324
+ ),
5325
+ max_price_per_unit: addPercent(
5326
+ estimate.l2_gas_price,
5327
+ overhead !== false ? overhead.l2_gas.max_price_per_unit : 0
5328
+ )
3645
5329
  },
3646
5330
  l1_gas: {
3647
- max_amount: addPercent(estimate.l1_gas_consumed, overhead.l1_gas.max_amount),
3648
- max_price_per_unit: addPercent(estimate.l1_gas_price, overhead.l1_gas.max_price_per_unit)
5331
+ max_amount: addPercent(
5332
+ estimate.l1_gas_consumed,
5333
+ overhead !== false ? overhead.l1_gas.max_amount : 0
5334
+ ),
5335
+ max_price_per_unit: addPercent(
5336
+ estimate.l1_gas_price,
5337
+ overhead !== false ? overhead.l1_gas.max_price_per_unit : 0
5338
+ )
3649
5339
  },
3650
5340
  l1_data_gas: {
3651
- max_amount: addPercent(estimate.l1_data_gas_consumed, overhead.l1_data_gas.max_amount),
5341
+ max_amount: addPercent(
5342
+ estimate.l1_data_gas_consumed,
5343
+ overhead !== false ? overhead.l1_data_gas.max_amount : 0
5344
+ ),
3652
5345
  max_price_per_unit: addPercent(
3653
5346
  estimate.l1_data_gas_price,
3654
- overhead.l1_data_gas.max_price_per_unit
5347
+ overhead !== false ? overhead.l1_data_gas.max_price_per_unit : 0
3655
5348
  )
3656
5349
  }
3657
5350
  };
3658
5351
  }
3659
- function resourceBoundsToEstimateFee(resourceBounds) {
5352
+ function resourceBoundsToEstimateFeeResponse(resourceBounds) {
3660
5353
  return {
3661
5354
  resourceBounds,
3662
5355
  /**
@@ -3667,7 +5360,16 @@ function resourceBoundsToEstimateFee(resourceBounds) {
3667
5360
  };
3668
5361
  }
3669
5362
  function toOverheadOverallFee(estimate, overhead = config.get("resourceBoundsOverhead")) {
3670
- return addPercent(estimate.l1_gas_consumed, overhead.l1_gas.max_amount) * addPercent(estimate.l1_gas_price, overhead.l1_gas.max_price_per_unit) + addPercent(estimate.l1_data_gas_consumed, overhead.l1_data_gas.max_amount) * addPercent(estimate.l1_data_gas_price, overhead.l1_data_gas.max_price_per_unit) + addPercent(estimate.l2_gas_consumed, overhead.l2_gas.max_amount) * addPercent(estimate.l2_gas_price, overhead.l2_gas.max_price_per_unit);
5363
+ return addPercent(estimate.l1_gas_consumed, overhead !== false ? overhead.l1_gas.max_amount : 0) * addPercent(
5364
+ estimate.l1_gas_price,
5365
+ overhead !== false ? overhead.l1_gas.max_price_per_unit : 0
5366
+ ) + addPercent(
5367
+ estimate.l1_data_gas_consumed,
5368
+ overhead !== false ? overhead.l1_data_gas.max_amount : 0
5369
+ ) * addPercent(
5370
+ estimate.l1_data_gas_price,
5371
+ overhead !== false ? overhead.l1_data_gas.max_price_per_unit : 0
5372
+ ) + addPercent(estimate.l2_gas_consumed, overhead !== false ? overhead.l2_gas.max_amount : 0) * addPercent(estimate.l2_gas_price, overhead !== false ? overhead.l2_gas.max_price_per_unit : 0);
3671
5373
  }
3672
5374
  function ZeroFeeEstimate() {
3673
5375
  return {
@@ -3712,7 +5414,7 @@ function v3Details(details) {
3712
5414
  accountDeploymentData: details.accountDeploymentData || [],
3713
5415
  nonceDataAvailabilityMode: details.nonceDataAvailabilityMode || EDataAvailabilityMode.L1,
3714
5416
  feeDataAvailabilityMode: details.feeDataAvailabilityMode || EDataAvailabilityMode.L1,
3715
- resourceBounds: details.resourceBounds ?? toOverheadResourceBounds(ZeroFeeEstimate(), void 0)
5417
+ resourceBounds: details.resourceBounds ?? zeroResourceBounds()
3716
5418
  };
3717
5419
  }
3718
5420
  function getFullPublicKey(privateKey) {
@@ -3782,114 +5484,6 @@ function contractClassResponseToLegacyCompiledContract(ccr) {
3782
5484
  return { ...contract, program: decompressProgram(contract.program) };
3783
5485
  }
3784
5486
 
3785
- // src/utils/errors/rpc.ts
3786
- var errorCodes = {
3787
- FAILED_TO_RECEIVE_TXN: 1,
3788
- NO_TRACE_AVAILABLE: 10,
3789
- CONTRACT_NOT_FOUND: 20,
3790
- ENTRYPOINT_NOT_FOUND: 21,
3791
- BLOCK_NOT_FOUND: 24,
3792
- INVALID_TXN_INDEX: 27,
3793
- CLASS_HASH_NOT_FOUND: 28,
3794
- TXN_HASH_NOT_FOUND: 29,
3795
- PAGE_SIZE_TOO_BIG: 31,
3796
- NO_BLOCKS: 32,
3797
- INVALID_CONTINUATION_TOKEN: 33,
3798
- TOO_MANY_KEYS_IN_FILTER: 34,
3799
- CONTRACT_ERROR: 40,
3800
- TRANSACTION_EXECUTION_ERROR: 41,
3801
- STORAGE_PROOF_NOT_SUPPORTED: 42,
3802
- CLASS_ALREADY_DECLARED: 51,
3803
- INVALID_TRANSACTION_NONCE: 52,
3804
- INSUFFICIENT_RESOURCES_FOR_VALIDATE: 53,
3805
- INSUFFICIENT_ACCOUNT_BALANCE: 54,
3806
- VALIDATION_FAILURE: 55,
3807
- COMPILATION_FAILED: 56,
3808
- CONTRACT_CLASS_SIZE_IS_TOO_LARGE: 57,
3809
- NON_ACCOUNT: 58,
3810
- DUPLICATE_TX: 59,
3811
- COMPILED_CLASS_HASH_MISMATCH: 60,
3812
- UNSUPPORTED_TX_VERSION: 61,
3813
- UNSUPPORTED_CONTRACT_CLASS_VERSION: 62,
3814
- UNEXPECTED_ERROR: 63,
3815
- INVALID_SUBSCRIPTION_ID: 66,
3816
- TOO_MANY_ADDRESSES_IN_FILTER: 67,
3817
- TOO_MANY_BLOCKS_BACK: 68,
3818
- COMPILATION_ERROR: 100,
3819
- INVALID_ADDRESS: 150,
3820
- TOKEN_NOT_SUPPORTED: 151,
3821
- INVALID_SIGNATURE: 153,
3822
- MAX_AMOUNT_TOO_LOW: 154,
3823
- CLASS_HASH_NOT_SUPPORTED: 155,
3824
- PAYMASTER_TRANSACTION_EXECUTION_ERROR: 156,
3825
- INVALID_TIME_BOUNDS: 157,
3826
- INVALID_DEPLOYMENT_DATA: 158,
3827
- INVALID_CLASS_HASH: 159,
3828
- INVALID_ID: 160,
3829
- UNKNOWN_ERROR: 163
3830
- };
3831
- var rpc_default = errorCodes;
3832
-
3833
- // src/utils/errors/index.ts
3834
- function fixStack(target, fn = target.constructor) {
3835
- const { captureStackTrace } = Error;
3836
- captureStackTrace && captureStackTrace(target, fn);
3837
- }
3838
- function fixProto(target, prototype) {
3839
- const { setPrototypeOf } = Object;
3840
- setPrototypeOf ? setPrototypeOf(target, prototype) : target.__proto__ = prototype;
3841
- }
3842
- var CustomError = class extends Error {
3843
- name;
3844
- constructor(message) {
3845
- super(message);
3846
- Object.defineProperty(this, "name", {
3847
- value: new.target.name,
3848
- enumerable: false,
3849
- configurable: true
3850
- });
3851
- fixProto(this, new.target.prototype);
3852
- fixStack(this);
3853
- }
3854
- };
3855
- var LibraryError = class extends CustomError {
3856
- };
3857
- var RpcError = class extends LibraryError {
3858
- constructor(baseError, method, params) {
3859
- super(`RPC: ${method} with params ${stringify2(params, null, 2)}
3860
-
3861
- ${baseError.code}: ${baseError.message}: ${stringify2(baseError.data)}`);
3862
- this.baseError = baseError;
3863
- this.request = { method, params };
3864
- }
3865
- request;
3866
- get code() {
3867
- return this.baseError.code;
3868
- }
3869
- /**
3870
- * Verifies the underlying RPC error, also serves as a type guard for the _baseError_ property
3871
- * @example
3872
- * ```typescript
3873
- * SomeError.isType('UNEXPECTED_ERROR');
3874
- * ```
3875
- */
3876
- isType(typeName) {
3877
- return rpc_default[typeName] === this.code;
3878
- }
3879
- };
3880
- var TimeoutError = class extends LibraryError {
3881
- constructor(message) {
3882
- super(message);
3883
- this.name = "TimeoutError";
3884
- }
3885
- };
3886
- var WebSocketNotConnectedError = class extends LibraryError {
3887
- constructor(message) {
3888
- super(message);
3889
- this.name = "WebSocketNotConnectedError";
3890
- }
3891
- };
3892
-
3893
5487
  // src/utils/eth.ts
3894
5488
  var eth_exports = {};
3895
5489
  __export(eth_exports, {
@@ -4028,7 +5622,7 @@ var Block = class {
4028
5622
  tag = null;
4029
5623
  setIdentifier(__identifier) {
4030
5624
  if (isString(__identifier)) {
4031
- if (isDecimalString(__identifier)) {
5625
+ if (isDecimalString2(__identifier)) {
4032
5626
  this.number = parseInt(__identifier, 10);
4033
5627
  } else if (isHex(__identifier)) {
4034
5628
  this.hash = __identifier;
@@ -4477,11 +6071,13 @@ var RpcChannel = class {
4477
6071
  RPCSPEC08.ETransactionStatus.ACCEPTED_ON_L2,
4478
6072
  RPCSPEC08.ETransactionStatus.ACCEPTED_ON_L1
4479
6073
  ];
6074
+ const txLife = [];
4480
6075
  let txStatus;
4481
6076
  while (!onchain) {
4482
6077
  await wait(retryInterval);
4483
6078
  try {
4484
6079
  txStatus = await this.getTransactionStatus(transactionHash);
6080
+ txLife.push(txStatus.finality_status);
4485
6081
  const executionStatus = txStatus.execution_status;
4486
6082
  const finalityStatus = txStatus.finality_status;
4487
6083
  if (!finalityStatus) {
@@ -4501,6 +6097,18 @@ var RpcChannel = class {
4501
6097
  if (error instanceof Error && isErrorState) {
4502
6098
  throw error;
4503
6099
  }
6100
+ if (error instanceof RpcError && error.isType("TXN_HASH_NOT_FOUND")) {
6101
+ logger.info("txLife: ", txLife);
6102
+ const errorMessages = {
6103
+ [RPCSPEC09.ETransactionStatus.RECEIVED]: SYSTEM_MESSAGES.txEvictedFromMempool,
6104
+ [RPCSPEC09.ETransactionStatus.PRE_CONFIRMED]: SYSTEM_MESSAGES.consensusFailed,
6105
+ [RPCSPEC09.ETransactionStatus.CANDIDATE]: SYSTEM_MESSAGES.txFailsBlockBuildingValidation
6106
+ };
6107
+ const errorMessage = errorMessages[txLife.at(-1)];
6108
+ if (errorMessage) {
6109
+ throw new Error(errorMessage);
6110
+ }
6111
+ }
4504
6112
  if (retries <= 0) {
4505
6113
  throw new Error(`waitForTransaction timed-out with retries ${this.retries}`);
4506
6114
  }
@@ -5050,11 +6658,13 @@ var RpcChannel2 = class {
5050
6658
  RPCSPEC09.ETransactionFinalityStatus.ACCEPTED_ON_L2,
5051
6659
  RPCSPEC09.ETransactionFinalityStatus.ACCEPTED_ON_L1
5052
6660
  ];
6661
+ const txLife = [];
5053
6662
  let txStatus;
5054
6663
  while (!onchain) {
5055
6664
  await wait(retryInterval);
5056
6665
  try {
5057
6666
  txStatus = await this.getTransactionStatus(transactionHash);
6667
+ txLife.push(txStatus.finality_status);
5058
6668
  const executionStatus = txStatus.execution_status;
5059
6669
  const finalityStatus = txStatus.finality_status;
5060
6670
  if (!finalityStatus) {
@@ -5074,6 +6684,18 @@ var RpcChannel2 = class {
5074
6684
  if (error instanceof Error && isErrorState) {
5075
6685
  throw error;
5076
6686
  }
6687
+ if (error instanceof RpcError && error.isType("TXN_HASH_NOT_FOUND")) {
6688
+ logger.info("txLife: ", txLife);
6689
+ const errorMessages = {
6690
+ [RPCSPEC09.ETransactionStatus.RECEIVED]: SYSTEM_MESSAGES.txEvictedFromMempool,
6691
+ [RPCSPEC09.ETransactionStatus.PRE_CONFIRMED]: SYSTEM_MESSAGES.consensusFailed,
6692
+ [RPCSPEC09.ETransactionStatus.CANDIDATE]: SYSTEM_MESSAGES.txFailsBlockBuildingValidation
6693
+ };
6694
+ const errorMessage = errorMessages[txLife.at(-1)];
6695
+ if (errorMessage) {
6696
+ throw new Error(errorMessage);
6697
+ }
6698
+ }
5077
6699
  if (retries <= 0) {
5078
6700
  throw new Error(`waitForTransaction timed-out with retries ${this.retries}`);
5079
6701
  }
@@ -6119,56 +7741,123 @@ var ReceiptTx = class _ReceiptTx {
6119
7741
  statusReceipt;
6120
7742
  value;
6121
7743
  constructor(receipt) {
6122
- [this.statusReceipt, this.value] = _ReceiptTx.isSuccess(receipt) ? ["success", receipt] : _ReceiptTx.isReverted(receipt) ? ["reverted", receipt] : ["error", new Error("Unknown response type")];
6123
- for (const [key] of Object.entries(this)) {
6124
- Object.defineProperty(this, key, {
6125
- enumerable: false
6126
- });
6127
- }
6128
- for (const [key, value] of Object.entries(receipt)) {
6129
- Object.defineProperty(this, key, {
6130
- enumerable: true,
7744
+ Object.assign(this, receipt);
7745
+ const [statusReceipt, value] = _ReceiptTx.isSuccess(receipt) ? ["SUCCEEDED", receipt] : _ReceiptTx.isReverted(receipt) ? ["REVERTED", receipt] : ["ERROR", new Error("Unknown response type")];
7746
+ Object.defineProperties(this, {
7747
+ statusReceipt: {
7748
+ value: statusReceipt,
6131
7749
  writable: false,
6132
- value
6133
- });
6134
- }
6135
- }
6136
- match(callbacks) {
6137
- if (this.statusReceipt in callbacks) {
6138
- return callbacks[this.statusReceipt](this.value);
6139
- }
6140
- return callbacks._();
6141
- }
6142
- isSuccess() {
6143
- return this.statusReceipt === "success";
6144
- }
6145
- isReverted() {
6146
- return this.statusReceipt === "reverted";
6147
- }
6148
- // TODO: Missing is Pending or Production block
6149
- // Status do not exist on receipts
6150
- /* isRejected(): this is RejectedTransactionReceiptResponse {
6151
- return this.statusReceipt === 'rejected';
6152
- } */
6153
- isError() {
6154
- return this.statusReceipt === "error";
7750
+ enumerable: false,
7751
+ configurable: false
7752
+ },
7753
+ value: {
7754
+ value,
7755
+ writable: false,
7756
+ enumerable: false,
7757
+ configurable: false
7758
+ },
7759
+ match: {
7760
+ value(callbacks) {
7761
+ return statusReceipt in callbacks ? callbacks[statusReceipt](value) : callbacks._();
7762
+ },
7763
+ writable: false,
7764
+ enumerable: false,
7765
+ configurable: false
7766
+ },
7767
+ isSuccess: {
7768
+ value: () => statusReceipt === "SUCCEEDED",
7769
+ writable: false,
7770
+ enumerable: false,
7771
+ configurable: false
7772
+ },
7773
+ isReverted: {
7774
+ value: () => statusReceipt === "REVERTED",
7775
+ writable: false,
7776
+ enumerable: false,
7777
+ configurable: false
7778
+ },
7779
+ isError: {
7780
+ value: () => statusReceipt === "ERROR",
7781
+ writable: false,
7782
+ enumerable: false,
7783
+ configurable: false
7784
+ }
7785
+ });
6155
7786
  }
7787
+ match;
7788
+ isSuccess;
7789
+ isReverted;
7790
+ isError;
6156
7791
  static isSuccess(transactionReceipt) {
6157
7792
  return transactionReceipt.execution_status === TransactionExecutionStatus.SUCCEEDED;
6158
7793
  }
6159
7794
  static isReverted(transactionReceipt) {
6160
7795
  return transactionReceipt.execution_status === TransactionExecutionStatus.REVERTED;
6161
7796
  }
6162
- // Status do not exist on receipts
6163
- /* static isRejected(
6164
- transactionReceipt: GetTxReceiptResponseWithoutHelper
6165
- ): transactionReceipt is RejectedTransactionReceiptResponse {
6166
- return (
6167
- (transactionReceipt as RejectedTransactionReceiptResponse).status ===
6168
- TransactionExecutionStatus.REJECTED
6169
- );
6170
- } */
6171
7797
  };
7798
+ var RECEIPT_CONFIG = {
7799
+ [TransactionExecutionStatus.SUCCEEDED]: {
7800
+ statusReceipt: "SUCCEEDED",
7801
+ getBaseData: (receipt) => receipt,
7802
+ getValue: (receipt) => receipt
7803
+ },
7804
+ [TransactionExecutionStatus.REVERTED]: {
7805
+ statusReceipt: "REVERTED",
7806
+ getBaseData: (receipt) => receipt,
7807
+ getValue: (receipt) => receipt
7808
+ }
7809
+ };
7810
+ function createTransactionReceipt(receipt) {
7811
+ const config2 = RECEIPT_CONFIG[receipt.execution_status];
7812
+ let obj;
7813
+ if (config2) {
7814
+ const { statusReceipt, getBaseData, getValue } = config2;
7815
+ const value = getValue(receipt);
7816
+ obj = {
7817
+ ...getBaseData(receipt),
7818
+ statusReceipt,
7819
+ value,
7820
+ match(callbacks) {
7821
+ return statusReceipt in callbacks ? callbacks[statusReceipt](value) : callbacks._();
7822
+ },
7823
+ isSuccess() {
7824
+ return statusReceipt === "SUCCEEDED";
7825
+ },
7826
+ isReverted() {
7827
+ return statusReceipt === "REVERTED";
7828
+ },
7829
+ isError() {
7830
+ return false;
7831
+ }
7832
+ };
7833
+ } else {
7834
+ const errorValue = new Error("Unknown response type");
7835
+ obj = {
7836
+ statusReceipt: "ERROR",
7837
+ value: errorValue,
7838
+ match(callbacks) {
7839
+ return "ERROR" in callbacks ? callbacks.ERROR(errorValue) : callbacks._();
7840
+ },
7841
+ isSuccess() {
7842
+ return false;
7843
+ },
7844
+ isReverted() {
7845
+ return false;
7846
+ },
7847
+ isError() {
7848
+ return true;
7849
+ }
7850
+ };
7851
+ }
7852
+ Object.setPrototypeOf(obj, ReceiptTx.prototype);
7853
+ Object.defineProperty(obj, "constructor", {
7854
+ value: ReceiptTx,
7855
+ writable: false,
7856
+ enumerable: false,
7857
+ configurable: false
7858
+ });
7859
+ return obj;
7860
+ }
6172
7861
 
6173
7862
  // src/utils/typedData.ts
6174
7863
  var typedData_exports = {};
@@ -6837,7 +8526,7 @@ var RpcProvider = class {
6837
8526
  async getTransactionReceipt(txHash) {
6838
8527
  const txReceiptWoHelper = await this.channel.getTransactionReceipt(txHash);
6839
8528
  const txReceiptWoHelperModified = this.responseParser.parseTransactionReceipt(txReceiptWoHelper);
6840
- return new ReceiptTx(txReceiptWoHelperModified);
8529
+ return createTransactionReceipt(txReceiptWoHelperModified);
6841
8530
  }
6842
8531
  async getTransactionTrace(txHash) {
6843
8532
  return this.channel.getTransactionTrace(txHash);
@@ -6853,7 +8542,7 @@ var RpcProvider = class {
6853
8542
  txHash,
6854
8543
  options
6855
8544
  );
6856
- return new ReceiptTx(receiptWoHelper);
8545
+ return createTransactionReceipt(receiptWoHelper);
6857
8546
  }
6858
8547
  async getStorageAt(contractAddress, key, blockIdentifier) {
6859
8548
  return this.channel.getStorageAt(contractAddress, key, blockIdentifier);
@@ -7860,12 +9549,12 @@ var LedgerSigner111 = class {
7860
9549
  */
7861
9550
  async signRaw(msgHash) {
7862
9551
  addHexPrefix(
7863
- buf2hex(await this._transporter.send(Number("0x5a"), 2, 0, 0, Buffer.from(this.pathBuffer)))
9552
+ buf2hex(await this._transporter.send(Number("0x5a"), 2, 0, 0, buffer_default.from(this.pathBuffer)))
7864
9553
  );
7865
9554
  const shiftedHash = toHex(BigInt(msgHash) << 4n);
7866
9555
  const buff2 = hexToBytes(shiftedHash);
7867
9556
  const respSign2 = Uint8Array.from(
7868
- await this._transporter.send(Number("0x5a"), 2, 1, 0, Buffer.from(buff2))
9557
+ await this._transporter.send(Number("0x5a"), 2, 1, 0, buffer_default.from(buff2))
7869
9558
  );
7870
9559
  const r = BigInt(addHexPrefix(buf2hex(respSign2.subarray(1, 33))));
7871
9560
  const s = BigInt(addHexPrefix(buf2hex(respSign2.subarray(33, 65))));
@@ -7878,7 +9567,7 @@ var LedgerSigner111 = class {
7878
9567
  async getPublicKeys() {
7879
9568
  const pathBuff = this.pathBuffer;
7880
9569
  const respGetPublic = Uint8Array.from(
7881
- await this._transporter.send(Number("0x5a"), 1, 0, 0, Buffer.from(pathBuff))
9570
+ await this._transporter.send(Number("0x5a"), 1, 0, 0, buffer_default.from(pathBuff))
7882
9571
  );
7883
9572
  this.pubKey = addHexPrefix(buf2hex(respGetPublic.subarray(1, 33)));
7884
9573
  this.fullPubKey = addHexPrefix(buf2hex(respGetPublic.subarray(0, 65)));
@@ -8134,7 +9823,7 @@ var LedgerSigner221 = class extends LedgerSigner111 {
8134
9823
  txDetails.accountDeploymentData.length <= 7,
8135
9824
  "accountDeploymentData includes more than 7 items"
8136
9825
  );
8137
- await this._transporter.send(Number("0x5a"), 3, 0, 0, Buffer.from(this.pathBuffer));
9826
+ await this._transporter.send(Number("0x5a"), 3, 0, 0, buffer_default.from(this.pathBuffer));
8138
9827
  const accountAddressBuf = this.convertBnToLedger(txDetails.walletAddress);
8139
9828
  const tipBuf = this.convertBnToLedger(txDetails.tip);
8140
9829
  const chainIdBuf = this.convertBnToLedger(txDetails.chainId);
@@ -8156,30 +9845,30 @@ var LedgerSigner221 = class extends LedgerSigner111 {
8156
9845
  nonceBuf,
8157
9846
  dAModeHashBuf
8158
9847
  ]);
8159
- await this._transporter.send(Number("0x5a"), 3, 1, 0, Buffer.from(dataBuf));
9848
+ await this._transporter.send(Number("0x5a"), 3, 1, 0, buffer_default.from(dataBuf));
8160
9849
  const paymasterBuf = concatenateArrayBuffer(
8161
9850
  txDetails.paymasterData.map((value) => {
8162
9851
  const a = this.convertBnToLedger(value);
8163
9852
  return a;
8164
9853
  })
8165
9854
  );
8166
- await this._transporter.send(Number("0x5a"), 3, 2, 0, Buffer.from(paymasterBuf));
9855
+ await this._transporter.send(Number("0x5a"), 3, 2, 0, buffer_default.from(paymasterBuf));
8167
9856
  const accountDeployDataBuf = concatenateArrayBuffer(
8168
9857
  txDetails.paymasterData.map((value) => {
8169
9858
  const a = this.convertBnToLedger(value);
8170
9859
  return a;
8171
9860
  })
8172
9861
  );
8173
- await this._transporter.send(Number("0x5a"), 3, 3, 0, Buffer.from(accountDeployDataBuf));
9862
+ await this._transporter.send(Number("0x5a"), 3, 3, 0, buffer_default.from(accountDeployDataBuf));
8174
9863
  const nbCallsBuf = this.convertBnToLedger(calls.length);
8175
- await this._transporter.send(Number("0x5a"), 3, 4, 0, Buffer.from(nbCallsBuf));
9864
+ await this._transporter.send(Number("0x5a"), 3, 4, 0, buffer_default.from(nbCallsBuf));
8176
9865
  let respSign = new Uint8Array(0);
8177
9866
  for (const call of calls) {
8178
9867
  const calldatas = this.encodeCall(call);
8179
- await this._transporter.send(Number("0x5a"), 3, 5, 0, Buffer.from(calldatas[0]));
9868
+ await this._transporter.send(Number("0x5a"), 3, 5, 0, buffer_default.from(calldatas[0]));
8180
9869
  if (calldatas.length > 1) {
8181
9870
  calldatas.slice(1).forEach(async (part) => {
8182
- await this._transporter.send(Number("0x5a"), 3, 5, 1, Buffer.from(part));
9871
+ await this._transporter.send(Number("0x5a"), 3, 5, 1, buffer_default.from(part));
8183
9872
  });
8184
9873
  }
8185
9874
  respSign = await this._transporter.send(Number("0x5a"), 3, 5, 2);
@@ -8216,7 +9905,7 @@ var LedgerSigner221 = class extends LedgerSigner111 {
8216
9905
  * ```
8217
9906
  */
8218
9907
  async signDeployAccountV3(deployAccountDetail) {
8219
- await this._transporter.send(Number("0x5a"), 5, 0, 0, Buffer.from(this.pathBuffer));
9908
+ await this._transporter.send(Number("0x5a"), 5, 0, 0, buffer_default.from(this.pathBuffer));
8220
9909
  const accountAddressBuf = this.convertBnToLedger(
8221
9910
  deployAccountDetail.contractAddress
8222
9911
  );
@@ -8238,7 +9927,7 @@ var LedgerSigner221 = class extends LedgerSigner111 {
8238
9927
  classHashBuf,
8239
9928
  saltBuf
8240
9929
  ]);
8241
- await this._transporter.send(Number("0x5a"), 5, 1, 0, Buffer.from(dataBuf));
9930
+ await this._transporter.send(Number("0x5a"), 5, 1, 0, buffer_default.from(dataBuf));
8242
9931
  const tipBuf = this.convertBnToLedger(deployAccountDetail.tip);
8243
9932
  const l1_gasBuf = this.convertBnToLedger(
8244
9933
  encodeResourceBoundsL1(deployAccountDetail.resourceBounds)
@@ -8247,17 +9936,17 @@ var LedgerSigner221 = class extends LedgerSigner111 {
8247
9936
  encodeResourceBoundsL2(deployAccountDetail.resourceBounds)
8248
9937
  );
8249
9938
  const feeBuf = concatenateArrayBuffer([tipBuf, l1_gasBuf, l2_gasBuf]);
8250
- await this._transporter.send(Number("0x5a"), 5, 2, 0, Buffer.from(feeBuf));
9939
+ await this._transporter.send(Number("0x5a"), 5, 2, 0, buffer_default.from(feeBuf));
8251
9940
  const paymasterBuf = concatenateArrayBuffer(
8252
9941
  deployAccountDetail.paymasterData.map((value) => {
8253
9942
  const a = this.convertBnToLedger(value);
8254
9943
  return a;
8255
9944
  })
8256
9945
  );
8257
- await this._transporter.send(Number("0x5a"), 5, 3, 0, Buffer.from(paymasterBuf));
9946
+ await this._transporter.send(Number("0x5a"), 5, 3, 0, buffer_default.from(paymasterBuf));
8258
9947
  const compiledConstructor = CallData.compile(deployAccountDetail.constructorCalldata);
8259
9948
  const constructorLengthBuf = this.convertBnToLedger(compiledConstructor.length);
8260
- await this._transporter.send(Number("0x5a"), 5, 4, 0, Buffer.from(constructorLengthBuf));
9949
+ await this._transporter.send(Number("0x5a"), 5, 4, 0, buffer_default.from(constructorLengthBuf));
8261
9950
  const constructorBuf = concatenateArrayBuffer(
8262
9951
  compiledConstructor.map((parameter) => {
8263
9952
  const a = this.convertBnToLedger(parameter);
@@ -8270,7 +9959,7 @@ var LedgerSigner221 = class extends LedgerSigner111 {
8270
9959
  constructorChunks.push(constructorBuf.subarray(i, i + chunkSize));
8271
9960
  let respSign = new Uint8Array(0);
8272
9961
  for (const chunk of constructorChunks) {
8273
- respSign = await this._transporter.send(Number("0x5a"), 5, 5, 0, Buffer.from(chunk));
9962
+ respSign = await this._transporter.send(Number("0x5a"), 5, 5, 0, buffer_default.from(chunk));
8274
9963
  }
8275
9964
  return this.decodeSignatureLedger(respSign);
8276
9965
  }
@@ -8360,7 +10049,7 @@ var LedgerSigner231 = class extends LedgerSigner221 {
8360
10049
  txDetails.accountDeploymentData.length <= 7,
8361
10050
  "accountDeploymentData includes more than 7 items"
8362
10051
  );
8363
- await this._transporter.send(Number("0x5a"), 3, 0, 0, Buffer.from(this.pathBuffer));
10052
+ await this._transporter.send(Number("0x5a"), 3, 0, 0, buffer_default.from(this.pathBuffer));
8364
10053
  const accountAddressBuf = this.convertBnToLedger(txDetails.walletAddress);
8365
10054
  const chainIdBuf = this.convertBnToLedger(txDetails.chainId);
8366
10055
  const nonceBuf = this.convertBnToLedger(txDetails.nonce);
@@ -8376,7 +10065,7 @@ var LedgerSigner231 = class extends LedgerSigner221 {
8376
10065
  nonceBuf,
8377
10066
  dAModeHashBuf
8378
10067
  ]);
8379
- await this._transporter.send(Number("0x5a"), 3, 1, 0, Buffer.from(dataBuf));
10068
+ await this._transporter.send(Number("0x5a"), 3, 1, 0, buffer_default.from(dataBuf));
8380
10069
  if (isRPC08Plus_ResourceBoundsBN(txDetails.resourceBounds)) {
8381
10070
  const tipBuf = this.convertBnToLedger(txDetails.tip);
8382
10071
  const l1_gasBuf = this.convertBnToLedger(encodeResourceBoundsL1(txDetails.resourceBounds));
@@ -8390,7 +10079,7 @@ var LedgerSigner231 = class extends LedgerSigner221 {
8390
10079
  l2_gasBuf,
8391
10080
  l1_data_gasBuf
8392
10081
  ]);
8393
- await this._transporter.send(Number("0x5a"), 3, 2, 0, Buffer.from(feeBuf));
10082
+ await this._transporter.send(Number("0x5a"), 3, 2, 0, buffer_default.from(feeBuf));
8394
10083
  }
8395
10084
  const paymasterBuf = concatenateArrayBuffer(
8396
10085
  txDetails.paymasterData.map((value) => {
@@ -8398,23 +10087,23 @@ var LedgerSigner231 = class extends LedgerSigner221 {
8398
10087
  return a;
8399
10088
  })
8400
10089
  );
8401
- await this._transporter.send(Number("0x5a"), 3, 3, 0, Buffer.from(paymasterBuf));
10090
+ await this._transporter.send(Number("0x5a"), 3, 3, 0, buffer_default.from(paymasterBuf));
8402
10091
  const accountDeployDataBuf = concatenateArrayBuffer(
8403
10092
  txDetails.paymasterData.map((value) => {
8404
10093
  const a = this.convertBnToLedger(value);
8405
10094
  return a;
8406
10095
  })
8407
10096
  );
8408
- await this._transporter.send(Number("0x5a"), 3, 4, 0, Buffer.from(accountDeployDataBuf));
10097
+ await this._transporter.send(Number("0x5a"), 3, 4, 0, buffer_default.from(accountDeployDataBuf));
8409
10098
  const nbCallsBuf = this.convertBnToLedger(calls.length);
8410
- await this._transporter.send(Number("0x5a"), 3, 5, 0, Buffer.from(nbCallsBuf));
10099
+ await this._transporter.send(Number("0x5a"), 3, 5, 0, buffer_default.from(nbCallsBuf));
8411
10100
  let respSign = new Uint8Array(0);
8412
10101
  for (const call of calls) {
8413
10102
  const calldatas = this.encodeCall(call);
8414
- respSign = await this._transporter.send(Number("0x5a"), 3, 6, 0, Buffer.from(calldatas[0]));
10103
+ respSign = await this._transporter.send(Number("0x5a"), 3, 6, 0, buffer_default.from(calldatas[0]));
8415
10104
  if (calldatas.length > 1) {
8416
10105
  calldatas.slice(1).forEach(async (part) => {
8417
- respSign = await this._transporter.send(Number("0x5a"), 3, 6, 1, Buffer.from(part));
10106
+ respSign = await this._transporter.send(Number("0x5a"), 3, 6, 1, buffer_default.from(part));
8418
10107
  });
8419
10108
  }
8420
10109
  }
@@ -8450,7 +10139,7 @@ var LedgerSigner231 = class extends LedgerSigner221 {
8450
10139
  * ```
8451
10140
  */
8452
10141
  async signDeployAccountV3(deployAccountDetail) {
8453
- await this._transporter.send(Number("0x5a"), 5, 0, 0, Buffer.from(this.pathBuffer));
10142
+ await this._transporter.send(Number("0x5a"), 5, 0, 0, buffer_default.from(this.pathBuffer));
8454
10143
  const accountAddressBuf = this.convertBnToLedger(
8455
10144
  deployAccountDetail.contractAddress
8456
10145
  );
@@ -8472,7 +10161,7 @@ var LedgerSigner231 = class extends LedgerSigner221 {
8472
10161
  classHashBuf,
8473
10162
  saltBuf
8474
10163
  ]);
8475
- await this._transporter.send(Number("0x5a"), 5, 1, 0, Buffer.from(dataBuf));
10164
+ await this._transporter.send(Number("0x5a"), 5, 1, 0, buffer_default.from(dataBuf));
8476
10165
  if (isRPC08Plus_ResourceBoundsBN(deployAccountDetail.resourceBounds)) {
8477
10166
  const tipBuf = this.convertBnToLedger(deployAccountDetail.tip);
8478
10167
  const l1_gasBuf = this.convertBnToLedger(
@@ -8490,7 +10179,7 @@ var LedgerSigner231 = class extends LedgerSigner221 {
8490
10179
  l2_gasBuf,
8491
10180
  l1_data_gasBuf
8492
10181
  ]);
8493
- await this._transporter.send(Number("0x5a"), 5, 2, 0, Buffer.from(feeBuf));
10182
+ await this._transporter.send(Number("0x5a"), 5, 2, 0, buffer_default.from(feeBuf));
8494
10183
  }
8495
10184
  const paymasterBuf = concatenateArrayBuffer(
8496
10185
  deployAccountDetail.paymasterData.map((value) => {
@@ -8498,10 +10187,10 @@ var LedgerSigner231 = class extends LedgerSigner221 {
8498
10187
  return a;
8499
10188
  })
8500
10189
  );
8501
- await this._transporter.send(Number("0x5a"), 5, 3, 0, Buffer.from(paymasterBuf));
10190
+ await this._transporter.send(Number("0x5a"), 5, 3, 0, buffer_default.from(paymasterBuf));
8502
10191
  const compiledConstructor = CallData.compile(deployAccountDetail.constructorCalldata);
8503
10192
  const constructorLengthBuf = this.convertBnToLedger(compiledConstructor.length);
8504
- await this._transporter.send(Number("0x5a"), 5, 4, 0, Buffer.from(constructorLengthBuf));
10193
+ await this._transporter.send(Number("0x5a"), 5, 4, 0, buffer_default.from(constructorLengthBuf));
8505
10194
  const constructorBuf = concatenateArrayBuffer(
8506
10195
  compiledConstructor.map((parameter) => {
8507
10196
  const a = this.convertBnToLedger(parameter);
@@ -8514,7 +10203,7 @@ var LedgerSigner231 = class extends LedgerSigner221 {
8514
10203
  constructorChunks.push(constructorBuf.subarray(i, i + chunkSize));
8515
10204
  let respSign = new Uint8Array(0);
8516
10205
  for (const chunk of constructorChunks) {
8517
- respSign = await this._transporter.send(Number("0x5a"), 5, 5, 0, Buffer.from(chunk));
10206
+ respSign = await this._transporter.send(Number("0x5a"), 5, 5, 0, buffer_default.from(chunk));
8518
10207
  }
8519
10208
  return this.decodeSignatureLedger(respSign);
8520
10209
  }
@@ -9183,7 +10872,8 @@ var Account = class extends RpcProvider2 {
9183
10872
  }
9184
10873
  async estimateFeeBulk(invocations, details = {}) {
9185
10874
  if (!invocations.length) throw TypeError("Invocations should be non-empty array");
9186
- if (details.resourceBounds) return [resourceBoundsToEstimateFee(details.resourceBounds)];
10875
+ if (details.resourceBounds)
10876
+ return [resourceBoundsToEstimateFeeResponse(details.resourceBounds)];
9187
10877
  const { nonce, blockIdentifier, version, skipValidate } = details;
9188
10878
  const detailsWithTip = await this.resolveDetailsWithTip(details);
9189
10879
  const accountInvocations = await this.accountInvocationsFactory(invocations, {
@@ -10041,7 +11731,11 @@ function mergeAbiEvents(target, source) {
10041
11731
  Object.keys(source).forEach((key) => {
10042
11732
  if (isObject(source[key])) {
10043
11733
  if (!(key in target)) Object.assign(output, { [key]: source[key] });
10044
- else output[key] = mergeAbiEvents(target[key], source[key]);
11734
+ else
11735
+ output[key] = mergeAbiEvents(
11736
+ target[key],
11737
+ source[key]
11738
+ );
10045
11739
  } else {
10046
11740
  Object.assign(output, { [key]: source[key] });
10047
11741
  }
@@ -10049,7 +11743,7 @@ function mergeAbiEvents(target, source) {
10049
11743
  }
10050
11744
  return output;
10051
11745
  }
10052
- function parseEvents(providerReceivedEvents, abiEvents, abiStructs, abiEnums) {
11746
+ function parseEvents(providerReceivedEvents, abiEvents, abiStructs, abiEnums, parser) {
10053
11747
  const ret = providerReceivedEvents.flat().reduce((acc, recEvent) => {
10054
11748
  const currentEvent = JSON.parse(JSON.stringify(recEvent));
10055
11749
  let abiEvent = abiEvents[currentEvent.keys.shift() ?? 0];
@@ -10068,22 +11762,24 @@ function parseEvents(providerReceivedEvents, abiEvents, abiStructs, abiEnums) {
10068
11762
  const abiEventKeys = abiEvent.members?.filter((it) => it.kind === "key") || abiEvent.keys;
10069
11763
  const abiEventData = abiEvent.members?.filter((it) => it.kind === "data") || abiEvent.data;
10070
11764
  abiEventKeys.forEach((key) => {
10071
- parsedEvent[abiEvent.name][key.name] = responseParser(
10072
- keysIter,
10073
- key,
10074
- abiStructs,
10075
- abiEnums,
10076
- parsedEvent[abiEvent.name]
10077
- );
11765
+ parsedEvent[abiEvent.name][key.name] = responseParser({
11766
+ responseIterator: keysIter,
11767
+ output: key,
11768
+ structs: abiStructs,
11769
+ enums: abiEnums,
11770
+ parser,
11771
+ parsedResult: parsedEvent[abiEvent.name]
11772
+ });
10078
11773
  });
10079
11774
  abiEventData.forEach((data) => {
10080
- parsedEvent[abiEvent.name][data.name] = responseParser(
10081
- dataIter,
10082
- data,
10083
- abiStructs,
10084
- abiEnums,
10085
- parsedEvent[abiEvent.name]
10086
- );
11775
+ parsedEvent[abiEvent.name][data.name] = responseParser({
11776
+ responseIterator: dataIter,
11777
+ output: data,
11778
+ structs: abiStructs,
11779
+ enums: abiEnums,
11780
+ parser,
11781
+ parsedResult: parsedEvent[abiEvent.name]
11782
+ });
10087
11783
  });
10088
11784
  if ("block_hash" in currentEvent) parsedEvent.block_hash = currentEvent.block_hash;
10089
11785
  if ("block_number" in currentEvent) parsedEvent.block_number = currentEvent.block_number;
@@ -10101,8 +11797,8 @@ function buildCall(contract, functionAbi) {
10101
11797
  const options = { ...contract.withOptionsProps };
10102
11798
  contract.withOptionsProps = void 0;
10103
11799
  return contract.call(functionAbi.name, args, {
10104
- parseRequest: true,
10105
- parseResponse: true,
11800
+ parseRequest: contract.parseRequest,
11801
+ parseResponse: contract.parseResponse,
10106
11802
  ...options
10107
11803
  });
10108
11804
  };
@@ -10112,7 +11808,7 @@ function buildInvoke(contract, functionAbi) {
10112
11808
  const options = { ...contract.withOptionsProps };
10113
11809
  contract.withOptionsProps = void 0;
10114
11810
  return contract.invoke(functionAbi.name, args, {
10115
- parseRequest: true,
11811
+ parseRequest: contract.parseRequest,
10116
11812
  ...options
10117
11813
  });
10118
11814
  };
@@ -10140,6 +11836,8 @@ var Contract = class _Contract {
10140
11836
  address;
10141
11837
  providerOrAccount;
10142
11838
  classHash;
11839
+ parseRequest;
11840
+ parseResponse;
10143
11841
  structs;
10144
11842
  events;
10145
11843
  functions;
@@ -10148,6 +11846,7 @@ var Contract = class _Contract {
10148
11846
  estimateFee;
10149
11847
  callData;
10150
11848
  withOptionsProps;
11849
+ parsingStrategy;
10151
11850
  /**
10152
11851
  * @param options
10153
11852
  * - abi: Abi of the contract object (required)
@@ -10155,14 +11854,18 @@ var Contract = class _Contract {
10155
11854
  * - providerOrAccount?: Provider or Account to attach to (fallback to defaultProvider)
10156
11855
  * - parseRequest?: compile and validate arguments (optional, default true)
10157
11856
  * - parseResponse?: Parse elements of the response array and structuring them into response object (optional, default true)
11857
+ * - parser?: Abi parser (optional, default createAbiParser(options.abi))
10158
11858
  */
10159
11859
  constructor(options) {
10160
- const parser = createAbiParser(options.abi);
10161
- this.address = options.address && options.address.toLowerCase();
11860
+ this.parsingStrategy = options.parsingStrategy;
11861
+ const parser = createAbiParser(options.abi, options.parsingStrategy);
10162
11862
  this.abi = parser.getLegacyFormat();
11863
+ this.address = options.address && options.address.toLowerCase();
10163
11864
  this.providerOrAccount = options.providerOrAccount ?? defaultProvider;
11865
+ this.parseRequest = options.parseRequest ?? true;
11866
+ this.parseResponse = options.parseResponse ?? true;
10164
11867
  this.classHash = options.classHash;
10165
- this.callData = new CallData(options.abi);
11868
+ this.callData = new CallData(options.abi, options.parsingStrategy);
10166
11869
  this.structs = CallData.getAbiStruct(options.abi);
10167
11870
  this.events = getAbiEvents(options.abi);
10168
11871
  const methodTypes = { enumerable: true, value: {}, writable: false };
@@ -10214,8 +11917,9 @@ var Contract = class _Contract {
10214
11917
  attach(address, abi) {
10215
11918
  this.address = address;
10216
11919
  if (abi) {
10217
- this.abi = createAbiParser(abi).getLegacyFormat();
10218
- this.callData = new CallData(abi);
11920
+ const parser = createAbiParser(abi, this.parsingStrategy);
11921
+ this.abi = parser.getLegacyFormat();
11922
+ this.callData = new CallData(abi, this.parsingStrategy);
10219
11923
  this.structs = CallData.getAbiStruct(abi);
10220
11924
  this.events = getAbiEvents(abi);
10221
11925
  }
@@ -10261,7 +11965,8 @@ var Contract = class _Contract {
10261
11965
  return this.callData.parse(method, it);
10262
11966
  });
10263
11967
  }
10264
- invoke(method, args = [], { parseRequest = true, signature, ...RestInvokeOptions } = {}) {
11968
+ async invoke(method, args = [], options = {}) {
11969
+ const { parseRequest = true, signature, waitForTransaction, ...RestInvokeOptions } = options;
10265
11970
  assert(this.address !== null, "contract is not connected to an address");
10266
11971
  const calldata = getCompiledCalldata(args, () => {
10267
11972
  if (parseRequest) {
@@ -10277,9 +11982,17 @@ var Contract = class _Contract {
10277
11982
  entrypoint: method
10278
11983
  };
10279
11984
  if (isAccount(this.providerOrAccount)) {
10280
- return this.providerOrAccount.execute(invocation, {
11985
+ const result = await this.providerOrAccount.execute(invocation, {
10281
11986
  ...RestInvokeOptions
10282
11987
  });
11988
+ if (waitForTransaction) {
11989
+ const result2 = await this.providerOrAccount.waitForTransaction(result.transaction_hash);
11990
+ if (result2.isSuccess()) {
11991
+ return result2;
11992
+ }
11993
+ throw new Error("Transaction failed", { cause: result2 });
11994
+ }
11995
+ return result;
10283
11996
  }
10284
11997
  if (!RestInvokeOptions.nonce)
10285
11998
  throw new Error(`Manual nonce is required when invoking a function without an account`);
@@ -10317,9 +12030,9 @@ var Contract = class _Contract {
10317
12030
  // TODO: Demistify what is going on here ???
10318
12031
  // TODO: receipt status filtering test and fix this do not look right
10319
12032
  parseEvents(receipt) {
10320
- let parsed;
12033
+ let parsed = [];
10321
12034
  receipt.match({
10322
- success: (txR) => {
12035
+ SUCCEEDED: (txR) => {
10323
12036
  const emittedEvents = txR.events?.map((event) => {
10324
12037
  return {
10325
12038
  // TODO: this do not check that block is production and block_hash and block_number actually exists
@@ -10332,16 +12045,26 @@ var Contract = class _Contract {
10332
12045
  }).filter((event) => cleanHex(event.from_address) === cleanHex(this.address), []) || [];
10333
12046
  parsed = parseEvents(
10334
12047
  emittedEvents,
10335
- // TODO: any temp hotfix, fix this
10336
12048
  this.events,
10337
12049
  this.structs,
10338
- CallData.getAbiEnum(this.abi)
12050
+ CallData.getAbiEnum(this.abi),
12051
+ this.callData.parser
10339
12052
  );
10340
12053
  },
10341
12054
  _: () => {
10342
12055
  throw Error("This transaction was not successful.");
10343
12056
  }
10344
12057
  });
12058
+ Object.defineProperty(parsed, "getByPath", {
12059
+ value: (path) => {
12060
+ const event = parsed.find((ev) => Object.keys(ev).some((key) => key.includes(path)));
12061
+ const eventKey = Object.keys(event || {}).find((key) => key.includes(path));
12062
+ return eventKey && event ? event[eventKey] : null;
12063
+ },
12064
+ writable: false,
12065
+ enumerable: false,
12066
+ configurable: false
12067
+ });
10345
12068
  return parsed;
10346
12069
  }
10347
12070
  isCairo1() {
@@ -10458,7 +12181,10 @@ var Contract = class _Contract {
10458
12181
  abi,
10459
12182
  address: contract_address,
10460
12183
  providerOrAccount: account,
10461
- classHash
12184
+ classHash,
12185
+ parseRequest: params.parseRequest,
12186
+ parseResponse: params.parseResponse,
12187
+ parsingStrategy: params.parsingStrategy
10462
12188
  });
10463
12189
  }
10464
12190
  };
@@ -10514,19 +12240,33 @@ function units(amount, simbol = "fri") {
10514
12240
  }
10515
12241
  // Annotate the CommonJS export names for ESM import in node:
10516
12242
  0 && (module.exports = {
12243
+ AbiParser1,
12244
+ AbiParser2,
12245
+ AbiParserInterface,
10517
12246
  Account,
10518
12247
  AccountInterface,
10519
12248
  BatchClient,
10520
12249
  BlockStatus,
10521
12250
  BlockTag,
12251
+ CairoByteArray,
10522
12252
  CairoCustomEnum,
10523
12253
  CairoFixedArray,
12254
+ CairoInt128,
12255
+ CairoInt16,
12256
+ CairoInt32,
12257
+ CairoInt64,
12258
+ CairoInt8,
10524
12259
  CairoOption,
10525
12260
  CairoOptionVariant,
10526
12261
  CairoResult,
10527
12262
  CairoResultVariant,
12263
+ CairoUint128,
12264
+ CairoUint16,
10528
12265
  CairoUint256,
10529
12266
  CairoUint512,
12267
+ CairoUint64,
12268
+ CairoUint8,
12269
+ CairoUint96,
10530
12270
  CallData,
10531
12271
  Contract,
10532
12272
  ContractInterface,
@@ -10542,6 +12282,7 @@ function units(amount, simbol = "fri") {
10542
12282
  ETransactionVersion3,
10543
12283
  EntryPointType,
10544
12284
  EthSigner,
12285
+ Int,
10545
12286
  LedgerSigner,
10546
12287
  LedgerSigner111,
10547
12288
  LedgerSigner221,
@@ -10595,6 +12336,8 @@ function units(amount, simbol = "fri") {
10595
12336
  config,
10596
12337
  constants,
10597
12338
  contractClassResponseToLegacyCompiledContract,
12339
+ createAbiParser,
12340
+ createTransactionReceipt,
10598
12341
  defaultDeployer,
10599
12342
  defaultPaymaster,
10600
12343
  defaultProvider,
@@ -10603,6 +12346,8 @@ function units(amount, simbol = "fri") {
10603
12346
  eth,
10604
12347
  events,
10605
12348
  extractContractHashes,
12349
+ fastParsingStrategy,
12350
+ getAbiVersion,
10606
12351
  getChecksumAddress,
10607
12352
  getGasPrices,
10608
12353
  getLedgerPathBuffer,
@@ -10610,7 +12355,9 @@ function units(amount, simbol = "fri") {
10610
12355
  getLedgerPathBuffer221,
10611
12356
  getTipStatsFromBlocks,
10612
12357
  hash,
12358
+ hdParsingStrategy,
10613
12359
  isAccount,
12360
+ isNoConstructorValid,
10614
12361
  isPendingBlock,
10615
12362
  isPendingStateUpdate,
10616
12363
  isPendingTransaction,