starknet 9.1.1 → 9.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
@@ -72,8 +72,8 @@ __export(index_exports, {
72
72
  ETH_ADDRESS: () => ETH_ADDRESS,
73
73
  ETransactionExecutionStatus: () => ETransactionExecutionStatus,
74
74
  ETransactionStatus: () => ETransactionStatus,
75
- ETransactionVersion: () => ETransactionVersion2,
76
- ETransactionVersion2: () => ETransactionVersion22,
75
+ ETransactionVersion: () => ETransactionVersion,
76
+ ETransactionVersion2: () => ETransactionVersion2,
77
77
  ETransactionVersion3: () => ETransactionVersion3,
78
78
  EntryPointType: () => EntryPointType,
79
79
  EthSigner: () => EthSigner,
@@ -261,6 +261,26 @@ __reExport(rpc_exports, require("@starknet-io/starknet-types-09"));
261
261
  // src/types/api/index.ts
262
262
  __reExport(api_exports, rpc_exports);
263
263
 
264
+ // src/provider/types/spec.type.ts
265
+ var { ETransactionVersion } = RPCSPEC09;
266
+ var { ETransactionVersion2 } = RPCSPEC09;
267
+ var { ETransactionVersion3 } = RPCSPEC09;
268
+ var { EDataAvailabilityMode } = RPCSPEC010;
269
+ var { EDAMode } = RPCSPEC010;
270
+ function isRPC08Plus_ResourceBounds(entry) {
271
+ return "l1_data_gas" in entry;
272
+ }
273
+ function isRPC08Plus_ResourceBoundsBN(entry) {
274
+ return "l1_data_gas" in entry;
275
+ }
276
+ var { ETransactionStatus } = RPCSPEC010;
277
+ var { ETransactionExecutionStatus } = RPCSPEC010;
278
+ var { ETransactionType: TransactionType } = RPCSPEC09;
279
+ var { EBlockStatus: BlockStatus } = RPCSPEC09;
280
+ var { ETransactionFinalityStatus: TransactionFinalityStatus } = RPCSPEC09;
281
+ var { ETransactionExecutionStatus: TransactionExecutionStatus } = RPCSPEC09;
282
+ var { EBlockTag: BlockTag } = RPCSPEC09;
283
+
264
284
  // src/utils/encode.ts
265
285
  var encode_exports = {};
266
286
  __export(encode_exports, {
@@ -491,6 +511,22 @@ var DEFAULT_GLOBAL_CONFIG = {
491
511
  }
492
512
  },
493
513
  defaultTipType: "recommendedTip",
514
+ channelDefaults: {
515
+ options: {
516
+ headers: { "Content-Type": "application/json" },
517
+ blockIdentifier: BlockTag.LATEST,
518
+ retries: 200
519
+ },
520
+ methods: {
521
+ simulateTransaction: {
522
+ skipValidate: true,
523
+ skipFeeCharge: true
524
+ },
525
+ getEstimateFee: {
526
+ skipValidate: true
527
+ }
528
+ }
529
+ },
494
530
  fetch: void 0,
495
531
  websocket: void 0,
496
532
  buffer: void 0,
@@ -535,11 +571,51 @@ var Configuration = class _Configuration {
535
571
  }
536
572
  return _Configuration.instance;
537
573
  }
574
+ /**
575
+ * Get a nested value from an object using a dot-notation path
576
+ * @param obj - The object to traverse
577
+ * @param path - The dot-notation path (e.g., 'a.b.c')
578
+ * @returns The value at the path, or undefined if not found
579
+ */
580
+ getNestedValue(obj, path) {
581
+ const keys = path.split(".");
582
+ return keys.reduce((current, key) => {
583
+ if (current === null || current === void 0) {
584
+ return void 0;
585
+ }
586
+ return current[key];
587
+ }, obj);
588
+ }
589
+ /**
590
+ * Set a nested value in an object using a dot-notation path
591
+ * @param obj - The object to modify
592
+ * @param path - The dot-notation path (e.g., 'a.b.c')
593
+ * @param value - The value to set
594
+ */
595
+ setNestedValue(obj, path, value) {
596
+ const keys = path.split(".");
597
+ const lastKey = keys.pop();
598
+ const target = keys.reduce((current, key) => {
599
+ if (!(key in current) || typeof current[key] !== "object" || current[key] === null) {
600
+ current[key] = {};
601
+ }
602
+ return current[key];
603
+ }, obj);
604
+ target[lastKey] = value;
605
+ }
538
606
  get(key, defaultValue) {
607
+ if (key.includes(".")) {
608
+ const value = this.getNestedValue(this.config, key);
609
+ return value ?? defaultValue;
610
+ }
539
611
  return this.config[key] ?? defaultValue;
540
612
  }
541
613
  set(key, value) {
542
- this.config[key] = value;
614
+ if (key.includes(".")) {
615
+ this.setNestedValue(this.config, key, value);
616
+ } else {
617
+ this.config[key] = value;
618
+ }
543
619
  }
544
620
  update(configData) {
545
621
  this.config = {
@@ -708,26 +784,6 @@ var EntryPointType = {
708
784
  CONSTRUCTOR: "CONSTRUCTOR"
709
785
  };
710
786
 
711
- // src/provider/types/spec.type.ts
712
- var { ETransactionVersion: ETransactionVersion2 } = RPCSPEC09;
713
- var { ETransactionVersion2: ETransactionVersion22 } = RPCSPEC09;
714
- var { ETransactionVersion3 } = RPCSPEC09;
715
- var { EDataAvailabilityMode } = RPCSPEC010;
716
- var { EDAMode } = RPCSPEC010;
717
- function isRPC08Plus_ResourceBounds(entry) {
718
- return "l1_data_gas" in entry;
719
- }
720
- function isRPC08Plus_ResourceBoundsBN(entry) {
721
- return "l1_data_gas" in entry;
722
- }
723
- var { ETransactionStatus } = RPCSPEC010;
724
- var { ETransactionExecutionStatus } = RPCSPEC010;
725
- var { ETransactionType: TransactionType } = RPCSPEC09;
726
- var { EBlockStatus: BlockStatus } = RPCSPEC09;
727
- var { ETransactionFinalityStatus: TransactionFinalityStatus } = RPCSPEC09;
728
- var { ETransactionExecutionStatus: TransactionExecutionStatus } = RPCSPEC09;
729
- var { EBlockTag: BlockTag } = RPCSPEC09;
730
-
731
787
  // src/types/calldata.ts
732
788
  var ValidateType = {
733
789
  DEPLOY: "DEPLOY",
@@ -5358,8 +5414,8 @@ function computeCompiledClassHashBlake(casm) {
5358
5414
 
5359
5415
  // src/utils/resolve.ts
5360
5416
  function isV3Tx(details) {
5361
- const version = details.version ? toHex(details.version) : ETransactionVersion2.V3;
5362
- return version === ETransactionVersion2.V3 || version === ETransactionVersion2.F3;
5417
+ const version = details.version ? toHex(details.version) : ETransactionVersion.V3;
5418
+ return version === ETransactionVersion.V3 || version === ETransactionVersion.F3;
5363
5419
  }
5364
5420
  function isVersion(expected, provided) {
5365
5421
  const expectedParts = expected.split(".");
@@ -5564,10 +5620,10 @@ function toTransactionVersion(defaultVersion, providedVersion) {
5564
5620
  function toFeeVersion(providedVersion) {
5565
5621
  if (!providedVersion) return void 0;
5566
5622
  const version = toHex(providedVersion);
5567
- if (version === ETransactionVersion2.V0) return ETransactionVersion2.F0;
5568
- if (version === ETransactionVersion2.V1) return ETransactionVersion2.F1;
5569
- if (version === ETransactionVersion2.V2) return ETransactionVersion2.F2;
5570
- if (version === ETransactionVersion2.V3) return ETransactionVersion2.F3;
5623
+ if (version === ETransactionVersion.V0) return ETransactionVersion.F0;
5624
+ if (version === ETransactionVersion.V1) return ETransactionVersion.F1;
5625
+ if (version === ETransactionVersion.V2) return ETransactionVersion.F2;
5626
+ if (version === ETransactionVersion.V3) return ETransactionVersion.F3;
5571
5627
  throw Error(`toFeeVersion: ${version} is not supported`);
5572
5628
  }
5573
5629
  function v3Details(details) {
@@ -5891,16 +5947,11 @@ var getExecuteCalldata = (calls, cairoVersion = "0") => {
5891
5947
  };
5892
5948
  function getVersionsByType(versionType) {
5893
5949
  return versionType === "fee" ? {
5894
- v3: ETransactionVersion2.F3
5895
- } : { v3: ETransactionVersion2.V3 };
5950
+ v3: ETransactionVersion.F3
5951
+ } : { v3: ETransactionVersion.V3 };
5896
5952
  }
5897
5953
 
5898
5954
  // src/channel/rpc_0_9_0.ts
5899
- var defaultOptions = {
5900
- headers: { "Content-Type": "application/json" },
5901
- blockIdentifier: BlockTag.LATEST,
5902
- retries: 200
5903
- };
5904
5955
  var RpcChannel = class {
5905
5956
  id = "RPC090";
5906
5957
  /**
@@ -5950,11 +6001,12 @@ var RpcChannel = class {
5950
6001
  this.channelSpecVersion
5951
6002
  );
5952
6003
  }
6004
+ const channelDefaults = config.get("channelDefaults");
5953
6005
  this.baseFetch = baseFetch || config.get("fetch") || fetch_default;
5954
- this.blockIdentifier = blockIdentifier ?? defaultOptions.blockIdentifier;
6006
+ this.blockIdentifier = blockIdentifier ?? channelDefaults.options.blockIdentifier;
5955
6007
  this.chainId = chainId;
5956
- this.headers = { ...defaultOptions.headers, ...headers };
5957
- this.retries = retries ?? defaultOptions.retries;
6008
+ this.headers = { ...channelDefaults.options.headers, ...headers };
6009
+ this.retries = retries ?? channelDefaults.options.retries;
5958
6010
  this.specVersion = specVersion;
5959
6011
  this.transactionRetryIntervalFallback = transactionRetryIntervalFallback;
5960
6012
  this.waitMode = waitMode ?? false;
@@ -6168,14 +6220,16 @@ var RpcChannel = class {
6168
6220
  * @param invocations AccountInvocations
6169
6221
  * @param simulateTransactionOptions blockIdentifier and flags to skip validation and fee charge<br/>
6170
6222
  * - blockIdentifier<br/>
6171
- * - skipValidate (default false)<br/>
6223
+ * - skipValidate (default true)<br/>
6172
6224
  * - skipFeeCharge (default true)<br/>
6173
6225
  */
6174
6226
  simulateTransaction(invocations, simulateTransactionOptions = {}) {
6227
+ const channelDefaults = config.get("channelDefaults");
6228
+ const methodDefaults = channelDefaults.methods.simulateTransaction || {};
6175
6229
  const {
6176
6230
  blockIdentifier = this.blockIdentifier,
6177
- skipValidate = true,
6178
- skipFeeCharge = true
6231
+ skipValidate = methodDefaults.skipValidate,
6232
+ skipFeeCharge = methodDefaults.skipFeeCharge
6179
6233
  } = simulateTransactionOptions;
6180
6234
  const block_id = new Block(blockIdentifier).identifier;
6181
6235
  const simulationFlags = [];
@@ -6335,7 +6389,10 @@ var RpcChannel = class {
6335
6389
  contract_address
6336
6390
  });
6337
6391
  }
6338
- async getEstimateFee(invocations, { blockIdentifier = this.blockIdentifier, skipValidate = true } = {}) {
6392
+ async getEstimateFee(invocations, options = {}) {
6393
+ const channelDefaults = config.get("channelDefaults");
6394
+ const methodDefaults = channelDefaults.methods.getEstimateFee || {};
6395
+ const { blockIdentifier = this.blockIdentifier, skipValidate = methodDefaults.skipValidate } = options;
6339
6396
  const block_id = new Block(blockIdentifier).identifier;
6340
6397
  const flags = {
6341
6398
  simulation_flags: skipValidate ? [RPCSPEC09.ESimulationFlag.SKIP_VALIDATE] : []
@@ -6493,11 +6550,6 @@ var rpc_0_10_0_exports = {};
6493
6550
  __export(rpc_0_10_0_exports, {
6494
6551
  RpcChannel: () => RpcChannel2
6495
6552
  });
6496
- var defaultOptions2 = {
6497
- headers: { "Content-Type": "application/json" },
6498
- blockIdentifier: BlockTag.LATEST,
6499
- retries: 200
6500
- };
6501
6553
  var RpcChannel2 = class {
6502
6554
  id = "RPC0.10.0";
6503
6555
  /**
@@ -6547,11 +6599,12 @@ var RpcChannel2 = class {
6547
6599
  this.channelSpecVersion
6548
6600
  );
6549
6601
  }
6602
+ const channelDefaults = config.get("channelDefaults");
6550
6603
  this.baseFetch = baseFetch || config.get("fetch") || fetch_default;
6551
- this.blockIdentifier = blockIdentifier ?? defaultOptions2.blockIdentifier;
6604
+ this.blockIdentifier = blockIdentifier ?? channelDefaults.options.blockIdentifier;
6552
6605
  this.chainId = chainId;
6553
- this.headers = { ...defaultOptions2.headers, ...headers };
6554
- this.retries = retries ?? defaultOptions2.retries;
6606
+ this.headers = { ...channelDefaults.options.headers, ...headers };
6607
+ this.retries = retries ?? channelDefaults.options.retries;
6555
6608
  this.specVersion = specVersion;
6556
6609
  this.transactionRetryIntervalFallback = transactionRetryIntervalFallback;
6557
6610
  this.waitMode = waitMode ?? false;
@@ -6765,14 +6818,16 @@ var RpcChannel2 = class {
6765
6818
  * @param invocations AccountInvocations
6766
6819
  * @param simulateTransactionOptions blockIdentifier and flags to skip validation and fee charge<br/>
6767
6820
  * - blockIdentifier<br/>
6768
- * - skipValidate (default false)<br/>
6821
+ * - skipValidate (default true)<br/>
6769
6822
  * - skipFeeCharge (default true)<br/>
6770
6823
  */
6771
6824
  simulateTransaction(invocations, simulateTransactionOptions = {}) {
6825
+ const channelDefaults = config.get("channelDefaults");
6826
+ const methodDefaults = channelDefaults.methods.simulateTransaction || {};
6772
6827
  const {
6773
6828
  blockIdentifier = this.blockIdentifier,
6774
- skipValidate = true,
6775
- skipFeeCharge = true
6829
+ skipValidate = methodDefaults.skipValidate,
6830
+ skipFeeCharge = methodDefaults.skipFeeCharge
6776
6831
  } = simulateTransactionOptions;
6777
6832
  const block_id = new Block(blockIdentifier).identifier;
6778
6833
  const simulationFlags = [];
@@ -6932,7 +6987,10 @@ var RpcChannel2 = class {
6932
6987
  contract_address
6933
6988
  });
6934
6989
  }
6935
- async getEstimateFee(invocations, { blockIdentifier = this.blockIdentifier, skipValidate = true } = {}) {
6990
+ async getEstimateFee(invocations, options = {}) {
6991
+ const channelDefaults = config.get("channelDefaults");
6992
+ const methodDefaults = channelDefaults.methods.getEstimateFee || {};
6993
+ const { blockIdentifier = this.blockIdentifier, skipValidate = methodDefaults.skipValidate } = options;
6936
6994
  const block_id = new Block(blockIdentifier).identifier;
6937
6995
  const flags = {
6938
6996
  simulation_flags: skipValidate ? [RPCSPEC010.ESimulationFlag.SKIP_VALIDATE] : []
@@ -10889,7 +10947,7 @@ var convertEXECUTION_PARAMETERS = (parameters) => ({
10889
10947
  feeMode: convertFEE_MODE(parameters.fee_mode),
10890
10948
  timeBounds: convertTIME_BOUNDS(parameters.time_bounds)
10891
10949
  });
10892
- var defaultOptions3 = {
10950
+ var defaultOptions = {
10893
10951
  headers: { "Content-Type": "application/json" }
10894
10952
  };
10895
10953
  var PaymasterRpc = class _PaymasterRpc {
@@ -10900,14 +10958,14 @@ var PaymasterRpc = class _PaymasterRpc {
10900
10958
  constructor(options) {
10901
10959
  if (options instanceof _PaymasterRpc) {
10902
10960
  this.nodeUrl = options.nodeUrl;
10903
- this.headers = { ...defaultOptions3.headers, ...options.headers };
10961
+ this.headers = { ...defaultOptions.headers, ...options.headers };
10904
10962
  this.baseFetch = options.baseFetch;
10905
10963
  this.requestId = options.requestId;
10906
10964
  return;
10907
10965
  }
10908
10966
  if (options && "nodeUrl" in options && "headers" in options && "baseFetch" in options) {
10909
10967
  this.nodeUrl = options.nodeUrl ?? getDefaultPaymasterNodeUrl(void 0);
10910
- this.headers = { ...defaultOptions3.headers, ...options.headers };
10968
+ this.headers = { ...defaultOptions.headers, ...options.headers };
10911
10969
  this.baseFetch = options.baseFetch ?? fetch_default;
10912
10970
  this.requestId = 0;
10913
10971
  return;
@@ -10921,7 +10979,7 @@ var PaymasterRpc = class _PaymasterRpc {
10921
10979
  this.nodeUrl = getDefaultPaymasterNodeUrl(void 0, options?.default);
10922
10980
  }
10923
10981
  this.baseFetch = baseFetch ?? fetch_default;
10924
- this.headers = { ...defaultOptions3.headers, ...headers };
10982
+ this.headers = { ...defaultOptions.headers, ...headers };
10925
10983
  this.requestId = 0;
10926
10984
  }
10927
10985
  fetch(method, params, id = 0) {