Skip to content

Commit

Permalink
Fix/kado widget mapping (#1112)
Browse files Browse the repository at this point in the history
* feat: fixes kado mapping

* feat: fixes kado mapping

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
towanTG and github-actions[bot] authored Dec 4, 2024
1 parent b1f2232 commit 1859a1d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .changeset/cool-spies-roll.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@swapkit/plugin-kado": patch
---

Fixes kado widget mapping
32 changes: 20 additions & 12 deletions packages/plugins/kado/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ function plugin({ config: { kadoApiKey } }: SwapKitPluginParams<{ kadoApiKey: st
async function fetchProviderQuote({
sellAsset,
buyAsset,
fiatMethod,
fiatMethod = "credit_card",
}: {
sellAsset: AssetValue;
buyAsset: AssetValue;
Expand Down Expand Up @@ -296,30 +296,37 @@ function plugin({ config: { kadoApiKey } }: SwapKitPluginParams<{ kadoApiKey: st
buyAsset,
supportedAssets,
recipient,
networkList,
type,
typeList,
sender,
widgetMode,
}: {
sellAsset: AssetValue;
buyAsset: AssetValue;
supportedAssets: AssetValue[];
recipient: string;
networkList: Chain[];
sender: string;
type: "BUY" | "SELL";
typeList: "BUY" | "SELL";
widgetMode: "minimal" | "full";
}) {
const urlParams = new URLSearchParams({
onPayAmount: sellAsset.getValue("string"),
onPayCurrency: sellAsset.symbol,
onRevCurrency: buyAsset.symbol,
apiKey: kadoApiKey,
...(type === "BUY"
? {
onPayAmount: sellAsset.getValue("string"),
onPayCurrency: sellAsset.symbol,
onRevCurrency: buyAsset.symbol,
onToAddress: recipient,
}
: {
offPayAmount: sellAsset.getValue("string"),
offPayCurrency: sellAsset.symbol,
offRevCurrency: buyAsset.symbol,
offFromAddress: sender,
}),
cryptoList: supportedAssets.map((asset) => asset.symbol).join(","),
onToAddress: recipient,
network: ChainToKadoChain(buyAsset.chain).toUpperCase(),
networkList: networkList.map((chain) => ChainToKadoChain(chain).toUpperCase()).join(","),
network: ChainToKadoChain(type === "BUY" ? buyAsset.chain : sellAsset.chain).toUpperCase(),
product: type,
productList: typeList,
mode: widgetMode,
});

Expand Down Expand Up @@ -379,7 +386,7 @@ function plugin({ config: { kadoApiKey } }: SwapKitPluginParams<{ kadoApiKey: st
buyAsset,
supportedAssets: [sellAsset, buyAsset],
recipient: route.destinationAddress,
networkList: [buyAsset.chain],
sender: route.sourceAddress,
type,
typeList: type,
widgetMode: "minimal",
Expand All @@ -399,6 +406,7 @@ function plugin({ config: { kadoApiKey } }: SwapKitPluginParams<{ kadoApiKey: st
getAssets,
getOrderStatus,
getKadoWidgetUrl,
createPopover,
swap,
supportedSwapkitProviders: [ProviderName.KADO],
};
Expand Down

0 comments on commit 1859a1d

Please sign in to comment.