@swapkit/helpers 1.0.0-rc.9 → 1.0.0-rc.90

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.
Files changed (38) hide show
  1. package/dist/index.js +2065 -0
  2. package/dist/index.js.map +28 -0
  3. package/package.json +24 -37
  4. package/src/helpers/__tests__/asset.test.ts +126 -108
  5. package/src/helpers/__tests__/memo.test.ts +52 -40
  6. package/src/helpers/__tests__/others.test.ts +42 -37
  7. package/src/helpers/__tests__/validators.test.ts +24 -0
  8. package/src/helpers/asset.ts +119 -87
  9. package/src/helpers/liquidity.ts +50 -43
  10. package/src/helpers/memo.ts +31 -28
  11. package/src/helpers/others.ts +29 -12
  12. package/src/helpers/validators.ts +15 -6
  13. package/src/helpers/web3wallets.ts +178 -0
  14. package/src/index.ts +13 -9
  15. package/src/modules/__tests__/assetValue.test.ts +325 -116
  16. package/src/modules/__tests__/bigIntArithmetics.test.ts +30 -0
  17. package/src/modules/__tests__/swapKitNumber.test.ts +306 -183
  18. package/src/modules/assetValue.ts +216 -152
  19. package/src/modules/bigIntArithmetics.ts +214 -147
  20. package/src/modules/requestClient.ts +29 -0
  21. package/src/modules/swapKitError.ts +32 -5
  22. package/src/modules/swapKitNumber.ts +8 -1
  23. package/src/types/abis/erc20.ts +99 -0
  24. package/src/types/abis/tcEthVault.ts +496 -0
  25. package/src/types/chains.ts +220 -0
  26. package/src/types/commonTypes.ts +119 -0
  27. package/src/types/derivationPath.ts +56 -0
  28. package/src/types/index.ts +10 -0
  29. package/src/types/network.ts +43 -0
  30. package/src/types/sdk.ts +11 -0
  31. package/src/types/tokens.ts +30 -0
  32. package/src/types/transactions.ts +45 -0
  33. package/src/types/wallet.ts +39 -0
  34. package/LICENSE +0 -201
  35. package/dist/index.cjs +0 -1
  36. package/dist/index.d.ts +0 -354
  37. package/dist/index.es.js +0 -1054
  38. package/src/helpers/request.ts +0 -16
