diff --git a/src/pages/SharedData.jsx b/src/pages/SharedData.jsx
index 6fc84ea..7a90a2d 100644
--- a/src/pages/SharedData.jsx
+++ b/src/pages/SharedData.jsx
@@ -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 ;
return (
@@ -87,6 +103,7 @@ function SharedData() {
))}
+ {!hasError && }
diff --git a/src/pages/digitalId/ProfileId.jsx b/src/pages/digitalId/ProfileId.jsx
index 28de925..380c7e7 100644
--- a/src/pages/digitalId/ProfileId.jsx
+++ b/src/pages/digitalId/ProfileId.jsx
@@ -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 = () => {
diff --git a/src/shared/fetchWrapper.js b/src/shared/fetchWrapper.js
index 39ae489..6f22841 100644
--- a/src/shared/fetchWrapper.js
+++ b/src/shared/fetchWrapper.js
@@ -68,35 +68,35 @@ function request(method, url, headers = {}, token, body) {
return fetch(prepareUrl(url), requestOptions);
};
-function get(url, headers, attempts = 1) {
+function get(url, headers, attempts = 3) {
return handleRequest('GET', url, headers, attempts, null);
}
-function getAuth(url, headers, attempts = 1) {
+function getAuth(url, headers, attempts = 3) {
return handleRequest('GET', url, headers, attempts, store.tokenKey);
}
-function del(url, headers, attempts = 1) {
+function del(url, headers, attempts = 3) {
return handleRequest('DELETE', url, headers, attempts, null);
}
-function delAuth(url, headers, attempts = 1) {
+function delAuth(url, headers, attempts = 3) {
return handleRequest('DELETE', url, headers, attempts, store.tokenKey);
}
-function post(url, headers, body, attempts = 1) {
+function post(url, headers, body, attempts = 3) {
return handleRequest('POST', url, headers, attempts, null, body);
}
-function postAuth(url, headers, body, attempts = 1) {
+function postAuth(url, headers, body, attempts = 3) {
return handleRequest('POST', url, headers, attempts, store.tokenKey, body);
}
-function put(url, headers, body, attempts = 1) {
+function put(url, headers, body, attempts = 3) {
return handleRequest('PUT', url, headers, attempts, null, body);
}
-function putAuth(url, headers, body, attempts = 1) {
+function putAuth(url, headers, body, attempts = 3) {
return handleRequest('PUT', url, headers, attempts, store.tokenKey, body);
}
diff --git a/src/store/store.js b/src/store/store.js
index cbd9254..d99c952 100644
--- a/src/store/store.js
+++ b/src/store/store.js
@@ -132,7 +132,7 @@ class Store {
networkIdentifier: this.nodeInfo.networkIdentifier,
lastBlockID: this.nodeInfo.lastBlockID,
},
- {publickey: pubKey, shared: encryptSharedData(data, this.passPhrase, pubKey)}
+ {publickey: this.pubKey, shared: encryptSharedData(data, this.passPhrase, pubKey)}
)
.catch((err) => this.throwError(err));
}
diff --git a/src/utils/Utils.js b/src/utils/Utils.js
index 394c910..09c7b1d 100644
--- a/src/utils/Utils.js
+++ b/src/utils/Utils.js
@@ -1,6 +1,10 @@
import resolveConfig from 'tailwindcss/resolveConfig';
import {cryptography, transactions} from '@liskhq/lisk-client';
-import {removeFeatureAssetSchema, setFeatureAssetSchema} from './Schemas';
+import {
+ removeFeatureAssetSchema,
+ setFeatureAssetSchema,
+ validateFeatureAssetSchema,
+} from './Schemas';
import {statusMap} from "../shared/statusMap";
export const tailwindConfig = () => {
@@ -50,7 +54,7 @@ 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);
+ let value = cryptography.encryptMessageWithPassphrase(item.seed + ":" + item.value, passPhrase, Buffer.from(pubKey, 'hex'));
return {
label: item.key,
value: value.encryptedMessage,
@@ -109,6 +113,7 @@ export const generateTransaction = (nonce = BigInt(0), senderPublicKey = '', net
return {
update: (features) => generateSetTransaction(features, nonce, senderPublicKey, networkIdentifier, passPhrase, fee),
remove: (features) => generateRemoveTransaction(features, nonce, senderPublicKey, networkIdentifier, passPhrase, fee),
+ validate: (features, recipientAddress) => generateValidateTransaction(features, nonce, senderPublicKey, networkIdentifier, passPhrase, fee, recipientAddress),
}
}
@@ -166,3 +171,36 @@ export const generateRemoveTransaction = (features, nonce = BigInt(0), senderPub
return signedTx;
}
+
+const generateValidateTransaction = (features, nonce = BigInt(0), senderPublicKey = '', networkIdentifier = '', passPhrase = '', fee = BigInt(500000), recipientAddress='') => {
+ const tx = {
+ "moduleID": 1001,
+ "assetID": 11,
+ nonce,
+ senderPublicKey: Buffer.from(senderPublicKey, "hex"),
+ fee,
+ "asset": {
+ features,
+ recipientAddress: Buffer.from(recipientAddress, "hex")
+ },
+ }
+
+ if(features.length === 0)
+ return;
+
+ const signedTx = transactions.signTransaction(validateFeatureAssetSchema,
+ tx, Buffer.from(networkIdentifier, "hex"),
+ passPhrase)
+
+ signedTx.senderPublicKey = signedTx.senderPublicKey.toString("hex");
+ signedTx.asset.recipientAddress = signedTx.asset.recipientAddress.toString("hex");
+ signedTx.signatures[0] = signedTx.signatures[0].toString("hex");
+ signedTx.asset.features = signedTx.asset.features.map(feature => ({
+ ...feature,
+ value: feature.value.toString("hex")
+ }))
+
+ delete signedTx.id;
+
+ return signedTx;
+}