Skip to content

Special case Moonpay/Ripple destination tag handling #5612

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

Merged
merged 2 commits into from
Jun 6, 2025
Merged
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
30 changes: 21 additions & 9 deletions src/plugins/gui/providers/moonpayProvider.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// import { div, gt, lt, mul, toFixed } from 'biggystring'
import { mul } from 'biggystring'
import { asArray, asBoolean, asEither, asNull, asNumber, asObject, asOptional, asString, asValue } from 'cleaners'
import { EdgeAssetAction, EdgeSpendInfo, EdgeTokenId, EdgeTxActionFiat } from 'edge-core-js'
import { EdgeAssetAction, EdgeMemo, EdgeSpendInfo, EdgeTokenId, EdgeTxActionFiat } from 'edge-core-js'
import { sprintf } from 'sprintf-js'
import URL from 'url-parse'

Expand Down Expand Up @@ -188,7 +188,7 @@ const NETWORK_CODE_PLUGINID_MAP: StringMap = {
polygon: 'polygon',
ripple: 'ripple',
solana: 'solana',
sonic: 'sonic',
s_sonic: 'sonic',
stellar: 'stellar',
sui: 'sui',
tezos: 'tezos',
Expand All @@ -197,6 +197,24 @@ const NETWORK_CODE_PLUGINID_MAP: StringMap = {
zksync: 'zksync'
}

// Special case memo creation for plugins
// Memo type is not documented by Moonpay but can be inferred from /currencies response field "addressTagRegex"
const createMemo = (pluginId: string, value: string): EdgeMemo => {
const memo: EdgeMemo = {
type: 'text',
value,
hidden: true
}

switch (pluginId) {
case 'ripple': {
memo.type = 'number'
memo.memoName = 'destination tag'
}
}
return memo
}

const PAYMENT_TYPE_MAP: Partial<Record<FiatPaymentType, FiatPaymentType | undefined>> = {
ach: 'ach',
applepay: 'credit',
Expand Down Expand Up @@ -620,13 +638,7 @@ export const moonpayProvider: FiatProviderFactory = {
}

if (depositWalletAddressTag != null) {
spendInfo.memos = [
{
type: 'text',
value: depositWalletAddressTag,
hidden: true
}
]
spendInfo.memos = [createMemo(coreWallet.currencyInfo.pluginId, depositWalletAddressTag)]
}

const sendParams: SendScene2Params = {
Expand Down
Loading