@kleros/kleros-sdk 2.2.0 → 2.3.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.
- package/lib/src/dataMappings/utils/disputeDetailsSchema.d.ts +2 -2
- package/lib/src/dataMappings/utils/index.d.ts +1 -0
- package/lib/src/dataMappings/utils/index.js +3 -0
- package/lib/src/dataMappings/utils/populateTemplate.js +14 -5
- package/lib/src/dataMappings/utils/replacePlaceholdersWithValues.js +2 -1
- package/package.json +2 -2
|
@@ -89,13 +89,13 @@ declare const DisputeDetailsSchema: z.ZodObject<{
|
|
|
89
89
|
}, "strip", z.ZodTypeAny, {
|
|
90
90
|
description: string;
|
|
91
91
|
question: string;
|
|
92
|
+
title: string;
|
|
92
93
|
answers: {
|
|
93
94
|
id: string;
|
|
94
95
|
description: string;
|
|
95
96
|
title: string;
|
|
96
97
|
reserved?: boolean | undefined;
|
|
97
98
|
}[];
|
|
98
|
-
title: string;
|
|
99
99
|
policyURI: string;
|
|
100
100
|
arbitratorChainID: string;
|
|
101
101
|
arbitratorAddress: `0x${string}`;
|
|
@@ -113,13 +113,13 @@ declare const DisputeDetailsSchema: z.ZodObject<{
|
|
|
113
113
|
}, {
|
|
114
114
|
description: string;
|
|
115
115
|
question: string;
|
|
116
|
+
title: string;
|
|
116
117
|
answers: {
|
|
117
118
|
id: string;
|
|
118
119
|
description: string;
|
|
119
120
|
title: string;
|
|
120
121
|
reserved?: boolean | undefined;
|
|
121
122
|
}[];
|
|
122
|
-
title: string;
|
|
123
123
|
policyURI: string;
|
|
124
124
|
arbitratorChainID: string;
|
|
125
125
|
arbitratorAddress: string;
|
|
@@ -14,6 +14,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.isUndefined = void 0;
|
|
17
18
|
__exportStar(require("./populateTemplate"), exports);
|
|
18
19
|
__exportStar(require("./retrieveVariables"), exports);
|
|
19
20
|
__exportStar(require("./disputeDetailsTypes"), exports);
|
|
21
|
+
const isUndefined = (maybeObject) => typeof maybeObject === "undefined" || maybeObject === null;
|
|
22
|
+
exports.isUndefined = isUndefined;
|
|
@@ -36,10 +36,19 @@ const populateTemplate = (mustacheTemplate, data) => {
|
|
|
36
36
|
if (!validation.success) {
|
|
37
37
|
throw validation.error;
|
|
38
38
|
}
|
|
39
|
-
dispute
|
|
40
|
-
disputeDetailsSchema_1.RefuseToArbitrateAnswer,
|
|
41
|
-
...(dispute.answers.filter((answer) => answer.id && BigInt(answer.id) !== BigInt(0)) || []),
|
|
42
|
-
];
|
|
43
|
-
return dispute;
|
|
39
|
+
return findAndUpdateRTA(dispute);
|
|
44
40
|
};
|
|
45
41
|
exports.populateTemplate = populateTemplate;
|
|
42
|
+
const findAndUpdateRTA = (dispute) => {
|
|
43
|
+
const templateRTAIndex = dispute.answers.findIndex((answer) => answer.id && BigInt(answer.id) === BigInt(0));
|
|
44
|
+
if (templateRTAIndex !== -1) {
|
|
45
|
+
dispute.answers[templateRTAIndex] = {
|
|
46
|
+
...disputeDetailsSchema_1.RefuseToArbitrateAnswer,
|
|
47
|
+
description: dispute.answers[templateRTAIndex].description ?? disputeDetailsSchema_1.RefuseToArbitrateAnswer.description,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
dispute.answers = [disputeDetailsSchema_1.RefuseToArbitrateAnswer, ...dispute.answers];
|
|
52
|
+
}
|
|
53
|
+
return dispute;
|
|
54
|
+
};
|
|
@@ -7,6 +7,7 @@ exports.replacePlaceholdersWithValues = replacePlaceholdersWithValues;
|
|
|
7
7
|
const mustache_1 = __importDefault(require("mustache"));
|
|
8
8
|
const retrieveVariables_1 = __importDefault(require("./retrieveVariables"));
|
|
9
9
|
const errors_1 = require("../../errors");
|
|
10
|
+
const _1 = require(".");
|
|
10
11
|
function replacePlaceholdersWithValues(mapping, context) {
|
|
11
12
|
function replace(obj) {
|
|
12
13
|
if (typeof obj === "string") {
|
|
@@ -28,7 +29,7 @@ function replacePlaceholdersWithValues(mapping, context) {
|
|
|
28
29
|
const validateContext = (template, context) => {
|
|
29
30
|
const variables = (0, retrieveVariables_1.default)(template);
|
|
30
31
|
variables.forEach((variable) => {
|
|
31
|
-
if (
|
|
32
|
+
if ((0, _1.isUndefined)(context[variable]))
|
|
32
33
|
throw new errors_1.InvalidContextError(`Expected key "${variable}" to be provided in context.`);
|
|
33
34
|
});
|
|
34
35
|
return true;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kleros/kleros-sdk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "SDK for Kleros version 2",
|
|
5
5
|
"repository": "git@github.com:kleros/kleros-v2.git",
|
|
6
6
|
"homepage": "https://github.com/kleros/kleros-v2/tree/master/kleros-sdk#readme",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"vitest": "^1.6.0"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@reality.eth/reality-eth-lib": "^3.2.
|
|
46
|
+
"@reality.eth/reality-eth-lib": "^3.2.60",
|
|
47
47
|
"@urql/core": "^5.0.8",
|
|
48
48
|
"mustache": "^4.2.0",
|
|
49
49
|
"zod": "^3.23.8"
|