edge-currency-accountbased 2.2.4 → 2.4.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 (95) hide show
  1. package/CHANGELOG.md +11 -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/504.chunk.js +2 -0
  6. package/android/src/main/assets/edge-currency-accountbased/612.chunk.js +1 -0
  7. package/android/src/main/assets/edge-currency-accountbased/{945.chunk.js → 814.chunk.js} +8 -8
  8. package/android/src/main/assets/edge-currency-accountbased/935.chunk.js +1 -1
  9. package/android/src/main/assets/edge-currency-accountbased/94.chunk.js +8 -0
  10. package/android/src/main/assets/edge-currency-accountbased/algorand.chunk.js +2 -2
  11. package/android/src/main/assets/edge-currency-accountbased/bnb.chunk.js +4 -4
  12. package/android/src/main/assets/edge-currency-accountbased/edge-currency-accountbased.js +10 -10
  13. package/android/src/main/assets/edge-currency-accountbased/eos.chunk.js +12 -12
  14. package/android/src/main/assets/edge-currency-accountbased/ethereum.chunk.js +5 -5
  15. package/android/src/main/assets/edge-currency-accountbased/filecoin.chunk.js +1 -1
  16. package/android/src/main/assets/edge-currency-accountbased/fio.chunk.js +2 -2
  17. package/android/src/main/assets/edge-currency-accountbased/hedera.chunk.js +2 -2
  18. package/android/src/main/assets/edge-currency-accountbased/polkadot.chunk.js +2 -2
  19. package/android/src/main/assets/edge-currency-accountbased/ripple.chunk.js +5 -5
  20. package/android/src/main/assets/edge-currency-accountbased/solana.chunk.js +3 -3
  21. package/android/src/main/assets/edge-currency-accountbased/stellar.chunk.js +4 -4
  22. package/android/src/main/assets/edge-currency-accountbased/tezos.chunk.js +3 -3
  23. package/android/src/main/assets/edge-currency-accountbased/tron.chunk.js +1 -1
  24. package/android/src/main/assets/edge-currency-accountbased/zcash.chunk.js +2 -2
  25. package/lib/algorand/AlgorandEngine.js +46 -24
  26. package/lib/algorand/algorandInfo.js +8 -7
  27. package/lib/algorand/algorandTestnetInfo.js +8 -7
  28. package/lib/binance/BinanceEngine.js +19 -17
  29. package/lib/binance/binanceInfo.js +10 -7
  30. package/lib/common/types.js +10 -0
  31. package/lib/common/upgradeMemos.js +52 -0
  32. package/lib/common/utf8.js +32 -0
  33. package/lib/common/validateMemos.js +107 -0
  34. package/lib/eos/EosEngine.js +42 -41
  35. package/lib/eos/info/eosCommonInfo.js +10 -0
  36. package/lib/eos/info/eosInfo.js +15 -17
  37. package/lib/eos/info/telosInfo.js +15 -15
  38. package/lib/eos/info/waxInfo.js +15 -16
  39. package/lib/ethereum/EthereumEngine.js +13 -12
  40. package/lib/ethereum/EthereumNetwork.js +16 -14
  41. package/lib/ethereum/info/avalancheInfo.js +9 -7
  42. package/lib/ethereum/info/binancesmartchainInfo.js +9 -7
  43. package/lib/ethereum/info/celoInfo.js +9 -7
  44. package/lib/ethereum/info/ethDevInfo.js +9 -7
  45. package/lib/ethereum/info/ethereumCommonInfo.js +10 -0
  46. package/lib/ethereum/info/ethereumInfo.js +9 -7
  47. package/lib/ethereum/info/ethereumclassicInfo.js +9 -7
  48. package/lib/ethereum/info/ethereumpowInfo.js +9 -7
  49. package/lib/ethereum/info/fantomInfo.js +9 -7
  50. package/lib/ethereum/info/goerliInfo.js +9 -7
  51. package/lib/ethereum/info/kovanInfo.js +9 -7
  52. package/lib/ethereum/info/optimismInfo.js +9 -7
  53. package/lib/ethereum/info/polygonInfo.js +9 -7
  54. package/lib/ethereum/info/pulsechainInfo.js +11 -9
  55. package/lib/ethereum/info/rinkebyInfo.js +9 -7
  56. package/lib/ethereum/info/ropstenInfo.js +9 -7
  57. package/lib/ethereum/info/rskInfo.js +9 -7
  58. package/lib/ethereum/info/zksyncInfo.js +9 -7
  59. package/lib/filecoin/FilecoinEngine.js +21 -15
  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/index.js +1 -1
  67. package/lib/piratechain/PiratechainEngine.js +469 -0
  68. package/lib/piratechain/PiratechainTools.js +239 -0
  69. package/lib/{zcash → piratechain}/piratechainInfo.js +13 -9
  70. package/lib/piratechain/piratechainTypes.js +177 -0
  71. package/lib/polkadot/PolkadotEngine.js +15 -9
  72. package/lib/polkadot/info/liberlandInfo.js +3 -2
  73. package/lib/polkadot/info/liberlandTestnetInfo.js +3 -2
  74. package/lib/polkadot/info/polkadotInfo.js +8 -5
  75. package/lib/react-native.js +93 -69
  76. package/lib/ripple/RippleEngine.js +53 -75
  77. package/lib/ripple/rippleInfo.js +16 -8
  78. package/lib/solana/SolanaEngine.js +17 -12
  79. package/lib/solana/solanaInfo.js +9 -5
  80. package/lib/stellar/StellarEngine.js +31 -22
  81. package/lib/stellar/stellarInfo.js +16 -7
  82. package/lib/tezos/TezosEngine.js +17 -11
  83. package/lib/tezos/tezosInfo.js +8 -5
  84. package/lib/tron/TronEngine.js +85 -68
  85. package/lib/tron/tronInfo.js +8 -7
  86. package/lib/zcash/ZcashEngine.js +86 -48
  87. package/lib/zcash/ZcashTools.js +10 -34
  88. package/lib/zcash/zcashInfo.js +8 -7
  89. package/lib/zcash/zcashTypes.js +2 -13
  90. package/package.json +4 -6
  91. package/android/src/main/assets/edge-currency-accountbased/124.chunk.js +0 -35
  92. package/android/src/main/assets/edge-currency-accountbased/223.chunk.js +0 -9
  93. package/android/src/main/assets/edge-currency-accountbased/650.chunk.js +0 -1
  94. package/android/src/main/assets/edge-currency-accountbased/689.chunk.js +0 -8
  95. package/android/src/main/assets/edge-currency-accountbased/826.chunk.js +0 -35
