starknet 10.0.3 → 10.1.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
@@ -70,7 +70,7 @@ var api_exports = {};
70
70
  __export(api_exports, {
71
71
  JRPC: () => jsonrpc_exports,
72
72
  PAYMASTER_API: () => PAYMASTER_API,
73
- RPCSPEC0101: () => RPCSPEC0101,
73
+ RPCSPEC0103: () => RPCSPEC0103,
74
74
  RPCSPEC09: () => RPCSPEC09
75
75
  });
76
76
 
@@ -79,13 +79,13 @@ var jsonrpc_exports = {};
79
79
 
80
80
  // src/types/api/index.ts
81
81
  import * as RPCSPEC09 from "@starknet-io/starknet-types-09";
82
- import * as RPCSPEC0101 from "@starknet-io/starknet-types-0101";
83
- import { PAYMASTER_API } from "@starknet-io/starknet-types-0101";
82
+ import * as RPCSPEC0103 from "@starknet-io/starknet-types-0103";
83
+ import { PAYMASTER_API } from "@starknet-io/starknet-types-0103";
84
84
 
85
85
  // src/types/api/rpc.ts
86
86
  var rpc_exports = {};
87
- __reExport(rpc_exports, starknet_types_0101_star);
88
- import * as starknet_types_0101_star from "@starknet-io/starknet-types-0101";
87
+ __reExport(rpc_exports, starknet_types_0103_star);
88
+ import * as starknet_types_0103_star from "@starknet-io/starknet-types-0103";
89
89
 
90
90
  // src/types/api/index.ts
91
91
  __reExport(api_exports, rpc_exports);
@@ -94,19 +94,19 @@ __reExport(api_exports, rpc_exports);
94
94
  var { ETransactionVersion } = RPCSPEC09;
95
95
  var { ETransactionVersion2 } = RPCSPEC09;
96
96
  var { ETransactionVersion3 } = RPCSPEC09;
97
- var { EDataAvailabilityMode } = RPCSPEC0101;
98
- var { EDAMode } = RPCSPEC0101;
97
+ var { EDataAvailabilityMode } = RPCSPEC0103;
98
+ var { EDAMode } = RPCSPEC0103;
99
99
  function isRPC08Plus_ResourceBounds(entry) {
100
100
  return "l1_data_gas" in entry;
101
101
  }
102
102
  function isRPC08Plus_ResourceBoundsBN(entry) {
103
103
  return "l1_data_gas" in entry;
104
104
  }
105
- var { ETxnResponseFlag } = RPCSPEC0101;
106
- var { ETraceFlag } = RPCSPEC0101;
107
- var { ESubscriptionTag } = RPCSPEC0101;
108
- var { ETransactionStatus } = RPCSPEC0101;
109
- var { ETransactionExecutionStatus } = RPCSPEC0101;
105
+ var { ETxnResponseFlag } = RPCSPEC0103;
106
+ var { ETraceFlag } = RPCSPEC0103;
107
+ var { ESubscriptionTag } = RPCSPEC0103;
108
+ var { ETransactionStatus } = RPCSPEC0103;
109
+ var { ETransactionExecutionStatus } = RPCSPEC0103;
110
110
  var { ETransactionType: TransactionType } = RPCSPEC09;
111
111
  var { EBlockStatus: BlockStatus } = RPCSPEC09;
112
112
  var { ETransactionFinalityStatus: TransactionFinalityStatus } = RPCSPEC09;
@@ -321,9 +321,11 @@ var _SupportedRpcVersion = {
321
321
  "0.9.0": "0.9.0",
322
322
  "0.10.0": "0.10.0",
323
323
  "0.10.2": "0.10.2",
324
+ "0.10.3": "0.10.3",
324
325
  v0_9_0: "0.9.0",
325
326
  v0_10_0: "0.10.0",
326
- v0_10_2: "0.10.2"
327
+ v0_10_2: "0.10.2",
328
+ v0_10_3: "0.10.3"
327
329
  };
