@swapkit/helpers 3.0.0-beta.0 → 3.0.0-beta.1

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 (100) hide show
  1. package/dist/api/index.cjs +2 -2
  2. package/dist/api/index.cjs.map +6 -6
  3. package/dist/api/index.js +2 -2
  4. package/dist/api/index.js.map +6 -6
  5. package/dist/chunk-1gwdyyeh.js +4 -0
  6. package/dist/chunk-1gwdyyeh.js.map +10 -0
  7. package/dist/chunk-2bhvezjh.js +4 -0
  8. package/dist/chunk-2bhvezjh.js.map +10 -0
  9. package/dist/chunk-3ptwhtpd.js +3 -0
  10. package/dist/chunk-3ptwhtpd.js.map +10 -0
  11. package/dist/{chunk-nm00d52v.js → chunk-3wnfcm30.js} +2 -2
  12. package/dist/{chunk-nm00d52v.js.map → chunk-3wnfcm30.js.map} +1 -1
  13. package/dist/chunk-40epvqbm.js +3 -0
  14. package/dist/chunk-40epvqbm.js.map +10 -0
  15. package/dist/chunk-49nsjaay.js +3 -0
  16. package/dist/chunk-49nsjaay.js.map +10 -0
  17. package/dist/chunk-4b66tryh.js +4 -0
  18. package/dist/chunk-4b66tryh.js.map +10 -0
  19. package/dist/chunk-4kzjrrjv.js +3 -0
  20. package/dist/chunk-4kzjrrjv.js.map +10 -0
  21. package/dist/chunk-5m49s8z8.js +4 -0
  22. package/dist/chunk-5m49s8z8.js.map +10 -0
  23. package/dist/chunk-9b6y7r75.js +4 -0
  24. package/dist/chunk-9b6y7r75.js.map +10 -0
  25. package/dist/chunk-9zcbvqq2.js +3 -0
  26. package/dist/chunk-9zcbvqq2.js.map +10 -0
  27. package/dist/chunk-a0bpx1q3.js +4 -0
  28. package/dist/chunk-a0bpx1q3.js.map +10 -0
  29. package/dist/chunk-a0fxkkfh.js +4 -0
  30. package/dist/chunk-a0fxkkfh.js.map +10 -0
  31. package/dist/chunk-a6bjd9ar.js +3 -0
  32. package/dist/chunk-a6bjd9ar.js.map +10 -0
  33. package/dist/chunk-bg6pz5qh.js +3 -0
  34. package/dist/chunk-bg6pz5qh.js.map +10 -0
  35. package/dist/chunk-cpdcnp2x.js +4 -0
  36. package/dist/chunk-cpdcnp2x.js.map +10 -0
  37. package/dist/chunk-fr86y3rx.js +4 -0
  38. package/dist/chunk-fr86y3rx.js.map +10 -0
  39. package/dist/chunk-ftdtdkhk.js +3 -0
  40. package/dist/chunk-ftdtdkhk.js.map +10 -0
  41. package/dist/chunk-gjeaw024.js +4 -0
  42. package/dist/chunk-gjeaw024.js.map +10 -0
  43. package/dist/chunk-hdcdd2cf.js +4 -0
  44. package/dist/chunk-hdcdd2cf.js.map +10 -0
  45. package/dist/chunk-q2pb6ggs.js +3 -0
  46. package/dist/chunk-q2pb6ggs.js.map +10 -0
  47. package/dist/chunk-t9s9811k.js +3 -0
  48. package/dist/chunk-t9s9811k.js.map +10 -0
  49. package/dist/chunk-v4dvhh90.js +4 -0
  50. package/dist/chunk-v4dvhh90.js.map +10 -0
  51. package/dist/chunk-vzptz52h.js +4 -0
  52. package/dist/chunk-vzptz52h.js.map +10 -0
  53. package/dist/chunk-wyr5d8ad.js +3 -0
  54. package/dist/chunk-wyr5d8ad.js.map +10 -0
  55. package/dist/chunk-x0jsq6ag.js +3 -0
  56. package/dist/chunk-x0jsq6ag.js.map +10 -0
  57. package/dist/chunk-x2fe9scs.js +3 -0
  58. package/dist/chunk-x2fe9scs.js.map +10 -0
  59. package/dist/chunk-xm5jkehh.js +4 -0
  60. package/dist/chunk-xm5jkehh.js.map +10 -0
  61. package/dist/chunk-xzb1nshn.js +3 -0
  62. package/dist/chunk-xzb1nshn.js.map +10 -0
  63. package/dist/contracts/index.cjs.map +2 -2
  64. package/dist/contracts/index.js +1 -1
  65. package/dist/contracts/index.js.map +2 -2
  66. package/dist/index.cjs +3 -3
  67. package/dist/index.cjs.map +19 -18
  68. package/dist/index.js +3 -3
  69. package/dist/index.js.map +19 -18
  70. package/dist/tokens/index.cjs +2 -2
  71. package/dist/tokens/index.cjs.map +3 -16
  72. package/dist/tokens/index.js +2 -2
  73. package/dist/tokens/index.js.map +3 -16
  74. package/package.json +8 -5
  75. package/src/api/midgard/endpoints.ts +120 -132
  76. package/src/api/swapkitApi/endpoints.ts +53 -158
  77. package/src/api/swapkitApi/types.ts +318 -514
  78. package/src/api/thorswapStatic/endpoints.ts +18 -2
  79. package/src/contracts/index.ts +1 -1
  80. package/src/index.ts +15 -10
  81. package/src/modules/__tests__/assetValue.test.ts +50 -22
  82. package/src/modules/__tests__/swapKitConfig.test.ts +3 -3
  83. package/src/modules/assetValue.ts +77 -67
  84. package/src/modules/requestClient.ts +52 -55
  85. package/src/modules/swapKitConfig.ts +8 -5
  86. package/src/modules/swapKitError.ts +18 -11
  87. package/src/tokens/lists/index.ts +1 -0
  88. package/src/types/chains.ts +22 -5
  89. package/src/types/commonTypes.ts +1 -1
  90. package/src/types/derivationPath.ts +11 -24
  91. package/src/types/radix.ts +2 -2
  92. package/src/types/sdk.ts +0 -7
  93. package/src/types/tokens.ts +13 -16
  94. package/src/types/wallet.ts +42 -21
  95. package/src/utils/asset.ts +118 -217
  96. package/src/utils/derivationPath.ts +24 -7
  97. package/src/utils/plugin.ts +1 -1
  98. package/src/utils/tokens.ts +73 -0
  99. package/src/utils/validators.ts +3 -2
  100. package/src/utils/wallets.ts +19 -10
