Skip to content

Commit

Permalink
subgraph mapping for UniversalRecipientRegistry
Browse files Browse the repository at this point in the history
  • Loading branch information
yuetloo committed Mar 1, 2022
1 parent 5fada67 commit e9af49f
Show file tree
Hide file tree
Showing 10 changed files with 999 additions and 5 deletions.
67 changes: 67 additions & 0 deletions contracts/scripts/deployRecipientRegistry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { ethers } from 'hardhat'
import { UNIT } from '../utils/constants'
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
* 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
*
* For example, to run the script on rinkeby network:
* From the contracts folder:
* npx hardhat run --network rinkeby scripts/deployRecipientRegistry.ts
*
*/
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()

if (!fundingRoundFactoryAddress) {
console.log('Environment variable FUNDING_ROUND_FACTORY_ADDRESS not set')
return
}
const fundingRoundFactory = await ethers.getContractAt(
'FundingRoundFactory',
fundingRoundFactoryAddress
)
const factoryOwner = await fundingRoundFactory.owner()

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}`)
const [deployer] = await ethers.getSigners()

const recipientRegistry = await RecipientRegistryFactory.deploy(
recipientRegistryType,
{
controller: fundingRoundFactory.address,
baseDeposit,
challengePeriodDuration,
},
deployer
)
console.log(` recipientRegistry address: ${recipientRegistry.address}`)

const setRecipientRegistryTx = await fundingRoundFactory.setRecipientRegistry(
recipientRegistry.address
)

await setRecipientRegistryTx.wait()
console.log('*******************')
}

main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error)
process.exit(1)
})
243 changes: 243 additions & 0 deletions subgraph/abis/UniversalRecipientRegistry.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,243 @@
[
{
"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 OptimisticRecipientRegistry.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 OptimisticRecipientRegistry.RequestType",
"name": "_type",
"type": "uint8"
},
{
"indexed": false,
"internalType": "address",
"name": "_recipient",
"type": "address"
},
{
"indexed": false,
"internalType": "string",
"name": "_metadataId",
"type": "string"
},
{
"indexed": false,
"internalType": "uint256",
"name": "_timestamp",
"type": "uint256"
}
],
"name": "RequestSubmitted",
"type": "event"
},
{
"inputs": [
{ "internalType": "address", "name": "_recipient", "type": "address" },
{ "internalType": "string", "name": "_metadataId", "type": "string" }
],
"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": "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": [
{ "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"
}
]
3 changes: 2 additions & 1 deletion subgraph/config/arbitrum-rinkeby.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"network": "arbitrum-rinkeby",
"address": "0xC032e80a413Be959d9a9B6e5CadE53c870074d37",
"factoryStartBlock": 4806990,
"recipientRegistryStartBlock": 4806990
"recipientRegistryStartBlock": 4806990,
"universalRecipientRegistryStartBlock": 4806990
}
3 changes: 2 additions & 1 deletion subgraph/config/arbitrum.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"network": "arbitrum-one",
"address": "0x2e89494a8fE02891511a43f7877b726787E0C160",
"factoryStartBlock": 3461582,
"recipientRegistryStartBlock": 3461582
"recipientRegistryStartBlock": 3461582,
"universalRecipientRegistryStartBlock": 3461582
}
3 changes: 2 additions & 1 deletion subgraph/config/hardhat.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"network": "hardhat",
"address": "0x5FC8d32690cc91D4c39d9d3abcBD16989F875707",
"factoryStartBlock": 0,
"recipientRegistryStartBlock": 0
"recipientRegistryStartBlock": 0,
"universalRecipientRegistryStartBlock": 0
}
3 changes: 2 additions & 1 deletion subgraph/config/rinkeby.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"network": "rinkeby",
"address": "0x93A990D939Ca592cD8cCa47b7a0c3F590A598F9d",
"factoryStartBlock": 9969110,
"recipientRegistryStartBlock": 9969130
"recipientRegistryStartBlock": 9969130,
"universalRecipientRegistryStartBlock": 10255005
}
3 changes: 2 additions & 1 deletion subgraph/config/xdai.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"network": "xdai",
"address": "0x549F91A93c94358C5f5380D7ABF23E1340CfF2db",
"factoryStartBlock": 15217676,
"recipientRegistryStartBlock": 0
"recipientRegistryStartBlock": 0,
"universalRecipientRegistryStartBlock": 15217676
}
Loading

0 comments on commit e9af49f

Please sign in to comment.