starknet 7.0.1 → 7.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.js CHANGED
@@ -154,7 +154,7 @@ var constants_exports = {};
154
154
  __export(constants_exports, {
155
155
  ADDR_BOUND: () => ADDR_BOUND,
156
156
  API_VERSION: () => API_VERSION,
157
- BaseUrl: () => BaseUrl,
157
+ BaseUrl: () => _BaseUrl,
158
158
  DEFAULT_GLOBAL_CONFIG: () => DEFAULT_GLOBAL_CONFIG,
159
159
  HARDENING_4BYTES: () => HARDENING_4BYTES,
160
160
  HARDENING_BYTE: () => HARDENING_BYTE,
@@ -162,7 +162,7 @@ __export(constants_exports, {
162
162
  MASK_250: () => MASK_250,
163
163
  MASK_31: () => MASK_31,
164
164
  MAX_STORAGE_ITEM_SIZE: () => MAX_STORAGE_ITEM_SIZE,
165
- NetworkName: () => NetworkName,
165
+ NetworkName: () => _NetworkName,
166
166
  OutsideExecutionCallerAny: () => OutsideExecutionCallerAny,
167
167
  PRIME: () => PRIME,
168
168
  RANGE_FELT: () => RANGE_FELT,
@@ -172,11 +172,11 @@ __export(constants_exports, {
172
172
  SNIP9_V1_INTERFACE_ID: () => SNIP9_V1_INTERFACE_ID,
173
173
  SNIP9_V2_INTERFACE_ID: () => SNIP9_V2_INTERFACE_ID,
174
174
  SYSTEM_MESSAGES: () => SYSTEM_MESSAGES,
175
- StarknetChainId: () => StarknetChainId,
176
- SupportedRpcVersion: () => SupportedRpcVersion,
175
+ StarknetChainId: () => _StarknetChainId,
176
+ SupportedRpcVersion: () => _SupportedRpcVersion,
177
177
  TEXT_TO_FELT_MAX_LEN: () => TEXT_TO_FELT_MAX_LEN,
178
178
  TRANSACTION_VERSION: () => TRANSACTION_VERSION,
179
- TransactionHashPrefix: () => TransactionHashPrefix,
179
+ TransactionHashPrefix: () => _TransactionHashPrefix,
180
180
  UDC: () => UDC,
181
181
  ZERO: () => ZERO
182
182
  });
@@ -290,29 +290,6 @@ var range = (min, max) => ({ min, max });
290
290
  var RANGE_FELT = range(ZERO, PRIME - 1n);
291
291
  var RANGE_I128 = range(-(2n ** 127n), 2n ** 127n - 1n);
292
292
  var RANGE_U128 = range(ZERO, 2n ** 128n - 1n);
293
- var BaseUrl = /* @__PURE__ */ ((BaseUrl2) => {
294
- BaseUrl2["SN_MAIN"] = "https://alpha-mainnet.starknet.io";
295
- BaseUrl2["SN_SEPOLIA"] = "https://alpha-sepolia.starknet.io";
296
- return BaseUrl2;
297
- })(BaseUrl || {});
298
- var NetworkName = /* @__PURE__ */ ((NetworkName2) => {
299
- NetworkName2["SN_MAIN"] = "SN_MAIN";
300
- NetworkName2["SN_SEPOLIA"] = "SN_SEPOLIA";
301
- return NetworkName2;
302
- })(NetworkName || {});
303
- var StarknetChainId = /* @__PURE__ */ ((StarknetChainId6) => {
304
- StarknetChainId6["SN_MAIN"] = "0x534e5f4d41494e";
305
- StarknetChainId6["SN_SEPOLIA"] = "0x534e5f5345504f4c4941";
306
- return StarknetChainId6;
307
- })(StarknetChainId || {});
308
- var TransactionHashPrefix = /* @__PURE__ */ ((TransactionHashPrefix2) => {
309
- TransactionHashPrefix2["DECLARE"] = "0x6465636c617265";
310
- TransactionHashPrefix2["DEPLOY"] = "0x6465706c6f79";
311
- TransactionHashPrefix2["DEPLOY_ACCOUNT"] = "0x6465706c6f795f6163636f756e74";
312
- TransactionHashPrefix2["INVOKE"] = "0x696e766f6b65";
313
- TransactionHashPrefix2["L1_HANDLER"] = "0x6c315f68616e646c6572";
314
- return TransactionHashPrefix2;
315
- })(TransactionHashPrefix || {});
316
293
  var UDC = {
317
294
  ADDRESS: "0x041a78e741e5af2fec34b695679bc6891742439f7afb8484ecd7766661ad02bf",
318
295
  ENTRYPOINT: "deployContract"
@@ -322,9 +299,37 @@ var SNIP9_V1_INTERFACE_ID = "0x68cfd18b92d1907b8ba3cc324900277f5a3622099431ea85d
322
299
  var SNIP9_V2_INTERFACE_ID = "0x1d1144bb2138366ff28d8e9ab57456b1d332ac42196230c3a602003c89872";
323
300
  var HARDENING_BYTE = 128;
324
301
  var HARDENING_4BYTES = 2147483648n;
325
- var SupportedRpcVersion = {
302
+ var _BaseUrl = {
303
+ SN_MAIN: "https://alpha-mainnet.starknet.io",
304
+ SN_SEPOLIA: "https://alpha-sepolia.starknet.io"
305
+ };
306
+ var _NetworkName = {
307
+ SN_MAIN: "SN_MAIN",
308
+ SN_SEPOLIA: "SN_SEPOLIA"
309
+ };
310
+ var _StarknetChainId = {
311
+ SN_MAIN: "0x534e5f4d41494e",
312
+ // encodeShortString('SN_MAIN'),
313
+ SN_SEPOLIA: "0x534e5f5345504f4c4941"
314
+ // encodeShortString('SN_SEPOLIA')
315
+ };
316
+ var _TransactionHashPrefix = {
317
+ DECLARE: "0x6465636c617265",
318
+ // encodeShortString('declare'),
319
+ DEPLOY: "0x6465706c6f79",
320
+ // encodeShortString('deploy'),
321
+ DEPLOY_ACCOUNT: "0x6465706c6f795f6163636f756e74",
322
+ // encodeShortString('deploy_account'),
323
+ INVOKE: "0x696e766f6b65",
324
+ // encodeShortString('invoke'),
325
+ L1_HANDLER: "0x6c315f68616e646c6572"
326
+ // encodeShortString('l1_handler'),
327
+ };
328
+ var _SupportedRpcVersion = {
326
329
  0.7: "0.7",
327
- 0.8: "0.8"
330
+ 0.8: "0.8",
331
+ v07: "0.7",
332
+ v08: "0.8"
328
333
  };
329
334
  var DEFAULT_GLOBAL_CONFIG = {
330
335
  legacyMode: false,
@@ -625,12 +630,11 @@ var OutsideExecutionTypesV2 = {
625
630
  { name: "Calldata", type: "felt*" }
626
631
  ]
627
632
  };
628
- var OutsideExecutionVersion = /* @__PURE__ */ ((OutsideExecutionVersion2) => {
629
- OutsideExecutionVersion2["UNSUPPORTED"] = "0";
630
- OutsideExecutionVersion2["V1"] = "1";
631
- OutsideExecutionVersion2["V2"] = "2";
632
- return OutsideExecutionVersion2;
633
- })(OutsideExecutionVersion || {});
633
+ var OutsideExecutionVersion = {
634
+ UNSUPPORTED: "0",
635
+ V1: "1",
636
+ V2: "2"
637
+ };
634
638
 
635
639
  // src/types/typedData.ts
636
640
  var import_starknet_types_07 = require("starknet-types-07");
@@ -3120,7 +3124,7 @@ function calculateTransactionHashCommon(txHashPrefix, version, contractAddress,
3120
3124
  }
3121
3125
  function calculateDeclareTransactionHash(classHash, senderAddress, version, maxFee, chainId, nonce, compiledClassHash) {
3122
3126
  return calculateTransactionHashCommon(
3123
- "0x6465636c617265" /* DECLARE */,
3127
+ _TransactionHashPrefix.DECLARE,
3124
3128
  version,
3125
3129
  senderAddress,
3126
3130
  0,
@@ -3133,7 +3137,7 @@ function calculateDeclareTransactionHash(classHash, senderAddress, version, maxF
3133
3137
  function calculateDeployAccountTransactionHash(contractAddress, classHash, constructorCalldata, salt, version, maxFee, chainId, nonce) {
3134
3138
  const calldata = [classHash, salt, ...constructorCalldata];
3135
3139
  return calculateTransactionHashCommon(
3136
- "0x6465706c6f795f6163636f756e74" /* DEPLOY_ACCOUNT */,
3140
+ _TransactionHashPrefix.DEPLOY_ACCOUNT,
3137
3141
  version,
3138
3142
  contractAddress,
3139
3143
  0,
@@ -3145,7 +3149,7 @@ function calculateDeployAccountTransactionHash(contractAddress, classHash, const
3145
3149
  }
3146
3150
  function calculateTransactionHash(contractAddress, version, calldata, maxFee, chainId, nonce) {
3147
3151
  return calculateTransactionHashCommon(
3148
- "0x696e766f6b65" /* INVOKE */,
3152
+ _TransactionHashPrefix.INVOKE,
3149
3153
  version,
3150
3154
  contractAddress,
3151
3155
  0,
@@ -3158,7 +3162,7 @@ function calculateTransactionHash(contractAddress, version, calldata, maxFee, ch
3158
3162
  function calculateL2MessageTxHash(l1FromAddress, l2ToAddress, l2Selector, l2Calldata, l2ChainId, l1Nonce) {
3159
3163
  const payload = [l1FromAddress, ...l2Calldata];
3160
3164
  return calculateTransactionHashCommon(
3161
- "0x6c315f68616e646c6572" /* L1_HANDLER */,
3165
+ _TransactionHashPrefix.L1_HANDLER,
3162
3166
  0,
3163
3167
  l2ToAddress,
3164
3168
  getSelector(l2Selector),
@@ -3233,7 +3237,7 @@ function calculateTransactionHashCommon2(txHashPrefix, version, senderAddress, c
3233
3237
  }
3234
3238
  function calculateDeployAccountTransactionHash2(contractAddress, classHash, compiledConstructorCalldata, salt, version, chainId, nonce, nonceDataAvailabilityMode, feeDataAvailabilityMode, resourceBounds, tip, paymasterData) {
3235
3239
  return calculateTransactionHashCommon2(
3236
- "0x6465706c6f795f6163636f756e74" /* DEPLOY_ACCOUNT */,
3240
+ _TransactionHashPrefix.DEPLOY_ACCOUNT,
3237
3241
  version,
3238
3242
  contractAddress,
3239
3243
  chainId,
@@ -3248,7 +3252,7 @@ function calculateDeployAccountTransactionHash2(contractAddress, classHash, comp
3248
3252
  }
3249
3253
  function calculateDeclareTransactionHash2(classHash, compiledClassHash, senderAddress, version, chainId, nonce, accountDeploymentData, nonceDataAvailabilityMode, feeDataAvailabilityMode, resourceBounds, tip, paymasterData) {
3250
3254
  return calculateTransactionHashCommon2(
3251
- "0x6465636c617265" /* DECLARE */,
3255
+ _TransactionHashPrefix.DECLARE,
3252
3256
  version,
3253
3257
  senderAddress,
3254
3258
  chainId,
@@ -3263,7 +3267,7 @@ function calculateDeclareTransactionHash2(classHash, compiledClassHash, senderAd
3263
3267
  }
3264
3268
  function calculateInvokeTransactionHash(senderAddress, version, compiledCalldata, chainId, nonce, accountDeploymentData, nonceDataAvailabilityMode, feeDataAvailabilityMode, resourceBounds, tip, paymasterData) {
3265
3269
  return calculateTransactionHashCommon2(
3266
- "0x696e766f6b65" /* INVOKE */,
3270
+ _TransactionHashPrefix.INVOKE,
3267
3271
  version,
3268
3272
  senderAddress,
3269
3273
  chainId,
@@ -3981,7 +3985,7 @@ var getDefaultNodeUrl = (networkName, mute = false, rpcVersion) => {
3981
3985
  logger.info("Using default public node url, please provide nodeUrl in provider options!");
3982
3986
  }
3983
3987
  const rpcNodes = getDefaultNodes(rpcVersion ?? config.get("rpcVersion"));
3984
- const nodes = rpcNodes[networkName ?? "SN_SEPOLIA" /* SN_SEPOLIA */];
3988
+ const nodes = rpcNodes[networkName ?? _NetworkName.SN_SEPOLIA];
3985
3989
  const randIdx = Math.floor(Math.random() * nodes.length);
3986
3990
  return nodes[randIdx];
3987
3991
  };
@@ -4240,7 +4244,7 @@ var RpcChannel = class {
4240
4244
  transactionRetryIntervalFallback,
4241
4245
  waitMode
4242
4246
  } = optionsOrProvider || {};
4243
- if (Object.values(NetworkName).includes(nodeUrl)) {
4247
+ if (Object.values(_NetworkName).includes(nodeUrl)) {
4244
4248
  this.nodeUrl = getDefaultNodeUrl(nodeUrl, optionsOrProvider?.default, "0.7");
4245
4249
  } else if (nodeUrl) {
4246
4250
  this.nodeUrl = nodeUrl;
@@ -4846,7 +4850,7 @@ var RpcChannel2 = class {
4846
4850
  transactionRetryIntervalFallback,
4847
4851
  waitMode
4848
4852
  } = optionsOrProvider || {};
4849
- if (Object.values(NetworkName).includes(nodeUrl)) {
4853
+ if (Object.values(_NetworkName).includes(nodeUrl)) {
4850
4854
  this.nodeUrl = getDefaultNodeUrl(nodeUrl, optionsOrProvider?.default, "0.8");
4851
4855
  } else if (nodeUrl) {
4852
4856
  this.nodeUrl = nodeUrl;
@@ -6358,7 +6362,7 @@ function verifyMessage(message, signature, fullPublicKey, accountAddress) {
6358
6362
  }
6359
6363
 
6360
6364
  // src/provider/rpc.ts
6361
- var RpcProvider = class _RpcProvider {
6365
+ var RpcProvider = class {
6362
6366
  responseParser;
6363
6367
  channel;
6364
6368
  constructor(optionsOrProvider) {
@@ -6385,16 +6389,17 @@ var RpcProvider = class _RpcProvider {
6385
6389
  * auto configure channel based on provided node
6386
6390
  * leave space for other async before constructor
6387
6391
  */
6392
+ // NOTE: the generic T and 'this' reference are used so that the expanded class is generated when a mixin is applied
6388
6393
  static async create(optionsOrProvider) {
6389
6394
  const channel = new rpc_0_7_exports.RpcChannel({ ...optionsOrProvider });
6390
6395
  const spec = await channel.getSpecVersion();
6391
6396
  if (isVersion("0.7", spec)) {
6392
- return new _RpcProvider({ ...optionsOrProvider, specVersion: "0.7" });
6397
+ return new this({ ...optionsOrProvider, specVersion: "0.7" });
6393
6398
  }
6394
6399
  if (isVersion("0.8", spec)) {
6395
- return new _RpcProvider({ ...optionsOrProvider, specVersion: "0.8" });
6400
+ return new this({ ...optionsOrProvider, specVersion: "0.8" });
6396
6401
  }
6397
- throw new Error("unable to detect specification version");
6402
+ throw new LibraryError("Unable to detect specification version");
6398
6403
  }
6399
6404
  fetch(method, params, id = 0) {
6400
6405
  return this.channel.fetch(method, params, id);
@@ -6916,9 +6921,9 @@ var StarknetIdContract = {
6916
6921
  };
6917
6922
  function getStarknetIdContract(chainId) {
6918
6923
  switch (chainId) {
6919
- case "0x534e5f4d41494e" /* SN_MAIN */:
6924
+ case _StarknetChainId.SN_MAIN:
6920
6925
  return StarknetIdContract.MAINNET;
6921
- case "0x534e5f5345504f4c4941" /* SN_SEPOLIA */:
6926
+ case _StarknetChainId.SN_SEPOLIA:
6922
6927
  return StarknetIdContract.TESTNET_SEPOLIA;
6923
6928
  default:
6924
6929
  throw new Error("Starknet.id is not yet deployed on this network");
@@ -6930,9 +6935,9 @@ var StarknetIdIdentityContract = {
6930
6935
  };
6931
6936
  function getStarknetIdIdentityContract(chainId) {
6932
6937
  switch (chainId) {
6933
- case "0x534e5f4d41494e" /* SN_MAIN */:
6938
+ case _StarknetChainId.SN_MAIN:
6934
6939
  return StarknetIdIdentityContract.MAINNET;
6935
- case "0x534e5f5345504f4c4941" /* SN_SEPOLIA */:
6940
+ case _StarknetChainId.SN_SEPOLIA:
6936
6941
  return StarknetIdIdentityContract.TESTNET_SEPOLIA;
6937
6942
  default:
6938
6943
  throw new Error("Starknet.id verifier contract is not yet deployed on this network");
@@ -6941,9 +6946,9 @@ function getStarknetIdIdentityContract(chainId) {
6941
6946
  var StarknetIdMulticallContract = "0x034ffb8f4452df7a613a0210824d6414dbadcddce6c6e19bf4ddc9e22ce5f970";
6942
6947
  function getStarknetIdMulticallContract(chainId) {
6943
6948
  switch (chainId) {
6944
- case "0x534e5f4d41494e" /* SN_MAIN */:
6949
+ case _StarknetChainId.SN_MAIN:
6945
6950
  return StarknetIdMulticallContract;
6946
- case "0x534e5f5345504f4c4941" /* SN_SEPOLIA */:
6951
+ case _StarknetChainId.SN_SEPOLIA:
6947
6952
  return StarknetIdMulticallContract;
6948
6953
  default:
6949
6954
  throw new Error("Starknet.id multicall contract is not yet deployed on this network");
@@ -6955,9 +6960,9 @@ var StarknetIdVerifierContract = {
6955
6960
  };
6956
6961
  function getStarknetIdVerifierContract(chainId) {
6957
6962
  switch (chainId) {
6958
- case "0x534e5f4d41494e" /* SN_MAIN */:
6963
+ case _StarknetChainId.SN_MAIN:
6959
6964
  return StarknetIdVerifierContract.MAINNET;
6960
- case "0x534e5f5345504f4c4941" /* SN_SEPOLIA */:
6965
+ case _StarknetChainId.SN_SEPOLIA:
6961
6966
  return StarknetIdVerifierContract.TESTNET_SEPOLIA;
6962
6967
  default:
6963
6968
  throw new Error("Starknet.id verifier contract is not yet deployed on this network");
@@ -6969,9 +6974,9 @@ var StarknetIdPfpContract = {
6969
6974
  };
6970
6975
  function getStarknetIdPfpContract(chainId) {
6971
6976
  switch (chainId) {
6972
- case "0x534e5f4d41494e" /* SN_MAIN */:
6977
+ case _StarknetChainId.SN_MAIN:
6973
6978
  return StarknetIdPfpContract.MAINNET;
6974
- case "0x534e5f5345504f4c4941" /* SN_SEPOLIA */:
6979
+ case _StarknetChainId.SN_SEPOLIA:
6975
6980
  return StarknetIdPfpContract.TESTNET_SEPOLIA;
6976
6981
  default:
6977
6982
  throw new Error(
@@ -6985,9 +6990,9 @@ var StarknetIdPopContract = {
6985
6990
  };
6986
6991
  function getStarknetIdPopContract(chainId) {
6987
6992
  switch (chainId) {
6988
- case "0x534e5f4d41494e" /* SN_MAIN */:
6993
+ case _StarknetChainId.SN_MAIN:
6989
6994
  return StarknetIdPopContract.MAINNET;
6990
- case "0x534e5f5345504f4c4941" /* SN_SEPOLIA */:
6995
+ case _StarknetChainId.SN_SEPOLIA:
6991
6996
  return StarknetIdPopContract.TESTNET_SEPOLIA;
6992
6997
  default:
6993
6998
  throw new Error(
@@ -8534,9 +8539,9 @@ function buildExecuteFromOutsideCall(outsideTransaction) {
8534
8539
  const myOutsideTransactions = Array.isArray(outsideTransaction) ? outsideTransaction : [outsideTransaction];
8535
8540
  const multiCall = myOutsideTransactions.map((outsideTx) => {
8536
8541
  let entrypoint;
8537
- if (outsideTx.version === "1" /* V1 */) {
8542
+ if (outsideTx.version === OutsideExecutionVersion.V1) {
8538
8543
  entrypoint = "execute_from_outside";
8539
- } else if (outsideTx.version === "2" /* V2 */) {
8544
+ } else if (outsideTx.version === OutsideExecutionVersion.V2) {
8540
8545
  entrypoint = "execute_from_outside_v2";
8541
8546
  } else {
8542
8547
  throw new Error("Unsupported OutsideExecution version");
@@ -8589,6 +8594,12 @@ var Account = class extends RpcProvider2 {
8589
8594
  channel: this.channel.id
8590
8595
  });
8591
8596
  }
8597
+ /** @deprecated @hidden */
8598
+ // The deprecation tag is meant to discourage use, not to signal future removal
8599
+ // it should only be removed if the relationship with the corresponding Provider.create(...) method changes
8600
+ static async create() {
8601
+ throw new LibraryError("Not supported");
8602
+ }
8592
8603
  // provided version or contract based preferred transactionVersion
8593
8604
  getPreferredVersion(type12, type3) {
8594
8605
  if (this.transactionVersion === ETransactionVersion2.V3) return type3;
@@ -8953,12 +8964,12 @@ var Account = class extends RpcProvider2 {
8953
8964
  */
8954
8965
  async getSnip9Version() {
8955
8966
  if (await supportsInterface(this, this.address, SNIP9_V2_INTERFACE_ID)) {
8956
- return "2" /* V2 */;
8967
+ return OutsideExecutionVersion.V2;
8957
8968
  }
8958
8969
  if (await supportsInterface(this, this.address, SNIP9_V1_INTERFACE_ID)) {
8959
- return "1" /* V1 */;
8970
+ return OutsideExecutionVersion.V1;
8960
8971
  }
8961
- return "0" /* UNSUPPORTED */;
8972
+ return OutsideExecutionVersion.UNSUPPORTED;
8962
8973
  }
8963
8974
  /**
8964
8975
  * Verify if a SNIP-9 nonce has not yet been used by the account.