Skip to content

Commit 1c9b6f0

Browse files
authored
Merge branch 'dev' into feat(web)/link-voting-mini-guides-and-commit-reveal-explanation
2 parents d8d21c1 + 524cc8b commit 1c9b6f0

38 files changed

+776
-108
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
[
2+
{
3+
"type": "graphql",
4+
"endpoint": "https://api.thegraph.com/subgraphs/name/kemuru/escrow-v2-devnet",
5+
"query": "query GetTransaction($transactionId: ID!) { escrow(id: $transactionId) { transactionUri buyer seller amount asset deadline } }",
6+
"variables": {
7+
"transactionId": "{{externalDisputeID}}"
8+
},
9+
"seek": [
10+
"escrow.transactionUri",
11+
"escrow.buyer",
12+
"escrow.seller",
13+
"escrow.amount",
14+
"escrow.asset",
15+
"escrow.deadline"
16+
],
17+
"populate": [
18+
"transactionUri",
19+
"address",
20+
"sendingRecipientAddress",
21+
"amount",
22+
"asset",
23+
"deadline"
24+
]
25+
},
26+
{
27+
"type": "fetch/ipfs/json",
28+
"ipfsUri": "{{transactionUri}}",
29+
"seek": [
30+
"title",
31+
"description",
32+
"extraDescriptionUri"
33+
],
34+
"populate": [
35+
"escrowTitle",
36+
"deliverableText",
37+
"extraDescriptionUri"
38+
]
39+
}
40+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"title": "{{escrowTitle}}",
3+
"description": "{{deliverableText}}",
4+
"question": "Which party abided by the terms of the contract?",
5+
"answers": [
6+
{
7+
"title": "Refund the Buyer",
8+
"description": "Select this to return the funds to the Buyer."
9+
},
10+
{
11+
"title": "Pay the Seller",
12+
"description": "Select this to release the funds to the Seller."
13+
}
14+
],
15+
"policyURI": "ipfs://TODO",
16+
"attachment": {
17+
"label": "Transaction Terms",
18+
"uri": "{{extraDescriptionUri}}"
19+
},
20+
"frontendUrl": "https://escrow-v2.kleros.builders/#/myTransactions/{{externalDisputeID}}",
21+
"arbitrableChainID": "421614",
22+
"arbitrableAddress": "{{arbitrator}}",
23+
"arbitratorChainID": "421614",
24+
"arbitratorAddress": "{{arbitrable}}",
25+
"metadata": {
26+
"buyer": "{{address}}",
27+
"seller": "{{sendingRecipientAddress}}",
28+
"amount": "{{sendingQuantity}}",
29+
"asset": "{{asset}}",
30+
"deadline": "{{deadline}}",
31+
"transactionUri": "{{transactionUri}}"
32+
},
33+
"category": "Escrow",
34+
"specification": "KIPXXX",
35+
"aliases": {
36+
"Buyer": "{{address}}",
37+
"Seller": "{{sendingRecipientAddress}}"
38+
},
39+
"version": "1.0"
40+
}

kleros-sdk/src/dataMappings/utils/actionTypeValidators.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
} from "./actionTypes";
1010

1111
export const validateSubgraphMapping = (mapping: ActionMapping) => {
12-
if ((mapping as SubgraphMapping).endpoint !== undefined) {
12+
if ((mapping as SubgraphMapping).endpoint === undefined) {
1313
throw new Error("Invalid mapping for graphql action.");
1414
}
1515
return mapping as SubgraphMapping;

kleros-sdk/src/dataMappings/utils/createResultObject.ts

+18-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,26 @@
11
// Can this be replaced by Mustache ?
22
export const createResultObject = (sourceData, seek, populate) => {
33
const result = {};
4+
45
seek.forEach((key, idx) => {
5-
let foundValue;
6-
if (typeof sourceData !== "object" || key === "0") {
7-
foundValue = sourceData;
6+
let foundValue = sourceData;
7+
8+
if (key.includes(".")) {
9+
const keyParts = key.split(".");
10+
for (const part of keyParts) {
11+
if (foundValue[part] !== undefined) {
12+
foundValue = foundValue[part];
13+
} else {
14+
foundValue = undefined;
15+
break;
16+
}
17+
}
818
} else {
9-
foundValue = sourceData[key];
19+
if (typeof sourceData !== "object" || key === "0") {
20+
foundValue = sourceData;
21+
} else {
22+
foundValue = sourceData[key];
23+
}
1024
}
1125

1226
console.log(`Seek key: ${key}, Found value:`, foundValue);

subgraph/core/schema.graphql

+1
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ type ClassicContribution implements Contribution @entity {
305305

306306
localRound: ClassicRound!
307307
amount: BigInt!
308+
rewardAmount: BigInt
308309
choice: BigInt!
309310
rewardWithdrawn: Boolean!
310311
}

subgraph/core/src/DisputeKitClassic.ts

+1
Original file line numberDiff line numberDiff line change
@@ -126,5 +126,6 @@ export function handleWithdrawal(event: Withdrawal): void {
126126
const contribution = ensureClassicContributionFromEvent(event);
127127
if (!contribution) return;
128128
contribution.rewardWithdrawn = true;
129+
contribution.rewardAmount = event.params._amount;
129130
contribution.save();
130131
}

subgraph/core/src/entities/ClassicContribution.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ import { Contribution as ContributionEvent, Withdrawal } from "../../generated/D
33
import { DISPUTEKIT_ID } from "../DisputeKitClassic";
44

55
export function ensureClassicContributionFromEvent<T>(event: T): ClassicContribution | null {
6-
if (!(event instanceof ContributionEvent) && !(event instanceof Withdrawal)) {
7-
return null;
8-
}
6+
if (!(event instanceof ContributionEvent) && !(event instanceof Withdrawal)) return null;
97
const coreDisputeID = event.params._coreDisputeID.toString();
108
const coreRoundIndex = event.params._coreRoundID.toString();
119
const roundID = `${DISPUTEKIT_ID}-${coreDisputeID}-${coreRoundIndex}`;
@@ -25,9 +23,11 @@ export function ensureClassicContributionFromEvent<T>(event: T): ClassicContribu
2523
classicContribution.rewardWithdrawn = false;
2624
} else {
2725
const currentAmount = classicContribution.amount;
28-
classicContribution.amount = currentAmount.plus(event.params._amount);
26+
// we dont want to increase amount on withdraw event, the amount in that event is reward/reimburse amount
27+
if (event instanceof ContributionEvent) {
28+
classicContribution.amount = currentAmount.plus(event.params._amount);
29+
}
2930
}
30-
3131
classicContribution.save();
3232
return classicContribution;
3333
}

subgraph/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@kleros/kleros-v2-subgraph",
3-
"version": "0.4.0",
3+
"version": "0.5.0",
44
"license": "MIT",
55
"scripts": {
66
"update:core:arbitrum-sepolia-devnet": "./scripts/update.sh arbitrumSepoliaDevnet arbitrum-sepolia core/subgraph.yaml",

web/src/assets/svgs/icons/eth.svg

+1-1
Loading
+11
Loading
Loading
Loading
Loading
Loading
Loading
Loading
+4
Loading

0 commit comments

Comments
 (0)