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.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
 
@@ -1362,7 +1364,7 @@ var CairoFelt252 = class _CairoFelt252 {
1362
1364
  return addHexPrefix(this.toBigInt().toString(16));
1363
1365
  }
1364
1366
  toApiRequest() {
1365
- return addCompiledFlag([this.toHexString()]);
1367
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
1366
1368
  }
1367
1369
  static assertRange(val) {
1368
1370
  assert(val >= 0n && val < PRIME, `Value ${val} is out of felt252 range [0, ${PRIME})`);
@@ -1992,7 +1994,7 @@ var CairoBytes31 = class _CairoBytes31 {
1992
1994
  throw new Error("Invalid input type for CairoBytes31. Expected string, Buffer, or Uint8Array");
1993
1995
  }
1994
1996
  toApiRequest() {
1995
- return addCompiledFlag([this.toHexString()]);
1997
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
1996
1998
  }
1997
1999
  toBigInt() {
1998
2000
  return uint8ArrayToBigInt(this.data);
@@ -2197,7 +2199,7 @@ var CairoUint32 = class _CairoUint32 {
2197
2199
  return BigInt(data);
2198
2200
  }
2199
2201
  toApiRequest() {
2200
- return addCompiledFlag([this.toHexString()]);
2202
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
2201
2203
  }
2202
2204
  toBigInt() {
2203
2205
  return this.data;
@@ -2317,7 +2319,7 @@ var CairoByteArray = class _CairoByteArray {
2317
2319
  toApiRequest() {
2318
2320
  this.assertInitialized();
2319
2321
  return addCompiledFlag([
2320
- addHexPrefix(this.data.length.toString(16)),
2322
+ this.data.length.toString(),
2321
2323
  ...this.data.flatMap((bytes31) => bytes31.toApiRequest()),
2322
2324
  ...this.pending_word.toApiRequest(),
2323
2325
  ...this.pending_word_len.toApiRequest()
@@ -2470,7 +2472,7 @@ var CairoUint8 = class _CairoUint8 {
2470
2472
  return BigInt(data);
2471
2473
  }
2472
2474
  toApiRequest() {
2473
- return addCompiledFlag([this.toHexString()]);
2475
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
2474
2476
  }
2475
2477
  toBigInt() {
2476
2478
  return this.data;
@@ -2528,7 +2530,7 @@ var CairoUint16 = class _CairoUint16 {
2528
2530
  return BigInt(data);
2529
2531
  }
2530
2532
  toApiRequest() {
2531
- return addCompiledFlag([this.toHexString()]);
2533
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
2532
2534
  }
2533
2535
  toBigInt() {
2534
2536
  return this.data;
@@ -2586,7 +2588,7 @@ var CairoUint64 = class _CairoUint64 {
2586
2588
  return BigInt(data);
2587
2589
  }
2588
2590
  toApiRequest() {
2589
- return addCompiledFlag([this.toHexString()]);
2591
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
2590
2592
  }
2591
2593
  toBigInt() {
2592
2594
  return this.data;
@@ -2644,7 +2646,7 @@ var CairoUint96 = class _CairoUint96 {
2644
2646
  return BigInt(data);
2645
2647
  }
2646
2648
  toApiRequest() {
2647
- return addCompiledFlag([this.toHexString()]);
2649
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
2648
2650
  }
2649
2651
  toBigInt() {
2650
2652
  return this.data;
@@ -2702,7 +2704,7 @@ var CairoUint128 = class _CairoUint128 {
2702
2704
  return BigInt(data);
2703
2705
  }
2704
2706
  toApiRequest() {
2705
- return addCompiledFlag([this.toHexString()]);
2707
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
2706
2708
  }
2707
2709
  toBigInt() {
2708
2710
  return this.data;
@@ -2760,7 +2762,7 @@ var CairoInt8 = class _CairoInt8 {
2760
2762
  return BigInt(data);
2761
2763
  }
2762
2764
  toApiRequest() {
2763
- return addCompiledFlag([this.toHexString()]);
2765
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
2764
2766
  }
2765
2767
  toBigInt() {
2766
2768
  return this.data;
@@ -2832,7 +2834,7 @@ var CairoInt16 = class _CairoInt16 {
2832
2834
  return BigInt(data);
2833
2835
  }
2834
2836
  toApiRequest() {
2835
- return addCompiledFlag([this.toHexString()]);
2837
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
2836
2838
  }
2837
2839
  toBigInt() {
2838
2840
  return this.data;
@@ -2904,7 +2906,7 @@ var CairoInt32 = class _CairoInt32 {
2904
2906
  return BigInt(data);
2905
2907
  }
2906
2908
  toApiRequest() {
2907
- return addCompiledFlag([this.toHexString()]);
2909
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
2908
2910
  }
2909
2911
  toBigInt() {
2910
2912
  return this.data;
@@ -2976,7 +2978,7 @@ var CairoInt64 = class _CairoInt64 {
2976
2978
  return BigInt(data);
2977
2979
  }
2978
2980
  toApiRequest() {
2979
- return addCompiledFlag([this.toHexString()]);
2981
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
2980
2982
  }
2981
2983
  toBigInt() {
2982
2984
  return this.data;
@@ -3048,7 +3050,7 @@ var CairoInt128 = class _CairoInt128 {
3048
3050
  return BigInt(data);
3049
3051
  }
3050
3052
  toApiRequest() {
3051
- return addCompiledFlag([this.toHexString()]);
3053
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
3052
3054
  }
3053
3055
  toBigInt() {
3054
3056
  return this.data;
@@ -3212,7 +3214,7 @@ var fastParsingStrategy = {
3212
3214
  return new CairoByteArray(val).toApiRequest();
3213
3215
  },
3214
3216
  [CairoFelt252.abiSelector]: (val) => {
3215
- return felt(val);
3217
+ return new CairoFelt252(val).toApiRequest();
3216
3218
  },
3217
3219
  [CairoUint256.abiSelector]: (val) => {
3218
3220
  return new CairoUint256(val).toApiRequest();
@@ -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, {
@@ -13623,6 +13804,7 @@ function units(amount, simbol = "fri") {
13623
13804
  ValidateType,
13624
13805
  WalletAccount,
13625
13806
  WalletAccountV5,
13807
+ WalletAccountV6,
13626
13808
  WebSocketChannel,
13627
13809
  WebSocketNotConnectedError,
13628
13810
  addAddressPadding,
@@ -13692,6 +13874,7 @@ function units(amount, simbol = "fri") {
13692
13874
  validateChecksumAddress,
13693
13875
  verifyMessageInStarknet,
13694
13876
  wallet,
13695
- walletV5
13877
+ walletV5,
13878
+ walletV6
13696
13879
  });
13697
13880
  //# sourceMappingURL=index.js.map