starknet 10.3.3 → 10.5.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
@@ -131,6 +131,7 @@ __export(index_exports, {
131
131
  ValidateType: () => ValidateType,
132
132
  WalletAccount: () => WalletAccount,
133
133
  WalletAccountV5: () => WalletAccountV5,
134
+ WalletAccountV6: () => WalletAccountV6,
134
135
  WebSocketChannel: () => WebSocketChannel,
135
136
  WebSocketNotConnectedError: () => WebSocketNotConnectedError,
136
137
  addAddressPadding: () => addAddressPadding,
@@ -200,7 +201,8 @@ __export(index_exports, {
200
201
  validateChecksumAddress: () => validateChecksumAddress,
201
202
  verifyMessageInStarknet: () => verifyMessageInStarknet,
202
203
  wallet: () => connect_exports,
203
- walletV5: () => connectV5_exports
204
+ walletV5: () => connectV5_exports,
205
+ walletV6: () => connectV6_exports
204
206
  });
205
207
  module.exports = __toCommonJS(index_exports);
206
208
 
@@ -12549,6 +12551,7 @@ __export(connect_exports, {
12549
12551
  requestChainId: () => requestChainId,
12550
12552
  signMessage: () => signMessage,
12551
12553
  supportedSpecs: () => supportedSpecs,
12554
+ supportedWalletApi: () => supportedWalletApi,
12552
12555
  switchStarknetChain: () => switchStarknetChain,
12553
12556
  watchAsset: () => watchAsset
12554
12557
  });
@@ -12591,6 +12594,9 @@ function signMessage(swo, typedData) {
12591
12594
  function supportedSpecs(swo) {
12592
12595
  return swo.request({ type: "wallet_supportedSpecs" });
12593
12596
  }
12597
+ function supportedWalletApi(swo) {
12598
+ return swo.request({ type: "wallet_supportedWalletApi" });
12599
+ }
12594
12600
  function onAccountChange(swo, callback) {
12595
12601
  swo.on("accountsChanged", callback);
12596
12602
  }
@@ -12714,11 +12720,16 @@ __export(connectV5_exports, {
12714
12720
  requestAccounts: () => requestAccounts2,
12715
12721
  requestChainId: () => requestChainId2,
12716
12722
  signMessage: () => signMessage2,
12723
+ standardConnect: () => standardConnect,
12717
12724
  subscribeWalletEvent: () => subscribeWalletEvent,
12718
12725
  supportedSpecs: () => supportedSpecs2,
12726
+ supportedWalletApi: () => supportedWalletApi2,
12719
12727
  switchStarknetChain: () => switchStarknetChain2,
12720
12728
  watchAsset: () => watchAsset2
12721
12729
  });
12730
+ function standardConnect(walletWSF, silent_mode = false) {
12731
+ return walletWSF.features["standard:connect"].connect({ silent: silent_mode });
12732
+ }
12722
12733
  function requestAccounts2(walletWSF, silent_mode = false) {
12723
12734
  return walletWSF.features["starknet:walletApi"].request({
12724
12735
  type: "wallet_requestAccounts",
@@ -12773,6 +12784,9 @@ function signMessage2(walletWSF, typedData) {
12773
12784
  function supportedSpecs2(walletWSF) {
12774
12785
  return walletWSF.features["starknet:walletApi"].request({ type: "wallet_supportedSpecs" });
12775
12786
  }
12787
+ function supportedWalletApi2(walletWSF) {
12788
+ return walletWSF.features["starknet:walletApi"].request({ type: "wallet_supportedWalletApi" });
12789
+ }
12776
12790
  function subscribeWalletEvent(walletWSF, callback) {
12777
12791
  return walletWSF.features["standard:events"].on("change", callback);
12778
12792
  }
@@ -12785,6 +12799,11 @@ var WalletAccountV5 = class _WalletAccountV5 extends Account {
12785
12799
  * To call before the instance is deleted.
12786
12800
  */
12787
12801
  unsubscribe;
12802
+ /**
12803
+ * Unsubscribe functions for the callbacks registered through {@link onChange}.
12804
+ * Released by {@link unsubscribeChange}.
12805
+ */
12806
+ changeSubscriptions = [];
12788
12807
  constructor(options) {
12789
12808
  super({ ...options, signer: "" });
12790
12809
  this.walletProvider = options.walletProvider;
@@ -12803,11 +12822,24 @@ var WalletAccountV5 = class _WalletAccountV5 extends Account {
12803
12822
  /**
12804
12823
  * WALLET EVENTS
12805
12824
  */
12825
+ /**
12826
+ * Subscribe a callback to wallet account/network changes.
12827
+ * @param {(change: StandardEventsChangeProperties) => void} callback called on each change.
12828
+ * @returns {() => void} a function to unsubscribe this specific callback.
12829
+ */
12806
12830
  onChange(callback) {
12807
- subscribeWalletEvent(this.walletProvider, callback);
12831
+ const unsubscribe = subscribeWalletEvent(this.walletProvider, callback);
12832
+ this.changeSubscriptions.push(unsubscribe);
12833
+ return unsubscribe;
12808
12834
  }
12835
+ /**
12836
+ * Unsubscribe from all wallet events, including the callbacks registered through {@link onChange}.
12837
+ * To call before the instance is deleted.
12838
+ */
12809
12839
  unsubscribeChange() {
12810
12840
  this.unsubscribe();
12841
+ this.changeSubscriptions.forEach((unsubscribe) => unsubscribe());
12842
+ this.changeSubscriptions = [];
12811
12843
  }
12812
12844
  /**
12813
12845
  * WALLET SPECIFIC METHODS
@@ -12872,7 +12904,8 @@ var WalletAccountV5 = class _WalletAccountV5 extends Account {
12872
12904
  return signMessage2(this.walletProvider, typedData);
12873
12905
  }
12874
12906
  static async connect(provider, walletProvider, cairoVersion, paymaster, silentMode = false) {
12875
- const [accountAddress] = await requestAccounts2(walletProvider, silentMode);
12907
+ const { accounts } = await standardConnect(walletProvider, silentMode);
12908
+ const accountAddress = accounts[0]?.address;
12876
12909
  return new _WalletAccountV5({
12877
12910
  provider,
12878
12911
  walletProvider,
@@ -12887,6 +12920,154 @@ var WalletAccountV5 = class _WalletAccountV5 extends Account {
12887
12920
  // TODO: MISSING ESTIMATES
12888
12921
  };
12889
12922
 
12923
+ // src/wallet/connectV6.ts
12924
+ var connectV6_exports = {};
12925
+ __export(connectV6_exports, {
12926
+ addDeclareTransaction: () => addDeclareTransaction3,
12927
+ addInvokeTransaction: () => addInvokeTransaction3,
12928
+ addStarknetChain: () => addStarknetChain3,
12929
+ deploymentData: () => deploymentData3,
12930
+ getPermissions: () => getPermissions3,
12931
+ requestAccounts: () => requestAccounts3,
12932
+ requestChainId: () => requestChainId3,
12933
+ signMessage: () => signMessage3,
12934
+ standardConnect: () => standardConnect2,
12935
+ strk20Balances: () => strk20Balances,
12936
+ strk20InvokeTransaction: () => strk20InvokeTransaction,
12937
+ strk20PrepareInvoke: () => strk20PrepareInvoke,
12938
+ subscribeWalletEvent: () => subscribeWalletEvent2,
12939
+ supportedSpecs: () => supportedSpecs3,
12940
+ supportedWalletApi: () => supportedWalletApi3,
12941
+ switchStarknetChain: () => switchStarknetChain3,
12942
+ watchAsset: () => watchAsset3
12943
+ });
12944
+ function standardConnect2(walletWSF, silent_mode = false) {
12945
+ return walletWSF.features["standard:connect"].connect({ silent: silent_mode });
12946
+ }
12947
+ function requestAccounts3(walletWSF, silent_mode = false) {
12948
+ return walletWSF.features["starknet:walletApi"].request({
12949
+ type: "wallet_requestAccounts",
12950
+ params: { silent_mode }
12951
+ });
12952
+ }
12953
+ function getPermissions3(walletWSF) {
12954
+ return walletWSF.features["starknet:walletApi"].request({ type: "wallet_getPermissions" });
12955
+ }
12956
+ function watchAsset3(walletWSF, asset) {
12957
+ return walletWSF.features["starknet:walletApi"].request({
12958
+ type: "wallet_watchAsset",
12959
+ params: asset
12960
+ });
12961
+ }
12962
+ function addStarknetChain3(walletWSF, chain) {
12963
+ return walletWSF.features["starknet:walletApi"].request({
12964
+ type: "wallet_addStarknetChain",
12965
+ params: chain
12966
+ });
12967
+ }
12968
+ function switchStarknetChain3(walletWSF, chainId, silent_mode = false) {
12969
+ return walletWSF.features["starknet:walletApi"].request({
12970
+ type: "wallet_switchStarknetChain",
12971
+ params: { chainId, silent_mode }
12972
+ });
12973
+ }
12974
+ function requestChainId3(walletWSF) {
12975
+ return walletWSF.features["starknet:walletApi"].request({ type: "wallet_requestChainId" });
12976
+ }
12977
+ function deploymentData3(walletWSF) {
12978
+ return walletWSF.features["starknet:walletApi"].request({ type: "wallet_deploymentData" });
12979
+ }
12980
+ function addInvokeTransaction3(walletWSF, params) {
12981
+ return walletWSF.features["starknet:walletApi"].request({
12982
+ type: "wallet_addInvokeTransaction",
12983
+ params
12984
+ });
12985
+ }
12986
+ function addDeclareTransaction3(walletWSF, params) {
12987
+ return walletWSF.features["starknet:walletApi"].request({
12988
+ type: "wallet_addDeclareTransaction",
12989
+ params
12990
+ });
12991
+ }
12992
+ function signMessage3(walletWSF, typedData) {
12993
+ return walletWSF.features["starknet:walletApi"].request({
12994
+ type: "wallet_signTypedData",
12995
+ params: typedData
12996
+ });
12997
+ }
12998
+ function supportedSpecs3(walletWSF) {
12999
+ return walletWSF.features["starknet:walletApi"].request({ type: "wallet_supportedSpecs" });
13000
+ }
13001
+ function supportedWalletApi3(walletWSF) {
13002
+ return walletWSF.features["starknet:walletApi"].request({ type: "wallet_supportedWalletApi" });
13003
+ }
13004
+ function subscribeWalletEvent2(walletWSF, callback) {
13005
+ return walletWSF.features["standard:events"].on("change", callback);
13006
+ }
13007
+ function strk20Balances(walletWSF, tokens) {
13008
+ return walletWSF.features["starknet:walletApi"].request({
13009
+ type: "wallet_strk20Balances",
13010
+ params: { tokens }
13011
+ });
13012
+ }
13013
+ function strk20PrepareInvoke(walletWSF, actions, simulate) {
13014
+ return walletWSF.features["starknet:walletApi"].request({
13015
+ type: "wallet_strk20PrepareInvoke",
13016
+ params: { actions, simulate }
13017
+ });
13018
+ }
13019
+ function strk20InvokeTransaction(walletWSF, actions) {
13020
+ return walletWSF.features["starknet:walletApi"].request({
13021
+ type: "wallet_strk20InvokeTransaction",
13022
+ params: { actions }
13023
+ });
13024
+ }
13025
+
13026
+ // src/wallet/accountV6.ts
13027
+ var WalletAccountV6 = class _WalletAccountV6 extends WalletAccountV5 {
13028
+ constructor(options) {
13029
+ super({ ...options, walletProvider: options.walletProvider });
13030
+ this.walletProvider = options.walletProvider;
13031
+ }
13032
+ get v6Provider() {
13033
+ return this.walletProvider;
13034
+ }
13035
+ switchStarknetChain(chainId, silent_mode = false) {
13036
+ return switchStarknetChain3(this.v6Provider, chainId, silent_mode);
13037
+ }
13038
+ executeWithProof(calls, proof) {
13039
+ const txCalls = [].concat(calls).map((it) => ({
13040
+ contract_address: it.contractAddress,
13041
+ entry_point: it.entrypoint,
13042
+ calldata: it.calldata
13043
+ }));
13044
+ return addInvokeTransaction3(this.v6Provider, { calls: txCalls, proof });
13045
+ }
13046
+ strk20Balances(tokens) {
13047
+ return strk20Balances(this.v6Provider, tokens);
13048
+ }
13049
+ strk20PrepareInvoke(actions, simulate) {
13050
+ return strk20PrepareInvoke(this.v6Provider, actions, simulate);
13051
+ }
13052
+ strk20InvokeTransaction(actions) {
13053
+ return strk20InvokeTransaction(this.v6Provider, actions);
13054
+ }
13055
+ static async connect(provider, walletProvider, cairoVersion, paymaster, silentMode = false) {
13056
+ const { accounts } = await standardConnect2(walletProvider, silentMode);
13057
+ const accountAddress = accounts[0]?.address;
13058
+ return new _WalletAccountV6({
13059
+ provider,
13060
+ walletProvider,
13061
+ address: accountAddress,
13062
+ cairoVersion,
13063
+ paymaster
13064
+ });
13065
+ }
13066
+ static async connectSilent(provider, walletProvider, cairoVersion, paymaster) {
13067
+ return _WalletAccountV6.connect(provider, walletProvider, cairoVersion, paymaster, true);
13068
+ }
13069
+ };
13070
+
12890
13071
  // src/utils/events/index.ts
12891
13072
  var events_exports = {};
12892
13073
  __export(events_exports, {
@@ -13331,12 +13512,14 @@ var Contract = class _Contract {
13331
13512
  }
13332
13513
  throw Error("Contract must be connected to the account contract to estimate");
13333
13514
  }
13515
+ compile(method, args = []) {
13516
+ return getCompiledCalldata(args, () => this.callData.compile(method, args));
13517
+ }
13334
13518
  populate(method, args = []) {
13335
- const calldata = getCompiledCalldata(args, () => this.callData.compile(method, args));
13336
13519
  return {
13337
13520
  contractAddress: this.address,
13338
13521
  entrypoint: method,
13339
- calldata
13522
+ calldata: this.compile(method, args)
13340
13523
  };
13341
13524
  }
13342
13525
  parseEvents(receipt) {
@@ -13623,6 +13806,7 @@ function units(amount, simbol = "fri") {
13623
13806
  ValidateType,
13624
13807
  WalletAccount,
13625
13808
  WalletAccountV5,
13809
+ WalletAccountV6,
13626
13810
  WebSocketChannel,
13627
13811
  WebSocketNotConnectedError,
13628
13812
  addAddressPadding,
@@ -13692,6 +13876,7 @@ function units(amount, simbol = "fri") {
13692
13876
  validateChecksumAddress,
13693
13877
  verifyMessageInStarknet,
13694
13878
  wallet,
13695
- walletV5
13879
+ walletV5,
13880
+ walletV6
13696
13881
  });
13697
13882
  //# sourceMappingURL=index.js.map