Skip to content

Commit 786d6d2

Browse files
committed
2 parents b60dbd8 + 394f7e6 commit 786d6d2

13 files changed

Lines changed: 252 additions & 23 deletions

File tree

.browserslistrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
> 3% in VN
2+
> 3% in ID
3+
last 3 major versions
4+
not dead

.eslintrc.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
module.exports = {
2+
//lintOnSave: process.env.NODE_ENV !== 'production',
3+
root: true,
4+
env: {
5+
'node': true
6+
},
7+
extends: [
8+
'plugin:vue/essential',
9+
'eslint:recommended'
10+
],
11+
parserOptions: {
12+
'parser': 'babel-eslint'
13+
},
14+
rules: {
15+
'no-unused-vars': 1,
16+
'no-debugger': 1,
17+
'no-constant-condition': 1,
18+
'vue/no-unused-components': 1,
19+
}
20+
}

.github/workflows/tests.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Tests
2+
3+
on: push
4+
5+
jobs:
6+
test:
7+
name: Pass tests and build
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Load node v15
11+
uses: actions/setup-node@v1
12+
with:
13+
node-version: '15'
14+
- name: Checkout
15+
uses: actions/checkout@v2
16+
- name: Install deps
17+
run: yarn install
18+
# Basics: test & build
19+
- name: Run tests
20+
run: yarn test
21+
- name: Build app
22+
run: yarn build
23+
# Keep an eye on bundle size
24+
- name: (bundlemon) run
25+
run: yarn bundlemon
26+
env:
27+
BUNDLEMON_PROJECT_ID: ${{ secrets.BUNDLEMON_PROJECT_ID }}
28+
BUNDLEMON_PROJECT_APIKEY: ${{ secrets.BUNDLEMON_PROJECT_APIKEY }}
29+
BUNDLEMON_GITHUB_TOKEN: ${{ secrets.BUNDLEMON_GITHUB_TOKEN }}

babel.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
presets: [
3+
'@vue/cli-plugin-babel/preset'
4+
]
5+
}

bundlemon.config.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
module.exports = {
2+
baseDir: './dist',
3+
reportOutput: [
4+
[
5+
'github-pr',
6+
{
7+
statusCheck: true,
8+
prComment: true,
9+
}
10+
]
11+
],
12+
files: [
13+
{
14+
path: 'js/app.<hash>.js',
15+
maxPercentIncrease: 40,
16+
maxSize: '50kb',
17+
},
18+
{
19+
path: 'js/chunk-vendors.<hash>.js',
20+
maxPercentIncrease: 40,
21+
maxSize: '1000kb',
22+
},
23+
{
24+
path: 'css/app.<hash>.css',
25+
maxPercentIncrease: 40,
26+
maxSize: '300kb',
27+
},
28+
]
29+
}

