@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.
@@ -2,24 +2,28 @@ import { EVMTransactionHistoryItem } from "./evm/transactionParsing";
2
2
  import { PriceResponse } from "./price.types";
3
3
  import { SVMTransactionHistoryItem } from "./svm/transactionParsing";
4
4
  import { Balance, ChainWalletConfig, TokenInfo, TransactionResult, UserTokenBalance, NFT } from "./types";
5
- export declare abstract class ChainWallet<AddressType, PrivateKeyType, ConnectionType> {
6
- protected privateKey: PrivateKeyType;
5
+ export declare abstract class ChainAddress<AddressType, ConnectionType> {
7
6
  config: ChainWalletConfig;
8
7
  address: AddressType;
9
8
  index: number | undefined;
10
9
  connection: ConnectionType | undefined;
11
- constructor(config: ChainWalletConfig, privateKey: PrivateKeyType, index?: number);
12
- abstract generateAddress(privateKey: PrivateKeyType): AddressType;
10
+ constructor(config: ChainWalletConfig, address: AddressType, index?: number);
13
11
  abstract getNativeBalance(): Promise<Balance>;
14
12
  abstract getTokenBalance(tokenAddress: AddressType): Promise<Balance>;
15
- abstract transferNative(to: AddressType, amount: number): Promise<TransactionResult>;
16
- abstract transferToken(tokenAddress: TokenInfo, to: AddressType, amount: number): Promise<TransactionResult>;
17
- abstract swap(tokenAddress: TokenInfo, to: AddressType, amount: number, slippage?: number): Promise<TransactionResult>;
18
13
  abstract discoverToken(): Promise<UserTokenBalance<AddressType>[]>;
19
14
  abstract discoverNFT(): Promise<NFT[]>;
20
15
  abstract getTransactionHistory(): Promise<(SVMTransactionHistoryItem | EVMTransactionHistoryItem)[]>;
21
16
  abstract getPrices(tokenAddresses: string[]): Promise<PriceResponse>;
22
17
  getAddress(): AddressType;
23
18
  getChainWalletConfig(): ChainWalletConfig;
19
+ }
20
+ export declare abstract class ChainWallet<AddressType, PrivateKeyType, ConnectionType> extends ChainAddress<AddressType, ConnectionType> {
21
+ protected privateKey: PrivateKeyType;
22
+ constructor(config: ChainWalletConfig, address: AddressType, privateKey: PrivateKeyType, index?: number);
23
+ protected abstract generateAddress(privateKey: PrivateKeyType): AddressType;
24
+ abstract transferNative(to: AddressType, amount: number): Promise<TransactionResult>;
25
+ abstract transferToken(tokenAddress: TokenInfo, to: AddressType, amount: number): Promise<TransactionResult>;
26
+ abstract swap(tokenAddress: TokenInfo, to: AddressType, amount: number, slippage?: number): Promise<TransactionResult>;
24
27
  abstract convertFromEntropyToPrivateKey(entropy: string): PrivateKeyType;
28
+ protected getPrivateKey(): PrivateKeyType;
25
29
  }
@@ -1,16 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ChainWallet = void 0;
4
- class ChainWallet {
5
- privateKey;
3
+ exports.ChainWallet = exports.ChainAddress = void 0;
4
+ class ChainAddress {
6
5
  config;
7
6
  address;
8
7
  index;
9
8
  connection;
10
- constructor(config, privateKey, index) {
9
+ constructor(config, address, index) {
11
10
  this.config = config;
12
- this.privateKey = privateKey;
13
- this.address = this.generateAddress(privateKey);
11
+ this.address = address;
14
12
  this.index = index;
15
13
  }
16
14
  getAddress() {
@@ -20,4 +18,15 @@ class ChainWallet {
20
18
  return this.config;
21
19
  }
22
20
  }
21
+ exports.ChainAddress = ChainAddress;
22
+ class ChainWallet extends ChainAddress {
23
+ privateKey;
24
+ constructor(config, address, privateKey, index) {
25
+ super(config, address, index);
26
+ this.privateKey = privateKey;
27
+ }
28
+ getPrivateKey() {
29
+ return this.privateKey;
30
+ }
31
+ }
23
32
  exports.ChainWallet = ChainWallet;
package/dist/constant.js CHANGED
@@ -3,32 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TRANSACTION_TYPE = exports.DefaultChains = void 0;
4
4
  const chains_1 = require("viem/chains");
5
5
  exports.DefaultChains = [{
6
- chainId: 24101,
7
- name: "Incentiv",
8
- rpcUrl: "https://rpc.incentiv.io",
9
- explorerUrl: "https://explorer.incentiv.io",
10
- nativeToken: {
11
- name: "Incentiv",
12
- symbol: "CENT",
13
- decimals: 18,
14
- },
15
- testnet: false,
16
- logoUrl: "https://incentiv.io/wp-content/uploads/2024/09/cropped-Favicon-1-32x32.png",
17
- vmType: "EVM"
18
- }, {
19
- chainId: 16661,
20
- name: "0G",
21
- rpcUrl: "https://evmrpc.0g.ai",
22
- explorerUrl: "https://chainscan.0g.ai/",
23
- nativeToken: {
24
- name: "OG Mainnet",
25
- symbol: "0G",
26
- decimals: 18,
27
- },
28
- testnet: false,
29
- logoUrl: "https://chainscan.0g.ai/static/media/zg-logo-new.b22d59dabf457524325ca81c29a4e055.svg",
30
- vmType: "EVM"
31
- }, {
32
6
  chainId: 123456789,
33
7
  name: "Solana",
34
8
  rpcUrl: "https://solana-mainnet.g.alchemy.com/v2/TFdA4BilCnKIwaqtypk0d",
@@ -40,7 +14,10 @@ exports.DefaultChains = [{
40
14
  },
41
15
  testnet: false,
42
16
  logoUrl: "https://solana.com/src/img/branding/solanaLogoMark.svg",
43
- vmType: "SVM"
17
+ vmType: "SVM",
18
+ savings: {
19
+ tokens: []
20
+ }
44
21
  },
45
22
  {
46
23
  chainId: 1,
@@ -67,7 +44,10 @@ exports.DefaultChains = [{
67
44
  },
68
45
  testnet: false,
69
46
  logoUrl: "https://bscscan.com/assets/bsc/images/svg/logos/token-light.svg?v=25.10.5.0",
70
- vmType: "EVM"
47
+ vmType: "EVM",
48
+ savings: {
49
+ tokens: []
50
+ }
71
51
  },
72
52
  {
73
53
  chainId: chains_1.base.id,
@@ -81,35 +61,44 @@ exports.DefaultChains = [{
81
61
  },
82
62
  testnet: chains_1.base.testnet,
83
63
  logoUrl: "https://avatars.githubusercontent.com/u/108554348?s=200&v=4",
84
- vmType: "EVM"
64
+ vmType: "EVM",
65
+ savings: {
66
+ tokens: []
67
+ }
85
68
  },
86
69
  {
87
- chainId: 42161,
88
- name: "Arbitrum One",
89
- rpcUrl: "https://arbitrum-mainnet.g.alchemy.com/v2/TFdA4BilCnKIwaqtypk0d",
90
- explorerUrl: "https://arbiscan.io",
70
+ chainId: chains_1.arbitrum.id,
71
+ name: chains_1.arbitrum.name,
72
+ rpcUrl: chains_1.arbitrum.rpcUrls.default.http[0],
73
+ explorerUrl: chains_1.arbitrum.blockExplorers?.default.url,
91
74
  nativeToken: {
92
- name: "Ether",
93
- symbol: "ETH",
94
- decimals: 18,
75
+ name: chains_1.arbitrum.nativeCurrency.name,
76
+ symbol: chains_1.arbitrum.nativeCurrency.symbol,
77
+ decimals: chains_1.arbitrum.nativeCurrency.decimals,
95
78
  },
96
79
  testnet: false,
97
- logoUrl: "https://arbiscan.io/images/svg/brands/arbitrum-light.svg?v=0.0.36",
98
- vmType: "EVM"
80
+ logoUrl: "https://avatars.githubusercontent.com/u/119917794?s=280&v=4",
81
+ vmType: "EVM",
82
+ savings: {
83
+ tokens: []
84
+ }
99
85
  },
100
86
  {
101
- chainId: 10,
102
- name: "Optimism",
103
- rpcUrl: "https://optimism-mainnet.g.alchemy.com/v2/TFdA4BilCnKIwaqtypk0d",
104
- explorerUrl: "https://optimistic.etherscan.io",
87
+ chainId: chains_1.optimism.id,
88
+ name: chains_1.optimism.name,
89
+ rpcUrl: chains_1.optimism.rpcUrls.default.http[0],
90
+ explorerUrl: chains_1.optimism.blockExplorers?.default.url,
105
91
  nativeToken: {
106
- name: "Ether",
107
- symbol: "ETH",
108
- decimals: 18,
92
+ name: chains_1.optimism.nativeCurrency.name,
93
+ symbol: chains_1.optimism.nativeCurrency.symbol,
94
+ decimals: chains_1.optimism.nativeCurrency.decimals,
109
95
  },
110
96
  testnet: false,
111
- logoUrl: "https://optimism.io/images/optimism-logo-light.svg",
112
- vmType: "EVM"
97
+ logoUrl: "https://avatars.githubusercontent.com/u/58791460?s=280&v=4",
98
+ vmType: "EVM",
99
+ savings: {
100
+ tokens: []
101
+ }
113
102
  },
114
103
  {
115
104
  chainId: 137,
@@ -123,7 +112,10 @@ exports.DefaultChains = [{
123
112
  },
124
113
  testnet: false,
125
114
  logoUrl: "https://polygonscan.com/images/svg/brands/polygon-light.svg?v=0.0.36",
126
- vmType: "EVM"
115
+ vmType: "EVM",
116
+ savings: {
117
+ tokens: []
118
+ }
127
119
  }
128
120
  ];
129
121
  exports.TRANSACTION_TYPE = {
package/dist/evm/evm.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ChainWallet } from "../IChainWallet";
1
+ import { ChainAddress, ChainWallet } from "../IChainWallet";
2
2
  import { Balance, ChainWalletConfig, UserTokenBalance, TokenInfo, TransactionResult, NFT, WalletDiscoveryOptions, WalletDiscoveryResult, PocketDiscoveryOptions } from "../types";
3
3
  import { VM } from "../vm";
4
4
  import { JsonRpcProvider } from "ethers";
@@ -7,6 +7,15 @@ import { Hex, WalletClient, PublicClient } from "viem";
7
7
  import { EVMSmartWallet } from "./smartWallet";
8
8
  import { SmartWalletOptions } from "./aa-service";
9
9
  import { PriceResponse } from "../price.types";
10
+ import { Account } from "viem/accounts";
11
+ export declare const createEvmPublicClient: (config: ChainWalletConfig) => PublicClient;
12
+ export declare const createEvmWalletClient: (config: ChainWalletConfig, account: Account) => WalletClient;
13
+ export declare const getEvmTransactionHistorySafe: (connection: PublicClient, address: string) => Promise<EVMTransactionHistoryItem[]>;
14
+ export declare const getSvmPricesForTokens: (config: ChainWalletConfig, tokenAddresses: string[]) => Promise<PriceResponse>;
15
+ export declare const getEvmNativeBalance: (address: string, connection: PublicClient) => Promise<Balance>;
16
+ export declare const getEvmTokenBalance: (address: string, tokenAddress: string, connection: PublicClient) => Promise<Balance>;
17
+ export declare const discoverEvmTokens: (address: string, config: ChainWalletConfig) => Promise<UserTokenBalance<string>[]>;
18
+ export declare const discoverEvmNFTs: (address: string, config: ChainWalletConfig) => Promise<NFT[]>;
10
19
  export declare class EVMVM extends VM<string, string, PublicClient> {
11
20
  derivationPath: string;
12
21
  constructor(seed: string);
@@ -29,6 +38,15 @@ export declare class EVMVM extends VM<string, string, PublicClient> {
29
38
  discoverPockets(connection: JsonRpcProvider | PublicClient, options?: PocketDiscoveryOptions): Promise<WalletDiscoveryResult>;
30
39
  private checkPocketBalance;
31
40
  }
41
+ export declare class EVMChainAddress extends ChainAddress<string, PublicClient> {
42
+ constructor(config: ChainWalletConfig, address: string, index?: number);
43
+ getNativeBalance(): Promise<Balance>;
44
+ getTokenBalance(tokenAddress: string): Promise<Balance>;
45
+ discoverToken(): Promise<UserTokenBalance<string>[]>;
46
+ discoverNFT(): Promise<NFT[]>;
47
+ getTransactionHistory(): Promise<EVMTransactionHistoryItem[]>;
48
+ getPrices(tokenAddresses: string[]): Promise<PriceResponse>;
49
+ }
32
50
  export declare class EVMChainWallet extends ChainWallet<string, string, PublicClient> {
33
51
  wallet: WalletClient;
34
52
  private smartWallet?;
package/dist/evm/evm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EVMChainWallet = exports.EVMVM = void 0;
3
+ exports.EVMChainWallet = exports.EVMChainAddress = exports.EVMVM = exports.discoverEvmNFTs = exports.discoverEvmTokens = exports.getEvmTokenBalance = exports.getEvmNativeBalance = exports.getSvmPricesForTokens = exports.getEvmTransactionHistorySafe = exports.createEvmWalletClient = exports.createEvmPublicClient = void 0;
4
4
  const walletBip32_1 = require("../walletBip32");
5
5
  const IChainWallet_1 = require("../IChainWallet");
6
6
  const vm_1 = require("../vm");
@@ -12,6 +12,54 @@ const viem_1 = require("viem");
12
12
  const smartWallet_1 = require("./smartWallet");
13
13
  const price_1 = require("../price");
14
14
  const accounts_1 = require("viem/accounts");
15
+ const createEvmPublicClient = (config) => (0, viem_1.createPublicClient)({
16
+ chain: (0, utils_1.fromChainToViemChain)(config),
17
+ transport: (0, viem_1.http)(config.rpcUrl),
18
+ });
19
+ exports.createEvmPublicClient = createEvmPublicClient;
20
+ const createEvmWalletClient = (config, account) => (0, viem_1.createWalletClient)({
21
+ account,
22
+ chain: (0, utils_1.fromChainToViemChain)(config),
23
+ transport: (0, viem_1.http)(config.rpcUrl),
24
+ });
25
+ exports.createEvmWalletClient = createEvmWalletClient;
26
+ const getEvmTransactionHistorySafe = async (connection, address) => {
27
+ try {
28
+ return await (0, transactionParsing_1.getEVMTransactionHistory)(connection, address);
29
+ }
30
+ catch {
31
+ return [];
32
+ }
33
+ };
34
+ exports.getEvmTransactionHistorySafe = getEvmTransactionHistorySafe;
35
+ const getSvmPricesForTokens = async (config, tokenAddresses) => {
36
+ const result = await (0, price_1.fetchPrices)({
37
+ vm: 'EVM',
38
+ chainId: config.chainId,
39
+ tokenAddresses,
40
+ });
41
+ if (result.error) {
42
+ throw new Error(result.error.message);
43
+ }
44
+ return result.data;
45
+ };
46
+ exports.getSvmPricesForTokens = getSvmPricesForTokens;
47
+ const getEvmNativeBalance = async (address, connection) => {
48
+ return await EVMVM.getNativeBalance(address, connection);
49
+ };
50
+ exports.getEvmNativeBalance = getEvmNativeBalance;
51
+ const getEvmTokenBalance = async (address, tokenAddress, connection) => {
52
+ return await EVMVM.getTokenBalance(address, tokenAddress, connection);
53
+ };
54
+ exports.getEvmTokenBalance = getEvmTokenBalance;
55
+ const discoverEvmTokens = async (address, config) => {
56
+ return await (0, utils_1.discoverTokens)(address, config);
57
+ };
58
+ exports.discoverEvmTokens = discoverEvmTokens;
59
+ const discoverEvmNFTs = async (address, config) => {
60
+ return await (0, utils_1.discoverNFTs)(address, config);
61
+ };
62
+ exports.discoverEvmNFTs = discoverEvmNFTs;
15
63
  class EVMVM extends vm_1.VM {
16
64
  derivationPath = "m/44'/60'/0'/0/";
17
65
  constructor(seed) {
@@ -72,7 +120,8 @@ class EVMVM extends vm_1.VM {
72
120
  return await (0, utils_1.getTokenBalance)(tokenAddress, address, connection);
73
121
  }
74
122
  static convertFromEntropyToPrivateKey = (entropy) => {
75
- return (0, viem_1.toHex)(entropy).substring(0, 64);
123
+ const p = ethers_1.ethers.id(entropy);
124
+ return p;
76
125
  };
77
126
  async discoverWallets(connection, options) {
78
127
  const startTime = Date.now();
@@ -387,24 +436,46 @@ class EVMVM extends vm_1.VM {
387
436
  }
388
437
  }
389
438
  exports.EVMVM = EVMVM;
439
+ class EVMChainAddress extends IChainWallet_1.ChainAddress {
440
+ constructor(config, address, index) {
441
+ const connection = (0, exports.createEvmPublicClient)(config);
442
+ super(config, address, index);
443
+ this.connection = connection;
444
+ }
445
+ async getNativeBalance() {
446
+ return await (0, exports.getEvmNativeBalance)(this.address, this.connection);
447
+ }
448
+ async getTokenBalance(tokenAddress) {
449
+ return await (0, exports.getEvmTokenBalance)(this.address, tokenAddress, this.connection);
450
+ }
451
+ async discoverToken() {
452
+ return await (0, exports.discoverEvmTokens)(this.address, this.config);
453
+ }
454
+ async discoverNFT() {
455
+ return await (0, exports.discoverEvmNFTs)(this.address, this.config);
456
+ }
457
+ async getTransactionHistory() {
458
+ return await (0, exports.getEvmTransactionHistorySafe)(this.connection, this.address);
459
+ }
460
+ async getPrices(tokenAddresses) {
461
+ return await (0, exports.getSvmPricesForTokens)(this.config, tokenAddresses);
462
+ }
463
+ }
464
+ exports.EVMChainAddress = EVMChainAddress;
390
465
  class EVMChainWallet extends IChainWallet_1.ChainWallet {
391
466
  wallet;
392
467
  smartWallet;
393
468
  constructor(config, privateKey, index) {
394
469
  privateKey = privateKey.startsWith('0x') ? privateKey : `0x${privateKey}`;
395
- super(config, privateKey, index);
396
- this.connection = (0, viem_1.createPublicClient)({
397
- chain: (0, utils_1.fromChainToViemChain)(config),
398
- transport: (0, viem_1.http)(config.rpcUrl)
399
- });
470
+ const connection = (0, exports.createEvmPublicClient)(config);
400
471
  const account = (0, accounts_1.privateKeyToAccount)(privateKey);
401
- this.wallet = (0, viem_1.createWalletClient)({
402
- account,
403
- chain: (0, utils_1.fromChainToViemChain)(config),
404
- transport: (0, viem_1.http)(config.rpcUrl)
405
- });
406
- this.address = account.address;
472
+ const wallet = (0, exports.createEvmWalletClient)(config, account);
473
+ const address = account.address;
474
+ super(config, address, privateKey, index);
407
475
  this.privateKey = privateKey;
476
+ this.wallet = wallet;
477
+ this.connection = connection;
478
+ this.address = address;
408
479
  }
409
480
  isAASupportedByChain() {
410
481
  return this.config.aaSupport?.enabled === true;
@@ -497,19 +568,19 @@ class EVMChainWallet extends IChainWallet_1.ChainWallet {
497
568
  return this.address;
498
569
  }
499
570
  async getNativeBalance() {
500
- return await EVMVM.getNativeBalance(this.address, this.connection);
571
+ return await (0, exports.getEvmNativeBalance)(this.address, this.connection);
501
572
  }
502
573
  async getTokenBalance(tokenAddress) {
503
- return await EVMVM.getTokenBalance(this.address, tokenAddress, this.connection);
574
+ return await (0, exports.getEvmTokenBalance)(this.address, tokenAddress, this.connection);
504
575
  }
505
576
  async getTokenInfo(tokenAddress) {
506
577
  return await EVMVM.getTokenInfo(tokenAddress, this.connection);
507
578
  }
508
579
  async discoverToken() {
509
- return await (0, utils_1.discoverTokens)(this.address, this.config);
580
+ return await (0, exports.discoverEvmTokens)(this.address, this.config);
510
581
  }
511
582
  async discoverNFT() {
512
- return await (0, utils_1.discoverNFTs)(this.address, this.config);
583
+ return await (0, exports.discoverEvmNFTs)(this.address, this.config);
513
584
  }
514
585
  async transferNative(to, amount) {
515
586
  const wallet = this.getWallet();
@@ -522,23 +593,10 @@ class EVMChainWallet extends IChainWallet_1.ChainWallet {
522
593
  async getTransactionHistory() {
523
594
  const wallet = this.getWallet();
524
595
  let res;
525
- try {
526
- return await (0, transactionParsing_1.getEVMTransactionHistory)(this.connection, this.address);
527
- }
528
- catch (error) {
529
- return [];
530
- }
596
+ return await (0, exports.getEvmTransactionHistorySafe)(this.connection, this.address);
531
597
  }
532
598
  async getPrices(tokenAddresses) {
533
- const result = await (0, price_1.fetchPrices)({
534
- vm: 'EVM',
535
- chainId: this.config.chainId,
536
- tokenAddresses,
537
- });
538
- if (result.error) {
539
- throw new Error(result.error.message);
540
- }
541
- return result.data;
599
+ return await (0, exports.getSvmPricesForTokens)(this.config, tokenAddresses);
542
600
  }
543
601
  async swap(tokenAddress, to, amount, slippage = 50) {
544
602
  throw new Error("Not Implemented");
@@ -176,6 +176,7 @@ export declare const ERC20_ABI: readonly [{
176
176
  }];
177
177
  }];
178
178
  export declare const fromChainToViemChain: (config: ChainWalletConfig) => Chain;
179
+ export declare const createPublicClientFromChainConfig: (chain: ChainWalletConfig) => PublicClient;
179
180
  export declare function viemReceiptToEthersReceipt(receipt: ViemTransactionReceipt): EthersTransactionReceipt;
180
181
  export declare const getNativeBalance: (address: Hex, client: PublicClient) => Promise<Balance>;
181
182
  export declare const getTokenInfo: (tokenAddress: Hex, client: PublicClient) => Promise<TokenInfo>;
package/dist/evm/utils.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getNFTCollection = exports.discoverAllNFTs = exports.discoverNFTs = exports.transformEVMNFTToUnified = exports.discoverTokens = exports.safeApprove = exports.resetAllowance = exports.checkAndApprove = exports.approveTokenUnlimited = exports.approveToken = exports.isAllowanceSufficient = exports.checkAllowance = exports.estimateGas = exports.getGasPrices = exports.sendERC20Token = exports.sendNativeToken = exports.signSendAndConfirm = exports.getTokenBalance = exports.getTokenInfo = exports.getNativeBalance = exports.fromChainToViemChain = exports.ERC20_ABI = exports.DESERIALIZED_SUPPORTED_CHAINS = void 0;
6
+ exports.getNFTCollection = exports.discoverAllNFTs = exports.discoverNFTs = exports.transformEVMNFTToUnified = exports.discoverTokens = exports.safeApprove = exports.resetAllowance = exports.checkAndApprove = exports.approveTokenUnlimited = exports.approveToken = exports.isAllowanceSufficient = exports.checkAllowance = exports.estimateGas = exports.getGasPrices = exports.sendERC20Token = exports.sendNativeToken = exports.signSendAndConfirm = exports.getTokenBalance = exports.getTokenInfo = exports.getNativeBalance = exports.createPublicClientFromChainConfig = exports.fromChainToViemChain = exports.ERC20_ABI = exports.DESERIALIZED_SUPPORTED_CHAINS = void 0;
7
7
  exports.viemReceiptToEthersReceipt = viemReceiptToEthersReceipt;
8
8
  exports.calcGasTotal = calcGasTotal;
9
9
  exports.toPrecisionWithoutTrailingZeros = toPrecisionWithoutTrailingZeros;
@@ -112,6 +112,13 @@ const fromChainToViemChain = (config) => {
112
112
  };
113
113
  };
114
114
  exports.fromChainToViemChain = fromChainToViemChain;
115
+ const createPublicClientFromChainConfig = (chain) => {
116
+ return (0, viem_1.createPublicClient)({
117
+ chain: (0, exports.fromChainToViemChain)(chain),
118
+ transport: (0, viem_1.http)(chain.rpcUrl)
119
+ });
120
+ };
121
+ exports.createPublicClientFromChainConfig = createPublicClientFromChainConfig;
115
122
  function viemReceiptToEthersReceipt(receipt) {
116
123
  return {
117
124
  to: receipt.to ?? null,
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@ export * from "./walletBip32";
2
2
  export * from "./types";
3
3
  export * from "./vm";
4
4
  export { EVMVM, EVMChainWallet, EVMSmartWallet } from "./evm";
5
- export { SVMVM, SVMChainWallet, } from "./svm";
5
+ export { SVMVM, SVMChainWallet, SVMChainAddress } from "./svm";
6
6
  export * as evm from "./evm";
7
7
  export * as svm from "./svm";
8
8
  export * from "./constant";
package/dist/index.js CHANGED
@@ -36,7 +36,7 @@ var __importStar = (this && this.__importStar) || (function () {
36
36
  };
37
37
  })();
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.svm = exports.evm = exports.SVMChainWallet = exports.SVMVM = exports.EVMSmartWallet = exports.EVMChainWallet = exports.EVMVM = void 0;
39
+ exports.svm = exports.evm = exports.SVMChainAddress = exports.SVMChainWallet = exports.SVMVM = exports.EVMSmartWallet = exports.EVMChainWallet = exports.EVMVM = void 0;
40
40
  __exportStar(require("./walletBip32"), exports);
41
41
  __exportStar(require("./types"), exports);
42
42
  __exportStar(require("./vm"), exports);
@@ -47,6 +47,7 @@ Object.defineProperty(exports, "EVMSmartWallet", { enumerable: true, get: functi
47
47
  var svm_1 = require("./svm");
48
48
  Object.defineProperty(exports, "SVMVM", { enumerable: true, get: function () { return svm_1.SVMVM; } });
49
49
  Object.defineProperty(exports, "SVMChainWallet", { enumerable: true, get: function () { return svm_1.SVMChainWallet; } });
50
+ Object.defineProperty(exports, "SVMChainAddress", { enumerable: true, get: function () { return svm_1.SVMChainAddress; } });
50
51
  exports.evm = __importStar(require("./evm"));
51
52
  exports.svm = __importStar(require("./svm"));
52
53
  __exportStar(require("./constant"), exports);
package/dist/svm/svm.d.ts CHANGED
@@ -1,10 +1,17 @@
1
1
  import { Connection, Keypair, PublicKey, Transaction, VersionedTransaction } from "@solana/web3.js";
2
2
  import { VM } from "../vm";
3
- import { ChainWallet } from "../IChainWallet";
3
+ import { ChainAddress, ChainWallet } from "../IChainWallet";
4
4
  import { Balance, ChainWalletConfig, UserTokenBalance, TokenInfo, TransactionResult, NFT, WalletDiscoveryOptions, WalletDiscoveryResult, PocketDiscoveryOptions } from "../types";
5
5
  import { JupiterQuoteResponse } from "./utils";
6
6
  import { PriceResponse } from "../price.types";
7
7
  import { SVMTransactionHistoryItem } from "./transactionParsing";
8
+ export declare const createSvmConnection: (config: ChainWalletConfig) => Connection;
9
+ export declare const getSvmNativeBalanceForAddress: (address: PublicKey, connection: Connection) => Promise<Balance>;
10
+ export declare const getSvmTokenBalanceForAddress: (address: PublicKey, tokenAddress: PublicKey, connection: Connection) => Promise<Balance>;
11
+ export declare const discoverSvmTokens: (address: PublicKey, connection: Connection) => Promise<UserTokenBalance<PublicKey>[]>;
12
+ export declare const discoverSvmNFTs: (address: PublicKey, connection: Connection) => Promise<NFT[]>;
13
+ export declare const getSvmTransactionHistoryForAddress: (connection: Connection, address: PublicKey) => Promise<SVMTransactionHistoryItem[]>;
14
+ export declare const getSvmPricesForTokens: (config: ChainWalletConfig, tokenAddresses: string[]) => Promise<PriceResponse>;
8
15
  export declare class SVMVM extends VM<PublicKey, Keypair, Connection> {
9
16
  getTokenInfo: (tokenAddress: PublicKey, connection: Connection, programId?: PublicKey) => Promise<TokenInfo>;
10
17
  static getTokenInfo: (tokenAddress: PublicKey, connection: Connection, programId?: PublicKey) => Promise<TokenInfo>;
@@ -36,6 +43,15 @@ export declare class SVMVM extends VM<PublicKey, Keypair, Connection> {
36
43
  discoverPockets(connection: Connection, options?: PocketDiscoveryOptions): Promise<WalletDiscoveryResult>;
37
44
  private checkPocketBalance;
38
45
  }
46
+ export declare class SVMChainAddress extends ChainAddress<PublicKey, Connection> {
47
+ constructor(config: ChainWalletConfig, address: PublicKey, index?: number);
48
+ getNativeBalance(): Promise<Balance>;
49
+ getTokenBalance(tokenAddress: PublicKey): Promise<Balance>;
50
+ discoverToken(): Promise<UserTokenBalance<PublicKey>[]>;
51
+ discoverNFT(): Promise<NFT[]>;
52
+ getTransactionHistory(): Promise<SVMTransactionHistoryItem[]>;
53
+ getPrices(tokenAddresses: string[]): Promise<PriceResponse>;
54
+ }
39
55
  export declare class SVMChainWallet extends ChainWallet<PublicKey, Keypair, Connection> {
40
56
  constructor(config: ChainWalletConfig, privateKey: Keypair, index: number);
41
57
  generateAddress(): PublicKey;