fix some bugs

This commit is contained in:
kandrusyak
2022-08-09 00:14:21 +03:00
parent c659e17344
commit 59dd4c9554
15 changed files with 124 additions and 228 deletions

View File

@@ -14,7 +14,7 @@ const usersImages = [User08,User06,User05,User09];
class Store {
_accountData = []
_passPhrase
_passPhrase = ''
_nodeInfo = {}
@@ -87,7 +87,7 @@ class Store {
};
fetchPassPhrase() {
this._passPhrase = sessionStorage.getItem('passPhrase')
this._passPhrase = sessionStorage.getItem('passPhrase') || ''
}
fetchSharedData() {
@@ -112,6 +112,10 @@ class Store {
this._accountData = data;
};
clearDataRegistration() {
this._accountData = [];
};
fetchNodeInfo() {
getNodeInfo()
.then((info)=>this.fetchNodeInfoSuccess(info))
@@ -175,7 +179,7 @@ class Store {
return this._accountData.map((elem) => ({
...elem,
key: elem.label,
label: labelMap[elem.label],
label: labelMap[elem.label] || elem.label,
value: cryptography.decryptMessageWithPassphrase(elem.value, elem.value_nonce, this.passPhrase, this.pubKey).split(':')[1]
}))
}
@@ -192,6 +196,18 @@ class Store {
})
}
get firstName() {
return this.decryptedAccountData.find(item => item.key === 'firstname')?.value
}
get lastName() {
return this.decryptedAccountData.find(item => item.key === 'secondname')?.value
}
get accountName() {
return this.firstName || this.lastName || this.pubKey
}
get keysArray() {
return this._keysArray;
}
@@ -228,6 +244,6 @@ class Store {
const sign = cryptography.signDataWithPassphrase(Buffer.from(stringToSign, 'hex'), this.passPhrase).toString('hex')
return this.pubKey + ':' +sign
}
};
}
export const registrationStore = new Store();
export const store = new Store();