@swapkit/plugins 4.0.0-beta.49 → 4.0.0-beta.51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/dist/chainflip/index.cjs +2 -2
  2. package/dist/chainflip/index.cjs.map +3 -3
  3. package/dist/chainflip/index.js +2 -2
  4. package/dist/chainflip/index.js.map +3 -3
  5. package/dist/chunk-hzmkxs26.js +5 -0
  6. package/dist/chunk-hzmkxs26.js.map +10 -0
  7. package/dist/chunk-npbmqeem.js +4 -0
  8. package/dist/chunk-npbmqeem.js.map +10 -0
  9. package/dist/evm/index.cjs +2 -2
  10. package/dist/evm/index.cjs.map +3 -3
  11. package/dist/evm/index.js +2 -2
  12. package/dist/evm/index.js.map +3 -3
  13. package/dist/index.cjs +2 -2
  14. package/dist/index.cjs.map +3 -4
  15. package/dist/index.js +2 -2
  16. package/dist/index.js.map +3 -4
  17. package/dist/near/index.cjs +2 -2
  18. package/dist/near/index.cjs.map +3 -3
  19. package/dist/near/index.js +2 -2
  20. package/dist/near/index.js.map +3 -3
  21. package/dist/radix/index.cjs +2 -2
  22. package/dist/radix/index.cjs.map +3 -3
  23. package/dist/radix/index.js +2 -2
  24. package/dist/radix/index.js.map +3 -3
  25. package/dist/solana/index.cjs +2 -2
  26. package/dist/solana/index.cjs.map +3 -3
  27. package/dist/solana/index.js +2 -2
  28. package/dist/solana/index.js.map +3 -3
  29. package/dist/thorchain/index.cjs +2 -2
  30. package/dist/thorchain/index.cjs.map +3 -3
  31. package/dist/thorchain/index.js +2 -2
  32. package/dist/thorchain/index.js.map +3 -3
  33. package/dist/types/chainflip/broker.d.ts +20 -0
  34. package/dist/types/chainflip/broker.d.ts.map +1 -0
  35. package/{src/chainflip/index.ts → dist/types/chainflip/index.d.ts} +1 -0
  36. package/dist/types/chainflip/index.d.ts.map +1 -0
  37. package/dist/types/chainflip/plugin.d.ts +10 -0
  38. package/dist/types/chainflip/plugin.d.ts.map +1 -0
  39. package/dist/types/chainflip/types.d.ts +41 -0
  40. package/dist/types/chainflip/types.d.ts.map +1 -0
  41. package/dist/types/evm/index.d.ts +19 -0
  42. package/dist/types/evm/index.d.ts.map +1 -0
  43. package/{src/index.ts → dist/types/index.d.ts} +1 -0
  44. package/dist/types/index.d.ts.map +1 -0
  45. package/{src/near/index.ts → dist/types/near/index.d.ts} +1 -0
  46. package/dist/types/near/index.d.ts.map +1 -0
  47. package/dist/types/near/nearNames.d.ts +3 -0
  48. package/dist/types/near/nearNames.d.ts.map +1 -0
  49. package/dist/types/near/plugin.d.ts +19 -0
  50. package/dist/types/near/plugin.d.ts.map +1 -0
  51. package/dist/types/near/types.d.ts +11 -0
  52. package/dist/types/near/types.d.ts.map +1 -0
  53. package/dist/types/radix/index.d.ts +10 -0
  54. package/dist/types/radix/index.d.ts.map +1 -0
  55. package/{src/solana/index.ts → dist/types/solana/index.d.ts} +1 -0
  56. package/dist/types/solana/index.d.ts.map +1 -0
  57. package/dist/types/solana/plugin.d.ts +10 -0
  58. package/dist/types/solana/plugin.d.ts.map +1 -0
  59. package/{src/thorchain/index.ts → dist/types/thorchain/index.d.ts} +1 -0
  60. package/dist/types/thorchain/index.d.ts.map +1 -0
  61. package/dist/types/thorchain/plugin.d.ts +107 -0
  62. package/dist/types/thorchain/plugin.d.ts.map +1 -0
  63. package/dist/types/thorchain/shared.d.ts +21 -0
  64. package/dist/types/thorchain/shared.d.ts.map +1 -0
  65. package/dist/types/thorchain/types.d.ts +64 -0
  66. package/dist/types/thorchain/types.d.ts.map +1 -0
  67. package/{src/types.ts → dist/types/types.d.ts} +7 -9
  68. package/dist/types/types.d.ts.map +1 -0
  69. package/dist/types/utils.d.ts +11 -0
  70. package/dist/types/utils.d.ts.map +1 -0
  71. package/package.json +12 -15
  72. package/dist/chunk-fazw0jvt.js +0 -4
  73. package/dist/chunk-fazw0jvt.js.map +0 -9
  74. package/dist/chunk-wfktpptf.js +0 -5
  75. package/dist/chunk-wfktpptf.js.map +0 -9
  76. package/src/chainflip/broker.ts +0 -127
  77. package/src/chainflip/plugin.ts +0 -73
  78. package/src/chainflip/types.ts +0 -48
  79. package/src/evm/index.ts +0 -82
  80. package/src/near/nearNames.ts +0 -37
  81. package/src/near/plugin.ts +0 -192
  82. package/src/near/types.ts +0 -11
  83. package/src/radix/index.ts +0 -36
  84. package/src/solana/plugin.ts +0 -36
  85. package/src/thorchain/plugin.ts +0 -528
  86. package/src/thorchain/shared.ts +0 -17
  87. package/src/thorchain/types.ts +0 -66
  88. package/src/utils.ts +0 -34
@@ -1,4 +1,4 @@
1
- var F={};R(F,{assetIdentifierToChainflipTicker:()=>T,ChainflipPlugin:()=>E,ChainflipBroker:()=>D});module.exports=k(F);var g=require("@polkadot/keyring"),h=require("@polkadot/util"),s=require("@swapkit/helpers"),T=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 i=e.api.tx.swapping?.registerAsBroker?.();if(!i)throw new s.SwapKitError("chainflip_broker_register");return e.signAndBroadcast({tx:i,address:e.getAddress()})},y=(e)=>({feeAsset:i,recipient:r})=>{let n=i.chain===s.Chain.Polkadot,p=s.wrapWithThrow(()=>{return n?e.encodeAddress(e.decodeAddress(r),"hex"):r},"chainflip_broker_recipient_error");return new Promise((o)=>{let a=e.api.tx?.swapping?.withdraw?.(i.ticker.toLowerCase(),{[i.chain.toLowerCase()]:p});if(!a)throw new s.SwapKitError("chainflip_broker_withdraw");e.signAndBroadcast({tx:a,callback:async(f)=>{if(!f.status?.isFinalized)return;let d=f.events.find((w)=>w.event.method==="WithdrawalRequested");if(!d)throw new s.SwapKitError("chainflip_channel_error","Could not find 'WithdrawalRequested' event");let{event:{data:{egressId:A,egressAsset:u,egressAmount:c,egressFee:m,destinationAddress:C}}}=d.toHuman();o({egressId:A,egressAsset:u,egressAmount:c,egressFee:m,destinationAddress:C})}})})},B=(e)=>async({evmToolbox:i,stateChainAccount:r,assetValue:n})=>{let{chainflipGateway:p}=await import("@swapkit/helpers/contracts"),o=s.AssetValue.from({asset:"ETH.FLIP"});if(!n.eqAsset(o))throw new s.SwapKitError("chainflip_broker_fund_only_flip_supported");if(!e.validateAddress(r))throw new s.SwapKitError("chainflip_broker_fund_invalid_address");let a=h.isHex(r)?r:h.u8aToHex(g.decodeAddress(r));return i.call({abi:p,contractAddress:"0x6995ab7c4d7f4b03f467cf4c8e920427d9621dbd",funcName:"fundStateChainAccount",funcParams:[a,n.getBaseValue("string")]})},D=(e)=>({registerAsBroker:b(e),fundStateChainAccount:B(e),withdrawFee:y(e)});var t=require("@swapkit/helpers"),l=require("@swapkit/helpers/api"),E=t.createPlugin({name:"chainflip",methods:({getWallet:e})=>({swap:async function i(r){let n=t.SKConfig.get("integrations").chainflip?.brokerUrl;if(!(r?.route?.buyAsset&&n&&r.route.meta.chainflip))throw new t.SwapKitError("core_swap_invalid_params",{...r,chainflipBrokerUrl:n});let{route:{buyAsset:p,sellAsset:o,sellAmount:a,destinationAddress:f,meta:{chainflip:d}},maxBoostFeeBps:A=0}=r;if(!(o&&p))throw new t.SwapKitError("core_swap_asset_not_recognized");let u=await t.AssetValue.from({asyncTokenLookup:!0,asset:o,value:a}),c=e(u.chain);if(!c)throw new t.SwapKitError("core_wallet_connection_not_found");let{depositAddress:m}=await l.SwapKitApi.getChainflipDepositChannel({...d,destinationAddress:f||d.destinationAddress,maxBoostFeeBps:A||d.maxBoostFeeBps});return await c.transfer({assetValue:u,sender:c.address,recipient:m,isProgramDerivedAddress:!0})}}),properties:{supportedSwapkitProviders:[t.ProviderName.CHAINFLIP,t.ProviderName.CHAINFLIP_STREAMING]}});
1
+ var _={};F(_,{assetIdentifierToChainflipTicker:()=>b,ChainflipPlugin:()=>k,ChainflipBroker:()=>E});module.exports=R(_);var g=require("@polkadot/keyring"),h=require("@polkadot/util"),r=require("@swapkit/helpers"),b=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"]]),y=(e)=>()=>{let n=e.api.tx.swapping?.registerAsBroker?.();if(!n)throw new r.SwapKitError("chainflip_broker_register");return e.signAndBroadcast({tx:n,address:e.getAddress()})},B=(e)=>({feeAsset:n,recipient:t})=>{let i=n.chain===r.Chain.Polkadot,p=r.wrapWithThrow(()=>{return i?e.encodeAddress(e.decodeAddress(t),"hex"):t},"chainflip_broker_recipient_error");return new Promise((o)=>{let a=e.api.tx?.swapping?.withdraw?.(n.ticker.toLowerCase(),{[n.chain.toLowerCase()]:p});if(!a)throw new r.SwapKitError("chainflip_broker_withdraw");e.signAndBroadcast({tx:a,callback:async(f)=>{if(!f.status?.isFinalized)return;let d=f.events.find((x)=>x.event.method==="WithdrawalRequested");if(!d)throw new r.SwapKitError("chainflip_channel_error","Could not find 'WithdrawalRequested' event");let{event:{data:{egressId:A,egressAsset:u,egressAmount:c,egressFee:m,destinationAddress:C}}}=d.toHuman();o({egressId:A,egressAsset:u,egressAmount:c,egressFee:m,destinationAddress:C})}})})},D=(e)=>async({evmToolbox:n,stateChainAccount:t,assetValue:i})=>{let{chainflipGateway:p}=await import("@swapkit/helpers/contracts"),o=r.AssetValue.from({asset:"ETH.FLIP"});if(!i.eqAsset(o))throw new r.SwapKitError("chainflip_broker_fund_only_flip_supported");if(!e.validateAddress(t))throw new r.SwapKitError("chainflip_broker_fund_invalid_address");let a=h.isHex(t)?t:h.u8aToHex(g.decodeAddress(t));return n.call({abi:p,contractAddress:"0x6995ab7c4d7f4b03f467cf4c8e920427d9621dbd",funcName:"fundStateChainAccount",funcParams:[a,i.getBaseValue("string")]})},E=(e)=>({registerAsBroker:y(e),fundStateChainAccount:D(e),withdrawFee:B(e)});var s=require("@swapkit/helpers"),w=require("@swapkit/helpers/api");var k=l({name:"chainflip",methods:({getWallet:e})=>({swap:async function n(t){let i=s.SKConfig.get("integrations").chainflip?.brokerUrl;if(!(t?.route?.buyAsset&&i&&t.route.meta.chainflip))throw new s.SwapKitError("core_swap_invalid_params",{...t,chainflipBrokerUrl:i});let{route:{buyAsset:p,sellAsset:o,sellAmount:a,destinationAddress:f,meta:{chainflip:d}},maxBoostFeeBps:A=0}=t;if(!(o&&p))throw new s.SwapKitError("core_swap_asset_not_recognized");let u=await s.AssetValue.from({asyncTokenLookup:!0,asset:o,value:a}),c=e(u.chain);if(!c)throw new s.SwapKitError("core_wallet_connection_not_found");let{depositAddress:m}=await w.SwapKitApi.getChainflipDepositChannel({...d,destinationAddress:f||d.destinationAddress,maxBoostFeeBps:A||d.maxBoostFeeBps});return await c.transfer({assetValue:u,sender:c.address,recipient:m,isProgramDerivedAddress:!0})}}),properties:{supportedSwapkitProviders:[s.ProviderName.CHAINFLIP,s.ProviderName.CHAINFLIP_STREAMING]}});
2
2
 
3
- //# debugId=E9F48CA793E45EBF64756E2164756E21
3
+ //# debugId=4FF966C4156EAAA864756E2164756E21
4
4
  //# sourceMappingURL=index.cjs.map
@@ -3,9 +3,9 @@
3
3
  "sources": ["../src/chainflip/broker.ts", "../src/chainflip/plugin.ts"],
