edge-currency-monero 1.2.0 → 1.3.1

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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  # Unreleased
4
4
 
5
+ # 1.3.1 (2024-03-21)
6
+
7
+ - fixed: Include missing files in the NPM package.
8
+
9
+ # 1.3.0 (2024-03-21)
10
+
11
+ - changed: Switch our codebase from Flow to TypeScript.
12
+
5
13
  # 1.2.0 (2024-03-20)
6
14
 
7
15
  - added: Report legacy payment ID's using the new core `memo` transaction property.
@@ -1,7 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }/**
2
2
  * Created by paul on 7/7/17.
3
3
  */
4
- //
5
4
 
6
5
  var _biggystring = require('biggystring');
7
6
 
@@ -31,9 +30,8 @@ var _biggystring = require('biggystring');
31
30
  var _types = require('edge-core-js/types');
32
31
 
33
32
 
34
- var _moneroInfojs = require('./moneroInfo.js');
35
- var _MoneroLocalDatajs = require('./MoneroLocalData.js');
36
- var _MoneroToolsjs = require('./MoneroTools.js');
33
+ var _moneroInfo = require('./moneroInfo');
34
+ var _MoneroLocalData = require('./MoneroLocalData');
37
35
 
38
36
 
39
37
 
@@ -43,18 +41,23 @@ var _MoneroToolsjs = require('./MoneroTools.js');
43
41
 
44
42
 
45
43
 
46
- var _moneroTypesjs = require('./moneroTypes.js');
47
- var _MyMoneroApijs = require('./MyMoneroApi.js');
48
- var _utilsjs = require('./utils.js');
44
+
45
+ var _moneroTypes = require('./moneroTypes');
46
+
47
+
48
+
49
+
50
+ var _MyMoneroApi = require('./MyMoneroApi');
51
+ var _utils = require('./utils');
49
52
 
50
53
  const SYNC_INTERVAL_MILLISECONDS = 5000
51
54
  const SAVE_DATASTORE_MILLISECONDS = 10000
52
55
  // const ADDRESS_QUERY_LOOKBACK_BLOCKS = '8' // ~ 2 minutes
53
56
  // const ADDRESS_QUERY_LOOKBACK_BLOCKS = (4 * 60 * 24 * 7) // ~ one week
54
57
 
55
- const PRIMARY_CURRENCY = _moneroInfojs.currencyInfo.currencyCode
58
+ const PRIMARY_CURRENCY = _moneroInfo.currencyInfo.currencyCode
56
59
 
