@witnet/sdk 1.0.1 → 1.0.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.
- package/dist/package.json +1 -1
- package/dist/src/bin/helpers.js +2 -2
- package/dist/src/lib/crypto/payloads/DataRequestPayload.d.ts +2 -2
- package/dist/src/lib/crypto/payloads/DataRequestPayload.d.ts.map +1 -1
- package/dist/src/lib/crypto/payloads/DataRequestPayload.js +8 -8
- package/dist/src/lib/crypto/transmitters/DataRequests.d.ts +0 -1
- package/dist/src/lib/crypto/transmitters/DataRequests.d.ts.map +1 -1
- package/dist/src/lib/crypto/transmitters/DataRequests.js +1 -2
- package/dist/src/lib/radon/ccdr/wit.d.ts +11 -0
- package/dist/src/lib/radon/ccdr/wit.d.ts.map +1 -1
- package/dist/src/lib/radon/ccdr/wit.js +17 -2
- package/dist/src/lib/radon/index.d.ts +1 -1
- package/dist/src/lib/radon/index.d.ts.map +1 -1
- package/dist/src/lib/radon/index.js +9 -3
- package/dist/src/lib/rpc/provider.d.ts +5 -3
- package/dist/src/lib/rpc/provider.d.ts.map +1 -1
- package/dist/src/lib/rpc/provider.js +14 -3
- package/dist/src/lib/rpc/reporter.d.ts +2 -3
- package/dist/src/lib/rpc/reporter.d.ts.map +1 -1
- package/dist/src/lib/rpc/reporter.js +1 -4
- package/dist/src/lib/rpc/types.d.ts +49 -24
- package/dist/src/lib/rpc/types.d.ts.map +1 -1
- package/dist/src/lib/rpc/types.js +3 -1
- package/dist/src/lib/types.d.ts +1 -1
- package/dist/src/lib/types.d.ts.map +1 -1
- package/dist/src/lib/types.js +1 -1
- package/dist/witnet/assets/modals/web3/wit.js +4 -7
- package/package.json +1 -1
- package/src/bin/cli/inspect.js +49 -3
- package/src/bin/cli/network.js +9 -7
- package/src/bin/cli/wallet.js +40 -17
- package/src/bin/helpers.js +1 -1
- package/witnet/assets/modals/web3/wit.js +2 -4
package/dist/src/lib/types.js
CHANGED
|
@@ -4,4 +4,4 @@ exports.StakingCapability = exports.StakesOrderBy = void 0;
|
|
|
4
4
|
var types_1 = require("./rpc/types");
|
|
5
5
|
Object.defineProperty(exports, "StakesOrderBy", { enumerable: true, get: function () { return types_1.StakesOrderBy; } });
|
|
6
6
|
Object.defineProperty(exports, "StakingCapability", { enumerable: true, get: function () { return types_1.StakingCapability; } });
|
|
7
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
7
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvbGliL3R5cGVzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUlBLHFDQWVvQjtBQU5oQixzR0FBQSxhQUFhLE9BQUE7QUFDYiwwR0FBQSxpQkFBaUIsT0FBQSIsInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCB7IElKc29uUnBjTm9kZUZhcm0gfSBmcm9tIFwiLi9ycGMvbm9kZXNcIlxyXG5leHBvcnQgeyBJSnNvblJwY1Byb3ZpZGVyIH0gZnJvbSBcIi4vcnBjL3Byb3ZpZGVyXCJcclxuZXhwb3J0IHsgSVJlcG9ydGVyIH0gZnJvbSBcIi4vcnBjL3JlcG9ydGVyXCJcclxuXHJcbmV4cG9ydCB7IFxyXG4gICAgQmFsYW5jZTIgYXMgQmFsYW5jZSwgXHJcbiAgICBCbG9jaywgXHJcbiAgICBCbG9ja1RyYW5zYWN0aW9uc0hhc2hlcyxcclxuICAgIENvbnNlbnN1c0NvbnN0YW50cyxcclxuICAgIE5ldHdvcmssXHJcbiAgICBQcmlvcml0aWVzIGFzIE5ldHdvcmtQcmlvcml0aWVzLFxyXG4gICAgUXVlcnlTdGFrZXNPcmRlcixcclxuICAgIFN0YWtlRW50cnksXHJcbiAgICBTdGFrZXNPcmRlckJ5LFxyXG4gICAgU3Rha2luZ0NhcGFiaWxpdHksXHJcbiAgICBTeW5jU3RhdHVzLCBcclxuICAgIFRyYW5zYWN0aW9uUmVwb3J0LFxyXG4gICAgVXR4b01ldGFkYXRhLFxyXG4gICAgVmFsdWVUcmFuc2Zlck91dHB1dCxcclxufSBmcm9tIFwiLi9ycGMvdHlwZXNcIlxyXG5cclxuZXhwb3J0IHR5cGUgZjY0ID0gbnVtYmVyO1xyXG5leHBvcnQgdHlwZSBpMzIgPSBudW1iZXI7XHJcbmV4cG9ydCB0eXBlIGk2NCA9IG51bWJlcjtcclxuZXhwb3J0IHR5cGUgdTggPSBudW1iZXI7XHJcbmV4cG9ydCB0eXBlIHUxNiA9IG51bWJlcjtcclxuZXhwb3J0IHR5cGUgdTMyID0gbnVtYmVyO1xyXG5leHBvcnQgdHlwZSB1NjQgPSBudW1iZXI7XHJcbmV4cG9ydCB0eXBlIHVzaXplID0gbnVtYmVyO1xyXG5cclxuZXhwb3J0IHR5cGUgRXBvY2ggPSBpMzI7XHJcbmV4cG9ydCB0eXBlIEVyciA9IHN0cmluZztcclxuZXhwb3J0IHR5cGUgSGFzaCA9IHN0cmluZztcclxuZXhwb3J0IHR5cGUgSGV4U3RyaW5nID0gc3RyaW5nO1xyXG5leHBvcnQgdHlwZSBOb25jZSA9IHU2NDtcclxuIl19
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const { RadonModal, RadonScript,
|
|
3
|
-
// filters,
|
|
4
|
-
// reducers,
|
|
5
|
-
retrievals, types, } = require("../../../../src/lib/radon");
|
|
2
|
+
const { RadonModal, RadonScript, retrievals, types, } = require("../../../../src/lib/radon");
|
|
6
3
|
module.exports = {
|
|
7
4
|
WitOracleWitGetBalance: new RadonModal({
|
|
8
5
|
retrieval: retrievals.JsonRPC({
|
|
@@ -12,9 +9,9 @@ module.exports = {
|
|
|
12
9
|
}),
|
|
13
10
|
WitOracleWitGetValueTransfer: new RadonModal({
|
|
14
11
|
retrieval: retrievals.JsonRPC({
|
|
15
|
-
rpc: retrievals.rpc.wit.
|
|
16
|
-
script: RadonScript(types.RadonString).parseJSONMap().getMap("result").getMap("
|
|
12
|
+
rpc: retrievals.rpc.wit.getValueTransfer("\\1\\", "\\2\\"),
|
|
13
|
+
script: RadonScript(types.RadonString).parseJSONMap().getMap("result").getMap("\\2\\").values(),
|
|
17
14
|
}),
|
|
18
15
|
}),
|
|
19
16
|
};
|
|
20
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
17
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoid2l0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vd2l0bmV0L2Fzc2V0cy9tb2RhbHMvd2ViMy93aXQuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLE1BQU0sRUFDSixVQUFVLEVBQ1YsV0FBVyxFQUNYLFVBQVUsRUFDVixLQUFLLEdBQ04sR0FBRyxPQUFPLENBQUMsMkJBQTJCLENBQUMsQ0FBQTtBQUV4QyxNQUFNLENBQUMsT0FBTyxHQUFHO0lBQ2Ysc0JBQXNCLEVBQUUsSUFBSSxVQUFVLENBQUM7UUFDckMsU0FBUyxFQUFFLFVBQVUsQ0FBQyxPQUFPLENBQUM7WUFDNUIsR0FBRyxFQUFFLFVBQVUsQ0FBQyxHQUFHLENBQUMsR0FBRyxDQUFDLFVBQVUsQ0FBQyxPQUFPLENBQUM7WUFDM0MsTUFBTSxFQUFFLFdBQVcsQ0FBQyxLQUFLLENBQUMsV0FBVyxDQUFDLENBQUMsWUFBWSxFQUFFLENBQUMsTUFBTSxDQUFDLFFBQVEsQ0FBQyxDQUFDLE1BQU0sRUFBRTtTQUNoRixDQUFDO0tBQ0gsQ0FBQztJQUNGLDRCQUE0QixFQUFFLElBQUksVUFBVSxDQUFDO1FBQzNDLFNBQVMsRUFBRSxVQUFVLENBQUMsT0FBTyxDQUFDO1lBQzVCLEdBQUcsRUFBRSxVQUFVLENBQUMsR0FBRyxDQUFDLEdBQUcsQ0FBQyxnQkFBZ0IsQ0FBQyxPQUFPLEVBQUUsT0FBTyxDQUFDO1lBQzFELE1BQU0sRUFBRSxXQUFXLENBQUMsS0FBSyxDQUFDLFdBQVcsQ0FBQyxDQUFDLFlBQVksRUFBRSxDQUFDLE1BQU0sQ0FBQyxRQUFRLENBQUMsQ0FBQyxNQUFNLENBQUMsT0FBTyxDQUFDLENBQUMsTUFBTSxFQUFFO1NBQ2hHLENBQUM7S0FDSCxDQUFDO0NBQ0gsQ0FBQSIsInNvdXJjZXNDb250ZW50IjpbImNvbnN0IHtcclxuICBSYWRvbk1vZGFsLFxyXG4gIFJhZG9uU2NyaXB0LFxyXG4gIHJldHJpZXZhbHMsXHJcbiAgdHlwZXMsXHJcbn0gPSByZXF1aXJlKFwiLi4vLi4vLi4vLi4vc3JjL2xpYi9yYWRvblwiKVxyXG5cclxubW9kdWxlLmV4cG9ydHMgPSB7XHJcbiAgV2l0T3JhY2xlV2l0R2V0QmFsYW5jZTogbmV3IFJhZG9uTW9kYWwoe1xyXG4gICAgcmV0cmlldmFsOiByZXRyaWV2YWxzLkpzb25SUEMoe1xyXG4gICAgICBycGM6IHJldHJpZXZhbHMucnBjLndpdC5nZXRCYWxhbmNlKFwiXFxcXDFcXFxcXCIpLFxyXG4gICAgICBzY3JpcHQ6IFJhZG9uU2NyaXB0KHR5cGVzLlJhZG9uU3RyaW5nKS5wYXJzZUpTT05NYXAoKS5nZXRNYXAoXCJyZXN1bHRcIikudmFsdWVzKCksXHJcbiAgICB9KSxcclxuICB9KSxcclxuICBXaXRPcmFjbGVXaXRHZXRWYWx1ZVRyYW5zZmVyOiBuZXcgUmFkb25Nb2RhbCh7XHJcbiAgICByZXRyaWV2YWw6IHJldHJpZXZhbHMuSnNvblJQQyh7XHJcbiAgICAgIHJwYzogcmV0cmlldmFscy5ycGMud2l0LmdldFZhbHVlVHJhbnNmZXIoXCJcXFxcMVxcXFxcIiwgXCJcXFxcMlxcXFxcIiksXHJcbiAgICAgIHNjcmlwdDogUmFkb25TY3JpcHQodHlwZXMuUmFkb25TdHJpbmcpLnBhcnNlSlNPTk1hcCgpLmdldE1hcChcInJlc3VsdFwiKS5nZXRNYXAoXCJcXFxcMlxcXFxcIikudmFsdWVzKCksXHJcbiAgICB9KSxcclxuICB9KSxcclxufVxyXG4iXX0=
|
package/package.json
CHANGED
package/src/bin/cli/inspect.js
CHANGED
|
@@ -31,8 +31,17 @@ module.exports = {
|
|
|
31
31
|
params: "BLOCK_HASH",
|
|
32
32
|
},
|
|
33
33
|
dataRequest: {
|
|
34
|
-
hint: "
|
|
34
|
+
hint: "Get query parameters and result to some data request transaction.",
|
|
35
35
|
params: "DR_TX_HASH",
|
|
36
|
+
options: {
|
|
37
|
+
force: {
|
|
38
|
+
hint: "Get data even if the WIT/RPC provider is not synced."
|
|
39
|
+
},
|
|
40
|
+
mode: {
|
|
41
|
+
hint: "Possible report formats (default: `ethereal`).",
|
|
42
|
+
param: "`ethereal` | `full``",
|
|
43
|
+
},
|
|
44
|
+
},
|
|
36
45
|
},
|
|
37
46
|
"dataRequests*": {
|
|
38
47
|
hint: "Search for in-flight or recently solved data request transactions.",
|
|
@@ -65,6 +74,19 @@ module.exports = {
|
|
|
65
74
|
hint: "List validators treasuring delegated stake from the specified address.",
|
|
66
75
|
params: "WIT_ADDRESS",
|
|
67
76
|
},
|
|
77
|
+
valueTransfer: {
|
|
78
|
+
hint: "Report value transfer details given its transaction hash.",
|
|
79
|
+
params: "VT_TX_HASH",
|
|
80
|
+
options: {
|
|
81
|
+
force: {
|
|
82
|
+
hint: "Get data even if the WIT/RPC provider is not synced."
|
|
83
|
+
},
|
|
84
|
+
mode: {
|
|
85
|
+
hint: "Possible report formats (default: `full`).",
|
|
86
|
+
param: "`ethereal` | `full` | `simple`",
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
},
|
|
68
90
|
withdrawers: {
|
|
69
91
|
hint: "List withdrawers currently delegating stake to the specified address.",
|
|
70
92
|
params: "WIT_ADDRESS",
|
|
@@ -80,7 +102,7 @@ module.exports = {
|
|
|
80
102
|
},
|
|
81
103
|
},
|
|
82
104
|
subcommands: {
|
|
83
|
-
balance, block, dataRequest, superblock, transaction, validators, withdrawers, utxos,
|
|
105
|
+
balance, block, dataRequest, superblock, transaction, validators, withdrawers, utxos, valueTransfer,
|
|
84
106
|
},
|
|
85
107
|
}
|
|
86
108
|
|
|
@@ -166,7 +188,12 @@ async function dataRequest (options = {}, args = []) {
|
|
|
166
188
|
}
|
|
167
189
|
}
|
|
168
190
|
|
|
169
|
-
const
|
|
191
|
+
const mode = options?.mode || `ethereal`
|
|
192
|
+
if (!["ethereal", "full"].includes(mode)) {
|
|
193
|
+
throw Error(`Invalid mode value: "${options.mode}"`)
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const report = await provider.getDataRequest(drTxHash, mode, options?.force)
|
|
170
197
|
console.info(JSON.stringify(report, drTxJsonReplacer, 4))
|
|
171
198
|
}
|
|
172
199
|
|
|
@@ -296,6 +323,25 @@ async function validators (options = {}, args = []) {
|
|
|
296
323
|
}
|
|
297
324
|
}
|
|
298
325
|
|
|
326
|
+
async function valueTransfer (options = {}, args = []) {
|
|
327
|
+
if (args.length === 0) {
|
|
328
|
+
throw Error("No VT_TX_HASH was specified")
|
|
329
|
+
}
|
|
330
|
+
const txHash = args[0].startsWith("0x") ? args[0].slice(2) : args[0]
|
|
331
|
+
if (!helpers.isHexString(txHash)) {
|
|
332
|
+
throw Error("Invalid VT_TX_HASH was provided")
|
|
333
|
+
}
|
|
334
|
+
const mode = options?.mode || `full`
|
|
335
|
+
if (!["ethereal", "full", "simple"].includes(mode)) {
|
|
336
|
+
throw Error(`Invalid mode value: "${options.mode}"`)
|
|
337
|
+
}
|
|
338
|
+
const provider = new Witnet.JsonRpcProvider(options?.provider)
|
|
339
|
+
const transaction = await provider.getValueTransfer(txHash, mode, options?.force)
|
|
340
|
+
console.info(
|
|
341
|
+
`${yellow(JSON.stringify(transaction, utils.txJsonReplacer, 2))}`
|
|
342
|
+
)
|
|
343
|
+
}
|
|
344
|
+
|
|
299
345
|
async function withdrawers (options = {}, args = []) {
|
|
300
346
|
if (args.length === 0) {
|
|
301
347
|
throw Error("No WIT_ADDRESS was specified")
|
package/src/bin/cli/network.js
CHANGED
|
@@ -114,12 +114,12 @@ module.exports = {
|
|
|
114
114
|
"stats*": {
|
|
115
115
|
hint: "Report network stats.",
|
|
116
116
|
},
|
|
117
|
+
status: {
|
|
118
|
+
hint: "Report the sync status of the network's Wit/Oracle RPC provider being used.",
|
|
119
|
+
},
|
|
117
120
|
supplyInfo: {
|
|
118
121
|
hint: "Get network's Wit supply information.",
|
|
119
122
|
},
|
|
120
|
-
syncStatus: {
|
|
121
|
-
hint: "Report the sync status of the network's Wit/Oracle RPC provider being used.",
|
|
122
|
-
},
|
|
123
123
|
versions: {
|
|
124
124
|
hint: "List known protocol versions and which one is currently live.",
|
|
125
125
|
},
|
|
@@ -142,7 +142,7 @@ module.exports = {
|
|
|
142
142
|
senate,
|
|
143
143
|
stakes,
|
|
144
144
|
supplyInfo,
|
|
145
|
-
syncStatus,
|
|
145
|
+
status: syncStatus,
|
|
146
146
|
versions,
|
|
147
147
|
wips,
|
|
148
148
|
},
|
|
@@ -483,23 +483,25 @@ async function supplyInfo (options = {}) {
|
|
|
483
483
|
}
|
|
484
484
|
|
|
485
485
|
async function syncStatus (options = {}) {
|
|
486
|
-
const provider =
|
|
486
|
+
const provider = await Witnet.JsonRpcProvider.fromEnv(options?.provider)
|
|
487
487
|
const syncStatus = await provider.syncStatus()
|
|
488
488
|
helpers.traceTable(
|
|
489
489
|
[[
|
|
490
|
+
provider.network === "mainnet" ? "Mainnet" : `Testnet (${provider.networkId.toString(16).toUpperCase()})`,
|
|
490
491
|
syncStatus.node_state || "",
|
|
491
492
|
syncStatus.current_epoch,
|
|
492
493
|
syncStatus.chain_beacon.checkpoint,
|
|
493
494
|
syncStatus.chain_beacon.hashPrevBlock,
|
|
494
495
|
]], {
|
|
495
496
|
headlines: [
|
|
497
|
+
"NETWORK",
|
|
496
498
|
":STATUS",
|
|
497
499
|
"Current epoch",
|
|
498
500
|
"Checkpoint epoch",
|
|
499
501
|
"Checkpoint block hash",
|
|
500
502
|
],
|
|
501
|
-
humanizers: [
|
|
502
|
-
colors: [helpers.colors.mgreen, helpers.colors.white,, helpers.colors.gray],
|
|
503
|
+
humanizers: [,, helpers.commas, helpers.commas],
|
|
504
|
+
colors: [helpers.colors.mgreen, helpers.colors.lgreen, helpers.colors.white,, helpers.colors.gray],
|
|
503
505
|
},
|
|
504
506
|
)
|
|
505
507
|
}
|
package/src/bin/cli/wallet.js
CHANGED
|
@@ -176,6 +176,10 @@ module.exports = {
|
|
|
176
176
|
hint: "Recipient address.",
|
|
177
177
|
param: "WIT_ADDRESS",
|
|
178
178
|
},
|
|
179
|
+
metadata: {
|
|
180
|
+
hint: "Optional 20-byte metadata info.",
|
|
181
|
+
param: "HEX_STRING"
|
|
182
|
+
},
|
|
179
183
|
value: {
|
|
180
184
|
hint: "Amount in Wits to be transfered (e.g. `0.5` Wits).",
|
|
181
185
|
param: "WITS | `all`",
|
|
@@ -191,6 +195,10 @@ module.exports = {
|
|
|
191
195
|
param: "WALLET_ADDRESS",
|
|
192
196
|
},
|
|
193
197
|
join: { hint: "Join selected UTXOs together into a single UTXO (requires --value)." },
|
|
198
|
+
limit: {
|
|
199
|
+
hint: "Max number of HD-accounts to derive.",
|
|
200
|
+
param: "LIMIT",
|
|
201
|
+
},
|
|
194
202
|
splits: {
|
|
195
203
|
hint: "Number of UTXOs to split the target balance into (max: 50; requires --value).",
|
|
196
204
|
param: "NUMBER",
|
|
@@ -610,15 +618,26 @@ async function transfer (options = {}) {
|
|
|
610
618
|
available = balance.unlocked
|
|
611
619
|
}
|
|
612
620
|
|
|
621
|
+
// validate metadata info, if specified
|
|
622
|
+
let metadata
|
|
623
|
+
if (options?.metadata) {
|
|
624
|
+
if (!utils.isHexStringOfLength(options.metadata, 20)) {
|
|
625
|
+
throw Error(`--metadata must be a 20-byte hex string`)
|
|
626
|
+
}
|
|
627
|
+
metadata = Witnet.PublicKeyHash.fromHexString(options.metadata).toBech32(wallet.network)
|
|
628
|
+
}
|
|
629
|
+
|
|
613
630
|
// validate recipient address
|
|
614
631
|
if (!options?.into) {
|
|
615
632
|
throw Error("--into address must be specified")
|
|
616
633
|
}
|
|
617
634
|
const into = Witnet.PublicKeyHash.fromBech32(options?.into).toBech32(wallet.network)
|
|
618
|
-
|
|
635
|
+
|
|
619
636
|
// determine transfer params
|
|
620
637
|
const params = await _loadTransactionParams({ ...options })
|
|
621
|
-
const coins = params?.value === "all"
|
|
638
|
+
const coins = params?.value === "all"
|
|
639
|
+
? Witnet.Coins.fromPedros(BigInt(available - params.fees.pedros - BigInt(options?.metadata ? 1: 0)))
|
|
640
|
+
: Witnet.Coins.fromWits(params?.value)
|
|
622
641
|
if (available < coins.pedros) {
|
|
623
642
|
throw Error(`Insufficient funds ${options?.from ? `on address ${options.from}.` : "on wallet."}`)
|
|
624
643
|
} else if (params?.fees && coins.pedros <= params.fees.pedros) {
|
|
@@ -626,12 +645,15 @@ async function transfer (options = {}) {
|
|
|
626
645
|
}
|
|
627
646
|
|
|
628
647
|
// transfer value
|
|
648
|
+
const recipients = options?.metadata
|
|
649
|
+
? [[into, coins], [metadata, Witnet.Coins.fromPedros(1n)]]
|
|
650
|
+
: [[into, coins]]
|
|
629
651
|
await helpers.traceTransaction(
|
|
630
652
|
Witnet.ValueTransfers.from(ledger), {
|
|
631
653
|
headline: "VALUE TRANSFER TRANSACTION",
|
|
632
654
|
color: colors.bblue,
|
|
633
655
|
...params,
|
|
634
|
-
recipients
|
|
656
|
+
recipients,
|
|
635
657
|
}
|
|
636
658
|
)
|
|
637
659
|
}
|
|
@@ -785,9 +807,10 @@ async function utxos (options = {}) {
|
|
|
785
807
|
}
|
|
786
808
|
const utxos = await ledger.selectUtxos({ value })
|
|
787
809
|
const covered = utxos.map(utxo => BigInt(utxo.value))?.reduce((prev, curr) => prev + curr, 0n) || 0n
|
|
788
|
-
if (value && covered < value.pedros) {
|
|
789
|
-
|
|
790
|
-
}
|
|
810
|
+
// if (value && covered < value.pedros) {
|
|
811
|
+
// console.log(value, covered)
|
|
812
|
+
// throw Error(`Insufficient unlocked UTXOs in ${options?.from ? `wallet account ${ledger.pkh}` : "wallet"}`)
|
|
813
|
+
// }
|
|
791
814
|
|
|
792
815
|
// only if at least one utxo is selected, proceed with report and other operations, if any
|
|
793
816
|
if (utxos.length > 0) {
|
|
@@ -816,7 +839,7 @@ async function utxos (options = {}) {
|
|
|
816
839
|
value,
|
|
817
840
|
]]
|
|
818
841
|
await helpers.traceTransaction(valueTransfer, {
|
|
819
|
-
headline: `JOINING UTXOs: ${utxos.length} -> ${
|
|
842
|
+
headline: `JOINING UTXOs: ${utxos.length} -> ${value.pedros < covered ? 2 : 1}`,
|
|
820
843
|
...params,
|
|
821
844
|
await: params?.await || options?.splits !== undefined,
|
|
822
845
|
recipients,
|
|
@@ -828,11 +851,11 @@ async function utxos (options = {}) {
|
|
|
828
851
|
if (splits > 50) {
|
|
829
852
|
throw Error("Not possible to split into more than 50 UTXOs")
|
|
830
853
|
}
|
|
831
|
-
value = Witnet.Coins.fromPedros(BigInt(Math.floor(value.pedros / splits)))
|
|
832
|
-
recipients.push(...Array(splits).fill([into,
|
|
854
|
+
value = Witnet.Coins.fromPedros(BigInt(Math.floor(Number(value.pedros) / splits)))
|
|
855
|
+
recipients.push(...Array(splits).fill([into, value]))
|
|
833
856
|
await helpers.traceTransaction(
|
|
834
857
|
valueTransfer, {
|
|
835
|
-
headline: `SPLITTING UTXOs: ${utxos.length} -> ${
|
|
858
|
+
headline: `SPLITTING UTXOs: ${utxos.length} -> ${Number(value.pedros) * splits < covered ? splits + 1 : splits}`,
|
|
836
859
|
...params,
|
|
837
860
|
recipients,
|
|
838
861
|
reload: options?.join,
|
|
@@ -908,16 +931,16 @@ async function validators (options = {}) {
|
|
|
908
931
|
|
|
909
932
|
async function _loadRadonRequest (options = {}) {
|
|
910
933
|
const args = options?.args || []
|
|
911
|
-
|
|
934
|
+
if (options?.pattern && typeof options.pattern === 'string' && utils.isHexString(options.pattern)) {
|
|
912
935
|
// if (options?.pattern && typeof options.pattern === 'string' && utils.isHexString(options.pattern)) {
|
|
913
936
|
// if (utils.isHexStringOfLength(options.pattern, 32)) {
|
|
914
937
|
// throw `Searching RADON_BYTECODE by RAD_HASH not yet supported.`
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
938
|
+
try {
|
|
939
|
+
return Witnet.Radon.RadonRequest.fromBytecode(options.pattern)
|
|
940
|
+
} catch (e) {
|
|
941
|
+
throw Error(`Invalid RADON_BYTECODE: ${e}`)
|
|
942
|
+
}
|
|
943
|
+
}
|
|
921
944
|
|
|
922
945
|
// load Radon assets from environment
|
|
923
946
|
let assets = utils.searchRadonAssets(
|
package/src/bin/helpers.js
CHANGED
|
@@ -347,7 +347,7 @@ function showVersion () {
|
|
|
347
347
|
|
|
348
348
|
function getWildcardsCountFromString (str) {
|
|
349
349
|
let maxArgsIndex = 0
|
|
350
|
-
if (str) {
|
|
350
|
+
if (str && typeof str === 'string') {
|
|
351
351
|
let match
|
|
352
352
|
const regexp = /\\\d\\/g
|
|
353
353
|
while ((match = regexp.exec(str)) !== null) {
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
const {
|
|
2
2
|
RadonModal,
|
|
3
3
|
RadonScript,
|
|
4
|
-
// filters,
|
|
5
|
-
// reducers,
|
|
6
4
|
retrievals,
|
|
7
5
|
types,
|
|
8
6
|
} = require("../../../../src/lib/radon")
|
|
@@ -16,8 +14,8 @@ module.exports = {
|
|
|
16
14
|
}),
|
|
17
15
|
WitOracleWitGetValueTransfer: new RadonModal({
|
|
18
16
|
retrieval: retrievals.JsonRPC({
|
|
19
|
-
rpc: retrievals.rpc.wit.
|
|
20
|
-
script: RadonScript(types.RadonString).parseJSONMap().getMap("result").getMap("
|
|
17
|
+
rpc: retrievals.rpc.wit.getValueTransfer("\\1\\", "\\2\\"),
|
|
18
|
+
script: RadonScript(types.RadonString).parseJSONMap().getMap("result").getMap("\\2\\").values(),
|
|
21
19
|
}),
|
|
22
20
|
}),
|
|
23
21
|
}
|