edge-currency-plugins 1.0.0-rc.4 → 1.0.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.
@@ -286,7 +286,10 @@ var _utils = require('./utils');
286
286
  await _asyncNullishCoalesce(await _asyncOptionalChain([options, 'optionalAccess', async _6 => _6.utxos]), async () => (
287
287
  ((await processor.fetchUtxos({ utxoIds: [] })) )))
288
288
 
289
- if (bs.gt(totalAmountToSend, `${_utils.sumUtxos.call(void 0, utxos)}`)) {
289
+ if (
290
+ bs.gt(totalAmountToSend, `${_utils.sumUtxos.call(void 0, utxos)}`) ||
291
+ utxos.length === 0
292
+ ) {
290
293
  throw new (0, _types.InsufficientFundsError)(currencyInfo.currencyCode)
291
294
  }
292
295
 
@@ -450,7 +450,7 @@ var _utils3 = require('./utils');
450
450
  const utxoMap = new Map()
451
451
  for (const utxo of utxos) {
452
452
  const utxoSet = _nullishCoalesce(utxoMap.get(utxo.scriptPubkey), () => ( new Set()))
453
- if (utxoMap.has(utxo.scriptPubkey) == null)
453
+ if (!utxoMap.has(utxo.scriptPubkey))
454
454
  utxoMap.set(utxo.scriptPubkey, utxoSet)
455
455
  utxoSet.add(utxo)
456
456
  }
@@ -52,7 +52,7 @@ const currencyInfo = {
52
52
 
53
53
  const engineInfo = {
54
54
  formats: ['bip44', 'bip32'],
55
- forks: ['bitcoinsv'],
55
+ // forks: ['bitcoinsv'],
56
56
  gapLimit: 10,
57
57
  defaultFee: 10000,
58
58
  feeUpdateInterval: 60000,
@@ -41,9 +41,9 @@ const currencyInfo = {
41
41
  metaTokens: [],
42
42
 
43
43
  // Explorers:
44
- blockExplorer: 'https://blockchair.com/bitcoin-sv/block/%s',
45
- addressExplorer: 'https://blockchair.com/bitcoin-sv/address/%s',
46
- transactionExplorer: 'https://blockchair.com/bitcoin-sv/transaction/%s',
44
+ blockExplorer: 'https://whatsonchain.com/block/%s',
45
+ addressExplorer: 'https://whatsonchain.com/address/%s',
46
+ transactionExplorer: 'https://whatsonchain.com/tx/%s',
47
47
 
48
48
  // Images:
49
49
  symbolImage: `${_constants.IMAGE_SERVER_URL}/bitcoinsv-logo-solo-64.png`,
@@ -47,6 +47,6 @@ var _utils = require('./utils'); var utils = _interopRequireWildcard(_utils);
47
47
 
48
48
  return {
49
49
  changeUsed: false,
50
- fee: feeRate * utils.transactionBytes(inputs, outputs)
50
+ fee: Math.ceil(feeRate * utils.transactionBytes(inputs, outputs))
51
51
  }
52
52
  } exports.accumulative = accumulative;
@@ -54,6 +54,6 @@ var _utils = require('./utils'); var utils = _interopRequireWildcard(_utils);
54
54
 
55
55
  return {
56
56
  changeUsed: false,
57
- fee: feeRate * utils.transactionBytes(inputs, outputs)
57
+ fee: Math.ceil(feeRate * utils.transactionBytes(inputs, outputs))
58
58
  }
59
59
  } exports.forceUseUtxo = forceUseUtxo;
@@ -10,7 +10,7 @@ var _utils = require('./utils'); var utils = _interopRequireWildcard(_utils);
10
10
  scriptPubkey: Buffer.from(target.script, 'hex')
11
11
  }))
12
12
 
13
- const fee = feeRate * utils.transactionBytes(utxos, outputs)
13
+ const fee = Math.ceil(feeRate * utils.transactionBytes(utxos, outputs))
14
14
  targets[0].value -= fee
15
15
  outputs[0].value -= fee
16
16
  return { inputs: utxos, outputs, fee, changeUsed: false }
@@ -275,7 +275,12 @@ const WAKE_UP_MS = 5000 // interval at which we wakeUp and potentially onQueueSp
275
275
  if (!subscription.subscribed) {
276
276
  subscription.deferred.reject()
277
277
  }
278
- subscription.cb(subscription.cleaner(json.data))
278
+ try {
279
+ subscription.cb(subscription.cleaner(json.data))
280
+ } catch (error) {
281
+ console.log({ uri, error, json, subscription })
282
+ throw error
283
+ }
279
284
  return
280
285
  }
281
286
  }
@@ -296,9 +301,9 @@ const WAKE_UP_MS = 5000 // interval at which we wakeUp and potentially onQueueSp
296
301
  } else {
297
302
  message.task.deferred.resolve(json.data)
298
303
  }
299
- } catch (e) {
300
- if (e instanceof TypeError) console.log({ json, message })
301
- message.task.deferred.reject(e)
304
+ } catch (error) {
305
+ console.log({ uri, error, json, message })
306
+ message.task.deferred.reject(error)
302
307
  }
303
308
  }
304
309
  } catch (e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "edge-currency-plugins",
3
- "version": "1.0.0-rc.4",
3
+ "version": "1.0.0",
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",
@@ -48,7 +48,7 @@
48
48
  "bs58smartcheck": "^2.0.4",
49
49
  "cleaners": "^0.3.12",
50
50
  "disklet": "^0.4.5",
51
- "edge-core-js": "^0.19.19",
51
+ "edge-core-js": "^0.19.20",
52
52
  "memlet": "^0.1.6",
53
53
  "uri-js": "^4.4.0",
54
54
  "url-parse": "^1.5.2",