edge-currency-plugins 1.1.5 → 1.1.6
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,5 @@
|
|
|
1
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(); } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await 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 _biggystring = require('biggystring');
|
|
2
|
+
var _cleaners = require('cleaners');
|
|
2
3
|
|
|
3
4
|
|
|
4
5
|
|
|
@@ -1109,6 +1110,42 @@ const processTransactionResponse = (
|
|
|
1109
1110
|
txResponse,
|
|
1110
1111
|
pluginInfo: { coinInfo }
|
|
1111
1112
|
} = args
|
|
1113
|
+
const inputs = txResponse.vin.map(vin => {
|
|
1114
|
+
const scriptPubkey =
|
|
1115
|
+
// Note: Blockbook has empirically not sent a hex value as the
|
|
1116
|
+
// scriptPubkey for vins. If we discover this to be changed for some
|
|
1117
|
+
// cases, we may want to use the `hex` field as an optimization.
|
|
1118
|
+
_cleaners.asMaybe.call(void 0,
|
|
1119
|
+
raw => _utils3.validScriptPubkeyFromAddress.call(void 0, raw),
|
|
1120
|
+
'unknown'
|
|
1121
|
+
)({
|
|
1122
|
+
address: vin.addresses[0],
|
|
1123
|
+
coin: coinInfo.name
|
|
1124
|
+
})
|
|
1125
|
+
return {
|
|
1126
|
+
txId: vin.txid,
|
|
1127
|
+
outputIndex: vin.vout, // case for tx `fefac8c22ba1178df5d7c90b78cc1c203d1a9f5f5506f7b8f6f469fa821c2674` no `vout` for input
|
|
1128
|
+
n: vin.n,
|
|
1129
|
+
scriptPubkey,
|
|
1130
|
+
amount: vin.value
|
|
1131
|
+
}
|
|
1132
|
+
})
|
|
1133
|
+
const outputs = txResponse.vout.map(vout => {
|
|
1134
|
+
const scriptPubkey =
|
|
1135
|
+
_nullishCoalesce(vout.hex, () => (
|
|
1136
|
+
_cleaners.asMaybe.call(void 0,
|
|
1137
|
+
raw => _utils3.validScriptPubkeyFromAddress.call(void 0, raw),
|
|
1138
|
+
'unknown'
|
|
1139
|
+
)({
|
|
1140
|
+
address: vout.addresses[0],
|
|
1141
|
+
coin: coinInfo.name
|
|
1142
|
+
})))
|
|
1143
|
+
return {
|
|
1144
|
+
n: vout.n,
|
|
1145
|
+
scriptPubkey,
|
|
1146
|
+
amount: vout.value
|
|
1147
|
+
}
|
|
1148
|
+
})
|
|
1112
1149
|
return {
|
|
1113
1150
|
txid: txResponse.txid,
|
|
1114
1151
|
hex: txResponse.hex,
|
|
@@ -1116,26 +1153,8 @@ const processTransactionResponse = (
|
|
|
1116
1153
|
blockHeight: txResponse.blockHeight > 0 ? txResponse.blockHeight : 0,
|
|
1117
1154
|
date: txResponse.blockTime,
|
|
1118
1155
|
fees: txResponse.fees,
|
|
1119
|
-
inputs
|
|
1120
|
-
|
|
1121
|
-
outputIndex: input.vout, // case for tx `fefac8c22ba1178df5d7c90b78cc1c203d1a9f5f5506f7b8f6f469fa821c2674` no `vout` for input
|
|
1122
|
-
n: input.n,
|
|
1123
|
-
scriptPubkey: _utils3.validScriptPubkeyFromAddress.call(void 0, {
|
|
1124
|
-
address: input.addresses[0],
|
|
1125
|
-
coin: coinInfo.name
|
|
1126
|
-
}),
|
|
1127
|
-
amount: input.value
|
|
1128
|
-
})),
|
|
1129
|
-
outputs: txResponse.vout.map(output => ({
|
|
1130
|
-
n: output.n,
|
|
1131
|
-
scriptPubkey:
|
|
1132
|
-
_nullishCoalesce(output.hex, () => (
|
|
1133
|
-
_utils3.validScriptPubkeyFromAddress.call(void 0, {
|
|
1134
|
-
address: output.addresses[0],
|
|
1135
|
-
coin: coinInfo.name
|
|
1136
|
-
}))),
|
|
1137
|
-
amount: output.value
|
|
1138
|
-
})),
|
|
1156
|
+
inputs,
|
|
1157
|
+
outputs,
|
|
1139
1158
|
ourIns: [],
|
|
1140
1159
|
ourOuts: [],
|
|
1141
1160
|
ourAmount: '0'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "edge-currency-plugins",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.6",
|
|
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",
|