@@ -0,0 +1,220 @@
1
+ import { ExplorerUrl, RPCUrl } from "./network";
2
+
3
+ export enum Chain {
4
+ Arbitrum = "ARB",
5
+ Avalanche = "AVAX",
6
+ Binance = "BNB",
7
+ BinanceSmartChain = "BSC",
8
+ Bitcoin = "BTC",
9
+ BitcoinCash = "BCH",
10
+ Cosmos = "GAIA",
11
+ Dash = "DASH",
12
+ Dogecoin = "DOGE",
13
+ Ethereum = "ETH",
14
+ Kujira = "KUJI",
15
+ Litecoin = "LTC",
16
+ Maya = "MAYA",
17
+ Optimism = "OP",
18
+ Polkadot = "DOT",
19
+ Chainflip = "FLIP",
20
+ Polygon = "MATIC",
21
+ THORChain = "THOR",
22
+ }
23
+
24
+ export enum ChainId {
25
+ Arbitrum = "42161",
26
+ ArbitrumHex = "0xa4b1",
27
+ Avalanche = "43114",
28
+ AvalancheHex = "0xa86a",
29
+ Binance = "Binance-Chain-Tigris",
30
+ BinanceSmartChain = "56",
31
+ BinanceSmartChainHex = "0x38",
32
+ Bitcoin = "bitcoin",
33
+ BitcoinCash = "bitcoincash",
34
+ Chainflip = "chainflip",
35
+ Cosmos = "cosmoshub-4",
36
+ Dash = "dash",
37
+ Dogecoin = "dogecoin",
38
+ Kujira = "kaiyo-1",
39
+ Ethereum = "1",
40
+ EthereumHex = "0x1",
41
+ Litecoin = "litecoin",
42
+ Maya = "mayachain-mainnet-v1",
43
+ MayaStagenet = "mayachain-stagenet-v1",
44
+ Optimism = "10",
45
+ OptimismHex = "0xa",
46
+ Polkadot = "polkadot",
47
+ Polygon = "137",
48
+ PolygonHex = "0x89",
49
+ THORChain = "thorchain-mainnet-v1",
50
+ THORChainStagenet = "thorchain-stagenet-v2",
51
+ }
52
+
53
+ export const ChainIdToChain: Record<ChainId, Chain> = {
54
+ [ChainId.ArbitrumHex]: Chain.Arbitrum,
55
+ [ChainId.Arbitrum]: Chain.Arbitrum,
56
+ [ChainId.AvalancheHex]: Chain.Avalanche,
57
+ [ChainId.Avalanche]: Chain.Avalanche,
58
+ [ChainId.BinanceSmartChainHex]: Chain.BinanceSmartChain,
59
+ [ChainId.BinanceSmartChain]: Chain.BinanceSmartChain,
60
+ [ChainId.Binance]: Chain.Binance,
61
+ [ChainId.BitcoinCash]: Chain.BitcoinCash,
62
+ [ChainId.Bitcoin]: Chain.Bitcoin,
63
+ [ChainId.Chainflip]: Chain.Chainflip,
64
+ [ChainId.Cosmos]: Chain.Cosmos,
65
+ [ChainId.Dash]: Chain.Dash,
66
+ [ChainId.Dogecoin]: Chain.Dogecoin,
67
+ [ChainId.EthereumHex]: Chain.Ethereum,
68
+ [ChainId.Kujira]: Chain.Kujira,
69
+ [ChainId.Ethereum]: Chain.Ethereum,
70
+ [ChainId.Litecoin]: Chain.Litecoin,
71
+ [ChainId.MayaStagenet]: Chain.Maya,
72
+ [ChainId.Maya]: Chain.Maya,
73
+ [ChainId.OptimismHex]: Chain.Optimism,
74
+ [ChainId.Optimism]: Chain.Optimism,
75
+ [ChainId.Polkadot]: Chain.Polkadot,
76
+ [ChainId.PolygonHex]: Chain.Polygon,
77
+ [ChainId.Polygon]: Chain.Polygon,
78
+ [ChainId.THORChainStagenet]: Chain.THORChain,
79
+ [ChainId.THORChain]: Chain.THORChain,
80
+ };
81
+
82
+ type ChainNameType = keyof typeof Chain;
83
+ const chainNames = Object.keys(Chain) as ChainNameType[];
84
+ const chains = Object.values(Chain) as Chain[];
85
+
86
+ export enum BaseDecimal {
87
+ ARB = 18,
88
+ AVAX = 18,
89
+ BCH = 8,
90
+ BNB = 8,
91
+ BSC = 18,
92
+ BTC = 8,
93
+ DASH = 8,
94
+ DOGE = 8,
95
+ DOT = 10,
96
+ ETH = 18,
97
+ FLIP = 18,
98
+ GAIA = 6,
99
+ KUJI = 6,
100
+ LTC = 8,
101
+ MATIC = 18,
102
+ MAYA = 10,
103
+ OP = 18,
104
+ THOR = 8,
105
+ ZEC = 8,
106
+ }
107
+
108
+ export type SubstrateChain = Chain.Polkadot | Chain.Chainflip;
109
+ export const SubstrateChains = [Chain.Polkadot, Chain.Chainflip];
110
+
111
+ export type EVMChain =
112
+ | Chain.Ethereum
113
+ | Chain.Avalanche
114
+ | Chain.BinanceSmartChain
115
+ | Chain.Arbitrum
116
+ | Chain.Optimism
117
+ | Chain.Polygon;
118
+ export const EVMChains = [
119
+ Chain.Ethereum,
120
+ Chain.Avalanche,
121
+ Chain.BinanceSmartChain,
122
+ Chain.Arbitrum,
123
+ Chain.Optimism,
124
+ Chain.Polygon,
125
+ ] as const;
126
+
127
+ export type UTXOChain =
128
+ | Chain.Bitcoin
129
+ | Chain.BitcoinCash
130
+ | Chain.Dash
131
+ | Chain.Dogecoin
132
+ | Chain.Litecoin;
133
+ export const UTXOChains = [
134
+ Chain.Bitcoin,
135
+ Chain.BitcoinCash,
136
+ Chain.Dash,
137
+ Chain.Dogecoin,
138
+ Chain.Litecoin,
139
+ ] as const;
140
+
141
+ export type CosmosChain =
142
+ | Chain.Cosmos
143
+ | Chain.THORChain
144
+ | Chain.Binance
145
+ | Chain.Maya
146
+ | Chain.Kujira;
147
+ export const CosmosChains = [
148
+ Chain.Cosmos,
149
+ Chain.THORChain,
150
+ Chain.Binance,
151
+ Chain.Maya,
152
+ Chain.Kujira,
153
+ ] as const;
154
+
155
+ export const TCSupportedChains = [
156
+ Chain.Avalanche,
157
+ Chain.Binance,
158
+ Chain.BinanceSmartChain,
159
+ Chain.Bitcoin,
160
+ Chain.BitcoinCash,
161
+ Chain.Cosmos,
162
+ Chain.Dogecoin,
163
+ Chain.Ethereum,
164
+ Chain.Litecoin,
165
+ Chain.THORChain,
166
+ ] as const;
167
+
168
+ export const MAYASupportedChains = [
169
+ Chain.Arbitrum,
170
+ Chain.Dash,
171
+ Chain.Ethereum,
172
+ Chain.Kujira,
173
+ Chain.Maya,
174
+ Chain.THORChain,
175
+ ] as const;
176
+
177
+ const ChainToChainName = chains.reduce(
178
+ (acc, chain) => {
179
+ const chainName = chainNames.find((key) => Chain[key as ChainNameType] === chain);
180
+
181
+ if (chainName) acc[chain] = chainName;
182
+
183
+ return acc;
184
+ },
185
+ {} as { [key in Chain]: ChainNameType },
186
+ );
187
+
188
+ export const ChainToChainId = chains.reduce(
189
+ (acc, chain) => {
190
+ acc[chain] = ChainId[ChainToChainName[chain]];
191
+ return acc;
192
+ },
193
+ {} as { [key in Chain]: ChainId },
194
+ );
195
+
196
+ export const ChainToRPC = chains.reduce(
197
+ (acc, chain) => {
198
+ acc[chain] = RPCUrl[ChainToChainName[chain]];
199
+ return acc;
200
+ },
201
+ {} as { [key in Chain]: RPCUrl },
202
+ );
203
+
204
+ export const ChainToHexChainId = chains.reduce(
205
+ (acc, chain) => {
206
+ const chainString = `${ChainToChainName[chain]}Hex` as keyof typeof ChainId;
207
+
208
+ acc[chain] = ChainId[chainString];
209
+ return acc;
210
+ },
211
+ {} as { [key in Chain]: ChainId },
212
+ );
213
+
214
+ export const ChainToExplorerUrl = chains.reduce(
215
+ (acc, chain) => {
216
+ acc[chain] = ExplorerUrl[ChainToChainName[chain]];
217
+ return acc;
218
+ },
219
+ {} as { [key in Chain]: string },
220
+ );
@@ -0,0 +1,119 @@
1
+ import type { AssetValue } from "../modules/assetValue.ts";
2
+ import type { Chain, CosmosChain, EVMChain, UTXOChain } from "./chains.ts";
3
+ import type { WalletOption } from "./wallet.ts";
4
+
5
+ export type ConnectConfig = {
6
+ stagenet?: boolean;
7
+ /**
8
+ * @required
9
+ */
10
+ thorswapApiKey?: string;
11
+ /**
12
+ * @required for AVAX & BSC
13
+ */
14
+ covalentApiKey?: string;
15
+ /**
16
+ * @required for ETH
17
+ */
18
+ ethplorerApiKey?: string;
19
+ /**
20
+ * @required for BTC, BCH, LTC, DOGE
21
+ */
22
+ blockchairApiKey?: string;
23
+ /**
24
+ * @required for Walletconnect
25
+ */
26
+ walletConnectProjectId?: string;
27
+ /**
28
+ * @optional for Trezor config
29
+ */
30
+ trezorManifest?: {
31
+ email: string;
32
+ appUrl: string;
33
+ };
34
+ /**
35
+ * @optional for KeepKey config
36
+ */
37
+ keepkeyConfig?: {
38
+ apiKey: string;
39
+ pairingInfo: {
40
+ name: string;
41
+ imageUrl: string;
42
+ basePath: string;
43
+ url: string;
44
+ };
45
+ };
46
+ };
47
+
48
+ export type AddChainWalletParams<T extends Chain> = {
49
+ address: string;
50
+ balance: AssetValue[];
51
+ walletType: WalletOption;
52
+ chain: T;
53
+ [key: string]: Todo;
54
+ };
55
+
56
+ type ApisType = { [key in UTXOChain]?: string | Todo } & {
57
+ [key in EVMChain]?: string | Todo;
58
+ } & {
59
+ [key in CosmosChain]?: string;
60
+ };
61
+
62
+ export type ConnectWalletParams = {
63
+ addChain: <T extends Chain>(params: AddChainWalletParams<T>) => void;
64
+ apis: ApisType;
65
+ config: ConnectConfig;
66
+ rpcUrls: { [chain in Chain]?: string };
67
+ };
68
+
69
+ export type Witness = {
70
+ value: number;
71
+ script: Buffer;
72
+ };
73
+
74
+ export enum QuoteMode {
75
+ TC_SUPPORTED_TO_TC_SUPPORTED = "TC-TC",
76
+ TC_SUPPORTED_TO_ETH = "TC-ERC20",
77
+ TC_SUPPORTED_TO_AVAX = "TC-ARC20",
78
+ TC_SUPPORTED_TO_BSC = "TC-BEP20",
79
+ ETH_TO_TC_SUPPORTED = "ERC20-TC",
80
+ ETH_TO_ETH = "ERC20-ERC20",
81
+ ETH_TO_AVAX = "ERC20-ARC20",
82
+ ETH_TO_BSC = "ERC20-BEP20",
83
+ AVAX_TO_TC_SUPPORTED = "ARC20-TC",
84
+ AVAX_TO_ETH = "ARC20-ERC20",
85
+ AVAX_TO_AVAX = "ARC20-ARC20",
86
+ AVAX_TO_BSC = "ARC20-BEP20",
87
+ BSC_TO_TC_SUPPORTED = "BEP20-TC",
88
+ BSC_TO_ETH = "BEP20-ERC20",
89
+ BSC_TO_AVAX = "BEP20-ARC20",
90
+ BSC_TO_BSC = "BEP20-BEP20",
91
+ }
92
+
93
+ export type Asset = {
94
+ chain: Chain;
95
+ symbol: string;
96
+ ticker: string;
97
+ synth?: boolean;
98
+ };
99
+
100
+ export const AGG_SWAP = [QuoteMode.ETH_TO_ETH, QuoteMode.AVAX_TO_AVAX, QuoteMode.BSC_TO_BSC];
101
+
102
+ export const SWAP_IN = [
103
+ QuoteMode.ETH_TO_TC_SUPPORTED,
104
+ QuoteMode.ETH_TO_AVAX,
105
+ QuoteMode.ETH_TO_BSC,
106
+ QuoteMode.AVAX_TO_TC_SUPPORTED,
107
+ QuoteMode.AVAX_TO_ETH,
108
+ QuoteMode.AVAX_TO_BSC,
109
+ QuoteMode.BSC_TO_TC_SUPPORTED,
110
+ QuoteMode.BSC_TO_ETH,
111
+ QuoteMode.BSC_TO_AVAX,
112
+ ];
113
+
114
+ export const SWAP_OUT = [
115
+ QuoteMode.TC_SUPPORTED_TO_TC_SUPPORTED,
116
+ QuoteMode.TC_SUPPORTED_TO_ETH,
117
+ QuoteMode.TC_SUPPORTED_TO_AVAX,
118
+ QuoteMode.TC_SUPPORTED_TO_BSC,
119
+ ];
@@ -0,0 +1,56 @@
1
+ import type { Chain } from "./chains";
2
+
3
+ export enum ContractAddress {
4
+ ARB = "0x0000000000000000000000000000000000000000",
5
+ AVAX = "0x0000000000000000000000000000000000000000",
6
+ ETH = "0x0000000000000000000000000000000000000000",
7
+ BSC = "0x0000000000000000000000000000000000000000",
8
+ MATIC = "0x0000000000000000000000000000000000001010",
9
+ OP = "0x4200000000000000000000000000000000000042",
10
+ }
11
+
12
+ export enum DerivationPath {
13
+ ARB = "m/44'/60'/0'/0",
14
+ AVAX = "m/44'/60'/0'/0",
15
+ BCH = "m/44'/145'/0'/0",
16
+ BNB = "m/44'/714'/0'/0",
17
+ BSC = "m/44'/60'/0'/0",
18
+ BTC = "m/84'/0'/0'/0",
19
+ DASH = "m/44'/5'/0'/0",
20
+ DOGE = "m/44'/3'/0'/0",
21
+ DOT = "////",
22
+ ETH = "m/44'/60'/0'/0",
23
+ FLIP = "////",
24
+ GAIA = "m/44'/118'/0'/0",
25
+ KUJI = "m/44'/118'/0'/0",
26
+ LTC = "m/84'/2'/0'/0",
27
+ MATIC = "m/44'/60'/0'/0",
28
+ MAYA = "m/44'/931'/0'/0",
29
+ OP = "m/44'/60'/0'/0",
30
+ THOR = "m/44'/931'/0'/0",
31
+ }
32
+
33
+ export type DerivationPathArray = [number, number, number, number, number?];
34
+
35
+ export const NetworkDerivationPath: Record<Chain, DerivationPathArray> = {
36
+ ARB: [44, 60, 0, 0, 0],
37
+ AVAX: [44, 60, 0, 0, 0],
38
+ BCH: [44, 145, 0, 0, 0],
39
+ BNB: [44, 714, 0, 0, 0],
40
+ BSC: [44, 60, 0, 0, 0],
41
+ BTC: [84, 0, 0, 0, 0],
42
+ DASH: [44, 5, 0, 0, 0],
43
+ DOGE: [44, 3, 0, 0, 0],
44
+ ETH: [44, 60, 0, 0, 0],
45
+ GAIA: [44, 118, 0, 0, 0],
46
+ KUJI: [44, 118, 0, 0, 0],
47
+ LTC: [84, 2, 0, 0, 0],
48
+ MATIC: [44, 60, 0, 0, 0],
49
+ MAYA: [44, 931, 0, 0, 0],
50
+ OP: [44, 60, 0, 0, 0],
51
+ THOR: [44, 931, 0, 0, 0],
52
+
53
+ // Polkadot and related network derivation path is not number based
54
+ DOT: [0, 0, 0, 0, 0],
55
+ FLIP: [0, 0, 0, 0, 0],
56
+ };
@@ -0,0 +1,10 @@
1
+ export * from "./abis/erc20";
2
+ export * from "./abis/tcEthVault";
3
+ export * from "./chains";
4
+ export * from "./commonTypes";
5
+ export * from "./derivationPath";
6
+ export * from "./network";
7
+ export * from "./tokens";
8
+ export * from "./transactions";
9
+ export * from "./wallet";
10
+ export * from "./sdk";
@@ -0,0 +1,43 @@
1
+ export enum RPCUrl {
2
+ Arbitrum = "https://arb1.arbitrum.io/rpc",
3
+ Avalanche = "https://node-router.thorswap.net/avalanche-c",
4
+ Binance = "",
5
+ BinanceSmartChain = "https://bsc-dataseed.binance.org",
6
+ Bitcoin = "https://node-router.thorswap.net/bitcoin",
7
+ BitcoinCash = "https://node-router.thorswap.net/bitcoin-cash",
8
+ Chainflip = "wss://mainnet-archive.chainflip.io",
9
+ Cosmos = "https://node-router.thorswap.net/cosmos/rpc",
10
+ Dash = "https://node-router.thorswap.net/dash",
11
+ Dogecoin = "https://node-router.thorswap.net/dogecoin",
12
+ Ethereum = "https://node-router.thorswap.net/ethereum",
13
+ Kujira = "https://rpc-kujira.synergynodes.com/",
14
+ Litecoin = "https://node-router.thorswap.net/litecoin",
15
+ Maya = "https://tendermint.mayachain.info",
16
+ MayaStagenet = "https://stagenet.tendermint.mayachain.info",
17
+ Optimism = "https://mainnet.optimism.io",
18
+ Polkadot = "wss://rpc.polkadot.io",
19
+ Polygon = "https://polygon-rpc.com",
20
+ THORChain = "https://rpc.thorswap.net",
21
+ THORChainStagenet = "https://stagenet-rpc.ninerealms.com",
22
+ }
23
+
24
+ export enum ExplorerUrl {
25
+ Arbitrum = "https://arbiscan.io",
26
+ Avalanche = "https://snowtrace.io",
27
+ Binance = "https://explorer.binance.org",
28
+ BinanceSmartChain = "https://bscscan.com",
29
+ Bitcoin = "https://blockchair.com/bitcoin",
30
+ BitcoinCash = "https://www.blockchair.com/bitcoin-cash",
31
+ Chainflip = "https://explorer.polkascan.io/polkadot",
32
+ Cosmos = "https://www.mintscan.io/cosmos",
33
+ Dash = "https://blockchair.com/dash",
34
+ Dogecoin = "https://blockchair.com/dogecoin",
35
+ Ethereum = "https://etherscan.io",
36
+ Kujira = "https://finder.kujira.network/kaiyo-1",
37
+ Litecoin = "https://blockchair.com/litecoin",
38
+ Maya = "https://www.mayascan.org",
39
+ Optimism = "https://optimistic.etherscan.io",
40
+ Polkadot = "https://polkadot.subscan.io/",
41
+ Polygon = "https://polygonscan.com",
42
+ THORChain = "https://runescan.io",
43
+ }
@@ -0,0 +1,11 @@
1
+ import type { AssetValue } from "../modules/assetValue";
2
+
3
+ export type GenericSwapParams = {
4
+ buyAsset: AssetValue;
5
+ sellAsset: AssetValue;
6
+ recipient: string;
7
+ };
8
+
9
+ export type SwapParams<PluginNames = string, T = GenericSwapParams> = T & {
10
+ pluginName: PluginNames;
11
+ };
@@ -0,0 +1,30 @@
1
+ import type {
2
+ ChainflipList,
3
+ CoinGeckoList,
4
+ MayaList,
5
+ PancakeswapETHList,
6
+ PancakeswapList,
7
+ PangolinList,
8
+ StargateARBList,
9
+ SushiswapList,
10
+ ThorchainList,
11
+ TraderjoeList,
12
+ UniswapList,
13
+ WoofiList,
14
+ } from "@swapkit/tokens";
15
+
16
+ export type TokenTax = { buy: number; sell: number };
17
+
18
+ export type TokenNames =
19
+ | (typeof ThorchainList)["tokens"][number]["identifier"]
20
+ | (typeof CoinGeckoList)["tokens"][number]["identifier"]
21
+ | (typeof MayaList)["tokens"][number]["identifier"]
22
+ | (typeof PancakeswapETHList)["tokens"][number]["identifier"]
23
+ | (typeof PancakeswapList)["tokens"][number]["identifier"]
24
+ | (typeof PangolinList)["tokens"][number]["identifier"]
25
+ | (typeof StargateARBList)["tokens"][number]["identifier"]
26
+ | (typeof SushiswapList)["tokens"][number]["identifier"]
27
+ | (typeof TraderjoeList)["tokens"][number]["identifier"]
28
+ | (typeof WoofiList)["tokens"][number]["identifier"]
29
+ | (typeof UniswapList)["tokens"][number]["identifier"]
30
+ | (typeof ChainflipList)["tokens"][number]["identifier"];
@@ -0,0 +1,45 @@
1
+ import type { AssetValue } from "../modules/assetValue";
2
+
3
+ export enum FeeOption {
4
+ Average = "average",
5
+ Fast = "fast",
6
+ Fastest = "fastest",
7
+ }
8
+
9
+ export enum ApproveMode {
10
+ Approve = "approve",
11
+ CheckOnly = "checkOnly",
12
+ }
13
+
14
+ export type ApproveReturnType<T extends ApproveMode> = T extends "checkOnly"
15
+ ? Promise<boolean>
16
+ : Promise<string>;
17
+
18
+ export type WalletTxParams = {
19
+ feeOptionKey?: FeeOption;
20
+ from?: string;
21
+ memo?: string; // optional memo to pass
22
+ recipient: string;
23
+ };
24
+
25
+ export enum MemoType {
26
+ BOND = "BOND",
27
+ DEPOSIT = "+",
28
+ LEAVE = "LEAVE",
29
+ THORNAME_REGISTER = "~",
30
+ UNBOND = "UNBOND",
31
+ WITHDRAW = "-",
32
+ OPEN_LOAN = "$+",
33
+ CLOSE_LOAN = "$-",
34
+ }
35
+
36
+ export type CoreTxParams = {
37
+ assetValue: AssetValue;
38
+ recipient: string;
39
+ memo?: string;
40
+ feeOptionKey?: FeeOption;
41
+ feeRate?: number;
42
+ data?: string;
43
+ from?: string;
44
+ expiration?: number;
45
+ };
@@ -0,0 +1,39 @@
1
+ import type { AssetValue } from "../modules/assetValue";
2
+ import type { Chain } from "./chains";
3
+
4
+ export enum WalletOption {
5
+ KEYSTORE = "KEYSTORE",
6
+ KEEPKEY = "KEEPKEY",
7
+ XDEFI = "XDEFI",
8
+ METAMASK = "METAMASK",
9
+ COINBASE_WEB = "COINBASE_WEB",
10
+ COINBASE_MOBILE = "COINBASE_MOBILE",
11
+ TREZOR = "TREZOR",
12
+ TRUSTWALLET_WEB = "TRUSTWALLET_WEB",
13
+ LEDGER = "LEDGER",
14
+ KEPLR = "KEPLR",
15
+ OKX = "OKX",
16
+ OKX_MOBILE = "OKX_MOBILE",
17
+ BRAVE = "BRAVE",
18
+ WALLETCONNECT = "WALLETCONNECT",
19
+ }
20
+
21
+ export enum LedgerErrorCode {
22
+ NoError = 0x9000,
23
+ LockedDevice = 0x5515,
24
+ TC_NotFound = 65535,
25
+ }
26
+
27
+ export type ChainWallet = {
28
+ chain: Chain;
29
+ address: string;
30
+ balance: AssetValue[];
31
+ walletType: WalletOption;
32
+ };
33
+
34
+ export type EmptyWallet = { [key in Chain]?: unknown };
35
+
36
+ export type BaseWallet<T extends EmptyWallet | unknown> = {
37
+ // @ts-expect-error
38
+ [key in Chain]: ChainWallet & T[key];
39
+ };