@@ -28,6 +28,7 @@ const errorCodes = {
28
28
  core_wallet_talisman_not_installed: 10110,
29
29
  core_wallet_not_keypair_wallet: 10111,
30
30
  core_wallet_sign_message_not_supported: 10110,
31
+ core_wallet_connection_failed: 10112,
31
32
  /**
32
33
  * Core - Swap
33
34
  */
@@ -95,6 +96,10 @@ const errorCodes = {
95
96
  wallet_keepkey_send_transaction_no_address: 20903,
96
97
  wallet_bitkeep_not_found: 21001,
97
98
  wallet_exodus_sign_transaction_error: 21100,
99
+ wallet_keystore_invalid_password: 29900,
100
+ wallet_keystore_unsupported_version: 29901,
101
+ wallet_onekey_not_found: 21200,
102
+ wallet_onekey_sign_transaction_error: 21201,
98
103
  /**
99
104
  * Chainflip
100
105
  */
@@ -143,6 +148,13 @@ const errorCodes = {
143
148
  toolbox_evm_error_estimating_gas_limit: 90211,
144
149
  toolbox_evm_error_sending_transaction: 90212,
145
150
  toolbox_radix_signer_not_defined: 90301,
151
+ toolbox_solana_no_signer: 90401,
152
+ toolbox_solana_fee_estimation_failed: 90402,
153
+ toolbox_ripple_rpc_not_configured: 90501,
154
+ toolbox_ripple_signer_not_found: 90502,
155
+ toolbox_ripple_asset_not_supported: 90503,
156
+ toolbox_ripple_broadcast_error: 90504,
157
+ toolbox_ripple_get_balance_error: 90505,
146
158
  /**
147
159
  * Helpers
148
160
  */
@@ -167,24 +179,19 @@ export class SwapKitError extends Error {
167
179
 
168
180
  constructor(
169
181
  errorOrErrorKey: ErrorKeys | { errorKey: ErrorKeys; info?: Record<string, any> },
170
- sourceError?: any,
182
+ sourceErrorOrInfo?: any,
171
183
  ) {
172
184
  const isErrorString = typeof errorOrErrorKey === "string";
173
185
  const errorKey = isErrorString ? errorOrErrorKey : errorOrErrorKey.errorKey;
174
- super(errorKey);
186
+ const message = `${errorKey}${isErrorString ? "" : `: ${JSON.stringify(errorOrErrorKey.info)}`}`;
175
187
 
176
- if (sourceError) {
177
- console.error(sourceError, {
178
- stack: sourceError?.stack,
179
- message: sourceError?.message,
180
- });
188
+ if (sourceErrorOrInfo) {
189
+ console.error(sourceErrorOrInfo);
181
190
  }
182
191
 
183
- console.error(errorKey, {
184
- code: SwapKitError.ErrorCode[errorKey],
185
- message: `${errorKey}${isErrorString ? "" : `: ${JSON.stringify(errorOrErrorKey.info)}`}`,
186
- });
192
+ console.error(errorKey, { code: SwapKitError.ErrorCode[errorKey], message });
187
193
 
194
+ super(errorKey);
188
195
  Object.setPrototypeOf(this, SwapKitError.prototype);
189
196
  }
190
197
  }
@@ -1,3 +1,4 @@
1
+ export { list as CamelotV3List } from "./camelot_v3";
1
2
  export { list as CaviarV1List } from "./caviar_v1";
2
3
  export { list as ChainflipList } from "./chainflip";
3
4
  export { list as JupiterList } from "./jupiter";
@@ -13,11 +13,13 @@ export enum Chain {
13
13
  Kujira = "KUJI",
14
14
  Litecoin = "LTC",
15
15
  Maya = "MAYA",
16
+ Near = "NEAR",
16
17
  Optimism = "OP",
17
18
  Polkadot = "DOT",
18
19
  Chainflip = "FLIP",
19
20
  Polygon = "MATIC",
20
21
  Radix = "XRD",
22
+ Ripple = "XRP",
21
23
  THORChain = "THOR",
22
24
  Solana = "SOL",
23
25
  }
@@ -49,12 +51,14 @@ export enum ChainId {
49
51
  Litecoin = "litecoin",
50
52
  Maya = "mayachain-mainnet-v1",
51
53
  MayaStagenet = "mayachain-stagenet-v1",
54
+ Near = "near",
52
55
  Optimism = "10",
53
56
  OptimismHex = "0xa",
54
57
  Polkadot = "polkadot",
55
58
  Polygon = "137",
56
59
  PolygonHex = "0x89",
57
60
  Radix = "radix-mainnet",
61
+ Ripple = "ripple",
58
62
  THORChain = "thorchain-1",
59
63
  THORChainStagenet = "thorchain-stagenet-v2",
60
64
  Solana = "solana",
@@ -76,21 +80,23 @@ export const ChainIdToChain: Record<ChainId, Chain> = {
76
80
  [ChainId.Dash]: Chain.Dash,
77
81
  [ChainId.Dogecoin]: Chain.Dogecoin,
78
82
  [ChainId.EthereumHex]: Chain.Ethereum,
83
+ [ChainId.Ethereum]: Chain.Ethereum,
79
84
  [ChainId.Fiat]: Chain.Fiat,
80
85
  [ChainId.Kujira]: Chain.Kujira,
81
- [ChainId.Ethereum]: Chain.Ethereum,
82
86
  [ChainId.Litecoin]: Chain.Litecoin,
83
87
  [ChainId.MayaStagenet]: Chain.Maya,
84
88
  [ChainId.Maya]: Chain.Maya,
89
+ [ChainId.Near]: Chain.Near,
85
90
  [ChainId.OptimismHex]: Chain.Optimism,
86
91
  [ChainId.Optimism]: Chain.Optimism,
87
92
  [ChainId.Polkadot]: Chain.Polkadot,
88
93
  [ChainId.PolygonHex]: Chain.Polygon,
89
94
  [ChainId.Polygon]: Chain.Polygon,
90
95
  [ChainId.Radix]: Chain.Radix,
96
+ [ChainId.Ripple]: Chain.Ripple,
97
+ [ChainId.Solana]: Chain.Solana,
91
98
  [ChainId.THORChainStagenet]: Chain.THORChain,
92
99
  [ChainId.THORChain]: Chain.THORChain,
93
- [ChainId.Solana]: Chain.Solana,
94
100
  };
95
101
 
96
102
  type ChainNameType = keyof typeof Chain;
@@ -115,10 +121,12 @@ export const BaseDecimal: Record<Chain, number> = {
115
121
  LTC: 8,
116
122
  MATIC: 18,
117
123
  MAYA: 8,
124
+ NEAR: 24,
118
125
  OP: 18,
119
126
  SOL: 9,
120
127
  THOR: 8,
121
128
  XRD: 18,
129
+ XRP: 6,
122
130
  };
123
131
 
124
132
  export const BlockTimes: Record<Partial<Chain>, number> = {
@@ -137,10 +145,12 @@ export const BlockTimes: Record<Partial<Chain>, number> = {
137
145
  [Chain.Kujira]: 2.2,
138
146
  [Chain.Litecoin]: 150,
139
147
  [Chain.Maya]: 6,
148
+ [Chain.Near]: 1,
140
149
  [Chain.Optimism]: 2,
141
150
  [Chain.Polkadot]: 6,
142
151
  [Chain.Polygon]: 2.1,
143
152
  [Chain.Radix]: 5,
153
+ [Chain.Ripple]: 5,
144
154
  [Chain.Solana]: 0.4,
145
155
  [Chain.THORChain]: 6,
146
156
  };
@@ -156,6 +166,7 @@ export type EVMChain =
156
166
  | Chain.Ethereum
157
167
  | Chain.Optimism
158
168
  | Chain.Polygon;
169
+
159
170
  export const EVMChains = [
160
171
  Chain.Arbitrum,
161
172
  Chain.Avalanche,
@@ -212,7 +223,7 @@ export const MAYASupportedChains = [
212
223
 
213
224
  export const RPC_URLS: Record<Chain | StagenetChain, string> = {
214
225
  [Chain.Arbitrum]: "https://arb1.arbitrum.io/rpc",
215
- [Chain.Avalanche]: "https://avalanche-c-chain-rpc.publicnode.com",
226
+ [Chain.Avalanche]: "https://api.avax.network/ext/bc/C/rpc",
216
227
  [Chain.Base]: "https://base-rpc.publicnode.com",
217
228
  [Chain.BinanceSmartChain]: "https://bsc-dataseed.binance.org",
218
229
  [Chain.BitcoinCash]: "https://node-router.thorswap.net/bitcoin-cash",
@@ -223,13 +234,15 @@ export const RPC_URLS: Record<Chain | StagenetChain, string> = {
223
234
  [Chain.Dogecoin]: "https://node-router.thorswap.net/dogecoin",
224
235
  [Chain.Ethereum]: "https://ethereum-rpc.publicnode.com",
225
236
  [Chain.Fiat]: "",
226
- [Chain.Kujira]: "https://rpc-kujira.synergynodes.com/",
237
+ [Chain.Kujira]: "https://kujira-rpc.ibs.team",
227
238
  [Chain.Litecoin]: "https://node-router.thorswap.net/litecoin",
228
239
  [Chain.Maya]: "https://tendermint.mayachain.info",
240
+ [Chain.Near]: "https://rpc.ankr.com/near",
229
241
  [Chain.Optimism]: "https://mainnet.optimism.io",
230
242
  [Chain.Polkadot]: "wss://rpc.polkadot.io",
231
243
  [Chain.Polygon]: "https://polygon-rpc.com",
232
244
  [Chain.Radix]: "https://radix-mainnet.rpc.grove.city/v1/326002fc/core",
245
+ [Chain.Ripple]: "wss://xrpl.ws/",
233
246
  [Chain.Solana]: "https://solana-rpc.publicnode.com",
234
247
  [Chain.THORChain]: "https://rpc.thorswap.net",
235
248
  [StagenetChain.Maya]: "https://stagenet.tendermint.mayachain.info",
@@ -271,10 +284,11 @@ export const FALLBACK_URLS: Record<Chain | StagenetChain, string[]> = {
271
284
  [Chain.Dogecoin]: ["https://doge.getblock.io/mainnet", "https://dogecoin.publicnode.com"],
272
285
  [Chain.Ethereum]: ["https://eth.llamarpc.com", "https://rpc.ankr.com/eth"],
273
286
  [Chain.Fiat]: [],
274
- [Chain.Kujira]: ["https://kujira-rpc.polkachu.com", "https://kujira-rpc.ibs.team"],
287
+ [Chain.Kujira]: ["https://kujira-rpc.polkachu.com", "https://rpc-kujira.synergynodes.com/"],
275
288
  [Chain.Litecoin]: ["https://ltc.getblock.io/mainnet", "https://litecoin.publicnode.com"],
276
289
  [Chain.Maya]: ["https://tendermint.mayachain.info", "https://maya-tendermint.publicnode.com"],
277
290
  [StagenetChain.Maya]: [],
291
+ [Chain.Near]: ["https://1rpc.io/near"],
278
292
  [Chain.Optimism]: ["https://optimism.llamarpc.com", "https://1rpc.io/op"],
279
293
  [Chain.Polkadot]: [
280
294
  "wss://polkadot-rpc.dwellir.com",
@@ -282,6 +296,7 @@ export const FALLBACK_URLS: Record<Chain | StagenetChain, string[]> = {
282
296
  ],
283
297
  [Chain.Polygon]: ["https://polygon.llamarpc.com", "https://rpc.ankr.com/polygon"],
284
298
  [Chain.Radix]: ["https://mainnet.radixdlt.com", "https://radix-mainnet.rpc.grove.city/v1"],
299
+ [Chain.Ripple]: ["wss://s1.ripple.com/", "wss://s2.ripple.com/"],
285
300
  [Chain.THORChain]: ["https://thornode.ninerealms.com", NODE_URLS[Chain.THORChain]],
286
301
  [StagenetChain.THORChain]: [],
287
302
  [Chain.Solana]: ["https://api.mainnet-beta.solana.com", "https://rpc.ankr.com/solana"],
@@ -303,10 +318,12 @@ export const EXPLORER_URLS: Record<Chain, string> = {
303
318
  [Chain.Kujira]: "https://finder.kujira.network/kaiyo-1",
304
319
  [Chain.Litecoin]: "https://blockchair.com/litecoin",
305
320
  [Chain.Maya]: "https://www.mayascan.org",
321
+ [Chain.Near]: "https://nearblocks.io",
306
322
  [Chain.Optimism]: "https://optimistic.etherscan.io",
307
323
  [Chain.Polkadot]: "https://polkadot.subscan.io",
308
324
  [Chain.Polygon]: "https://polygonscan.com",
309
325
  [Chain.Radix]: "https://dashboard.radixdlt.com",
326
+ [Chain.Ripple]: "https://livenet.xrpl.org/",
310
327
  [Chain.THORChain]: "https://runescan.io",
311
328
  [Chain.Solana]: "https://solscan.io",
312
329
  };
@@ -2,7 +2,7 @@ import type { Chain } from "./chains";
2
2
  import type { ChainWallet, CryptoChain } from "./wallet";
3
3
 
4
4
  export type AddChainType<M = { [key in string]: any }> = <T extends CryptoChain>(
5
- params: ChainWallet<T> & M,
5
+ params: Omit<ChainWallet<T>, "balance"> & M,
6
6
  ) => void;
7
7
 
8
8
  export type Witness = {
@@ -1,3 +1,4 @@
1
+ import { derivationPathToString } from "../utils/derivationPath";
1
2
  import type { Chain } from "./chains";
2
3
 
3
4
  export enum ContractAddress {
@@ -10,30 +11,6 @@ export enum ContractAddress {
10
11
  OP = "0x4200000000000000000000000000000000000042",
11
12
  }
12
13
 
13
- export enum DerivationPath {
14
- ARB = "m/44'/60'/0'/0",
15
- AVAX = "m/44'/60'/0'/0",
16
- BASE = "m/44'/60'/0'/0",
17
- BCH = "m/44'/145'/0'/0",
18
- BSC = "m/44'/60'/0'/0",
19
- BTC = "m/84'/0'/0'/0",
20
- DASH = "m/44'/5'/0'/0",
21
- DOGE = "m/44'/3'/0'/0",
22
- DOT = "////",
23
- ETH = "m/44'/60'/0'/0",
24
- FLIP = "////",
25
- GAIA = "m/44'/118'/0'/0",
26
- KUJI = "m/44'/118'/0'/0",
27
- LTC = "m/84'/2'/0'/0",
28
- MATIC = "m/44'/60'/0'/0",
29
- MAYA = "m/44'/931'/0'/0",
30
- OP = "m/44'/60'/0'/0",
31
- SOL = "m/44'/501'/0'/0",
32
- THOR = "m/44'/931'/0'/0",
33
- XRD = "////",
34
- FIAT = "////",
35
- }
36
-
37
14
  export type DerivationPathArray = [number, number, number, number, number?];
38
15
 
39
16
  export const NetworkDerivationPath: Record<Chain, DerivationPathArray> = {
@@ -51,6 +28,7 @@ export const NetworkDerivationPath: Record<Chain, DerivationPathArray> = {
51
28
  LTC: [84, 2, 0, 0, 0],
52
29
  MATIC: [44, 60, 0, 0, 0],
53
30
  MAYA: [44, 931, 0, 0, 0],
31
+ NEAR: [44, 397, 0, 0, 0],
54
32
  OP: [44, 60, 0, 0, 0],
55
33
  SOL: [44, 501, 0, 0, 0],
56
34
  THOR: [44, 931, 0, 0, 0],
@@ -60,4 +38,13 @@ export const NetworkDerivationPath: Record<Chain, DerivationPathArray> = {
60
38
  FIAT: [0, 0, 0, 0, 0],
61
39
  FLIP: [0, 0, 0, 0, 0],
62
40
  XRD: [0, 0, 0, 0, 0],
41
+ XRP: [44, 144, 0, 0, 0],
63
42
  };
43
+
44
+ export const DerivationPath: Record<Chain, string> = Object.keys(NetworkDerivationPath).reduce(
45
+ (acc, key) => {
46
+ acc[key as Chain] = derivationPathToString(NetworkDerivationPath[key as Chain]);
47
+ return acc;
48
+ },
49
+ {} as Record<Chain, string>,
50
+ );
@@ -1,5 +1,5 @@
1
1
  export type RadixCoreStateResourceDTO = {
2
- at_ledger_state?: any; // not needed
2
+ at_ledger_state?: any;
3
3
  manager: {
4
4
  resource_type: string;
5
5
  divisibility: {
@@ -10,5 +10,5 @@ export type RadixCoreStateResourceDTO = {
10
10
  };
11
11
  };
12
12
  };
13
- owner_role?: any; // not needed
13
+ owner_role?: any;
14
14
  };
package/src/types/sdk.ts CHANGED
@@ -27,13 +27,6 @@ export type ApproveReturnType<T extends ApproveMode> = T extends "checkOnly"
27
27
  ? Promise<boolean>
28
28
  : Promise<string>;
29
29
 
30
- export type WalletTxParams = {
31
- feeOptionKey?: FeeOption;
32
- from?: string;
33
- memo?: string; // optional memo to pass
34
- recipient: string;
35
- };
36
-
37
30
  export enum MemoType {
38
31
  NAME_REGISTER = "~",
39
32
  BOND = "BOND",
@@ -2,19 +2,16 @@ import type { tokenLists } from "@swapkit/helpers/tokens";
2
2
 
3
3
  export type TokenTax = { buy: number; sell: number };
4
4
 
5
- export type TokenNames =
6
- | (typeof tokenLists)["CaviarV1List"]["tokens"][number]["identifier"]
7
- | (typeof tokenLists)["ChainflipList"]["tokens"][number]["identifier"]
8
- | (typeof tokenLists)["JupiterList"]["tokens"][number]["identifier"]
9
- // | (typeof tokenLists)["KadoList"]["tokens"][number]["identifier"]
10
- | (typeof tokenLists)["MayaList"]["tokens"][number]["identifier"]
11
- // | (typeof tokenLists)['OciswapV1List']["tokens"][number]["identifier"]
12
- | (typeof tokenLists)["OneInchList"]["tokens"][number]["identifier"]
13
- | (typeof tokenLists)["OpenOceanV2List"]["tokens"][number]["identifier"]
14
- | (typeof tokenLists)["PancakeswapList"]["tokens"][number]["identifier"]
15
- | (typeof tokenLists)["PangolinList"]["tokens"][number]["identifier"]
16
- | (typeof tokenLists)["SushiswapList"]["tokens"][number]["identifier"]
17
- | (typeof tokenLists)["ThorchainList"]["tokens"][number]["identifier"]
18
- | (typeof tokenLists)["TraderjoeV2List"]["tokens"][number]["identifier"]
19
- | (typeof tokenLists)["UniswapV2List"]["tokens"][number]["identifier"]
20
- | (typeof tokenLists)["UniswapV3List"]["tokens"][number]["identifier"];
5
+ type ListOfTokens = Exclude<
6
+ keyof typeof tokenLists,
7
+ | "JupiterList"
8
+ | "CamelotV3List"
9
+ | "OneInchList"
10
+ | "OpenOceanV2List"
11
+ | "PancakeswapList"
12
+ | "PangolinList"
13
+ | "SushiswapList"
14
+ | "TraderjoeV2List"
15
+ >;
16
+
17
+ export type TokenNames = (typeof tokenLists)[ListOfTokens]["tokens"][number]["identifier"];
@@ -1,14 +1,16 @@
1
1
  import type { CosmosWallets, ThorchainWallets } from "@swapkit/toolboxes/cosmos";
2
- import type { EVMWallets } from "@swapkit/toolboxes/evm";
3
- import type { RadixWallets } from "@swapkit/toolboxes/radix";
4
- import type { SolanaWallets } from "@swapkit/toolboxes/solana";
5
- import type { SubstrateWallets } from "@swapkit/toolboxes/substrate";
6
- import type { UTXOWallets } from "@swapkit/toolboxes/utxo";
2
+ import type { EVMToolboxes } from "@swapkit/toolboxes/evm";
3
+ import type { RadixWallet } from "@swapkit/toolboxes/radix";
4
+ import type { RippleWallet } from "@swapkit/toolboxes/ripple";
5
+ import type { SolanaWallet } from "@swapkit/toolboxes/solana";
6
+ import type { SubstrateToolboxes } from "@swapkit/toolboxes/substrate";
7
+ import type { UTXOToolboxes } from "@swapkit/toolboxes/utxo";
7
8
  import type { BrowserProvider } from "ethers";
8
9
  import type { Eip1193Provider } from "ethers";
9
10
 
10
11
  import type { AssetValue } from "../modules/assetValue";
11
- import type { Chain, ChainId } from "./chains";
12
+ import { Chain, type ChainId } from "./chains";
13
+ import type { FeeOption } from "./sdk";
12
14
 
13
15
  declare global {
14
16
  interface WindowEventMap {
@@ -27,7 +29,10 @@ export type EthereumWindowProvider = BrowserProvider & {
27
29
  isTalisman?: boolean;
28
30
  on: (event: string, callback?: () => void) => void;
29
31
  overrideIsMetaMask?: boolean;
30
- request: <T = unknown>(args: { method: string; params?: unknown[] }) => Promise<T>;
32
+ request: <T = unknown>(args: {
33
+ method: string;
34
+ params?: unknown[];
35
+ }) => Promise<T>;
31
36
  selectedProvider?: EthereumWindowProvider;
32
37
  };
33
38
 
@@ -43,15 +48,6 @@ export type NetworkParams = {
43
48
  blockExplorerUrls: string[];
44
49
  };
45
50
 
46
- export type {
47
- CosmosWallets,
48
- ThorchainWallets,
49
- EVMWallets,
50
- SubstrateWallets,
51
- UTXOWallets,
52
- SolanaWallets,
53
- };
54
-
55
51
  export enum WalletOption {
56
52
  BITGET = "BITGET",
57
53
  BRAVE = "BRAVE",
@@ -70,6 +66,7 @@ export enum WalletOption {
70
66
  METAMASK = "METAMASK",
71
67
  OKX = "OKX",
72
68
  OKX_MOBILE = "OKX_MOBILE",
69
+ ONEKEY = "ONEKEY",
73
70
  PHANTOM = "PHANTOM",
74
71
  POLKADOT_JS = "POLKADOT_JS",
75
72
  RADIX_WALLET = "RADIX_WALLET",
@@ -102,13 +99,15 @@ export type BaseWallet<T extends EmptyWallet | Record<string, unknown>> = {
102
99
  };
103
100
 
104
101
  export type FullWallet = BaseWallet<
105
- EVMWallets &
106
- UTXOWallets &
102
+ EVMToolboxes &
103
+ UTXOToolboxes &
107
104
  CosmosWallets &
108
105
  ThorchainWallets &
109
- SubstrateWallets &
110
- SolanaWallets &
111
- RadixWallets
106
+ SubstrateToolboxes & {
107
+ [Chain.Radix]: RadixWallet;
108
+ [Chain.Ripple]: RippleWallet;
109
+ [Chain.Solana]: SolanaWallet;
110
+ }
112
111
  >;
113
112
 
114
113
  export type SwapKitPluginParams = {
@@ -136,3 +135,25 @@ export type EIP6963Provider = {
136
135
  export type EIP6963AnnounceProviderEvent = Event & {
137
136
  detail: EIP6963Provider;
138
137
  };
138
+
139
+ export type ChainSigner<T, S> = {
140
+ signTransaction: (params: T) => Promise<S>;
141
+ getAddress: () => Promise<string>;
142
+ sign?: (message: string) => Promise<string>;
143
+ };
144
+
145
+ export type GenericTransferParams = {
146
+ recipient: string;
147
+ assetValue: AssetValue;
148
+ memo?: string;
149
+ feeRate?: number;
150
+ feeOptionKey?: FeeOption;
151
+ };
152
+
153
+ export type GenericCreateTransactionParams = Omit<
154
+ GenericTransferParams,
155
+ "feeOptionKey" & "feeRate"
156
+ > & {
157
+ sender: string;
158
+ feeRate: number;
159
+ };