-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy pathargentinaConsumerProtection.builder.ts
More file actions
38 lines (31 loc) · 1.27 KB
/
argentinaConsumerProtection.builder.ts
File metadata and controls
38 lines (31 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { getVoteKey } from "actions/helpers/storage/getVoteKey";
import {
disputeKitGatedArgentinaConsumerProtectionAbi,
disputeKitGatedArgentinaConsumerProtectionAddress,
} from "hooks/contracts/generated";
import { hashVote } from "utils/crypto/hashVote";
import { ArgentinaConsumerProtectionCommitDeps } from "../deps";
import { ArgentinaConsumerProtectionCommitParams } from "../params";
import { defineCommitBuilder } from "./baseBuilder";
export const argentinaConsumerProtectionCommitBuilder = defineCommitBuilder({
build: async (
params: ArgentinaConsumerProtectionCommitParams,
context,
deps: ArgentinaConsumerProtectionCommitDeps
) => {
const { disputeId, voteIds, choice, salt, roundIndex } = params;
const { chain, account } = context;
const key = getVoteKey(disputeId, roundIndex, voteIds);
deps.storeCommitData(key, { choice, salt });
const commit = hashVote(choice, salt);
const chainKey = chain.id as keyof typeof disputeKitGatedArgentinaConsumerProtectionAddress;
return {
account,
address: disputeKitGatedArgentinaConsumerProtectionAddress[chainKey],
abi: disputeKitGatedArgentinaConsumerProtectionAbi,
functionName: "castCommit",
args: [disputeId, voteIds, commit],
chain,
};
},
});