starknet 10.3.2 → 10.4.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.
@@ -146,6 +146,7 @@ var starknet = (() => {
146
146
  ValidateType: () => ValidateType,
147
147
  WalletAccount: () => WalletAccount,
148
148
  WalletAccountV5: () => WalletAccountV5,
149
+ WalletAccountV6: () => WalletAccountV6,
149
150
  WebSocketChannel: () => WebSocketChannel,
150
151
  WebSocketNotConnectedError: () => WebSocketNotConnectedError,
151
152
  addAddressPadding: () => addAddressPadding,
@@ -215,7 +216,8 @@ var starknet = (() => {
215
216
  validateChecksumAddress: () => validateChecksumAddress,
216
217
  verifyMessageInStarknet: () => verifyMessageInStarknet,
217
218
  wallet: () => connect_exports,
218
- walletV5: () => connectV5_exports
219
+ walletV5: () => connectV5_exports,
220
+ walletV6: () => connectV6_exports
219
221
  });
220
222
 
221
223
  // src/global/constants.ts
@@ -5591,7 +5593,7 @@ ${indent}}` : "}";
5591
5593
  return addHexPrefix(this.toBigInt().toString(16));
5592
5594
  }
5593
5595
  toApiRequest() {
5594
- return addCompiledFlag([this.toHexString()]);
5596
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
5595
5597
  }
5596
5598
  static assertRange(val) {
5597
5599
  assert(val >= 0n && val < PRIME, `Value ${val} is out of felt252 range [0, ${PRIME})`);
@@ -6221,7 +6223,7 @@ ${indent}}` : "}";
6221
6223
  throw new Error("Invalid input type for CairoBytes31. Expected string, Buffer, or Uint8Array");
6222
6224
  }
6223
6225
  toApiRequest() {
6224
- return addCompiledFlag([this.toHexString()]);
6226
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
6225
6227
  }
6226
6228
  toBigInt() {
6227
6229
  return uint8ArrayToBigInt(this.data);
@@ -6424,7 +6426,7 @@ ${indent}}` : "}";
6424
6426
  return BigInt(data);
6425
6427
  }
6426
6428
  toApiRequest() {
6427
- return addCompiledFlag([this.toHexString()]);
6429
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
6428
6430
  }
6429
6431
  toBigInt() {
6430
6432
  return this.data;
@@ -6544,7 +6546,7 @@ ${indent}}` : "}";
6544
6546
  toApiRequest() {
6545
6547
  this.assertInitialized();
6546
6548
  return addCompiledFlag([
6547
- addHexPrefix(this.data.length.toString(16)),
6549
+ this.data.length.toString(),
6548
6550
  ...this.data.flatMap((bytes31) => bytes31.toApiRequest()),
6549
6551
  ...this.pending_word.toApiRequest(),
6550
6552
  ...this.pending_word_len.toApiRequest()
@@ -6697,7 +6699,7 @@ ${indent}}` : "}";
6697
6699
  return BigInt(data);
6698
6700
  }
6699
6701
  toApiRequest() {
6700
- return addCompiledFlag([this.toHexString()]);
6702
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
6701
6703
  }
6702
6704
  toBigInt() {
6703
6705
  return this.data;
@@ -6755,7 +6757,7 @@ ${indent}}` : "}";
6755
6757
  return BigInt(data);
6756
6758
  }
6757
6759
  toApiRequest() {
6758
- return addCompiledFlag([this.toHexString()]);
6760
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
6759
6761
  }
6760
6762
  toBigInt() {
6761
6763
  return this.data;
@@ -6813,7 +6815,7 @@ ${indent}}` : "}";
6813
6815
  return BigInt(data);
6814
6816
  }
6815
6817
  toApiRequest() {
6816
- return addCompiledFlag([this.toHexString()]);
6818
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
6817
6819
  }
6818
6820
  toBigInt() {
6819
6821
  return this.data;
@@ -6871,7 +6873,7 @@ ${indent}}` : "}";
6871
6873
  return BigInt(data);
6872
6874
  }
