add prettier
This commit is contained in:
@@ -1,31 +1,31 @@
|
||||
export const IdentityModuleSchema = {
|
||||
$id: "idntty/identity/module",
|
||||
title: "Identity module account schema",
|
||||
type: "object",
|
||||
$id: 'idntty/identity/module',
|
||||
title: 'Identity module account schema',
|
||||
type: 'object',
|
||||
properties: {
|
||||
features: {
|
||||
fieldNumber: 1,
|
||||
type: "array",
|
||||
type: 'array',
|
||||
maxItems: 256,
|
||||
items: {
|
||||
type: "object",
|
||||
required: ["label", "value"],
|
||||
type: 'object',
|
||||
required: ['label', 'value'],
|
||||
properties: {
|
||||
label: { fieldNumber: 1, dataType: "string" },
|
||||
value: { fieldNumber: 2, dataType: "bytes" },
|
||||
label: { fieldNumber: 1, dataType: 'string' },
|
||||
value: { fieldNumber: 2, dataType: 'bytes' },
|
||||
},
|
||||
},
|
||||
},
|
||||
verifications: {
|
||||
fieldNumber: 2,
|
||||
type: "array",
|
||||
type: 'array',
|
||||
items: {
|
||||
type: "object",
|
||||
required: ["label", "account", "tx"],
|
||||
type: 'object',
|
||||
required: ['label', 'account', 'tx'],
|
||||
properties: {
|
||||
label: { fieldNumber: 1, dataType: "string" },
|
||||
account: { fieldNumber: 2, dataType: "bytes" },
|
||||
tx: { fieldNumber: 3, dataType: "bytes" },
|
||||
label: { fieldNumber: 1, dataType: 'string' },
|
||||
account: { fieldNumber: 2, dataType: 'bytes' },
|
||||
tx: { fieldNumber: 3, dataType: 'bytes' },
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -34,22 +34,22 @@ export const IdentityModuleSchema = {
|
||||
};
|
||||
|
||||
export const setFeatureAssetSchema = {
|
||||
$id: "idntty/identity/setfeature",
|
||||
title: "Asset schema to set or update account features for identity module",
|
||||
type: "object",
|
||||
required: ["features"],
|
||||
$id: 'idntty/identity/setfeature',
|
||||
title: 'Asset schema to set or update account features for identity module',
|
||||
type: 'object',
|
||||
required: ['features'],
|
||||
properties: {
|
||||
features: {
|
||||
fieldNumber: 1,
|
||||
type: "array",
|
||||
type: 'array',
|
||||
minItems: 1,
|
||||
maxItems: 16,
|
||||
items: {
|
||||
type: "object",
|
||||
required: ["label", "value"],
|
||||
type: 'object',
|
||||
required: ['label', 'value'],
|
||||
properties: {
|
||||
label: { fieldNumber: 1, dataType: "string", maxLength: 16 },
|
||||
value: { fieldNumber: 2, dataType: "bytes", maxLength: 32 },
|
||||
label: { fieldNumber: 1, dataType: 'string', maxLength: 16 },
|
||||
value: { fieldNumber: 2, dataType: 'bytes', maxLength: 32 },
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -57,21 +57,21 @@ export const setFeatureAssetSchema = {
|
||||
};
|
||||
|
||||
export const removeFeatureAssetSchema = {
|
||||
$id: "idntty/identity/removefeature",
|
||||
title: "Asset schema to remove account features for identity module",
|
||||
type: "object",
|
||||
required: ["features"],
|
||||
$id: 'idntty/identity/removefeature',
|
||||
title: 'Asset schema to remove account features for identity module',
|
||||
type: 'object',
|
||||
required: ['features'],
|
||||
properties: {
|
||||
features: {
|
||||
fieldNumber: 1,
|
||||
type: "array",
|
||||
type: 'array',
|
||||
minItems: 1,
|
||||
maxItems: 16,
|
||||
items: {
|
||||
type: "object",
|
||||
required: ["label"],
|
||||
type: 'object',
|
||||
required: ['label'],
|
||||
properties: {
|
||||
label: { fieldNumber: 1, dataType: "string", maxLength: 16 },
|
||||
label: { fieldNumber: 1, dataType: 'string', maxLength: 16 },
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -79,28 +79,28 @@ export const removeFeatureAssetSchema = {
|
||||
};
|
||||
|
||||
export const validateFeatureAssetSchema = {
|
||||
$id: "idntty/identity/validatefeature",
|
||||
title: "Asset schema to validate account features for identity module",
|
||||
type: "object",
|
||||
required: ["recipientAddress", "features"],
|
||||
$id: 'idntty/identity/validatefeature',
|
||||
title: 'Asset schema to validate account features for identity module',
|
||||
type: 'object',
|
||||
required: ['recipientAddress', 'features'],
|
||||
properties: {
|
||||
recipientAddress: {
|
||||
fieldNumber: 1,
|
||||
dataType: "bytes",
|
||||
dataType: 'bytes',
|
||||
minLength: 20,
|
||||
maxLength: 20,
|
||||
},
|
||||
features: {
|
||||
fieldNumber: 2,
|
||||
type: "array",
|
||||
type: 'array',
|
||||
minItems: 1,
|
||||
maxItems: 16,
|
||||
items: {
|
||||
type: "object",
|
||||
required: ["label", "value"],
|
||||
type: 'object',
|
||||
required: ['label', 'value'],
|
||||
properties: {
|
||||
label: { fieldNumber: 1, dataType: "string", maxLength: 16 },
|
||||
value: { fieldNumber: 2, dataType: "bytes", maxLength: 32 },
|
||||
label: { fieldNumber: 1, dataType: 'string', maxLength: 16 },
|
||||
value: { fieldNumber: 2, dataType: 'bytes', maxLength: 32 },
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -108,27 +108,27 @@ export const validateFeatureAssetSchema = {
|
||||
};
|
||||
|
||||
export const invalidateFeatureAssetSchema = {
|
||||
$id: "idntty/identity/invalidatefeature",
|
||||
title: "Asset schema to invalidate account features for identity module",
|
||||
type: "object",
|
||||
required: ["recipientAddress", "features"],
|
||||
$id: 'idntty/identity/invalidatefeature',
|
||||
title: 'Asset schema to invalidate account features for identity module',
|
||||
type: 'object',
|
||||
required: ['recipientAddress', 'features'],
|
||||
properties: {
|
||||
recipientAddress: {
|
||||
fieldNumber: 1,
|
||||
dataType: "bytes",
|
||||
dataType: 'bytes',
|
||||
minLength: 20,
|
||||
maxLength: 20,
|
||||
},
|
||||
features: {
|
||||
fieldNumber: 2,
|
||||
type: "array",
|
||||
type: 'array',
|
||||
minItems: 1,
|
||||
maxItems: 16,
|
||||
items: {
|
||||
type: "object",
|
||||
required: ["label"],
|
||||
type: 'object',
|
||||
required: ['label'],
|
||||
properties: {
|
||||
label: { fieldNumber: 1, dataType: "string", maxLength: 16 },
|
||||
label: { fieldNumber: 1, dataType: 'string', maxLength: 16 },
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -136,26 +136,26 @@ export const invalidateFeatureAssetSchema = {
|
||||
};
|
||||
|
||||
export const voteDelegateAssetSchema = {
|
||||
$id: "lisk/dpos/vote",
|
||||
type: "object",
|
||||
required: ["votes"],
|
||||
$id: 'lisk/dpos/vote',
|
||||
type: 'object',
|
||||
required: ['votes'],
|
||||
properties: {
|
||||
votes: {
|
||||
type: "array",
|
||||
type: 'array',
|
||||
minItems: 1,
|
||||
maxItems: 20,
|
||||
items: {
|
||||
type: "object",
|
||||
required: ["delegateAddress", "amount"],
|
||||
type: 'object',
|
||||
required: ['delegateAddress', 'amount'],
|
||||
properties: {
|
||||
delegateAddress: {
|
||||
dataType: "bytes",
|
||||
dataType: 'bytes',
|
||||
fieldNumber: 1,
|
||||
minLength: 20,
|
||||
maxLength: 20,
|
||||
},
|
||||
amount: {
|
||||
dataType: "sint64",
|
||||
dataType: 'sint64',
|
||||
fieldNumber: 2,
|
||||
},
|
||||
},
|
||||
@@ -166,30 +166,30 @@ export const voteDelegateAssetSchema = {
|
||||
};
|
||||
|
||||
export const unlockDelegateAssetSchema = {
|
||||
$id: "lisk/dpos/unlock",
|
||||
type: "object",
|
||||
required: ["unlockObjects"],
|
||||
$id: 'lisk/dpos/unlock',
|
||||
type: 'object',
|
||||
required: ['unlockObjects'],
|
||||
properties: {
|
||||
unlockObjects: {
|
||||
type: "array",
|
||||
type: 'array',
|
||||
minItems: 1,
|
||||
maxItems: 20,
|
||||
items: {
|
||||
type: "object",
|
||||
required: ["delegateAddress", "amount", "unvoteHeight"],
|
||||
type: 'object',
|
||||
required: ['delegateAddress', 'amount', 'unvoteHeight'],
|
||||
properties: {
|
||||
delegateAddress: {
|
||||
dataType: "bytes",
|
||||
dataType: 'bytes',
|
||||
fieldNumber: 1,
|
||||
minLength: 20,
|
||||
maxLength: 20,
|
||||
},
|
||||
amount: {
|
||||
dataType: "uint64",
|
||||
dataType: 'uint64',
|
||||
fieldNumber: 2,
|
||||
},
|
||||
unvoteHeight: {
|
||||
dataType: "uint32",
|
||||
dataType: 'uint32',
|
||||
fieldNumber: 3,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -3,13 +3,13 @@ import { CSSTransition as ReactCSSTransition } from 'react-transition-group';
|
||||
|
||||
const TransitionContext = React.createContext({
|
||||
parent: {},
|
||||
})
|
||||
});
|
||||
|
||||
function useIsInitialRender() {
|
||||
const isInitialRender = useRef(true);
|
||||
useEffect(() => {
|
||||
isInitialRender.current = false;
|
||||
}, [])
|
||||
}, []);
|
||||
return isInitialRender.current;
|
||||
}
|
||||
|
||||
@@ -53,34 +53,40 @@ function CSSTransition({
|
||||
unmountOnExit={removeFromDom}
|
||||
in={show}
|
||||
addEndListener={(done) => {
|
||||
nodeRef.current.addEventListener('transitionend', done, false)
|
||||
nodeRef.current.addEventListener('transitionend', done, false);
|
||||
}}
|
||||
onEnter={() => {
|
||||
if (!removeFromDom) nodeRef.current.style.display = null;
|
||||
addClasses(nodeRef.current, [...enterClasses, ...enterStartClasses])
|
||||
addClasses(nodeRef.current, [...enterClasses, ...enterStartClasses]);
|
||||
}}
|
||||
onEntering={() => {
|
||||
removeClasses(nodeRef.current, enterStartClasses)
|
||||
addClasses(nodeRef.current, enterEndClasses)
|
||||
removeClasses(nodeRef.current, enterStartClasses);
|
||||
addClasses(nodeRef.current, enterEndClasses);
|
||||
}}
|
||||
onEntered={() => {
|
||||
removeClasses(nodeRef.current, [...enterEndClasses, ...enterClasses])
|
||||
removeClasses(nodeRef.current, [...enterEndClasses, ...enterClasses]);
|
||||
}}
|
||||
onExit={() => {
|
||||
addClasses(nodeRef.current, [...leaveClasses, ...leaveStartClasses])
|
||||
addClasses(nodeRef.current, [...leaveClasses, ...leaveStartClasses]);
|
||||
}}
|
||||
onExiting={() => {
|
||||
removeClasses(nodeRef.current, leaveStartClasses)
|
||||
addClasses(nodeRef.current, leaveEndClasses)
|
||||
removeClasses(nodeRef.current, leaveStartClasses);
|
||||
addClasses(nodeRef.current, leaveEndClasses);
|
||||
}}
|
||||
onExited={() => {
|
||||
removeClasses(nodeRef.current, [...leaveEndClasses, ...leaveClasses])
|
||||
removeClasses(nodeRef.current, [...leaveEndClasses, ...leaveClasses]);
|
||||
if (!removeFromDom) nodeRef.current.style.display = 'none';
|
||||
}}
|
||||
>
|
||||
<Component ref={nodeRef} {...rest} style={{ display: !removeFromDom ? 'none': null }}>{children}</Component>
|
||||
<Component
|
||||
ref={nodeRef}
|
||||
{...rest}
|
||||
style={{ display: !removeFromDom ? 'none' : null }}
|
||||
>
|
||||
{children}
|
||||
</Component>
|
||||
</ReactCSSTransition>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function Transition({ show, appear, ...rest }) {
|
||||
@@ -95,7 +101,7 @@ function Transition({ show, appear, ...rest }) {
|
||||
show={parent.show}
|
||||
{...rest}
|
||||
/>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -110,7 +116,7 @@ function Transition({ show, appear, ...rest }) {
|
||||
>
|
||||
<CSSTransition appear={appear} show={show} {...rest} />
|
||||
</TransitionContext.Provider>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
export default Transition;
|
||||
export default Transition;
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
import resolveConfig from "tailwindcss/resolveConfig";
|
||||
import { cryptography, transactions } from "@liskhq/lisk-client";
|
||||
import resolveConfig from 'tailwindcss/resolveConfig';
|
||||
import { cryptography, transactions } from '@liskhq/lisk-client';
|
||||
import {
|
||||
removeFeatureAssetSchema,
|
||||
setFeatureAssetSchema,
|
||||
unlockDelegateAssetSchema,
|
||||
validateFeatureAssetSchema,
|
||||
voteDelegateAssetSchema,
|
||||
} from "./Schemas";
|
||||
import { statusMap } from "../shared/statusMap";
|
||||
} from './Schemas';
|
||||
import { statusMap } from '../shared/statusMap';
|
||||
|
||||
export const tailwindConfig = () => {
|
||||
// Tailwind config
|
||||
return resolveConfig("./src/tailwind.config.js");
|
||||
return resolveConfig('./src/tailwind.config.js');
|
||||
};
|
||||
|
||||
export const hexToRGB = (h) => {
|
||||
@@ -31,17 +31,17 @@ export const hexToRGB = (h) => {
|
||||
};
|
||||
|
||||
export const formatValue = (value) =>
|
||||
Intl.NumberFormat("en-US", {
|
||||
style: "currency",
|
||||
currency: "USD",
|
||||
Intl.NumberFormat('en-US', {
|
||||
style: 'currency',
|
||||
currency: 'USD',
|
||||
maximumSignificantDigits: 3,
|
||||
notation: "compact",
|
||||
notation: 'compact',
|
||||
}).format(value);
|
||||
|
||||
export const formatThousands = (value) =>
|
||||
Intl.NumberFormat("en-US", {
|
||||
Intl.NumberFormat('en-US', {
|
||||
maximumSignificantDigits: 3,
|
||||
notation: "compact",
|
||||
notation: 'compact',
|
||||
}).format(value);
|
||||
|
||||
export const formatAddressBig = (address) =>
|
||||
@@ -50,12 +50,12 @@ export const formatAddressBig = (address) =>
|
||||
address.length - 4
|
||||
)} ${address.slice(address.length - 4)}`;
|
||||
|
||||
export const encryptAccountData = (data = [], passPhrase = "", pubKey = "") => {
|
||||
export const encryptAccountData = (data = [], passPhrase = '', pubKey = '') => {
|
||||
return data
|
||||
.filter((item) => item.status !== statusMap.blockchained)
|
||||
.map((item) => {
|
||||
let value = cryptography.encryptMessageWithPassphrase(
|
||||
item.seed + ":" + item.value,
|
||||
item.seed + ':' + item.value,
|
||||
passPhrase,
|
||||
pubKey
|
||||
);
|
||||
@@ -68,12 +68,12 @@ export const encryptAccountData = (data = [], passPhrase = "", pubKey = "") => {
|
||||
});
|
||||
};
|
||||
|
||||
export const encryptSharedData = (data = [], passPhrase = "", pubKey = "") => {
|
||||
export const encryptSharedData = (data = [], passPhrase = '', pubKey = '') => {
|
||||
return data.map((item) => {
|
||||
let value = cryptography.encryptMessageWithPassphrase(
|
||||
item.seed + ":" + item.value,
|
||||
item.seed + ':' + item.value,
|
||||
passPhrase,
|
||||
Buffer.from(pubKey, "hex")
|
||||
Buffer.from(pubKey, 'hex')
|
||||
);
|
||||
return {
|
||||
label: item.key,
|
||||
@@ -111,8 +111,8 @@ export const hashAccountData = (data = [], oldData = [], hashMap = {}) => {
|
||||
const changed = data.reduce((acc, item) => {
|
||||
if (!oldAccountMap[item.label]) return [...acc, item];
|
||||
const oldValue = hashMap[item.key];
|
||||
const newValue = hashValue(item.value, item.seed).toString("hex");
|
||||
if (oldValue !== newValue && item.status === "new") return [...acc, item];
|
||||
const newValue = hashValue(item.value, item.seed).toString('hex');
|
||||
if (oldValue !== newValue && item.status === 'new') return [...acc, item];
|
||||
return acc;
|
||||
}, []);
|
||||
return [
|
||||
@@ -128,22 +128,22 @@ export const hashAccountData = (data = [], oldData = [], hashMap = {}) => {
|
||||
};
|
||||
|
||||
export const jsonReplacer = (key, value) => {
|
||||
if (key === "big") {
|
||||
if (key === 'big') {
|
||||
return value.toString();
|
||||
}
|
||||
return value;
|
||||
};
|
||||
|
||||
export const hashValue = (value = "", seed = "") =>
|
||||
export const hashValue = (value = '', seed = '') =>
|
||||
cryptography.hash(
|
||||
Buffer.concat([Buffer.from(seed, "utf8"), cryptography.hash(value, "utf8")])
|
||||
Buffer.concat([Buffer.from(seed, 'utf8'), cryptography.hash(value, 'utf8')])
|
||||
);
|
||||
|
||||
export const generateTransaction = (
|
||||
nonce = BigInt(0),
|
||||
senderPublicKey = "",
|
||||
networkIdentifier = "",
|
||||
passPhrase = "",
|
||||
senderPublicKey = '',
|
||||
networkIdentifier = '',
|
||||
passPhrase = '',
|
||||
fee = BigInt(500000)
|
||||
) => {
|
||||
return {
|
||||
@@ -202,9 +202,9 @@ export const generateTransaction = (
|
||||
export const generateSetTransaction = (
|
||||
features,
|
||||
nonce = BigInt(0),
|
||||
senderPublicKey = "",
|
||||
networkIdentifier = "",
|
||||
passPhrase = "",
|
||||
senderPublicKey = '',
|
||||
networkIdentifier = '',
|
||||
passPhrase = '',
|
||||
fee = BigInt(500000)
|
||||
) => {
|
||||
const tx = {
|
||||
@@ -223,15 +223,15 @@ export const generateSetTransaction = (
|
||||
const signedTx = transactions.signTransaction(
|
||||
setFeatureAssetSchema,
|
||||
tx,
|
||||
Buffer.from(networkIdentifier, "hex"),
|
||||
Buffer.from(networkIdentifier, 'hex'),
|
||||
passPhrase
|
||||
);
|
||||
|
||||
signedTx.senderPublicKey = signedTx.senderPublicKey.toString("hex");
|
||||
signedTx.signatures[0] = signedTx.signatures[0].toString("hex");
|
||||
signedTx.senderPublicKey = signedTx.senderPublicKey.toString('hex');
|
||||
signedTx.signatures[0] = signedTx.signatures[0].toString('hex');
|
||||
signedTx.asset.features = signedTx.asset.features.map((feature) => ({
|
||||
...feature,
|
||||
value: feature.value.toString("hex"),
|
||||
value: feature.value.toString('hex'),
|
||||
}));
|
||||
|
||||
delete signedTx.id;
|
||||
@@ -242,9 +242,9 @@ export const generateSetTransaction = (
|
||||
export const generateRemoveTransaction = (
|
||||
features,
|
||||
nonce = BigInt(0),
|
||||
senderPublicKey = "",
|
||||
networkIdentifier = "",
|
||||
passPhrase = "",
|
||||
senderPublicKey = '',
|
||||
networkIdentifier = '',
|
||||
passPhrase = '',
|
||||
fee = BigInt(500000)
|
||||
) => {
|
||||
const tx = {
|
||||
@@ -260,12 +260,12 @@ export const generateRemoveTransaction = (
|
||||
const signedTx = transactions.signTransaction(
|
||||
removeFeatureAssetSchema,
|
||||
tx,
|
||||
Buffer.from(networkIdentifier, "hex"),
|
||||
Buffer.from(networkIdentifier, 'hex'),
|
||||
passPhrase
|
||||
);
|
||||
|
||||
signedTx.senderPublicKey = signedTx.senderPublicKey.toString("hex");
|
||||
signedTx.signatures[0] = signedTx.signatures[0].toString("hex");
|
||||
signedTx.senderPublicKey = signedTx.senderPublicKey.toString('hex');
|
||||
signedTx.signatures[0] = signedTx.signatures[0].toString('hex');
|
||||
|
||||
delete signedTx.id;
|
||||
|
||||
@@ -275,21 +275,21 @@ export const generateRemoveTransaction = (
|
||||
const generateValidateTransaction = (
|
||||
features,
|
||||
nonce = BigInt(0),
|
||||
senderPublicKey = "",
|
||||
networkIdentifier = "",
|
||||
passPhrase = "",
|
||||
senderPublicKey = '',
|
||||
networkIdentifier = '',
|
||||
passPhrase = '',
|
||||
fee = BigInt(500000),
|
||||
recipientAddress = ""
|
||||
recipientAddress = ''
|
||||
) => {
|
||||
const tx = {
|
||||
moduleID: 1001,
|
||||
assetID: 11,
|
||||
nonce,
|
||||
senderPublicKey: Buffer.from(senderPublicKey, "hex"),
|
||||
senderPublicKey: Buffer.from(senderPublicKey, 'hex'),
|
||||
fee,
|
||||
asset: {
|
||||
features,
|
||||
recipientAddress: Buffer.from(recipientAddress, "hex"),
|
||||
recipientAddress: Buffer.from(recipientAddress, 'hex'),
|
||||
},
|
||||
};
|
||||
|
||||
@@ -298,17 +298,17 @@ const generateValidateTransaction = (
|
||||
const signedTx = transactions.signTransaction(
|
||||
validateFeatureAssetSchema,
|
||||
tx,
|
||||
Buffer.from(networkIdentifier, "hex"),
|
||||
Buffer.from(networkIdentifier, 'hex'),
|
||||
passPhrase
|
||||
);
|
||||
|
||||
signedTx.senderPublicKey = signedTx.senderPublicKey.toString("hex");
|
||||
signedTx.senderPublicKey = signedTx.senderPublicKey.toString('hex');
|
||||
signedTx.asset.recipientAddress =
|
||||
signedTx.asset.recipientAddress.toString("hex");
|
||||
signedTx.signatures[0] = signedTx.signatures[0].toString("hex");
|
||||
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"),
|
||||
value: feature.value.toString('hex'),
|
||||
}));
|
||||
|
||||
delete signedTx.id;
|
||||
@@ -318,23 +318,23 @@ const generateValidateTransaction = (
|
||||
|
||||
const generateVoteTransaction = (
|
||||
nonce = BigInt(0),
|
||||
senderPublicKey = "",
|
||||
networkIdentifier = "",
|
||||
passPhrase = "",
|
||||
senderPublicKey = '',
|
||||
networkIdentifier = '',
|
||||
passPhrase = '',
|
||||
fee = BigInt(500000),
|
||||
delegateAddress = "",
|
||||
delegateAddress = '',
|
||||
amount = 0n
|
||||
) => {
|
||||
const tx = {
|
||||
moduleID: 5,
|
||||
assetID: 1,
|
||||
nonce,
|
||||
senderPublicKey: Buffer.from(senderPublicKey, "hex"),
|
||||
senderPublicKey: Buffer.from(senderPublicKey, 'hex'),
|
||||
fee,
|
||||
asset: {
|
||||
votes: [
|
||||
{
|
||||
delegateAddress: Buffer.from(delegateAddress, "hex"),
|
||||
delegateAddress: Buffer.from(delegateAddress, 'hex'),
|
||||
amount: amount * 100000000n,
|
||||
},
|
||||
],
|
||||
@@ -344,15 +344,15 @@ const generateVoteTransaction = (
|
||||
const signedTx = transactions.signTransaction(
|
||||
voteDelegateAssetSchema,
|
||||
tx,
|
||||
Buffer.from(networkIdentifier, "hex"),
|
||||
Buffer.from(networkIdentifier, 'hex'),
|
||||
passPhrase
|
||||
);
|
||||
|
||||
signedTx.senderPublicKey = signedTx.senderPublicKey.toString("hex");
|
||||
signedTx.signatures[0] = signedTx.signatures[0].toString("hex");
|
||||
signedTx.senderPublicKey = signedTx.senderPublicKey.toString('hex');
|
||||
signedTx.signatures[0] = signedTx.signatures[0].toString('hex');
|
||||
signedTx.asset.votes = signedTx.asset.votes.map((vote) => ({
|
||||
...vote,
|
||||
delegateAddress: vote.delegateAddress.toString("hex"),
|
||||
delegateAddress: vote.delegateAddress.toString('hex'),
|
||||
}));
|
||||
|
||||
delete signedTx.id;
|
||||
@@ -362,11 +362,11 @@ const generateVoteTransaction = (
|
||||
|
||||
const generateUnlockTransaction = (
|
||||
nonce = BigInt(0),
|
||||
senderPublicKey = "",
|
||||
networkIdentifier = "",
|
||||
passPhrase = "",
|
||||
senderPublicKey = '',
|
||||
networkIdentifier = '',
|
||||
passPhrase = '',
|
||||
fee = BigInt(500000),
|
||||
delegateAddress = "",
|
||||
delegateAddress = '',
|
||||
amount = 0n,
|
||||
unvoteHeight = 0
|
||||
) => {
|
||||
@@ -374,12 +374,12 @@ const generateUnlockTransaction = (
|
||||
moduleID: 5,
|
||||
assetID: 2,
|
||||
nonce,
|
||||
senderPublicKey: Buffer.from(senderPublicKey, "hex"),
|
||||
senderPublicKey: Buffer.from(senderPublicKey, 'hex'),
|
||||
fee,
|
||||
asset: {
|
||||
unlockObjects: [
|
||||
{
|
||||
delegateAddress: Buffer.from(delegateAddress, "hex"),
|
||||
delegateAddress: Buffer.from(delegateAddress, 'hex'),
|
||||
amount: amount * 100000000n,
|
||||
unvoteHeight,
|
||||
},
|
||||
@@ -390,15 +390,15 @@ const generateUnlockTransaction = (
|
||||
const signedTx = transactions.signTransaction(
|
||||
unlockDelegateAssetSchema,
|
||||
tx,
|
||||
Buffer.from(networkIdentifier, "hex"),
|
||||
Buffer.from(networkIdentifier, 'hex'),
|
||||
passPhrase
|
||||
);
|
||||
|
||||
signedTx.senderPublicKey = signedTx.senderPublicKey.toString("hex");
|
||||
signedTx.signatures[0] = signedTx.signatures[0].toString("hex");
|
||||
signedTx.senderPublicKey = signedTx.senderPublicKey.toString('hex');
|
||||
signedTx.signatures[0] = signedTx.signatures[0].toString('hex');
|
||||
signedTx.asset.unlockObjects = signedTx.asset.unlockObjects.map((vote) => ({
|
||||
...vote,
|
||||
delegateAddress: vote.delegateAddress.toString("hex"),
|
||||
delegateAddress: vote.delegateAddress.toString('hex'),
|
||||
}));
|
||||
|
||||
delete signedTx.id;
|
||||
|
||||
@@ -1,54 +1,81 @@
|
||||
import {labelMap} from "../shared/labelMap";
|
||||
import {statusMap} from "../shared/statusMap";
|
||||
import {cryptography} from "@liskhq/lisk-client";
|
||||
import { labelMap } from '../shared/labelMap';
|
||||
import { statusMap } from '../shared/statusMap';
|
||||
import { cryptography } from '@liskhq/lisk-client';
|
||||
|
||||
export const decryptedData=(serverData, blockchainData, passPhrase, pubKey, processedFeatures)=>{
|
||||
const allAccountData=serverData.concat(blockchainData.filter(item=>!serverData.find(elem=>elem.label===item.label)))
|
||||
export const decryptedData = (
|
||||
serverData,
|
||||
blockchainData,
|
||||
passPhrase,
|
||||
pubKey,
|
||||
processedFeatures
|
||||
) => {
|
||||
const allAccountData = serverData.concat(
|
||||
blockchainData.filter(
|
||||
(item) => !serverData.find((elem) => elem.label === item.label)
|
||||
)
|
||||
);
|
||||
return allAccountData.map((elem) => {
|
||||
const initialData={
|
||||
const initialData = {
|
||||
...elem,
|
||||
key: elem.label,
|
||||
label: labelMap[elem.label] || elem.label,
|
||||
status: '',
|
||||
value: '',
|
||||
seed: ''
|
||||
}
|
||||
if(processedFeatures[elem.label])
|
||||
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 {
|
||||
...initialData,
|
||||
status: statusMap.blockchained,
|
||||
value: elem.value
|
||||
}
|
||||
value: elem.value,
|
||||
};
|
||||
}
|
||||
const [seed, value] = cryptography.decryptMessageWithPassphrase(elem.value, elem.value_nonce, passPhrase, pubKey).split(':');
|
||||
const hashValue=cryptography.hash(Buffer.concat([Buffer.from(seed, 'utf8'), cryptography.hash(value, 'utf8')])).toString('hex')
|
||||
if(!blockchainData.find(item=>item.label===elem.label)) {
|
||||
const [seed, value] = cryptography
|
||||
.decryptMessageWithPassphrase(
|
||||
elem.value,
|
||||
elem.value_nonce,
|
||||
passPhrase,
|
||||
pubKey
|
||||
)
|
||||
.split(':');
|
||||
const hashValue = cryptography
|
||||
.hash(
|
||||
Buffer.concat([
|
||||
Buffer.from(seed, 'utf8'),
|
||||
cryptography.hash(value, 'utf8'),
|
||||
])
|
||||
)
|
||||
.toString('hex');
|
||||
if (!blockchainData.find((item) => item.label === elem.label)) {
|
||||
return {
|
||||
...initialData,
|
||||
status: statusMap.stored,
|
||||
value,
|
||||
seed
|
||||
}
|
||||
seed,
|
||||
};
|
||||
}
|
||||
if(blockchainData.find(item=>item.label===elem.label).value!==hashValue) {
|
||||
if (
|
||||
blockchainData.find((item) => item.label === elem.label).value !==
|
||||
hashValue
|
||||
) {
|
||||
return {
|
||||
...initialData,
|
||||
status: statusMap.incorrect,
|
||||
value,
|
||||
seed
|
||||
}
|
||||
seed,
|
||||
};
|
||||
}
|
||||
return {
|
||||
...initialData,
|
||||
status: statusMap.completed,
|
||||
value,
|
||||
seed
|
||||
}
|
||||
})
|
||||
}
|
||||
seed,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,31 +1,50 @@
|
||||
import {cryptography, passphrase} from "@liskhq/lisk-client";
|
||||
import sodium from 'sodium-universal';
|
||||
|
||||
let passphrase1 = passphrase.Mnemonic.generateMnemonic();
|
||||
const keys = cryptography.getPrivateAndPublicKeyFromPassphrase(passphrase1);
|
||||
console.log('IDNTTY Public & Private keys(hex):');
|
||||
console.log('publicKey:', keys.publicKey.length, keys.publicKey.toString('hex'));
|
||||
console.log('privateKey:', keys.privateKey.length, keys.privateKey.toString('hex'));
|
||||
|
||||
console.log('');
|
||||
console.log('SODIUM Public & Private keys(hex):');
|
||||
|
||||
let pk = Buffer.alloc(sodium.crypto_sign_PUBLICKEYBYTES);
|
||||
let sk = Buffer.alloc(sodium.crypto_sign_SECRETKEYBYTES);
|
||||
|
||||
let x25519_sk = Buffer.alloc(sodium.crypto_box_SECRETKEYBYTES);
|
||||
let x25519_pk = Buffer.alloc(sodium.crypto_box_PUBLICKEYBYTES);
|
||||
|
||||
sodium.crypto_sign_seed_keypair(pk, sk, cryptography.hash(Buffer.from(passphrase1, 'UTF-8')));
|
||||
|
||||
sodium.crypto_sign_ed25519_sk_to_curve25519(x25519_sk, sk);
|
||||
sodium.crypto_sign_ed25519_pk_to_curve25519(x25519_pk, pk)
|
||||
|
||||
console.log('Public & Private keys(hex):');
|
||||
console.log('publicKey:', pk.length, pk.toString('hex'));
|
||||
console.log('privateKey:', sk.length, sk.toString('hex'));
|
||||
console.log('');
|
||||
|
||||
console.log('x25519_sk privateKey:', x25519_sk.length, x25519_sk.toString('Base64'));
|
||||
console.log('x25519_pk publicKey:', x25519_pk.length, x25519_pk.toString('Base64'));
|
||||
|
||||
import { cryptography, passphrase } from '@liskhq/lisk-client';
|
||||
import sodium from 'sodium-universal';
|
||||
|
||||
let passphrase1 = passphrase.Mnemonic.generateMnemonic();
|
||||
const keys = cryptography.getPrivateAndPublicKeyFromPassphrase(passphrase1);
|
||||
console.log('IDNTTY Public & Private keys(hex):');
|
||||
console.log(
|
||||
'publicKey:',
|
||||
keys.publicKey.length,
|
||||
keys.publicKey.toString('hex')
|
||||
);
|
||||
console.log(
|
||||
'privateKey:',
|
||||
keys.privateKey.length,
|
||||
keys.privateKey.toString('hex')
|
||||
);
|
||||
|
||||
console.log('');
|
||||
console.log('SODIUM Public & Private keys(hex):');
|
||||
|
||||
let pk = Buffer.alloc(sodium.crypto_sign_PUBLICKEYBYTES);
|
||||
let sk = Buffer.alloc(sodium.crypto_sign_SECRETKEYBYTES);
|
||||
|
||||
let x25519_sk = Buffer.alloc(sodium.crypto_box_SECRETKEYBYTES);
|
||||
let x25519_pk = Buffer.alloc(sodium.crypto_box_PUBLICKEYBYTES);
|
||||
|
||||
sodium.crypto_sign_seed_keypair(
|
||||
pk,
|
||||
sk,
|
||||
cryptography.hash(Buffer.from(passphrase1, 'UTF-8'))
|
||||
);
|
||||
|
||||
sodium.crypto_sign_ed25519_sk_to_curve25519(x25519_sk, sk);
|
||||
sodium.crypto_sign_ed25519_pk_to_curve25519(x25519_pk, pk);
|
||||
|
||||
console.log('Public & Private keys(hex):');
|
||||
console.log('publicKey:', pk.length, pk.toString('hex'));
|
||||
console.log('privateKey:', sk.length, sk.toString('hex'));
|
||||
console.log('');
|
||||
|
||||
console.log(
|
||||
'x25519_sk privateKey:',
|
||||
x25519_sk.length,
|
||||
x25519_sk.toString('Base64')
|
||||
);
|
||||
console.log(
|
||||
'x25519_pk publicKey:',
|
||||
x25519_pk.length,
|
||||
x25519_pk.toString('Base64')
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user