@maci-protocol/sdk 0.0.0-ci.26f28d6
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/CHANGELOG.md +80 -0
- package/LICENSE +22 -0
- package/README.md +12 -0
- package/build/package.json +56 -0
- package/build/ts/browser/index.d.ts +15 -0
- package/build/ts/browser/index.d.ts.map +1 -0
- package/build/ts/browser/index.js +43 -0
- package/build/ts/browser/index.js.map +1 -0
- package/build/ts/deploy/index.d.ts +5 -0
- package/build/ts/deploy/index.d.ts.map +1 -0
- package/build/ts/deploy/index.js +10 -0
- package/build/ts/deploy/index.js.map +1 -0
- package/build/ts/deploy/maci.d.ts +8 -0
- package/build/ts/deploy/maci.d.ts.map +1 -0
- package/build/ts/deploy/maci.js +87 -0
- package/build/ts/deploy/maci.js.map +1 -0
- package/build/ts/deploy/poll.d.ts +8 -0
- package/build/ts/deploy/poll.d.ts.map +1 -0
- package/build/ts/deploy/poll.js +107 -0
- package/build/ts/deploy/poll.js.map +1 -0
- package/build/ts/deploy/types.d.ts +204 -0
- package/build/ts/deploy/types.d.ts.map +1 -0
- package/build/ts/deploy/types.js +3 -0
- package/build/ts/deploy/types.js.map +1 -0
- package/build/ts/deploy/utils.d.ts +11 -0
- package/build/ts/deploy/utils.d.ts.map +1 -0
- package/build/ts/deploy/utils.js +22 -0
- package/build/ts/deploy/utils.js.map +1 -0
- package/build/ts/deploy/vkRegistry.d.ts +7 -0
- package/build/ts/deploy/vkRegistry.d.ts.map +1 -0
- package/build/ts/deploy/vkRegistry.js +14 -0
- package/build/ts/deploy/vkRegistry.js.map +1 -0
- package/build/ts/index.d.ts +16 -0
- package/build/ts/index.d.ts.map +1 -0
- package/build/ts/index.js +69 -0
- package/build/ts/index.js.map +1 -0
- package/build/ts/maci/index.d.ts +6 -0
- package/build/ts/maci/index.d.ts.map +1 -0
- package/build/ts/maci/index.js +17 -0
- package/build/ts/maci/index.js.map +1 -0
- package/build/ts/maci/merge.d.ts +9 -0
- package/build/ts/maci/merge.d.ts.map +1 -0
- package/build/ts/maci/merge.js +29 -0
- package/build/ts/maci/merge.js.map +1 -0
- package/build/ts/maci/policy.d.ts +41 -0
- package/build/ts/maci/policy.d.ts.map +1 -0
- package/build/ts/maci/policy.js +127 -0
- package/build/ts/maci/policy.js.map +1 -0
- package/build/ts/maci/state.d.ts +8 -0
- package/build/ts/maci/state.d.ts.map +1 -0
- package/build/ts/maci/state.js +82 -0
- package/build/ts/maci/state.js.map +1 -0
- package/build/ts/maci/types.d.ts +176 -0
- package/build/ts/maci/types.d.ts.map +1 -0
- package/build/ts/maci/types.js +18 -0
- package/build/ts/maci/types.js.map +1 -0
- package/build/ts/maciKeys/__tests__/keypair.test.d.ts +2 -0
- package/build/ts/maciKeys/__tests__/keypair.test.d.ts.map +1 -0
- package/build/ts/maciKeys/__tests__/keypair.test.js +24 -0
- package/build/ts/maciKeys/__tests__/keypair.test.js.map +1 -0
- package/build/ts/maciKeys/__tests__/publicKeys.test.d.ts +2 -0
- package/build/ts/maciKeys/__tests__/publicKeys.test.d.ts.map +1 -0
- package/build/ts/maciKeys/__tests__/publicKeys.test.js +22 -0
- package/build/ts/maciKeys/__tests__/publicKeys.test.js.map +1 -0
- package/build/ts/maciKeys/index.d.ts +4 -0
- package/build/ts/maciKeys/index.d.ts.map +1 -0
- package/build/ts/maciKeys/index.js +8 -0
- package/build/ts/maciKeys/index.js.map +1 -0
- package/build/ts/maciKeys/keypair.d.ts +9 -0
- package/build/ts/maciKeys/keypair.d.ts.map +1 -0
- package/build/ts/maciKeys/keypair.js +20 -0
- package/build/ts/maciKeys/keypair.js.map +1 -0
- package/build/ts/maciKeys/publicKeys.d.ts +8 -0
- package/build/ts/maciKeys/publicKeys.d.ts.map +1 -0
- package/build/ts/maciKeys/publicKeys.js +23 -0
- package/build/ts/maciKeys/publicKeys.js.map +1 -0
- package/build/ts/maciKeys/types.d.ts +23 -0
- package/build/ts/maciKeys/types.d.ts.map +1 -0
- package/build/ts/maciKeys/types.js +3 -0
- package/build/ts/maciKeys/types.js.map +1 -0
- package/build/ts/poll/index.d.ts +4 -0
- package/build/ts/poll/index.d.ts.map +1 -0
- package/build/ts/poll/index.js +9 -0
- package/build/ts/poll/index.js.map +1 -0
- package/build/ts/poll/poll.d.ts +14 -0
- package/build/ts/poll/poll.d.ts.map +1 -0
- package/build/ts/poll/poll.js +62 -0
- package/build/ts/poll/poll.js.map +1 -0
- package/build/ts/poll/types.d.ts +152 -0
- package/build/ts/poll/types.d.ts.map +1 -0
- package/build/ts/poll/types.js +3 -0
- package/build/ts/poll/types.js.map +1 -0
- package/build/ts/poll/utils.d.ts +9 -0
- package/build/ts/poll/utils.d.ts.map +1 -0
- package/build/ts/poll/utils.js +43 -0
- package/build/ts/poll/utils.js.map +1 -0
- package/build/ts/proof/__tests__/download.test.d.ts +2 -0
- package/build/ts/proof/__tests__/download.test.d.ts.map +1 -0
- package/build/ts/proof/__tests__/download.test.js +50 -0
- package/build/ts/proof/__tests__/download.test.js.map +1 -0
- package/build/ts/proof/constants.d.ts +17 -0
- package/build/ts/proof/constants.d.ts.map +1 -0
- package/build/ts/proof/constants.js +20 -0
- package/build/ts/proof/constants.js.map +1 -0
- package/build/ts/proof/download.d.ts +9 -0
- package/build/ts/proof/download.d.ts.map +1 -0
- package/build/ts/proof/download.js +49 -0
- package/build/ts/proof/download.js.map +1 -0
- package/build/ts/proof/generate.d.ts +8 -0
- package/build/ts/proof/generate.d.ts.map +1 -0
- package/build/ts/proof/generate.js +127 -0
- package/build/ts/proof/generate.js.map +1 -0
- package/build/ts/proof/index.d.ts +4 -0
- package/build/ts/proof/index.d.ts.map +1 -0
- package/build/ts/proof/index.js +8 -0
- package/build/ts/proof/index.js.map +1 -0
- package/build/ts/proof/prove.d.ts +8 -0
- package/build/ts/proof/prove.d.ts.map +1 -0
- package/build/ts/proof/prove.js +81 -0
- package/build/ts/proof/prove.js.map +1 -0
- package/build/ts/proof/types.d.ts +175 -0
- package/build/ts/proof/types.d.ts.map +1 -0
- package/build/ts/proof/types.js +3 -0
- package/build/ts/proof/types.js.map +1 -0
- package/build/ts/relayer/__tests__/messages.test.d.ts +2 -0
- package/build/ts/relayer/__tests__/messages.test.d.ts.map +1 -0
- package/build/ts/relayer/__tests__/messages.test.js +76 -0
- package/build/ts/relayer/__tests__/messages.test.js.map +1 -0
- package/build/ts/relayer/__tests__/utils.test.d.ts +2 -0
- package/build/ts/relayer/__tests__/utils.test.d.ts.map +1 -0
- package/build/ts/relayer/__tests__/utils.test.js +73 -0
- package/build/ts/relayer/__tests__/utils.test.js.map +1 -0
- package/build/ts/relayer/index.d.ts +3 -0
- package/build/ts/relayer/index.d.ts.map +1 -0
- package/build/ts/relayer/index.js +8 -0
- package/build/ts/relayer/index.js.map +1 -0
- package/build/ts/relayer/messages.d.ts +23 -0
- package/build/ts/relayer/messages.d.ts.map +1 -0
- package/build/ts/relayer/messages.js +66 -0
- package/build/ts/relayer/messages.js.map +1 -0
- package/build/ts/relayer/types.d.ts +168 -0
- package/build/ts/relayer/types.d.ts.map +1 -0
- package/build/ts/relayer/types.js +3 -0
- package/build/ts/relayer/types.js.map +1 -0
- package/build/ts/relayer/utils.d.ts +12 -0
- package/build/ts/relayer/utils.d.ts.map +1 -0
- package/build/ts/relayer/utils.js +37 -0
- package/build/ts/relayer/utils.js.map +1 -0
- package/build/ts/tally/commitments.d.ts +9 -0
- package/build/ts/tally/commitments.d.ts.map +1 -0
- package/build/ts/tally/commitments.js +42 -0
- package/build/ts/tally/commitments.js.map +1 -0
- package/build/ts/tally/index.d.ts +4 -0
- package/build/ts/tally/index.d.ts.map +1 -0
- package/build/ts/tally/index.js +8 -0
- package/build/ts/tally/index.js.map +1 -0
- package/build/ts/tally/types.d.ts +179 -0
- package/build/ts/tally/types.d.ts.map +1 -0
- package/build/ts/tally/types.js +3 -0
- package/build/ts/tally/types.js.map +1 -0
- package/build/ts/tally/utils.d.ts +24 -0
- package/build/ts/tally/utils.d.ts.map +1 -0
- package/build/ts/tally/utils.js +50 -0
- package/build/ts/tally/utils.js.map +1 -0
- package/build/ts/tally/verification.d.ts +7 -0
- package/build/ts/tally/verification.d.ts.map +1 -0
- package/build/ts/tally/verification.js +62 -0
- package/build/ts/tally/verification.js.map +1 -0
- package/build/ts/trees/index.d.ts +3 -0
- package/build/ts/trees/index.d.ts.map +1 -0
- package/build/ts/trees/index.js +6 -0
- package/build/ts/trees/index.js.map +1 -0
- package/build/ts/trees/stateTree.d.ts +13 -0
- package/build/ts/trees/stateTree.d.ts.map +1 -0
- package/build/ts/trees/stateTree.js +53 -0
- package/build/ts/trees/stateTree.js.map +1 -0
- package/build/ts/trees/types.d.ts +46 -0
- package/build/ts/trees/types.d.ts.map +1 -0
- package/build/ts/trees/types.js +3 -0
- package/build/ts/trees/types.js.map +1 -0
- package/build/ts/user/index.d.ts +3 -0
- package/build/ts/user/index.d.ts.map +1 -0
- package/build/ts/user/index.js +11 -0
- package/build/ts/user/index.js.map +1 -0
- package/build/ts/user/types.d.ts +424 -0
- package/build/ts/user/types.d.ts.map +1 -0
- package/build/ts/user/types.js +3 -0
- package/build/ts/user/types.js.map +1 -0
- package/build/ts/user/user.d.ts +42 -0
- package/build/ts/user/user.d.ts.map +1 -0
- package/build/ts/user/user.js +192 -0
- package/build/ts/user/user.js.map +1 -0
- package/build/ts/user/utils.d.ts +52 -0
- package/build/ts/user/utils.d.ts.map +1 -0
- package/build/ts/user/utils.js +186 -0
- package/build/ts/user/utils.js.map +1 -0
- package/build/ts/utils/cid.d.ts +23 -0
- package/build/ts/utils/cid.d.ts.map +1 -0
- package/build/ts/utils/cid.js +72 -0
- package/build/ts/utils/cid.js.map +1 -0
- package/build/ts/utils/constants.d.ts +2 -0
- package/build/ts/utils/constants.d.ts.map +1 -0
- package/build/ts/utils/constants.js +5 -0
- package/build/ts/utils/constants.js.map +1 -0
- package/build/ts/utils/contracts.d.ts +15 -0
- package/build/ts/utils/contracts.d.ts.map +1 -0
- package/build/ts/utils/contracts.js +26 -0
- package/build/ts/utils/contracts.js.map +1 -0
- package/build/ts/utils/files.d.ts +9 -0
- package/build/ts/utils/files.d.ts.map +1 -0
- package/build/ts/utils/files.js +20 -0
- package/build/ts/utils/files.js.map +1 -0
- package/build/ts/utils/formatting.d.ts +8 -0
- package/build/ts/utils/formatting.d.ts.map +1 -0
- package/build/ts/utils/formatting.js +11 -0
- package/build/ts/utils/formatting.js.map +1 -0
- package/build/ts/utils/fundWallet.d.ts +7 -0
- package/build/ts/utils/fundWallet.d.ts.map +1 -0
- package/build/ts/utils/fundWallet.js +20 -0
- package/build/ts/utils/fundWallet.js.map +1 -0
- package/build/ts/utils/index.d.ts +12 -0
- package/build/ts/utils/index.d.ts.map +1 -0
- package/build/ts/utils/index.js +28 -0
- package/build/ts/utils/index.js.map +1 -0
- package/build/ts/utils/params.d.ts +7 -0
- package/build/ts/utils/params.d.ts.map +1 -0
- package/build/ts/utils/params.js +19 -0
- package/build/ts/utils/params.js.map +1 -0
- package/build/ts/utils/proofs.d.ts +13 -0
- package/build/ts/utils/proofs.d.ts.map +1 -0
- package/build/ts/utils/proofs.js +41 -0
- package/build/ts/utils/proofs.js.map +1 -0
- package/build/ts/utils/timeTravel.d.ts +7 -0
- package/build/ts/utils/timeTravel.d.ts.map +1 -0
- package/build/ts/utils/timeTravel.js +14 -0
- package/build/ts/utils/timeTravel.js.map +1 -0
- package/build/ts/utils/trees.d.ts +13 -0
- package/build/ts/utils/trees.d.ts.map +1 -0
- package/build/ts/utils/trees.js +30 -0
- package/build/ts/utils/trees.js.map +1 -0
- package/build/ts/utils/types.d.ts +71 -0
- package/build/ts/utils/types.d.ts.map +1 -0
- package/build/ts/utils/types.js +3 -0
- package/build/ts/utils/types.js.map +1 -0
- package/build/ts/utils/utils.d.ts +16 -0
- package/build/ts/utils/utils.d.ts.map +1 -0
- package/build/ts/utils/utils.js +36 -0
- package/build/ts/utils/utils.js.map +1 -0
- package/build/ts/verifyingKeys/checkVerifyingKeys.d.ts +10 -0
- package/build/ts/verifyingKeys/checkVerifyingKeys.d.ts.map +1 -0
- package/build/ts/verifyingKeys/checkVerifyingKeys.js +67 -0
- package/build/ts/verifyingKeys/checkVerifyingKeys.js.map +1 -0
- package/build/ts/verifyingKeys/index.d.ts +5 -0
- package/build/ts/verifyingKeys/index.d.ts.map +1 -0
- package/build/ts/verifyingKeys/index.js +13 -0
- package/build/ts/verifyingKeys/index.js.map +1 -0
- package/build/ts/verifyingKeys/setVerifyingKeys.d.ts +7 -0
- package/build/ts/verifyingKeys/setVerifyingKeys.d.ts.map +1 -0
- package/build/ts/verifyingKeys/setVerifyingKeys.js +73 -0
- package/build/ts/verifyingKeys/setVerifyingKeys.js.map +1 -0
- package/build/ts/verifyingKeys/types.d.ts +231 -0
- package/build/ts/verifyingKeys/types.d.ts.map +1 -0
- package/build/ts/verifyingKeys/types.js +3 -0
- package/build/ts/verifyingKeys/types.js.map +1 -0
- package/build/ts/verifyingKeys/utils.d.ts +29 -0
- package/build/ts/verifyingKeys/utils.d.ts.map +1 -0
- package/build/ts/verifyingKeys/utils.js +102 -0
- package/build/ts/verifyingKeys/utils.js.map +1 -0
- package/build/ts/vote/generate.d.ts +8 -0
- package/build/ts/vote/generate.d.ts.map +1 -0
- package/build/ts/vote/generate.js +46 -0
- package/build/ts/vote/generate.js.map +1 -0
- package/build/ts/vote/index.d.ts +6 -0
- package/build/ts/vote/index.d.ts.map +1 -0
- package/build/ts/vote/index.js +15 -0
- package/build/ts/vote/index.js.map +1 -0
- package/build/ts/vote/invalidate.d.ts +13 -0
- package/build/ts/vote/invalidate.d.ts.map +1 -0
- package/build/ts/vote/invalidate.js +44 -0
- package/build/ts/vote/invalidate.js.map +1 -0
- package/build/ts/vote/publish.d.ts +14 -0
- package/build/ts/vote/publish.d.ts.map +1 -0
- package/build/ts/vote/publish.js +88 -0
- package/build/ts/vote/publish.js.map +1 -0
- package/build/ts/vote/submit.d.ts +13 -0
- package/build/ts/vote/submit.d.ts.map +1 -0
- package/build/ts/vote/submit.js +36 -0
- package/build/ts/vote/submit.js.map +1 -0
- package/build/ts/vote/types.d.ts +238 -0
- package/build/ts/vote/types.d.ts.map +1 -0
- package/build/ts/vote/types.js +3 -0
- package/build/ts/vote/types.js.map +1 -0
- package/build/ts/vote/utils.d.ts +16 -0
- package/build/ts/vote/utils.d.ts.map +1 -0
- package/build/ts/vote/utils.js +26 -0
- package/build/ts/vote/utils.js.map +1 -0
- package/build/tsconfig.build.tsbuildinfo +1 -0
- package/package.json +57 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { PrivKey, PubKey } from "@maci-protocol/domainobjs";
|
|
2
|
+
import type { IGetPollJoiningCircuitEventsArgs, IGetPollJoiningCircuitInputsFromStateFileArgs, IParsePollJoinEventsArgs, IParseSignupEventsArgs, IPollJoiningCircuitInputs } from "./types";
|
|
3
|
+
import { IGenerateSignUpTree } from "../trees";
|
|
4
|
+
import { CircuitInputs } from "../utils/types";
|
|
5
|
+
/**
|
|
6
|
+
* Parse the poll joining events from the Poll contract
|
|
7
|
+
*/
|
|
8
|
+
export declare const parsePollJoinEvents: ({ pollContract, startBlock, currentBlock, pollPublicKey, }: IParsePollJoinEventsArgs) => Promise<{
|
|
9
|
+
pollStateIndex?: string;
|
|
10
|
+
voiceCredits?: string;
|
|
11
|
+
}>;
|
|
12
|
+
/**
|
|
13
|
+
* Parse the signup events from the MACI contract
|
|
14
|
+
*/
|
|
15
|
+
export declare const parseSignupEvents: ({ maciContract, startBlock, currentBlock, publicKey, }: IParseSignupEventsArgs) => Promise<{
|
|
16
|
+
stateIndex?: string;
|
|
17
|
+
}>;
|
|
18
|
+
/**
|
|
19
|
+
* Get state index from maci state leaves or from sign up leaves
|
|
20
|
+
* @param pubKeys Public keys from maci state or sign up tree
|
|
21
|
+
* @param userMaciPubKey Public key of the maci user
|
|
22
|
+
* @param stateIndex State index from the command
|
|
23
|
+
* @returns State index
|
|
24
|
+
*/
|
|
25
|
+
export declare const getStateIndex: (pubKeys: PubKey[], userMaciPubKey: PubKey, stateIndex?: bigint) => bigint | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Create circuit input for pollJoining
|
|
28
|
+
* @param signUpData Sign up tree and state leaves
|
|
29
|
+
* @param stateTreeDepth Maci state tree depth
|
|
30
|
+
* @param maciPrivKey User's private key for signing up
|
|
31
|
+
* @param stateLeafIndex Index where the user is stored in the state leaves
|
|
32
|
+
* @param pollPrivKey Poll's private key for the poll joining
|
|
33
|
+
* @param pollPubKey Poll's public key for the poll joining
|
|
34
|
+
* @param pollId Poll's id
|
|
35
|
+
* @returns stringified circuit inputs
|
|
36
|
+
*/
|
|
37
|
+
export declare const joiningCircuitInputs: (signUpData: IGenerateSignUpTree, stateTreeDepth: bigint, maciPrivKey: PrivKey, stateLeafIndex: bigint, pollPubKey: PubKey, pollId: bigint) => IPollJoiningCircuitInputs;
|
|
38
|
+
/**
|
|
39
|
+
* Get the poll joining circuit inputs from a state file
|
|
40
|
+
* @param stateFile - The path to the state file
|
|
41
|
+
* @returns The poll joining circuit inputs
|
|
42
|
+
*/
|
|
43
|
+
export declare const getPollJoiningCircuitInputsFromStateFile: ({ stateFile, pollId, stateIndex, userMaciPrivKey, }: IGetPollJoiningCircuitInputsFromStateFileArgs) => Promise<CircuitInputs>;
|
|
44
|
+
/**
|
|
45
|
+
* Get the poll joining circuit events from a state file
|
|
46
|
+
* @param maciContract - The MACI contract
|
|
47
|
+
* @param startBlock - The start block
|
|
48
|
+
* @param signer - The signer
|
|
49
|
+
* @returns The poll joining circuit events
|
|
50
|
+
*/
|
|
51
|
+
export declare const getPollJoiningCircuitEvents: ({ maciContract, stateIndex, pollId, userMaciPrivKey, signer, startBlock, endBlock, blocksPerBatch, }: IGetPollJoiningCircuitEventsArgs) => Promise<CircuitInputs>;
|
|
52
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../ts/user/utils.ts"],"names":[],"mappings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mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getPollJoiningCircuitEvents = exports.getPollJoiningCircuitInputsFromStateFile = exports.joiningCircuitInputs = exports.getStateIndex = exports.parseSignupEvents = exports.parsePollJoinEvents = void 0;
|
|
7
|
+
const core_1 = require("@maci-protocol/core");
|
|
8
|
+
const crypto_1 = require("@maci-protocol/crypto");
|
|
9
|
+
const domainobjs_1 = require("@maci-protocol/domainobjs");
|
|
10
|
+
const fs_1 = __importDefault(require("fs"));
|
|
11
|
+
const trees_1 = require("../trees");
|
|
12
|
+
const constants_1 = require("../utils/constants");
|
|
13
|
+
/**
|
|
14
|
+
* Parse the poll joining events from the Poll contract
|
|
15
|
+
*/
|
|
16
|
+
const parsePollJoinEvents = async ({ pollContract, startBlock, currentBlock, pollPublicKey, }) => {
|
|
17
|
+
for (let block = startBlock; block <= currentBlock; block += constants_1.BLOCKS_STEP) {
|
|
18
|
+
const toBlock = Math.min(block + constants_1.BLOCKS_STEP - 1, currentBlock);
|
|
19
|
+
const pubKey = pollPublicKey.asArray();
|
|
20
|
+
// eslint-disable-next-line no-await-in-loop
|
|
21
|
+
const newEvents = await pollContract.queryFilter(pollContract.filters.PollJoined(pubKey[0], pubKey[1], undefined, undefined, undefined, undefined), block, toBlock);
|
|
22
|
+
if (newEvents.length > 0) {
|
|
23
|
+
const [event] = newEvents;
|
|
24
|
+
return {
|
|
25
|
+
pollStateIndex: event.args[5].toString(),
|
|
26
|
+
voiceCredits: event.args[2].toString(),
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
pollStateIndex: undefined,
|
|
32
|
+
voiceCredits: undefined,
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
exports.parsePollJoinEvents = parsePollJoinEvents;
|
|
36
|
+
/**
|
|
37
|
+
* Parse the signup events from the MACI contract
|
|
38
|
+
*/
|
|
39
|
+
const parseSignupEvents = async ({ maciContract, startBlock, currentBlock, publicKey, }) => {
|
|
40
|
+
for (let block = startBlock; block <= currentBlock; block += constants_1.BLOCKS_STEP) {
|
|
41
|
+
const toBlock = Math.min(block + constants_1.BLOCKS_STEP - 1, currentBlock);
|
|
42
|
+
// eslint-disable-next-line no-await-in-loop
|
|
43
|
+
const newEvents = await maciContract.queryFilter(maciContract.filters.SignUp(undefined, undefined, publicKey.rawPubKey[0], publicKey.rawPubKey[1]), block, toBlock);
|
|
44
|
+
if (newEvents.length > 0) {
|
|
45
|
+
const [event] = newEvents;
|
|
46
|
+
return {
|
|
47
|
+
stateIndex: event.args[0].toString(),
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
stateIndex: undefined,
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
exports.parseSignupEvents = parseSignupEvents;
|
|
56
|
+
/**
|
|
57
|
+
* Get state index from maci state leaves or from sign up leaves
|
|
58
|
+
* @param pubKeys Public keys from maci state or sign up tree
|
|
59
|
+
* @param userMaciPubKey Public key of the maci user
|
|
60
|
+
* @param stateIndex State index from the command
|
|
61
|
+
* @returns State index
|
|
62
|
+
*/
|
|
63
|
+
const getStateIndex = (pubKeys, userMaciPubKey, stateIndex) => {
|
|
64
|
+
if (!stateIndex) {
|
|
65
|
+
const index = pubKeys.findIndex((key) => key.equals(userMaciPubKey));
|
|
66
|
+
if (index > 0) {
|
|
67
|
+
return BigInt(index);
|
|
68
|
+
}
|
|
69
|
+
throw new Error("MACI Public key not found");
|
|
70
|
+
}
|
|
71
|
+
return stateIndex;
|
|
72
|
+
};
|
|
73
|
+
exports.getStateIndex = getStateIndex;
|
|
74
|
+
/**
|
|
75
|
+
* Create circuit input for pollJoining
|
|
76
|
+
* @param signUpData Sign up tree and state leaves
|
|
77
|
+
* @param stateTreeDepth Maci state tree depth
|
|
78
|
+
* @param maciPrivKey User's private key for signing up
|
|
79
|
+
* @param stateLeafIndex Index where the user is stored in the state leaves
|
|
80
|
+
* @param pollPrivKey Poll's private key for the poll joining
|
|
81
|
+
* @param pollPubKey Poll's public key for the poll joining
|
|
82
|
+
* @param pollId Poll's id
|
|
83
|
+
* @returns stringified circuit inputs
|
|
84
|
+
*/
|
|
85
|
+
const joiningCircuitInputs = (signUpData, stateTreeDepth, maciPrivKey, stateLeafIndex, pollPubKey, pollId) => {
|
|
86
|
+
// Get the state leaf on the index position
|
|
87
|
+
const { signUpTree: stateTree } = signUpData;
|
|
88
|
+
// calculate the path elements for the state tree given the original state tree
|
|
89
|
+
const { siblings, index } = stateTree.generateProof(Number(stateLeafIndex));
|
|
90
|
+
const siblingsLength = siblings.length;
|
|
91
|
+
// The index must be converted to a list of indices, 1 for each tree level.
|
|
92
|
+
// The circuit tree depth is this.stateTreeDepth, so the number of siblings must be this.stateTreeDepth,
|
|
93
|
+
// even if the tree depth is actually 3. The missing siblings can be set to 0, as they
|
|
94
|
+
// won't be used to calculate the root in the circuit.
|
|
95
|
+
const indices = [];
|
|
96
|
+
for (let i = 0; i < stateTreeDepth; i += 1) {
|
|
97
|
+
// eslint-disable-next-line no-bitwise
|
|
98
|
+
indices.push(BigInt((index >> i) & 1));
|
|
99
|
+
if (i >= siblingsLength) {
|
|
100
|
+
siblings[i] = BigInt(0);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
const siblingsArray = siblings.map((sibling) => [sibling]);
|
|
104
|
+
// Create nullifier from private key
|
|
105
|
+
const inputNullifier = BigInt(maciPrivKey.asCircuitInputs());
|
|
106
|
+
const nullifier = (0, crypto_1.poseidon)([inputNullifier, pollId]);
|
|
107
|
+
// Get pll state tree's root
|
|
108
|
+
const stateRoot = stateTree.root;
|
|
109
|
+
// Set actualStateTreeDepth as number of initial siblings length
|
|
110
|
+
const actualStateTreeDepth = BigInt(siblingsLength);
|
|
111
|
+
// Calculate public input hash from nullifier, credits and current root
|
|
112
|
+
const circuitInputs = {
|
|
113
|
+
privKey: maciPrivKey.asCircuitInputs(),
|
|
114
|
+
pollPubKey: pollPubKey.asCircuitInputs(),
|
|
115
|
+
siblings: siblingsArray,
|
|
116
|
+
indices,
|
|
117
|
+
nullifier,
|
|
118
|
+
stateRoot,
|
|
119
|
+
actualStateTreeDepth,
|
|
120
|
+
pollId,
|
|
121
|
+
};
|
|
122
|
+
return (0, crypto_1.stringifyBigInts)(circuitInputs);
|
|
123
|
+
};
|
|
124
|
+
exports.joiningCircuitInputs = joiningCircuitInputs;
|
|
125
|
+
/**
|
|
126
|
+
* Get the poll joining circuit inputs from a state file
|
|
127
|
+
* @param stateFile - The path to the state file
|
|
128
|
+
* @returns The poll joining circuit inputs
|
|
129
|
+
*/
|
|
130
|
+
const getPollJoiningCircuitInputsFromStateFile = async ({ stateFile, pollId, stateIndex, userMaciPrivKey, }) => {
|
|
131
|
+
const file = await fs_1.default.promises.readFile(stateFile);
|
|
132
|
+
const content = JSON.parse(file.toString());
|
|
133
|
+
const maciState = core_1.MaciState.fromJSON(content);
|
|
134
|
+
const poll = maciState.polls.get(pollId);
|
|
135
|
+
const { pubKey: userPubKey } = new domainobjs_1.Keypair(userMaciPrivKey);
|
|
136
|
+
const loadedStateIndex = (0, exports.getStateIndex)(maciState.pubKeys, userPubKey, stateIndex);
|
|
137
|
+
// check < 1 cause index zero is a blank state leaf
|
|
138
|
+
if (loadedStateIndex < 1) {
|
|
139
|
+
throw new Error("Invalid state index");
|
|
140
|
+
}
|
|
141
|
+
poll.updatePoll(BigInt(maciState.pubKeys.length));
|
|
142
|
+
const circuitInputs = poll.joiningCircuitInputs({
|
|
143
|
+
maciPrivKey: userMaciPrivKey,
|
|
144
|
+
stateLeafIndex: stateIndex,
|
|
145
|
+
pollPubKey: userPubKey,
|
|
146
|
+
});
|
|
147
|
+
return circuitInputs;
|
|
148
|
+
};
|
|
149
|
+
exports.getPollJoiningCircuitInputsFromStateFile = getPollJoiningCircuitInputsFromStateFile;
|
|
150
|
+
/**
|
|
151
|
+
* Get the poll joining circuit events from a state file
|
|
152
|
+
* @param maciContract - The MACI contract
|
|
153
|
+
* @param startBlock - The start block
|
|
154
|
+
* @param signer - The signer
|
|
155
|
+
* @returns The poll joining circuit events
|
|
156
|
+
*/
|
|
157
|
+
const getPollJoiningCircuitEvents = async ({ maciContract, stateIndex, pollId, userMaciPrivKey, signer, startBlock, endBlock, blocksPerBatch, }) => {
|
|
158
|
+
// build an off-chain representation of the MACI contract using data in the contract storage
|
|
159
|
+
const [defaultStartBlockSignup, defaultStartBlockPoll, stateTreeDepth] = await Promise.all([
|
|
160
|
+
maciContract
|
|
161
|
+
.queryFilter(maciContract.filters.SignUp(), startBlock ?? 0)
|
|
162
|
+
.then((events) => events[0]?.blockNumber ?? 0),
|
|
163
|
+
maciContract
|
|
164
|
+
.queryFilter(maciContract.filters.DeployPoll(), startBlock ?? 0)
|
|
165
|
+
.then((events) => events[0]?.blockNumber ?? 0),
|
|
166
|
+
maciContract.stateTreeDepth(),
|
|
167
|
+
]);
|
|
168
|
+
const defaultStartBlock = Math.min(defaultStartBlockPoll, defaultStartBlockSignup);
|
|
169
|
+
const fromBlock = startBlock ? Number(startBlock) : defaultStartBlock;
|
|
170
|
+
const signUpData = await (0, trees_1.generateSignUpTree)({
|
|
171
|
+
provider: signer.provider,
|
|
172
|
+
address: await maciContract.getAddress(),
|
|
173
|
+
blocksPerRequest: blocksPerBatch || 50,
|
|
174
|
+
fromBlock,
|
|
175
|
+
endBlock,
|
|
176
|
+
sleepAmount: 0,
|
|
177
|
+
});
|
|
178
|
+
const { pubKey: userPubKey } = new domainobjs_1.Keypair(userMaciPrivKey);
|
|
179
|
+
const loadedStateIndex = (0, exports.getStateIndex)(signUpData.pubKeys, userPubKey, stateIndex);
|
|
180
|
+
if (loadedStateIndex < 1) {
|
|
181
|
+
throw new Error("Invalid state index");
|
|
182
|
+
}
|
|
183
|
+
return (0, exports.joiningCircuitInputs)(signUpData, stateTreeDepth, userMaciPrivKey, stateIndex, userPubKey, pollId);
|
|
184
|
+
};
|
|
185
|
+
exports.getPollJoiningCircuitEvents = getPollJoiningCircuitEvents;
|
|
186
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../ts/user/utils.ts"],"names":[],"mappings":";;;;;;AAAA,8CAAgE;AAChE,kDAAmE;AACnE,0DAAqE;AAErE,4CAAoB;AAUpB,oCAAmE;AACnE,kDAAiD;AAGjD;;GAEG;AACI,MAAM,mBAAmB,GAAG,KAAK,EAAE,EACxC,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,aAAa,GACY,EAGxB,EAAE;IACH,KAAK,IAAI,KAAK,GAAG,UAAU,EAAE,KAAK,IAAI,YAAY,EAAE,KAAK,IAAI,uBAAW,EAAE,CAAC;QACzE,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,uBAAW,GAAG,CAAC,EAAE,YAAY,CAAC,CAAC;QAChE,MAAM,MAAM,GAAG,aAAa,CAAC,OAAO,EAAE,CAAC;QACvC,4CAA4C;QAC5C,MAAM,SAAS,GAAG,MAAM,YAAY,CAAC,WAAW,CAC9C,YAAY,CAAC,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC,EACjG,KAAK,EACL,OAAO,CACR,CAAC;QAEF,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACzB,MAAM,CAAC,KAAK,CAAC,GAAG,SAAS,CAAC;YAE1B,OAAO;gBACL,cAAc,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;gBACxC,YAAY,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;aACvC,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO;QACL,cAAc,E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S,GAAG,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC;IAEtE,MAAM,UAAU,GAAG,MAAM,IAAA,0BAAkB,EAAC;QAC1C,QAAQ,EAAE,MAAM,CAAC,QAAS;QAC1B,OAAO,EAAE,MAAM,YAAY,CAAC,UAAU,EAAE;QACxC,gBAAgB,EAAE,cAAc,IAAI,EAAE;QACtC,SAAS;QACT,QAAQ;QACR,WAAW,EAAE,CAAC;KACf,CAAC,CAAC;IAEH,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,IAAI,oBAAO,CAAC,eAAe,CAAC,CAAC;IAC5D,MAAM,gBAAgB,GAAG,IAAA,qBAAa,EAAC,UAAU,CAAC,OAAO,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;IAEnF,IAAI,gBAAiB,GAAG,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;IACzC,CAAC;IAED,OAAO,IAAA,4BAAoB,EACzB,UAAU,EACV,cAAc,EACd,eAAe,EACf,UAAU,EACV,UAAU,EACV,MAAM,CACqB,CAAC;AAChC,CAAC,CAAC;AA/CW,QAAA,2BAA2B,+BA+CtC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts an IPFS CIDv1 to a bytes32-compatible hex string.
|
|
3
|
+
*
|
|
4
|
+
* This function:
|
|
5
|
+
* - Decodes the Base32-encoded CIDv1
|
|
6
|
+
* - Extracts the SHA-256 digest from the multihash
|
|
7
|
+
* - Converts it to a Solidity-compatible `bytes32` format
|
|
8
|
+
*
|
|
9
|
+
* @param hash - The CIDv1 string
|
|
10
|
+
* @returns A `bytes32`-compatible hex string (e.g., `0x...`)
|
|
11
|
+
*/
|
|
12
|
+
export declare const cidToBytes32: (hash: string) => Promise<string>;
|
|
13
|
+
/**
|
|
14
|
+
* Creates a CID (Content Identifier) from an object by encoding the object into JSON and
|
|
15
|
+
* hashing it using the SHA-256 algorithm, and then creating a CID using the Multiformats CID library.
|
|
16
|
+
*
|
|
17
|
+
* @template T
|
|
18
|
+
* @param {T} data The input object to be encoded and hashed to generate the CID.
|
|
19
|
+
* @returns A CID generated from the hashed JSON-encoded object.
|
|
20
|
+
*
|
|
21
|
+
*/
|
|
22
|
+
export declare const createCidFromObject: <T>(data: T) => Promise<string>;
|
|
23
|
+
//# sourceMappingURL=cid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cid.d.ts","sourceRoot":"","sources":["../../../ts/utils/cid.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,YAAY,GAAU,MAAM,MAAM,KAAG,OAAO,CAAC,MAAM,CAI/D,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,mBAAmB,GAAU,CAAC,EAAE,MAAM,CAAC,KAAG,OAAO,CAAC,MAAM,CAUpE,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.createCidFromObject = exports.cidToBytes32 = void 0;
|
|
37
|
+
/**
|
|
38
|
+
* Converts an IPFS CIDv1 to a bytes32-compatible hex string.
|
|
39
|
+
*
|
|
40
|
+
* This function:
|
|
41
|
+
* - Decodes the Base32-encoded CIDv1
|
|
42
|
+
* - Extracts the SHA-256 digest from the multihash
|
|
43
|
+
* - Converts it to a Solidity-compatible `bytes32` format
|
|
44
|
+
*
|
|
45
|
+
* @param hash - The CIDv1 string
|
|
46
|
+
* @returns A `bytes32`-compatible hex string (e.g., `0x...`)
|
|
47
|
+
*/
|
|
48
|
+
const cidToBytes32 = async (hash) => {
|
|
49
|
+
const [{ CID }, { ethers }] = await Promise.all([Promise.resolve().then(() => __importStar(require("multiformats/cid"))), Promise.resolve().then(() => __importStar(require("ethers")))]);
|
|
50
|
+
return ethers.hexlify(CID.parse(hash).multihash.digest);
|
|
51
|
+
};
|
|
52
|
+
exports.cidToBytes32 = cidToBytes32;
|
|
53
|
+
/**
|
|
54
|
+
* Creates a CID (Content Identifier) from an object by encoding the object into JSON and
|
|
55
|
+
* hashing it using the SHA-256 algorithm, and then creating a CID using the Multiformats CID library.
|
|
56
|
+
*
|
|
57
|
+
* @template T
|
|
58
|
+
* @param {T} data The input object to be encoded and hashed to generate the CID.
|
|
59
|
+
* @returns A CID generated from the hashed JSON-encoded object.
|
|
60
|
+
*
|
|
61
|
+
*/
|
|
62
|
+
const createCidFromObject = async (data) => {
|
|
63
|
+
const [{ CID }, json, { sha256 }] = await Promise.all([
|
|
64
|
+
Promise.resolve().then(() => __importStar(require("multiformats/cid"))),
|
|
65
|
+
Promise.resolve().then(() => __importStar(require("multiformats/codecs/json"))),
|
|
66
|
+
Promise.resolve().then(() => __importStar(require("multiformats/hashes/sha2"))),
|
|
67
|
+
]);
|
|
68
|
+
const hash = await sha256.digest(json.encode(data));
|
|
69
|
+
return CID.create(1, json.code, hash).toString();
|
|
70
|
+
};
|
|
71
|
+
exports.createCidFromObject = createCidFromObject;
|
|
72
|
+
//# sourceMappingURL=cid.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cid.js","sourceRoot":"","sources":["../../../ts/utils/cid.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;GAUG;AACI,MAAM,YAAY,GAAG,KAAK,EAAE,IAAY,EAAmB,EAAE;IAClE,MAAM,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,mDAAQ,kBAAkB,uDAAU,QAAQ,IAAE,CAAC,CAAC;IAEhG,OAAO,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;AAC1D,CAAC,CAAC;AAJW,QAAA,YAAY,gBAIvB;AAEF;;;;;;;;GAQG;AACI,MAAM,mBAAmB,GAAG,KAAK,EAAK,IAAO,EAAmB,EAAE;IACvE,MAAM,CAAC,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;0DAC7C,kBAAkB;0DAClB,0BAA0B;0DAC1B,0BAA0B;KAClC,CAAC,CAAC;IAEH,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;IAEpD,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC;AACnD,CAAC,CAAC;AAVW,QAAA,mBAAmB,uBAU9B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../ts/utils/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,OAAO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../ts/utils/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,WAAW,GAAG,IAAI,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Provider } from "ethers";
|
|
2
|
+
/**
|
|
3
|
+
* Small utility function to check whether a contract exists at a given address
|
|
4
|
+
* @param provider - the provider to use to interact with the chain
|
|
5
|
+
* @param address - the address of the contract to check
|
|
6
|
+
* @returns a boolean indicating whether the contract exists
|
|
7
|
+
*/
|
|
8
|
+
export declare const contractExists: (provider: Provider, address: string) => Promise<boolean>;
|
|
9
|
+
/**
|
|
10
|
+
* Small utility to retrieve the current block timestamp from the blockchain
|
|
11
|
+
* @param provider the provider to use to interact with the chain
|
|
12
|
+
* @returns the current block timestamp
|
|
13
|
+
*/
|
|
14
|
+
export declare const currentBlockTimestamp: (provider: Provider) => Promise<number>;
|
|
15
|
+
//# sourceMappingURL=contracts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../../../ts/utils/contracts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAEvC;;;;;GAKG;AACH,eAAO,MAAM,cAAc,GAAU,UAAU,QAAQ,EAAE,SAAS,MAAM,KAAG,OAAO,CAAC,OAAO,CAGzF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GAAU,UAAU,QAAQ,KAAG,OAAO,CAAC,MAAM,CAK9E,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.currentBlockTimestamp = exports.contractExists = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Small utility function to check whether a contract exists at a given address
|
|
6
|
+
* @param provider - the provider to use to interact with the chain
|
|
7
|
+
* @param address - the address of the contract to check
|
|
8
|
+
* @returns a boolean indicating whether the contract exists
|
|
9
|
+
*/
|
|
10
|
+
const contractExists = async (provider, address) => {
|
|
11
|
+
const code = await provider.getCode(address);
|
|
12
|
+
return code.length > 2;
|
|
13
|
+
};
|
|
14
|
+
exports.contractExists = contractExists;
|
|
15
|
+
/**
|
|
16
|
+
* Small utility to retrieve the current block timestamp from the blockchain
|
|
17
|
+
* @param provider the provider to use to interact with the chain
|
|
18
|
+
* @returns the current block timestamp
|
|
19
|
+
*/
|
|
20
|
+
const currentBlockTimestamp = async (provider) => {
|
|
21
|
+
const blockNum = await provider.getBlockNumber();
|
|
22
|
+
const block = await provider.getBlock(blockNum);
|
|
23
|
+
return Number(block?.timestamp);
|
|
24
|
+
};
|
|
25
|
+
exports.currentBlockTimestamp = currentBlockTimestamp;
|
|
26
|
+
//# sourceMappingURL=contracts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contracts.js","sourceRoot":"","sources":["../../../ts/utils/contracts.ts"],"names":[],"mappings":";;;AAEA;;;;;GAKG;AACI,MAAM,cAAc,GAAG,KAAK,EAAE,QAAkB,EAAE,OAAe,EAAoB,EAAE;IAC5F,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAC7C,OAAO,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;AACzB,CAAC,CAAC;AAHW,QAAA,cAAc,kBAGzB;AAEF;;;;GAIG;AACI,MAAM,qBAAqB,GAAG,KAAK,EAAE,QAAkB,EAAmB,EAAE;IACjF,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,cAAc,EAAE,CAAC;IACjD,MAAM,KAAK,GAAG,MAAM,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAEhD,OAAO,MAAM,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;AAClC,CAAC,CAAC;AALW,QAAA,qBAAqB,yBAKhC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check if an array of paths exist on the local file system
|
|
3
|
+
* @param paths - the array of paths to check
|
|
4
|
+
* @returns an array of boolean and string,
|
|
5
|
+
* where the boolean indicates whether all paths exist, and the string
|
|
6
|
+
* is the path that does not exist
|
|
7
|
+
*/
|
|
8
|
+
export declare const doesPathExist: (paths: string[]) => [boolean, string | null];
|
|
9
|
+
//# sourceMappingURL=files.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../../ts/utils/files.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,GAAI,OAAO,MAAM,EAAE,KAAG,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAItE,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.doesPathExist = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
/**
|
|
9
|
+
* Check if an array of paths exist on the local file system
|
|
10
|
+
* @param paths - the array of paths to check
|
|
11
|
+
* @returns an array of boolean and string,
|
|
12
|
+
* where the boolean indicates whether all paths exist, and the string
|
|
13
|
+
* is the path that does not exist
|
|
14
|
+
*/
|
|
15
|
+
const doesPathExist = (paths) => {
|
|
16
|
+
const notFoundPath = paths.find((path) => !fs_1.default.existsSync(path));
|
|
17
|
+
return notFoundPath ? [false, notFoundPath] : [true, null];
|
|
18
|
+
};
|
|
19
|
+
exports.doesPathExist = doesPathExist;
|
|
20
|
+
//# sourceMappingURL=files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.js","sourceRoot":"","sources":["../../../ts/utils/files.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AAEpB;;;;;;GAMG;AACI,MAAM,aAAa,GAAG,CAAC,KAAe,EAA4B,EAAE;IACzE,MAAM,YAAY,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,YAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;IAEhE,OAAO,YAAY,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AAC7D,CAAC,CAAC;AAJW,QAAA,aAAa,iBAIxB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { BigNumberish } from "ethers";
|
|
2
|
+
/**
|
|
3
|
+
* Convert a value to its hex representation
|
|
4
|
+
* @param val - the value to convert
|
|
5
|
+
* @returns the value converted as a hex string
|
|
6
|
+
*/
|
|
7
|
+
export declare const asHex: (val: BigNumberish) => string;
|
|
8
|
+
//# sourceMappingURL=formatting.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatting.d.ts","sourceRoot":"","sources":["../../../ts/utils/formatting.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAE3C;;;;GAIG;AACH,eAAO,MAAM,KAAK,GAAI,KAAK,YAAY,KAAG,MAAyC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.asHex = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Convert a value to its hex representation
|
|
6
|
+
* @param val - the value to convert
|
|
7
|
+
* @returns the value converted as a hex string
|
|
8
|
+
*/
|
|
9
|
+
const asHex = (val) => `0x${BigInt(val).toString(16)}`;
|
|
10
|
+
exports.asHex = asHex;
|
|
11
|
+
//# sourceMappingURL=formatting.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatting.js","sourceRoot":"","sources":["../../../ts/utils/formatting.ts"],"names":[],"mappings":";;;AAEA;;;;GAIG;AACI,MAAM,KAAK,GAAG,CAAC,GAAiB,EAAU,EAAE,CAAC,KAAK,MAAM,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC;AAAvE,QAAA,KAAK,SAAkE"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { IFundWalletArgs } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Fund a new wallet with Ether
|
|
4
|
+
* @param args Fund wallet arguments
|
|
5
|
+
*/
|
|
6
|
+
export declare const fundWallet: ({ amount, address, signer }: IFundWalletArgs) => Promise<string>;
|
|
7
|
+
//# sourceMappingURL=fundWallet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fundWallet.d.ts","sourceRoot":"","sources":["../../../ts/utils/fundWallet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C;;;GAGG;AACH,eAAO,MAAM,UAAU,GAAU,6BAA6B,eAAe,KAAG,OAAO,CAAC,MAAM,CAY7F,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fundWallet = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Fund a new wallet with Ether
|
|
6
|
+
* @param args Fund wallet arguments
|
|
7
|
+
*/
|
|
8
|
+
const fundWallet = async ({ amount, address, signer }) => {
|
|
9
|
+
const tx = await signer.sendTransaction({
|
|
10
|
+
to: address,
|
|
11
|
+
value: amount.toString(),
|
|
12
|
+
});
|
|
13
|
+
const receipt = await tx.wait();
|
|
14
|
+
if (receipt?.status !== 1) {
|
|
15
|
+
throw new Error("Transaction failed");
|
|
16
|
+
}
|
|
17
|
+
return receipt.hash;
|
|
18
|
+
};
|
|
19
|
+
exports.fundWallet = fundWallet;
|
|
20
|
+
//# sourceMappingURL=fundWallet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fundWallet.js","sourceRoot":"","sources":["../../../ts/utils/fundWallet.ts"],"names":[],"mappings":";;;AAEA;;;GAGG;AACI,MAAM,UAAU,GAAG,KAAK,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAmB,EAAmB,EAAE;IAChG,MAAM,EAAE,GAAG,MAAM,MAAM,CAAC,eAAe,CAAC;QACtC,EAAE,EAAE,OAAO;QACX,KAAK,EAAE,MAAM,CAAC,QAAQ,EAAE;KACzB,CAAC,CAAC;IACH,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC;IAEhC,IAAI,OAAO,EAAE,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;IACxC,CAAC;IAED,OAAO,OAAO,CAAC,IAAI,CAAC;AACtB,CAAC,CAAC;AAZW,QAAA,UAAU,cAYrB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { cidToBytes32, createCidFromObject } from "./cid";
|
|
2
|
+
export { BLOCKS_STEP } from "./constants";
|
|
3
|
+
export { contractExists, currentBlockTimestamp } from "./contracts";
|
|
4
|
+
export { asHex } from "./formatting";
|
|
5
|
+
export { fundWallet } from "./fundWallet";
|
|
6
|
+
export { validateParams } from "./params";
|
|
7
|
+
export { timeTravel } from "./timeTravel";
|
|
8
|
+
export { calculateBinaryTreeDepthFromMaxLeaves, calculateQuinTreeDepthFromMaxLeaves } from "./trees";
|
|
9
|
+
export { isArm, sleep } from "./utils";
|
|
10
|
+
export { generateAndVerifyProof } from "./proofs";
|
|
11
|
+
export type { ICircuitParams, ISnarkJSVerificationKey, ITimeTravelArgs, IFundWalletArgs } from "./types";
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../ts/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,qCAAqC,EAAE,mCAAmC,EAAE,MAAM,SAAS,CAAC;AACrG,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAElD,YAAY,EAAE,cAAc,EAAE,uBAAuB,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateAndVerifyProof = exports.sleep = exports.isArm = exports.calculateQuinTreeDepthFromMaxLeaves = exports.calculateBinaryTreeDepthFromMaxLeaves = exports.timeTravel = exports.validateParams = exports.fundWallet = exports.asHex = exports.currentBlockTimestamp = exports.contractExists = exports.BLOCKS_STEP = exports.createCidFromObject = exports.cidToBytes32 = void 0;
|
|
4
|
+
var cid_1 = require("./cid");
|
|
5
|
+
Object.defineProperty(exports, "cidToBytes32", { enumerable: true, get: function () { return cid_1.cidToBytes32; } });
|
|
6
|
+
Object.defineProperty(exports, "createCidFromObject", { enumerable: true, get: function () { return cid_1.createCidFromObject; } });
|
|
7
|
+
var constants_1 = require("./constants");
|
|
8
|
+
Object.defineProperty(exports, "BLOCKS_STEP", { enumerable: true, get: function () { return constants_1.BLOCKS_STEP; } });
|
|
9
|
+
var contracts_1 = require("./contracts");
|
|
10
|
+
Object.defineProperty(exports, "contractExists", { enumerable: true, get: function () { return contracts_1.contractExists; } });
|
|
11
|
+
Object.defineProperty(exports, "currentBlockTimestamp", { enumerable: true, get: function () { return contracts_1.currentBlockTimestamp; } });
|
|
12
|
+
var formatting_1 = require("./formatting");
|
|
13
|
+
Object.defineProperty(exports, "asHex", { enumerable: true, get: function () { return formatting_1.asHex; } });
|
|
14
|
+
var fundWallet_1 = require("./fundWallet");
|
|
15
|
+
Object.defineProperty(exports, "fundWallet", { enumerable: true, get: function () { return fundWallet_1.fundWallet; } });
|
|
16
|
+
var params_1 = require("./params");
|
|
17
|
+
Object.defineProperty(exports, "validateParams", { enumerable: true, get: function () { return params_1.validateParams; } });
|
|
18
|
+
var timeTravel_1 = require("./timeTravel");
|
|
19
|
+
Object.defineProperty(exports, "timeTravel", { enumerable: true, get: function () { return timeTravel_1.timeTravel; } });
|
|
20
|
+
var trees_1 = require("./trees");
|
|
21
|
+
Object.defineProperty(exports, "calculateBinaryTreeDepthFromMaxLeaves", { enumerable: true, get: function () { return trees_1.calculateBinaryTreeDepthFromMaxLeaves; } });
|
|
22
|
+
Object.defineProperty(exports, "calculateQuinTreeDepthFromMaxLeaves", { enumerable: true, get: function () { return trees_1.calculateQuinTreeDepthFromMaxLeaves; } });
|
|
23
|
+
var utils_1 = require("./utils");
|
|
24
|
+
Object.defineProperty(exports, "isArm", { enumerable: true, get: function () { return utils_1.isArm; } });
|
|
25
|
+
Object.defineProperty(exports, "sleep", { enumerable: true, get: function () { return utils_1.sleep; } });
|
|
26
|
+
var proofs_1 = require("./proofs");
|
|
27
|
+
Object.defineProperty(exports, "generateAndVerifyProof", { enumerable: true, get: function () { return proofs_1.generateAndVerifyProof; } });
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../ts/utils/index.ts"],"names":[],"mappings":";;;AAAA,6BAA0D;AAAjD,mGAAA,YAAY,OAAA;AAAE,0GAAA,mBAAmB,OAAA;AAC1C,yCAA0C;AAAjC,wGAAA,WAAW,OAAA;AACpB,yCAAoE;AAA3D,2GAAA,cAAc,OAAA;AAAE,kHAAA,qBAAqB,OAAA;AAC9C,2CAAqC;AAA5B,mGAAA,KAAK,OAAA;AACd,2CAA0C;AAAjC,wGAAA,UAAU,OAAA;AACnB,mCAA0C;AAAjC,wGAAA,cAAc,OAAA;AACvB,2CAA0C;AAAjC,wGAAA,UAAU,OAAA;AACnB,iCAAqG;AAA5F,8HAAA,qCAAqC,OAAA;AAAE,4HAAA,mCAAmC,OAAA;AACnF,iCAAuC;AAA9B,8FAAA,KAAK,OAAA;AAAE,8FAAA,KAAK,OAAA;AACrB,mCAAkD;AAAzC,gHAAA,sBAAsB,OAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ICircuitParams } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Validate the circuit parameters
|
|
4
|
+
* @param params - The circuit parameters
|
|
5
|
+
*/
|
|
6
|
+
export declare const validateParams: ({ stateTreeDepth, intStateTreeDepth, voteOptionTreeDepth, messageBatchSize, }: ICircuitParams) => boolean;
|
|
7
|
+
//# sourceMappingURL=params.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"params.d.ts","sourceRoot":"","sources":["../../../ts/utils/params.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C;;;GAGG;AACH,eAAO,MAAM,cAAc,GAAI,+EAK5B,cAAc,KAAG,OAWnB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateParams = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Validate the circuit parameters
|
|
6
|
+
* @param params - The circuit parameters
|
|
7
|
+
*/
|
|
8
|
+
const validateParams = ({ stateTreeDepth, intStateTreeDepth, voteOptionTreeDepth, messageBatchSize, }) => {
|
|
9
|
+
// validate args
|
|
10
|
+
if (stateTreeDepth < 1 || intStateTreeDepth < 1 || voteOptionTreeDepth < 1 || messageBatchSize < 1) {
|
|
11
|
+
throw new Error("Invalid depth or batch size parameters");
|
|
12
|
+
}
|
|
13
|
+
if (stateTreeDepth < intStateTreeDepth) {
|
|
14
|
+
throw new Error("Invalid state tree depth or intermediate state tree depth");
|
|
15
|
+
}
|
|
16
|
+
return true;
|
|
17
|
+
};
|
|
18
|
+
exports.validateParams = validateParams;
|
|
19
|
+
//# sourceMappingURL=params.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"params.js","sourceRoot":"","sources":["../../../ts/utils/params.ts"],"names":[],"mappings":";;;AAEA;;;GAGG;AACI,MAAM,cAAc,GAAG,CAAC,EAC7B,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,GACD,EAAW,EAAE;IAC5B,gBAAgB;IAChB,IAAI,cAAc,GAAG,CAAC,IAAI,iBAAiB,GAAG,CAAC,IAAI,mBAAmB,GAAG,CAAC,IAAI,gBAAgB,GAAG,CAAC,EAAE,CAAC;QACnG,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;IAC5D,CAAC;IAED,IAAI,cAAc,GAAG,iBAAiB,EAAE,CAAC;QACvC,MAAM,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAC;IAC/E,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAhBW,QAAA,cAAc,kBAgBzB"}
|