4
4
  "sourcesContent": [
5
5
  "import { decodeAddress } from \"@polkadot/keyring\";\nimport { isHex, u8aToHex } from \"@polkadot/util\";\nimport { AssetValue, Chain, SwapKitError, wrapWithThrow } from \"@swapkit/helpers\";\nimport type { getEvmToolbox } from \"@swapkit/toolboxes/evm\";\nimport type { getSubstrateToolbox } from \"@swapkit/toolboxes/substrate\";\n\nimport type { WithdrawFeeResponse } from \"./types\";\n\ntype ChainflipToolbox = Awaited<ReturnType<typeof getSubstrateToolbox<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 SwapKitError(\"chainflip_broker_register\");\n }\n\n return toolbox.signAndBroadcast({ tx: extrinsic, address: toolbox.getAddress() });\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\n ? toolbox.encodeAddress(toolbox.decodeAddress(recipient), \"hex\")\n : 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 SwapKitError(\"chainflip_broker_withdraw\");\n }\n\n toolbox.signAndBroadcast({\n tx: extrinsic,\n callback: async (result) => {\n if (!result.status?.isFinalized) {\n return;\n }\n\n const withdrawEvent = result.events.find(\n (event) => event.event.method === \"WithdrawalRequested\",\n );\n\n if (!withdrawEvent) {\n throw new SwapKitError(\n \"chainflip_channel_error\",\n \"Could not find 'WithdrawalRequested' event\",\n );\n }\n const {\n event: {\n data: { egressId, egressAsset, egressAmount, egressFee, destinationAddress },\n },\n } = withdrawEvent.toHuman() as any;\n resolve({\n egressId,\n egressAsset,\n egressAmount,\n egressFee,\n destinationAddress,\n });\n },\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(\"@swapkit/helpers/contracts\");\n\n const flipAssetValue = AssetValue.from({ asset: \"ETH.FLIP\" });\n\n if (!assetValue.eqAsset(flipAssetValue)) {\n throw new SwapKitError(\"chainflip_broker_fund_only_flip_supported\");\n }\n\n if (!chainflipToolbox.validateAddress(stateChainAccount)) {\n throw new SwapKitError(\"chainflip_broker_fund_invalid_address\");\n }\n\n const hexAddress = isHex(stateChainAccount)\n ? stateChainAccount\n : 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 registerAsBroker: registerAsBroker(chainflipToolbox),\n fundStateChainAccount: fundStateChainAccount(chainflipToolbox),\n withdrawFee: withdrawFee(chainflipToolbox),\n});\n",
6
- "import {\n AssetValue,\n type CryptoChain,\n ProviderName,\n SKConfig,\n SwapKitError,\n createPlugin,\n} from \"@swapkit/helpers\";\nimport { SwapKitApi } from \"@swapkit/helpers/api\";\nimport type { RequestSwapDepositAddressParams } from \"./types\";\n\nexport const ChainflipPlugin = createPlugin({\n name: \"chainflip\",\n methods: ({ getWallet }) => ({\n swap: async function chainflipSwap(swapParams: RequestSwapDepositAddressParams) {\n const brokerUrl = SKConfig.get(\"integrations\").chainflip?.brokerUrl;\n\n if (!(swapParams?.route?.buyAsset && brokerUrl && swapParams.route.meta.chainflip)) {\n throw new SwapKitError(\"core_swap_invalid_params\", {\n ...swapParams,\n chainflipBrokerUrl: brokerUrl,\n });\n }\n\n const {\n route: {\n buyAsset: buyAssetString,\n sellAsset: sellAssetString,\n sellAmount,\n destinationAddress: recipient,\n meta: { chainflip },\n },\n maxBoostFeeBps = 0,\n } = swapParams;\n\n if (!(sellAssetString && buyAssetString)) {\n throw new SwapKitError(\"core_swap_asset_not_recognized\");\n }\n\n const sellAsset = await AssetValue.from({\n asyncTokenLookup: true,\n asset: sellAssetString,\n value: sellAmount,\n });\n\n const wallet = getWallet(sellAsset.chain as CryptoChain);\n\n if (!wallet) {\n throw new SwapKitError(\"core_wallet_connection_not_found\");\n }\n\n const { depositAddress } = await SwapKitApi.getChainflipDepositChannel({\n ...chainflip,\n destinationAddress: recipient || chainflip.destinationAddress,\n maxBoostFeeBps: maxBoostFeeBps || chainflip.maxBoostFeeBps,\n });\n\n // @ts-expect-error TODO: right now it's inferred from toolboxes\n // we need to simplify this to one object params\n const tx = await wallet.transfer({\n assetValue: sellAsset,\n sender: wallet.address,\n recipient: depositAddress,\n isProgramDerivedAddress: true,\n });\n\n return tx as string;\n },\n }),\n properties: {\n supportedSwapkitProviders: [ProviderName.CHAINFLIP, ProviderName.CHAINFLIP_STREAMING],\n },\n});\n"
6
+ "import {\n AssetValue,\n type CryptoChain,\n ProviderName,\n SKConfig,\n SwapKitError,\n} from \"@swapkit/helpers\";\nimport { SwapKitApi } from \"@swapkit/helpers/api\";\nimport { createPlugin } from \"../utils\";\nimport type { RequestSwapDepositAddressParams } from \"./types\";\n\nexport const ChainflipPlugin = createPlugin({\n name: \"chainflip\",\n methods: ({ getWallet }) => ({\n swap: async function chainflipSwap(swapParams: RequestSwapDepositAddressParams) {\n const brokerUrl = SKConfig.get(\"integrations\").chainflip?.brokerUrl;\n\n if (!(swapParams?.route?.buyAsset && brokerUrl && swapParams.route.meta.chainflip)) {\n throw new SwapKitError(\"core_swap_invalid_params\", {\n ...swapParams,\n chainflipBrokerUrl: brokerUrl,\n });\n }\n\n const {\n route: {\n buyAsset: buyAssetString,\n sellAsset: sellAssetString,\n sellAmount,\n destinationAddress: recipient,\n meta: { chainflip },\n },\n maxBoostFeeBps = 0,\n } = swapParams;\n\n if (!(sellAssetString && buyAssetString)) {\n throw new SwapKitError(\"core_swap_asset_not_recognized\");\n }\n\n const sellAsset = await AssetValue.from({\n asyncTokenLookup: true,\n asset: sellAssetString,\n value: sellAmount,\n });\n\n const wallet = getWallet(sellAsset.chain as CryptoChain);\n\n if (!wallet) {\n throw new SwapKitError(\"core_wallet_connection_not_found\");\n }\n\n const { depositAddress } = await SwapKitApi.getChainflipDepositChannel({\n ...chainflip,\n destinationAddress: recipient || chainflip.destinationAddress,\n maxBoostFeeBps: maxBoostFeeBps || chainflip.maxBoostFeeBps,\n });\n\n // @ts-expect-error TODO: right now it's inferred from toolboxes\n // we need to simplify this to one object params\n const tx = await wallet.transfer({\n assetValue: sellAsset,\n sender: wallet.address,\n recipient: depositAddress,\n isProgramDerivedAddress: true,\n });\n\n return tx as string;\n },\n }),\n properties: {\n supportedSwapkitProvi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AM,IAAI,eAAa,2BAA4B,IAC9C,EACH,mBAAoB,CACtB,CAAC,EAGH,IACE,OACE,SAAU,EACV,UAAW,EACX,aACA,mBAAoB,EACpB,MAAQ,cAEV,iBAAiB,GACf,EAEJ,KAAM,GAAmB,GACvB,MAAM,IAAI,eAAa,gCAAgC,EAGzD,IAAM,EAAY,MAAM,aAAW,KAAK,CACtC,iBAAkB,GAClB,MAAO,EACP,MAAO,CACT,CAAC,EAEK,EAAS,EAAU,EAAU,KAAoB,EAEvD,IAAK,EACH,MAAM,IAAI,eAAa,kCAAkC,EAG3D,IAAQ,kBAAmB,MAAM,aAAW,2BAA2B,IAClE,EACH,mBAAoB,GAAa,EAAU,mBAC3C,eAAgB,GAAkB,EAAU,cAC9C,CAAC,EAWD,OAPW,MAAM,EAAO,SAAS,CAC/B,WAAY,EACZ,OAAQ,EAAO,QACf,UAAW,EACX,wBAAyB,EAC3B,CAAC,EAIL,GACA,WAAY,CACV,0BAA2B,CAAC,eAAa,UAAW,eAAa,mBAAmB,CACtF,CACF,CAAC",
9
+ "debugId": "4FF966C4156EAAA864756E2164756E21",
10
10
  "names": []
11
11
  }
@@ -1,4 +1,4 @@
1
- import{a as l,b as w}from"../chunk-wfktpptf.js";import{decodeAddress as x}from"@polkadot/keyring";import{isHex as T,u8aToHex as b}from"@polkadot/util";import{AssetValue as y,Chain as B,SwapKitError as p,wrapWithThrow as D}from"@swapkit/helpers";var L=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=(e)=>()=>{let r=e.api.tx.swapping?.registerAsBroker?.();if(!r)throw new p("chainflip_broker_register");return e.signAndBroadcast({tx:r,address:e.getAddress()})},k=(e)=>({feeAsset:r,recipient:t})=>{let s=r.chain===B.Polkadot,a=D(()=>{return s?e.encodeAddress(e.decodeAddress(t),"hex"):t},"chainflip_broker_recipient_error");return new Promise((i)=>{let n=e.api.tx?.swapping?.withdraw?.(r.ticker.toLowerCase(),{[r.chain.toLowerCase()]:a});if(!n)throw new p("chainflip_broker_withdraw");e.signAndBroadcast({tx:n,callback:async(c)=>{if(!c.status?.isFinalized)return;let o=c.events.find((g)=>g.event.method==="WithdrawalRequested");if(!o)throw new p("chainflip_channel_error","Could not find 'WithdrawalRequested' event");let{event:{data:{egressId:u,egressAsset:f,egressAmount:d,egressFee:h,destinationAddress:m}}}=o.toHuman();i({egressId:u,egressAsset:f,egressAmount:d,egressFee:h,destinationAddress:m})}})})},R=(e)=>async({evmToolbox:r,stateChainAccount:t,assetValue:s})=>{let{chainflipGateway:a}=await import("@swapkit/helpers/contracts"),i=y.from({asset:"ETH.FLIP"});if(!s.eqAsset(i))throw new p("chainflip_broker_fund_only_flip_supported");if(!e.validateAddress(t))throw new p("chainflip_broker_fund_invalid_address");let n=T(t)?t:b(x(t));return r.call({abi:a,contractAddress:"0x6995ab7c4d7f4b03f467cf4c8e920427d9621dbd",funcName:"fundStateChainAccount",funcParams:[n,s.getBaseValue("string")]})},U=(e)=>({registerAsBroker:E(e),fundStateChainAccount:R(e),withdrawFee:k(e)});import{AssetValue as F,ProviderName as C,SKConfig as _,SwapKitError as A,createPlugin as S}from"@swapkit/helpers";import{SwapKitApi as H}from"@swapkit/helpers/api";var M=S({name:"chainflip",methods:({getWallet:e})=>({swap:async function r(t){let s=_.get("integrations").chainflip?.brokerUrl;if(!(t?.route?.buyAsset&&s&&t.route.meta.chainflip))throw new A("core_swap_invalid_params",{...t,chainflipBrokerUrl:s});let{route:{buyAsset:a,sellAsset:i,sellAmount:n,destinationAddress:c,meta:{chainflip:o}},maxBoostFeeBps:u=0}=t;if(!(i&&a))throw new A("core_swap_asset_not_recognized");let f=await F.from({asyncTokenLookup:!0,asset:i,value:n}),d=e(f.chain);if(!d)throw new A("core_wallet_connection_not_found");let{depositAddress:h}=await H.getChainflipDepositChannel({...o,destinationAddress:c||o.destinationAddress,maxBoostFeeBps:u||o.maxBoostFeeBps});return await d.transfer({assetValue:f,sender:d.address,recipient:h,isProgramDerivedAddress:!0})}}),properties:{supportedSwapkitProviders:[C.CHAINFLIP,C.CHAINFLIP_STREAMING]}});export{L as assetIdentifierToChainflipTicker,M as ChainflipPlugin,U as ChainflipBroker};
1
+ import{a as l,b as x,c as g}from"../chunk-hzmkxs26.js";import{decodeAddress as T}from"@polkadot/keyring";import{isHex as b,u8aToHex as y}from"@polkadot/util";import{AssetValue as B,Chain as D,SwapKitError as p,wrapWithThrow as E}from"@swapkit/helpers";var L=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"]]),k=(e)=>()=>{let r=e.api.tx.swapping?.registerAsBroker?.();if(!r)throw new p("chainflip_broker_register");return e.signAndBroadcast({tx:r,address:e.getAddress()})},R=(e)=>({feeAsset:r,recipient:t})=>{let s=r.chain===D.Polkadot,a=E(()=>{return s?e.encodeAddress(e.decodeAddress(t),"hex"):t},"chainflip_broker_recipient_error");return new Promise((n)=>{let i=e.api.tx?.swapping?.withdraw?.(r.ticker.toLowerCase(),{[r.chain.toLowerCase()]:a});if(!i)throw new p("chainflip_broker_withdraw");e.signAndBroadcast({tx:i,callback:async(c)=>{if(!c.status?.isFinalized)return;let o=c.events.find((w)=>w.event.method==="WithdrawalRequested");if(!o)throw new p("chainflip_channel_error","Could not find 'WithdrawalRequested' event");let{event:{data:{egressId:u,egressAsset:f,egressAmount:d,egressFee:h,destinationAddress:m}}}=o.toHuman();n({egressId:u,egressAsset:f,egressAmount:d,egressFee:h,destinationAddress:m})}})})},F=(e)=>async({evmToolbox:r,stateChainAccount:t,assetValue:s})=>{let{chainflipGateway:a}=await import("@swapkit/helpers/contracts"),n=B.from({asset:"ETH.FLIP"});if(!s.eqAsset(n))throw new p("chainflip_broker_fund_only_flip_supported");if(!e.validateAddress(t))throw new p("chainflip_broker_fund_invalid_address");let i=b(t)?t:y(T(t));return r.call({abi:a,contractAddress:"0x6995ab7c4d7f4b03f467cf4c8e920427d9621dbd",funcName:"fundStateChainAccount",funcParams:[i,s.getBaseValue("string")]})},U=(e)=>({registerAsBroker:k(e),fundStateChainAccount:F(e),withdrawFee:R(e)});import{AssetValue as _,ProviderName as C,SKConfig as S,SwapKitError as A}from"@swapkit/helpers";import{SwapKitApi as H}from"@swapkit/helpers/api";var O=g({name:"chainflip",methods:({getWallet:e})=>({swap:async function r(t){let s=S.get("integrations").chainflip?.brokerUrl;if(!(t?.route?.buyAsset&&s&&t.route.meta.chainflip))throw new A("core_swap_invalid_params",{...t,chainflipBrokerUrl:s});let{route:{buyAsset:a,sellAsset:n,sellAmount:i,destinationAddress:c,meta:{chainflip:o}},maxBoostFeeBps:u=0}=t;if(!(n&&a))throw new A("core_swap_asset_not_recognized");let f=await _.from({asyncTokenLookup:!0,asset:n,value:i}),d=e(f.chain);if(!d)throw new A("core_wallet_connection_not_found");let{depositAddress:h}=await H.getChainflipDepositChannel({...o,destinationAddress:c||o.destinationAddress,maxBoostFeeBps:u||o.maxBoostFeeBps});return await d.transfer({assetValue:f,sender:d.address,recipient:h,isProgramDerivedAddress:!0})}}),properties:{supportedSwapkitProviders:[C.CHAINFLIP,C.CHAINFLIP_STREAMING]}});export{L as assetIdentifierToChainflipTicker,O as ChainflipPlugin,U as ChainflipBroker};
2
2
 
