@kleros/kleros-sdk 2.3.1 → 2.4.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/CHANGELOG.md ADDED
@@ -0,0 +1,13 @@
1
+ # Changelog
2
+
3
+ All notable changes to this package will be documented in this file.
4
+
5
+ The format is based on [Common Changelog](https://common-changelog.org/).
6
+
7
+ ## [2.4.0] - 2026-01-09
8
+
9
+ ### Added
10
+
11
+ - Add optional field `extraEvidences` to the dispute details model to allow some arbitrable events to be rendered as evidence. ([#2210](https://github.com/kleros/kleros-v2/pull/2210))
12
+
13
+ [2.4.0]: https://github.com/kleros/kleros-v2/releases/tag/%40kleros%2Fkleros-%402.4.0
@@ -18,6 +18,7 @@ const callAction = async (mapping) => {
18
18
  functionName,
19
19
  args,
20
20
  });
21
- return (0, createResultObject_1.createResultObject)(data, seek, populate);
21
+ const sourceData = typeof data !== "object" ? { value: data } : data;
22
+ return (0, createResultObject_1.createResultObject)(sourceData, seek, populate);
22
23
  };
23
24
  exports.callAction = callAction;
@@ -5,6 +5,7 @@ export declare const isMultiaddr: (str: string) => boolean;
5
5
  export declare const ethAddressSchema: z.ZodEffects<z.ZodString, `0x${string}`, string>;
6
6
  export declare const ensNameSchema: z.ZodEffects<z.ZodString, string, string>;
7
7
  export declare const ethAddressOrEnsNameSchema: z.ZodUnion<[z.ZodEffects<z.ZodString, `0x${string}`, string>, z.ZodEffects<z.ZodString, string, string>]>;
8
+ export declare const TxHashSchema: z.ZodEffects<z.ZodString, string, string>;
8
9
  export declare enum QuestionType {
9
10
  Bool = "bool",
10
11
  Datetime = "datetime",
@@ -46,6 +47,31 @@ export declare const AttachmentSchema: z.ZodObject<{
46
47
  uri: string;
47
48
  }>;
48
49
  export declare const AliasSchema: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodEffects<z.ZodString, `0x${string}`, string>, z.ZodEffects<z.ZodString, string, string>]>>;
50
+ export declare const EvidenceSchema: z.ZodObject<{
51
+ name: z.ZodString;
52
+ description: z.ZodString;
53
+ fileURI: z.ZodOptional<z.ZodString>;
54
+ fileTypeExtension: z.ZodOptional<z.ZodString>;
55
+ transactionHash: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
56
+ sender: z.ZodOptional<z.ZodUnion<[z.ZodEffects<z.ZodString, `0x${string}`, string>, z.ZodEffects<z.ZodString, string, string>]>>;
57
+ timestamp: z.ZodOptional<z.ZodNumber>;
58
+ }, "strip", z.ZodTypeAny, {
59
+ name: string;
60
+ description: string;
61
+ timestamp?: number | undefined;
62
+ sender?: string | undefined;
63
+ transactionHash?: string | undefined;
64
+ fileURI?: string | undefined;
65
+ fileTypeExtension?: string | undefined;
66
+ }, {
67
+ name: string;
68
+ description: string;
69
+ timestamp?: number | undefined;
70
+ sender?: string | undefined;
71
+ transactionHash?: string | undefined;
72
+ fileURI?: string | undefined;
73
+ fileTypeExtension?: string | undefined;
74
+ }>;
49
75
  declare const DisputeDetailsSchema: z.ZodObject<{
50
76
  title: z.ZodString;
51
77
  description: z.ZodString;
@@ -85,6 +111,31 @@ declare const DisputeDetailsSchema: z.ZodObject<{
85
111
  lang: z.ZodOptional<z.ZodString>;
86
112
  specification: z.ZodOptional<z.ZodString>;
87
113
  aliases: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodEffects<z.ZodString, `0x${string}`, string>, z.ZodEffects<z.ZodString, string, string>]>>>;
114
+ extraEvidences: z.ZodDefault<z.ZodArray<z.ZodObject<{
115
+ name: z.ZodString;
116
+ description: z.ZodString;
117
+ fileURI: z.ZodOptional<z.ZodString>;
118
+ fileTypeExtension: z.ZodOptional<z.ZodString>;
119
+ transactionHash: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
120
+ sender: z.ZodOptional<z.ZodUnion<[z.ZodEffects<z.ZodString, `0x${string}`, string>, z.ZodEffects<z.ZodString, string, string>]>>;
121
+ timestamp: z.ZodOptional<z.ZodNumber>;
122
+ }, "strip", z.ZodTypeAny, {
123
+ name: string;
124
+ description: string;
125
+ timestamp?: number | undefined;
126
+ sender?: string | undefined;
127
+ transactionHash?: string | undefined;
128
+ fileURI?: string | undefined;
129
+ fileTypeExtension?: string | undefined;
130
+ }, {
131
+ name: string;
132
+ description: string;
133
+ timestamp?: number | undefined;
134
+ sender?: string | undefined;
135
+ transactionHash?: string | undefined;
136
+ fileURI?: string | undefined;
137
+ fileTypeExtension?: string | undefined;
138
+ }>, "many">>;
88
139
  version: z.ZodString;
89
140
  }, "strip", z.ZodTypeAny, {
90
141
  description: string;
@@ -99,6 +150,15 @@ declare const DisputeDetailsSchema: z.ZodObject<{
99
150
  policyURI: string;
100
151
  arbitratorChainID: string;
101
152
  arbitratorAddress: `0x${string}`;
153
+ extraEvidences: {
154
+ name: string;
155
+ description: string;
156
+ timestamp?: number | undefined;
157
+ sender?: string | undefined;
158
+ transactionHash?: string | undefined;
159
+ fileURI?: string | undefined;
160
+ fileTypeExtension?: string | undefined;
161
+ }[];
102
162
  version: string;
103
163
  attachment?: {
104
164
  label: string;
@@ -134,5 +194,14 @@ declare const DisputeDetailsSchema: z.ZodObject<{
134
194
  lang?: string | undefined;
135
195
  specification?: string | undefined;
136
196
  aliases?: Record<string, string> | undefined;
197
+ extraEvidences?: {
198
+ name: string;
199
+ description: string;
200
+ timestamp?: number | undefined;
201
+ sender?: string | undefined;
202
+ transactionHash?: string | undefined;
203
+ fileURI?: string | undefined;
204
+ fileTypeExtension?: string | undefined;
205
+ }[] | undefined;
137
206
  }>;
138
207
  export default DisputeDetailsSchema;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AliasSchema = exports.AttachmentSchema = exports.RefuseToArbitrateAnswer = exports.AnswerSchema = exports.QuestionTypeSchema = exports.QuestionType = exports.ethAddressOrEnsNameSchema = exports.ensNameSchema = exports.ethAddressSchema = exports.isMultiaddr = exports.isHexId = exports.isHexAddress = void 0;
3
+ exports.EvidenceSchema = exports.AliasSchema = exports.AttachmentSchema = exports.RefuseToArbitrateAnswer = exports.AnswerSchema = exports.QuestionTypeSchema = exports.QuestionType = exports.TxHashSchema = exports.ethAddressOrEnsNameSchema = exports.ensNameSchema = exports.ethAddressSchema = exports.isMultiaddr = exports.isHexId = exports.isHexAddress = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const viem_1 = require("viem");
6
6
  const ens_1 = require("viem/ens");
@@ -21,6 +21,9 @@ exports.ensNameSchema = zod_1.z
21
21
  exports.ethAddressOrEnsNameSchema = zod_1.z.union([exports.ethAddressSchema, exports.ensNameSchema], {
22
22
  errorMap: () => ({ message: "Provided address or ENS name is invalid." }),
23
23
  });
24
+ exports.TxHashSchema = zod_1.z.string().refine((value) => (0, exports.isHexId)(value) && value.length === 66, {
25
+ message: "Provided transaction hash is invalid.",
26
+ });
24
27
  var QuestionType;
25
28
  (function (QuestionType) {
26
29
  QuestionType["Bool"] = "bool";
@@ -47,6 +50,15 @@ exports.AttachmentSchema = zod_1.z.object({
47
50
  uri: zod_1.z.string(),
48
51
  });
49
52
  exports.AliasSchema = zod_1.z.record(exports.ethAddressOrEnsNameSchema);
53
+ exports.EvidenceSchema = zod_1.z.object({
54
+ name: zod_1.z.string(),
55
+ description: zod_1.z.string(),
56
+ fileURI: zod_1.z.string().optional(),
57
+ fileTypeExtension: zod_1.z.string().optional(),
58
+ transactionHash: exports.TxHashSchema.optional(),
59
+ sender: exports.ethAddressOrEnsNameSchema.optional(),
60
+ timestamp: zod_1.z.number().optional(),
61
+ });
50
62
  const MetadataSchema = zod_1.z.record(zod_1.z.unknown());
51
63
  const DisputeDetailsSchema = zod_1.z.object({
52
64
  title: zod_1.z.string(),
@@ -65,6 +77,7 @@ const DisputeDetailsSchema = zod_1.z.object({
65
77
  lang: zod_1.z.string().optional(),
66
78
  specification: zod_1.z.string().optional(),
67
79
  aliases: exports.AliasSchema.optional(),
80
+ extraEvidences: zod_1.z.array(exports.EvidenceSchema).default([]),
68
81
  version: zod_1.z.string(),
69
82
  });
70
83
  exports.default = DisputeDetailsSchema;
@@ -0,0 +1,3 @@
1
+ export declare const lambdas: {
2
+ hex: () => (text: string, render: (value: string) => string) => string;
3
+ };
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.lambdas = void 0;
4
+ exports.lambdas = {
5
+ hex: function () {
6
+ return function (text, render) {
7
+ const originalValueStr = render(text);
8
+ const num = parseInt(originalValueStr, 10);
9
+ if (!isNaN(num)) {
10
+ return "0x" + num.toString(16).toLowerCase();
11
+ }
12
+ return originalValueStr;
13
+ };
14
+ },
15
+ };
@@ -29,8 +29,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.populateTemplate = void 0;
30
30
  const mustache_1 = __importDefault(require("mustache"));
31
31
  const disputeDetailsSchema_1 = __importStar(require("./disputeDetailsSchema"));
32
+ const lambdas_1 = require("./lambdas");
32
33
  const populateTemplate = (mustacheTemplate, data) => {
33
- const render = mustache_1.default.render(mustacheTemplate, data);
34
+ const render = mustache_1.default.render(mustacheTemplate, { ...lambdas_1.lambdas, ...data });
34
35
  const dispute = JSON.parse(render);
35
36
  const validation = disputeDetailsSchema_1.default.safeParse(dispute);
36
37
  if (!validation.success) {
@@ -4,7 +4,6 @@ type DisputeDetailsQueryResponse = {
4
4
  id: string;
5
5
  };
6
6
  arbitrableChainId: number;
7
- externalDisputeId: number;
8
7
  templateId: number;
9
8
  };
10
9
  };
@@ -13,7 +13,6 @@ const query = (0, core_1.gql) `
13
13
  id
14
14
  }
15
15
  arbitrableChainId
16
- externalDisputeId
17
16
  templateId
18
17
  }
19
18
  }
@@ -27,7 +27,6 @@ const getDispute = async (disputeParameters) => {
27
27
  const initialContext = {
28
28
  arbitrableAddress: disputeDetails.dispute.arbitrated.id,
29
29
  arbitrableChainID: disputeDetails.dispute.arbitrableChainId,
30
- externalDisputeID: disputeDetails.dispute.externalDisputeId,
31
30
  ...options?.additionalContext,
32
31
  };
33
32
  let data = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kleros/kleros-sdk",
3
- "version": "2.3.1",
3
+ "version": "2.4.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",
@@ -15,7 +15,7 @@
15
15
  ],
16
16
  "type": "commonjs",
17
17
  "volta": {
18
- "node": "20.18.3"
18
+ "node": "20.19.5"
19
19
  },
20
20
  "publishConfig": {
21
21
  "access": "public",
@@ -33,22 +33,22 @@
33
33
  },
34
34
  "devDependencies": {
35
35
  "@types/mustache": "^4.2.5",
36
- "@types/node": "^20.17.6",
37
- "@vitest/ui": "^1.6.0",
36
+ "@types/node": "^20.19.24",
37
+ "@vitest/ui": "^1.6.1",
38
38
  "mocha": "^10.8.2",
39
39
  "rimraf": "^6.0.1",
40
40
  "ts-node": "^10.9.2",
41
41
  "typescript": "^5.6.3",
42
- "viem": "^2.21.48",
43
- "vitest": "^1.6.0"
42
+ "viem": "^2.24.1",
43
+ "vitest": "^1.6.1"
44
44
  },
45
45
  "dependencies": {
46
- "@reality.eth/reality-eth-lib": "^3.2.60",
46
+ "@reality.eth/reality-eth-lib": "^3.4.15",
47
47
  "@urql/core": "^5.0.8",
48
48
  "mustache": "^4.2.0",
49
49
  "zod": "^3.23.8"
50
50
  },
51
51
  "peerDependencies": {
52
- "viem": "^2.21.48"
52
+ "viem": "^2.24.1"
53
53
  }
54
54
  }