328
330
  var DEFAULT_GLOBAL_CONFIG = {
329
331
  rpcVersion: "0.10.0",
@@ -1143,31 +1145,6 @@ function addCompiledFlag(compiled) {
1143
1145
  }
1144
1146
 
1145
1147
  // src/utils/cairoDataTypes/felt.ts
1146
- function CairoFelt(it) {
1147
- if (isBigInt(it) || Number.isInteger(it)) {
1148
- return it.toString();
1149
- }
1150
- if (isString(it)) {
1151
- if (isHex(it)) {
1152
- return BigInt(it).toString();
1153
- }
1154
- if (isText(it)) {
1155
- if (!isShortString(it)) {
1156
- throw new Error(
1157
- `${it} is a long string > 31 chars. Please split it into an array of short strings.`
1158
- );
1159
- }
1160
- return BigInt(encodeShortString(it)).toString();
1161
- }
1162
- if (isStringWholeNumber(it)) {
1163
- return it;
1164
- }
1165
- }
1166
- if (isBoolean(it)) {
1167
- return `${+it}`;
1168
- }
1169
- throw new Error(`${it} can't be computed by felt()`);
1170
- }
1171
1148
  var CairoFelt252 = class _CairoFelt252 {
1172
1149
  /**
1173
1150
  * byte representation of the felt252
@@ -1206,6 +1183,9 @@ var CairoFelt252 = class _CairoFelt252 {
1206
1183
  toApiRequest() {
1207
1184
  return addCompiledFlag([this.toHexString()]);
1208
1185
  }
1186
+ static assertRange(val) {
1187
+ assert(val >= 0n && val < PRIME, `Value ${val} is out of felt252 range [0, ${PRIME})`);
1188
+ }
1209
1189
  static validate(data) {
1210
1190
  assert(data !== null, "null value is not allowed for felt252");
1211
1191
  assert(data !== void 0, "undefined value is not allowed for felt252");
@@ -1215,7 +1195,7 @@ var CairoFelt252 = class _CairoFelt252 {
1215
1195
  );
1216
1196
  const value = _CairoFelt252.__processData(data);
1217
1197
  const bn = uint8ArrayToBigInt(value);
1218
- assert(bn >= 0n && bn < PRIME, `Value ${value} is out of felt252 range [0, ${PRIME})`);
1198
+ _CairoFelt252.assertRange(bn);
1219
1199
  }
1220
1200
  static is(data) {
1221
1201
  try {
@@ -1232,6 +1212,37 @@ var CairoFelt252 = class _CairoFelt252 {
1232
1212
  return new _CairoFelt252(getNext(responseIterator));
1233
1213
  }
1234
1214
  };
1215
+ function CairoFelt(it) {
1216
+ if (isBigInt(it) || Number.isInteger(it)) {
1217
+ const val = BigInt(it);
1218
+ CairoFelt252.assertRange(val);
1219
+ return val.toString();
1220
+ }
1221
+ if (isString(it)) {
1222
+ if (isHex(it)) {
1223
+ const val = BigInt(it);
1224
+ CairoFelt252.assertRange(val);
1225
+ return val.toString();
1226
+ }
1227
+ if (isText(it)) {
1228
+ if (!isShortString(it)) {
1229
+ throw new Error(
1230
+ `${it} is a long string > 31 chars. Please split it into an array of short strings.`
1231
+ );
1232
+ }
1233
+ return BigInt(encodeShortString(it)).toString();
1234
+ }
1235
+ if (isStringWholeNumber(it)) {
1236
+ const val = BigInt(it);
1237
+ CairoFelt252.assertRange(val);
1238
+ return val.toString();
1239
+ }
1240
+ }
1241
+ if (isBoolean(it)) {
1242
+ return `${+it}`;
1243
+ }
1244
+ throw new Error(`${it} can't be computed by felt()`);
1245
+ }
1235
1246
 
1236
1247
  // src/utils/cairoDataTypes/uint256.ts
1237
1248
  var UINT_128_MAX = (1n << 128n) - 1n;
@@ -6540,6 +6551,7 @@ var rpc_0_10_2_exports = {};
6540
6551
  __export(rpc_0_10_2_exports, {
6541
6552
  RpcChannel: () => RpcChannel2
6542
6553
  });
6554
+ import * as RPC from "@starknet-io/starknet-types-0101";
6543
6555
  var RpcChannel2 = class {
6544
6556
  id = "RPC0.10.2";
6545
6557
  /**
@@ -6759,7 +6771,7 @@ var RpcChannel2 = class {
6759
6771
  */
6760
6772
  getBlockWithTxs(blockIdentifier = this.blockIdentifier, options) {
6761
6773
  const block_id = new Block(blockIdentifier).identifier;
6762
- const response_flags = options?.includeProofFacts ? [RPCSPEC0101.ETxnResponseFlag.INCLUDE_PROOF_FACTS] : void 0;
6774
+ const response_flags = options?.includeProofFacts ? [RPC.ETxnResponseFlag.INCLUDE_PROOF_FACTS] : void 0;
6763
6775
  return this.fetchEndpoint("starknet_getBlockWithTxs", {
6764
6776
  block_id,
6765
6777
  ...response_flags && { response_flags }
@@ -6773,7 +6785,7 @@ var RpcChannel2 = class {
6773
6785
  */
6774
6786
  getBlockWithReceipts(blockIdentifier = this.blockIdentifier, options) {
6775
6787
  const block_id = new Block(blockIdentifier).identifier;
6776
- const response_flags = options?.includeProofFacts ? [RPCSPEC0101.ETxnResponseFlag.INCLUDE_PROOF_FACTS] : void 0;
6788
+ const response_flags = options?.includeProofFacts ? [RPC.ETxnResponseFlag.INCLUDE_PROOF_FACTS] : void 0;
6777
6789
  return this.fetchEndpoint("starknet_getBlockWithReceipts", {
6778
6790
  block_id,
6779
6791
  ...response_flags && { response_flags }
@@ -6796,7 +6808,7 @@ var RpcChannel2 = class {
6796
6808
  */
6797
6809
  getBlockTransactionsTraces(blockIdentifier = this.blockIdentifier, options) {
6798
6810
  const block_id = new Block(blockIdentifier).identifier;
6799
- const trace_flags = options?.returnInitialReads ? [RPCSPEC0101.ETraceFlag.RETURN_INITIAL_READS] : void 0;
6811
+ const trace_flags = options?.returnInitialReads ? [RPC.ETraceFlag.RETURN_INITIAL_READS] : void 0;
6800
6812
  return this.fetchEndpoint("starknet_traceBlockTransactions", {
6801
6813
  block_id,
6802
6814
  ...trace_flags && { trace_flags }
@@ -6814,7 +6826,7 @@ var RpcChannel2 = class {
6814
6826
  */
6815
6827
  getTransactionByHash(txHash, options) {
6816
6828
  const transaction_hash = toHex(txHash);
6817
- const response_flags = options?.includeProofFacts ? [RPCSPEC0101.ETxnResponseFlag.INCLUDE_PROOF_FACTS] : void 0;
6829
+ const response_flags = options?.includeProofFacts ? [RPC.ETxnResponseFlag.INCLUDE_PROOF_FACTS] : void 0;
6818
6830
  return this.fetchEndpoint("starknet_getTransactionByHash", {
6819
6831
  transaction_hash,
6820
6832
  ...response_flags && { response_flags }
@@ -6829,7 +6841,7 @@ var RpcChannel2 = class {
6829
6841
  */
6830
6842
  getTransactionByBlockIdAndIndex(blockIdentifier, index, options) {
6831
6843
  const block_id = new Block(blockIdentifier).identifier;
6832
- const response_flags = options?.includeProofFacts ? [RPCSPEC0101.ETxnResponseFlag.INCLUDE_PROOF_FACTS] : void 0;
6844
+ const response_flags = options?.includeProofFacts ? [RPC.ETxnResponseFlag.INCLUDE_PROOF_FACTS] : void 0;
6833
6845
  return this.fetchEndpoint("starknet_getTransactionByBlockIdAndIndex", {
6834
6846
  block_id,
6835
6847
  index,
@@ -6870,9 +6882,9 @@ var RpcChannel2 = class {
6870
6882
  } = simulateTransactionOptions;
6871
6883
  const block_id = new Block(blockIdentifier).identifier;
6872
6884
  const simulationFlags = [];
6873
- if (skipValidate) simulationFlags.push(RPCSPEC0101.ESimulationFlag.SKIP_VALIDATE);
6874
- if (skipFeeCharge) simulationFlags.push(RPCSPEC0101.ESimulationFlag.SKIP_FEE_CHARGE);
6875
- const trace_flags = returnInitialReads ? [RPCSPEC0101.ETraceFlag.RETURN_INITIAL_READS] : void 0;
6885
+ if (skipValidate) simulationFlags.push(RPC.ESimulationFlag.SKIP_VALIDATE);
6886
+ if (skipFeeCharge) simulationFlags.push(RPC.ESimulationFlag.SKIP_FEE_CHARGE);
6887
+ const trace_flags = returnInitialReads ? [RPC.ETraceFlag.RETURN_INITIAL_READS] : void 0;
6876
6888
  return this.fetchEndpoint("starknet_simulateTransactions", {
6877
6889
  block_id,
6878
6890
  transactions: await Promise.all(invocations.map((it) => this.buildTransaction(it))),
@@ -6890,13 +6902,13 @@ var RpcChannel2 = class {
6890
6902
  const errorStates = options?.errorStates ?? [];
6891
6903
  const successStates = options?.successStates ?? [
6892
6904
  // RPC.ETransactionExecutionStatus.SUCCEEDED, // UDC on SUCCEEDED + pre_confirmed had no proper events to parse UDC
6893
- RPCSPEC0101.ETransactionFinalityStatus.ACCEPTED_ON_L2,
6894
- RPCSPEC0101.ETransactionFinalityStatus.ACCEPTED_ON_L1
6905
+ RPC.ETransactionFinalityStatus.ACCEPTED_ON_L2,
6906
+ RPC.ETransactionFinalityStatus.ACCEPTED_ON_L1
6895
6907
  ];
6896
6908
  const errorMessages = {
6897
- [RPCSPEC0101.ETransactionStatus.RECEIVED]: SYSTEM_MESSAGES.txEvictedFromMempool,
6898
- [RPCSPEC0101.ETransactionStatus.PRE_CONFIRMED]: SYSTEM_MESSAGES.consensusFailed,
6899
- [RPCSPEC0101.ETransactionStatus.CANDIDATE]: SYSTEM_MESSAGES.txFailsBlockBuildingValidation
6909
+ [RPC.ETransactionStatus.RECEIVED]: SYSTEM_MESSAGES.txEvictedFromMempool,
6910
+ [RPC.ETransactionStatus.PRE_CONFIRMED]: SYSTEM_MESSAGES.consensusFailed,
6911
+ [RPC.ETransactionStatus.CANDIDATE]: SYSTEM_MESSAGES.txFailsBlockBuildingValidation
6900
6912
  };
6901
6913
  const txLife = [];
6902
6914
  let txStatus;
@@ -6993,7 +7005,7 @@ var RpcChannel2 = class {
6993
7005
  const { blockIdentifier = this.blockIdentifier, skipValidate = methodDefaults.skipValidate } = options;
6994
7006
  const block_id = new Block(blockIdentifier).identifier;
6995
7007
  const flags = {
6996
- simulation_flags: skipValidate ? [RPCSPEC0101.ESimulationFlag.SKIP_VALIDATE] : []
7008
+ simulation_flags: skipValidate ? [RPC.ESimulationFlag.SKIP_VALIDATE] : []
6997
7009
  };
6998
7010
  return this.fetchEndpoint("starknet_estimateFee", {
6999
7011
  request: await Promise.all(invocations.map((it) => this.buildTransaction(it, "fee"))),
@@ -7107,7 +7119,7 @@ var RpcChannel2 = class {
7107
7119
  };
7108
7120
  if (invocation.type === api_exports.ETransactionType.INVOKE) {
7109
7121
  const btx = {
7110
- type: RPCSPEC0101.ETransactionType.INVOKE,
7122
+ type: RPC.ETransactionType.INVOKE,
7111
7123
  sender_address: invocation.contractAddress,
7112
7124
  calldata: CallData.toHex(invocation.calldata),
7113
7125
  ...details,
@@ -7149,6 +7161,16 @@ var RpcChannel2 = class {
7149
7161
  }
7150
7162
  };
7151
7163
 
7164
+ // src/channel/rpc_0_10_3.ts
7165
+ var rpc_0_10_3_exports = {};
7166
+ __export(rpc_0_10_3_exports, {
7167
+ RpcChannel: () => RpcChannel3
7168
+ });
7169
+ var RpcChannel3 = class extends RpcChannel2 {
7170
+ id = "RPC0.10.3";
7171
+ channelSpecVersion = _SupportedRpcVersion.v0_10_3;
7172
+ };
7173
+
7152
7174
  // src/utils/eventEmitter.ts
7153
7175
  var EventEmitter = class {
7154
7176
  listeners = {};
@@ -9420,12 +9442,12 @@ var RpcProvider = class {
9420
9442
  if (isVersion("0.9", options.specVersion)) {
9421
9443
  this.channel = new rpc_0_9_0_exports.RpcChannel({ ...options, waitMode: false });
9422
9444
  } else if (isVersion("0.10", options.specVersion)) {
9423
- this.channel = new rpc_0_10_2_exports.RpcChannel({ ...options, waitMode: false });
9445
+ this.channel = new rpc_0_10_3_exports.RpcChannel({ ...options, waitMode: false });
9424
9446
  } else throw new Error(`unsupported channel for spec version: ${options.specVersion}`);
9425
9447
  } else if (isVersion("0.9", config.get("rpcVersion"))) {
9426
9448
  this.channel = new rpc_0_9_0_exports.RpcChannel({ ...options, waitMode: false });
9427
9449
  } else if (isVersion("0.10", config.get("rpcVersion"))) {
9428
- this.channel = new rpc_0_10_2_exports.RpcChannel({ ...options, waitMode: false });
9450
+ this.channel = new rpc_0_10_3_exports.RpcChannel({ ...options, waitMode: false });
9429
9451
  } else throw new Error("unable to define spec version for channel");
9430
9452
  this.responseParser = new RPCResponseParser(options?.resourceBoundsOverhead);
9431
9453
  const plugins = options?.plugins === false ? [] : options?.plugins ?? defaultPlugins;
@@ -9454,7 +9476,7 @@ var RpcProvider = class {
9454
9476
  if (isVersion("0.10", spec)) {
9455
9477
  return new this({
9456
9478
  ...optionsOrProvider,
9457
- specVersion: _SupportedRpcVersion.v0_10_2
9479
+ specVersion: _SupportedRpcVersion.v0_10_3
9458
9480
  });
9459
9481
  }
9460
9482
  throw new LibraryError(
@@ -13235,12 +13257,13 @@ export {
13235
13257
  RpcProvider as Provider,
13236
13258
  ProviderInterface,
13237
13259
  api_exports as RPC,
13238
- rpc_0_10_2_exports as RPC0101,
13260
+ rpc_0_10_2_exports as RPC0102,
13261
+ rpc_0_10_3_exports as RPC0103,
13239
13262
  rpc_0_9_0_exports as RPC09,
13240
13263
  RPCResponseParser,
13241
13264
  ReceiptTx,
13242
13265
  ResponseParser,
13243
- RpcChannel2 as RpcChannel,
13266
+ RpcChannel3 as RpcChannel,
13244
13267
  RpcError,
13245
13268
  RpcProvider,
13246
13269
  Signer,