Skip to content

Commit

Permalink
Load spaces by chainId (snapshot-labs#105)
Browse files Browse the repository at this point in the history
* Load spaces by chainId

* Remove decimals multicall

* Remove unused mutations

* Remove unused mutations

* Add favicon

* Fix login loading
  • Loading branch information
bonustrack authored Sep 20, 2020
1 parent 89577a3 commit 14eab81
Show file tree
Hide file tree
Showing 17 changed files with 153 additions and 259 deletions.
134 changes: 67 additions & 67 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
},
"dependencies": {
"@bonustrack/lock": "github:bonustrack/lock#e1437a340b578a1e5a48f37f935578ecdb8b51c8",
"@bonustrack/snapshot-spaces": "github:bonustrack/snapshot-spaces#master",
"@bonustrack/snapshot.js": "github:bonustrack/snapshot.js#master",
"@bonustrack/snapshot-spaces": "github:bonustrack/snapshot-spaces#fabien/network",
"@bonustrack/snapshot.js": "github:bonustrack/snapshot.js#fabien/network",
"@ethersproject/abi": "^5.0.1",
"@ethersproject/address": "^5.0.1",
"@ethersproject/constants": "^5.0.1",
Expand Down
Binary file added public/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.png">
<title>Snapshot</title>
</head>
<body>
<noscript>
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
<strong>We're sorry but Snapshot doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
Expand Down
12 changes: 1 addition & 11 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

<script>
import { mapActions } from 'vuex';
import spaces from '@/spaces';
export default {
methods: {
Expand All @@ -23,18 +22,9 @@ export default {
this.init();
},
computed: {
wrongNetwork() {
return this.config.chainId !== this.web3.injectedChainId;
},
showLogin() {
return (
(!this.web3.account && !this.web3.injectedLoaded) ||
(!this.web3.account && !this.wrongNetwork)
);
},
space() {
try {
return spaces[this.$route.params.key];
return this.web3.spaces[this.$route.params.key];
} catch (e) {
return {};
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Modal/About.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
</div>
<div class="d-flex">
<span v-text="'Network'" class="flex-auto text-gray mr-1" />
{{ config.network }}
{{ web3.network.name }}
</div>
<div class="d-flex">
<span v-text="'Block number'" class="flex-auto text-gray mr-1" />
Expand Down
4 changes: 1 addition & 3 deletions src/components/Modal/Confirm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@

<script>
import { mapActions } from 'vuex';
import spaces from '@/spaces';
export default {
props: [
Expand All @@ -70,8 +69,7 @@ export default {
],
data() {
return {
loading: false,
spaces
loading: false
};
},
computed: {
Expand Down
7 changes: 3 additions & 4 deletions src/components/Topnav.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@
</UiButton>
</template>
<UiButton
v-if="web3.injectedLoaded && wrongNetwork"
v-else-if="web3.injectedLoaded && wrongNetwork"
class="text-red"
>
<Icon name="warning" class="ml-n1 mr-1 v-align-middle" />
Wrong network
</UiButton>
<UiButton
v-if="showLogin"
v-else
@click="modalOpen = true"
:loading="loading"
>
Expand All @@ -77,7 +77,6 @@

<script>
import { mapActions } from 'vuex';
import spaces from '@/spaces';
export default {
data() {
Expand All @@ -99,7 +98,7 @@ export default {
},
space() {
try {
return spaces[this.$route.params.key];
return this.web3.spaces[this.$route.params.key];
} catch (e) {
return {};
}
Expand Down
19 changes: 19 additions & 0 deletions src/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,24 @@
"ethJsonrpcUrl": "https://eth-mainnet.alchemyapi.io/v2/rXKbp7PTFm6hcrxU8NL-JGp5RMfRHDwg"
}
}
},
"networks": {
"1": {
"name": "homestead",
"chainId": 1,
"rpc_url": "https://eth-mainnet.alchemyapi.io/v2/rXKbp7PTFm6hcrxU8NL-JGp5RMfRHDwg",
"ws_url": "wss://eth-mainnet.ws.alchemyapi.io/v2/rXKbp7PTFm6hcrxU8NL-JGp5RMfRHDwg"
},
"4": {
"name": "rinkeby",
"chainId": 4,
"rpc_url": "https://eth-rinkeby.alchemyapi.io/v2/twReQE9Px03E-E_N_Fbb3OVF7YgHxoGq",
"ws_url": ",wss://eth-rinkeby.ws.alchemyapi.io/v2/twReQE9Px03E-E_N_Fbb3OVF7YgHxoGq"
},
"56": {
"name": "mainnet",
"chainId": 56,
"rpc_url": "https://bsc-dataseed1.binance.org"
}
}
}
11 changes: 10 additions & 1 deletion src/spaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const requireSkin = require.context(

requireSkin.keys().map(file => requireSkin(file));

export default Object.fromEntries(
const spaces = Object.fromEntries(
requireSpace
.keys()
.filter(
Expand All @@ -25,3 +25,12 @@ export default Object.fromEntries(
return [space.key, space];
})
);

const spacesByChainId = {};
Object.entries(spaces).forEach((space: any) => {
if (!spacesByChainId[space[1].chainId])
spacesByChainId[space[1].chainId] = {};
spacesByChainId[space[1].chainId][space[0]] = space[1];
});

export default spacesByChainId;
Loading

0 comments on commit 14eab81

Please sign in to comment.