@kleros/kleros-sdk 2.1.5 → 2.1.7
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/actions/fetchIpfsJsonAction.js +1 -1
- package/lib/src/dataMappings/actions/subgraphAction.js +1 -1
- package/lib/src/requests/fetchDisputeDetails.d.ts +1 -1
- package/lib/src/requests/fetchDisputeDetails.js +30 -14
- package/lib/src/requests/fetchDisputeTemplateFromId.d.ts +1 -1
- package/lib/src/requests/fetchDisputeTemplateFromId.js +27 -11
- package/lib/src/requests/gqlClient.d.ts +3 -0
- package/lib/src/requests/gqlClient.js +16 -0
- package/package.json +5 -3
|
@@ -31,7 +31,7 @@ const fetchIpfsJsonAction = async (mapping) => {
|
|
|
31
31
|
if (!contentType || !contentType.includes("application/json")) {
|
|
32
32
|
throw new errors_1.RequestError("Fetched data is not JSON", httpUri);
|
|
33
33
|
}
|
|
34
|
-
const data = await response.json();
|
|
34
|
+
const data = (await response.json());
|
|
35
35
|
return (0, createResultObject_1.createResultObject)(data, seek, populate);
|
|
36
36
|
};
|
|
37
37
|
exports.fetchIpfsJsonAction = fetchIpfsJsonAction;
|
|
@@ -12,7 +12,7 @@ const subgraphAction = async (mapping) => {
|
|
|
12
12
|
},
|
|
13
13
|
body: JSON.stringify({ query, variables }),
|
|
14
14
|
});
|
|
15
|
-
const { data } = await response.json();
|
|
15
|
+
const { data } = (await response.json());
|
|
16
16
|
return (0, createResultObject_1.createResultObject)(data, seek, populate);
|
|
17
17
|
};
|
|
18
18
|
exports.subgraphAction = subgraphAction;
|
|
@@ -8,5 +8,5 @@ type DisputeDetailsQueryResponse = {
|
|
|
8
8
|
templateId: number;
|
|
9
9
|
};
|
|
10
10
|
};
|
|
11
|
-
declare const fetchDisputeDetails: (endpoint: string, id: bigint) => Promise<DisputeDetailsQueryResponse>;
|
|
11
|
+
declare const fetchDisputeDetails: (endpoint: string, id: bigint) => Promise<DisputeDetailsQueryResponse | undefined>;
|
|
12
12
|
export default fetchDisputeDetails;
|
|
@@ -1,26 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const graphql_request_1 = require("graphql-request");
|
|
4
6
|
const errors_1 = require("../errors");
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
arbitrableChainId
|
|
13
|
-
externalDisputeId
|
|
14
|
-
templateId
|
|
7
|
+
const core_1 = require("@urql/core");
|
|
8
|
+
const gqlClient_1 = __importDefault(require("./gqlClient"));
|
|
9
|
+
const query = (0, core_1.gql) `
|
|
10
|
+
query DisputeDetails($id: ID!) {
|
|
11
|
+
dispute(id: $id) {
|
|
12
|
+
arbitrated {
|
|
13
|
+
id
|
|
15
14
|
}
|
|
15
|
+
arbitrableChainId
|
|
16
|
+
externalDisputeId
|
|
17
|
+
templateId
|
|
16
18
|
}
|
|
17
|
-
|
|
19
|
+
}
|
|
20
|
+
`;
|
|
21
|
+
const fetchDisputeDetails = async (endpoint, id) => {
|
|
18
22
|
const variables = { id: id.toString() };
|
|
19
23
|
try {
|
|
20
|
-
|
|
24
|
+
const client = (0, gqlClient_1.default)(endpoint);
|
|
25
|
+
return client
|
|
26
|
+
.query(query, variables)
|
|
27
|
+
.toPromise()
|
|
28
|
+
.then((res) => {
|
|
29
|
+
if (res?.error) {
|
|
30
|
+
throw res.error;
|
|
31
|
+
}
|
|
32
|
+
return res?.data;
|
|
33
|
+
});
|
|
21
34
|
}
|
|
22
35
|
catch (error) {
|
|
23
|
-
if (error instanceof
|
|
36
|
+
if (error instanceof core_1.CombinedError) {
|
|
37
|
+
throw error;
|
|
38
|
+
}
|
|
39
|
+
else if (error instanceof Error) {
|
|
24
40
|
throw new errors_1.RequestError(`Error querying Dispute Details: ${error.message}`, endpoint);
|
|
25
41
|
}
|
|
26
42
|
throw new errors_1.RequestError("An unknown error occurred while querying Dispute Details", endpoint);
|
|
@@ -4,5 +4,5 @@ type DisputeTemplateQueryResponse = {
|
|
|
4
4
|
templateDataMappings: string;
|
|
5
5
|
};
|
|
6
6
|
};
|
|
7
|
-
declare const fetchDisputeTemplateFromId: (endpoint: string, id: number) => Promise<DisputeTemplateQueryResponse>;
|
|
7
|
+
declare const fetchDisputeTemplateFromId: (endpoint: string, id: number) => Promise<DisputeTemplateQueryResponse | undefined>;
|
|
8
8
|
export default fetchDisputeTemplateFromId;
|
|
@@ -1,22 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
6
|
+
const core_1 = require("@urql/core");
|
|
4
7
|
const errors_1 = require("../errors");
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
8
|
+
const gqlClient_1 = __importDefault(require("./gqlClient"));
|
|
9
|
+
const query = (0, core_1.gql) `
|
|
10
|
+
query DisputeTemplate($id: ID!) {
|
|
11
|
+
disputeTemplate(id: $id) {
|
|
12
|
+
templateData
|
|
13
|
+
templateDataMappings
|
|
12
14
|
}
|
|
13
|
-
|
|
15
|
+
}
|
|
16
|
+
`;
|
|
17
|
+
const fetchDisputeTemplateFromId = async (endpoint, id) => {
|
|
14
18
|
const variables = { id: id.toString() };
|
|
15
19
|
try {
|
|
16
|
-
|
|
20
|
+
const client = (0, gqlClient_1.default)(endpoint);
|
|
21
|
+
return client
|
|
22
|
+
.query(query, variables)
|
|
23
|
+
.toPromise()
|
|
24
|
+
.then((res) => {
|
|
25
|
+
if (res?.error) {
|
|
26
|
+
throw res.error;
|
|
27
|
+
}
|
|
28
|
+
return res?.data;
|
|
29
|
+
});
|
|
17
30
|
}
|
|
18
31
|
catch (error) {
|
|
19
|
-
if (error instanceof
|
|
32
|
+
if (error instanceof core_1.CombinedError) {
|
|
33
|
+
throw error;
|
|
34
|
+
}
|
|
35
|
+
else if (error instanceof Error) {
|
|
20
36
|
throw new errors_1.RequestError(`Error querying Dispute Template: ${error.message}`, endpoint);
|
|
21
37
|
}
|
|
22
38
|
throw new errors_1.RequestError("An unknown error occurred while querying Dispute Template", endpoint);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@urql/core");
|
|
4
|
+
const clients = new Map();
|
|
5
|
+
const getClient = (endpoint) => {
|
|
6
|
+
let client = clients.get(endpoint);
|
|
7
|
+
if (!client) {
|
|
8
|
+
client = new core_1.Client({
|
|
9
|
+
url: endpoint,
|
|
10
|
+
exchanges: [core_1.cacheExchange, core_1.fetchExchange],
|
|
11
|
+
});
|
|
12
|
+
clients.set(endpoint, client);
|
|
13
|
+
}
|
|
14
|
+
return client;
|
|
15
|
+
};
|
|
16
|
+
exports.default = getClient;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kleros/kleros-sdk",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.7",
|
|
4
4
|
"description": "SDK for Kleros version 2",
|
|
5
5
|
"repository": "git@github.com:kleros/kleros-v2.git",
|
|
6
6
|
"author": "Kleros",
|
|
@@ -30,7 +30,9 @@
|
|
|
30
30
|
"test": "vitest",
|
|
31
31
|
"test:ui": "vitest --ui",
|
|
32
32
|
"test:run": "vitest run",
|
|
33
|
-
"
|
|
33
|
+
"release:patch": "scripts/publish.sh patch",
|
|
34
|
+
"release:minor": "scripts/publish.sh minor",
|
|
35
|
+
"release:major": "scripts/publish.sh major"
|
|
34
36
|
},
|
|
35
37
|
"devDependencies": {
|
|
36
38
|
"@types/mustache": "^4.2.5",
|
|
@@ -43,7 +45,7 @@
|
|
|
43
45
|
},
|
|
44
46
|
"dependencies": {
|
|
45
47
|
"@reality.eth/reality-eth-lib": "^3.2.30",
|
|
46
|
-
"
|
|
48
|
+
"@urql/core": "^5.0.8",
|
|
47
49
|
"mustache": "^4.2.0",
|
|
48
50
|
"viem": "^2.21.26",
|
|
49
51
|
"zod": "^3.22.4"
|