made userDataStore
This commit is contained in:
@@ -10,6 +10,8 @@ class Store {
|
||||
|
||||
_nodeInfo = {}
|
||||
|
||||
_userData = {}
|
||||
|
||||
constructor() {
|
||||
makeAutoObservable(this);
|
||||
|
||||
@@ -18,15 +20,18 @@ class Store {
|
||||
reaction(() => this.tokenKey, () => fetchWrapper.getAuth('http://3.125.47.101/api/data/account', {
|
||||
networkIdentifier: this.nodeInfo.networkIdentifier,
|
||||
lastBlockID: this.nodeInfo.lastBlockID
|
||||
}))
|
||||
}).then((res) => this.userInfoFetchChange(res)))
|
||||
};
|
||||
|
||||
fetchCreateNewAccount() {
|
||||
fetchWrapper.postAuth('http://3.125.47.101/api/data/account', {
|
||||
networkIdentifier: this.nodeInfo.networkIdentifier,
|
||||
lastBlockID: this.nodeInfo.lastBlockID
|
||||
}, [...this.encryptAccountData])
|
||||
.catch(()=>{})
|
||||
}, [...this.encryptAccountData]).catch(()=>{})
|
||||
};
|
||||
|
||||
userInfoFetchChange(res) {
|
||||
this._userData = res;
|
||||
}
|
||||
|
||||
savePassPhrase(phrase) {
|
||||
@@ -51,6 +56,10 @@ class Store {
|
||||
console.log(err)
|
||||
}
|
||||
|
||||
get userData() {
|
||||
return this._userData;
|
||||
}
|
||||
|
||||
get passPhrase() {
|
||||
return 'rocket north inform swift improve fringe sweet crew client canyon bean autumn'
|
||||
}
|
||||
|
||||
24
src/store/userDataStore.js
Normal file
24
src/store/userDataStore.js
Normal file
@@ -0,0 +1,24 @@
|
||||
import { cryptography } from "@liskhq/lisk-client";
|
||||
import { makeAutoObservable, reaction } from "mobx";
|
||||
import { registrationStore } from './store';
|
||||
|
||||
class UserDataStore{
|
||||
_data = []
|
||||
|
||||
constructor() {
|
||||
makeAutoObservable(this);
|
||||
|
||||
reaction(() => ({data: registrationStore.userData}), ({data}) => {
|
||||
this._data = data.data;
|
||||
})
|
||||
}
|
||||
|
||||
get userData(){
|
||||
return this._data.map((elem) => ({
|
||||
...elem,
|
||||
value: cryptography.decryptMessageWithPassphrase(elem.value, elem.value_nonce, registrationStore.passPhrase, registrationStore.pubKey)
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
export const userDataStore = new UserDataStore();
|
||||
Reference in New Issue
Block a user