mirror of
https://github.com/seigler/dash-platform-console
synced 2025-07-28 18:16:10 +00:00
Merge with master
This commit is contained in:
parent
3f8ecf0b08
commit
6c1dccdeb4
4 changed files with 539 additions and 11 deletions
|
@ -1,9 +1,15 @@
|
|||
import Vue from 'vue';
|
||||
import Vuex from 'vuex';
|
||||
import createPersistedState from 'vuex-persistedstate';
|
||||
import DashDemoSDK from 'evo-net-demo';
|
||||
|
||||
Vue.use(Vuex);
|
||||
|
||||
const demoSDK = new DashDemoSDK();
|
||||
const seeds = [
|
||||
{ service: '18.236.131.253' },
|
||||
];
|
||||
|
||||
export const identityTypes = {
|
||||
application: {
|
||||
name: 'application',
|
||||
|
@ -17,6 +23,10 @@ export const identityTypes = {
|
|||
|
||||
export default new Vuex.Store({
|
||||
state: {
|
||||
isSyncing: true,
|
||||
mnemonic: 'final vocal warm mansion person awesome sell spend solar tobacco gain canoe',
|
||||
errorDetails: null,
|
||||
isError: false,
|
||||
identities: {
|
||||
user: [],
|
||||
application: [],
|
||||
|
@ -47,13 +57,31 @@ export default new Vuex.Store({
|
|||
[id]: contract,
|
||||
};
|
||||
},
|
||||
changeMnemonic(state, mnemonic) {
|
||||
state.mnemonic = mnemonic;
|
||||
},
|
||||
setSyncing(state, syncStatus) {
|
||||
state.isSyncing = syncStatus;
|
||||
},
|
||||
setError(state, error) {
|
||||
state.errorDetails = error;
|
||||
state.isError = true;
|
||||
},
|
||||
clearError(state) {
|
||||
state.errorDetails = null;
|
||||
state.isError = false;
|
||||
},
|
||||
reset(state) {
|
||||
state.errorDetails = null;
|
||||
state.isError = false;
|
||||
state.isSyncing = true;
|
||||
},
|
||||
},
|
||||
actions: {
|
||||
async createIdentity({ commit }, type) {
|
||||
const identity = await new Promise((resolve) => {
|
||||
setTimeout(() => resolve({ id: `t_${type.name}_id_${Date.now()}`, type }), 2000);
|
||||
});
|
||||
commit('addIdentity', { identity, type });
|
||||
const identityId = await demoSDK.registerIdentity(type);
|
||||
const identity = await demoSDK.getIdentityFromNetwork(identityId);
|
||||
commit('addIdentity', { identity, type: identity.getType() });
|
||||
},
|
||||
async registerName({ commit }, { identity, name }) {
|
||||
await new Promise((resolve) => {
|
||||
|
@ -67,6 +95,29 @@ export default new Vuex.Store({
|
|||
});
|
||||
commit('addContract', { identity, contract });
|
||||
},
|
||||
async initWallet({ commit }) {
|
||||
commit('reset', true);
|
||||
const { mnemonic } = this.state;
|
||||
|
||||
console.debug('Start wallet sync...');
|
||||
|
||||
try {
|
||||
await demoSDK.init({ mnemonic, seeds });
|
||||
} catch (e) {
|
||||
console.debug('Wallet synchronized with an error:');
|
||||
console.error(e);
|
||||
commit('setError', e);
|
||||
commit('setSyncing', false);
|
||||
return;
|
||||
}
|
||||
|
||||
console.debug('Wallet is synchronized');
|
||||
|
||||
commit('setSyncing', false);
|
||||
demoSDK.listIdentities().forEach((identity) => {
|
||||
commit('addIdentity', { identity, type: identity.getType() });
|
||||
});
|
||||
},
|
||||
},
|
||||
getters: {
|
||||
identityLists(state) {
|
||||
|
|
|
@ -1,5 +1,28 @@
|
|||
<template>
|
||||
<v-container>
|
||||
|
||||
<v-row>
|
||||
<v-card>
|
||||
<v-card-title>
|
||||
Error occurred
|
||||
</v-card-title>
|
||||
<v-card-text>
|
||||
Text is here
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
</v-row>
|
||||
|
||||
<v-row>
|
||||
<v-card>
|
||||
<v-card-title>
|
||||
Wallet is syncing
|
||||
</v-card-title>
|
||||
<v-card-text>
|
||||
This usually takes from 10 seconds to 1 minute on fast internet
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
</v-row>
|
||||
|
||||
<v-row>
|
||||
<v-col
|
||||
v-for="list in identityLists"
|
||||
|
@ -50,7 +73,7 @@ export default {
|
|||
};
|
||||
},
|
||||
computed: {
|
||||
...mapGetters(['identityLists']),
|
||||
...mapGetters(['identityLists', 'identities', 'isSyncing', 'errorDetails', 'isError']),
|
||||
},
|
||||
methods: {
|
||||
createIdentity(type) {
|
||||
|
@ -60,6 +83,9 @@ export default {
|
|||
});
|
||||
},
|
||||
},
|
||||
created() {
|
||||
this.$store.dispatch('initWallet');
|
||||
},
|
||||
|
||||
};
|
||||
</script>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue