diff --git a/contracts/contracts/recipientRegistry/UniversalRecipientRegistry.sol b/contracts/contracts/recipientRegistry/UniversalRecipientRegistry.sol deleted file mode 100644 index a87ca27c7..000000000 --- a/contracts/contracts/recipientRegistry/UniversalRecipientRegistry.sol +++ /dev/null @@ -1,204 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0 - -pragma solidity 0.6.12; - -import '@openzeppelin/contracts/access/Ownable.sol'; - -import './BaseRecipientRegistry.sol'; - -/** - * @dev Optimistic Recipient registry with recipient metadata stored externally, potentially in a different network. - */ -contract UniversalRecipientRegistry is Ownable, BaseRecipientRegistry { - - // Enums - enum RequestType { - Registration, - Removal - } - - // Structs - struct Request { - RequestType requestType; - address payable requester; - uint256 submissionTime; - uint256 deposit; - address recipientAddress; // Only for registration requests - } - - // constant - string public registryType = 'universal'; - - // State - uint256 public baseDeposit; - uint256 public challengePeriodDuration; - mapping(bytes32 => Request) private requests; - - // Events - event RequestSubmitted( - bytes32 indexed _recipientId, - RequestType indexed _type, - address _recipient, - uint256 _timestamp - ); - event RequestResolved( - bytes32 indexed _recipientId, - RequestType indexed _type, - bool indexed _rejected, - uint256 _recipientIndex, // Only for accepted registration requests - uint256 _timestamp - ); - - /** - * @dev Deploy the registry. - * @param _baseDeposit Deposit required to add or remove item. - * @param _challengePeriodDuration The time owner has to challenge a request (seconds). - * @param _controller Controller address. Normally it's a funding round factory contract. - */ - constructor( - uint256 _baseDeposit, - uint256 _challengePeriodDuration, - address _controller - ) - public - { - baseDeposit = _baseDeposit; - challengePeriodDuration = _challengePeriodDuration; - controller = _controller; - } - - /** - * @dev Change base deposit. - */ - function setBaseDeposit(uint256 _baseDeposit) - external - onlyOwner - { - baseDeposit = _baseDeposit; - } - - /** - * @dev Change challenge period duration. - */ - function setChallengePeriodDuration(uint256 _challengePeriodDuration) - external - onlyOwner - { - challengePeriodDuration = _challengePeriodDuration; - } - - /** - * @dev Submit recipient registration request. - * @param _recipient The address that receives funds. - * @param _metadataId The id of the recipient metadata that is stored externally - * which is used as the recipient id in this registry - */ - function addRecipient(address _recipient, bytes32 _metadataId) - external - payable - { - require(_recipient != address(0), 'RecipientRegistry: Recipient address is zero'); - require(recipients[_metadataId].index == 0, 'RecipientRegistry: Recipient already registered'); - require(requests[_metadataId].submissionTime == 0, 'RecipientRegistry: Request already submitted'); - require(msg.value == baseDeposit, 'RecipientRegistry: Incorrect deposit amount'); - requests[_metadataId] = Request( - RequestType.Registration, - msg.sender, - block.timestamp, - msg.value, - _recipient - ); - emit RequestSubmitted( - _metadataId, - RequestType.Registration, - _recipient, - block.timestamp - ); - } - - /** - * @dev Submit recipient removal request. - * @param _recipientId The ID of recipient. - */ - function removeRecipient(bytes32 _recipientId) - external - payable - { - require(recipients[_recipientId].index != 0, 'RecipientRegistry: Recipient is not in the registry'); - require(recipients[_recipientId].removedAt == 0, 'RecipientRegistry: Recipient already removed'); - require(requests[_recipientId].submissionTime == 0, 'RecipientRegistry: Request already submitted'); - require(msg.value == baseDeposit, 'RecipientRegistry: Incorrect deposit amount'); - requests[_recipientId] = Request( - RequestType.Removal, - msg.sender, - block.timestamp, - msg.value, - address(0) - ); - emit RequestSubmitted( - _recipientId, - RequestType.Removal, - address(0), - block.timestamp - ); - } - - /** - * @dev Reject request. - * @param _recipientId The ID of recipient. - * @param _beneficiary Address to which the deposit should be transferred. - */ - function challengeRequest(bytes32 _recipientId, address payable _beneficiary) - external - onlyOwner - returns (bool) - { - Request memory request = requests[_recipientId]; - require(request.submissionTime != 0, 'RecipientRegistry: Request does not exist'); - delete requests[_recipientId]; - bool isSent = _beneficiary.send(request.deposit); - emit RequestResolved( - _recipientId, - request.requestType, - true, - 0, - block.timestamp - ); - return isSent; - } - - /** - * @dev Execute request. - * @param _recipientId The ID of recipient. - */ - function executeRequest(bytes32 _recipientId) - external - returns (bool) - { - Request memory request = requests[_recipientId]; - require(request.submissionTime != 0, 'RecipientRegistry: Request does not exist'); - if (msg.sender != owner()) { - require( - block.timestamp - request.submissionTime >= challengePeriodDuration, - 'RecipientRegistry: Challenge period is not over' - ); - } - uint256 recipientIndex = 0; - if (request.requestType == RequestType.Removal) { - _removeRecipient(_recipientId); - } else { - // WARNING: Could revert if no slots are available or if recipient limit is not set - recipientIndex = _addRecipient(_recipientId, request.recipientAddress); - } - delete requests[_recipientId]; - bool isSent = request.requester.send(request.deposit); - emit RequestResolved( - _recipientId, - request.requestType, - false, - recipientIndex, - block.timestamp - ); - return isSent; - } -} diff --git a/contracts/scripts/deployRecipientRegistry.ts b/contracts/scripts/deployRecipientRegistry.ts index 233a480b8..582bdbaf2 100644 --- a/contracts/scripts/deployRecipientRegistry.ts +++ b/contracts/scripts/deployRecipientRegistry.ts @@ -6,7 +6,7 @@ import { RecipientRegistryFactory } from '../utils/recipient-registry-factory' * Deploy a new recipient registry. * The following environment variables must be set to run the script * - * RECIPIENT_REGISTRY_TYPE - default is simple, values can be simple, optimistic, universal + * RECIPIENT_REGISTRY_TYPE - default is simple, values can be simple, optimistic * FUNDING_ROUND_FACTORY_ADDRESS - address of the funding round factory * WALLET_PRIVATE_KEY - private key of the account that will fund this transaction * JSONRPC_HTTP_URL - URL to connect to the node @@ -19,8 +19,13 @@ import { RecipientRegistryFactory } from '../utils/recipient-registry-factory' async function main() { const recipientRegistryType = process.env.RECIPIENT_REGISTRY_TYPE || 'simple' const fundingRoundFactoryAddress = process.env.FUNDING_ROUND_FACTORY_ADDRESS - const challengePeriodDuration = process.env.CHALLENGE_PERIOD_IN_SECONDS || 300 - const baseDeposit = process.env.BASE_DEPOSIT || UNIT.div(10).toString() + let challengePeriodDuration = '0' + let baseDeposit = '0' + + if (recipientRegistryType === 'optimistic') { + challengePeriodDuration = process.env.CHALLENGE_PERIOD_IN_SECONDS || '300' + baseDeposit = process.env.BASE_DEPOSIT || UNIT.div(10).toString() + } if (!fundingRoundFactoryAddress) { console.log('Environment variable FUNDING_ROUND_FACTORY_ADDRESS not set') @@ -35,9 +40,9 @@ async function main() { console.log('*******************') console.log(`Deploying a new ${recipientRegistryType} recipient registry!`) console.log(` challenge period in seconds: ${challengePeriodDuration}`) - console.log(` baseDeposit ${baseDeposit}`) - console.log(` fundingRoundFactoryAddress ${fundingRoundFactoryAddress}`) - console.log(` fundingRoundFactoryOwner ${factoryOwner}`) + console.log(` baseDeposit: ${baseDeposit}`) + console.log(` fundingRoundFactoryAddress: ${fundingRoundFactoryAddress}`) + console.log(` fundingRoundFactoryOwner: ${factoryOwner}`) const [deployer] = await ethers.getSigners() const recipientRegistry = await RecipientRegistryFactory.deploy( diff --git a/contracts/scripts/deployTestRound.ts b/contracts/scripts/deployTestRound.ts index 715674d6b..1c724611d 100644 --- a/contracts/scripts/deployTestRound.ts +++ b/contracts/scripts/deployTestRound.ts @@ -113,7 +113,6 @@ async function main() { const RecipientRegistryName: Record = { simple: 'SimpleRecipientRegistry', optimistic: 'OptimisticRecipientRegistry', - universal: 'UniversalRecipientRegistry', } const recipientRegistryAddress = await factory.recipientRegistry() const recipientRegistryName = RecipientRegistryName[recipientRegistryType] diff --git a/contracts/tests/recipientRegistryUniversal.ts b/contracts/tests/recipientRegistryUniversal.ts deleted file mode 100644 index 05ab669da..000000000 --- a/contracts/tests/recipientRegistryUniversal.ts +++ /dev/null @@ -1,436 +0,0 @@ -import { ethers, waffle } from 'hardhat' -import { use, expect } from 'chai' -import { solidity } from 'ethereum-waffle' -import { BigNumber, Contract, utils } from 'ethers' - -import { UNIT, ZERO_ADDRESS } from '../utils/constants' -import { getTxFee } from '../utils/contracts' -import { deployContract } from '../utils/deployment' - -use(solidity) - -const { provider } = waffle - -const MAX_RECIPIENTS = 16 - -async function getCurrentTime(): Promise { - return (await provider.getBlock('latest')).timestamp -} - -describe('Universal recipient registry', () => { - const [, deployer, controller, recipient, requester] = provider.getWallets() - let registry: Contract - - const baseDeposit = UNIT.div(10) // 0.1 ETH - const challengePeriodDuration = BigNumber.from(86400) // Seconds - - enum RequestType { - Registration = 0, - Removal = 1, - } - - beforeEach(async () => { - registry = await deployContract(deployer, 'UniversalRecipientRegistry', [ - baseDeposit, - challengePeriodDuration, - controller.address, - ]) - }) - - it('initializes correctly', async () => { - expect(await registry.baseDeposit()).to.equal(baseDeposit) - expect(await registry.challengePeriodDuration()).to.equal( - challengePeriodDuration - ) - expect(await registry.controller()).to.equal(controller.address) - expect(await registry.maxRecipients()).to.equal(0) - }) - - it('changes base deposit', async () => { - const newBaseDeposit = baseDeposit.mul(2) - await registry.setBaseDeposit(newBaseDeposit) - expect(await registry.baseDeposit()).to.equal(newBaseDeposit) - }) - - it('changes challenge period duration', async () => { - const newChallengePeriodDuration = challengePeriodDuration.mul(2) - await registry.setChallengePeriodDuration(newChallengePeriodDuration) - expect(await registry.challengePeriodDuration()).to.equal( - newChallengePeriodDuration - ) - }) - - describe('managing recipients', () => { - const recipientIndex = 1 - let recipientAddress: string - let metadata: string - let recipientId: string - - function getRecipientId(address: string, metadata: string): string { - return utils.id(`${address}${metadata}`) - } - - beforeEach(async () => { - await registry.connect(controller).setMaxRecipients(MAX_RECIPIENTS) - recipientAddress = recipient.address - metadata = JSON.stringify({ - name: 'Recipient', - description: 'Description', - imageHash: 'Ipfs imageHash', - }) - recipientId = getRecipientId(recipientAddress, metadata) - }) - - it('allows anyone to submit registration request', async () => { - const requestSubmitted = await registry - .connect(requester) - .addRecipient(recipientAddress, recipientId, { value: baseDeposit }) - const currentTime = await getCurrentTime() - expect(requestSubmitted) - .to.emit(registry, 'RequestSubmitted') - .withArgs( - recipientId, - RequestType.Registration, - recipientAddress, - currentTime - ) - expect(await provider.getBalance(registry.address)).to.equal(baseDeposit) - }) - - it('should not accept zero-address as recipient address', async () => { - recipientAddress = ZERO_ADDRESS - await expect( - registry.addRecipient(recipientAddress, recipientId, { - value: baseDeposit, - }) - ).to.be.revertedWith('RecipientRegistry: Recipient address is zero') - }) - - it('should not accept registration request if recipient is already registered', async () => { - await registry.addRecipient(recipientAddress, recipientId, { - value: baseDeposit, - }) - await provider.send('evm_increaseTime', [86400]) - await registry.executeRequest(recipientId) - await expect( - registry.addRecipient(recipientAddress, recipientId, { - value: baseDeposit, - }) - ).to.be.revertedWith('RecipientRegistry: Recipient already registered') - }) - - it('should not accept new registration request if previous request is not resolved', async () => { - await registry.addRecipient(recipientAddress, recipientId, { - value: baseDeposit, - }) - await expect( - registry.addRecipient(recipientAddress, recipientId, { - value: baseDeposit, - }) - ).to.be.revertedWith('RecipientRegistry: Request already submitted') - }) - - it('should not accept registration request with incorrect deposit size', async () => { - await expect( - registry.addRecipient(recipientAddress, recipientId, { - value: baseDeposit.div(2), - }) - ).to.be.revertedWith('RecipientRegistry: Incorrect deposit amount') - }) - - it('allows owner to challenge registration request', async () => { - await registry - .connect(requester) - .addRecipient(recipientAddress, recipientId, { value: baseDeposit }) - const requesterBalanceBefore = await provider.getBalance( - requester.address - ) - const requestRejected = await registry.challengeRequest( - recipientId, - requester.address - ) - const currentTime = await getCurrentTime() - expect(requestRejected) - .to.emit(registry, 'RequestResolved') - .withArgs(recipientId, RequestType.Registration, true, 0, currentTime) - const requesterBalanceAfter = await provider.getBalance(requester.address) - expect(requesterBalanceBefore.add(baseDeposit)).to.equal( - requesterBalanceAfter - ) - }) - - it('allows owner to set beneficiary address when challenging request', async () => { - await registry.addRecipient(recipientAddress, recipientId, { - value: baseDeposit, - }) - const controllerBalanceBefore = await provider.getBalance( - controller.address - ) - await registry.challengeRequest(recipientId, controller.address) - const controllerBalanceAfter = await provider.getBalance( - controller.address - ) - expect(controllerBalanceBefore.add(baseDeposit)).to.equal( - controllerBalanceAfter - ) - }) - - it('allows only owner to challenge requests', async () => { - await registry - .connect(requester) - .addRecipient(recipientAddress, recipientId, { value: baseDeposit }) - await expect( - registry - .connect(requester) - .challengeRequest(recipientId, requester.address) - ).to.be.revertedWith('Ownable: caller is not the owner') - }) - - it('should not allow to challenge resolved request', async () => { - await registry - .connect(requester) - .addRecipient(recipientAddress, recipientId, { value: baseDeposit }) - await registry.challengeRequest(recipientId, requester.address) - await expect( - registry.challengeRequest(recipientId, requester.address) - ).to.be.revertedWith('RecipientRegistry: Request does not exist') - }) - - it('allows anyone to execute unchallenged registration request', async () => { - await registry - .connect(requester) - .addRecipient(recipientAddress, recipientId, { value: baseDeposit }) - await provider.send('evm_increaseTime', [86400]) - - const requesterBalanceBefore = await provider.getBalance( - requester.address - ) - const requestExecuted = await registry - .connect(requester) - .executeRequest(recipientId) - const currentTime = await getCurrentTime() - expect(requestExecuted) - .to.emit(registry, 'RequestResolved') - .withArgs( - recipientId, - RequestType.Registration, - false, - recipientIndex, - currentTime - ) - const txFee = await getTxFee(requestExecuted) - const requesterBalanceAfter = await provider.getBalance(requester.address) - expect(requesterBalanceBefore.sub(txFee).add(baseDeposit)).to.equal( - requesterBalanceAfter - ) - - expect( - await registry.getRecipientAddress( - recipientIndex, - currentTime, - currentTime - ) - ).to.equal(recipientAddress) - }) - - it('should not allow to execute request that does not exist', async () => { - await expect(registry.executeRequest(recipientId)).to.be.revertedWith( - 'RecipientRegistry: Request does not exist' - ) - }) - - it('should not allow non-owner to execute request during challenge period', async () => { - await registry.addRecipient(recipientAddress, recipientId, { - value: baseDeposit, - }) - - await expect( - registry.connect(requester).executeRequest(recipientId) - ).to.be.revertedWith('RecipientRegistry: Challenge period is not over') - }) - - it('should allow owner to execute request during challenge period', async () => { - await registry.addRecipient(recipientAddress, recipientId, { - value: baseDeposit, - }) - - let recipientCount = await registry.getRecipientCount() - expect(recipientCount.toNumber()).to.equal(0) - - await registry.executeRequest(recipientId) - - recipientCount = await registry.getRecipientCount() - expect(recipientCount.toNumber()).to.equal(1) - }) - - it('should remember initial deposit amount during registration', async () => { - await registry - .connect(requester) - .addRecipient(recipientAddress, recipientId, { value: baseDeposit }) - await registry.setBaseDeposit(baseDeposit.mul(2)) - await provider.send('evm_increaseTime', [86400]) - - const requesterBalanceBefore = await provider.getBalance( - requester.address - ) - const requestExecuted = await registry - .connect(requester) - .executeRequest(recipientId) - const txFee = await getTxFee(requestExecuted) - const requesterBalanceAfter = await provider.getBalance(requester.address) - expect(requesterBalanceBefore.sub(txFee).add(baseDeposit)).to.equal( - requesterBalanceAfter - ) - }) - - it('should limit the number of recipients', async () => { - let recipientName - for (let i = 0; i < MAX_RECIPIENTS + 1; i++) { - recipientName = String(i + 1).padStart(4, '0') - metadata = JSON.stringify({ - name: recipientName, - description: 'Description', - imageHash: 'Ipfs imageHash', - }) - recipientAddress = `0x000000000000000000000000000000000000${recipientName}` - recipientId = getRecipientId(recipientAddress, metadata) - if (i < MAX_RECIPIENTS) { - await registry.addRecipient(recipientAddress, recipientId, { - value: baseDeposit, - }) - await provider.send('evm_increaseTime', [86400]) - await registry.executeRequest(recipientId) - } else { - await registry.addRecipient(recipientAddress, recipientId, { - value: baseDeposit, - }) - await provider.send('evm_increaseTime', [86400]) - await expect(registry.executeRequest(recipientId)).to.be.revertedWith( - 'RecipientRegistry: Recipient limit reached' - ) - } - } - }) - - it('allows owner to submit removal request', async () => { - await registry.addRecipient(recipientAddress, recipientId, { - value: baseDeposit, - }) - await provider.send('evm_increaseTime', [86400]) - await registry.executeRequest(recipientId) - - const requestSubmitted = await registry.removeRecipient(recipientId, { - value: baseDeposit, - }) - const currentTime = await getCurrentTime() - expect(requestSubmitted) - .to.emit(registry, 'RequestSubmitted') - .withArgs(recipientId, RequestType.Removal, ZERO_ADDRESS, currentTime) - }) - - it('allows only owner to execute removal request during challenge period', async () => { - await registry.addRecipient(recipientAddress, recipientId, { - value: baseDeposit, - }) - await registry.executeRequest(recipientId) - - const registryAsRequester = registry.connect(requester) - await registryAsRequester.removeRecipient(recipientId, { - value: baseDeposit, - }) - - await expect( - registryAsRequester.executeRequest(recipientId) - ).to.be.revertedWith('RecipientRegistry: Challenge period is not over') - }) - - it('should not accept removal request if recipient is not in registry', async () => { - await expect(registry.removeRecipient(recipientId)).to.be.revertedWith( - 'RecipientRegistry: Recipient is not in the registry' - ) - }) - - it('should not accept removal request if recipient is already removed', async () => { - await registry.addRecipient(recipientAddress, recipientId, { - value: baseDeposit, - }) - await provider.send('evm_increaseTime', [86400]) - await registry.executeRequest(recipientId) - - await registry.removeRecipient(recipientId, { value: baseDeposit }) - await provider.send('evm_increaseTime', [86400]) - await registry.connect(requester).executeRequest(recipientId) - - await expect(registry.removeRecipient(recipientId)).to.be.revertedWith( - 'RecipientRegistry: Recipient already removed' - ) - }) - - it('should not accept new removal request if previous removal request is not resolved', async () => { - await registry.addRecipient(recipientAddress, recipientId, { - value: baseDeposit, - }) - await provider.send('evm_increaseTime', [86400]) - await registry.executeRequest(recipientId) - - await registry.removeRecipient(recipientId, { value: baseDeposit }) - await expect(registry.removeRecipient(recipientId)).to.be.revertedWith( - 'RecipientRegistry: Request already submitted' - ) - }) - - it('allows owner to challenge removal request', async () => { - await registry.addRecipient(recipientAddress, recipientId, { - value: baseDeposit, - }) - await provider.send('evm_increaseTime', [86400]) - await registry.executeRequest(recipientId) - - await registry.removeRecipient(recipientId, { value: baseDeposit }) - const requestRejected = await registry.challengeRequest( - recipientId, - requester.address - ) - const currentTime = await getCurrentTime() - expect(requestRejected) - .to.emit(registry, 'RequestResolved') - .withArgs(recipientId, RequestType.Removal, true, 0, currentTime) - - // Recipient is not removed - expect( - await registry.getRecipientAddress( - recipientIndex, - currentTime, - currentTime - ) - ).to.equal(recipientAddress) - }) - - it('allows anyone to execute unchallenged removal request', async () => { - await registry.addRecipient(recipientAddress, recipientId, { - value: baseDeposit, - }) - await provider.send('evm_increaseTime', [86400]) - await registry.executeRequest(recipientId) - - await registry.removeRecipient(recipientId, { value: baseDeposit }) - await provider.send('evm_increaseTime', [86400]) - - const requestExecuted = await registry - .connect(requester) - .executeRequest(recipientId) - const currentTime = await getCurrentTime() - expect(requestExecuted) - .to.emit(registry, 'RequestResolved') - .withArgs(recipientId, RequestType.Removal, false, 0, currentTime) - - expect( - await registry.getRecipientAddress( - recipientIndex, - currentTime, - currentTime - ) - ).to.equal(ZERO_ADDRESS) - }) - }) -}) diff --git a/contracts/utils/recipient-registry-factory/index.ts b/contracts/utils/recipient-registry-factory/index.ts index 00afa7a66..d65704165 100644 --- a/contracts/utils/recipient-registry-factory/index.ts +++ b/contracts/utils/recipient-registry-factory/index.ts @@ -1,14 +1,12 @@ import { Contract, Signer } from 'ethers' import { SimpleRecipientRegistryFactory } from './simple' import { OptimisticRecipientRegistryFactory } from './optimistic' -import { UniversalRecipientRegistryFactory } from './universal' import { RecipientRegistryConstructorArgs } from './types' // Map of recipient registry type to the deployment function const RegistryFactoryMap: Record = { simple: SimpleRecipientRegistryFactory.deploy, optimistic: OptimisticRecipientRegistryFactory.deploy, - universal: UniversalRecipientRegistryFactory.deploy, } /** diff --git a/contracts/utils/recipient-registry-factory/universal.ts b/contracts/utils/recipient-registry-factory/universal.ts deleted file mode 100644 index 0f1c6f466..000000000 --- a/contracts/utils/recipient-registry-factory/universal.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { ethers } from 'hardhat' -import { Contract, Signer } from 'ethers' -import { RecipientRegistryConstructorArgs } from './types' - -export class UniversalRecipientRegistryFactory { - static async deploy( - args: RecipientRegistryConstructorArgs, - signer: Signer - ): Promise { - if (args.baseDeposit === undefined) { - throw new Error('missing base deposit ') - } - - if (args.challengePeriodDuration === undefined) { - throw new Error('missing challenge period duration') - } - - const UniversalRecipientRegistry = await ethers.getContractFactory( - 'UniversalRecipientRegistry', - signer - ) - - const recipientRegistry = await UniversalRecipientRegistry.deploy( - args.baseDeposit, - args.challengePeriodDuration, - args.controller - ) - - return recipientRegistry - } -} diff --git a/subgraph/abis/UniversalRecipientRegistry.json b/subgraph/abis/UniversalRecipientRegistry.json deleted file mode 100644 index 8758685a9..000000000 --- a/subgraph/abis/UniversalRecipientRegistry.json +++ /dev/null @@ -1,369 +0,0 @@ -[ - { - "inputs": [ - { - "internalType": "uint256", - "name": "_baseDeposit", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "_challengePeriodDuration", - "type": "uint256" - }, - { - "internalType": "address", - "name": "_controller", - "type": "address" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "previousOwner", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "OwnershipTransferred", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "bytes32", - "name": "_recipientId", - "type": "bytes32" - }, - { - "indexed": true, - "internalType": "enum UniversalRecipientRegistry.RequestType", - "name": "_type", - "type": "uint8" - }, - { - "indexed": true, - "internalType": "bool", - "name": "_rejected", - "type": "bool" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_recipientIndex", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_timestamp", - "type": "uint256" - } - ], - "name": "RequestResolved", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "bytes32", - "name": "_recipientId", - "type": "bytes32" - }, - { - "indexed": true, - "internalType": "enum UniversalRecipientRegistry.RequestType", - "name": "_type", - "type": "uint8" - }, - { - "indexed": false, - "internalType": "address", - "name": "_recipient", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "_timestamp", - "type": "uint256" - } - ], - "name": "RequestSubmitted", - "type": "event" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_recipient", - "type": "address" - }, - { - "internalType": "bytes32", - "name": "_metadataId", - "type": "bytes32" - } - ], - "name": "addRecipient", - "outputs": [], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [], - "name": "baseDeposit", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "challengePeriodDuration", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "_recipientId", - "type": "bytes32" - }, - { - "internalType": "address payable", - "name": "_beneficiary", - "type": "address" - } - ], - "name": "challengeRequest", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "controller", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "_recipientId", - "type": "bytes32" - } - ], - "name": "executeRequest", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_index", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "_startTime", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "_endTime", - "type": "uint256" - } - ], - "name": "getRecipientAddress", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getRecipientCount", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "maxRecipients", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "owner", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "registryType", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "_recipientId", - "type": "bytes32" - } - ], - "name": "removeRecipient", - "outputs": [], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [], - "name": "renounceOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_baseDeposit", - "type": "uint256" - } - ], - "name": "setBaseDeposit", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_challengePeriodDuration", - "type": "uint256" - } - ], - "name": "setChallengePeriodDuration", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_maxRecipients", - "type": "uint256" - } - ], - "name": "setMaxRecipients", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "transferOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - } -] diff --git a/subgraph/config/arbitrum-rinkeby.json b/subgraph/config/arbitrum-rinkeby.json index 9e4c9c053..c8850d0b0 100644 --- a/subgraph/config/arbitrum-rinkeby.json +++ b/subgraph/config/arbitrum-rinkeby.json @@ -2,6 +2,5 @@ "network": "arbitrum-rinkeby", "address": "0xC032e80a413Be959d9a9B6e5CadE53c870074d37", "factoryStartBlock": 4806990, - "recipientRegistryStartBlock": 4806990, - "universalRecipientRegistryStartBlock": 4806990 + "recipientRegistryStartBlock": 4806990 } diff --git a/subgraph/config/arbitrum.json b/subgraph/config/arbitrum.json index 973ecdf73..8f72d1d1f 100644 --- a/subgraph/config/arbitrum.json +++ b/subgraph/config/arbitrum.json @@ -2,6 +2,5 @@ "network": "arbitrum-one", "address": "0x2e89494a8fE02891511a43f7877b726787E0C160", "factoryStartBlock": 3461582, - "recipientRegistryStartBlock": 3461582, - "universalRecipientRegistryStartBlock": 3461582 + "recipientRegistryStartBlock": 3461582 } diff --git a/subgraph/config/hardhat.json b/subgraph/config/hardhat.json index bff76574a..308788d1d 100644 --- a/subgraph/config/hardhat.json +++ b/subgraph/config/hardhat.json @@ -2,6 +2,5 @@ "network": "hardhat", "address": "0x5FC8d32690cc91D4c39d9d3abcBD16989F875707", "factoryStartBlock": 0, - "recipientRegistryStartBlock": 0, - "universalRecipientRegistryStartBlock": 0 + "recipientRegistryStartBlock": 0 } diff --git a/subgraph/config/rinkeby.json b/subgraph/config/rinkeby.json index b81deae58..434b744c9 100644 --- a/subgraph/config/rinkeby.json +++ b/subgraph/config/rinkeby.json @@ -2,6 +2,5 @@ "network": "rinkeby", "address": "0x93A990D939Ca592cD8cCa47b7a0c3F590A598F9d", "factoryStartBlock": 9969110, - "recipientRegistryStartBlock": 9969130, - "universalRecipientRegistryStartBlock": 10255005 + "recipientRegistryStartBlock": 9969130 } diff --git a/subgraph/generated/FundingRoundFactory/MACI.ts b/subgraph/generated/FundingRoundFactory/MACI.ts deleted file mode 100644 index de37f2956..000000000 --- a/subgraph/generated/FundingRoundFactory/MACI.ts +++ /dev/null @@ -1,1634 +0,0 @@ -// 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/UniversalRecipientRegistry/UniversalRecipientRegistry.ts b/subgraph/generated/UniversalRecipientRegistry/UniversalRecipientRegistry.ts deleted file mode 100644 index fd3246a96..000000000 --- a/subgraph/generated/UniversalRecipientRegistry/UniversalRecipientRegistry.ts +++ /dev/null @@ -1,638 +0,0 @@ -// 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 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 RequestResolved extends ethereum.Event { - get params(): RequestResolved__Params { - return new RequestResolved__Params(this); - } -} - -export class RequestResolved__Params { - _event: RequestResolved; - - constructor(event: RequestResolved) { - this._event = event; - } - - get _recipientId(): Bytes { - return this._event.parameters[0].value.toBytes(); - } - - get _type(): i32 { - return this._event.parameters[1].value.toI32(); - } - - get _rejected(): boolean { - return this._event.parameters[2].value.toBoolean(); - } - - get _recipientIndex(): BigInt { - return this._event.parameters[3].value.toBigInt(); - } - - get _timestamp(): BigInt { - return this._event.parameters[4].value.toBigInt(); - } -} - -export class RequestSubmitted extends ethereum.Event { - get params(): RequestSubmitted__Params { - return new RequestSubmitted__Params(this); - } -} - -export class RequestSubmitted__Params { - _event: RequestSubmitted; - - constructor(event: RequestSubmitted) { - this._event = event; - } - - get _recipientId(): Bytes { - return this._event.parameters[0].value.toBytes(); - } - - get _type(): i32 { - return this._event.parameters[1].value.toI32(); - } - - get _recipient(): Address { - return this._event.parameters[2].value.toAddress(); - } - - get _metadataId(): string { - return this._event.parameters[3].value.toString(); - } - - get _timestamp(): BigInt { - return this._event.parameters[4].value.toBigInt(); - } -} - -export class UniversalRecipientRegistry extends ethereum.SmartContract { - static bind(address: Address): UniversalRecipientRegistry { - return new UniversalRecipientRegistry( - "UniversalRecipientRegistry", - address - ); - } - - baseDeposit(): BigInt { - let result = super.call("baseDeposit", "baseDeposit():(uint256)", []); - - return result[0].toBigInt(); - } - - try_baseDeposit(): ethereum.CallResult { - let result = super.tryCall("baseDeposit", "baseDeposit():(uint256)", []); - if (result.reverted) { - return new ethereum.CallResult(); - } - let value = result.value; - return ethereum.CallResult.fromValue(value[0].toBigInt()); - } - - challengePeriodDuration(): BigInt { - let result = super.call( - "challengePeriodDuration", - "challengePeriodDuration():(uint256)", - [] - ); - - return result[0].toBigInt(); - } - - try_challengePeriodDuration(): ethereum.CallResult { - let result = super.tryCall( - "challengePeriodDuration", - "challengePeriodDuration():(uint256)", - [] - ); - if (result.reverted) { - return new ethereum.CallResult(); - } - let value = result.value; - return ethereum.CallResult.fromValue(value[0].toBigInt()); - } - - challengeRequest(_recipientId: Bytes, _beneficiary: Address): boolean { - let result = super.call( - "challengeRequest", - "challengeRequest(bytes32,address):(bool)", - [ - ethereum.Value.fromFixedBytes(_recipientId), - ethereum.Value.fromAddress(_beneficiary) - ] - ); - - return result[0].toBoolean(); - } - - try_challengeRequest( - _recipientId: Bytes, - _beneficiary: Address - ): ethereum.CallResult { - let result = super.tryCall( - "challengeRequest", - "challengeRequest(bytes32,address):(bool)", - [ - ethereum.Value.fromFixedBytes(_recipientId), - ethereum.Value.fromAddress(_beneficiary) - ] - ); - if (result.reverted) { - return new ethereum.CallResult(); - } - let value = result.value; - return ethereum.CallResult.fromValue(value[0].toBoolean()); - } - - controller(): Address { - let result = super.call("controller", "controller():(address)", []); - - return result[0].toAddress(); - } - - try_controller(): ethereum.CallResult
{ - let result = super.tryCall("controller", "controller():(address)", []); - if (result.reverted) { - return new ethereum.CallResult(); - } - let value = result.value; - return ethereum.CallResult.fromValue(value[0].toAddress()); - } - - executeRequest(_recipientId: Bytes): boolean { - let result = super.call( - "executeRequest", - "executeRequest(bytes32):(bool)", - [ethereum.Value.fromFixedBytes(_recipientId)] - ); - - return result[0].toBoolean(); - } - - try_executeRequest(_recipientId: Bytes): ethereum.CallResult { - let result = super.tryCall( - "executeRequest", - "executeRequest(bytes32):(bool)", - [ethereum.Value.fromFixedBytes(_recipientId)] - ); - if (result.reverted) { - return new ethereum.CallResult(); - } - let value = result.value; - return ethereum.CallResult.fromValue(value[0].toBoolean()); - } - - getRecipientAddress( - _index: BigInt, - _startTime: BigInt, - _endTime: BigInt - ): Address { - let result = super.call( - "getRecipientAddress", - "getRecipientAddress(uint256,uint256,uint256):(address)", - [ - ethereum.Value.fromUnsignedBigInt(_index), - ethereum.Value.fromUnsignedBigInt(_startTime), - ethereum.Value.fromUnsignedBigInt(_endTime) - ] - ); - - return result[0].toAddress(); - } - - try_getRecipientAddress( - _index: BigInt, - _startTime: BigInt, - _endTime: BigInt - ): ethereum.CallResult
{ - let result = super.tryCall( - "getRecipientAddress", - "getRecipientAddress(uint256,uint256,uint256):(address)", - [ - ethereum.Value.fromUnsignedBigInt(_index), - ethereum.Value.fromUnsignedBigInt(_startTime), - ethereum.Value.fromUnsignedBigInt(_endTime) - ] - ); - if (result.reverted) { - return new ethereum.CallResult(); - } - let value = result.value; - return ethereum.CallResult.fromValue(value[0].toAddress()); - } - - maxRecipients(): BigInt { - let result = super.call("maxRecipients", "maxRecipients():(uint256)", []); - - return result[0].toBigInt(); - } - - try_maxRecipients(): ethereum.CallResult { - let result = super.tryCall( - "maxRecipients", - "maxRecipients():(uint256)", - [] - ); - if (result.reverted) { - return new ethereum.CallResult(); - } - let value = result.value; - return ethereum.CallResult.fromValue(value[0].toBigInt()); - } - - 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()); - } - - setMaxRecipients(_maxRecipients: BigInt): boolean { - let result = super.call( - "setMaxRecipients", - "setMaxRecipients(uint256):(bool)", - [ethereum.Value.fromUnsignedBigInt(_maxRecipients)] - ); - - return result[0].toBoolean(); - } - - try_setMaxRecipients(_maxRecipients: BigInt): ethereum.CallResult { - let result = super.tryCall( - "setMaxRecipients", - "setMaxRecipients(uint256):(bool)", - [ethereum.Value.fromUnsignedBigInt(_maxRecipients)] - ); - if (result.reverted) { - return new ethereum.CallResult(); - } - let value = result.value; - return ethereum.CallResult.fromValue(value[0].toBoolean()); - } -} - -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 _baseDeposit(): BigInt { - return this._call.inputValues[0].value.toBigInt(); - } - - get _challengePeriodDuration(): BigInt { - return this._call.inputValues[1].value.toBigInt(); - } - - get _controller(): Address { - return this._call.inputValues[2].value.toAddress(); - } -} - -export class ConstructorCall__Outputs { - _call: ConstructorCall; - - constructor(call: ConstructorCall) { - this._call = call; - } -} - -export class AddRecipientCall extends ethereum.Call { - get inputs(): AddRecipientCall__Inputs { - return new AddRecipientCall__Inputs(this); - } - - get outputs(): AddRecipientCall__Outputs { - return new AddRecipientCall__Outputs(this); - } -} - -export class AddRecipientCall__Inputs { - _call: AddRecipientCall; - - constructor(call: AddRecipientCall) { - this._call = call; - } - - get _recipient(): Address { - return this._call.inputValues[0].value.toAddress(); - } - - get _metadataId(): string { - return this._call.inputValues[1].value.toString(); - } -} - -export class AddRecipientCall__Outputs { - _call: AddRecipientCall; - - constructor(call: AddRecipientCall) { - this._call = call; - } -} - -export class ChallengeRequestCall extends ethereum.Call { - get inputs(): ChallengeRequestCall__Inputs { - return new ChallengeRequestCall__Inputs(this); - } - - get outputs(): ChallengeRequestCall__Outputs { - return new ChallengeRequestCall__Outputs(this); - } -} - -export class ChallengeRequestCall__Inputs { - _call: ChallengeRequestCall; - - constructor(call: ChallengeRequestCall) { - this._call = call; - } - - get _recipientId(): Bytes { - return this._call.inputValues[0].value.toBytes(); - } - - get _beneficiary(): Address { - return this._call.inputValues[1].value.toAddress(); - } -} - -export class ChallengeRequestCall__Outputs { - _call: ChallengeRequestCall; - - constructor(call: ChallengeRequestCall) { - this._call = call; - } - - get value0(): boolean { - return this._call.outputValues[0].value.toBoolean(); - } -} - -export class ExecuteRequestCall extends ethereum.Call { - get inputs(): ExecuteRequestCall__Inputs { - return new ExecuteRequestCall__Inputs(this); - } - - get outputs(): ExecuteRequestCall__Outputs { - return new ExecuteRequestCall__Outputs(this); - } -} - -export class ExecuteRequestCall__Inputs { - _call: ExecuteRequestCall; - - constructor(call: ExecuteRequestCall) { - this._call = call; - } - - get _recipientId(): Bytes { - return this._call.inputValues[0].value.toBytes(); - } -} - -export class ExecuteRequestCall__Outputs { - _call: ExecuteRequestCall; - - constructor(call: ExecuteRequestCall) { - this._call = call; - } - - get value0(): boolean { - return this._call.outputValues[0].value.toBoolean(); - } -} - -export class RemoveRecipientCall extends ethereum.Call { - get inputs(): RemoveRecipientCall__Inputs { - return new RemoveRecipientCall__Inputs(this); - } - - get outputs(): RemoveRecipientCall__Outputs { - return new RemoveRecipientCall__Outputs(this); - } -} - -export class RemoveRecipientCall__Inputs { - _call: RemoveRecipientCall; - - constructor(call: RemoveRecipientCall) { - this._call = call; - } - - get _recipientId(): Bytes { - return this._call.inputValues[0].value.toBytes(); - } -} - -export class RemoveRecipientCall__Outputs { - _call: RemoveRecipientCall; - - constructor(call: RemoveRecipientCall) { - 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 SetBaseDepositCall extends ethereum.Call { - get inputs(): SetBaseDepositCall__Inputs { - return new SetBaseDepositCall__Inputs(this); - } - - get outputs(): SetBaseDepositCall__Outputs { - return new SetBaseDepositCall__Outputs(this); - } -} - -export class SetBaseDepositCall__Inputs { - _call: SetBaseDepositCall; - - constructor(call: SetBaseDepositCall) { - this._call = call; - } - - get _baseDeposit(): BigInt { - return this._call.inputValues[0].value.toBigInt(); - } -} - -export class SetBaseDepositCall__Outputs { - _call: SetBaseDepositCall; - - constructor(call: SetBaseDepositCall) { - this._call = call; - } -} - -export class SetChallengePeriodDurationCall extends ethereum.Call { - get inputs(): SetChallengePeriodDurationCall__Inputs { - return new SetChallengePeriodDurationCall__Inputs(this); - } - - get outputs(): SetChallengePeriodDurationCall__Outputs { - return new SetChallengePeriodDurationCall__Outputs(this); - } -} - -export class SetChallengePeriodDurationCall__Inputs { - _call: SetChallengePeriodDurationCall; - - constructor(call: SetChallengePeriodDurationCall) { - this._call = call; - } - - get _challengePeriodDuration(): BigInt { - return this._call.inputValues[0].value.toBigInt(); - } -} - -export class SetChallengePeriodDurationCall__Outputs { - _call: SetChallengePeriodDurationCall; - - constructor(call: SetChallengePeriodDurationCall) { - this._call = call; - } -} - -export class SetMaxRecipientsCall extends ethereum.Call { - get inputs(): SetMaxRecipientsCall__Inputs { - return new SetMaxRecipientsCall__Inputs(this); - } - - get outputs(): SetMaxRecipientsCall__Outputs { - return new SetMaxRecipientsCall__Outputs(this); - } -} - -export class SetMaxRecipientsCall__Inputs { - _call: SetMaxRecipientsCall; - - constructor(call: SetMaxRecipientsCall) { - this._call = call; - } - - get _maxRecipients(): BigInt { - return this._call.inputValues[0].value.toBigInt(); - } -} - -export class SetMaxRecipientsCall__Outputs { - _call: SetMaxRecipientsCall; - - constructor(call: SetMaxRecipientsCall) { - this._call = call; - } - - get value0(): boolean { - return this._call.outputValues[0].value.toBoolean(); - } -} - -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; - } -} diff --git a/subgraph/src/MACIMapping.ts b/subgraph/src/MACIMapping.ts index fa76a8ef3..bf84663c3 100644 --- a/subgraph/src/MACIMapping.ts +++ b/subgraph/src/MACIMapping.ts @@ -20,7 +20,7 @@ import { FundingRound, Message, PublicKey } from '../generated/schema' // - contract.verifier(...) export function handlePublishMessage(event: PublishMessage): void { - const fundingRoundId = event.transaction.to.toHexString() + let fundingRoundId = event.transaction.to.toHexString() if (fundingRoundId == null) { log.error( 'Error: handlePublishMessage failed fundingRound not registered', @@ -28,7 +28,7 @@ export function handlePublishMessage(event: PublishMessage): void { ) return } - const fundingRound = FundingRound.load(fundingRoundId) + let fundingRound = FundingRound.load(fundingRoundId) if (fundingRound == null) { log.error( 'Error: handlePublishMessage failed fundingRound not registered', @@ -37,23 +37,23 @@ export function handlePublishMessage(event: PublishMessage): void { return } - const messageID = event.transaction.hash.toHexString() + let messageID = event.transaction.hash.toHexString() - const timestamp = event.block.timestamp.toString() - const message = new Message(messageID) + let timestamp = event.block.timestamp.toString() + let 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) + let publicKeyId = event.transaction.from.toHexString() + let publicKey = PublicKey.load(publicKeyId) //NOTE: If the public keys aren't being tracked initialize them if (publicKey == null) { - const publicKey = new PublicKey(publicKeyId) + let publicKey = new PublicKey(publicKeyId) publicKey.x = event.params._encPubKey.x publicKey.y = event.params._encPubKey.y - const _messages = [messageID] as string[] + let _messages = [messageID] as string[] publicKey.messages = _messages publicKey.fundingRound = fundingRoundId @@ -68,12 +68,12 @@ export function handlePublishMessage(event: PublishMessage): void { } export function handleSignUp(event: SignUp): void { - const publicKeyId = event.transaction.from.toHexString() - const publicKey = PublicKey.load(publicKeyId) + let publicKeyId = event.transaction.from.toHexString() + let publicKey = PublicKey.load(publicKeyId) //NOTE: If the public keys aren't being tracked initialize them if (publicKey == null) { - const publicKey = new PublicKey(publicKeyId) + let publicKey = new PublicKey(publicKeyId) publicKey.x = event.params._userPubKey.x publicKey.y = event.params._userPubKey.y publicKey.stateIndex = event.params._stateIndex diff --git a/subgraph/src/RecipientMapping.ts b/subgraph/src/RecipientMapping.ts index 64b48ef0e..614bdb305 100644 --- a/subgraph/src/RecipientMapping.ts +++ b/subgraph/src/RecipientMapping.ts @@ -1,10 +1,12 @@ import { Recipient } from '../generated/schema' +export const RECIPIENT_REQUEST_TYPE_REGISTRATION = '0' +export const RECIPIENT_REQUEST_TYPE_REMOVAL = '1' + export function removeRecipient(id: string, timestamp: string): void { let recipient = Recipient.load(id) if (recipient) { - // TODO: should we hard delete the recipient record? - recipient.rejected = true + recipient.requestType = RECIPIENT_REQUEST_TYPE_REMOVAL recipient.lastUpdatedAt = timestamp recipient.save() } diff --git a/subgraph/src/recipientRegistry/KlerosRecipientRegistryMapping.ts b/subgraph/src/recipientRegistry/KlerosRecipientRegistryMapping.ts index 6f04d3792..b09b88964 100644 --- a/subgraph/src/recipientRegistry/KlerosRecipientRegistryMapping.ts +++ b/subgraph/src/recipientRegistry/KlerosRecipientRegistryMapping.ts @@ -4,13 +4,19 @@ import { } from '../../generated/templates/KlerosRecipientRegistry/KlerosRecipientRegistry' import { Recipient } from '../../generated/schema' -import { removeRecipient } from '../RecipientMapping' +import { + removeRecipient, + RECIPIENT_REQUEST_TYPE_REGISTRATION, +} from '../RecipientMapping' export function handleRecipientAdded(event: RecipientAdded): void { let recipientRegistryId = event.address.toHexString() let recipientId = event.params._tcrItemId.toHexString() let recipient = new Recipient(recipientId) + recipient.requestType = RECIPIENT_REQUEST_TYPE_REGISTRATION + // recipient was verified by kleros + recipient.verified = true recipient.recipientRegistry = recipientRegistryId recipient.createdAt = event.block.timestamp.toString() recipient.recipientIndex = event.params._index diff --git a/subgraph/src/recipientRegistry/RecipientRegistryFactory.ts b/subgraph/src/recipientRegistry/RecipientRegistryFactory.ts index e4e391538..eb130d90e 100644 --- a/subgraph/src/recipientRegistry/RecipientRegistryFactory.ts +++ b/subgraph/src/recipientRegistry/RecipientRegistryFactory.ts @@ -2,7 +2,6 @@ import { Address } from '@graphprotocol/graph-ts' import { OptimisticRecipientRegistry as OptimisticRecipientRegistryContract } from '../../generated/FundingRoundFactory/OptimisticRecipientRegistry' import { SimpleRecipientRegistry as SimpleRecipientRegistryContract } from '../../generated/FundingRoundFactory/SimpleRecipientRegistry' import { KlerosRecipientRegistry as KlerosRecipientRegistryContract } from '../../generated/FundingRoundFactory/KlerosRecipientRegistry' -import { UniversalRecipientRegistry as UniversalRecipientRegistryContract } from '../../generated/FundingRoundFactory/UniversalRecipientRegistry' import { RecipientRegistry } from '../../generated/schema' import { @@ -38,28 +37,6 @@ class RecipientRegistryFactoryOptimistic { } } -class RecipientRegistryFactoryUniversal { - static create(params: RecipientRegistryCreateParams): RecipientRegistry { - let recipientRegistryId = params.recipientRegistryAddress.toHexString() - let recipientRegistry = new RecipientRegistry(recipientRegistryId) - - let registry = UniversalRecipientRegistryContract.bind( - params.recipientRegistryAddress - ) - recipientRegistry.baseDeposit = registry.baseDeposit() - recipientRegistry.challengePeriodDuration = - registry.challengePeriodDuration() - recipientRegistry.owner = registry.owner() - - recipientRegistry.controller = registry.controller() - recipientRegistry.maxRecipients = registry.maxRecipients() - recipientRegistry.fundingRoundFactory = params.fundingRoundFactoryId - recipientRegistry.createdAt = params.createdAt - - return recipientRegistry - } -} - class RecipientRegistryFactorySimple { static create(params: RecipientRegistryCreateParams): RecipientRegistry { let recipientRegistryId = params.recipientRegistryAddress.toHexString() @@ -105,8 +82,6 @@ export class RecipientRegistryFactory { return RecipientRegistryFactoryOptimistic.create(params) case RecipientRegistryType.Kleros: return RecipientRegistryFactoryKleros.create(params) - case RecipientRegistryType.Universal: - return RecipientRegistryFactoryUniversal.create(params) case RecipientRegistryType.Simple: return RecipientRegistryFactorySimple.create(params) default: diff --git a/subgraph/src/recipientRegistry/RecipientRegistryTemplate.ts b/subgraph/src/recipientRegistry/RecipientRegistryTemplate.ts index 3c1c3c9b6..0c8d4d0fc 100644 --- a/subgraph/src/recipientRegistry/RecipientRegistryTemplate.ts +++ b/subgraph/src/recipientRegistry/RecipientRegistryTemplate.ts @@ -7,7 +7,6 @@ import { OptimisticRecipientRegistry as OptimisticRecipientRegistryTemplate, SimpleRecipientRegistry as SimpleRecipientRegistryTemplate, KlerosRecipientRegistry as KlerosRecipientRegistryTemplate, - UniversalRecipientRegistry as UniversalRecipientRegistryTemplate, } from '../../generated/templates' export class RecipientRegistryTemplate { @@ -20,9 +19,6 @@ export class RecipientRegistryTemplate { case RecipientRegistryType.Optimistic: OptimisticRecipientRegistryTemplate.create(registryAddress) break - case RecipientRegistryType.Universal: - UniversalRecipientRegistryTemplate.create(registryAddress) - break case RecipientRegistryType.Simple: SimpleRecipientRegistryTemplate.create(registryAddress) break diff --git a/subgraph/src/recipientRegistry/RecipientRegistryType.ts b/subgraph/src/recipientRegistry/RecipientRegistryType.ts index af438676a..29cc86204 100644 --- a/subgraph/src/recipientRegistry/RecipientRegistryType.ts +++ b/subgraph/src/recipientRegistry/RecipientRegistryType.ts @@ -1,21 +1,18 @@ import { Address, TypedMap, log } from '@graphprotocol/graph-ts' import { OptimisticRecipientRegistry as OptimisticRecipientRegistryContract } from '../../generated/FundingRoundFactory/OptimisticRecipientRegistry' import { KlerosRecipientRegistry as KlerosRecipientRegistryContract } from '../../generated/FundingRoundFactory/KlerosRecipientRegistry' -import { UniversalRecipientRegistry as UniversalRecipientRegistryContract } from '../../generated/FundingRoundFactory/UniversalRecipientRegistry' export enum RecipientRegistryType { Unknown, Simple, Kleros, Optimistic, - Universal, } let registryTypeMap = new TypedMap() registryTypeMap.set('simple', RecipientRegistryType.Simple) -registryTypeMap.set('klerso', RecipientRegistryType.Kleros) +registryTypeMap.set('kleros', RecipientRegistryType.Kleros) registryTypeMap.set('optimistic', RecipientRegistryType.Optimistic) -registryTypeMap.set('universal', RecipientRegistryType.Universal) /** * Determine the type of the registry given the registry address @@ -31,19 +28,6 @@ registryTypeMap.set('universal', RecipientRegistryType.Universal) export function getRecipientRegistryType( registryAddress: Address ): RecipientRegistryType { - let universalRegistry = - UniversalRecipientRegistryContract.bind(registryAddress) - let registryType = universalRegistry.try_registryType() - if (!registryType.reverted) { - let entry = registryTypeMap.getEntry(registryType.value) - if (entry) { - return entry.value - } else { - log.error('Error: unknown registry type {}', [registryType.value]) - return RecipientRegistryType.Unknown - } - } - let klerosRegistry = KlerosRecipientRegistryContract.bind(registryAddress) let tcr = klerosRegistry.try_tcr() if (!tcr.reverted) { diff --git a/subgraph/src/recipientRegistry/SimpleRecipientRegistryMapping.ts b/subgraph/src/recipientRegistry/SimpleRecipientRegistryMapping.ts index 583f0826c..9bbc6e9e9 100644 --- a/subgraph/src/recipientRegistry/SimpleRecipientRegistryMapping.ts +++ b/subgraph/src/recipientRegistry/SimpleRecipientRegistryMapping.ts @@ -4,7 +4,10 @@ import { } from '../../generated/templates/SimpleRecipientRegistry/SimpleRecipientRegistry' import { Recipient } from '../../generated/schema' -import { removeRecipient } from '../RecipientMapping' +import { + removeRecipient, + RECIPIENT_REQUEST_TYPE_REGISTRATION, +} from '../RecipientMapping' export function handleRecipientAdded(event: RecipientAdded): void { let recipientRegistryId = event.address.toHexString() @@ -13,12 +16,15 @@ export function handleRecipientAdded(event: RecipientAdded): void { let recipient = new Recipient(recipientId) recipient.requester = event.transaction.from.toHexString() + recipient.requestType = RECIPIENT_REQUEST_TYPE_REGISTRATION recipient.recipientRegistry = recipientRegistryId recipient.recipientMetadata = event.params._metadata recipient.recipientIndex = event.params._index recipient.recipientAddress = event.params._recipient recipient.submissionTime = event.params._timestamp.toString() recipient.requestResolvedHash = event.transaction.hash + // recipients are verified as they are added by the admin + recipient.verified = true recipient.createdAt = event.block.timestamp.toString() recipient.save() diff --git a/subgraph/src/recipientRegistry/UniversalRecipientRegistryMapping.ts b/subgraph/src/recipientRegistry/UniversalRecipientRegistryMapping.ts deleted file mode 100644 index ea75880c6..000000000 --- a/subgraph/src/recipientRegistry/UniversalRecipientRegistryMapping.ts +++ /dev/null @@ -1,54 +0,0 @@ -import { BigInt, log } from '@graphprotocol/graph-ts' -import { - OwnershipTransferred, - RequestResolved, - RequestSubmitted, -} from '../../generated/templates/UniversalRecipientRegistry/UniversalRecipientRegistry' - -import { Recipient } from '../../generated/schema' - -export function handleOwnershipTransferred(event: OwnershipTransferred): void { - log.info('handleOwnershipTransferred - universal recipient registry', []) -} - -export function handleRequestResolved(event: RequestResolved): void { - let recipientRegistryId = event.address.toHexString() - - log.info('handleRequestResolved', []) - let recipientId = event.params._recipientId.toHexString() - let recipient = new Recipient(recipientId) - - recipient.requestType = BigInt.fromI32(event.params._type).toString() - recipient.requester = event.transaction.from.toHexString() - recipient.submissionTime = event.params._timestamp.toString() - recipient.rejected = event.params._rejected - recipient.verified = !event.params._rejected - recipient.recipientRegistry = recipientRegistryId - recipient.recipientIndex = event.params._recipientIndex - recipient.requestResolvedHash = event.transaction.hash - - recipient.save() -} - -export function handleRequestSubmitted(event: RequestSubmitted): void { - log.info('handleRequestSubmitted', []) - let recipientRegistryId = event.address.toHexString() - - //TODO: create RecipientRegistry entity here if it does not exist. - - let recipientId = event.params._recipientId.toHexString() - let recipient = new Recipient(recipientId) - - recipient.recipientRegistry = recipientRegistryId - recipient.recipientAddress = event.params._recipient - recipient.recipientMetadata = null - recipient.recipientMetadataId = recipientId - recipient.requestType = BigInt.fromI32(event.params._type).toString() - recipient.requester = event.transaction.from.toHexString() - recipient.submissionTime = event.params._timestamp.toString() - recipient.deposit = event.transaction.value - recipient.verified = false - recipient.requestSubmittedHash = event.transaction.hash - - recipient.save() -} diff --git a/subgraph/subgraph.template.yaml b/subgraph/subgraph.template.yaml index 9ac2f45d7..3bc4bcd58 100644 --- a/subgraph/subgraph.template.yaml +++ b/subgraph/subgraph.template.yaml @@ -33,8 +33,6 @@ dataSources: file: ./abis/SimpleRecipientRegistry.json - name: KlerosRecipientRegistry file: ./abis/KlerosRecipientRegistry.json - - name: UniversalRecipientRegistry - file: ./abis/UniversalRecipientRegistry.json - name: BrightIdUserRegistry file: ./abis/BrightIdUserRegistry.json eventHandlers: @@ -181,29 +179,6 @@ templates: - event: RecipientRemoved(indexed bytes32,uint256) handler: handleRecipientRemoved file: ./src/recipientRegistry/KlerosRecipientRegistryMapping.ts - - name: UniversalRecipientRegistry - kind: ethereum/contract - network: {{network}} - source: - abi: UniversalRecipientRegistry - mapping: - kind: ethereum/events - apiVersion: 0.0.4 - language: wasm/assemblyscript - entities: - - RecipientRegistry - - Recipient - abis: - - name: UniversalRecipientRegistry - file: ./abis/UniversalRecipientRegistry.json - eventHandlers: - - event: OwnershipTransferred(indexed address,indexed address) - handler: handleOwnershipTransferred - - event: RequestResolved(indexed bytes32,indexed uint8,indexed bool,uint256,uint256) - handler: handleRequestResolved - - event: RequestSubmitted(indexed bytes32,indexed uint8,address,uint256) - handler: handleRequestSubmitted - file: ./src/recipientRegistry/UniversalRecipientRegistryMapping.ts - name: BrightIdUserRegistry kind: ethereum/contract network: {{network}} diff --git a/subgraph/subgraph.yaml b/subgraph/subgraph.yaml index 70236d542..93a19c4da 100644 --- a/subgraph/subgraph.yaml +++ b/subgraph/subgraph.yaml @@ -33,8 +33,6 @@ dataSources: file: ./abis/SimpleRecipientRegistry.json - name: KlerosRecipientRegistry file: ./abis/KlerosRecipientRegistry.json - - name: UniversalRecipientRegistry - file: ./abis/UniversalRecipientRegistry.json - name: BrightIdUserRegistry file: ./abis/BrightIdUserRegistry.json eventHandlers: @@ -58,7 +56,7 @@ dataSources: network: xdai source: abi: OptimisticRecipientRegistry - startBlock: 0 + startBlock: 15217676 mapping: kind: ethereum/events apiVersion: 0.0.4 @@ -181,29 +179,6 @@ templates: - event: RecipientRemoved(indexed bytes32,uint256) handler: handleRecipientRemoved file: ./src/recipientRegistry/KlerosRecipientRegistryMapping.ts - - name: UniversalRecipientRegistry - kind: ethereum/contract - network: xdai - source: - abi: UniversalRecipientRegistry - mapping: - kind: ethereum/events - apiVersion: 0.0.4 - language: wasm/assemblyscript - entities: - - RecipientRegistry - - Recipient - abis: - - name: UniversalRecipientRegistry - file: ./abis/UniversalRecipientRegistry.json - eventHandlers: - - event: OwnershipTransferred(indexed address,indexed address) - handler: handleOwnershipTransferred - - event: RequestResolved(indexed bytes32,indexed uint8,indexed bool,uint256,uint256) - handler: handleRequestResolved - - event: RequestSubmitted(indexed bytes32,indexed uint8,address,uint256) - handler: handleRequestSubmitted - file: ./src/recipientRegistry/UniversalRecipientRegistryMapping.ts - name: BrightIdUserRegistry kind: ethereum/contract network: xdai diff --git a/vue-app/.env.example b/vue-app/.env.example index 367d59b19..c3b1bdd93 100644 --- a/vue-app/.env.example +++ b/vue-app/.env.example @@ -44,16 +44,16 @@ VUE_APP_GOOGLE_SPREADSHEET_ID= # metadata registry configurations # The networks where metadata is stored; as comma separated strings -# i.e. rinkeby,ropsten,mainnet +# i.e. arbitrum-rinkeby,ropsten,mainnet VUE_APP_METADATA_NETWORKS= # metadata registry subgraph url prefix # Add the network part (VUE_APP_METADATA_NETWORKS) to form the complete url -# i.e. https://api.thegraph.com/subgraphs/name/yuetloo/metadata- -METADATA_SUBGRAPH_URL_PREFIX= +# i.e. https://api.thegraph.com/subgraphs/name/clrfund/metadata- +VUE_APP_METADATA_SUBGRAPH_URL_PREFIX= # subgraph query batch size, default to 30 -QUERY_BATCH_SIZE= +VUE_APP_QUERY_BATCH_SIZE= # Select the sheet's name to write the data, by default 'Raw' GOOGLE_SHEET_NAME= diff --git a/vue-app/.env.xdai b/vue-app/.env.xdai index f92ce255e..06415ba8d 100644 --- a/vue-app/.env.xdai +++ b/vue-app/.env.xdai @@ -19,7 +19,7 @@ VUE_APP_USER_REGISTRY_TYPE=brightid # Learn more about BrightID and context in /docs/brightid.md VUE_APP_BRIGHTID_CONTEXT=clr.fund -# Supported values: simple, optimistic, kleros, universal +# Supported values: simple, optimistic, kleros VUE_APP_RECIPIENT_REGISTRY_TYPE=optimistic VUE_APP_RECIPIENT_REGISTRY_POLICY=QmeygKjvrpidJeFHv6ywjUrj718nwtFQgCCPPR4r5nL87R diff --git a/vue-app/src/App.vue b/vue-app/src/App.vue index a4ba66248..4c2d1a60f 100644 --- a/vue-app/src/App.vue +++ b/vue-app/src/App.vue @@ -177,6 +177,7 @@ export default class App extends Vue { 'join-step', 'round-information', 'transaction-success', + 'metadata-success', 'verify', 'verify-step', 'verified', diff --git a/vue-app/src/api/abi.ts b/vue-app/src/api/abi.ts index bcda861fa..528ad6edd 100644 --- a/vue-app/src/api/abi.ts +++ b/vue-app/src/api/abi.ts @@ -7,7 +7,6 @@ import { abi as UserRegistry } from '../../../contracts/build/contracts/contract import { abi as BrightIdUserRegistry } from '../../../contracts/build/contracts/contracts/userRegistry/BrightIdUserRegistry.sol/BrightIdUserRegistry.json' import { abi as SimpleRecipientRegistry } from '../../../contracts/build/contracts/contracts/recipientRegistry/SimpleRecipientRegistry.sol/SimpleRecipientRegistry.json' import { abi as OptimisticRecipientRegistry } from '../../../contracts/build/contracts/contracts/recipientRegistry/OptimisticRecipientRegistry.sol/OptimisticRecipientRegistry.json' -import { abi as UniversalRecipientRegistry } from '../../../contracts/build/contracts/contracts/recipientRegistry/UniversalRecipientRegistry.sol/UniversalRecipientRegistry.json' import { abi as KlerosGTCR } from '../../../contracts/build/contracts/contracts/recipientRegistry/IKlerosGTCR.sol/IKlerosGTCR.json' import { abi as KlerosGTCRAdapter } from '../../../contracts/build/contracts/contracts/recipientRegistry/KlerosGTCRAdapter.sol/KlerosGTCRAdapter.json' import { abi as BaseRecipientRegistry } from '../../../contracts/build/contracts/contracts/recipientRegistry/BaseRecipientRegistry.sol/BaseRecipientRegistry.json' @@ -22,7 +21,6 @@ export { BrightIdUserRegistry, SimpleRecipientRegistry, OptimisticRecipientRegistry, - UniversalRecipientRegistry, KlerosGTCR, KlerosGTCRAdapter, BaseRecipientRegistry, diff --git a/vue-app/src/api/core.ts b/vue-app/src/api/core.ts index a34ec3a1b..244cf7838 100644 --- a/vue-app/src/api/core.ts +++ b/vue-app/src/api/core.ts @@ -40,7 +40,6 @@ export enum RecipientRegistryType { SIMPLE = 'simple', OPTIMISTIC = 'optimistic', KLEROS = 'kleros', - UNIVERSAL = 'universal', } export const recipientRegistryType = process.env.VUE_APP_RECIPIENT_REGISTRY_TYPE || '' @@ -71,7 +70,8 @@ export const METADATA_NETWORKS = process.env.VUE_APP_METADATA_NETWORKS ? process.env.VUE_APP_METADATA_NETWORKS.split(',') : ['rinkeby'] -export const QUERY_BATCH_SIZE = Number(process.env.QUERY_BATCH_SIZE) || 30 +export const QUERY_BATCH_SIZE = + Number(process.env.VUE_APP_QUERY_BATCH_SIZE) || 30 export const MAX_RETRIES = Number(process.env.VUE_APP_MAX_RETRIES) || 10 @@ -80,3 +80,10 @@ export enum ThemeMode { LIGHT = 'light', DARK = 'dark', } + +// transaction progress reported as the current block seen +// and the last block the transaction is expected to be in +export type TransactionProgress = { + current: number + last: number +} diff --git a/vue-app/src/api/metadata.ts b/vue-app/src/api/metadata.ts index 4b772e083..c99bf3d3e 100644 --- a/vue-app/src/api/metadata.ts +++ b/vue-app/src/api/metadata.ts @@ -4,6 +4,9 @@ import { METADATA_NETWORKS, METADATA_SUBGRAPH_URL_PREFIX, chain } from './core' import { Project } from './projects' import { Ipfs } from './ipfs' import { MAX_RETRIES } from './core' +import { required, url, maxLength } from 'vuelidate/lib/validators' +import * as isIPFS from 'is-ipfs' +import { ReceivingAddress } from '@/api/receiving-address' const subgraphUrl = (network: string): string => `${METADATA_SUBGRAPH_URL_PREFIX}${network}` @@ -39,11 +42,13 @@ export interface MetadataFormData { } fund: { receivingAddresses: string[] + currentChainReceivingAddress: string plans: string } team: { name: string description: string + email: string } links: { github: string @@ -63,23 +68,56 @@ export interface MetadataFormData { owner?: string } +export const MetadataFormValidations = { + project: { + name: { required }, + tagline: { + required, + maxLength: maxLength(140), + }, + description: { required }, + category: { required }, + problemSpace: { required }, + }, + fund: { + receivingAddresses: {}, + currentChainReceivingAddress: { + required, + validEthAddress: utils.isAddress, + }, + plans: { required }, + }, + team: { + name: {}, + description: {}, + }, + links: { + github: { url }, + radicle: { url }, + website: { url }, + twitter: { url }, + discord: { url }, + }, + image: { + bannerHash: { + required, + validIpfsHash: isIPFS.cid, + }, + thumbnailHash: { + required, + validIpfsHash: isIPFS.cid, + }, + }, +} + /** - * Extract address for the given chain + * Extract address for the current chain from the fund receiving addresses * @param receivingAddresses array of EIP-3770 addresses, i.e. eth:0x11111... - * @param chainShortName chain short name - * @returns address for the chain + * @returns address for the current chain */ -function getAddressForChain( - receivingAddresses: string[] = [], - chainShortName: string -): string { - const chainAddresses = receivingAddresses.reduce((addresses, data) => { - const [chainName, address] = data.split(':') - addresses[chainName] = address - return addresses - }, {}) - - return chainAddresses[chainShortName] +function getAddressForCurrentChain(receivingAddresses: string[] = []): string { + const addresses = ReceivingAddress.fromArray(receivingAddresses) + return addresses[chain.shortName] } /** @@ -103,23 +141,6 @@ async function getLatestBlock(network: string): Promise { return meta.block.number } -/** - * Parse and populate receiving addresses - * @param data data containing receivingAddresses - * @returns metadata populated with resolvedAddress and addressName - */ -async function populateAddresses(data: any): Promise { - const addressName = getAddressForChain( - data.receivingAddresses, - chain.shortName - ) - - return { - ...data, - addressName, - } -} - function sleep(factor: number): Promise { const timeout = factor ** 2 * 1000 return new Promise((resolve) => setTimeout(resolve, timeout)) @@ -134,8 +155,7 @@ export class Metadata { owner?: string network?: string receivingAddresses?: string[] - addressName?: string - resolvedAddress?: string + currentChainReceivingAddress?: string tagline?: string description?: string category?: string @@ -152,6 +172,8 @@ export class Metadata { thumbnailImageHash?: string imageHash?: string deletedAt?: number + furthestStep?: number + email?: string constructor(data: any) { this.id = data.id @@ -159,6 +181,9 @@ export class Metadata { this.owner = data.owner this.network = data.network this.receivingAddresses = data.receivingAddresses + this.currentChainReceivingAddress = getAddressForCurrentChain( + data.receivingAddresses + ) this.tagline = data.tagline this.description = data.description this.category = data.category @@ -174,6 +199,8 @@ export class Metadata { this.bannerImageHash = data.bannerImageHash this.thumbnailImageHash = data.thumbnailImageHash this.imageHash = data.imageHash + this.furthestStep = data.furthestStep + this.email = data.email } /** @@ -211,8 +238,7 @@ export class Metadata { return null } - const arg = await populateAddresses(data) - return new Metadata({ ...arg }) + return new Metadata({ ...data }) } /** @@ -230,29 +256,14 @@ export class Metadata { return result.data?.metadataEntries || [] } - /** - * get the receiving address of the current chain - * @param addresses list of EIP3770 addresses - * @returns the address of the current chain - */ - getCurrentChainAddress(addresses: string[] = []): string { - const chainPrefix = chain.shortName + ':' - const chainAddress = addresses.find((addr) => { - return addr.startsWith(chainPrefix) - }) - - return chainAddress ? chainAddress.substring(chainPrefix.length) : '' - } - /** * Convert metadata to project interface * @returns project */ toProject(): Project { - const address = this.getCurrentChainAddress(this.receivingAddresses) return { id: this.id || '', - address, + address: this.currentChainReceivingAddress || '', name: this.name || '', tagline: this.tagline, description: this.description || '', @@ -290,11 +301,14 @@ export class Metadata { }, fund: { receivingAddresses: this.receivingAddresses || [], + currentChainReceivingAddress: + getAddressForCurrentChain(this.receivingAddresses) || '', plans: this.plans || '', }, team: { name: this.teamName || '', description: this.teamDescription || '', + email: this.email || '', }, links: { github: this.githubUrl || '', diff --git a/vue-app/src/api/projects.ts b/vue-app/src/api/projects.ts index 358e0a944..0ab238d6d 100644 --- a/vue-app/src/api/projects.ts +++ b/vue-app/src/api/projects.ts @@ -7,7 +7,6 @@ import { recipientRegistryType, } from './core' -import SimpleRegistry from './recipient-registry-simple' import KlerosRegistry from './recipient-registry-kleros' import RecipientRegistry from './recipient-registry' @@ -57,9 +56,7 @@ export async function getProjects( startTime?: number, endTime?: number ): Promise { - if (recipientRegistryType === 'simple') { - return await SimpleRegistry.getProjects(registryAddress, startTime, endTime) - } else if (recipientRegistryType === 'kleros') { + if (recipientRegistryType === 'kleros') { return await KlerosRegistry.getProjects(registryAddress, startTime, endTime) } else { return await RecipientRegistry.getProjects( @@ -74,9 +71,7 @@ export async function getProject( registryAddress: string, recipientId: string ): Promise { - if (recipientRegistryType === 'simple') { - return await SimpleRegistry.getProject(registryAddress, recipientId) - } else if (recipientRegistryType === 'kleros') { + if (recipientRegistryType === 'kleros') { return await KlerosRegistry.getProject(registryAddress, recipientId) } else { return await RecipientRegistry.getProject(recipientId) diff --git a/vue-app/src/api/receiving-address.ts b/vue-app/src/api/receiving-address.ts new file mode 100644 index 000000000..6f12d0424 --- /dev/null +++ b/vue-app/src/api/receiving-address.ts @@ -0,0 +1,36 @@ +/** + * Fund Receiving Address + */ +export class ReceivingAddress { + /** + * Convert the receiving addresses from string to a lookup dictionary + * @param addresses array of EIP3770 addresses (e.g. eth:0x1234...) + * @returns a dictionary of chain short name to address + */ + static fromArray(addresses: string[]): Record { + const result: Record = addresses.reduce( + (addresses, item) => { + const chainAddress = item.split(':') + + if (chainAddress.length === 2) { + addresses[chainAddress[0]] = chainAddress[1] + } + return addresses + }, + {} + ) + + return result + } + + /** + * Convert a chain-address dictionary to an array of EIP3770 addresses + * @param addresses a dictionary with chain short name to address + * @returns an array of EIP3770 addresses + */ + static toArray(addresses: Record): string[] { + return Object.entries(addresses).map( + ([chain, address]) => `${chain}:${address}` + ) + } +} diff --git a/vue-app/src/api/recipient-registry-kleros.ts b/vue-app/src/api/recipient-registry-kleros.ts index 1c2285378..694ca736b 100644 --- a/vue-app/src/api/recipient-registry-kleros.ts +++ b/vue-app/src/api/recipient-registry-kleros.ts @@ -226,8 +226,8 @@ export function create(): RecipientRegistryInterface { removeProject, registerProject, rejectProject, - isRegistrationOpen: true, - requireRegistrationDeposit: true, + isSelfRegistration: false, //TODO: add support for self registration + requireRegistrationDeposit: false, } } diff --git a/vue-app/src/api/recipient-registry-optimistic.ts b/vue-app/src/api/recipient-registry-optimistic.ts index da452d4ac..a8c7d6682 100644 --- a/vue-app/src/api/recipient-registry-optimistic.ts +++ b/vue-app/src/api/recipient-registry-optimistic.ts @@ -6,8 +6,9 @@ import { import { getEventArg } from '@/utils/contracts' import { OptimisticRecipientRegistry } from './abi' -import { RecipientApplicationData } from './recipient' import { RecipientRegistryInterface } from './types' +import { MetadataFormData } from './metadata' +import { chain } from './core' // TODO merge this with `Project` inteface export interface RecipientData { @@ -31,33 +32,9 @@ export interface RecipientData { thumbnailImageHash?: string } -export function formToRecipientData( - data: RecipientApplicationData -): RecipientData { - const { project, fund, team, links, image } = data - return { - address: fund.resolvedAddress, - name: project.name, - tagline: project.tagline, - description: project.description, - category: project.category, - problemSpace: project.problemSpace, - plans: fund.plans, - teamName: team.name, - teamDescription: team.description, - githubUrl: links.github, - radicleUrl: links.radicle, - websiteUrl: links.website, - twitterUrl: links.twitter, - discordUrl: links.discord, - bannerImageHash: image.bannerHash, - thumbnailImageHash: image.thumbnailHash, - } -} - export async function addRecipient( registryAddress: string, - recipientApplicationData: RecipientApplicationData, + recipientMetadata: MetadataFormData, deposit: BigNumber, signer: Signer ): Promise { @@ -66,12 +43,23 @@ export async function addRecipient( OptimisticRecipientRegistry, signer ) - const recipientData = formToRecipientData(recipientApplicationData) - const { address, ...metadata } = recipientData + const { id, fund } = recipientMetadata + if (!id) { + throw new Error('Missing metadata id') + } + + const { currentChainReceivingAddress: address } = fund + if (!address) { + throw new Error(`Missing recipient address for the ${chain.name} network`) + } + + const json = { id } const transaction = await registry.addRecipient( address, - JSON.stringify(metadata), - { value: deposit } + JSON.stringify(json), + { + value: deposit, + } ) return transaction } @@ -139,7 +127,7 @@ export function create(): RecipientRegistryInterface { registerProject, removeProject, rejectProject, - isRegistrationOpen: true, + isSelfRegistration: true, requireRegistrationDeposit: true, } } diff --git a/vue-app/src/api/recipient-registry-simple.ts b/vue-app/src/api/recipient-registry-simple.ts index 0e12dd0fa..fc835e4f5 100644 --- a/vue-app/src/api/recipient-registry-simple.ts +++ b/vue-app/src/api/recipient-registry-simple.ts @@ -1,9 +1,10 @@ import { BigNumber, Contract, Event, Signer } from 'ethers' -import { TransactionResponse } from '@ethersproject/abstract-provider' +import { ContractTransaction } from '@ethersproject/contracts' + import { isHexString } from '@ethersproject/bytes' import { SimpleRecipientRegistry } from './abi' -import { provider, ipfsGatewayUrl } from './core' +import { provider, ipfsGatewayUrl, chain } from './core' import { RecipientRegistryInterface } from './types' import { Project, toProjectInterface } from './projects' @@ -122,18 +123,37 @@ export function addRecipient( recipientData: any, _deposit: BigNumber, signer: Signer -): Promise { +): Promise { const registry = new Contract( registryAddress, SimpleRecipientRegistry, signer ) - const { address, ...metadata } = recipientData - return registry.addRecipient(address, JSON.stringify(metadata)) + const { id, fund } = recipientData + if (!id) { + throw new Error('Missing metadata id') + } + + const { currentChainReceivingAddress: address } = fund + if (!address) { + throw new Error(`Missing recipient address for the ${chain.name} network`) + } + + const json = { id } + return registry.addRecipient(address, JSON.stringify(json)) } -function removeProject() { - throw new Error('removeProject not implemented') +function removeProject( + registryAddress: string, + recipientId: string, + signer: Signer +): Promise { + const registry = new Contract( + registryAddress, + SimpleRecipientRegistry, + signer + ) + return registry.removeRecipient(recipientId) } function rejectProject() { @@ -150,7 +170,7 @@ export function create(): RecipientRegistryInterface { removeProject, registerProject, rejectProject, - isRegistrationOpen: false, + isSelfRegistration: false, requireRegistrationDeposit: false, } } diff --git a/vue-app/src/api/recipient-registry-universal.ts b/vue-app/src/api/recipient-registry-universal.ts deleted file mode 100644 index b2f02ffc9..000000000 --- a/vue-app/src/api/recipient-registry-universal.ts +++ /dev/null @@ -1,95 +0,0 @@ -import { Contract, BigNumber, Signer } from 'ethers' -import { TransactionResponse } from '@ethersproject/abstract-provider' -import { UniversalRecipientRegistry } from './abi' -import { RecipientRegistryInterface } from './types' -import { Metadata } from './metadata' -import { chain } from './core' - -export async function addRecipient( - registryAddress: string, - recipientData: any, - deposit: BigNumber, - signer: Signer -): Promise { - const registry = new Contract( - registryAddress, - UniversalRecipientRegistry, - signer - ) - const metadata = Metadata.fromFormData(recipientData) - const { id, address } = metadata.toProject() - if (!id) { - throw new Error('Missing metadata id') - } - - if (!address) { - throw new Error(`Missing recipient address for the ${chain.name} network`) - } - - const transaction = await registry.addRecipient(address, id, { - value: deposit, - }) - return transaction -} - -export async function registerProject( - registryAddress: string, - recipientId: string, - signer: Signer -): Promise { - const registry = new Contract( - registryAddress, - UniversalRecipientRegistry, - signer - ) - const transaction = await registry.executeRequest(recipientId) - return transaction -} - -export async function rejectProject( - registryAddress: string, - recipientId: string, - requesterAddress: string, - signer: Signer -) { - const registry = new Contract( - registryAddress, - UniversalRecipientRegistry, - signer - ) - const transaction = await registry.challengeRequest( - recipientId, - requesterAddress - ) - return transaction -} - -export async function removeProject( - registryAddress: string, - recipientId: string, - signer: Signer -) { - const registry = new Contract( - registryAddress, - UniversalRecipientRegistry, - signer - ) - - await registry.removeRecipient(recipientId) - const transaction = await registry.executeRequest(recipientId) - - return transaction -} - -export function create(): RecipientRegistryInterface { - return { - addRecipient, - removeProject, - registerProject, - rejectProject, - isRegistrationOpen: true, - requireRegistrationDeposit: true, - } -} - -export default { create } diff --git a/vue-app/src/api/recipient-registry.ts b/vue-app/src/api/recipient-registry.ts index ef32c6d2a..6c53b1333 100644 --- a/vue-app/src/api/recipient-registry.ts +++ b/vue-app/src/api/recipient-registry.ts @@ -1,4 +1,4 @@ -import { BigNumber, Contract } from 'ethers' +import { BigNumber, Contract, Signer } from 'ethers' import sdk from '@/graphql/sdk' import { BaseRecipientRegistry } from './abi' import { @@ -19,17 +19,15 @@ import { } from '@/api/types' import OptimisticRegistry from './recipient-registry-optimistic' import SimpleRegistry from './recipient-registry-simple' -import UniversalRegistry from './recipient-registry-universal' import KlerosRegistry from './recipient-registry-kleros' import { isHexString } from '@ethersproject/bytes' import { Recipient } from '@/graphql/API' import { Project } from './projects' -import { Metadata } from './metadata' +import { Metadata, MetadataFormData } from './metadata' import { DateTime } from 'luxon' const registryLookup: Record = { [RecipientRegistryType.OPTIMISTIC]: OptimisticRegistry.create, - [RecipientRegistryType.UNIVERSAL]: UniversalRegistry.create, [RecipientRegistryType.SIMPLE]: SimpleRegistry.create, [RecipientRegistryType.KLEROS]: KlerosRegistry.create, } @@ -76,7 +74,7 @@ export async function getRegistryInfo( listingPolicyUrl: `${ipfsGatewayUrl}/ipfs/${recipientRegistryPolicy}`, recipientCount: recipientCount.toNumber(), owner, - isRegistrationOpen: registry.isRegistrationOpen, + isSelfRegistration: registry.isSelfRegistration, requireRegistrationDeposit: registry.requireRegistrationDeposit, } } @@ -131,15 +129,6 @@ function decodeProject(recipient: Partial): Project { } } -/** - * Returns the metadata id if available - * @param recipient a recipient structure - * @returns metadata id or an empty string - */ -function metadataId(recipient: Partial): string { - return recipient.recipientMetadataId || '' -} - /** * Build a map to lookup metadata by id * Retrieve metadata in batches to avoid hitting server too often @@ -180,11 +169,19 @@ async function buildMetadataMap( async function normalizeRecipients( recipients: Partial[] ): Promise[]> { - const metadataIds = recipients.map(metadataId).filter(Boolean) - const metadataMap = await buildMetadataMap(metadataIds) + const metadataIds = recipients.map(({ recipientMetadata }) => { + try { + const json = JSON.parse(recipientMetadata || '') + return json.id + } catch { + return null + } + }) + + const metadataMap = await buildMetadataMap(metadataIds.filter(Boolean)) - return recipients.map((recipient) => { - const metadata = metadataMap[metadataId(recipient)] + return recipients.map((recipient, index) => { + const metadata = metadataMap[metadataIds[index]] if (metadata) { recipient.recipientMetadata = metadata } @@ -337,7 +334,7 @@ export async function getRequests( try { metadata = JSON.parse(recipient.recipientMetadata || '{}') } catch { - // instead of throwing error, let it flow throw so + // instead of throwing error, let it flow through so // we can investigate the issue from the subgraph metadata.name = 'N/A' } @@ -345,11 +342,19 @@ export async function getRequests( const requestType = Number(recipient.requestType) if (requestType === RequestTypeCode.Registration) { // Registration request - const { name, description, imageHash, thumbnailImageHash } = metadata + const { + name, + description, + imageHash, + bannerImageHash, + thumbnailImageHash, + } = metadata + metadata = { name, description, imageUrl: `${ipfsGatewayUrl}/ipfs/${imageHash}`, + bannerImageUrl: `${ipfsGatewayUrl}/ipfs/${bannerImageHash}`, thumbnailImageUrl: thumbnailImageHash ? `${ipfsGatewayUrl}/ipfs/${thumbnailImageHash}` : `${ipfsGatewayUrl}/ipfs/${imageHash}`, @@ -396,4 +401,19 @@ export async function getRequests( return Object.keys(requests).map((recipientId) => requests[recipientId]) } -export default { getProject, getProjects, projectExists } +export async function addRecipient( + registryAddress: string, + recipientMetadata: MetadataFormData, + deposit: BigNumber, + signer: Signer +) { + const registry = RecipientRegistry.create(recipientRegistryType) + return registry.addRecipient( + registryAddress, + recipientMetadata, + deposit, + signer + ) +} + +export default { addRecipient, getProject, getProjects, projectExists } diff --git a/vue-app/src/api/recipient.ts b/vue-app/src/api/recipient.ts index 951e5893b..d001923b2 100644 --- a/vue-app/src/api/recipient.ts +++ b/vue-app/src/api/recipient.ts @@ -1,6 +1,3 @@ -import { Project } from './projects' -import { ipfsGatewayUrl } from './core' - export interface RecipientApplicationData { project: { name: string @@ -35,31 +32,3 @@ export interface RecipientApplicationData { hasEns: boolean id?: string } - -export function formToProjectInterface( - data: RecipientApplicationData -): Project { - const { project, fund, team, links, image } = data - return { - id: fund.resolvedAddress, - address: fund.resolvedAddress, - name: project.name, - tagline: project.tagline, - description: project.description, - category: project.category, - problemSpace: project.problemSpace, - plans: fund.plans, - teamName: team.name, - teamDescription: team.description, - githubUrl: links.github, - radicleUrl: links.radicle, - websiteUrl: links.website, - twitterUrl: links.twitter, - discordUrl: links.discord, - bannerImageUrl: `${ipfsGatewayUrl}/ipfs/${image.bannerHash}`, - thumbnailImageUrl: `${ipfsGatewayUrl}/ipfs/${image.thumbnailHash}`, - index: 0, - isHidden: false, - isLocked: true, - } -} diff --git a/vue-app/src/api/types.ts b/vue-app/src/api/types.ts index 6649bb368..0f5a57927 100644 --- a/vue-app/src/api/types.ts +++ b/vue-app/src/api/types.ts @@ -8,7 +8,7 @@ export interface RegistryInfo { listingPolicyUrl: string recipientCount: number owner: string - isRegistrationOpen: boolean + isSelfRegistration: boolean requireRegistrationDeposit: boolean } @@ -17,7 +17,7 @@ export interface RecipientRegistryInterface { registerProject: Function rejectProject: Function removeProject: Function - isRegistrationOpen?: boolean + isSelfRegistration?: boolean requireRegistrationDeposit?: boolean } @@ -43,6 +43,7 @@ interface RecipientMetadata { name: string description: string imageUrl: string + thumbnailImageUrl: string } export interface RecipientRegistryRequest { diff --git a/vue-app/src/components/CriteriaModal.vue b/vue-app/src/components/CriteriaModal.vue index f903d132b..9662a47a4 100644 --- a/vue-app/src/components/CriteriaModal.vue +++ b/vue-app/src/components/CriteriaModal.vue @@ -35,7 +35,7 @@ Add project diff --git a/vue-app/src/components/MetadataSubmissionWidget.vue b/vue-app/src/components/MetadataSubmissionWidget.vue index be2f179d7..f06117839 100644 --- a/vue-app/src/components/MetadataSubmissionWidget.vue +++ b/vue-app/src/components/MetadataSubmissionWidget.vue @@ -1,39 +1,45 @@ @@ -41,23 +47,13 @@ import Vue from 'vue' import Component from 'vue-class-component' import { Prop } from 'vue-property-decorator' -import { Web3Provider } from '@ethersproject/providers' -import { MetadataFormData, Metadata } from '@/api/metadata' import { User } from '@/api/user' -import { chain } from '@/api/core' +import { chain, TransactionProgress } from '@/api/core' import Loader from '@/components/Loader.vue' import Transaction from '@/components/Transaction.vue' import WalletWidget from '@/components/WalletWidget.vue' -import { waitForTransaction } from '@/utils/contracts' -import { ContractTransaction, ContractReceipt } from '@ethersproject/contracts' - -type Progress = { - latest: number - total: number -} - @Component({ components: { Loader, @@ -66,81 +62,26 @@ type Progress = { }, }) export default class MetadataSubmissionWidget extends Vue { - @Prop() buttonLabel!: string - @Prop() form!: MetadataFormData - @Prop() onSubmit!: ( - form: MetadataFormData, - provider: any - ) => Promise - @Prop() onSuccess!: (receipt: ContractReceipt, chainId: number) => void - - isLoading = true - isWaiting = false - isTxRejected = false - txHash = '' - txError = '' - progress: Progress | null = null - - async created() { - this.isLoading = false - } + @Prop() isWaiting!: boolean + @Prop({ default: null }) progress!: TransactionProgress | null + @Prop({ default: '' }) txHash!: string + @Prop({ default: '' }) txError!: string + @Prop({ default: null }) buttonHandler!: () => void + @Prop({ default: false }) disableButton!: boolean get currentUser(): User | null { return this.$store.state.currentUser } - get walletProvider(): Web3Provider | undefined { - return this.$web3.provider - } - get blockExplorerLabel(): string { return chain.explorerLabel } - get canSubmit(): boolean { - return !!this.currentUser && !!this.walletProvider - } get hasTxError(): boolean { return !!this.txError } - - updateProgress(latest: number, total: number): void { - this.progress = { latest, total } - } - - async handleSubmit(): Promise { - const { currentUser } = this.$store.state - - // Reset errors when submitting - this.txError = '' - this.isTxRejected = false - if (currentUser) { - const { walletProvider } = currentUser - try { - this.isWaiting = true - const transaction = this.onSubmit(this.form, walletProvider) - const receipt = await waitForTransaction( - transaction, - (hash) => (this.txHash = hash) - ) - - await Metadata.waitForBlock( - receipt.blockNumber, - chain.name, - 0, - this.updateProgress - ) - this.isWaiting = false - - if (this.onSuccess) { - this.onSuccess(receipt, this.$web3.chainId) - } - } catch (error) { - this.isWaiting = false - this.txError = error.message - return - } - } + get showButton(): boolean { + return !!this.buttonHandler } } diff --git a/vue-app/src/components/NavBar.vue b/vue-app/src/components/NavBar.vue index 45f3e288b..a9bf16244 100644 --- a/vue-app/src/components/NavBar.vue +++ b/vue-app/src/components/NavBar.vue @@ -8,13 +8,6 @@ />
- - Manage Recipients -
{ + return chain.isLayer2 || item.text !== 'Layer 2' + }) created() { const savedTheme = lsGet(this.themeKey) const theme = isValidTheme(savedTheme) ? savedTheme : getOsColorScheme() this.$store.commit(TOGGLE_THEME, theme) - - if (chain.isLayer2) { - this.dropdownItems.splice(-1, 0, { - to: '/about/layer-2', - text: 'Layer 2', - emoji: '🚀', - }) - } } closeHelpDropdown(): void { diff --git a/vue-app/src/components/RecipientSubmissionWidget.vue b/vue-app/src/components/RecipientSubmissionWidget.vue index 31a767ae7..e4f88f5c0 100644 --- a/vue-app/src/components/RecipientSubmissionWidget.vue +++ b/vue-app/src/components/RecipientSubmissionWidget.vue @@ -1,5 +1,5 @@ @@ -71,6 +73,11 @@ export default class TransactionModal extends Vue { padding: 1.5rem; } +.btn-row { + display: flex; + justify-content: center; +} + .close-btn { margin-top: $modal-space; } diff --git a/vue-app/src/components/TransactionResult.vue b/vue-app/src/components/TransactionResult.vue index 6a94933c3..0800ddab4 100644 --- a/vue-app/src/components/TransactionResult.vue +++ b/vue-app/src/components/TransactionResult.vue @@ -20,8 +20,9 @@ import Vue from 'vue' import Component from 'vue-class-component' import { Prop } from 'vue-property-decorator' -import { ChainInfo, CHAIN_INFO, ChainId } from '@/plugins/Web3/constants/chains' +import { ChainInfo } from '@/plugins/Web3/constants/chains' import { LinkInfo } from '@/api/types' +import { chain } from '@/api/core' import TransactionReceipt from '@/components/TransactionReceipt.vue' import Links from '@/components/Links.vue' import ImageResponsive from '@/components/ImageResponsive.vue' @@ -35,11 +36,10 @@ import ImageResponsive from '@/components/ImageResponsive.vue' }) export default class TransactionResult extends Vue { @Prop() hash!: string - @Prop() chainId!: ChainId @Prop() buttons!: LinkInfo[] get chain(): ChainInfo { - return CHAIN_INFO[this.chainId] + return chain } } diff --git a/vue-app/src/plugins/Web3/constants/chains.ts b/vue-app/src/plugins/Web3/constants/chains.ts index 6e69784ab..7035a8041 100644 --- a/vue-app/src/plugins/Web3/constants/chains.ts +++ b/vue-app/src/plugins/Web3/constants/chains.ts @@ -47,8 +47,8 @@ export const CHAIN_INFO: ChainInfo = { explorer: 'https://goerli.etherscan.io', explorerLogo: 'etherscan.svg', explorerLabel: 'Etherscan', - shortName: 'rin', - name: 'rinkeby', + shortName: 'gor', + name: 'goerli', }, [ChainId.HARDHAT]: { label: 'Arbitrum Hardhat', @@ -60,7 +60,7 @@ export const CHAIN_INFO: ChainInfo = { explorerLabel: 'Arbiscan', rpcUrl: 'https://rinkeby.arbitrum.io/rpc', bridge: 'https://bridge.arbitrum.io', - shortName: 'got', + shortName: 'arb-rinkeby', name: 'arbitrum-rinkeby', }, [ChainId.ARBITRUM_ONE]: { diff --git a/vue-app/src/router/index.ts b/vue-app/src/router/index.ts index 124b763f2..3573a74b9 100644 --- a/vue-app/src/router/index.ts +++ b/vue-app/src/router/index.ts @@ -29,6 +29,7 @@ import MetadataDetail from '@/views/Metadata.vue' import MetadataRegistry from '@/views/MetadataRegistry.vue' import MetadataFormAdd from '@/views/MetadataFormAdd.vue' import MetadataFormEdit from '@/views/MetadataFormEdit.vue' +import MetadataTransactionSuccess from '@/views/MetadataTransactionSuccess.vue' import NotFound from '@/views/NotFound.vue' Vue.use(VueRouter) @@ -237,6 +238,14 @@ const routes = [ title: 'Transaction Success', }, }, + { + path: '/metadata-success/:hash/:id', + name: 'metadata-success', + component: MetadataTransactionSuccess, + meta: { + title: 'Metadata Transaction Success', + }, + }, { path: '/metadata', name: 'metadata-registry', diff --git a/vue-app/src/store/getters.ts b/vue-app/src/store/getters.ts index 9b2f56941..323072821 100644 --- a/vue-app/src/store/getters.ts +++ b/vue-app/src/store/getters.ts @@ -4,11 +4,7 @@ import { DateTime } from 'luxon' // API import { CartItem, Contributor } from '@/api/contributions' -import { - recipientRegistryType, - RecipientRegistryType, - operator, -} from '@/api/core' +import { operator } from '@/api/core' import { RoundInfo, RoundStatus } from '@/api/round' import { Tally } from '@/api/tally' import { User } from '@/api/user' @@ -83,13 +79,6 @@ const getters = { getters.recipientSpacesRemaining < 20 ) }, - isRoundBufferPhase: (state: RootState, getters): boolean => { - return ( - !!state.currentRound && - !getters.isJoinPhase && - !hasDateElapsed(state.currentRound.signUpDeadline) - ) - }, isRoundContributionPhase: (state: RootState): boolean => { return ( !!state.currentRound && @@ -229,17 +218,31 @@ const getters = { return nativeTokenDecimals }, - isRecipientRegistrationOpen: (state: RootState): boolean => { - return !!state.recipientRegistryInfo?.isRegistrationOpen + isSelfRegistration: (state: RootState): boolean => { + return !!state.recipientRegistryInfo?.isSelfRegistration }, requireRegistrationDeposit: (state: RootState): boolean => { return !!state.recipientRegistryInfo?.requireRegistrationDeposit }, - addProjectUrl: (): string => { - return recipientRegistryType === RecipientRegistryType.UNIVERSAL - ? '/join/metadata' - : '/join/project' + canAddProject: (_, getters): boolean => { + const { + requireRegistrationDeposit, + isRecipientRegistryOwner, + isRecipientRegistryFull, + isRoundJoinPhase, + } = getters + + return ( + (requireRegistrationDeposit || isRecipientRegistryOwner) && + !isRecipientRegistryFull && + isRoundJoinPhase + ) }, + joinFormUrl: + () => + (metadataId?: string): string => { + return metadataId ? `/join/metadata/${metadataId}` : '/join/project' + }, maxRecipients: (state: RootState): number | undefined => { const { currentRound, maciFactory } = state if (currentRound) { diff --git a/vue-app/src/views/AboutHowItWorks.vue b/vue-app/src/views/AboutHowItWorks.vue index 091e0cce5..b2481f0ed 100644 --- a/vue-app/src/views/AboutHowItWorks.vue +++ b/vue-app/src/views/AboutHowItWorks.vue @@ -83,7 +83,7 @@

- If you dont contribute in the contribution phase, the round is over for + If you don't contribute in the contribution phase, the round is over for you once this phase ends.

diff --git a/vue-app/src/views/AboutRecipients.vue b/vue-app/src/views/AboutRecipients.vue index a47a9b635..f80bd1b13 100644 --- a/vue-app/src/views/AboutRecipients.vue +++ b/vue-app/src/views/AboutRecipients.vue @@ -37,9 +37,14 @@

Register your project

- In order to participate in a funding round as a project, you'll need to - submit an application to join the recipient registry (via an on-chain - transaction). + In order to participate in a funding round as a project, + you'll need to submit an application to join the recipient registry + (via an on-chain transaction)you'll need to contact the round coordinator to submit an + application.

MACI, our anti-bribery tech, currently limits the amount of projects @@ -58,12 +63,19 @@ Click "See round criteria" and familiarize yourself with the criteria for projects. +

  • + Once you're familiar with the criteria and you're sure your project + meets them, + click "Add project." You'll see a series of forms to fill out asking + for more information about your project + contact the round coordinator to add your project to the recipient + registry. +