validate data

This commit is contained in:
kandrusyak
2022-09-13 18:10:07 +03:00
parent 4f73075cf9
commit 8e5c0a3edc
5 changed files with 68 additions and 12 deletions

View File

@@ -8,6 +8,7 @@ import SharedDataRoadMap from "../partials/sharedData/SharedDataRoadmap";
import { store } from "../store/store";
import { fetchWrapper } from "../shared/fetchWrapper";
import { cryptography } from "@liskhq/lisk-client";
import {generateTransaction} from '../utils/Utils';
function SharedData() {
const [encryptedData, setEncryptedData] = useState([]);
@@ -35,7 +36,7 @@ function SharedData() {
item.value,
item.value_nonce,
passPhrase,
pubKey
Buffer.from(pubKey, 'hex')
)
.split(":");
hash = cryptography
@@ -60,6 +61,21 @@ function SharedData() {
});
}, [encryptedData]);
const validateAccountData = () => {
const builder = generateTransaction(BigInt(store.accountInfo?.sequence?.nonce || 0),
store.pubKey, store.nodeInfo.networkIdentifier, store.passPhrase)
const signedTx = builder.validate(decryptedData.map(e => ({
label: e.label,
value: Buffer.from(e.hash, 'hex')
})), address)
if (signedTx) {
fetchWrapper.post('transactions', {}, signedTx)
.catch((err) => console.log(err));
}
}
if (!passPhrase) return <Navigate to="/" replace={true} />;
return (
@@ -87,6 +103,7 @@ function SharedData() {
</li>
))}
</ul>
{!hasError && <button className="mt-12 btn bg-indigo-500 hover:bg-indigo-600 text-white" onClick={validateAccountData}>Validate data</button>}
</div>
</div>
</div>

View File

@@ -170,6 +170,7 @@ const Profile = observer (() => {
const shareAccountData = () => {
const sharedData = store.decryptedAccountData.filter(item => selectedItems.includes(item.key))
store.pushSharedData(sharedData, publicKey)
cancelSharePanel();
}
const addDataParameters = () => {