Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
200f4f58a7 | ||
|
|
86a6bf013d | ||
|
|
6afa08e5f5 |
@@ -165,6 +165,11 @@ const Profile = observer (() => {
|
|||||||
store.pushAccountDataToBlockchain(updatedData.filter(elem=>elem.status!=='Stored'))
|
store.pushAccountDataToBlockchain(updatedData.filter(elem=>elem.status!=='Stored'))
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const sharedDataAccount = () => {
|
||||||
|
const sharedData = store.decryptedAccountData.filter(item => selectedItems.includes(item.key))
|
||||||
|
store.pushSharedData(sharedData)
|
||||||
|
}
|
||||||
|
|
||||||
const addDataParameters = () => {
|
const addDataParameters = () => {
|
||||||
const label = addedValues.label.toLowerCase().split(' ').join('');
|
const label = addedValues.label.toLowerCase().split(' ').join('');
|
||||||
if(labelMap[label])
|
if(labelMap[label])
|
||||||
@@ -517,7 +522,10 @@ const Profile = observer (() => {
|
|||||||
</svg>
|
</svg>
|
||||||
<span className="ml-2">Update</span>
|
<span className="ml-2">Update</span>
|
||||||
</button>
|
</button>
|
||||||
<button className="btn w-full border-slate-200 hover:border-slate-300 text-slate-600 px-[100px] justify-start">
|
<button
|
||||||
|
className="btn w-full border-slate-200 hover:border-slate-300 text-slate-600 px-[100px] justify-start"
|
||||||
|
onClick={sharedDataAccount}
|
||||||
|
>
|
||||||
<svg className="w-4 h-4 fill-rose-500 shrink-0" viewBox="0 0 16 16">
|
<svg className="w-4 h-4 fill-rose-500 shrink-0" viewBox="0 0 16 16">
|
||||||
<path d="M14.682 2.318A4.485 4.485 0 0 0 11.5 1 4.377 4.377 0 0 0 8 2.707 4.383 4.383 0 0 0 4.5 1a4.5 4.5 0 0 0-3.182 7.682L8 15l6.682-6.318a4.5 4.5 0 0 0 0-6.364Zm-1.4 4.933L8 12.247l-5.285-5A2.5 2.5 0 0 1 4.5 3c1.437 0 2.312.681 3.5 2.625C9.187 3.681 10.062 3 11.5 3a2.5 2.5 0 0 1 1.785 4.251h-.003Z" />
|
<path d="M14.682 2.318A4.485 4.485 0 0 0 11.5 1 4.377 4.377 0 0 0 8 2.707 4.383 4.383 0 0 0 4.5 1a4.5 4.5 0 0 0-3.182 7.682L8 15l6.682-6.318a4.5 4.5 0 0 0 0-6.364Zm-1.4 4.933L8 12.247l-5.285-5A2.5 2.5 0 0 1 4.5 3c1.437 0 2.312.681 3.5 2.625C9.187 3.681 10.062 3 11.5 3a2.5 2.5 0 0 1 1.785 4.251h-.003Z" />
|
||||||
</svg>
|
</svg>
|
||||||
|
|||||||
@@ -4,9 +4,10 @@ import { passphrase } from '@liskhq/lisk-client';
|
|||||||
import { getNodeInfo } from '../api/node';
|
import { getNodeInfo } from '../api/node';
|
||||||
import { fetchWrapper } from '../shared/fetchWrapper';
|
import { fetchWrapper } from '../shared/fetchWrapper';
|
||||||
import { labelMap } from '../shared/labelMap';
|
import { labelMap } from '../shared/labelMap';
|
||||||
|
import { statusMap } from "../shared/statusMap";
|
||||||
import { generateSvgAvatar } from '../images/GenerateOnboardingSvg/GenerateSvg';
|
import { generateSvgAvatar } from '../images/GenerateOnboardingSvg/GenerateSvg';
|
||||||
import {decryptedData} from "../utils/decryptedData";
|
import {decryptedData} from "../utils/decryptedData";
|
||||||
import { encryptAccountData, generateTransaction, hashAccountData } from '../utils/Utils';
|
import {encryptAccountData, encryptSharedData, generateTransaction, hashAccountData} from '../utils/Utils';
|
||||||
|
|
||||||
class Store {
|
class Store {
|
||||||
_accountData = [];
|
_accountData = [];
|
||||||
@@ -39,6 +40,7 @@ class Store {
|
|||||||
() => this.fetchAccountInfo()
|
() => this.fetchAccountInfo()
|
||||||
);
|
);
|
||||||
onBecomeObserved(this, 'decryptedAccountData', () => this.fetchNewAccountData());
|
onBecomeObserved(this, 'decryptedAccountData', () => this.fetchNewAccountData());
|
||||||
|
onBecomeUnobserved(this, 'decryptedAccountData', () => this.unobservedAccountData())
|
||||||
onBecomeObserved(this, 'sharedData', () => this.fetchKeysArray());
|
onBecomeObserved(this, 'sharedData', () => this.fetchKeysArray());
|
||||||
onBecomeUnobserved(this, 'sharedData', () => this.unobservedSharedData());
|
onBecomeUnobserved(this, 'sharedData', () => this.unobservedSharedData());
|
||||||
onBecomeObserved(this, 'transactionsInfo', () => this.fetchTransactionsInfo());
|
onBecomeObserved(this, 'transactionsInfo', () => this.fetchTransactionsInfo());
|
||||||
@@ -105,11 +107,12 @@ class Store {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fetchSharedData() {
|
fetchSharedData() {
|
||||||
this._keysArray.forEach((elem) =>
|
this._keysArray.forEach((elem) => {
|
||||||
fetchWrapper
|
fetchWrapper
|
||||||
.get(`data/shared/${elem}`)
|
.get(`data/shared/${elem}`)
|
||||||
.then((res) => this.changeSharedData(res))
|
.then((res) => this.changeSharedData(res))
|
||||||
.catch((err) => this.fetchError(err))
|
.catch((err) => this.fetchError(err))
|
||||||
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,6 +122,22 @@ class Store {
|
|||||||
.catch((err) => this.fetchError(err));
|
.catch((err) => this.fetchError(err));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pushSharedData(data) {
|
||||||
|
data=data.filter(item=>item.status!==statusMap.blockchained)
|
||||||
|
if(data.length>0) {
|
||||||
|
fetchWrapper
|
||||||
|
.postAuth(
|
||||||
|
'data/shared',
|
||||||
|
{
|
||||||
|
networkIdentifier: this.nodeInfo.networkIdentifier,
|
||||||
|
lastBlockID: this.nodeInfo.lastBlockID,
|
||||||
|
},
|
||||||
|
{publickey: this.pubKey, shared: encryptSharedData(data, this.passPhrase, this.pubKey)}
|
||||||
|
)
|
||||||
|
.catch((err) => this.fetchError(err));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pushAccountData(data = this.accountData) {
|
pushAccountData(data = this.accountData) {
|
||||||
fetchWrapper
|
fetchWrapper
|
||||||
.postAuth(
|
.postAuth(
|
||||||
@@ -173,6 +192,10 @@ class Store {
|
|||||||
this._sharedData = [];
|
this._sharedData = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unobservedAccountData() {
|
||||||
|
this._accountData=[]
|
||||||
|
}
|
||||||
|
|
||||||
changeSharedData(incomingData) {
|
changeSharedData(incomingData) {
|
||||||
this._sharedData.push({
|
this._sharedData.push({
|
||||||
data: incomingData.data,
|
data: incomingData.data,
|
||||||
@@ -224,7 +247,7 @@ class Store {
|
|||||||
get sharedData() {
|
get sharedData() {
|
||||||
return this._sharedData.map((elem) => ({
|
return this._sharedData.map((elem) => ({
|
||||||
data: elem.data.map((item) => ({
|
data: elem.data.map((item) => ({
|
||||||
label: labelMap[item.label],
|
label: labelMap[item.label] || item.label,
|
||||||
value: item.value,
|
value: item.value,
|
||||||
})),
|
})),
|
||||||
}));
|
}));
|
||||||
@@ -252,7 +275,7 @@ class Store {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
get decryptedAccountData() {
|
get decryptedAccountData() {
|
||||||
return decryptedData(this._accountData, this.accountFeatures, this.passPhrase, this.pubKey)
|
return decryptedData(this._accountData, this.accountFeatures, this.passPhrase, this.pubKey, this.processedFeatures)
|
||||||
}
|
}
|
||||||
|
|
||||||
get firstName() {
|
get firstName() {
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import resolveConfig from 'tailwindcss/resolveConfig';
|
|||||||
import {cryptography, transactions} from '@liskhq/lisk-client';
|
import {cryptography, transactions} from '@liskhq/lisk-client';
|
||||||
import {removeFeatureAssetSchema, setFeatureAssetSchema} from './Schemas';
|
import {removeFeatureAssetSchema, setFeatureAssetSchema} from './Schemas';
|
||||||
import {statusMap} from "../shared/statusMap";
|
import {statusMap} from "../shared/statusMap";
|
||||||
import {labelMap} from "../shared/labelMap";
|
|
||||||
|
|
||||||
export const tailwindConfig = () => {
|
export const tailwindConfig = () => {
|
||||||
// Tailwind config
|
// Tailwind config
|
||||||
@@ -49,6 +48,17 @@ export const encryptAccountData = (data = [], passPhrase = '', pubKey = '') => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const encryptSharedData = (data = [], passPhrase = '', pubKey = '') => {
|
||||||
|
return data.map((item)=> {
|
||||||
|
let value = cryptography.encryptMessageWithPassphrase(item.seed + ":" + item.value, passPhrase, pubKey);
|
||||||
|
return {
|
||||||
|
label: item.key,
|
||||||
|
value: value.encryptedMessage,
|
||||||
|
value_nonce: value.nonce,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
export const hashAccountData = (data = [], oldData = [], hashMap = {}) => {
|
export const hashAccountData = (data = [], oldData = [], hashMap = {}) => {
|
||||||
const accountMap = data.reduce((acc, item) => ({
|
const accountMap = data.reduce((acc, item) => ({
|
||||||
...acc,
|
...acc,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import {labelMap} from "../shared/labelMap";
|
|||||||
import {statusMap} from "../shared/statusMap";
|
import {statusMap} from "../shared/statusMap";
|
||||||
import {cryptography} from "@liskhq/lisk-client";
|
import {cryptography} from "@liskhq/lisk-client";
|
||||||
|
|
||||||
export const decryptedData=(serverData, blockchainData, passPhrase, pubKey)=>{
|
export const decryptedData=(serverData, blockchainData, passPhrase, pubKey, processedFeatures)=>{
|
||||||
const allAccountData=serverData.concat(blockchainData.filter(item=>!serverData.find(elem=>elem.label===item.label)))
|
const allAccountData=serverData.concat(blockchainData.filter(item=>!serverData.find(elem=>elem.label===item.label)))
|
||||||
return allAccountData.map((elem) => {
|
return allAccountData.map((elem) => {
|
||||||
const initialData={
|
const initialData={
|
||||||
@@ -13,6 +13,12 @@ export const decryptedData=(serverData, blockchainData, passPhrase, pubKey)=>{
|
|||||||
value: '',
|
value: '',
|
||||||
seed: ''
|
seed: ''
|
||||||
}
|
}
|
||||||
|
if(processedFeatures[elem.label])
|
||||||
|
return {
|
||||||
|
...initialData,
|
||||||
|
status: statusMap.processed,
|
||||||
|
value: elem.value,
|
||||||
|
}
|
||||||
if(!serverData.find(item=>item.label===elem.label)) {
|
if(!serverData.find(item=>item.label===elem.label)) {
|
||||||
return {
|
return {
|
||||||
...initialData,
|
...initialData,
|
||||||
|
|||||||
Reference in New Issue
Block a user