@tcswap/plugins 4.2.15
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/chainflip/index.cjs +4 -0
- package/dist/chainflip/index.cjs.map +11 -0
- package/dist/chainflip/index.js +4 -0
- package/dist/chainflip/index.js.map +11 -0
- package/dist/chunk-vzvcxw96.js +5 -0
- package/dist/chunk-vzvcxw96.js.map +10 -0
- package/dist/chunk-zweecvg1.js +4 -0
- package/dist/chunk-zweecvg1.js.map +10 -0
- package/dist/evm/index.cjs +4 -0
- package/dist/evm/index.cjs.map +10 -0
- package/dist/evm/index.js +4 -0
- package/dist/evm/index.js.map +10 -0
- package/dist/garden/index.cjs +4 -0
- package/dist/garden/index.cjs.map +10 -0
- package/dist/garden/index.js +4 -0
- package/dist/garden/index.js.map +10 -0
- package/dist/index.cjs +4 -0
- package/dist/index.cjs.map +10 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +10 -0
- package/dist/near/index.cjs +4 -0
- package/dist/near/index.cjs.map +11 -0
- package/dist/near/index.js +4 -0
- package/dist/near/index.js.map +11 -0
- package/dist/radix/index.cjs +4 -0
- package/dist/radix/index.cjs.map +10 -0
- package/dist/radix/index.js +4 -0
- package/dist/radix/index.js.map +10 -0
- package/dist/solana/index.cjs +4 -0
- package/dist/solana/index.cjs.map +10 -0
- package/dist/solana/index.js +4 -0
- package/dist/solana/index.js.map +10 -0
- package/dist/thorchain/index.cjs +4 -0
- package/dist/thorchain/index.cjs.map +11 -0
- package/dist/thorchain/index.js +4 -0
- package/dist/thorchain/index.js.map +11 -0
- package/dist/types/chainflip/broker.d.ts +23 -0
- package/dist/types/chainflip/broker.d.ts.map +1 -0
- package/dist/types/chainflip/index.d.ts +4 -0
- package/dist/types/chainflip/index.d.ts.map +1 -0
- package/dist/types/chainflip/plugin.d.ts +13 -0
- package/dist/types/chainflip/plugin.d.ts.map +1 -0
- package/dist/types/chainflip/types.d.ts +41 -0
- package/dist/types/chainflip/types.d.ts.map +1 -0
- package/dist/types/evm/index.d.ts +21 -0
- package/dist/types/evm/index.d.ts.map +1 -0
- package/dist/types/garden/index.d.ts +2 -0
- package/dist/types/garden/index.d.ts.map +1 -0
- package/dist/types/garden/plugin.d.ts +21 -0
- package/dist/types/garden/plugin.d.ts.map +1 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/near/index.d.ts +3 -0
- package/dist/types/near/index.d.ts.map +1 -0
- package/dist/types/near/nearNames.d.ts +3 -0
- package/dist/types/near/nearNames.d.ts.map +1 -0
- package/dist/types/near/plugin.d.ts +22 -0
- package/dist/types/near/plugin.d.ts.map +1 -0
- package/dist/types/near/types.d.ts +12 -0
- package/dist/types/near/types.d.ts.map +1 -0
- package/dist/types/radix/index.d.ts +13 -0
- package/dist/types/radix/index.d.ts.map +1 -0
- package/dist/types/solana/index.d.ts +2 -0
- package/dist/types/solana/index.d.ts.map +1 -0
- package/dist/types/solana/plugin.d.ts +13 -0
- package/dist/types/solana/plugin.d.ts.map +1 -0
- package/dist/types/thorchain/index.d.ts +4 -0
- package/dist/types/thorchain/index.d.ts.map +1 -0
- package/dist/types/thorchain/plugin.d.ts +110 -0
- package/dist/types/thorchain/plugin.d.ts.map +1 -0
- package/dist/types/thorchain/shared.d.ts +21 -0
- package/dist/types/thorchain/shared.d.ts.map +1 -0
- package/dist/types/thorchain/types.d.ts +64 -0
- package/dist/types/thorchain/types.d.ts.map +1 -0
- package/dist/types/types.d.ts +19 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/utils.d.ts +20 -0
- package/dist/types/utils.d.ts.map +1 -0
- package/package.json +88 -0
- package/src/chainflip/broker.ts +116 -0
- package/src/chainflip/index.ts +3 -0
- package/src/chainflip/plugin.ts +56 -0
- package/src/chainflip/types.ts +37 -0
- package/src/evm/index.ts +49 -0
- package/src/garden/index.ts +1 -0
- package/src/garden/plugin.ts +50 -0
- package/src/index.ts +41 -0
- package/src/near/index.ts +2 -0
- package/src/near/nearNames.ts +37 -0
- package/src/near/plugin.ts +214 -0
- package/src/near/types.ts +9 -0
- package/src/radix/index.ts +28 -0
- package/src/solana/index.ts +1 -0
- package/src/solana/plugin.ts +30 -0
- package/src/thorchain/index.ts +3 -0
- package/src/thorchain/plugin.ts +491 -0
- package/src/thorchain/shared.ts +17 -0
- package/src/thorchain/types.ts +59 -0
- package/src/types.ts +26 -0
- package/src/utils.ts +46 -0
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var F={};P(F,{assetIdentifierToChainflipTicker:()=>S,ChainflipPlugin:()=>_,ChainflipBroker:()=>T});module.exports=D(F);var A=require("@polkadot/keyring"),f=require("@polkadot/util"),s=require("@tcswap/helpers"),S=new Map([["ARB.ETH","ArbEth"],["ARB.USDC-0XAF88D065E77C8CC2239327C5EDB3A432268E5831","ArbUsdc"],["BTC.BTC","Btc"],["DOT.DOT","Dot"],["ETH.ETH","Eth"],["ETH.FLIP-0X826180541412D574CF1336D22C0C0A287822678A","Flip"],["ETH.USDC-0XA0B86991C6218B36C1D19D4A2E9EB0CE3606EB48","Usdc"],["ETH.USDT-0XDAC17F958D2EE523A2206206994597C13D831EC7","Usdt"],["SOL.SOL","Sol"],["SOL.USDC-EPJFWDD5AUFQSSQEM2QN1XZYBAPC8G4WEGGKZWYTDT1V","SolUsdc"]]),b=(e)=>()=>{let r=e.api.tx.swapping?.registerAsBroker?.();if(!r)throw new s.USwapError("chainflip_broker_register");return e.signAndBroadcast({address:e.getAddress(),tx:r})},B=(e)=>({feeAsset:r,recipient:t})=>{let a=r.chain===s.Chain.Polkadot,n=s.wrapWithThrow(()=>{return a?e.encodeAddress(e.decodeAddress(t),"hex"):t},"chainflip_broker_recipient_error");return new Promise((d)=>{let o=e.api.tx?.swapping?.withdraw?.(r.ticker.toLowerCase(),{[r.chain.toLowerCase()]:n});if(!o)throw new s.USwapError("chainflip_broker_withdraw");e.signAndBroadcast({callback:(l)=>{if(!l.status?.isFinalized)return;let c=l.events.find((x)=>x.event.method==="WithdrawalRequested");if(!c)throw new s.USwapError("chainflip_channel_error","Could not find 'WithdrawalRequested' event");let{event:{data:{egressId:p,egressAsset:u,egressAmount:m,egressFee:g,destinationAddress:C}}}=c.toHuman();d({destinationAddress:C,egressAmount:m,egressAsset:u,egressFee:g,egressId:p})},tx:o})})},E=(e)=>async({evmToolbox:r,stateChainAccount:t,assetValue:a})=>{let{chainflipGateway:n}=await import("@tcswap/helpers/contracts"),d=s.AssetValue.from({asset:"ETH.FLIP"});if(!a.eqAsset(d))throw new s.USwapError("chainflip_broker_fund_only_flip_supported");if(!e.validateAddress(t))throw new s.USwapError("chainflip_broker_fund_invalid_address");let o=f.isHex(t)?t:f.u8aToHex(A.decodeAddress(t));return r.call({abi:n,contractAddress:"0x6995ab7c4d7f4b03f467cf4c8e920427d9621dbd",funcName:"fundStateChainAccount",funcParams:[o,a.getBaseValue("string")]})},T=(e)=>({fundStateChainAccount:E(e),registerAsBroker:b(e),withdrawFee:B(e)});var i=require("@tcswap/helpers"),h=require("@tcswap/helpers/api");var _=w({methods:({getWallet:e})=>({swap:async function(t){if(!(t?.route?.buyAsset&&t.route.meta?.chainflip))throw new i.USwapError("core_swap_invalid_params",{...t});let{route:{buyAsset:a,sellAsset:n,sellAmount:d,meta:{chainflip:o}},maxBoostFeeBps:l=0}=t;if(!(n&&a))throw new i.USwapError("core_swap_asset_not_recognized");let c=await i.AssetValue.from({asset:n,asyncTokenLookup:!0,value:d}),p=e(c.chain);if(!p||!("transfer"in p))throw new i.USwapError("core_wallet_connection_not_found");let{depositAddress:u}=await h.USwapApi.getChainflipDepositChannel({...o,maxBoostFeeBps:l||o.maxBoostFeeBps});return await p.transfer({assetValue:c,isProgramDerivedAddress:!0,recipient:u,sender:p.address})}}),name:"chainflip",properties:{supportedUSwapProviders:[i.ProviderName.CHAINFLIP,i.ProviderName.CHAINFLIP_STREAMING]}});
|
|
2
|
+
|
|
3
|
+
//# debugId=3F8C87AD726A78DA64756E2164756E21
|
|
4
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/chainflip/broker.ts", "../src/chainflip/plugin.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/**\n * Modifications © 2025 Horizontal Systems.\n */\n\nimport { decodeAddress } from \"@polkadot/keyring\";\nimport { isHex, u8aToHex } from \"@polkadot/util\";\nimport { AssetValue, Chain, USwapError, wrapWithThrow } from \"@tcswap/helpers\";\nimport type { getEvmToolbox } from \"@tcswap/toolboxes/evm\";\nimport type { getSubstrateToolbox } from \"@tcswap/toolboxes/substrate\";\n\nimport type { WithdrawFeeResponse } from \"./types\";\n\ntype ChainflipToolbox = Awaited<ReturnType<typeof getSubstrateToolbox<typeof Chain.Chainflip>>>;\n\nexport const assetIdentifierToChainflipTicker = new Map<string, string>([\n [\"ARB.ETH\", \"ArbEth\"],\n [\"ARB.USDC-0XAF88D065E77C8CC2239327C5EDB3A432268E5831\", \"ArbUsdc\"],\n [\"BTC.BTC\", \"Btc\"],\n [\"DOT.DOT\", \"Dot\"],\n [\"ETH.ETH\", \"Eth\"],\n [\"ETH.FLIP-0X826180541412D574CF1336D22C0C0A287822678A\", \"Flip\"],\n [\"ETH.USDC-0XA0B86991C6218B36C1D19D4A2E9EB0CE3606EB48\", \"Usdc\"],\n [\"ETH.USDT-0XDAC17F958D2EE523A2206206994597C13D831EC7\", \"Usdt\"],\n [\"SOL.SOL\", \"Sol\"],\n [\"SOL.USDC-EPJFWDD5AUFQSSQEM2QN1XZYBAPC8G4WEGGKZWYTDT1V\", \"SolUsdc\"],\n]);\n\nconst registerAsBroker = (toolbox: ChainflipToolbox) => () => {\n const extrinsic = toolbox.api.tx.swapping?.registerAsBroker?.();\n\n if (!extrinsic) {\n throw new USwapError(\"chainflip_broker_register\");\n }\n\n return toolbox.signAndBroadcast({ address: toolbox.getAddress(), tx: extrinsic });\n};\n\nconst withdrawFee =\n (toolbox: ChainflipToolbox) =>\n ({ feeAsset, recipient }: { feeAsset: AssetValue; recipient: string }) => {\n const isFeeChainPolkadot = feeAsset.chain === Chain.Polkadot;\n\n const recipientAddress = wrapWithThrow(() => {\n return isFeeChainPolkadot ? toolbox.encodeAddress(toolbox.decodeAddress(recipient), \"hex\") : recipient;\n }, \"chainflip_broker_recipient_error\");\n\n return new Promise<WithdrawFeeResponse>((resolve) => {\n const extrinsic = toolbox.api.tx?.swapping?.withdraw?.(feeAsset.ticker.toLowerCase(), {\n [feeAsset.chain.toLowerCase()]: recipientAddress,\n });\n\n if (!extrinsic) {\n throw new USwapError(\"chainflip_broker_withdraw\");\n }\n\n toolbox.signAndBroadcast({\n callback: (result) => {\n if (!result.status?.isFinalized) {\n return;\n }\n\n const withdrawEvent = result.events.find((event) => event.event.method === \"WithdrawalRequested\");\n\n if (!withdrawEvent) {\n throw new USwapError(\"chainflip_channel_error\", \"Could not find 'WithdrawalRequested' event\");\n }\n const {\n event: {\n data: { egressId, egressAsset, egressAmount, egressFee, destinationAddress },\n },\n } = withdrawEvent.toHuman() as any;\n resolve({ destinationAddress, egressAmount, egressAsset, egressFee, egressId });\n },\n tx: extrinsic,\n });\n });\n };\n\nconst fundStateChainAccount =\n (chainflipToolbox: ChainflipToolbox) =>\n async ({\n evmToolbox,\n stateChainAccount,\n assetValue,\n }: {\n evmToolbox: Awaited<ReturnType<typeof getEvmToolbox>>;\n stateChainAccount: string;\n assetValue: AssetValue;\n }) => {\n const { chainflipGateway } = await import(\"@tcswap/helpers/contracts\");\n\n const flipAssetValue = AssetValue.from({ asset: \"ETH.FLIP\" });\n\n if (!assetValue.eqAsset(flipAssetValue)) {\n throw new USwapError(\"chainflip_broker_fund_only_flip_supported\");\n }\n\n if (!chainflipToolbox.validateAddress(stateChainAccount)) {\n throw new USwapError(\"chainflip_broker_fund_invalid_address\");\n }\n\n const hexAddress = isHex(stateChainAccount) ? stateChainAccount : u8aToHex(decodeAddress(stateChainAccount));\n\n return evmToolbox.call<string>({\n abi: chainflipGateway,\n contractAddress: \"0x6995ab7c4d7f4b03f467cf4c8e920427d9621dbd\",\n funcName: \"fundStateChainAccount\",\n funcParams: [hexAddress, assetValue.getBaseValue(\"string\")],\n });\n };\n\nexport const ChainflipBroker = (chainflipToolbox: ChainflipToolbox) => ({\n fundStateChainAccount: fundStateChainAccount(chainflipToolbox),\n registerAsBroker: registerAsBroker(chainflipToolbox),\n withdrawFee: withdrawFee(chainflipToolbox),\n});\n",
|
|
6
|
+
"/**\n * Modifications © 2025 Horizontal Systems.\n */\n\nimport { AssetValue, type Chain, ProviderName, USwapError } from \"@tcswap/helpers\";\nimport { USwapApi } from \"@tcswap/helpers/api\";\nimport { createPlugin } from \"../utils\";\nimport type { RequestSwapDepositAddressParams } from \"./types\";\n\nexport const ChainflipPlugin = createPlugin({\n methods: ({ getWallet }) => ({\n swap: async function chainflipSwap(swapParams: RequestSwapDepositAddressParams) {\n if (!(swapParams?.route?.buyAsset && swapParams.route.meta?.chainflip)) {\n throw new USwapError(\"core_swap_invalid_params\", { ...swapParams });\n }\n\n const {\n route: {\n buyAsset: buyAssetString,\n sellAsset: sellAssetString,\n sellAmount,\n meta: { chainflip },\n },\n maxBoostFeeBps = 0,\n } = swapParams;\n\n if (!(sellAssetString && buyAssetString)) {\n throw new USwapError(\"core_swap_asset_not_recognized\");\n }\n\n const sellAsset = await AssetValue.from({ asset: sellAssetString, asyncTokenLookup: true, value: sellAmount });\n\n const wallet = getWallet(sellAsset.chain as Exclude<Chain, Chain.Radix>);\n\n if (!wallet || !(\"transfer\" in wallet)) {\n throw new USwapError(\"core_wallet_connection_not_found\");\n }\n\n const { depositAddress } = await USwapApi.getChainflipDepositChannel({\n ...chainflip,\n maxBoostFeeBps: maxBoostFeeBps || chainflip.maxBoostFeeBps,\n });\n\n const tx = await wallet.transfer({\n assetValue: sellAsset,\n isProgramDerivedAddress: true,\n recipient: depositAddress,\n sender: wallet.address,\n });\n\n return tx;\n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,EAEvG,EAAS,EAAU,EAAU,KAAoC,EAEvE,GAAI,CAAC,GAAU,EAAE,aAAc,GAC7B,MAAM,IAAI,aAAW,kCAAkC,EAGzD,IAAQ,kBAAmB,MAAM,WAAS,2BAA2B,IAChE,EACH,eAAgB,GAAkB,EAAU,cAC9C,CAAC,EASD,OAPW,MAAM,EAAO,SAAS,CAC/B,WAAY,EACZ,wBAAyB,GACzB,UAAW,EACX,OAAQ,EAAO,OACjB,CAAC,EAIL,GACA,KAAM,YACN,WAAY,CAAE,wBAAyB,CAAC,eAAa,UAAW,eAAa,mBAAmB,CAAW,CAC7G,CAAC",
|
|
9
|
+
"debugId": "3F8C87AD726A78DA64756E2164756E21",
|
|
10
|
+
"names": []
|
|
11
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{a as C,b as x,c as A}from"../chunk-vzvcxw96.js";import{decodeAddress as y}from"@polkadot/keyring";import{isHex as S,u8aToHex as b}from"@polkadot/util";import{AssetValue as B,Chain as E,USwapError as d,wrapWithThrow as T}from"@tcswap/helpers";var U=new Map([["ARB.ETH","ArbEth"],["ARB.USDC-0XAF88D065E77C8CC2239327C5EDB3A432268E5831","ArbUsdc"],["BTC.BTC","Btc"],["DOT.DOT","Dot"],["ETH.ETH","Eth"],["ETH.FLIP-0X826180541412D574CF1336D22C0C0A287822678A","Flip"],["ETH.USDC-0XA0B86991C6218B36C1D19D4A2E9EB0CE3606EB48","Usdc"],["ETH.USDT-0XDAC17F958D2EE523A2206206994597C13D831EC7","Usdt"],["SOL.SOL","Sol"],["SOL.USDC-EPJFWDD5AUFQSSQEM2QN1XZYBAPC8G4WEGGKZWYTDT1V","SolUsdc"]]),_=(e)=>()=>{let s=e.api.tx.swapping?.registerAsBroker?.();if(!s)throw new d("chainflip_broker_register");return e.signAndBroadcast({address:e.getAddress(),tx:s})},D=(e)=>({feeAsset:s,recipient:t})=>{let i=s.chain===E.Polkadot,o=T(()=>{return i?e.encodeAddress(e.decodeAddress(t),"hex"):t},"chainflip_broker_recipient_error");return new Promise((n)=>{let r=e.api.tx?.swapping?.withdraw?.(s.ticker.toLowerCase(),{[s.chain.toLowerCase()]:o});if(!r)throw new d("chainflip_broker_withdraw");e.signAndBroadcast({callback:(c)=>{if(!c.status?.isFinalized)return;let p=c.events.find((g)=>g.event.method==="WithdrawalRequested");if(!p)throw new d("chainflip_channel_error","Could not find 'WithdrawalRequested' event");let{event:{data:{egressId:a,egressAsset:l,egressAmount:u,egressFee:w,destinationAddress:h}}}=p.toHuman();n({destinationAddress:h,egressAmount:u,egressAsset:l,egressFee:w,egressId:a})},tx:r})})},P=(e)=>async({evmToolbox:s,stateChainAccount:t,assetValue:i})=>{let{chainflipGateway:o}=await import("@tcswap/helpers/contracts"),n=B.from({asset:"ETH.FLIP"});if(!i.eqAsset(n))throw new d("chainflip_broker_fund_only_flip_supported");if(!e.validateAddress(t))throw new d("chainflip_broker_fund_invalid_address");let r=S(t)?t:b(y(t));return s.call({abi:o,contractAddress:"0x6995ab7c4d7f4b03f467cf4c8e920427d9621dbd",funcName:"fundStateChainAccount",funcParams:[r,i.getBaseValue("string")]})},I=(e)=>({fundStateChainAccount:P(e),registerAsBroker:_(e),withdrawFee:D(e)});import{AssetValue as F,ProviderName as m,USwapError as f}from"@tcswap/helpers";import{USwapApi as R}from"@tcswap/helpers/api";var M=A({methods:({getWallet:e})=>({swap:async function(t){if(!(t?.route?.buyAsset&&t.route.meta?.chainflip))throw new f("core_swap_invalid_params",{...t});let{route:{buyAsset:i,sellAsset:o,sellAmount:n,meta:{chainflip:r}},maxBoostFeeBps:c=0}=t;if(!(o&&i))throw new f("core_swap_asset_not_recognized");let p=await F.from({asset:o,asyncTokenLookup:!0,value:n}),a=e(p.chain);if(!a||!("transfer"in a))throw new f("core_wallet_connection_not_found");let{depositAddress:l}=await R.getChainflipDepositChannel({...r,maxBoostFeeBps:c||r.maxBoostFeeBps});return await a.transfer({assetValue:p,isProgramDerivedAddress:!0,recipient:l,sender:a.address})}}),name:"chainflip",properties:{supportedUSwapProviders:[m.CHAINFLIP,m.CHAINFLIP_STREAMING]}});export{U as assetIdentifierToChainflipTicker,M as ChainflipPlugin,I as ChainflipBroker};
|
|
2
|
+
|
|
3
|
+
//# debugId=CDFAAE7CFF61497E64756E2164756E21
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/chainflip/broker.ts", "../src/chainflip/plugin.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/**\n * Modifications © 2025 Horizontal Systems.\n */\n\nimport { decodeAddress } from \"@polkadot/keyring\";\nimport { isHex, u8aToHex } from \"@polkadot/util\";\nimport { AssetValue, Chain, USwapError, wrapWithThrow } from \"@tcswap/helpers\";\nimport type { getEvmToolbox } from \"@tcswap/toolboxes/evm\";\nimport type { getSubstrateToolbox } from \"@tcswap/toolboxes/substrate\";\n\nimport type { WithdrawFeeResponse } from \"./types\";\n\ntype ChainflipToolbox = Awaited<ReturnType<typeof getSubstrateToolbox<typeof Chain.Chainflip>>>;\n\nexport const assetIdentifierToChainflipTicker = new Map<string, string>([\n [\"ARB.ETH\", \"ArbEth\"],\n [\"ARB.USDC-0XAF88D065E77C8CC2239327C5EDB3A432268E5831\", \"ArbUsdc\"],\n [\"BTC.BTC\", \"Btc\"],\n [\"DOT.DOT\", \"Dot\"],\n [\"ETH.ETH\", \"Eth\"],\n [\"ETH.FLIP-0X826180541412D574CF1336D22C0C0A287822678A\", \"Flip\"],\n [\"ETH.USDC-0XA0B86991C6218B36C1D19D4A2E9EB0CE3606EB48\", \"Usdc\"],\n [\"ETH.USDT-0XDAC17F958D2EE523A2206206994597C13D831EC7\", \"Usdt\"],\n [\"SOL.SOL\", \"Sol\"],\n [\"SOL.USDC-EPJFWDD5AUFQSSQEM2QN1XZYBAPC8G4WEGGKZWYTDT1V\", \"SolUsdc\"],\n]);\n\nconst registerAsBroker = (toolbox: ChainflipToolbox) => () => {\n const extrinsic = toolbox.api.tx.swapping?.registerAsBroker?.();\n\n if (!extrinsic) {\n throw new USwapError(\"chainflip_broker_register\");\n }\n\n return toolbox.signAndBroadcast({ address: toolbox.getAddress(), tx: extrinsic });\n};\n\nconst withdrawFee =\n (toolbox: ChainflipToolbox) =>\n ({ feeAsset, recipient }: { feeAsset: AssetValue; recipient: string }) => {\n const isFeeChainPolkadot = feeAsset.chain === Chain.Polkadot;\n\n const recipientAddress = wrapWithThrow(() => {\n return isFeeChainPolkadot ? toolbox.encodeAddress(toolbox.decodeAddress(recipient), \"hex\") : recipient;\n }, \"chainflip_broker_recipient_error\");\n\n return new Promise<WithdrawFeeResponse>((resolve) => {\n const extrinsic = toolbox.api.tx?.swapping?.withdraw?.(feeAsset.ticker.toLowerCase(), {\n [feeAsset.chain.toLowerCase()]: recipientAddress,\n });\n\n if (!extrinsic) {\n throw new USwapError(\"chainflip_broker_withdraw\");\n }\n\n toolbox.signAndBroadcast({\n callback: (result) => {\n if (!result.status?.isFinalized) {\n return;\n }\n\n const withdrawEvent = result.events.find((event) => event.event.method === \"WithdrawalRequested\");\n\n if (!withdrawEvent) {\n throw new USwapError(\"chainflip_channel_error\", \"Could not find 'WithdrawalRequested' event\");\n }\n const {\n event: {\n data: { egressId, egressAsset, egressAmount, egressFee, destinationAddress },\n },\n } = withdrawEvent.toHuman() as any;\n resolve({ destinationAddress, egressAmount, egressAsset, egressFee, egressId });\n },\n tx: extrinsic,\n });\n });\n };\n\nconst fundStateChainAccount =\n (chainflipToolbox: ChainflipToolbox) =>\n async ({\n evmToolbox,\n stateChainAccount,\n assetValue,\n }: {\n evmToolbox: Awaited<ReturnType<typeof getEvmToolbox>>;\n stateChainAccount: string;\n assetValue: AssetValue;\n }) => {\n const { chainflipGateway } = await import(\"@tcswap/helpers/contracts\");\n\n const flipAssetValue = AssetValue.from({ asset: \"ETH.FLIP\" });\n\n if (!assetValue.eqAsset(flipAssetValue)) {\n throw new USwapError(\"chainflip_broker_fund_only_flip_supported\");\n }\n\n if (!chainflipToolbox.validateAddress(stateChainAccount)) {\n throw new USwapError(\"chainflip_broker_fund_invalid_address\");\n }\n\n const hexAddress = isHex(stateChainAccount) ? stateChainAccount : u8aToHex(decodeAddress(stateChainAccount));\n\n return evmToolbox.call<string>({\n abi: chainflipGateway,\n contractAddress: \"0x6995ab7c4d7f4b03f467cf4c8e920427d9621dbd\",\n funcName: \"fundStateChainAccount\",\n funcParams: [hexAddress, assetValue.getBaseValue(\"string\")],\n });\n };\n\nexport const ChainflipBroker = (chainflipToolbox: ChainflipToolbox) => ({\n fundStateChainAccount: fundStateChainAccount(chainflipToolbox),\n registerAsBroker: registerAsBroker(chainflipToolbox),\n withdrawFee: withdrawFee(chainflipToolbox),\n});\n",
|
|
6
|
+
"/**\n * Modifications © 2025 Horizontal Systems.\n */\n\nimport { AssetValue, type Chain, ProviderName, USwapError } from \"@tcswap/helpers\";\nimport { USwapApi } from \"@tcswap/helpers/api\";\nimport { createPlugin } from \"../utils\";\nimport type { RequestSwapDepositAddressParams } from \"./types\";\n\nexport const ChainflipPlugin = createPlugin({\n methods: ({ getWallet }) => ({\n swap: async function chainflipSwap(swapParams: RequestSwapDepositAddressParams) {\n if (!(swapParams?.route?.buyAsset && swapParams.route.meta?.chainflip)) {\n throw new USwapError(\"core_swap_invalid_params\", { ...swapParams });\n }\n\n const {\n route: {\n buyAsset: buyAssetString,\n sellAsset: sellAssetString,\n sellAmount,\n meta: { chainflip },\n },\n maxBoostFeeBps = 0,\n } = swapParams;\n\n if (!(sellAssetString && buyAssetString)) {\n throw new USwapError(\"core_swap_asset_not_recognized\");\n }\n\n const sellAsset = await AssetValue.from({ asset: sellAssetString, asyncTokenLookup: true, value: sellAmount });\n\n const wallet = getWallet(sellAsset.chain as Exclude<Chain, Chain.Radix>);\n\n if (!wallet || !(\"transfer\" in wallet)) {\n throw new USwapError(\"core_wallet_connection_not_found\");\n }\n\n const { depositAddress } = await USwapApi.getChainflipDepositChannel({\n ...chainflip,\n maxBoostFeeBps: maxBoostFeeBps || chainflip.maxBoostFeeBps,\n });\n\n const tx = await wallet.transfer({\n assetValue: sellAsset,\n isProgramDerivedAddress: true,\n recipient: depositAddress,\n sender: wallet.address,\n });\n\n return tx;\n },\n }),\n name: \"chainflip\",\n properties: { supportedUSwapProviders: [ProviderName.CHAINFLIP, ProviderName.CHAINFLIP_STREAMING] as const },\n});\n"
|
|
7
|
+
],
|
|
8
|
+
"mappings": "uDAIA,wBAAS,0BACT,gBAAS,cAAO,uBAChB,qBAAS,WAAY,gBAAO,mBAAY,wBAQjC,IAAM,EAAmC,IAAI,IAAoB,CACtE,CAAC,UAAW,QAAQ,EACpB,CAAC,sDAAuD,SAAS,EACjE,CAAC,UAAW,KAAK,EACjB,CAAC,UAAW,KAAK,EACjB,CAAC,UAAW,KAAK,EACjB,CAAC,sDAAuD,MAAM,EAC9D,CAAC,sDAAuD,MAAM,EAC9D,CAAC,sDAAuD,MAAM,EAC9D,CAAC,UAAW,KAAK,EACjB,CAAC,wDAAyD,SAAS,CACrE,CAAC,EAEK,EAAmB,CAAC,IAA8B,IAAM,CAC5D,IAAM,EAAY,EAAQ,IAAI,GAAG,UAAU,mBAAmB,EAE9D,GAAI,CAAC,EACH,MAAM,IAAI,EAAW,2BAA2B,EAGlD,OAAO,EAAQ,iBAAiB,CAAE,QAAS,EAAQ,WAAW,EAAG,GAAI,CAAU,CAAC,GAG5E,EACJ,CAAC,IACD,EAAG,WAAU,eAA6D,CACxE,IAAM,EAAqB,EAAS,QAAU,EAAM,SAE9C,EAAmB,EAAc,IAAM,CAC3C,OAAO,EAAqB,EAAQ,cAAc,EAAQ,cAAc,CAAS,EAAG,KAAK,EAAI,GAC5F,kCAAkC,EAErC,OAAO,IAAI,QAA6B,CAAC,IAAY,CACnD,IAAM,EAAY,EAAQ,IAAI,IAAI,UAAU,WAAW,EAAS,OAAO,YAAY,EAAG,EACnF,EAAS,MAAM,YAAY,GAAI,CAClC,CAAC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4B,IAAK,CAAW,CAAC,EAGpE,IACE,OACE,SAAU,EACV,UAAW,EACX,aACA,MAAQ,cAEV,iBAAiB,GACf,EAEJ,GAAI,EAAE,GAAmB,GACvB,MAAM,IAAI,EAAW,gCAAgC,EAGvD,IAAM,EAAY,MAAM,EAAW,KAAK,CAAE,MAAO,EAAiB,iBAAkB,GAAM,MAAO,CAAW,CAAC,EAEvG,EAAS,EAAU,EAAU,KAAoC,EAEvE,GAAI,CAAC,GAAU,EAAE,aAAc,GAC7B,MAAM,IAAI,EAAW,kCAAkC,EAGzD,IAAQ,kBAAmB,MAAM,EAAS,2BAA2B,IAChE,EACH,eAAgB,GAAkB,EAAU,cAC9C,CAAC,EASD,OAPW,MAAM,EAAO,SAAS,CAC/B,WAAY,EACZ,wBAAyB,GACzB,UAAW,EACX,OAAQ,EAAO,OACjB,CAAC,EAIL,GACA,KAAM,YACN,WAAY,CAAE,wBAAyB,CAAC,EAAa,UAAW,EAAa,mBAAmB,CAAW,CAC7G,CAAC",
|
|
9
|
+
"debugId": "CDFAAE7CFF61497E64756E2164756E21",
|
|
10
|
+
"names": []
|
|
11
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
var c=Object.create;var{getPrototypeOf:m,defineProperty:a,getOwnPropertyNames:u}=Object;var v=Object.prototype.hasOwnProperty;var P=(e,n,s)=>{s=e!=null?c(m(e)):{};let r=n||!e||!e.__esModule?a(s,"default",{value:e,enumerable:!0}):s;for(let t of u(e))if(!v.call(r,t))a(r,t,{get:()=>e[t],enumerable:!0});return r};var g=((e)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(n,s)=>(typeof require<"u"?require:n)[s]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});import{EVMChains as l,USwapError as f}from"@tcswap/helpers";function M({name:e,properties:n,methods:s}){function r(t){return{...s(t),...n}}return{[e]:r}}function T({approveMode:e,getWallet:n}){return function({assetValue:r,spenderAddress:t}){let i=r.chain,p=l.includes(i);if(p&&r.isGasAsset||!p||r.isSynthetic)return Promise.resolve(e==="checkOnly"||"approved");let o=n(i),d=e==="checkOnly"?o.isApproved:o.approve;if(!(r.address&&o.address))throw new f("core_approve_asset_address_or_from_not_found");return d({amount:r.getBaseValue("bigint"),assetAddress:r.address,from:o.address,spenderAddress:t})}}
|
|
2
|
+
export{P as a,g as b,M as c,T as d};
|
|
3
|
+
|
|
4
|
+
//# debugId=E728D6BDDD04954164756E2164756E21
|
|
5
|
+
//# sourceMappingURL=chunk-vzvcxw96.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/utils.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/**\n * Modifications © 2025 Horizontal Systems.\n */\n\nimport type { ApproveMode, ApproveReturnType, EVMChain, ProviderName } from \"@tcswap/helpers\";\nimport { type AssetValue, EVMChains, USwapError } from \"@tcswap/helpers\";\nimport type { SwapKitPluginParams } from \"./types\";\n\nexport function createPlugin<\n const Name extends string,\n T extends (params: SwapKitPluginParams) => Record<string, unknown>,\n K extends { supportedUSwapProviders?: readonly ProviderName[] },\n>({ name, properties, methods }: { name: Name; properties?: K; methods: T }) {\n function plugin(pluginParams: SwapKitPluginParams) {\n return { ...methods(pluginParams), ...properties } as K & ReturnType<T>;\n }\n\n return { [name]: plugin } as { [key in Name]: typeof plugin };\n}\n\nexport function approve<T extends ApproveMode>({ approveMode, getWallet }: { approveMode: T } & SwapKitPluginParams) {\n return function approve({ assetValue, spenderAddress }: { spenderAddress: string; assetValue: AssetValue }) {\n const evmChain = assetValue.chain as EVMChain;\n const isEVMChain = EVMChains.includes(evmChain);\n const isNativeEVM = isEVMChain && assetValue.isGasAsset;\n\n if (isNativeEVM || !isEVMChain || assetValue.isSynthetic) {\n const isApproved = approveMode === \"checkOnly\" || \"approved\";\n return Promise.resolve(isApproved) as ApproveReturnType<T>;\n }\n\n const wallet = getWallet(evmChain);\n const walletAction = approveMode === \"checkOnly\" ? wallet.isApproved : wallet.approve;\n\n if (!(assetValue.address && wallet.address)) {\n throw new USwapError(\"core_approve_asset_address_or_from_not_found\");\n }\n\n return walletAction({\n amount: assetValue.getBaseValue(\"bigint\"),\n assetAddress: assetValue.address,\n from: wallet.address,\n spenderAddress,\n });\n };\n}\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": "kjBAKA,oBAA0B,gBAAW,wBAG9B,SAAS,CAIf,EAAG,OAAM,aAAY,WAAuD,CAC3E,SAAS,CAAM,CAAC,EAAmC,CACjD,MAAO,IAAK,EAAQ,CAAY,KAAM,CAAW,EAGnD,MAAO,EAAG,GAAO,CAAO,EAGnB,SAAS,CAA8B,EAAG,cAAa,aAAuD,CACnH,OAAO,QAAgB,EAAG,aAAY,kBAAsE,CAC1G,IAAM,EAAW,EAAW,MACtB,EAAa,EAAU,SAAS,CAAQ,EAG9C,GAFoB,GAAc,EAAW,YAE1B,CAAC,GAAc,EAAW,YAE3C,OAAO,QAAQ,QADI,IAAgB,aAAe,UACjB,EAGnC,IAAM,EAAS,EAAU,CAAQ,EAC3B,EAAe,IAAgB,YAAc,EAAO,WAAa,EAAO,QAE9E,GAAI,EAAE,EAAW,SAAW,EAAO,SACjC,MAAM,IAAI,EAAW,8CAA8C,EAGrE,OAAO,EAAa,CAClB,OAAQ,EAAW,aAAa,QAAQ,EACxC,aAAc,EAAW,QACzB,KAAM,EAAO,QACb,gBACF,CAAC",
|
|
8
|
+
"debugId": "E728D6BDDD04954164756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var l=Object.create;var{getPrototypeOf:f,defineProperty:o,getOwnPropertyNames:m,getOwnPropertyDescriptor:y}=Object,u=Object.prototype.hasOwnProperty;var g=(e,s,n)=>{n=e!=null?l(f(e)):{};let r=s||!e||!e.__esModule?o(n,"default",{value:e,enumerable:!0}):n;for(let t of m(e))if(!u.call(r,t))o(r,t,{get:()=>e[t],enumerable:!0});return r},c=new WeakMap,h=(e)=>{var s=c.get(e),n;if(s)return s;if(s=o({},"__esModule",{value:!0}),e&&typeof e==="object"||typeof e==="function")m(e).map((r)=>!u.call(s,r)&&o(s,r,{get:()=>e[r],enumerable:!(n=y(e,r))||n.enumerable}));return c.set(e,s),s};var w=(e,s)=>{for(var n in s)o(e,n,{get:s[n],enumerable:!0,configurable:!0,set:(r)=>s[n]=()=>r})};var p=require("@tcswap/helpers");function T({name:e,properties:s,methods:n}){function r(t){return{...n(t),...s}}return{[e]:r}}function S({approveMode:e,getWallet:s}){return function({assetValue:r,spenderAddress:t}){let a=r.chain,d=p.EVMChains.includes(a);if(d&&r.isGasAsset||!d||r.isSynthetic)return Promise.resolve(e==="checkOnly"||"approved");let i=s(a),v=e==="checkOnly"?i.isApproved:i.approve;if(!(r.address&&i.address))throw new p.USwapError("core_approve_asset_address_or_from_not_found");return v({amount:r.getBaseValue("bigint"),assetAddress:r.address,from:i.address,spenderAddress:t})}}
|
|
2
|
+
|
|
3
|
+
//# debugId=38DCA2467E0AF85564756E2164756E21
|
|
4
|
+
//# sourceMappingURL=chunk-zweecvg1.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/utils.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/**\n * Modifications © 2025 Horizontal Systems.\n */\n\nimport type { ApproveMode, ApproveReturnType, EVMChain, ProviderName } from \"@tcswap/helpers\";\nimport { type AssetValue, EVMChains, USwapError } from \"@tcswap/helpers\";\nimport type { SwapKitPluginParams } from \"./types\";\n\nexport function createPlugin<\n const Name extends string,\n T extends (params: SwapKitPluginParams) => Record<string, unknown>,\n K extends { supportedUSwapProviders?: readonly ProviderName[] },\n>({ name, properties, methods }: { name: Name; properties?: K; methods: T }) {\n function plugin(pluginParams: SwapKitPluginParams) {\n return { ...methods(pluginParams), ...properties } as K & ReturnType<T>;\n }\n\n return { [name]: plugin } as { [key in Name]: typeof plugin };\n}\n\nexport function approve<T extends ApproveMode>({ approveMode, getWallet }: { approveMode: T } & SwapKitPluginParams) {\n return function approve({ assetValue, spenderAddress }: { spenderAddress: string; assetValue: AssetValue }) {\n const evmChain = assetValue.chain as EVMChain;\n const isEVMChain = EVMChains.includes(evmChain);\n const isNativeEVM = isEVMChain && assetValue.isGasAsset;\n\n if (isNativeEVM || !isEVMChain || assetValue.isSynthetic) {\n const isApproved = approveMode === \"checkOnly\" || \"approved\";\n return Promise.resolve(isApproved) as ApproveReturnType<T>;\n }\n\n const wallet = getWallet(evmChain);\n const walletAction = approveMode === \"checkOnly\" ? wallet.isApproved : wallet.approve;\n\n if (!(assetValue.address && wallet.address)) {\n throw new USwapError(\"core_approve_asset_address_or_from_not_found\");\n }\n\n return walletAction({\n amount: assetValue.getBaseValue(\"bigint\"),\n assetAddress: assetValue.address,\n from: wallet.address,\n spenderAddress,\n });\n };\n}\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": "mqBAKuD,IAAvD,6BAGO,SAAS,CAIf,EAAG,OAAM,aAAY,WAAuD,CAC3E,SAAS,CAAM,CAAC,EAAmC,CACjD,MAAO,IAAK,EAAQ,CAAY,KAAM,CAAW,EAGnD,MAAO,EAAG,GAAO,CAAO,EAGnB,SAAS,CAA8B,EAAG,cAAa,aAAuD,CACnH,OAAO,QAAgB,EAAG,aAAY,kBAAsE,CAC1G,IAAM,EAAW,EAAW,MACtB,EAAa,YAAU,SAAS,CAAQ,EAG9C,GAFoB,GAAc,EAAW,YAE1B,CAAC,GAAc,EAAW,YAE3C,OAAO,QAAQ,QADI,IAAgB,aAAe,UACjB,EAGnC,IAAM,EAAS,EAAU,CAAQ,EAC3B,EAAe,IAAgB,YAAc,EAAO,WAAa,EAAO,QAE9E,GAAI,EAAE,EAAW,SAAW,EAAO,SACjC,MAAM,IAAI,aAAW,8CAA8C,EAGrE,OAAO,EAAa,CAClB,OAAQ,EAAW,aAAa,QAAQ,EACxC,aAAc,EAAW,QACzB,KAAM,EAAO,QACb,gBACF,CAAC",
|
|
8
|
+
"debugId": "38DCA2467E0AF85564756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var d={};A(d,{EVMPlugin:()=>E});module.exports=v(d);var e=require("@tcswap/helpers");var E=p({methods:({getWallet:a})=>({approveAssetValue:o({approveMode:e.ApproveMode.Approve,getWallet:a}),isAssetValueApproved:o({approveMode:e.ApproveMode.CheckOnly,getWallet:a}),swap:async function({route:{tx:s,sellAsset:t},feeOptionKey:n}){let r=(await e.AssetValue.from({asset:t,asyncTokenLookup:!0})).chain,i=a(r);if(!(e.EVMChains.includes(r)&&s))throw new e.USwapError("core_swap_invalid_params");let{from:u,to:c,data:m,value:V}=s;return i.sendTransaction({data:m,feeOptionKey:n,from:u,to:c,value:BigInt(V)})}}),name:"evm",properties:{supportedUSwapProviders:[e.ProviderName.CAMELOT_V3,e.ProviderName.OPENOCEAN_V2,e.ProviderName.OKX,e.ProviderName.ONEINCH,e.ProviderName.PANCAKESWAP,e.ProviderName.PANGOLIN_V1,e.ProviderName.SUSHISWAP_V2,e.ProviderName.TRADERJOE_V2,e.ProviderName.UNISWAP_V2,e.ProviderName.UNISWAP_V3]}});
|
|
2
|
+
|
|
3
|
+
//# debugId=922424E400B1F8C364756E2164756E21
|
|
4
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/evm/index.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/**\n * Modifications © 2025 Horizontal Systems.\n */\n\nimport {\n ApproveMode,\n AssetValue,\n type EVMChain,\n EVMChains,\n ProviderName,\n type SwapParams,\n USwapError,\n} from \"@tcswap/helpers\";\nimport type { EVMTransaction, QuoteResponseRoute } from \"@tcswap/helpers/api\";\nimport { approve, createPlugin } from \"../utils\";\n\nexport const EVMPlugin = createPlugin({\n methods: ({ getWallet }) => ({\n approveAssetValue: approve({ approveMode: ApproveMode.Approve, getWallet }),\n isAssetValueApproved: approve({ approveMode: ApproveMode.CheckOnly, getWallet }),\n swap: async function evmSwap({ route: { tx, sellAsset }, feeOptionKey }: SwapParams<\"evm\", QuoteResponseRoute>) {\n const assetValue = await AssetValue.from({ asset: sellAsset, asyncTokenLookup: true });\n const evmChain = assetValue.chain as EVMChain;\n const wallet = getWallet(evmChain);\n\n if (!(EVMChains.includes(evmChain) && tx)) {\n throw new USwapError(\"core_swap_invalid_params\");\n }\n\n const { from, to, data, value } = tx as EVMTransaction;\n return wallet.sendTransaction({ data, feeOptionKey, from, to, value: BigInt(value) });\n },\n }),\n name: \"evm\",\n properties: {\n supportedUSwapProviders: [\n ProviderName.CAMELOT_V3,\n ProviderName.OPENOCEAN_V2,\n ProviderName.OKX,\n ProviderName.ONEINCH,\n ProviderName.PANCAKESWAP,\n ProviderName.PANGOLIN_V1,\n ProviderName.SUSHISWAP_V2,\n ProviderName.TRADERJOE_V2,\n ProviderName.UNISWAP_V2,\n ProviderName.UNISWAP_V3,\n ] as const,\n },\n});\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": "oDAYO,IARP,6BAYO,IAAM,EAAY,EAAa,CACpC,QAAS,EAAG,gBAAiB,CAC3B,kBAAmB,EAAQ,CAAE,YAAa,cAAY,QAAS,WAAU,CAAC,EAC1E,qBAAsB,EAAQ,CAAE,YAAa,cAAY,UAAW,WAAU,CAAC,EAC/E,KAAM,cAAsB,EAAG,OAAS,KAAI,aAAa,gBAAuD,CAE9G,IAAM,GADa,MAAM,aAAW,KAAK,CAAE,MAAO,EAAW,iBAAkB,EAAK,CAAC,GACzD,MACtB,EAAS,EAAU,CAAQ,EAEjC,GAAI,EAAE,YAAU,SAAS,CAAQ,GAAK,GACpC,MAAM,IAAI,aAAW,0BAA0B,EAGjD,IAAQ,OAAM,KAAI,OAAM,SAAU,EAClC,OAAO,EAAO,gBAAgB,CAAE,OAAM,eAAc,OAAM,KAAI,MAAO,OAAO,CAAK,CAAE,CAAC,EAExF,GACA,KAAM,MACN,WAAY,CACV,wBAAyB,CACvB,eAAa,WACb,eAAa,aACb,eAAa,IACb,eAAa,QACb,eAAa,YACb,eAAa,YACb,eAAa,aACb,eAAa,aACb,eAAa,WACb,eAAa,UACf,CACF,CACF,CAAC",
|
|
8
|
+
"debugId": "922424E400B1F8C364756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{c as t,d as o}from"../chunk-vzvcxw96.js";import{ApproveMode as p,AssetValue as A,EVMChains as E,ProviderName as e,USwapError as d}from"@tcswap/helpers";var M=t({methods:({getWallet:a})=>({approveAssetValue:o({approveMode:p.Approve,getWallet:a}),isAssetValueApproved:o({approveMode:p.CheckOnly,getWallet:a}),swap:async function({route:{tx:s,sellAsset:n},feeOptionKey:i}){let r=(await A.from({asset:n,asyncTokenLookup:!0})).chain,u=a(r);if(!(E.includes(r)&&s))throw new d("core_swap_invalid_params");let{from:c,to:m,data:V,value:v}=s;return u.sendTransaction({data:V,feeOptionKey:i,from:c,to:m,value:BigInt(v)})}}),name:"evm",properties:{supportedUSwapProviders:[e.CAMELOT_V3,e.OPENOCEAN_V2,e.OKX,e.ONEINCH,e.PANCAKESWAP,e.PANGOLIN_V1,e.SUSHISWAP_V2,e.TRADERJOE_V2,e.UNISWAP_V2,e.UNISWAP_V3]}});export{M as EVMPlugin};
|
|
2
|
+
|
|
3
|
+
//# debugId=88CC7EB9E2423D6C64756E2164756E21
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/evm/index.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/**\n * Modifications © 2025 Horizontal Systems.\n */\n\nimport {\n ApproveMode,\n AssetValue,\n type EVMChain,\n EVMChains,\n ProviderName,\n type SwapParams,\n USwapError,\n} from \"@tcswap/helpers\";\nimport type { EVMTransaction, QuoteResponseRoute } from \"@tcswap/helpers/api\";\nimport { approve, createPlugin } from \"../utils\";\n\nexport const EVMPlugin = createPlugin({\n methods: ({ getWallet }) => ({\n approveAssetValue: approve({ approveMode: ApproveMode.Approve, getWallet }),\n isAssetValueApproved: approve({ approveMode: ApproveMode.CheckOnly, getWallet }),\n swap: async function evmSwap({ route: { tx, sellAsset }, feeOptionKey }: SwapParams<\"evm\", QuoteResponseRoute>) {\n const assetValue = await AssetValue.from({ asset: sellAsset, asyncTokenLookup: true });\n const evmChain = assetValue.chain as EVMChain;\n const wallet = getWallet(evmChain);\n\n if (!(EVMChains.includes(evmChain) && tx)) {\n throw new USwapError(\"core_swap_invalid_params\");\n }\n\n const { from, to, data, value } = tx as EVMTransaction;\n return wallet.sendTransaction({ data, feeOptionKey, from, to, value: BigInt(value) });\n },\n }),\n name: \"evm\",\n properties: {\n supportedUSwapProviders: [\n ProviderName.CAMELOT_V3,\n ProviderName.OPENOCEAN_V2,\n ProviderName.OKX,\n ProviderName.ONEINCH,\n ProviderName.PANCAKESWAP,\n ProviderName.PANGOLIN_V1,\n ProviderName.SUSHISWAP_V2,\n ProviderName.TRADERJOE_V2,\n ProviderName.UNISWAP_V2,\n ProviderName.UNISWAP_V3,\n ] as const,\n },\n});\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": "gDAIA,sBACE,gBACA,eAEA,kBACA,gBAEA,wBAKK,IAAM,EAAY,EAAa,CACpC,QAAS,EAAG,gBAAiB,CAC3B,kBAAmB,EAAQ,CAAE,YAAa,EAAY,QAAS,WAAU,CAAC,EAC1E,qBAAsB,EAAQ,CAAE,YAAa,EAAY,UAAW,WAAU,CAAC,EAC/E,KAAM,cAAsB,EAAG,OAAS,KAAI,aAAa,gBAAuD,CAE9G,IAAM,GADa,MAAM,EAAW,KAAK,CAAE,MAAO,EAAW,iBAAkB,EAAK,CAAC,GACzD,MACtB,EAAS,EAAU,CAAQ,EAEjC,GAAI,EAAE,EAAU,SAAS,CAAQ,GAAK,GACpC,MAAM,IAAI,EAAW,0BAA0B,EAGjD,IAAQ,OAAM,KAAI,OAAM,SAAU,EAClC,OAAO,EAAO,gBAAgB,CAAE,OAAM,eAAc,OAAM,KAAI,MAAO,OAAO,CAAK,CAAE,CAAC,EAExF,GACA,KAAM,MACN,WAAY,CACV,wBAAyB,CACvB,EAAa,WACb,EAAa,aACb,EAAa,IACb,EAAa,QACb,EAAa,YACb,EAAa,YACb,EAAa,aACb,EAAa,aACb,EAAa,WACb,EAAa,UACf,CACF,CACF,CAAC",
|
|
8
|
+
"debugId": "88CC7EB9E2423D6C64756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var M={};V(M,{GardenPlugin:()=>l});module.exports=A(M);var u=require("@solana/web3.js"),a=require("@tcswap/helpers"),m=require("ts-pattern");var l=d({methods:({getWallet:e})=>({approveAssetValue:o({approveMode:a.ApproveMode.Approve,getWallet:e}),isAssetValueApproved:o({approveMode:a.ApproveMode.CheckOnly,getWallet:e}),swap:function({route:w}){let{sellAsset:h,sellAmount:f,targetAddress:i,tx:p}=w,c=a.AssetValue.from({asset:h,value:f});return m.match(c.chain).returnType().with(...a.EVMChains,(s)=>{let r=e(s),{from:t,to:n,data:g,value:v}=p;return r.sendTransaction({data:g,from:t,to:n,value:BigInt(v)})}).with(a.Chain.Solana,async(s)=>{let r=e(s),t=u.VersionedTransaction.deserialize(Buffer.from(p,"base64")),n=await r.signTransaction(t);return r.broadcastTransaction(n)}).otherwise(async(s)=>{if(!i)throw new a.USwapError("plugin_garden_missing_data",{message:"Missing target address: "});return await e(s).transfer({assetValue:c,recipient:i})})}}),name:"garden",properties:{supportedUSwapProviders:[a.ProviderName.GARDEN]}});
|
|
2
|
+
|
|
3
|
+
//# debugId=25F6BB4857BEE34864756E2164756E21
|
|
4
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/garden/plugin.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/**\n * Modifications © 2025 Horizontal Systems.\n */\n\nimport { VersionedTransaction } from \"@solana/web3.js\";\nimport { ApproveMode, AssetValue, Chain, EVMChains, ProviderName, type SwapParams, USwapError } from \"@tcswap/helpers\";\nimport type { EVMTransaction, QuoteResponseRoute } from \"@tcswap/helpers/api\";\nimport { match } from \"ts-pattern\";\nimport { approve, createPlugin } from \"../utils\";\n\nexport const GardenPlugin = createPlugin({\n methods: ({ getWallet }) => ({\n approveAssetValue: approve({ approveMode: ApproveMode.Approve, getWallet }),\n isAssetValueApproved: approve({ approveMode: ApproveMode.CheckOnly, getWallet }),\n swap: function gardenSwap({ route }: SwapParams<\"garden\", QuoteResponseRoute>) {\n const { sellAsset, sellAmount, targetAddress, tx } = route;\n\n const sellAssetValue = AssetValue.from({ asset: sellAsset, value: sellAmount });\n\n return match(sellAssetValue.chain as Chain)\n .returnType<Promise<string>>()\n .with(...EVMChains, (chain) => {\n const wallet = getWallet(chain);\n\n const { from, to, data, value } = tx as EVMTransaction;\n return wallet.sendTransaction({ data, from, to, value: BigInt(value) });\n })\n .with(Chain.Solana, async (chain) => {\n const wallet = getWallet(chain);\n const transaction = VersionedTransaction.deserialize(Buffer.from(tx as string, \"base64\"));\n\n const signedTransaction = await wallet.signTransaction(transaction);\n\n return wallet.broadcastTransaction(signedTransaction);\n })\n .otherwise(async (chain) => {\n if (!targetAddress) {\n throw new USwapError(\"plugin_garden_missing_data\", { message: \"Missing target address: \" });\n }\n const wallet = getWallet(chain as Exclude<Chain, Chain.Radix>);\n\n const txHash = await wallet.transfer({ assetValue: sellAssetValue, recipient: targetAddress });\n\n return txHash;\n });\n },\n }),\n name: \"garden\",\n properties: { supportedUSwapProviders: [ProviderName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xw96.js";import{VersionedTransaction as f}from"@solana/web3.js";import{ApproveMode as c,AssetValue as g,Chain as v,EVMChains as A,ProviderName as V,USwapError as M}from"@tcswap/helpers";import{match as P}from"ts-pattern";var T=d({methods:({getWallet:a})=>({approveAssetValue:n({approveMode:c.Approve,getWallet:a}),isAssetValueApproved:n({approveMode:c.CheckOnly,getWallet:a}),swap:function({route:u}){let{sellAsset:m,sellAmount:l,targetAddress:o,tx:i}=u,p=g.from({asset:m,value:l});return P(p.chain).returnType().with(...A,(e)=>{let s=a(e),{from:r,to:t,data:w,value:h}=i;return s.sendTransaction({data:w,from:r,to:t,value:BigInt(h)})}).with(v.Solana,async(e)=>{let s=a(e),r=f.deserialize(Buffer.from(i,"base64")),t=await s.signTransaction(r);return s.broadcastTransaction(t)}).otherwise(async(e)=>{if(!o)throw new M("plugin_garden_missing_data",{message:"Missing target address: "});return await a(e).transfer({assetValue:p,recipient:o})})}}),name:"garden",properties:{supportedUSwapProviders:[V.GARDEN]}});export{T as GardenPlugin};
|
|
2
|
+
|
|
3
|
+
//# debugId=FA32A676D409F72F64756E2164756E21
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/garden/plugin.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/**\n * Modifications © 2025 Horizontal Systems.\n */\n\nimport { VersionedTransaction } from \"@solana/web3.js\";\nimport { ApproveMode, AssetValue, Chain, EVMChains, ProviderName, type SwapParams, USwapError } from \"@tcswap/helpers\";\nimport type { EVMTransaction, QuoteResponseRoute } from \"@tcswap/helpers/api\";\nimport { match } from \"ts-pattern\";\nimport { approve, createPlugin } from \"../utils\";\n\nexport const GardenPlugin = createPlugin({\n methods: ({ getWallet }) => ({\n approveAssetValue: approve({ approveMode: ApproveMode.Approve, getWallet }),\n isAssetValueApproved: approve({ approveMode: ApproveMode.CheckOnly, getWallet }),\n swap: function gardenSwap({ route }: SwapParams<\"garden\", QuoteResponseRoute>) {\n const { sellAsset, sellAmount, targetAddress, tx } = route;\n\n const sellAssetValue = AssetValue.from({ asset: sellAsset, value: sellAmount });\n\n return match(sellAssetValue.chain as Chain)\n .returnType<Promise<string>>()\n .with(...EVMChains, (chain) => {\n const wallet = getWallet(chain);\n\n const { from, to, data, value } = tx as EVMTransaction;\n return wallet.sendTransaction({ data, from, to, value: BigInt(value) });\n })\n .with(Chain.Solana, async (chain) => {\n const wallet = getWallet(chain);\n const transaction = VersionedTransaction.deserialize(Buffer.from(tx as string, \"base64\"));\n\n const signedTransaction = await wallet.signTransaction(transaction);\n\n return wallet.broadcastTransaction(signedTransaction);\n })\n .otherwise(async (chain) => {\n if (!targetAddress) {\n throw new USwapError(\"plugin_garden_missing_data\", { message: \"Missing target address: \" });\n }\n const wallet = getWallet(chain as Exclude<Chain, Chain.Radix>);\n\n const txHash = await wallet.transfer({ assetValue: sellAssetValue, recipient: targetAddress });\n\n return txHash;\n });\n },\n }),\n name: \"garden\",\n properties: { supportedUSwapProviders: [ProviderName.GARDEN] as const },\n});\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": "gDAIA,+BAAS,wBACT,sBAAS,gBAAa,WAAY,eAAO,kBAAW,gBAA+B,wBAEnF,gBAAS,mBAGF,IAAM,EAAe,EAAa,CACvC,QAAS,EAAG,gBAAiB,CAC3B,kBAAmB,EAAQ,CAAE,YAAa,EAAY,QAAS,WAAU,CAAC,EAC1E,qBAAsB,EAAQ,CAAE,YAAa,EAAY,UAAW,WAAU,CAAC,EAC/E,KAAM,QAAmB,EAAG,SAAmD,CAC7E,IAAQ,YAAW,aAAY,gBAAe,MAAO,EAE/C,EAAiB,EAAW,KAAK,CAAE,MAAO,EAAW,MAAO,CAAW,CAAC,EAE9E,OAAO,EAAM,EAAe,KAAc,EACvC,WAA4B,EAC5B,KAAK,GAAG,EAAW,CAAC,IAAU,CAC7B,IAAM,EAAS,EAAU,CAAK,GAEtB,OAAM,KAAI,OAAM,SAAU,EAClC,OAAO,EAAO,gBAAgB,CAAE,OAAM,OAAM,KAAI,MAAO,OAAO,CAAK,CAAE,CAAC,EACvE,EACA,KAAK,EAAM,OAAQ,MAAO,IAAU,CACnC,IAAM,EAAS,EAAU,CAAK,EACxB,EAAc,EAAqB,YAAY,OAAO,KAAK,EAAc,QAAQ,CAAC,EAElF,EAAoB,MAAM,EAAO,gBAAgB,CAAW,EAElE,OAAO,EAAO,qBAAqB,CAAiB,EACrD,EACA,UAAU,MAAO,IAAU,CAC1B,GAAI,CAAC,EACH,MAAM,IAAI,EAAW,6BAA8B,CAAE,QAAS,0BAA2B,CAAC,EAM5F,OAFe,MAFA,EAAU,CAAoC,EAEjC,SAAS,CAAE,WAAY,EAAgB,UAAW,CAAc,CAAC,EAG9F,EAEP,GACA,KAAM,SACN,WAAY,CAAE,wBAAyB,CAAC,EAAa,MAAM,CAAW,CACxE,CAAC",
|
|
8
|
+
"debugId": "FA32A676D409F72F64756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var u={};r(u,{loadPlugin:()=>l,createPlugin:()=>e,approve:()=>p});module.exports=o(u);async function l(n){let{match:a}=await import("ts-pattern");return await a(n).with("chainflip",async()=>{let{ChainflipPlugin:i}=await import("./chainflip/index.cjs");return i}).with("thorchain",async()=>{let{ThorchainPlugin:i}=await import("./thorchain/index.cjs");return i}).with("radix",async()=>{let{RadixPlugin:i}=await import("./radix/index.cjs");return i}).with("evm",async()=>{let{EVMPlugin:i}=await import("./evm/index.cjs");return i}).with("solana",async()=>{let{SolanaPlugin:i}=await import("./solana/index.cjs");return i}).with("near",async()=>{let{NearPlugin:i}=await import("./near/index.cjs");return i}).exhaustive()}
|
|
2
|
+
|
|
3
|
+
//# debugId=3FEDB5802C7E431864756E2164756E21
|
|
4
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/index.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/**\n * Modifications © 2025 Horizontal Systems.\n */\n\nimport type { PluginName, USwapPlugins } from \"./types\";\n\nexport * from \"./types\";\nexport * from \"./utils\";\n\nexport async function loadPlugin<P extends PluginName>(pluginName: P) {\n const { match } = await import(\"ts-pattern\");\n\n const plugin = await match(pluginName as PluginName)\n .with(\"chainflip\", async () => {\n const { ChainflipPlugin } = await import(\"./chainflip\");\n return ChainflipPlugin;\n })\n .with(\"thorchain\", async () => {\n const { ThorchainPlugin } = await import(\"./thorchain\");\n return ThorchainPlugin;\n })\n .with(\"radix\", async () => {\n const { RadixPlugin } = await import(\"./radix\");\n return RadixPlugin;\n })\n .with(\"evm\", async () => {\n const { EVMPlugin } = await import(\"./evm\");\n return EVMPlugin;\n })\n .with(\"solana\", async () => {\n const { SolanaPlugin } = await import(\"./solana\");\n return SolanaPlugin;\n })\n .with(\"near\", async () => {\n const { NearPlugin } = await import(\"./near\");\n return NearPlugin;\n })\n .exhaustive();\n\n return plugin as unknown as USwapPlugins[P];\n}\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": "sFASA,eAAsB,CAAgC,CAAC,EAAe,CACpE,IAAQ,SAAU,KAAa,sBA6B/B,OA3Be,MAAM,EAAM,CAAwB,EAChD,KAAK,YAAa,SAAY,CAC7B,IAAQ,mBAAoB,KAAa,iCACzC,OAAO,EACR,EACA,KAAK,YAAa,SAAY,CAC7B,IAAQ,mBAAoB,KAAa,iCACzC,OAAO,EACR,EACA,KAAK,QAAS,SAAY,CACzB,IAAQ,eAAgB,KAAa,6BACrC,OAAO,EACR,EACA,KAAK,MAAO,SAAY,CACvB,IAAQ,aAAc,KAAa,2BACnC,OAAO,EACR,EACA,KAAK,SAAU,SAAY,CAC1B,IAAQ,gBAAiB,KAAa,8BACtC,OAAO,EACR,EACA,KAAK,OAAQ,SAAY,CACxB,IAAQ,cAAe,KAAa,4BACpC,OAAO,EACR,EACA,WAAW",
|
|
8
|
+
"debugId": "3FEDB5802C7E431864756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{a as t,b as n,c as s,d as m}from"./chunk-vzvcxw96.js";async function e(a){let{match:o}=await import("ts-pattern");return await o(a).with("chainflip",async()=>{let{ChainflipPlugin:i}=await import("./chainflip/index.js");return i}).with("thorchain",async()=>{let{ThorchainPlugin:i}=await import("./thorchain/index.js");return i}).with("radix",async()=>{let{RadixPlugin:i}=await import("./radix/index.js");return i}).with("evm",async()=>{let{EVMPlugin:i}=await import("./evm/index.js");return i}).with("solana",async()=>{let{SolanaPlugin:i}=await import("./solana/index.js");return i}).with("near",async()=>{let{NearPlugin:i}=await import("./near/index.js");return i}).exhaustive()}export{e as loadPlugin,s as createPlugin,m as approve};
|
|
2
|
+
|
|
3
|
+
//# debugId=151908FEFCA9D53564756E2164756E21
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/index.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/**\n * Modifications © 2025 Horizontal Systems.\n */\n\nimport type { PluginName, USwapPlugins } from \"./types\";\n\nexport * from \"./types\";\nexport * from \"./utils\";\n\nexport async function loadPlugin<P extends PluginName>(pluginName: P) {\n const { match } = await import(\"ts-pattern\");\n\n const plugin = await match(pluginName as PluginName)\n .with(\"chainflip\", async () => {\n const { ChainflipPlugin } = await import(\"./chainflip\");\n return ChainflipPlugin;\n })\n .with(\"thorchain\", async () => {\n const { ThorchainPlugin } = await import(\"./thorchain\");\n return ThorchainPlugin;\n })\n .with(\"radix\", async () => {\n const { RadixPlugin } = await import(\"./radix\");\n return RadixPlugin;\n })\n .with(\"evm\", async () => {\n const { EVMPlugin } = await import(\"./evm\");\n return EVMPlugin;\n })\n .with(\"solana\", async () => {\n const { SolanaPlugin } = await import(\"./solana\");\n return SolanaPlugin;\n })\n .with(\"near\", async () => {\n const { NearPlugin } = await import(\"./near\");\n return NearPlugin;\n })\n .exhaustive();\n\n return plugin as unknown as USwapPlugins[P];\n}\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": "6DASA,eAAsB,CAAgC,CAAC,EAAe,CACpE,IAAQ,SAAU,KAAa,sBA6B/B,OA3Be,MAAM,EAAM,CAAwB,EAChD,KAAK,YAAa,SAAY,CAC7B,IAAQ,mBAAoB,KAAa,gCACzC,OAAO,EACR,EACA,KAAK,YAAa,SAAY,CAC7B,IAAQ,mBAAoB,KAAa,gCACzC,OAAO,EACR,EACA,KAAK,QAAS,SAAY,CACzB,IAAQ,eAAgB,KAAa,4BACrC,OAAO,EACR,EACA,KAAK,MAAO,SAAY,CACvB,IAAQ,aAAc,KAAa,0BACnC,OAAO,EACR,EACA,KAAK,SAAU,SAAY,CAC1B,IAAQ,gBAAiB,KAAa,6BACtC,OAAO,EACR,EACA,KAAK,OAAQ,SAAY,CACxB,IAAQ,cAAe,KAAa,2BACpC,OAAO,EACR,EACA,WAAW",
|
|
8
|
+
"debugId": "151908FEFCA9D53564756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var T={};P(T,{NearPlugin:()=>k});module.exports=O(T);var x=require("@tcswap/helpers");var H=require("@near-js/utils"),G=2,L=64;function Z(K){if(K.length<G||K.length>L)return!1;return/^[a-z0-9]+(-[a-z0-9]+)*$/.test(K)}function V(K){let B=K.length,q;if(B<=2)q="50";else if(B<=3)q="20";else if(B<=4)q="5";else if(B<=5)q="1";else q="0.1";return H.parseNearAmount(q)||"0"}var k=X({methods:({getWallet:K})=>({nearNames:{async getInfo(B){let q=B.toLowerCase().replace(/\.near$/,"");if(!Z(q))throw new x.USwapError("plugin_near_invalid_name");let F=`${q}.near`,D=K(x.Chain.Near);if(!D)throw new x.USwapError("plugin_near_no_connection");try{let J=await D.provider.query({account_id:F,finality:"final",request_type:"view_account"}),Y=await D.provider.query({account_id:F,finality:"final",request_type:"view_access_key_list"});return{accountId:F,balance:J.amount,codeHash:J.code_hash,publicKeys:Y.keys?.map((Q)=>Q.public_key)||[],storageUsed:J.storage_usage}}catch(J){if(/UNKNOWN_ACCOUNT|does not exist while viewing/.test(J.message))return null;throw J}},async isAvailable(B){return await this.resolve(B)===null},async lookupNames(B){let q=K(x.Chain.Near);if(!q)throw new x.USwapError("plugin_near_no_connection");try{if(await q.provider.query({account_id:B,finality:"final",request_type:"view_account"}),B.endsWith(".near"))return[B];return[]}catch{return[]}},async register(B){let{name:q,publicKey:F}=B,D=q.toLowerCase().replace(/\.near$/,"");if(!Z(D))throw new x.USwapError("plugin_near_invalid_name");let J=K(x.Chain.Near),Y=F||await J.getPublicKey(),Q=V(D);return J.callFunction({args:{new_account_id:`${D}.near`,new_public_key:Y},contractId:"near",deposit:Q,methodName:"create_account"})},async resolve(B){let q=B.toLowerCase().replace(/\.near$/,"");if(!Z(q))throw new x.USwapError("plugin_near_invalid_name");let F=`${q}.near`,D=K(x.Chain.Near);if(!D)throw new x.USwapError("plugin_near_no_connection");try{return await D.provider.query({account_id:F,finality:"final",request_type:"view_account"}),F}catch(J){if(/UNKNOWN_ACCOUNT|does not exist while viewing/.test(J.message))return null;throw J}},transfer(B,q){let F=B.toLowerCase().replace(/\.near$/,"");if(!Z(F))throw new x.USwapError("plugin_near_invalid_name");return K(x.Chain.Near).callFunction({args:{name:F,new_owner:q},contractId:"near",deposit:"1",methodName:"transfer"})}},async swap(B){let{route:{buyAsset:q,sellAsset:F,inboundAddress:D,sellAmount:J,meta:Y}}=B;if(!(F&&q&&Y?.near?.sellAsset))throw new x.USwapError("core_swap_asset_not_recognized");if(!D)throw new x.USwapError("core_swap_invalid_params",{missing:["inboundAddress"]});let Q=await x.AssetValue.from({asset:F,value:J}),b=Q.chain,j=K(Q.chain);if(b===x.Chain.Near&&!Q.isGasAsset){let $=K(Q.chain);if(!$)throw new x.USwapError("core_wallet_connection_not_found");let y=await $.createContractFunctionCall({args:{amount:Q.getBaseValue("string"),msg:JSON.stringify({receiver_id:D}),receiver_id:"intents.near"},attachedDeposit:"1",contractId:Q.address,gas:"250000000000000",methodName:"ft_transfer_call",sender:$.address});return $.signAndSendTransaction(y)}if(!j)throw new x.USwapError("core_wallet_connection_not_found");return await j.transfer({assetValue:Q,isProgramDerivedAddress:!0,recipient:D,sender:j.address})}}),name:"near",properties:{supportedUSwapProviders:[x.ProviderName.NEAR]}});
|
|
2
|
+
|
|
3
|
+
//# debugId=FAC10B996571F83E64756E2164756E21
|
|
4
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/near/plugin.ts", "../src/near/nearNames.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/**\n * Modifications © 2025 Horizontal Systems.\n */\n\nimport { AssetValue, Chain, ProviderName, type SwapParams, USwapError } from \"@tcswap/helpers\";\nimport type { QuoteResponseRoute } from \"@tcswap/helpers/api\";\nimport type { NearWallet } from \"@tcswap/toolboxes/near\";\nimport { createPlugin } from \"../utils\";\nimport { calculateNearNameCost, validateNearName } from \"./nearNames\";\nimport type { NearAccountInfo, NearNameRegistrationParams } from \"./types\";\n\nexport const NearPlugin = createPlugin({\n methods: ({ getWallet }) => ({\n nearNames: {\n async getInfo(name: string): Promise<NearAccountInfo | null> {\n const normalizedName = name.toLowerCase().replace(/\\.near$/, \"\");\n\n if (!validateNearName(normalizedName)) {\n throw new USwapError(\"plugin_near_invalid_name\");\n }\n\n const accountId = `${normalizedName}.near`;\n const wallet = getWallet(Chain.Near);\n\n if (!wallet) {\n throw new USwapError(\"plugin_near_no_connection\");\n }\n\n try {\n // Get account info\n const accountInfo = await wallet.provider.query({\n account_id: accountId,\n finality: \"final\",\n request_type: \"view_account\",\n });\n\n // Optionally get the account's public keys\n const keysInfo = await wallet.provider.query({\n account_id: accountId,\n finality: \"final\",\n request_type: \"view_access_key_list\",\n });\n\n return {\n accountId,\n balance: (accountInfo as any).amount,\n codeHash: (accountInfo as any).code_hash,\n publicKeys: (keysInfo as any).keys?.map((k: any) => k.public_key) || [],\n storageUsed: (accountInfo as any).storage_usage,\n };\n } catch (err: any) {\n if (/UNKNOWN_ACCOUNT|does not exist while viewing/.test(err.message)) {\n return null;\n }\n throw err;\n }\n },\n\n async isAvailable(name: string) {\n const owner = await this.resolve(name);\n return owner === null;\n },\n\n async lookupNames(accountId: string) {\n // NEAR doesn't have a central registry to look up all names owned by an account\n // This would require indexing or an external service\n // For now, we can only check if a specific account exists\n const wallet = getWallet(Chain.Near);\n\n if (!wallet) {\n throw new USwapError(\"plugin_near_no_connection\");\n }\n\n try {\n // Check if the account exists\n await wallet.provider.query({ account_id: accountId, finality: \"final\", request_type: \"view_account\" });\n\n // If the account ID ends with .near, it's a NEAR name\n if (accountId.endsWith(\".near\")) {\n return [accountId];\n }\n\n // Otherwise, we can't determine what names they own without an indexer\n return [];\n } catch {\n return [];\n }\n },\n\n async register(params: NearNameRegistrationParams) {\n const { name, publicKey: publicKeyOverwrite } = params;\n const normalizedName = name.toLowerCase().replace(/\\.near$/, \"\");\n\n if (!validateNearName(normalizedName)) {\n throw new USwapError(\"plugin_near_invalid_name\");\n }\n\n const wallet = getWallet(Chain.Near) as NearWallet;\n\n const newPublicKey = publicKeyOverwrite || (await wallet.getPublicKey());\n\n const cost = calculateNearNameCost(normalizedName);\n\n return wallet.callFunction({\n args: { new_account_id: `${normalizedName}.near`, new_public_key: newPublicKey },\n contractId: \"near\",\n deposit: cost,\n methodName: \"create_account\",\n });\n },\n async resolve(name: string) {\n const normalizedName = name.toLowerCase().replace(/\\.near$/, \"\");\n\n if (!validateNearName(normalizedName)) {\n throw new USwapError(\"plugin_near_invalid_name\");\n }\n\n const accountId = `${normalizedName}.near`;\n const wallet = getWallet(Chain.Near);\n\n if (!wallet) {\n throw new USwapError(\"plugin_near_no_connection\");\n }\n\n try {\n // Ask RPC whether the account exists\n await wallet.provider.query({ account_id: accountId, finality: \"final\", request_type: \"view_account\" });\n // If no error is thrown, the account exists\n return accountId; // Account is taken, return the account ID as \"owner\"\n } catch (err: any) {\n // UNKNOWN_ACCOUNT means it hasn't been created yet → available\n if (/UNKNOWN_ACCOUNT|does not exist while viewing/.test(err.message)) {\n return null;\n }\n // Re-throw any unexpected errors\n throw err;\n }\n },\n\n transfer(name: string, newOwner: string) {\n const normalizedName = name.toLowerCase().replace(/\\.near$/, \"\");\n\n if (!validateNearName(normalizedName)) {\n throw new USwapError(\"plugin_near_invalid_name\");\n }\n\n const wallet = getWallet(Chain.Near) as NearWallet;\n\n return wallet.callFunction({\n args: { name: normalizedName, new_owner: newOwner },\n contractId: \"near\",\n deposit: \"1\",\n methodName: \"transfer\",\n });\n },\n },\n async swap(swapParams: SwapParams<\"near\", QuoteResponseRoute>) {\n const {\n route: { buyAsset: buyAssetString, sellAsset: sellAssetString, inboundAddress, sellAmount, meta },\n } = swapParams;\n\n if (!(sellAssetString && buyAssetString && meta?.near?.sellAsset)) {\n throw new USwapError(\"core_swap_asset_not_recognized\");\n }\n\n if (!inboundAddress) {\n throw new USwapError(\"core_swap_invalid_params\", { missing: [\"inboundAddress\"] });\n }\n\n const sellAsset = await AssetValue.from({ asset: sellAssetString, value: sellAmount });\n\n const sellAssetChain = sellAsset.chain;\n\n const wallet = getWallet(sellAsset.chain as Exclude<Chain, typeof Chain.Radix>);\n\n if (sellAssetChain === Chain.Near && !sellAsset.isGasAsset) {\n const wallet = getWallet(sellAsset.chain as Chain.Near);\n if (!wallet) {\n throw new USwapError(\"core_wallet_connection_not_found\");\n }\n\n const unsignedTransaction = await wallet.createContractFunctionCall({\n args: {\n amount: sellAsset.getBaseValue(\"string\"),\n msg: JSON.stringify({ receiver_id: inboundAddress }),\n receiver_id: \"intents.near\",\n },\n attachedDeposit: \"1\",\n contractId: sellAsset.address as string,\n gas: \"250000000000000\",\n methodName: \"ft_transfer_call\",\n sender: wallet.address,\n });\n\n return wallet.signAndSendTransaction(unsignedTransaction);\n }\n\n if (!wallet) {\n throw new USwapError(\"core_wallet_connection_not_found\");\n }\n\n const tx = await wallet.transfer({\n assetValue: sellAsset,\n isProgramDerivedAddress: true,\n recipient: inboundAddress,\n sender: wallet.address,\n });\n\n return tx as string;\n },\n }),\n name: \"near\",\n properties: { supportedUSwapProviders: [ProviderName.NEAR] as const },\n});\n",
|
|
6
|
+
"import { parseNearAmount } from \"@near-js/utils\";\n\nconst MINIMUM_NAME_LENGTH = 2;\nconst MAXIMUM_NAME_LENGTH = 64;\n\nexport function validateNearName(name: string): boolean {\n if (name.length < MINIMUM_NAME_LENGTH || name.length > MAXIMUM_NAME_LENGTH) {\n return false;\n }\n\n // Only lowercase letters, numbers, and hyphens\n // Cannot start or end with hyphen\n // No consecutive hyphens\n return /^[a-z0-9]+(-[a-z0-9]+)*$/.test(name);\n}\n\nexport function calculateNearNameCost(name: string): string {\n // Pricing based on name length\n // These are suggested prices, the actual minimum is ~0.00182 NEAR\n const length = name.length;\n\n let costInNear: string;\n if (length <= 2) {\n costInNear = \"50\"; // 50 NEAR for 2-char names\n } else if (length <= 3) {\n costInNear = \"20\"; // 20 NEAR for 3-char names\n } else if (length <= 4) {\n costInNear = \"5\"; // 5 NEAR for 4-char names\n } else if (length <= 5) {\n costInNear = \"1\"; // 1 NEAR for 5-char names\n } else {\n costInNear = \"0.1\"; // 0.1 NEAR for 6+ characters\n }\n\n // Convert NEAR to yoctoNEAR\n return parseNearAmount(costInNear) || \"0\";\n}\n"
|
|
7
|
+
],
|
|
8
|
+
"mappings": "qDAI6E,IAA7E,6BCJgC,IAAhC,4BAEM,EAAsB,EACtB,EAAsB,GAErB,SAAS,CAAgB,CAAC,EAAuB,CACtD,GAAI,EAAK,OAAS,GAAuB,EAAK,OAAS,EACrD,MAAO,G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wapError as Q}from"@tcswap/helpers";import{parseNearAmount as G}from"@near-js/utils";var L=2,k=64;function $(J){if(J.length<L||J.length>k)return!1;return/^[a-z0-9]+(-[a-z0-9]+)*$/.test(J)}function V(J){let q=J.length,x;if(q<=2)x="50";else if(q<=3)x="20";else if(q<=4)x="5";else if(q<=5)x="1";else x="0.1";return G(x)||"0"}var z=X({methods:({getWallet:J})=>({nearNames:{async getInfo(q){let x=q.toLowerCase().replace(/\.near$/,"");if(!$(x))throw new Q("plugin_near_invalid_name");let D=`${x}.near`,B=J(Y.Near);if(!B)throw new Q("plugin_near_no_connection");try{let F=await B.provider.query({account_id:D,finality:"final",request_type:"view_account"}),Z=await B.provider.query({account_id:D,finality:"final",request_type:"view_access_key_list"});return{accountId:D,balance:F.amount,codeHash:F.code_hash,publicKeys:Z.keys?.map((K)=>K.public_key)||[],storageUsed:F.storage_usage}}catch(F){if(/UNKNOWN_ACCOUNT|does not exist while viewing/.test(F.message))return null;throw F}},async isAvailable(q){return await this.resolve(q)===null},async lookupNames(q){let x=J(Y.Near);if(!x)throw new Q("plugin_near_no_connection");try{if(await x.provider.query({account_id:q,finality:"final",request_type:"view_account"}),q.endsWith(".near"))return[q];return[]}catch{return[]}},async register(q){let{name:x,publicKey:D}=q,B=x.toLowerCase().replace(/\.near$/,"");if(!$(B))throw new Q("plugin_near_invalid_name");let F=J(Y.Near),Z=D||await F.getPublicKey(),K=V(B);return F.callFunction({args:{new_account_id:`${B}.near`,new_public_key:Z},contractId:"near",deposit:K,methodName:"create_account"})},async resolve(q){let x=q.toLowerCase().replace(/\.near$/,"");if(!$(x))throw new Q("plugin_near_invalid_name");let D=`${x}.near`,B=J(Y.Near);if(!B)throw new Q("plugin_near_no_connection");try{return await B.provider.query({account_id:D,finality:"final",request_type:"view_account"}),D}catch(F){if(/UNKNOWN_ACCOUNT|does not exist while viewing/.test(F.message))return null;throw F}},transfer(q,x){let D=q.toLowerCase().replace(/\.near$/,"");if(!$(D))throw new Q("plugin_near_invalid_name");return J(Y.Near).callFunction({args:{name:D,new_owner:x},contractId:"near",deposit:"1",methodName:"transfer"})}},async swap(q){let{route:{buyAsset:x,sellAsset:D,inboundAddress:B,sellAmount:F,meta:Z}}=q;if(!(D&&x&&Z?.near?.sellAsset))throw new Q("core_swap_asset_not_recognized");if(!B)throw new Q("core_swap_invalid_params",{missing:["inboundAddress"]});let K=await O.from({asset:D,value:F}),b=K.chain,H=J(K.chain);if(b===Y.Near&&!K.isGasAsset){let j=J(K.chain);if(!j)throw new Q("core_wallet_connection_not_found");let y=await j.createContractFunctionCall({args:{amount:K.getBaseValue("string"),msg:JSON.stringify({receiver_id:B}),receiver_id:"intents.near"},attachedDeposit:"1",contractId:K.address,gas:"250000000000000",methodName:"ft_transfer_call",sender:j.address});return j.signAndSendTransaction(y)}if(!H)throw new Q("core_wallet_connection_not_found");return await H.transfer({assetValue:K,isProgramDerivedAddress:!0,recipient:B,sender:H.address})}}),name:"near",properties:{supportedUSwapProviders:[P.NEAR]}});export{z as NearPlugin};
|
|
2
|
+
|
|
3
|
+
//# debugId=C2CE7E7659844A8D64756E2164756E21
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/near/plugin.ts", "../src/near/nearNames.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/**\n * Modifications © 2025 Horizontal Systems.\n */\n\nimport { AssetValue, Chain, ProviderName, type SwapParams, USwapError } from \"@tcswap/helpers\";\nimport type { QuoteResponseRoute } from \"@tcswap/helpers/api\";\nimport type { NearWallet } from \"@tcswap/toolboxes/near\";\nimport { createPlugin } from \"../utils\";\nimport { calculateNearNameCost, validateNearName } from \"./nearNames\";\nimport type { NearAccountInfo, NearNameRegistrationParams } from \"./types\";\n\nexport const NearPlugin = createPlugin({\n methods: ({ getWallet }) => ({\n nearNames: {\n async getInfo(name: string): Promise<NearAccountInfo | null> {\n const normalizedName = name.toLowerCase().replace(/\\.near$/, \"\");\n\n if (!validateNearName(normalizedName)) {\n throw new USwapError(\"plugin_near_invalid_name\");\n }\n\n const accountId = `${normalizedName}.near`;\n const wallet = getWallet(Chain.Near);\n\n if (!wallet) {\n throw new USwapError(\"plugin_near_no_connection\");\n }\n\n try {\n // Get account info\n const accountInfo = await wallet.provider.query({\n account_id: accountId,\n finality: \"final\",\n request_type: \"view_account\",\n });\n\n // Optionally get the account's public keys\n const keysInfo = await wallet.provider.query({\n account_id: accountId,\n finality: \"final\",\n request_type: \"view_access_key_list\",\n });\n\n return {\n accountId,\n balance: (accountInfo as any).amount,\n codeHash: (accountInfo as any).code_hash,\n publicKeys: (keysInfo as any).keys?.map((k: any) => k.public_key) || [],\n storageUsed: (accountInfo as any).storage_usage,\n };\n } catch (err: any) {\n if (/UNKNOWN_ACCOUNT|does not exist while viewing/.test(err.message)) {\n return null;\n }\n throw err;\n }\n },\n\n async isAvailable(name: string) {\n const owner = await this.resolve(name);\n return owner === null;\n },\n\n async lookupNames(accountId: string) {\n // NEAR doesn't have a central registry to look up all names owned by an account\n // This would require indexing or an external service\n // For now, we can only check if a specific account exists\n const wallet = getWallet(Chain.Near);\n\n if (!wallet) {\n throw new USwapError(\"plugin_near_no_connection\");\n }\n\n try {\n // Check if the account exists\n await wallet.provider.query({ account_id: accountId, finality: \"final\", request_type: \"view_account\" });\n\n // If the account ID ends with .near, it's a NEAR name\n if (accountId.endsWith(\".near\")) {\n return [accountId];\n }\n\n // Otherwise, we can't determine what names they own without an indexer\n return [];\n } catch {\n return [];\n }\n },\n\n async register(params: NearNameRegistrationParams) {\n const { name, publicKey: publicKeyOverwrite } = params;\n const normalizedName = name.toLowerCase().replace(/\\.near$/, \"\");\n\n if (!validateNearName(normalizedName)) {\n throw new USwapError(\"plugin_near_invalid_name\");\n }\n\n const wallet = getWallet(Chain.Near) as NearWallet;\n\n const newPublicKey = publicKeyOverwrite || (await wallet.getPublicKey());\n\n const cost = calculateNearNameCost(normalizedName);\n\n return wallet.callFunction({\n args: { new_account_id: `${normalizedName}.near`, new_public_key: newPublicKey },\n contractId: \"near\",\n deposit: cost,\n methodName: \"create_account\",\n });\n },\n async resolve(name: string) {\n const normalizedName = name.toLowerCase().replace(/\\.near$/, \"\");\n\n if (!validateNearName(normalizedName)) {\n throw new USwapError(\"plugin_near_invalid_name\");\n }\n\n const accountId = `${normalizedName}.near`;\n const wallet = getWallet(Chain.Near);\n\n if (!wallet) {\n throw new USwapError(\"plugin_near_no_connection\");\n }\n\n try {\n // Ask RPC whether the account exists\n await wallet.provider.query({ account_id: accountId, finality: \"final\", request_type: \"view_account\" });\n // If no error is thrown, the account exists\n return accountId; // Account is taken, return the account ID as \"owner\"\n } catch (err: any) {\n // UNKNOWN_ACCOUNT means it hasn't been created yet → available\n if (/UNKNOWN_ACCOUNT|does not exist while viewing/.test(err.message)) {\n return null;\n }\n // Re-throw any unexpected errors\n throw err;\n }\n },\n\n transfer(name: string, newOwner: string) {\n const normalizedName = name.toLowerCase().replace(/\\.near$/, \"\");\n\n if (!validateNearName(normalizedName)) {\n throw new USwapError(\"plugin_near_invalid_name\");\n }\n\n const wallet = getWallet(Chain.Near) as NearWallet;\n\n return wallet.callFunction({\n args: { name: normalizedName, new_owner: newOwner },\n contractId: \"near\",\n deposit: \"1\",\n methodName: \"transfer\",\n });\n },\n },\n async swap(swapParams: SwapParams<\"near\", QuoteResponseRoute>) {\n const {\n route: { buyAsset: buyAssetString, sellAsset: sellAssetString, inboundAddress, sellAmount, meta },\n } = swapParams;\n\n if (!(sellAssetString && buyAssetString && meta?.near?.sellAsset)) {\n throw new USwapError(\"core_swap_asset_not_recognized\");\n }\n\n if (!inboundAddress) {\n throw new USwapError(\"core_swap_invalid_params\", { missing: [\"inboundAddress\"] });\n }\n\n const sellAsset = await AssetValue.from({ asset: sellAssetString, value: sellAmount });\n\n const sellAssetChain = sellAsset.chain;\n\n const wallet = getWallet(sellAsset.chain as Exclude<Chain, typeof Chain.Radix>);\n\n if (sellAssetChain === Chain.Near && !sellAsset.isGasAsset) {\n const wallet = getWallet(sellAsset.chain as Chain.Near);\n if (!wallet) {\n throw new USwapError(\"core_wallet_connection_not_found\");\n }\n\n const unsignedTransaction = await wallet.createContractFunctionCall({\n args: {\n amount: sellAsset.getBaseValue(\"string\"),\n msg: JSON.stringify({ receiver_id: inboundAddress }),\n receiver_id: \"intents.near\",\n },\n attachedDeposit: \"1\",\n contractId: sellAsset.address as string,\n gas: \"250000000000000\",\n methodName: \"ft_transfer_call\",\n sender: wallet.address,\n });\n\n return wallet.signAndSendTransaction(unsignedTransaction);\n }\n\n if (!wallet) {\n throw new USwapError(\"core_wallet_connection_not_found\");\n }\n\n const tx = await wallet.transfer({\n assetValue: sellAsset,\n isProgramDerivedAddress: true,\n recipient: inboundAddress,\n sender: wallet.address,\n });\n\n return tx as string;\n },\n }),\n name: \"near\",\n properties: { supportedUSwapProviders: [ProviderName.NEAR] as const },\n});\n",
|
|
6
|
+
"import { parseNearAmount } from \"@near-js/utils\";\n\nconst MINIMUM_NAME_LENGTH = 2;\nconst MAXIMUM_NAME_LENGTH = 64;\n\nexport function validateNearName(name: string): boolean {\n if (name.length < MINIMUM_NAME_LENGTH || name.length > MAXIMUM_NAME_LENGTH) {\n return false;\n }\n\n // Only lowercase letters, numbers, and hyphens\n // Cannot start or end with hyphen\n // No consecutive hyphens\n return /^[a-z0-9]+(-[a-z0-9]+)*$/.test(name);\n}\n\nexport function calculateNearNameCost(name: string): string {\n // Pricing based on name length\n // These are suggested prices, the actual minimum is ~0.00182 NEAR\n const length = name.length;\n\n let costInNear: string;\n if (length <= 2) {\n costInNear = \"50\"; // 50 NEAR for 2-char names\n } else if (length <= 3) {\n costInNear = \"20\"; // 20 NEAR for 3-char names\n } else if (length <= 4) {\n costInNear = \"5\"; // 5 NEAR for 4-char names\n } else if (length <= 5) {\n costInNear = \"1\"; // 1 NEAR for 5-char names\n } else {\n costInNear = \"0.1\"; // 0.1 NEAR for 6+ characters\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AAO,OACjB,CAAC,EAIL,GACA,KAAM,OACN,WAAY,CAAE,wBAAyB,CAAC,EAAa,IAAI,CAAW,CACtE,CAAC",
|
|
9
|
+
"debugId": "C2CE7E7659844A8D64756E2164756E21",
|
|
10
|
+
"names": []
|
|
11
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var w={};m(w,{RadixPlugin:()=>u});module.exports=c(w);var a=require("@tcswap/helpers");var u=e({methods:({getWallet:o})=>({swap:async function({route:{tx:s,sellAmount:t,sellAsset:i}}){let r=await a.AssetValue.from({asset:i,asyncTokenLookup:!0,value:t});if(a.Chain.Radix!==r.chain)throw new a.USwapError("core_swap_invalid_params");let n=o(r.chain);try{return n.signAndBroadcast({manifest:s})}catch(p){throw new a.USwapError("core_swap_invalid_params",p)}}}),name:"radix",properties:{supportedUSwapProviders:[a.ProviderName.CAVIAR_V1]}});
|
|
2
|
+
|
|
3
|
+
//# debugId=64FEF4CDBFABF24E64756E2164756E21
|
|
4
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/radix/index.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/**\n * Modifications © 2025 Horizontal Systems.\n */\n\nimport { AssetValue, Chain, ProviderName, type SwapParams, USwapError } from \"@tcswap/helpers\";\nimport type { QuoteResponseRoute } from \"@tcswap/helpers/api\";\nimport { createPlugin } from \"../utils\";\n\nexport const RadixPlugin = createPlugin({\n methods: ({ getWallet }) => ({\n swap: async function radixSwap({ route: { tx, sellAmount, sellAsset } }: SwapParams<\"radix\", QuoteResponseRoute>) {\n const assetValue = await AssetValue.from({ asset: sellAsset, asyncTokenLookup: true, value: sellAmount });\n\n if (Chain.Radix !== assetValue.chain) {\n throw new USwapError(\"core_swap_invalid_params\");\n }\n\n const wallet = getWallet(assetValue.chain);\n try {\n return wallet.signAndBroadcast({ manifest: tx as string });\n } catch (error) {\n throw new USwapError(\"core_swap_invalid_params\", error);\n }\n },\n }),\n name: \"radix\",\n properties: { supportedUSwapProviders: [ProviderName.CAVIAR_V1] as const },\n});\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": "sDAI6E,IAA7E,6BAIO,IAAM,EAAc,EAAa,CACtC,QAAS,EAAG,gBAAiB,CAC3B,KAAM,cAAwB,EAAG,OAAS,KAAI,aAAY,cAAwD,CAChH,IAAM,EAAa,MAAM,aAAW,KAAK,CAAE,MAAO,EAAW,iBAAkB,GAAM,MAAO,CAAW,CAAC,EAExG,GAAI,QAAM,QAAU,EAAW,MAC7B,MAAM,IAAI,aAAW,0BAA0B,EAGjD,IAAM,EAAS,EAAU,EAAW,KAAK,EACzC,GAAI,CACF,OAAO,EAAO,iBAAiB,CAAE,SAAU,CAAa,CAAC,EACzD,MAAO,EAAO,CACd,MAAM,IAAI,aAAW,2BAA4B,CAAK,GAG5D,GACA,KAAM,QACN,WAAY,CAAE,wBAAyB,CAAC,eAAa,SAAS,CAAW,CAC3E,CAAC",
|
|
8
|
+
"debugId": "64FEF4CDBFABF24E64756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{c as e}from"../chunk-vzvcxw96.js";import{AssetValue as c,Chain as m,ProviderName as u,USwapError as r}from"@tcswap/helpers";var f=e({methods:({getWallet:o})=>({swap:async function({route:{tx:s,sellAmount:t,sellAsset:i}}){let a=await c.from({asset:i,asyncTokenLookup:!0,value:t});if(m.Radix!==a.chain)throw new r("core_swap_invalid_params");let n=o(a.chain);try{return n.signAndBroadcast({manifest:s})}catch(p){throw new r("core_swap_invalid_params",p)}}}),name:"radix",properties:{supportedUSwapProviders:[u.CAVIAR_V1]}});export{f as RadixPlugin};
|
|
2
|
+
|
|
3
|
+
//# debugId=2888197BCB4382B664756E2164756E21
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/radix/index.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/**\n * Modifications © 2025 Horizontal Systems.\n */\n\nimport { AssetValue, Chain, ProviderName, type SwapParams, USwapError } from \"@tcswap/helpers\";\nimport type { QuoteResponseRoute } from \"@tcswap/helpers/api\";\nimport { createPlugin } from \"../utils\";\n\nexport const RadixPlugin = createPlugin({\n methods: ({ getWallet }) => ({\n swap: async function radixSwap({ route: { tx, sellAmount, sellAsset } }: SwapParams<\"radix\", QuoteResponseRoute>) {\n const assetValue = await AssetValue.from({ asset: sellAsset, asyncTokenLookup: true, value: sellAmount });\n\n if (Chain.Radix !== assetValue.chain) {\n throw new USwapError(\"core_swap_invalid_params\");\n }\n\n const wallet = getWallet(assetValue.chain);\n try {\n return wallet.signAndBroadcast({ manifest: tx as string });\n } catch (error) {\n throw new USwapError(\"core_swap_invalid_params\", error);\n }\n },\n }),\n name: \"radix\",\n properties: { supportedUSwapProviders: [ProviderName.CAVIAR_V1] as const },\n});\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": "yCAIA,qBAAS,WAAY,kBAAO,gBAA+B,wBAIpD,IAAM,EAAc,EAAa,CACtC,QAAS,EAAG,gBAAiB,CAC3B,KAAM,cAAwB,EAAG,OAAS,KAAI,aAAY,cAAwD,CAChH,IAAM,EAAa,MAAM,EAAW,KAAK,CAAE,MAAO,EAAW,iBAAkB,GAAM,MAAO,CAAW,CAAC,EAExG,GAAI,EAAM,QAAU,EAAW,MAC7B,MAAM,IAAI,EAAW,0BAA0B,EAGjD,IAAM,EAAS,EAAU,EAAW,KAAK,EACzC,GAAI,CACF,OAAO,EAAO,iBAAiB,CAAE,SAAU,CAAa,CAAC,EACzD,MAAO,EAAO,CACd,MAAM,IAAI,EAAW,2BAA4B,CAAK,GAG5D,GACA,KAAM,QACN,WAAY,CAAE,wBAAyB,CAAC,EAAa,SAAS,CAAW,CAC3E,CAAC",
|
|
8
|
+
"debugId": "2888197BCB4382B664756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var d={};f(d,{SolanaPlugin:()=>n});module.exports=w(d);var a=require("@tcswap/helpers");var n=e({methods:({getWallet:r})=>({swap:async function({route:i}){let{VersionedTransaction:p}=await import("@solana/web3.js"),{tx:s,sellAsset:c}=i,o=(await a.AssetValue.from({asset:c})).chain;if(!(o===a.Chain.Solana&&s))throw new a.USwapError("core_swap_invalid_params");let t=r(o),l=p.deserialize(Buffer.from(s,"base64")),m=await t.signTransaction(l);return t.broadcastTransaction(m)}}),name:"solana",properties:{supportedUSwapProviders:[a.ProviderName.JUPITER]}});
|
|
2
|
+
|
|
3
|
+
//# debugId=E8D3F6CF6293E82564756E2164756E21
|
|
4
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/solana/plugin.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/**\n * Modifications © 2025 Horizontal Systems.\n */\n\nimport { AssetValue, Chain, ProviderName, type SwapParams, USwapError } from \"@tcswap/helpers\";\nimport type { QuoteResponseRoute } from \"@tcswap/helpers/api\";\nimport { createPlugin } from \"../utils\";\n\nexport const SolanaPlugin = createPlugin({\n methods: ({ getWallet }) => ({\n swap: async function solanaSwap({ route }: SwapParams<\"solana\", QuoteResponseRoute>) {\n const { VersionedTransaction } = await import(\"@solana/web3.js\");\n const { tx, sellAsset } = route;\n\n const assetValue = await AssetValue.from({ asset: sellAsset });\n\n const chain = assetValue.chain;\n if (!(chain === Chain.Solana && tx)) throw new USwapError(\"core_swap_invalid_params\");\n\n const wallet = getWallet(chain);\n const transaction = VersionedTransaction.deserialize(Buffer.from(tx as string, \"base64\"));\n\n const signedTransaction = await wallet.signTransaction(transaction);\n\n return wallet.broadcastTransaction(signedTransaction);\n },\n }),\n name: \"solana\",\n properties: { supportedUSwapProviders: [ProviderName.JUPITER] as const },\n});\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": "uDAI6E,IAA7E,6BAIO,IAAM,EAAe,EAAa,CACvC,QAAS,EAAG,gBAAiB,CAC3B,KAAM,cAAyB,EAAG,SAAmD,CACnF,IAAQ,wBAAyB,KAAa,4BACtC,KAAI,aAAc,EAIpB,GAFa,MAAM,aAAW,KAAK,CAAE,MAAO,CAAU,CAAC,GAEpC,MACzB,GAAI,EAAE,IAAU,QAAM,QAAU,GAAK,MAAM,IAAI,aAAW,0BAA0B,EAEpF,IAAM,EAAS,EAAU,CAAK,EACxB,EAAc,EAAqB,YAAY,OAAO,KAAK,EAAc,QAAQ,CAAC,EAElF,EAAoB,MAAM,EAAO,gBAAgB,CAAW,EAElE,OAAO,EAAO,qBAAqB,CAAiB,EAExD,GACA,KAAM,SACN,WAAY,CAAE,wBAAyB,CAAC,eAAa,OAAO,CAAW,CACzE,CAAC",
|
|
8
|
+
"debugId": "E8D3F6CF6293E82564756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{a as l,b as m,c as t}from"../chunk-vzvcxw96.js";import{AssetValue as u,Chain as w,ProviderName as f,USwapError as d}from"@tcswap/helpers";var S=t({methods:({getWallet:e})=>({swap:async function({route:n}){let{VersionedTransaction:r}=await import("@solana/web3.js"),{tx:a,sellAsset:i}=n,s=(await u.from({asset:i})).chain;if(!(s===w.Solana&&a))throw new d("core_swap_invalid_params");let o=e(s),p=r.deserialize(Buffer.from(a,"base64")),c=await o.signTransaction(p);return o.broadcastTransaction(c)}}),name:"solana",properties:{supportedUSwapProviders:[f.JUPITER]}});export{S as SolanaPlugin};
|
|
2
|
+
|
|
3
|
+
//# debugId=96F3A980D334120964756E2164756E21
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/solana/plugin.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/**\n * Modifications © 2025 Horizontal Systems.\n */\n\nimport { AssetValue, Chain, ProviderName, type SwapParams, USwapError } from \"@tcswap/helpers\";\nimport type { QuoteResponseRoute } from \"@tcswap/helpers/api\";\nimport { createPlugin } from \"../utils\";\n\nexport const SolanaPlugin = createPlugin({\n methods: ({ getWallet }) => ({\n swap: async function solanaSwap({ route }: SwapParams<\"solana\", QuoteResponseRoute>) {\n const { VersionedTransaction } = await import(\"@solana/web3.js\");\n const { tx, sellAsset } = route;\n\n const assetValue = await AssetValue.from({ asset: sellAsset });\n\n const chain = assetValue.chain;\n if (!(chain === Chain.Solana && tx)) throw new USwapError(\"core_swap_invalid_params\");\n\n const wallet = getWallet(chain);\n const transaction = VersionedTransaction.deserialize(Buffer.from(tx as string, \"base64\"));\n\n const signedTransaction = await wallet.signTransaction(transaction);\n\n return wallet.broadcastTransaction(signedTransaction);\n },\n }),\n name: \"solana\",\n properties: { supportedUSwapProviders: [ProviderName.JUPITER] as const },\n});\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": "uDAIA,qBAAS,WAAY,kBAAO,gBAA+B,wBAIpD,IAAM,EAAe,EAAa,CACvC,QAAS,EAAG,gBAAiB,CAC3B,KAAM,cAAyB,EAAG,SAAmD,CACnF,IAAQ,wBAAyB,KAAa,4BACtC,KAAI,aAAc,EAIpB,GAFa,MAAM,EAAW,KAAK,CAAE,MAAO,CAAU,CAAC,GAEpC,MACzB,GAAI,EAAE,IAAU,EAAM,QAAU,GAAK,MAAM,IAAI,EAAW,0BAA0B,EAEpF,IAAM,EAAS,EAAU,CAAK,EACxB,EAAc,EAAqB,YAAY,OAAO,KAAK,EAAc,QAAQ,CAAC,EAElF,EAAoB,MAAM,EAAO,gBAAgB,CAAW,EAElE,OAAO,EAAO,qBAAqB,CAAiB,EAExD,GACA,KAAM,SACN,WAAY,CAAE,wBAAyB,CAAC,EAAa,OAAO,CAAW,CACzE,CAAC",
|
|
8
|
+
"debugId": "96F3A980D334120964756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var zx={};qx(zx,{validateAddressType:()=>v,ThorchainPlugin:()=>y,MayachainPlugin:()=>w});module.exports=xx(zx);var x=require("@tcswap/helpers"),S=require("@tcswap/helpers/api"),Z=require("@tcswap/helpers/contracts");var T=require("@tcswap/helpers");function v({chain:R,address:O}){if(!O)return!1;return R===T.Chain.Bitcoin?!O.startsWith("bc1p"):!0}function b({assetValue:R,from:O,memo:X="",...P}){return{...P,assetValue:R,from:O,memo:X}}var t={[x.FeeOption.Average]:1.2,[x.FeeOption.Fast]:1.5,[x.FeeOption.Fastest]:2},s={[x.Chain.Avalanche]:Z.TCAvalancheDepositABI,[x.Chain.Base]:Z.TCBaseDepositABI,[x.Chain.BinanceSmartChain]:Z.TCBscDepositABI,[x.Chain.Ethereum]:Z.TCEthereumVaultAbi},a={[x.Chain.Arbitrum]:Z.MayaArbitrumVaultAbi,[x.Chain.Ethereum]:Z.MayaEthereumVaultAbi},y=M({methods:C(x.Chain.THORChain),name:"thorchain",properties:{supportedUSwapProviders:[x.ProviderName.THORCHAIN,x.ProviderName.THORCHAIN_STREAMING]}}),w=M({methods:C(x.Chain.Maya),name:"mayachain",properties:{supportedUSwapProviders:[x.ProviderName.MAYACHAIN,x.ProviderName.MAYACHAIN_STREAMING]}});function e(R){return async function(X){if(R==="thorchain"&&X===x.Chain.THORChain||R==="mayachain"&&X===x.Chain.Maya)return{address:"",chain:X,dust_threshold:"0",gas_rate:"0",halted:!1,router:""};let $=(await S.USwapApi.thornode.getInboundAddresses(R)).find((F)=>F.chain===X);if(!$)throw new x.USwapError("core_inbound_data_not_found");if($?.halted)throw new x.USwapError("core_chain_halted");return $}}function C(R){return function({getWallet:X}){let P=R===x.Chain.Maya?"mayachain":"thorchain",$=e(P);async function F({assetValue:q,type:z="checkOnly"}){let H=(await $(q.chain)).router,J=q.chain,Q=x.EVMChains.includes(J);if(Q&&q.isGasAsset||!Q||q.isSynthetic)return Promise.resolve(z==="checkOnly"?!0:"approved");let Y=X(J);if(!Y)throw new x.USwapError("core_wallet_connection_not_found");let j=z==="checkOnly"?Y.isApproved:Y.approve;if(!(q.address&&Y.address))throw new x.USwapError("core_approve_asset_address_or_from_not_found");return j({amount:q.getBaseValue("bigint"),assetAddress:q.address,from:Y.address,spenderAddress:H})}async function k({assetValue:q,recipient:z,router:H,...J}){let Q=P==="thorchain"?s:a,{chain:L,symbol:Y,ticker:j}=q,I=X(L);if(!I)throw new x.USwapError("core_wallet_connection_not_found");let{address:f}=I;if(!v({address:f,chain:L}))throw new x.USwapError("core_transaction_invalid_sender_address");let N=b({assetValue:q,from:f,recipient:z,router:H,...J});try{let G=Q?.[L];if(!G){let B=X(L);return R===L&&z===""?B.deposit(N):B.transfer(N)}let{getChecksumAddressFromAsset:_}=await import("@tcswap/toolboxes/evm");return X(L).call({abi:G,contractAddress:H||(await $(L)).router,funcName:"depositWithExpiry",funcParams:[z,_({chain:L,symbol:Y,ticker:j},L),q.getBaseValue("string"),N.memo,J.expiration||Number.parseInt(`${(Date.now()+900000)/1000}`,10)],txOverrides:{from:N.from,value:q.isGasAsset?q.getBaseValue("bigint"):void 0}})}catch(G){let _=typeof G==="string"?G.toLowerCase():G?.message.toLowerCase(),U=_?.includes("insufficient funds"),B=_?.includes("gas"),W=_?.includes("server"),i=_?.includes("user rejected");throw new x.USwapError(U?"core_transaction_deposit_insufficient_funds_error":B?"core_transaction_deposit_gas_error":W?"core_transaction_deposit_server_error":i?"core_transaction_user_rejected":"core_transaction_deposit_error",G)}}async function D({memo:q,assetValue:z}){let H=await S.USwapApi.thornode.getMimirInfo(P);if(H.HALTCHAINGLOBAL>=1||H.HALTTHORCHAIN>=1)throw new x.USwapError("thorchain_chain_halted");return k({assetValue:z,memo:q,recipient:""})}async function K({assetValue:q,memo:z,feeOptionKey:H=x.FeeOption.Fast}){let{gas_rate:J="0",router:Q,address:L}=await $(q.chain);return k({assetValue:q,feeRate:Number.parseInt(J,10)*t[H],memo:z,recipient:L,router:Q})}function A({assetValue:q}){return F({assetValue:q,type:x.ApproveMode.Approve})}function g({assetValue:q}){return F({assetValue:q,type:x.ApproveMode.CheckOnly})}function m({assetValue:q,...z}){return D({assetValue:q,memo:x.getMemoForNameRegister(z)})}function c({assetValue:q,payoutAddress:z,name:H,ownerAddress:J}){let Q=z||X(q.chain)?.address;if(!Q)throw new x.USwapError("thorchain_preferred_asset_payout_required");return D({assetValue:x.AssetValue.from({chain:R}),memo:x.getMemoForNamePreferredAssetRegister({asset:q.toString(),chain:q.chain,name:H,owner:J,payout:Q})})}function h({type:q,assetValue:z,address:H}){let J=q===x.MemoType.UNBOND?x.getMemoForUnbond({address:H,unbondAmount:z.getBaseValue("number")}):x.getMemoForLeaveAndBond({address:H,type:q}),Q=q===x.MemoType.BOND?z:x.getMinAmountByChain(R);return D({assetValue:Q,memo:J})}async function V({baseAssetValue:q,assetValue:z}){if(q.lte(0)||z.lte(0))throw new x.USwapError("core_transaction_create_liquidity_invalid_params");let H=X(z.chain).address,J=X(R).address,Q=await x.wrapWithThrow(()=>{return K({assetValue:q,memo:x.getMemoForDeposit({...z,address:H})})},"core_transaction_create_liquidity_base_error");return{assetTx:await x.wrapWithThrow(()=>{return K({assetValue:z,memo:x.getMemoForDeposit({...z,address:J})})},"core_transaction_create_liquidity_asset_error"),baseAssetTx:Q}}function p({assetValue:q,poolAddress:z,address:H,symmetric:J}){if(J&&!H)throw new x.USwapError("core_transaction_add_liquidity_invalid_params");let Q=x.getMemoForDeposit({address:J?H:"",chain:z.split(".")[0],symbol:z.split(".")[1]});return K({assetValue:q,memo:Q})}async function d({baseAssetValue:q,assetValue:z,baseAssetAddr:H,assetAddr:J,isPendingSymmAsset:Q,mode:L="sym"}){let{chain:Y,symbol:j}=z,I=L==="sym",f=q?.gt(0)&&(I||L==="baseAsset"),E=z?.gt(0)&&(I||L==="asset"),N=Q||f,G=X(R).address,_=N?H||G:"",U=I||L==="asset"?J||X(Y).address:"";if(!(f||E))throw new x.USwapError("core_transaction_add_liquidity_invalid_params");if(N&&!_)throw new x.USwapError("core_transaction_add_liquidity_base_address");let B=f&&q?await x.wrapWithThrow(()=>{return K({assetValue:q,memo:x.getMemoForDeposit({address:U,chain:Y,symbol:j})})},"core_transaction_add_liquidity_base_error"):void 0;return{assetTx:E&&z?await x.wrapWithThrow(()=>{return K({assetValue:z,memo:x.getMemoForDeposit({address:_,chain:Y,symbol:j})})},"core_transaction_add_liquidity_asset_error"):void 0,baseAssetTx:B}}function n({memo:q,assetValue:z,percent:H,from:J,to:Q}){let L=Q==="baseAsset"&&J!=="baseAsset"?x.AssetValue.from({chain:R}):J==="sym"&&Q==="sym"||J==="baseAsset"||J==="asset"?void 0:z,Y=x.getMinAmountByChain(J==="asset"?z.chain:R),j=q||x.getMemoForWithdraw({basisPoints:Math.min(1e4,Math.round(H*100)),chain:z.chain,symbol:z.symbol,targetAsset:L?.toString(),ticker:z.ticker});return K({assetValue:Y,memo:j})}async function u({chain:q,thorAddress:z}){let H=await $(q),J=H.dust_threshold,{baseDecimal:Q}=x.getChainConfig(q),{baseDecimal:L}=x.getChainConfig(x.Chain.THORChain);return k({assetValue:x.AssetValue.from({chain:q,fromBaseDecimal:Math.min(Q,L),value:q!==x.Chain.THORChain?J:0}),memo:x.getMemoForTcyClaim(x.MemoType.CLAIM_TCY,{address:z}),recipient:H.address,router:H.router})}function r(q){if(q.type==="stake"){if(q.assetValue.toString()!=="THOR.TCY")throw new x.USwapError("thorchain_asset_is_not_tcy");return k({assetValue:q.assetValue,memo:x.getMemoForTcyStake(x.MemoType.STAKE_TCY,{}),recipient:""})}return k({assetValue:x.AssetValue.from({chain:x.Chain.THORChain}),memo:x.getMemoForTcyStake(x.MemoType.UNSTAKE_TCY,{unstakeBps:q.unstakeBps}),recipient:""})}async function o({feeOptionKey:q,route:z}){let{memo:H,expiration:J,targetAddress:Q}=z,L=await x.AssetValue.from({asset:z.sellAsset,asyncTokenLookup:!0,value:z.sellAmount});if(!L)throw new x.USwapError("core_swap_asset_not_recognized");if(!v({address:z.destinationAddress,chain:x.AssetValue.from({asset:z.buyAsset}).chain}))throw new x.USwapError("core_transaction_invalid_recipient_address");let{address:j}=await $(L.chain);return k({assetValue:L,expiration:Number(J),feeOptionKey:q,memo:H,recipient:j,router:Q})}return{addLiquidity:d,addLiquidityPart:p,approveAssetValue:A,claimTcy:u,createLiquidity:V,deposit:k,depositToPool:K,getInboundDataByChain:$,isAssetValueApproved:g,nodeAction:h,registerName:m,registerPreferredAsset:c,stakeTcyAction:r,swap:o,withdraw:n}}}
|
|
2
|
+
|
|
3
|
+
//# debugId=C4AEAE79BA0C04FC64756E2164756E21
|
|
4
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/thorchain/plugin.ts", "../src/thorchain/shared.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/**\n * Modifications © 2025 Horizontal Systems.\n */\n\nimport {\n ApproveMode,\n type ApproveReturnType,\n AssetValue,\n Chain,\n type ErrorKeys,\n type EVMChain,\n EVMChains,\n FeeOption,\n getChainConfig,\n getMemoForDeposit,\n getMemoForLeaveAndBond,\n getMemoForNamePreferredAssetRegister,\n getMemoForNameRegister,\n getMemoForTcyClaim,\n getMemoForTcyStake,\n getMemoForUnbond,\n getMemoForWithdraw,\n getMinAmountByChain,\n MemoType,\n ProviderName,\n type SwapParams,\n type TCLikeChain,\n USwapError,\n wrapWithThrow,\n} from \"@tcswap/helpers\";\nimport { type InboundAddressesItem, type QuoteResponseRoute, type THORNodeType, USwapApi } from \"@tcswap/helpers/api\";\nimport {\n MayaArbitrumVaultAbi,\n MayaEthereumVaultAbi,\n TCAvalancheDepositABI,\n TCBaseDepositABI,\n TCBscDepositABI,\n TCEthereumVaultAbi,\n} from \"@tcswap/helpers/contracts\";\nimport type { SwapKitPluginParams } from \"../types\";\nimport { createPlugin } from \"../utils\";\nimport { prepareTxParams, validateAddressType } from \"./shared\";\nimport type {\n AddLiquidityParams,\n AddLiquidityPartParams,\n CoreTxParams,\n CreateLiquidityParams,\n NodeActionParams,\n RegisterThornameParams,\n WithdrawParams,\n} from \"./types\";\n\nconst gasFeeMultiplier: Record<FeeOption, number> = {\n [FeeOption.Average]: 1.2,\n [FeeOption.Fast]: 1.5,\n [FeeOption.Fastest]: 2,\n};\n\nconst TCSpecificAbi = {\n [Chain.Avalanche]: TCAvalancheDepositABI,\n [Chain.Base]: TCBaseDepositABI,\n [Chain.BinanceSmartChain]: TCBscDepositABI,\n [Chain.Ethereum]: TCEthereumVaultAbi,\n};\n\nconst MayaSpecificAbi = { [Chain.Arbitrum]: MayaArbitrumVaultAbi, [Chain.Ethereum]: MayaEthereumVaultAbi };\n\nexport const ThorchainPlugin = createPlugin({\n methods: createTCBasedPlugin(Chain.THORChain),\n name: \"thorchain\",\n properties: { supportedUSwapProviders: [ProviderName.THORCHAIN, ProviderName.THORCHAIN_STREAMING] as const },\n});\n\nexport const MayachainPlugin = createPlugin({\n methods: createTCBasedPlugin(Chain.Maya),\n name: \"mayachain\",\n properties: { supportedUSwapProviders: [ProviderName.MAYACHAIN, ProviderName.MAYACHAIN_STREAMING] as const },\n});\n\nfunction getInboundDataFunction(type?: THORNodeType) {\n return async function getInboundDataByChain<T extends Chain>(chain: T) {\n if ((type === \"thorchain\" && chain === Chain.THORChain) || (type === \"mayachain\" && chain === Chain.Maya)) {\n return {\n address: \"\",\n chain,\n dust_threshold: \"0\",\n gas_rate: \"0\",\n halted: false,\n router: \"\",\n } as InboundAddressesItem;\n }\n\n const inboundData = await USwapApi.thornode.getInboundAddresses(type);\n const chainAddressData = inboundData.find((item) => item.chain === chain);\n\n if (!chainAddressData) throw new USwapError(\"core_inbound_data_not_found\");\n if (chainAddressData?.halted) throw new USwapError(\"core_chain_halted\");\n\n return chainAddressData;\n };\n}\n\nfunction createTCBasedPlugin<T extends TCLikeChain>(pluginChain: T) {\n return function plugin({ getWallet }: SwapKitPluginParams) {\n const pluginType = pluginChain === Chain.Maya ? \"mayachain\" : \"thorchain\";\n const getInboundDataByChain = getInboundDataFunction(pluginType);\n\n async function approve<T extends ApproveMode>({\n assetValue,\n type = \"checkOnly\" as T,\n }: {\n type: T;\n assetValue: AssetValue;\n }) {\n const router = (await getInboundDataByChain(assetValue.chain)).router as string;\n\n const chain = assetValue.chain as EVMChain;\n\n const isEVMChain = EVMChains.includes(chain as EVMChain);\n const isNativeEVM = isEVMChain && assetValue.isGasAsset;\n\n if (isNativeEVM || !isEVMChain || assetValue.isSynthetic) {\n return Promise.resolve(type === \"checkOnly\" ? true : \"approved\") as ApproveReturnType<T>;\n }\n\n const wallet = getWallet(chain);\n\n if (!wallet) {\n throw new USwapError(\"core_wallet_connection_not_found\");\n }\n\n const walletAction = type === \"checkOnly\" ? wallet.isApproved : wallet.approve;\n\n if (!(assetValue.address && wallet.address)) {\n throw new USwapError(\"core_approve_asset_address_or_from_not_found\");\n }\n\n return walletAction({\n amount: assetValue.getBaseValue(\"bigint\"),\n assetAddress: assetValue.address,\n from: wallet.address,\n spenderAddress: router,\n });\n }\n\n // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: TODO\n async function deposit({ assetValue, recipient, router, ...rest }: CoreTxParams & { router?: string }) {\n const abis = pluginType === \"thorchain\" ? TCSpecificAbi : MayaSpecificAbi;\n const { chain, symbol, ticker } = assetValue;\n\n const wallet = getWallet(chain);\n if (!wallet) {\n throw new USwapError(\"core_wallet_connection_not_found\");\n }\n const { address } = wallet;\n const isAddressValidated = validateAddressType({ address, chain });\n if (!isAddressValidated) {\n throw new USwapError(\"core_transaction_invalid_sender_address\");\n }\n\n const params = prepareTxParams({ assetValue, from: address, recipient, router, ...rest });\n\n try {\n const abi = abis?.[chain as keyof typeof abis];\n\n if (!abi) {\n const wallet = getWallet(chain as TCLikeChain);\n const shouldDeposit = pluginChain === chain && recipient === \"\";\n // @Towan: Is that the same action? :)\n return shouldDeposit ? wallet.deposit(params) : wallet.transfer(params);\n }\n\n const { getChecksumAddressFromAsset } = await import(\"@tcswap/toolboxes/evm\");\n const wallet = getWallet(chain as EVMChain);\n\n return wallet.call<string>({\n abi,\n contractAddress: router || ((await getInboundDataByChain(chain)).router as string),\n funcName: \"depositWithExpiry\",\n funcParams: [\n recipient,\n getChecksumAddressFromAsset({ chain, symbol, ticker }, chain as EVMChain),\n assetValue.getBaseValue(\"string\"),\n params.memo,\n rest.expiration || Number.parseInt(`${(Date.now() + 15 * 60 * 1000) / 1000}`, 10),\n ],\n txOverrides: {\n from: params.from,\n value: assetValue.isGasAsset ? assetValue.getBaseValue(\"bigint\") : undefined,\n },\n });\n } catch (error) {\n const errorMessage =\n // @ts-expect-error Fine to use error as string\n typeof error === \"string\" ? error.toLowerCase() : error?.message.toLowerCase();\n const isInsufficientFunds = errorMessage?.includes(\"insufficient funds\");\n const isGas = errorMessage?.includes(\"gas\");\n const isServer = errorMessage?.includes(\"server\");\n const isUserRejected = errorMessage?.includes(\"user rejected\");\n const errorKey: ErrorKeys = isInsufficientFunds\n ? \"core_transaction_deposit_insufficient_funds_error\"\n : isGas\n ? \"core_transaction_deposit_gas_error\"\n : isServer\n ? \"core_transaction_deposit_server_error\"\n : isUserRejected\n ? \"core_transaction_user_rejected\"\n : \"core_transaction_deposit_error\";\n\n throw new USwapError(errorKey, error);\n }\n }\n\n async function depositToProtocol({ memo, assetValue }: { assetValue: AssetValue; memo: string }) {\n const mimir = await USwapApi.thornode.getMimirInfo(pluginType);\n\n // check if trading is halted or not\n if (mimir.HALTCHAINGLOBAL >= 1 || mimir.HALTTHORCHAIN >= 1) {\n throw new USwapError(\"thorchain_chain_halted\");\n }\n\n return deposit({ assetValue, memo, recipient: \"\" });\n }\n\n async function depositToPool({\n assetValue,\n memo,\n feeOptionKey = FeeOption.Fast,\n }: {\n assetValue: AssetValue;\n memo: string;\n feeOptionKey?: FeeOption;\n }) {\n const { gas_rate = \"0\", router, address: poolAddress } = await getInboundDataByChain(assetValue.chain);\n\n return deposit({\n assetValue,\n feeRate: Number.parseInt(gas_rate, 10) * gasFeeMultiplier[feeOptionKey],\n memo,\n recipient: poolAddress,\n router,\n });\n }\n\n function approveAssetValue({ assetValue }: { assetValue: AssetValue }) {\n return approve({ assetValue, type: ApproveMode.Approve });\n }\n\n function isAssetValueApproved({ assetValue }: { assetValue: AssetValue }) {\n return approve({ assetValue, type: ApproveMode.CheckOnly });\n }\n\n function registerName({ assetValue, ...params }: RegisterThornameParams) {\n return depositToProtocol({ assetValue, memo: getMemoForNameRegister(params) });\n }\n\n function registerPreferredAsset({\n assetValue,\n payoutAddress,\n name,\n ownerAddress,\n }: {\n assetValue: AssetValue;\n payoutAddress?: string;\n name: string;\n ownerAddress: string;\n }) {\n const payout = payoutAddress || getWallet(assetValue.chain)?.address;\n\n if (!payout) {\n throw new USwapError(\"thorchain_preferred_asset_payout_required\");\n }\n\n return depositToProtocol({\n assetValue: AssetValue.from({ chain: pluginChain }),\n memo: getMemoForNamePreferredAssetRegister({\n asset: assetValue.toString(),\n chain: assetValue.chain,\n name,\n owner: ownerAddress,\n payout,\n }),\n });\n }\n\n function nodeAction({ type, assetValue, address }: NodeActionParams) {\n const memo =\n type === MemoType.UNBOND\n ? getMemoForUnbond({ address, unbondAmount: assetValue.getBaseValue(\"number\") })\n : getMemoForLeaveAndBond({ address, type });\n\n const assetToTransfer = type === MemoType.BOND ? assetValue : getMinAmountByChain(pluginChain);\n return depositToProtocol({ assetValue: assetToTransfer, memo });\n }\n\n async function createLiquidity({ baseAssetValue, assetValue }: CreateLiquidityParams) {\n if (baseAssetValue.lte(0) || assetValue.lte(0)) {\n throw new USwapError(\"core_transaction_create_liquidity_invalid_params\");\n }\n\n const assetAddress = getWallet(assetValue.chain).address;\n const baseAssetAddress = getWallet(pluginChain).address;\n\n const baseAssetTx = await wrapWithThrow(() => {\n return depositToPool({\n assetValue: baseAssetValue,\n memo: getMemoForDeposit({ ...assetValue, address: assetAddress }),\n });\n }, \"core_transaction_create_liquidity_base_error\");\n\n const assetTx = await wrapWithThrow(() => {\n return depositToPool({ assetValue, memo: getMemoForDeposit({ ...assetValue, address: baseAssetAddress }) });\n }, \"core_transaction_create_liquidity_asset_error\");\n\n return { assetTx, baseAssetTx };\n }\n\n function addLiquidityPart({ assetValue, poolAddress, address, symmetric }: AddLiquidityPartParams) {\n if (symmetric && !address) {\n throw new USwapError(\"core_transaction_add_liquidity_invalid_params\");\n }\n const memo = getMemoForDeposit({\n address: symmetric ? address : \"\",\n chain: poolAddress.split(\".\")[0] as Chain,\n symbol: poolAddress.split(\".\")[1] as string,\n });\n\n return depositToPool({ assetValue, memo });\n }\n\n // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: TODO\n async function addLiquidity({\n baseAssetValue,\n assetValue,\n baseAssetAddr,\n assetAddr,\n isPendingSymmAsset,\n mode = \"sym\",\n }: AddLiquidityParams) {\n const { chain, symbol } = assetValue;\n const isSym = mode === \"sym\";\n const baseTransfer = baseAssetValue?.gt(0) && (isSym || mode === \"baseAsset\");\n const assetTransfer = assetValue?.gt(0) && (isSym || mode === \"asset\");\n const includeBaseAddress = isPendingSymmAsset || baseTransfer;\n const baseAssetWalletAddress = getWallet(pluginChain).address;\n\n const baseAddress = includeBaseAddress ? baseAssetAddr || baseAssetWalletAddress : \"\";\n const assetAddress = isSym || mode === \"asset\" ? assetAddr || getWallet(chain).address : \"\";\n\n if (!(baseTransfer || assetTransfer)) {\n throw new USwapError(\"core_transaction_add_liquidity_invalid_params\");\n }\n if (includeBaseAddress && !baseAddress) {\n throw new USwapError(\"core_transaction_add_liquidity_base_address\");\n }\n\n const baseAssetTx =\n baseTransfer && baseAssetValue\n ? await wrapWithThrow(() => {\n return depositToPool({\n assetValue: baseAssetValue,\n memo: getMemoForDeposit({ address: assetAddress, chain, symbol }),\n });\n }, \"core_transaction_add_liquidity_base_error\")\n : undefined;\n\n const assetTx =\n assetTransfer && assetValue\n ? await wrapWithThrow(() => {\n return depositToPool({ assetValue, memo: getMemoForDeposit({ address: baseAddress, chain, symbol }) });\n }, \"core_transaction_add_liquidity_asset_error\")\n : undefined;\n\n return { assetTx, baseAssetTx };\n }\n\n function withdraw({ memo, assetValue, percent, from, to }: WithdrawParams) {\n const targetAsset =\n to === \"baseAsset\" && from !== \"baseAsset\"\n ? AssetValue.from({ chain: pluginChain })\n : (from === \"sym\" && to === \"sym\") || from === \"baseAsset\" || from === \"asset\"\n ? undefined\n : assetValue;\n\n const value = getMinAmountByChain(from === \"asset\" ? assetValue.chain : pluginChain);\n const memoString =\n memo ||\n getMemoForWithdraw({\n basisPoints: Math.min(10000, Math.round(percent * 100)),\n chain: assetValue.chain,\n symbol: assetValue.symbol,\n targetAsset: targetAsset?.toString(),\n ticker: assetValue.ticker,\n });\n\n return depositToPool({ assetValue: value, memo: memoString });\n }\n\n async function claimTcy({ chain, thorAddress }: { chain: Chain; thorAddress: string }) {\n const inboundData = await getInboundDataByChain(chain);\n const dust_threshold = inboundData.dust_threshold;\n const { baseDecimal: chainDecimal } = getChainConfig(chain);\n const { baseDecimal: tcDecimal } = getChainConfig(Chain.THORChain);\n\n return deposit({\n assetValue: AssetValue.from({\n chain,\n fromBaseDecimal: Math.min(chainDecimal, tcDecimal),\n value: chain !== Chain.THORChain ? dust_threshold : 0,\n }),\n memo: getMemoForTcyClaim(MemoType.CLAIM_TCY, { address: thorAddress }),\n recipient: inboundData.address,\n router: inboundData.router,\n });\n }\n\n function stakeTcyAction(\n params: { type: \"unstake\"; unstakeBps: number } | { type: \"stake\"; assetValue: AssetValue },\n ) {\n if (params.type === \"stake\") {\n if (params.assetValue.toString() !== \"THOR.TCY\") {\n throw new USwapError(\"thorchain_asset_is_not_tcy\");\n }\n\n return deposit({\n assetValue: params.assetValue,\n memo: getMemoForTcyStake(MemoType.STAKE_TCY, {}),\n recipient: \"\",\n });\n }\n\n return deposit({\n assetValue: AssetValue.from({ chain: Chain.THORChain }),\n memo: getMemoForTcyStake(MemoType.UNSTAKE_TCY, { unstakeBps: params.unstakeBps }),\n recipient: \"\",\n });\n }\n\n async function swap({ feeOptionKey, route }: SwapParams<typeof pluginType, QuoteResponseRoute>) {\n const { memo, expiration, targetAddress } = route;\n\n const assetValue = await AssetValue.from({\n asset: route.sellAsset,\n asyncTokenLookup: true,\n value: route.sellAmount,\n });\n\n if (!assetValue) {\n throw new USwapError(\"core_swap_asset_not_recognized\");\n }\n\n const isRecipientValidated = validateAddressType({\n address: route.destinationAddress,\n chain: AssetValue.from({ asset: route.buyAsset }).chain,\n });\n\n if (!isRecipientValidated) {\n throw new USwapError(\"core_transaction_invalid_recipient_address\");\n }\n\n const { address: recipient } = await getInboundDataByChain(assetValue.chain);\n\n return deposit({\n assetValue,\n expiration: Number(expiration),\n feeOptionKey,\n memo,\n recipient,\n router: targetAddress,\n });\n }\n\n return {\n addLiquidity,\n addLiquidityPart,\n approveAssetValue,\n claimTcy,\n createLiquidity,\n deposit,\n depositToPool,\n getInboundDataByChain,\n isAssetValueApproved,\n nodeAction,\n registerName,\n registerPreferredAsset,\n stakeTcyAction,\n swap,\n withdraw,\n };\n };\n}\n",
|
|
6
|
+
"import { Chain } from \"@tcswap/helpers\";\nimport type { CoreTxParams } from \"./types\";\n\nexport function validateAddressType({ chain, address }: { chain?: Chain; address?: string }) {\n if (!address) return false;\n\n return chain === Chain.Bitcoin ? !address.startsWith(\"bc1p\") : true;\n}\n\nexport function prepareTxParams({\n assetValue,\n from,\n memo = \"\",\n ...restTxParams\n}: CoreTxParams & { from: string; router?: string }) {\n return { ...restTxParams, assetValue, from, memo };\n}\n"
|
|
7
|
+
],
|
|
8
|
+
"mappings": "+GA6BO,IAzBP,6BA0BA,iCACA,uCC/BsB,IAAtB,6BAGO,SAAS,CAAmB,EAAG,QAAO,WAAgD,CAC3F,GAAI,CAAC,EAAS,MAAO,GAErB,OAAO,IAAU,QAAM,Q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