@reality.eth/reality-eth-lib 3.2.44 → 3.2.46
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/formatters/question.js +7 -0
- package/package.json +3 -3
- package/test/formatters.js +10 -0
package/formatters/question.js
CHANGED
|
@@ -563,3 +563,10 @@ exports.answerHash = function(answer_plaintext, nonce) {
|
|
|
563
563
|
[ new BN(answer_plaintext.replace(/^0x/, ''), 16), new BN(nonce.replace(/^0x/, ''), 16)]
|
|
564
564
|
).toString('hex');
|
|
565
565
|
}
|
|
566
|
+
|
|
567
|
+
exports.shortDisplayQuestionID = function(question_id) {
|
|
568
|
+
// Question ID may or may not have the contract address prepended
|
|
569
|
+
const bits = question_id.split('-');
|
|
570
|
+
const qid = bits[bits.length-1];
|
|
571
|
+
return qid.substring(2,9) + '...' + qid.slice(-7);
|
|
572
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reality.eth/reality-eth-lib",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.46",
|
|
4
4
|
"description": "Tools for handling questions in the reality.eth fact verification platform",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "env TZ='Asia/Kabul' mocha ./test"
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"author": "Edmund Edgar (https://reality.eth.link)",
|
|
17
17
|
"license": "GPL-3.0",
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@reality.eth/contracts": "^3.0.
|
|
19
|
+
"@reality.eth/contracts": "^3.0.62",
|
|
20
20
|
"bignumber.js": "^7.2.1",
|
|
21
21
|
"bn.js": "^5.2.1",
|
|
22
22
|
"ethereumjs-abi": "^0.6.5",
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"url": "https://github.com/RealityETH/monorepo/issues"
|
|
40
40
|
},
|
|
41
41
|
"homepage": "https://reality.eth.link",
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "6f86d929c31197aa5c70afbc0648d96f5fa1b0f4"
|
|
43
43
|
}
|
package/test/formatters.js
CHANGED
|
@@ -386,6 +386,16 @@ describe('Question ID tests', function() {
|
|
|
386
386
|
|
|
387
387
|
});
|
|
388
388
|
|
|
389
|
+
describe('Short question ID tests', function() {
|
|
390
|
+
// First 7 characters of main ID (without prefixing contract address), "...", last 7 characters
|
|
391
|
+
const full_qid = '0xe78996a233895be74a66f451f1019ca9734205cc-0x2703ce72afee88da2cb1e7b405c6d5354af732d9893538f684083698763ef35a';
|
|
392
|
+
const normal_qid = '0x2703ce72afee88da2cb1e7b405c6d5354af732d9893538f684083698763ef35a';
|
|
393
|
+
const full_to_short = rc_question.shortDisplayQuestionID(full_qid);
|
|
394
|
+
const normal_to_short = rc_question.shortDisplayQuestionID(normal_qid);
|
|
395
|
+
expect(full_to_short).to.equal('2703ce7...63ef35a');
|
|
396
|
+
expect(normal_to_short).to.equal('2703ce7...63ef35a');
|
|
397
|
+
});
|
|
398
|
+
|
|
389
399
|
describe('Custom template handling', function() {
|
|
390
400
|
const example_template = '{"title": "%s", "dogs": "%s", "cats": "%s"}';
|
|
391
401
|
const example_template_arr = '{"title": "%s", "dogs": "%s", "cats": [%s], "ants": [%s]}';
|