edge-currency-accountbased 2.2.3 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/android/src/main/assets/edge-currency-accountbased/234.chunk.js +35 -0
  3. package/android/src/main/assets/edge-currency-accountbased/248.chunk.js +35 -0
  4. package/android/src/main/assets/edge-currency-accountbased/336.chunk.js +9 -0
  5. package/android/src/main/assets/edge-currency-accountbased/612.chunk.js +1 -0
  6. package/android/src/main/assets/edge-currency-accountbased/{945.chunk.js → 814.chunk.js} +8 -8
  7. package/android/src/main/assets/edge-currency-accountbased/935.chunk.js +1 -1
  8. package/android/src/main/assets/edge-currency-accountbased/94.chunk.js +8 -0
  9. package/android/src/main/assets/edge-currency-accountbased/algorand.chunk.js +2 -2
  10. package/android/src/main/assets/edge-currency-accountbased/bnb.chunk.js +4 -4
  11. package/android/src/main/assets/edge-currency-accountbased/edge-currency-accountbased.js +10 -10
  12. package/android/src/main/assets/edge-currency-accountbased/eos.chunk.js +12 -12
  13. package/android/src/main/assets/edge-currency-accountbased/ethereum.chunk.js +5 -5
  14. package/android/src/main/assets/edge-currency-accountbased/filecoin.chunk.js +1 -1
  15. package/android/src/main/assets/edge-currency-accountbased/fio.chunk.js +2 -2
  16. package/android/src/main/assets/edge-currency-accountbased/hedera.chunk.js +2 -2
  17. package/android/src/main/assets/edge-currency-accountbased/polkadot.chunk.js +2 -2
  18. package/android/src/main/assets/edge-currency-accountbased/ripple.chunk.js +5 -5
  19. package/android/src/main/assets/edge-currency-accountbased/solana.chunk.js +3 -3
  20. package/android/src/main/assets/edge-currency-accountbased/stellar.chunk.js +4 -4
  21. package/android/src/main/assets/edge-currency-accountbased/tezos.chunk.js +3 -3
  22. package/android/src/main/assets/edge-currency-accountbased/tron.chunk.js +1 -1
  23. package/android/src/main/assets/edge-currency-accountbased/zcash.chunk.js +2 -2
  24. package/lib/algorand/AlgorandEngine.js +46 -24
  25. package/lib/algorand/algorandInfo.js +8 -7
  26. package/lib/algorand/algorandTestnetInfo.js +8 -7
  27. package/lib/binance/BinanceEngine.js +19 -17
  28. package/lib/binance/binanceInfo.js +10 -7
  29. package/lib/common/types.js +10 -0
  30. package/lib/common/upgradeMemos.js +52 -0
  31. package/lib/common/utf8.js +32 -0
  32. package/lib/common/validateMemos.js +107 -0
  33. package/lib/eos/EosEngine.js +42 -41
  34. package/lib/eos/info/eosCommonInfo.js +10 -0
  35. package/lib/eos/info/eosInfo.js +15 -17
  36. package/lib/eos/info/telosInfo.js +15 -15
  37. package/lib/eos/info/waxInfo.js +15 -16
  38. package/lib/ethereum/EthereumEngine.js +13 -12
  39. package/lib/ethereum/EthereumNetwork.js +16 -14
  40. package/lib/ethereum/info/avalancheInfo.js +17 -7
  41. package/lib/ethereum/info/binancesmartchainInfo.js +9 -7
  42. package/lib/ethereum/info/celoInfo.js +9 -7
  43. package/lib/ethereum/info/ethDevInfo.js +9 -7
  44. package/lib/ethereum/info/ethereumCommonInfo.js +10 -0
  45. package/lib/ethereum/info/ethereumInfo.js +17 -7
  46. package/lib/ethereum/info/ethereumclassicInfo.js +9 -7
  47. package/lib/ethereum/info/ethereumpowInfo.js +9 -7
  48. package/lib/ethereum/info/fantomInfo.js +9 -7
  49. package/lib/ethereum/info/goerliInfo.js +9 -7
  50. package/lib/ethereum/info/kovanInfo.js +9 -7
  51. package/lib/ethereum/info/optimismInfo.js +9 -7
  52. package/lib/ethereum/info/polygonInfo.js +9 -7
  53. package/lib/ethereum/info/pulsechainInfo.js +9 -7
  54. package/lib/ethereum/info/rinkebyInfo.js +9 -7
  55. package/lib/ethereum/info/ropstenInfo.js +9 -7
  56. package/lib/ethereum/info/rskInfo.js +9 -7
  57. package/lib/ethereum/info/zksyncInfo.js +9 -7
  58. package/lib/filecoin/FilecoinEngine.js +125 -87
  59. package/lib/filecoin/Filfox.js +68 -1
  60. package/lib/filecoin/filecoinInfo.js +5 -7
  61. package/lib/fio/FioEngine.js +25 -17
  62. package/lib/fio/fioInfo.js +8 -6
  63. package/lib/hedera/HederaEngine.js +22 -18
  64. package/lib/hedera/hederaInfo.js +11 -8
  65. package/lib/hedera/hederaTestnetInfo.js +6 -6
  66. package/lib/polkadot/PolkadotEngine.js +15 -9
  67. package/lib/polkadot/info/liberlandInfo.js +3 -2
  68. package/lib/polkadot/info/liberlandTestnetInfo.js +3 -2
  69. package/lib/polkadot/info/polkadotInfo.js +8 -5
  70. package/lib/ripple/RippleEngine.js +53 -75
  71. package/lib/ripple/rippleInfo.js +16 -8
  72. package/lib/solana/SolanaEngine.js +17 -12
  73. package/lib/solana/solanaInfo.js +9 -5
  74. package/lib/stellar/StellarEngine.js +31 -22
  75. package/lib/stellar/stellarInfo.js +16 -7
  76. package/lib/tezos/TezosEngine.js +17 -11
  77. package/lib/tezos/tezosInfo.js +8 -5
  78. package/lib/tron/TronEngine.js +85 -68
  79. package/lib/tron/tronInfo.js +8 -7
  80. package/lib/zcash/ZcashEngine.js +23 -23
  81. package/lib/zcash/piratechainInfo.js +8 -6
  82. package/lib/zcash/zcashInfo.js +7 -6
  83. package/package.json +2 -2
  84. package/android/src/main/assets/edge-currency-accountbased/124.chunk.js +0 -35
  85. package/android/src/main/assets/edge-currency-accountbased/223.chunk.js +0 -9
  86. package/android/src/main/assets/edge-currency-accountbased/650.chunk.js +0 -1
  87. package/android/src/main/assets/edge-currency-accountbased/689.chunk.js +0 -8
  88. package/android/src/main/assets/edge-currency-accountbased/826.chunk.js +0 -35
