Skip to content

Commit

Permalink
Remove use of legacy memos
Browse files Browse the repository at this point in the history
Latest edge-currency-accountbased removed use so we must use the new `memos` field or risk having memos dropped
  • Loading branch information
paullinator committed Apr 5, 2024
1 parent 46d3f87 commit e6083de
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/swap/defi/lifi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,11 +353,11 @@ export function makeLifiPlugin(opts: EdgeCorePluginOptions): EdgeSwapPlugin {
tokenId: request.fromTokenId,
spendTargets: [
{
memo: data,
nativeAmount: fromNativeAmount,
publicAddress: approvalAddress
}
],
memos: [{ type: 'hex', value: data.replace('0x', '') }],
networkFeeOption: 'custom',
customNetworkFee: {
// XXX Hack. Lifi doesn't properly estimate ethereum gas limits. Increase by 40%
Expand Down
5 changes: 4 additions & 1 deletion src/swap/defi/thorchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -625,9 +625,12 @@ export function makeThorchainPlugin(
expirationDate: new Date(Date.now() + EXPIRATION_MS)
}
} else {
// For UTXO chains, we send the memo as text which gets
// encoded by the plugins
memoType = 'text'
// Cannot yet do tokens on non-EVM chains

if (fromTokenId != null) {
// Cannot yet do tokens on utxo chains
throw new SwapCurrencyError(swapInfo, request)
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/swap/defi/thorchainDa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,9 @@ export function makeThorchainDaPlugin(
assetActionType: 'swap'
},
memos:
memo == null ? [] : [{ type: memoType, value: memo.replace('0x', '') }],
memo == null
? undefined
: [{ type: memoType, value: memo.replace('0x', '') }],
savedAction: {
actionType: 'swap',
swapInfo,
Expand Down
5 changes: 4 additions & 1 deletion src/swap/defi/uni-v2-based/plugins/spookySwap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,17 @@ export function makeSpookySwapPlugin(
tokenId: request.fromTokenId,
spendTargets: [
{
memo: swapTx.data,
nativeAmount:
swapTxs.length === 2 && i === 0
? '0' // approval transactions don't have a value
: amountToSwap,
publicAddress: swapTx.to
}
],
memos:
swapTx.data != null
? [{ type: 'hex', value: swapTx.data?.replace('0x', '') }]
: undefined,
customNetworkFee: {
gasPrice:
swapTx.gasPrice != null
Expand Down
5 changes: 4 additions & 1 deletion src/swap/defi/uni-v2-based/plugins/tombSwap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,17 @@ export function makeTombSwapPlugin(
tokenId: request.fromTokenId,
spendTargets: [
{
memo: swapTx.data,
nativeAmount:
swapTxs.length === 2 && i === 0
? '0' // approval transactions don't have a value
: amountToSwap,
publicAddress: swapTx.to
}
],
memos:
swapTx.data != null
? [{ type: 'hex', value: swapTx.data?.replace('0x', '') }]
: undefined,
customNetworkFee: {
gasPrice:
swapTx.gasPrice != null
Expand Down
5 changes: 4 additions & 1 deletion src/swap/defi/uni-v2-based/plugins/velodrome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,17 @@ export function makeVelodromePlugin(
tokenId: request.fromTokenId,
spendTargets: [
{
memo: swapTx.data,
nativeAmount:
swapTxs.length === 2 && i === 0
? '0' // approval transactions don't have a value
: amountToSwap,
publicAddress: swapTx.to
}
],
memos:
swapTx.data != null
? [{ type: 'hex', value: swapTx.data?.replace('0x', '') }]
: undefined,
customNetworkFee: {
gasPrice:
swapTx.gasPrice != null
Expand Down

0 comments on commit e6083de

Please sign in to comment.