starknet 10.3.3 → 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
@@ -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, {