Skip to content
This repository has been archived by the owner on Sep 28, 2020. It is now read-only.

Commit

Permalink
Add develop env custom db
Browse files Browse the repository at this point in the history
  • Loading branch information
bonustrack committed Jul 23, 2020
1 parent a2db2ca commit be3eef1
Show file tree
Hide file tree
Showing 11 changed files with 108 additions and 29 deletions.
4 changes: 1 addition & 3 deletions .env
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
VUE_APP_NETWORK=homestead
VUE_APP_IPFS_NODE=gateway.pinata.cloud
VUE_APP_REST_API=https://beta.vote.balancer.finance
VUE_APP_INFURA_ID=c00cb7215b614b0282964cf1a9b117c0
VUE_APP_ALCHEMY_KEY=rXKbp7PTFm6hcrxU8NL-JGp5RMfRHDwg
PINATA_API_KEY=123...
PINATA_SECRET_API_KEY=123...
DATABASE_URL=redis://...
DATABASE_URL=redis://rediscloud:password@localhost:6379
RELAYER_PK=0x123...
2 changes: 1 addition & 1 deletion server/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ router.post('/message', async (req, res) => {

if (
!msg.payload.start ||
ts > msg.payload.start ||
// ts > msg.payload.start ||
!msg.payload.end ||
msg.payload.start >= msg.payload.end
) return sendError(res, 'wrong proposal period');
Expand Down
10 changes: 4 additions & 6 deletions src/components/Modal/About.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</div>
<div class="d-flex">
<span v-text="'Network'" class="flex-auto text-gray mr-1" />
{{ network === 'homestead' ? 'mainnet' : network }}
{{ config.network === 'homestead' ? 'mainnet' : config.network }}
</div>
<div class="d-flex">
<span v-text="'Block number'" class="flex-auto text-gray mr-1" />
Expand All @@ -30,8 +30,8 @@
{{ ipfsNode }}
</div>
<div class="d-flex">
<span v-text="'Matching API'" class="flex-auto text-gray mr-1" />
{{ api }}
<span v-text="'Hub'" class="flex-auto text-gray mr-1" />
{{ config.hubUrl }}
</div>
</div>
<div class="m-4">
Expand All @@ -58,9 +58,7 @@ export default {
data() {
return {
pkg,
network: process.env.VUE_APP_NETWORK,
ipfsNode: process.env.VUE_APP_IPFS_NODE,
api: process.env.VUE_APP_REST_API
ipfsNode: process.env.VUE_APP_IPFS_NODE
};
}
};
Expand Down
6 changes: 2 additions & 4 deletions src/components/Modal/Account.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<h3 class="m-4 mb-0 text-center">Connect wallet</h3>
<div class="m-4 mb-5">
<a
v-for="(connector, id, i) in connectors"
v-for="(connector, id, i) in config.connectors"
:key="i"
@click="$emit('login', connector.id)"
target="_blank"
Expand Down Expand Up @@ -56,14 +56,12 @@

<script>
import { mapActions } from 'vuex';
import config from '@/helpers/config';
export default {
props: ['open'],
data() {
return {
step: null,
connectors: config.connectors
step: null
};
},
watch: {
Expand Down
7 changes: 5 additions & 2 deletions src/components/Topnav.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@

<script>
import { mapActions } from 'vuex';
import config from '@/helpers/config';
import namespaces from '@/namespaces.json';
export default {
data() {
Expand All @@ -72,8 +72,11 @@ export default {
};
},
computed: {
namespace() {
return namespaces['balancer'];
},
wrongNetwork() {
return config.chainId !== this.web3.injectedChainId;
return this.config.chainId !== this.web3.injectedChainId;
},
showLogin() {
return (
Expand Down
46 changes: 38 additions & 8 deletions src/config.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"kovan": {
"network": "kovan",
"chainId": 42,
"subgraphUrl": "https://api.thegraph.com/subgraphs/name/bonustrack/balancer-kovan",
"multicall": "0x2cc8688C5f75E365aaEEb4ea8D6a480405A48D2A",
"master": {
"network": "homestead",
"chainId": 1,
"subgraphUrl": "https://api.thegraph.com/subgraphs/name/balancer-labs/balancer",
"hubUrl": "https://vote.balancer.finance",
"multicall": "0xeefBa1e63905eF1D7ACbA5a8513c70307C1cE441",
"connectors": {
"injected": {
"id": "injected",
Expand All @@ -21,15 +22,44 @@
"name": "Portis",
"options": {
"dappId": "3f1c3cfc-7dd5-4e8a-aa03-71ff7396d9fe",
"network": "kovan"
"network": "mainnet"
}
}
}
},
"develop": {
"network": "homestead",
"chainId": 1,
"subgraphUrl": "https://api.thegraph.com/subgraphs/name/balancer-labs/balancer",
"hubUrl": "https://beta.vote.balancer.finance",
"multicall": "0xeefBa1e63905eF1D7ACbA5a8513c70307C1cE441",
"connectors": {
"injected": {
"id": "injected",
"name": "MetaMask"
},
"walletconnect": {
"id": "walletconnect",
"name": "WalletConnect",
"options": {
"infuraId": "c00cb7215b614b0282964cf1a9b117c0"
}
},
"portis": {
"id": "portis",
"name": "Portis",
"options": {
"dappId": "3f1c3cfc-7dd5-4e8a-aa03-71ff7396d9fe",
"network": "mainnet"
}
}
}
},
"homestead": {
"local": {
"network": "homestead",
"chainId": 1,
"subgraphUrl": "https://api.thegraph.com/subgraphs/name/bonustrack/balancer",
"subgraphUrl": "https://api.thegraph.com/subgraphs/name/balancer-labs/balancer",
"hubUrl": "http://localhost:3000",
"multicall": "0xeefBa1e63905eF1D7ACbA5a8513c70307C1cE441",
"connectors": {
"injected": {
Expand Down
10 changes: 9 additions & 1 deletion src/helpers/client.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
let defaultRestApi = 'http://localhost:3000';
const domainName = window.location.hostname;
if (domainName === 'beta.vote.balancer.finance')
defaultRestApi = 'https://beta.vote.balancer.finance';
if (domainName === 'vote.balancer.finance')
defaultRestApi = 'https://vote.balancer.finance';
const restApi = process.env.VUE_APP_REST_API || defaultRestApi;

class Client {
request(command, body?) {
const url = `${process.env.VUE_APP_REST_API}/api/${command}`;
const url = `${restApi}/api/${command}`;
let init;
if (body) {
init = {
Expand Down
7 changes: 5 additions & 2 deletions src/helpers/config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import config from '@/config.json';

const networkId = process.env.VUE_APP_NETWORK || 'kovan';
let id = 'master';
const domainName = window.location.hostname;
if (domainName.includes('localhost:')) id = 'local';
if (domainName === 'beta.vote.balancer.finance') id = 'beta';

export default config[networkId];
export default config[id];
6 changes: 6 additions & 0 deletions src/mixins.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import { mapState } from 'vuex';
import numeral from 'numeral';
import store from '@/store';
import config from '@/helpers/config';
import { shorten, etherscanLink } from '@/helpers/utils';

// @ts-ignore
const modules = Object.entries(store.state).map(module => module[0]);

export default {
data() {
return {
config
};
},
computed: {
...mapState(modules)
},
Expand Down
7 changes: 5 additions & 2 deletions src/namespaces.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
"token": "0xba100000625a3754423978a60c9317c58a424e3D",
"verified": [
"0x24A12Fa313F57aF541d447c594072A992c605DCf",
"0x8BBE4Ac64246d600BC2889ef5d83809D138F03DF"
"0x8BBE4Ac64246d600BC2889ef5d83809D138F03DF",
"0xeF8305E140ac520225DAf050e2f71d5fBcC543e7",
"0x107174D70b33523E83711EA4C3F4229cdB8A7Cb1",
"0x0b21Dbc34A953a35dFA629ad31e1cEE3dE0433Fb"
],
"visible": true
},
Expand All @@ -20,6 +23,6 @@
"0x107174D70b33523E83711EA4C3F4229cdB8A7Cb1",
"0x0b21Dbc34A953a35dFA629ad31e1cEE3dE0433Fb"
],
"visible": true
"visible": false
}
}
32 changes: 32 additions & 0 deletions src/store/modules/gov.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import wsProvider from '@/helpers/ws';
import { formatProposal, formatProposals } from '@/helpers/utils';
import { version } from '@/../package.json';

const state = {
votingPower: 0
};

const mutations = {
SEND_REQUEST() {
console.debug('SEND_REQUEST');
Expand Down Expand Up @@ -45,6 +49,15 @@ const mutations = {
},
GET_VOTERS_BALANCES_FAILURE(_state, payload) {
console.debug('GET_VOTERS_BALANCES_FAILURE', payload);
},
GET_MY_VOTING_POWER_REQUEST() {
console.debug('GET_MY_VOTING_POWER_REQUEST');
},
GET_MY_VOTING_POWER_SUCCESS() {
console.debug('GET_MY_VOTING_POWER_SUCCESS');
},
GET_MY_VOTING_POWER_FAILURE(_state, payload) {
console.debug('GET_MY_VOTING_POWER_FAILURE', payload);
}
};

Expand Down Expand Up @@ -182,10 +195,29 @@ const actions = {
commit('GET_VOTERS_BALANCES_FAILURE', e);
return Promise.reject();
}
},
getMyVotingPower: async (
{ commit, dispatch, rootState },
{ snapshot, token }
) => {
commit('GET_MY_VOTING_POWER_REQUEST');
const address = rootState.web3.account;
try {
const myVotingPower = await dispatch('getVotingPowers', {
snapshot,
token,
addresses: [address]
});
commit('GET_MY_VOTING_POWER_SUCCESS');
return myVotingPower;
} catch (e) {
commit('GET_MY_VOTING_POWER_FAILURE', e);
}
}
};

export default {
state,
mutations,
actions
};

0 comments on commit be3eef1

Please sign in to comment.