Skip to content

Commit

Permalink
fixup! Implement 0xgasless swap metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
samholmes committed Jun 26, 2024
1 parent 3740e80 commit f5510c4
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions src/swap/defi/0x/0xGasless.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,11 @@ export const make0xGaslessPlugin: EdgeCorePluginFactory = opts => {
return {
swapInfo,
fetchSwapQuote: async (swapRequest): Promise<EdgeSwapQuote> => {
// The fromWallet and toWallet must be of the same currency plugin
// type and therefore of the same network.
if (
swapRequest.fromWallet.currencyInfo.pluginId !==
swapRequest.toWallet.currencyInfo.pluginId
) {
throw new Error('Swap between different networks is not supported')
// The fromWallet and toWallet must be of the same because the swap
// service only supports swaps of the same network and for the same
// account/address.
if (swapRequest.toWallet.id !== swapRequest.fromWallet.id) {
throw new Error('Swap between different wallets is not supported')
}

const fromTokenAddress = getTokenAddress(
Expand Down Expand Up @@ -184,11 +182,6 @@ export const make0xGaslessPlugin: EdgeCorePluginFactory = opts => {
assetActionType: 'swap'
}
const orderId = apiSwapSubmition.tradeHash
const {
publicAddress: toWalletAddress
} = await swapRequest.toWallet.getReceiveAddress({
tokenId: swapRequest.toTokenId
})

const savedAction: EdgeTxAction = {
actionType: 'swap',
Expand All @@ -200,7 +193,7 @@ export const make0xGaslessPlugin: EdgeCorePluginFactory = opts => {
nativeAmount: swapRequest.nativeAmount
},
orderId,
payoutAddress: toWalletAddress,
payoutAddress: fromWalletAddress,
payoutWalletId: swapRequest.toWallet.id,
refundAddress: fromWalletAddress,
swapInfo,
Expand Down

0 comments on commit f5510c4

Please sign in to comment.