@@ -16,6 +16,7 @@ var _rfc4648 = require('rfc4648');
16
16
 
17
17
  var _CurrencyEngine = require('../common/CurrencyEngine');
18
18
 
19
+ var _upgradeMemos = require('../common/upgradeMemos');
19
20
  var _utils = require('../common/utils');
20
21
 
21
22
 
@@ -365,18 +366,19 @@ var _hederaTypes = require('./hederaTypes');
365
366
  if (_biggystring.gt.call(void 0, nativeAmount, '0')) ourReceiveAddresses.push(accountIdStr)
366
367
 
367
368
  txs.push({
368
- txid: hashToTxid(_rfc4648.base64.parse(tx.transaction_hash)),
369
- date: parseInt(tx.valid_start_timestamp),
370
- currencyCode: this.currencyInfo.currencyCode, // currencyCode
371
369
  blockHeight: 1, // blockHeight
372
- nativeAmount,
370
+ currencyCode: this.currencyInfo.currencyCode, // currencyCode
371
+ date: parseInt(tx.valid_start_timestamp),
373
372
  isSend: nativeAmount.startsWith('-'),
373
+ memos: [],
374
+ nativeAmount,
374
375
  networkFee: tx.charged_tx_fee.toString(), // networkFee
375
- ourReceiveAddresses, // ourReceiveAddresses
376
- signedTx: '', // signedTx
377
376
  otherParams: {
378
377
  consensusAt: tx.consensus_timestamp
379
378
  },
379
+ ourReceiveAddresses, // ourReceiveAddresses
380
+ signedTx: '', // signedTx
381
+ txid: hashToTxid(_rfc4648.base64.parse(tx.transaction_hash)),
380
382
  walletId: this.walletId
381
383
  })
382
384
  }
@@ -411,18 +413,19 @@ var _hederaTypes = require('./hederaTypes');
411
413
  }
412
414
 
