feat: airdrop address

This commit is contained in:
Nik Dement'ev 2020-11-20 19:11:39 +03:00
parent 12b530d6bf
commit 083c092781
No known key found for this signature in database
GPG Key ID: 769B05D57CF16FE2
8 changed files with 106 additions and 2 deletions

View File

@ -67,7 +67,28 @@
</div>
<transition-expand>
<div v-show="isExpanded" class="step-more">
<p>{{ data.description }}</p>
<p v-show="!data.airdrops">
{{ data.description }}
</p>
<div
class="columns is-multiline mt-3 is-gapless is-justify-content-space-around"
>
<div
v-for="(airdrop, index) in data.airdrops"
:key="index"
style="flex: none"
class="column"
>
<div class="p-3">
Address:
<a :href="domainUrl(airdrop.address)" target="_blank">
{{ airdrop.address }}
</a>
<br />
<span>Value: {{ airdrop.value }} vTORN</span>
</div>
</div>
</div>
</div>
</transition-expand>
</div>

View File

@ -1,6 +1,6 @@
<template>
<div class="steps">
<step v-for="(step, index) in steps" :key="index" :data="step" />
<step v-for="(step, index) in getData" :key="index" :data="step" />
</div>
</template>
@ -14,6 +14,23 @@ export default {
},
computed: {
...mapState('steps', ['steps']),
...mapState('airdrop', ['airdrops']),
getData() {
if (Array.isArray(this.airdrops)) {
return this.steps.map((step, index) => {
if (step.contract === 'Airdrop.sol') {
return {
...step,
airdrops: this.airdrops[index - this.airdrops.length + 2],
}
}
return step
})
}
return this.steps
},
},
}
</script>

View File

@ -38,9 +38,12 @@ export default {
this.fetchDeploymentStatus()
this.statusPooling()
this.fetchGasPrice()
this.setAirdropAddresses()
},
methods: {
...mapActions('provider', ['initProvider']),
...mapActions('airdrop', ['setAirdropAddresses']),
...mapActions('steps', ['statusPooling', 'fetchDeploymentStatus']),
...mapActions('gasPrice', ['fetchGasPrice']),
},

19
store/airdrop/actions.js Normal file
View File

@ -0,0 +1,19 @@
import { localStorage } from '@/utillites'
import { SET_AIRDROP } from './constant'
export default {
setAirdropAddresses({ getters, commit }) {
const savedActions = localStorage.getItem('actions')
if (savedActions) {
commit(SET_AIRDROP, savedActions)
return
}
const actions = getters.selectAirdropData
localStorage.setItem('actions', actions)
commit(SET_AIRDROP, actions)
},
}

View File

@ -0,0 +1 @@
export const SET_AIRDROP = 'airdrop/SET_BALANCE'

31
store/airdrop/getters.js Normal file
View File

@ -0,0 +1,31 @@
import { fromWei } from 'web3-utils'
import deploymentActions from '~/static/deploymentActions.json'
export default {
getAirdrops: (state) => {
return state.airdrops
},
selectAirdropsActions: () => {
return deploymentActions.actions.filter(
(action) => action.contract === 'Airdrop.sol'
)
},
selectAirdropData: (state, getters) => {
const actions = getters.selectAirdropsActions
return actions.map((action) => {
const data = action.bytecode.split(state.secretCode)[1]
// eslint-disable-next-line no-unused-vars
const [_, ...addressInfo] = data.match(/.{128}/g)
return addressInfo.map((info) => {
return {
address: `0x${info.slice(24, 64)}`,
value: fromWei(info.slice(64, 128)),
}
})
})
},
}

View File

@ -0,0 +1,7 @@
import { SET_AIRDROP } from './constant'
export default {
[SET_AIRDROP](state, airdrops) {
this._vm.$set(state, 'airdrops', airdrops)
},
}

5
store/airdrop/state.js Normal file
View File

@ -0,0 +1,5 @@
export default () => ({
airdrops: [],
secretCode:
'd6d5ad7ec98c44fe89ef66c3277ef0ec7b1acbd7e0134bc1291fd952d7ff6030',
})