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.mjs CHANGED
@@ -12368,6 +12368,7 @@ __export(connect_exports, {
12368
12368
  requestChainId: () => requestChainId,
12369
12369
  signMessage: () => signMessage,
12370
12370
  supportedSpecs: () => supportedSpecs,
12371
+ supportedWalletApi: () => supportedWalletApi,
12371
12372
  switchStarknetChain: () => switchStarknetChain,
12372
12373
  watchAsset: () => watchAsset
12373
12374
  });
@@ -12410,6 +12411,9 @@ function signMessage(swo, typedData) {
12410
12411
  function supportedSpecs(swo) {
12411
12412
  return swo.request({ type: "wallet_supportedSpecs" });
12412
12413
  }
12414
+ function supportedWalletApi(swo) {
12415
+ return swo.request({ type: "wallet_supportedWalletApi" });
12416
+ }
12413
12417
  function onAccountChange(swo, callback) {
12414
12418
  swo.on("accountsChanged", callback);
12415
12419
  }
@@ -12533,11 +12537,16 @@ __export(connectV5_exports, {
12533
12537
  requestAccounts: () => requestAccounts2,
12534
12538
  requestChainId: () => requestChainId2,
12535
12539
  signMessage: () => signMessage2,
12540
+ standardConnect: () => standardConnect,
12536
12541
  subscribeWalletEvent: () => subscribeWalletEvent,
12537
12542
  supportedSpecs: () => supportedSpecs2,
12543
+ supportedWalletApi: () => supportedWalletApi2,
12538
12544
  switchStarknetChain: () => switchStarknetChain2,
12539
12545
  watchAsset: () => watchAsset2
12540
12546
  });
12547
+ function standardConnect(walletWSF, silent_mode = false) {
12548
+ return walletWSF.features["standard:connect"].connect({ silent: silent_mode });
12549
+ }
12541
12550
  function requestAccounts2(walletWSF, silent_mode = false) {
12542
12551
  return walletWSF.features["starknet:walletApi"].request({
12543
12552
  type: "wallet_requestAccounts",
@@ -12592,6 +12601,9 @@ function signMessage2(walletWSF, typedData) {
12592
12601
  function supportedSpecs2(walletWSF) {
12593
12602
  return walletWSF.features["starknet:walletApi"].request({ type: "wallet_supportedSpecs" });
12594
12603
  }
12604
+ function supportedWalletApi2(walletWSF) {
12605
+ return walletWSF.features["starknet:walletApi"].request({ type: "wallet_supportedWalletApi" });
12606
+ }
12595
12607
  function subscribeWalletEvent(walletWSF, callback) {
12596
12608
  return walletWSF.features["standard:events"].on("change", callback);
12597
12609
  }
@@ -12604,6 +12616,11 @@ var WalletAccountV5 = class _WalletAccountV5 extends Account {
12604
12616
  * To call before the instance is deleted.
12605
12617
  */
12606
12618
  unsubscribe;
12619
+ /**
12620
+ * Unsubscribe functions for the callbacks registered through {@link onChange}.
12621
+ * Released by {@link unsubscribeChange}.
12622
+ */
12623
+ changeSubscriptions = [];
12607
12624
  constructor(options) {
12608
12625
  super({ ...options, signer: "" });
12609
12626
  this.walletProvider = options.walletProvider;
@@ -12622,11 +12639,24 @@ var WalletAccountV5 = class _WalletAccountV5 extends Account {
12622
12639
  /**
12623
12640
  * WALLET EVENTS
12624
12641
  */
12642
+ /**
12643
+ * Subscribe a callback to wallet account/network changes.
12644
+ * @param {(change: StandardEventsChangeProperties) => void} callback called on each change.
12645
+ * @returns {() => void} a function to unsubscribe this specific callback.
12646
+ */
12625
12647
  onChange(callback) {
12626
- subscribeWalletEvent(this.walletProvider, callback);
12648
+ const unsubscribe = subscribeWalletEvent(this.walletProvider, callback);
12649
+ this.changeSubscriptions.push(unsubscribe);
12650
+ return unsubscribe;
12627
12651
  }
12652
+ /**
12653
+ * Unsubscribe from all wallet events, including the callbacks registered through {@link onChange}.
12654
+ * To call before the instance is deleted.
12655
+ */
12628
12656
  unsubscribeChange() {
12629
12657
  this.unsubscribe();
12658
+ this.changeSubscriptions.forEach((unsubscribe) => unsubscribe());
12659
+ this.changeSubscriptions = [];
12630
12660
  }
12631
12661
  /**
12632
12662
  * WALLET SPECIFIC METHODS
@@ -12691,7 +12721,8 @@ var WalletAccountV5 = class _WalletAccountV5 extends Account {
12691
12721
  return signMessage2(this.walletProvider, typedData);
12692
12722
  }
12693
12723
  static async connect(provider, walletProvider, cairoVersion, paymaster, silentMode = false) {
12694
- const [accountAddress] = await requestAccounts2(walletProvider, silentMode);
12724
+ const { accounts } = await standardConnect(walletProvider, silentMode);
12725
+ const accountAddress = accounts[0]?.address;
12695
12726
  return new _WalletAccountV5({
12696
12727
  provider,
12697
12728
  walletProvider,
@@ -12706,6 +12737,154 @@ var WalletAccountV5 = class _WalletAccountV5 extends Account {
12706
12737
  // TODO: MISSING ESTIMATES
12707
12738
  };
12708
12739
 
12740
+ // src/wallet/connectV6.ts
12741
+ var connectV6_exports = {};
12742
+ __export(connectV6_exports, {
12743
+ addDeclareTransaction: () => addDeclareTransaction3,
12744
+ addInvokeTransaction: () => addInvokeTransaction3,
12745
+ addStarknetChain: () => addStarknetChain3,
12746
+ deploymentData: () => deploymentData3,
12747
+ getPermissions: () => getPermissions3,
12748
+ requestAccounts: () => requestAccounts3,
12749
+ requestChainId: () => requestChainId3,
12750
+ signMessage: () => signMessage3,
12751
+ standardConnect: () => standardConnect2,
12752
+ strk20Balances: () => strk20Balances,
12753
+ strk20InvokeTransaction: () => strk20InvokeTransaction,
12754
+ strk20PrepareInvoke: () => strk20PrepareInvoke,
12755
+ subscribeWalletEvent: () => subscribeWalletEvent2,
12756
+ supportedSpecs: () => supportedSpecs3,
12757
+ supportedWalletApi: () => supportedWalletApi3,
12758
+ switchStarknetChain: () => switchStarknetChain3,
12759
+ watchAsset: () => watchAsset3
12760
+ });
12761
+ function standardConnect2(walletWSF, silent_mode = false) {
12762
+ return walletWSF.features["standard:connect"].connect({ silent: silent_mode });
12763
+ }
12764
+ function requestAccounts3(walletWSF, silent_mode = false) {
12765
+ return walletWSF.features["starknet:walletApi"].request({
12766
+ type: "wallet_requestAccounts",
12767
+ params: { silent_mode }
12768
+ });
12769
+ }
12770
+ function getPermissions3(walletWSF) {
12771
+ return walletWSF.features["starknet:walletApi"].request({ type: "wallet_getPermissions" });
12772
+ }
12773
+ function watchAsset3(walletWSF, asset) {
12774
+ return walletWSF.features["starknet:walletApi"].request({
12775
+ type: "wallet_watchAsset",
12776
+ params: asset
12777
+ });
12778
+ }
12779
+ function addStarknetChain3(walletWSF, chain) {
12780
+ return walletWSF.features["starknet:walletApi"].request({
12781
+ type: "wallet_addStarknetChain",
12782
+ params: chain
12783
+ });
12784
+ }
12785
+ function switchStarknetChain3(walletWSF, chainId, silent_mode = false) {
12786
+ return walletWSF.features["starknet:walletApi"].request({
12787
+ type: "wallet_switchStarknetChain",
12788
+ params: { chainId, silent_mode }
12789
+ });
12790
+ }
12791
+ function requestChainId3(walletWSF) {
12792
+ return walletWSF.features["starknet:walletApi"].request({ type: "wallet_requestChainId" });
12793
+ }
12794
+ function deploymentData3(walletWSF) {
12795
+ return walletWSF.features["starknet:walletApi"].request({ type: "wallet_deploymentData" });
12796
+ }
12797
+ function addInvokeTransaction3(walletWSF, params) {
12798
+ return walletWSF.features["starknet:walletApi"].request({
12799
+ type: "wallet_addInvokeTransaction",
12800
+ params
12801
+ });
12802
+ }
12803
+ function addDeclareTransaction3(walletWSF, params) {
12804
+ return walletWSF.features["starknet:walletApi"].request({
12805
+ type: "wallet_addDeclareTransaction",
12806
+ params
12807
+ });
12808
+ }
12809
+ function signMessage3(walletWSF, typedData) {
12810
+ return walletWSF.features["starknet:walletApi"].request({
12811
+ type: "wallet_signTypedData",
12812
+ params: typedData
12813
+ });
12814
+ }
12815
+ function supportedSpecs3(walletWSF) {
12816
+ return walletWSF.features["starknet:walletApi"].request({ type: "wallet_supportedSpecs" });
12817
+ }
12818
+ function supportedWalletApi3(walletWSF) {
12819
+ return walletWSF.features["starknet:walletApi"].request({ type: "wallet_supportedWalletApi" });
12820
+ }
12821
+ function subscribeWalletEvent2(walletWSF, callback) {
12822
+ return walletWSF.features["standard:events"].on("change", callback);
12823
+ }
12824
+ function strk20Balances(walletWSF, tokens) {
12825
+ return walletWSF.features["starknet:walletApi"].request({
12826
+ type: "wallet_strk20Balances",
12827
+ params: { tokens }
12828
+ });
12829
+ }
12830
+ function strk20PrepareInvoke(walletWSF, actions, simulate) {
12831
+ return walletWSF.features["starknet:walletApi"].request({
12832
+ type: "wallet_strk20PrepareInvoke",
12833
+ params: { actions, simulate }
12834
+ });
12835
+ }
12836
+ function strk20InvokeTransaction(walletWSF, actions) {
12837
+ return walletWSF.features["starknet:walletApi"].request({
12838
+ type: "wallet_strk20InvokeTransaction",
12839
+ params: { actions }
12840
+ });
12841
+ }
12842
+
12843
+ // src/wallet/accountV6.ts
12844
+ var WalletAccountV6 = class _WalletAccountV6 extends WalletAccountV5 {
12845
+ constructor(options) {
12846
+ super({ ...options, walletProvider: options.walletProvider });
12847
+ this.walletProvider = options.walletProvider;
12848
+ }
12849
+ get v6Provider() {
12850
+ return this.walletProvider;
12851
+ }
12852
+ switchStarknetChain(chainId, silent_mode = false) {
12853
+ return switchStarknetChain3(this.v6Provider, chainId, silent_mode);
12854
+ }
12855
+ executeWithProof(calls, proof) {
12856
+ const txCalls = [].concat(calls).map((it) => ({
12857
+ contract_address: it.contractAddress,
12858
+ entry_point: it.entrypoint,
12859
+ calldata: it.calldata
12860
+ }));
12861
+ return addInvokeTransaction3(this.v6Provider, { calls: txCalls, proof });
12862
+ }
12863
+ strk20Balances(tokens) {
12864
+ return strk20Balances(this.v6Provider, tokens);
12865
+ }
12866
+ strk20PrepareInvoke(actions, simulate) {
12867
+ return strk20PrepareInvoke(this.v6Provider, actions, simulate);
12868
+ }
12869
+ strk20InvokeTransaction(actions) {
12870
+ return strk20InvokeTransaction(this.v6Provider, actions);
12871
+ }
12872
+ static async connect(provider, walletProvider, cairoVersion, paymaster, silentMode = false) {
12873
+ const { accounts } = await standardConnect2(walletProvider, silentMode);
12874
+ const accountAddress = accounts[0]?.address;
12875
+ return new _WalletAccountV6({
12876
+ provider,
12877
+ walletProvider,
12878
+ address: accountAddress,
12879
+ cairoVersion,
12880
+ paymaster
12881
+ });
12882
+ }
12883
+ static async connectSilent(provider, walletProvider, cairoVersion, paymaster) {
12884
+ return _WalletAccountV6.connect(provider, walletProvider, cairoVersion, paymaster, true);
12885
+ }
12886
+ };
12887
+
12709
12888
  // src/utils/events/index.ts
12710
12889
  var events_exports = {};
12711
12890
  __export(events_exports, {
@@ -13150,12 +13329,14 @@ var Contract = class _Contract {
13150
13329
  }
13151
13330
  throw Error("Contract must be connected to the account contract to estimate");
13152
13331
  }
13332
+ compile(method, args = []) {
13333
+ return getCompiledCalldata(args, () => this.callData.compile(method, args));
13334
+ }
13153
13335
  populate(method, args = []) {
13154
- const calldata = getCompiledCalldata(args, () => this.callData.compile(method, args));
13155
13336
  return {
13156
13337
  contractAddress: this.address,
13157
13338
  entrypoint: method,
13158
- calldata
13339
+ calldata: this.compile(method, args)
13159
13340
  };
13160
13341
  }
13161
13342
  parseEvents(receipt) {
@@ -13442,6 +13623,7 @@ export {
13442
13623
  ValidateType,
13443
13624
  WalletAccount,
13444
13625
  WalletAccountV5,
13626
+ WalletAccountV6,
13445
13627
  WebSocketChannel,
13446
13628
  WebSocketNotConnectedError,
13447
13629
  addAddressPadding,
@@ -13511,6 +13693,7 @@ export {
13511
13693
  validateChecksumAddress,
13512
13694
  verifyMessageInStarknet,
13513
13695
  connect_exports as wallet,
13514
- connectV5_exports as walletV5
13696
+ connectV5_exports as walletV5,
13697
+ connectV6_exports as walletV6
13515
13698
  };
13516
13699
  //# sourceMappingURL=index.mjs.map