@@ -17,6 +17,7 @@ var _tronweb = require('tronweb'); var _tronweb2 = _interopRequireDefault(_tronw
17
17
 
18
18
  var _CurrencyEngine = require('../common/CurrencyEngine');
19
19
 
20
+ var _upgradeMemos = require('../common/upgradeMemos');
20
21
 
21
22
 
22
23
 
@@ -481,15 +482,16 @@ const NETWORKFEES_POLL_MILLISECONDS = 60 * 10 * 1000
481
482
  const { currencyCode } = this.currencyInfo
482
483
 
483
484
  const edgeTransaction = {
484
- txid,
485
- date: Math.floor(timestamp / 1000),
486
- currencyCode,
487
485
  blockHeight: blockNumber,
488
- nativeAmount,
486
+ currencyCode,
487
+ date: Math.floor(timestamp / 1000),
489
488
  isSend: nativeAmount.startsWith('-'),
489
+ memos: [],
490
+ nativeAmount,
490
491
  networkFee: feeNativeAmount,
491
492
  ourReceiveAddresses: ourReceiveAddresses,
492
493
  signedTx: '',
494
+ txid,
493
495
  walletId: this.walletId
494
496
  }
495
497
 
@@ -518,15 +520,16 @@ const NETWORKFEES_POLL_MILLISECONDS = 60 * 10 * 1000
518
520
  const { currencyCode } = this.currencyInfo
519
521
 
520
522
  const edgeTransaction = {
521
- txid,
522
- date: Math.floor(timestamp / 1000),
523
- currencyCode,
524
523
  blockHeight: blockNumber,
525
- nativeAmount: _biggystring.mul.call(void 0, feeNativeAmount, '-1'),
524
+ currencyCode,
525
+ date: Math.floor(timestamp / 1000),
526
526
  isSend: true,
527
+ memos: [],
528
+ nativeAmount: _biggystring.mul.call(void 0, feeNativeAmount, '-1'),
527
529
  networkFee: feeNativeAmount,
528
530
  ourReceiveAddresses,
529
531
  signedTx: '',
532
+ txid,
530
533
  walletId: this.walletId
531
534
  }
532
535
 
@@ -554,15 +557,16 @@ const NETWORKFEES_POLL_MILLISECONDS = 60 * 10 * 1000
554
557
  const { currencyCode } = this.currencyInfo
555
558
 
556
559
  const edgeTransaction = {
557
- txid,
558
- date: Math.floor(timestamp / 1000),
559
- currencyCode,
560
560
  blockHeight: blockNumber,
561
- nativeAmount: _biggystring.mul.call(void 0, nativeAmount, '-1'),
561
+ currencyCode,
562
+ date: Math.floor(timestamp / 1000),
562
563
  isSend: true,
564
+ memos: [],
565
+ nativeAmount: _biggystring.mul.call(void 0, nativeAmount, '-1'),
563
566
  networkFee: feeNativeAmount,
564
567
  ourReceiveAddresses,
565
568
  signedTx: '',
569
+ txid,
566
570
  walletId: this.walletId
567
571
  }
568
572
 
@@ -591,15 +595,16 @@ const NETWORKFEES_POLL_MILLISECONDS = 60 * 10 * 1000
591
595
  const nativeAmount = _biggystring.sub.call(void 0, unfreezeAmount.toString(), feeNativeAmount)
592
596
 
593
597
  const edgeTransaction = {
594
- txid,
595
- date: Math.floor(timestamp / 1000),
596
- currencyCode,
597
598
  blockHeight: blockNumber,
598
- nativeAmount,
599
+ currencyCode,
600
+ date: Math.floor(timestamp / 1000),
599
601
  isSend: nativeAmount.startsWith('-'),
602
+ memos: [],
603
+ nativeAmount,
600
604
  networkFee: feeNativeAmount,
601
605
  ourReceiveAddresses,
602
606
  signedTx: '',
607
+ txid,
603
608
  walletId: this.walletId
604
609
  }
605
610
 
@@ -627,15 +632,16 @@ const NETWORKFEES_POLL_MILLISECONDS = 60 * 10 * 1000
627
632
  const { currencyCode } = this.currencyInfo
628
633
 
629
634
  const edgeTransaction = {
630
- txid,
631
- date: Math.floor(timestamp / 1000),
632
- currencyCode,
633
635
  blockHeight: blockNumber,
634
- nativeAmount: _biggystring.mul.call(void 0, nativeAmount, '-1'),
636
+ currencyCode,
637
+ date: Math.floor(timestamp / 1000),
638
+ memos: [],
635
639
  isSend: true,
640
+ nativeAmount: _biggystring.mul.call(void 0, nativeAmount, '-1'),
636
641
  networkFee: feeNativeAmount,
637
642
  ourReceiveAddresses,
638
643
  signedTx: '',
644
+ txid,
639
645
  walletId: this.walletId
640
646
  }
641
647
 
@@ -668,15 +674,16 @@ const NETWORKFEES_POLL_MILLISECONDS = 60 * 10 * 1000
668
674
  const nativeAmount = _biggystring.sub.call(void 0, unfreezeBalance.toString(), feeNativeAmount)
669
675
 
670
676
  const edgeTransaction = {
671
- txid,
672
- date: Math.floor(timestamp / 1000),
673
- currencyCode,
674
677
  blockHeight: blockNumber,
675
- nativeAmount,
678
+ currencyCode,
679
+ date: Math.floor(timestamp / 1000),
676
680
  isSend: nativeAmount.startsWith('-'),
681
+ memos: [],
682
+ nativeAmount,
677
683
  networkFee: feeNativeAmount,
678
684
  ourReceiveAddresses,
679
685
  signedTx: '',
686
+ txid,
680
687
  walletId: this.walletId
681
688
  }
682
689
 
@@ -740,15 +747,16 @@ const NETWORKFEES_POLL_MILLISECONDS = 60 * 10 * 1000
740
747
  }