6873
6875
  toApiRequest() {
6874
- return addCompiledFlag([this.toHexString()]);
6876
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
6875
6877
  }
6876
6878
  toBigInt() {
6877
6879
  return this.data;
@@ -6929,7 +6931,7 @@ ${indent}}` : "}";
6929
6931
  return BigInt(data);
6930
6932
  }
6931
6933
  toApiRequest() {
6932
- return addCompiledFlag([this.toHexString()]);
6934
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
6933
6935
  }
6934
6936
  toBigInt() {
6935
6937
  return this.data;
@@ -6987,7 +6989,7 @@ ${indent}}` : "}";
6987
6989
  return BigInt(data);
6988
6990
  }
6989
6991
  toApiRequest() {
6990
- return addCompiledFlag([this.toHexString()]);
6992
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
6991
6993
  }
6992
6994
  toBigInt() {
6993
6995
  return this.data;
@@ -7059,7 +7061,7 @@ ${indent}}` : "}";
7059
7061
  return BigInt(data);
7060
7062
  }
7061
7063
  toApiRequest() {
7062
- return addCompiledFlag([this.toHexString()]);
7064
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
7063
7065
  }
7064
7066
  toBigInt() {
7065
7067
  return this.data;
@@ -7131,7 +7133,7 @@ ${indent}}` : "}";
7131
7133
  return BigInt(data);
7132
7134
  }
7133
7135
  toApiRequest() {
7134
- return addCompiledFlag([this.toHexString()]);
7136
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
7135
7137
  }
7136
7138
  toBigInt() {
7137
7139
  return this.data;
@@ -7203,7 +7205,7 @@ ${indent}}` : "}";
7203
7205
  return BigInt(data);
7204
7206
  }
7205
7207
  toApiRequest() {
7206
- return addCompiledFlag([this.toHexString()]);
7208
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
7207
7209
  }
7208
7210
  toBigInt() {
7209
7211
  return this.data;
@@ -7275,7 +7277,7 @@ ${indent}}` : "}";
7275
7277
  return BigInt(data);
7276
7278
  }
7277
7279
  toApiRequest() {
7278
- return addCompiledFlag([this.toHexString()]);
7280
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
7279
7281
  }
7280
7282
  toBigInt() {
7281
7283
  return this.data;
@@ -7439,7 +7441,7 @@ ${indent}}` : "}";
7439
7441
  return new CairoByteArray(val).toApiRequest();
7440
7442
  },
7441
7443
  [CairoFelt252.abiSelector]: (val) => {
7442
- return felt(val);
7444
+ return new CairoFelt252(val).toApiRequest();
7443
7445
  },
7444
7446
  [CairoUint256.abiSelector]: (val) => {
7445
7447
  return new CairoUint256(val).toApiRequest();
@@ -17585,6 +17587,7 @@ ${indent}}` : "}";
17585
17587
  requestChainId: () => requestChainId,
17586
17588
  signMessage: () => signMessage,
17587
17589
  supportedSpecs: () => supportedSpecs,
17590
+ supportedWalletApi: () => supportedWalletApi,
17588
17591
  switchStarknetChain: () => switchStarknetChain,
17589
17592
  watchAsset: () => watchAsset
17590
17593
  });
@@ -17627,6 +17630,9 @@ ${indent}}` : "}";
17627
17630
  function supportedSpecs(swo) {
17628
17631
  return swo.request({ type: "wallet_supportedSpecs" });
17629
17632
  }
17633
+ function supportedWalletApi(swo) {
17634
+ return swo.request({ type: "wallet_supportedWalletApi" });
17635
+ }
17630
17636
  function onAccountChange(swo, callback) {
17631
17637
  swo.on("accountsChanged", callback);
17632
17638
  }
@@ -17750,11 +17756,16 @@ ${indent}}` : "}";
17750
17756
  requestAccounts: () => requestAccounts2,