3
- //# debugId=8EB8AC0447903D3764756E2164756E21
3
+ //# debugId=931534199E78406564756E2164756E21
4
4
  //# sourceMappingURL=index.js.map
@@ -3,9 +3,9 @@
3
3
  "sources": ["../src/chainflip/broker.ts", "../src/chainflip/plugin.ts"],
4
4
  "sourcesContent": [
5
5
  "import { decodeAddress } from \"@polkadot/keyring\";\nimport { isHex, u8aToHex } from \"@polkadot/util\";\nimport { AssetValue, Chain, SwapKitError, wrapWithThrow } from \"@swapkit/helpers\";\nimport type { getEvmToolbox } from \"@swapkit/toolboxes/evm\";\nimport type { getSubstrateToolbox } from \"@swapkit/toolboxes/substrate\";\n\nimport type { WithdrawFeeResponse } from \"./types\";\n\ntype ChainflipToolbox = Awaited<ReturnType<typeof getSubstrateToolbox<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 SwapKitError(\"chainflip_broker_register\");\n }\n\n return toolbox.signAndBroadcast({ tx: extrinsic, address: toolbox.getAddress() });\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\n ? toolbox.encodeAddress(toolbox.decodeAddress(recipient), \"hex\")\n : 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 SwapKitError(\"chainflip_broker_withdraw\");\n }\n\n toolbox.signAndBroadcast({\n tx: extrinsic,\n callback: async (result) => {\n if (!result.status?.isFinalized) {\n return;\n }\n\n const withdrawEvent = result.events.find(\n (event) => event.event.method === \"WithdrawalRequested\",\n );\n\n if (!withdrawEvent) {\n throw new SwapKitError(\n \"chainflip_channel_error\",\n \"Could not find 'WithdrawalRequested' event\",\n );\n }\n const {\n event: {\n data: { egressId, egressAsset, egressAmount, egressFee, destinationAddress },\n },\n } = withdrawEvent.toHuman() as any;\n resolve({\n egressId,\n egressAsset,\n egressAmount,\n egressFee,\n destinationAddress,\n });\n },\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(\"@swapkit/helpers/contracts\");\n\n const flipAssetValue = AssetValue.from({ asset: \"ETH.FLIP\" });\n\n if (!assetValue.eqAsset(flipAssetValue)) {\n throw new SwapKitError(\"chainflip_broker_fund_only_flip_supported\");\n }\n\n if (!chainflipToolbox.validateAddress(stateChainAccount)) {\n throw new SwapKitError(\"chainflip_broker_fund_invalid_address\");\n }\n\n const hexAddress = isHex(stateChainAccount)\n ? stateChainAccount\n : 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 registerAsBroker: registerAsBroker(chainflipToolbox),\n fundStateChainAccount: fundStateChainAccount(chainflipToolbox),\n withdrawFee: withdrawFee(chainflipToolbox),\n});\n",
6
- "import {\n AssetValue,\n type CryptoChain,\n ProviderName,\n SKConfig,\n SwapKitError,\n createPlugin,\n} from \"@swapkit/helpers\";\nimport { SwapKitApi } from \"@swapkit/helpers/api\";\nimport type { RequestSwapDepositAddressParams } from \"./types\";\n\nexport const ChainflipPlugin = createPlugin({\n name: \"chainflip\",\n methods: ({ getWallet }) => ({\n swap: async function chainflipSwap(swapParams: RequestSwapDepositAddressParams) {\n const brokerUrl = SKConfig.get(\"integrations\").chainflip?.brokerUrl;\n\n if (!(swapParams?.route?.buyAsset && brokerUrl && swapParams.route.meta.chainflip)) {\n throw new SwapKitError(\"core_swap_invalid_params\", {\n ...swapParams,\n chainflipBrokerUrl: brokerUrl,\n });\n }\n\n const {\n route: {\n buyAsset: buyAssetString,\n sellAsset: sellAssetString,\n sellAmount,\n destinationAddress: recipient,\n meta: { chainflip },\n },\n maxBoostFeeBps = 0,\n } = swapParams;\n\n if (!(sellAssetString && buyAssetString)) {\n throw new SwapKitError(\"core_swap_asset_not_recognized\");\n }\n\n const sellAsset = await AssetValue.from({\n asyncTokenLookup: true,\n asset: sellAssetString,\n value: sellAmount,\n });\n\n const wallet = getWallet(sellAsset.chain as CryptoChain);\n\n if (!wallet) {\n throw new SwapKitError(\"core_wallet_connection_not_found\");\n }\n\n const { depositAddress } = await SwapKitApi.getChainflipDepositChannel({\n ...chainflip,\n destinationAddress: recipient || chainflip.destinationAddress,\n maxBoostFeeBps: maxBoostFeeBps || chainflip.maxBoostFeeBps,\n });\n\n // @ts-expect-error TODO: right now it's inferred from toolboxes\n // we need to simplify this to one object params\n const tx = await wallet.transfer({\n assetValue: sellAsset,\n sender: wallet.address,\n recipient: depositAddress,\n isProgramDerivedAddress: true,\n });\n\n return tx as string;\n },\n }),\n properties: {\n supportedSwapkitProviders: [ProviderName.CHAINFLIP, ProviderName.CHAINFLIP_STREAMING],\n },\n});\n"
6
+ "import {\n AssetValue,\n type CryptoChain,\n ProviderName,\n SKConfig,\n SwapKitError,\n} from \"@swapkit/helpers\";\nimport { SwapKitApi } from \"@swapkit/helpers/api\";\nimport { createPlugin } from \"../utils\";\nimport type { RequestSwapDepositAddressParams } from \"./types\";\n\nexport const ChainflipPlugin = createPlugin({\n name: \"chainflip\",\n methods: ({ getWallet }) => ({\n swap: async function chainflipSwap(swapParams: RequestSwapDepositAddressParams) {\n const brokerUrl = SKConfig.get(\"integrations\").chainflip?.brokerUrl;\n\n if (!(swapParams?.route?.buyAsset && brokerUrl && swapParams.route.meta.chainflip)) {\n throw new SwapKitError(\"core_swap_invalid_params\", {\n ...swapParams,\n chainflipBrokerUrl: brokerUrl,\n });\n }\n\n const {\n route: {\n buyAsset: buyAssetString,\n sellAsset: sellAssetString,\n sellAmount,\n destinationAddress: recipient,\n meta: { chainflip },\n },\n maxBoostFeeBps = 0,\n } = swapParams;\n\n if (!(sellAssetString && buyAssetString)) {\n throw new SwapKitError(\"core_swap_asset_not_recognized\");\n }\n\n const sellAsset = await AssetValue.from({\n asyncTokenLookup: true,\n asset: sellAssetString,\n value: sellAmount,\n });\n\n const wallet = getWallet(sellAsset.chain as CryptoChain);\n\n if (!wallet) {\n throw new SwapKitError(\"core_wallet_connection_not_found\");\n }\n\n const { depositAddress } = await SwapKitApi.getChainflipDepositChannel({\n ...chainflip,\n destinationAddress: recipient || chainflip.destinationAddress,\n maxBoostFeeBps: maxBoostFeeBps || chainflip.maxBoostFeeBps,\n });\n\n // @ts-expect-error TODO: right now it's inferred from toolboxes\n // we need to simplify this to one object params\n const tx = await wallet.transfer({\n assetValue: sellAsset,\n sender: wallet.address,\n recipient: depositAddress,\n isProgramDerivedAddress: true,\n });\n\n return tx as string;\n },\n }),\n properties: {\n supportedSwapkitProviders: [ProviderName.CHAINFLIP, ProviderName.CHAINFLIP_STREAMING],\n },\n});\n"
7
7
  ],
8
- "mappings": "gDAAA,wBAAS,0BACT,gBAAS,cAAO,uBAChB,qBAAS,WAAY,kBAAO,mBAAc,yBAQnC,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,IAAK,EACH,MAAM,IAAI,EAAa,2BAA2B,EAGpD,OAAO,EAAQ,iBAAiB,CAAE,GAAI,EAAW,QAAS,EAAQ,WAAW,CAAE,CAAC,GAG5E,EACJ,CAAC,IACD,EAAG,WAAU,eAA6D,CACxE,IAAM,EAAqB,EAAS,QAAU,EAAM,SAE9C,EAAmB,EAAc,IAAM,CAC3C,OAAO,EACH,EAAQ,cAAc,EAAQ,cAAc,CAAS,EAAG,KAAK,EAC7D,GACH,kCAAkC,EAErC,OAAO,IAAI,QAA6B,CAAC,IAAY,CACnD,IAAM,EAAY,EAAQ,IAAI,IAAI,UAAU,WAAW,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AAU,wBACV,WAAY,CAAC,EAAY,EAAW,aAAa,QAAQ,CAAC,CAC5D,CAAC,GAGQ,EAAkB,CAAC,KAAwC,CACtE,iBAAkB,EAAiB,CAAgB,EACnD,sBAAuB,EAAsB,CAAgB,EAC7D,YAAa,EAAY,CAAgB,CAC3C,GC9HA,qBACE,kBAEA,cACA,kBACA,yBAEF,qBAAS,6BAIF,IAAM,EAAkB,EAAa,CAC1C,KAAM,YACN,QAAS,EAAG,gBAAiB,CAC3B,KAAM,eAAe,CAAa,CAAC,EAA6C,CAC9E,IAAM,EAAY,EAAS,IAAI,cAAc,EAAE,WAAW,UAE1D,KAAM,GAAY,OAAO,UAAY,GAAa,EAAW,MAAM,KAAK,WACtE,MAAM,IAAI,EAAa,2BAA4B,IAC9C,EACH,mBAAoB,CACtB,CAAC,EAGH,IACE,OACE,SAAU,EACV,UAAW,EACX,aACA,mBAAoB,EACpB,MAAQ,cAEV,iBAAiB,GACf,EAEJ,KAAM,GAAmB,GACvB,MAAM,IAAI,EAAa,gCAAgC,EAGzD,IAAM,EAAY,MAAM,EAAW,KAAK,CACtC,iBAAkB,GAClB,MAAO,EACP,MAAO,CACT,CAAC,EAEK,EAAS,EAAU,EAAU,KAAoB,EAEvD,IAAK,EACH,MAAM,IAAI,EAAa,kCAAkC,EAG3D,IAAQ,kBAAmB,MAAM,EAAW,2BAA2B,IAClE,EACH,mBAAoB,GAAa,EAAU,mBAC3C,eAAgB,GAAkB,EAAU,cAC9C,CAAC,EAWD,OAPW,MAAM,EAAO,SAAS,CAC/B,WAAY,EACZ,OAAQ,EAAO,QACf,UAAW,EACX,wBAAyB,EAC3B,CAAC,EAIL,GACA,WAAY,CACV,0BAA2B,CAAC,EAAa,UAAW,EAAa,mBAAmB,CACtF,CACF,CAAC",
9
+ "debugId": "931534199E78406564756E2164756E21",
10
10
  "names": []
11
11
  }
