-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy pathgated.builder.ts
More file actions
31 lines (24 loc) · 1.01 KB
/
gated.builder.ts
File metadata and controls
31 lines (24 loc) · 1.01 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
import { getVoteKey } from "actions/helpers/storage/getVoteKey";
import { disputeKitGatedAbi, disputeKitGatedAddress } from "hooks/contracts/generated";
import { hashVote } from "utils/crypto/hashVote";
import { GatedCommitDeps } from "../deps";
import { GatedCommitParams } from "../params";
import { defineCommitBuilder } from "./baseBuilder";
export const gatedCommitBuilder = defineCommitBuilder({
build: async (params: GatedCommitParams, context, deps: GatedCommitDeps) => {
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 disputeKitGatedAddress;
return {
account,
address: disputeKitGatedAddress[chainKey],
abi: disputeKitGatedAbi,
functionName: "castCommit",
args: [disputeId, voteIds, commit],
chain,
};
},
});