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
@@ -4,6 +4,7 @@ var _innerPlugin = require('../../common/innerPlugin');
4
4
  var _tokenHelpers = require('../../common/tokenHelpers');
5
5
 
6
6
 
7
+ var _ethereumCommonInfo = require('./ethereumCommonInfo');
7
8
 
8
9
  const builtinTokens = {
9
10
  '3355df6d4c9c3035724fd0e3914de96a5a83aaf4': {
@@ -74,28 +75,29 @@ const defaultSettings = {
74
75
  }
75
76
 
76
77
  const currencyInfo = {
77
- // Basic currency information:
78
+ canReplaceByFee: true,
78
79
  currencyCode: 'ETH',
79
80
  displayName: 'zkSync',
81
+ memoOptions: _ethereumCommonInfo.evmMemoOptions,
80
82
  pluginId: 'zksync',
81
83
  walletType: 'wallet:zksync',
82
- memoType: 'hex',
83
-
84
- canReplaceByFee: true,
85
- defaultSettings,
86
84
 
85
+ // Explorers:
87
86
  addressExplorer: 'https://explorer.zksync.io/address/%s',
88
87
  transactionExplorer: 'https://explorer.zksync.io/tx/%s',
89
88
 
90
89
  denominations: [
91
- // An array of Objects of the possible denominations for this currency
92
90
  {
93
91
  name: 'ETH',
94
92
  multiplier: '1000000000000000000',
95
93
  symbol: 'Ξ'
96
94
  }
97
95
  ],
98
- metaTokens: _tokenHelpers.makeMetaTokens.call(void 0, builtinTokens) // Deprecated
96
+
97
+ // Deprecated:
98
+ defaultSettings,
99
+ memoType: 'hex',
100
+ metaTokens: _tokenHelpers.makeMetaTokens.call(void 0, builtinTokens)
99
101
  }; exports.currencyInfo = currencyInfo
100
102
 
101
103
  const zksync = _innerPlugin.makeOuterPlugin({
@@ -23,6 +23,7 @@ var _types = require('edge-core-js/types');
23
23
 
24
24
  var _CurrencyEngine = require('../common/CurrencyEngine');
25
25
 
26
+ var _upgradeMemos = require('../common/upgradeMemos');
26
27
 
27
28
 
28
29
 
@@ -51,6 +52,7 @@ const CHECK_TRANSACTION_INTERVAL = 15000
51
52
 
52
53
 
53
54
 
55
+
54
56
 
55
57
  // Backends:
56
58
 
@@ -68,6 +70,10 @@ const CHECK_TRANSACTION_INTERVAL = 15000
68
70
  const { networkInfo } = env
69
71
  this.address = _izarifilecoin.Address.fromString(walletInfo.keys.address)
70
72
  this.availableAttoFil = '0'
73
+ this.isScanning = false
74
+ this.networkInfo = networkInfo
75
+ this.pluginId = this.currencyInfo.pluginId
76
+
71
77
  this.filRpc = new (0, _izarifilecoin.RPC)(env.networkInfo.rpcNode.networkName, {
72
78
  url: env.networkInfo.rpcNode.url,
73
79
  token: env.currencyInfo.currencyCode
@@ -75,9 +81,6 @@ const CHECK_TRANSACTION_INTERVAL = 15000
75
81
  this.filfoxApi = new (0, _Filfox.Filfox)(env.networkInfo.filfoxUrl, env.io.fetchCors)
76
82
  this.filscanApi = new (0, _Filscan.Filscan)(env.networkInfo.filscanUrl, env.io.fetchCors)
77
83
  this.rpcExtra = new (0, _RpcExtra.RpcExtra)(env.networkInfo.rpcNode.url, env.io.fetchCors)
78
-
79
- this.networkInfo = networkInfo
80
- this.pluginId = this.currencyInfo.pluginId
81
84
  }
82
85
 
83
86
  setOtherData(raw) {
@@ -85,9 +88,7 @@ const CHECK_TRANSACTION_INTERVAL = 15000
85
88
  }
86
89
 
87
90
  initData() {
88
- // Initialize walletLocalData:
89
- // ...
90
-
91
+ this.tokenCheckTransactionsStatus[this.currencyInfo.currencyCode] = 0
91
92
  // Engine variables
92
93
  this.availableAttoFil = '0'
93
94
  }
@@ -161,7 +162,9 @@ const CHECK_TRANSACTION_INTERVAL = 15000
161
162
  }
162
163
 
163
164
  async makeSpend(edgeSpendInfoIn) {
165
+ edgeSpendInfoIn = _upgradeMemos.upgradeMemos.call(void 0, edgeSpendInfoIn, this.currencyInfo)
164
166
  const { edgeSpendInfo, currencyCode } = this.makeSpendCheck(edgeSpendInfoIn)
167
+ const { memos = [] } = edgeSpendInfo
165
168
  const spendTarget = edgeSpendInfo.spendTargets[0]
166
169
  const { publicAddress, nativeAmount } = spendTarget
167
170
 
@@ -189,19 +192,20 @@ const CHECK_TRANSACTION_INTERVAL = 15000
189
192
  }
190
193
 
191
194
  const networkFee = _biggystring.mul.call(void 0, txJson.GasLimit.toString(), txJson.GasPremium) // TODO: Include base fee and burn fee somehow?
192
- const totalTxAmount = _biggystring.add.call(void 0, nativeAmount, networkFee)
195
+ const txNativeAmount = _biggystring.mul.call(void 0, _biggystring.add.call(void 0, nativeAmount, networkFee), '-1')
193
196
 
194
197
  const edgeTransaction = {
195
- txid: '',
196
- date: 0,
197
- currencyCode,
198
198
  blockHeight: 0,
199
- nativeAmount: `-${totalTxAmount}`,
200
- isSend: nativeAmount.startsWith('-'),
199
+ currencyCode,
200
+ date: 0,
201
+ isSend: true,
202
+ memos,
203
+ nativeAmount: txNativeAmount,
201
204
  networkFee,
202
- ourReceiveAddresses: [],
203
205
  otherParams,
206
+ ourReceiveAddresses: [],
204
207
  signedTx: '',
208
+ txid: '',
205
209
  walletId: this.walletId
206
210
  }
207
211
 
@@ -230,6 +234,8 @@ const CHECK_TRANSACTION_INTERVAL = 15000
230
234
  sigJson: signature.toJSON()
231
235
  }
232
236
 
237
+ edgeTransaction.date = Date.now() / 1000
238
+
233
239
  return edgeTransaction
234
240
  }
235
241
 
@@ -297,52 +303,71 @@ const CHECK_TRANSACTION_INTERVAL = 15000
297
303
  }
298
304
 
299
305
  async checkTransactions() {
300
- const addressString = this.address.toString()
301
-
302
- const handleScanProgress = (progress) => {
303
- const currentProgress =
304
- this.tokenCheckTransactionsStatus[this.currencyInfo.currencyCode]
305
- const newProgress = progress
306
-
307
- if (
308
- // Only send event if we haven't completed sync
309
- currentProgress < 1 &&
310
- // Avoid thrashing
311
- (newProgress >= 1 || newProgress > currentProgress * 1.1)
312
- ) {
313
- this.tokenCheckTransactionsStatus[this.currencyInfo.currencyCode] =
314
- newProgress
315
- this.updateOnAddressesChecked()
306
+ // We shouldn't start scanning if scanning is already happening:
307
+ if (this.isScanning) return
308
+ try {
309
+ this.isScanning = true
310
+
311
+ const addressString = this.address.toString()
312
+
313
+ const handleScanProgress = (progress) => {
314
+ const currentProgress =
315
+ this.tokenCheckTransactionsStatus[this.currencyInfo.currencyCode]
316
+ const newProgress = progress
317
+
318
+ if (
319
+ // Only send event if we haven't completed sync
320
+ currentProgress < 1 &&
321
+ // Avoid thrashing
322
+ (newProgress >= 1 || newProgress > currentProgress * 1.1)
323
+ ) {
324
+ this.tokenCheckTransactionsStatus[this.currencyInfo.currencyCode] =
325
+ newProgress
326
+ this.updateOnAddressesChecked()
327
+ }
316
328
  }
317
- }
318
329
 
319
- const handleScan = ({
320
- tx,
321
- progress
322
- }
330
+ const handleScan = ({
331
+ tx,
332
+ progress
333
+ }
323
334
 
324
335
 
325
336
  ) => {
326
- this.addTransaction(this.currencyInfo.currencyCode, tx)
327
- this.onUpdateTransactions()
337
+ this.addTransaction(this.currencyInfo.currencyCode, tx)
338
+ this.onUpdateTransactions()
339
+
340
+ // Progress the block-height if the message's height is greater than
341
+ // last poll for block-height.
342
+ if (this.walletLocalData.blockHeight < tx.blockHeight) {
343
+ this.onUpdateBlockHeight(tx.blockHeight)
344
+ }
328
345
 
329
- // Progress the block-height if the message's height is greater than
330
- // last poll for block-height.
331
- if (this.walletLocalData.blockHeight < tx.blockHeight) {
332
- this.onUpdateBlockHeight(tx.blockHeight)
346
+ handleScanProgress(progress)
333
347
  }
334
348
 
335
- handleScanProgress(progress)
336
- }
349
+ const scanners = [
350
+ // this.scanTransactionsFromFilscan(addressString, handleScan),
351
+ this.scanTransactionsFromFilfox(addressString, handleScan)
352
+ ]
353
+
354
+ const startingNetworkHeight = this.walletLocalData.blockHeight
337
355
 
338
- const scanners = [
339
- this.scanTransactionsFromFilscan(addressString, handleScan),
340
- this.scanTransactionsFromFilfox(addressString, handleScan)
341
- ]
356
+ // Run scanners:
357
+ await Promise.all(scanners)
342
358
 
343
- await Promise.all(scanners)
359
+ // Save the network height at the start of the scanning
360
+ this.walletLocalData.lastAddressQueryHeight = startingNetworkHeight
361
+ this.walletLocalDataDirty = true
344
362
 
345
- handleScanProgress(1)
363
+ // Make sure the sync progress is 100%
364
+ handleScanProgress(1)
365
+ } catch (error) {
366
+ console.error(error)
367
+ throw error
368
+ } finally {
369
+ this.isScanning = false
370
+ }
346
371
  }
347
372
 
348
373
  async scanTransactionsFromFilfox(
@@ -367,17 +392,14 @@ const CHECK_TRANSACTION_INTERVAL = 15000
367
392
 
368
393
  const messages = messagesResponse.messages
369
394
  for (const message of messages) {
370
- const txid = message.cid
371
- const idx = this.findTransaction(this.currencyInfo.currencyCode, txid)
372
-
373
- if (idx >= 0) {
374
- // Exit early because we reached transaction history from previous
375
- // check
376
- return
377
- }
395
+ // Exit when we reach a transaction we may already have saved
396
+ if (message.height < this.walletLocalData.lastAddressQueryHeight) return
378
397
 
379
398
  // Process message into a transaction
380
- const tx = this.filfoxMessageToEdgeTransaction(message)
399
+ const messageDetails = await this.filfoxApi.getMessageDetails(
400
+ message.cid
401
+ )
402
+ const tx = this.filfoxMessageToEdgeTransaction(messageDetails)
381
403
 
382
404
  // Calculate the progress
383
405
  const progress =
@@ -410,14 +432,8 @@ const CHECK_TRANSACTION_INTERVAL = 15000
410
432
 
411
433
  const messages = messagesResponse.messages_by_account_id_list
412
434
  for (const message of messages) {
413
- const txid = message.cid
414
- const idx = this.findTransaction(this.currencyInfo.currencyCode, txid)
415
-
416
- if (idx >= 0) {
417
- // Exit early because we reached transaction history from previous
418
- // check
419
- return
420
- }
435
+ // Exit when we reach a transaction we may already have saved
436
+ if (message.height < this.walletLocalData.lastAddressQueryHeight) return
421
437
 
422
438
  // Process message into a transaction
423
439
  const tx = this.filscanMessageToEdgeTransaction(message)
@@ -432,31 +448,46 @@ const CHECK_TRANSACTION_INTERVAL = 15000
432
448
  }
433
449
 
434
450
  __init() {this.filfoxMessageToEdgeTransaction = (
435
- message
451
+ messageDetails
436
452
  ) => {
437
453
  const addressString = this.address.toString()
438
- let netNativeAmount = message.value
439
454
  const ourReceiveAddresses = []
440
455
 
441
- const networkFee = '0' // TODO: calculate transaction fee from onchain gas fields
442
- if (message.to !== addressString) {
443
- // check if tx is a spend
444
- netNativeAmount = `-${_biggystring.add.call(void 0, netNativeAmount, networkFee)}`
456
+ // Handle network fees:
457
+ const networkFee = messageDetails.transfers
458
+ .filter(
459
+ transfer =>
460
+ transfer.type === 'miner-fee' || transfer.type === 'burner-fee'
461
+ )
462
+ .reduce((sum, transfer) => _biggystring.add.call(void 0, sum, transfer.value), '0')
463
+
464
+ // Handle native amount:
465
+ let nativeAmount
466
+ if (messageDetails.from === addressString) {
467
+ // For spends, always include network fee
468
+ nativeAmount = `-${networkFee}`
469
+ if (messageDetails.to !== addressString) {
470
+ // For spends not to self, subtract tx value
471
+ nativeAmount = _biggystring.sub.call(void 0, nativeAmount, messageDetails.value)
472
+ }
445
473
  } else {
474
+ // For receives nativeAMount is always positively the value
475
+ nativeAmount = messageDetails.value
446
476
  ourReceiveAddresses.push(addressString)
447
477
  }
448
478
 
449
479
  const edgeTransaction = {
450
- txid: message.cid,
451
- date: message.timestamp,
480
+ blockHeight: messageDetails.height,
452
481
  currencyCode: this.currencyInfo.currencyCode,
453
- blockHeight: message.height,
454
- nativeAmount: netNativeAmount,
455
- isSend: netNativeAmount.startsWith('-'),
482
+ date: messageDetails.timestamp,
483
+ isSend: nativeAmount.startsWith('-'),
484
+ memos: [],
485
+ nativeAmount,
456
486
  networkFee,
487
+ otherParams: {},
457
488
  ourReceiveAddresses, // blank if you sent money otherwise array of addresses that are yours in this transaction
458
489
  signedTx: '',
459
- otherParams: {},
490
+ txid: messageDetails.cid,
460
491
  walletId: this.walletId
461
492
  }
462
493
 
@@ -465,28 +496,35 @@ const CHECK_TRANSACTION_INTERVAL = 15000
465
496
 
466
497
  filscanMessageToEdgeTransaction(message) {
467
498
  const addressString = this.address.toString()
468
- let netNativeAmount = message.value
469
499
  const ourReceiveAddresses = []
470
500
 
471
501
  const networkFee = '0' // TODO: calculate transaction fee from onchain gas fields
472
- if (message.to !== addressString) {
473
- // check if tx is a spend
474
- netNativeAmount = `-${_biggystring.add.call(void 0, netNativeAmount, networkFee)}`
502
+ let nativeAmount
503
+ if (message.from === addressString) {
504
+ // For spends, always include network fee
505
+ nativeAmount = `-${networkFee}`
506
+ if (message.to !== addressString) {
507
+ // For spends not to self, subtract tx value
508
+ nativeAmount = _biggystring.sub.call(void 0, nativeAmount, message.value)
509
+ }
475
510
  } else {
511
+ // For receives nativeAMount is always positively the value
512
+ nativeAmount = message.value
476
513
  ourReceiveAddresses.push(addressString)
477
514
  }
478
515
 
479
516
  const edgeTransaction = {
480
- txid: message.cid,
481
- date: message.block_time,
482
- currencyCode: this.currencyInfo.currencyCode,
483
517
  blockHeight: message.height,
484
- nativeAmount: netNativeAmount,
485
- isSend: netNativeAmount.startsWith('-'),
518
+ currencyCode: this.currencyInfo.currencyCode,
519
+ date: message.block_time,
520
+ isSend: nativeAmount.startsWith('-'),
521
+ memos: [],
522
+ nativeAmount,
486
523
  networkFee,
524
+ otherParams: {},
487
525
  ourReceiveAddresses, // blank if you sent money otherwise array of addresses that are yours in this transaction
488
526
  signedTx: '',
489
- otherParams: {},
527
+ txid: message.cid,
490
528
  walletId: this.walletId
491
529
  }
492
530
 
@@ -40,7 +40,7 @@ var _cleaners = require('cleaners');
40
40
  height: _cleaners.asNumber,
41
41
  method: _cleaners.asString,
42
42
  nonce: _cleaners.asNumber,
43
- reciept: _cleaners.asObject.call(void 0, {
43
+ receipt: _cleaners.asObject.call(void 0, {
44
44
  exitCode: _cleaners.asNumber
45
45
  }),
46
46
  timestamp: _cleaners.asNumber,
@@ -48,6 +48,42 @@ var _cleaners = require('cleaners');
48
48
  value: _cleaners.asString
49
49
  }); exports.asFilfoxMessage = asFilfoxMessage
50
50
 
51
+
52
+ const asFilfoxMessageDetailed = _cleaners.asObject.call(void 0, {
53
+ cid: _cleaners.asString,
54
+ height: _cleaners.asNumber,
55
+ timestamp: _cleaners.asNumber,
56
+ from: _cleaners.asString,
57
+ to: _cleaners.asString,
58
+ value: _cleaners.asString,
59
+ gasLimit: _cleaners.asNumber,
60
+ gasFeeCap: _cleaners.asString,
61
+ gasPremium: _cleaners.asString,
62
+ receipt: _cleaners.asObject.call(void 0, {
63
+ exitCode: _cleaners.asNumber,
64
+ return: _cleaners.asString,
65
+ gasUsed: _cleaners.asNumber
66
+ }),
67
+ baseFee: _cleaners.asString,
68
+ fee: _cleaners.asObject.call(void 0, {
69
+ baseFeeBurn: _cleaners.asString,
70
+ overEstimationBurn: _cleaners.asString,
71
+ minerPenalty: _cleaners.asString,
72
+ minerTip: _cleaners.asString,
73
+ refund: _cleaners.asString
74
+ }),
75
+ transfers: _cleaners.asArray.call(void 0,
76
+ _cleaners.asObject.call(void 0, {
77
+ from: _cleaners.asString,
78
+ fromId: _cleaners.asString,
79
+ to: _cleaners.asString,
80
+ toId: _cleaners.asString,
81
+ value: _cleaners.asString,
82
+ type: _cleaners.asString
83
+ })
84
+ )
85
+ }); exports.asFilfoxMessageDetailed = asFilfoxMessageDetailed
86
+
51
87
  //
52
88
  // Messages
53
89
  //
@@ -58,6 +94,15 @@ var _cleaners = require('cleaners');
58
94
  totalCount: _cleaners.asNumber
59
95
  }); exports.asFilfoxMessagesResult = asFilfoxMessagesResult
60
96
 
97
+ //
98
+ // Message Details
99
+ //
100
+
101
+
102
+
103
+
104
+ const asFilfoxMessageDetailsResult = exports.asFilfoxMessageDetailed; exports.asFilfoxMessageDetailsResult = asFilfoxMessageDetailsResult
105
+
61
106
  // -----------------------------------------------------------------------------
62
107
  // Implementation
63
108
  // -----------------------------------------------------------------------------
@@ -98,4 +143,26 @@ var _cleaners = require('cleaners');
98
143
 
99
144
  return responseBody
100
145
  }
146
+
147
+ async getMessageDetails(
148
+ messageCid
149
+ ) {
150
+ const response = await this.fetch(`${this.baseUrl}/message/${messageCid}`, {
151
+ method: 'GET',
152
+ headers: {
153
+ 'content-type': 'application/json'
154
+ }
155
+ })
156
+ const responseText = await response.text()
157
+ const responseBody = exports.asFilfoxEnvelope.call(void 0, (0, exports.asFilfoxMessageDetailsResult))(
158
+ responseText
159
+ )
160
+
161
+ if ('error' in responseBody)
162
+ throw new Error(
163
+ `Error response code ${responseBody.statusCode}: ${responseBody.message} ${responseBody.error}`
164
+ )
165
+
166
+ return responseBody
167
+ }
101
168
  } exports.Filfox = Filfox;
@@ -16,20 +16,18 @@ const networkInfo = {
16
16
  }
17
17
 
18
18
  const currencyInfo = {
19
- // Basic currency information:
20
19
  currencyCode: 'FIL',
21
20
  displayName: 'Filecoin',
22
21
  pluginId: 'filecoin',
23
22
  requiredConfirmations: 900,
23
+ unsafeBroadcastTx: true,
24
24
  walletType: 'wallet:filecoin',
25
25
 
26
- defaultSettings: {},
27
-
26
+ // Explorers:
28
27
  addressExplorer: 'https://filscan.io/en/address/%s',
29
28
  transactionExplorer: 'https://filscan.io/en/message/%s',
30
29
 
31
30
  denominations: [
32
- // An array of Objects of the possible denominations for this currency
33
31
  {
34
32
  name: 'FIL',
35
33
  multiplier: '1000000000000000000',
@@ -67,9 +65,9 @@ const networkInfo = {
67
65
  }
68
66
  ],
69
67
 
70
- metaTokens: [], // Deprecated
71
-
72
- unsafeBroadcastTx: true
68
+ // Deprecated:
69
+ defaultSettings: {},
70
+ metaTokens: []
73
71
  }; exports.currencyInfo = currencyInfo
74
72
 
75
73
  const filecoin = _innerPlugin.makeOuterPlugin({
@@ -26,6 +26,7 @@ var _types = require('edge-core-js/types');
26
26
 
27
27
  var _CurrencyEngine = require('../common/CurrencyEngine');
28
28
 
29
+ var _upgradeMemos = require('../common/upgradeMemos');
29
30
 
30
31
 
31
32
 
@@ -483,16 +484,17 @@ const SYNC_NETWORK_INTERVAL = 10000
483
484
  otherParams.meta.isTransferProcessed = true
484
485
 
485
486
  const edgeTransaction = {
486
- txid: action.action_trace.trx_id,
487
- date: this.getUTCDate(action.block_time) / 1000,
488
- currencyCode,
489
487
  blockHeight: action.block_num > 0 ? action.block_num : 0,
490
- nativeAmount,
488
+ currencyCode,
489
+ date: this.getUTCDate(action.block_time) / 1000,
491
490
  isSend: nativeAmount.startsWith('-'),
491
+ memos: [],
492
+ nativeAmount,
492
493
  networkFee,
494
+ otherParams,
493
495
  ourReceiveAddresses,
494
496
  signedTx: '',
495
- otherParams,
497
+ txid: action.action_trace.trx_id,
496
498
  walletId: this.walletId
497
499
  }
498
500
  this.addTransaction(currencyCode, edgeTransaction)
@@ -570,16 +572,17 @@ const SYNC_NETWORK_INTERVAL = 10000
570
572
 
571
573
  otherParams.meta.isFeeProcessed = true
572
574
  const edgeTransaction = {
573
- txid: action.action_trace.trx_id,
574
- date: this.getUTCDate(action.block_time) / 1000,
575
- currencyCode,
576
575
  blockHeight: action.block_num > 0 ? action.block_num : 0,
577
- nativeAmount,
576
+ currencyCode,
577
+ date: this.getUTCDate(action.block_time) / 1000,
578
578
  isSend: nativeAmount.startsWith('-'),
579
+ memos: [],
580
+ nativeAmount,
579
581
  networkFee,
580
- signedTx: '',
581
- ourReceiveAddresses: [],
582
582
  otherParams,
583
+ ourReceiveAddresses: [],
584
+ signedTx: '',
585
+ txid: action.action_trace.trx_id,
583
586
  walletId: this.walletId
584
587
  }
585
588
  this.addTransaction(currencyCode, edgeTransaction)
@@ -1376,6 +1379,7 @@ const SYNC_NETWORK_INTERVAL = 10000
1376
1379
  }
1377
1380
 
1378
1381
  async getMaxSpendable(spendInfo) {
1382
+ spendInfo = _upgradeMemos.upgradeMemos.call(void 0, spendInfo, this.currencyInfo)
1379
1383
  const balance = this.getBalance({
1380
1384
  currencyCode: spendInfo.currencyCode
1381
1385
  })
@@ -1397,8 +1401,11 @@ const SYNC_NETWORK_INTERVAL = 10000
1397
1401
  }
1398
1402
 
1399
1403
  async makeSpend(edgeSpendInfoIn) {
1404
+ edgeSpendInfoIn = _upgradeMemos.upgradeMemos.call(void 0, edgeSpendInfoIn, this.currencyInfo)
1400
1405
  const { edgeSpendInfo, nativeBalance, currencyCode } =
1401
1406
  this.makeSpendCheck(edgeSpendInfoIn)
1407
+ const { memos = [] } = edgeSpendInfo
1408
+
1402
1409
  const lockedBalance =
1403
1410
  _nullishCoalesce(this.walletLocalData.totalBalances[
1404
1411
  this.networkInfo.balanceCurrencyCodes.locked
@@ -1678,19 +1685,20 @@ const SYNC_NETWORK_INTERVAL = 10000
1678
1685
  }
1679
1686
 
1680
1687
  const edgeTransaction = {
1681
- txid: '',
1682
- date: 0,
1683
- currencyCode,
1684
1688
  blockHeight: 0,
1685
- nativeAmount: _biggystring.sub.call(void 0, `-${quantity}`, `${fee}`),
1689
+ currencyCode,
1690
+ date: 0,
1686
1691
  isSend: true,
1692
+ memos,
1693
+ nativeAmount: _biggystring.sub.call(void 0, `-${quantity}`, `${fee}`),
1687
1694
  networkFee: `${fee}`,
1688
- ourReceiveAddresses: [],
1689
- signedTx: '',
1690
1695
  otherParams: {
1691
1696
  ...otherParams,
1692
1697
  txParams
1693
1698
  },
1699
+ ourReceiveAddresses: [],
1700
+ signedTx: '',
1701
+ txid: '',
1694
1702
  walletId: this.walletId
1695
1703
  }
1696
1704
 
@@ -48,28 +48,30 @@ const networkInfo = {
48
48
  }
49
49
 
50
50
  const currencyInfo = {
51
- // Basic currency information:
52
51
  currencyCode: 'FIO',
53
52
  displayName: 'FIO',
54
53
  pluginId: 'fio',
54
+ unsafeSyncNetwork: true,
55
55
  walletType: 'wallet:fio',
56
56
 
57
- defaultSettings: { ...networkInfo },
58
-
57
+ // Explorers:
59
58
  addressExplorer: 'https://fio.bloks.io/key/%s',
60
59
  transactionExplorer: 'https://fio.bloks.io/transaction/%s',
61
60
 
62
61
  denominations: [
63
- // An array of Objects of the possible denominations for this currency
64
62
  {
65
63
  name: 'FIO',
66
64
  multiplier: '1000000000',
67
65
  symbol: 'ᵮ'
68
66
  }
69
67
  ],
70
- metaTokens: [], // Deprecated
71
68
 
72
- unsafeSyncNetwork: true
69
+ // No memo support:
70
+ memoOptions: [],
71
+
72
+ // Deprecated:
73
+ defaultSettings: { ...networkInfo },
74
+ metaTokens: []
73
75
  }; exports.currencyInfo = currencyInfo
74
76
 
75
77
  const fio = _innerPlugin.makeOuterPlugin({