@@ -0,0 +1,5 @@
1
+ var u=Object.create;var{getPrototypeOf:p,defineProperty:o,getOwnPropertyNames:m}=Object;var l=Object.prototype.hasOwnProperty;var r=(t,a,i)=>{i=t!=null?u(p(t)):{};let n=a||!t||!t.__esModule?o(i,"default",{value:t,enumerable:!0}):i;for(let s of m(t))if(!l.call(n,s))o(n,s,{get:()=>t[s],enumerable:!0});return n};var e=((t)=>typeof require!=="undefined"?require:typeof Proxy!=="undefined"?new Proxy(t,{get:(a,i)=>(typeof require!=="undefined"?require:a)[i]}):t)(function(t){if(typeof require!=="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});function P({name:t,properties:a,methods:i}){function n(s){return{...i(s),...a}}return{[t]:n}}async function g(t){let{match:a}=await import("ts-pattern");return await a(t).with("chainflip",async()=>{let{ChainflipPlugin:n}=await import("./chainflip/index.js");return n}).with("thorchain",async()=>{let{ThorchainPlugin:n}=await import("./thorchain/index.js");return n}).with("radix",async()=>{let{RadixPlugin:n}=await import("./radix/index.js");return n}).with("evm",async()=>{let{EVMPlugin:n}=await import("./evm/index.js");return n}).with("solana",async()=>{let{SolanaPlugin:n}=await import("./solana/index.js");return n}).with("near",async()=>{let{NearPlugin:n}=await import("./near/index.js");return n}).exhaustive()}
2
+ export{r as a,e as b,P as c,g as d};
3
+
4
+ //# debugId=97D313AFCE5799DA64756E2164756E21
5
+ //# sourceMappingURL=chunk-hzmkxs26.js.map
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/utils.ts"],
4
+ "sourcesContent": [
5
+ "import type { ProviderName } from \"@swapkit/helpers\";\nimport type { PluginName, SKPlugins, SwapKitPluginParams } from \"./types\";\n\nexport function createPlugin<\n const Name extends string,\n T extends (params: SwapKitPluginParams) => Record<string, unknown>,\n K extends { supportedSwapkitProviders?: (ProviderName | string)[] },\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 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 SKPlugins[P];\n}\n"
6
+ ],
7
+ "mappings": "0lBAGO,SAAS,CAIf,EAAG,OAAM,aAAY,WAAuD,CAC3E,SAAS,CAAM,CAAC,EAAmC,CACjD,MAAO,IAAK,EAAQ,CAAY,KAAM,CAAW,EAGnD,MAAO,EAAG,GAAO,CAAO,EAG1B,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": "97D313AFCE5799DA64756E2164756E21",
9
+ "names": []
10
+ }
@@ -0,0 +1,4 @@
1
+ var m=Object.create;var{getPrototypeOf:l,defineProperty:s,getOwnPropertyNames:u,getOwnPropertyDescriptor:c}=Object,p=Object.prototype.hasOwnProperty;var r=(t,i,a)=>{a=t!=null?m(l(t)):{};let n=i||!t||!t.__esModule?s(a,"default",{value:t,enumerable:!0}):a;for(let e of u(t))if(!p.call(n,e))s(n,e,{get:()=>t[e],enumerable:!0});return n},o=new WeakMap,P=(t)=>{var i=o.get(t),a;if(i)return i;if(i=s({},"__esModule",{value:!0}),t&&typeof t==="object"||typeof t==="function")u(t).map((n)=>!p.call(i,n)&&s(i,n,{get:()=>t[n],enumerable:!(a=c(t,n))||a.enumerable}));return o.set(t,i),i};var g=(t,i)=>{for(var a in i)s(t,a,{get:i[a],enumerable:!0,configurable:!0,set:(n)=>i[a]=()=>n})};function h({name:t,properties:i,methods:a}){function n(e){return{...a(e),...i}}return{[t]:n}}async function d(t){let{match:i}=await import("ts-pattern");return await i(t).with("chainflip",async()=>{let{ChainflipPlugin:n}=await import("./chainflip/index.cjs");return n}).with("thorchain",async()=>{let{ThorchainPlugin:n}=await import("./thorchain/index.cjs");return n}).with("radix",async()=>{let{RadixPlugin:n}=await import("./radix/index.cjs");return n}).with("evm",async()=>{let{EVMPlugin:n}=await import("./evm/index.cjs");return n}).with("solana",async()=>{let{SolanaPlugin:n}=await import("./solana/index.cjs");return n}).with("near",async()=>{let{NearPlugin:n}=await import("./near/index.cjs");return n}).exhaustive()}
2
+
3
+ //# debugId=02AEC6FD9069CF5D64756E2164756E21
4
+ //# sourceMappingURL=chunk-npbmqeem.js.map
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/utils.ts"],
4
+ "sourcesContent": [
5
+ "import type { ProviderName } from \"@swapkit/helpers\";\nimport type { PluginName, SKPlugins, SwapKitPluginParams } from \"./types\";\n\nexport function createPlugin<\n const Name extends string,\n T extends (params: SwapKitPluginParams) => Record<string, unknown>,\n K extends { supportedSwapkitProviders?: (ProviderName | string)[] },\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 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 SKPlugins[P];\n}\n"
6
+ ],
7
+ "mappings": "mqBAGO,SAAS,CAIf,EAAG,OAAM,aAAY,WAAuD,CAC3E,SAAS,CAAM,CAAC,EAAmC,CACjD,MAAO,IAAK,EAAQ,CAAY,KAAM,CAAW,EAGnD,MAAO,EAAG,GAAO,CAAO,EAG1B,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": "02AEC6FD9069CF5D64756E2164756E21",
9
+ "names": []
10
+ }
@@ -1,4 +1,4 @@
1
- var E={};V(E,{EVMPlugin:()=>l});module.exports=m(E);var e=require("@swapkit/helpers");function v({approveMode:a,getWallet:c}){return function n({assetValue:s,spenderAddress:t}){let p=s.chain,r=e.EVMChains.includes(p);if(r&&s.isGasAsset||!r||s.isSynthetic){let d=a==="checkOnly"||"approved";return Promise.resolve(d)}let o=c(p),i=a==="checkOnly"?o.isApproved:o.approve;if(!(s.address&&o.address))throw new e.SwapKitError("core_approve_asset_address_or_from_not_found");return i({amount:s.getBaseValue("bigint"),assetAddress:s.address,from:o.address,spenderAddress:t})}}var l=e.createPlugin({name:"evm",properties:{supportedSwapkitProviders:[e.ProviderName.CAMELOT_V3,e.ProviderName.OPENOCEAN_V2,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]},methods:({getWallet:a})=>({approveAssetValue:v({approveMode:e.ApproveMode.Approve,getWallet:a}),isAssetValueApproved:v({approveMode:e.ApproveMode.CheckOnly,getWallet:a}),swap:async function c({route:{tx:n,sellAsset:s},feeOptionKey:t}){let r=(await e.AssetValue.from({asset:s,asyncTokenLookup:!0})).chain,u=a(r);if(!(e.EVMChains.includes(r)&&n))throw new e.SwapKitError("core_swap_invalid_params");let{from:o,to:i,data:d,value:A}=n;return u.sendTransaction({from:o,to:i,data:d,value:BigInt(A),feeOptionKey:t})}})});
1
+ var w={};l(w,{EVMPlugin:()=>E});module.exports=V(w);var e=require("@swapkit/helpers");function v({approveMode:o,getWallet:c}){return function t({assetValue:s,spenderAddress:n}){let p=s.chain,a=e.EVMChains.includes(p);if(a&&s.isGasAsset||!a||s.isSynthetic){let d=o==="checkOnly"||"approved";return Promise.resolve(d)}let r=c(p),i=o==="checkOnly"?r.isApproved:r.approve;if(!(s.address&&r.address))throw new e.SwapKitError("core_approve_asset_address_or_from_not_found");return i({amount:s.getBaseValue("bigint"),assetAddress:s.address,from:r.address,spenderAddress:n})}}var E=m({name:"evm",properties:{supportedSwapkitProviders:[e.ProviderName.CAMELOT_V3,e.ProviderName.OPENOCEAN_V2,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]},methods:({getWallet:o})=>({approveAssetValue:v({approveMode:e.ApproveMode.Approve,getWallet:o}),isAssetValueApproved:v({approveMode:e.ApproveMode.CheckOnly,getWallet:o}),swap:async function c({route:{tx:t,sellAsset:s},feeOptionKey:n}){let a=(await e.AssetValue.from({asset:s,asyncTokenLookup:!0})).chain,u=o(a);if(!(e.EVMChains.includes(a)&&t))throw new e.SwapKitError("core_swap_invalid_params");let{from:r,to:i,data:d,value:A}=t;return u.sendTransaction({from:r,to:i,data:d,value:BigInt(A),feeOptionKey:n})}})});
2
2
 
3
- //# debugId=FDF9BDCE1CF4B05064756E2164756E21
3
+ //# debugId=AED96F017E783F9164756E2164756E21
4
4
  //# sourceMappingURL=index.cjs.map
@@ -2,9 +2,9 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/evm/index.ts"],
4
4
  "sourcesContent": [
5
- "import {\n ApproveMode,\n type ApproveReturnType,\n AssetValue,\n type EVMChain,\n EVMChains,\n ProviderName,\n SwapKitError,\n type SwapKitPluginParams,\n type SwapParams,\n createPlugin,\n} from \"@swapkit/helpers\";\nimport type { EVMTransaction, QuoteResponseRoute } from \"@swapkit/helpers/api\";\n\nfunction approve<T extends ApproveMode>({\n approveMode,\n getWallet,\n}: { approveMode: T } & SwapKitPluginParams) {\n return function approveEVM({\n assetValue,\n spenderAddress,\n }: { 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 SwapKitError(\"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\nexport const EVMPlugin = createPlugin({\n name: \"evm\",\n properties: {\n supportedSwapkitProviders: [\n ProviderName.CAMELOT_V3,\n ProviderName.OPENOCEAN_V2,\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 ],\n },\n methods: ({ getWallet }) => ({\n approveAssetValue: approve({ approveMode: ApproveMode.Approve, getWallet }),\n isAssetValueApproved: approve({ approveMode: ApproveMode.CheckOnly, getWallet }),\n swap: async function evmSwap({\n route: { tx, sellAsset },\n feeOptionKey,\n }: 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 SwapKitError(\"core_swap_invalid_params\");\n }\n\n const { from, to, data, value } = tx as EVMTransaction;\n return wallet.sendTransaction({ from, to, data, value: BigInt(value), feeOptionKey });\n },\n }),\n});\n"
5
+ "import {\n ApproveMode,\n type ApproveReturnType,\n AssetValue,\n type EVMChain,\n EVMChains,\n ProviderName,\n SwapKitError,\n type SwapParams,\n} from \"@swapkit/helpers\";\nimport type { EVMTransaction, QuoteResponseRoute } from \"@swapkit/helpers/api\";\nimport type { SwapKitPluginParams } from \"../types\";\nimport { createPlugin } from \"../utils\";\n\nfunction approve<T extends ApproveMode>({\n approveMode,\n getWallet,\n}: { approveMode: T } & SwapKitPluginParams) {\n return function approveEVM({\n assetValue,\n spenderAddress,\n }: { 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 SwapKitError(\"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\nexport const EVMPlugin = createPlugin({\n name: \"evm\",\n properties: {\n supportedSwapkitProviders: [\n ProviderName.CAMELOT_V3,\n ProviderName.OPENOCEAN_V2,\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 ],\n },\n methods: ({ getWallet }) => ({\n approveAssetValue: approve({ approveMode: ApproveMode.Approve, getWallet }),\n isAssetValueApproved: approve({ approveMode: ApproveMode.CheckOnly, getWallet }),\n swap: async function evmSwap({\n route: { tx, sellAsset },\n feeOptionKey,\n }: 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 SwapKitError(\"core_swap_invalid_params\");\n }\n\n const { from, to, data, value } = tx as EVMTransaction;\n return wallet.sendTransaction({ from, to, data, value: BigInt(value), feeOptionKey });\n },\n }),\n});\n"
6
6
  ],
7
- "mappings": "oDAWO,IAXP,8BAcA,SAAS,CAA8B,EACrC,cACA,aAC2C,CAC3C,OAAO,SAAS,CAAU,EACxB,aACA,kBACqD,CACrD,IAAM,EAAW,EAAW,MACtB,EAAa,YAAU,SAAS,CAAQ,EAG9C,GAFoB,GAAc,EAAW,aAEzB,GAAc,EAAW,YAAa,CACxD,IAAM,EAAa,IAAgB,aAAe,WAClD,OAAO,QAAQ,QAAQ,CAAU,EAGnC,IAAM,EAAS,EAAU,CAAQ,EAC3B,EAAe,IAAgB,YAAc,EAAO,WAAa,EAAO,QAE9E,KAAM,EAAW,SAAW,EAAO,SACjC,MAAM,IAAI,eAAa,8CAA8C,EAGvE,OAAO,EAAa,CAClB,OAAQ,EAAW,aAAa,QAAQ,EACxC,aAAc,EAAW,QACzB,KAAM,EAAO,QACb,gBACF,CAAC,GAIE,IAAM,EAAY,eAAa,CACpC,KAAM,MACN,WAAY,CACV,0BAA2B,CACzB,eAAa,WACb,eAAa,aACb,eAAa,QACb,eAAa,YACb,eAAa,YACb,eAAa,aACb,eAAa,aACb,eAAa,WACb,eAAa,UACf,CACF,EACA,QAAS,EAAG,gBAAiB,CAC3B,kBAAmB,EAAQ,CAAE,YAAa,cAAY,QAAS,WAAU,CAAC,EAC1E,qBAAsB,EAAQ,CAAE,YAAa,cAAY,UAAW,WAAU,CAAC,EAC/E,KAAM,eAAe,CAAO,EAC1B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Ae,CAAO,EAC1B,OAAS,KAAI,aACb,gBACwC,CAExC,IAAM,GADa,MAAM,aAAW,KAAK,CAAE,MAAO,EAAW,iBAAkB,EAAK,CAAC,GACzD,MACtB,EAAS,EAAU,CAAQ,EAEjC,KAAM,YAAU,SAAS,CAAQ,GAAK,GACpC,MAAM,IAAI,eAAa,0BAA0B,EAGnD,IAAQ,OAAM,KAAI,OAAM,SAAU,EAClC,OAAO,EAAO,gBAAgB,CAAE,OAAM,KAAI,OAAM,MAAO,OAAO,CAAK,EAAG,cAAa,CAAC,EAExF,EACF,CAAC",
8
+ "debugId": "AED96F017E783F9164756E2164756E21",
9
9
  "names": []
10
10
  }
package/dist/evm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import"../chunk-wfktpptf.js";import{ApproveMode as v,AssetValue as E,EVMChains as m,ProviderName as e,SwapKitError as V,createPlugin as w}from"@swapkit/helpers";function A({approveMode:a,getWallet:c}){return function n({assetValue:s,spenderAddress:t}){let p=s.chain,r=m.includes(p);if(r&&s.isGasAsset||!r||s.isSynthetic){let d=a==="checkOnly"||"approved";return Promise.resolve(d)}let o=c(p),i=a==="checkOnly"?o.isApproved:o.approve;if(!(s.address&&o.address))throw new V("core_approve_asset_address_or_from_not_found");return i({amount:s.getBaseValue("bigint"),assetAddress:s.address,from:o.address,spenderAddress:t})}}var h=w({name:"evm",properties:{supportedSwapkitProviders:[e.CAMELOT_V3,e.OPENOCEAN_V2,e.ONEINCH,e.PANCAKESWAP,e.PANGOLIN_V1,e.SUSHISWAP_V2,e.TRADERJOE_V2,e.UNISWAP_V2,e.UNISWAP_V3]},methods:({getWallet:a})=>({approveAssetValue:A({approveMode:v.Approve,getWallet:a}),isAssetValueApproved:A({approveMode:v.CheckOnly,getWallet:a}),swap:async function c({route:{tx:n,sellAsset:s},feeOptionKey:t}){let r=(await E.from({asset:s,asyncTokenLookup:!0})).chain,u=a(r);if(!(m.includes(r)&&n))throw new V("core_swap_invalid_params");let{from:o,to:i,data:d,value:l}=n;return u.sendTransaction({from:o,to:i,data:d,value:BigInt(l),feeOptionKey:t})}})});export{h as EVMPlugin};
1
+ import{c as l}from"../chunk-hzmkxs26.js";import{ApproveMode as v,AssetValue as w,EVMChains as A,ProviderName as e,SwapKitError as V}from"@swapkit/helpers";function m({approveMode:o,getWallet:c}){return function t({assetValue:s,spenderAddress:n}){let p=s.chain,a=A.includes(p);if(a&&s.isGasAsset||!a||s.isSynthetic){let d=o==="checkOnly"||"approved";return Promise.resolve(d)}let r=c(p),i=o==="checkOnly"?r.isApproved:r.approve;if(!(s.address&&r.address))throw new V("core_approve_asset_address_or_from_not_found");return i({amount:s.getBaseValue("bigint"),assetAddress:s.address,from:r.address,spenderAddress:n})}}var _=l({name:"evm",properties:{supportedSwapkitProviders:[e.CAMELOT_V3,e.OPENOCEAN_V2,e.ONEINCH,e.PANCAKESWAP,e.PANGOLIN_V1,e.SUSHISWAP_V2,e.TRADERJOE_V2,e.UNISWAP_V2,e.UNISWAP_V3]},methods:({getWallet:o})=>({approveAssetValue:m({approveMode:v.Approve,getWallet:o}),isAssetValueApproved:m({approveMode:v.CheckOnly,getWallet:o}),swap:async function c({route:{tx:t,sellAsset:s},feeOptionKey:n}){let a=(await w.from({asset:s,asyncTokenLookup:!0})).chain,u=o(a);if(!(A.includes(a)&&t))throw new V("core_swap_invalid_params");let{from:r,to:i,data:d,value:E}=t;return u.sendTransaction({from:r,to:i,data:d,value:BigInt(E),feeOptionKey:n})}})});export{_ as EVMPlugin};
2
2
 
