@swapkit/types 1.0.0-rc.36 → 1.0.0-rc.38

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/src/chainflip.ts CHANGED
@@ -19,12 +19,12 @@ export enum ErrorCode {
19
19
  }
20
20
 
21
21
  export enum MemoType {
22
- BOND = 'BOND',
23
- DEPOSIT = '+',
24
- LEAVE = 'LEAVE',
25
- THORNAME_REGISTER = '~',
26
- UNBOND = 'UNBOND',
27
- WITHDRAW = '-',
28
- OPEN_LOAN = '$+',
29
- CLOSE_LOAN = '$-',
22
+ BOND = "BOND",
23
+ DEPOSIT = "+",
24
+ LEAVE = "LEAVE",
25
+ THORNAME_REGISTER = "~",
26
+ UNBOND = "UNBOND",
27
+ WITHDRAW = "-",
28
+ OPEN_LOAN = "$+",
29
+ CLOSE_LOAN = "$-",
30
30
  }
@@ -1,22 +1,16 @@
1
- import type { Chain, CosmosChain, EVMChain, UTXOChain } from './network.ts';
2
- import type { WalletOption } from './wallet.ts';
1
+ import type { Chain, CosmosChain, EVMChain, UTXOChain } from "./network.ts";
2
+ import type { WalletOption } from "./wallet.ts";
3
3
 
4
4
  type ConnectMethodNames =
5
- | 'connectEVMWallet'
6
- | 'connectKeplr'
7
- | 'connectKeystore'
8
- | 'connectKeepkey'
9
- | 'connectLedger'
10
- | 'connectOkx'
11
- | 'connectTrezor'
12
- | 'connectWalletconnect'
13
- | 'connectXDEFI';
14
-
15
- type ChainWallet = {
16
- address: string;
17
- balance: any[];
18
- walletType: WalletOption;
19
- };
5
+ | "connectEVMWallet"
6
+ | "connectKeplr"
7
+ | "connectKeystore"
8
+ | "connectKeepkey"
9
+ | "connectLedger"
10
+ | "connectOkx"
11
+ | "connectTrezor"
12
+ | "connectWalletconnect"
13
+ | "connectXDEFI";
20
14
 
21
15
  export type ConnectConfig = {
22
16
  stagenet?: boolean;
@@ -65,15 +59,12 @@ export type ConnectConfig = {
65
59
  };
66
60
  };
67
61
 