57
- class MoneroEngine {
60
+ class MoneroEngine {
58
61
 
59
62
 
60
63
 
@@ -82,7 +85,7 @@ const PRIMARY_CURRENCY = _moneroInfojs.currencyInfo.currencyCode
82
85
  opts
83
86
  ) {
84
87
  const { callbacks, userSettings = {}, walletLocalDisklet } = opts
85
- const initOptions = _moneroTypesjs.asMoneroInitOptions.call(void 0, _nullishCoalesce(env.initOptions, () => ( {})))
88
+ const initOptions = _moneroTypes.asMoneroInitOptions.call(void 0, _nullishCoalesce(env.initOptions, () => ( {})))
86
89
  const { networkInfo } = tools
87
90
 
88
91
  this.apiKey = initOptions.apiKey
@@ -93,26 +96,29 @@ const PRIMARY_CURRENCY = _moneroInfojs.currencyInfo.currencyCode
93
96
  this.addressesChecked = false
94
97
  this.walletLocalDataDirty = false
95
98
  this.transactionsChangedArray = []
96
- this.walletInfo = walletInfo
99
+ this.walletInfo = walletInfo // We derive the public keys at init
97
100
  this.walletId = walletInfo.id
98
- this.currencyInfo = _moneroInfojs.currencyInfo
101
+ this.currencyInfo = _moneroInfo.currencyInfo
99
102
  this.currencyTools = tools
100
- this.myMoneroApi = new (0, _MyMoneroApijs.MyMoneroApi)(tools.cppBridge, {
103
+ this.myMoneroApi = new (0, _MyMoneroApi.MyMoneroApi)(tools.cppBridge, {
101
104
  apiKey: initOptions.apiKey,
102
105
  apiServer: networkInfo.defaultServer,
103
106
  fetch: env.io.fetch,
104
107
  nettype: networkInfo.nettype
105
108
  })
106
109
 
107
- this.allTokens = _moneroInfojs.currencyInfo.metaTokens.slice(0)
110
+ this.allTokens = _moneroInfo.currencyInfo.metaTokens.slice(0)
108
111
  // this.customTokens = []
109
112
  this.timers = {}
110
113
 
111
114
  this.currentSettings = {
112
- ..._moneroInfojs.currencyInfo.defaultSettings,
113
- ..._moneroTypesjs.asMoneroUserSettings.call(void 0, userSettings)
115
+ ..._moneroInfo.currencyInfo.defaultSettings,
116
+ ..._moneroTypes.asMoneroUserSettings.call(void 0, userSettings)
114
117
  }
115
- if (this.currentSettings.enableCustomServers) {
118
+ if (
119
+ this.currentSettings.enableCustomServers &&
120
+ this.currentSettings.moneroLightwalletServer != null
121
+ ) {
116
122
  this.myMoneroApi.changeServer(
117
123
  this.currentSettings.moneroLightwalletServer,
118
124
  ''
@@ -131,7 +137,7 @@ const PRIMARY_CURRENCY = _moneroInfojs.currencyInfo.currencyCode
131
137
  }
132
138
 
133
139
  async init() {
134
- const safeWalletInfo = await _moneroTypesjs.makeSafeWalletInfo.call(void 0,
140
+ const safeWalletInfo = await _moneroTypes.makeSafeWalletInfo.call(void 0,
135
141
  this.currencyTools,
136
142
  this.walletInfo
137
143
  )
@@ -170,6 +176,7 @@ const PRIMARY_CURRENCY = _moneroInfojs.currencyInfo.currencyCode
170
176
  if ('new_address' in result && !this.loggedIn) {
171
177
  this.loggedIn = true
172
178
  this.walletLocalData.hasLoggedIn = true
179
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
173
180
  this.addToLoop('saveWalletLoop', SAVE_DATASTORE_MILLISECONDS)
174
181
  }
175
182
  } catch (e) {
@@ -206,7 +213,9 @@ const PRIMARY_CURRENCY = _moneroInfojs.currencyInfo.currencyCode
206
213
  this.walletLocalData.lockedXmrBalance = addrResult.lockedBalance
207
214
  } catch (e) {
208
215
  this.log.error(
209
- 'Error fetching address info: ' + this.walletInfo.keys.moneroAddress + e
216
+ `Error fetching address info: ${
217
+ this.walletInfo.keys.moneroAddress
218
+ } ${String(e)}`
210
219
  )
211
220
  }
212
221
  }
@@ -280,7 +289,7 @@ const PRIMARY_CURRENCY = _moneroInfojs.currencyInfo.currencyCode
280
289
  nativeAmount: edgeTx.nativeAmount
281
290
  }
282
291
 
283
- this.log(`Update transaction: ${tx.hash} height:${tx.blockNumber}`)
292
+ this.log(`Update transaction: ${tx.hash} height:${tx.height}`)
284
293
  this.updateTransaction(PRIMARY_CURRENCY, edgeTransaction, idx)
285
294
  this.edgeTxLibCallbacks.onTransactionsChanged(
286
295
  this.transactionsChangedArray
@@ -307,7 +316,7 @@ const PRIMARY_CURRENCY = _moneroInfojs.currencyInfo.currencyCode
307
316
  publicSpendKey: privateKeys.moneroSpendKeyPublic
308
317
  })
309
318
 
310
- this.log('Fetched transactions count: ' + transactions.length)
319
+ this.log(`Fetched transactions count: ${transactions.length}`)
311
320
 
312
321
  // Get transactions
313
322
  // Iterate over transactions in address
@@ -333,7 +342,7 @@ const PRIMARY_CURRENCY = _moneroInfojs.currencyInfo.currencyCode
333
342
 
334
343
  const currency = this.walletLocalData.transactionsObj[currencyCode]
335
344
  return currency.findIndex(element => {
336
- return _utilsjs.normalizeAddress.call(void 0, element.txid) === _utilsjs.normalizeAddress.call(void 0, txid)
345
+ return _utils.normalizeAddress.call(void 0, element.txid) === _utils.normalizeAddress.call(void 0, txid)
337
346
  })
338
347
  }
339
348
 
@@ -390,7 +399,7 @@ const PRIMARY_CURRENCY = _moneroInfojs.currencyInfo.currencyCode
390
399
  try {
391
400
  this.log('walletLocalDataDirty. Saving...')
392
401
  const walletJson = JSON.stringify(this.walletLocalData)
393
- await this.walletLocalDisklet.setText(_MoneroLocalDatajs.DATA_STORE_FILE, walletJson)
402
+ await this.walletLocalDisklet.setText(_MoneroLocalData.DATA_STORE_FILE, walletJson)
394
403
  this.walletLocalDataDirty = false
395
404
  } catch (err) {
396
405
  this.log.error('saveWalletLoop', err)
@@ -413,7 +422,7 @@ const PRIMARY_CURRENCY = _moneroInfojs.currencyInfo.currencyCode
413
422
 
414
423
  async addToLoop(func, timer) {
415
424
  try {
416
- // $FlowFixMe
425
+ // @ts-expect-error
417
426
  await this[func]()
418
427
  } catch (e) {
419
428
  this.log.error('Error in Loop:', func, e)
@@ -421,6 +430,7 @@ const PRIMARY_CURRENCY = _moneroInfojs.currencyInfo.currencyCode
421
430
  if (this.engineOn) {
422
431
  this.timers[func] = setTimeout(() => {
423
432
  if (this.engineOn) {
433
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
424
434
  this.addToLoop(func, timer)
425
435
  }
426
436
  }, timer)
@@ -434,9 +444,12 @@ const PRIMARY_CURRENCY = _moneroInfojs.currencyInfo.currencyCode
434
444
  async changeUserSettings(userSettings) {
435
445
  this.currentSettings = {
436
446
  ...this.currencyInfo.defaultSettings,
437
- ..._moneroTypesjs.asMoneroUserSettings.call(void 0, userSettings)
447
+ ..._moneroTypes.asMoneroUserSettings.call(void 0, userSettings)
438
448
  }
439
- if (this.currentSettings.enableCustomServers) {
449
+ if (
450
+ this.currentSettings.enableCustomServers &&
451
+ this.currentSettings.moneroLightwalletServer != null
452
+ ) {
440
453
  this.myMoneroApi.changeServer(
441
454
  this.currentSettings.moneroLightwalletServer,
442
455
  ''
@@ -474,7 +487,7 @@ const PRIMARY_CURRENCY = _moneroInfojs.currencyInfo.currencyCode
474
487
  moneroAddress: this.walletInfo.keys.moneroAddress,
475
488
  moneroViewKeyPrivate: this.walletInfo.keys.moneroViewKeyPrivate
476
489
  })
477
- this.walletLocalData = new (0, _MoneroLocalDatajs.MoneroLocalData)(temp)
490
+ this.walletLocalData = new (0, _MoneroLocalData.MoneroLocalData)(temp)
478
491
  this.walletLocalDataDirty = true
479
492
  this.addressesChecked = false
480
493
  await this.saveWalletLoop()
@@ -482,7 +495,7 @@ const PRIMARY_CURRENCY = _moneroInfojs.currencyInfo.currencyCode
482
495
  }
483
496
 
484
497
  async syncNetwork(opts) {
485
- const xmrPrivateKeys = _moneroTypesjs.asPrivateKeys.call(void 0, opts.privateKeys)
498
+ const xmrPrivateKeys = _moneroTypes.asPrivateKeys.call(void 0, opts.privateKeys)
486
499
 
487
500
  // Login only if not logged in
488
501
  if (!this.loggedIn) {
@@ -498,7 +511,7 @@ const PRIMARY_CURRENCY = _moneroInfojs.currencyInfo.currencyCode
498
511
  }
499
512
 
500
513
  getBlockHeight() {
501
- return parseInt(this.walletLocalData.blockHeight)
514
+ return this.walletLocalData.blockHeight
502
515
  }
503
516
 
504
517
  async enableTokens(tokens) {}
@@ -568,7 +581,7 @@ const PRIMARY_CURRENCY = _moneroInfojs.currencyInfo.currencyCode
568
581
  edgeSpendInfo,
569
582
  opts
570
583
  ) {
571
- const privateKeys = _moneroTypesjs.asPrivateKeys.call(void 0, _optionalChain([opts, 'optionalAccess', _ => _.privateKeys]))
584
+ const privateKeys = _moneroTypes.asPrivateKeys.call(void 0, _optionalChain([opts, 'optionalAccess', _ => _.privateKeys]))
572
585
  const [spendTarget] = edgeSpendInfo.spendTargets
573
586
  const { publicAddress } = spendTarget
574
587
  if (publicAddress == null) {
@@ -615,7 +628,7 @@ const PRIMARY_CURRENCY = _moneroInfojs.currencyInfo.currencyCode
615
628
  opts
616
629
  ) {
617
630
  const { memos = [] } = edgeSpendInfo
618
- const privateKeys = _moneroTypesjs.asPrivateKeys.call(void 0, _optionalChain([opts, 'optionalAccess', _2 => _2.privateKeys]))
631
+ const privateKeys = _moneroTypes.asPrivateKeys.call(void 0, _optionalChain([opts, 'optionalAccess', _2 => _2.privateKeys]))
619
632
 
620
633
  // Monero can only have one output
621
634
  // TODO: The new SDK fixes this!
@@ -671,7 +684,7 @@ const PRIMARY_CURRENCY = _moneroInfojs.currencyInfo.currencyCode
671
684
  txSecret: result.tx_key,
672
685
  walletId: this.walletId
673
686
  }
674
- this.log.warn(`makeSpend edgeTransaction ${_utilsjs.cleanTxLogs.call(void 0, edgeTransaction)}`)
687
+ this.log.warn(`makeSpend edgeTransaction ${_utils.cleanTxLogs.call(void 0, edgeTransaction)}`)
675
688
  return edgeTransaction
676
689
  }
677
690
 
@@ -687,11 +700,11 @@ const PRIMARY_CURRENCY = _moneroInfojs.currencyInfo.currencyCode
687
700
  ) {
688
701
  try {
689
702
  await this.myMoneroApi.broadcastTransaction(edgeTransaction.signedTx)
690
- this.log.warn(`broadcastTx success ${_utilsjs.cleanTxLogs.call(void 0, edgeTransaction)}`)
703
+ this.log.warn(`broadcastTx success ${_utils.cleanTxLogs.call(void 0, edgeTransaction)}`)
691
704
  return edgeTransaction
692
705
  } catch (e) {
693
706
  this.log.error(
694
- `broadcastTx failed: ${String(e)} ${_utilsjs.cleanTxLogs.call(void 0, edgeTransaction)}`
707
+ `broadcastTx failed: ${String(e)} ${_utils.cleanTxLogs.call(void 0, edgeTransaction)}`
695
708
  )
696
709
  if (e instanceof Error && e.message.includes(' 422 ')) {
697
710
  throw new Error(
@@ -710,12 +723,12 @@ const PRIMARY_CURRENCY = _moneroInfojs.currencyInfo.currencyCode
710
723
  }
711
724
 
712
725
  getDisplayPrivateSeed(privateKeys) {
713
- const xmrPrivateKeys = _moneroTypesjs.asPrivateKeys.call(void 0, privateKeys)
726
+ const xmrPrivateKeys = _moneroTypes.asPrivateKeys.call(void 0, privateKeys)
714
727
  return xmrPrivateKeys.moneroKey
715
728
  }
716
729
 
717
730
  getDisplayPublicSeed() {
718
- if (this.walletInfo.keys && this.walletInfo.keys.moneroViewKeyPrivate) {
731
+ if (_optionalChain([this, 'access', _3 => _3.walletInfo, 'access', _4 => _4.keys, 'optionalAccess', _5 => _5.moneroViewKeyPrivate]) != null) {
719
732
  return this.walletInfo.keys.moneroViewKeyPrivate
720
733
  }
721
734
  return ''
@@ -725,6 +738,7 @@ const PRIMARY_CURRENCY = _moneroInfojs.currencyInfo.currencyCode
725
738
  const dataDump = {
726
739
  walletId: this.walletId,
727
740
  walletType: this.walletInfo.type,
741
+ // @ts-expect-error
728
742
  pluginType: this.currencyInfo.pluginId,
729
743
  data: {
730
744
  walletLocalData: this.walletLocalData
@@ -746,24 +760,26 @@ function translateFee(fee) {
746
760
  walletInfo,
747
761
  opts
748
762
  ) {
749
- const safeWalletInfo = _moneroTypesjs.asSafeWalletInfo.call(void 0, walletInfo)
763
+ const safeWalletInfo = _moneroTypes.asSafeWalletInfo.call(void 0, walletInfo)
750
764
 
751
765
  const engine = new MoneroEngine(env, tools, safeWalletInfo, opts)
752
766
  await engine.init()
753
767
  try {
754
- const result = await engine.walletLocalDisklet.getText(_MoneroLocalDatajs.DATA_STORE_FILE)
755
- engine.walletLocalData = new (0, _MoneroLocalDatajs.MoneroLocalData)(result)
768
+ const result = await engine.walletLocalDisklet.getText(_MoneroLocalData.DATA_STORE_FILE)
769
+ engine.walletLocalData = new (0, _MoneroLocalData.MoneroLocalData)(result)
756
770
  } catch (err) {
757
771
  try {
758
772
  opts.log(err)
759
773
  opts.log('No walletLocalData setup yet: Failure is ok')
760
- engine.walletLocalData = new (0, _MoneroLocalDatajs.MoneroLocalData)(null)
774
+ engine.walletLocalData = new (0, _MoneroLocalData.MoneroLocalData)(null)
761
775
  await engine.walletLocalDisklet.setText(
762
- _MoneroLocalDatajs.DATA_STORE_FILE,
776
+ _MoneroLocalData.DATA_STORE_FILE,
763
777
  JSON.stringify(engine.walletLocalData)
764
778
  )
765
779
  } catch (e) {
766
- opts.log.error('Error writing to localDataStore. Engine not started:' + e)
780
+ opts.log.error(
781
+ `Error writing to localDataStore. Engine not started: ${String(e)}`
782
+ )
767
783
  }
768
784
  }
769
785
 
@@ -1,11 +1,9 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});//
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
-
4
-
5
- var _moneroInfojs = require('./moneroInfo.js');
3
+ var _moneroInfo = require('./moneroInfo');
6
4
 
7
5
  const DATA_STORE_FILE = 'txEngineFolder/walletLocalData.json'; exports.DATA_STORE_FILE = DATA_STORE_FILE
8
- const PRIMARY_CURRENCY = _moneroInfojs.currencyInfo.currencyCode; exports.PRIMARY_CURRENCY = PRIMARY_CURRENCY
6
+ const PRIMARY_CURRENCY = _moneroInfo.currencyInfo.currencyCode; exports.PRIMARY_CURRENCY = PRIMARY_CURRENCY
9
7
 
10
8
  class MoneroLocalData {
11
9
 
@@ -1,6 +1,5 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }//
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _biggystring = require('biggystring');
2
2
 
3
- var _biggystring = require('biggystring');
4
3
 
5
4
 
6
5
 
@@ -11,18 +10,16 @@ var _biggystring = require('biggystring');
11
10
 
12
11
 
13
12
 
14
- var _CppBridgejs = require('react-native-mymonero-core/src/CppBridge.js'); var _CppBridgejs2 = _interopRequireDefault(_CppBridgejs);
15
- var _urijs = require('uri-js');
16
-
17
- var _moneroInfojs = require('./moneroInfo.js');
18
-
19
13
 
20
14
 
15
+ var _CppBridge = require('react-native-mymonero-core/src/CppBridge'); var _CppBridge2 = _interopRequireDefault(_CppBridge);
16
+ var _urijs = require('uri-js');
21
17
 
18
+ var _moneroInfo = require('./moneroInfo');
22
19
 
23
20
 
24
21
  function getDenomInfo(denom) {
25
- return _moneroInfojs.currencyInfo.denominations.find(element => {
22
+ return _moneroInfo.currencyInfo.denominations.find(element => {
26
23
  return element.name === denom
27
24
  })
28
25
  }
@@ -31,8 +28,7 @@ function getParameterByName(param, url) {
31
28
  const name = param.replace(/[[\]]/g, '\\$&')
32
29
  const regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)')
33
30
  const results = regex.exec(url)
34
- if (!results) return null
35
- if (!results[2]) return ''
31
+ if (results == null || results[2] == null) return
36
32
  return decodeURIComponent(results[2].replace(/\+/g, ' '))
37
33
  }
38
34
 
@@ -49,56 +45,53 @@ function getParameterByName(param, url) {
49
45
  const { io, log, nativeIo } = env
50
46
 
51
47
  // Grab the raw C++ API and wrap it in argument parsing:
52
- const cppModule = nativeIo['edge-currency-monero']
53
- this.cppBridge = new (0, _CppBridgejs2.default)(cppModule)
48
+ const cppModule = nativeIo['edge-currency-monero']
49
+ this.cppBridge = new (0, _CppBridge2.default)(cppModule)
54
50
 
55
51
  this.io = io
56
52
  this.log = log
57
53
  }
58
54
 
59
55
  async createPrivateKey(walletType) {
60
- const type = walletType.replace('wallet:', '')
61
-
62
- if (type === 'monero') {
63
- const result = await this.cppBridge.generateWallet(
64
- 'english',
65
- this.networkInfo.nettype
66
- )
67
- const privateKeys = {
68
- moneroKey: result.mnemonic,
69
- moneroSpendKeyPrivate: result.privateSpendKey,
70
- moneroSpendKeyPublic: result.publicSpendKey
71
- }
72
- return privateKeys
73
- } else {
56
+ if (walletType !== 'wallet:monero') {
74
57
  throw new Error('InvalidWalletType')
75
58
  }
59
+
60
+ const result = await this.cppBridge.generateWallet(
61
+ 'english',
62
+ this.networkInfo.nettype
63
+ )
64
+ const privateKeys = {
65
+ moneroKey: result.mnemonic,
66
+ moneroSpendKeyPrivate: result.privateSpendKey,
67
+ moneroSpendKeyPublic: result.publicSpendKey
68
+ }
69
+ return privateKeys
76
70
  }
77
71
 
78
72
  async derivePublicKey(walletInfo) {
79
- const type = walletInfo.type.replace('wallet:', '')
80
- if (type === 'monero') {
81
- const result = await this.cppBridge.seedAndKeysFromMnemonic(
82
- walletInfo.keys.moneroKey,
83
- this.networkInfo.nettype
84
- )
85
- const publicKeys = {
86
- moneroAddress: result.address,
87
- moneroViewKeyPrivate: result.privateViewKey,
88
- moneroViewKeyPublic: result.publicViewKey,
89
- moneroSpendKeyPublic: result.publicSpendKey
90
- }
91
- return publicKeys
92
- } else {
73
+ if (walletInfo.type !== 'wallet:monero') {
93
74
  throw new Error('InvalidWalletType')
94
75
  }
76
+
77
+ const result = await this.cppBridge.seedAndKeysFromMnemonic(
78
+ walletInfo.keys.moneroKey,
79
+ this.networkInfo.nettype
80
+ )
81
+ const publicKeys = {
82
+ moneroAddress: result.address,
83
+ moneroViewKeyPrivate: result.privateViewKey,
84
+ moneroViewKeyPublic: result.publicViewKey,
85
+ moneroSpendKeyPublic: result.publicSpendKey
86
+ }
87
+ return publicKeys
95
88
  }
96
89
 
97
90
  async parseUri(uri) {
98
91
  const parsedUri = _urijs.parse.call(void 0, uri)
99
92
  let address
100
- let nativeAmount = null
101
- let currencyCode = null
93
+ let nativeAmount
94
+ let currencyCode
102
95
 
103
96
  if (
104
97
  typeof parsedUri.scheme !== 'undefined' &&
@@ -123,9 +116,9 @@ function getParameterByName(param, url) {
123
116
  }
124
117
 
125
118
  const amountStr = getParameterByName('amount', uri)
126
- if (amountStr && typeof amountStr === 'string') {
119
+ if (amountStr != null) {
127
120
  const denom = getDenomInfo('XMR')
128
- if (!denom) {
121
+ if (denom == null) {
129
122
  throw new Error('InternalErrorInvalidCurrencyCode')
130
123
  }
131
124
  nativeAmount = _biggystring.mul.call(void 0, amountStr, denom.multiplier)
@@ -140,24 +133,24 @@ function getParameterByName(param, url) {
140
133
  const edgeParsedUri = {
141
134
  publicAddress: address
142
135
  }
143
- if (nativeAmount) {
136
+ if (nativeAmount != null) {
144
137
  edgeParsedUri.nativeAmount = nativeAmount
145
138
  }
146
- if (currencyCode) {
139
+ if (currencyCode != null) {
147
140
  edgeParsedUri.currencyCode = currencyCode
148
141
  }
149
- if (uniqueIdentifier) {
142
+ if (uniqueIdentifier != null) {
150
143
  edgeParsedUri.uniqueIdentifier = uniqueIdentifier
151
144
  }
152
- if (label || message || category) {
145
+ if (label != null || message != null || category != null) {
153
146
  edgeParsedUri.metadata = {}
154
- if (label) {
147
+ if (label != null) {
155
148
  edgeParsedUri.metadata.name = label
156
149
  }
157
- if (message) {
150
+ if (message != null) {
158
151
  edgeParsedUri.metadata.notes = message
159
152
  }
160
- if (category) {
153
+ if (category != null) {
161
154
  edgeParsedUri.metadata.category = category
162
155
  }
163
156
  }
@@ -166,7 +159,7 @@ function getParameterByName(param, url) {
166
159
  }
167
160
 
168
161
  async encodeUri(obj) {
169
- if (!obj.publicAddress) {
162
+ if (obj.publicAddress == null) {
170
163
  throw new Error('InvalidPublicAddressError')
171
164
  }
172
165
  try {
@@ -177,7 +170,7 @@ function getParameterByName(param, url) {
177
170
  } catch (e) {
178
171
  throw new Error('InvalidPublicAddressError')
179
172
  }
180
- if (!obj.nativeAmount && !obj.label && !obj.message) {
173
+ if (obj.nativeAmount == null && obj.label == null && obj.message == null) {
181
174
  return obj.publicAddress
182
175
  } else {
183
176
  let queryString = ''
@@ -186,7 +179,7 @@ function getParameterByName(param, url) {
186
179
  const currencyCode = 'XMR'
187
180
  const nativeAmount = obj.nativeAmount
188
181
  const denom = getDenomInfo(currencyCode)
189
- if (!denom) {
182
+ if (denom == null) {
190
183
  throw new Error('InternalErrorInvalidCurrencyCode')
191
184
  }
192
185
  const amount = _biggystring.div.call(void 0, nativeAmount, denom.multiplier, 12)
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }//
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }// @flow
2
2
 
3
3
 
4
4
 
@@ -17,7 +17,7 @@ var _cleaners = require('cleaners');
17
17
 
18
18
 
19
19
 
20
- const parserUtils = require('./mymonero-utils/ResponseParser.js')
20
+ var _ResponseParser = require('./mymonero-utils/ResponseParser'); var _ResponseParser2 = _interopRequireDefault(_ResponseParser);
21
21
 
22
22
 
23
23
 
@@ -64,6 +64,28 @@ const asSpentOutput = _cleaners.asObject.call(void 0, {
64
64
  tx_pub_key: _cleaners.asString // Bytes of the tx public key
65
65
  })
66
66
 
67
+
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+
80
+
81
+
82
+
83
+
84
+
85
+
86
+
87
+
88
+
67
89
  //
68
90
  // Response Cleaners
69
91
  //
@@ -174,7 +196,7 @@ const asGetAddressTxsResponse = _cleaners.asObject.call(void 0, {
174
196
  view_key: privateViewKey
175
197
  })
176
198
 
177
- const parsed = await parserUtils.Parsed_AddressTransactions__async(
199
+ const parsed = await _ResponseParser2.default.Parsed_AddressTransactions__async(
178
200
  this.keyImageCache,
179
201
  asGetAddressTxsResponse(response),
180
202
  address,
@@ -194,7 +216,7 @@ const asGetAddressTxsResponse = _cleaners.asObject.call(void 0, {
194
216
  view_key: privateViewKey
195
217
  })
196
218
 
197
- const parsed = await parserUtils.Parsed_AddressInfo__async(
219
+ const parsed = await _ResponseParser2.default.Parsed_AddressInfo__async(
198
220
  this.keyImageCache,
199
221
  asAddressInfoResponse(response),
200
222
  address,
@@ -292,6 +314,6 @@ const asGetAddressTxsResponse = _cleaners.asObject.call(void 0, {
292
314
  `The server returned error code ${response.status} for ${url}`
293
315
  )
294
316
  }
295
- return response.json()
317
+ return await response.json()
296
318
  }
297
319
  } exports.MyMoneroApi = MyMoneroApi;
package/lib/index.js CHANGED
@@ -1,11 +1,17 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});//
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('regenerator-runtime/runtime');
2
+
3
+
4
+
5
+ var _moneroPlugin = require('./moneroPlugin');
6
+
7
+
8
+
9
+
2
10
 
3
- require('regenerator-runtime/runtime');
4
11
 
5
- var _moneroPluginjs = require('./moneroPlugin.js');
6
12
 
7
13
  const edgeCorePlugins = {
8
- monero: _moneroPluginjs.makeMoneroPlugin
14
+ monero: _moneroPlugin.makeMoneroPlugin
9
15
  }
10
16
 
11
17
  exports. default = edgeCorePlugins
package/lib/moneroInfo.js CHANGED
@@ -1,6 +1,4 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});//
2
-
3
-
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
4
2
 
5
3
 
6
4