17751
17757
  requestChainId: () => requestChainId2,
17752
17758
  signMessage: () => signMessage2,
17759
+ standardConnect: () => standardConnect,
17753
17760
  subscribeWalletEvent: () => subscribeWalletEvent,
17754
17761
  supportedSpecs: () => supportedSpecs2,
17762
+ supportedWalletApi: () => supportedWalletApi2,
17755
17763
  switchStarknetChain: () => switchStarknetChain2,
17756
17764
  watchAsset: () => watchAsset2
17757
17765
  });
17766
+ function standardConnect(walletWSF, silent_mode = false) {
17767
+ return walletWSF.features["standard:connect"].connect({ silent: silent_mode });
17768
+ }
17758
17769
  function requestAccounts2(walletWSF, silent_mode = false) {
17759
17770
  return walletWSF.features["starknet:walletApi"].request({
17760
17771
  type: "wallet_requestAccounts",
@@ -17809,6 +17820,9 @@ ${indent}}` : "}";
17809
17820
  function supportedSpecs2(walletWSF) {
17810
17821
  return walletWSF.features["starknet:walletApi"].request({ type: "wallet_supportedSpecs" });
17811
17822
  }
17823
+ function supportedWalletApi2(walletWSF) {
17824
+ return walletWSF.features["starknet:walletApi"].request({ type: "wallet_supportedWalletApi" });
17825
+ }
17812
17826
  function subscribeWalletEvent(walletWSF, callback) {
17813
17827
  return walletWSF.features["standard:events"].on("change", callback);
17814
17828
  }
@@ -17821,6 +17835,11 @@ ${indent}}` : "}";
17821
17835
  * To call before the instance is deleted.
17822
17836
  */
17823
17837
  unsubscribe;
17838
+ /**
17839
+ * Unsubscribe functions for the callbacks registered through {@link onChange}.
17840
+ * Released by {@link unsubscribeChange}.
17841
+ */
17842
+ changeSubscriptions = [];
17824
17843
  constructor(options) {
17825
17844
  super({ ...options, signer: "" });
17826
17845
  this.walletProvider = options.walletProvider;
@@ -17839,11 +17858,24 @@ ${indent}}` : "}";
17839
17858
  /**
17840
17859
  * WALLET EVENTS
17841
17860
  */
17861
+ /**
17862
+ * Subscribe a callback to wallet account/network changes.
17863
+ * @param {(change: StandardEventsChangeProperties) => void} callback called on each change.
17864
+ * @returns {() => void} a function to unsubscribe this specific callback.
17865
+ */
17842
17866
  onChange(callback) {
17843
- subscribeWalletEvent(this.walletProvider, callback);
17867
+ const unsubscribe = subscribeWalletEvent(this.walletProvider, callback);
17868
+ this.changeSubscriptions.push(unsubscribe);
17869
+ return unsubscribe;
17844
17870
  }
17871
+ /**
17872
+ * Unsubscribe from all wallet events, including the callbacks registered through {@link onChange}.
17873
+ * To call before the instance is deleted.
17874
+ */
17845
17875
  unsubscribeChange() {
17846
17876
  this.unsubscribe();
17877
+ this.changeSubscriptions.forEach((unsubscribe) => unsubscribe());
17878
+ this.changeSubscriptions = [];
17847
17879
  }
17848
17880
  /**
17849
17881
  * WALLET SPECIFIC METHODS
@@ -17908,7 +17940,8 @@ ${indent}}` : "}";
17908
17940
  return signMessage2(this.walletProvider, typedData);
17909
17941
  }
17910
17942
  static async connect(provider, walletProvider, cairoVersion, paymaster, silentMode = false) {
17911
- const [accountAddress] = await requestAccounts2(walletProvider, silentMode);
17943
+ const { accounts } = await standardConnect(walletProvider, silentMode);
17944
+ const accountAddress = accounts[0]?.address;
17912
17945
  return new _WalletAccountV5({
17913
17946
  provider,
17914
17947
  walletProvider,
@@ -17923,6 +17956,154 @@ ${indent}}` : "}";
17923
17956
  // TODO: MISSING ESTIMATES
17924
17957
  };
17925
17958
 
17959
+ // src/wallet/connectV6.ts
17960
+ var connectV6_exports = {};
17961
+ __export(connectV6_exports, {
17962
+ addDeclareTransaction: () => addDeclareTransaction3,
17963
+ addInvokeTransaction: () => addInvokeTransaction3,
17964
+ addStarknetChain: () => addStarknetChain3,
17965
+ deploymentData: () => deploymentData3,
17966
+ getPermissions: () => getPermissions3,
17967
+ requestAccounts: () => requestAccounts3,
17968
+ requestChainId: () => requestChainId3,
17969
+ signMessage: () => signMessage3,
17970
+ standardConnect: () => standardConnect2,
17971
+ strk20Balances: () => strk20Balances,
17972
+ strk20InvokeTransaction: () => strk20InvokeTransaction,
17973
+ strk20PrepareInvoke: () => strk20PrepareInvoke,
17974
+ subscribeWalletEvent: () => subscribeWalletEvent2,
17975
+ supportedSpecs: () => supportedSpecs3,
17976
+ supportedWalletApi: () => supportedWalletApi3,
17977
+ switchStarknetChain: () => switchStarknetChain3,
17978
+ watchAsset: () => watchAsset3
17979
+ });
17980
+ function standardConnect2(walletWSF, silent_mode = false) {
17981
+ return walletWSF.features["standard:connect"].connect({ silent: silent_mode });
17982
+ }
17983
+ function requestAccounts3(walletWSF, silent_mode = false) {
17984
+ return walletWSF.features["starknet:walletApi"].request({
17985
+ type: "wallet_requestAccounts",
17986
+ params: { silent_mode }
17987
+ });
17988
+ }
17989
+ function getPermissions3(walletWSF) {
17990
+ return walletWSF.features["starknet:walletApi"].request({ type: "wallet_getPermissions" });
17991
+ }
17992
+ function watchAsset3(walletWSF, asset) {
17993
+ return walletWSF.features["starknet:walletApi"].request({
17994
+ type: "wallet_watchAsset",
17995
+ params: asset
17996
+ });
17997
+ }
17998
+ function addStarknetChain3(walletWSF, chain2) {
17999
+ return walletWSF.features["starknet:walletApi"].request({
18000
+ type: "wallet_addStarknetChain",
18001
+ params: chain2
18002
+ });
18003
+ }
18004
+ function switchStarknetChain3(walletWSF, chainId, silent_mode = false) {
18005
+ return walletWSF.features["starknet:walletApi"].request({
18006
+ type: "wallet_switchStarknetChain",
18007
+ params: { chainId, silent_mode }
18008
+ });
18009
+ }
18010
+ function requestChainId3(walletWSF) {
18011
+ return walletWSF.features["starknet:walletApi"].request({ type: "wallet_requestChainId" });
18012
+ }
18013
+ function deploymentData3(walletWSF) {
18014
+ return walletWSF.features["starknet:walletApi"].request({ type: "wallet_deploymentData" });
18015
+ }
18016
+ function addInvokeTransaction3(walletWSF, params) {
18017
+ return walletWSF.features["starknet:walletApi"].request({
18018
+ type: "wallet_addInvokeTransaction",
18019
+ params
18020
+ });
18021
+ }
18022
+ function addDeclareTransaction3(walletWSF, params) {
18023
+ return walletWSF.features["starknet:walletApi"].request({
18024
+ type: "wallet_addDeclareTransaction",
18025
+ params
18026
+ });
18027
+ }
18028
+ function signMessage3(walletWSF, typedData) {
18029
+ return walletWSF.features["starknet:walletApi"].request({
18030
+ type: "wallet_signTypedData",
18031
+ params: typedData
18032
+ });
18033
+ }
18034
+ function supportedSpecs3(walletWSF) {
18035
+ return walletWSF.features["starknet:walletApi"].request({ type: "wallet_supportedSpecs" });
18036
+ }
18037
+ function supportedWalletApi3(walletWSF) {
18038
+ return walletWSF.features["starknet:walletApi"].request({ type: "wallet_supportedWalletApi" });
18039
+ }
18040
+ function subscribeWalletEvent2(walletWSF, callback) {
18041
+ return walletWSF.features["standard:events"].on("change", callback);
18042
+ }
18043
+ function strk20Balances(walletWSF, tokens) {
18044
+ return walletWSF.features["starknet:walletApi"].request({
18045
+ type: "wallet_strk20Balances",
18046
+ params: { tokens }
18047
+ });
18048
+ }
18049
+ function strk20PrepareInvoke(walletWSF, actions, simulate) {
18050
+ return walletWSF.features["starknet:walletApi"].request({
18051
+ type: "wallet_strk20PrepareInvoke",
18052
+ params: { actions, simulate }
18053
+ });
18054
+ }
18055
+ function strk20InvokeTransaction(walletWSF, actions) {
18056
+ return walletWSF.features["starknet:walletApi"].request({
18057
+ type: "wallet_strk20InvokeTransaction",
18058
+ params: { actions }
18059
+ });
18060
+ }
18061
+
18062
+ // src/wallet/accountV6.ts
18063
+ var WalletAccountV6 = class _WalletAccountV6 extends WalletAccountV5 {
18064
+ constructor(options) {
18065
+ super({ ...options, walletProvider: options.walletProvider });
18066
+ this.walletProvider = options.walletProvider;
18067
+ }
18068
+ get v6Provider() {
18069
+ return this.walletProvider;
18070
+ }
18071
+ switchStarknetChain(chainId, silent_mode = false) {
18072
+ return switchStarknetChain3(this.v6Provider, chainId, silent_mode);
18073
+ }
18074
+ executeWithProof(calls, proof) {
18075
+ const txCalls = [].concat(calls).map((it) => ({
18076
+ contract_address: it.contractAddress,
18077
+ entry_point: it.entrypoint,
18078
+ calldata: it.calldata
18079
+ }));
18080
+ return addInvokeTransaction3(this.v6Provider, { calls: txCalls, proof });
18081
+ }
18082
+ strk20Balances(tokens) {
18083
+ return strk20Balances(this.v6Provider, tokens);
18084
+ }
18085
+ strk20PrepareInvoke(actions, simulate) {
18086
+ return strk20PrepareInvoke(this.v6Provider, actions, simulate);
18087
+ }
18088
+ strk20InvokeTransaction(actions) {
18089
+ return strk20InvokeTransaction(this.v6Provider, actions);
18090
+ }
18091
+ static async connect(provider, walletProvider, cairoVersion, paymaster, silentMode = false) {
18092
+ const { accounts } = await standardConnect2(walletProvider, silentMode);
18093
+ const accountAddress = accounts[0]?.address;
18094
+ return new _WalletAccountV6({
18095
+ provider,
18096
+ walletProvider,
18097
+ address: accountAddress,
18098
+ cairoVersion,
18099
+ paymaster
18100
+ });
18101
+ }
18102
+ static async connectSilent(provider, walletProvider, cairoVersion, paymaster) {
18103
+ return _WalletAccountV6.connect(provider, walletProvider, cairoVersion, paymaster, true);
18104
+ }
18105
+ };
18106
+
17926
18107
  // src/utils/events/index.ts
17927
18108
  var events_exports = {};
17928
18109
  __export(events_exports, {