Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update mappings in create transaction flow #67

Merged
merged 5 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions contracts/deploy/00-escrow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const disputeTemplate = `{
"policyURI": "/ipfs/XxxxxXXX/escrow-general-policy.pdf",
"attachment": {
"label": "Transaction Terms",
"uri": "{{extraDescriptionUri}}"
"uri": "{{{extraDescriptionUri}}}"
},
"frontendUrl": "https://escrow-v2.kleros.builders/#/transactions/{{externalDisputeID}}",
"arbitrableChainID": "421614",
Expand All @@ -33,7 +33,7 @@ const disputeTemplate = `{
"amount": "{{amount}}",
"token": "{{token}}",
"deadline": "{{deadline}}",
"transactionUri": "{{transactionUri}}"
"transactionUri": "{{{transactionUri}}}"
},
"category": "Escrow",
"specification": "KIPXXX",
Expand Down Expand Up @@ -66,7 +66,7 @@ const mapping = `[

// General court, 3 jurors
const extraData =
"0x00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000003";
"0x00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000003";

const deploy: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
const { deployments, getNamedAccounts, getChainId } = hre;
Expand All @@ -81,7 +81,7 @@ const deploy: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
const disputeTemplateRegistry = await deployments.get("DisputeTemplateRegistry");
const feeTimeout = 600; // 10 minutes
const settlementTimeout = 600; // 10 minutes

await deploy("EscrowUniversal", {
from: deployer,
args: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,66 +74,71 @@ const DepositPaymentButton: React.FC = () => {
}
}, [allowance, transactionValue]);

const templateData = useMemo(
() =>
JSON.stringify({
$schema: "../NewDisputeTemplate.schema.json",
title: escrowTitle,
description: deliverableText,
question: "Which party abided by the terms of the contract?",
answers: [
{
title: "Refund the Buyer",
description: "Select this to return the funds to the Buyer.",
},
{
title: "Pay the Seller",
description: "Select this to release the funds to the Seller.",
},
],
policyURI: "ipfs://TODO",
attachment: {
label: "Transaction Terms",
uri: extraDescriptionUri,
},
frontendUrl: `https://escrow-v2.kleros.builders/#/transactions/%s`,
arbitrableChainID: "421614",
arbitrableAddress: "0x250AB0477346aDFC010585b58FbF61cff1d8f3ea",
arbitratorChainID: "421614",
arbitratorAddress: "0xA54e7A16d7460e38a8F324eF46782FB520d58CE8",
metadata: {
buyer: address,
seller: sellerAddress,
amount: sendingQuantity,
token: isNativeTransaction ? "native" : sendingToken?.address,
deadline: deadlineTimestamp.toString(),
transactionUri: transactionUri,
},
category: "Escrow",
specification: "KIPXXX",
aliases: {
Buyer: address,
Seller: sellerAddress,
},
version: "1.0",
}),
[
escrowTitle,
deliverableText,
extraDescriptionUri,
sendingQuantity,
sellerAddress,
address,
isNativeTransaction,
sendingToken?.address,
deadlineTimestamp,
transactionUri,
]
);
const disputeTemplate = `{
"$schema": "../NewDisputeTemplate.schema.json",
"title": "Escrow dispute: {{escrowTitle}}",
"description": "{{deliverableText}}",
"question": "Which party abided by the terms of the contract?",
"answers": [
{
"title": "Refund the Buyer",
"description": "Select this to return the funds to the Buyer."
},
{
"title": "Pay the Seller",
"description": "Select this to release the funds to the Seller."
}
],
"policyURI": "/ipfs/XxxxxXXX/escrow-general-policy.pdf",
"attachment": {
"label": "Transaction Terms",
"uri": "{{{extraDescriptionUri}}}"
},
"frontendUrl": "https://escrow-v2.kleros.builders/#/transactions/{{externalDisputeID}}",
"arbitrableChainID": "421614",
"arbitrableAddress": "0xFromContext",
"arbitratorChainID": "421614",
"arbitratorAddress": "0xA54e7A16d7460e38a8F324eF46782FB520d58CE8",
"metadata": {
"buyer": "{{buyer}}",
"seller": "{{seller}}",
"amount": "{{amount}}",
"token": "{{token}}",
"deadline": "{{deadline}}",
"transactionUri": "{{{transactionUri}}}"
},
"category": "Escrow",
"specification": "KIPXXX",
"aliases": {
"Buyer": "{{buyer}}",
"Seller": "{{seller}}"
},
"version": "1.0"
}
`;

const dataMappings = `[
{
"type": "graphql",
"endpoint": "https://gateway-arbitrum.network.thegraph.com/api/{{{graphApiKey}}}/subgraphs/id/3aZxYcZpZL5BuVhuUupqVrCV8VeNyZEvjmPXibyPHDFQ",
"query": "query GetTransaction($transactionId: ID!) { escrow(id: $transactionId) { transactionUri buyer seller amount token deadline } }",
"variables": {
"transactionId": "{{externalDisputeID}}"
},
"seek": ["escrow.transactionUri", "escrow.buyer", "escrow.seller", "escrow.amount", "escrow.token", "escrow.deadline"],
"populate": ["transactionUri", "buyer", "seller", "amount", "token", "deadline"]
},
{
"type": "fetch/ipfs/json",
"ipfsUri": "{{{transactionUri}}}",
"seek": ["title", "description", "extraDescriptionUri"],
"populate": ["escrowTitle", "deliverableText", "extraDescriptionUri"]
}
]`;

const { config: createNativeTransactionConfig } = usePrepareEscrowUniversalCreateNativeTransaction({
enabled: isNativeTransaction && ethAddressPattern.test(finalRecipientAddress),
args: [deadlineTimestamp, transactionUri, finalRecipientAddress, templateData, ""],
args: [deadlineTimestamp, transactionUri, finalRecipientAddress, disputeTemplate, dataMappings],
value: transactionValue,
});

Expand All @@ -149,8 +154,8 @@ const DepositPaymentButton: React.FC = () => {
deadlineTimestamp,
transactionUri,
finalRecipientAddress,
templateData,
"",
disputeTemplate,
dataMappings,
],
});

Expand Down
Loading