413
415
  async makeSpend(edgeSpendInfoIn) {
416
+ edgeSpendInfoIn = _upgradeMemos.upgradeMemos.call(void 0, edgeSpendInfoIn, this.currencyInfo)
417
+ const { edgeSpendInfo, currencyCode } = this.makeSpendCheck(edgeSpendInfoIn)
418
+ const { memos = [] } = edgeSpendInfo
419
+
414
420
  if (this.otherData.hederaAccount == null) {
415
421
  throw Error('ErrorAccountNotActivated')
416
422
  }
417
-
418
- const { edgeSpendInfo, currencyCode } = this.makeSpendCheck(edgeSpendInfoIn)
419
-
420
423
  if (edgeSpendInfo.spendTargets.length !== 1) {
421
424
  throw new Error('Error: only one output allowed')
422
425
  }
423
426
 
424
- const { publicAddress, uniqueIdentifier = '' } =
425
- edgeSpendInfo.spendTargets[0]
427
+ const memo = _optionalChain([memos, 'access', _2 => _2[0], 'optionalAccess', _3 => _3.type]) === 'text' ? memos[0].value : ''
428
+ const { publicAddress } = edgeSpendInfo.spendTargets[0]
426
429
  let { nativeAmount } = edgeSpendInfo.spendTargets[0]
427
430
 
428
431
  if (publicAddress == null)
@@ -455,25 +458,26 @@ var _hederaTypes = require('./hederaTypes');
455
458
  .addHbarTransfer(this.otherData.hederaAccount, hbar.negated())
456
459
  .addHbarTransfer(publicAddress, hbar)
457
460
  .setMaxTransactionFee(txnFee)
458
- .setTransactionMemo(uniqueIdentifier)
461
+ .setTransactionMemo(memo)
459
462
  .build(this.client)
460
463
 
461
464
  const edgeTransaction = {
462
- txid: '',
463
- date: 0,
464
- currencyCode, // currencyCode
465
465
  blockHeight: 0, // blockHeight
466
- nativeAmount: `-${nativeAmount}`,
466
+ currencyCode, // currencyCode
467
+ date: 0,
467
468
  isSend: true,
469
+ memos,
470
+ nativeAmount: `-${nativeAmount}`,
468
471
  // UI shows the fee subtracted from the sent amount which doesn't make sense here
469
472
  networkFee, // networkFee
470
- ourReceiveAddresses: [], // ourReceiveAddresses
471
- signedTx: '', // signedTx
472
473
  otherParams: {
473
474
  fromAddress: this.walletLocalData.publicKey,
474
475
  toAddress: publicAddress,
475
476
  transferTx: _rfc4648.base64.stringify(transferTx.toBytes())
476
477
  },
478
+ ourReceiveAddresses: [], // ourReceiveAddresses
479
+ signedTx: '', // signedTx
480
+ txid: '',
477
481
  walletId: this.walletId
478
482
  }
479
483
  return edgeTransaction
@@ -14,22 +14,17 @@ const networkInfo = {
14
14
  }
15
15
 
16
16
  const currencyInfo = {
17
- // Basic currency information:
18
17
  currencyCode: 'HBAR',
19
18
  displayName: 'Hedera',
20
19
  pluginId: 'hedera',
21
20
  walletType: 'wallet:hedera',
22
21
 
23
- defaultSettings: {},
24
-
25
- memoMaxLength: 100,
26
-
22
+ // Explorers:
27
23
  addressExplorer: 'https://hashscan.io/mainnet/account/%s',
28
24
  transactionExplorer: 'https://hashscan.io/mainnet/transaction/%s',
29
25
 
30
26
  denominations: [
31
- // An array of Objects of the possible denominations for this currency
32
- // other denominations are specified but these are the most common
27
+ // Other denominations are specified but these are the most common:
33
28
  {
34
29
  name: 'HBAR',
35
30
  multiplier: '100000000', // 100,000,000
@@ -41,7 +36,15 @@ const currencyInfo = {
41
36
  symbol: 'tℏ'
42
37
  }
43
38
  ],
44
- metaTokens: [] // Deprecated
39
+
40
+ // https://docs.hedera.com/hedera/sdks-and-apis/sdks/transactions/modify-transaction-fields
41
+ memoOptions: [{ type: 'text', memoName: 'memo', maxLength: 100 }],
42
+
43
+ // Deprecated:
44
+ defaultSettings: {},
45
+ memoMaxLength: 100,
46
+ memoType: 'text',
47
+ metaTokens: []
45
48
  }
46
49
 
47
50
  const hedera = _innerPlugin.makeOuterPlugin({
@@ -13,20 +13,17 @@ const networkInfo = {
13
13
  }
14
14
 
15
15
  const currencyInfo = {
16
- // Basic currency information:
17
16
  currencyCode: 'THBAR',
18
17
  displayName: 'Hedera Testnet',
19
18
  pluginId: 'hederatestnet',
20
19
  walletType: 'wallet:hederatestnet',
21
20
 
22
- defaultSettings: {},
23
-
21
+ // Explorers:
24
22
  addressExplorer: `https://explorer.kabuto.sh/testnet/id/%s`,
25
23
  transactionExplorer: `https://explorer.kabuto.sh/testnet/transaction/%s`,
26
24
 
27
25
  denominations: [
28
- // An array of Objects of the possible denominations for this currency
29
- // other denominations are specified but these are the most common
26
+ // Other denominations are specified but these are the most common:
30
27
  {
31
28
  name: 'THBAR',
32
29
  multiplier: '100000000', // 100,000,000
@@ -38,7 +35,10 @@ const currencyInfo = {
38
35
  symbol: 'tℏ'
39
36
  }
40
37
  ],
41
- metaTokens: [] // Deprecated
38
+
39
+ // Deprecated:
40
+ defaultSettings: {},
41
+ metaTokens: []
42
42
  }
43
43
 
44
44
  const hederatestnet = _innerPlugin.makeOuterPlugin({
@@ -20,6 +20,7 @@ var _rfc4648 = require('rfc4648');
20
20
  var _CurrencyEngine = require('../common/CurrencyEngine');
21
21
 
22
22
  var _tokenHelpers = require('../common/tokenHelpers');
23
+ var _upgradeMemos = require('../common/upgradeMemos');
23
24
 
24
25
 
25
26
 
@@ -189,15 +190,16 @@ const queryTxMutex = _utils.makeMutex.call(void 0, )
189
190
  }
190
191
 
191
192
  const edgeTransaction = {
192
- txid: hash,
193
- date,
194
- currencyCode: this.currencyInfo.currencyCode,
195
193
  blockHeight,
196
- nativeAmount,
194
+ currencyCode: this.currencyInfo.currencyCode,
195
+ date,
197
196
  isSend: nativeAmount.startsWith('-'),
197
+ memos: [],
198
+ nativeAmount,
198
199
  networkFee: fee,
199
200
  ourReceiveAddresses,
200
201
  signedTx: '',
202
+ txid: hash,
201
203
  walletId: this.walletId
202
204
  }
203
205
  this.addTransaction(this.currencyInfo.currencyCode, edgeTransaction)
@@ -320,6 +322,7 @@ const queryTxMutex = _utils.makeMutex.call(void 0, )
320
322
  }
321
323
 
322
324
  async getMaxSpendable(spendInfo) {
325
+ spendInfo = _upgradeMemos.upgradeMemos.call(void 0, spendInfo, this.currencyInfo)
323
326
  if (
324
327
  spendInfo.spendTargets.length === 0 ||
325
328
  spendInfo.spendTargets[0].publicAddress == null
@@ -385,7 +388,9 @@ const queryTxMutex = _utils.makeMutex.call(void 0, )
385
388
  }
386
389
 
387
390
  async makeSpend(edgeSpendInfoIn) {
391
+ edgeSpendInfoIn = _upgradeMemos.upgradeMemos.call(void 0, edgeSpendInfoIn, this.currencyInfo)
388
392
  const { edgeSpendInfo, currencyCode } = this.makeSpendCheck(edgeSpendInfoIn)
393
+ const { memos = [] } = edgeSpendInfo
389
394
 
390
395
  if (edgeSpendInfo.spendTargets.length !== 1) {
391
396
  throw new Error('Error: only one output allowed')
@@ -482,16 +487,17 @@ const queryTxMutex = _utils.makeMutex.call(void 0, )
482
487
  // **********************************
483
488
  // Create the unsigned EdgeTransaction
484
489
  const edgeTransaction = {
485
- txid: '',
486
- date: 0,
487
- currencyCode,
488
490
  blockHeight: 0,
489
- nativeAmount: _biggystring.mul.call(void 0, totalTxAmount, '-1'),
491
+ currencyCode,
492
+ date: 0,
490
493
  isSend: true,
494
+ memos,
495
+ nativeAmount: _biggystring.mul.call(void 0, totalTxAmount, '-1'),
491
496
  networkFee: nativeNetworkFee,
497
+ otherParams,
492
498
  ourReceiveAddresses: [],
493
499
  signedTx: '',
494
- otherParams,
500
+ txid: '',
495
501
  walletId: this.walletId
496
502
  }
497
503
 
@@ -30,6 +30,7 @@ const networkInfo = {
30
30
  pluginId: 'liberland',
31
31
  walletType: 'wallet:liberland',
32
32
 
33
+ // Explorers:
33
34
  addressExplorer: '',
34
35
  transactionExplorer:
35
36
  'https://polkadot.js.org/apps/?rpc=wss%%3A%%2F%%2Fmainnet.liberland.org%%2F#/explorer/query/%s',
@@ -42,9 +43,9 @@ const networkInfo = {
42
43
  }
43
44
  ],
44
45
 
45
- // Deprecated
46
+ // Deprecated:
46
47
  defaultSettings: {},
47
- metaTokens: _tokenHelpers.makeMetaTokens.call(void 0, builtinTokens) // Deprecated
48
+ metaTokens: _tokenHelpers.makeMetaTokens.call(void 0, builtinTokens)
48
49
  }; exports.currencyInfo = currencyInfo
49
50
 
50
51
  const liberland = _innerPlugin.makeOuterPlugin({
@@ -30,6 +30,7 @@ const networkInfo = {
30
30
  pluginId: 'liberlandtestnet',
31
31
  walletType: 'wallet:liberlandtestnet',
32
32
 
33
+ // Explorers:
33
34
  addressExplorer: '',
34
35
  transactionExplorer:
35
36
  'https://polkadot.js.org/apps/?rpc=wss%%3A%%2F%%2Ftestchain.liberland.org%%2F#/explorer/query/%s',
@@ -42,9 +43,9 @@ const networkInfo = {
42
43
  }
43
44
  ],
44
45
 
45
- // Deprecated
46
+ // Deprecated:
46
47
  defaultSettings: {},
47
- metaTokens: _tokenHelpers.makeMetaTokens.call(void 0, builtinTokens) // Deprecated
48
+ metaTokens: _tokenHelpers.makeMetaTokens.call(void 0, builtinTokens)
48
49
  }; exports.currencyInfo = currencyInfo
49
50
 
50
51
  const liberlandtestnet = _innerPlugin.makeOuterPlugin
@@ -13,26 +13,29 @@ const networkInfo = {
13
13
  }
14
14
 
15
15
  const currencyInfo = {
16
- // Basic currency information:
17
16
  currencyCode: 'DOT',
18
17
  displayName: 'Polkadot',
19
18
  pluginId: 'polkadot',
20
19
  walletType: 'wallet:polkadot',
21
20
 
22
- defaultSettings: {},
23
-
21
+ // Explorers:
24
22
  addressExplorer: 'https://polkadot.subscan.io/account/%s',
25
23
  transactionExplorer: 'https://polkadot.subscan.io/extrinsic/%s',
26
24
 
27
25
  denominations: [
28
- // An array of Objects of the possible denominations for this currency
29
26
  {
30
27
  name: 'DOT',
31
28
  multiplier: '10000000000',
32
29
  symbol: ''
33
30
  }
34
31
  ],
35
- metaTokens: [] // Deprecated
32
+
33
+ // No memo support:
34
+ memoOptions: [],
35
+
36
+ // Deprecated:
37
+ defaultSettings: {},
38
+ metaTokens: []
36
39
  }; exports.currencyInfo = currencyInfo
37
40
 
38
41
  const polkadot = _innerPlugin.makeOuterPlugin({
@@ -27,6 +27,7 @@ var _biggystring = require('biggystring');
27
27
 
28
28
 
29
29
  var _types = require('edge-core-js/types');
30
+ var _rfc4648 = require('rfc4648');
30
31
 
31
32
 
32
33
 
@@ -43,18 +44,14 @@ var _payment = require('xrpl/dist/npm/models/transactions/payment');
43
44
  var _CurrencyEngine = require('../common/CurrencyEngine');
44
45
 
45
46
  var _tokenHelpers = require('../common/tokenHelpers');
47
+ var _upgradeMemos = require('../common/upgradeMemos');
48
+ var _utf8 = require('../common/utf8');
46
49
 
47
50
 
48
51
 
49
52
 
50
53
 
51
54
  var _utils = require('../common/utils');
52
-
53
-
54
-
55
-
56
-
57
- var _pluginError = require('../pluginError');
58
55
  var _rippleInfo = require('./rippleInfo');
59
56
 
60
57
 
@@ -166,19 +163,20 @@ const SET_TRUST_LINE_FEE = '12'
166
163
  : this.allTokensMap[fromTokenId]
167
164
 
168
165
  const out = {
169
- txid: '',
170
- date: Date.now() / 1000,
171
- currencyCode,
172
166
  blockHeight: 0, // blockHeight,
167
+ currencyCode,
168
+ date: Date.now() / 1000,
169
+ isSend: true,
170
+ memos: [],
173
171
  metadata,
174
172
  nativeAmount: `-${_biggystring.add.call(void 0, fromNativeAmount, networkFee)}`,
175
- isSend: true,
176
173
  networkFee,
177
- ourReceiveAddresses: [],
178
- signedTx: '',
179
174
  otherParams: {
180
175
  xrpTransaction
181
176
  },
177
+ ourReceiveAddresses: [],
178
+ signedTx: '',
179
+ txid: '',
182
180
  walletId: this.walletId
183
181
  }
184
182
  return out
@@ -337,16 +335,17 @@ const SET_TRUST_LINE_FEE = '12'
337
335
  }
338
336
  // Parent currency like XRP
339
337
  this.addTransaction(currency, {
340
- txid: hash.toLowerCase(),
341
- date: _xrpl.rippleTimeToUnixTime.call(void 0, date) / 1000, // Returned date is in "ripple time" which is unix time if it had started on Jan 1 2000
342
- currencyCode: currency,
343
338
  blockHeight: _nullishCoalesce(tx.ledger_index, () => ( -1)),
344
- nativeAmount,
339
+ currencyCode: currency,
340
+ date: _xrpl.rippleTimeToUnixTime.call(void 0, date) / 1000, // Returned date is in "ripple time" which is unix time if it had started on Jan 1 2000
345
341
  isSend,
342
+ memos: [],
343
+ nativeAmount,
346
344
  networkFee,
345
+ otherParams: {},
347
346
  ourReceiveAddresses,
348
347
  signedTx: '',
349
- otherParams: {},
348
+ txid: hash.toLowerCase(),
350
349
  walletId: this.walletId
351
350
  })
352
351
  } else {
@@ -372,16 +371,17 @@ const SET_TRUST_LINE_FEE = '12'
372
371
  }
373
372
 
374
373
  this.addTransaction(currencyCode, {
375
- txid: hash.toLowerCase(),
376
- date: _xrpl.rippleTimeToUnixTime.call(void 0, date) / 1000, // Returned date is in "ripple time" which is unix time if it had started on Jan 1 2000
377
- currencyCode,
378
374
  blockHeight: _nullishCoalesce(tx.ledger_index, () => ( -1)),
379
- nativeAmount,
375
+ currencyCode,
376
+ date: _xrpl.rippleTimeToUnixTime.call(void 0, date) / 1000, // Returned date is in "ripple time" which is unix time if it had started on Jan 1 2000
380
377
  isSend,
378
+ memos: [],
379
+ nativeAmount,
381
380
  networkFee: '0',
381
+ otherParams: {},
382
382
  ourReceiveAddresses,
383
383
  signedTx: '',
384
- otherParams: {},
384
+ txid: hash.toLowerCase(),
385
385
  walletId: this.walletId
386
386
  })
387
387
  }
@@ -583,6 +583,7 @@ const SET_TRUST_LINE_FEE = '12'
583
583
  }
584
584
 
585
585
  async getMaxSpendable(spendInfo) {
586
+ spendInfo = _upgradeMemos.upgradeMemos.call(void 0, spendInfo, this.currencyInfo)
586
587
  const { currencyCode } = spendInfo
587
588
  let spendableBalance = this.getBalance({
588
589
  currencyCode
@@ -599,8 +600,11 @@ const SET_TRUST_LINE_FEE = '12'
599
600
  }
600
601
 
601
602
  async makeSpend(edgeSpendInfoIn) {
603
+ edgeSpendInfoIn = _upgradeMemos.upgradeMemos.call(void 0, edgeSpendInfoIn, this.currencyInfo)
602
604
  const { edgeSpendInfo, currencyCode, nativeBalance } =
603
605
  this.makeSpendCheck(edgeSpendInfoIn)
606
+ const { memos = [] } = edgeSpendInfo
607
+
604
608
  const parentCurrencyCode = this.currencyInfo.currencyCode
605
609
 
606
610
  // Activation Transaction:
@@ -628,19 +632,20 @@ const SET_TRUST_LINE_FEE = '12'
628
632
  })
629
633
 
630
634
  return {
631
- txid: '',
632
- date: Date.now() / 1000,
633
- currencyCode: this.currencyInfo.currencyCode,
634
635
  blockHeight: 0, // blockHeight,
636
+ currencyCode: this.currencyInfo.currencyCode,
637
+ date: Date.now() / 1000,
638
+ isSend: true,
639
+ memos,
635
640
  metadata: edgeSpendInfo.metadata,
636
641
  nativeAmount: `-${networkFee}`,
637
- isSend: true,
638
642
  networkFee,
639
- ourReceiveAddresses: [],
640
- signedTx: '',
641
643
  otherParams: {
642
644
  xrpTransaction
643
645
  },
646
+ ourReceiveAddresses: [],
647
+ signedTx: '',
648
+ txid: '',
644
649
  walletId: this.walletId
645
650
  }
646
651
  }
@@ -688,44 +693,6 @@ const SET_TRUST_LINE_FEE = '12'
688
693
  }
689
694
  }
690
695
 
691
- const uniqueIdentifier =
692
- _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(edgeSpendInfo.spendTargets[0].memo, () => (
693
- edgeSpendInfo.spendTargets[0].uniqueIdentifier)), () => (
694
- _optionalChain([edgeSpendInfo, 'access', _18 => _18.spendTargets, 'access', _19 => _19[0], 'access', _20 => _20.otherParams, 'optionalAccess', _21 => _21.uniqueIdentifier]))), () => (
695
- ''))
696
-
697
- if (uniqueIdentifier !== '') {
698
- // Destination Tag Checks
699
- const { memoMaxLength = Infinity, memoMaxValue } = this.currencyInfo
700
-
701
- if (Number.isNaN(parseInt(uniqueIdentifier))) {
702
- throw new (0, _pluginError.PluginError)(
703
- 'Please enter a valid Destination Tag',
704
- _pluginError.pluginErrorName.XRP_ERROR,
705
- _pluginError.pluginErrorCodes[0],
706
- _pluginError.pluginErrorLabels.UNIQUE_IDENTIFIER_FORMAT
707
- )
708
- }
709
-
710
- if (uniqueIdentifier.length > memoMaxLength) {
711
- throw new (0, _pluginError.PluginError)(
712
- `Destination Tag must be ${memoMaxLength} characters or less`,
713
- _pluginError.pluginErrorName.XRP_ERROR,
714
- _pluginError.pluginErrorCodes[0],
715
- _pluginError.pluginErrorLabels.UNIQUE_IDENTIFIER_EXCEEDS_LENGTH
716
- )
717
- }
718
-
719
- if (memoMaxValue != null && _biggystring.gt.call(void 0, uniqueIdentifier, memoMaxValue)) {
720
- throw new (0, _pluginError.PluginError)(
721
- 'XRP Destination Tag is above its maximum limit',
722
- _pluginError.pluginErrorName.XRP_ERROR,
723
- _pluginError.pluginErrorCodes[0],
724
- _pluginError.pluginErrorLabels.UNIQUE_IDENTIFIER_EXCEEDS_LIMIT
725
- )
726
- }
727
- }
728
-
729
696
  let payment
730
697
  if (currencyCode === parentCurrencyCode) {
731
698
  payment = {
@@ -765,8 +732,18 @@ const SET_TRUST_LINE_FEE = '12'
765
732
  nativeAmount = `-${nativeAmount}`
766
733
  }
767
734
 
768
- if (uniqueIdentifier !== '') {
769
- payment.DestinationTag = parseInt(uniqueIdentifier)
735
+ for (const memo of memos) {
736
+ if (memo.type === 'number') {
737
+ payment.DestinationTag = parseInt(memos[0].value)
738
+ } else if (memo.type === 'text') {
739
+ if (payment.Memos == null) payment.Memos = []
740
+ payment.Memos.push({
741
+ Memo: {
742
+ MemoFormat: _rfc4648.base16.stringify(_utf8.utf8.parse('text/plain')),
743
+ MemoData: _rfc4648.base16.stringify(_utf8.utf8.parse(memo.value))
744
+ }
745
+ })
746
+ }
770
747
  }
771
748
 
772
749
  const otherParams = {
@@ -774,17 +751,18 @@ const SET_TRUST_LINE_FEE = '12'
774
751
  }
775
752
 
776
753
  const edgeTransaction = {
777
- txid: '', // txid
778
- date: 0, // date
779
- currencyCode, // currencyCode
780
754
  blockHeight: 0, // blockHeight
781
- nativeAmount, // nativeAmount
755
+ currencyCode, // currencyCode
756
+ date: 0, // date
782
757
  isSend: true,
758
+ memos: [],
759
+ nativeAmount, // nativeAmount
783
760
  networkFee,
784
- parentNetworkFee,
761
+ otherParams,
785
762
  ourReceiveAddresses: [], // ourReceiveAddresses
763
+ parentNetworkFee,
786
764
  signedTx: '', // signedTx
787
- otherParams,
765
+ txid: '', // txid
788
766
  walletId: this.walletId
789
767
  }
790
768
 
@@ -904,7 +882,7 @@ const SET_TRUST_LINE_FEE = '12'
904
882
  )
905
883
  if (paymentTokenId != null)
906
884
  throw new Error(`Must activate with ${this.currencyInfo.currencyCode}`)
907
- if (_optionalChain([paymentWallet, 'optionalAccess', _22 => _22.id]) !== this.walletId)
885
+ if (_optionalChain([paymentWallet, 'optionalAccess', _18 => _18.id]) !== this.walletId)
908
886
  throw new Error('Must pay with same wallet you are activating token with')
909
887
 
910
888
  for (const activateTokenId of activateTokenIds) {
@@ -15,29 +15,37 @@ const networkInfo = {
15
15
  }
16
16
 
17
17
  const currencyInfo = {
18
- // Basic currency information:
19
18
  currencyCode: 'XRP',
20
19
  displayName: 'XRP',
21
20
  pluginId: 'ripple',
22
21
  walletType: 'wallet:ripple',
23
22
 
24
- defaultSettings: {},
25
-
26
- memoMaxLength: 10,
27
- memoMaxValue: '4294967295',
28
-
23
+ // Explorers:
29
24
  addressExplorer: 'https://xrpscan.com/account/%s',
30
25
  transactionExplorer: 'https://xrpscan.com/tx/%s',
31
26
 
32
27
  denominations: [
33
- // An array of Objects of the possible denominations for this currency
34
28
  {
35
29
  name: 'XRP',
36
30
  multiplier: '1000000',
37
31
  symbol: 'X'
38
32
  }
39
33
  ],
40
- metaTokens: [] // Deprecated
34
+
35
+ memoOptions: [
36
+ // https://xrpl.org/payment.html#payment-fields
37
+ { type: 'number', memoName: 'destination tag', maxValue: '4294967295' },
38
+ // https://xrpl.org/transaction-common-fields.html#memos-field
39
+ { type: 'text', memoName: 'memo', maxLength: 990 }
40
+ ],
41
+ multipleMemos: true,
42
+
43
+ // Deprecated:
44
+ defaultSettings: {},
45
+ memoMaxLength: 10,
46
+ memoMaxValue: '4294967295',
47
+ memoType: 'number',
48
+ metaTokens: []
41
49
  }; exports.currencyInfo = currencyInfo
42
50
 
43
51
  const builtinTokens = {
@@ -16,6 +16,8 @@ var _rfc4648 = require('rfc4648');
16
16
 
17
17
  var _CurrencyEngine = require('../common/CurrencyEngine');
18
18
 
19
+ var _upgradeMemos = require('../common/upgradeMemos');
20
+ var _utf8 = require('../common/utf8');
19
21
 
20
22
 
21
23
 
@@ -176,15 +178,16 @@ const TRANSACTION_POLL_MILLISECONDS = 3000
176
178
  ourReceiveAddresses.push(this.base58PublicKey)
177
179
  }
178
180
  const edgeTransaction = {
179
- txid: tx.transaction.signatures[0],
180
- date: timestamp,
181
- currencyCode: this.chainCode,
182
181
  blockHeight: tx.slot,
183
- nativeAmount: amount.toString(),
182
+ currencyCode: this.chainCode,
183
+ date: timestamp,
184
184
  isSend: amount.toString().startsWith('-'),
185
+ memos: [],
186
+ nativeAmount: amount.toString(),
185
187
  networkFee: fee.toString(),
186
188
  ourReceiveAddresses,
187
189
  signedTx: '',
190
+ txid: tx.transaction.signatures[0],
188
191
  walletId: this.walletId
189
192
  }
190
193
  this.addTransaction(this.chainCode, edgeTransaction)
@@ -314,7 +317,9 @@ const TRANSACTION_POLL_MILLISECONDS = 3000
314
317
  }
315
318
 
316
319
  async makeSpend(edgeSpendInfoIn) {
320
+ edgeSpendInfoIn = _upgradeMemos.upgradeMemos.call(void 0, edgeSpendInfoIn, this.currencyInfo)
317
321
  const { edgeSpendInfo, currencyCode } = this.makeSpendCheck(edgeSpendInfoIn)
322
+ const { memos = [] } = edgeSpendInfo
318
323
 
319
324
  if (edgeSpendInfo.spendTargets.length !== 1) {
320
325
  throw new Error('Error: only one output allowed')
@@ -348,8 +353,7 @@ const TRANSACTION_POLL_MILLISECONDS = 3000
348
353
  })
349
354
  )
350
355
 
351
- const memo = _optionalChain([edgeSpendInfo, 'access', _ => _.spendTargets, 'access', _2 => _2[0], 'optionalAccess', _3 => _3.otherParams, 'optionalAccess', _4 => _4.uniqueIdentifier])
352
- if (memo != null && memo !== '') {
356
+ if (_optionalChain([memos, 'access', _ => _[0], 'optionalAccess', _2 => _2.type]) === 'text') {
353
357
  const memoOpts = new TransactionInstruction({
354
358
  keys: [
355
359
  {
@@ -359,7 +363,7 @@ const TRANSACTION_POLL_MILLISECONDS = 3000
359
363
  }
360
364
  ],
361
365
  programId: new PublicKey(this.networkInfo.memoPublicKey),
362
- data: Buffer.from(memo)
366
+ data: Buffer.from(_utf8.utf8.parse(memos[0].value))
363
367
  })
364
368
  solTx.add(memoOpts)
365
369
  }
@@ -374,16 +378,17 @@ const TRANSACTION_POLL_MILLISECONDS = 3000
374
378
  // Create the unsigned EdgeTransaction
375
379
 
376
380
  const edgeTransaction = {
377
- txid: '',
378
- date: 0,
379
- currencyCode,
380
381
  blockHeight: 0,
381
- nativeAmount: _biggystring.mul.call(void 0, totalTxAmount, '-1'),
382
+ currencyCode,
383
+ date: 0,
382
384
  isSend: true,
385
+ memos,
386
+ nativeAmount: _biggystring.mul.call(void 0, totalTxAmount, '-1'),
383
387
  networkFee: nativeNetworkFee,
388
+ otherParams,
384
389
  ourReceiveAddresses: [],
385
390
  signedTx: '',
386
- otherParams,
391
+ txid: '',
387
392
  walletId: this.walletId
388
393
  }
389
394