package.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@
44
"private": true,
55
"scripts": {
66
"dev": "vue-cli-service serve",
7-
"build": "vue-cli-service build"
7+
"build": "vue-cli-service build",
8+
"test": "vue-cli-service lint"
89
},
910
"dependencies": {
11+
"anylogger": "^1.0.11",
1012
"buefy": "^0.9.7",
1113
"core-js": "^3.6.5",
1214
"ethers": "^5.1.4",
15+
"ulog": "^2.0.0-beta.18",
1316
"vue": "^2.6.12",
1417
"vue-router": "^3.5.1",
1518
"vuex": "^3.6.2",
@@ -20,7 +23,12 @@
2023
},
2124
"devDependencies": {
2225
"@vue/cli-plugin-babel": "~4.5.0",
26+
"@vue/cli-plugin-eslint": "~4.5.0",
2327
"@vue/cli-service": "~4.5.0",
28+
"babel-eslint": "^10.1.0",
29+
"bundlemon": "^0.3.2",
30+
"eslint": "^6.7.2",
31+
"eslint-plugin-vue": "^6.2.2",
2432
"sass": "^1.32.11",
2533
"sass-loader": "^8.0.2",
2634
"vue-template-compiler": "^2.6.12"

src/App.vue

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
<template>
22
<div>
33
<NavBar/>
4-
<router-view class="app-router-view m-3" />
4+
<router-view class="app-router-view m-3"/>
5+
<UxModal ref="uxModal"/>
56
</div>
67
</template>
78
<script>
89
import NavBar from './components/NavBar'
910
import router from './plugins/Router'
11+
import UxModal from './components/organisms/UxModal'
12+
import UxEvents from './modules/UxEvents'
1013
1114
export default {
1215
router,
13-
components: { NavBar },
16+
components: { UxModal, NavBar },
17+
created () {
18+
UxEvents.setUiApp(this)
19+
},
1420
mounted () {
1521
this.$router.replace('/')
1622
}

src/components/molecules/WalletDetails.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ export default {
5151
computed: {
5252
isConnected () {
5353
this.updateProviderInfo()
54-
this.canConnect = this.$wallet.getState() === WalletState.IDLE
54+
this.$nextTick(() => {
55+
// temporary workaround for vue/no-side-effects-in-computed-properties
56+
this.canConnect = this.$wallet.getState() === WalletState.IDLE
57+
})
5558
return this.$wallet.isConnected()
5659
},
5760
account () { return this.$wallet.getAccount() },
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<template>
2+
<div class="uxmodal-container">
3+
<b-modal v-model="isVisible" :width="width">
4+
<div class="card">
5+
<div class="card-content">
6+
<div class="title is-4" :class="titleClass">{{ title }}</div>
7+
<div class="content" v-html="content"></div>
8+
</div>
9+
</div>
10+
</b-modal>
11+
</div>
12+
</template>
13+
14+
<script>
15+
export default {
16+
name: 'UxModal',
17+
data () {
18+
return {
19+
isVisible: false,
20+
title: '',
21+
titleClass: '',
22+
content: '',
23+
width: 400,
24+
}
25+
},
26+
methods: {
27+
setupModal (options) {
28+
// set modal data from options as is
29+
Object.keys(options).forEach((k) => {
30+
this.$set(this.$data, k, options[k])
31+
})
32+
return this
33+
},
34+
// toggle modal to foreground
35+
show () {
36+
this.isVisible = true
37+
},
38+
// toggle modal back to background
39+
hide () {
40+
this.isVisible = false
41+
},
42+
}
43+
}
44+
</script>
45+
46+
<style scoped>
47+
48+
</style>

src/modules/UxEvents.js

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import { chains } from './EthChains'
2+
3+
export const UxEventCategory = {
4+
ETH_WRONG_CHAIN: 'ethWrongChain'
5+
}
6+
7+
class UxEvents {
8+
9+
uiApp
10+
11+
setUiApp (appInstance) {
12+
this.uiApp = appInstance
13+
}
14+
15+
getModalProvider () {
16+
return this.uiApp.$refs.uxModal
17+
}
18+
19+
raise (eventCategory, payload) {
20+
switch (eventCategory) {
21+
22+
case UxEventCategory.ETH_WRONG_CHAIN: {
23+
// compose error message
24+
let content = [
25+
'Please connect to the appropriate Ethereum network. Allowed networks:'
26+
]
27+
// populate with allowed networks for reference
28+
content = content.concat(chains.reduce((list, chain) => {
29+
if (chain.allowed) {
30+
list.push('<span><b>' + chain.chainId + '</b>&nbsp;' + chain.label + '</span>')
31+
}
32+
return list
33+
}, []))
34+
// if wrong network id provided - show it too
35+
if (payload) {
36+
content.push('Trying to connect: <b class="has-text-danger">' + payload + '</b>')
37+
}
38+
// run the modal
39+
let options = {
40+
title: 'Wrong network',
41+
titleClass: 'has-text-danger',
42+
content: content.join('<br/>')
43+
}
44+
this.getModalProvider().setupModal(options).show()
45+
break
46+
}
47+
default:
48+
break
49+
}
50+
}
51+
52+
}
53+
54+
export default new UxEvents()

0 commit comments

Comments
 (0)