fix header mistake

This commit is contained in:
kandrusyak
2022-12-01 16:21:02 +03:00
parent a8bb75b2f5
commit 3e8a0e2233

View File

@@ -3,27 +3,27 @@ import {
makeAutoObservable, makeAutoObservable,
onBecomeObserved, onBecomeObserved,
onBecomeUnobserved, onBecomeUnobserved,
} from 'mobx'; } from "mobx";
import { cryptography } from '@liskhq/lisk-client'; import { cryptography } from "@liskhq/lisk-client";
import { passphrase } 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 { decryptedData } from '../utils/decryptedData'; import { decryptedData } from "../utils/decryptedData";
import { import {
encryptAccountData, encryptAccountData,
encryptSharedData, encryptSharedData,
generateTransaction, generateTransaction,
hashAccountData, hashAccountData,
} from '../utils/Utils'; } from "../utils/Utils";
import sodium from 'sodium-universal'; import sodium from "sodium-universal";
class Store { class Store {
_accountData = []; _accountData = [];
_passPhrase = ''; _passPhrase = "";
_nodeInfo = {}; _nodeInfo = {};
@@ -63,18 +63,18 @@ class Store {
() => this.address, () => this.address,
() => this.fetchAccountInfo() () => this.fetchAccountInfo()
); );
onBecomeObserved(this, 'decryptedAccountData', () => onBecomeObserved(this, "decryptedAccountData", () =>
this.fetchNewAccountData() this.fetchNewAccountData()
); );
onBecomeUnobserved(this, 'decryptedAccountData', () => onBecomeUnobserved(this, "decryptedAccountData", () =>
this.unobservedAccountData() 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', () => onBecomeObserved(this, "transactionsInfo", () =>
this.fetchTransactionsInfo() this.fetchTransactionsInfo()
); );
onBecomeUnobserved(this, 'transactionsInfo', () => onBecomeUnobserved(this, "transactionsInfo", () =>
this.unobservedTransactionsInfo() this.unobservedTransactionsInfo()
); );
@@ -83,7 +83,10 @@ class Store {
fetchVPNServers() { fetchVPNServers() {
fetchWrapper fetchWrapper
.getAuth('vpn/servers') .getAuth("vpn/servers", {
networkIdentifier: this.nodeInfo.networkIdentifier,
lastBlockID: this.nodeInfo.lastBlockID,
})
.then((r) => this.fetchVPNServersSuccess(r)); .then((r) => this.fetchVPNServersSuccess(r));
} }
@@ -98,7 +101,7 @@ class Store {
.then((info) => { .then((info) => {
this.fetchNodeInfoSuccess(info); this.fetchNodeInfoSuccess(info);
fetchWrapper fetchWrapper
.getAuth('data/private', { .getAuth("data/private", {
networkIdentifier: this.nodeInfo.networkIdentifier, networkIdentifier: this.nodeInfo.networkIdentifier,
lastBlockID: this.nodeInfo.lastBlockID, lastBlockID: this.nodeInfo.lastBlockID,
}) })
@@ -120,7 +123,7 @@ class Store {
.then((info) => { .then((info) => {
this.fetchNodeInfoSuccess(info); this.fetchNodeInfoSuccess(info);
fetchWrapper fetchWrapper
.getAuth('data/shared/', { .getAuth("data/shared/", {
networkIdentifier: this.nodeInfo.networkIdentifier, networkIdentifier: this.nodeInfo.networkIdentifier,
lastBlockID: this.nodeInfo.lastBlockID, lastBlockID: this.nodeInfo.lastBlockID,
}) })
@@ -141,13 +144,13 @@ class Store {
fetchTempTransactions() { fetchTempTransactions() {
fetchWrapper fetchWrapper
.get('node/transactions') .get("node/transactions")
.then((res) => this.fetchTempTransactionsSuccess(res)) .then((res) => this.fetchTempTransactionsSuccess(res))
.catch((err) => this.throwError(err)); .catch((err) => this.throwError(err));
} }
fetchPassPhrase() { fetchPassPhrase() {
this._passPhrase = sessionStorage.getItem('passPhrase') || ''; this._passPhrase = sessionStorage.getItem("passPhrase") || "";
} }
fetchSharedData() { fetchSharedData() {
@@ -170,7 +173,7 @@ class Store {
if (data.length > 0) { if (data.length > 0) {
fetchWrapper fetchWrapper
.postAuth( .postAuth(
'data/shared', "data/shared",
{ {
networkIdentifier: this.nodeInfo.networkIdentifier, networkIdentifier: this.nodeInfo.networkIdentifier,
lastBlockID: this.nodeInfo.lastBlockID, lastBlockID: this.nodeInfo.lastBlockID,
@@ -187,7 +190,7 @@ class Store {
pushAccountData(data = this.accountData) { pushAccountData(data = this.accountData) {
fetchWrapper fetchWrapper
.postAuth( .postAuth(
'data/private', "data/private",
{ {
networkIdentifier: this.nodeInfo.networkIdentifier, networkIdentifier: this.nodeInfo.networkIdentifier,
lastBlockID: this.nodeInfo.lastBlockID, lastBlockID: this.nodeInfo.lastBlockID,
@@ -218,7 +221,7 @@ class Store {
if (changed.length !== 0) signedTx = builder.update(changed); if (changed.length !== 0) signedTx = builder.update(changed);
if (signedTx) { if (signedTx) {
fetchWrapper fetchWrapper
.post('transactions', {}, signedTx) .post("transactions", {}, signedTx)
.then(() => this.fetchTempTransactions()) .then(() => this.fetchTempTransactions())
.catch((err) => this.throwError(err)); .catch((err) => this.throwError(err));
this.accountInfo.sequence.nonce++; this.accountInfo.sequence.nonce++;
@@ -237,7 +240,7 @@ class Store {
if (signedTx) { if (signedTx) {
fetchWrapper fetchWrapper
.post('transactions', {}, signedTx) .post("transactions", {}, signedTx)
.then(() => this.fetchTempTransactions()) .then(() => this.fetchTempTransactions())
.catch((err) => this.throwError(err)); .catch((err) => this.throwError(err));
this.accountInfo.sequence.nonce++; this.accountInfo.sequence.nonce++;
@@ -259,7 +262,7 @@ class Store {
if (signedTx) { if (signedTx) {
fetchWrapper fetchWrapper
.post('transactions', {}, signedTx) .post("transactions", {}, signedTx)
.then(() => this.fetchTempTransactions()) .then(() => this.fetchTempTransactions())
.catch((err) => this.throwError(err)); .catch((err) => this.throwError(err));
this.accountInfo.sequence.nonce++; this.accountInfo.sequence.nonce++;
@@ -268,12 +271,12 @@ class Store {
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() {
@@ -395,12 +398,12 @@ class Store {
} }
get firstName() { get firstName() {
return this.decryptedAccountData.find((item) => item.key === 'firstname') return this.decryptedAccountData.find((item) => item.key === "firstname")
?.value; ?.value;
} }
get lastName() { get lastName() {
return this.decryptedAccountData.find((item) => item.key === 'secondname') return this.decryptedAccountData.find((item) => item.key === "secondname")
?.value; ?.value;
} }
@@ -441,27 +444,27 @@ class Store {
let x25519_sk = Buffer.alloc(sodium.crypto_box_SECRETKEYBYTES); let x25519_sk = Buffer.alloc(sodium.crypto_box_SECRETKEYBYTES);
sodium.crypto_sign_ed25519_sk_to_curve25519( sodium.crypto_sign_ed25519_sk_to_curve25519(
x25519_sk, x25519_sk,
Buffer.from(this.privateKey, 'hex') Buffer.from(this.privateKey, "hex")
); );
return x25519_sk.toString('Base64'); return x25519_sk.toString("Base64");
} }
get pubKey() { get pubKey() {
return this.addressAndPubKey.publicKey.toString('hex'); return this.addressAndPubKey.publicKey.toString("hex");
} }
get address() { get address() {
return this.addressAndPubKey.address.toString('hex'); return this.addressAndPubKey.address.toString("hex");
} }
get tokenKey() { get tokenKey() {
const stringToSign = const stringToSign =
this.nodeInfo.networkIdentifier + this.nodeInfo.lastBlockID; this.nodeInfo.networkIdentifier + this.nodeInfo.lastBlockID;
if (!stringToSign) return ''; if (!stringToSign) return "";
const sign = cryptography const sign = cryptography
.signDataWithPassphrase(Buffer.from(stringToSign, 'hex'), this.passPhrase) .signDataWithPassphrase(Buffer.from(stringToSign, "hex"), this.passPhrase)
.toString('hex'); .toString("hex");
return this.pubKey + ':' + sign; return this.pubKey + ":" + sign;
} }
get accountIdentity() { get accountIdentity() {
@@ -608,13 +611,13 @@ class Store {
let amount = this.processedVotes[address]; let amount = this.processedVotes[address];
if (amount) return 'Pending'; if (amount) return "Pending";
amount = this.accountSentVotes[address]; amount = this.accountSentVotes[address];
if (amount) return 'Unvote'; if (amount) return "Unvote";
return 'Vote'; return "Vote";
}; };
return this._delegates.data.map((delegate) => ({ return this._delegates.data.map((delegate) => ({