edge-currency-plugins 1.0.0 → 1.1.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.
|
@@ -1,4 +1,6 @@
|
|
|
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; }
|
|
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(); } } 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; }var _altcoinjs = require('altcoin-js');
|
|
2
|
+
var _bnjs = require('bn.js'); var _bnjs2 = _interopRequireDefault(_bnjs);
|
|
3
|
+
|
|
2
4
|
|
|
3
5
|
|
|
4
6
|
|
|
@@ -56,12 +58,11 @@ var _keymanager = require('../../keymanager/keymanager');
|
|
|
56
58
|
|
|
57
59
|
|
|
58
60
|
|
|
59
|
-
|
|
60
61
|
const toEdgeTransaction = async (
|
|
61
62
|
args
|
|
62
63
|
) => {
|
|
63
|
-
const { tx, processor, walletTools,
|
|
64
|
-
|
|
64
|
+
const { tx, processor, walletTools, pluginInfo } = args
|
|
65
|
+
const { engineInfo, currencyInfo } = pluginInfo
|
|
65
66
|
const ourReceiveAddresses = []
|
|
66
67
|
for (const out of tx.ourOuts) {
|
|
67
68
|
const { scriptPubkey } = tx.outputs[parseInt(out)]
|
|
@@ -95,14 +96,32 @@ var _keymanager = require('../../keymanager/keymanager');
|
|
|
95
96
|
}
|
|
96
97
|
}
|
|
97
98
|
|
|
99
|
+
const feeRes = {}
|
|
100
|
+
|
|
101
|
+
try {
|
|
102
|
+
const altcoinTx = _altcoinjs.Transaction.fromHex(tx.hex)
|
|
103
|
+
const vBytes = altcoinTx.virtualSize()
|
|
104
|
+
// feeRate must be of a number type (limited to 53 bits)
|
|
105
|
+
const feeRate = new (0, _bnjs2.default)(tx.fees, 10)
|
|
106
|
+
.div(new (0, _bnjs2.default)(vBytes, 10))
|
|
107
|
+
.toNumber()
|
|
108
|
+
Object.assign(feeRes, {
|
|
109
|
+
feeRateUsed: {
|
|
110
|
+
// GUI repo uses satPerVByte rather than satPerByte defined in customFeeTemplate
|
|
111
|
+
satPerVByte: feeRate
|
|
112
|
+
}
|
|
113
|
+
})
|
|
114
|
+
} catch (e) {}
|
|
115
|
+
|
|
98
116
|
return {
|
|
99
|
-
currencyCode:
|
|
100
|
-
txid:
|
|
101
|
-
blockHeight:
|
|
102
|
-
date:
|
|
103
|
-
nativeAmount:
|
|
104
|
-
networkFee:
|
|
105
|
-
signedTx:
|
|
106
|
-
ourReceiveAddresses
|
|
117
|
+
currencyCode: currencyInfo.currencyCode,
|
|
118
|
+
txid: tx.txid,
|
|
119
|
+
blockHeight: tx.blockHeight,
|
|
120
|
+
date: tx.date,
|
|
121
|
+
nativeAmount: tx.ourAmount,
|
|
122
|
+
networkFee: tx.fees,
|
|
123
|
+
signedTx: tx.hex,
|
|
124
|
+
ourReceiveAddresses,
|
|
125
|
+
...feeRes
|
|
107
126
|
}
|
|
108
127
|
}; exports.toEdgeTransaction = toEdgeTransaction
|
|
@@ -253,10 +253,9 @@ var _utils = require('./utils');
|
|
|
253
253
|
async (tx) =>
|
|
254
254
|
await _ProcessorTransaction.toEdgeTransaction.call(void 0, {
|
|
255
255
|
tx,
|
|
256
|
-
currencyCode: currencyInfo.currencyCode,
|
|
257
256
|
walletTools,
|
|
258
257
|
processor,
|
|
259
|
-
|
|
258
|
+
pluginInfo
|
|
260
259
|
})
|
|
261
260
|
)
|
|
262
261
|
)
|
|
@@ -647,20 +647,13 @@ const addToAddressTransactionCache = async (
|
|
|
647
647
|
const transactionChanged = async (
|
|
648
648
|
args
|
|
649
649
|
) => {
|
|
650
|
-
const {
|
|
651
|
-
emitter,
|
|
652
|
-
walletTools,
|
|
653
|
-
processor,
|
|
654
|
-
pluginInfo: { currencyInfo, engineInfo },
|
|
655
|
-
tx
|
|
656
|
-
} = args
|
|
650
|
+
const { emitter, walletTools, processor, pluginInfo, tx } = args
|
|
657
651
|
emitter.emit(_makeEngineEmitter.EngineEvent.TRANSACTIONS_CHANGED, [
|
|
658
652
|
await _ProcessorTransaction.toEdgeTransaction.call(void 0, {
|
|
659
653
|
tx,
|
|
660
|
-
currencyCode: currencyInfo.currencyCode,
|
|
661
654
|
walletTools,
|
|
662
655
|
processor,
|
|
663
|
-
|
|
656
|
+
pluginInfo
|
|
664
657
|
})
|
|
665
658
|
])
|
|
666
659
|
}; exports.transactionChanged = transactionChanged
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { EdgeTransaction } from 'edge-core-js/types';
|
|
2
|
-
import {
|
|
2
|
+
import { PluginInfo } from '../../../plugin/types';
|
|
3
3
|
import { UTXOPluginWalletTools } from '../../engine/makeUtxoWalletTools';
|
|
4
4
|
import { Processor } from '../makeProcessor';
|
|
5
5
|
import { IProcessorTransaction } from '../types';
|
|
6
6
|
export declare const fromEdgeTransaction: (tx: EdgeTransaction) => IProcessorTransaction;
|
|
7
7
|
interface ToEdgeTransactionArgs {
|
|
8
8
|
tx: IProcessorTransaction;
|
|
9
|
-
currencyCode: string;
|
|
10
9
|
walletTools: UTXOPluginWalletTools;
|
|
11
10
|
processor: Processor;
|
|
12
|
-
|
|
11
|
+
pluginInfo: PluginInfo;
|
|
13
12
|
}
|
|
14
13
|
export declare const toEdgeTransaction: (args: ToEdgeTransactionArgs) => Promise<EdgeTransaction>;
|
|
15
14
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "edge-currency-plugins",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.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",
|