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.mjs CHANGED
@@ -84,6 +84,26 @@ import * as starknet_types_09_star from "@starknet-io/starknet-types-09";
84
84
  // src/types/api/index.ts
85
85
  __reExport(api_exports, rpc_exports);
86
86
 
87
+ // src/provider/types/spec.type.ts
88
+ var { ETransactionVersion } = RPCSPEC09;
89
+ var { ETransactionVersion2 } = RPCSPEC09;
90
+ var { ETransactionVersion3 } = RPCSPEC09;
91
+ var { EDataAvailabilityMode } = RPCSPEC010;
92
+ var { EDAMode } = RPCSPEC010;
93
+ function isRPC08Plus_ResourceBounds(entry) {
94
+ return "l1_data_gas" in entry;
95
+ }
96
+ function isRPC08Plus_ResourceBoundsBN(entry) {
97
+ return "l1_data_gas" in entry;
98
+ }
99
+ var { ETransactionStatus } = RPCSPEC010;
100
+ var { ETransactionExecutionStatus } = RPCSPEC010;
101
+ var { ETransactionType: TransactionType } = RPCSPEC09;
102
+ var { EBlockStatus: BlockStatus } = RPCSPEC09;
103
+ var { ETransactionFinalityStatus: TransactionFinalityStatus } = RPCSPEC09;
104
+ var { ETransactionExecutionStatus: TransactionExecutionStatus } = RPCSPEC09;
105
+ var { EBlockTag: BlockTag } = RPCSPEC09;
106
+
87
107
  // src/utils/encode.ts
88
108
  var encode_exports = {};
89
109
  __export(encode_exports, {
@@ -314,6 +334,22 @@ var DEFAULT_GLOBAL_CONFIG = {
314
334
  }
315
335
  },
316
336
  defaultTipType: "recommendedTip",
337
+ channelDefaults: {
338
+ options: {
339
+ headers: { "Content-Type": "application/json" },
340
+ blockIdentifier: BlockTag.LATEST,
341
+ retries: 200
342
+ },
343
+ methods: {
344
+ simulateTransaction: {
345
+ skipValidate: true,
346
+ skipFeeCharge: true
347
+ },
348
+ getEstimateFee: {
349
+ skipValidate: true
350
+ }
351
+ }
352
+ },
317
353
  fetch: void 0,
318
354
  websocket: void 0,
319
355
  buffer: void 0,
@@ -358,11 +394,51 @@ var Configuration = class _Configuration {
358
394
  }
359
395
  return _Configuration.instance;
360
396
  }
397
+ /**
398
+ * Get a nested value from an object using a dot-notation path
399
+ * @param obj - The object to traverse
400
+ * @param path - The dot-notation path (e.g., 'a.b.c')
401
+ * @returns The value at the path, or undefined if not found
402
+ */
403
+ getNestedValue(obj, path) {
404
+ const keys = path.split(".");
405
+ return keys.reduce((current, key) => {
406
+ if (current === null || current === void 0) {
407
+ return void 0;
408
+ }
409
+ return current[key];
410
+ }, obj);
411
+ }
412
+ /**
413
+ * Set a nested value in an object using a dot-notation path
414
+ * @param obj - The object to modify
415
+ * @param path - The dot-notation path (e.g., 'a.b.c')
416
+ * @param value - The value to set
417
+ */
418
+ setNestedValue(obj, path, value) {
419
+ const keys = path.split(".");
420
+ const lastKey = keys.pop();
421
+ const target = keys.reduce((current, key) => {
422
+ if (!(key in current) || typeof current[key] !== "object" || current[key] === null) {
423
+ current[key] = {};
424
+ }
425
+ return current[key];
426
+ }, obj);
427
+ target[lastKey] = value;
428
+ }
361
429
  get(key, defaultValue) {
430
+ if (key.includes(".")) {
431
+ const value = this.getNestedValue(this.config, key);
432
+ return value ?? defaultValue;
433
+ }
362
434
  return this.config[key] ?? defaultValue;
363
435
  }
364
436
  set(key, value) {
365
- this.config[key] = value;
437
+ if (key.includes(".")) {
438
+ this.setNestedValue(this.config, key, value);
439
+ } else {
440
+ this.config[key] = value;
441
+ }
366
442
  }