68
- export type AddChainWalletParams = {
69
- chain: Chain;
70
- wallet: ChainWallet;
71
- walletMethods: any;
72
- };
73
-
74
- export type Witness = {
75
- value: number;
76
- script: Buffer;
62
+ export type AddChainWalletParams<T extends Chain> = {
63
+ address: string;
64
+ balance: any[];
65
+ walletType: WalletOption;
66
+ chain: T;
67
+ [key: string]: any;
77
68
  };
78
69
 
79
70
  type ApisType = { [key in UTXOChain]?: string | any } & {
@@ -83,13 +74,18 @@ type ApisType = { [key in UTXOChain]?: string | any } & {
83
74
  };
84
75
 
85
76
  export type ConnectWalletParams = {
86
- addChain: (params: AddChainWalletParams) => void;
77
+ addChain: <T extends Chain>(params: AddChainWalletParams<T>) => void;
87
78
  config: ConnectConfig;
88
79
  rpcUrls: { [chain in Chain]?: string };
89
80
  apis: ApisType;
90
81
  };
91
82
 
92
- export type ExtendParams<WalletConnectMethodNames = ''> = {
83
+ export type Witness = {
84
+ value: number;
85
+ script: Buffer;
86
+ };
87
+
88
+ export type ExtendParams<WalletConnectMethodNames = ""> = {
93
89
  excludedChains?: Chain[];
94
90
  config?: ConnectConfig;
95
91
  rpcUrls?: { [chain in Chain]?: string };
@@ -101,22 +97,22 @@ export type ExtendParams<WalletConnectMethodNames = ''> = {
101
97
  };
102
98
 
103
99
  export enum QuoteMode {
104
- TC_SUPPORTED_TO_TC_SUPPORTED = 'TC-TC',
105
- TC_SUPPORTED_TO_ETH = 'TC-ERC20',
106
- TC_SUPPORTED_TO_AVAX = 'TC-ARC20',
107
- TC_SUPPORTED_TO_BSC = 'TC-BEP20',
108
- ETH_TO_TC_SUPPORTED = 'ERC20-TC',
109
- ETH_TO_ETH = 'ERC20-ERC20',
110
- ETH_TO_AVAX = 'ERC20-ARC20',
111
- ETH_TO_BSC = 'ERC20-BEP20',
112
- AVAX_TO_TC_SUPPORTED = 'ARC20-TC',
113
- AVAX_TO_ETH = 'ARC20-ERC20',
114
- AVAX_TO_AVAX = 'ARC20-ARC20',
115
- AVAX_TO_BSC = 'ARC20-BEP20',
116
- BSC_TO_TC_SUPPORTED = 'BEP20-TC',
117
- BSC_TO_ETH = 'BEP20-ERC20',
118
- BSC_TO_AVAX = 'BEP20-ARC20',
119
- BSC_TO_BSC = 'BEP20-BEP20',
100
+ TC_SUPPORTED_TO_TC_SUPPORTED = "TC-TC",
101
+ TC_SUPPORTED_TO_ETH = "TC-ERC20",
102
+ TC_SUPPORTED_TO_AVAX = "TC-ARC20",
103
+ TC_SUPPORTED_TO_BSC = "TC-BEP20",
104
+ ETH_TO_TC_SUPPORTED = "ERC20-TC",
105
+ ETH_TO_ETH = "ERC20-ERC20",
106
+ ETH_TO_AVAX = "ERC20-ARC20",
107
+ ETH_TO_BSC = "ERC20-BEP20",
108
+ AVAX_TO_TC_SUPPORTED = "ARC20-TC",
109
+ AVAX_TO_ETH = "ARC20-ERC20",
110
+ AVAX_TO_AVAX = "ARC20-ARC20",
111
+ AVAX_TO_BSC = "ARC20-BEP20",
112
+ BSC_TO_TC_SUPPORTED = "BEP20-TC",
113
+ BSC_TO_ETH = "BEP20-ERC20",
114
+ BSC_TO_AVAX = "BEP20-ARC20",
115
+ BSC_TO_BSC = "BEP20-BEP20",
120
116
  }
121
117
 
122
118
  export type Asset = {
package/src/index.ts CHANGED
@@ -1,8 +1,7 @@
1
- export { erc20ABI } from './abis/erc20.ts';
2
- export { TCAvalancheDepositABI, TCBscDepositABI, TCEthereumVaultAbi } from './abis/tcEthVault.ts';
3
- export * from './commonTypes.ts';
4
- export * from './errors/index.ts';
5
- export * from './network.ts';
6
- export * from './thorchain.ts';
7
- export * from './transactions.ts';
8
- export * from './wallet.ts';
1
+ export { erc20ABI } from "./abis/erc20.ts";
2
+ export { TCAvalancheDepositABI, TCBscDepositABI, TCEthereumVaultAbi } from "./abis/tcEthVault.ts";
3
+ export * from "./commonTypes.ts";
4
+ export * from "./network.ts";
5
+ export * from "./thorchain.ts";
6
+ export * from "./transactions.ts";
7
+ export * from "./wallet.ts";
package/src/network.ts CHANGED
@@ -1,31 +1,32 @@
1
1
  export enum Chain {
2
- Arbitrum = 'ARB',
3
- Avalanche = 'AVAX',
4
- Binance = 'BNB',
5
- BinanceSmartChain = 'BSC',
6
- Bitcoin = 'BTC',
7
- BitcoinCash = 'BCH',
8
- Cosmos = 'GAIA',
9
- Dogecoin = 'DOGE',
10
- Ethereum = 'ETH',
11
- Kujira = 'KUJI',
12
- Litecoin = 'LTC',
13
- Maya = 'MAYA',
14
- Optimism = 'OP',
15
- Polkadot = 'DOT',
16
- Chainflip = 'FLIP',
17
- Polygon = 'MATIC',
18
- THORChain = 'THOR',
2
+ Arbitrum = "ARB",
3
+ Avalanche = "AVAX",
4
+ Binance = "BNB",
5
+ BinanceSmartChain = "BSC",
6
+ Bitcoin = "BTC",
7
+ BitcoinCash = "BCH",
8
+ Cosmos = "GAIA",
9
+ Dash = "DASH",
10
+ Dogecoin = "DOGE",
11
+ Ethereum = "ETH",
12
+ Kujira = "KUJI",
13
+ Litecoin = "LTC",
14
+ Maya = "MAYA",
15
+ Optimism = "OP",
16
+ Polkadot = "DOT",
17
+ Chainflip = "FLIP",
18
+ Polygon = "MATIC",
19
+ THORChain = "THOR",
19
20
  }
20
21
  type ChainNameType = keyof typeof Chain;
21
22
 
22
23
  export enum ContractAddress {
23
- ARB = '0x0000000000000000000000000000000000000000',
24
- AVAX = '0x0000000000000000000000000000000000000000',
25
- ETH = '0x0000000000000000000000000000000000000000',
26
- BSC = '0x0000000000000000000000000000000000000000',
27
- MATIC = '0x0000000000000000000000000000000000001010',
28
- OP = '0x4200000000000000000000000000000000000042',
24
+ ARB = "0x0000000000000000000000000000000000000000",
25
+ AVAX = "0x0000000000000000000000000000000000000000",
26
+ ETH = "0x0000000000000000000000000000000000000000",
27
+ BSC = "0x0000000000000000000000000000000000000000",
28
+ MATIC = "0x0000000000000000000000000000000000001010",
29
+ OP = "0x4200000000000000000000000000000000000042",
29
30
  }
30
31
 
31
32
  export enum DerivationPath {
@@ -35,10 +36,11 @@ export enum DerivationPath {
35
36
  BNB = "m/44'/714'/0'/0",
36
37
  BSC = "m/44'/60'/0'/0",
37
38
  BTC = "m/84'/0'/0'/0",
39
+ DASH = "m/44'/5'/0'/0",
38
40
  DOGE = "m/44'/3'/0'/0",
39
- DOT = '////',
41
+ DOT = "////",
40
42
  ETH = "m/44'/60'/0'/0",
41
- FLIP = '////',
43
+ FLIP = "////",
42
44
  GAIA = "m/44'/118'/0'/0",
43
45
  KUJI = "m/44'/118'/0'/0",
44
46
  LTC = "m/84'/2'/0'/0",
@@ -57,6 +59,7 @@ export const NetworkDerivationPath: Record<Chain, DerivationPathArray> = {
57
59
  BNB: [44, 714, 0, 0, 0],
58
60
  BSC: [44, 60, 0, 0, 0],
59
61
  BTC: [84, 0, 0, 0, 0],
62
+ DASH: [44, 5, 0, 0, 0],
60
63
  DOGE: [44, 3, 0, 0, 0],
61
64
  ETH: [44, 60, 0, 0, 0],
62
65
  GAIA: [44, 118, 0, 0, 0],
@@ -90,6 +93,7 @@ export enum BaseDecimal {
90
93
  MAYA = 10,
91
94
  OP = 18,
92
95
  THOR = 8,
96
+ ZEC = 8,
93
97
  }
94
98
 
95
99
  export type SubstrateChain = Chain.Polkadot | Chain.Chainflip;
@@ -104,23 +108,39 @@ export type EVMChain =
104
108
  | Chain.Optimism
105
109
  | Chain.Polygon;
106
110
 
107
- export const EVMChainList: EVMChain[] = [
111
+ export const EVMChains = [
108
112
  Chain.Ethereum,
109
113
  Chain.Avalanche,
110
114
  Chain.BinanceSmartChain,
111
115
  Chain.Arbitrum,
112
116
  Chain.Optimism,
113
117
  Chain.Polygon,
114
- ];
118
+ ] as const;
119
+ /**
120
+ * @deprecated
121
+ * Use `EVMChains` instead
122
+ */
123
+ export const EVMChainList = EVMChains;
115
124
 
116
- export type UTXOChain = Chain.Bitcoin | Chain.BitcoinCash | Chain.Dogecoin | Chain.Litecoin;
125
+ export type UTXOChain =
126
+ | Chain.Bitcoin
127
+ | Chain.BitcoinCash
128
+ | Chain.Dash
129
+ | Chain.Dogecoin
130
+ | Chain.Litecoin;
117
131
 
118
- export const UTXOChainList: UTXOChain[] = [
132
+ export const UTXOChains = [
119
133
  Chain.Bitcoin,
120
134
  Chain.BitcoinCash,
135
+ Chain.Dash,
121
136
  Chain.Dogecoin,
122
137
  Chain.Litecoin,
123
- ];
138
+ ] as const;
139
+ /**
140
+ * @deprecated
141
+ * Use `UTXOChains` instead
142
+ */
143
+ export const UTXOChainList = UTXOChains;
124
144
 
125
145
  export type CosmosChain =
126
146
  | Chain.Cosmos
@@ -129,9 +149,15 @@ export type CosmosChain =
129
149
  | Chain.Maya
130
150
  | Chain.Kujira;
131
151
 
132
- export const CosmosChainList: CosmosChain[] = [Chain.Cosmos, Chain.THORChain, Chain.Binance];
152
+ export const CosmosChains = [Chain.Cosmos, Chain.THORChain, Chain.Binance] as const;
133
153
 
134
- export const TCSupportedChainList = [
154
+ /**
155
+ * @deprecated
156
+ * Use `CosmosChains` instead
157
+ */
158
+ export const CosmosChainList = CosmosChains;
159
+
160
+ export const TCSupportedChains = [
135
161
  Chain.Avalanche,
136
162
  Chain.Binance,
137
163
  Chain.BinanceSmartChain,
@@ -142,67 +168,75 @@ export const TCSupportedChainList = [
142
168
  Chain.Ethereum,
143
169
  Chain.Litecoin,
144
170
  Chain.THORChain,
145
- ];
171
+ ] as const;
172
+
173
+ /**
174
+ * @deprecated
175
+ * Use `TCSupportedChains` instead
176
+ */
177
+ export const TCSupportedChainList = TCSupportedChains;
146
178
 
147
179
  export enum ChainId {
148
- Arbitrum = '42161',
149
- ArbitrumHex = '0xa4b1',
150
- Avalanche = '43114',
151
- AvalancheHex = '0xa86a',
152
- Binance = 'Binance-Chain-Tigris',
153
- BinanceSmartChain = '56',
154
- BinanceSmartChainHex = '0x38',
155
- Bitcoin = 'bitcoin',
156
- BitcoinCash = 'bitcoincash',
157
- Chainflip = 'chainflip',
158
- Cosmos = 'cosmoshub-4',
159
- Dogecoin = 'dogecoin',
160
- Kujira = 'kaiyo-1',
161
- Ethereum = '1',
162
- EthereumHex = '0x1',
163
- Litecoin = 'litecoin',
164
- Maya = 'mayachain-mainnet-v1',
165
- MayaStagenet = 'mayachain-stagenet-v1',
166
- Optimism = '10',
167
- OptimismHex = '0xa',
168
- Polkadot = 'polkadot',
169
- Polygon = '137',
170
- PolygonHex = '0x89',
171
- THORChain = 'thorchain-mainnet-v1',
172
- THORChainStagenet = 'thorchain-stagenet-v2',
180
+ Arbitrum = "42161",
181
+ ArbitrumHex = "0xa4b1",
182
+ Avalanche = "43114",
183
+ AvalancheHex = "0xa86a",
184
+ Binance = "Binance-Chain-Tigris",
185
+ BinanceSmartChain = "56",
186
+ BinanceSmartChainHex = "0x38",
187
+ Bitcoin = "bitcoin",
188
+ BitcoinCash = "bitcoincash",
189
+ Chainflip = "chainflip",
190
+ Cosmos = "cosmoshub-4",
191
+ Dash = "dash",
192
+ Dogecoin = "dogecoin",
193
+ Kujira = "kaiyo-1",
194
+ Ethereum = "1",
195
+ EthereumHex = "0x1",
196
+ Litecoin = "litecoin",
197
+ Maya = "mayachain-mainnet-v1",
198
+ MayaStagenet = "mayachain-stagenet-v1",
199
+ Optimism = "10",
200
+ OptimismHex = "0xa",
201
+ Polkadot = "polkadot",
202
+ Polygon = "137",
203
+ PolygonHex = "0x89",
204
+ THORChain = "thorchain-mainnet-v1",
205
+ THORChainStagenet = "thorchain-stagenet-v2",
173
206
  }
174
207
 
175
208
  export enum RPCUrl {
176
- Arbitrum = 'https://arb1.arbitrum.io/rpc',
177
- Avalanche = 'https://node-router.thorswap.net/avalanche-c',
178
- Binance = '',
179
- BinanceSmartChain = 'https://bsc-dataseed.binance.org',
180
- Bitcoin = 'https://node-router.thorswap.net/bitcoin',
181
- BitcoinCash = 'https://node-router.thorswap.net/bitcoin-cash',
182
- Chainflip = 'wss://mainnet-archive.chainflip.io',
183
- Cosmos = 'https://node-router.thorswap.net/cosmos/rpc',
184
- Kujira = 'https://rpc-kujira.synergynodes.com/',
185
- Dogecoin = 'https://node-router.thorswap.net/dogecoin',
186
- Ethereum = 'https://node-router.thorswap.net/ethereum',
187
- Litecoin = 'https://node-router.thorswap.net/litecoin',
188
- Maya = 'https://tendermint.mayachain.info',
189
- MayaStagenet = 'https://stagenet.tendermint.mayachain.info',
190
- Optimism = 'https://mainnet.optimism.io',
191
- Polkadot = 'wss://rpc.polkadot.io',
192
- Polygon = 'https://polygon-rpc.com',
193
- THORChain = 'https://rpc.thorswap.net',
194
- THORChainStagenet = 'https://stagenet-rpc.ninerealms.com',
209
+ Arbitrum = "https://arb1.arbitrum.io/rpc",
210
+ Avalanche = "https://node-router.thorswap.net/avalanche-c",
211
+ Binance = "",
212
+ BinanceSmartChain = "https://bsc-dataseed.binance.org",
213
+ Bitcoin = "https://node-router.thorswap.net/bitcoin",
214
+ BitcoinCash = "https://node-router.thorswap.net/bitcoin-cash",
215
+ Chainflip = "wss://mainnet-archive.chainflip.io",
216
+ Cosmos = "https://node-router.thorswap.net/cosmos/rpc",
217
+ Dash = "https://node-router.thorswap.net/dash",
218
+ Dogecoin = "https://node-router.thorswap.net/dogecoin",
219
+ Ethereum = "https://node-router.thorswap.net/ethereum",
220
+ Kujira = "https://rpc-kujira.synergynodes.com/",
221
+ Litecoin = "https://node-router.thorswap.net/litecoin",
222
+ Maya = "https://tendermint.mayachain.info",
223
+ MayaStagenet = "https://stagenet.tendermint.mayachain.info",
224
+ Optimism = "https://mainnet.optimism.io",
225
+ Polkadot = "wss://rpc.polkadot.io",
226
+ Polygon = "https://polygon-rpc.com",
227
+ THORChain = "https://rpc.thorswap.net",
228
+ THORChainStagenet = "https://stagenet-rpc.ninerealms.com",
195
229
  }
196
230
 
197
231
  export enum ApiUrl {
198
- Cosmos = 'https://node-router.thorswap.net/cosmos/rest',
199
- Kujira = 'https://lcd-kujira.synergynodes.com/',
200
- MayanodeMainnet = 'https://mayanode.mayachain.info',
201
- MayanodeStagenet = 'https://stagenet.mayanode.mayachain.info',
202
- ThornodeMainnet = 'https://thornode.thorswap.net',
203
- ThornodeStagenet = 'https://stagenet-thornode.ninerealms.com',
204
- ThorswapApi = 'https://api.thorswap.net',
205
- ThorswapStatic = 'https://static.thorswap.net',
232
+ Cosmos = "https://node-router.thorswap.net/cosmos/rest",
233
+ Kujira = "https://lcd-kujira.synergynodes.com/",
234
+ MayanodeMainnet = "https://mayanode.mayachain.info",
235
+ MayanodeStagenet = "https://stagenet.mayanode.mayachain.info",
236
+ ThornodeMainnet = "https://thornode.thorswap.net",
237
+ ThornodeStagenet = "https://stagenet-thornode.ninerealms.com",
238
+ ThorswapApi = "https://api.thorswap.net",
239
+ ThorswapStatic = "https://static.thorswap.net",
206
240
  }
207
241
 
208
242
  const chains = Object.values(Chain) as Chain[];
@@ -257,6 +291,7 @@ export const ChainIdToChain: Record<ChainId, Chain> = {
257
291
  [ChainId.Bitcoin]: Chain.Bitcoin,
258
292
  [ChainId.Chainflip]: Chain.Chainflip,
259
293
  [ChainId.Cosmos]: Chain.Cosmos,
294
+ [ChainId.Dash]: Chain.Dash,
260
295
  [ChainId.Dogecoin]: Chain.Dogecoin,
261
296
  [ChainId.EthereumHex]: Chain.Ethereum,
262
297
  [ChainId.Kujira]: Chain.Kujira,
@@ -274,21 +309,22 @@ export const ChainIdToChain: Record<ChainId, Chain> = {
274
309
  };
275
310
 
276
311
  export const ChainToExplorerUrl: Record<Chain, string> = {
277
- [Chain.Arbitrum]: 'https://arbiscan.io',
278
- [Chain.Avalanche]: 'https://snowtrace.io',
279
- [Chain.BinanceSmartChain]: 'https://bscscan.com',
280
- [Chain.Binance]: 'https://explorer.binance.org',
281
- [Chain.BitcoinCash]: 'https://www.blockchair.com/bitcoin-cash',
282
- [Chain.Bitcoin]: 'https://blockchair.com/bitcoin',
283
- [Chain.Chainflip]: 'https://explorer.polkascan.io/polkadot',
284
- [Chain.Cosmos]: 'https://cosmos.bigdipper.live',
285
- [Chain.Dogecoin]: 'https://blockchair.com/dogecoin',
286
- [Chain.Kujira]: 'https://finder.kujira.network/kaiyo-1',
287
- [Chain.Ethereum]: 'https://etherscan.io',
288
- [Chain.Litecoin]: 'https://blockchair.com/litecoin',
289
- [Chain.Maya]: 'https://www.mayascan.org',
290
- [Chain.Optimism]: 'https://optimistic.etherscan.io',
291
- [Chain.Polkadot]: 'https://explorer.polkascan.io/polkadot',
292
- [Chain.Polygon]: 'https://polygonscan.com',
293
- [Chain.THORChain]: 'https://runescan.io',
312
+ [Chain.Arbitrum]: "https://arbiscan.io",
313
+ [Chain.Avalanche]: "https://snowtrace.io",
314
+ [Chain.BinanceSmartChain]: "https://bscscan.com",
315
+ [Chain.Binance]: "https://explorer.binance.org",
316
+ [Chain.BitcoinCash]: "https://www.blockchair.com/bitcoin-cash",
317
+ [Chain.Bitcoin]: "https://blockchair.com/bitcoin",
318
+ [Chain.Chainflip]: "https://explorer.polkascan.io/polkadot",
319
+ [Chain.Cosmos]: "https://cosmos.bigdipper.live",
320
+ [Chain.Dash]: "https://blockchair.com/dash",
321
+ [Chain.Dogecoin]: "https://blockchair.com/dogecoin",
322
+ [Chain.Kujira]: "https://finder.kujira.network/kaiyo-1",
323
+ [Chain.Ethereum]: "https://etherscan.io",
324
+ [Chain.Litecoin]: "https://blockchair.com/litecoin",
325
+ [Chain.Maya]: "https://www.mayascan.org",
326
+ [Chain.Optimism]: "https://optimistic.etherscan.io",
327
+ [Chain.Polkadot]: "https://explorer.polkascan.io/polkadot",
328
+ [Chain.Polygon]: "https://polygonscan.com",
329
+ [Chain.THORChain]: "https://runescan.io",
294
330
  };
package/src/thorchain.ts CHANGED
@@ -15,12 +15,12 @@ export type Signature = {
15
15
  };
16
16
 
17
17
  export enum MemoType {
18
- BOND = 'BOND',
19
- DEPOSIT = '+',
20
- LEAVE = 'LEAVE',
21
- THORNAME_REGISTER = '~',
22
- UNBOND = 'UNBOND',
23
- WITHDRAW = '-',
24
- OPEN_LOAN = '$+',
25
- CLOSE_LOAN = '$-',
18
+ BOND = "BOND",
19
+ DEPOSIT = "+",
20
+ LEAVE = "LEAVE",
21
+ THORNAME_REGISTER = "~",
22
+ UNBOND = "UNBOND",
23
+ WITHDRAW = "-",
24
+ OPEN_LOAN = "$+",
25
+ CLOSE_LOAN = "$-",
26
26
  }
@@ -1,7 +1,7 @@
1
1
  export enum FeeOption {
2
- Average = 'average',
3
- Fast = 'fast',
4
- Fastest = 'fastest',
2
+ Average = "average",
3
+ Fast = "fast",
4
+ Fastest = "fastest",
5
5
  }
6
6
 
7
7
  export type WalletTxParams = {
package/src/wallet.ts CHANGED
@@ -1,17 +1,17 @@
1
1
  export enum WalletOption {
2
- 'KEYSTORE' = 'KEYSTORE',
3
- 'KEEPKEY' = 'KEEPKEY',
4
- 'XDEFI' = 'XDEFI',
5
- 'METAMASK' = 'METAMASK',
6
- 'COINBASE_WEB' = 'COINBASE_WEB',
7
- 'TREZOR' = 'TREZOR',
8
- 'TRUSTWALLET_WEB' = 'TRUSTWALLET_WEB',
9
- 'LEDGER' = 'LEDGER',
10
- 'KEPLR' = 'KEPLR',
11
- 'OKX' = 'OKX',
12
- 'OKX_MOBILE' = 'OKX_MOBILE',
13
- 'BRAVE' = 'BRAVE',
14
- 'WALLETCONNECT' = 'WALLETCONNECT',
2
+ KEYSTORE = "KEYSTORE",
3
+ KEEPKEY = "KEEPKEY",
4
+ XDEFI = "XDEFI",
5
+ METAMASK = "METAMASK",
6
+ COINBASE_WEB = "COINBASE_WEB",
7
+ TREZOR = "TREZOR",
8
+ TRUSTWALLET_WEB = "TRUSTWALLET_WEB",
9
+ LEDGER = "LEDGER",
10
+ KEPLR = "KEPLR",
11
+ OKX = "OKX",
12
+ OKX_MOBILE = "OKX_MOBILE",
13
+ BRAVE = "BRAVE",
14
+ WALLETCONNECT = "WALLETCONNECT",
15
15
  }
16
16
 
17
17
  export type EVMWalletOptions =
@@ -1,75 +0,0 @@
1
- import { getDisplayMessage } from './displayMessages.ts';
2
- import type { ApiErrorOptions, ERROR_CODE, ERROR_MODULE, ErrorInfo } from './types.ts';
3
- import { ERROR_TYPE } from './types.ts';
4
-
5
- export class ApiError extends Error {
6
- public readonly status: number;
7
- public readonly revision: string;
8
- public readonly type?: ERROR_TYPE;
9
- public readonly module: ERROR_MODULE;
10
- public readonly code: ERROR_CODE;
11
- public readonly message: string;
12
- public readonly display: string;
13
- public readonly stack?: string;
14
- public readonly options: ApiErrorOptions;
15
- public readonly displayMessageParams?: string[];
16
-
17
- constructor({
18
- status,
19
- revision,
20
- module,
21
- code,
22
- message,
23
- type,
24
- options: { shouldLog, shouldThrow, shouldTrace } = {
25
- shouldLog: true,
26
- shouldThrow: true,
27
- shouldTrace: true,
28
- },
29
- displayMessageParams,
30
- }: ErrorInfo) {
31
- const safeMessage = message || getDisplayMessage(code, displayMessageParams || []) || '';
32
- super(safeMessage);
33
-
34
- this.status = status;
35
- this.revision = revision || 'NO_REVISION';
36
- this.module = module;
37
- this.message = safeMessage;
38
- this.display = getDisplayMessage(code, displayMessageParams || []);
39
- this.code = code;
40
- this.type = type || ERROR_TYPE.UNHANDLED_ERROR;
41
- this.options = {
42
- shouldLog: shouldLog || true,
43
- shouldTrace: shouldTrace || true,
44
- shouldThrow: shouldThrow || false,
45
- };
46
- this.displayMessageParams = displayMessageParams || [];
47
-
48
- if (this.options.shouldTrace) Error.captureStackTrace(this);
49
- }
50
-
51
- public static fromErrorInfo(errorInfo: ErrorInfo): ApiError {
52
- return new ApiError(errorInfo);
53
- }
54
-
55
- public toErrorInfo(): ErrorInfo {
56
- return { ...this, identifier: this.identifier };
57
- }
58
-
59
- public get identifier(): string {
60
- return `${this.revision}-${this.type || 'NO_TYPE'}-${this.module}-${this.code}`;
61
- }
62
-
63
- public get displayMessage(): string {
64
- return getDisplayMessage(this.code, this.displayMessageParams || []);
65
- }
66
-
67
- public handle() {
68
- const message = `[${this.identifier}]: ${this.message}`;
69
-
70
- if (this.options.shouldLog) console.error(message, '\n', this.stack || '');
71
- if (this.options.shouldThrow) throw Error(message, { cause: this.stack });
72
-
73
- return this.toErrorInfo();
74
- }
75
- }