@maci-protocol/sdk 0.0.0-ci.f4bc8a6 → 0.0.0-ci.f9da2fc
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/build/package.json +4 -3
- package/build/ts/browser/index.d.ts +5 -7
- package/build/ts/browser/index.d.ts.map +1 -1
- package/build/ts/browser/index.js +11 -20
- package/build/ts/browser/index.js.map +1 -1
- package/build/ts/browser/joinPoll.d.ts +8 -0
- package/build/ts/browser/joinPoll.d.ts.map +1 -0
- package/build/ts/browser/joinPoll.js +84 -0
- package/build/ts/browser/joinPoll.js.map +1 -0
- package/build/ts/browser/utils.d.ts +18 -0
- package/build/ts/browser/utils.d.ts.map +1 -0
- package/build/ts/browser/utils.js +37 -0
- package/build/ts/browser/utils.js.map +1 -0
- package/build/ts/deploy/index.d.ts +1 -0
- package/build/ts/deploy/index.d.ts.map +1 -1
- package/build/ts/deploy/index.js +3 -1
- package/build/ts/deploy/index.js.map +1 -1
- package/build/ts/deploy/poll.d.ts +1 -1
- package/build/ts/deploy/poll.d.ts.map +1 -1
- package/build/ts/deploy/poll.js +12 -6
- package/build/ts/deploy/poll.js.map +1 -1
- package/build/ts/deploy/types.d.ts +8 -0
- package/build/ts/deploy/types.d.ts.map +1 -1
- package/build/ts/index.d.ts +1 -1
- package/build/ts/index.d.ts.map +1 -1
- package/build/ts/index.js +15 -2
- package/build/ts/index.js.map +1 -1
- package/build/ts/maci/policy.d.ts +13 -1
- package/build/ts/maci/policy.d.ts.map +1 -1
- package/build/ts/maci/policy.js +41 -2
- package/build/ts/maci/policy.js.map +1 -1
- package/build/ts/maci/state.js +3 -3
- package/build/ts/maci/state.js.map +1 -1
- package/build/ts/maci/types.d.ts +33 -1
- package/build/ts/maci/types.d.ts.map +1 -1
- package/build/ts/maci/types.js +2 -0
- package/build/ts/maci/types.js.map +1 -1
- package/build/ts/poll/types.d.ts +0 -1
- package/build/ts/poll/types.d.ts.map +1 -1
- package/build/ts/poll/utils.js +3 -3
- package/build/ts/poll/utils.js.map +1 -1
- package/build/ts/proof/generate.js +2 -2
- package/build/ts/proof/generate.js.map +1 -1
- package/build/ts/proof/prove.js +5 -5
- package/build/ts/proof/prove.js.map +1 -1
- package/build/ts/proof/types.d.ts +1 -1
- package/build/ts/proof/types.d.ts.map +1 -1
- package/build/ts/relayer/utils.js +3 -3
- package/build/ts/relayer/utils.js.map +1 -1
- package/build/ts/trees/stateTree.js +7 -4
- package/build/ts/trees/stateTree.js.map +1 -1
- package/build/ts/user/index.d.ts +3 -1
- package/build/ts/user/index.d.ts.map +1 -1
- package/build/ts/user/index.js +10 -8
- package/build/ts/user/index.js.map +1 -1
- package/build/ts/user/joinPoll.d.ts +8 -0
- package/build/ts/user/joinPoll.d.ts.map +1 -0
- package/build/ts/user/joinPoll.js +84 -0
- package/build/ts/user/joinPoll.js.map +1 -0
- package/build/ts/user/signup.d.ts +20 -0
- package/build/ts/user/signup.d.ts.map +1 -0
- package/build/ts/user/signup.js +79 -0
- package/build/ts/user/signup.js.map +1 -0
- package/build/ts/user/types.d.ts +0 -8
- package/build/ts/user/types.d.ts.map +1 -1
- package/build/ts/user/utils.d.ts +19 -3
- package/build/ts/user/utils.d.ts.map +1 -1
- package/build/ts/user/utils.js +43 -5
- package/build/ts/user/utils.js.map +1 -1
- package/build/ts/utils/utils.d.ts +8 -0
- package/build/ts/utils/utils.d.ts.map +1 -1
- package/build/ts/utils/utils.js +14 -1
- package/build/ts/utils/utils.js.map +1 -1
- package/build/ts/verifyingKeys/setVerifyingKeys.d.ts.map +1 -1
- package/build/ts/verifyingKeys/setVerifyingKeys.js +2 -1
- package/build/ts/verifyingKeys/setVerifyingKeys.js.map +1 -1
- package/build/ts/verifyingKeys/utils.d.ts +1 -1
- package/build/ts/verifyingKeys/utils.d.ts.map +1 -1
- package/build/ts/verifyingKeys/utils.js +2 -1
- package/build/ts/verifyingKeys/utils.js.map +1 -1
- package/build/ts/vote/submit.js +3 -3
- package/build/ts/vote/submit.js.map +1 -1
- package/build/ts/vote/utils.js +2 -2
- package/build/ts/vote/utils.js.map +1 -1
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +10 -9
- package/build/ts/user/user.d.ts +0 -42
- package/build/ts/user/user.d.ts.map +0 -1
- package/build/ts/user/user.js +0 -192
- package/build/ts/user/user.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maci-protocol/sdk",
|
|
3
|
-
"version": "0.0.0-ci.
|
|
3
|
+
"version": "0.0.0-ci.f9da2fc",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "MACI's SDK",
|
|
6
6
|
"main": "build/ts/index.js",
|
|
@@ -35,23 +35,24 @@
|
|
|
35
35
|
"docs": "typedoc --plugin typedoc-plugin-markdown --options ./typedoc.json"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@maci-protocol/contracts": "0.0.0-ci.
|
|
39
|
-
"@maci-protocol/core": "0.0.0-ci.
|
|
40
|
-
"@maci-protocol/crypto": "0.0.0-ci.
|
|
41
|
-
"@maci-protocol/domainobjs": "0.0.0-ci.
|
|
38
|
+
"@maci-protocol/contracts": "0.0.0-ci.f9da2fc",
|
|
39
|
+
"@maci-protocol/core": "0.0.0-ci.f9da2fc",
|
|
40
|
+
"@maci-protocol/crypto": "0.0.0-ci.f9da2fc",
|
|
41
|
+
"@maci-protocol/domainobjs": "0.0.0-ci.f9da2fc",
|
|
42
42
|
"@zk-kit/lean-imt": "^2.2.3",
|
|
43
43
|
"ethers": "^6.13.4",
|
|
44
|
-
"multiformats": "9.9.0"
|
|
44
|
+
"multiformats": "9.9.0",
|
|
45
|
+
"snarkjs": "^0.7.5"
|
|
45
46
|
},
|
|
46
47
|
"devDependencies": {
|
|
47
48
|
"@types/jest": "^29.5.2",
|
|
48
|
-
"@types/node": "^22.
|
|
49
|
+
"@types/node": "^22.14.0",
|
|
49
50
|
"@types/snarkjs": "^0.7.9",
|
|
50
51
|
"jest": "^29.5.0",
|
|
51
52
|
"mocha": "^11.1.0",
|
|
52
53
|
"nyc": "^17.1.0",
|
|
53
54
|
"ts-jest": "^29.3.0",
|
|
54
|
-
"typescript": "^5.8.
|
|
55
|
+
"typescript": "^5.8.3"
|
|
55
56
|
},
|
|
56
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "6dbb127aeeb12898e9a75377c8a633a06b9a8132"
|
|
57
58
|
}
|
package/build/ts/user/user.d.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import type { IIsRegisteredUser, IJoinedUserArgs, ISignupArgs, ISignupData, IRegisteredUserArgs, IJoinPollData, IJoinPollArgs, IIsNullifierOnChainArgs, IHasUserSignedUpArgs } from "./types";
|
|
2
|
-
/**
|
|
3
|
-
* Checks if user is registered with a given public key and get its data
|
|
4
|
-
* @param IRegisteredArgs - The arguments for the check register command
|
|
5
|
-
* @returns whether the user is registered or not and their state index
|
|
6
|
-
*/
|
|
7
|
-
export declare const getSignedupUserData: ({ maciAddress, maciPubKey, signer, startBlock, }: IRegisteredUserArgs) => Promise<IIsRegisteredUser>;
|
|
8
|
-
/**
|
|
9
|
-
* Signup a user to the MACI contract
|
|
10
|
-
* @param {SignupArgs} args - The arguments for the signup command
|
|
11
|
-
* @returns {ISignupData} The state index of the user and transaction hash
|
|
12
|
-
*/
|
|
13
|
-
export declare const signup: ({ maciPubKey, maciAddress, sgData, signer }: ISignupArgs) => Promise<ISignupData>;
|
|
14
|
-
/**
|
|
15
|
-
* Checks if user is joined to a poll with their public key and get its data
|
|
16
|
-
* @param {IJoinedUserArgs} - The arguments for the join check command
|
|
17
|
-
* @returns user joined or not and poll state index, voice credit balance
|
|
18
|
-
*/
|
|
19
|
-
export declare const getJoinedUserData: ({ maciAddress, pollId, pollPubKey, signer, startBlock, }: IJoinedUserArgs) => Promise<{
|
|
20
|
-
isJoined: boolean;
|
|
21
|
-
pollStateIndex?: string;
|
|
22
|
-
voiceCredits?: string;
|
|
23
|
-
}>;
|
|
24
|
-
/**
|
|
25
|
-
* Checks if a user joined a poll with a given nullifier
|
|
26
|
-
* @param {IIsNullifierOnChainArgs} args - The arguments for the is nullifier on chain command
|
|
27
|
-
* @returns whether the nullifier is on chain or not
|
|
28
|
-
*/
|
|
29
|
-
export declare const hasUserJoinedPoll: ({ maciAddress, pollId, nullifier, signer, }: IIsNullifierOnChainArgs) => Promise<boolean>;
|
|
30
|
-
/**
|
|
31
|
-
* Join Poll user to the Poll contract
|
|
32
|
-
* @param {IJoinPollArgs} args - The arguments for the join poll command
|
|
33
|
-
* @returns {IJoinPollData} The poll state index of the joined user and transaction hash
|
|
34
|
-
*/
|
|
35
|
-
export declare const joinPoll: ({ maciAddress, privateKey, stateFile, pollId, signer, startBlock, endBlock, blocksPerBatch, pollJoiningZkey, useWasm, rapidsnark, pollWitgen, pollWasm, sgDataArg, ivcpDataArg, }: IJoinPollArgs) => Promise<IJoinPollData>;
|
|
36
|
-
/**
|
|
37
|
-
* Checks if a user is signed up with a given public key
|
|
38
|
-
* @param {IIsSignedUpArgs} args - The arguments for the is signed up command
|
|
39
|
-
* @returns {boolean} Whether the user is signed up or not
|
|
40
|
-
*/
|
|
41
|
-
export declare const hasUserSignedUp: ({ maciAddress, maciPubKey, signer }: IHasUserSignedUpArgs) => Promise<boolean>;
|
|
42
|
-
//# sourceMappingURL=user.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../../ts/user/user.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,iBAAiB,EACjB,eAAe,EACf,WAAW,EACX,WAAW,EACX,mBAAmB,EACnB,aAAa,EACb,aAAa,EACb,uBAAuB,EACvB,oBAAoB,EACrB,MAAM,SAAS,CAAC;AAYjB;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAAU,kDAKvC,mBAAmB,KAAG,OAAO,CAAC,iBAAiB,CAiBjD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,MAAM,GAAU,6CAA6C,WAAW,KAAG,OAAO,CAAC,WAAW,CA6C1G,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAAU,0DAMrC,eAAe,KAAG,OAAO,CAAC;IAAE,QAAQ,EAAE,OAAO,CAAC;IAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,CAqBjG,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAAU,6CAKrC,uBAAuB,KAAG,OAAO,CAAC,OAAO,CAM3C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,QAAQ,GAAU,mLAgB5B,aAAa,KAAG,OAAO,CAAC,aAAa,CA6FvC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAU,qCAAqC,oBAAoB,KAAG,OAAO,CAAC,OAAO,CAMhH,CAAC"}
|
package/build/ts/user/user.js
DELETED
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.hasUserSignedUp = exports.joinPoll = exports.hasUserJoinedPoll = exports.getJoinedUserData = exports.signup = exports.getSignedupUserData = void 0;
|
|
4
|
-
/* eslint-disable no-underscore-dangle */
|
|
5
|
-
const contracts_1 = require("@maci-protocol/contracts");
|
|
6
|
-
const crypto_1 = require("@maci-protocol/crypto");
|
|
7
|
-
const domainobjs_1 = require("@maci-protocol/domainobjs");
|
|
8
|
-
const ethers_1 = require("ethers");
|
|
9
|
-
const utils_1 = require("../utils");
|
|
10
|
-
const utils_2 = require("./utils");
|
|
11
|
-
/**
|
|
12
|
-
* Checks if user is registered with a given public key and get its data
|
|
13
|
-
* @param IRegisteredArgs - The arguments for the check register command
|
|
14
|
-
* @returns whether the user is registered or not and their state index
|
|
15
|
-
*/
|
|
16
|
-
const getSignedupUserData = async ({ maciAddress, maciPubKey, signer, startBlock, }) => {
|
|
17
|
-
const maciContract = contracts_1.MACI__factory.connect(maciAddress, signer);
|
|
18
|
-
const publicKey = domainobjs_1.PubKey.deserialize(maciPubKey);
|
|
19
|
-
const startBlockNumber = startBlock || 0;
|
|
20
|
-
const currentBlock = await signer.provider.getBlockNumber();
|
|
21
|
-
const { stateIndex } = await (0, utils_2.parseSignupEvents)({
|
|
22
|
-
maciContract,
|
|
23
|
-
startBlock: startBlockNumber,
|
|
24
|
-
currentBlock,
|
|
25
|
-
publicKey,
|
|
26
|
-
});
|
|
27
|
-
return {
|
|
28
|
-
isRegistered: stateIndex !== undefined,
|
|
29
|
-
stateIndex,
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
exports.getSignedupUserData = getSignedupUserData;
|
|
33
|
-
/**
|
|
34
|
-
* Signup a user to the MACI contract
|
|
35
|
-
* @param {SignupArgs} args - The arguments for the signup command
|
|
36
|
-
* @returns {ISignupData} The state index of the user and transaction hash
|
|
37
|
-
*/
|
|
38
|
-
const signup = async ({ maciPubKey, maciAddress, sgData, signer }) => {
|
|
39
|
-
// validate user key
|
|
40
|
-
if (!domainobjs_1.PubKey.isValidSerializedPubKey(maciPubKey)) {
|
|
41
|
-
throw new Error("Invalid MACI public key");
|
|
42
|
-
}
|
|
43
|
-
const userMaciPubKey = domainobjs_1.PubKey.deserialize(maciPubKey);
|
|
44
|
-
const validContract = await (0, utils_1.contractExists)(signer.provider, maciAddress);
|
|
45
|
-
if (!validContract) {
|
|
46
|
-
throw new Error("There is no contract deployed at the specified address");
|
|
47
|
-
}
|
|
48
|
-
// we validate that the signup data and voice credit data is valid
|
|
49
|
-
if (!(0, ethers_1.isBytesLike)(sgData)) {
|
|
50
|
-
throw new Error("invalid signup gateway data");
|
|
51
|
-
}
|
|
52
|
-
const maciContract = contracts_1.MACI__factory.connect(maciAddress, signer);
|
|
53
|
-
let stateIndex = "";
|
|
54
|
-
let receipt = null;
|
|
55
|
-
// sign up to the MACI contract
|
|
56
|
-
const tx = await maciContract.signUp(userMaciPubKey.asContractParam(), sgData);
|
|
57
|
-
receipt = await tx.wait();
|
|
58
|
-
if (receipt?.status !== 1) {
|
|
59
|
-
throw new Error("The transaction failed");
|
|
60
|
-
}
|
|
61
|
-
// get state index from the event
|
|
62
|
-
const [{ args = [] } = { args: [] }] = await maciContract.queryFilter(maciContract.filters.SignUp, receipt.blockNumber, receipt.blockNumber);
|
|
63
|
-
stateIndex = args[0].toString();
|
|
64
|
-
return {
|
|
65
|
-
stateIndex: stateIndex ? stateIndex.toString() : "",
|
|
66
|
-
transactionHash: receipt.hash,
|
|
67
|
-
};
|
|
68
|
-
};
|
|
69
|
-
exports.signup = signup;
|
|
70
|
-
/**
|
|
71
|
-
* Checks if user is joined to a poll with their public key and get its data
|
|
72
|
-
* @param {IJoinedUserArgs} - The arguments for the join check command
|
|
73
|
-
* @returns user joined or not and poll state index, voice credit balance
|
|
74
|
-
*/
|
|
75
|
-
const getJoinedUserData = async ({ maciAddress, pollId, pollPubKey, signer, startBlock, }) => {
|
|
76
|
-
const maciContract = contracts_1.MACI__factory.connect(maciAddress, signer);
|
|
77
|
-
const pollContracts = await maciContract.getPoll(pollId);
|
|
78
|
-
const pollContract = contracts_1.Poll__factory.connect(pollContracts.poll, signer);
|
|
79
|
-
const pollPublicKey = domainobjs_1.PubKey.deserialize(pollPubKey);
|
|
80
|
-
const startBlockNumber = startBlock || 0;
|
|
81
|
-
const currentBlock = await signer.provider.getBlockNumber();
|
|
82
|
-
const { pollStateIndex, voiceCredits } = await (0, utils_2.parsePollJoinEvents)({
|
|
83
|
-
pollContract,
|
|
84
|
-
startBlock: startBlockNumber,
|
|
85
|
-
currentBlock,
|
|
86
|
-
pollPublicKey,
|
|
87
|
-
});
|
|
88
|
-
return {
|
|
89
|
-
isJoined: pollStateIndex !== undefined,
|
|
90
|
-
pollStateIndex,
|
|
91
|
-
voiceCredits,
|
|
92
|
-
};
|
|
93
|
-
};
|
|
94
|
-
exports.getJoinedUserData = getJoinedUserData;
|
|
95
|
-
/**
|
|
96
|
-
* Checks if a user joined a poll with a given nullifier
|
|
97
|
-
* @param {IIsNullifierOnChainArgs} args - The arguments for the is nullifier on chain command
|
|
98
|
-
* @returns whether the nullifier is on chain or not
|
|
99
|
-
*/
|
|
100
|
-
const hasUserJoinedPoll = async ({ maciAddress, pollId, nullifier, signer, }) => {
|
|
101
|
-
const maciContract = contracts_1.MACI__factory.connect(maciAddress, signer);
|
|
102
|
-
const pollContracts = await maciContract.getPoll(pollId);
|
|
103
|
-
const pollContract = contracts_1.Poll__factory.connect(pollContracts.poll, signer);
|
|
104
|
-
return pollContract.pollNullifiers(nullifier);
|
|
105
|
-
};
|
|
106
|
-
exports.hasUserJoinedPoll = hasUserJoinedPoll;
|
|
107
|
-
/**
|
|
108
|
-
* Join Poll user to the Poll contract
|
|
109
|
-
* @param {IJoinPollArgs} args - The arguments for the join poll command
|
|
110
|
-
* @returns {IJoinPollData} The poll state index of the joined user and transaction hash
|
|
111
|
-
*/
|
|
112
|
-
const joinPoll = async ({ maciAddress, privateKey, stateFile, pollId, signer, startBlock, endBlock, blocksPerBatch, pollJoiningZkey, useWasm, rapidsnark, pollWitgen, pollWasm, sgDataArg, ivcpDataArg, }) => {
|
|
113
|
-
const validContract = await (0, utils_1.contractExists)(signer.provider, maciAddress);
|
|
114
|
-
if (!validContract) {
|
|
115
|
-
throw new Error("MACI contract does not exist");
|
|
116
|
-
}
|
|
117
|
-
if (!domainobjs_1.PrivKey.isValidSerializedPrivKey(privateKey)) {
|
|
118
|
-
throw new Error("Invalid MACI private key");
|
|
119
|
-
}
|
|
120
|
-
if (pollId < 0) {
|
|
121
|
-
throw new Error("Invalid poll id");
|
|
122
|
-
}
|
|
123
|
-
const userMaciPrivKey = domainobjs_1.PrivKey.deserialize(privateKey);
|
|
124
|
-
const userMaciPubKey = new domainobjs_1.Keypair(userMaciPrivKey).pubKey;
|
|
125
|
-
const nullifier = (0, crypto_1.poseidon)([BigInt(userMaciPrivKey.asCircuitInputs()), pollId]);
|
|
126
|
-
// check if the user has already joined the poll based on the nullifier
|
|
127
|
-
const hasUserJoinedAlready = await (0, exports.hasUserJoinedPoll)({
|
|
128
|
-
maciAddress,
|
|
129
|
-
pollId,
|
|
130
|
-
nullifier,
|
|
131
|
-
signer,
|
|
132
|
-
});
|
|
133
|
-
if (hasUserJoinedAlready) {
|
|
134
|
-
throw new Error("User has already joined");
|
|
135
|
-
}
|
|
136
|
-
const maciContract = contracts_1.MACI__factory.connect(maciAddress, signer);
|
|
137
|
-
const pollContracts = await maciContract.getPoll(pollId);
|
|
138
|
-
const pollContract = contracts_1.Poll__factory.connect(pollContracts.poll, signer);
|
|
139
|
-
// get the state index from the MACI contract
|
|
140
|
-
const stateIndex = await maciContract.getStateIndex(userMaciPubKey.hash()).catch(() => -1n);
|
|
141
|
-
let circuitInputs;
|
|
142
|
-
if (stateFile) {
|
|
143
|
-
circuitInputs = await (0, utils_2.getPollJoiningCircuitInputsFromStateFile)({
|
|
144
|
-
stateFile,
|
|
145
|
-
pollId,
|
|
146
|
-
stateIndex,
|
|
147
|
-
userMaciPrivKey,
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
else {
|
|
151
|
-
circuitInputs = await (0, utils_2.getPollJoiningCircuitEvents)({
|
|
152
|
-
maciContract,
|
|
153
|
-
stateIndex,
|
|
154
|
-
pollId,
|
|
155
|
-
userMaciPrivKey,
|
|
156
|
-
signer,
|
|
157
|
-
startBlock,
|
|
158
|
-
endBlock,
|
|
159
|
-
blocksPerBatch,
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
const currentStateRootIndex = Number.parseInt((await maciContract.numSignUps()).toString(), 10) - 1;
|
|
163
|
-
// generate the proof for this batch
|
|
164
|
-
const proof = await (0, utils_1.generateAndVerifyProof)(circuitInputs, pollJoiningZkey, useWasm, rapidsnark, pollWitgen, pollWasm);
|
|
165
|
-
// submit the message onchain as well as the encryption public key
|
|
166
|
-
const tx = await pollContract.joinPoll(nullifier, userMaciPubKey.asContractParam(), currentStateRootIndex, proof, sgDataArg, ivcpDataArg);
|
|
167
|
-
const receipt = await tx.wait();
|
|
168
|
-
if (receipt?.status !== 1) {
|
|
169
|
-
throw new Error("Transaction failed");
|
|
170
|
-
}
|
|
171
|
-
const [{ args }] = await pollContract.queryFilter(pollContract.filters.PollJoined, receipt.blockNumber, receipt.blockNumber);
|
|
172
|
-
return {
|
|
173
|
-
pollStateIndex: args._pollStateIndex.toString(),
|
|
174
|
-
voiceCredits: args._voiceCreditBalance.toString(),
|
|
175
|
-
timestamp: args._timestamp.toString(),
|
|
176
|
-
nullifier: nullifier.toString(),
|
|
177
|
-
hash: receipt.hash,
|
|
178
|
-
};
|
|
179
|
-
};
|
|
180
|
-
exports.joinPoll = joinPoll;
|
|
181
|
-
/**
|
|
182
|
-
* Checks if a user is signed up with a given public key
|
|
183
|
-
* @param {IIsSignedUpArgs} args - The arguments for the is signed up command
|
|
184
|
-
* @returns {boolean} Whether the user is signed up or not
|
|
185
|
-
*/
|
|
186
|
-
const hasUserSignedUp = async ({ maciAddress, maciPubKey, signer }) => {
|
|
187
|
-
const maciContract = contracts_1.MACI__factory.connect(maciAddress, signer);
|
|
188
|
-
const stateIndex = await maciContract.getStateIndex(domainobjs_1.PubKey.deserialize(maciPubKey).hash());
|
|
189
|
-
return stateIndex !== 0n;
|
|
190
|
-
};
|
|
191
|
-
exports.hasUserSignedUp = hasUserSignedUp;
|
|
192
|
-
//# sourceMappingURL=user.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"user.js","sourceRoot":"","sources":["../../../ts/user/user.ts"],"names":[],"mappings":";;;AAAA,yCAAyC;AACzC,wDAAsG;AACtG,kDAAiD;AACjD,0DAAqE;AACrE,mCAAiE;AAejE,oCAAkE;AAElE,mCAKiB;AAEjB;;;;GAIG;AACI,MAAM,mBAAmB,GAAG,KAAK,EAAE,EACxC,WAAW,EACX,UAAU,EACV,MAAM,EACN,UAAU,GACU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