741
748
 
742
749
  const edgeTransaction = {
743
- txid,
744
- date: Math.floor(timestamp / 1000),
745
- currencyCode: metaToken.currencyCode,
746
750
  blockHeight,
747
- nativeAmount,
751
+ currencyCode: metaToken.currencyCode,
752
+ date: Math.floor(timestamp / 1000),
748
753
  isSend: nativeAmount.startsWith('-'),
754
+ memos: [],
755
+ nativeAmount,
749
756
  networkFee: '0',
750
757
  ourReceiveAddresses,
751
758
  signedTx: '',
759
+ txid,
752
760
  walletId: this.walletId
753
761
  }
754
762
 
@@ -1106,20 +1114,21 @@ const NETWORKFEES_POLL_MILLISECONDS = 60 * 10 * 1000
1106
1114
  const networkFee = await this.calcTxFee({ unsignedTxHex: transactionHex })
1107
1115
 
1108
1116
  const edgeTransaction = {
1109
- txid: '',
1110
- date: 0,
1111
- currencyCode: this.currencyInfo.currencyCode,
1112
1117
  blockHeight: 0,
1113
- nativeAmount: stakedAmount.nativeAmount,
1118
+ currencyCode: this.currencyInfo.currencyCode,
1119
+ date: 0,
1114
1120
  isSend: stakedAmount.nativeAmount.startsWith('-'),
1121
+ memos: [],
1122
+ metadata: {
1123
+ notes: resource
1124
+ },
1125
+ nativeAmount: stakedAmount.nativeAmount,
1115
1126
  networkFee,
1127
+ otherParams: txOtherParams,
1116
1128
  ourReceiveAddresses: [],
1117
1129
  signedTx: '',
1118
- otherParams: txOtherParams,
1119
- walletId: this.walletId,
1120
- metadata: {
1121
- notes: resource
1122
- }
1130
+ txid: '',
1131
+ walletId: this.walletId
1123
1132
  }