3
- //# debugId=E47DB87BB400068364756E2164756E21
3
+ //# debugId=15C981C390DE2DAE64756E2164756E21
4
4
  //# sourceMappingURL=index.js.map
@@ -2,9 +2,9 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/evm/index.ts"],
4
4
  "sourcesContent": [
5
- "import {\n ApproveMode,\n type ApproveReturnType,\n AssetValue,\n type EVMChain,\n EVMChains,\n ProviderName,\n SwapKitError,\n type SwapKitPluginParams,\n type SwapParams,\n createPlugin,\n} from \"@swapkit/helpers\";\nimport type { EVMTransaction, QuoteResponseRoute } from \"@swapkit/helpers/api\";\n\nfunction approve<T extends ApproveMode>({\n approveMode,\n getWallet,\n}: { approveMode: T } & SwapKitPluginParams) {\n return function approveEVM({\n assetValue,\n spenderAddress,\n }: { 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 SwapKitError(\"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\nexport const EVMPlugin = createPlugin({\n name: \"evm\",\n properties: {\n supportedSwapkitProviders: [\n ProviderName.CAMELOT_V3,\n ProviderName.OPENOCEAN_V2,\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 ],\n },\n methods: ({ getWallet }) => ({\n approveAssetValue: approve({ approveMode: ApproveMode.Approve, getWallet }),\n isAssetValueApproved: approve({ approveMode: ApproveMode.CheckOnly, getWallet }),\n swap: async function evmSwap({\n route: { tx, sellAsset },\n feeOptionKey,\n }: 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 SwapKitError(\"core_swap_invalid_params\");\n }\n\n const { from, to, data, value } = tx as EVMTransaction;\n return wallet.sendTransaction({ from, to, data, value: BigInt(value), feeOptionKey });\n },\n }),\n});\n"
5
+ "import {\n ApproveMode,\n type ApproveReturnType,\n AssetValue,\n type EVMChain,\n EVMChains,\n ProviderName,\n SwapKitError,\n type SwapParams,\n} from \"@swapkit/helpers\";\nimport type { EVMTransaction, QuoteResponseRoute } from \"@swapkit/helpers/api\";\nimport type { SwapKitPluginParams } from \"../types\";\nimport { createPlugin } from \"../utils\";\n\nfunction approve<T extends ApproveMode>({\n approveMode,\n getWallet,\n}: { approveMode: T } & SwapKitPluginParams) {\n return function approveEVM({\n assetValue,\n spenderAddress,\n }: { 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 SwapKitError(\"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\nexport const EVMPlugin = createPlugin({\n name: \"evm\",\n properties: {\n supportedSwapkitProviders: [\n ProviderName.CAMELOT_V3,\n ProviderName.OPENOCEAN_V2,\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 ],\n },\n methods: ({ getWallet }) => ({\n approveAssetValue: approve({ approveMode: ApproveMode.Approve, getWallet }),\n isAssetValueApproved: approve({ approveMode: ApproveMode.CheckOnly, getWallet }),\n swap: async function evmSwap({\n route: { tx, sellAsset },\n feeOptionKey,\n }: 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 SwapKitError(\"core_swap_invalid_params\");\n }\n\n const { from, to, data, value } = tx as EVMTransaction;\n return wallet.sendTransaction({ from, to, data, value: BigInt(value), feeOptionKey });\n },\n }),\n});\n"
6
6
  ],
7
- "mappings": "6BAAA,sBACE,gBAEA,eAEA,kBACA,kBACA,kBAGA,yBAIF,SAAS,CAA8B,EACrC,cACA,aAC2C,CAC3C,OAAO,SAAS,CAAU,EACxB,aACA,kBACqD,CACrD,IAAM,EAAW,EAAW,MACtB,EAAa,EAAU,SAAS,CAAQ,EAG9C,GAFoB,GAAc,EAAW,aAEzB,GAAc,EAAW,YAAa,CACxD,IAAM,EAAa,IAAgB,aAAe,WAClD,OAAO,QAAQ,QAAQ,CAAU,EAGnC,IAAM,EAAS,EAAU,CAAQ,EAC3B,EAAe,IAAgB,YAAc,EAAO,WAAa,EAAO,QAE9E,KAAM,EAAW,SAAW,EAAO,SACjC,MAAM,IAAI,EAAa,8CAA8C,EAGvE,OAAO,EAAa,CAClB,OAAQ,EAAW,aAAa,QAAQ,EACxC,aAAc,EAAW,QACzB,KAAM,EAAO,QACb,gBACF,CAAC,GAIE,IAAM,EAAY,EAAa,CACpC,KAAM,MACN,WAAY,CACV,0BAA2B,CACzB,EAAa,WACb,EAAa,aACb,EAAa,QACb,EAAa,YACb,EAAa,YACb,EAAa,aACb,EAAa,aACb,EAAa,WACb,EAAa,UACf,CACF,EACA,QAAS,EAAG,gBAAiB,CAC3B,kBAAmB,EAAQ,CAAE,YAAa,EAAY,QAAS,WAAU,CAAC,EAC1E,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YAAa,EAAY,QAAS,WAAU,CAAC,EAC1E,qBAAsB,EAAQ,CAAE,YAAa,EAAY,UAAW,WAAU,CAAC,EAC/E,KAAM,eAAe,CAAO,EAC1B,OAAS,KAAI,aACb,gBACwC,CAExC,IAAM,GADa,MAAM,EAAW,KAAK,CAAE,MAAO,EAAW,iBAAkB,EAAK,CAAC,GACzD,MACtB,EAAS,EAAU,CAAQ,EAEjC,KAAM,EAAU,SAAS,CAAQ,GAAK,GACpC,MAAM,IAAI,EAAa,0BAA0B,EAGnD,IAAQ,OAAM,KAAI,OAAM,SAAU,EAClC,OAAO,EAAO,gBAAgB,CAAE,OAAM,KAAI,OAAM,MAAO,OAAO,CAAK,EAAG,cAAa,CAAC,EAExF,EACF,CAAC",
8
+ "debugId": "15C981C390DE2DAE64756E2164756E21",
9
9
  "names": []
10
10
  }
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- var p={};e(p,{loadPlugin:()=>o});module.exports=r(p);async function o(t){let{match:a}=await import("ts-pattern");return await a(t).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()}
1
+ var e={};p(e,{loadPlugin:()=>o,createPlugin:()=>i});module.exports=t(e);
2
2
 
3
- //# debugId=A3E8E694D24EF52A64756E2164756E21
3
+ //# debugId=98BC382EEFD78AD264756E2164756E21
4
4
  //# sourceMappingURL=index.cjs.map
@@ -1,10 +1,9 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../src/utils.ts"],
3
+ "sources": [],
4
4
  "sourcesContent": [
5
- "import type { PluginName, SKPlugins } from \"./types\";\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 SKPlugins[P];\n}\n"
6
5
  ],
7
- "mappings": "qDAEA,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": "A3E8E694D24EF52A64756E2164756E21",
6
+ "mappings": "",
7
+ "debugId": "98BC382EEFD78AD264756E2164756E21",
9
8
  "names": []
10
9
  }
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import{a as n,b as t}from"./chunk-wfktpptf.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};
1
+ import{c as o,d as e}from"./chunk-hzmkxs26.js";export{e as loadPlugin,o as createPlugin};
2
2
 
3
- //# debugId=FA0901EFAAEE532D64756E2164756E21
3
+ //# debugId=B5B58507827190F964756E2164756E21
4
4
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1,10 +1,9 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../src/utils.ts"],
3
+ "sources": [],
4
4
  "sourcesContent": [
5
- "import type { PluginName, SKPlugins } from \"./types\";\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 SKPlugins[P];\n}\n"
6
5
  ],
7
- "mappings": "+CAEA,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": "FA0901EFAAEE532D64756E2164756E21",
6
+ "mappings": "",
7
+ "debugId": "B5B58507827190F964756E2164756E21",
9
8
  "names": []
10
9
  }
@@ -1,4 +1,4 @@
1
- var S={};g(S,{NearPlugin:()=>y});module.exports=d(S);var r=require("@swapkit/helpers"),w=require("@swapkit/helpers/api");var u=require("near-api-js/lib/utils/format"),m=2,f=64;function i(o){if(o.length<m||o.length>f)return!1;return/^[a-z0-9]+(-[a-z0-9]+)*$/.test(o)}function p(o){let t=o.length,e;if(t<=2)e="50";else if(t<=3)e="20";else if(t<=4)e="5";else if(t<=5)e="1";else e="0.1";return u.parseNearAmount(e)||"0"}var y=r.createPlugin({name:"near",properties:{supportedSwapkitProviders:[r.ProviderName.NEAR]},methods:({getWallet:o})=>({async swap(t){let{route:{buyAsset:e,sellAsset:n,sellAmount:a,meta:{near:s}}}=t;if(!(n&&e&&s?.sellAsset))throw new r.SwapKitError("core_swap_asset_not_recognized");let l=await r.AssetValue.from({asyncTokenLookup:!0,asset:n,value:a}),c=o(l.chain);if(!c)throw new r.SwapKitError("core_wallet_connection_not_found");let{depositAddress:_}=await w.SwapKitApi.getNearDepositChannel(s);return await c.transfer({assetValue:l,recipient:_,isProgramDerivedAddress:!0})},nearNames:{async resolve(t){try{let e=t.toLowerCase().replace(/\.near$/,"");if(!i(e))throw new r.SwapKitError("plugin_near_invalid_name");let n=o(r.Chain.Near);if(!n)throw new r.SwapKitError("plugin_near_no_connection");let a=await n.provider.query({request_type:"call_function",finality:"final",account_id:"near",method_name:"resolve",args_base64:Buffer.from(JSON.stringify({name:e})).toString("base64")});return JSON.parse(Buffer.from(a.result).toString())?.owner||null}catch{return null}},async isAvailable(t){return await this.resolve(t)===null},async getInfo(t){try{let e=t.toLowerCase().replace(/\.near$/,"");if(!i(e))throw new r.SwapKitError("plugin_near_invalid_name");let n=o(r.Chain.Near);if(!n)throw new r.SwapKitError("plugin_near_no_connection");let a=await n.provider.query({request_type:"call_function",finality:"final",account_id:"near",method_name:"get_info",args_base64:Buffer.from(JSON.stringify({name:e})).toString("base64")});return JSON.parse(Buffer.from(a.result).toString())||null}catch{return null}},async lookupNames(t){try{let e=o(r.Chain.Near);if(!e)throw new r.SwapKitError("plugin_near_no_connection");let n=await e.provider.query({request_type:"call_function",finality:"final",account_id:"near",method_name:"get_names_by_owner",args_base64:Buffer.from(JSON.stringify({account_id:t})).toString("base64")}),a=JSON.parse(Buffer.from(n.result).toString());return Array.isArray(a)?a.map((s)=>`${s}.near`):[]}catch{return[]}},async register(t){let{name:e,publicKey:n}=t,a=e.toLowerCase().replace(/\.near$/,"");if(!i(a))throw new r.SwapKitError("plugin_near_invalid_name");let s=o(r.Chain.Near),l=n||await s.getPublicKey(),c=p(a);return s.callFunction({contractId:"near",methodName:"create_account",args:{new_account_id:`${a}.near`,new_public_key:l},deposit:c})},transfer(t,e){let n=t.toLowerCase().replace(/\.near$/,"");if(!i(n))throw new r.SwapKitError("plugin_near_invalid_name");return o(r.Chain.Near).callFunction({contractId:"near",methodName:"transfer",args:{name:n,new_owner:e},deposit:"1"})}}})});
1
+ var N={};S(N,{NearPlugin:()=>d});module.exports=g(N);var r=require("@swapkit/helpers"),w=require("@swapkit/helpers/api");var u=require("near-api-js/lib/utils/format"),f=2,y=64;function i(o){if(o.length<f||o.length>y)return!1;return/^[a-z0-9]+(-[a-z0-9]+)*$/.test(o)}function p(o){let t=o.length,e;if(t<=2)e="50";else if(t<=3)e="20";else if(t<=4)e="5";else if(t<=5)e="1";else e="0.1";return u.parseNearAmount(e)||"0"}var d=m({name:"near",properties:{supportedSwapkitProviders:[r.ProviderName.NEAR]},methods:({getWallet:o})=>({async swap(t){let{route:{buyAsset:e,sellAsset:n,sellAmount:a,meta:{near:s}}}=t;if(!(n&&e&&s?.sellAsset))throw new r.SwapKitError("core_swap_asset_not_recognized");let l=await r.AssetValue.from({asyncTokenLookup:!0,asset:n,value:a}),c=o(l.chain);if(!c)throw new r.SwapKitError("core_wallet_connection_not_found");let{depositAddress:_}=await w.SwapKitApi.getNearDepositChannel(s);return await c.transfer({assetValue:l,recipient:_,isProgramDerivedAddress:!0})},nearNames:{async resolve(t){try{let e=t.toLowerCase().replace(/\.near$/,"");if(!i(e))throw new r.SwapKitError("plugin_near_invalid_name");let n=o(r.Chain.Near);if(!n)throw new r.SwapKitError("plugin_near_no_connection");let a=await n.provider.query({request_type:"call_function",finality:"final",account_id:"near",method_name:"resolve",args_base64:Buffer.from(JSON.stringify({name:e})).toString("base64")});return JSON.parse(Buffer.from(a.result).toString())?.owner||null}catch{return null}},async isAvailable(t){return await this.resolve(t)===null},async getInfo(t){try{let e=t.toLowerCase().replace(/\.near$/,"");if(!i(e))throw new r.SwapKitError("plugin_near_invalid_name");let n=o(r.Chain.Near);if(!n)throw new r.SwapKitError("plugin_near_no_connection");let a=await n.provider.query({request_type:"call_function",finality:"final",account_id:"near",method_name:"get_info",args_base64:Buffer.from(JSON.stringify({name:e})).toString("base64")});return JSON.parse(Buffer.from(a.result).toString())||null}catch{return null}},async lookupNames(t){try{let e=o(r.Chain.Near);if(!e)throw new r.SwapKitError("plugin_near_no_connection");let n=await e.provider.query({request_type:"call_function",finality:"final",account_id:"near",method_name:"get_names_by_owner",args_base64:Buffer.from(JSON.stringify({account_id:t})).toString("base64")}),a=JSON.parse(Buffer.from(n.result).toString());return Array.isArray(a)?a.map((s)=>`${s}.near`):[]}catch{return[]}},async register(t){let{name:e,publicKey:n}=t,a=e.toLowerCase().replace(/\.near$/,"");if(!i(a))throw new r.SwapKitError("plugin_near_invalid_name");let s=o(r.Chain.Near),l=n||await s.getPublicKey(),c=p(a);return s.callFunction({contractId:"near",methodName:"create_account",args:{new_account_id:`${a}.near`,new_public_key:l},deposit:c})},transfer(t,e){let n=t.toLowerCase().replace(/\.near$/,"");if(!i(n))throw new r.SwapKitError("plugin_near_invalid_name");return o(r.Chain.Near).callFunction({contractId:"near",methodName:"transfer",args:{name:n,new_owner:e},deposit:"1"})}}})});
2
2
 
