starknet 5.24.4 → 5.25.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/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ # [5.25.0](https://github.com/starknet-io/starknet.js/compare/v5.24.5...v5.25.0) (2023-12-18)
2
+
3
+ ### Features
4
+
5
+ - sepolia ([26d7044](https://github.com/starknet-io/starknet.js/commit/26d70446edd7c098b7f257d9242cc9d9d220b11e))
6
+
7
+ ## [5.24.5](https://github.com/starknet-io/starknet.js/compare/v5.24.4...v5.24.5) (2023-12-10)
8
+
9
+ ### Bug Fixes
10
+
11
+ - apply bound for contract address from hash calculation ([6d8c291](https://github.com/starknet-io/starknet.js/commit/6d8c291bce130d7b00ae6d81aff071c4986f04af))
12
+ - **Calldata.compile:** do not split long `entrypoint` names before calling `getSelectorFromName` ([89715da](https://github.com/starknet-io/starknet.js/commit/89715da3fdb4b497cc5771eb83a88460007740b6))
13
+ - prioritize error states in waitForTransaction evaluation ([ac54404](https://github.com/starknet-io/starknet.js/commit/ac544045e2079b68042d850a09b203fc5536c0d0))
14
+
1
15
  ## [5.24.4](https://github.com/starknet-io/starknet.js/compare/v5.24.3...v5.24.4) (2023-12-06)
2
16
 
3
17
  ### Bug Fixes
package/README.md CHANGED
@@ -64,6 +64,8 @@ If you consider to contribute to this project please read [CONTRIBUTING.md](http
64
64
 
65
65
  Special thanks to all the [contributors](https://github.com/starknet-io/starknet.js/graphs/contributors), especially to:
66
66
 
67
+ - Sean ([@0xs34n](https://github.com/0xs34n)), the original creator of Straknet.js!
68
+
67
69
  - Janek ([@janek26](https://github.com/janek26)) and Dhruv ([@dhruvkelawala](https://github.com/dhruvkelawala)) from [Argent](https://github.com/argentlabs)
68
70
 
69
71
  - Toni ([@tabaktoni](https://github.com/tabaktoni)) and Ivan ([@ivpavici](https://github.com/ivpavici)) from [SpaceShard](https://www.spaceshard.io/)
package/dist/index.d.ts CHANGED
@@ -128,19 +128,23 @@ declare const BN_FEE_TRANSACTION_VERSION_1: bigint;
128
128
  declare const BN_FEE_TRANSACTION_VERSION_2: bigint;
129
129
  declare const ZERO = 0n;
130
130
  declare const MASK_250: bigint;
131
- declare const MASK_251: bigint;
132
131
  declare const API_VERSION = 0n;
132
+ declare const MAX_STORAGE_ITEM_SIZE = 256n;
133
+ declare const ADDR_BOUND: bigint;
133
134
  declare enum BaseUrl {
134
135
  SN_MAIN = "https://alpha-mainnet.starknet.io",
135
- SN_GOERLI = "https://alpha4.starknet.io"
136
+ SN_GOERLI = "https://alpha4.starknet.io",
137
+ SN_SEPOLIA = "https://alpha-sepolia.starknet.io"
136
138
  }
137
139
  declare enum NetworkName {
138
140
  SN_MAIN = "SN_MAIN",
139
- SN_GOERLI = "SN_GOERLI"
141
+ SN_GOERLI = "SN_GOERLI",
142
+ SN_SEPOLIA = "SN_SEPOLIA"
140
143
  }
141
144
  declare enum StarknetChainId {
142
145
  SN_MAIN = "0x534e5f4d41494e",
143
- SN_GOERLI = "0x534e5f474f45524c49"
146
+ SN_GOERLI = "0x534e5f474f45524c49",
147
+ SN_SEPOLIA = "0x534e5f5345504f4c4941"
144
148
  }
145
149
  declare enum TransactionHashPrefix {
146
150
  DECLARE = "0x6465636c617265",
@@ -153,9 +157,14 @@ declare const UDC: {
153
157
  ADDRESS: string;
154
158
  ENTRYPOINT: string;
155
159
  };
156
- declare const RPC_GOERLI_NODES: string[];
157
- declare const RPC_MAINNET_NODES: string[];
160
+ declare const RPC_DEFAULT_VERSION = "v0_5";
161
+ declare const RPC_NODES: {
162
+ SN_GOERLI: string[];
163
+ SN_MAIN: string[];
164
+ SN_SEPOLIA: string[];
165
+ };
158
166
 
167
+ declare const constants_ADDR_BOUND: typeof ADDR_BOUND;
159
168
  declare const constants_API_VERSION: typeof API_VERSION;
160
169
  declare const constants_BN_FEE_TRANSACTION_VERSION_1: typeof BN_FEE_TRANSACTION_VERSION_1;
161
170
  declare const constants_BN_FEE_TRANSACTION_VERSION_2: typeof BN_FEE_TRANSACTION_VERSION_2;
@@ -167,11 +176,11 @@ declare const constants_HEX_STR_TRANSACTION_VERSION_1: typeof HEX_STR_TRANSACTIO
167
176
  declare const constants_HEX_STR_TRANSACTION_VERSION_2: typeof HEX_STR_TRANSACTION_VERSION_2;
168
177
  declare const constants_IS_BROWSER: typeof IS_BROWSER;
169
178
  declare const constants_MASK_250: typeof MASK_250;
170
- declare const constants_MASK_251: typeof MASK_251;
179
+ declare const constants_MAX_STORAGE_ITEM_SIZE: typeof MAX_STORAGE_ITEM_SIZE;
171
180
  type constants_NetworkName = NetworkName;
172
181
  declare const constants_NetworkName: typeof NetworkName;
173
- declare const constants_RPC_GOERLI_NODES: typeof RPC_GOERLI_NODES;
174
- declare const constants_RPC_MAINNET_NODES: typeof RPC_MAINNET_NODES;
182
+ declare const constants_RPC_DEFAULT_VERSION: typeof RPC_DEFAULT_VERSION;
183
+ declare const constants_RPC_NODES: typeof RPC_NODES;
175
184
  type constants_StarknetChainId = StarknetChainId;
176
185
  declare const constants_StarknetChainId: typeof StarknetChainId;
177
186
  declare const constants_TEXT_TO_FELT_MAX_LEN: typeof TEXT_TO_FELT_MAX_LEN;
@@ -181,6 +190,7 @@ declare const constants_UDC: typeof UDC;
181
190
  declare const constants_ZERO: typeof ZERO;
182
191
  declare namespace constants {
183
192
  export {
193
+ constants_ADDR_BOUND as ADDR_BOUND,
184
194
  constants_API_VERSION as API_VERSION,
185
195
  constants_BN_FEE_TRANSACTION_VERSION_1 as BN_FEE_TRANSACTION_VERSION_1,
186
196
  constants_BN_FEE_TRANSACTION_VERSION_2 as BN_FEE_TRANSACTION_VERSION_2,
@@ -191,10 +201,10 @@ declare namespace constants {
191
201
  constants_HEX_STR_TRANSACTION_VERSION_2 as HEX_STR_TRANSACTION_VERSION_2,
192
202
  constants_IS_BROWSER as IS_BROWSER,
193
203
  constants_MASK_250 as MASK_250,
194
- constants_MASK_251 as MASK_251,
204
+ constants_MAX_STORAGE_ITEM_SIZE as MAX_STORAGE_ITEM_SIZE,
195
205
  constants_NetworkName as NetworkName,
196
- constants_RPC_GOERLI_NODES as RPC_GOERLI_NODES,
197
- constants_RPC_MAINNET_NODES as RPC_MAINNET_NODES,
206
+ constants_RPC_DEFAULT_VERSION as RPC_DEFAULT_VERSION,
207
+ constants_RPC_NODES as RPC_NODES,
198
208
  constants_StarknetChainId as StarknetChainId,
199
209
  constants_TEXT_TO_FELT_MAX_LEN as TEXT_TO_FELT_MAX_LEN,
200
210
  constants_TransactionHashPrefix as TransactionHashPrefix,
@@ -710,6 +720,7 @@ type RpcProviderOptions = {
710
720
  blockIdentifier?: BlockIdentifier;
711
721
  chainId?: StarknetChainId;
712
722
  default?: boolean;
723
+ rpcVersion?: 'v0_5' | 'v0_6';
713
724
  };
714
725
  type SequencerHttpMethod = 'POST' | 'GET';
715
726
  type SequencerProviderOptions = {
@@ -3583,7 +3594,7 @@ declare class SequencerProvider implements ProviderInterface {
3583
3594
  private chainId;
3584
3595
  private responseParser;
3585
3596
  constructor(optionsOrProvider?: SequencerProviderOptions);
3586
- protected static getNetworkFromName(name: NetworkName | StarknetChainId): BaseUrl;
3597
+ protected static getNetworkFromName(name: NetworkName | StarknetChainId): BaseUrl.SN_MAIN | BaseUrl.SN_GOERLI;
3587
3598
  protected static getChainIdFromBaseUrl(baseUrl: string): StarknetChainId;
3588
3599
  private getFetchUrl;
3589
3600
  private getFetchMethod;
@@ -3659,7 +3670,13 @@ declare class SequencerProvider implements ProviderInterface {
3659
3670
  buildTransaction(invocation: AccountInvocationItem, versionType?: 'fee' | 'transaction'): AccountTransactionItem;
3660
3671
  }
3661
3672
 
3662
- declare const getDefaultNodeUrl: (networkName?: NetworkName, mute?: boolean) => string;
3673
+ /**
3674
+ * Return randomly select available public node
3675
+ * @param networkName NetworkName
3676
+ * @param mute mute public node warning
3677
+ * @returns default node url
3678
+ */
3679
+ declare const getDefaultNodeUrl: (networkName?: NetworkName, mute?: boolean, version?: 'v0_5' | 'v0_6') => string;
3663
3680
  declare class RpcProvider implements ProviderInterface {
3664
3681
  nodeUrl: string;
3665
3682
  headers: object;
@@ -362,7 +362,7 @@ var starknet = (() => {
362
362
  statusText: xhr.statusText,
363
363
  headers: parseHeaders(xhr.getAllResponseHeaders() || "")
364
364
  };
365
- if (request.url.startsWith("file://") && (xhr.status < 200 || xhr.status > 599)) {
365
+ if (request.url.indexOf("file://") === 0 && (xhr.status < 200 || xhr.status > 599)) {
366
366
  options.status = 200;
367
367
  } else {
368
368
  options.status = xhr.status;
@@ -536,6 +536,7 @@ var starknet = (() => {
536
536
  };
537
537
  Response.error = function() {
538
538
  var response = new Response(null, { status: 200, statusText: "" });
539
+ response.ok = false;
539
540
  response.status = 0;
540
541
  response.type = "error";
541
542
  return response;
@@ -720,6 +721,7 @@ var starknet = (() => {
720
721
  // src/constants.ts
721
722
  var constants_exports = {};
722
723
  __export(constants_exports, {
724
+ ADDR_BOUND: () => ADDR_BOUND,
723
725
  API_VERSION: () => API_VERSION,
724
726
  BN_FEE_TRANSACTION_VERSION_1: () => BN_FEE_TRANSACTION_VERSION_1,
725
727
  BN_FEE_TRANSACTION_VERSION_2: () => BN_FEE_TRANSACTION_VERSION_2,
@@ -730,10 +732,10 @@ var starknet = (() => {
730
732
  HEX_STR_TRANSACTION_VERSION_2: () => HEX_STR_TRANSACTION_VERSION_2,
731
733
  IS_BROWSER: () => IS_BROWSER,
732
734
  MASK_250: () => MASK_250,
733
- MASK_251: () => MASK_251,
735
+ MAX_STORAGE_ITEM_SIZE: () => MAX_STORAGE_ITEM_SIZE,
734
736
  NetworkName: () => NetworkName,
735
- RPC_GOERLI_NODES: () => RPC_GOERLI_NODES,
736
- RPC_MAINNET_NODES: () => RPC_MAINNET_NODES,
737
+ RPC_DEFAULT_VERSION: () => RPC_DEFAULT_VERSION,
738
+ RPC_NODES: () => RPC_NODES,
737
739
  StarknetChainId: () => StarknetChainId,
738
740
  TEXT_TO_FELT_MAX_LEN: () => TEXT_TO_FELT_MAX_LEN,
739
741
  TransactionHashPrefix: () => TransactionHashPrefix,
@@ -765,10 +767,14 @@ var starknet = (() => {
765
767
  if (!Number.isSafeInteger(n))
766
768
  throw new Error(`Wrong integer: ${n}`);
767
769
  }
770
+ function isBytes(a) {
771
+ return a instanceof Uint8Array || a != null && typeof a === "object" && a.constructor.name === "Uint8Array";
772
+ }
768
773
  function chain(...args) {
774
+ const id = (a) => a;
769
775
  const wrap = (a, b) => (c) => a(b(c));
770
- const encode = Array.from(args).reverse().reduce((acc, i) => acc ? wrap(acc, i.encode) : i.encode, void 0);
771
- const decode2 = args.reduce((acc, i) => acc ? wrap(acc, i.decode) : i.decode, void 0);
776
+ const encode = args.map((x) => x.encode).reduceRight(wrap, id);
777
+ const decode2 = args.map((x) => x.decode).reduce(wrap, id);
772
778
  return { encode, decode: decode2 };
773
779
  }
774
780
  function alphabet(alphabet2) {
@@ -904,13 +910,13 @@ var starknet = (() => {
904
910
  throw new Error("radix2: carry overflow");
905
911
  return {
906
912
  encode: (bytes2) => {
907
- if (!(bytes2 instanceof Uint8Array))
913
+ if (!isBytes(bytes2))
908
914
  throw new Error("radix2.encode input should be Uint8Array");
909
915
  return convertRadix2(Array.from(bytes2), 8, bits, !revPadding);
910
916
  },
911
917
  decode: (digits) => {
912
918
  if (!Array.isArray(digits) || digits.length && typeof digits[0] !== "number")
913
- throw new Error("radix2.decode input should be array of strings");
919
+ throw new Error("radix2.decode input should be array of numbers");
914
920
  return Uint8Array.from(convertRadix2(digits, bits, 8, revPadding));
915
921
  }
916
922
  };
@@ -996,21 +1002,25 @@ var starknet = (() => {
996
1002
  var BN_FEE_TRANSACTION_VERSION_2 = 2n ** 128n + BN_TRANSACTION_VERSION_2;
997
1003
  var ZERO = 0n;
998
1004
  var MASK_250 = 2n ** 250n - 1n;
999
- var MASK_251 = 2n ** 251n;
1000
1005
  var API_VERSION = ZERO;
1006
+ var MAX_STORAGE_ITEM_SIZE = 256n;
1007
+ var ADDR_BOUND = 2n ** 251n - MAX_STORAGE_ITEM_SIZE;
1001
1008
  var BaseUrl = /* @__PURE__ */ ((BaseUrl2) => {
1002
1009
  BaseUrl2["SN_MAIN"] = "https://alpha-mainnet.starknet.io";
1003
1010
  BaseUrl2["SN_GOERLI"] = "https://alpha4.starknet.io";
1011
+ BaseUrl2["SN_SEPOLIA"] = "https://alpha-sepolia.starknet.io";
1004
1012
  return BaseUrl2;
1005
1013
  })(BaseUrl || {});
1006
1014
  var NetworkName = /* @__PURE__ */ ((NetworkName2) => {
1007
1015
  NetworkName2["SN_MAIN"] = "SN_MAIN";
1008
1016
  NetworkName2["SN_GOERLI"] = "SN_GOERLI";
1017
+ NetworkName2["SN_SEPOLIA"] = "SN_SEPOLIA";
1009
1018
  return NetworkName2;
1010
1019
  })(NetworkName || {});
1011
1020
  var StarknetChainId = /* @__PURE__ */ ((StarknetChainId4) => {
1012
1021
  StarknetChainId4["SN_MAIN"] = "0x534e5f4d41494e";
1013
1022
  StarknetChainId4["SN_GOERLI"] = "0x534e5f474f45524c49";
1023
+ StarknetChainId4["SN_SEPOLIA"] = "0x534e5f5345504f4c4941";
1014
1024
  return StarknetChainId4;
1015
1025
  })(StarknetChainId || {});
1016
1026
  var TransactionHashPrefix = /* @__PURE__ */ ((TransactionHashPrefix2) => {
@@ -1025,14 +1035,21 @@ var starknet = (() => {
1025
1035
  ADDRESS: "0x041a78e741e5af2fec34b695679bc6891742439f7afb8484ecd7766661ad02bf",
1026
1036
  ENTRYPOINT: "deployContract"
1027
1037
  };
1028
- var RPC_GOERLI_NODES = [
1029
- "https://starknet-testnet.public.blastapi.io/rpc/v0.5",
1030
- "https://limited-rpc.nethermind.io/goerli-juno/v0_5"
1031
- ];
1032
- var RPC_MAINNET_NODES = [
1033
- "https://starknet-mainnet.public.blastapi.io/rpc/v0.5",
1034
- "https://limited-rpc.nethermind.io/mainnet-juno/v0_5"
1035
- ];
1038
+ var RPC_DEFAULT_VERSION = "v0_5";
1039
+ var RPC_NODES = {
1040
+ SN_GOERLI: [
1041
+ `https://starknet-testnet.public.blastapi.io/rpc/`,
1042
+ `https://free-rpc.nethermind.io/goerli-juno/`
1043
+ ],
1044
+ SN_MAIN: [
1045
+ `https://starknet-mainnet.public.blastapi.io/rpc/`,
1046
+ `https://free-rpc.nethermind.io/mainnet-juno/`
1047
+ ],
1048
+ SN_SEPOLIA: [
1049
+ `https://starknet-sepolia.public.blastapi.io/rpc/`,
1050
+ `https://free-rpc.nethermind.io/sepolia-juno/`
1051
+ ]
1052
+ };
1036
1053
 
1037
1054
  // src/types/index.ts
1038
1055
  var types_exports = {};
@@ -1246,6 +1263,7 @@ var starknet = (() => {
1246
1263
  equalBytes: () => equalBytes,
1247
1264
  hexToBytes: () => hexToBytes,
1248
1265
  hexToNumber: () => hexToNumber,
1266
+ isBytes: () => isBytes2,
1249
1267
  numberToBytesBE: () => numberToBytesBE,
1250
1268
  numberToBytesLE: () => numberToBytesLE,
1251
1269
  numberToHexUnpadded: () => numberToHexUnpadded,
@@ -1256,10 +1274,12 @@ var starknet = (() => {
1256
1274
  var _0n = BigInt(0);
1257
1275
  var _1n = BigInt(1);
1258
1276
  var _2n = BigInt(2);
1259
- var u8a = (a) => a instanceof Uint8Array;
1277
+ function isBytes2(a) {
1278
+ return a instanceof Uint8Array || a != null && typeof a === "object" && a.constructor.name === "Uint8Array";
1279
+ }
1260
1280
  var hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0"));
1261
1281
  function bytesToHex(bytes2) {
1262
- if (!u8a(bytes2))
1282
+ if (!isBytes2(bytes2))
1263
1283
  throw new Error("Uint8Array expected");
1264
1284
  let hex2 = "";
1265
1285
  for (let i = 0; i < bytes2.length; i++) {
@@ -1276,20 +1296,32 @@ var starknet = (() => {
1276
1296
  throw new Error("hex string expected, got " + typeof hex2);
1277
1297
  return BigInt(hex2 === "" ? "0" : `0x${hex2}`);
1278
1298
  }
1299
+ var asciis = { _0: 48, _9: 57, _A: 65, _F: 70, _a: 97, _f: 102 };
1300
+ function asciiToBase16(char) {
1301
+ if (char >= asciis._0 && char <= asciis._9)
1302
+ return char - asciis._0;
1303
+ if (char >= asciis._A && char <= asciis._F)
1304
+ return char - (asciis._A - 10);
1305
+ if (char >= asciis._a && char <= asciis._f)
1306
+ return char - (asciis._a - 10);
1307
+ return;
1308
+ }
1279
1309
  function hexToBytes(hex2) {
1280
1310
  if (typeof hex2 !== "string")
1281
1311
  throw new Error("hex string expected, got " + typeof hex2);
1282
- const len = hex2.length;
1283
- if (len % 2)
1284
- throw new Error("padded hex string expected, got unpadded hex of length " + len);
1285
- const array = new Uint8Array(len / 2);
1286
- for (let i = 0; i < array.length; i++) {
1287
- const j = i * 2;
1288
- const hexByte = hex2.slice(j, j + 2);
1289
- const byte = Number.parseInt(hexByte, 16);
1290
- if (Number.isNaN(byte) || byte < 0)
1291
- throw new Error("Invalid byte sequence");
1292
- array[i] = byte;
1312
+ const hl = hex2.length;
1313
+ const al = hl / 2;
1314
+ if (hl % 2)
1315
+ throw new Error("padded hex string expected, got unpadded hex of length " + hl);
1316
+ const array = new Uint8Array(al);
1317
+ for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {
1318
+ const n1 = asciiToBase16(hex2.charCodeAt(hi));
1319
+ const n2 = asciiToBase16(hex2.charCodeAt(hi + 1));
1320
+ if (n1 === void 0 || n2 === void 0) {
1321
+ const char = hex2[hi] + hex2[hi + 1];
1322
+ throw new Error('hex string expected, got non-hex character "' + char + '" at index ' + hi);
1323
+ }
1324
+ array[ai] = n1 * 16 + n2;
1293
1325
  }
1294
1326
  return array;
1295
1327
  }
@@ -1297,7 +1329,7 @@ var starknet = (() => {
1297
1329
  return hexToNumber(bytesToHex(bytes2));
1298
1330
  }
1299
1331
  function bytesToNumberLE(bytes2) {
1300
- if (!u8a(bytes2))
1332
+ if (!isBytes2(bytes2))
1301
1333
  throw new Error("Uint8Array expected");
1302
1334
  return hexToNumber(bytesToHex(Uint8Array.from(bytes2).reverse()));
1303
1335
  }
@@ -1318,7 +1350,7 @@ var starknet = (() => {
1318
1350
  } catch (e) {
1319
1351
  throw new Error(`${title} must be valid hex string, got "${hex2}". Cause: ${e}`);
1320
1352
  }
1321
- } else if (u8a(hex2)) {
1353
+ } else if (isBytes2(hex2)) {
1322
1354
  res = Uint8Array.from(hex2);
1323
1355
  } else {
1324
1356
  throw new Error(`${title} must be hex string or Uint8Array`);
@@ -1329,23 +1361,29 @@ var starknet = (() => {
1329
1361
  return res;
1330
1362
  }
1331
1363
  function concatBytes(...arrays) {
1332
- const r = new Uint8Array(arrays.reduce((sum, a) => sum + a.length, 0));
1333
- let pad = 0;
1334
- arrays.forEach((a) => {
1335
- if (!u8a(a))
1364
+ let sum = 0;
1365
+ for (let i = 0; i < arrays.length; i++) {
1366
+ const a = arrays[i];
1367
+ if (!isBytes2(a))
1336
1368
  throw new Error("Uint8Array expected");
1337
- r.set(a, pad);
1369
+ sum += a.length;
1370
+ }
1371
+ let res = new Uint8Array(sum);
1372
+ let pad = 0;
1373
+ for (let i = 0; i < arrays.length; i++) {
1374
+ const a = arrays[i];
1375
+ res.set(a, pad);
1338
1376
  pad += a.length;
1339
- });
1340
- return r;
1377
+ }
1378
+ return res;
1341
1379
  }
1342
- function equalBytes(b1, b2) {
1343
- if (b1.length !== b2.length)
1380
+ function equalBytes(a, b) {
1381
+ if (a.length !== b.length)
1344
1382
  return false;
1345
- for (let i = 0; i < b1.length; i++)
1346
- if (b1[i] !== b2[i])
1347
- return false;
1348
- return true;
1383
+ let diff = 0;
1384
+ for (let i = 0; i < a.length; i++)
1385
+ diff |= a[i] ^ b[i];
1386
+ return diff === 0;
1349
1387
  }
1350
1388
  function utf8ToBytes(str) {
1351
1389
  if (typeof str !== "string")
@@ -1420,7 +1458,7 @@ var starknet = (() => {
1420
1458
  function: (val) => typeof val === "function",
1421
1459
  boolean: (val) => typeof val === "boolean",
1422
1460
  string: (val) => typeof val === "string",
1423
- stringOrUint8Array: (val) => typeof val === "string" || val instanceof Uint8Array,
1461
+ stringOrUint8Array: (val) => typeof val === "string" || isBytes2(val),
1424
1462
  isSafeInteger: (val) => Number.isSafeInteger(val),
1425
1463
  array: (val) => Array.isArray(val),
1426
1464
  field: (val, object) => object.Fp.isValid(val),
@@ -1561,8 +1599,11 @@ var starknet = (() => {
1561
1599
  if (!Number.isSafeInteger(n) || n < 0)
1562
1600
  throw new Error(`Wrong positive integer: ${n}`);
1563
1601
  }
1602
+ function isBytes3(a) {
1603
+ return a instanceof Uint8Array || a != null && typeof a === "object" && a.constructor.name === "Uint8Array";
1604
+ }
1564
1605
  function bytes(b, ...lengths) {
1565
- if (!(b instanceof Uint8Array))
1606
+ if (!isBytes3(b))
1566
1607
  throw new Error("Expected Uint8Array");
1567
1608
  if (lengths.length > 0 && !lengths.includes(b.length))
1568
1609
  throw new Error(`Expected Uint8Array of length ${lengths}, not of length=${b.length}`);
@@ -1613,8 +1654,10 @@ var starknet = (() => {
1613
1654
  var crypto = typeof globalThis === "object" && "crypto" in globalThis ? globalThis.crypto : void 0;
1614
1655
 
1615
1656
  // node_modules/@noble/hashes/esm/utils.js
1616
- var u8a2 = (a) => a instanceof Uint8Array;
1617
1657
  var u32 = (arr) => new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
1658
+ function isBytes4(a) {
1659
+ return a instanceof Uint8Array || a != null && typeof a === "object" && a.constructor.name === "Uint8Array";
1660
+ }
1618
1661
  var createView = (arr) => new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
1619
1662
  var rotr = (word, shift) => word << 32 - shift | word >>> shift;
1620
1663
  var isLE = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
@@ -1628,20 +1671,25 @@ var starknet = (() => {
1628
1671
  function toBytes(data) {
1629
1672
  if (typeof data === "string")
1630
1673
  data = utf8ToBytes2(data);
1631
- if (!u8a2(data))
1674
+ if (!isBytes4(data))
1632
1675
  throw new Error(`expected Uint8Array, got ${typeof data}`);
1633
1676
  return data;
1634
1677
  }
1635
1678
  function concatBytes2(...arrays) {
1636
- const r = new Uint8Array(arrays.reduce((sum, a) => sum + a.length, 0));
1637
- let pad = 0;
1638
- arrays.forEach((a) => {
1639
- if (!u8a2(a))
1679
+ let sum = 0;
1680
+ for (let i = 0; i < arrays.length; i++) {
1681
+ const a = arrays[i];
1682
+ if (!isBytes4(a))
1640
1683
  throw new Error("Uint8Array expected");
1641
- r.set(a, pad);
1684
+ sum += a.length;
1685
+ }
1686
+ const res = new Uint8Array(sum);
1687
+ for (let i = 0, pad = 0; i < arrays.length; i++) {
1688
+ const a = arrays[i];
1689
+ res.set(a, pad);
1642
1690
  pad += a.length;
1643
- });
1644
- return r;
1691
+ }
1692
+ return res;
1645
1693
  }
1646
1694
  var Hash = class {
1647
1695
  // Safe version that clones internal state
@@ -2647,7 +2695,7 @@ var starknet = (() => {
2647
2695
  toSig(hex2) {
2648
2696
  const { Err: E } = DER;
2649
2697
  const data = typeof hex2 === "string" ? h2b(hex2) : hex2;
2650
- if (!(data instanceof Uint8Array))
2698
+ if (!isBytes2(data))
2651
2699
  throw new Error("ui8a expected");
2652
2700
  let l = data.length;
2653
2701
  if (l < 2 || data[0] != 48)
@@ -2711,7 +2759,7 @@ var starknet = (() => {
2711
2759
  function normPrivateKeyToScalar(key) {
2712
2760
  const { allowedPrivateKeyLengths: lengths, nByteLength, wrapPrivateKey, n } = CURVE2;
2713
2761
  if (lengths && typeof key !== "bigint") {
2714
- if (key instanceof Uint8Array)
2762
+ if (isBytes2(key))
2715
2763
  key = bytesToHex(key);
2716
2764
  if (typeof key !== "string" || !lengths.includes(key.length))
2717
2765
  throw new Error("Invalid key");
@@ -3246,7 +3294,7 @@ var starknet = (() => {
3246
3294
  return Point.fromPrivateKey(privateKey).toRawBytes(isCompressed);
3247
3295
  }
3248
3296
  function isProbPub(item) {
3249
- const arr = item instanceof Uint8Array;
3297
+ const arr = isBytes2(item);
3250
3298
  const str = typeof item === "string";
3251
3299
  const len = (arr || str) && item.length;
3252
3300
  if (arr)
@@ -3341,7 +3389,7 @@ var starknet = (() => {
3341
3389
  let _sig = void 0;
3342
3390
  let P;
3343
3391
  try {
3344
- if (typeof sg === "string" || sg instanceof Uint8Array) {
3392
+ if (typeof sg === "string" || isBytes2(sg)) {
3345
3393
  try {
3346
3394
  _sig = Signature3.fromDER(sg);
3347
3395
  } catch (derError) {
@@ -5156,10 +5204,10 @@ var starknet = (() => {
5156
5204
  const oe = Array.isArray(o) ? [o.length.toString(), ...o] : o;
5157
5205
  return Object.entries(oe).flatMap(([k, v]) => {
5158
5206
  let value = v;
5159
- if (isLongText(value))
5160
- value = splitLongString(value);
5161
5207
  if (k === "entrypoint")
5162
5208
  value = getSelectorFromName(value);
5209
+ else if (isLongText(value))
5210
+ value = splitLongString(value);
5163
5211
  const kk = Array.isArray(oe) && k === "0" ? "$$len" : k;
5164
5212
  if (isBigInt(value))
5165
5213
  return [[`${prefix}${kk}`, felt(value)]];
@@ -6084,13 +6132,14 @@ var starknet = (() => {
6084
6132
  const compiledCalldata = CallData.compile(constructorCalldata);
6085
6133
  const constructorCalldataHash = computeHashOnElements2(compiledCalldata);
6086
6134
  const CONTRACT_ADDRESS_PREFIX = felt("0x535441524b4e45545f434f4e54524143545f41444452455353");
6087
- return computeHashOnElements2([
6135
+ const hash2 = computeHashOnElements2([
6088
6136
  CONTRACT_ADDRESS_PREFIX,
6089
6137
  deployerAddress,
6090
6138
  salt,
6091
6139
  classHash,
6092
6140
  constructorCalldataHash
6093
6141
  ]);
6142
+ return toHex(BigInt(hash2) % ADDR_BOUND);
6094
6143
  }
6095
6144
  function nullSkipReplacer(key, value) {
6096
6145
  if (key === "attributes" || key === "accessible_scopes") {
@@ -10797,12 +10846,12 @@ var starknet = (() => {
10797
10846
  };
10798
10847
 
10799
10848
  // src/provider/rpc.ts
10800
- var getDefaultNodeUrl = (networkName, mute = false) => {
10849
+ var getDefaultNodeUrl = (networkName, mute = false, version = RPC_DEFAULT_VERSION) => {
10801
10850
  if (!mute)
10802
10851
  console.warn("Using default public node url, please provide nodeUrl in provider options!");
10803
- const nodes = networkName === "SN_MAIN" /* SN_MAIN */ ? RPC_MAINNET_NODES : RPC_GOERLI_NODES;
10852
+ const nodes = RPC_NODES[networkName ?? "SN_GOERLI" /* SN_GOERLI */];
10804
10853
  const randIdx = Math.floor(Math.random() * nodes.length);
10805
- return nodes[randIdx];
10854
+ return `${nodes[randIdx]}${version}`;
10806
10855
  };
10807
10856
  var defaultOptions = {
10808
10857
  headers: { "Content-Type": "application/json" },
@@ -10840,13 +10889,17 @@ var starknet = (() => {
10840
10889
  * @deprecated renamed to simulateTransaction();
10841
10890
  */
10842
10891
  this.getSimulateTransaction = this.simulateTransaction;
10843
- const { nodeUrl, retries, headers, blockIdentifier, chainId } = optionsOrProvider || {};
10892
+ const { nodeUrl, retries, headers, blockIdentifier, chainId, rpcVersion } = optionsOrProvider || {};
10844
10893
  if (Object.values(NetworkName).includes(nodeUrl)) {
10845
- this.nodeUrl = getDefaultNodeUrl(nodeUrl, optionsOrProvider?.default);
10894
+ this.nodeUrl = getDefaultNodeUrl(
10895
+ nodeUrl,
10896
+ optionsOrProvider?.default,
10897
+ rpcVersion
10898
+ );
10846
10899
  } else if (nodeUrl) {
10847
10900
  this.nodeUrl = nodeUrl;
10848
10901
  } else {
10849
- this.nodeUrl = getDefaultNodeUrl(void 0, optionsOrProvider?.default);
10902
+ this.nodeUrl = getDefaultNodeUrl(void 0, optionsOrProvider?.default, rpcVersion);
10850
10903
  }
10851
10904
  this.retries = retries || defaultOptions.retries;
10852
10905
  this.headers = { ...defaultOptions.headers, ...headers };
@@ -11022,8 +11075,10 @@ var starknet = (() => {
11022
11075
  let isErrorState = false;
11023
11076
  const retryInterval = options?.retryInterval ?? 5e3;
11024
11077
  const errorStates = options?.errorStates ?? [
11025
- rpc_exports.ETransactionStatus.REJECTED,
11026
- rpc_exports.ETransactionExecutionStatus.REVERTED
11078
+ rpc_exports.ETransactionStatus.REJECTED
11079
+ // TODO: commented out to preserve the long-standing behavior of "reverted" not being treated as an error by default
11080
+ // should decide which behavior to keep in the future
11081
+ // RPC.ETransactionExecutionStatus.REVERTED,
11027
11082
  ];
11028
11083
  const successStates = options?.successStates ?? [
11029
11084
  rpc_exports.ETransactionExecutionStatus.SUCCEEDED,
@@ -11041,14 +11096,14 @@ var starknet = (() => {
11041
11096
  const error = new Error("waiting for transaction status");
11042
11097
  throw error;
11043
11098
  }
11044
- if (successStates.includes(executionStatus) || successStates.includes(finalityStatus)) {
11045
- onchain = true;
11046
- } else if (errorStates.includes(executionStatus) || errorStates.includes(finalityStatus)) {
11099
+ if (errorStates.includes(executionStatus) || errorStates.includes(finalityStatus)) {
11047
11100
  const message = `${executionStatus}: ${finalityStatus}`;
11048
11101
  const error = new Error(message);
11049
11102
  error.response = txStatus;
11050
11103
  isErrorState = true;
11051
11104
  throw error;
11105
+ } else if (successStates.includes(executionStatus) || successStates.includes(finalityStatus)) {
11106
+ onchain = true;
11052
11107
  }
11053
11108
  } catch (error) {
11054
11109
  if (error instanceof Error && isErrorState) {
@@ -13402,7 +13457,7 @@ ${res.tx_failure_reason.error_message}`;
13402
13457
  return addHexPrefix(removeHexPrefix(toHex(address)).padStart(64, "0"));
13403
13458
  }
13404
13459
  function validateAndParseAddress(address) {
13405
- assertInRange(address, ZERO, MASK_251, "Starknet Address");
13460
+ assertInRange(address, ZERO, ADDR_BOUND - 1n, "Starknet Address");
13406
13461
  const result = addAddressPadding(address);
13407
13462
  if (!result.match(/^(0x)?[0-9a-fA-F]{64}$/)) {
13408
13463
  throw new Error("Invalid Address Format");