Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to edge-core-js v1.6.0 #290

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
"buffer": "^6.0.3",
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"edge-core-js": "^1.4.0",
"edge-core-js": "^1.7.0",
"eslint": "^7.14.0",
"eslint-config-standard-kit": "0.15.1",
"eslint-plugin-flowtype": "^5.2.0",
Expand Down
9 changes: 6 additions & 3 deletions src/swap/changehero.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
makeSwapPluginQuote,
SwapOrder
} from '../swap-helpers'
import { convertRequest, getAddress } from '../util/utils'
import { convertRequest, getAddress, makeEdgeMemos } from '../util/utils'
import { EdgeSwapRequestPlugin } from './types'

const pluginId = 'changehero'
Expand Down Expand Up @@ -255,10 +255,13 @@ export function makeChangeHeroPlugin(
spendTargets: [
{
nativeAmount: amountExpectedFromNative,
publicAddress: quoteInfo.payinAddress,
uniqueIdentifier: quoteInfo.payinExtraId ?? undefined
publicAddress: quoteInfo.payinAddress
}
],
memos: makeEdgeMemos(
request.fromWallet.currencyInfo,
quoteInfo.payinExtraId
),
networkFeeOption:
request.fromCurrencyCode.toUpperCase() === 'BTC' ? 'high' : 'standard',
swapData: {
Expand Down
10 changes: 5 additions & 5 deletions src/swap/changenow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
makeSwapPluginQuote,
SwapOrder
} from '../swap-helpers'
import { convertRequest, getAddress } from '../util/utils'
import { convertRequest, getAddress, makeEdgeMemos } from '../util/utils'
import { EdgeSwapRequestPlugin } from './types'
const pluginId = 'changenow'

Expand Down Expand Up @@ -200,10 +200,10 @@ export function makeChangeNowPlugin(
spendTargets: [
{
nativeAmount,
publicAddress: payinAddress,
uniqueIdentifier: payinExtraId
publicAddress: payinAddress
}
],
memos: makeEdgeMemos(request.fromWallet.currencyInfo, payinExtraId),
networkFeeOption: fromCurrencyCode === 'BTC' ? 'high' : 'standard',
swapData: {
orderId: id,
Expand Down Expand Up @@ -255,10 +255,10 @@ export function makeChangeNowPlugin(
spendTargets: [
{
nativeAmount: fromNativeAmount,
publicAddress: payinAddress,
uniqueIdentifier: payinExtraId
publicAddress: payinAddress
}
],
memos: makeEdgeMemos(request.fromWallet.currencyInfo, payinExtraId),
networkFeeOption: fromCurrencyCode === 'BTC' ? 'high' : 'standard',
swapData: {
orderId: id,
Expand Down
5 changes: 3 additions & 2 deletions src/swap/defi/lifi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
fetchWaterfall,
getAddress,
hexToDecimal,
makeEdgeMemos,
makeQueryParams,
promiseWithTimeout
} from '../../util/utils'
Expand Down Expand Up @@ -311,11 +312,11 @@ export function makeLifiPlugin(opts: EdgeCorePluginOptions): EdgeSwapPlugin {
currencyCode: request.fromCurrencyCode,
spendTargets: [
{
memo: approvalData,
nativeAmount: '0',
publicAddress: fromContractAddress
}
],
memos: makeEdgeMemos(request.fromWallet.currencyInfo, approvalData),
networkFeeOption: 'custom',
customNetworkFee: {
gasPrice: gasPriceGwei
Expand All @@ -332,11 +333,11 @@ export function makeLifiPlugin(opts: EdgeCorePluginOptions): EdgeSwapPlugin {
currencyCode: request.fromCurrencyCode,
spendTargets: [
{
memo: data,
nativeAmount: mul(transactionRequest.value, '1'),
publicAddress: approvalAddress
}
],
memos: makeEdgeMemos(request.fromWallet.currencyInfo, data),
networkFeeOption: 'custom',
customNetworkFee: {
// XXX Hack. Lifi doesn't properly estimate ethereum gas limits. Increase by 40%
Expand Down
6 changes: 3 additions & 3 deletions src/swap/defi/thorchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import {
fetchInfo,
fetchWaterfall,
getAddress,
makeEdgeMemos,
makeQueryParams,
promiseWithTimeout,
QueryParams
Expand Down Expand Up @@ -564,11 +565,11 @@ export function makeThorchainPlugin(
currencyCode: request.fromCurrencyCode,
spendTargets: [
{
memo: approvalData,
nativeAmount: '0',
publicAddress: sourceTokenContractAddress
}
],
memos: makeEdgeMemos(request.fromWallet.currencyInfo, approvalData),
metadata: {
name: 'Thorchain',
category: 'expense:Token Approval'
Expand All @@ -581,12 +582,11 @@ export function makeThorchainPlugin(
currencyCode: request.fromCurrencyCode,
spendTargets: [
{
memo,
nativeAmount: ethNativeAmount,
publicAddress
}
],

memos: makeEdgeMemos(request.fromWallet.currencyInfo, memo),
swapData: {
isEstimate: false,
payoutAddress: toAddress,
Expand Down
6 changes: 3 additions & 3 deletions src/swap/defi/thorchainDa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {
fetchInfo,
fetchWaterfall,
getAddress,
makeEdgeMemos,
makeQueryParams,
promiseWithTimeout
} from '../../util/utils'
Expand Down Expand Up @@ -409,11 +410,11 @@ export function makeThorchainDaPlugin(
currencyCode: fromMainnetCode,
spendTargets: [
{
memo: approvalData,
nativeAmount: '0',
publicAddress: sourceTokenContractAddress
}
],
memos: makeEdgeMemos(request.fromWallet.currencyInfo, approvalData),
metadata: {
name: 'Thorchain DEX Aggregator',
category: 'expense:Token Approval'
Expand All @@ -426,12 +427,11 @@ export function makeThorchainDaPlugin(
currencyCode: request.fromCurrencyCode,
spendTargets: [
{
memo,
nativeAmount: ethNativeAmount,
publicAddress
}
],

memos: makeEdgeMemos(request.fromWallet.currencyInfo, memo),
swapData: {
isEstimate,
payoutAddress: toAddress,
Expand Down
4 changes: 2 additions & 2 deletions src/swap/defi/uni-v2-based/plugins/spookySwap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
makeSwapPluginQuote,
SwapOrder
} from '../../../../swap-helpers'
import { convertRequest } from '../../../../util/utils'
import { convertRequest, makeEdgeMemos } from '../../../../util/utils'
import { EdgeSwapRequestPlugin } from '../../../types'
import { getInOutTokenAddresses, InOutTokenAddresses } from '../../defiUtils'
import {
Expand Down Expand Up @@ -113,7 +113,6 @@ export function makeSpookySwapPlugin(
currencyCode: request.fromCurrencyCode, // what is being sent out, only if token. Blank if not token
spendTargets: [
{
memo: swapTx.data,
nativeAmount: swapTx.value != null ? swapTx.value.toString() : '0', // biggy/number string integer
publicAddress: swapTx.to
}
Expand All @@ -125,6 +124,7 @@ export function makeSpookySwapPlugin(
: '0',
gasLimit: swapTx.gasLimit?.toString() ?? '0'
},
memos: makeEdgeMemos(request.fromWallet.currencyInfo, swapTx.data),
networkFeeOption: 'custom',
swapData: {
isEstimate: false,
Expand Down
4 changes: 2 additions & 2 deletions src/swap/defi/uni-v2-based/plugins/tombSwap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
makeSwapPluginQuote,
SwapOrder
} from '../../../../swap-helpers'
import { convertRequest } from '../../../../util/utils'
import { convertRequest, makeEdgeMemos } from '../../../../util/utils'
import { EdgeSwapRequestPlugin } from '../../../types'
import { getInOutTokenAddresses, InOutTokenAddresses } from '../../defiUtils'
import {
Expand Down Expand Up @@ -113,7 +113,6 @@ export function makeTombSwapPlugin(
currencyCode: request.fromCurrencyCode, // what is being sent out, only if token. Blank if not token
spendTargets: [
{
memo: swapTx.data,
nativeAmount: swapTx.value != null ? swapTx.value.toString() : '0', // biggy/number string integer
publicAddress: swapTx.to
}
Expand All @@ -125,6 +124,7 @@ export function makeTombSwapPlugin(
: '0',
gasLimit: swapTx.gasLimit?.toString() ?? '0'
},
memos: makeEdgeMemos(request.fromWallet.currencyInfo, swapTx.data),
networkFeeOption: 'custom',
swapData: {
isEstimate: false,
Expand Down
4 changes: 2 additions & 2 deletions src/swap/defi/uni-v2-based/plugins/velodrome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
makeSwapPluginQuote,
SwapOrder
} from '../../../../swap-helpers'
import { convertRequest } from '../../../../util/utils'
import { convertRequest, makeEdgeMemos } from '../../../../util/utils'
import { EdgeSwapRequestPlugin } from '../../../types'
import VELODROME_V1_ROUTER_ABI from '../../abi/VELODROME_V1_ROUTER_ABI'
import WRAPPED_OPTIMISM_ETH_ABI from '../../abi/WRAPPED_OPTIMISM_ETH_ABI'
Expand Down Expand Up @@ -128,7 +128,6 @@ export function makeVelodromePlugin(
currencyCode: request.fromCurrencyCode, // what is being sent out, only if token. Blank if not token
spendTargets: [
{
memo: swapTx.data,
nativeAmount: swapTx.value != null ? swapTx.value.toString() : '0', // biggy/number string integer
publicAddress: swapTx.to
}
Expand All @@ -140,6 +139,7 @@ export function makeVelodromePlugin(
: '0',
gasLimit: swapTx.gasLimit?.toString() ?? '0'
},
memos: makeEdgeMemos(request.fromWallet.currencyInfo, swapTx.data),
networkFeeOption: 'custom',
swapData: {
isEstimate: false,
Expand Down
9 changes: 6 additions & 3 deletions src/swap/exolix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
makeSwapPluginQuote,
SwapOrder
} from '../swap-helpers'
import { convertRequest, getAddress } from '../util/utils'
import { convertRequest, getAddress, makeEdgeMemos } from '../util/utils'
import { EdgeSwapRequestPlugin } from './types'

const pluginId = 'exolix'
Expand Down Expand Up @@ -239,10 +239,13 @@ export function makeExolixPlugin(opts: EdgeCorePluginOptions): EdgeSwapPlugin {
spendTargets: [
{
nativeAmount: fromNativeAmount,
publicAddress: quoteInfo.depositAddress,
uniqueIdentifier: quoteInfo.depositExtraId
publicAddress: quoteInfo.depositAddress
}
],
memos: makeEdgeMemos(
request.fromWallet.currencyInfo,
quoteInfo.depositExtraId
),
networkFeeOption:
request.fromCurrencyCode.toUpperCase() === 'BTC' ? 'high' : 'standard',
swapData: {
Expand Down
9 changes: 6 additions & 3 deletions src/swap/godex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
makeSwapPluginQuote,
SwapOrder
} from '../swap-helpers'
import { convertRequest, getAddress } from '../util/utils'
import { convertRequest, getAddress, makeEdgeMemos } from '../util/utils'
import { asNumberString, EdgeSwapRequestPlugin } from './types'

const pluginId = 'godex'
Expand Down Expand Up @@ -267,10 +267,13 @@ export function makeGodexPlugin(opts: EdgeCorePluginOptions): EdgeSwapPlugin {
spendTargets: [
{
nativeAmount: fromNativeAmount,
publicAddress: quoteInfo.deposit,
uniqueIdentifier: quoteInfo.deposit_extra_id ?? undefined
publicAddress: quoteInfo.deposit
}
],
memos: makeEdgeMemos(
request.fromWallet.currencyInfo,
quoteInfo.deposit_extra_id
),
networkFeeOption:
request.fromCurrencyCode.toUpperCase() === 'BTC' ? 'high' : 'standard',
swapData: {
Expand Down
9 changes: 6 additions & 3 deletions src/swap/letsexchange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
makeSwapPluginQuote,
SwapOrder
} from '../swap-helpers'
import { convertRequest, getAddress } from '../util/utils'
import { convertRequest, getAddress, makeEdgeMemos } from '../util/utils'
import { asOptionalBlank } from './changenow'
import { asNumberString, EdgeSwapRequestPlugin } from './types'

Expand Down Expand Up @@ -276,10 +276,13 @@ export function makeLetsExchangePlugin(
spendTargets: [
{
nativeAmount: fromNativeAmount,
publicAddress: quoteInfo.deposit,
uniqueIdentifier: quoteInfo.deposit_extra_id
publicAddress: quoteInfo.deposit
}
],
memos: makeEdgeMemos(
request.fromWallet.currencyInfo,
quoteInfo.deposit_extra_id
),
networkFeeOption:
request.fromCurrencyCode.toUpperCase() === 'BTC' ? 'high' : 'standard',
swapData: {
Expand Down
6 changes: 3 additions & 3 deletions src/swap/sideshift.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
makeSwapPluginQuote,
SwapOrder
} from '../swap-helpers'
import { convertRequest, getAddress } from '../util/utils'
import { convertRequest, getAddress, makeEdgeMemos } from '../util/utils'
import { EdgeSwapRequestPlugin } from './types'

// See https://help.sideshift.ai/en/articles/4559664-which-coins-and-tokens-are-listed for list of supported currencies
Expand Down Expand Up @@ -218,10 +218,10 @@ const fetchSwapQuoteInner = async (
spendTargets: [
{
nativeAmount: amountExpectedFromNative,
publicAddress: order.depositAddress,
uniqueIdentifier: order.depositMemo
publicAddress: order.depositAddress
}
],
memos: makeEdgeMemos(request.fromWallet.currencyInfo, order.depositMemo),
networkFeeOption:
request.fromCurrencyCode.toUpperCase() === 'BTC' ? 'high' : 'standard',
swapData: {
Expand Down
6 changes: 3 additions & 3 deletions src/swap/swapuz.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
SwapOrder
} from '../swap-helpers'
import { div18 } from '../util/biggystringplus'
import { convertRequest, getAddress } from '../util/utils'
import { convertRequest, getAddress, makeEdgeMemos } from '../util/utils'
import { EdgeSwapRequestPlugin } from './types'

const pluginId = 'swapuz'
Expand Down Expand Up @@ -181,10 +181,10 @@ export function makeSwapuzPlugin(opts: EdgeCorePluginOptions): EdgeSwapPlugin {
spendTargets: [
{
nativeAmount: request.nativeAmount,
publicAddress: addressFrom,
uniqueIdentifier: memoFrom
publicAddress: addressFrom
}
],
memos: makeEdgeMemos(fromWallet.currencyInfo, memoFrom),
networkFeeOption: fromCurrencyCode === 'BTC' ? 'high' : 'standard',
swapData: {
orderId: uid,
Expand Down
Loading
Loading