3
- //# debugId=425E65333AF45BC164756E2164756E21
3
+ //# debugId=50F95822C2C5EE5864756E2164756E21
4
4
  //# sourceMappingURL=index.cjs.map
@@ -2,10 +2,10 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/near/plugin.ts", "../src/near/nearNames.ts"],
4
4
  "sourcesContent": [
5
- "import {\n AssetValue,\n Chain,\n type CryptoChain,\n ProviderName,\n SwapKitError,\n type SwapParams,\n createPlugin,\n} from \"@swapkit/helpers\";\nimport { type QuoteResponseRoute, SwapKitApi } from \"@swapkit/helpers/api\";\nimport type { NearWallet } from \"@swapkit/toolboxes/near\";\nimport { calculateNearNameCost, validateNearName } from \"./nearNames\";\nimport type { NearNameRegistrationParams } from \"./types\";\n\nexport const NearPlugin = createPlugin({\n name: \"near\",\n properties: {\n supportedSwapkitProviders: [ProviderName.NEAR],\n },\n methods: ({ getWallet }) => ({\n async swap(swapParams: SwapParams<\"near\", QuoteResponseRoute>) {\n const {\n route: {\n buyAsset: buyAssetString,\n sellAsset: sellAssetString,\n sellAmount,\n meta: { near },\n },\n } = swapParams;\n\n if (!(sellAssetString && buyAssetString && near?.sellAsset)) {\n throw new SwapKitError(\"core_swap_asset_not_recognized\");\n }\n\n const sellAsset = await AssetValue.from({\n asyncTokenLookup: true,\n asset: sellAssetString,\n value: sellAmount,\n });\n\n const wallet = getWallet(sellAsset.chain as Exclude<CryptoChain, Chain.Radix>);\n\n if (!wallet) {\n throw new SwapKitError(\"core_wallet_connection_not_found\");\n }\n\n const { depositAddress } = await SwapKitApi.getNearDepositChannel(near);\n\n const tx = await wallet.transfer({\n assetValue: sellAsset,\n recipient: depositAddress,\n isProgramDerivedAddress: true,\n });\n\n return tx as string;\n },\n\n // NEAR Names functionality\n nearNames: {\n async resolve(name: string) {\n try {\n const normalizedName = name.toLowerCase().replace(/\\.near$/, \"\");\n\n if (!validateNearName(normalizedName)) {\n throw new SwapKitError(\"plugin_near_invalid_name\");\n }\n\n const wallet = getWallet(Chain.Near);\n\n if (!wallet) {\n throw new SwapKitError(\"plugin_near_no_connection\");\n }\n\n const result = await wallet.provider.query({\n request_type: \"call_function\",\n finality: \"final\",\n account_id: \"near\",\n method_name: \"resolve\",\n args_base64: Buffer.from(JSON.stringify({ name: normalizedName })).toString(\"base64\"),\n });\n\n const response = JSON.parse(Buffer.from((result as any).result).toString());\n return response?.owner || null;\n } catch {\n return null;\n }\n },\n\n async isAvailable(name: string) {\n const owner = await this.resolve(name);\n return owner === null;\n },\n\n async getInfo(name: string) {\n try {\n const normalizedName = name.toLowerCase().replace(/\\.near$/, \"\");\n\n if (!validateNearName(normalizedName)) {\n throw new SwapKitError(\"plugin_near_invalid_name\");\n }\n\n const wallet = getWallet(Chain.Near);\n\n if (!wallet) {\n throw new SwapKitError(\"plugin_near_no_connection\");\n }\n\n const result = await wallet.provider.query({\n request_type: \"call_function\",\n finality: \"final\",\n account_id: \"near\",\n method_name: \"get_info\",\n args_base64: Buffer.from(JSON.stringify({ name: normalizedName })).toString(\"base64\"),\n });\n\n const response = JSON.parse(Buffer.from((result as any).result).toString());\n return response || null;\n } catch {\n return null;\n }\n },\n\n async lookupNames(accountId: string) {\n try {\n const wallet = getWallet(Chain.Near);\n\n if (!wallet) {\n throw new SwapKitError(\"plugin_near_no_connection\");\n }\n\n const result = await wallet.provider.query({\n request_type: \"call_function\",\n finality: \"final\",\n account_id: \"near\",\n method_name: \"get_names_by_owner\",\n args_base64: Buffer.from(JSON.stringify({ account_id: accountId })).toString(\"base64\"),\n });\n\n const response = JSON.parse(Buffer.from((result as any).result).toString());\n return Array.isArray(response) ? response.map((n) => `${n}.near`) : [];\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 SwapKitError(\"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 contractId: \"near\",\n methodName: \"create_account\",\n args: {\n new_account_id: `${normalizedName}.near`,\n new_public_key: newPublicKey,\n },\n deposit: cost,\n });\n },\n\n transfer(name: string, newOwner: string) {\n const normalizedName = name.toLowerCase().replace(/\\.near$/, \"\");\n\n if (!validateNearName(normalizedName)) {\n throw new SwapKitError(\"plugin_near_invalid_name\");\n }\n\n const wallet = getWallet(Chain.Near) as NearWallet;\n\n return wallet.callFunction({\n contractId: \"near\",\n methodName: \"transfer\",\n args: {\n name: normalizedName,\n new_owner: newOwner,\n },\n deposit: \"1\",\n });\n },\n },\n }),\n});\n",
5
+ "import {\n AssetValue,\n Chain,\n type CryptoChain,\n ProviderName,\n SwapKitError,\n type SwapParams,\n} from \"@swapkit/helpers\";\nimport { type QuoteResponseRoute, SwapKitApi } from \"@swapkit/helpers/api\";\nimport type { NearWallet } from \"@swapkit/toolboxes/near\";\nimport { createPlugin } from \"../utils\";\nimport { calculateNearNameCost, validateNearName } from \"./nearNames\";\nimport type { NearNameRegistrationParams } from \"./types\";\n\nexport const NearPlugin = createPlugin({\n name: \"near\",\n properties: {\n supportedSwapkitProviders: [ProviderName.NEAR],\n },\n methods: ({ getWallet }) => ({\n async swap(swapParams: SwapParams<\"near\", QuoteResponseRoute>) {\n const {\n route: {\n buyAsset: buyAssetString,\n sellAsset: sellAssetString,\n sellAmount,\n meta: { near },\n },\n } = swapParams;\n\n if (!(sellAssetString && buyAssetString && near?.sellAsset)) {\n throw new SwapKitError(\"core_swap_asset_not_recognized\");\n }\n\n const sellAsset = await AssetValue.from({\n asyncTokenLookup: true,\n asset: sellAssetString,\n value: sellAmount,\n });\n\n const wallet = getWallet(sellAsset.chain as Exclude<CryptoChain, Chain.Radix>);\n\n if (!wallet) {\n throw new SwapKitError(\"core_wallet_connection_not_found\");\n }\n\n const { depositAddress } = await SwapKitApi.getNearDepositChannel(near);\n\n const tx = await wallet.transfer({\n assetValue: sellAsset,\n recipient: depositAddress,\n isProgramDerivedAddress: true,\n });\n\n return tx as string;\n },\n\n // NEAR Names functionality\n nearNames: {\n async resolve(name: string) {\n try {\n const normalizedName = name.toLowerCase().replace(/\\.near$/, \"\");\n\n if (!validateNearName(normalizedName)) {\n throw new SwapKitError(\"plugin_near_invalid_name\");\n }\n\n const wallet = getWallet(Chain.Near);\n\n if (!wallet) {\n throw new SwapKitError(\"plugin_near_no_connection\");\n }\n\n const result = await wallet.provider.query({\n request_type: \"call_function\",\n finality: \"final\",\n account_id: \"near\",\n method_name: \"resolve\",\n args_base64: Buffer.from(JSON.stringify({ name: normalizedName })).toString(\"base64\"),\n });\n\n const response = JSON.parse(Buffer.from((result as any).result).toString());\n return response?.owner || null;\n } catch {\n return null;\n }\n },\n\n async isAvailable(name: string) {\n const owner = await this.resolve(name);\n return owner === null;\n },\n\n async getInfo(name: string) {\n try {\n const normalizedName = name.toLowerCase().replace(/\\.near$/, \"\");\n\n if (!validateNearName(normalizedName)) {\n throw new SwapKitError(\"plugin_near_invalid_name\");\n }\n\n const wallet = getWallet(Chain.Near);\n\n if (!wallet) {\n throw new SwapKitError(\"plugin_near_no_connection\");\n }\n\n const result = await wallet.provider.query({\n request_type: \"call_function\",\n finality: \"final\",\n account_id: \"near\",\n method_name: \"get_info\",\n args_base64: Buffer.from(JSON.stringify({ name: normalizedName })).toString(\"base64\"),\n });\n\n const response = JSON.parse(Buffer.from((result as any).result).toString());\n return response || null;\n } catch {\n return null;\n }\n },\n\n async lookupNames(accountId: string) {\n try {\n const wallet = getWallet(Chain.Near);\n\n if (!wallet) {\n throw new SwapKitError(\"plugin_near_no_connection\");\n }\n\n const result = await wallet.provider.query({\n request_type: \"call_function\",\n finality: \"final\",\n account_id: \"near\",\n method_name: \"get_names_by_owner\",\n args_base64: Buffer.from(JSON.stringify({ account_id: accountId })).toString(\"base64\"),\n });\n\n const response = JSON.parse(Buffer.from((result as any).result).toString());\n return Array.isArray(response) ? response.map((n) => `${n}.near`) : [];\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 SwapKitError(\"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 contractId: \"near\",\n methodName: \"create_account\",\n args: {\n new_account_id: `${normalizedName}.near`,\n new_public_key: newPublicKey,\n },\n deposit: cost,\n });\n },\n\n transfer(name: string, newOwner: string) {\n const normalizedName = name.toLowerCase().replace(/\\.near$/, \"\");\n\n if (!validateNearName(normalizedName)) {\n throw new SwapKitError(\"plugin_near_invalid_name\");\n }\n\n const wallet = getWallet(Chain.Near) as NearWallet;\n\n return wallet.callFunction({\n contractId: \"near\",\n methodName: \"transfer\",\n args: {\n name: normalizedName,\n new_owner: newOwner,\n },\n deposit: \"1\",\n });\n },\n },\n }),\n});\n",
6
6
  "import { parseNearAmount } from \"near-api-js/lib/utils/format\";\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
7
  ],
