starknet 10.6.8 → 10.7.1

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
@@ -192,6 +192,7 @@ __export(index_exports, {
192
192
  starknetIdPlugin: () => starknetId,
193
193
  toAnyPatchVersion: () => toAnyPatchVersion,
194
194
  toApiVersion: () => toApiVersion,
195
+ toReleaseVersion: () => toReleaseVersion,
195
196
  transaction: () => transaction_exports,
196
197
  typedData: () => typedData_exports,
197
198
  uint256: () => uint256_exports,
@@ -5510,13 +5511,16 @@ function toAnyPatchVersion(version) {
5510
5511
  }
5511
5512
  return `${parts[0]}.${parts[1]}.*`;
5512
5513
  }
5514
+ function toReleaseVersion(version) {
5515
+ return version.split(/[-+]/)[0];
5516
+ }
5513
5517
  function toApiVersion(version) {
5514
5518
  const [major, minor] = version.replace(/^v/, "").split(".");
5515
5519
  return `v${major}_${minor}`;
5516
5520
  }
5517
5521
  function compareVersions(a, b) {
5518
- const aParts = a.split(".").map(Number);
5519
- const bParts = b.split(".").map(Number);
5522
+ const aParts = toReleaseVersion(a).split(".").map(Number);
5523
+ const bParts = toReleaseVersion(b).split(".").map(Number);
5520
5524
  const maxLen = Math.max(aParts.length, bParts.length);
5521
5525
  for (let i = 0; i < maxLen; i += 1) {
5522
5526
  const aNum = aParts[i] || 0;
@@ -6274,7 +6278,7 @@ var RpcChannel = class {
6274
6278
  this.chainId = chainId;
6275
6279
  this.headers = { ...channelDefaults.options.headers, ...headers };
6276
6280
  this.retries = retries ?? channelDefaults.options.retries;
6277
- this.specVersion = specVersion;
6281
+ this.specVersion = specVersion ? toReleaseVersion(specVersion) : void 0;
6278
6282
  this.transactionRetryIntervalFallback = transactionRetryIntervalFallback ?? channelDefaults.options.transactionRetryIntervalFallback;
6279
6283
  this.waitMode = waitMode ?? false;
6280
6284
  this.requestId = 0;
@@ -6362,18 +6366,19 @@ var RpcChannel = class {
6362
6366
  */
6363
6367
  async setUpSpecVersion() {
6364
6368
  if (!this.specVersion) {
6365
- const unknownSpecVersion = await this.fetchEndpoint("starknet_specVersion");
6366
- if (!isVersion(this.channelSpecVersion, unknownSpecVersion)) {
6369
+ const nodeSpecVersion = await this.fetchEndpoint("starknet_specVersion");
6370
+ const specVersion = toReleaseVersion(nodeSpecVersion);
6371
+ if (!isVersion(this.channelSpecVersion, specVersion)) {
6367
6372
  logger.error(SYSTEM_MESSAGES.channelVersionMismatch, {
6368
6373
  channelId: this.id,
6369
6374
  channelSpecVersion: this.channelSpecVersion,
6370
- nodeSpecVersion: this.specVersion
6375
+ nodeSpecVersion
6371
6376
  });
6372
6377
  }
6373
- if (!isSupportedSpecVersion(unknownSpecVersion)) {
6378
+ if (!isSupportedSpecVersion(specVersion)) {
6374
6379
  throw new LibraryError(`${SYSTEM_MESSAGES.unsupportedSpecVersion}, channelId: ${this.id}`);
6375
6380
  }
6376
- this.specVersion = unknownSpecVersion;
6381
+ this.specVersion = specVersion;
6377
6382
  }
6378
6383
  return this.specVersion;
6379
6384
  }
@@ -6835,7 +6840,7 @@ var RpcChannel2 = class {
6835
6840
  this.chainId = chainId;
6836
6841
  this.headers = { ...channelDefaults.options.headers, ...headers };
6837
6842
  this.retries = retries ?? channelDefaults.options.retries;
6838
- this.specVersion = specVersion;
6843
+ this.specVersion = specVersion ? toReleaseVersion(specVersion) : void 0;
6839
6844
  this.transactionRetryIntervalFallback = transactionRetryIntervalFallback ?? channelDefaults.options.transactionRetryIntervalFallback;
6840
6845
  this.waitMode = waitMode ?? false;
6841
6846
  this.requestId = 0;
@@ -6923,18 +6928,19 @@ var RpcChannel2 = class {
6923
6928
  */
6924
6929
  async setUpSpecVersion() {
6925
6930
  if (!this.specVersion) {
6926
- const unknownSpecVersion = await this.fetchEndpoint("starknet_specVersion");
6927
- if (!isVersion("0.10", unknownSpecVersion)) {
6931
+ const nodeSpecVersion = await this.fetchEndpoint("starknet_specVersion");
6932
+ const specVersion = toReleaseVersion(nodeSpecVersion);
6933
+ if (!isVersion("0.10", specVersion)) {
6928
6934
  logger.error(SYSTEM_MESSAGES.channelVersionMismatch, {
6929
6935
  channelId: this.id,
6930
6936
  channelSpecVersion: this.channelSpecVersion,
6931
- nodeSpecVersion: this.specVersion
6937
+ nodeSpecVersion
6932
6938
  });
6933
6939
  }
6934
- if (!isSupportedSpecVersion(unknownSpecVersion)) {
6940
+ if (!isSupportedSpecVersion(specVersion)) {
6935
6941
  throw new LibraryError(`${SYSTEM_MESSAGES.unsupportedSpecVersion}, channelId: ${this.id}`);
6936
6942
  }
6937
- this.specVersion = unknownSpecVersion;
6943
+ this.specVersion = specVersion;
6938
6944
  }
6939
6945
  return this.specVersion;
6940
6946
  }
@@ -9888,16 +9894,17 @@ var RpcProvider = class {
9888
9894
  static async create(optionsOrProvider) {
9889
9895
  const channel = new rpc_0_9_0_exports.RpcChannel({ ...optionsOrProvider });
9890
9896
  const spec = await channel.getSpecVersion();
9891
- if (!isSupportedSpecVersion(spec)) {
9897
+ const specVersion = toReleaseVersion(spec);
9898
+ if (!isSupportedSpecVersion(specVersion)) {
9892
9899
  logger.warn(`Using incompatible node spec version ${spec}`);
9893
9900
  }
9894
- if (isVersion("0.9", spec)) {
9901
+ if (isVersion("0.9", specVersion)) {
9895
9902
  return new this({
9896
9903
  ...optionsOrProvider,
9897
9904
  specVersion: _SupportedRpcVersion.v0_9_0
9898
9905
  });
9899
9906
  }
9900
- if (isVersion("0.10", spec)) {
9907
+ if (isVersion("0.10", specVersion)) {
9901
9908
  return new this({
9902
9909
  ...optionsOrProvider,
9903
9910
  specVersion: _SupportedRpcVersion.v0_10_3
@@ -13111,7 +13118,7 @@ function fromWalletApiCall(call) {
13111
13118
  }
13112
13119
  function toWalletApiActions(actions) {
13113
13120
  return actions.map(
13114
- (action) => action.type === "subaccount_invoke" ? { ...action, calls: action.calls.map(toWalletApiCall) } : action
13121
+ (action) => action.type === "shadow_account_invoke" ? { ...action, calls: action.calls.map(toWalletApiCall) } : action
13115
13122
  );
13116
13123
  }
13117
13124
 
@@ -13130,7 +13137,7 @@ __export(connectV6_exports, {
13130
13137
  strk20Balances: () => strk20Balances,
13131
13138
  strk20InvokeTransaction: () => strk20InvokeTransaction,
13132
13139
  strk20PrepareInvoke: () => strk20PrepareInvoke,
13133
- strk20SubaccountCommitment: () => strk20SubaccountCommitment,
13140
+ strk20ShadowAccountCommitment: () => strk20ShadowAccountCommitment,
13134
13141
  subscribeWalletEvent: () => subscribeWalletEvent2,
13135
13142
  supportedSpecs: () => supportedSpecs3,
13136
13143
  supportedWalletApi: () => supportedWalletApi3,
@@ -13218,9 +13225,9 @@ function strk20InvokeTransaction(walletWSF, actions) {
13218
13225
  params: { actions }
13219
13226
  });
13220
13227
  }
13221
- function strk20SubaccountCommitment(walletWSF, dapp_name, nonce) {
13228
+ function strk20ShadowAccountCommitment(walletWSF, dapp_name, nonce) {
13222
13229
  return walletWSF.features["starknet:walletApi"].request({
13223
- type: "wallet_strk20SubaccountCommitment",
13230
+ type: "wallet_strk20ShadowAccountCommitment",
13224
13231
  params: { dapp_name, nonce }
13225
13232
  });
13226
13233
  }
@@ -13312,25 +13319,25 @@ var WalletAccountV6 = class _WalletAccountV6 extends WalletAccountV5 {
13312
13319
  return strk20InvokeTransaction(this.v6Provider, toWalletApiActions(actions));
13313
13320
  }
13314
13321
  /**
13315
- * Compute the commitment of a DAPP STRK20 sub-account. The commitment is computed
13322
+ * Compute the commitment of a DAPP STRK20 shadow account. The commitment is computed
13316
13323
  * locally by the wallet from the user private state ; no transaction is sent.
13317
13324
  *
13318
- * When `nonce` is given, the full commitment of this single sub-account is returned.
13325
+ * When `nonce` is given, the full commitment of this single shadow account is returned.
13319
13326
  * When `nonce` is omitted, the partial (nonce independent) commitment is returned
13320
- * instead : it is shared by every sub-account the user derives for this DAPP, so it can
13321
- * be published once to let a DAPP recognize all the sub-accounts of a user without
13322
- * learning any individual nonce.
13323
- * @param {STRK20_DAPP_NAME} dappName - The DAPP that scopes the sub-account(s).
13324
- * @param {FELT} [nonce] - The sub-account nonce ; each nonce selects a distinct sub-account for this user + DAPP. Omit it to get the partial commitment.
13325
- * @returns {Promise<FELT>} The sub-account commitment.
13327
+ * instead : it is shared by every shadow account the user derives for this DAPP, so it
13328
+ * can be published once to let a DAPP recognize all the shadow accounts of a user
13329
+ * without learning any individual nonce.
13330
+ * @param {STRK20_DAPP_NAME} dappName - The DAPP that scopes the shadow account(s).
13331
+ * @param {FELT} [nonce] - The shadow account nonce ; each nonce selects a distinct shadow account for this user + DAPP. Omit it to get the partial commitment.
13332
+ * @returns {Promise<FELT>} The shadow account commitment.
13326
13333
  * @example
13327
13334
  * ```typescript
13328
- * const commitment = await myWalletAccount.strk20SubaccountCommitment('myDapp', '0x0');
13335
+ * const commitment = await myWalletAccount.strk20ShadowAccountCommitment('myDapp', '0x0');
13329
13336
  * // commitment = '0x5f2e...'
13330
13337
  * ```
13331
13338
  */
13332
- strk20SubaccountCommitment(dappName, nonce) {
13333
- return strk20SubaccountCommitment(this.v6Provider, dappName, nonce);
13339
+ strk20ShadowAccountCommitment(dappName, nonce) {
13340
+ return strk20ShadowAccountCommitment(this.v6Provider, dappName, nonce);
13334
13341
  }
13335
13342
  static async connect(provider, walletProvider, cairoVersion, paymaster, silentMode = false) {
13336
13343
  const { accounts } = await standardConnect2(walletProvider, silentMode);
@@ -14147,6 +14154,7 @@ function units(amount, simbol = "fri") {
14147
14154
  starknetIdPlugin,
14148
14155
  toAnyPatchVersion,
14149
14156
  toApiVersion,
14157
+ toReleaseVersion,
14150
14158
  transaction,
14151
14159
  typedData,
14152
14160
  uint256,