add processed fields
This commit is contained in:
@@ -161,7 +161,6 @@ const Profile = observer (() => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const addDataParameters = () => {
|
const addDataParameters = () => {
|
||||||
console.log(addedValues)
|
|
||||||
const label = addedValues.label.toLowerCase().split(' ').join('');
|
const label = addedValues.label.toLowerCase().split(' ').join('');
|
||||||
if(labelMap[label])
|
if(labelMap[label])
|
||||||
addedValues.key = addedValues.label.toLowerCase().split(' ').join('');
|
addedValues.key = addedValues.label.toLowerCase().split(' ').join('');
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
|
import { statusMap } from '../../shared/statusMap';
|
||||||
|
|
||||||
function ProfileTableItem(props) {
|
function ProfileTableItem(props) {
|
||||||
const [descriptionOpen, setDescriptionOpen] = useState(false);
|
const [descriptionOpen, setDescriptionOpen] = useState(false);
|
||||||
@@ -10,7 +11,13 @@ function ProfileTableItem(props) {
|
|||||||
<div className="flex items-center">
|
<div className="flex items-center">
|
||||||
<label className="inline-flex">
|
<label className="inline-flex">
|
||||||
<span className="sr-only">Select</span>
|
<span className="sr-only">Select</span>
|
||||||
<input id={props.id} className="form-checkbox" type="checkbox" onChange={props.handleClick} checked={props.isChecked} />
|
<input
|
||||||
|
id={props.id}
|
||||||
|
className="form-checkbox"
|
||||||
|
type="checkbox"
|
||||||
|
onChange={props.handleClick}
|
||||||
|
checked={props.isChecked}
|
||||||
|
/>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
@@ -20,39 +27,45 @@ function ProfileTableItem(props) {
|
|||||||
<img className="rounded-full" src={props.image} width="40" height="40" alt={props.property} />
|
<img className="rounded-full" src={props.image} width="40" height="40" alt={props.property} />
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-col w-60">
|
<div className="flex flex-col w-60">
|
||||||
<div className="font-semibold text-slate-800 text-base">{props.status==='Blockchained'?`${props.value.slice(0,4)}****${props.value.slice(props.value.length-4)}`:props.value}</div>
|
<div className="font-semibold text-slate-800 text-base">
|
||||||
|
{props.status === 'Blockchained' || props.status === statusMap.processed
|
||||||
|
? `${props.value.slice(0, 4)}****${props.value.slice(props.value.length - 4)}`
|
||||||
|
: props.value}
|
||||||
|
</div>
|
||||||
<div className="font-normal text-xxs">{props.property}</div>
|
<div className="font-normal text-xxs">{props.property}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td className="py-3 whitespace-nowrap w-px">
|
<td className="py-3 whitespace-nowrap w-px">
|
||||||
<div className="w-fit text-xs inline-flex font-medium px-2.5 py-1">
|
<div className="w-fit text-xs inline-flex font-medium px-2.5 py-1">
|
||||||
{(props.status === 'Blockchained') ? (
|
{props.status === 'Blockchained' ? (
|
||||||
<div className="bg-amber-100 text-amber-600 rounded-full text-center px-2.5 py-1">
|
<div className="bg-amber-100 text-amber-600 rounded-full text-center px-2.5 py-1">{props.status}</div>
|
||||||
{props.status}
|
) : props.status === statusMap.processed ? (
|
||||||
</div>) :
|
<div className="bg-amber-100 text-amber-600 rounded-full text-center px-2.5 py-1">{props.status}</div>
|
||||||
(props.status === 'Stored') ? (
|
) : props.status === 'Stored' ? (
|
||||||
<div className="bg-slate-700 text-slate-100 rounded-full text-center px-2.5 py-1">
|
<div className="bg-slate-700 text-slate-100 rounded-full text-center px-2.5 py-1">{props.status}</div>
|
||||||
{props.status}
|
) : props.status === 'Completed' ? (
|
||||||
</div>) :
|
<div className="bg-emerald-100 text-emerald-600 rounded-full text-center px-2.5 py-1">{props.status}</div>
|
||||||
(props.status === 'Completed') ? (
|
) : (
|
||||||
<div className="bg-emerald-100 text-emerald-600 rounded-full text-center px-2.5 py-1">
|
<div className="bg-rose-100 text-rose-600 rounded-full text-center px-2.5 py-1">{props.status}</div>
|
||||||
{props.status}
|
)}
|
||||||
</div>) : (
|
|
||||||
<div className="bg-rose-100 text-rose-600 rounded-full text-center px-2.5 py-1">
|
|
||||||
{props.status}
|
|
||||||
</div>)
|
|
||||||
}
|
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td className="px-2 py-3 whitespace-nowrap w-[340px] box-border">
|
<td className="px-2 py-3 whitespace-nowrap w-[340px] box-border">
|
||||||
<div className="flex flex-wrap items-center -m-1.5 justify-center">
|
<div className="flex flex-wrap items-center -m-1.5 justify-center">
|
||||||
<div className="flex -space-x-3 -ml-0.5">
|
<div className="flex -space-x-3 -ml-0.5">
|
||||||
{(props.avatars) ? (
|
{props.avatars
|
||||||
props.avatars.map((avatar, index) => (
|
? props.avatars.map((avatar, index) => (
|
||||||
<img className="rounded-full border-2 border-slate-100 box-content" key={index} src={avatar} width="32" height="32" alt="Avatar" />
|
<img
|
||||||
|
className="rounded-full border-2 border-slate-100 box-content"
|
||||||
|
key={index}
|
||||||
|
src={avatar}
|
||||||
|
width="32"
|
||||||
|
height="32"
|
||||||
|
alt="Avatar"
|
||||||
|
/>
|
||||||
))
|
))
|
||||||
): null}
|
: null}
|
||||||
<button className="flex justify-center items-center w-9 h-9 rounded-full bg-white border-2 border-slate-200 hover:border-slate-300 text-indigo-500 shadow-sm transition duration-150">
|
<button className="flex justify-center items-center w-9 h-9 rounded-full bg-white border-2 border-slate-200 hover:border-slate-300 text-indigo-500 shadow-sm transition duration-150">
|
||||||
<span className="sr-only">Add avatar</span>
|
<span className="sr-only">Add avatar</span>
|
||||||
<svg className="w-4 h-4 fill-current" viewBox="0 0 16 16">
|
<svg className="w-4 h-4 fill-current" viewBox="0 0 16 16">
|
||||||
@@ -93,12 +106,21 @@ function ProfileTableItem(props) {
|
|||||||
<td colSpan="10" className="px-12 pt-3.5 pb-[14px]">
|
<td colSpan="10" className="px-12 pt-3.5 pb-[14px]">
|
||||||
<div className="flex items-center gap-x-5">
|
<div className="flex items-center gap-x-5">
|
||||||
<div>
|
<div>
|
||||||
<label className="block text-sm font-medium mb-1" htmlFor="placeholder">Seed</label>
|
<label className="block text-sm font-medium mb-1" htmlFor="placeholder">
|
||||||
<input id="placeholder" className="form-input w-[396px] bg-white" type="text" placeholder="2342423423423234223" />
|
Seed
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
id="placeholder"
|
||||||
|
className="form-input w-[396px] bg-white"
|
||||||
|
type="text"
|
||||||
|
placeholder="2342423423423234223"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<span className="block text-sm font-medium mb-1">Transaction</span>
|
<span className="block text-sm font-medium mb-1">Transaction</span>
|
||||||
<a href="" className="w-[396px] text-slate-400 font-normal text-sm underline">0x12831823791203192418234841238468</a>
|
<a href="" className="w-[396px] text-slate-400 font-normal text-sm underline">
|
||||||
|
0x12831823791203192418234841238468
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/* Progress validation bar */}
|
{/* Progress validation bar */}
|
||||||
@@ -113,8 +135,11 @@ function ProfileTableItem(props) {
|
|||||||
{props.transactions.map((data, index) => (
|
{props.transactions.map((data, index) => (
|
||||||
<li className="relative py-2" key={index}>
|
<li className="relative py-2" key={index}>
|
||||||
<div className="flex items-center mb-2.5">
|
<div className="flex items-center mb-2.5">
|
||||||
{(props.transactions[index+1]) ? (
|
{props.transactions[index + 1] ? (
|
||||||
<div className="absolute left-0 h-full w-0.5 bg-slate-200 self-start ml-2.5 -translate-x-1/2 translate-y-3" aria-hidden="true"></div>
|
<div
|
||||||
|
className="absolute left-0 h-full w-0.5 bg-slate-200 self-start ml-2.5 -translate-x-1/2 translate-y-3"
|
||||||
|
aria-hidden="true"
|
||||||
|
></div>
|
||||||
) : null}
|
) : null}
|
||||||
<div className="absolute left-0 rounded-full bg-indigo-500" aria-hidden="true">
|
<div className="absolute left-0 rounded-full bg-indigo-500" aria-hidden="true">
|
||||||
<svg className="w-5 h-5 fill-current text-white" viewBox="0 0 20 20">
|
<svg className="w-5 h-5 fill-current text-white" viewBox="0 0 20 20">
|
||||||
@@ -123,15 +148,21 @@ function ProfileTableItem(props) {
|
|||||||
</div>
|
</div>
|
||||||
<h3 className="pl-9 whitespace-nowrap">
|
<h3 className="pl-9 whitespace-nowrap">
|
||||||
<span className="text-validateSize font-bold text-slate-800">Validate by </span>
|
<span className="text-validateSize font-bold text-slate-800">Validate by </span>
|
||||||
<a href="" className="font-bold text-validateSize underline text-indigo-500">{data}</a>
|
<a href="" className="font-bold text-validateSize underline text-indigo-500">
|
||||||
|
{data}
|
||||||
|
</a>
|
||||||
</h3>
|
</h3>
|
||||||
</div>
|
</div>
|
||||||
<div className="pl-9">
|
<div className="pl-9">
|
||||||
<a href="" className="w-[396px] text-slate-800 font-semibold text-base underline">{data}</a>
|
<a href="" className="w-[396px] text-slate-800 font-semibold text-base underline">
|
||||||
|
{data}
|
||||||
|
</a>
|
||||||
<span className="block text-xxs font-normal mb-1">Transactions ID</span>
|
<span className="block text-xxs font-normal mb-1">Transactions ID</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="pl-9">
|
<div className="pl-9">
|
||||||
<a href="" className="w-[396px] text-slate-800 font-semibold text-base underline">{data.slice(2, data.length)}</a>
|
<a href="" className="w-[396px] text-slate-800 font-semibold text-base underline">
|
||||||
|
{data.slice(2, data.length)}
|
||||||
|
</a>
|
||||||
<span className="block text-xxs font-normal mb-1">Validated data</span>
|
<span className="block text-xxs font-normal mb-1">Validated data</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="pl-9 pt-[14px]">
|
<div className="pl-9 pt-[14px]">
|
||||||
|
|||||||
@@ -8,8 +8,9 @@ function prepareUrl(url) {
|
|||||||
|
|
||||||
function handleRequest(method, url, headers, attempts, token, body) {
|
function handleRequest(method, url, headers, attempts, token, body) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
store.loading = true;
|
|
||||||
(function internalRequest() {
|
(function internalRequest() {
|
||||||
|
if(store)
|
||||||
|
store.loading = true;
|
||||||
return request(method, url, headers, token, body)
|
return request(method, url, headers, token, body)
|
||||||
.then(resolve)
|
.then(resolve)
|
||||||
.catch(err => --attempts > 0 ? internalRequest() : reject(err))
|
.catch(err => --attempts > 0 ? internalRequest() : reject(err))
|
||||||
|
|||||||
@@ -2,5 +2,6 @@ export const statusMap={
|
|||||||
completed:'Completed',
|
completed:'Completed',
|
||||||
incorrect:'Incorrect',
|
incorrect:'Incorrect',
|
||||||
stored: 'Stored',
|
stored: 'Stored',
|
||||||
blockchained: 'Blockchained'
|
blockchained: 'Blockchained',
|
||||||
|
processed: 'Processed'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,169 +1,202 @@
|
|||||||
import {reaction, makeAutoObservable, onBecomeObserved, onBecomeUnobserved} from "mobx";
|
import { reaction, makeAutoObservable, onBecomeObserved, onBecomeUnobserved } from 'mobx';
|
||||||
import {cryptography} from "@liskhq/lisk-client";
|
import { cryptography } from '@liskhq/lisk-client';
|
||||||
import { passphrase, transactions } from "@liskhq/lisk-client";
|
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 { statusMap } from '../shared/statusMap';
|
||||||
import {generateSvgAvatar} from "../images/GenerateOnboardingSvg/GenerateSvg";
|
import { generateSvgAvatar } from '../images/GenerateOnboardingSvg/GenerateSvg';
|
||||||
import {
|
import { encryptAccountData, generateTransaction, hashAccountData } from '../utils/Utils';
|
||||||
encryptAccountData,
|
|
||||||
generateSetTransaction, generateTransaction,
|
|
||||||
hashAccountData,
|
|
||||||
} from '../utils/Utils';
|
|
||||||
import {
|
|
||||||
removeFeatureAssetSchema,
|
|
||||||
setFeatureAssetSchema,
|
|
||||||
} from '../utils/Schemas';
|
|
||||||
|
|
||||||
class Store {
|
class Store {
|
||||||
_accountData = []
|
_accountData = [];
|
||||||
|
|
||||||
_passPhrase = ''
|
_passPhrase = '';
|
||||||
|
|
||||||
_nodeInfo = {}
|
_nodeInfo = {};
|
||||||
|
|
||||||
_keysArray = []
|
_keysArray = [];
|
||||||
|
|
||||||
_sharedData = []
|
_sharedData = [];
|
||||||
|
|
||||||
_transactionsInfo = []
|
_transactionsInfo = [];
|
||||||
|
|
||||||
_accountInfo = {};
|
_accountInfo = {};
|
||||||
|
|
||||||
_loading = false;
|
_loading = false;
|
||||||
|
|
||||||
|
_tempTransactions = [];
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
makeAutoObservable(this, {});
|
makeAutoObservable(this, {});
|
||||||
|
|
||||||
reaction(() => this.keysArray, () => this.fetchSharedData())
|
reaction(
|
||||||
reaction(() => this.address, () => this.fetchAccountInfo())
|
() => this.keysArray,
|
||||||
onBecomeObserved(this, "decryptedAccountData", () => this.fetchNewAccountData())
|
() => this.fetchSharedData()
|
||||||
onBecomeObserved(this, "sharedData", () => this.fetchKeysArray())
|
);
|
||||||
onBecomeUnobserved(this, "sharedData", () => this.unobservedSharedData())
|
reaction(
|
||||||
onBecomeObserved(this, "transactionsInfo", () => this.fetchTransactionsInfo())
|
() => this.address,
|
||||||
onBecomeUnobserved(this, "transactionsInfo", () => this.unobservedTransactionsInfo())
|
() => this.fetchAccountInfo()
|
||||||
|
);
|
||||||
|
onBecomeObserved(this, 'decryptedAccountData', () => this.fetchNewAccountData());
|
||||||
|
onBecomeObserved(this, 'sharedData', () => this.fetchKeysArray());
|
||||||
|
onBecomeUnobserved(this, 'sharedData', () => this.unobservedSharedData());
|
||||||
|
onBecomeObserved(this, 'transactionsInfo', () => this.fetchTransactionsInfo());
|
||||||
|
onBecomeUnobserved(this, 'transactionsInfo', () => this.unobservedTransactionsInfo());
|
||||||
|
|
||||||
this.fetchNodeInfo()
|
this.fetchNodeInfo();
|
||||||
};
|
}
|
||||||
|
|
||||||
fetchNewAccountData() {
|
fetchNewAccountData() {
|
||||||
getNodeInfo()
|
getNodeInfo()
|
||||||
.then((info) => {
|
.then((info) => {
|
||||||
this.fetchNodeInfoSuccess(info)
|
this.fetchNodeInfoSuccess(info);
|
||||||
fetchWrapper.getAuth('data/private', {
|
fetchWrapper
|
||||||
|
.getAuth('data/private', {
|
||||||
networkIdentifier: this.nodeInfo.networkIdentifier,
|
networkIdentifier: this.nodeInfo.networkIdentifier,
|
||||||
lastBlockID: this.nodeInfo.lastBlockID
|
lastBlockID: this.nodeInfo.lastBlockID,
|
||||||
}).then((res) => this.accountDataFetchChange(res))
|
|
||||||
})
|
})
|
||||||
.catch((err) => this.fetchNodeInfoFailed(err))
|
.then((res) => this.accountDataFetchChange(res))
|
||||||
|
.catch((err) => this.fetchError(err));
|
||||||
|
})
|
||||||
|
.catch((err) => this.fetchError(err));
|
||||||
}
|
}
|
||||||
|
|
||||||
fetchAccountInfo() {
|
fetchAccountInfo() {
|
||||||
fetchWrapper.get(`accounts/${this.address}`).then((res) => this.fetchAccountInfoSuccess(res))
|
fetchWrapper
|
||||||
|
.get(`accounts/${this.address}`)
|
||||||
|
.then((res) => this.fetchAccountInfoSuccess(res))
|
||||||
|
.catch((err) => this.fetchError(err));
|
||||||
}
|
}
|
||||||
|
|
||||||
fetchKeysArray() {
|
fetchKeysArray() {
|
||||||
getNodeInfo()
|
getNodeInfo()
|
||||||
.then((info) => {
|
.then((info) => {
|
||||||
this.fetchNodeInfoSuccess(info)
|
this.fetchNodeInfoSuccess(info);
|
||||||
fetchWrapper.getAuth('data/shared/', {
|
fetchWrapper
|
||||||
|
.getAuth('data/shared/', {
|
||||||
networkIdentifier: this.nodeInfo.networkIdentifier,
|
networkIdentifier: this.nodeInfo.networkIdentifier,
|
||||||
lastBlockID: this.nodeInfo.lastBlockID
|
lastBlockID: this.nodeInfo.lastBlockID,
|
||||||
}).then((res) => this.keysArrayFetchChange(res))
|
|
||||||
})
|
})
|
||||||
.catch((err) => this.fetchNodeInfoFailed(err))
|
.then((res) => this.keysArrayFetchChange(res));
|
||||||
|
})
|
||||||
|
.catch((err) => this.fetchError(err));
|
||||||
}
|
}
|
||||||
|
|
||||||
fetchTransactionsInfo() {
|
fetchTransactionsInfo() {
|
||||||
fetchWrapper.get(`account/transactions/${this.address}`, {
|
fetchWrapper
|
||||||
|
.get(`account/transactions/${this.address}`, {
|
||||||
networkIdentifier: this.nodeInfo.networkIdentifier,
|
networkIdentifier: this.nodeInfo.networkIdentifier,
|
||||||
lastBlockID: this.nodeInfo.lastBlockID
|
lastBlockID: this.nodeInfo.lastBlockID,
|
||||||
}).then((res) => this.saveInfoTransactions(res))
|
})
|
||||||
};
|
.then((res) => this.saveInfoTransactions(res))
|
||||||
|
.catch((err) => this.fetchError(err));
|
||||||
|
}
|
||||||
|
|
||||||
|
fetchTempTransactions() {
|
||||||
|
fetchWrapper
|
||||||
|
.get('node/transactions')
|
||||||
|
.then((res) => this.fetchTempTransactionsSuccess(res))
|
||||||
|
.catch((err) => this.fetchError(err));
|
||||||
|
}
|
||||||
|
|
||||||
fetchPassPhrase() {
|
fetchPassPhrase() {
|
||||||
this._passPhrase = sessionStorage.getItem('passPhrase') || ''
|
this._passPhrase = sessionStorage.getItem('passPhrase') || '';
|
||||||
}
|
}
|
||||||
|
|
||||||
fetchSharedData() {
|
fetchSharedData() {
|
||||||
this._keysArray.forEach((elem) => fetchWrapper.get(`data/shared/${elem}`).then((res) => this.changeSharedData(res)))
|
this._keysArray.forEach((elem) =>
|
||||||
};
|
fetchWrapper
|
||||||
|
.get(`data/shared/${elem}`)
|
||||||
|
.then((res) => this.changeSharedData(res))
|
||||||
|
.catch((err) => this.fetchError(err))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
fetchNodeInfo() {
|
fetchNodeInfo() {
|
||||||
getNodeInfo()
|
getNodeInfo()
|
||||||
.then((info) => this.fetchNodeInfoSuccess(info))
|
.then((info) => this.fetchNodeInfoSuccess(info))
|
||||||
.catch((err) => this.fetchNodeInfoFailed(err))
|
.catch((err) => this.fetchError(err));
|
||||||
}
|
}
|
||||||
|
|
||||||
pushAccountData(data = this.accountData) {
|
pushAccountData(data = this.accountData) {
|
||||||
fetchWrapper.postAuth('data/private', {
|
fetchWrapper
|
||||||
|
.postAuth(
|
||||||
|
'data/private',
|
||||||
|
{
|
||||||
networkIdentifier: this.nodeInfo.networkIdentifier,
|
networkIdentifier: this.nodeInfo.networkIdentifier,
|
||||||
lastBlockID: this.nodeInfo.lastBlockID
|
lastBlockID: this.nodeInfo.lastBlockID,
|
||||||
}, [...encryptAccountData(data, this.passPhrase, this.pubKey)])
|
},
|
||||||
|
[...encryptAccountData(data, this.passPhrase, this.pubKey)]
|
||||||
|
)
|
||||||
.then(() => this.fetchNewAccountData())
|
.then(() => this.fetchNewAccountData())
|
||||||
|
.catch((err) => this.fetchError(err));
|
||||||
}
|
}
|
||||||
|
|
||||||
pushAccountDataToBlockchain(data = this.decryptedAccountData) {
|
pushAccountDataToBlockchain(data = this.decryptedAccountData) {
|
||||||
const [removed, changed] = hashAccountData(data, this.decryptedAccountData, this.accountFeaturesMap)
|
const [removed, changed] = hashAccountData(data, this.decryptedAccountData, this.accountFeaturesMap);
|
||||||
const builder = generateTransaction(BigInt(this.accountInfo?.sequence?.nonce || 0), this.addressAndPubKey.publicKey, this.nodeInfo.networkIdentifier, this.passPhrase);
|
const builder = generateTransaction(
|
||||||
|
BigInt(this.accountInfo?.sequence?.nonce || 0),
|
||||||
|
this.addressAndPubKey.publicKey,
|
||||||
|
this.nodeInfo.networkIdentifier,
|
||||||
|
this.passPhrase
|
||||||
|
);
|
||||||
|
|
||||||
let signedTx = null;
|
let signedTx = null;
|
||||||
|
|
||||||
if(removed.length !== 0)
|
if (removed.length !== 0) signedTx = builder.remove(removed);
|
||||||
signedTx = builder.remove(removed);
|
|
||||||
|
|
||||||
if(changed.length !== 0)
|
if (changed.length !== 0) signedTx = builder.update(changed);
|
||||||
signedTx = builder.update(changed)
|
|
||||||
if (signedTx) {
|
if (signedTx) {
|
||||||
fetchWrapper.post('transactions', {}, signedTx);
|
fetchWrapper.post('transactions', {}, signedTx)
|
||||||
|
.then(() => this.fetchTempTransactions())
|
||||||
|
.catch((err) => this.fetchError(err));
|
||||||
this.accountInfo.sequence.nonce++;
|
this.accountInfo.sequence.nonce++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
generatePassPhrase() {
|
generatePassPhrase() {
|
||||||
this._passPhrase = passphrase.Mnemonic.generateMnemonic();
|
this._passPhrase = passphrase.Mnemonic.generateMnemonic();
|
||||||
sessionStorage.setItem('passPhrase', this._passPhrase);
|
sessionStorage.setItem('passPhrase', this._passPhrase);
|
||||||
};
|
}
|
||||||
|
|
||||||
savePastPassPhrase(phrase) {
|
savePastPassPhrase(phrase) {
|
||||||
this._passPhrase=phrase
|
this._passPhrase = phrase;
|
||||||
sessionStorage.setItem('passPhrase', this._passPhrase);
|
sessionStorage.setItem('passPhrase', this._passPhrase);
|
||||||
};
|
}
|
||||||
|
|
||||||
unobservedTransactionsInfo() {
|
unobservedTransactionsInfo() {
|
||||||
this._transactionsInfo = []
|
this._transactionsInfo = [];
|
||||||
};
|
}
|
||||||
|
|
||||||
unobservedSharedData() {
|
unobservedSharedData() {
|
||||||
this._sharedData = []
|
this._sharedData = [];
|
||||||
};
|
}
|
||||||
|
|
||||||
changeSharedData(incomingData) {
|
changeSharedData(incomingData) {
|
||||||
this._sharedData.push({
|
this._sharedData.push({
|
||||||
data: incomingData.data,
|
data: incomingData.data,
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
saveDataRegistration(data) {
|
saveDataRegistration(data) {
|
||||||
this._accountData = data;
|
this._accountData = data;
|
||||||
};
|
}
|
||||||
|
|
||||||
clearDataRegistration() {
|
clearDataRegistration() {
|
||||||
this._accountData = [];
|
this._accountData = [];
|
||||||
};
|
}
|
||||||
|
|
||||||
saveInfoTransactions(transaction) {
|
saveInfoTransactions(transaction) {
|
||||||
this._transactionsInfo = transaction.data
|
this._transactionsInfo = transaction.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
accountDataFetchChange(res) {
|
accountDataFetchChange(res) {
|
||||||
if (res.data) {
|
if (res.data) {
|
||||||
this._accountData = res.data;
|
this._accountData = res.data;
|
||||||
}
|
}
|
||||||
};
|
this.fetchTempTransactions();
|
||||||
|
}
|
||||||
|
|
||||||
keysArrayFetchChange(res) {
|
keysArrayFetchChange(res) {
|
||||||
this._keysArray = res.data;
|
this._keysArray = res.data;
|
||||||
@@ -171,48 +204,58 @@ class Store {
|
|||||||
|
|
||||||
fetchNodeInfoSuccess(info) {
|
fetchNodeInfoSuccess(info) {
|
||||||
this._nodeInfo = info.data;
|
this._nodeInfo = info.data;
|
||||||
this.fetchPassPhrase()
|
this.fetchPassPhrase();
|
||||||
}
|
|
||||||
|
|
||||||
fetchNodeInfoFailed(err) {
|
|
||||||
console.log(err);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fetchAccountInfoSuccess(res) {
|
fetchAccountInfoSuccess(res) {
|
||||||
this._accountInfo = res.data;
|
this._accountInfo = res.data;
|
||||||
if (this.accountInfo?.sequence?.nonce)
|
if (this.accountInfo?.sequence?.nonce)
|
||||||
this.accountInfo.sequence.nonce = parseInt(this.accountInfo.sequence.nonce) || 0
|
this.accountInfo.sequence.nonce = parseInt(this.accountInfo.sequence.nonce) || 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
fetchTempTransactionsSuccess(res) {
|
||||||
|
this._tempTransactions = res.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
fetchError(err) {
|
||||||
|
console.log(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
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],
|
||||||
value: item.value,
|
value: item.value,
|
||||||
}))
|
})),
|
||||||
}));
|
}));
|
||||||
};
|
}
|
||||||
|
|
||||||
get transactionsInfo() {
|
get transactionsInfo() {
|
||||||
return this._transactionsInfo.map(item => {
|
return this._transactionsInfo.map((item) => {
|
||||||
return {
|
return {
|
||||||
id: item.id,
|
id: item.id,
|
||||||
sender_avatar: item.asset.recipientAddress && generateSvgAvatar(item.senderPublicKey),
|
sender_avatar: item.asset.recipientAddress && generateSvgAvatar(item.senderPublicKey),
|
||||||
avatar_size: 24,
|
avatar_size: 24,
|
||||||
transaction: item.asset.features.map(asset => {
|
transaction: item.asset.features.map((asset) => {
|
||||||
return {
|
return {
|
||||||
transaction_id: item.id,
|
transaction_id: item.id,
|
||||||
address: item.asset.recipientAddress && cryptography.bufferToHex(cryptography.getAddressFromPublicKey(cryptography.hexToBuffer(item.senderPublicKey))),
|
address:
|
||||||
|
item.asset.recipientAddress &&
|
||||||
|
cryptography.bufferToHex(
|
||||||
|
cryptography.getAddressFromPublicKey(cryptography.hexToBuffer(item.senderPublicKey))
|
||||||
|
),
|
||||||
value: asset.value,
|
value: asset.value,
|
||||||
label: labelMap[asset.label] || asset.label
|
label: labelMap[asset.label] || asset.label,
|
||||||
}
|
};
|
||||||
})
|
}),
|
||||||
}
|
};
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
get decryptedAccountData() {
|
get decryptedAccountData() {
|
||||||
const allAccountData=this._accountData.concat(this.accountFeatures.filter(item=>!this._accountData.find(elem=>elem.label===item.label)))
|
const allAccountData = this._accountData.concat(
|
||||||
|
this.accountFeatures.filter((item) => !this._accountData.find((elem) => elem.label === item.label))
|
||||||
|
);
|
||||||
return allAccountData.map((elem) => {
|
return allAccountData.map((elem) => {
|
||||||
const initialData = {
|
const initialData = {
|
||||||
...elem,
|
...elem,
|
||||||
@@ -220,52 +263,62 @@ class Store {
|
|||||||
label: labelMap[elem.label] || elem.label,
|
label: labelMap[elem.label] || elem.label,
|
||||||
status: '',
|
status: '',
|
||||||
value: '',
|
value: '',
|
||||||
seed: ''
|
seed: '',
|
||||||
|
};
|
||||||
|
if(this.processedFeatures[elem.label])
|
||||||
|
return {
|
||||||
|
...initialData,
|
||||||
|
status: statusMap.processed,
|
||||||
|
value: elem.value,
|
||||||
}
|
}
|
||||||
if(!this._accountData.find(item=>item.label===elem.label)) {
|
if (!this._accountData.find((item) => item.label === elem.label)) {
|
||||||
return {
|
return {
|
||||||
...initialData,
|
...initialData,
|
||||||
status: statusMap.blockchained,
|
status: statusMap.blockchained,
|
||||||
value: elem.value
|
value: elem.value,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
const [seed, value] = cryptography
|
||||||
const [seed, value] = cryptography.decryptMessageWithPassphrase(elem.value, elem.value_nonce, this.passPhrase, this.pubKey).split(':');
|
.decryptMessageWithPassphrase(elem.value, elem.value_nonce, this.passPhrase, this.pubKey)
|
||||||
const hashValue=cryptography.hash(Buffer.concat([Buffer.from(seed, 'utf8'), cryptography.hash(value, 'utf8')])).toString('hex')
|
.split(':');
|
||||||
if(!this.accountFeatures.find(item=>item.label===elem.label)) {
|
const hashValue = cryptography
|
||||||
|
.hash(Buffer.concat([Buffer.from(seed, 'utf8'), cryptography.hash(value, 'utf8')]))
|
||||||
|
.toString('hex');
|
||||||
|
if (!this.accountFeatures.find((item) => item.label === elem.label)) {
|
||||||
return {
|
return {
|
||||||
...initialData,
|
...initialData,
|
||||||
status: statusMap.stored,
|
status: statusMap.stored,
|
||||||
value,
|
value,
|
||||||
seed
|
seed,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
if (this.accountFeatures.find((item) => item.label === elem.label).value !== hashValue) {
|
||||||
if(this.accountFeatures.find(item=>item.label===elem.label).value!==hashValue) {
|
|
||||||
return {
|
return {
|
||||||
...initialData,
|
...initialData,
|
||||||
status: statusMap.incorrect,
|
status: statusMap.incorrect,
|
||||||
value,
|
value,
|
||||||
seed
|
seed,
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
...initialData,
|
...initialData,
|
||||||
status: statusMap.completed,
|
status: statusMap.completed,
|
||||||
value,
|
value,
|
||||||
seed
|
seed,
|
||||||
}
|
};
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
get firstName() {
|
get firstName() {
|
||||||
return this.decryptedAccountData.find(item => item.key === 'firstname')?.value
|
return this.decryptedAccountData.find((item) => item.key === 'firstname')?.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
get lastName() {
|
get lastName() {
|
||||||
return this.decryptedAccountData.find(item => item.key === 'secondname')?.value
|
return this.decryptedAccountData.find((item) => item.key === 'secondname')?.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
get accountName() {
|
get accountName() {
|
||||||
return this.firstName || this.lastName || this.pubKey
|
return this.firstName || this.lastName || this.pubKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
get keysArray() {
|
get keysArray() {
|
||||||
@@ -273,12 +326,12 @@ class Store {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get passPhrase() {
|
get passPhrase() {
|
||||||
return this._passPhrase
|
return this._passPhrase;
|
||||||
}
|
}
|
||||||
|
|
||||||
get accountData() {
|
get accountData() {
|
||||||
return this._accountData
|
return this._accountData;
|
||||||
};
|
}
|
||||||
|
|
||||||
get accountInfo() {
|
get accountInfo() {
|
||||||
return this._accountInfo;
|
return this._accountInfo;
|
||||||
@@ -297,15 +350,14 @@ class Store {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get address() {
|
get address() {
|
||||||
return this.addressAndPubKey.address.toString('hex')
|
return this.addressAndPubKey.address.toString('hex');
|
||||||
}
|
}
|
||||||
|
|
||||||
get tokenKey() {
|
get tokenKey() {
|
||||||
const stringToSign = this.nodeInfo.networkIdentifier + this.nodeInfo.lastBlockID;
|
const stringToSign = this.nodeInfo.networkIdentifier + this.nodeInfo.lastBlockID;
|
||||||
if(!stringToSign)
|
if (!stringToSign) return '';
|
||||||
return '';
|
const sign = cryptography.signDataWithPassphrase(Buffer.from(stringToSign, 'hex'), this.passPhrase).toString('hex');
|
||||||
const sign = cryptography.signDataWithPassphrase(Buffer.from(stringToSign, 'hex'), this.passPhrase).toString('hex')
|
return this.pubKey + ':' + sign;
|
||||||
return this.pubKey + ':' +sign
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get accountIdentity() {
|
get accountIdentity() {
|
||||||
@@ -317,10 +369,13 @@ class Store {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get accountFeaturesMap() {
|
get accountFeaturesMap() {
|
||||||
return this.accountFeatures.reduce((acc, item) => ({
|
return this.accountFeatures.reduce(
|
||||||
|
(acc, item) => ({
|
||||||
...acc,
|
...acc,
|
||||||
[item.label]: item.value
|
[item.label]: item.value,
|
||||||
}), {})
|
}),
|
||||||
|
{}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
get loading() {
|
get loading() {
|
||||||
@@ -330,6 +385,22 @@ class Store {
|
|||||||
set loading(value) {
|
set loading(value) {
|
||||||
this._loading = value;
|
this._loading = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get tempTransactions() {
|
||||||
|
return this._tempTransactions;
|
||||||
|
}
|
||||||
|
|
||||||
|
get processedFeatures() {
|
||||||
|
return this.tempTransactions
|
||||||
|
.filter(item => item.senderPublicKey === this.pubKey)
|
||||||
|
.reduce((acc, item) => {
|
||||||
|
const { features } = item.asset;
|
||||||
|
return {
|
||||||
|
...acc,
|
||||||
|
...features.reduce((obj, feature) => ({...obj, [feature.label]: true}), {})
|
||||||
|
}
|
||||||
|
}, {})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const store = new Store();
|
export const store = new Store();
|
||||||
|
|||||||
Reference in New Issue
Block a user