@reality.eth/reality-eth-lib 3.4.12 → 3.4.14
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 +3 -0
- package/package.json +3 -3
- package/test/formatters.js +14 -2
package/formatters/question.js
CHANGED
|
@@ -96,6 +96,9 @@ exports.arrayToBitmaskBigNumber = function(selections) {
|
|
|
96
96
|
|
|
97
97
|
exports.answerToBytes32 = function(answer, qjson) {
|
|
98
98
|
var qtype = qjson['type'];
|
|
99
|
+
if (qtype == 'hash') {
|
|
100
|
+
return module.exports.bytes32ToString(answer, qjson);
|
|
101
|
+
}
|
|
99
102
|
if (qtype == 'multiple-select') {
|
|
100
103
|
answer = module.exports.arrayToBitmaskBigNumber(answer);
|
|
101
104
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reality.eth/reality-eth-lib",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.14",
|
|
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.2.
|
|
19
|
+
"@reality.eth/contracts": "^3.2.12",
|
|
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": "f7ba43cc16293f7b170fbc6775ae2ea6558f2e5e"
|
|
43
43
|
}
|
package/test/formatters.js
CHANGED
|
@@ -36,6 +36,18 @@ describe('Answer formatting', function() {
|
|
|
36
36
|
expect(rc_question.answerToBytes32(1, q)).to.equal('0x0000000000000000000000000000000000000000000000000000000000000001');
|
|
37
37
|
expect(rc_question.answerToBytes32(0, q)).to.equal('0x0000000000000000000000000000000000000000000000000000000000000000');
|
|
38
38
|
});
|
|
39
|
+
it('Keeps hex as hex', function() {
|
|
40
|
+
var q = rc_question.populatedJSONForTemplate(rc_template.defaultTemplateForType('uint'), '');
|
|
41
|
+
q['type'] = 'hash';
|
|
42
|
+
//var q = rc_question.populatedJSONForTemplate(rc_template.defaultTemplateForType('hash'), '');
|
|
43
|
+
expect(rc_question.answerToBytes32("a", q)).to.equal('0x000000000000000000000000000000000000000000000000000000000000000a');
|
|
44
|
+
expect(rc_question.answerToBytes32("0xa", q)).to.equal('0x000000000000000000000000000000000000000000000000000000000000000a');
|
|
45
|
+
expect(rc_question.answerToBytes32("0", q)).to.equal('0x0000000000000000000000000000000000000000000000000000000000000000');
|
|
46
|
+
expect(rc_question.answerToBytes32("0x0", q)).to.equal('0x0000000000000000000000000000000000000000000000000000000000000000');
|
|
47
|
+
expect(rc_question.answerToBytes32("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd", q)).to.equal('0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd');
|
|
48
|
+
expect(rc_question.answerToBytes32("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffFD", q)).to.equal('0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd');
|
|
49
|
+
expect(rc_question.answerToBytes32("1", q)).to.equal('0x0000000000000000000000000000000000000000000000000000000000000001');
|
|
50
|
+
});
|
|
39
51
|
it('Turns options into hex', function() {
|
|
40
52
|
var outcomes = ['thing1', 'thing2', 'thing3'];
|
|
41
53
|
var qtext = rc_question.encodeText('multiple-select', 'oink', outcomes, 'my-category');
|
|
@@ -99,7 +111,6 @@ describe('Answer strings', function() {
|
|
|
99
111
|
expect(rc_question.getAnswerString(q, '0x0000000000000000000000000000000000000000000000001BC16D674EC80000')).to.equal('2');
|
|
100
112
|
});
|
|
101
113
|
|
|
102
|
-
/*
|
|
103
114
|
it('Leaves bytes32 strings unchanged except forced to lower case', function() {
|
|
104
115
|
// We don't have a built-in type for this yet so just switch out the uint one
|
|
105
116
|
var q = rc_question.populatedJSONForTemplate(rc_template.defaultTemplateForType('uint'), '');
|
|
@@ -109,8 +120,9 @@ describe('Answer strings', function() {
|
|
|
109
120
|
expect(rc_question.getAnswerString(q, '0x0000000000000000000000000000000000000000000000000de0b6b3a7640000')).to.equal('0x0000000000000000000000000000000000000000000000000de0b6b3a7640000');
|
|
110
121
|
expect(rc_question.getAnswerString(q, '0x0000000000000000000000000000000000000000000000001BC16D674EC80000')).to.equal('0x0000000000000000000000000000000000000000000000001BC16D674EC80000'.toLowerCase());
|
|
111
122
|
expect(rc_question.getAnswerString(q, '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff')).to.equal('Invalid');
|
|
123
|
+
expect(rc_question.getAnswerString(q, '0xa')).to.equal('0x000000000000000000000000000000000000000000000000000000000000000a');
|
|
124
|
+
expect(rc_question.getAnswerString(q, 'a')).to.equal('0x000000000000000000000000000000000000000000000000000000000000000a');
|
|
112
125
|
});
|
|
113
|
-
*/
|
|
114
126
|
|
|
115
127
|
|
|
116
128
|
/*
|