1124
1133
 
1125
1134
  return edgeTransaction
@@ -1148,20 +1157,21 @@ const NETWORKFEES_POLL_MILLISECONDS = 60 * 10 * 1000
1148
1157
  const networkFee = await this.calcTxFee({ unsignedTxHex: transactionHex })
1149
1158
 
1150
1159
  const edgeTransaction = {
1151
- txid: '',
1152
- date: 0,
1153
- currencyCode: this.currencyInfo.currencyCode,
1154
1160
  blockHeight: 0,
1155
- nativeAmount: _biggystring.mul.call(void 0, nativeAmount, '-1'),
1161
+ currencyCode: this.currencyInfo.currencyCode,
1162
+ date: 0,
1156
1163
  isSend: true,
1164
+ memos: [],
1165
+ metadata: {
1166
+ notes: resource
1167
+ },
1168
+ nativeAmount: _biggystring.mul.call(void 0, nativeAmount, '-1'),
1157
1169
  networkFee,
1170
+ otherParams: txOtherParams,
1158
1171
  ourReceiveAddresses: [],
1159
1172
  signedTx: '',
1160
- otherParams: txOtherParams,
1161
- walletId: this.walletId,
1162
- metadata: {
1163
- notes: resource
1164
- }
1173
+ txid: '',
1174
+ walletId: this.walletId
1165
1175
  }
1166
1176
 
1167
1177
  return edgeTransaction
@@ -1195,20 +1205,21 @@ const NETWORKFEES_POLL_MILLISECONDS = 60 * 10 * 1000
1195
1205
  const networkFee = await this.calcTxFee({ unsignedTxHex: transactionHex })
1196
1206
 
1197
1207
  const edgeTransaction = {
1198
- txid: '',
1199
- date: 0,
1200
- currencyCode: this.currencyInfo.currencyCode,
1201
1208
  blockHeight: 0,
1202
- nativeAmount: stakedAmount.nativeAmount,
1209
+ currencyCode: this.currencyInfo.currencyCode,
1210
+ date: 0,
1203
1211
  isSend: stakedAmount.nativeAmount.startsWith('-'),
1212
+ memos: [],
1213
+ metadata: {
1214
+ notes: resource
1215
+ },
1216
+ nativeAmount: stakedAmount.nativeAmount,
1204
1217
  networkFee,
1218
+ otherParams: txOtherParams,
1205
1219
  ourReceiveAddresses: [],
1206
1220
  signedTx: '',
1207
- otherParams: txOtherParams,
1208
- walletId: this.walletId,
1209
- metadata: {
1210
- notes: resource
1211
- }
1221
+ txid: '',
1222
+ walletId: this.walletId
1212
1223
  }
1213
1224
 
1214
1225
  return edgeTransaction
@@ -1251,6 +1262,8 @@ const NETWORKFEES_POLL_MILLISECONDS = 60 * 10 * 1000
1251
1262
  }
1252
1263
 
1253
1264
  async getMaxSpendable(spendInfo) {
1265
+ spendInfo = _upgradeMemos.upgradeMemos.call(void 0, spendInfo, this.currencyInfo)
1266
+ const { memos = [] } = spendInfo
1254
1267
  const balance = this.getBalance({
1255
1268
  currencyCode: spendInfo.currencyCode
1256
1269
  })
@@ -1259,8 +1272,8 @@ const NETWORKFEES_POLL_MILLISECONDS = 60 * 10 * 1000
1259
1272
  throw new Error('Error: only one output allowed')
1260
1273
  }
1261
1274
 
1262
- const { publicAddress, memo } = spendInfo.spendTargets[0]
1263
- const note = memo === '' ? undefined : memo
1275
+ const { publicAddress } = spendInfo.spendTargets[0]
1276
+ const note = _optionalChain([memos, 'access', _13 => _13[0], 'optionalAccess', _14 => _14.type]) === 'text' ? memos[0].value : undefined
1264
1277
 
1265
1278
  if (publicAddress == null || spendInfo.currencyCode == null) {
1266
1279
  throw new Error('Error: need recipient address and/or currencyCode')
@@ -1317,6 +1330,8 @@ const NETWORKFEES_POLL_MILLISECONDS = 60 * 10 * 1000
1317
1330
  }
1318
1331
 
