edge-currency-plugins 1.0.0-rc.2 → 1.0.0-rc.3

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.
@@ -104,7 +104,7 @@ var _utils = require('./utils');
104
104
  const processor = await _makeProcessor.makeProcessor.call(void 0, {
105
105
  disklet: walletLocalDisklet
106
106
  })
107
- const state = _makeUtxoEngineState.makeUtxoEngineState.call(void 0, {
107
+ const engineState = _makeUtxoEngineState.makeUtxoEngineState.call(void 0, {
108
108
  ...config,
109
109
  walletTools,
110
110
  walletInfo,
@@ -120,15 +120,15 @@ var _utils = require('./utils');
120
120
  metadata.balance
121
121
  )
122
122
 
123
- pluginState.addEngine(state)
123
+ pluginState.addEngine(engineState)
124
124
  await fees.start()
125
- await state.start()
125
+ await engineState.start()
126
126
  },
127
127
 
128
128
  async killEngine() {
129
- await state.stop()
129
+ await engineState.stop()
130
130
  fees.stop()
131
- pluginState.removeEngine(state)
131
+ pluginState.removeEngine(engineState)
132
132
  },
133
133
 
134
134
  getBalance(_opts) {
@@ -144,7 +144,7 @@ var _utils = require('./utils');
144
144
  },
145
145
 
146
146
  async addGapLimitAddresses(addresses) {
147
- return await state.addGapLimitAddresses(addresses)
147
+ return await engineState.addGapLimitAddresses(addresses)
148
148
  },
149
149
 
150
150
  async broadcastTx(transaction) {
@@ -164,7 +164,7 @@ var _utils = require('./utils');
164
164
  )
165
165
  }
166
166
  }
167
- const id = await state.broadcastTx(transaction)
167
+ const id = await engineState.broadcastTx(transaction)
168
168
  if (id !== transaction.txid) {
169
169
  throw new Error('broadcast response txid does not match original')
170
170
  }
@@ -221,7 +221,7 @@ var _utils = require('./utils');
221
221
  async getFreshAddress(
222
222
  _opts
223
223
  ) {
224
- return await state.getFreshAddress()
224
+ return await engineState.getFreshAddress()
225
225
  },
226
226
 
227
227
  getNumTransactions(_opts) {
@@ -302,7 +302,7 @@ var _utils = require('./utils');
302
302
  const { script } = target.otherParams
303
303
  if (script.type === 'replayProtection') {
304
304
  // construct a replay protection p2sh address
305
- const { publicAddress } = await state.deriveScriptAddress(
305
+ const { publicAddress } = await engineState.deriveScriptAddress(
306
306
  script.type
307
307
  )
308
308
  targets.push({
@@ -328,7 +328,7 @@ var _utils = require('./utils');
328
328
  throw new Error('Need to provide Spend Targets')
329
329
  }
330
330
 
331
- const freshAddress = await state.getFreshAddress(1)
331
+ const freshAddress = await engineState.getFreshAddress(1)
332
332
  const freshChangeAddress =
333
333
  _nullishCoalesce(freshAddress.segwitAddress, () => ( freshAddress.publicAddress))
334
334
  const setRBF = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _9 => _9.setRBF]), () => ( false))
@@ -467,7 +467,7 @@ var _utils = require('./utils');
467
467
  Get the wallet's UTXOs from the new transaction and save them to the processsor.
468
468
  */
469
469
  const utxos = await _getOwnUtxosFromTx.getOwnUtxosFromTx.call(void 0, engineInfo, processor, tx)
470
- await Promise.all(utxos.map(async utxo => await processor.saveUtxo(utxo)))
470
+ await engineState.processUtxos(utxos)
471
471
  },
472
472
 
473
473
  async signTx(transaction) {
@@ -82,6 +82,8 @@ var _utils3 = require('./utils');
82
82
 
83
83
 
84
84
 
85
+
86
+
85
87
 
86
88
 
87
89
 
@@ -440,6 +442,22 @@ var _utils3 = require('./utils');
440
442
  }
441
443
  }
442
444
  }
445
+ },
446
+ async processUtxos(utxos) {
447
+ const utxoMap = new Map()
448
+ for (const utxo of utxos) {
449
+ const utxoSet = _nullishCoalesce(utxoMap.get(utxo.scriptPubkey), () => ( new Set()))
450
+ if (utxoMap.has(utxo.scriptPubkey) == null)
451
+ utxoMap.set(utxo.scriptPubkey, utxoSet)
452
+ utxoSet.add(utxo)
453
+ }
454
+ for (const [scriptPubkey, utxos] of utxoMap.entries()) {
455
+ await processProcessorUtxos({
456
+ ...commonArgs,
457
+ scriptPubkey,
458
+ utxos
459
+ })
460
+ }
443
461
  }
444
462
  }
445
463
  } exports.makeUtxoEngineState = makeUtxoEngineState;
@@ -681,8 +699,7 @@ const addToAddressTransactionCache = async (
681
699
  await processProcessorUtxos({
682
700
  ...args,
683
701
  scriptPubkey,
684
- utxos: state.utxos,
685
- path: state.path
702
+ utxos: state.utxos
686
703
  })
687
704
  _utils.removeItem.call(void 0, processorUtxoCache, scriptPubkey)
688
705
  return true
@@ -1196,7 +1213,6 @@ const processAddressUtxos = async (
1196
1213
 
1197
1214
 
1198
1215
 
1199
-
1200
1216
  const processProcessorUtxos = async (
1201
1217
  args
1202
1218
  ) => {
@@ -21,6 +21,7 @@ export interface UtxoEngineState {
21
21
  getServerList: () => string[];
22
22
  setServerList: (serverList: string[]) => void;
23
23
  loadWifs: (wifs: string[]) => Promise<void>;
24
+ processUtxos: (utxos: IUTXO[]) => Promise<void>;
24
25
  }
25
26
  export interface UtxoEngineStateConfig extends EngineConfig {
26
27
  walletTools: UTXOPluginWalletTools;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "edge-currency-plugins",
3
- "version": "1.0.0-rc.2",
3
+ "version": "1.0.0-rc.3",
4
4
  "description": "Edge currency plugins to fetch and process wallet accounts, balances and transactions.",
5
5
  "repository": "https://github.com/EdgeApp/edge-currency-plugins",
6
6
  "license": "MIT",