Skip to content

Commit

Permalink
Wsdt/subgraph dao (#48)
Browse files Browse the repository at this point in the history
* Subgraph: Added GovernorBravoDelegate

* Gateway: Subgraph integration first draft

* Gateway cleanup

* Subgraph: Local deployment

* update package.json for L1 and L2

* Update README.md

* query adaption

* clean

* Update contract address

* subgraph dao fix/adaptation

* further fixes: GraphQL Service

* Gateway: Using graphql lib now

* other library

* update package.json

* enable the graph for rinkeby proposal lookup

* system working now

* Update address

* enable DAO proposal title display

Co-authored-by: CAPtheorem <79423264+CAPtheorem@users.noreply.github.com>
Co-authored-by: cby3149 <cby3149@gmail.com>
  • Loading branch information
3 people authored Mar 29, 2022
1 parent e2a671b commit 0bedbb8
Show file tree
Hide file tree
Showing 27 changed files with 1,615 additions and 59 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ temp
coverage.json
*.tsbuildinfo

.idea/

dist
artifacts
cache
Expand Down
8 changes: 8 additions & 0 deletions boba_community/sdk-examples/kyc/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions boba_community/sdk-examples/kyc/.idea/kyc.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions boba_community/sdk-examples/kyc/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions boba_community/sdk-examples/kyc/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/boba/gateway/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea
2 changes: 2 additions & 0 deletions packages/boba/gateway/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"deploy:rinkeby": "GENERATE_SOURCEMAP=false REACT_APP_ENV=prod REACT_APP_CHAIN=rinkeby react-scripts build && aws s3 rm s3://boba-gateway-rinkeby --recursive && aws s3 sync build s3://boba-gateway-rinkeby && aws s3 cp s3://boba-gateway-rinkeby/index.html s3://boba-gateway-rinkeby/index.html --metadata-directive REPLACE --cache-control max-age=0 --content-type text/html"
},
"dependencies": {
"@apollo/client": "^3.5.10",
"@emotion/react": "^11.7.1",
"@emotion/styled": "^11.6.0",
"@eth-optimism/contracts": "^0.5.11",
Expand All @@ -33,6 +34,7 @@
"dotenv": "^8.2.0",
"eslint-config-react-app": "^7.0.0",
"ethers": "^5.0.32",
"graphql": "^16.3.0",
"html-react-parser": "^1.4.0",
"human-standard-token-abi": "^2.0.0",
"lodash": "^4.17.20",
Expand Down
19 changes: 9 additions & 10 deletions packages/boba/gateway/src/components/Proposal/Proposal.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ function Proposal({
const startTime = moment.unix(proposal.startTimestamp).format('lll')
const endTime = moment.unix(proposal.endTimestamp).format('lll')

let hasVoted = false
if(proposal.hasVoted && proposal.hasVoted.hasVoted) hasVoted = true

return (
<S.Wrapper>
<S.GridContainer container
Expand All @@ -108,7 +111,7 @@ function Proposal({
xs={12}
md={12}
>
<Typography variant="body2" style={{ fontWeight: '700', textDecoration: 'underline' }}>
<Typography variant="body2" style={{ fontWeight: '700' }}>
Proposal {proposal.id} : <FormatDescription description={proposal.description} />
</Typography>
<Box sx={{ display: 'flex', width: '100%', justifyContent: 'space-between', alignItems: 'center', my: '10px' }}>
Expand Down Expand Up @@ -143,16 +146,12 @@ function Proposal({
<Circle sx={{ height: "10px", width: "10px" }} />&nbsp; {proposal.state}</span>

}
{proposal.state !== 'Succeeded' && proposal.state !== 'Defeated' &&
<span style={{ color: 'yellow' }}>
<Circle sx={{ height: "10px", width: "10px" }} />&nbsp; {proposal.state}</span>
}
{proposal.state === 'Active' && !proposal.hasVoted &&
{proposal.state === 'Active' && !hasVoted &&
<span style={{ fontSize: '0.8em', lineHeight: '1.2em', color: 'yellow', fontWeight: '700' }}>
<Circle sx={{ height: "10px", width: "10px" }} />&nbsp; Proposal active
</span>
}
{proposal.state === 'Active' && proposal.hasVoted &&
{proposal.state === 'Active' && hasVoted &&
<span style={{ fontSize: '0.8em', lineHeight: '1.2em', color: 'green', fontWeight: '700' }}>
<Circle sx={{ height: "10px", width: "10px" }} />&nbsp; Vote recorded: thank you
</span>
Expand Down Expand Up @@ -209,21 +208,21 @@ function Proposal({
gap: '20px'
}}
>
{proposal.state === 'Active' && !proposal.hasVoted &&
{proposal.state === 'Active' && !hasVoted &&
<Button
type="primary"
variant="outlined"
onClick={(e) => { updateVote(proposal.id, 1, 'Cast Vote For') }}
>Vote For</Button>
}
{proposal.state === 'Active' && !proposal.hasVoted &&
{proposal.state === 'Active' && !hasVoted &&
<Button
type="primary"
variant="outlined"
onClick={(e) => { updateVote(proposal.id, 0, 'Cast Vote Against') }}
>Vote Against</Button>
}
{proposal.state === 'Active' && !proposal.hasVoted &&
{proposal.state === 'Active' && !hasVoted &&
<Button
type="outline"
variant="outlined"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function ProposalList() {
// const startingIndex = page === 1 ? 0 : ((page - 1) * PER_PAGE)
// const endingIndex = page * PER_PAGE
// const paginatedProposals = orderedProposals.slice(startingIndex, endingIndex)
const paginatedProposals = orderedProposals;
const paginatedProposals = orderedProposals

let totalNumberOfPages = Math.ceil(orderedProposals.length / PER_PAGE)
if (totalNumberOfPages === 0) totalNumberOfPages = 1
Expand Down
21 changes: 9 additions & 12 deletions packages/boba/gateway/src/containers/ecosystem/project.list.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ import OolongswapLogo from '../../images/ecosystem/Oolongswap.webp'
import safepalLogo from '../../images/ecosystem/safepal.webp'
import satisLogo from '../../images/ecosystem/satis.webp'
import shibuiDAOLogo from '../../images/ecosystem/shibuidao.svg'
import swapperChanLogo from '../../images/ecosystem/swapperChan.webp'
import synLogo from '../../images/ecosystem/syn.webp'
import thetanutsLogo from '../../images/ecosystem/thetanuts.webp'
import tofuNftLogo from '../../images/ecosystem/tofuNft.webp'
import umaprotocolLogo from '../../images/ecosystem/umaprotocol.webp'
import unidexLogo from '../../images/ecosystem/unidex.webp'
import witnetLogo from '../../images/ecosystem/witnet.svg'
import zenchaLogo from '../../images/ecosystem/zencha.webp'
import multiSigLogo from '../../images/ecosystem/multiSig.svg'

/**
* thematical order of type.
Expand Down Expand Up @@ -89,17 +89,6 @@ export const projectList = [
"image": synLogo,
"description": "The most widely used cross-chain liquidity network connecting all blockchains"
},
{
"title": "SwapperChan",
"canLaunch": true,
"link": "https://swapperchan.com/swap",
"telegram": "https://t.me/swapperchan",
"twitter": "https://twitter.com/SwapperChan",
"discord": "https://discord.com/invite/u6V3g5gdpV",
"type": "defi",
"image": swapperChanLogo,
"description": "Decentralized Trading Platform"
},
{
"title": "Zencha",
"canLaunch": true,
Expand Down Expand Up @@ -225,6 +214,14 @@ export const projectList = [
"image": bandProtocolLogo,
"description": "Secure, scalable cross-chain decentralized "
},
{
"title": "Boba MultiSig",
"canLaunch": true,
"link": "https://multisig.boba.network/",
"type": "wallet",
"image": multiSigLogo,
"description": "The most trusted platform to manage digital assets on Ethereum"
},
{
"title": "MEW",
"canLaunch": true,
Expand Down
26 changes: 26 additions & 0 deletions packages/boba/gateway/src/images/ecosystem/multiSig.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
37 changes: 37 additions & 0 deletions packages/boba/gateway/src/services/graphQLService.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
const apollo = require('@apollo/client')
const fetch = require('cross-fetch')

require('dotenv').config()

class GraphQLService {

getBridgeEndpoint = () => {
return `https://graph.${process.env.REACT_APP_CHAIN ?? 'rinkeby'}.boba.network/subgraphs/name/boba/Bridges`
}

async queryBridgeProposalCreated() {

const query = apollo.gql(`query { governorProposalCreateds { proposalId values description proposer } }`)

/*
curl -g -X POST \
-H "Content-Type: application/json" \
-d '{"query":"{ governorProposalCreateds {proposalId values description proposer}}"}' \
https://graph.rinkeby.boba.network/subgraphs/name/boba/Bridges
*/

const client = new apollo.ApolloClient({
uri: this.getBridgeEndpoint(),
link: new apollo.HttpLink({
uri: this.getBridgeEndpoint(),
fetch
}),
cache: new apollo.InMemoryCache()
})

return await client.query({ query })
}
}

const graphQLService = new GraphQLService()
export default graphQLService
38 changes: 22 additions & 16 deletions packages/boba/gateway/src/services/networkService.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ import etherScanInstance from 'api/etherScanAxios'
import omgxWatcherAxiosInstance from 'api/omgxWatcherAxios'
import coinGeckoAxiosInstance from 'api/coinGeckoAxios'
import verifierWatcherAxiosInstance from 'api/verifierWatcherAxios'

import { sortRawTokens } from 'util/common'
import GraphQLService from "./graphQLService"

import addresses_Rinkeby from "@boba/register/addresses/addressesRinkeby_0x93A96D6A5beb1F661cf052722A1424CDDA3e9418"
//import addresses_Local from "@boba/register/addresses/addressesLocal_0x93A96D6A5beb1F661cf052722A1424CDDA3e9418"
Expand Down Expand Up @@ -151,7 +153,7 @@ class NetworkService {
this.networkName = null

// gas
this.L1GasLimit = 9999999
this.L1GasLimit = 9999999
// setting of this value not important since it's not connected to anything in the contracts
// "param _l1Gas Unused, but included for potential forward compatibility considerations"
this.L2GasLimit = 1300000 //use the same as the hardcoded receive
Expand Down Expand Up @@ -576,7 +578,7 @@ class NetworkService {
'L2': L2a
}
}
}
}
else if(key === 'WAGMIv0') {
allTokens[key] = {
'L1': 'WAGMIv0',
Expand Down Expand Up @@ -616,7 +618,7 @@ class NetworkService {
if (!(await this.getAddressCached(addresses, 'BobaMonsters', 'BobaMonsters'))) return

if (!(await this.getAddressCached(addresses, 'Proxy__L1LiquidityPool', 'L1LPAddress'))) return
if (!(await this.getAddressCached(addresses, 'Proxy__L2LiquidityPool', 'L2LPAddress'))) return
if (!(await this.getAddressCached(addresses, 'Proxy__L2LiquidityPool', 'L2LPAddress'))) return

if(allAddresses.L2StandardBridgeAddress !== null) {
this.L2StandardBridgeContract = new ethers.Contract(
Expand Down Expand Up @@ -1371,6 +1373,10 @@ class NetworkService {

try {

// get current WAGMI_v0 balance

// settle(uint256 longTokensToRedeem, uint256 shortTokensToRedeem)
// https://github.com/UMAprotocol/protocol/blob/master/packages/core/contracts/financial-templates/long-short-pair/LongShortPair.sol
const contractLSP = new ethers.Contract(
'0x7F969E3F19355C47f6bc957E502c79C75b373BF3',
WAGMIv0Json.abi,
Expand All @@ -1382,7 +1388,7 @@ class NetworkService {
L1ERC20Json.abi,
this.L2Provider
)

const balance = await contractWAGMIv0.connect(this.provider).balanceOf(this.account)
console.log("You have WAGMIv0:", balance.toString())

Expand Down Expand Up @@ -1413,6 +1419,10 @@ class NetworkService {

try {

// get current WAGMI_v0 balance

// settle(uint256 longTokensToRedeem, uint256 shortTokensToRedeem)
// https://github.com/UMAprotocol/protocol/blob/master/packages/core/contracts/financial-templates/long-short-pair/LongShortPair.sol
const contractLSP = new ethers.Contract(
//need to update this address
'0x9153ACD675F04Fe16B7df72577F6553526879A6e',
Expand All @@ -1425,7 +1435,7 @@ class NetworkService {
L1ERC20Json.abi,
this.L2Provider
)

const balance = await contractWAGMIv1.connect(this.provider).balanceOf(this.account)
console.log("You have WAGMIv1:", balance.toString())

Expand Down Expand Up @@ -3254,23 +3264,19 @@ class NetworkService {
/// @notice An event emitted when a new proposal is created
// event ProposalCreated(uint id, address proposer, address[] targets, uint[] values, string[] signatures, bytes[] calldatas, uint startTimestamp, uint endTimestamp, string description);

const filter = delegateCheck.filters.ProposalCreated(
null, null, null, null, null,
null, null, null, null
)

// temporary fix to avoid eth_getLogs(zero, latest)
const descriptionList = await delegateCheck.queryFilter(filter, -4000)
let descriptionList = await GraphQLService.queryBridgeProposalCreated()

for (let i = 0; i < totalProposals; i++) {

if(typeof(descriptionList[i]) === 'undefined') continue
const proposalRaw = descriptionList.data.governorProposalCreateds[i]

let proposalID = descriptionList[i].args[0]
if(typeof(proposalRaw) === 'undefined') continue

let proposalID = proposalRaw.proposalId

//this is a number such as 2
let proposalData = await delegateCheck.proposals(proposalID)

const proposalStates = [
'Pending',
'Active',
Expand Down Expand Up @@ -3300,7 +3306,7 @@ class NetworkService {
hasVoted = await delegateCheck.getReceipt(proposalID, this.account)
}

let description = descriptionList[i].args[8].toString()
let description = proposalRaw.description.toString()

proposalList.push({
id: proposalID.toString(),
Expand Down
6 changes: 3 additions & 3 deletions packages/boba/subgraph/L1/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"deploy:subgraph:mainnet": "graph deploy --studio boba-network-mainnet"
},
"devDependencies": {
"@graphprotocol/graph-cli": "^0.20.1",
"@graphprotocol/graph-ts": "^0.20.0"
"@graphprotocol/graph-cli": "^0.29.0",
"@graphprotocol/graph-ts": "^0.26.0"
},
"dependencies": {
"@openzeppelin/contracts": "3.4.1",
Expand All @@ -22,4 +22,4 @@
"truffle-contract": "^4.0.5",
"truffle-hdwallet-provider": "^1.0.4"
}
}
}
Loading

0 comments on commit 0bedbb8

Please sign in to comment.