367
443
  update(configData) {
368
444
  this.config = {
@@ -531,26 +607,6 @@ var EntryPointType = {
531
607
  CONSTRUCTOR: "CONSTRUCTOR"
532
608
  };
533
609
 
534
- // src/provider/types/spec.type.ts
535
- var { ETransactionVersion: ETransactionVersion2 } = RPCSPEC09;
536
- var { ETransactionVersion2: ETransactionVersion22 } = RPCSPEC09;
537
- var { ETransactionVersion3 } = RPCSPEC09;
538
- var { EDataAvailabilityMode } = RPCSPEC010;
539
- var { EDAMode } = RPCSPEC010;
540
- function isRPC08Plus_ResourceBounds(entry) {
541
- return "l1_data_gas" in entry;
542
- }
543
- function isRPC08Plus_ResourceBoundsBN(entry) {
544
- return "l1_data_gas" in entry;
545
- }
546
- var { ETransactionStatus } = RPCSPEC010;
547
- var { ETransactionExecutionStatus } = RPCSPEC010;
548
- var { ETransactionType: TransactionType } = RPCSPEC09;
549
- var { EBlockStatus: BlockStatus } = RPCSPEC09;
550
- var { ETransactionFinalityStatus: TransactionFinalityStatus } = RPCSPEC09;
551
- var { ETransactionExecutionStatus: TransactionExecutionStatus } = RPCSPEC09;
552
- var { EBlockTag: BlockTag } = RPCSPEC09;
553
-
554
610
  // src/types/calldata.ts
555
611
  var ValidateType = {
556
612
  DEPLOY: "DEPLOY",
@@ -5181,8 +5237,8 @@ function computeCompiledClassHashBlake(casm) {
5181
5237
 
5182
5238
  // src/utils/resolve.ts
5183
5239
  function isV3Tx(details) {
5184
- const version = details.version ? toHex(details.version) : ETransactionVersion2.V3;
5185
- return version === ETransactionVersion2.V3 || version === ETransactionVersion2.F3;
5240
+ const version = details.version ? toHex(details.version) : ETransactionVersion.V3;
5241
+ return version === ETransactionVersion.V3 || version === ETransactionVersion.F3;
5186
5242
  }
5187
5243
  function isVersion(expected, provided) {
5188
5244
  const expectedParts = expected.split(".");
@@ -5387,10 +5443,10 @@ function toTransactionVersion(defaultVersion, providedVersion) {
5387
5443
  function toFeeVersion(providedVersion) {
5388
5444
  if (!providedVersion) return void 0;
5389
5445
  const version = toHex(providedVersion);
5390
- if (version === ETransactionVersion2.V0) return ETransactionVersion2.F0;
5391
- if (version === ETransactionVersion2.V1) return ETransactionVersion2.F1;
5392
- if (version === ETransactionVersion2.V2) return ETransactionVersion2.F2;
5393
- if (version === ETransactionVersion2.V3) return ETransactionVersion2.F3;
5446
+ if (version === ETransactionVersion.V0) return ETransactionVersion.F0;
5447
+ if (version === ETransactionVersion.V1) return ETransactionVersion.F1;
5448
+ if (version === ETransactionVersion.V2) return ETransactionVersion.F2;
5449
+ if (version === ETransactionVersion.V3) return ETransactionVersion.F3;
5394
5450
  throw Error(`toFeeVersion: ${version} is not supported`);
5395
5451
  }
5396
5452
  function v3Details(details) {
@@ -5714,16 +5770,11 @@ var getExecuteCalldata = (calls, cairoVersion = "0") => {
5714
5770
  };
5715
5771
  function getVersionsByType(versionType) {
5716
5772
  return versionType === "fee" ? {
5717
- v3: ETransactionVersion2.F3
5718
- } : { v3: ETransactionVersion2.V3 };
5773
+ v3: ETransactionVersion.F3
5774
+ } : { v3: ETransactionVersion.V3 };
5719
5775
  }
5720
5776
 
5721
5777
  // src/channel/rpc_0_9_0.ts
5722
- var defaultOptions = {
5723
- headers: { "Content-Type": "application/json" },
5724
- blockIdentifier: BlockTag.LATEST,
5725
- retries: 200
5726
- };
5727
5778
  var RpcChannel = class {
5728
5779
  id = "RPC090";
5729
5780
  /**
@@ -5773,11 +5824,12 @@ var RpcChannel = class {
5773
5824
  this.channelSpecVersion
5774
5825
  );
5775
5826
  }
5827
+ const channelDefaults = config.get("channelDefaults");
5776
5828
  this.baseFetch = baseFetch || config.get("fetch") || fetch_default;
5777
- this.blockIdentifier = blockIdentifier ?? defaultOptions.blockIdentifier;
5829
+ this.blockIdentifier = blockIdentifier ?? channelDefaults.options.blockIdentifier;
5778
5830
  this.chainId = chainId;
5779
- this.headers = { ...defaultOptions.headers, ...headers };
5780
- this.retries = retries ?? defaultOptions.retries;
5831
+ this.headers = { ...channelDefaults.options.headers, ...headers };
5832
+ this.retries = retries ?? channelDefaults.options.retries;
5781
5833
  this.specVersion = specVersion;
5782
5834
  this.transactionRetryIntervalFallback = transactionRetryIntervalFallback;
5783
5835
  this.waitMode = waitMode ?? false;
@@ -5991,14 +6043,16 @@ var RpcChannel = class {
5991
6043
  * @param invocations AccountInvocations
5992
6044
  * @param simulateTransactionOptions blockIdentifier and flags to skip validation and fee charge<br/>
5993
6045
  * - blockIdentifier<br/>
5994
- * - skipValidate (default false)<br/>
6046
+ * - skipValidate (default true)<br/>
5995
6047
  * - skipFeeCharge (default true)<br/>
5996
6048
  */
5997
6049
  simulateTransaction(invocations, simulateTransactionOptions = {}) {
6050
+ const channelDefaults = config.get("channelDefaults");
6051
+ const methodDefaults = channelDefaults.methods.simulateTransaction || {};
5998
6052
  const {
5999
6053
  blockIdentifier = this.blockIdentifier,
6000
- skipValidate = true,
6001
- skipFeeCharge = true
6054
+ skipValidate = methodDefaults.skipValidate,
6055
+ skipFeeCharge = methodDefaults.skipFeeCharge
6002
6056
  } = simulateTransactionOptions;
6003
6057
  const block_id = new Block(blockIdentifier).identifier;
6004
6058
  const simulationFlags = [];
@@ -6158,7 +6212,10 @@ var RpcChannel = class {
6158
6212
  contract_address
6159
6213
  });
6160
6214
  }
6161
- async getEstimateFee(invocations, { blockIdentifier = this.blockIdentifier, skipValidate = true } = {}) {
6215
+ async getEstimateFee(invocations, options = {}) {
6216
+ const channelDefaults = config.get("channelDefaults");
6217
+ const methodDefaults = channelDefaults.methods.getEstimateFee || {};
6218
+ const { blockIdentifier = this.blockIdentifier, skipValidate = methodDefaults.skipValidate } = options;
6162
6219
  const block_id = new Block(blockIdentifier).identifier;
6163
6220
  const flags = {
6164
6221
  simulation_flags: skipValidate ? [RPCSPEC09.ESimulationFlag.SKIP_VALIDATE] : []
@@ -6316,11 +6373,6 @@ var rpc_0_10_0_exports = {};
6316
6373
  __export(rpc_0_10_0_exports, {
6317
6374
  RpcChannel: () => RpcChannel2
6318
6375
  });
6319
- var defaultOptions2 = {
6320
- headers: { "Content-Type": "application/json" },
6321
- blockIdentifier: BlockTag.LATEST,
6322
- retries: 200
6323
- };
6324
6376
  var RpcChannel2 = class {
6325
6377
  id = "RPC0.10.0";
6326
6378
  /**
@@ -6370,11 +6422,12 @@ var RpcChannel2 = class {
6370
6422
  this.channelSpecVersion
6371
6423
  );
6372
6424
  }
6425
+ const channelDefaults = config.get("channelDefaults");
6373
6426
  this.baseFetch = baseFetch || config.get("fetch") || fetch_default;
6374
- this.blockIdentifier = blockIdentifier ?? defaultOptions2.blockIdentifier;
6427
+ this.blockIdentifier = blockIdentifier ?? channelDefaults.options.blockIdentifier;
6375
6428
  this.chainId = chainId;
6376
- this.headers = { ...defaultOptions2.headers, ...headers };
6377
- this.retries = retries ?? defaultOptions2.retries;
6429
+ this.headers = { ...channelDefaults.options.headers, ...headers };
6430
+ this.retries = retries ?? channelDefaults.options.retries;
6378
6431
  this.specVersion = specVersion;
6379
6432
  this.transactionRetryIntervalFallback = transactionRetryIntervalFallback;
6380
6433
  this.waitMode = waitMode ?? false;
@@ -6588,14 +6641,16 @@ var RpcChannel2 = class {
6588
6641
  * @param invocations AccountInvocations
6589
6642
  * @param simulateTransactionOptions blockIdentifier and flags to skip validation and fee charge<br/>
6590
6643
  * - blockIdentifier<br/>
6591
- * - skipValidate (default false)<br/>
6644
+ * - skipValidate (default true)<br/>
6592
6645
  * - skipFeeCharge (default true)<br/>
6593
6646
  */
6594
6647
  simulateTransaction(invocations, simulateTransactionOptions = {}) {
6648
+ const channelDefaults = config.get("channelDefaults");
6649
+ const methodDefaults = channelDefaults.methods.simulateTransaction || {};
6595
6650
  const {
6596
6651
  blockIdentifier = this.blockIdentifier,
6597
- skipValidate = true,
6598
- skipFeeCharge = true
6652
+ skipValidate = methodDefaults.skipValidate,
6653
+ skipFeeCharge = methodDefaults.skipFeeCharge
6599
6654
  } = simulateTransactionOptions;
6600
6655
  const block_id = new Block(blockIdentifier).identifier;
6601
6656
  const simulationFlags = [];
@@ -6755,7 +6810,10 @@ var RpcChannel2 = class {
6755
6810
  contract_address
6756
6811
  });
6757
6812
  }
6758
- async getEstimateFee(invocations, { blockIdentifier = this.blockIdentifier, skipValidate = true } = {}) {
6813
+ async getEstimateFee(invocations, options = {}) {
6814
+ const channelDefaults = config.get("channelDefaults");
6815
+ const methodDefaults = channelDefaults.methods.getEstimateFee || {};
6816
+ const { blockIdentifier = this.blockIdentifier, skipValidate = methodDefaults.skipValidate } = options;
6759
6817
  const block_id = new Block(blockIdentifier).identifier;
6760
6818
  const flags = {
6761
6819
  simulation_flags: skipValidate ? [RPCSPEC010.ESimulationFlag.SKIP_VALIDATE] : []
@@ -10712,7 +10770,7 @@ var convertEXECUTION_PARAMETERS = (parameters) => ({
10712
10770
  feeMode: convertFEE_MODE(parameters.fee_mode),
10713
10771
  timeBounds: convertTIME_BOUNDS(parameters.time_bounds)
10714
10772
  });
10715
- var defaultOptions3 = {
10773
+ var defaultOptions = {
10716
10774
  headers: { "Content-Type": "application/json" }
10717
10775
  };
10718
10776
  var PaymasterRpc = class _PaymasterRpc {
@@ -10723,14 +10781,14 @@ var PaymasterRpc = class _PaymasterRpc {
10723
10781
  constructor(options) {
10724
10782
  if (options instanceof _PaymasterRpc) {
10725
10783
  this.nodeUrl = options.nodeUrl;
10726
- this.headers = { ...defaultOptions3.headers, ...options.headers };
10784
+ this.headers = { ...defaultOptions.headers, ...options.headers };
10727
10785
  this.baseFetch = options.baseFetch;
10728
10786
  this.requestId = options.requestId;
10729
10787
  return;
10730
10788
  }
10731
10789
  if (options && "nodeUrl" in options && "headers" in options && "baseFetch" in options) {
10732
10790
  this.nodeUrl = options.nodeUrl ?? getDefaultPaymasterNodeUrl(void 0);
10733
- this.headers = { ...defaultOptions3.headers, ...options.headers };
10791
+ this.headers = { ...defaultOptions.headers, ...options.headers };
10734
10792
  this.baseFetch = options.baseFetch ?? fetch_default;
10735
10793
  this.requestId = 0;
10736
10794
  return;
@@ -10744,7 +10802,7 @@ var PaymasterRpc = class _PaymasterRpc {
10744
10802
  this.nodeUrl = getDefaultPaymasterNodeUrl(void 0, options?.default);
10745
10803
  }
10746
10804
  this.baseFetch = baseFetch ?? fetch_default;
10747
- this.headers = { ...defaultOptions3.headers, ...headers };
10805
+ this.headers = { ...defaultOptions.headers, ...headers };
10748
10806
  this.requestId = 0;
10749
10807
  }
10750
10808
  fetch(method, params, id = 0) {
@@ -12770,8 +12828,8 @@ export {
12770
12828
  ETH_ADDRESS,
12771
12829
  ETransactionExecutionStatus,
12772
12830
  ETransactionStatus,
12773
- ETransactionVersion2 as ETransactionVersion,
12774
- ETransactionVersion22 as ETransactionVersion2,
12831
+ ETransactionVersion,
12832
+ ETransactionVersion2,
12775
12833
  ETransactionVersion3,
12776
12834
  EntryPointType,
12777
12835
  EthSigner,