8
- "mappings": "qDAQO,IARP,8BASA,kCCTgC,IAAhC,0CAEM,EAAsB,EACtB,EAAsB,GAErB,SAAS,CAAgB,CAAC,EAAuB,CACtD,GAAI,EAAK,OAAS,GAAuB,EAAK,OAAS,EACrD,MAAO,GAMT,MAAO,2BAA2B,KAAK,CAAI,EAGtC,SAAS,CAAqB,CAAC,EAAsB,CAG1D,IAAM,EAAS,EAAK,OAEhB,EACJ,GAAI,GAAU,EACZ,EAAa,KACR,QAAI,GAAU,EACnB,EAAa,KACR,QAAI,GAAU,EACnB,EAAa,IACR,QAAI,GAAU,EACnB,EAAa,IAEb,OAAa,MAIf,OAAO,kBAAgB,CAAU,GAAK,IDrBjC,IAAM,EAAa,eAAa,CACrC,KAAM,OACN,WAAY,CACV,0BAA2B,CAAC,eAAa,IAAI,CAC/C,EACA,QAAS,EAAG,gBAAiB,MACrB,KAAI,CAAC,EAAoD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s,createPlugin as g}from"@swapkit/helpers";import{SwapKitApi as S}from"@swapkit/helpers/api";import{parseNearAmount as _}from"near-api-js/lib/utils/format";var m=2,f=64;function i(a){if(a.length<m||a.length>f)return!1;return/^[a-z0-9]+(-[a-z0-9]+)*$/.test(a)}function p(a){let r=a.length,e;if(r<=2)e="50";else if(r<=3)e="20";else if(r<=4)e="5";else if(r<=5)e="1";else e="0.1";return _(e)||"0"}var C=g({name:"near",properties:{supportedSwapkitProviders:[d.NEAR]},methods:({getWallet:a})=>({async swap(r){let{route:{buyAsset:e,sellAsset:t,sellAmount:n,meta:{near:o}}}=r;if(!(t&&e&&o?.sellAsset))throw new s("core_swap_asset_not_recognized");let c=await y.from({asyncTokenLookup:!0,asset:t,value:n}),u=a(c.chain);if(!u)throw new s("core_wallet_connection_not_found");let{depositAddress:w}=await S.getNearDepositChannel(o);return await u.transfer({assetValue:c,recipient:w,isProgramDerivedAddress:!0})},nearNames:{async resolve(r){try{let e=r.toLowerCase().replace(/\.near$/,"");if(!i(e))throw new s("plugin_near_invalid_name");let t=a(l.Near);if(!t)throw new s("plugin_near_no_connection");let n=await t.provider.query({request_type:"call_function",finality:"final",account_id:"near",method_name:"resolve",args_base64:Buffer.from(JSON.stringify({name:e})).toString("base64")});return JSON.parse(Buffer.from(n.result).toString())?.owner||null}catch{return null}},async isAvailable(r){return await this.resolve(r)===null},async getInfo(r){try{let e=r.toLowerCase().replace(/\.near$/,"");if(!i(e))throw new s("plugin_near_invalid_name");let t=a(l.Near);if(!t)throw new s("plugin_near_no_connection");let n=await t.provider.query({request_type:"call_function",finality:"final",account_id:"near",method_name:"get_info",args_base64:Buffer.from(JSON.stringify({name:e})).toString("base64")});return JSON.parse(Buffer.from(n.result).toString())||null}catch{return null}},async lookupNames(r){try{let e=a(l.Near);if(!e)throw new s("plugin_near_no_connection");let t=await e.provider.query({request_type:"call_function",finality:"final",account_id:"near",method_name:"get_names_by_owner",args_base64:Buffer.from(JSON.stringify({account_id:r})).toString("base64")}),n=JSON.parse(Buffer.from(t.result).toString());return Array.isArray(n)?n.map((o)=>`${o}.near`):[]}catch{return[]}},async register(r){let{name:e,publicKey:t}=r,n=e.toLowerCase().replace(/\.near$/,"");if(!i(n))throw new s("plugin_near_invalid_name");let o=a(l.Near),c=t||await o.getPublicKey(),u=p(n);return o.callFunction({contractId:"near",methodName:"create_account",args:{new_account_id:`${n}.near`,new_public_key:c},deposit:u})},transfer(r,e){let t=r.toLowerCase().replace(/\.near$/,"");if(!i(t))throw new s("plugin_near_invalid_name");return a(l.Near).callFunction({contractId:"near",methodName:"transfer",args:{name:t,new_owner:e},deposit:"1"})}}})});export{C as NearPlugin};
1
+ import{c as w}from"../chunk-hzmkxs26.js";import{AssetValue as d,Chain as l,ProviderName as g,SwapKitError as s}from"@swapkit/helpers";import{SwapKitApi as S}from"@swapkit/helpers/api";import{parseNearAmount as _}from"near-api-js/lib/utils/format";var f=2,y=64;function i(a){if(a.length<f||a.length>y)return!1;return/^[a-z0-9]+(-[a-z0-9]+)*$/.test(a)}function p(a){let r=a.length,e;if(r<=2)e="50";else if(r<=3)e="20";else if(r<=4)e="5";else if(r<=5)e="1";else e="0.1";return _(e)||"0"}var K=w({name:"near",properties:{supportedSwapkitProviders:[g.NEAR]},methods:({getWallet:a})=>({async swap(r){let{route:{buyAsset:e,sellAsset:t,sellAmount:n,meta:{near:o}}}=r;if(!(t&&e&&o?.sellAsset))throw new s("core_swap_asset_not_recognized");let c=await d.from({asyncTokenLookup:!0,asset:t,value:n}),u=a(c.chain);if(!u)throw new s("core_wallet_connection_not_found");let{depositAddress:m}=await S.getNearDepositChannel(o);return await u.transfer({assetValue:c,recipient:m,isProgramDerivedAddress:!0})},nearNames:{async resolve(r){try{let e=r.toLowerCase().replace(/\.near$/,"");if(!i(e))throw new s("plugin_near_invalid_name");let t=a(l.Near);if(!t)throw new s("plugin_near_no_connection");let n=await t.provider.query({request_type:"call_function",finality:"final",account_id:"near",method_name:"resolve",args_base64:Buffer.from(JSON.stringify({name:e})).toString("base64")});return JSON.parse(Buffer.from(n.result).toString())?.owner||null}catch{return null}},async isAvailable(r){return await this.resolve(r)===null},async getInfo(r){try{let e=r.toLowerCase().replace(/\.near$/,"");if(!i(e))throw new s("plugin_near_invalid_name");let t=a(l.Near);if(!t)throw new s("plugin_near_no_connection");let n=await t.provider.query({request_type:"call_function",finality:"final",account_id:"near",method_name:"get_info",args_base64:Buffer.from(JSON.stringify({name:e})).toString("base64")});return JSON.parse(Buffer.from(n.result).toString())||null}catch{return null}},async lookupNames(r){try{let e=a(l.Near);if(!e)throw new s("plugin_near_no_connection");let t=await e.provider.query({request_type:"call_function",finality:"final",account_id:"near",method_name:"get_names_by_owner",args_base64:Buffer.from(JSON.stringify({account_id:r})).toString("base64")}),n=JSON.parse(Buffer.from(t.result).toString());return Array.isArray(n)?n.map((o)=>`${o}.near`):[]}catch{return[]}},async register(r){let{name:e,publicKey:t}=r,n=e.toLowerCase().replace(/\.near$/,"");if(!i(n))throw new s("plugin_near_invalid_name");let o=a(l.Near),c=t||await o.getPublicKey(),u=p(n);return o.callFunction({contractId:"near",methodName:"create_account",args:{new_account_id:`${n}.near`,new_public_key:c},deposit:u})},transfer(r,e){let t=r.toLowerCase().replace(/\.near$/,"");if(!i(t))throw new s("plugin_near_invalid_name");return a(l.Near).callFunction({contractId:"near",methodName:"transfer",args:{name:t,new_owner:e},deposit:"1"})}}})});export{K as NearPlugin};
2
2
 
3
- //# debugId=21F9A07322F2947864756E2164756E21
3
+ //# debugId=B198351ED8F97D3564756E2164756E21
4
4
  //# sourceMappingURL=index.js.map
@@ -2,10 +2,10 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/near/plugin.ts", "../src/near/nearNames.ts"],
4
4
  "sourcesContent": [
5
- "import {\n AssetValue,\n Chain,\n type CryptoChain,\n ProviderName,\n SwapKitError,\n type SwapParams,\n createPlugin,\n} from \"@swapkit/helpers\";\nimport { type QuoteResponseRoute, SwapKitApi } from \"@swapkit/helpers/api\";\nimport type { NearWallet } from \"@swapkit/toolboxes/near\";\nimport { calculateNearNameCost, validateNearName } from \"./nearNames\";\nimport type { NearNameRegistrationParams } from \"./types\";\n\nexport const NearPlugin = createPlugin({\n name: \"near\",\n properties: {\n supportedSwapkitProviders: [ProviderName.NEAR],\n },\n methods: ({ getWallet }) => ({\n async swap(swapParams: SwapParams<\"near\", QuoteResponseRoute>) {\n const {\n route: {\n buyAsset: buyAssetString,\n sellAsset: sellAssetString,\n sellAmount,\n meta: { near },\n },\n } = swapParams;\n\n if (!(sellAssetString && buyAssetString && near?.sellAsset)) {\n throw new SwapKitError(\"core_swap_asset_not_recognized\");\n }\n\n const sellAsset = await AssetValue.from({\n asyncTokenLookup: true,\n asset: sellAssetString,\n value: sellAmount,\n });\n\n const wallet = getWallet(sellAsset.chain as Exclude<CryptoChain, Chain.Radix>);\n\n if (!wallet) {\n throw new SwapKitError(\"core_wallet_connection_not_found\");\n }\n\n const { depositAddress } = await SwapKitApi.getNearDepositChannel(near);\n\n const tx = await wallet.transfer({\n assetValue: sellAsset,\n recipient: depositAddress,\n isProgramDerivedAddress: true,\n });\n\n return tx as string;\n },\n\n // NEAR Names functionality\n nearNames: {\n async resolve(name: string) {\n try {\n const normalizedName = name.toLowerCase().replace(/\\.near$/, \"\");\n\n if (!validateNearName(normalizedName)) {\n throw new SwapKitError(\"plugin_near_invalid_name\");\n }\n\n const wallet = getWallet(Chain.Near);\n\n if (!wallet) {\n throw new SwapKitError(\"plugin_near_no_connection\");\n }\n\n const result = await wallet.provider.query({\n request_type: \"call_function\",\n finality: \"final\",\n account_id: \"near\",\n method_name: \"resolve\",\n args_base64: Buffer.from(JSON.stringify({ name: normalizedName })).toString(\"base64\"),\n });\n\n const response = JSON.parse(Buffer.from((result as any).result).toString());\n return response?.owner || null;\n } catch {\n return null;\n }\n },\n\n async isAvailable(name: string) {\n const owner = await this.resolve(name);\n return owner === null;\n },\n\n async getInfo(name: string) {\n try {\n const normalizedName = name.toLowerCase().replace(/\\.near$/, \"\");\n\n if (!validateNearName(normalizedName)) {\n throw new SwapKitError(\"plugin_near_invalid_name\");\n }\n\n const wallet = getWallet(Chain.Near);\n\n if (!wallet) {\n throw new SwapKitError(\"plugin_near_no_connection\");\n }\n\n const result = await wallet.provider.query({\n request_type: \"call_function\",\n finality: \"final\",\n account_id: \"near\",\n method_name: \"get_info\",\n args_base64: Buffer.from(JSON.stringify({ name: normalizedName })).toString(\"base64\"),\n });\n\n const response = JSON.parse(Buffer.from((result as any).result).toString());\n return response || null;\n } catch {\n return null;\n }\n },\n\n async lookupNames(accountId: string) {\n try {\n const wallet = getWallet(Chain.Near);\n\n if (!wallet) {\n throw new SwapKitError(\"plugin_near_no_connection\");\n }\n\n const result = await wallet.provider.query({\n request_type: \"call_function\",\n finality: \"final\",\n account_id: \"near\",\n method_name: \"get_names_by_owner\",\n args_base64: Buffer.from(JSON.stringify({ account_id: accountId })).toString(\"base64\"),\n });\n\n const response = JSON.parse(Buffer.from((result as any).result).toString());\n return Array.isArray(response) ? response.map((n) => `${n}.near`) : [];\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 SwapKitError(\"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 contractId: \"near\",\n methodName: \"create_account\",\n args: {\n new_account_id: `${normalizedName}.near`,\n new_public_key: newPublicKey,\n },\n deposit: cost,\n });\n },\n\n transfer(name: string, newOwner: string) {\n const normalizedName = name.toLowerCase().replace(/\\.near$/, \"\");\n\n if (!validateNearName(normalizedName)) {\n throw new SwapKitError(\"plugin_near_invalid_name\");\n }\n\n const wallet = getWallet(Chain.Near) as NearWallet;\n\n return wallet.callFunction({\n contractId: \"near\",\n methodName: \"transfer\",\n args: {\n name: normalizedName,\n new_owner: newOwner,\n },\n deposit: \"1\",\n });\n },\n },\n }),\n});\n",
5
+ "import {\n AssetValue,\n Chain,\n type CryptoChain,\n ProviderName,\n SwapKitError,\n type SwapParams,\n} from \"@swapkit/helpers\";\nimport { type QuoteResponseRoute, SwapKitApi } from \"@swapkit/helpers/api\";\nimport type { NearWallet } from \"@swapkit/toolboxes/near\";\nimport { createPlugin } from \"../utils\";\nimport { calculateNearNameCost, validateNearName } from \"./nearNames\";\nimport type { NearNameRegistrationParams } from \"./types\";\n\nexport const NearPlugin = createPlugin({\n name: \"near\",\n properties: {\n supportedSwapkitProviders: [ProviderName.NEAR],\n },\n methods: ({ getWallet }) => ({\n async swap(swapParams: SwapParams<\"near\", QuoteResponseRoute>) {\n const {\n route: {\n buyAsset: buyAssetString,\n sellAsset: sellAssetString,\n sellAmount,\n meta: { near },\n },\n } = swapParams;\n\n if (!(sellAssetString && buyAssetString && near?.sellAsset)) {\n throw new SwapKitError(\"core_swap_asset_not_recognized\");\n }\n\n const sellAsset = await AssetValue.from({\n asyncTokenLookup: true,\n asset: sellAssetString,\n value: sellAmount,\n });\n\n const wallet = getWallet(sellAsset.chain as Exclude<CryptoChain, Chain.Radix>);\n\n if (!wallet) {\n throw new SwapKitError(\"core_wallet_connection_not_found\");\n }\n\n const { depositAddress } = await SwapKitApi.getNearDepositChannel(near);\n\n const tx = await wallet.transfer({\n assetValue: sellAsset,\n recipient: depositAddress,\n isProgramDerivedAddress: true,\n });\n\n return tx as string;\n },\n\n // NEAR Names functionality\n nearNames: {\n async resolve(name: string) {\n try {\n const normalizedName = name.toLowerCase().replace(/\\.near$/, \"\");\n\n if (!validateNearName(normalizedName)) {\n throw new SwapKitError(\"plugin_near_invalid_name\");\n }\n\n const wallet = getWallet(Chain.Near);\n\n if (!wallet) {\n throw new SwapKitError(\"plugin_near_no_connection\");\n }\n\n const result = await wallet.provider.query({\n request_type: \"call_function\",\n finality: \"final\",\n account_id: \"near\",\n method_name: \"resolve\",\n args_base64: Buffer.from(JSON.stringify({ name: normalizedName })).toString(\"base64\"),\n });\n\n const response = JSON.parse(Buffer.from((result as any).result).toString());\n return response?.owner || null;\n } catch {\n return null;\n }\n },\n\n async isAvailable(name: string) {\n const owner = await this.resolve(name);\n return owner === null;\n },\n\n async getInfo(name: string) {\n try {\n const normalizedName = name.toLowerCase().replace(/\\.near$/, \"\");\n\n if (!validateNearName(normalizedName)) {\n throw new SwapKitError(\"plugin_near_invalid_name\");\n }\n\n const wallet = getWallet(Chain.Near);\n\n if (!wallet) {\n throw new SwapKitError(\"plugin_near_no_connection\");\n }\n\n const result = await wallet.provider.query({\n request_type: \"call_function\",\n finality: \"final\",\n account_id: \"near\",\n method_name: \"get_info\",\n args_base64: Buffer.from(JSON.stringify({ name: normalizedName })).toString(\"base64\"),\n });\n\n const response = JSON.parse(Buffer.from((result as any).result).toString());\n return response || null;\n } catch {\n return null;\n }\n },\n\n async lookupNames(accountId: string) {\n try {\n const wallet = getWallet(Chain.Near);\n\n if (!wallet) {\n throw new SwapKitError(\"plugin_near_no_connection\");\n }\n\n const result = await wallet.provider.query({\n request_type: \"call_function\",\n finality: \"final\",\n account_id: \"near\",\n method_name: \"get_names_by_owner\",\n args_base64: Buffer.from(JSON.stringify({ account_id: accountId })).toString(\"base64\"),\n });\n\n const response = JSON.parse(Buffer.from((result as any).result).toString());\n return Array.isArray(response) ? response.map((n) => `${n}.near`) : [];\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 SwapKitError(\"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 contractId: \"near\",\n methodName: \"create_account\",\n args: {\n new_account_id: `${normalizedName}.near`,\n new_public_key: newPublicKey,\n },\n deposit: cost,\n });\n },\n\n transfer(name: string, newOwner: string) {\n const normalizedName = name.toLowerCase().replace(/\\.near$/, \"\");\n\n if (!validateNearName(normalizedName)) {\n throw new SwapKitError(\"plugin_near_invalid_name\");\n }\n\n const wallet = getWallet(Chain.Near) as NearWallet;\n\n return wallet.callFunction({\n contractId: \"near\",\n methodName: \"transfer\",\n args: {\n name: normalizedName,\n new_owner: newOwner,\n },\n deposit: \"1\",\n });\n },\n },\n }),\n});\n",
6
6
  "import { parseNearAmount } from \"near-api-js/lib/utils/format\";\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
7
  ],
