@deserialize/multi-vm-wallet 1.5.21 → 1.5.31

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.
@@ -13,6 +13,8 @@ import {
13
13
  encodeFunctionData,
14
14
  parseEther,
15
15
  formatEther,
16
+ createPublicClient,
17
+ http,
16
18
  } from 'viem'
17
19
  export interface TransactionParams {
18
20
  to: string
@@ -236,6 +238,16 @@ export const fromChainToViemChain = (config: ChainWalletConfig): Chain => {
236
238
 
237
239
 
238
240
  }
241
+
242
+
243
+ export const createPublicClientFromChainConfig = (chain: ChainWalletConfig): PublicClient => {
244
+ return createPublicClient({
245
+ chain: fromChainToViemChain(chain),
246
+ transport: http(chain.rpcUrl)
247
+ });
248
+ }
249
+
250
+
239
251
  export function viemReceiptToEthersReceipt(
240
252
  receipt: ViemTransactionReceipt,
241
253
  ): EthersTransactionReceipt {
package/utils/index.ts CHANGED
@@ -6,7 +6,7 @@ export * from "./vm"
6
6
  // Note: Utility functions (discoverTokens, getTokenBalance, etc.) have name conflicts
7
7
  // Import them directly from './evm' or './svm' submodules when needed
8
8
  export { EVMVM, EVMChainWallet, EVMSmartWallet } from "./evm"
9
- export { SVMVM, SVMChainWallet, } from "./svm"
9
+ export { SVMVM, SVMChainWallet, SVMChainAddress } from "./svm"
10
10
 
11
11
  // Re-export all EVM exports as namespace to avoid conflicts
12
12
  export * as evm from "./evm"
@@ -17,4 +17,4 @@ export * from "./constant"
17
17
  export * from "bs58"
18
18
  export * from "@solana/web3.js"
19
19
  export * from "./price"
20
- export * from "./utils"
20
+ export * from "./utils"
@@ -43,7 +43,7 @@ import BN from "bn.js";
43
43
  */
44
44
  export class SVMSavingsManager extends SavingsManager<PublicKey, Connection, Keypair> {
45
45
  coinType = 501;
46
- derivationPathBase = "m/44'/501'/";
46
+ derivationPathBase = "m/44'/501'/"; // Base path for account derivation
47
47
 
48
48
  private rpcUrl: string;
49
49
  private _client?: Connection;
package/utils/svm/svm.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Connection, Keypair, PublicKey, Transaction, VersionedTransaction } from "@solana/web3.js";
2
2
  import { SVMDeriveChildPrivateKey } from "../walletBip32";
3
3
  import { VM } from "../vm";
4
- import { ChainWallet } from "../IChainWallet";
4
+ import { ChainAddress, ChainWallet } from "../IChainWallet";
5
5
  import { Balance, ChainWalletConfig, UserTokenBalance, TokenInfo, TransactionResult, NFT, DiscoveredWallet, WalletDiscoveryOptions, WalletDiscoveryResult, PocketDiscoveryOptions } from "../types";
6
6
  import { VMValidation, sanitizeError, logSafeError } from "../vm-validation";
7
7
  import {
@@ -29,10 +29,122 @@ import { fetchPrices } from "../price";
29
29
  import { PriceResponse } from "../price.types";
30
30
  import { getSVMTransactionHistory, SVMTransactionHistoryItem } from "./transactionParsing";
31
31
 
32
+ /**
33
+ * Create a Solana connection for the provided chain configuration.
34
+ *
35
+ * @param config - Chain configuration containing the RPC URL.
36
+ * @returns Solana `Connection` instance.
37
+ */
38
+ export const createSvmConnection = (config: ChainWalletConfig): Connection =>
39
+ new Connection(config.rpcUrl);
40
+
41
+ /**
42
+ * Get native SOL balance for an address.
43
+ *
44
+ * @param address - Solana public key to query.
45
+ * @param connection - Solana connection.
46
+ * @returns Native balance details.
47
+ */
48
+ export const getSvmNativeBalanceForAddress = async (
49
+ address: PublicKey,
50
+ connection: Connection
51
+ ): Promise<Balance> => {
52
+ return await SVMVM.getNativeBalance(address, connection);
53
+ };
54
+
55
+ /**
56
+ * Get SPL token balance for an address.
57
+ *
58
+ * @param address - Wallet public key to query.
59
+ * @param tokenAddress - SPL token mint address.
60
+ * @param connection - Solana connection.
61
+ * @returns Token balance details.
62
+ */
63
+ export const getSvmTokenBalanceForAddress = async (
64
+ address: PublicKey,
65
+ tokenAddress: PublicKey,
66
+ connection: Connection
67
+ ): Promise<Balance> => {
68
+ return await SVMVM.getTokenBalance(address, tokenAddress, connection);
69
+ };
70
+
71
+ /**
72
+ * Discover SPL tokens held by an address.
73
+ *
74
+ * @param address - Wallet public key to scan.
75
+ * @param connection - Solana connection.
76
+ * @returns Discovered token balances.
77
+ */
78
+ export const discoverSvmTokens = async (
79
+ address: PublicKey,
80
+ connection: Connection
81
+ ): Promise<UserTokenBalance<PublicKey>[]> => {
82
+ return await discoverTokens(address, connection);
83
+ };
84
+
85
+ /**
86
+ * Discover NFTs held by an address.
87
+ *
88
+ * @param address - Wallet public key to scan.
89
+ * @param connection - Solana connection.
90
+ * @returns Discovered NFTs.
91
+ */
92
+ export const discoverSvmNFTs = async (
93
+ address: PublicKey,
94
+ connection: Connection
95
+ ): Promise<NFT[]> => {
96
+ return await fetchWalletNfts(address, connection);
97
+ };
98
+
99
+ /**
100
+ * Get parsed transaction history for an address.
101
+ *
102
+ * @param connection - Solana connection.
103
+ * @param address - Wallet public key to inspect.
104
+ * @returns Transaction history entries.
105
+ */
106
+ export const getSvmTransactionHistoryForAddress = async (
107
+ connection: Connection,
108
+ address: PublicKey
109
+ ): Promise<SVMTransactionHistoryItem[]> => {
110
+ return await getSVMTransactionHistory(connection, address);
111
+ };
112
+
113
+ /**
114
+ * Fetch token prices for SVM tokens on the configured chain.
115
+ *
116
+ * @param config - Chain configuration used for chain ID resolution.
117
+ * @param tokenAddresses - Token mint addresses.
118
+ * @returns Price response payload.
119
+ * @throws Error when the price service reports a failure.
120
+ */
121
+ export const getSvmPricesForTokens = async (
122
+ config: ChainWalletConfig,
123
+ tokenAddresses: string[]
124
+ ): Promise<PriceResponse> => {
125
+ const result = await fetchPrices({
126
+ vm: 'SVM',
127
+ chainId: config.chainId,
128
+ tokenAddresses,
129
+ });
130
+
131
+ if (result.error) {
132
+ throw new Error(result.error.message);
133
+ }
134
+
135
+ return result.data as PriceResponse;
136
+ };
137
+
32
138
 
33
139
  export class SVMVM extends VM<PublicKey, Keypair, Connection> {
34
140
  getTokenInfo = getTokenInfo
35
141
  static getTokenInfo = getTokenInfo
142
+ /**
143
+ * Validate that an input can be parsed as a Solana public key.
144
+ *
145
+ * @param address - Address candidate.
146
+ * @returns `true` if valid, otherwise `false`.
147
+ */
36
148
  static validateAddress(address: PublicKey): boolean {
37
149
  try {
38
150
  new PublicKey(address)
@@ -42,15 +154,30 @@ export class SVMVM extends VM<PublicKey, Keypair, Connection> {
42
154
 
43
155
  }
44
156
  }
45
- derivationPath = "m/44'/501'/"; // Default SVM derivation path
157
+ derivationPath = "m/44'/501'/0'/"; // Phantom standard derivation path
46
158
 
47
159
  constructor(seed: string) {
48
160
  super(seed, "SVM");
49
161
  }
50
162
 
163
+ /**
164
+ * Read native SOL balance for a wallet.
165
+ *
166
+ * @param address - Wallet public key.
167
+ * @param connection - Solana connection.
168
+ * @returns Native balance details.
169
+ */
51
170
  static getNativeBalance(address: PublicKey, connection: Connection): Promise<Balance> {
52
171
  return getSvmNativeBalance(address, connection);
53
172
  }
173
+ /**
174
+ * Read SPL token balance for a wallet.
175
+ *
176
+ * @param address - Wallet public key.
177
+ * @param tokenAddress - SPL token mint address.
178
+ * @param connection - Solana connection.
179
+ * @returns Token balance details normalized to `Balance`.
180
+ */
54
181
  static async getTokenBalance(address: PublicKey, tokenAddress: PublicKey, connection: Connection): Promise<Balance> {
55
182
  const balance = await getTokenBalance(address, tokenAddress, connection);
56
183
  if (balance === 0) {
@@ -65,11 +192,26 @@ export class SVMVM extends VM<PublicKey, Keypair, Connection> {
65
192
 
66
193
  static sendTransaction = sendTransaction
67
194
 
195
+ /**
196
+ * Convert entropy bytes (as string) into a Solana keypair seed.
197
+ *
198
+ * @param entropy - Entropy string.
199
+ * @returns Derived Solana keypair.
200
+ */
68
201
  static convertFromEntropyToPrivateKey = (entropy: string): Keypair => {
69
202
  return Keypair.fromSeed(Buffer.from(entropy))
70
203
  }
71
204
 
72
205
 
206
+ /**
207
+ * Derive a child keypair for a wallet index.
208
+ *
209
+ * @param index - Wallet index in derivation path.
210
+ * @param seed - Optional explicit seed (takes priority over mnemonic).
211
+ * @param mnemonic - Optional mnemonic used when seed is not provided.
212
+ * @param derivationPath - Base derivation path prefix.
213
+ * @returns Derived keypair and index.
214
+ */
73
215
  generatePrivateKey(index: number, seed?: string, mnemonic?: string, derivationPath = this.derivationPath) {
74
216
  // Validate inputs
75
217
  VMValidation.validateIndex(index, 'Wallet index');
@@ -95,6 +237,12 @@ export class SVMVM extends VM<PublicKey, Keypair, Connection> {
95
237
 
96
238
 
97
239
 
240
+ /**
241
+ * Create an `SVMVM` instance from a mnemonic phrase.
242
+ *
243
+ * @param mnemonic - BIP-39 mnemonic phrase.
244
+ * @returns Initialized SVM VM instance.
245
+ */
98
246
  static fromMnemonic(mnemonic: string): VM<PublicKey, Keypair, Connection> {
99
247
  const seed = VM.mnemonicToSeed(mnemonic)
100
248
  return new SVMVM(seed)
@@ -562,43 +710,159 @@ export class SVMVM extends VM<PublicKey, Keypair, Connection> {
562
710
  }
563
711
  }
564
712
 
713
+ export class SVMChainAddress extends ChainAddress<PublicKey, Connection> {
714
+ /**
715
+ * Create a chain-address wrapper with a managed Solana connection.
716
+ *
717
+ * @param config - Chain configuration.
718
+ * @param address - Wallet public key.
719
+ * @param index - Optional wallet index.
720
+ */
721
+ constructor(config: ChainWalletConfig, address: PublicKey, index?: number) {
722
+ const connection = createSvmConnection(config);
723
+ super(config, address, index);
724
+ this.connection = connection;
725
+ }
726
+
727
+ /**
728
+ * Get native SOL balance for this address.
729
+ *
730
+ * @returns Native balance details.
731
+ */
732
+ async getNativeBalance(): Promise<Balance> {
733
+ return await getSvmNativeBalanceForAddress(this.address, this.connection!);
734
+ }
735
+
736
+ /**
737
+ * Get SPL token balance for this address.
738
+ *
739
+ * @param tokenAddress - SPL token mint address.
740
+ * @returns Token balance details.
741
+ */
742
+ async getTokenBalance(tokenAddress: PublicKey): Promise<Balance> {
743
+ return await getSvmTokenBalanceForAddress(this.address, tokenAddress, this.connection!);
744
+ }
745
+
746
+ /**
747
+ * Discover SPL tokens held by this address.
748
+ *
749
+ * @returns Discovered token balances.
750
+ */
751
+ async discoverToken(): Promise<UserTokenBalance<PublicKey>[]> {
752
+ return await discoverSvmTokens(this.address, this.connection!);
753
+ }
754
+
755
+ /**
756
+ * Discover NFTs held by this address.
757
+ *
758
+ * @returns Discovered NFTs.
759
+ */
760
+ async discoverNFT(): Promise<NFT[]> {
761
+ return await discoverSvmNFTs(this.address, this.connection!);
762
+ }
763
+
764
+ /**
765
+ * Get transaction history for this address.
766
+ *
767
+ * @returns Parsed transaction history entries.
768
+ */
769
+ async getTransactionHistory(): Promise<SVMTransactionHistoryItem[]> {
770
+ return await getSvmTransactionHistoryForAddress(this.connection!, this.address);
771
+ }
772
+
773
+ /**
774
+ * Fetch price data for token mints.
775
+ *
776
+ * @param tokenAddresses - Token mint addresses.
777
+ * @returns Price response.
778
+ */
779
+ async getPrices(tokenAddresses: string[]): Promise<PriceResponse> {
780
+ return await getSvmPricesForTokens(this.config, tokenAddresses);
781
+ }
782
+ }
783
+
565
784
  export class SVMChainWallet extends ChainWallet<PublicKey, Keypair, Connection> {
785
+ /**
786
+ * Create a chain wallet around a Solana keypair.
787
+ *
788
+ * @param config - Chain configuration.
789
+ * @param privateKey - Wallet keypair.
790
+ * @param index - Wallet index.
791
+ */
566
792
  constructor(config: ChainWalletConfig, privateKey: Keypair, index: number) {
567
- super(config, privateKey, index);
793
+ const address = privateKey.publicKey;
794
+ super(config, address, privateKey, index);
568
795
  this.address = privateKey.publicKey;
569
796
  this.privateKey = privateKey;
570
- this.connection = new Connection(config.rpcUrl)
797
+ this.connection = createSvmConnection(config);
571
798
  }
799
+ /**
800
+ * Get this wallet's public address.
801
+ *
802
+ * @returns Solana public key.
803
+ */
572
804
  generateAddress() {
573
805
  return this.address;
574
806
  }
575
807
 
808
+ /**
809
+ * Convert entropy bytes (as string) into a Solana keypair.
810
+ *
811
+ * @param entropy - Entropy string.
812
+ * @returns Derived keypair.
813
+ */
576
814
  convertFromEntropyToPrivateKey = (entropy: string): Keypair => {
577
815
  return Keypair.fromSeed(Buffer.from(entropy))
578
816
  }
817
+ /**
818
+ * Get native SOL balance for this wallet.
819
+ *
820
+ * @returns Native balance details.
821
+ */
579
822
  async getNativeBalance(): Promise<Balance> {
580
823
  // Implement native balance retrieval logic here
581
- return await SVMVM.getNativeBalance(this.address, this.connection!)
824
+ return await getSvmNativeBalanceForAddress(this.address, this.connection!);
582
825
  }
583
826
 
584
827
 
585
828
 
829
+ /**
830
+ * Get SPL token balance for this wallet.
831
+ *
832
+ * @param tokenAddress - SPL token mint address.
833
+ * @returns Token balance details.
834
+ */
586
835
  async getTokenBalance(tokenAddress: PublicKey): Promise<Balance> {
587
836
  // Implement token balance retrieval logic here
588
- return await SVMVM.getTokenBalance(this.address, (tokenAddress), this.connection!);
837
+ return await getSvmTokenBalanceForAddress(this.address, tokenAddress, this.connection!);
589
838
  }
839
+ /**
840
+ * Discover SPL tokens held by this wallet.
841
+ *
842
+ * @returns Discovered token balances.
843
+ */
590
844
  async discoverToken(): Promise<UserTokenBalance<PublicKey>[]> {
591
845
  // Implement token discovery logic here
592
- const tokens = await discoverTokens(this.address, this.connection!)
593
- return tokens
846
+ return await discoverSvmTokens(this.address, this.connection!);
594
847
  }
595
848
 
849
+ /**
850
+ * Discover NFTs held by this wallet.
851
+ *
852
+ * @returns Discovered NFTs.
853
+ */
596
854
  async discoverNFT(): Promise<NFT[]> {
597
855
  // Implement NFT discovery logic here
598
- const nfts = await fetchWalletNfts(this.address, this.connection!)
599
- return nfts
856
+ return await discoverSvmNFTs(this.address, this.connection!);
600
857
  }
601
858
 
859
+ /**
860
+ * Transfer native SOL to another address.
861
+ *
862
+ * @param to - Recipient public key.
863
+ * @param amount - Amount of SOL to transfer.
864
+ * @returns Transaction result containing signature hash.
865
+ */
602
866
  async transferNative(to: PublicKey, amount: number): Promise<TransactionResult> {
603
867
  // Implement native transfer logic here
604
868
  const transaction = await getTransferNativeTransaction(
@@ -617,6 +881,14 @@ export class SVMChainWallet extends ChainWallet<PublicKey, Keypair, Connection>
617
881
  return { success: true, hash };
618
882
  }
619
883
 
884
+ /**
885
+ * Transfer SPL tokens to another address.
886
+ *
887
+ * @param token - Token info to transfer.
888
+ * @param to - Recipient public key.
889
+ * @param amount - Amount in UI units.
890
+ * @returns Transaction result containing signature hash.
891
+ */
620
892
  async transferToken(token: TokenInfo, to: PublicKey, amount: number): Promise<TransactionResult> {
621
893
  // Implement token transfer logic here
622
894
  const transaction = await getTransferTokenTransaction(
@@ -636,41 +908,74 @@ export class SVMChainWallet extends ChainWallet<PublicKey, Keypair, Connection>
636
908
  return { success: true, hash };
637
909
  }
638
910
 
911
+ /**
912
+ * Sign a transaction with this wallet.
913
+ *
914
+ * @param transaction - Legacy or versioned transaction.
915
+ * @returns Signed transaction.
916
+ */
639
917
  async signTransaction(transaction: VersionedTransaction | Transaction) {
640
918
  return await SVMVM.signTransaction(transaction, this.privateKey)
641
919
  }
642
920
 
921
+ /**
922
+ * Send a pre-signed transaction to the network.
923
+ *
924
+ * @param transaction - Signed legacy or versioned transaction.
925
+ * @returns Transaction signature hash.
926
+ */
643
927
  async sendTransaction(transaction: VersionedTransaction | Transaction) {
644
928
  return await SVMVM.sendTransaction(transaction, this.connection!)
645
929
  }
646
930
 
931
+ /**
932
+ * Sign and send a transaction in one step.
933
+ *
934
+ * @param transaction - Legacy or versioned transaction.
935
+ * @returns Transaction signature hash.
936
+ */
647
937
  async signAndSendTransaction(transaction: VersionedTransaction | Transaction) {
648
938
  return await SVMVM.signAndSendTransaction(transaction, this.connection!, this.privateKey);
649
939
  }
650
940
 
941
+ /**
942
+ * Get transaction history for this wallet.
943
+ *
944
+ * @returns Parsed transaction history entries.
945
+ */
651
946
  async getTransactionHistory(): Promise<SVMTransactionHistoryItem[]> {
652
- const history = await getSVMTransactionHistory(this.connection!, this.address);
653
- return history;
947
+ return await getSvmTransactionHistoryForAddress(this.connection!, this.address);
654
948
  }
655
949
 
950
+ /**
951
+ * Get token metadata for an SPL mint.
952
+ *
953
+ * @param tokenAddress - SPL token mint address.
954
+ * @returns Token metadata from `getTokenInfo`.
955
+ */
656
956
  async getTokenInfo(tokenAddress: PublicKey) {
657
957
  return await SVMVM.getTokenInfo(tokenAddress, this.connection!)
658
958
  }
659
959
 
960
+ /**
961
+ * Fetch prices for provided token mints.
962
+ *
963
+ * @param tokenAddresses - Token mint addresses.
964
+ * @returns Price response.
965
+ */
660
966
  async getPrices(tokenAddresses: string[]): Promise<PriceResponse> {
661
- const result = await fetchPrices({
662
- vm: 'SVM',
663
- chainId: this.config.chainId,
664
- tokenAddresses,
665
- });
666
-
667
- if (result.error) {
668
- throw new Error(result.error.message);
669
- }
670
-
671
- return result.data as PriceResponse;
967
+ return await getSvmPricesForTokens(this.config, tokenAddresses);
672
968
  }
673
969
 
970
+ /**
971
+ * Execute a token swap via Jupiter.
972
+ *
973
+ * @param fromToken - Source token info.
974
+ * @param toToken - Destination token mint.
975
+ * @param amount - Amount in source token UI units.
976
+ * @param slippage - Slippage tolerance in basis points.
977
+ * @returns Transaction result with success/error details.
978
+ */
674
979
  async swap(fromToken: TokenInfo, toToken: PublicKey, amount: number, slippage: number = 50): Promise<TransactionResult> {
675
980
  try {
676
981
  if (amount <= 0) {
@@ -751,6 +1056,15 @@ export class SVMChainWallet extends ChainWallet<PublicKey, Keypair, Connection>
751
1056
  }
752
1057
  }
753
1058
 
1059
+ /**
1060
+ * Fetch a Jupiter quote without sending a transaction.
1061
+ *
1062
+ * @param fromToken - Source token info.
1063
+ * @param toToken - Destination token mint.
1064
+ * @param amount - Amount in source token UI units.
1065
+ * @param slippage - Slippage tolerance in basis points.
1066
+ * @returns Quote payload with input/output values and route data.
1067
+ */
754
1068
  async getSwapQuote(fromToken: TokenInfo, toToken: PublicKey, amount: number, slippage: number = 50): Promise<{
755
1069
  success: boolean;
756
1070
  inputAmount?: string;
@@ -786,8 +1100,14 @@ export class SVMChainWallet extends ChainWallet<PublicKey, Keypair, Connection>
786
1100
  };
787
1101
  }
788
1102
  }
1103
+ /**
1104
+ * Sign raw message bytes using ed25519 detached signature.
1105
+ *
1106
+ * @param message - Message bytes to sign.
1107
+ * @returns Detached signature bytes.
1108
+ */
789
1109
  signMessage = (message: Uint8Array<ArrayBuffer>,) => {
790
1110
  const signature = nacl.sign.detached(message, this.privateKey.secretKey);
791
1111
  return signature
792
1112
  };
793
- }
1113
+ }
package/utils/test.ts CHANGED
@@ -5,10 +5,10 @@ import base58 from "bs58";
5
5
  import { NATIVE_MINT } from "@solana/spl-token";
6
6
  import { Connection, PublicKey, Keypair } from "@solana/web3.js";
7
7
  // import { GenerateNewMnemonic } from "./bip32";
8
- import { SVMChainWallet, SVMVM, } from "./svm";
8
+ import { SVMChainAddress, SVMChainWallet, SVMVM, } from "./svm";
9
9
  import { VM } from "./vm";
10
10
  import { ChainWalletConfig } from "./types";
11
- import { discoverNFTs, EVMChainWallet, EVMVM } from "./evm";
11
+ import { discoverNFTs, EVMChainAddress, EVMChainWallet, EVMVM } from "./evm";
12
12
  import { } from "./svm/transactionParsing";
13
13
  import { getEVMTransactionHistory } from "./evm/transactionParsing";
14
14
  import { createPublicClient, encodeFunctionData, Hex, http, parseAbi, parseUnits, PublicClient, zeroAddress } from "viem";
@@ -53,7 +53,6 @@ const chainConfig: ChainWalletConfig = {
53
53
  confirmationNo: 1,
54
54
  vmType: "SVM",
55
55
  logoUrl: ""
56
-
57
56
  }
58
57
 
59
58
  const evmChainConfig: ChainWalletConfig = {
@@ -388,6 +387,22 @@ const testSavingsPocketMultiChain = async () => {
388
387
  console.log('\n✅ Multi-Chain Savings Test Complete\n');
389
388
  }
390
389
 
390
+ const testEntropy = () => {
391
+ const p = EVMVM.convertFromEntropyToPrivateKey("thishgbmytesentropystringis32bytes!hjkjkhknkjtdyftgkh,jryctdrfygh")
392
+ console.log('p: ', p);
393
+ const res = new EVMChainWallet(evmChainConfig, p, 0)
394
+ console.log('res: ', res);
395
+ }
396
+
397
+ const testAddressClass = async () => {
398
+
399
+ const evmAddressClass = new EVMChainAddress(evmChainConfig, "0xC9C1D854b82BA9b4FB6f6D58E9EF3d1fAEd601AA", 0)
400
+ const res = await evmAddressClass.getNativeBalance()
401
+ console.log('res: ', res);
402
+
403
+ // const svmAddressClass = new SVMChainAddress( )
404
+ }
405
+ testAddressClass()
391
406
  // Uncomment to run tests
392
407
  // testSavingsPocket()
393
408
  // testSavingsPocketSVM()
package/utils/types.ts CHANGED
@@ -18,13 +18,17 @@ export interface ChainWalletConfig {
18
18
  confirmationNo?: number
19
19
  testnet?: boolean;
20
20
  vmType: vmTypes
21
-
21
+ savings?: ChainSavingConfig
22
22
  // Smart wallet configuration (optional) only for EVM chains and 7702
23
-
24
23
  aaSupport?: AA_SupportConfig
25
24
 
26
25
  }
27
26
 
27
+ export interface ChainSavingConfig {
28
+ tokens: string[]; // List of token addresses to track for savings
29
+
30
+ }
31
+
28
32
  export interface AA_SupportConfig {
29
33
  enabled: boolean;
30
34
  entryPoints: {
package/utils/utils.ts CHANGED
@@ -18,3 +18,10 @@ export const getPrivateKeyFromAnother = (privateKey: any, fromVm: vmTypes, toVm:
18
18
  throw new Error("No conversion available for this vms yet")
19
19
  }
20
20
  }
21
+
22
+
23
+ //TODO:
24
+
25
+ // create a unified evm svm balan e querying function
26
+ //create a chain wallet class that takes address and chain config and probably vm
27
+