|
1 | 1 | // import { div, gt, lt, mul, toFixed } from 'biggystring'
|
2 | 2 | import { mul } from 'biggystring'
|
3 | 3 | 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' |
5 | 5 | import { sprintf } from 'sprintf-js'
|
6 | 6 | import URL from 'url-parse'
|
7 | 7 |
|
@@ -197,6 +197,24 @@ const NETWORK_CODE_PLUGINID_MAP: StringMap = {
|
197 | 197 | zksync: 'zksync'
|
198 | 198 | }
|
199 | 199 |
|
| 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 | + |
200 | 218 | const PAYMENT_TYPE_MAP: Partial<Record<FiatPaymentType, FiatPaymentType | undefined>> = {
|
201 | 219 | ach: 'ach',
|
202 | 220 | applepay: 'credit',
|
@@ -620,13 +638,7 @@ export const moonpayProvider: FiatProviderFactory = {
|
620 | 638 | }
|
621 | 639 |
|
622 | 640 | 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)] |
630 | 642 | }
|
631 | 643 |
|
632 | 644 | const sendParams: SendScene2Params = {
|
|
0 commit comments