@swapkit/core 1.0.0-rc.161 → 1.0.0-rc.163

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/dist/index.js CHANGED
@@ -6,9 +6,18 @@ export * from "@swapkit/helpers";
6
6
  import {
7
7
  ApproveMode,
8
8
  AssetValue,
9
+ Chain as Chain2,
9
10
  EVMChains,
10
11
  SwapKitError
11
12
  } from "@swapkit/helpers";
13
+ import {
14
+ evmValidateAddress
15
+ } from "@swapkit/toolbox-evm";
16
+ import {
17
+ cosmosValidateAddress
18
+ } from "@swapkit/toolbox-cosmos";
19
+ import {substrateValidateAddress} from "@swapkit/toolbox-substrate";
20
+ import {utxoValidateAddress} from "@swapkit/toolbox-utxo";
12
21
 
13
22
  // src/helpers/explorerUrls.ts
14
23
  import {Chain, ChainToExplorerUrl} from "@swapkit/helpers";
@@ -140,7 +149,33 @@ function SwapKit({
140
149
  return getWallet(chain)?.address || "";
141
150
  }
142
151
  function validateAddress({ address, chain }) {
143
- return getWallet(chain)?.validateAddress?.(address);
152
+ switch (chain) {
153
+ case Chain2.Arbitrum:
154
+ case Chain2.Avalanche:
155
+ case Chain2.Optimism:
156
+ case Chain2.BinanceSmartChain:
157
+ case Chain2.Polygon:
158
+ case Chain2.Ethereum: {
159
+ return evmValidateAddress({ address });
160
+ }
161
+ case Chain2.Polkadot: {
162
+ return substrateValidateAddress({ address, chain });
163
+ }
164
+ case Chain2.Litecoin:
165
+ case Chain2.Dash:
166
+ case Chain2.Dogecoin:
167
+ case Chain2.BitcoinCash:
168
+ case Chain2.Bitcoin: {
169
+ return utxoValidateAddress({ address, chain });
170
+ }
171
+ case Chain2.Cosmos:
172
+ case Chain2.Kujira:
173
+ case Chain2.Maya:
174
+ case Chain2.THORChain: {
175
+ return cosmosValidateAddress({ address, chain });
176
+ }
177
+ }
178
+ return false;
144
179
  }
145
180
  function getBalance(chain, refresh) {
146
181
  if (refresh) {
@@ -175,6 +210,18 @@ function SwapKit({
175
210
  }
176
211
  throw new SwapKitError("core_plugin_swap_not_found");
177
212
  }
213
+ function transfer({
214
+ from,
215
+ recipient,
216
+ assetValue,
217
+ feeOptionKey
218
+ }) {
219
+ const chain = assetValue.chain;
220
+ const wallet = connectedWallets[chain];
221
+ if (!wallet)
222
+ throw new SwapKitError("core_wallet_connection_not_found");
223
+ return wallet.transfer({ from, recipient, assetValue, feeOptionKey });
224
+ }
178
225
  function disconnectAll() {
179
226
  for (const chain of Object.keys(connectedWallets)) {
180
227
  const wallet = connectedWallets[chain];
@@ -205,6 +252,7 @@ function SwapKit({
205
252
  getWalletWithBalance,
206
253
  isAssetValueApproved,
207
254
  swap,
255
+ transfer,
208
256
  validateAddress,
209
257
  disconnectAll,
210
258
  disconnectChain
@@ -214,4 +262,4 @@ export {
214
262
  SwapKit
215
263
  };
216
264
 
217
- //# debugId=E0205D68B547A0FA64756e2164756e21
265
+ //# debugId=F6D931ECC10E5F9864756e2164756e21
package/dist/index.js.map CHANGED
@@ -3,10 +3,10 @@
3
3
  "sources": ["../src/index.ts", "../src/client.ts", "../src/helpers/explorerUrls.ts"],
4
4
  "sourcesContent": [
5
5
  "export * from \"@swapkit/api\";\nexport * from \"@swapkit/helpers\";\n\nexport * from \"./client.ts\";\nexport * from \"./types.ts\";\n",
6
- "import {\n type AddChainWalletParams,\n ApproveMode,\n type ApproveReturnType,\n AssetValue,\n type Chain,\n type ConnectConfig,\n type EVMChain,\n EVMChains,\n type ProviderName as PluginNameEnum,\n SwapKitError,\n type SwapParams,\n} from \"@swapkit/helpers\";\nimport type { BaseEVMWallet } from \"@swapkit/toolbox-evm\";\n\nimport {\n getExplorerAddressUrl as getAddressUrl,\n getExplorerTxUrl as getTxUrl,\n} from \"./helpers/explorerUrls.ts\";\nimport type { Apis, SwapKitPluginInterface, SwapKitWallet, Wallet } from \"./types.ts\";\n\nexport function SwapKit<\n Plugins extends { [key in string]: SwapKitPluginInterface<{ [key in string]: Todo }> },\n Wallets extends { [key in string]: SwapKitWallet<NotWorth[]> },\n>({\n apis = {},\n config = {},\n plugins,\n rpcUrls = {},\n stagenet = false,\n wallets,\n}: {\n apis?: Apis;\n config?: ConnectConfig;\n plugins: Plugins;\n rpcUrls?: { [key in Chain]?: string };\n stagenet?: boolean;\n wallets: Wallets;\n}) {\n type PluginName = keyof Plugins;\n\n /**\n * @REMOVE (V1)\n * Compatibility layer for plugins and wallets for easier migration and backwards compatibility\n */\n const compatPlugins: Plugins = Array.isArray(plugins)\n ? plugins.reduce((acc, pluginInterface) => {\n // @ts-ignore Ignore until we remove the compatibility layer\n const { name, plugin } = Object.values(pluginInterface)?.[0] || {};\n acc[name] = plugin;\n return acc;\n }, {})\n : plugins;\n const compatWallets: Wallets = Array.isArray(wallets)\n ? wallets.reduce((acc, wallet) => {\n // @ts-ignore Ignore until we remove the compatibility layer\n const [walletName, connectWallet] = Object.entries(wallet)?.[0] || {};\n acc[walletName] = connectWallet;\n return acc;\n }, {})\n : wallets;\n\n const connectedWallets = {} as Wallet;\n const availablePlugins = Object.entries(compatPlugins).reduce(\n (acc, [pluginName, { plugin, config: pluginConfig }]) => {\n const methods = plugin({\n wallets: connectedWallets,\n stagenet,\n config: pluginConfig ?? config,\n });\n\n // @ts-expect-error\n acc[pluginName] = methods;\n return acc;\n },\n {} as { [key in PluginName]: ReturnType<Plugins[key][\"plugin\"]> },\n );\n\n const connectWalletMethods = Object.entries(compatWallets).reduce(\n (acc, [walletName, wallet]) => {\n const connectWallet = wallet({ addChain, config, apis, rpcUrls });\n\n // @ts-expect-error\n acc[walletName] = connectWallet;\n return acc;\n },\n {} as { [key in keyof Wallets]: ReturnType<Wallets[key]> },\n );\n\n /**\n * @Private\n */\n function getSwapKitPlugin<T extends PluginName>(pluginName: T) {\n const plugin = availablePlugins[pluginName] || Object.values(availablePlugins)[0];\n\n if (!plugin) {\n throw new SwapKitError(\"core_plugin_not_found\", \"Could not find the requested plugin\");\n }\n\n return plugin;\n }\n\n /**\n * @Private\n */\n function getSwapKitPluginForSKProvider(pluginName: PluginNameEnum): Plugins[keyof Plugins] {\n const plugin = Object.values(availablePlugins).find((plugin) =>\n plugin.supportedSwapkitProviders?.includes(pluginName),\n );\n\n if (!plugin) {\n throw new SwapKitError(\"core_plugin_not_found\", \"Could not find the requested plugin\");\n }\n\n return plugin;\n }\n\n function addChain<T extends Chain>(connectWallet: AddChainWalletParams<T>) {\n // @ts-expect-error: TODO\n connectedWallets[connectWallet.chain] = connectWallet;\n }\n\n // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: <explanation>\n function approve<T extends ApproveMode>({\n assetValue,\n type = \"checkOnly\" as T,\n contractAddress: spenderAddress,\n }: {\n type: T;\n assetValue: AssetValue;\n contractAddress: string | PluginName;\n }) {\n const plugin = availablePlugins[spenderAddress];\n\n if (plugin) {\n if (type === ApproveMode.CheckOnly && \"isAssetValueApproved\" in plugin) {\n return plugin.isAssetValueApproved({ assetValue }) as ApproveReturnType<T>;\n }\n if (type === ApproveMode.Approve && \"approveAssetValue\" in plugin) {\n return plugin.approveAssetValue({ assetValue }) as ApproveReturnType<T>;\n }\n\n throw new SwapKitError(\n \"core_approve_asset_target_invalid\",\n `Target ${String(spenderAddress)} cannot be used for approve operation`,\n );\n }\n\n const { address, chain, isGasAsset, isSynthetic } = assetValue;\n const isEVMChain = EVMChains.includes(chain as EVMChain);\n const isNativeEVM = isEVMChain && isGasAsset;\n\n if (isNativeEVM || !isEVMChain || isSynthetic) {\n return Promise.resolve(type === \"checkOnly\" ? true : \"approved\") as ApproveReturnType<T>;\n }\n\n const walletMethods = connectedWallets[chain] as BaseEVMWallet;\n const walletAction = type === \"checkOnly\" ? walletMethods?.isApproved : walletMethods?.approve;\n if (!walletAction) throw new SwapKitError(\"core_wallet_connection_not_found\");\n\n const from = getAddress(chain);\n if (!(address && from && typeof spenderAddress === \"string\")) {\n throw new SwapKitError(\"core_approve_asset_address_or_from_not_found\");\n }\n\n return walletAction({\n amount: assetValue.getBaseValue(\"bigint\"),\n assetAddress: address,\n from,\n spenderAddress,\n }) as ApproveReturnType<T>;\n }\n\n /**\n * @Public\n */\n function getWallet<T extends Chain>(chain: T) {\n return connectedWallets[chain];\n }\n function getAllWallets() {\n return { ...connectedWallets };\n }\n function getAddress<T extends Chain>(chain: T) {\n return getWallet(chain)?.address || \"\";\n }\n /**\n * TODO: Figure out validation without connecting to wallet\n */\n function validateAddress({ address, chain }: { address: string; chain: Chain }) {\n // @ts-expect-error TODO add validate address to radix\n return getWallet(chain)?.validateAddress?.(address);\n }\n\n function getBalance<T extends Chain>(chain: T, refresh?: boolean) {\n if (refresh) {\n return getWalletWithBalance(chain).then((wallet) => wallet.balance);\n }\n\n return getWallet(chain)?.balance || [];\n }\n\n async function getWalletWithBalance<T extends Chain>(chain: T, potentialScamFilter = true) {\n const defaultBalance = [AssetValue.fromChainOrSignature(chain)];\n const wallet = getWallet(chain);\n\n if (!wallet) {\n throw new SwapKitError(\"core_wallet_connection_not_found\");\n }\n\n if (\"getBalance\" in wallet) {\n // @ts-expect-error TODO add getBalance to radix\n const balance = await wallet.getBalance(wallet.address, potentialScamFilter);\n wallet.balance = balance?.length ? balance : defaultBalance;\n }\n\n return wallet;\n }\n\n function approveAssetValue(assetValue: AssetValue, contractAddress: string | PluginName) {\n return approve({ assetValue, contractAddress, type: ApproveMode.Approve });\n }\n\n function isAssetValueApproved(assetValue: AssetValue, contractAddress: string | PluginName) {\n return approve({ assetValue, contractAddress, type: ApproveMode.CheckOnly });\n }\n\n function swap<T extends PluginName>({ route, pluginName, ...rest }: SwapParams<T>) {\n const plugin =\n (pluginName && getSwapKitPlugin(pluginName)) ||\n getSwapKitPluginForSKProvider(route.providers[0] as PluginNameEnum);\n if (!plugin) throw new SwapKitError(\"core_swap_route_not_complete\");\n\n if (\"swap\" in plugin) {\n return plugin.swap({ ...rest, route });\n }\n\n throw new SwapKitError(\"core_plugin_swap_not_found\");\n }\n\n function disconnectAll() {\n for (const chain of Object.keys(connectedWallets)) {\n // @ts-expect-error: TODO\n const wallet = connectedWallets[chain];\n if (\"disconnect\" in wallet) {\n wallet.disconnect();\n }\n // @ts-expect-error: TODO\n delete connectedWallets[chain];\n }\n }\n\n function disconnectChain(chain: Chain) {\n const wallet = connectedWallets[chain];\n const disconnect = wallet?.disconnect;\n if (disconnect) {\n disconnect();\n }\n delete connectedWallets[chain];\n }\n\n return {\n ...availablePlugins,\n ...connectWalletMethods,\n\n approveAssetValue,\n getAddress,\n getBalance,\n getExplorerAddressUrl: getAddressUrl,\n getExplorerTxUrl: getTxUrl,\n getWallet,\n getAllWallets,\n getWalletWithBalance,\n isAssetValueApproved,\n swap,\n validateAddress,\n disconnectAll,\n disconnectChain,\n };\n}\n",
6
+ "import {\n type AddChainWalletParams,\n ApproveMode,\n type ApproveReturnType,\n AssetValue,\n Chain,\n type ConnectConfig,\n type EVMChain,\n EVMChains,\n type ProviderName as PluginNameEnum,\n SwapKitError,\n type SwapParams,\n type WalletChain,\n} from \"@swapkit/helpers\";\nimport {\n type BaseEVMWallet,\n type TransferParams as EVMTransferParams,\n evmValidateAddress,\n} from \"@swapkit/toolbox-evm\";\n\nimport {\n type TransferParams as CosmosTransferParams,\n cosmosValidateAddress,\n} from \"@swapkit/toolbox-cosmos\";\nimport { substrateValidateAddress } from \"@swapkit/toolbox-substrate\";\nimport { type UTXOTransferParams, utxoValidateAddress } from \"@swapkit/toolbox-utxo\";\nimport {\n getExplorerAddressUrl as getAddressUrl,\n getExplorerTxUrl as getTxUrl,\n} from \"./helpers/explorerUrls.ts\";\nimport type { Apis, SwapKitPluginInterface, SwapKitWallet, Wallet } from \"./types.ts\";\n\nexport function SwapKit<\n Plugins extends { [key in string]: SwapKitPluginInterface<{ [key in string]: Todo }> },\n Wallets extends { [key in string]: SwapKitWallet<NotWorth[]> },\n>({\n apis = {},\n config = {},\n plugins,\n rpcUrls = {},\n stagenet = false,\n wallets,\n}: {\n apis?: Apis;\n config?: ConnectConfig;\n plugins: Plugins;\n rpcUrls?: { [key in Chain]?: string };\n stagenet?: boolean;\n wallets: Wallets;\n}) {\n type PluginName = keyof Plugins;\n\n /**\n * @REMOVE (V1)\n * Compatibility layer for plugins and wallets for easier migration and backwards compatibility\n */\n const compatPlugins: Plugins = Array.isArray(plugins)\n ? plugins.reduce((acc, pluginInterface) => {\n // @ts-ignore Ignore until we remove the compatibility layer\n const { name, plugin } = Object.values(pluginInterface)?.[0] || {};\n acc[name] = plugin;\n return acc;\n }, {})\n : plugins;\n const compatWallets: Wallets = Array.isArray(wallets)\n ? wallets.reduce((acc, wallet) => {\n // @ts-ignore Ignore until we remove the compatibility layer\n const [walletName, connectWallet] = Object.entries(wallet)?.[0] || {};\n acc[walletName] = connectWallet;\n return acc;\n }, {})\n : wallets;\n\n const connectedWallets = {} as Wallet;\n const availablePlugins = Object.entries(compatPlugins).reduce(\n (acc, [pluginName, { plugin, config: pluginConfig }]) => {\n const methods = plugin({\n wallets: connectedWallets,\n stagenet,\n config: pluginConfig ?? config,\n });\n\n // @ts-expect-error\n acc[pluginName] = methods;\n return acc;\n },\n {} as { [key in PluginName]: ReturnType<Plugins[key][\"plugin\"]> },\n );\n\n const connectWalletMethods = Object.entries(compatWallets).reduce(\n (acc, [walletName, wallet]) => {\n const connectWallet = wallet({ addChain, config, apis, rpcUrls });\n\n // @ts-expect-error\n acc[walletName] = connectWallet;\n return acc;\n },\n {} as { [key in keyof Wallets]: ReturnType<Wallets[key]> },\n );\n\n /**\n * @Private\n */\n function getSwapKitPlugin<T extends PluginName>(pluginName: T) {\n const plugin = availablePlugins[pluginName] || Object.values(availablePlugins)[0];\n\n if (!plugin) {\n throw new SwapKitError(\"core_plugin_not_found\", \"Could not find the requested plugin\");\n }\n\n return plugin;\n }\n\n /**\n * @Private\n */\n function getSwapKitPluginForSKProvider(pluginName: PluginNameEnum): Plugins[keyof Plugins] {\n const plugin = Object.values(availablePlugins).find((plugin) =>\n plugin.supportedSwapkitProviders?.includes(pluginName),\n );\n\n if (!plugin) {\n throw new SwapKitError(\"core_plugin_not_found\", \"Could not find the requested plugin\");\n }\n\n return plugin;\n }\n\n function addChain<T extends Chain>(connectWallet: AddChainWalletParams<T>) {\n // @ts-expect-error: TODO\n connectedWallets[connectWallet.chain] = connectWallet;\n }\n\n // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: <explanation>\n function approve<T extends ApproveMode>({\n assetValue,\n type = \"checkOnly\" as T,\n contractAddress: spenderAddress,\n }: {\n type: T;\n assetValue: AssetValue;\n contractAddress: string | PluginName;\n }) {\n const plugin = availablePlugins[spenderAddress];\n\n if (plugin) {\n if (type === ApproveMode.CheckOnly && \"isAssetValueApproved\" in plugin) {\n return plugin.isAssetValueApproved({ assetValue }) as ApproveReturnType<T>;\n }\n if (type === ApproveMode.Approve && \"approveAssetValue\" in plugin) {\n return plugin.approveAssetValue({ assetValue }) as ApproveReturnType<T>;\n }\n\n throw new SwapKitError(\n \"core_approve_asset_target_invalid\",\n `Target ${String(spenderAddress)} cannot be used for approve operation`,\n );\n }\n\n const { address, chain, isGasAsset, isSynthetic } = assetValue;\n const isEVMChain = EVMChains.includes(chain as EVMChain);\n const isNativeEVM = isEVMChain && isGasAsset;\n\n if (isNativeEVM || !isEVMChain || isSynthetic) {\n return Promise.resolve(type === \"checkOnly\" ? true : \"approved\") as ApproveReturnType<T>;\n }\n\n const walletMethods = connectedWallets[chain] as BaseEVMWallet;\n const walletAction = type === \"checkOnly\" ? walletMethods?.isApproved : walletMethods?.approve;\n if (!walletAction) throw new SwapKitError(\"core_wallet_connection_not_found\");\n\n const from = getAddress(chain);\n if (!(address && from && typeof spenderAddress === \"string\")) {\n throw new SwapKitError(\"core_approve_asset_address_or_from_not_found\");\n }\n\n return walletAction({\n amount: assetValue.getBaseValue(\"bigint\"),\n assetAddress: address,\n from,\n spenderAddress,\n }) as ApproveReturnType<T>;\n }\n\n /**\n * @Public\n */\n function getWallet<T extends Chain>(chain: T) {\n return connectedWallets[chain];\n }\n function getAllWallets() {\n return { ...connectedWallets };\n }\n function getAddress<T extends Chain>(chain: T) {\n return getWallet(chain)?.address || \"\";\n }\n\n function validateAddress({ address, chain }: { address: string; chain: Chain }) {\n switch (chain) {\n case Chain.Arbitrum:\n case Chain.Avalanche:\n case Chain.Optimism:\n case Chain.BinanceSmartChain:\n case Chain.Polygon:\n case Chain.Ethereum: {\n return evmValidateAddress({ address });\n }\n case Chain.Polkadot: {\n return substrateValidateAddress({ address, chain });\n }\n case Chain.Litecoin:\n case Chain.Dash:\n case Chain.Dogecoin:\n case Chain.BitcoinCash:\n case Chain.Bitcoin: {\n return utxoValidateAddress({ address, chain });\n }\n case Chain.Cosmos:\n case Chain.Kujira:\n case Chain.Maya:\n case Chain.THORChain: {\n return cosmosValidateAddress({ address, chain });\n }\n }\n return false;\n }\n\n function getBalance<T extends Chain>(chain: T, refresh?: boolean) {\n if (refresh) {\n return getWalletWithBalance(chain).then((wallet) => wallet.balance);\n }\n\n return getWallet(chain)?.balance || [];\n }\n\n async function getWalletWithBalance<T extends Chain>(chain: T, potentialScamFilter = true) {\n const defaultBalance = [AssetValue.fromChainOrSignature(chain)];\n const wallet = getWallet(chain);\n\n if (!wallet) {\n throw new SwapKitError(\"core_wallet_connection_not_found\");\n }\n\n if (\"getBalance\" in wallet) {\n // @ts-expect-error TODO add getBalance to radix\n const balance = await wallet.getBalance(wallet.address, potentialScamFilter);\n wallet.balance = balance?.length ? balance : defaultBalance;\n }\n\n return wallet;\n }\n\n function approveAssetValue(assetValue: AssetValue, contractAddress: string | PluginName) {\n return approve({ assetValue, contractAddress, type: ApproveMode.Approve });\n }\n\n function isAssetValueApproved(assetValue: AssetValue, contractAddress: string | PluginName) {\n return approve({ assetValue, contractAddress, type: ApproveMode.CheckOnly });\n }\n\n function swap<T extends PluginName>({ route, pluginName, ...rest }: SwapParams<T>) {\n const plugin =\n (pluginName && getSwapKitPlugin(pluginName)) ||\n getSwapKitPluginForSKProvider(route.providers[0] as PluginNameEnum);\n if (!plugin) throw new SwapKitError(\"core_swap_route_not_complete\");\n\n if (\"swap\" in plugin) {\n return plugin.swap({ ...rest, route });\n }\n\n throw new SwapKitError(\"core_plugin_swap_not_found\");\n }\n\n function transfer({\n from,\n recipient,\n assetValue,\n feeOptionKey,\n }: UTXOTransferParams | EVMTransferParams | CosmosTransferParams) {\n const chain = assetValue.chain as WalletChain;\n const wallet = connectedWallets[chain];\n if (!wallet) throw new SwapKitError(\"core_wallet_connection_not_found\");\n return wallet.transfer({ from, recipient, assetValue, feeOptionKey });\n }\n\n function disconnectAll() {\n for (const chain of Object.keys(connectedWallets)) {\n // @ts-expect-error: TODO\n const wallet = connectedWallets[chain];\n if (\"disconnect\" in wallet) {\n wallet.disconnect();\n }\n // @ts-expect-error: TODO\n delete connectedWallets[chain];\n }\n }\n\n function disconnectChain(chain: Chain) {\n const wallet = connectedWallets[chain];\n const disconnect = wallet?.disconnect;\n if (disconnect) {\n disconnect();\n }\n delete connectedWallets[chain];\n }\n\n return {\n ...availablePlugins,\n ...connectWalletMethods,\n\n approveAssetValue,\n getAddress,\n getBalance,\n getExplorerAddressUrl: getAddressUrl,\n getExplorerTxUrl: getTxUrl,\n getWallet,\n getAllWallets,\n getWalletWithBalance,\n isAssetValueApproved,\n swap,\n transfer,\n validateAddress,\n disconnectAll,\n disconnectChain,\n };\n}\n",
7
7
  "import { Chain, ChainToExplorerUrl } from \"@swapkit/helpers\";\n\nexport function getExplorerTxUrl({ chain, txHash }: { txHash: string; chain: Chain }) {\n const baseUrl = ChainToExplorerUrl[chain];\n\n switch (chain) {\n case Chain.Binance:\n case Chain.Maya:\n case Chain.Kujira:\n case Chain.Cosmos:\n case Chain.THORChain:\n return `${baseUrl}/tx/${txHash.startsWith(\"0x\") ? txHash.slice(2) : txHash}`;\n\n case Chain.Arbitrum:\n case Chain.Avalanche:\n case Chain.BinanceSmartChain:\n case Chain.Ethereum:\n case Chain.Optimism:\n case Chain.Polkadot:\n case Chain.Polygon:\n return `${baseUrl}/tx/${txHash.startsWith(\"0x\") ? txHash : `0x${txHash}`}`;\n\n case Chain.Litecoin:\n case Chain.Bitcoin:\n case Chain.BitcoinCash:\n case Chain.Dogecoin:\n return `${baseUrl}/transaction/${txHash.toLowerCase()}`;\n\n default:\n throw new Error(`Unsupported chain: ${chain}`);\n }\n}\n\nexport function getExplorerAddressUrl({ chain, address }: { address: string; chain: Chain }) {\n const baseUrl = ChainToExplorerUrl[chain];\n\n return `${baseUrl}/address/${address}`;\n}\n"
8
8
  ],
9
- "mappings": ";AAAA;AACA;;;ACDA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAEO,SAAS,gBAAgB,GAAG,OAAO,UAA4C;AACpF,QAAM,UAAU,mBAAmB;AAEnC,UAAQ;AAAA,SACD,MAAM;AAAA,SACN,MAAM;AAAA,SACN,MAAM;AAAA,SACN,MAAM;AAAA,SACN,MAAM;AACT,aAAO,GAAG,cAAc,OAAO,WAAW,IAAI,IAAI,OAAO,MAAM,CAAC,IAAI;AAAA,SAEjE,MAAM;AAAA,SACN,MAAM;AAAA,SACN,MAAM;AAAA,SACN,MAAM;AAAA,SACN,MAAM;AAAA,SACN,MAAM;AAAA,SACN,MAAM;AACT,aAAO,GAAG,cAAc,OAAO,WAAW,IAAI,IAAI,SAAS,KAAK;AAAA,SAE7D,MAAM;AAAA,SACN,MAAM;AAAA,SACN,MAAM;AAAA,SACN,MAAM;AACT,aAAO,GAAG,uBAAuB,OAAO,YAAY;AAAA;AAGpD,YAAM,IAAI,MAAM,sBAAsB,OAAO;AAAA;AAAA;AAI5C,SAAS,qBAAqB,GAAG,OAAO,WAA8C;AAC3F,QAAM,UAAU,mBAAmB;AAEnC,SAAO,GAAG,mBAAmB;AAAA;;;ADfxB,SAAS,OAGf;AAAA,EACC,OAAO,CAAC;AAAA,EACR,SAAS,CAAC;AAAA,EACV;AAAA,EACA,UAAU,CAAC;AAAA,EACX,WAAW;AAAA,EACX;AAAA,GAQC;AAOD,QAAM,gBAAyB,MAAM,QAAQ,OAAO,IAChD,QAAQ,OAAO,CAAC,KAAK,o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IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA;",
10
+ "debugId": "F6D931ECC10E5F9864756e2164756e21",
11
11
  "names": []
12
12
  }
package/package.json CHANGED
@@ -1,26 +1,26 @@
1
1
  {
2
2
  "author": "swapkit-oss",
3
3
  "dependencies": {
4
- "@swapkit/api": "1.0.0-rc.78",
5
- "@swapkit/helpers": "1.0.0-rc.110"
4
+ "@swapkit/api": "1.0.0-rc.79",
5
+ "@swapkit/helpers": "1.0.0-rc.111"
6
6
  },
7
7
  "description": "SwapKit - Core",
8
8
  "devDependencies": {
9
9
  "@swapkit/tokens": "1.0.0-rc.53",
10
- "@swapkit/toolbox-cosmos": "1.0.0-rc.136",
11
- "@swapkit/toolbox-evm": "1.0.0-rc.116",
12
- "@swapkit/toolbox-substrate": "1.0.0-rc.45",
13
- "@swapkit/toolbox-utxo": "1.0.0-rc.119",
10
+ "@swapkit/toolbox-cosmos": "1.0.0-rc.137",
11
+ "@swapkit/toolbox-evm": "1.0.0-rc.118",
12
+ "@swapkit/toolbox-substrate": "1.0.0-rc.46",
13
+ "@swapkit/toolbox-utxo": "1.0.0-rc.120",
14
14
  "bun-types": "1.1.8"
15
15
  },
16
16
  "peerDependencies": {
17
- "@swapkit/api": "1.0.0-rc.78",
18
- "@swapkit/helpers": "1.0.0-rc.110",
17
+ "@swapkit/api": "1.0.0-rc.79",
18
+ "@swapkit/helpers": "1.0.0-rc.111",
19
19
  "@swapkit/tokens": "1.0.0-rc.53",
20
- "@swapkit/toolbox-cosmos": "1.0.0-rc.136",
21
- "@swapkit/toolbox-evm": "1.0.0-rc.116",
22
- "@swapkit/toolbox-substrate": "1.0.0-rc.45",
23
- "@swapkit/toolbox-utxo": "1.0.0-rc.119"
20
+ "@swapkit/toolbox-cosmos": "1.0.0-rc.137",
21
+ "@swapkit/toolbox-evm": "1.0.0-rc.118",
22
+ "@swapkit/toolbox-substrate": "1.0.0-rc.46",
23
+ "@swapkit/toolbox-utxo": "1.0.0-rc.120"
24
24
  },
25
25
  "files": [
26
26
  "src/",
@@ -45,5 +45,5 @@
45
45
  },
46
46
  "type": "module",
47
47
  "types": "./src/index.ts",
48
- "version": "1.0.0-rc.161"
48
+ "version": "1.0.0-rc.163"
49
49
  }
package/src/client.ts CHANGED
@@ -3,16 +3,27 @@ import {
3
3
  ApproveMode,
4
4
  type ApproveReturnType,
5
5
  AssetValue,
6
- type Chain,
6
+ Chain,
7
7
  type ConnectConfig,
8
8
  type EVMChain,
9
9
  EVMChains,
10
10
  type ProviderName as PluginNameEnum,
11
11
  SwapKitError,
12
12
  type SwapParams,
13
+ type WalletChain,
13
14
  } from "@swapkit/helpers";
14
- import type { BaseEVMWallet } from "@swapkit/toolbox-evm";
15
+ import {
16
+ type BaseEVMWallet,
17
+ type TransferParams as EVMTransferParams,
18
+ evmValidateAddress,
19
+ } from "@swapkit/toolbox-evm";
15
20
 
21
+ import {
22
+ type TransferParams as CosmosTransferParams,
23
+ cosmosValidateAddress,
24
+ } from "@swapkit/toolbox-cosmos";
25
+ import { substrateValidateAddress } from "@swapkit/toolbox-substrate";
26
+ import { type UTXOTransferParams, utxoValidateAddress } from "@swapkit/toolbox-utxo";
16
27
  import {
17
28
  getExplorerAddressUrl as getAddressUrl,
18
29
  getExplorerTxUrl as getTxUrl,
@@ -183,12 +194,35 @@ export function SwapKit<
183
194
  function getAddress<T extends Chain>(chain: T) {
184
195
  return getWallet(chain)?.address || "";
185
196
  }
186
- /**
187
- * TODO: Figure out validation without connecting to wallet
188
- */
197
+
189
198
  function validateAddress({ address, chain }: { address: string; chain: Chain }) {
190
- // @ts-expect-error TODO add validate address to radix
191
- return getWallet(chain)?.validateAddress?.(address);
199
+ switch (chain) {
200
+ case Chain.Arbitrum:
201
+ case Chain.Avalanche:
202
+ case Chain.Optimism:
203
+ case Chain.BinanceSmartChain:
204
+ case Chain.Polygon:
205
+ case Chain.Ethereum: {
206
+ return evmValidateAddress({ address });
207
+ }
208
+ case Chain.Polkadot: {
209
+ return substrateValidateAddress({ address, chain });
210
+ }
211
+ case Chain.Litecoin:
212
+ case Chain.Dash:
213
+ case Chain.Dogecoin:
214
+ case Chain.BitcoinCash:
215
+ case Chain.Bitcoin: {
216
+ return utxoValidateAddress({ address, chain });
217
+ }
218
+ case Chain.Cosmos:
219
+ case Chain.Kujira:
220
+ case Chain.Maya:
221
+ case Chain.THORChain: {
222
+ return cosmosValidateAddress({ address, chain });
223
+ }
224
+ }
225
+ return false;
192
226
  }
193
227
 
194
228
  function getBalance<T extends Chain>(chain: T, refresh?: boolean) {
@@ -237,6 +271,18 @@ export function SwapKit<
237
271
  throw new SwapKitError("core_plugin_swap_not_found");
238
272
  }
239
273
 
274
+ function transfer({
275
+ from,
276
+ recipient,
277
+ assetValue,
278
+ feeOptionKey,
279
+ }: UTXOTransferParams | EVMTransferParams | CosmosTransferParams) {
280
+ const chain = assetValue.chain as WalletChain;
281
+ const wallet = connectedWallets[chain];
282
+ if (!wallet) throw new SwapKitError("core_wallet_connection_not_found");
283
+ return wallet.transfer({ from, recipient, assetValue, feeOptionKey });
284
+ }
285
+
240
286
  function disconnectAll() {
241
287
  for (const chain of Object.keys(connectedWallets)) {
242
288
  // @ts-expect-error: TODO
@@ -272,6 +318,7 @@ export function SwapKit<
272
318
  getWalletWithBalance,
273
319
  isAssetValueApproved,
274
320
  swap,
321
+ transfer,
275
322
  validateAddress,
276
323
  disconnectAll,
277
324
  disconnectChain,