Skip to content

Commit f775aef

Browse files
peachbitssamholmes
authored andcommitted
Add special case memo handling
1 parent c3535c8 commit f775aef

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

src/plugins/gui/providers/moonpayProvider.ts

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// import { div, gt, lt, mul, toFixed } from 'biggystring'
22
import { mul } from 'biggystring'
33
import { asArray, asBoolean, asEither, asNull, asNumber, asObject, asOptional, asString, asValue } from 'cleaners'
4-
import { EdgeAssetAction, EdgeSpendInfo, EdgeTokenId, EdgeTxActionFiat } from 'edge-core-js'
4+
import { EdgeAssetAction, EdgeMemo, EdgeSpendInfo, EdgeTokenId, EdgeTxActionFiat } from 'edge-core-js'
55
import { sprintf } from 'sprintf-js'
66
import URL from 'url-parse'
77

@@ -197,6 +197,24 @@ const NETWORK_CODE_PLUGINID_MAP: StringMap = {
197197
zksync: 'zksync'
198198
}
199199

200+
// Special case memo creation for plugins
201+
// Memo type is not documented by Moonpay but can be inferred from /currencies response field "addressTagRegex"
202+
const createMemo = (pluginId: string, value: string): EdgeMemo => {
203+
const memo: EdgeMemo = {
204+
type: 'text',
205+
value,
206+
hidden: true
207+
}
208+
209+
switch (pluginId) {
210+
case 'ripple': {
211+
memo.type = 'number'
212+
memo.memoName = 'destination tag'
213+
}
214+
}
215+
return memo
216+
}
217+
200218
const PAYMENT_TYPE_MAP: Partial<Record<FiatPaymentType, FiatPaymentType | undefined>> = {
201219
ach: 'ach',
202220
applepay: 'credit',
@@ -620,13 +638,7 @@ export const moonpayProvider: FiatProviderFactory = {
620638
}
621639

622640
if (depositWalletAddressTag != null) {
623-
spendInfo.memos = [
624-
{
625-
type: 'text',
626-
value: depositWalletAddressTag,
627-
hidden: true
628-
}
629-
]
641+
spendInfo.memos = [createMemo(coreWallet.currencyInfo.pluginId, depositWalletAddressTag)]
630642
}
631643

632644
const sendParams: SendScene2Params = {

0 commit comments

Comments
 (0)