8
- "mappings": "6BAAA,qBACE,WACA,kBAEA,kBACA,kBAEA,yBAEF,qBAAkC,6BCTlC,0BAAS,qCAET,IAAM,EAAsB,EACtB,EAAsB,GAErB,SAAS,CAAgB,CAAC,EAAuB,CACtD,GAAI,EAAK,OAAS,GA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,QAAS,CACX,CAAC,GAGH,QAAQ,CAAC,EAAc,EAAkB,CACvC,IAAM,EAAiB,EAAK,YAAY,EAAE,QAAQ,UAAW,EAAE,EAE/D,IAAK,EAAiB,CAAc,EAClC,MAAM,IAAI,EAAa,0BAA0B,EAKnD,OAFe,EAAU,EAAM,IAAI,EAErB,aAAa,CACzB,WAAY,OACZ,WAAY,WACZ,KAAM,CACJ,KAAM,EACN,UAAW,CACb,EACA,QAAS,GACX,CAAC,EAEL,CACF,EACF,CAAC",
9
+ "debugId": "B198351ED8F97D3564756E2164756E21",
10
10
  "names": []
11
11
  }
@@ -1,4 +1,4 @@
1
- var c={};u(c,{RadixPlugin:()=>w});module.exports=p(c);var a=require("@swapkit/helpers"),w=a.createPlugin({name:"radix",properties:{supportedSwapkitProviders:[a.ProviderName.CAVIAR_V1]},methods:({getWallet:r})=>({swap:async function d({route:{tx:t,sellAmount:s,sellAsset:o}}){let e=await a.AssetValue.from({asyncTokenLookup:!0,value:s,asset:o});if(a.Chain.Radix!==e.chain)throw new a.SwapKitError("core_swap_invalid_params");let i=r(e.chain);try{return i.signAndBroadcast({manifest:t})}catch(n){throw new a.SwapKitError("core_swap_invalid_params",n)}}})});
1
+ var c={};u(c,{RadixPlugin:()=>w});module.exports=m(c);var a=require("@swapkit/helpers");var w=e({name:"radix",properties:{supportedSwapkitProviders:[a.ProviderName.CAVIAR_V1]},methods:({getWallet:t})=>({swap:async function d({route:{tx:o,sellAmount:s,sellAsset:i}}){let r=await a.AssetValue.from({asyncTokenLookup:!0,value:s,asset:i});if(a.Chain.Radix!==r.chain)throw new a.SwapKitError("core_swap_invalid_params");let p=t(r.chain);try{return p.signAndBroadcast({manifest:o})}catch(n){throw new a.SwapKitError("core_swap_invalid_params",n)}}})});
2
2
 
3
- //# debugId=0E4076998B38FA0B64756E2164756E21
3
+ //# debugId=19B018F1C343AAFE64756E2164756E21
4
4
  //# sourceMappingURL=index.cjs.map
@@ -2,9 +2,9 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/radix/index.ts"],
4
4
  "sourcesContent": [
5
- "import {\n AssetValue,\n Chain,\n ProviderName,\n SwapKitError,\n type SwapParams,\n createPlugin,\n} from \"@swapkit/helpers\";\nimport type { QuoteResponseRoute } from \"@swapkit/helpers/api\";\n\nexport const RadixPlugin = createPlugin({\n name: \"radix\",\n properties: { supportedSwapkitProviders: [ProviderName.CAVIAR_V1] },\n methods: ({ getWallet }) => ({\n swap: async function radixSwap({\n route: { tx, sellAmount, sellAsset },\n }: SwapParams<\"radix\", QuoteResponseRoute>) {\n const assetValue = await AssetValue.from({\n asyncTokenLookup: true,\n value: sellAmount,\n asset: sellAsset,\n });\n\n if (Chain.Radix !== assetValue.chain) {\n throw new SwapKitError(\"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 SwapKitError(\"core_swap_invalid_params\", error);\n }\n },\n }),\n});\n"
5
+ "import { AssetValue, Chain, ProviderName, SwapKitError, type SwapParams } from \"@swapkit/helpers\";\nimport type { QuoteResponseRoute } from \"@swapkit/helpers/api\";\nimport { createPlugin } from \"../utils\";\n\nexport const RadixPlugin = createPlugin({\n name: \"radix\",\n properties: { supportedSwapkitProviders: [ProviderName.CAVIAR_V1] },\n methods: ({ getWallet }) => ({\n swap: async function radixSwap({\n route: { tx, sellAmount, sellAsset },\n }: SwapParams<\"radix\", QuoteResponseRoute>) {\n const assetValue = await AssetValue.from({\n asyncTokenLookup: true,\n value: sellAmount,\n asset: sellAsset,\n });\n\n if (Chain.Radix !== assetValue.chain) {\n throw new SwapKitError(\"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 SwapKitError(\"core_swap_invalid_params\", error);\n }\n },\n }),\n});\n"
6
6
  ],
7
- "mappings": "sDAOO,IAPP,8BAUa,EAAc,eAAa,CACtC,KAAM,QACN,WAAY,CAAE,0BAA2B,CAAC,eAAa,SAAS,CAAE,EAClE,QAAS,EAAG,gBAAiB,CAC3B,KAAM,eAAe,CAAS,EAC5B,OAAS,KAAI,aAAY,cACiB,CAC1C,IAAM,EAAa,MAAM,aAAW,KAAK,CACvC,iBAAkB,GAClB,MAAO,EACP,MAAO,CACT,CAAC,EAED,GAAI,QAAM,QAAU,EAAW,MAC7B,MAAM,IAAI,eAAa,0BAA0B,EAGnD,IAAM,EAAS,EAAU,EAAW,KAAK,EACzC,GAAI,CACF,OAAO,EAAO,iBAAiB,CAAE,SAAU,CAAa,CAAC,EACzD,MAAO,EAAO,CACd,MAAM,IAAI,eAAa,2BAA4B,CAAK,GAG9D,EACF,CAAC",
8
- "debugId": "0E4076998B38FA0B64756E2164756E21",
7
+ "mappings": "sDAA+E,IAA/E,8BAIO,IAAM,EAAc,EAAa,CACtC,KAAM,QACN,WAAY,CAAE,0BAA2B,CAAC,eAAa,SAAS,CAAE,EAClE,QAAS,EAAG,gBAAiB,CAC3B,KAAM,eAAe,CAAS,EAC5B,OAAS,KAAI,aAAY,cACiB,CAC1C,IAAM,EAAa,MAAM,aAAW,KAAK,CACvC,iBAAkB,GAClB,MAAO,EACP,MAAO,CACT,CAAC,EAED,GAAI,QAAM,QAAU,EAAW,MAC7B,MAAM,IAAI,eAAa,0BAA0B,EAGnD,IAAM,EAAS,EAAU,EAAW,KAAK,EACzC,GAAI,CACF,OAAO,EAAO,iBAAiB,CAAE,SAAU,CAAa,CAAC,EACzD,MAAO,EAAO,CACd,MAAM,IAAI,eAAa,2BAA4B,CAAK,GAG9D,EACF,CAAC",
8
+ "debugId": "19B018F1C343AAFE64756E2164756E21",
9
9
  "names": []
10
10
  }
@@ -1,4 +1,4 @@
1
- import"../chunk-wfktpptf.js";import{AssetValue as p,Chain as u,ProviderName as w,SwapKitError as e,createPlugin as c}from"@swapkit/helpers";var l=c({name:"radix",properties:{supportedSwapkitProviders:[w.CAVIAR_V1]},methods:({getWallet:r})=>({swap:async function d({route:{tx:t,sellAmount:s,sellAsset:o}}){let a=await p.from({asyncTokenLookup:!0,value:s,asset:o});if(u.Radix!==a.chain)throw new e("core_swap_invalid_params");let i=r(a.chain);try{return i.signAndBroadcast({manifest:t})}catch(n){throw new e("core_swap_invalid_params",n)}}})});export{l as RadixPlugin};
1
+ import{c as e}from"../chunk-hzmkxs26.js";import{AssetValue as m,Chain as u,ProviderName as w,SwapKitError as r}from"@swapkit/helpers";var h=e({name:"radix",properties:{supportedSwapkitProviders:[w.CAVIAR_V1]},methods:({getWallet:t})=>({swap:async function c({route:{tx:o,sellAmount:s,sellAsset:i}}){let a=await m.from({asyncTokenLookup:!0,value:s,asset:i});if(u.Radix!==a.chain)throw new r("core_swap_invalid_params");let p=t(a.chain);try{return p.signAndBroadcast({manifest:o})}catch(n){throw new r("core_swap_invalid_params",n)}}})});export{h as RadixPlugin};
2
2
 
3
- //# debugId=1CB0136C68E6C70064756E2164756E21
3
+ //# debugId=4CE7C68C4DE6A9B164756E2164756E21
4
4
  //# sourceMappingURL=index.js.map
@@ -2,9 +2,9 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/radix/index.ts"],
4
4
  "sourcesContent": [
5
- "import {\n AssetValue,\n Chain,\n ProviderName,\n SwapKitError,\n type SwapParams,\n createPlugin,\n} from \"@swapkit/helpers\";\nimport type { QuoteResponseRoute } from \"@swapkit/helpers/api\";\n\nexport const RadixPlugin = createPlugin({\n name: \"radix\",\n properties: { supportedSwapkitProviders: [ProviderName.CAVIAR_V1] },\n methods: ({ getWallet }) => ({\n swap: async function radixSwap({\n route: { tx, sellAmount, sellAsset },\n }: SwapParams<\"radix\", QuoteResponseRoute>) {\n const assetValue = await AssetValue.from({\n asyncTokenLookup: true,\n value: sellAmount,\n asset: sellAsset,\n });\n\n if (Chain.Radix !== assetValue.chain) {\n throw new SwapKitError(\"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 SwapKitError(\"core_swap_invalid_params\", error);\n }\n },\n }),\n});\n"
5
+ "import { AssetValue, Chain, ProviderName, SwapKitError, type SwapParams } from \"@swapkit/helpers\";\nimport type { QuoteResponseRoute } from \"@swapkit/helpers/api\";\nimport { createPlugin } from \"../utils\";\n\nexport const RadixPlugin = createPlugin({\n name: \"radix\",\n properties: { supportedSwapkitProviders: [ProviderName.CAVIAR_V1] },\n methods: ({ getWallet }) => ({\n swap: async function radixSwap({\n route: { tx, sellAmount, sellAsset },\n }: SwapParams<\"radix\", QuoteResponseRoute>) {\n const assetValue = await AssetValue.from({\n asyncTokenLookup: true,\n value: sellAmount,\n asset: sellAsset,\n });\n\n if (Chain.Radix !== assetValue.chain) {\n throw new SwapKitError(\"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 SwapKitError(\"core_swap_invalid_params\", error);\n }\n },\n }),\n});\n"
6
6
  ],
7
- "mappings": "6BAAA,qBACE,WACA,kBACA,kBACA,kBAEA,yBAIK,IAAM,EAAc,EAAa,CACtC,KAAM,QACN,WAAY,CAAE,0BAA2B,CAAC,EAAa,SAAS,CAAE,EAClE,QAAS,EAAG,gBAAiB,CAC3B,KAAM,eAAe,CAAS,EAC5B,OAAS,KAAI,aAAY,cACiB,CAC1C,IAAM,EAAa,MAAM,EAAW,KAAK,CACvC,iBAAkB,GAClB,MAAO,EACP,MAAO,CACT,CAAC,EAED,GAAI,EAAM,QAAU,EAAW,MAC7B,MAAM,IAAI,EAAa,0BAA0B,EAGnD,IAAM,EAAS,EAAU,EAAW,KAAK,EACzC,GAAI,CACF,OAAO,EAAO,iBAAiB,CAAE,SAAU,CAAa,CAAC,EACzD,MAAO,EAAO,CACd,MAAM,IAAI,EAAa,2BAA4B,CAAK,GAG9D,EACF,CAAC",
8
- "debugId": "1CB0136C68E6C70064756E2164756E21",
7
+ "mappings": "yCAAA,qBAAS,WAAY,kBAAO,kBAAc,yBAInC,IAAM,EAAc,EAAa,CACtC,KAAM,QACN,WAAY,CAAE,0BAA2B,CAAC,EAAa,SAAS,CAAE,EAClE,QAAS,EAAG,gBAAiB,CAC3B,KAAM,eAAe,CAAS,EAC5B,OAAS,KAAI,aAAY,cACiB,CAC1C,IAAM,EAAa,MAAM,EAAW,KAAK,CACvC,iBAAkB,GAClB,MAAO,EACP,MAAO,CACT,CAAC,EAED,GAAI,EAAM,QAAU,EAAW,MAC7B,MAAM,IAAI,EAAa,0BAA0B,EAGnD,IAAM,EAAS,EAAU,EAAW,KAAK,EACzC,GAAI,CACF,OAAO,EAAO,iBAAiB,CAAE,SAAU,CAAa,CAAC,EACzD,MAAO,EAAO,CACd,MAAM,IAAI,EAAa,2BAA4B,CAAK,GAG9D,EACF,CAAC",
8
+ "debugId": "4CE7C68C4DE6A9B164756E2164756E21",
9
9
  "names": []
10
10
  }