-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make multiTx modal, limit to 20 actions / transactions
- Loading branch information
Showing
6 changed files
with
198 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<template> | ||
<div v-if="visible && current === 'MultiTx'" class="modal-container multitx"> | ||
<div class="modal-layerclose" @click="close"></div> | ||
<div class="modal-content"> | ||
<div class="modal-xmark neon-button"><fa-icon @click="close" :icon="['fas','xmark']" /></div> | ||
<h2>Sign transactions</h2> | ||
<p>Please sign several transactions</p> | ||
<ul> | ||
<li @click="sendTx(i)" v-for="(acts, i) in actions"> | ||
<span>Transaction {{ i + 1 }}</span> | ||
<div v-if="results[i] === 'loading'"><ClipLoader color="#ff00ec"/></div> | ||
<div v-else-if="results[i] === 'sent'"><fa-icon :icon="['fas','check']" /></div> | ||
<button v-else class="neon-button">Sign</button> | ||
</li> | ||
</ul> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import { mapState, mapActions } from 'vuex' | ||
import ClipLoader from 'vue-spinner/src/ClipLoader.vue' | ||
export default { | ||
components: { | ||
ClipLoader | ||
}, | ||
computed: { | ||
...mapState('modal', ['current', 'visible']), | ||
...mapState('MultiTx', ['actions', 'results']), | ||
}, | ||
mounted() { | ||
}, | ||
methods: { | ||
close() { | ||
this.$store.dispatch('modal/closeModal') | ||
}, | ||
...mapActions('MultiTx', ['sendTx']) | ||
} | ||
} | ||
</script> | ||
<style scoped> | ||
.modal-content ul { | ||
margin-top: 1em; | ||
} | ||
.modal-content ul li { | ||
display: flex; | ||
justify-content: space-around; | ||
align-items: center; | ||
margin-bottom: 0.5em; | ||
} | ||
.modal-content ul li div { | ||
width: 52px; | ||
height: 42px; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
} | ||
.modal-content ul li .svg-inline--fa { | ||
color: #ff00ec; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,22 @@ | ||
<template> | ||
<div> | ||
<LoginModal /> | ||
<MultiTxModal /> | ||
<LPdistrib/> | ||
<notifications position="bottom right" classes="neonnotifications"/> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import LoginModal from '~/components/modals/Login.vue' | ||
import MultiTxModal from '~/components/modals/MultiTx.vue' | ||
export default { | ||
name: 'IndexPage', | ||
layout: 'default', | ||
components: { | ||
LoginModal | ||
LoginModal, | ||
MultiTxModal | ||
}, | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
export const state = () => ({ | ||
actions: [], // array of array of actions | ||
results: [], // array of tx state | ||
}) | ||
|
||
export const mutations = { | ||
setActions: (state, actions) => state.actions = actions, | ||
setResults: (state, results) => state.results = results, | ||
} | ||
|
||
export const actions = { | ||
async sendTx({commit, dispatch, state}, i) { | ||
dispatch('chain/sendTransaction', | ||
{ | ||
updateRoute: 'MultiTx/TxSent', | ||
updateFailedRoute: 'MultiTx/TxFailed', | ||
updateDelay: 500, | ||
updateParam: i, | ||
actions: state.actions[i] | ||
}, | ||
{root: true} | ||
) | ||
|
||
let results = state.results.slice() | ||
results[i] = 'loading' | ||
commit('setResults', results) | ||
}, | ||
async TxSent({commit, state}, {updateParam}) { | ||
let results = state.results.slice() | ||
results[updateParam] = 'sent' | ||
commit('setResults', results) | ||
}, | ||
async TxFailed({commit, state}, {updateParam}) { | ||
let results = state.results.slice() | ||
results[updateParam] = 'ready' | ||
commit('setResults', results) | ||
}, | ||
initModal({commit, dispatch}, actions) { | ||
const maxTx = 20 | ||
|
||
let commitActions = []; | ||
let commitResults = []; | ||
commit('setActions', commitActions) | ||
commit('setResults', commitResults) | ||
for (let i = 0; i < actions.length; i += maxTx) { | ||
commitActions.push(actions.slice(i, i + maxTx)) | ||
commitResults.push('ready') | ||
} | ||
commit('setActions', commitActions) | ||
commit('setResults', commitResults) | ||
|
||
dispatch('modal/open', 'MultiTx', {root: true}) | ||
} | ||
} | ||
|
||
export const getters = { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters