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.mjs CHANGED
@@ -21,7 +21,7 @@ var constants_exports = {};
21
21
  __export(constants_exports, {
22
22
  ADDR_BOUND: () => ADDR_BOUND,
23
23
  API_VERSION: () => API_VERSION,
24
- BaseUrl: () => BaseUrl,
24
+ BaseUrl: () => _BaseUrl,
25
25
  DEFAULT_GLOBAL_CONFIG: () => DEFAULT_GLOBAL_CONFIG,
26
26
  HARDENING_4BYTES: () => HARDENING_4BYTES,
27
27
  HARDENING_BYTE: () => HARDENING_BYTE,
@@ -29,7 +29,7 @@ __export(constants_exports, {
29
29
  MASK_250: () => MASK_250,
30
30
  MASK_31: () => MASK_31,
31
31
  MAX_STORAGE_ITEM_SIZE: () => MAX_STORAGE_ITEM_SIZE,
32
- NetworkName: () => NetworkName,
32
+ NetworkName: () => _NetworkName,
33
33
  OutsideExecutionCallerAny: () => OutsideExecutionCallerAny,
34
34
  PRIME: () => PRIME,
35
35
  RANGE_FELT: () => RANGE_FELT,
@@ -39,11 +39,11 @@ __export(constants_exports, {
39
39
  SNIP9_V1_INTERFACE_ID: () => SNIP9_V1_INTERFACE_ID,
40
40
  SNIP9_V2_INTERFACE_ID: () => SNIP9_V2_INTERFACE_ID,
41
41
  SYSTEM_MESSAGES: () => SYSTEM_MESSAGES,
42
- StarknetChainId: () => StarknetChainId,
43
- SupportedRpcVersion: () => SupportedRpcVersion,
42
+ StarknetChainId: () => _StarknetChainId,
43
+ SupportedRpcVersion: () => _SupportedRpcVersion,
44
44
  TEXT_TO_FELT_MAX_LEN: () => TEXT_TO_FELT_MAX_LEN,
45
45
  TRANSACTION_VERSION: () => TRANSACTION_VERSION,
46
- TransactionHashPrefix: () => TransactionHashPrefix,
46
+ TransactionHashPrefix: () => _TransactionHashPrefix,
47
47
  UDC: () => UDC,
48
48
  ZERO: () => ZERO
49
49
  });
@@ -158,29 +158,6 @@ var range = (min, max) => ({ min, max });
158
158
  var RANGE_FELT = range(ZERO, PRIME - 1n);
159
159
  var RANGE_I128 = range(-(2n ** 127n), 2n ** 127n - 1n);
160
160
  var RANGE_U128 = range(ZERO, 2n ** 128n - 1n);
161
- var BaseUrl = /* @__PURE__ */ ((BaseUrl2) => {
162
- BaseUrl2["SN_MAIN"] = "https://alpha-mainnet.starknet.io";
163
- BaseUrl2["SN_SEPOLIA"] = "https://alpha-sepolia.starknet.io";
164
- return BaseUrl2;
165
- })(BaseUrl || {});
166
- var NetworkName = /* @__PURE__ */ ((NetworkName2) => {
167
- NetworkName2["SN_MAIN"] = "SN_MAIN";
168
- NetworkName2["SN_SEPOLIA"] = "SN_SEPOLIA";
169
- return NetworkName2;
170
- })(NetworkName || {});
171
- var StarknetChainId = /* @__PURE__ */ ((StarknetChainId6) => {
172
- StarknetChainId6["SN_MAIN"] = "0x534e5f4d41494e";
173
- StarknetChainId6["SN_SEPOLIA"] = "0x534e5f5345504f4c4941";
174
- return StarknetChainId6;
175
- })(StarknetChainId || {});
176
- var TransactionHashPrefix = /* @__PURE__ */ ((TransactionHashPrefix2) => {
177
- TransactionHashPrefix2["DECLARE"] = "0x6465636c617265";
178
- TransactionHashPrefix2["DEPLOY"] = "0x6465706c6f79";
179
- TransactionHashPrefix2["DEPLOY_ACCOUNT"] = "0x6465706c6f795f6163636f756e74";
180
- TransactionHashPrefix2["INVOKE"] = "0x696e766f6b65";
181
- TransactionHashPrefix2["L1_HANDLER"] = "0x6c315f68616e646c6572";
182
- return TransactionHashPrefix2;
183
- })(TransactionHashPrefix || {});
184
161
  var UDC = {
185
162
  ADDRESS: "0x041a78e741e5af2fec34b695679bc6891742439f7afb8484ecd7766661ad02bf",
186
163
  ENTRYPOINT: "deployContract"
@@ -190,9 +167,37 @@ var SNIP9_V1_INTERFACE_ID = "0x68cfd18b92d1907b8ba3cc324900277f5a3622099431ea85d
190
167
  var SNIP9_V2_INTERFACE_ID = "0x1d1144bb2138366ff28d8e9ab57456b1d332ac42196230c3a602003c89872";
191
168
  var HARDENING_BYTE = 128;
192
169
  var HARDENING_4BYTES = 2147483648n;
193
- var SupportedRpcVersion = {
170
+ var _BaseUrl = {
171
+ SN_MAIN: "https://alpha-mainnet.starknet.io",
172
+ SN_SEPOLIA: "https://alpha-sepolia.starknet.io"
173
+ };
174
+ var _NetworkName = {
175
+ SN_MAIN: "SN_MAIN",
176
+ SN_SEPOLIA: "SN_SEPOLIA"
177
+ };
178
+ var _StarknetChainId = {
179
+ SN_MAIN: "0x534e5f4d41494e",
180
+ // encodeShortString('SN_MAIN'),
181
+ SN_SEPOLIA: "0x534e5f5345504f4c4941"
182
+ // encodeShortString('SN_SEPOLIA')
183
+ };
184
+ var _TransactionHashPrefix = {
185
+ DECLARE: "0x6465636c617265",
186
+ // encodeShortString('declare'),
187
+ DEPLOY: "0x6465706c6f79",
188
+ // encodeShortString('deploy'),
189
+ DEPLOY_ACCOUNT: "0x6465706c6f795f6163636f756e74",
190
+ // encodeShortString('deploy_account'),
191
+ INVOKE: "0x696e766f6b65",
192
+ // encodeShortString('invoke'),
193
+ L1_HANDLER: "0x6c315f68616e646c6572"
194
+ // encodeShortString('l1_handler'),
195
+ };
196
+ var _SupportedRpcVersion = {
194
197
  0.7: "0.7",
195
- 0.8: "0.8"
198
+ 0.8: "0.8",
199
+ v07: "0.7",
200
+ v08: "0.8"
196
201
  };
197
202
  var DEFAULT_GLOBAL_CONFIG = {
198
203
  legacyMode: false,
@@ -493,12 +498,11 @@ var OutsideExecutionTypesV2 = {
493
498
  { name: "Calldata", type: "felt*" }
494
499
  ]
495
500
  };
496
- var OutsideExecutionVersion = /* @__PURE__ */ ((OutsideExecutionVersion2) => {
497
- OutsideExecutionVersion2["UNSUPPORTED"] = "0";
498
- OutsideExecutionVersion2["V1"] = "1";
499
- OutsideExecutionVersion2["V2"] = "2";
500
- return OutsideExecutionVersion2;
501
- })(OutsideExecutionVersion || {});
501
+ var OutsideExecutionVersion = {
502
+ UNSUPPORTED: "0",
503
+ V1: "1",
504
+ V2: "2"
505
+ };
502
506
 
503
507
  // src/types/typedData.ts
504
508
  import {
@@ -2990,7 +2994,7 @@ function calculateTransactionHashCommon(txHashPrefix, version, contractAddress,
2990
2994
  }
2991
2995
  function calculateDeclareTransactionHash(classHash, senderAddress, version, maxFee, chainId, nonce, compiledClassHash) {
2992
2996
  return calculateTransactionHashCommon(
2993
- "0x6465636c617265" /* DECLARE */,
2997
+ _TransactionHashPrefix.DECLARE,
2994
2998
  version,
2995
2999
  senderAddress,
2996
3000
  0,
@@ -3003,7 +3007,7 @@ function calculateDeclareTransactionHash(classHash, senderAddress, version, maxF
3003
3007
  function calculateDeployAccountTransactionHash(contractAddress, classHash, constructorCalldata, salt, version, maxFee, chainId, nonce) {
3004
3008
  const calldata = [classHash, salt, ...constructorCalldata];
3005
3009
  return calculateTransactionHashCommon(
3006
- "0x6465706c6f795f6163636f756e74" /* DEPLOY_ACCOUNT */,
3010
+ _TransactionHashPrefix.DEPLOY_ACCOUNT,
3007
3011
  version,
3008
3012
  contractAddress,
3009
3013
  0,
@@ -3015,7 +3019,7 @@ function calculateDeployAccountTransactionHash(contractAddress, classHash, const
3015
3019
  }
3016
3020
  function calculateTransactionHash(contractAddress, version, calldata, maxFee, chainId, nonce) {
3017
3021
  return calculateTransactionHashCommon(
3018
- "0x696e766f6b65" /* INVOKE */,
3022
+ _TransactionHashPrefix.INVOKE,
3019
3023
  version,
3020
3024
  contractAddress,
3021
3025
  0,
@@ -3028,7 +3032,7 @@ function calculateTransactionHash(contractAddress, version, calldata, maxFee, ch
3028
3032
  function calculateL2MessageTxHash(l1FromAddress, l2ToAddress, l2Selector, l2Calldata, l2ChainId, l1Nonce) {
3029
3033
  const payload = [l1FromAddress, ...l2Calldata];
3030
3034
  return calculateTransactionHashCommon(
3031
- "0x6c315f68616e646c6572" /* L1_HANDLER */,
3035
+ _TransactionHashPrefix.L1_HANDLER,
3032
3036
  0,
3033
3037
  l2ToAddress,
3034
3038
  getSelector(l2Selector),
@@ -3103,7 +3107,7 @@ function calculateTransactionHashCommon2(txHashPrefix, version, senderAddress, c
3103
3107
  }
3104
3108
  function calculateDeployAccountTransactionHash2(contractAddress, classHash, compiledConstructorCalldata, salt, version, chainId, nonce, nonceDataAvailabilityMode, feeDataAvailabilityMode, resourceBounds, tip, paymasterData) {
3105
3109
  return calculateTransactionHashCommon2(
3106
- "0x6465706c6f795f6163636f756e74" /* DEPLOY_ACCOUNT */,
3110
+ _TransactionHashPrefix.DEPLOY_ACCOUNT,
3107
3111
  version,
3108
3112
  contractAddress,
3109
3113
  chainId,
@@ -3118,7 +3122,7 @@ function calculateDeployAccountTransactionHash2(contractAddress, classHash, comp
3118
3122
  }
3119
3123
  function calculateDeclareTransactionHash2(classHash, compiledClassHash, senderAddress, version, chainId, nonce, accountDeploymentData, nonceDataAvailabilityMode, feeDataAvailabilityMode, resourceBounds, tip, paymasterData) {
3120
3124
  return calculateTransactionHashCommon2(
3121
- "0x6465636c617265" /* DECLARE */,
3125
+ _TransactionHashPrefix.DECLARE,
3122
3126
  version,
3123
3127
  senderAddress,
3124
3128
  chainId,
@@ -3133,7 +3137,7 @@ function calculateDeclareTransactionHash2(classHash, compiledClassHash, senderAd
3133
3137
  }
3134
3138
  function calculateInvokeTransactionHash(senderAddress, version, compiledCalldata, chainId, nonce, accountDeploymentData, nonceDataAvailabilityMode, feeDataAvailabilityMode, resourceBounds, tip, paymasterData) {
3135
3139
  return calculateTransactionHashCommon2(
3136
- "0x696e766f6b65" /* INVOKE */,
3140
+ _TransactionHashPrefix.INVOKE,
3137
3141
  version,
3138
3142
  senderAddress,
3139
3143
  chainId,
@@ -3851,7 +3855,7 @@ var getDefaultNodeUrl = (networkName, mute = false, rpcVersion) => {
3851
3855
  logger.info("Using default public node url, please provide nodeUrl in provider options!");
3852
3856
  }
3853
3857
  const rpcNodes = getDefaultNodes(rpcVersion ?? config.get("rpcVersion"));
3854
- const nodes = rpcNodes[networkName ?? "SN_SEPOLIA" /* SN_SEPOLIA */];
3858
+ const nodes = rpcNodes[networkName ?? _NetworkName.SN_SEPOLIA];
3855
3859
  const randIdx = Math.floor(Math.random() * nodes.length);
3856
3860
  return nodes[randIdx];
3857
3861
  };
@@ -4110,7 +4114,7 @@ var RpcChannel = class {
4110
4114
  transactionRetryIntervalFallback,
4111
4115
  waitMode
4112
4116
  } = optionsOrProvider || {};
4113
- if (Object.values(NetworkName).includes(nodeUrl)) {
4117
+ if (Object.values(_NetworkName).includes(nodeUrl)) {
4114
4118
  this.nodeUrl = getDefaultNodeUrl(nodeUrl, optionsOrProvider?.default, "0.7");
4115
4119
  } else if (nodeUrl) {
4116
4120
  this.nodeUrl = nodeUrl;
@@ -4716,7 +4720,7 @@ var RpcChannel2 = class {
4716
4720
  transactionRetryIntervalFallback,
4717
4721
  waitMode
4718
4722
  } = optionsOrProvider || {};
4719
- if (Object.values(NetworkName).includes(nodeUrl)) {
4723
+ if (Object.values(_NetworkName).includes(nodeUrl)) {
4720
4724
  this.nodeUrl = getDefaultNodeUrl(nodeUrl, optionsOrProvider?.default, "0.8");
4721
4725
  } else if (nodeUrl) {
4722
4726
  this.nodeUrl = nodeUrl;
@@ -6228,7 +6232,7 @@ function verifyMessage(message, signature, fullPublicKey, accountAddress) {
6228
6232
  }
6229
6233
 
6230
6234
  // src/provider/rpc.ts
6231
- var RpcProvider = class _RpcProvider {
6235
+ var RpcProvider = class {
6232
6236
  responseParser;
6233
6237
  channel;
6234
6238
  constructor(optionsOrProvider) {
@@ -6255,16 +6259,17 @@ var RpcProvider = class _RpcProvider {
6255
6259
  * auto configure channel based on provided node
6256
6260
  * leave space for other async before constructor
6257
6261
  */
6262
+ // NOTE: the generic T and 'this' reference are used so that the expanded class is generated when a mixin is applied
6258
6263
  static async create(optionsOrProvider) {
6259
6264
  const channel = new rpc_0_7_exports.RpcChannel({ ...optionsOrProvider });
6260
6265
  const spec = await channel.getSpecVersion();
6261
6266
  if (isVersion("0.7", spec)) {
6262
- return new _RpcProvider({ ...optionsOrProvider, specVersion: "0.7" });
6267
+ return new this({ ...optionsOrProvider, specVersion: "0.7" });
6263
6268
  }
6264
6269
  if (isVersion("0.8", spec)) {
6265
- return new _RpcProvider({ ...optionsOrProvider, specVersion: "0.8" });
6270
+ return new this({ ...optionsOrProvider, specVersion: "0.8" });
6266
6271
  }
6267
- throw new Error("unable to detect specification version");
6272
+ throw new LibraryError("Unable to detect specification version");
6268
6273
  }
6269
6274
  fetch(method, params, id = 0) {
6270
6275
  return this.channel.fetch(method, params, id);
@@ -6786,9 +6791,9 @@ var StarknetIdContract = {
6786
6791
  };
6787
6792
  function getStarknetIdContract(chainId) {
6788
6793
  switch (chainId) {
6789
- case "0x534e5f4d41494e" /* SN_MAIN */:
6794
+ case _StarknetChainId.SN_MAIN:
6790
6795
  return StarknetIdContract.MAINNET;
6791
- case "0x534e5f5345504f4c4941" /* SN_SEPOLIA */:
6796
+ case _StarknetChainId.SN_SEPOLIA:
6792
6797
  return StarknetIdContract.TESTNET_SEPOLIA;
6793
6798
  default:
6794
6799
  throw new Error("Starknet.id is not yet deployed on this network");
@@ -6800,9 +6805,9 @@ var StarknetIdIdentityContract = {
6800
6805
  };
6801
6806
  function getStarknetIdIdentityContract(chainId) {
6802
6807
  switch (chainId) {
6803
- case "0x534e5f4d41494e" /* SN_MAIN */:
6808
+ case _StarknetChainId.SN_MAIN:
6804
6809
  return StarknetIdIdentityContract.MAINNET;
6805
- case "0x534e5f5345504f4c4941" /* SN_SEPOLIA */:
6810
+ case _StarknetChainId.SN_SEPOLIA:
6806
6811
  return StarknetIdIdentityContract.TESTNET_SEPOLIA;
6807
6812
  default:
6808
6813
  throw new Error("Starknet.id verifier contract is not yet deployed on this network");
@@ -6811,9 +6816,9 @@ function getStarknetIdIdentityContract(chainId) {
6811
6816
  var StarknetIdMulticallContract = "0x034ffb8f4452df7a613a0210824d6414dbadcddce6c6e19bf4ddc9e22ce5f970";
6812
6817
  function getStarknetIdMulticallContract(chainId) {
6813
6818
  switch (chainId) {
6814
- case "0x534e5f4d41494e" /* SN_MAIN */:
6819
+ case _StarknetChainId.SN_MAIN:
6815
6820
  return StarknetIdMulticallContract;
6816
- case "0x534e5f5345504f4c4941" /* SN_SEPOLIA */:
6821
+ case _StarknetChainId.SN_SEPOLIA:
6817
6822
  return StarknetIdMulticallContract;
6818
6823
  default:
6819
6824
  throw new Error("Starknet.id multicall contract is not yet deployed on this network");
@@ -6825,9 +6830,9 @@ var StarknetIdVerifierContract = {
6825
6830
  };
6826
6831
  function getStarknetIdVerifierContract(chainId) {
6827
6832
  switch (chainId) {
6828
- case "0x534e5f4d41494e" /* SN_MAIN */:
6833
+ case _StarknetChainId.SN_MAIN:
6829
6834
  return StarknetIdVerifierContract.MAINNET;
6830
- case "0x534e5f5345504f4c4941" /* SN_SEPOLIA */:
6835
+ case _StarknetChainId.SN_SEPOLIA:
6831
6836
  return StarknetIdVerifierContract.TESTNET_SEPOLIA;
6832
6837
  default:
6833
6838
  throw new Error("Starknet.id verifier contract is not yet deployed on this network");
@@ -6839,9 +6844,9 @@ var StarknetIdPfpContract = {
6839
6844
  };
6840
6845
  function getStarknetIdPfpContract(chainId) {
6841
6846
  switch (chainId) {
6842
- case "0x534e5f4d41494e" /* SN_MAIN */:
6847
+ case _StarknetChainId.SN_MAIN:
6843
6848
  return StarknetIdPfpContract.MAINNET;
6844
- case "0x534e5f5345504f4c4941" /* SN_SEPOLIA */:
6849
+ case _StarknetChainId.SN_SEPOLIA:
6845
6850
  return StarknetIdPfpContract.TESTNET_SEPOLIA;
6846
6851
  default:
6847
6852
  throw new Error(
@@ -6855,9 +6860,9 @@ var StarknetIdPopContract = {
6855
6860
  };
6856
6861
  function getStarknetIdPopContract(chainId) {
6857
6862
  switch (chainId) {
6858
- case "0x534e5f4d41494e" /* SN_MAIN */:
6863
+ case _StarknetChainId.SN_MAIN:
6859
6864
  return StarknetIdPopContract.MAINNET;
6860
- case "0x534e5f5345504f4c4941" /* SN_SEPOLIA */:
6865
+ case _StarknetChainId.SN_SEPOLIA:
6861
6866
  return StarknetIdPopContract.TESTNET_SEPOLIA;
6862
6867
  default:
6863
6868
  throw new Error(
@@ -8404,9 +8409,9 @@ function buildExecuteFromOutsideCall(outsideTransaction) {
8404
8409
  const myOutsideTransactions = Array.isArray(outsideTransaction) ? outsideTransaction : [outsideTransaction];
8405
8410
  const multiCall = myOutsideTransactions.map((outsideTx) => {
8406
8411
  let entrypoint;
8407
- if (outsideTx.version === "1" /* V1 */) {
8412
+ if (outsideTx.version === OutsideExecutionVersion.V1) {
8408
8413
  entrypoint = "execute_from_outside";
8409
- } else if (outsideTx.version === "2" /* V2 */) {
8414
+ } else if (outsideTx.version === OutsideExecutionVersion.V2) {
8410
8415
  entrypoint = "execute_from_outside_v2";
8411
8416
  } else {
8412
8417
  throw new Error("Unsupported OutsideExecution version");
@@ -8459,6 +8464,12 @@ var Account = class extends RpcProvider2 {
8459
8464
  channel: this.channel.id
8460
8465
  });
8461
8466
  }
8467
+ /** @deprecated @hidden */
8468
+ // The deprecation tag is meant to discourage use, not to signal future removal
8469
+ // it should only be removed if the relationship with the corresponding Provider.create(...) method changes
8470
+ static async create() {
8471
+ throw new LibraryError("Not supported");
8472
+ }
8462
8473
  // provided version or contract based preferred transactionVersion
8463
8474
  getPreferredVersion(type12, type3) {
8464
8475
  if (this.transactionVersion === ETransactionVersion2.V3) return type3;
@@ -8823,12 +8834,12 @@ var Account = class extends RpcProvider2 {
8823
8834
  */
8824
8835
  async getSnip9Version() {
8825
8836
  if (await supportsInterface(this, this.address, SNIP9_V2_INTERFACE_ID)) {
8826
- return "2" /* V2 */;
8837
+ return OutsideExecutionVersion.V2;
8827
8838
  }
8828
8839
  if (await supportsInterface(this, this.address, SNIP9_V1_INTERFACE_ID)) {
8829
- return "1" /* V1 */;
8840
+ return OutsideExecutionVersion.V1;
8830
8841
  }
8831
- return "0" /* UNSUPPORTED */;
8842
+ return OutsideExecutionVersion.UNSUPPORTED;
8832
8843
  }
8833
8844
  /**
8834
8845
  * Verify if a SNIP-9 nonce has not yet been used by the account.