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.
package/dist/index.mjs CHANGED
@@ -1181,7 +1181,7 @@ var CairoFelt252 = class _CairoFelt252 {
1181
1181
  return addHexPrefix(this.toBigInt().toString(16));
1182
1182
  }
1183
1183
  toApiRequest() {
1184
- return addCompiledFlag([this.toHexString()]);
1184
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
1185
1185
  }
1186
1186
  static assertRange(val) {
1187
1187
  assert(val >= 0n && val < PRIME, `Value ${val} is out of felt252 range [0, ${PRIME})`);
@@ -1811,7 +1811,7 @@ var CairoBytes31 = class _CairoBytes31 {
1811
1811
  throw new Error("Invalid input type for CairoBytes31. Expected string, Buffer, or Uint8Array");
1812
1812
  }
1813
1813
  toApiRequest() {
1814
- return addCompiledFlag([this.toHexString()]);
1814
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
1815
1815
  }
1816
1816
  toBigInt() {
1817
1817
  return uint8ArrayToBigInt(this.data);
@@ -2016,7 +2016,7 @@ var CairoUint32 = class _CairoUint32 {
2016
2016
  return BigInt(data);
2017
2017
  }
2018
2018
  toApiRequest() {
2019
- return addCompiledFlag([this.toHexString()]);
2019
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
2020
2020
  }
2021
2021
  toBigInt() {
2022
2022
  return this.data;
@@ -2136,7 +2136,7 @@ var CairoByteArray = class _CairoByteArray {
2136
2136
  toApiRequest() {
2137
2137
  this.assertInitialized();
2138
2138
  return addCompiledFlag([
2139
- addHexPrefix(this.data.length.toString(16)),
2139
+ this.data.length.toString(),
2140
2140
  ...this.data.flatMap((bytes31) => bytes31.toApiRequest()),
2141
2141
  ...this.pending_word.toApiRequest(),
2142
2142
  ...this.pending_word_len.toApiRequest()
@@ -2289,7 +2289,7 @@ var CairoUint8 = class _CairoUint8 {
2289
2289
  return BigInt(data);
2290
2290
  }
2291
2291
  toApiRequest() {
2292
- return addCompiledFlag([this.toHexString()]);
2292
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
2293
2293
  }
2294
2294
  toBigInt() {
2295
2295
  return this.data;
@@ -2347,7 +2347,7 @@ var CairoUint16 = class _CairoUint16 {
2347
2347
  return BigInt(data);
2348
2348
  }
2349
2349
  toApiRequest() {
2350
- return addCompiledFlag([this.toHexString()]);
2350
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
2351
2351
  }
2352
2352
  toBigInt() {
2353
2353
  return this.data;
@@ -2405,7 +2405,7 @@ var CairoUint64 = class _CairoUint64 {
2405
2405
  return BigInt(data);
2406
2406
  }
2407
2407
  toApiRequest() {
2408
- return addCompiledFlag([this.toHexString()]);
2408
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
2409
2409
  }
2410
2410
  toBigInt() {
2411
2411
  return this.data;
@@ -2463,7 +2463,7 @@ var CairoUint96 = class _CairoUint96 {
2463
2463
  return BigInt(data);
2464
2464
  }
2465
2465
  toApiRequest() {
2466
- return addCompiledFlag([this.toHexString()]);
2466
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
2467
2467
  }
2468
2468
  toBigInt() {
2469
2469
  return this.data;
@@ -2521,7 +2521,7 @@ var CairoUint128 = class _CairoUint128 {
2521
2521
  return BigInt(data);
2522
2522
  }
2523
2523
  toApiRequest() {
2524
- return addCompiledFlag([this.toHexString()]);
2524
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
2525
2525
  }
2526
2526
  toBigInt() {
2527
2527
  return this.data;
@@ -2579,7 +2579,7 @@ var CairoInt8 = class _CairoInt8 {
2579
2579
  return BigInt(data);
2580
2580
  }
2581
2581
  toApiRequest() {
2582
- return addCompiledFlag([this.toHexString()]);
2582
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
2583
2583
  }
2584
2584
  toBigInt() {
2585
2585
  return this.data;
@@ -2651,7 +2651,7 @@ var CairoInt16 = class _CairoInt16 {
2651
2651
  return BigInt(data);
2652
2652
  }
2653
2653
  toApiRequest() {
2654
- return addCompiledFlag([this.toHexString()]);
2654
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
2655
2655
  }
2656
2656
  toBigInt() {
2657
2657
  return this.data;
@@ -2723,7 +2723,7 @@ var CairoInt32 = class _CairoInt32 {
2723
2723
  return BigInt(data);
2724
2724
  }
2725
2725
  toApiRequest() {
2726
- return addCompiledFlag([this.toHexString()]);
2726
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
2727
2727
  }
2728
2728
  toBigInt() {
2729
2729
  return this.data;
@@ -2795,7 +2795,7 @@ var CairoInt64 = class _CairoInt64 {
2795
2795
  return BigInt(data);
2796
2796
  }
2797
2797
  toApiRequest() {
2798
- return addCompiledFlag([this.toHexString()]);
2798
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
2799
2799
  }
2800
2800
  toBigInt() {
2801
2801
  return this.data;
@@ -2867,7 +2867,7 @@ var CairoInt128 = class _CairoInt128 {
2867
2867
  return BigInt(data);
2868
2868
  }
2869
2869
  toApiRequest() {
2870
- return addCompiledFlag([this.toHexString()]);
2870
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
2871
2871
  }
2872
2872
  toBigInt() {
2873
2873
  return this.data;
@@ -3031,7 +3031,7 @@ var fastParsingStrategy = {
3031
3031
  return new CairoByteArray(val).toApiRequest();
3032
3032
  },
3033
3033
  [CairoFelt252.abiSelector]: (val) => {
3034
- return felt(val);
3034
+ return new CairoFelt252(val).toApiRequest();
3035
3035
  },
3036
3036
  [CairoUint256.abiSelector]: (val) => {
3037
3037
  return new CairoUint256(val).toApiRequest();
@@ -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, {
@@ -13442,6 +13621,7 @@ export {
13442
13621
  ValidateType,
13443
13622
  WalletAccount,
13444
13623
  WalletAccountV5,
13624
+ WalletAccountV6,
13445
13625
  WebSocketChannel,
13446
13626
  WebSocketNotConnectedError,
13447
13627
  addAddressPadding,
@@ -13511,6 +13691,7 @@ export {
13511
13691
  validateChecksumAddress,
13512
13692
  verifyMessageInStarknet,
13513
13693
  connect_exports as wallet,
13514
- connectV5_exports as walletV5
13694
+ connectV5_exports as walletV5,
13695
+ connectV6_exports as walletV6
13515
13696
  };
13516
13697
  //# sourceMappingURL=index.mjs.map