From 0ae518ee349488642028abfa832f1847fbf28dba Mon Sep 17 00:00:00 2001 From: daodesigner Date: Wed, 15 Sep 2021 04:35:30 -0400 Subject: [PATCH 1/3] fire events that allow subgraph to track user and recipient registries independent of clrfund instance + tests --- contracts/contracts/ClrFundDeployer.sol | 56 ++++++++++++++++++++++--- contracts/tests/deployer.ts | 45 +++++++++++++++++--- 2 files changed, 91 insertions(+), 10 deletions(-) diff --git a/contracts/contracts/ClrFundDeployer.sol b/contracts/contracts/ClrFundDeployer.sol index 4c93617bc..3182478a3 100644 --- a/contracts/contracts/ClrFundDeployer.sol +++ b/contracts/contracts/ClrFundDeployer.sol @@ -22,6 +22,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. pragma solidity ^0.6.12; import './MACIFactory.sol'; import './ClrFund.sol'; +import './recipientRegistry/OptimisticRecipientRegistry.sol'; +import './userRegistry/BrightIdUserRegistry.sol'; contract CloneFactory { // implementation of eip-1167 - see https://eips.ethereum.org/EIPS/eip-1167 function createClone(address target) internal returns (address result) { @@ -40,16 +42,26 @@ contract ClrFundDeployer is CloneFactory { address public template; mapping (address => bool) public clrfunds; + mapping (address => bool) public recipientRegistries; + mapping (address => bool) public userRegistries; + uint clrId = 0; + uint recipientRegistryId = 0; + uint userId = 0; + ClrFund private clrfund; // funding factory contract - + OptimisticRecipientRegistry private recipientRegistry; // recipient registry contract + BrightIdUserRegistry private userRegistry; // user registry contract + constructor(address _template) public { template = _template; } event NewInstance(address indexed clrfund); - event Register(address indexed clrfund, string metadata); - + event RegisterFund(address indexed clrfund, string metadata); + event RegisterOptimisticRecipientRegistry(address indexed recipientRegistry, string metadata); + event RegisterBrightIdUserRegistry(address indexed userRegistry, string metadata); + function deployFund( MACIFactory _maciFactory ) public returns (address) { @@ -64,7 +76,7 @@ contract ClrFundDeployer is CloneFactory { return address(clrfund); } - function registerInstance( + function registerFundInstance( address _clrFundAddress, string memory _metadata ) public returns (bool) { @@ -76,7 +88,41 @@ contract ClrFundDeployer is CloneFactory { clrfunds[_clrFundAddress] = true; clrId = clrId + 1; - emit Register(_clrFundAddress, _metadata); + emit RegisterFund(_clrFundAddress, _metadata); + return true; + + } + + function registerRecipientRegistryInstance( + address _recipientRegistryAddress, + string memory _metadata + ) public returns (bool) { + + recipientRegistry = OptimisticRecipientRegistry(_recipientRegistryAddress); + + require(recipientRegistries[_recipientRegistryAddress] == false, 'RecipientRegistry: metadata already registered'); + + recipientRegistries[_recipientRegistryAddress] = true; + + recipientRegistryId = recipientRegistryId + 1; + emit RegisterOptimisticRecipientRegistry(_recipientRegistryAddress, _metadata); + return true; + + } + + function registerUserRegistryInstance( + address _userRegistryAddress, + string memory _metadata + ) public returns (bool) { + + userRegistry = BrightIdUserRegistry(_userRegistryAddress); + + require(userRegistries[_userRegistryAddress] == false, 'UserRegistry: metadata already registered'); + + userRegistries[_userRegistryAddress] = true; + + userId = userId + 1; + emit RegisterBrightIdUserRegistry(_userRegistryAddress, _metadata); return true; } diff --git a/contracts/tests/deployer.ts b/contracts/tests/deployer.ts index 219b31011..480a40bb6 100644 --- a/contracts/tests/deployer.ts +++ b/contracts/tests/deployer.ts @@ -86,26 +86,61 @@ describe('Clr fund deployer', () => { it('can register with the subgraph', async () => { await expect( - clrFundDeployer.registerInstance( + clrFundDeployer.registerFundInstance( factory.address, '{name:dead,title:beef}' ) ) - .to.emit(clrFundDeployer, 'Register') + .to.emit(clrFundDeployer, 'RegisterFund') + .withArgs(factory.address, '{name:dead,title:beef}') + }) + //TODO: Test Optimistic Recipient Registry subgraph registration event is idempotent + it('can register Optimistic Recipient Registries with the subgraph', async () => { + await expect( + clrFundDeployer.registerRecipientRegistryInstance( + recipientRegistry.address, + '{name:dead,title:beef}' + ) + ) + .to.emit(clrFundDeployer, 'RegisterOptimisticRecipientRegistry') + .withArgs(recipientRegistry.address, '{name:dead,title:beef}') + }) + + //TODO: Test Bright ID User Registry subgraph registration event is idempotent + it('can register BrightId User Registries with the subgraph', async () => { + await expect( + clrFundDeployer.registerUserRegistryInstance( + userRegistry.address, + '{name:dead,title:beef}' + ) + ) + .to.emit(clrFundDeployer, 'RegisterBrightIdUserRegistry') + .withArgs(userRegistry.address, '{name:dead,title:beef}') + }) + + //TODO: Test brightId subgraph registration + it('can register fun instances with the subgraph', async () => { + await expect( + clrFundDeployer.registerFundInstance( + factory.address, + '{name:dead,title:beef}' + ) + ) + .to.emit(clrFundDeployer, 'RegisterFund') .withArgs(factory.address, '{name:dead,title:beef}') }) it('cannot register with the subgraph twice', async () => { await expect( - clrFundDeployer.registerInstance( + clrFundDeployer.registerFundInstance( factory.address, '{name:dead,title:beef}' ) ) - .to.emit(clrFundDeployer, 'Register') + .to.emit(clrFundDeployer, 'RegisterFund') .withArgs(factory.address, '{name:dead,title:beef}') await expect( - clrFundDeployer.registerInstance( + clrFundDeployer.registerFundInstance( factory.address, '{name:dead,title:beef}' ) From 3208ead454fd5ed40358919045b51b279ecfc723 Mon Sep 17 00:00:00 2001 From: daodesigner Date: Wed, 29 Sep 2021 00:45:28 -0400 Subject: [PATCH 2/3] maci contract mappings added when a new round is deployed --- subgraph/abis/MACI.json | 1154 ++++++++++++ .../generated/FundingRoundFactory/MACI.ts | 1634 +++++++++++++++++ subgraph/generated/schema.ts | 266 ++- subgraph/generated/templates.ts | 10 + .../generated/templates/MACI/FundingRound.ts | 821 +++++++++ subgraph/generated/templates/MACI/MACI.ts | 1634 +++++++++++++++++ subgraph/schema.graphql | 22 +- subgraph/src/FundingRoundFactoryMapping.ts | 3 + subgraph/src/MACIMapping.ts | 84 + subgraph/subgraph.yaml | 28 +- 10 files changed, 5637 insertions(+), 19 deletions(-) create mode 100644 subgraph/abis/MACI.json create mode 100644 subgraph/generated/FundingRoundFactory/MACI.ts create mode 100644 subgraph/generated/templates/MACI/FundingRound.ts create mode 100644 subgraph/generated/templates/MACI/MACI.ts create mode 100644 subgraph/src/MACIMapping.ts diff --git a/subgraph/abis/MACI.json b/subgraph/abis/MACI.json new file mode 100644 index 000000000..9bd23ef87 --- /dev/null +++ b/subgraph/abis/MACI.json @@ -0,0 +1,1154 @@ +[ + { + "inputs": [ + { + "components": [ + { + "internalType": "uint8", + "name": "stateTreeDepth", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "messageTreeDepth", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "voteOptionTreeDepth", + "type": "uint8" + } + ], + "internalType": "struct MACIParameters.TreeDepths", + "name": "_treeDepths", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "uint8", + "name": "tallyBatchSize", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "messageBatchSize", + "type": "uint8" + } + ], + "internalType": "struct MACIParameters.BatchSizes", + "name": "_batchSizes", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "maxUsers", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "maxMessages", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "maxVoteOptions", + "type": "uint256" + } + ], + "internalType": "struct MACIParameters.MaxValues", + "name": "_maxValues", + "type": "tuple" + }, + { + "internalType": "contract SignUpGatekeeper", + "name": "_signUpGatekeeper", + "type": "address" + }, + { + "internalType": "contract SnarkVerifier", + "name": "_batchUstVerifier", + "type": "address" + }, + { + "internalType": "contract SnarkVerifier", + "name": "_qvtVerifier", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_signUpDurationSeconds", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_votingDurationSeconds", + "type": "uint256" + }, + { + "internalType": "contract InitialVoiceCreditProxy", + "name": "_initialVoiceCreditProxy", + "type": "address" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "x", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "y", + "type": "uint256" + } + ], + "internalType": "struct MACISharedObjs.PubKey", + "name": "_coordinatorPubKey", + "type": "tuple" + }, + { + "internalType": "address", + "name": "_coordinatorAddress", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "iv", + "type": "uint256" + }, + { + "internalType": "uint256[10]", + "name": "data", + "type": "uint256[10]" + } + ], + "indexed": false, + "internalType": "struct MACISharedObjs.Message", + "name": "_message", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "x", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "y", + "type": "uint256" + } + ], + "indexed": false, + "internalType": "struct MACISharedObjs.PubKey", + "name": "_encPubKey", + "type": "tuple" + } + ], + "name": "PublishMessage", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "x", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "y", + "type": "uint256" + } + ], + "indexed": false, + "internalType": "struct MACISharedObjs.PubKey", + "name": "_userPubKey", + "type": "tuple" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_stateIndex", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_voiceCreditBalance", + "type": "uint256" + } + ], + "name": "SignUp", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_newStateRoot", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "x", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "y", + "type": "uint256" + } + ], + "internalType": "struct MACISharedObjs.PubKey[]", + "name": "_ecdhPubKeys", + "type": "tuple[]" + }, + { + "internalType": "uint256[8]", + "name": "_proof", + "type": "uint256[8]" + } + ], + "name": "batchProcessMessage", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "_levels", + "type": "uint8" + } + ], + "name": "calcEmptyVoteOptionTreeRoot", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "calcSignUpDeadline", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "calcVotingDeadline", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "_treeLevels", + "type": "uint8" + }, + { + "internalType": "uint256", + "name": "_zeroValue", + "type": "uint256" + } + ], + "name": "computeEmptyQuinRoot", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "_treeLevels", + "type": "uint8" + }, + { + "internalType": "uint256", + "name": "_zeroValue", + "type": "uint256" + } + ], + "name": "computeEmptyRoot", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "pure", + "type": "function" + }, + + { + "inputs": [], + "name": "coordinatorAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "coordinatorPubKey", + "outputs": [ + { + "internalType": "uint256", + "name": "x", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "y", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "coordinatorReset", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "currentMessageBatchIndex", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "currentPerVOSpentVoiceCreditsCommitment", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "currentQvtBatchNum", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "currentResultsCommitment", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "currentSpentVoiceCreditsCommitment", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "emptyVoteOptionTreeRoot", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_newStateRoot", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "x", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "y", + "type": "uint256" + } + ], + "internalType": "struct MACISharedObjs.PubKey[]", + "name": "_ecdhPubKeys", + "type": "tuple[]" + } + ], + "name": "genBatchUstPublicSignals", + "outputs": [ + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_intermediateStateRoot", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_newResultsCommitment", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_newSpentVoiceCreditsCommitment", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_newPerVOSpentVoiceCreditsCommitment", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_totalVotes", + "type": "uint256" + } + ], + "name": "genQvtPublicSignals", + "outputs": [ + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getMessageTreeRoot", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getStateTreeRoot", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "hasUnprocessedMessages", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "hasUntalliedStateLeaves", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256[]", + "name": "array", + "type": "uint256[]" + } + ], + "name": "hash11", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256[5]", + "name": "array", + "type": "uint256[5]" + } + ], + "name": "hash5", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_left", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_right", + "type": "uint256" + } + ], + "name": "hashLeftRight", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "iv", + "type": "uint256" + }, + { + "internalType": "uint256[10]", + "name": "data", + "type": "uint256[10]" + } + ], + "internalType": "struct MACISharedObjs.Message", + "name": "_message", + "type": "tuple" + } + ], + "name": "hashMessage", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "components": [ + { + "internalType": "uint256", + "name": "x", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "y", + "type": "uint256" + } + ], + "internalType": "struct MACISharedObjs.PubKey", + "name": "pubKey", + "type": "tuple" + }, + { + "internalType": "uint256", + "name": "voteOptionTreeRoot", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "voiceCreditBalance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + } + ], + "internalType": "struct DomainObjs.StateLeaf", + "name": "_stateLeaf", + "type": "tuple" + } + ], + "name": "hashStateLeaf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "hashedBlankStateLeaf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "initialVoiceCreditProxy", + "outputs": [ + { + "internalType": "contract InitialVoiceCreditProxy", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "maxMessages", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "maxUsers", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "messageBatchSize", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "messageTree", + "outputs": [ + { + "internalType": "contract IncrementalMerkleTree", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "messageTreeMaxLeafIndex", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "numMessages", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "numSignUps", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "originalCurrentResultsCommitment", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "originalSpentVoiceCreditsCommitment", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_intermediateStateRoot", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_newResultsCommitment", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_newSpentVoiceCreditsCommitment", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_newPerVOSpentVoiceCreditsCommitment", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_totalVotes", + "type": "uint256" + }, + { + "internalType": "uint256[8]", + "name": "_proof", + "type": "uint256[8]" + } + ], + "name": "proveVoteTallyBatch", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "iv", + "type": "uint256" + }, + { + "internalType": "uint256[10]", + "name": "data", + "type": "uint256[10]" + } + ], + "internalType": "struct MACISharedObjs.Message", + "name": "_message", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "x", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "y", + "type": "uint256" + } + ], + "internalType": "struct MACISharedObjs.PubKey", + "name": "_encPubKey", + "type": "tuple" + } + ], + "name": "publishMessage", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "x", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "y", + "type": "uint256" + } + ], + "internalType": "struct MACISharedObjs.PubKey", + "name": "_userPubKey", + "type": "tuple" + }, + { + "internalType": "bytes", + "name": "_signUpGatekeeperData", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "_initialVoiceCreditProxyData", + "type": "bytes" + } + ], + "name": "signUp", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "signUpDurationSeconds", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "signUpGatekeeper", + "outputs": [ + { + "internalType": "contract SignUpGatekeeper", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "signUpTimestamp", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "stateRoot", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "stateRootBeforeProcessing", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "stateTree", + "outputs": [ + { + "internalType": "contract IncrementalMerkleTree", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "tallyBatchSize", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalVotes", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "treeDepths", + "outputs": [ + { + "internalType": "uint8", + "name": "stateTreeDepth", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "messageTreeDepth", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "voteOptionTreeDepth", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_spent", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_salt", + "type": "uint256" + } + ], + "name": "verifySpentVoiceCredits", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "voteOptionsMaxLeafIndex", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "votingDurationSeconds", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + } +] diff --git a/subgraph/generated/FundingRoundFactory/MACI.ts b/subgraph/generated/FundingRoundFactory/MACI.ts new file mode 100644 index 000000000..de37f2956 --- /dev/null +++ b/subgraph/generated/FundingRoundFactory/MACI.ts @@ -0,0 +1,1634 @@ +// THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. + +import { + ethereum, + JSONValue, + TypedMap, + Entity, + Bytes, + Address, + BigInt +} from "@graphprotocol/graph-ts"; + +export class PublishMessage extends ethereum.Event { + get params(): PublishMessage__Params { + return new PublishMessage__Params(this); + } +} + +export class PublishMessage__Params { + _event: PublishMessage; + + constructor(event: PublishMessage) { + this._event = event; + } + + get _message(): PublishMessage_messageStruct { + return this._event.parameters[0].value.toTuple() as PublishMessage_messageStruct; + } + + get _encPubKey(): PublishMessage_encPubKeyStruct { + return this._event.parameters[1].value.toTuple() as PublishMessage_encPubKeyStruct; + } +} + +export class PublishMessage_messageStruct extends ethereum.Tuple { + get iv(): BigInt { + return this[0].toBigInt(); + } + + get data(): Array { + return this[1].toBigIntArray(); + } +} + +export class PublishMessage_encPubKeyStruct extends ethereum.Tuple { + get x(): BigInt { + return this[0].toBigInt(); + } + + get y(): BigInt { + return this[1].toBigInt(); + } +} + +export class SignUp extends ethereum.Event { + get params(): SignUp__Params { + return new SignUp__Params(this); + } +} + +export class SignUp__Params { + _event: SignUp; + + constructor(event: SignUp) { + this._event = event; + } + + get _userPubKey(): SignUp_userPubKeyStruct { + return this._event.parameters[0].value.toTuple() as SignUp_userPubKeyStruct; + } + + get _stateIndex(): BigInt { + return this._event.parameters[1].value.toBigInt(); + } + + get _voiceCreditBalance(): BigInt { + return this._event.parameters[2].value.toBigInt(); + } +} + +export class SignUp_userPubKeyStruct extends ethereum.Tuple { + get x(): BigInt { + return this[0].toBigInt(); + } + + get y(): BigInt { + return this[1].toBigInt(); + } +} + +export class MACI__coordinatorPubKeyResult { + value0: BigInt; + value1: BigInt; + + constructor(value0: BigInt, value1: BigInt) { + this.value0 = value0; + this.value1 = value1; + } + + toMap(): TypedMap { + let map = new TypedMap(); + map.set("value0", ethereum.Value.fromUnsignedBigInt(this.value0)); + map.set("value1", ethereum.Value.fromUnsignedBigInt(this.value1)); + return map; + } +} + +export class MACI__genBatchUstPublicSignalsInput_ecdhPubKeysStruct extends ethereum.Tuple { + get x(): BigInt { + return this[0].toBigInt(); + } + + get y(): BigInt { + return this[1].toBigInt(); + } +} + +export class MACI__hashMessageInput_messageStruct extends ethereum.Tuple { + get iv(): BigInt { + return this[0].toBigInt(); + } + + get data(): Array { + return this[1].toBigIntArray(); + } +} + +export class MACI__hashStateLeafInput_stateLeafStruct extends ethereum.Tuple { + get pubKey(): MACI__hashStateLeafInput_stateLeafPubKeyStruct { + return this[0].toTuple() as MACI__hashStateLeafInput_stateLeafPubKeyStruct; + } + + get voteOptionTreeRoot(): BigInt { + return this[1].toBigInt(); + } + + get voiceCreditBalance(): BigInt { + return this[2].toBigInt(); + } + + get nonce(): BigInt { + return this[3].toBigInt(); + } +} + +export class MACI__hashStateLeafInput_stateLeafPubKeyStruct extends ethereum.Tuple { + get x(): BigInt { + return this[0].toBigInt(); + } + + get y(): BigInt { + return this[1].toBigInt(); + } +} + +export class MACI__treeDepthsResult { + value0: i32; + value1: i32; + value2: i32; + + constructor(value0: i32, value1: i32, value2: i32) { + this.value0 = value0; + this.value1 = value1; + this.value2 = value2; + } + + toMap(): TypedMap { + let map = new TypedMap(); + map.set( + "value0", + ethereum.Value.fromUnsignedBigInt(BigInt.fromI32(this.value0)) + ); + map.set( + "value1", + ethereum.Value.fromUnsignedBigInt(BigInt.fromI32(this.value1)) + ); + map.set( + "value2", + ethereum.Value.fromUnsignedBigInt(BigInt.fromI32(this.value2)) + ); + return map; + } +} + +export class MACI extends ethereum.SmartContract { + static bind(address: Address): MACI { + return new MACI("MACI", address); + } + + calcEmptyVoteOptionTreeRoot(_levels: i32): BigInt { + let result = super.call( + "calcEmptyVoteOptionTreeRoot", + "calcEmptyVoteOptionTreeRoot(uint8):(uint256)", + [ethereum.Value.fromUnsignedBigInt(BigInt.fromI32(_levels))] + ); + + return result[0].toBigInt(); + } + + try_calcEmptyVoteOptionTreeRoot(_levels: i32): ethereum.CallResult { + let result = super.tryCall( + "calcEmptyVoteOptionTreeRoot", + "calcEmptyVoteOptionTreeRoot(uint8):(uint256)", + [ethereum.Value.fromUnsignedBigInt(BigInt.fromI32(_levels))] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + calcSignUpDeadline(): BigInt { + let result = super.call( + "calcSignUpDeadline", + "calcSignUpDeadline():(uint256)", + [] + ); + + return result[0].toBigInt(); + } + + try_calcSignUpDeadline(): ethereum.CallResult { + let result = super.tryCall( + "calcSignUpDeadline", + "calcSignUpDeadline():(uint256)", + [] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + calcVotingDeadline(): BigInt { + let result = super.call( + "calcVotingDeadline", + "calcVotingDeadline():(uint256)", + [] + ); + + return result[0].toBigInt(); + } + + try_calcVotingDeadline(): ethereum.CallResult { + let result = super.tryCall( + "calcVotingDeadline", + "calcVotingDeadline():(uint256)", + [] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + computeEmptyQuinRoot(_treeLevels: i32, _zeroValue: BigInt): BigInt { + let result = super.call( + "computeEmptyQuinRoot", + "computeEmptyQuinRoot(uint8,uint256):(uint256)", + [ + ethereum.Value.fromUnsignedBigInt(BigInt.fromI32(_treeLevels)), + ethereum.Value.fromUnsignedBigInt(_zeroValue) + ] + ); + + return result[0].toBigInt(); + } + + try_computeEmptyQuinRoot( + _treeLevels: i32, + _zeroValue: BigInt + ): ethereum.CallResult { + let result = super.tryCall( + "computeEmptyQuinRoot", + "computeEmptyQuinRoot(uint8,uint256):(uint256)", + [ + ethereum.Value.fromUnsignedBigInt(BigInt.fromI32(_treeLevels)), + ethereum.Value.fromUnsignedBigInt(_zeroValue) + ] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + computeEmptyRoot(_treeLevels: i32, _zeroValue: BigInt): BigInt { + let result = super.call( + "computeEmptyRoot", + "computeEmptyRoot(uint8,uint256):(uint256)", + [ + ethereum.Value.fromUnsignedBigInt(BigInt.fromI32(_treeLevels)), + ethereum.Value.fromUnsignedBigInt(_zeroValue) + ] + ); + + return result[0].toBigInt(); + } + + try_computeEmptyRoot( + _treeLevels: i32, + _zeroValue: BigInt + ): ethereum.CallResult { + let result = super.tryCall( + "computeEmptyRoot", + "computeEmptyRoot(uint8,uint256):(uint256)", + [ + ethereum.Value.fromUnsignedBigInt(BigInt.fromI32(_treeLevels)), + ethereum.Value.fromUnsignedBigInt(_zeroValue) + ] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + coordinatorAddress(): Address { + let result = super.call( + "coordinatorAddress", + "coordinatorAddress():(address)", + [] + ); + + return result[0].toAddress(); + } + + try_coordinatorAddress(): ethereum.CallResult
{ + let result = super.tryCall( + "coordinatorAddress", + "coordinatorAddress():(address)", + [] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toAddress()); + } + + coordinatorPubKey(): MACI__coordinatorPubKeyResult { + let result = super.call( + "coordinatorPubKey", + "coordinatorPubKey():(uint256,uint256)", + [] + ); + + return new MACI__coordinatorPubKeyResult( + result[0].toBigInt(), + result[1].toBigInt() + ); + } + + try_coordinatorPubKey(): ethereum.CallResult { + let result = super.tryCall( + "coordinatorPubKey", + "coordinatorPubKey():(uint256,uint256)", + [] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue( + new MACI__coordinatorPubKeyResult( + value[0].toBigInt(), + value[1].toBigInt() + ) + ); + } + + currentMessageBatchIndex(): BigInt { + let result = super.call( + "currentMessageBatchIndex", + "currentMessageBatchIndex():(uint256)", + [] + ); + + return result[0].toBigInt(); + } + + try_currentMessageBatchIndex(): ethereum.CallResult { + let result = super.tryCall( + "currentMessageBatchIndex", + "currentMessageBatchIndex():(uint256)", + [] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + currentPerVOSpentVoiceCreditsCommitment(): BigInt { + let result = super.call( + "currentPerVOSpentVoiceCreditsCommitment", + "currentPerVOSpentVoiceCreditsCommitment():(uint256)", + [] + ); + + return result[0].toBigInt(); + } + + try_currentPerVOSpentVoiceCreditsCommitment(): ethereum.CallResult { + let result = super.tryCall( + "currentPerVOSpentVoiceCreditsCommitment", + "currentPerVOSpentVoiceCreditsCommitment():(uint256)", + [] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + currentQvtBatchNum(): BigInt { + let result = super.call( + "currentQvtBatchNum", + "currentQvtBatchNum():(uint256)", + [] + ); + + return result[0].toBigInt(); + } + + try_currentQvtBatchNum(): ethereum.CallResult { + let result = super.tryCall( + "currentQvtBatchNum", + "currentQvtBatchNum():(uint256)", + [] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + currentResultsCommitment(): BigInt { + let result = super.call( + "currentResultsCommitment", + "currentResultsCommitment():(uint256)", + [] + ); + + return result[0].toBigInt(); + } + + try_currentResultsCommitment(): ethereum.CallResult { + let result = super.tryCall( + "currentResultsCommitment", + "currentResultsCommitment():(uint256)", + [] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + currentSpentVoiceCreditsCommitment(): BigInt { + let result = super.call( + "currentSpentVoiceCreditsCommitment", + "currentSpentVoiceCreditsCommitment():(uint256)", + [] + ); + + return result[0].toBigInt(); + } + + try_currentSpentVoiceCreditsCommitment(): ethereum.CallResult { + let result = super.tryCall( + "currentSpentVoiceCreditsCommitment", + "currentSpentVoiceCreditsCommitment():(uint256)", + [] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + emptyVoteOptionTreeRoot(): BigInt { + let result = super.call( + "emptyVoteOptionTreeRoot", + "emptyVoteOptionTreeRoot():(uint256)", + [] + ); + + return result[0].toBigInt(); + } + + try_emptyVoteOptionTreeRoot(): ethereum.CallResult { + let result = super.tryCall( + "emptyVoteOptionTreeRoot", + "emptyVoteOptionTreeRoot():(uint256)", + [] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + genBatchUstPublicSignals( + _newStateRoot: BigInt, + _ecdhPubKeys: Array + ): Array { + let result = super.call( + "genBatchUstPublicSignals", + "genBatchUstPublicSignals(uint256,(uint256,uint256)[]):(uint256[])", + [ + ethereum.Value.fromUnsignedBigInt(_newStateRoot), + ethereum.Value.fromTupleArray(_ecdhPubKeys) + ] + ); + + return result[0].toBigIntArray(); + } + + try_genBatchUstPublicSignals( + _newStateRoot: BigInt, + _ecdhPubKeys: Array + ): ethereum.CallResult> { + let result = super.tryCall( + "genBatchUstPublicSignals", + "genBatchUstPublicSignals(uint256,(uint256,uint256)[]):(uint256[])", + [ + ethereum.Value.fromUnsignedBigInt(_newStateRoot), + ethereum.Value.fromTupleArray(_ecdhPubKeys) + ] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigIntArray()); + } + + genQvtPublicSignals( + _intermediateStateRoot: BigInt, + _newResultsCommitment: BigInt, + _newSpentVoiceCreditsCommitment: BigInt, + _newPerVOSpentVoiceCreditsCommitment: BigInt, + _totalVotes: BigInt + ): Array { + let result = super.call( + "genQvtPublicSignals", + "genQvtPublicSignals(uint256,uint256,uint256,uint256,uint256):(uint256[])", + [ + ethereum.Value.fromUnsignedBigInt(_intermediateStateRoot), + ethereum.Value.fromUnsignedBigInt(_newResultsCommitment), + ethereum.Value.fromUnsignedBigInt(_newSpentVoiceCreditsCommitment), + ethereum.Value.fromUnsignedBigInt(_newPerVOSpentVoiceCreditsCommitment), + ethereum.Value.fromUnsignedBigInt(_totalVotes) + ] + ); + + return result[0].toBigIntArray(); + } + + try_genQvtPublicSignals( + _intermediateStateRoot: BigInt, + _newResultsCommitment: BigInt, + _newSpentVoiceCreditsCommitment: BigInt, + _newPerVOSpentVoiceCreditsCommitment: BigInt, + _totalVotes: BigInt + ): ethereum.CallResult> { + let result = super.tryCall( + "genQvtPublicSignals", + "genQvtPublicSignals(uint256,uint256,uint256,uint256,uint256):(uint256[])", + [ + ethereum.Value.fromUnsignedBigInt(_intermediateStateRoot), + ethereum.Value.fromUnsignedBigInt(_newResultsCommitment), + ethereum.Value.fromUnsignedBigInt(_newSpentVoiceCreditsCommitment), + ethereum.Value.fromUnsignedBigInt(_newPerVOSpentVoiceCreditsCommitment), + ethereum.Value.fromUnsignedBigInt(_totalVotes) + ] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigIntArray()); + } + + getMessageTreeRoot(): BigInt { + let result = super.call( + "getMessageTreeRoot", + "getMessageTreeRoot():(uint256)", + [] + ); + + return result[0].toBigInt(); + } + + try_getMessageTreeRoot(): ethereum.CallResult { + let result = super.tryCall( + "getMessageTreeRoot", + "getMessageTreeRoot():(uint256)", + [] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + getStateTreeRoot(): BigInt { + let result = super.call( + "getStateTreeRoot", + "getStateTreeRoot():(uint256)", + [] + ); + + return result[0].toBigInt(); + } + + try_getStateTreeRoot(): ethereum.CallResult { + let result = super.tryCall( + "getStateTreeRoot", + "getStateTreeRoot():(uint256)", + [] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + hasUnprocessedMessages(): boolean { + let result = super.call( + "hasUnprocessedMessages", + "hasUnprocessedMessages():(bool)", + [] + ); + + return result[0].toBoolean(); + } + + try_hasUnprocessedMessages(): ethereum.CallResult { + let result = super.tryCall( + "hasUnprocessedMessages", + "hasUnprocessedMessages():(bool)", + [] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBoolean()); + } + + hasUntalliedStateLeaves(): boolean { + let result = super.call( + "hasUntalliedStateLeaves", + "hasUntalliedStateLeaves():(bool)", + [] + ); + + return result[0].toBoolean(); + } + + try_hasUntalliedStateLeaves(): ethereum.CallResult { + let result = super.tryCall( + "hasUntalliedStateLeaves", + "hasUntalliedStateLeaves():(bool)", + [] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBoolean()); + } + + hash11(array: Array): BigInt { + let result = super.call("hash11", "hash11(uint256[]):(uint256)", [ + ethereum.Value.fromUnsignedBigIntArray(array) + ]); + + return result[0].toBigInt(); + } + + try_hash11(array: Array): ethereum.CallResult { + let result = super.tryCall("hash11", "hash11(uint256[]):(uint256)", [ + ethereum.Value.fromUnsignedBigIntArray(array) + ]); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + hash5(array: Array): BigInt { + let result = super.call("hash5", "hash5(uint256[5]):(uint256)", [ + ethereum.Value.fromUnsignedBigIntArray(array) + ]); + + return result[0].toBigInt(); + } + + try_hash5(array: Array): ethereum.CallResult { + let result = super.tryCall("hash5", "hash5(uint256[5]):(uint256)", [ + ethereum.Value.fromUnsignedBigIntArray(array) + ]); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + hashLeftRight(_left: BigInt, _right: BigInt): BigInt { + let result = super.call( + "hashLeftRight", + "hashLeftRight(uint256,uint256):(uint256)", + [ + ethereum.Value.fromUnsignedBigInt(_left), + ethereum.Value.fromUnsignedBigInt(_right) + ] + ); + + return result[0].toBigInt(); + } + + try_hashLeftRight( + _left: BigInt, + _right: BigInt + ): ethereum.CallResult { + let result = super.tryCall( + "hashLeftRight", + "hashLeftRight(uint256,uint256):(uint256)", + [ + ethereum.Value.fromUnsignedBigInt(_left), + ethereum.Value.fromUnsignedBigInt(_right) + ] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + hashMessage(_message: MACI__hashMessageInput_messageStruct): BigInt { + let result = super.call( + "hashMessage", + "hashMessage((uint256,uint256[10])):(uint256)", + [ethereum.Value.fromTuple(_message)] + ); + + return result[0].toBigInt(); + } + + try_hashMessage( + _message: MACI__hashMessageInput_messageStruct + ): ethereum.CallResult { + let result = super.tryCall( + "hashMessage", + "hashMessage((uint256,uint256[10])):(uint256)", + [ethereum.Value.fromTuple(_message)] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + hashStateLeaf(_stateLeaf: MACI__hashStateLeafInput_stateLeafStruct): BigInt { + let result = super.call( + "hashStateLeaf", + "hashStateLeaf(((uint256,uint256),uint256,uint256,uint256)):(uint256)", + [ethereum.Value.fromTuple(_stateLeaf)] + ); + + return result[0].toBigInt(); + } + + try_hashStateLeaf( + _stateLeaf: MACI__hashStateLeafInput_stateLeafStruct + ): ethereum.CallResult { + let result = super.tryCall( + "hashStateLeaf", + "hashStateLeaf(((uint256,uint256),uint256,uint256,uint256)):(uint256)", + [ethereum.Value.fromTuple(_stateLeaf)] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + hashedBlankStateLeaf(): BigInt { + let result = super.call( + "hashedBlankStateLeaf", + "hashedBlankStateLeaf():(uint256)", + [] + ); + + return result[0].toBigInt(); + } + + try_hashedBlankStateLeaf(): ethereum.CallResult { + let result = super.tryCall( + "hashedBlankStateLeaf", + "hashedBlankStateLeaf():(uint256)", + [] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + initialVoiceCreditProxy(): Address { + let result = super.call( + "initialVoiceCreditProxy", + "initialVoiceCreditProxy():(address)", + [] + ); + + return result[0].toAddress(); + } + + try_initialVoiceCreditProxy(): ethereum.CallResult
{ + let result = super.tryCall( + "initialVoiceCreditProxy", + "initialVoiceCreditProxy():(address)", + [] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toAddress()); + } + + maxMessages(): BigInt { + let result = super.call("maxMessages", "maxMessages():(uint256)", []); + + return result[0].toBigInt(); + } + + try_maxMessages(): ethereum.CallResult { + let result = super.tryCall("maxMessages", "maxMessages():(uint256)", []); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + maxUsers(): BigInt { + let result = super.call("maxUsers", "maxUsers():(uint256)", []); + + return result[0].toBigInt(); + } + + try_maxUsers(): ethereum.CallResult { + let result = super.tryCall("maxUsers", "maxUsers():(uint256)", []); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + messageBatchSize(): i32 { + let result = super.call( + "messageBatchSize", + "messageBatchSize():(uint8)", + [] + ); + + return result[0].toI32(); + } + + try_messageBatchSize(): ethereum.CallResult { + let result = super.tryCall( + "messageBatchSize", + "messageBatchSize():(uint8)", + [] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toI32()); + } + + messageTree(): Address { + let result = super.call("messageTree", "messageTree():(address)", []); + + return result[0].toAddress(); + } + + try_messageTree(): ethereum.CallResult
{ + let result = super.tryCall("messageTree", "messageTree():(address)", []); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toAddress()); + } + + messageTreeMaxLeafIndex(): BigInt { + let result = super.call( + "messageTreeMaxLeafIndex", + "messageTreeMaxLeafIndex():(uint256)", + [] + ); + + return result[0].toBigInt(); + } + + try_messageTreeMaxLeafIndex(): ethereum.CallResult { + let result = super.tryCall( + "messageTreeMaxLeafIndex", + "messageTreeMaxLeafIndex():(uint256)", + [] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + numMessages(): BigInt { + let result = super.call("numMessages", "numMessages():(uint256)", []); + + return result[0].toBigInt(); + } + + try_numMessages(): ethereum.CallResult { + let result = super.tryCall("numMessages", "numMessages():(uint256)", []); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + numSignUps(): BigInt { + let result = super.call("numSignUps", "numSignUps():(uint256)", []); + + return result[0].toBigInt(); + } + + try_numSignUps(): ethereum.CallResult { + let result = super.tryCall("numSignUps", "numSignUps():(uint256)", []); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + originalCurrentResultsCommitment(): BigInt { + let result = super.call( + "originalCurrentResultsCommitment", + "originalCurrentResultsCommitment():(uint256)", + [] + ); + + return result[0].toBigInt(); + } + + try_originalCurrentResultsCommitment(): ethereum.CallResult { + let result = super.tryCall( + "originalCurrentResultsCommitment", + "originalCurrentResultsCommitment():(uint256)", + [] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + originalSpentVoiceCreditsCommitment(): BigInt { + let result = super.call( + "originalSpentVoiceCreditsCommitment", + "originalSpentVoiceCreditsCommitment():(uint256)", + [] + ); + + return result[0].toBigInt(); + } + + try_originalSpentVoiceCreditsCommitment(): ethereum.CallResult { + let result = super.tryCall( + "originalSpentVoiceCreditsCommitment", + "originalSpentVoiceCreditsCommitment():(uint256)", + [] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + signUpDurationSeconds(): BigInt { + let result = super.call( + "signUpDurationSeconds", + "signUpDurationSeconds():(uint256)", + [] + ); + + return result[0].toBigInt(); + } + + try_signUpDurationSeconds(): ethereum.CallResult { + let result = super.tryCall( + "signUpDurationSeconds", + "signUpDurationSeconds():(uint256)", + [] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + signUpGatekeeper(): Address { + let result = super.call( + "signUpGatekeeper", + "signUpGatekeeper():(address)", + [] + ); + + return result[0].toAddress(); + } + + try_signUpGatekeeper(): ethereum.CallResult
{ + let result = super.tryCall( + "signUpGatekeeper", + "signUpGatekeeper():(address)", + [] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toAddress()); + } + + signUpTimestamp(): BigInt { + let result = super.call( + "signUpTimestamp", + "signUpTimestamp():(uint256)", + [] + ); + + return result[0].toBigInt(); + } + + try_signUpTimestamp(): ethereum.CallResult { + let result = super.tryCall( + "signUpTimestamp", + "signUpTimestamp():(uint256)", + [] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + stateRoot(): BigInt { + let result = super.call("stateRoot", "stateRoot():(uint256)", []); + + return result[0].toBigInt(); + } + + try_stateRoot(): ethereum.CallResult { + let result = super.tryCall("stateRoot", "stateRoot():(uint256)", []); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + stateRootBeforeProcessing(): BigInt { + let result = super.call( + "stateRootBeforeProcessing", + "stateRootBeforeProcessing():(uint256)", + [] + ); + + return result[0].toBigInt(); + } + + try_stateRootBeforeProcessing(): ethereum.CallResult { + let result = super.tryCall( + "stateRootBeforeProcessing", + "stateRootBeforeProcessing():(uint256)", + [] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + stateTree(): Address { + let result = super.call("stateTree", "stateTree():(address)", []); + + return result[0].toAddress(); + } + + try_stateTree(): ethereum.CallResult
{ + let result = super.tryCall("stateTree", "stateTree():(address)", []); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toAddress()); + } + + tallyBatchSize(): i32 { + let result = super.call("tallyBatchSize", "tallyBatchSize():(uint8)", []); + + return result[0].toI32(); + } + + try_tallyBatchSize(): ethereum.CallResult { + let result = super.tryCall( + "tallyBatchSize", + "tallyBatchSize():(uint8)", + [] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toI32()); + } + + totalVotes(): BigInt { + let result = super.call("totalVotes", "totalVotes():(uint256)", []); + + return result[0].toBigInt(); + } + + try_totalVotes(): ethereum.CallResult { + let result = super.tryCall("totalVotes", "totalVotes():(uint256)", []); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + treeDepths(): MACI__treeDepthsResult { + let result = super.call( + "treeDepths", + "treeDepths():(uint8,uint8,uint8)", + [] + ); + + return new MACI__treeDepthsResult( + result[0].toI32(), + result[1].toI32(), + result[2].toI32() + ); + } + + try_treeDepths(): ethereum.CallResult { + let result = super.tryCall( + "treeDepths", + "treeDepths():(uint8,uint8,uint8)", + [] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue( + new MACI__treeDepthsResult( + value[0].toI32(), + value[1].toI32(), + value[2].toI32() + ) + ); + } + + verifySpentVoiceCredits(_spent: BigInt, _salt: BigInt): boolean { + let result = super.call( + "verifySpentVoiceCredits", + "verifySpentVoiceCredits(uint256,uint256):(bool)", + [ + ethereum.Value.fromUnsignedBigInt(_spent), + ethereum.Value.fromUnsignedBigInt(_salt) + ] + ); + + return result[0].toBoolean(); + } + + try_verifySpentVoiceCredits( + _spent: BigInt, + _salt: BigInt + ): ethereum.CallResult { + let result = super.tryCall( + "verifySpentVoiceCredits", + "verifySpentVoiceCredits(uint256,uint256):(bool)", + [ + ethereum.Value.fromUnsignedBigInt(_spent), + ethereum.Value.fromUnsignedBigInt(_salt) + ] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBoolean()); + } + + voteOptionsMaxLeafIndex(): BigInt { + let result = super.call( + "voteOptionsMaxLeafIndex", + "voteOptionsMaxLeafIndex():(uint256)", + [] + ); + + return result[0].toBigInt(); + } + + try_voteOptionsMaxLeafIndex(): ethereum.CallResult { + let result = super.tryCall( + "voteOptionsMaxLeafIndex", + "voteOptionsMaxLeafIndex():(uint256)", + [] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + votingDurationSeconds(): BigInt { + let result = super.call( + "votingDurationSeconds", + "votingDurationSeconds():(uint256)", + [] + ); + + return result[0].toBigInt(); + } + + try_votingDurationSeconds(): ethereum.CallResult { + let result = super.tryCall( + "votingDurationSeconds", + "votingDurationSeconds():(uint256)", + [] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } +} + +export class ConstructorCall extends ethereum.Call { + get inputs(): ConstructorCall__Inputs { + return new ConstructorCall__Inputs(this); + } + + get outputs(): ConstructorCall__Outputs { + return new ConstructorCall__Outputs(this); + } +} + +export class ConstructorCall__Inputs { + _call: ConstructorCall; + + constructor(call: ConstructorCall) { + this._call = call; + } + + get _treeDepths(): ConstructorCall_treeDepthsStruct { + return this._call.inputValues[0].value.toTuple() as ConstructorCall_treeDepthsStruct; + } + + get _batchSizes(): ConstructorCall_batchSizesStruct { + return this._call.inputValues[1].value.toTuple() as ConstructorCall_batchSizesStruct; + } + + get _maxValues(): ConstructorCall_maxValuesStruct { + return this._call.inputValues[2].value.toTuple() as ConstructorCall_maxValuesStruct; + } + + get _signUpGatekeeper(): Address { + return this._call.inputValues[3].value.toAddress(); + } + + get _batchUstVerifier(): Address { + return this._call.inputValues[4].value.toAddress(); + } + + get _qvtVerifier(): Address { + return this._call.inputValues[5].value.toAddress(); + } + + get _signUpDurationSeconds(): BigInt { + return this._call.inputValues[6].value.toBigInt(); + } + + get _votingDurationSeconds(): BigInt { + return this._call.inputValues[7].value.toBigInt(); + } + + get _initialVoiceCreditProxy(): Address { + return this._call.inputValues[8].value.toAddress(); + } + + get _coordinatorPubKey(): ConstructorCall_coordinatorPubKeyStruct { + return this._call.inputValues[9].value.toTuple() as ConstructorCall_coordinatorPubKeyStruct; + } + + get _coordinatorAddress(): Address { + return this._call.inputValues[10].value.toAddress(); + } +} + +export class ConstructorCall__Outputs { + _call: ConstructorCall; + + constructor(call: ConstructorCall) { + this._call = call; + } +} + +export class ConstructorCall_treeDepthsStruct extends ethereum.Tuple { + get stateTreeDepth(): i32 { + return this[0].toI32(); + } + + get messageTreeDepth(): i32 { + return this[1].toI32(); + } + + get voteOptionTreeDepth(): i32 { + return this[2].toI32(); + } +} + +export class ConstructorCall_batchSizesStruct extends ethereum.Tuple { + get tallyBatchSize(): i32 { + return this[0].toI32(); + } + + get messageBatchSize(): i32 { + return this[1].toI32(); + } +} + +export class ConstructorCall_maxValuesStruct extends ethereum.Tuple { + get maxUsers(): BigInt { + return this[0].toBigInt(); + } + + get maxMessages(): BigInt { + return this[1].toBigInt(); + } + + get maxVoteOptions(): BigInt { + return this[2].toBigInt(); + } +} + +export class ConstructorCall_coordinatorPubKeyStruct extends ethereum.Tuple { + get x(): BigInt { + return this[0].toBigInt(); + } + + get y(): BigInt { + return this[1].toBigInt(); + } +} + +export class BatchProcessMessageCall extends ethereum.Call { + get inputs(): BatchProcessMessageCall__Inputs { + return new BatchProcessMessageCall__Inputs(this); + } + + get outputs(): BatchProcessMessageCall__Outputs { + return new BatchProcessMessageCall__Outputs(this); + } +} + +export class BatchProcessMessageCall__Inputs { + _call: BatchProcessMessageCall; + + constructor(call: BatchProcessMessageCall) { + this._call = call; + } + + get _newStateRoot(): BigInt { + return this._call.inputValues[0].value.toBigInt(); + } + + get _ecdhPubKeys(): Array { + return this._call.inputValues[1].value.toTupleArray< + BatchProcessMessageCall_ecdhPubKeysStruct + >(); + } + + get _proof(): Array { + return this._call.inputValues[2].value.toBigIntArray(); + } +} + +export class BatchProcessMessageCall__Outputs { + _call: BatchProcessMessageCall; + + constructor(call: BatchProcessMessageCall) { + this._call = call; + } +} + +export class BatchProcessMessageCall_ecdhPubKeysStruct extends ethereum.Tuple { + get x(): BigInt { + return this[0].toBigInt(); + } + + get y(): BigInt { + return this[1].toBigInt(); + } +} + +export class CoordinatorResetCall extends ethereum.Call { + get inputs(): CoordinatorResetCall__Inputs { + return new CoordinatorResetCall__Inputs(this); + } + + get outputs(): CoordinatorResetCall__Outputs { + return new CoordinatorResetCall__Outputs(this); + } +} + +export class CoordinatorResetCall__Inputs { + _call: CoordinatorResetCall; + + constructor(call: CoordinatorResetCall) { + this._call = call; + } +} + +export class CoordinatorResetCall__Outputs { + _call: CoordinatorResetCall; + + constructor(call: CoordinatorResetCall) { + this._call = call; + } +} + +export class ProveVoteTallyBatchCall extends ethereum.Call { + get inputs(): ProveVoteTallyBatchCall__Inputs { + return new ProveVoteTallyBatchCall__Inputs(this); + } + + get outputs(): ProveVoteTallyBatchCall__Outputs { + return new ProveVoteTallyBatchCall__Outputs(this); + } +} + +export class ProveVoteTallyBatchCall__Inputs { + _call: ProveVoteTallyBatchCall; + + constructor(call: ProveVoteTallyBatchCall) { + this._call = call; + } + + get _intermediateStateRoot(): BigInt { + return this._call.inputValues[0].value.toBigInt(); + } + + get _newResultsCommitment(): BigInt { + return this._call.inputValues[1].value.toBigInt(); + } + + get _newSpentVoiceCreditsCommitment(): BigInt { + return this._call.inputValues[2].value.toBigInt(); + } + + get _newPerVOSpentVoiceCreditsCommitment(): BigInt { + return this._call.inputValues[3].value.toBigInt(); + } + + get _totalVotes(): BigInt { + return this._call.inputValues[4].value.toBigInt(); + } + + get _proof(): Array { + return this._call.inputValues[5].value.toBigIntArray(); + } +} + +export class ProveVoteTallyBatchCall__Outputs { + _call: ProveVoteTallyBatchCall; + + constructor(call: ProveVoteTallyBatchCall) { + this._call = call; + } +} + +export class PublishMessageCall extends ethereum.Call { + get inputs(): PublishMessageCall__Inputs { + return new PublishMessageCall__Inputs(this); + } + + get outputs(): PublishMessageCall__Outputs { + return new PublishMessageCall__Outputs(this); + } +} + +export class PublishMessageCall__Inputs { + _call: PublishMessageCall; + + constructor(call: PublishMessageCall) { + this._call = call; + } + + get _message(): PublishMessageCall_messageStruct { + return this._call.inputValues[0].value.toTuple() as PublishMessageCall_messageStruct; + } + + get _encPubKey(): PublishMessageCall_encPubKeyStruct { + return this._call.inputValues[1].value.toTuple() as PublishMessageCall_encPubKeyStruct; + } +} + +export class PublishMessageCall__Outputs { + _call: PublishMessageCall; + + constructor(call: PublishMessageCall) { + this._call = call; + } +} + +export class PublishMessageCall_messageStruct extends ethereum.Tuple { + get iv(): BigInt { + return this[0].toBigInt(); + } + + get data(): Array { + return this[1].toBigIntArray(); + } +} + +export class PublishMessageCall_encPubKeyStruct extends ethereum.Tuple { + get x(): BigInt { + return this[0].toBigInt(); + } + + get y(): BigInt { + return this[1].toBigInt(); + } +} + +export class SignUpCall extends ethereum.Call { + get inputs(): SignUpCall__Inputs { + return new SignUpCall__Inputs(this); + } + + get outputs(): SignUpCall__Outputs { + return new SignUpCall__Outputs(this); + } +} + +export class SignUpCall__Inputs { + _call: SignUpCall; + + constructor(call: SignUpCall) { + this._call = call; + } + + get _userPubKey(): SignUpCall_userPubKeyStruct { + return this._call.inputValues[0].value.toTuple() as SignUpCall_userPubKeyStruct; + } + + get _signUpGatekeeperData(): Bytes { + return this._call.inputValues[1].value.toBytes(); + } + + get _initialVoiceCreditProxyData(): Bytes { + return this._call.inputValues[2].value.toBytes(); + } +} + +export class SignUpCall__Outputs { + _call: SignUpCall; + + constructor(call: SignUpCall) { + this._call = call; + } +} + +export class SignUpCall_userPubKeyStruct extends ethereum.Tuple { + get x(): BigInt { + return this[0].toBigInt(); + } + + get y(): BigInt { + return this[1].toBigInt(); + } +} diff --git a/subgraph/generated/schema.ts b/subgraph/generated/schema.ts index 0233621fe..94e244bec 100644 --- a/subgraph/generated/schema.ts +++ b/subgraph/generated/schema.ts @@ -468,6 +468,221 @@ export class FundingRoundFactory extends Entity { } } +export class Message extends Entity { + constructor(id: string) { + super(); + this.set("id", Value.fromString(id)); + } + + save(): void { + let id = this.get("id"); + assert(id !== null, "Cannot save Message entity without an ID"); + assert( + id.kind == ValueKind.STRING, + "Cannot save Message entity with non-string ID. " + + 'Considering using .toHex() to convert the "id" to a string.' + ); + store.set("Message", id.toString(), this); + } + + static load(id: string): Message | null { + return store.get("Message", id) as Message | null; + } + + get id(): string { + let value = this.get("id"); + return value.toString(); + } + + set id(value: string) { + this.set("id", Value.fromString(value)); + } + + get data(): Array | null { + let value = this.get("data"); + if (value === null || value.kind == ValueKind.NULL) { + return null; + } else { + return value.toBigIntArray(); + } + } + + set data(value: Array | null) { + if (value === null) { + this.unset("data"); + } else { + this.set("data", Value.fromBigIntArray(value as Array)); + } + } + + get iv(): BigInt | null { + let value = this.get("iv"); + if (value === null || value.kind == ValueKind.NULL) { + return null; + } else { + return value.toBigInt(); + } + } + + set iv(value: BigInt | null) { + if (value === null) { + this.unset("iv"); + } else { + this.set("iv", Value.fromBigInt(value as BigInt)); + } + } + + get publicKey(): string | null { + let value = this.get("publicKey"); + if (value === null || value.kind == ValueKind.NULL) { + return null; + } else { + return value.toString(); + } + } + + set publicKey(value: string | null) { + if (value === null) { + this.unset("publicKey"); + } else { + this.set("publicKey", Value.fromString(value as string)); + } + } + + get fundingRound(): string | null { + let value = this.get("fundingRound"); + if (value === null || value.kind == ValueKind.NULL) { + return null; + } else { + return value.toString(); + } + } + + set fundingRound(value: string | null) { + if (value === null) { + this.unset("fundingRound"); + } else { + this.set("fundingRound", Value.fromString(value as string)); + } + } + + get timestamp(): string | null { + let value = this.get("timestamp"); + if (value === null || value.kind == ValueKind.NULL) { + return null; + } else { + return value.toString(); + } + } + + set timestamp(value: string | null) { + if (value === null) { + this.unset("timestamp"); + } else { + this.set("timestamp", Value.fromString(value as string)); + } + } +} + +export class PublicKey extends Entity { + constructor(id: string) { + super(); + this.set("id", Value.fromString(id)); + } + + save(): void { + let id = this.get("id"); + assert(id !== null, "Cannot save PublicKey entity without an ID"); + assert( + id.kind == ValueKind.STRING, + "Cannot save PublicKey entity with non-string ID. " + + 'Considering using .toHex() to convert the "id" to a string.' + ); + store.set("PublicKey", id.toString(), this); + } + + static load(id: string): PublicKey | null { + return store.get("PublicKey", id) as PublicKey | null; + } + + get id(): string { + let value = this.get("id"); + return value.toString(); + } + + set id(value: string) { + this.set("id", Value.fromString(value)); + } + + get fundingRound(): string | null { + let value = this.get("fundingRound"); + if (value === null || value.kind == ValueKind.NULL) { + return null; + } else { + return value.toString(); + } + } + + set fundingRound(value: string | null) { + if (value === null) { + this.unset("fundingRound"); + } else { + this.set("fundingRound", Value.fromString(value as string)); + } + } + + get messages(): Array | null { + let value = this.get("messages"); + if (value === null || value.kind == ValueKind.NULL) { + return null; + } else { + return value.toStringArray(); + } + } + + set messages(value: Array | null) { + if (value === null) { + this.unset("messages"); + } else { + this.set("messages", Value.fromStringArray(value as Array)); + } + } + + get x(): BigInt | null { + let value = this.get("x"); + if (value === null || value.kind == ValueKind.NULL) { + return null; + } else { + return value.toBigInt(); + } + } + + set x(value: BigInt | null) { + if (value === null) { + this.unset("x"); + } else { + this.set("x", Value.fromBigInt(value as BigInt)); + } + } + + get y(): BigInt | null { + let value = this.get("y"); + if (value === null || value.kind == ValueKind.NULL) { + return null; + } else { + return value.toBigInt(); + } + } + + set y(value: BigInt | null) { + if (value === null) { + this.unset("y"); + } else { + this.set("y", Value.fromBigInt(value as BigInt)); + } + } +} + export class FundingRound extends Entity { constructor(id: string) { super(); @@ -515,6 +730,40 @@ export class FundingRound extends Entity { } } + get maci(): Bytes | null { + let value = this.get("maci"); + if (value === null || value.kind == ValueKind.NULL) { + return null; + } else { + return value.toBytes(); + } + } + + set maci(value: Bytes | null) { + if (value === null) { + this.unset("maci"); + } else { + this.set("maci", Value.fromBytes(value as Bytes)); + } + } + + get messages(): Array | null { + let value = this.get("messages"); + if (value === null || value.kind == ValueKind.NULL) { + return null; + } else { + return value.toStringArray(); + } + } + + set messages(value: Array | null) { + if (value === null) { + this.unset("messages"); + } else { + this.set("messages", Value.fromStringArray(value as Array)); + } + } + get recipientRegistry(): string | null { let value = this.get("recipientRegistry"); if (value === null || value.kind == ValueKind.NULL) { @@ -668,23 +917,6 @@ export class FundingRound extends Entity { } } - get maci(): Bytes | null { - let value = this.get("maci"); - if (value === null || value.kind == ValueKind.NULL) { - return null; - } else { - return value.toBytes(); - } - } - - set maci(value: Bytes | null) { - if (value === null) { - this.unset("maci"); - } else { - this.set("maci", Value.fromBytes(value as Bytes)); - } - } - get voiceCreditFactor(): BigInt | null { let value = this.get("voiceCreditFactor"); if (value === null || value.kind == ValueKind.NULL) { diff --git a/subgraph/generated/templates.ts b/subgraph/generated/templates.ts index 5a9ffb36b..754dd9bd0 100644 --- a/subgraph/generated/templates.ts +++ b/subgraph/generated/templates.ts @@ -47,3 +47,13 @@ export class BrightIdUserRegistry extends DataSourceTemplate { ); } } + +export class MACI extends DataSourceTemplate { + static create(address: Address): void { + DataSourceTemplate.create("MACI", [address.toHex()]); + } + + static createWithContext(address: Address, context: DataSourceContext): void { + DataSourceTemplate.createWithContext("MACI", [address.toHex()], context); + } +} diff --git a/subgraph/generated/templates/MACI/FundingRound.ts b/subgraph/generated/templates/MACI/FundingRound.ts new file mode 100644 index 000000000..fd49a661b --- /dev/null +++ b/subgraph/generated/templates/MACI/FundingRound.ts @@ -0,0 +1,821 @@ +// THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. + +import { + ethereum, + JSONValue, + TypedMap, + Entity, + Bytes, + Address, + BigInt +} from "@graphprotocol/graph-ts"; + +export class Contribution extends ethereum.Event { + get params(): Contribution__Params { + return new Contribution__Params(this); + } +} + +export class Contribution__Params { + _event: Contribution; + + constructor(event: Contribution) { + this._event = event; + } + + get _sender(): Address { + return this._event.parameters[0].value.toAddress(); + } + + get _amount(): BigInt { + return this._event.parameters[1].value.toBigInt(); + } +} + +export class ContributionWithdrawn extends ethereum.Event { + get params(): ContributionWithdrawn__Params { + return new ContributionWithdrawn__Params(this); + } +} + +export class ContributionWithdrawn__Params { + _event: ContributionWithdrawn; + + constructor(event: ContributionWithdrawn) { + this._event = event; + } + + get _contributor(): Address { + return this._event.parameters[0].value.toAddress(); + } +} + +export class FundsClaimed extends ethereum.Event { + get params(): FundsClaimed__Params { + return new FundsClaimed__Params(this); + } +} + +export class FundsClaimed__Params { + _event: FundsClaimed; + + constructor(event: FundsClaimed) { + this._event = event; + } + + get _voteOptionIndex(): BigInt { + return this._event.parameters[0].value.toBigInt(); + } + + get _recipient(): Address { + return this._event.parameters[1].value.toAddress(); + } + + get _amount(): BigInt { + return this._event.parameters[2].value.toBigInt(); + } +} + +export class OwnershipTransferred extends ethereum.Event { + get params(): OwnershipTransferred__Params { + return new OwnershipTransferred__Params(this); + } +} + +export class OwnershipTransferred__Params { + _event: OwnershipTransferred; + + constructor(event: OwnershipTransferred) { + this._event = event; + } + + get previousOwner(): Address { + return this._event.parameters[0].value.toAddress(); + } + + get newOwner(): Address { + return this._event.parameters[1].value.toAddress(); + } +} + +export class TallyPublished extends ethereum.Event { + get params(): TallyPublished__Params { + return new TallyPublished__Params(this); + } +} + +export class TallyPublished__Params { + _event: TallyPublished; + + constructor(event: TallyPublished) { + this._event = event; + } + + get _tallyHash(): string { + return this._event.parameters[0].value.toString(); + } +} + +export class Voted extends ethereum.Event { + get params(): Voted__Params { + return new Voted__Params(this); + } +} + +export class Voted__Params { + _event: Voted; + + constructor(event: Voted) { + this._event = event; + } + + get _contributor(): Address { + return this._event.parameters[0].value.toAddress(); + } +} + +export class FundingRound extends ethereum.SmartContract { + static bind(address: Address): FundingRound { + return new FundingRound("FundingRound", address); + } + + contributorCount(): BigInt { + let result = super.call( + "contributorCount", + "contributorCount():(uint256)", + [] + ); + + return result[0].toBigInt(); + } + + try_contributorCount(): ethereum.CallResult { + let result = super.tryCall( + "contributorCount", + "contributorCount():(uint256)", + [] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + coordinator(): Address { + let result = super.call("coordinator", "coordinator():(address)", []); + + return result[0].toAddress(); + } + + try_coordinator(): ethereum.CallResult
{ + let result = super.tryCall("coordinator", "coordinator():(address)", []); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toAddress()); + } + + getAllocatedAmount(_tallyResult: BigInt, _spent: BigInt): BigInt { + let result = super.call( + "getAllocatedAmount", + "getAllocatedAmount(uint256,uint256):(uint256)", + [ + ethereum.Value.fromUnsignedBigInt(_tallyResult), + ethereum.Value.fromUnsignedBigInt(_spent) + ] + ); + + return result[0].toBigInt(); + } + + try_getAllocatedAmount( + _tallyResult: BigInt, + _spent: BigInt + ): ethereum.CallResult { + let result = super.tryCall( + "getAllocatedAmount", + "getAllocatedAmount(uint256,uint256):(uint256)", + [ + ethereum.Value.fromUnsignedBigInt(_tallyResult), + ethereum.Value.fromUnsignedBigInt(_spent) + ] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + getVoiceCredits(param0: Address, _data: Bytes): BigInt { + let result = super.call( + "getVoiceCredits", + "getVoiceCredits(address,bytes):(uint256)", + [ethereum.Value.fromAddress(param0), ethereum.Value.fromBytes(_data)] + ); + + return result[0].toBigInt(); + } + + try_getVoiceCredits( + param0: Address, + _data: Bytes + ): ethereum.CallResult { + let result = super.tryCall( + "getVoiceCredits", + "getVoiceCredits(address,bytes):(uint256)", + [ethereum.Value.fromAddress(param0), ethereum.Value.fromBytes(_data)] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + isCancelled(): boolean { + let result = super.call("isCancelled", "isCancelled():(bool)", []); + + return result[0].toBoolean(); + } + + try_isCancelled(): ethereum.CallResult { + let result = super.tryCall("isCancelled", "isCancelled():(bool)", []); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBoolean()); + } + + isFinalized(): boolean { + let result = super.call("isFinalized", "isFinalized():(bool)", []); + + return result[0].toBoolean(); + } + + try_isFinalized(): ethereum.CallResult { + let result = super.tryCall("isFinalized", "isFinalized():(bool)", []); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBoolean()); + } + + maci(): Address { + let result = super.call("maci", "maci():(address)", []); + + return result[0].toAddress(); + } + + try_maci(): ethereum.CallResult
{ + let result = super.tryCall("maci", "maci():(address)", []); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toAddress()); + } + + matchingPoolSize(): BigInt { + let result = super.call( + "matchingPoolSize", + "matchingPoolSize():(uint256)", + [] + ); + + return result[0].toBigInt(); + } + + try_matchingPoolSize(): ethereum.CallResult { + let result = super.tryCall( + "matchingPoolSize", + "matchingPoolSize():(uint256)", + [] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + nativeToken(): Address { + let result = super.call("nativeToken", "nativeToken():(address)", []); + + return result[0].toAddress(); + } + + try_nativeToken(): ethereum.CallResult
{ + let result = super.tryCall("nativeToken", "nativeToken():(address)", []); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toAddress()); + } + + owner(): Address { + let result = super.call("owner", "owner():(address)", []); + + return result[0].toAddress(); + } + + try_owner(): ethereum.CallResult
{ + let result = super.tryCall("owner", "owner():(address)", []); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toAddress()); + } + + recipientRegistry(): Address { + let result = super.call( + "recipientRegistry", + "recipientRegistry():(address)", + [] + ); + + return result[0].toAddress(); + } + + try_recipientRegistry(): ethereum.CallResult
{ + let result = super.tryCall( + "recipientRegistry", + "recipientRegistry():(address)", + [] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toAddress()); + } + + tallyHash(): string { + let result = super.call("tallyHash", "tallyHash():(string)", []); + + return result[0].toString(); + } + + try_tallyHash(): ethereum.CallResult { + let result = super.tryCall("tallyHash", "tallyHash():(string)", []); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toString()); + } + + totalSpent(): BigInt { + let result = super.call("totalSpent", "totalSpent():(uint256)", []); + + return result[0].toBigInt(); + } + + try_totalSpent(): ethereum.CallResult { + let result = super.tryCall("totalSpent", "totalSpent():(uint256)", []); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + totalVotes(): BigInt { + let result = super.call("totalVotes", "totalVotes():(uint256)", []); + + return result[0].toBigInt(); + } + + try_totalVotes(): ethereum.CallResult { + let result = super.tryCall("totalVotes", "totalVotes():(uint256)", []); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + userRegistry(): Address { + let result = super.call("userRegistry", "userRegistry():(address)", []); + + return result[0].toAddress(); + } + + try_userRegistry(): ethereum.CallResult
{ + let result = super.tryCall("userRegistry", "userRegistry():(address)", []); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toAddress()); + } + + voiceCreditFactor(): BigInt { + let result = super.call( + "voiceCreditFactor", + "voiceCreditFactor():(uint256)", + [] + ); + + return result[0].toBigInt(); + } + + try_voiceCreditFactor(): ethereum.CallResult { + let result = super.tryCall( + "voiceCreditFactor", + "voiceCreditFactor():(uint256)", + [] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } +} + +export class ConstructorCall extends ethereum.Call { + get inputs(): ConstructorCall__Inputs { + return new ConstructorCall__Inputs(this); + } + + get outputs(): ConstructorCall__Outputs { + return new ConstructorCall__Outputs(this); + } +} + +export class ConstructorCall__Inputs { + _call: ConstructorCall; + + constructor(call: ConstructorCall) { + this._call = call; + } + + get _nativeToken(): Address { + return this._call.inputValues[0].value.toAddress(); + } + + get _userRegistry(): Address { + return this._call.inputValues[1].value.toAddress(); + } + + get _recipientRegistry(): Address { + return this._call.inputValues[2].value.toAddress(); + } + + get _coordinator(): Address { + return this._call.inputValues[3].value.toAddress(); + } +} + +export class ConstructorCall__Outputs { + _call: ConstructorCall; + + constructor(call: ConstructorCall) { + this._call = call; + } +} + +export class CancelCall extends ethereum.Call { + get inputs(): CancelCall__Inputs { + return new CancelCall__Inputs(this); + } + + get outputs(): CancelCall__Outputs { + return new CancelCall__Outputs(this); + } +} + +export class CancelCall__Inputs { + _call: CancelCall; + + constructor(call: CancelCall) { + this._call = call; + } +} + +export class CancelCall__Outputs { + _call: CancelCall; + + constructor(call: CancelCall) { + this._call = call; + } +} + +export class ContributeCall extends ethereum.Call { + get inputs(): ContributeCall__Inputs { + return new ContributeCall__Inputs(this); + } + + get outputs(): ContributeCall__Outputs { + return new ContributeCall__Outputs(this); + } +} + +export class ContributeCall__Inputs { + _call: ContributeCall; + + constructor(call: ContributeCall) { + this._call = call; + } + + get pubKey(): ContributeCallPubKeyStruct { + return this._call.inputValues[0].value.toTuple() as ContributeCallPubKeyStruct; + } + + get amount(): BigInt { + return this._call.inputValues[1].value.toBigInt(); + } +} + +export class ContributeCall__Outputs { + _call: ContributeCall; + + constructor(call: ContributeCall) { + this._call = call; + } +} + +export class ContributeCallPubKeyStruct extends ethereum.Tuple { + get x(): BigInt { + return this[0].toBigInt(); + } + + get y(): BigInt { + return this[1].toBigInt(); + } +} + +export class FinalizeCall extends ethereum.Call { + get inputs(): FinalizeCall__Inputs { + return new FinalizeCall__Inputs(this); + } + + get outputs(): FinalizeCall__Outputs { + return new FinalizeCall__Outputs(this); + } +} + +export class FinalizeCall__Inputs { + _call: FinalizeCall; + + constructor(call: FinalizeCall) { + this._call = call; + } + + get _totalSpent(): BigInt { + return this._call.inputValues[0].value.toBigInt(); + } + + get _totalSpentSalt(): BigInt { + return this._call.inputValues[1].value.toBigInt(); + } +} + +export class FinalizeCall__Outputs { + _call: FinalizeCall; + + constructor(call: FinalizeCall) { + this._call = call; + } +} + +export class PublishTallyHashCall extends ethereum.Call { + get inputs(): PublishTallyHashCall__Inputs { + return new PublishTallyHashCall__Inputs(this); + } + + get outputs(): PublishTallyHashCall__Outputs { + return new PublishTallyHashCall__Outputs(this); + } +} + +export class PublishTallyHashCall__Inputs { + _call: PublishTallyHashCall; + + constructor(call: PublishTallyHashCall) { + this._call = call; + } + + get _tallyHash(): string { + return this._call.inputValues[0].value.toString(); + } +} + +export class PublishTallyHashCall__Outputs { + _call: PublishTallyHashCall; + + constructor(call: PublishTallyHashCall) { + this._call = call; + } +} + +export class RegisterCall extends ethereum.Call { + get inputs(): RegisterCall__Inputs { + return new RegisterCall__Inputs(this); + } + + get outputs(): RegisterCall__Outputs { + return new RegisterCall__Outputs(this); + } +} + +export class RegisterCall__Inputs { + _call: RegisterCall; + + constructor(call: RegisterCall) { + this._call = call; + } + + get value0(): Address { + return this._call.inputValues[0].value.toAddress(); + } + + get _data(): Bytes { + return this._call.inputValues[1].value.toBytes(); + } +} + +export class RegisterCall__Outputs { + _call: RegisterCall; + + constructor(call: RegisterCall) { + this._call = call; + } +} + +export class RenounceOwnershipCall extends ethereum.Call { + get inputs(): RenounceOwnershipCall__Inputs { + return new RenounceOwnershipCall__Inputs(this); + } + + get outputs(): RenounceOwnershipCall__Outputs { + return new RenounceOwnershipCall__Outputs(this); + } +} + +export class RenounceOwnershipCall__Inputs { + _call: RenounceOwnershipCall; + + constructor(call: RenounceOwnershipCall) { + this._call = call; + } +} + +export class RenounceOwnershipCall__Outputs { + _call: RenounceOwnershipCall; + + constructor(call: RenounceOwnershipCall) { + this._call = call; + } +} + +export class SetMaciCall extends ethereum.Call { + get inputs(): SetMaciCall__Inputs { + return new SetMaciCall__Inputs(this); + } + + get outputs(): SetMaciCall__Outputs { + return new SetMaciCall__Outputs(this); + } +} + +export class SetMaciCall__Inputs { + _call: SetMaciCall; + + constructor(call: SetMaciCall) { + this._call = call; + } + + get _maci(): Address { + return this._call.inputValues[0].value.toAddress(); + } +} + +export class SetMaciCall__Outputs { + _call: SetMaciCall; + + constructor(call: SetMaciCall) { + this._call = call; + } +} + +export class SubmitMessageBatchCall extends ethereum.Call { + get inputs(): SubmitMessageBatchCall__Inputs { + return new SubmitMessageBatchCall__Inputs(this); + } + + get outputs(): SubmitMessageBatchCall__Outputs { + return new SubmitMessageBatchCall__Outputs(this); + } +} + +export class SubmitMessageBatchCall__Inputs { + _call: SubmitMessageBatchCall; + + constructor(call: SubmitMessageBatchCall) { + this._call = call; + } + + get _messages(): Array { + return this._call.inputValues[0].value.toTupleArray< + SubmitMessageBatchCall_messagesStruct + >(); + } + + get _encPubKeys(): Array { + return this._call.inputValues[1].value.toTupleArray< + SubmitMessageBatchCall_encPubKeysStruct + >(); + } +} + +export class SubmitMessageBatchCall__Outputs { + _call: SubmitMessageBatchCall; + + constructor(call: SubmitMessageBatchCall) { + this._call = call; + } +} + +export class SubmitMessageBatchCall_messagesStruct extends ethereum.Tuple { + get iv(): BigInt { + return this[0].toBigInt(); + } + + get data(): Array { + return this[1].toBigIntArray(); + } +} + +export class SubmitMessageBatchCall_encPubKeysStruct extends ethereum.Tuple { + get x(): BigInt { + return this[0].toBigInt(); + } + + get y(): BigInt { + return this[1].toBigInt(); + } +} + +export class TransferOwnershipCall extends ethereum.Call { + get inputs(): TransferOwnershipCall__Inputs { + return new TransferOwnershipCall__Inputs(this); + } + + get outputs(): TransferOwnershipCall__Outputs { + return new TransferOwnershipCall__Outputs(this); + } +} + +export class TransferOwnershipCall__Inputs { + _call: TransferOwnershipCall; + + constructor(call: TransferOwnershipCall) { + this._call = call; + } + + get newOwner(): Address { + return this._call.inputValues[0].value.toAddress(); + } +} + +export class TransferOwnershipCall__Outputs { + _call: TransferOwnershipCall; + + constructor(call: TransferOwnershipCall) { + this._call = call; + } +} + +export class WithdrawContributionCall extends ethereum.Call { + get inputs(): WithdrawContributionCall__Inputs { + return new WithdrawContributionCall__Inputs(this); + } + + get outputs(): WithdrawContributionCall__Outputs { + return new WithdrawContributionCall__Outputs(this); + } +} + +export class WithdrawContributionCall__Inputs { + _call: WithdrawContributionCall; + + constructor(call: WithdrawContributionCall) { + this._call = call; + } +} + +export class WithdrawContributionCall__Outputs { + _call: WithdrawContributionCall; + + constructor(call: WithdrawContributionCall) { + this._call = call; + } +} diff --git a/subgraph/generated/templates/MACI/MACI.ts b/subgraph/generated/templates/MACI/MACI.ts new file mode 100644 index 000000000..de37f2956 --- /dev/null +++ b/subgraph/generated/templates/MACI/MACI.ts @@ -0,0 +1,1634 @@ +// THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. + +import { + ethereum, + JSONValue, + TypedMap, + Entity, + Bytes, + Address, + BigInt +} from "@graphprotocol/graph-ts"; + +export class PublishMessage extends ethereum.Event { + get params(): PublishMessage__Params { + return new PublishMessage__Params(this); + } +} + +export class PublishMessage__Params { + _event: PublishMessage; + + constructor(event: PublishMessage) { + this._event = event; + } + + get _message(): PublishMessage_messageStruct { + return this._event.parameters[0].value.toTuple() as PublishMessage_messageStruct; + } + + get _encPubKey(): PublishMessage_encPubKeyStruct { + return this._event.parameters[1].value.toTuple() as PublishMessage_encPubKeyStruct; + } +} + +export class PublishMessage_messageStruct extends ethereum.Tuple { + get iv(): BigInt { + return this[0].toBigInt(); + } + + get data(): Array { + return this[1].toBigIntArray(); + } +} + +export class PublishMessage_encPubKeyStruct extends ethereum.Tuple { + get x(): BigInt { + return this[0].toBigInt(); + } + + get y(): BigInt { + return this[1].toBigInt(); + } +} + +export class SignUp extends ethereum.Event { + get params(): SignUp__Params { + return new SignUp__Params(this); + } +} + +export class SignUp__Params { + _event: SignUp; + + constructor(event: SignUp) { + this._event = event; + } + + get _userPubKey(): SignUp_userPubKeyStruct { + return this._event.parameters[0].value.toTuple() as SignUp_userPubKeyStruct; + } + + get _stateIndex(): BigInt { + return this._event.parameters[1].value.toBigInt(); + } + + get _voiceCreditBalance(): BigInt { + return this._event.parameters[2].value.toBigInt(); + } +} + +export class SignUp_userPubKeyStruct extends ethereum.Tuple { + get x(): BigInt { + return this[0].toBigInt(); + } + + get y(): BigInt { + return this[1].toBigInt(); + } +} + +export class MACI__coordinatorPubKeyResult { + value0: BigInt; + value1: BigInt; + + constructor(value0: BigInt, value1: BigInt) { + this.value0 = value0; + this.value1 = value1; + } + + toMap(): TypedMap { + let map = new TypedMap(); + map.set("value0", ethereum.Value.fromUnsignedBigInt(this.value0)); + map.set("value1", ethereum.Value.fromUnsignedBigInt(this.value1)); + return map; + } +} + +export class MACI__genBatchUstPublicSignalsInput_ecdhPubKeysStruct extends ethereum.Tuple { + get x(): BigInt { + return this[0].toBigInt(); + } + + get y(): BigInt { + return this[1].toBigInt(); + } +} + +export class MACI__hashMessageInput_messageStruct extends ethereum.Tuple { + get iv(): BigInt { + return this[0].toBigInt(); + } + + get data(): Array { + return this[1].toBigIntArray(); + } +} + +export class MACI__hashStateLeafInput_stateLeafStruct extends ethereum.Tuple { + get pubKey(): MACI__hashStateLeafInput_stateLeafPubKeyStruct { + return this[0].toTuple() as MACI__hashStateLeafInput_stateLeafPubKeyStruct; + } + + get voteOptionTreeRoot(): BigInt { + return this[1].toBigInt(); + } + + get voiceCreditBalance(): BigInt { + return this[2].toBigInt(); + } + + get nonce(): BigInt { + return this[3].toBigInt(); + } +} + +export class MACI__hashStateLeafInput_stateLeafPubKeyStruct extends ethereum.Tuple { + get x(): BigInt { + return this[0].toBigInt(); + } + + get y(): BigInt { + return this[1].toBigInt(); + } +} + +export class MACI__treeDepthsResult { + value0: i32; + value1: i32; + value2: i32; + + constructor(value0: i32, value1: i32, value2: i32) { + this.value0 = value0; + this.value1 = value1; + this.value2 = value2; + } + + toMap(): TypedMap { + let map = new TypedMap(); + map.set( + "value0", + ethereum.Value.fromUnsignedBigInt(BigInt.fromI32(this.value0)) + ); + map.set( + "value1", + ethereum.Value.fromUnsignedBigInt(BigInt.fromI32(this.value1)) + ); + map.set( + "value2", + ethereum.Value.fromUnsignedBigInt(BigInt.fromI32(this.value2)) + ); + return map; + } +} + +export class MACI extends ethereum.SmartContract { + static bind(address: Address): MACI { + return new MACI("MACI", address); + } + + calcEmptyVoteOptionTreeRoot(_levels: i32): BigInt { + let result = super.call( + "calcEmptyVoteOptionTreeRoot", + "calcEmptyVoteOptionTreeRoot(uint8):(uint256)", + [ethereum.Value.fromUnsignedBigInt(BigInt.fromI32(_levels))] + ); + + return result[0].toBigInt(); + } + + try_calcEmptyVoteOptionTreeRoot(_levels: i32): ethereum.CallResult { + let result = super.tryCall( + "calcEmptyVoteOptionTreeRoot", + "calcEmptyVoteOptionTreeRoot(uint8):(uint256)", + [ethereum.Value.fromUnsignedBigInt(BigInt.fromI32(_levels))] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + calcSignUpDeadline(): BigInt { + let result = super.call( + "calcSignUpDeadline", + "calcSignUpDeadline():(uint256)", + [] + ); + + return result[0].toBigInt(); + } + + try_calcSignUpDeadline(): ethereum.CallResult { + let result = super.tryCall( + "calcSignUpDeadline", + "calcSignUpDeadline():(uint256)", + [] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + calcVotingDeadline(): BigInt { + let result = super.call( + "calcVotingDeadline", + "calcVotingDeadline():(uint256)", + [] + ); + + return result[0].toBigInt(); + } + + try_calcVotingDeadline(): ethereum.CallResult { + let result = super.tryCall( + "calcVotingDeadline", + "calcVotingDeadline():(uint256)", + [] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + computeEmptyQuinRoot(_treeLevels: i32, _zeroValue: BigInt): BigInt { + let result = super.call( + "computeEmptyQuinRoot", + "computeEmptyQuinRoot(uint8,uint256):(uint256)", + [ + ethereum.Value.fromUnsignedBigInt(BigInt.fromI32(_treeLevels)), + ethereum.Value.fromUnsignedBigInt(_zeroValue) + ] + ); + + return result[0].toBigInt(); + } + + try_computeEmptyQuinRoot( + _treeLevels: i32, + _zeroValue: BigInt + ): ethereum.CallResult { + let result = super.tryCall( + "computeEmptyQuinRoot", + "computeEmptyQuinRoot(uint8,uint256):(uint256)", + [ + ethereum.Value.fromUnsignedBigInt(BigInt.fromI32(_treeLevels)), + ethereum.Value.fromUnsignedBigInt(_zeroValue) + ] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + computeEmptyRoot(_treeLevels: i32, _zeroValue: BigInt): BigInt { + let result = super.call( + "computeEmptyRoot", + "computeEmptyRoot(uint8,uint256):(uint256)", + [ + ethereum.Value.fromUnsignedBigInt(BigInt.fromI32(_treeLevels)), + ethereum.Value.fromUnsignedBigInt(_zeroValue) + ] + ); + + return result[0].toBigInt(); + } + + try_computeEmptyRoot( + _treeLevels: i32, + _zeroValue: BigInt + ): ethereum.CallResult { + let result = super.tryCall( + "computeEmptyRoot", + "computeEmptyRoot(uint8,uint256):(uint256)", + [ + ethereum.Value.fromUnsignedBigInt(BigInt.fromI32(_treeLevels)), + ethereum.Value.fromUnsignedBigInt(_zeroValue) + ] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + coordinatorAddress(): Address { + let result = super.call( + "coordinatorAddress", + "coordinatorAddress():(address)", + [] + ); + + return result[0].toAddress(); + } + + try_coordinatorAddress(): ethereum.CallResult
{ + let result = super.tryCall( + "coordinatorAddress", + "coordinatorAddress():(address)", + [] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toAddress()); + } + + coordinatorPubKey(): MACI__coordinatorPubKeyResult { + let result = super.call( + "coordinatorPubKey", + "coordinatorPubKey():(uint256,uint256)", + [] + ); + + return new MACI__coordinatorPubKeyResult( + result[0].toBigInt(), + result[1].toBigInt() + ); + } + + try_coordinatorPubKey(): ethereum.CallResult { + let result = super.tryCall( + "coordinatorPubKey", + "coordinatorPubKey():(uint256,uint256)", + [] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue( + new MACI__coordinatorPubKeyResult( + value[0].toBigInt(), + value[1].toBigInt() + ) + ); + } + + currentMessageBatchIndex(): BigInt { + let result = super.call( + "currentMessageBatchIndex", + "currentMessageBatchIndex():(uint256)", + [] + ); + + return result[0].toBigInt(); + } + + try_currentMessageBatchIndex(): ethereum.CallResult { + let result = super.tryCall( + "currentMessageBatchIndex", + "currentMessageBatchIndex():(uint256)", + [] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + currentPerVOSpentVoiceCreditsCommitment(): BigInt { + let result = super.call( + "currentPerVOSpentVoiceCreditsCommitment", + "currentPerVOSpentVoiceCreditsCommitment():(uint256)", + [] + ); + + return result[0].toBigInt(); + } + + try_currentPerVOSpentVoiceCreditsCommitment(): ethereum.CallResult { + let result = super.tryCall( + "currentPerVOSpentVoiceCreditsCommitment", + "currentPerVOSpentVoiceCreditsCommitment():(uint256)", + [] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + currentQvtBatchNum(): BigInt { + let result = super.call( + "currentQvtBatchNum", + "currentQvtBatchNum():(uint256)", + [] + ); + + return result[0].toBigInt(); + } + + try_currentQvtBatchNum(): ethereum.CallResult { + let result = super.tryCall( + "currentQvtBatchNum", + "currentQvtBatchNum():(uint256)", + [] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + currentResultsCommitment(): BigInt { + let result = super.call( + "currentResultsCommitment", + "currentResultsCommitment():(uint256)", + [] + ); + + return result[0].toBigInt(); + } + + try_currentResultsCommitment(): ethereum.CallResult { + let result = super.tryCall( + "currentResultsCommitment", + "currentResultsCommitment():(uint256)", + [] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + currentSpentVoiceCreditsCommitment(): BigInt { + let result = super.call( + "currentSpentVoiceCreditsCommitment", + "currentSpentVoiceCreditsCommitment():(uint256)", + [] + ); + + return result[0].toBigInt(); + } + + try_currentSpentVoiceCreditsCommitment(): ethereum.CallResult { + let result = super.tryCall( + "currentSpentVoiceCreditsCommitment", + "currentSpentVoiceCreditsCommitment():(uint256)", + [] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + emptyVoteOptionTreeRoot(): BigInt { + let result = super.call( + "emptyVoteOptionTreeRoot", + "emptyVoteOptionTreeRoot():(uint256)", + [] + ); + + return result[0].toBigInt(); + } + + try_emptyVoteOptionTreeRoot(): ethereum.CallResult { + let result = super.tryCall( + "emptyVoteOptionTreeRoot", + "emptyVoteOptionTreeRoot():(uint256)", + [] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + genBatchUstPublicSignals( + _newStateRoot: BigInt, + _ecdhPubKeys: Array + ): Array { + let result = super.call( + "genBatchUstPublicSignals", + "genBatchUstPublicSignals(uint256,(uint256,uint256)[]):(uint256[])", + [ + ethereum.Value.fromUnsignedBigInt(_newStateRoot), + ethereum.Value.fromTupleArray(_ecdhPubKeys) + ] + ); + + return result[0].toBigIntArray(); + } + + try_genBatchUstPublicSignals( + _newStateRoot: BigInt, + _ecdhPubKeys: Array + ): ethereum.CallResult> { + let result = super.tryCall( + "genBatchUstPublicSignals", + "genBatchUstPublicSignals(uint256,(uint256,uint256)[]):(uint256[])", + [ + ethereum.Value.fromUnsignedBigInt(_newStateRoot), + ethereum.Value.fromTupleArray(_ecdhPubKeys) + ] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigIntArray()); + } + + genQvtPublicSignals( + _intermediateStateRoot: BigInt, + _newResultsCommitment: BigInt, + _newSpentVoiceCreditsCommitment: BigInt, + _newPerVOSpentVoiceCreditsCommitment: BigInt, + _totalVotes: BigInt + ): Array { + let result = super.call( + "genQvtPublicSignals", + "genQvtPublicSignals(uint256,uint256,uint256,uint256,uint256):(uint256[])", + [ + ethereum.Value.fromUnsignedBigInt(_intermediateStateRoot), + ethereum.Value.fromUnsignedBigInt(_newResultsCommitment), + ethereum.Value.fromUnsignedBigInt(_newSpentVoiceCreditsCommitment), + ethereum.Value.fromUnsignedBigInt(_newPerVOSpentVoiceCreditsCommitment), + ethereum.Value.fromUnsignedBigInt(_totalVotes) + ] + ); + + return result[0].toBigIntArray(); + } + + try_genQvtPublicSignals( + _intermediateStateRoot: BigInt, + _newResultsCommitment: BigInt, + _newSpentVoiceCreditsCommitment: BigInt, + _newPerVOSpentVoiceCreditsCommitment: BigInt, + _totalVotes: BigInt + ): ethereum.CallResult> { + let result = super.tryCall( + "genQvtPublicSignals", + "genQvtPublicSignals(uint256,uint256,uint256,uint256,uint256):(uint256[])", + [ + ethereum.Value.fromUnsignedBigInt(_intermediateStateRoot), + ethereum.Value.fromUnsignedBigInt(_newResultsCommitment), + ethereum.Value.fromUnsignedBigInt(_newSpentVoiceCreditsCommitment), + ethereum.Value.fromUnsignedBigInt(_newPerVOSpentVoiceCreditsCommitment), + ethereum.Value.fromUnsignedBigInt(_totalVotes) + ] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigIntArray()); + } + + getMessageTreeRoot(): BigInt { + let result = super.call( + "getMessageTreeRoot", + "getMessageTreeRoot():(uint256)", + [] + ); + + return result[0].toBigInt(); + } + + try_getMessageTreeRoot(): ethereum.CallResult { + let result = super.tryCall( + "getMessageTreeRoot", + "getMessageTreeRoot():(uint256)", + [] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + getStateTreeRoot(): BigInt { + let result = super.call( + "getStateTreeRoot", + "getStateTreeRoot():(uint256)", + [] + ); + + return result[0].toBigInt(); + } + + try_getStateTreeRoot(): ethereum.CallResult { + let result = super.tryCall( + "getStateTreeRoot", + "getStateTreeRoot():(uint256)", + [] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + hasUnprocessedMessages(): boolean { + let result = super.call( + "hasUnprocessedMessages", + "hasUnprocessedMessages():(bool)", + [] + ); + + return result[0].toBoolean(); + } + + try_hasUnprocessedMessages(): ethereum.CallResult { + let result = super.tryCall( + "hasUnprocessedMessages", + "hasUnprocessedMessages():(bool)", + [] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBoolean()); + } + + hasUntalliedStateLeaves(): boolean { + let result = super.call( + "hasUntalliedStateLeaves", + "hasUntalliedStateLeaves():(bool)", + [] + ); + + return result[0].toBoolean(); + } + + try_hasUntalliedStateLeaves(): ethereum.CallResult { + let result = super.tryCall( + "hasUntalliedStateLeaves", + "hasUntalliedStateLeaves():(bool)", + [] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBoolean()); + } + + hash11(array: Array): BigInt { + let result = super.call("hash11", "hash11(uint256[]):(uint256)", [ + ethereum.Value.fromUnsignedBigIntArray(array) + ]); + + return result[0].toBigInt(); + } + + try_hash11(array: Array): ethereum.CallResult { + let result = super.tryCall("hash11", "hash11(uint256[]):(uint256)", [ + ethereum.Value.fromUnsignedBigIntArray(array) + ]); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + hash5(array: Array): BigInt { + let result = super.call("hash5", "hash5(uint256[5]):(uint256)", [ + ethereum.Value.fromUnsignedBigIntArray(array) + ]); + + return result[0].toBigInt(); + } + + try_hash5(array: Array): ethereum.CallResult { + let result = super.tryCall("hash5", "hash5(uint256[5]):(uint256)", [ + ethereum.Value.fromUnsignedBigIntArray(array) + ]); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + hashLeftRight(_left: BigInt, _right: BigInt): BigInt { + let result = super.call( + "hashLeftRight", + "hashLeftRight(uint256,uint256):(uint256)", + [ + ethereum.Value.fromUnsignedBigInt(_left), + ethereum.Value.fromUnsignedBigInt(_right) + ] + ); + + return result[0].toBigInt(); + } + + try_hashLeftRight( + _left: BigInt, + _right: BigInt + ): ethereum.CallResult { + let result = super.tryCall( + "hashLeftRight", + "hashLeftRight(uint256,uint256):(uint256)", + [ + ethereum.Value.fromUnsignedBigInt(_left), + ethereum.Value.fromUnsignedBigInt(_right) + ] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + hashMessage(_message: MACI__hashMessageInput_messageStruct): BigInt { + let result = super.call( + "hashMessage", + "hashMessage((uint256,uint256[10])):(uint256)", + [ethereum.Value.fromTuple(_message)] + ); + + return result[0].toBigInt(); + } + + try_hashMessage( + _message: MACI__hashMessageInput_messageStruct + ): ethereum.CallResult { + let result = super.tryCall( + "hashMessage", + "hashMessage((uint256,uint256[10])):(uint256)", + [ethereum.Value.fromTuple(_message)] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + hashStateLeaf(_stateLeaf: MACI__hashStateLeafInput_stateLeafStruct): BigInt { + let result = super.call( + "hashStateLeaf", + "hashStateLeaf(((uint256,uint256),uint256,uint256,uint256)):(uint256)", + [ethereum.Value.fromTuple(_stateLeaf)] + ); + + return result[0].toBigInt(); + } + + try_hashStateLeaf( + _stateLeaf: MACI__hashStateLeafInput_stateLeafStruct + ): ethereum.CallResult { + let result = super.tryCall( + "hashStateLeaf", + "hashStateLeaf(((uint256,uint256),uint256,uint256,uint256)):(uint256)", + [ethereum.Value.fromTuple(_stateLeaf)] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + hashedBlankStateLeaf(): BigInt { + let result = super.call( + "hashedBlankStateLeaf", + "hashedBlankStateLeaf():(uint256)", + [] + ); + + return result[0].toBigInt(); + } + + try_hashedBlankStateLeaf(): ethereum.CallResult { + let result = super.tryCall( + "hashedBlankStateLeaf", + "hashedBlankStateLeaf():(uint256)", + [] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + initialVoiceCreditProxy(): Address { + let result = super.call( + "initialVoiceCreditProxy", + "initialVoiceCreditProxy():(address)", + [] + ); + + return result[0].toAddress(); + } + + try_initialVoiceCreditProxy(): ethereum.CallResult
{ + let result = super.tryCall( + "initialVoiceCreditProxy", + "initialVoiceCreditProxy():(address)", + [] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toAddress()); + } + + maxMessages(): BigInt { + let result = super.call("maxMessages", "maxMessages():(uint256)", []); + + return result[0].toBigInt(); + } + + try_maxMessages(): ethereum.CallResult { + let result = super.tryCall("maxMessages", "maxMessages():(uint256)", []); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + maxUsers(): BigInt { + let result = super.call("maxUsers", "maxUsers():(uint256)", []); + + return result[0].toBigInt(); + } + + try_maxUsers(): ethereum.CallResult { + let result = super.tryCall("maxUsers", "maxUsers():(uint256)", []); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + messageBatchSize(): i32 { + let result = super.call( + "messageBatchSize", + "messageBatchSize():(uint8)", + [] + ); + + return result[0].toI32(); + } + + try_messageBatchSize(): ethereum.CallResult { + let result = super.tryCall( + "messageBatchSize", + "messageBatchSize():(uint8)", + [] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toI32()); + } + + messageTree(): Address { + let result = super.call("messageTree", "messageTree():(address)", []); + + return result[0].toAddress(); + } + + try_messageTree(): ethereum.CallResult
{ + let result = super.tryCall("messageTree", "messageTree():(address)", []); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toAddress()); + } + + messageTreeMaxLeafIndex(): BigInt { + let result = super.call( + "messageTreeMaxLeafIndex", + "messageTreeMaxLeafIndex():(uint256)", + [] + ); + + return result[0].toBigInt(); + } + + try_messageTreeMaxLeafIndex(): ethereum.CallResult { + let result = super.tryCall( + "messageTreeMaxLeafIndex", + "messageTreeMaxLeafIndex():(uint256)", + [] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + numMessages(): BigInt { + let result = super.call("numMessages", "numMessages():(uint256)", []); + + return result[0].toBigInt(); + } + + try_numMessages(): ethereum.CallResult { + let result = super.tryCall("numMessages", "numMessages():(uint256)", []); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + numSignUps(): BigInt { + let result = super.call("numSignUps", "numSignUps():(uint256)", []); + + return result[0].toBigInt(); + } + + try_numSignUps(): ethereum.CallResult { + let result = super.tryCall("numSignUps", "numSignUps():(uint256)", []); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + originalCurrentResultsCommitment(): BigInt { + let result = super.call( + "originalCurrentResultsCommitment", + "originalCurrentResultsCommitment():(uint256)", + [] + ); + + return result[0].toBigInt(); + } + + try_originalCurrentResultsCommitment(): ethereum.CallResult { + let result = super.tryCall( + "originalCurrentResultsCommitment", + "originalCurrentResultsCommitment():(uint256)", + [] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + originalSpentVoiceCreditsCommitment(): BigInt { + let result = super.call( + "originalSpentVoiceCreditsCommitment", + "originalSpentVoiceCreditsCommitment():(uint256)", + [] + ); + + return result[0].toBigInt(); + } + + try_originalSpentVoiceCreditsCommitment(): ethereum.CallResult { + let result = super.tryCall( + "originalSpentVoiceCreditsCommitment", + "originalSpentVoiceCreditsCommitment():(uint256)", + [] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + signUpDurationSeconds(): BigInt { + let result = super.call( + "signUpDurationSeconds", + "signUpDurationSeconds():(uint256)", + [] + ); + + return result[0].toBigInt(); + } + + try_signUpDurationSeconds(): ethereum.CallResult { + let result = super.tryCall( + "signUpDurationSeconds", + "signUpDurationSeconds():(uint256)", + [] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + signUpGatekeeper(): Address { + let result = super.call( + "signUpGatekeeper", + "signUpGatekeeper():(address)", + [] + ); + + return result[0].toAddress(); + } + + try_signUpGatekeeper(): ethereum.CallResult
{ + let result = super.tryCall( + "signUpGatekeeper", + "signUpGatekeeper():(address)", + [] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toAddress()); + } + + signUpTimestamp(): BigInt { + let result = super.call( + "signUpTimestamp", + "signUpTimestamp():(uint256)", + [] + ); + + return result[0].toBigInt(); + } + + try_signUpTimestamp(): ethereum.CallResult { + let result = super.tryCall( + "signUpTimestamp", + "signUpTimestamp():(uint256)", + [] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + stateRoot(): BigInt { + let result = super.call("stateRoot", "stateRoot():(uint256)", []); + + return result[0].toBigInt(); + } + + try_stateRoot(): ethereum.CallResult { + let result = super.tryCall("stateRoot", "stateRoot():(uint256)", []); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + stateRootBeforeProcessing(): BigInt { + let result = super.call( + "stateRootBeforeProcessing", + "stateRootBeforeProcessing():(uint256)", + [] + ); + + return result[0].toBigInt(); + } + + try_stateRootBeforeProcessing(): ethereum.CallResult { + let result = super.tryCall( + "stateRootBeforeProcessing", + "stateRootBeforeProcessing():(uint256)", + [] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + stateTree(): Address { + let result = super.call("stateTree", "stateTree():(address)", []); + + return result[0].toAddress(); + } + + try_stateTree(): ethereum.CallResult
{ + let result = super.tryCall("stateTree", "stateTree():(address)", []); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toAddress()); + } + + tallyBatchSize(): i32 { + let result = super.call("tallyBatchSize", "tallyBatchSize():(uint8)", []); + + return result[0].toI32(); + } + + try_tallyBatchSize(): ethereum.CallResult { + let result = super.tryCall( + "tallyBatchSize", + "tallyBatchSize():(uint8)", + [] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toI32()); + } + + totalVotes(): BigInt { + let result = super.call("totalVotes", "totalVotes():(uint256)", []); + + return result[0].toBigInt(); + } + + try_totalVotes(): ethereum.CallResult { + let result = super.tryCall("totalVotes", "totalVotes():(uint256)", []); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + treeDepths(): MACI__treeDepthsResult { + let result = super.call( + "treeDepths", + "treeDepths():(uint8,uint8,uint8)", + [] + ); + + return new MACI__treeDepthsResult( + result[0].toI32(), + result[1].toI32(), + result[2].toI32() + ); + } + + try_treeDepths(): ethereum.CallResult { + let result = super.tryCall( + "treeDepths", + "treeDepths():(uint8,uint8,uint8)", + [] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue( + new MACI__treeDepthsResult( + value[0].toI32(), + value[1].toI32(), + value[2].toI32() + ) + ); + } + + verifySpentVoiceCredits(_spent: BigInt, _salt: BigInt): boolean { + let result = super.call( + "verifySpentVoiceCredits", + "verifySpentVoiceCredits(uint256,uint256):(bool)", + [ + ethereum.Value.fromUnsignedBigInt(_spent), + ethereum.Value.fromUnsignedBigInt(_salt) + ] + ); + + return result[0].toBoolean(); + } + + try_verifySpentVoiceCredits( + _spent: BigInt, + _salt: BigInt + ): ethereum.CallResult { + let result = super.tryCall( + "verifySpentVoiceCredits", + "verifySpentVoiceCredits(uint256,uint256):(bool)", + [ + ethereum.Value.fromUnsignedBigInt(_spent), + ethereum.Value.fromUnsignedBigInt(_salt) + ] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBoolean()); + } + + voteOptionsMaxLeafIndex(): BigInt { + let result = super.call( + "voteOptionsMaxLeafIndex", + "voteOptionsMaxLeafIndex():(uint256)", + [] + ); + + return result[0].toBigInt(); + } + + try_voteOptionsMaxLeafIndex(): ethereum.CallResult { + let result = super.tryCall( + "voteOptionsMaxLeafIndex", + "voteOptionsMaxLeafIndex():(uint256)", + [] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } + + votingDurationSeconds(): BigInt { + let result = super.call( + "votingDurationSeconds", + "votingDurationSeconds():(uint256)", + [] + ); + + return result[0].toBigInt(); + } + + try_votingDurationSeconds(): ethereum.CallResult { + let result = super.tryCall( + "votingDurationSeconds", + "votingDurationSeconds():(uint256)", + [] + ); + if (result.reverted) { + return new ethereum.CallResult(); + } + let value = result.value; + return ethereum.CallResult.fromValue(value[0].toBigInt()); + } +} + +export class ConstructorCall extends ethereum.Call { + get inputs(): ConstructorCall__Inputs { + return new ConstructorCall__Inputs(this); + } + + get outputs(): ConstructorCall__Outputs { + return new ConstructorCall__Outputs(this); + } +} + +export class ConstructorCall__Inputs { + _call: ConstructorCall; + + constructor(call: ConstructorCall) { + this._call = call; + } + + get _treeDepths(): ConstructorCall_treeDepthsStruct { + return this._call.inputValues[0].value.toTuple() as ConstructorCall_treeDepthsStruct; + } + + get _batchSizes(): ConstructorCall_batchSizesStruct { + return this._call.inputValues[1].value.toTuple() as ConstructorCall_batchSizesStruct; + } + + get _maxValues(): ConstructorCall_maxValuesStruct { + return this._call.inputValues[2].value.toTuple() as ConstructorCall_maxValuesStruct; + } + + get _signUpGatekeeper(): Address { + return this._call.inputValues[3].value.toAddress(); + } + + get _batchUstVerifier(): Address { + return this._call.inputValues[4].value.toAddress(); + } + + get _qvtVerifier(): Address { + return this._call.inputValues[5].value.toAddress(); + } + + get _signUpDurationSeconds(): BigInt { + return this._call.inputValues[6].value.toBigInt(); + } + + get _votingDurationSeconds(): BigInt { + return this._call.inputValues[7].value.toBigInt(); + } + + get _initialVoiceCreditProxy(): Address { + return this._call.inputValues[8].value.toAddress(); + } + + get _coordinatorPubKey(): ConstructorCall_coordinatorPubKeyStruct { + return this._call.inputValues[9].value.toTuple() as ConstructorCall_coordinatorPubKeyStruct; + } + + get _coordinatorAddress(): Address { + return this._call.inputValues[10].value.toAddress(); + } +} + +export class ConstructorCall__Outputs { + _call: ConstructorCall; + + constructor(call: ConstructorCall) { + this._call = call; + } +} + +export class ConstructorCall_treeDepthsStruct extends ethereum.Tuple { + get stateTreeDepth(): i32 { + return this[0].toI32(); + } + + get messageTreeDepth(): i32 { + return this[1].toI32(); + } + + get voteOptionTreeDepth(): i32 { + return this[2].toI32(); + } +} + +export class ConstructorCall_batchSizesStruct extends ethereum.Tuple { + get tallyBatchSize(): i32 { + return this[0].toI32(); + } + + get messageBatchSize(): i32 { + return this[1].toI32(); + } +} + +export class ConstructorCall_maxValuesStruct extends ethereum.Tuple { + get maxUsers(): BigInt { + return this[0].toBigInt(); + } + + get maxMessages(): BigInt { + return this[1].toBigInt(); + } + + get maxVoteOptions(): BigInt { + return this[2].toBigInt(); + } +} + +export class ConstructorCall_coordinatorPubKeyStruct extends ethereum.Tuple { + get x(): BigInt { + return this[0].toBigInt(); + } + + get y(): BigInt { + return this[1].toBigInt(); + } +} + +export class BatchProcessMessageCall extends ethereum.Call { + get inputs(): BatchProcessMessageCall__Inputs { + return new BatchProcessMessageCall__Inputs(this); + } + + get outputs(): BatchProcessMessageCall__Outputs { + return new BatchProcessMessageCall__Outputs(this); + } +} + +export class BatchProcessMessageCall__Inputs { + _call: BatchProcessMessageCall; + + constructor(call: BatchProcessMessageCall) { + this._call = call; + } + + get _newStateRoot(): BigInt { + return this._call.inputValues[0].value.toBigInt(); + } + + get _ecdhPubKeys(): Array { + return this._call.inputValues[1].value.toTupleArray< + BatchProcessMessageCall_ecdhPubKeysStruct + >(); + } + + get _proof(): Array { + return this._call.inputValues[2].value.toBigIntArray(); + } +} + +export class BatchProcessMessageCall__Outputs { + _call: BatchProcessMessageCall; + + constructor(call: BatchProcessMessageCall) { + this._call = call; + } +} + +export class BatchProcessMessageCall_ecdhPubKeysStruct extends ethereum.Tuple { + get x(): BigInt { + return this[0].toBigInt(); + } + + get y(): BigInt { + return this[1].toBigInt(); + } +} + +export class CoordinatorResetCall extends ethereum.Call { + get inputs(): CoordinatorResetCall__Inputs { + return new CoordinatorResetCall__Inputs(this); + } + + get outputs(): CoordinatorResetCall__Outputs { + return new CoordinatorResetCall__Outputs(this); + } +} + +export class CoordinatorResetCall__Inputs { + _call: CoordinatorResetCall; + + constructor(call: CoordinatorResetCall) { + this._call = call; + } +} + +export class CoordinatorResetCall__Outputs { + _call: CoordinatorResetCall; + + constructor(call: CoordinatorResetCall) { + this._call = call; + } +} + +export class ProveVoteTallyBatchCall extends ethereum.Call { + get inputs(): ProveVoteTallyBatchCall__Inputs { + return new ProveVoteTallyBatchCall__Inputs(this); + } + + get outputs(): ProveVoteTallyBatchCall__Outputs { + return new ProveVoteTallyBatchCall__Outputs(this); + } +} + +export class ProveVoteTallyBatchCall__Inputs { + _call: ProveVoteTallyBatchCall; + + constructor(call: ProveVoteTallyBatchCall) { + this._call = call; + } + + get _intermediateStateRoot(): BigInt { + return this._call.inputValues[0].value.toBigInt(); + } + + get _newResultsCommitment(): BigInt { + return this._call.inputValues[1].value.toBigInt(); + } + + get _newSpentVoiceCreditsCommitment(): BigInt { + return this._call.inputValues[2].value.toBigInt(); + } + + get _newPerVOSpentVoiceCreditsCommitment(): BigInt { + return this._call.inputValues[3].value.toBigInt(); + } + + get _totalVotes(): BigInt { + return this._call.inputValues[4].value.toBigInt(); + } + + get _proof(): Array { + return this._call.inputValues[5].value.toBigIntArray(); + } +} + +export class ProveVoteTallyBatchCall__Outputs { + _call: ProveVoteTallyBatchCall; + + constructor(call: ProveVoteTallyBatchCall) { + this._call = call; + } +} + +export class PublishMessageCall extends ethereum.Call { + get inputs(): PublishMessageCall__Inputs { + return new PublishMessageCall__Inputs(this); + } + + get outputs(): PublishMessageCall__Outputs { + return new PublishMessageCall__Outputs(this); + } +} + +export class PublishMessageCall__Inputs { + _call: PublishMessageCall; + + constructor(call: PublishMessageCall) { + this._call = call; + } + + get _message(): PublishMessageCall_messageStruct { + return this._call.inputValues[0].value.toTuple() as PublishMessageCall_messageStruct; + } + + get _encPubKey(): PublishMessageCall_encPubKeyStruct { + return this._call.inputValues[1].value.toTuple() as PublishMessageCall_encPubKeyStruct; + } +} + +export class PublishMessageCall__Outputs { + _call: PublishMessageCall; + + constructor(call: PublishMessageCall) { + this._call = call; + } +} + +export class PublishMessageCall_messageStruct extends ethereum.Tuple { + get iv(): BigInt { + return this[0].toBigInt(); + } + + get data(): Array { + return this[1].toBigIntArray(); + } +} + +export class PublishMessageCall_encPubKeyStruct extends ethereum.Tuple { + get x(): BigInt { + return this[0].toBigInt(); + } + + get y(): BigInt { + return this[1].toBigInt(); + } +} + +export class SignUpCall extends ethereum.Call { + get inputs(): SignUpCall__Inputs { + return new SignUpCall__Inputs(this); + } + + get outputs(): SignUpCall__Outputs { + return new SignUpCall__Outputs(this); + } +} + +export class SignUpCall__Inputs { + _call: SignUpCall; + + constructor(call: SignUpCall) { + this._call = call; + } + + get _userPubKey(): SignUpCall_userPubKeyStruct { + return this._call.inputValues[0].value.toTuple() as SignUpCall_userPubKeyStruct; + } + + get _signUpGatekeeperData(): Bytes { + return this._call.inputValues[1].value.toBytes(); + } + + get _initialVoiceCreditProxyData(): Bytes { + return this._call.inputValues[2].value.toBytes(); + } +} + +export class SignUpCall__Outputs { + _call: SignUpCall; + + constructor(call: SignUpCall) { + this._call = call; + } +} + +export class SignUpCall_userPubKeyStruct extends ethereum.Tuple { + get x(): BigInt { + return this[0].toBigInt(); + } + + get y(): BigInt { + return this[1].toBigInt(); + } +} diff --git a/subgraph/schema.graphql b/subgraph/schema.graphql index c0581d573..e4597adae 100644 --- a/subgraph/schema.graphql +++ b/subgraph/schema.graphql @@ -31,9 +31,28 @@ type FundingRoundFactory @entity { lastUpdatedAt: String } +type Message @entity { + id: ID! + data: [BigInt!] + iv: BigInt! + publicKey: PublicKey + fundingRound: FundingRound + timestamp: String +} + +type PublicKey @entity { + id: ID! + fundingRound: FundingRound + messages: [Message!] @derivedFrom(field: "publicKey") + x: BigInt! + y: BigInt! +} + type FundingRound @entity { id: ID! fundingRoundFactory: FundingRoundFactory + maci: Bytes + messages: [Message!] @derivedFrom(field: "fundingRound") recipientRegistry: RecipientRegistry recipientRegistryAddress: Bytes contributorRegistry: ContributorRegistry @@ -44,7 +63,7 @@ type FundingRound @entity { votingDeadline: BigInt coordinator: Bytes - maci: Bytes + voiceCreditFactor: BigInt contributorCount: BigInt! recipientCount: BigInt! @@ -174,3 +193,4 @@ type Token @entity { createdAt: String lastUpdatedAt: String } + diff --git a/subgraph/src/FundingRoundFactoryMapping.ts b/subgraph/src/FundingRoundFactoryMapping.ts index 1c83ead45..21dbe152a 100644 --- a/subgraph/src/FundingRoundFactoryMapping.ts +++ b/subgraph/src/FundingRoundFactoryMapping.ts @@ -18,6 +18,7 @@ import { OptimisticRecipientRegistry as RecipientRegistryContract } from '../gen import { FundingRound as FundingRoundTemplate, OptimisticRecipientRegistry as recipientRegistryTemplate, + MACI as MACITemplate, } from '../generated/templates' import { FundingRoundFactory, @@ -95,6 +96,8 @@ export function handleRoundStarted(event: RoundStarted): void { let contributorCount = fundingRoundContract.contributorCount() let matchingPoolSize = fundingRoundContract.matchingPoolSize() + MACITemplate.create(maci) + fundingRound.fundingRoundFactory = fundingRoundFactoryId fundingRound.nativeToken = nativeToken fundingRound.coordinator = coordinator diff --git a/subgraph/src/MACIMapping.ts b/subgraph/src/MACIMapping.ts new file mode 100644 index 000000000..6426c1cf9 --- /dev/null +++ b/subgraph/src/MACIMapping.ts @@ -0,0 +1,84 @@ +import { log } from '@graphprotocol/graph-ts' +import { PublishMessage, SignUp } from '../generated/templates/MACI/MACI' + +import { FundingRound, Message, PublicKey } from '../generated/schema' + +// It is also possible to access smart contracts from mappings. For +// example, the contract that has emitted the event can be connected to +// with: +// +// let contract = Contract.bind(event.address) +// +// The following functions can then be called on this contract to access +// state variables and other data: +// +// - contract.context(...) +// - contract.isOwner(...) +// - contract.isVerifiedUser(...) +// - contract.owner(...) +// - contract.verifications(...) +// - contract.verifier(...) + +export function handlePublishMessage(event: PublishMessage): void { + const fundingRoundId = event.transaction.to.toHexString() + if (fundingRoundId == null) { + log.error( + 'Error: handlePublishMessage failed fundingRound not registered', + [] + ) + return + } + const fundingRound = FundingRound.load(fundingRoundId) + if (fundingRound == null) { + log.error( + 'Error: handlePublishMessage failed fundingRound not registered', + [] + ) + return + } + + const messageID = event.transaction.hash.toHexString() + + const timestamp = event.block.timestamp.toString() + const message = new Message(messageID) + message.data = event.params._message.data + message.iv = event.params._message.iv + + const publicKeyId = event.transaction.from.toHexString() + const publicKey = PublicKey.load(publicKeyId) + + //NOTE: If the public keys aren't being tracked initialize them + if (publicKey == null) { + const publicKey = new PublicKey(publicKeyId) + publicKey.x = event.params._encPubKey.x + publicKey.y = event.params._encPubKey.y + + const _messages = [messageID] as string[] + publicKey.messages = _messages + publicKey.fundingRound = fundingRoundId + + publicKey.save() + } + + message.publicKey = publicKeyId as string + message.timestamp = timestamp + message.fundingRound = fundingRoundId + message.save() + log.info('handlePublishMessage', []) +} + +export function handleSignUp(event: SignUp): void { + const publicKeyId = event.transaction.from.toHexString() + const publicKey = PublicKey.load(publicKeyId) + + //NOTE: If the public keys aren't being tracked initialize them + if (publicKey == null) { + const publicKey = new PublicKey(publicKeyId) + publicKey.x = event.params._userPubKey.x + publicKey.y = event.params._userPubKey.y + + publicKey.save() + } + + log.info('SignUp', []) +} diff --git a/subgraph/subgraph.yaml b/subgraph/subgraph.yaml index 6e938b5dd..6072a6e6d 100644 --- a/subgraph/subgraph.yaml +++ b/subgraph/subgraph.yaml @@ -20,6 +20,7 @@ dataSources: - RecipientRegistry - ContributorRegistry - FundingRound + - MACI abis: - name: FundingRoundFactory file: ./abis/FundingRoundFactory.json @@ -31,6 +32,8 @@ dataSources: file: ./abis/OptimisticRecipientRegistry.json - name: BrightIdUserRegistry file: ./abis/BrightIdUserRegistry.json + - name: MACI + file: ./abis/MACI.json eventHandlers: - event: CoordinatorChanged(address) handler: handleCoordinatorChanged @@ -52,7 +55,7 @@ dataSources: network: xdai source: abi: OptimisticRecipientRegistry - startBlock: 0 + startBlock: 15217676 mapping: kind: ethereum/events apiVersion: 0.0.4 @@ -154,3 +157,26 @@ templates: - event: Sponsor(indexed address) handler: handleSponsor file: ./src/BrightIdUserRegistryMapping.ts + - name: MACI + kind: ethereum/contract + network: xdai + source: + abi: MACI + mapping: + kind: ethereum/events + apiVersion: 0.0.4 + language: wasm/assemblyscript + entities: + - MACI + - FundingRound + abis: + - name: MACI + file: ./abis/MACI.json + - name: FundingRound + file: ./abis/FundingRound.json + eventHandlers: + - event: PublishMessage((uint256,uint256[10]),(uint256,uint256)) + handler: handlePublishMessage + - event: SignUp((uint256,uint256),uint256,uint256) + handler: handleSignUp + file: ./src/MACIMapping.ts \ No newline at end of file From 994c59033d48c7e01b20bf6b2542852ff046af14 Mon Sep 17 00:00:00 2001 From: daodesigner Date: Wed, 29 Sep 2021 01:09:17 -0400 Subject: [PATCH 3/3] track the initial voice credit balance as well --- subgraph/generated/schema.ts | 52 +++++++++++++++++++++--------------- subgraph/schema.graphql | 2 ++ subgraph/src/MACIMapping.ts | 3 +++ 3 files changed, 36 insertions(+), 21 deletions(-) diff --git a/subgraph/generated/schema.ts b/subgraph/generated/schema.ts index 94e244bec..a868e9c45 100644 --- a/subgraph/generated/schema.ts +++ b/subgraph/generated/schema.ts @@ -515,21 +515,13 @@ export class Message extends Entity { } } - get iv(): BigInt | null { + get iv(): BigInt { let value = this.get("iv"); - if (value === null || value.kind == ValueKind.NULL) { - return null; - } else { - return value.toBigInt(); - } + return value.toBigInt(); } - set iv(value: BigInt | null) { - if (value === null) { - this.unset("iv"); - } else { - this.set("iv", Value.fromBigInt(value as BigInt)); - } + set iv(value: BigInt) { + this.set("iv", Value.fromBigInt(value)); } get publicKey(): string | null { @@ -648,8 +640,26 @@ export class PublicKey extends Entity { } } - get x(): BigInt | null { + get x(): BigInt { let value = this.get("x"); + return value.toBigInt(); + } + + set x(value: BigInt) { + this.set("x", Value.fromBigInt(value)); + } + + get y(): BigInt { + let value = this.get("y"); + return value.toBigInt(); + } + + set y(value: BigInt) { + this.set("y", Value.fromBigInt(value)); + } + + get stateIndex(): BigInt | null { + let value = this.get("stateIndex"); if (value === null || value.kind == ValueKind.NULL) { return null; } else { @@ -657,16 +667,16 @@ export class PublicKey extends Entity { } } - set x(value: BigInt | null) { + set stateIndex(value: BigInt | null) { if (value === null) { - this.unset("x"); + this.unset("stateIndex"); } else { - this.set("x", Value.fromBigInt(value as BigInt)); + this.set("stateIndex", Value.fromBigInt(value as BigInt)); } } - get y(): BigInt | null { - let value = this.get("y"); + get voiceCreditBalance(): BigInt | null { + let value = this.get("voiceCreditBalance"); if (value === null || value.kind == ValueKind.NULL) { return null; } else { @@ -674,11 +684,11 @@ export class PublicKey extends Entity { } } - set y(value: BigInt | null) { + set voiceCreditBalance(value: BigInt | null) { if (value === null) { - this.unset("y"); + this.unset("voiceCreditBalance"); } else { - this.set("y", Value.fromBigInt(value as BigInt)); + this.set("voiceCreditBalance", Value.fromBigInt(value as BigInt)); } } } diff --git a/subgraph/schema.graphql b/subgraph/schema.graphql index e4597adae..c87363f76 100644 --- a/subgraph/schema.graphql +++ b/subgraph/schema.graphql @@ -46,6 +46,8 @@ type PublicKey @entity { messages: [Message!] @derivedFrom(field: "publicKey") x: BigInt! y: BigInt! + stateIndex: BigInt + voiceCreditBalance: BigInt } type FundingRound @entity { diff --git a/subgraph/src/MACIMapping.ts b/subgraph/src/MACIMapping.ts index 6426c1cf9..fa76a8ef3 100644 --- a/subgraph/src/MACIMapping.ts +++ b/subgraph/src/MACIMapping.ts @@ -76,6 +76,9 @@ export function handleSignUp(event: SignUp): void { const publicKey = new PublicKey(publicKeyId) publicKey.x = event.params._userPubKey.x publicKey.y = event.params._userPubKey.y + publicKey.stateIndex = event.params._stateIndex + + publicKey.voiceCreditBalance = event.params._voiceCreditBalance publicKey.save() }