Skip to content

Commit

Permalink
Changes to the javascript-sdk-migration branch (#619)
Browse files Browse the repository at this point in the history
* Account.isValidPair method used in repo

* correct implementation of Account.isValidPair method

* Removed unnecessary use of 'as' keyword
  • Loading branch information
tomijaga authored Apr 29, 2021
1 parent 2a785d1 commit a69c023
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 31 deletions.
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
"resolve-url-loader": "^3.1.2",
"semver": "7.3.2",
"terser-webpack-plugin": "^4.2.3",
"thenewboston": "^1.1.0-alpha.3",
"thenewboston": "^1.1.0-alpha.4",
"ts-pnp": "^1.2.0",
"tweetnacl": "^1.0.3",
"typeface-roboto": "^0.0.75",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,8 @@ const AddValidatorSigningKeysModal: FC<ComponentProps> = ({close}) => {
close();
};

const checkPrivateSigningKey = (publicKey: string, privateKey: string): boolean => {
try {
const {accountNumberHex} = new Account(privateKey);
return accountNumberHex === publicKey;
} catch (error) {
return false;
}
};
const checkPrivateSigningKey = (publicKey: string, privateKey: string): boolean =>
Account.isValidPair(privateKey, publicKey);

const validationSchema = useMemo(() => {
return yup.object().shape({
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/dispatchers/banks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export const fetchBankConfig = (address: string) => async (
): Promise<{address: string; data?: BankConfig; error?: any}> => {
try {
const rawData = await new Bank(address).getConfig();
const data = sanitizePortFieldFromRawBankConfig(rawData as RawBankConfig);
const data = sanitizePortFieldFromRawBankConfig(rawData);

if (data.node_type !== NodeType.bank) {
const errorObject = {address, error: 'Node not a bank'};
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/dispatchers/validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const fetchValidatorConfig = (address: string) => async (

const rawData = await validator.getConfig();

const data = sanitizePortFieldFromRawValidatorConfig(rawData as RawValidatorConfig);
const data = sanitizePortFieldFromRawValidatorConfig(rawData);

if (data.node_type !== NodeType.primaryValidator && data.node_type !== NodeType.confirmationValidator) {
const errorObject = {address, error: 'Node not a validator'};
Expand Down
6 changes: 2 additions & 4 deletions src/renderer/hooks/useCleanSockets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,13 @@ const useCleanSockets = (): void => {
node = new Bank(address);
const nodeConfig = await node.getConfig();

if (nodeConfig.node_type === NodeType.confirmationValidator) {
if (nodeConfig.node_type !== NodeType.bank) {
node = new ConfirmationValidator(address);
}

const inCleaning = cleanSocket.clean_status === CleanStatus.cleaning;

const data = inCleaning
? ((await node.stopClean(socketNetworkId)) as NodeCleanStatusWithAddress)
: ((await node.startClean(socketNetworkId)) as NodeCleanStatusWithAddress);
const data = inCleaning ? await node.stopClean(socketNetworkId) : await node.startClean(socketNetworkId);

dispatch(
updateCleanProcess({
Expand Down
6 changes: 3 additions & 3 deletions src/renderer/hooks/useCrawlSockets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ const useCrawlSockets = (): void => {
node = new Bank(address);
const nodeConfig = await node.getConfig();

if (nodeConfig.node_type === NodeType.confirmationValidator) {
if (nodeConfig.node_type !== NodeType.bank) {
node = new ConfirmationValidator(address);
}

const inCrawling = crawlSocket.crawl_status === CrawlStatus.crawling;

const data = inCrawling
? ((await node.stopCrawl(socketNetworkKeyPair)) as NodeCrawlStatusWithAddress)
: ((await node.startCrawl(socketNetworkKeyPair)) as NodeCrawlStatusWithAddress);
? await node.stopCrawl(socketNetworkKeyPair)
: await node.startCrawl(socketNetworkKeyPair);

dispatch(
updateCrawlProcess({
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/hooks/useNetworkCleanFetcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ const useNetworkCleanFetcher = (
node = new Bank(address);
const nodeConfig = await node.getConfig();

if (nodeConfig.node_type === NodeType.confirmationValidator) {
if (nodeConfig.node_type !== NodeType.bank) {
node = new ConfirmationValidator(address);
}

const data = (await node.getCleanStatus()) as NodeCleanStatusWithAddress;
const data = await node.getCleanStatus();

setCleanStatus(data.clean_status || CleanStatus.notCleaning);
setCleanLastCompleted(data.clean_last_completed);
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/hooks/useNetworkCrawlFetcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ const useNetworkCrawlFetcher = (
node = new Bank(address);
const nodeConfig = await node.getConfig();

if (nodeConfig.node_type === NodeType.confirmationValidator) {
if (nodeConfig.node_type !== NodeType.bank) {
node = new ConfirmationValidator(address);
}

const data = (await node.getCrawlStatus()) as NodeCrawlStatusWithAddress;
const data = await node.getCrawlStatus();

setCrawlStatus(data.crawl_status || CrawlStatus.notCrawling);
setCrawlLastCompleted(data.crawl_last_completed);
Expand Down

0 comments on commit a69c023

Please sign in to comment.