1319
1332
  async makeSpend(edgeSpendInfoIn) {
1333
+ edgeSpendInfoIn = _upgradeMemos.upgradeMemos.call(void 0, edgeSpendInfoIn, this.currencyInfo)
1334
+
1320
1335
  // Check for other transaction types first
1321
1336
  if (edgeSpendInfoIn.otherParams != null) {
1322
1337
  let action
@@ -1338,6 +1353,7 @@ const NETWORKFEES_POLL_MILLISECONDS = 60 * 10 * 1000
1338
1353
  const { edgeSpendInfo, currencyCode } = super.makeSpendCheck(
1339
1354
  edgeSpendInfoIn
1340
1355
  )
1356
+ const { memos = [] } = edgeSpendInfo
1341
1357
 
1342
1358
  const isTokenTransfer = currencyCode !== this.currencyInfo.currencyCode
1343
1359
 
@@ -1346,14 +1362,14 @@ const NETWORKFEES_POLL_MILLISECONDS = 60 * 10 * 1000
1346
1362
  throw new Error('Error: only one output allowed')
1347
1363
  }
1348
1364
 
1349
- const { nativeAmount, publicAddress, otherParams, memo } =
1365
+ const { nativeAmount, publicAddress, otherParams } =
1350
1366
  edgeSpendInfo.spendTargets[0]
1351
1367
  if (publicAddress == null)
1352
1368
  throw new Error('makeSpend Missing publicAddress')
1353
1369
 
1354
1370
  if (nativeAmount == null) throw new (0, _types.NoAmountSpecifiedError)()
1355
1371
  const data =
1356
- _nullishCoalesce(_optionalChain([otherParams, 'optionalAccess', _13 => _13.data]), () => (
1372
+ _nullishCoalesce(_optionalChain([otherParams, 'optionalAccess', _15 => _15.data]), () => (
1357
1373
  (currencyCode !== this.currencyInfo.currencyCode
1358
1374
  ? _tronUtils.encodeTRC20Transfer.call(void 0, publicAddress, nativeAmount)
1359
1375
  : undefined)))
@@ -1361,13 +1377,13 @@ const NETWORKFEES_POLL_MILLISECONDS = 60 * 10 * 1000
1361
1377
  ? this.allTokens.find(token => token.currencyCode === currencyCode)
1362
1378
  : undefined
1363
1379
 
1364
- const note = memo === '' ? undefined : memo
1380
+ const note = _optionalChain([memos, 'access', _16 => _16[0], 'optionalAccess', _17 => _17.type]) === 'text' ? memos[0].value : undefined
1365
1381
 
1366
1382
  const txTransferParams = {
1367
1383
  currencyCode,
1368
1384
  toAddress: publicAddress,
1369
1385
  nativeAmount,
1370
- contractAddress: _optionalChain([metaToken, 'optionalAccess', _14 => _14.contractAddress]),
1386
+ contractAddress: _optionalChain([metaToken, 'optionalAccess', _18 => _18.contractAddress]),
1371
1387
  data,
1372
1388
  note
1373
1389
  }
@@ -1381,8 +1397,8 @@ const NETWORKFEES_POLL_MILLISECONDS = 60 * 10 * 1000
1381
1397
  })
1382
1398
 
1383
1399
  const tokenOpts =
1384
- _optionalChain([metaToken, 'optionalAccess', _15 => _15.contractAddress]) != null && data != null
1385
- ? { contractAddress: _optionalChain([metaToken, 'optionalAccess', _16 => _16.contractAddress]), data }
1400
+ _optionalChain([metaToken, 'optionalAccess', _19 => _19.contractAddress]) != null && data != null
1401
+ ? { contractAddress: _optionalChain([metaToken, 'optionalAccess', _20 => _20.contractAddress]), data }
1386
1402
  : undefined
1387
1403
 
1388
1404
  const totalFeeSUN = await this.calcTxFee({
@@ -1422,16 +1438,17 @@ const NETWORKFEES_POLL_MILLISECONDS = 60 * 10 * 1000
1422
1438
  // **********************************
1423
1439
  // Create the unsigned EdgeTransaction
1424
1440
  const edgeTransaction = {
1425
- txid: '', // txid
1426
- date: 0, // date
1427
- currencyCode, // currencyCode
1428
1441
  blockHeight: 0, // blockHeight
1429
- nativeAmount: _biggystring.mul.call(void 0, edgeNativeAmount, '-1'), // nativeAmount
1442
+ currencyCode, // currencyCode
1443
+ date: 0, // date
1430
1444
  isSend: true,
1445
+ memos,
1446
+ nativeAmount: _biggystring.mul.call(void 0, edgeNativeAmount, '-1'), // nativeAmount
1431
1447
  networkFee, // networkFee
1448
+ otherParams: txOtherParams, // otherParams
1432
1449
  ourReceiveAddresses: [], // ourReceiveAddresses
1433
1450
  signedTx: '', // signedTx
1434
- otherParams: txOtherParams, // otherParams
1451
+ txid: '', // txid
1435
1452
  walletId: this.walletId
1436
1453
  }
1437
1454
 
@@ -110,21 +110,16 @@ const builtinTokens = {
110
110
  }; exports.networkInfo = networkInfo
111
111
 
112
112
  const currencyInfo = {
113
- // Basic currency information:
114
113
  currencyCode: 'TRX',
115
114
  displayName: 'Tron',
116
115
  pluginId: 'tron',
117
116
  walletType: 'wallet:tron',
118
117
 
119
- defaultSettings: {},
120
-
121
- memoType: 'text',
122
-
118
+ // Explorers:
123
119
  addressExplorer: 'https://tronscan.org/#/address/%s',
124
120
  transactionExplorer: 'https://tronscan.org/#/transaction/%s',
125
121
 
126
122
  denominations: [
127
- // An array of Objects of the possible denominations for this currency
128
123
  {
129
124
  name: 'TRX',
130
125
  multiplier: '1000000',
@@ -132,7 +127,13 @@ const builtinTokens = {
132
127
  }
133
128
  ],
134
129
 
135
- metaTokens: _tokenHelpers.makeMetaTokens.call(void 0, builtinTokens) // Deprecated
130
+ // https://developers.tron.network/v3.7/docs/how-to-build-a-transaction-locally
131
+ memoOptions: [{ type: 'text', memoName: 'data', maxLength: 10 }],
132
+
133
+ // Deprecated:
134
+ defaultSettings: {},
135
+ memoType: 'text',
136
+ metaTokens: _tokenHelpers.makeMetaTokens.call(void 0, builtinTokens)
136
137
  }; exports.currencyInfo = currencyInfo
137
138
 
138
139
  const tron = _innerPlugin.makeOuterPlugin({
@@ -8,10 +8,13 @@
8
8
 
9
9
 
10
10
 
11
+
12
+
11
13
  var _types = require('edge-core-js/types');
12
14
 
13
15
  var _CurrencyEngine = require('../common/CurrencyEngine');
14
16
 
17
+ var _upgradeMemos = require('../common/upgradeMemos');
15
18
  var _utils = require('../common/utils');
16
19
 
17
20
 
@@ -42,11 +45,14 @@ var _zcashTypes = require('./zcashTypes');
42
45
 
43
46
 
44
47
 
45
-
46
-
47
48
 
48
49
 
49
50
 
51
+ // Synchronizer management
52
+
53
+
54
+
55
+
50
56
  constructor(
51
57
  env,
52
58
  tools,
@@ -60,6 +66,8 @@ var _zcashTypes = require('./zcashTypes');
60
66
  this.networkInfo = networkInfo
61
67
  this.makeSynchronizer = makeSynchronizer
62
68
  this.queryMutex = false
69
+
70
+ this.started = false
63
71
  }
64
72
 
65
73
  setOtherData(raw) {
@@ -67,7 +75,7 @@ var _zcashTypes = require('./zcashTypes');
67
75
  }
68
76
 
69
77
  initData() {
70
- const { birthdayHeight, alias } = this.initializer
78
+ const { birthdayHeight } = this.initializer
71
79
 
72
80
  // walletLocalData
73
81
  if (this.otherData.blockRange.first === 0) {
@@ -78,7 +86,6 @@ var _zcashTypes = require('./zcashTypes');
78
86
  }
79
87
 
80
88
  // Engine variables
81
- this.alias = alias
82
89
  this.initialNumBlocksToDownload = -1
83
90
  this.synchronizerStatus = 'DISCONNECTED'
84
91
  this.availableZatoshi = '0'
@@ -86,6 +93,7 @@ var _zcashTypes = require('./zcashTypes');
86
93
  }
87
94
 
88
95
  initSubscriptions() {
96
+ if (this.synchronizer == null) return
89
97
  this.synchronizer.on('update', async payload => {
90
98
  const { lastDownloadedHeight, scanProgress, networkBlockHeight } = payload
91
99
  this.onUpdateBlockHeight(networkBlockHeight)
@@ -175,10 +183,8 @@ var _zcashTypes = require('./zcashTypes');
175
183
  }
176
184
 
177
185
  async startEngine() {
178
- this.initData()
179
- this.synchronizer = await this.makeSynchronizer(this.initializer)
180
- await this.synchronizer.start()
181
- this.initSubscriptions()
186
+ this.engineOn = true
187
+ this.started = true
182
188
  await super.startEngine()
183
189
  }
184
190
 
@@ -188,9 +194,9 @@ var _zcashTypes = require('./zcashTypes');
188
194
  }
189
195
 
190
196
  async queryBalance() {
191
- if (!this.isSynced()) return
197
+ if (!this.isSynced() || this.synchronizer == null) return
192
198
  try {
193
- const balances = await this.synchronizer.getShieldedBalance()
199
+ const balances = await this.synchronizer.getBalance()
194
200
  if (balances.totalZatoshi === '-1') return
195
201
  this.availableZatoshi = balances.availableZatoshi
196
202
  this.updateBalance(this.currencyInfo.currencyCode, balances.totalZatoshi)
@@ -201,6 +207,7 @@ var _zcashTypes = require('./zcashTypes');
201
207
  }
202
208
 
203
209
  async queryTransactions() {
210
+ if (this.synchronizer == null) return
204
211
  try {
205
212
  let first = this.otherData.blockRange.first
206
213
  let last = this.otherData.blockRange.last
@@ -254,24 +261,62 @@ var _zcashTypes = require('./zcashTypes');
254
261
  ourReceiveAddresses.push(this.walletInfo.keys.publicKey)
255
262
  }
256
263
 
264
+ const memos = []
265
+ if (tx.memo != null) {
266
+ memos.push({
267
+ type: 'text',
268
+ value: tx.memo
269
+ })
270
+ }
271
+
257
272
  const edgeTransaction = {
258
- txid: tx.rawTransactionId,
259
- date: tx.blockTimeInSeconds,
260
- currencyCode: this.currencyInfo.currencyCode,
261
273
  blockHeight: tx.minedHeight,
262
- nativeAmount: netNativeAmount,
274
+ currencyCode: this.currencyInfo.currencyCode,
275
+ date: tx.blockTimeInSeconds,
263
276
  isSend: netNativeAmount.startsWith('-'),
277
+ memos,
278
+ nativeAmount: netNativeAmount,
264
279
  networkFee: this.networkInfo.defaultNetworkFee,
280
+ otherParams: {},
265
281
  ourReceiveAddresses, // blank if you sent money otherwise array of addresses that are yours in this transaction
266
282
  signedTx: '',
267
- otherParams: {},
283
+ txid: tx.rawTransactionId,
268
284
  walletId: this.walletId
269
285
  }
270
286
  this.addTransaction(this.currencyInfo.currencyCode, edgeTransaction)
271
287
  }
272
288
 
289
+ async syncNetwork(opts) {
290
+ if (!this.started) return 1000
291
+
292
+ const zcashPrivateKeys = _zcashTypes.asZcashPrivateKeys.call(void 0, this.currencyInfo.pluginId)(
293
+ _optionalChain([opts, 'optionalAccess', _ => _.privateKeys])
294
+ )
295
+
296
+ const { rpcNode } = this.networkInfo
297
+ this.initializer = {
298
+ mnemonicSeed: zcashPrivateKeys.mnemonic,
299
+ birthdayHeight: zcashPrivateKeys.birthdayHeight,
300
+ alias: this.walletInfo.keys.publicKey.slice(0, 99),
301
+ ...rpcNode
302
+ }
303
+
304
+ this.synchronizer = await this.makeSynchronizer(this.initializer)
305
+ this.initData()
306
+ this.initSubscriptions()
307
+
308
+ return await new Promise(resolve => {
309
+ this.stopSyncing = resolve
310
+ })
311
+ }
312
+
273
313
  async killEngine() {
274
- await this.synchronizer.stop()
314
+ this.started = false
315
+ if (this.stopSyncing != null) {
316
+ await this.stopSyncing(1000)
317
+ this.stopSyncing = undefined
318
+ }
319
+ await _optionalChain([this, 'access', _2 => _2.synchronizer, 'optionalAccess', _3 => _3.stop, 'call', _4 => _4()])
275
320
  await super.killEngine()
276
321
  }
277
322
 
@@ -284,9 +329,11 @@ var _zcashTypes = require('./zcashTypes');
284
329
  await super.killEngine()
285
330
  await this.clearBlockchainCache()
286
331
  await this.startEngine()
287
- this.synchronizer
288
- .rescan(this.walletInfo.keys.birthdayHeight)
289
- .catch((e) => this.warn('resyncBlockchain failed: ', e))
332
+ _optionalChain([this, 'access', _5 => _5.synchronizer
333
+ , 'optionalAccess', _6 => _6.rescan, 'call', _7 => _7()
334
+ , 'access', _8 => _8.catch, 'call', _9 => _9((e) => this.warn('resyncBlockchain failed: ', e))])
335
+ this.initData()
336
+ this.synchronizerStatus = 'SYNCING'
290
337
  }
291
338
 
292
339
  async getMaxSpendable() {
@@ -300,8 +347,10 @@ var _zcashTypes = require('./zcashTypes');
300
347
  }
301
348
 
302
349
  async makeSpend(edgeSpendInfoIn) {
350
+ edgeSpendInfoIn = _upgradeMemos.upgradeMemos.call(void 0, edgeSpendInfoIn, this.currencyInfo)
303
351
  if (!this.isSynced()) throw new Error('Cannot spend until wallet is synced')
304
352
  const { edgeSpendInfo, currencyCode } = this.makeSpendCheck(edgeSpendInfoIn)
353
+ const { memos = [] } = edgeSpendInfo
305
354
  const spendTarget = edgeSpendInfo.spendTargets[0]
306
355
  const { publicAddress, nativeAmount } = spendTarget
307
356
 
@@ -330,27 +379,19 @@ var _zcashTypes = require('./zcashTypes');
330
379
  // **********************************
331
380
  // Create the unsigned EdgeTransaction
332
381
 
333
- const spendTargets = edgeSpendInfo.spendTargets.map(si => ({
334
- uniqueIdentifier: si.uniqueIdentifier,
335
- memo: si.memo,
336
- nativeAmount: _nullishCoalesce(si.nativeAmount, () => ( '0')),
337
- currencyCode,
338
- publicAddress
339
- }))
340
-
341
382
  const txNativeAmount = _biggystring.mul.call(void 0, totalTxAmount, '-1')
342
383
 
343
384
  const edgeTransaction = {
344
- txid: '',
345
- date: 0,
346
- currencyCode,
347
385
  blockHeight: 0,
348
- nativeAmount: txNativeAmount,
386
+ currencyCode,
387
+ date: 0,
349
388
  isSend: true,
389
+ memos,
390
+ nativeAmount: txNativeAmount,
350
391
  networkFee: this.networkInfo.defaultNetworkFee,
351
392
  ourReceiveAddresses: [],
352
393
  signedTx: '',
353
- spendTargets,
394
+ txid: '',
354
395
  walletId: this.walletId
355
396
  }
356
397
 
@@ -366,8 +407,10 @@ var _zcashTypes = require('./zcashTypes');
366
407
  edgeTransaction,
367
408
  opts
368
409
  ) {
410
+ if (this.synchronizer == null) throw new Error('Synchronizer undefined')
411
+ const { memos } = edgeTransaction
369
412
  const zcashPrivateKeys = _zcashTypes.asZcashPrivateKeys.call(void 0, this.pluginId)(
370
- _optionalChain([opts, 'optionalAccess', _ => _.privateKeys])
413
+ _optionalChain([opts, 'optionalAccess', _10 => _10.privateKeys])
371
414
  )
372
415
  if (
373
416
  edgeTransaction.spendTargets == null ||
@@ -375,6 +418,7 @@ var _zcashTypes = require('./zcashTypes');
375
418
  )
376
419
  throw new Error('Invalid spend targets')
377
420
 
421
+ const memo = _optionalChain([memos, 'access', _11 => _11[0], 'optionalAccess', _12 => _12.type]) === 'text' ? memos[0].value : ''
378
422
  const spendTarget = edgeTransaction.spendTargets[0]
379
423
  const txParams = {
380
424
  zatoshi: _biggystring.sub.call(void 0,
@@ -382,9 +426,9 @@ var _zcashTypes = require('./zcashTypes');
382
426
  edgeTransaction.networkFee
383
427
  ),
384
428
  toAddress: spendTarget.publicAddress,
385
- memo: _nullishCoalesce(_nullishCoalesce(spendTarget.memo, () => ( spendTarget.uniqueIdentifier)), () => ( '')),
429
+ memo,
386
430
  fromAccountIndex: 0,
387
- spendingKey: zcashPrivateKeys.spendKey
431
+ mnemonicSeed: zcashPrivateKeys.mnemonic
388
432
  }
389
433
 
390
434
  try {
@@ -400,20 +444,15 @@ var _zcashTypes = require('./zcashTypes');
400
444
  return edgeTransaction
401
445
  }
402
446
 
403
- async loadEngine() {
404
- const { walletInfo } = this
405
- await super.loadEngine()
406
- this.engineOn = true
407
-
408
- const { rpcNode } = this.networkInfo
409
- this.initializer = {
410
- fullViewingKey: walletInfo.keys.unifiedViewingKeys,
411
- birthdayHeight: walletInfo.keys.birthdayHeight,
412
- alias: walletInfo.keys.publicKey,
413
- ...rpcNode
447
+ async getFreshAddress() {
448
+ if (this.synchronizer == null) throw new Error('Synchronizer undefined')
449
+ const unifiedAddress = await this.synchronizer.deriveUnifiedAddress()
450
+ return {
451
+ publicAddress: unifiedAddress
414
452
  }
415
453
  }
416
454
  } exports.ZcashEngine = ZcashEngine;
455
+
417
456
  async function makeCurrencyEngine(
418
457
  env,
419
458
  tools,
@@ -421,8 +460,7 @@ var _zcashTypes = require('./zcashTypes');
421
460
  opts
422
461
  ) {
423
462
  const safeWalletInfo = _zcashTypes.asSafeZcashWalletInfo.call(void 0, walletInfo)
424
- const { makeSynchronizer } =
425
- env.nativeIo['edge-currency-accountbased'][env.networkInfo.nativeSdk]
463
+ const { makeSynchronizer } = env.nativeIo['edge-currency-accountbased'].zcash
426
464
 
427
465
  const engine = new ZcashEngine(
428
466
  env,