From 40bf5f39ad0b215f0ac2931406c675f65bf1ad80 Mon Sep 17 00:00:00 2001 From: "ildar.timerbaev" Date: Thu, 27 Jun 2024 00:19:51 +0600 Subject: [PATCH 1/2] Fixed hive engine transfer account checking for existence --- src/common/api/hive.ts | 8 ++++++-- src/common/components/transfer-he/index.tsx | 8 +++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/common/api/hive.ts b/src/common/api/hive.ts index a520bc93310..756f82d497a 100644 --- a/src/common/api/hive.ts +++ b/src/common/api/hive.ts @@ -1,10 +1,10 @@ -import { Client, RCAPI, SMTAsset, utils } from "@hiveio/dhive"; +import { Client, RCAPI, SMTAsset } from "@hiveio/dhive"; import { RCAccount } from "@hiveio/dhive/lib/chain/rc"; import { TrendingTag } from "../store/trending-tags/types"; import { DynamicProps } from "../store/dynamic-props/types"; -import { FullAccount, AccountProfile, AccountFollowStats } from "../store/accounts/types"; +import { AccountFollowStats, AccountProfile, FullAccount } from "../store/accounts/types"; import { Entry } from "../store/entries/types"; import parseAsset from "../helper/parse-asset"; @@ -147,6 +147,7 @@ export interface Reputations { account: string; reputation: number; } + interface ApiError { error: string; data: any; @@ -288,6 +289,9 @@ export const getAccounts = (usernames: string[]): Promise => { export const getAccount = async (username: string): Promise => { let aa = await getAccounts([username]).then((resp) => resp[0]); + if (!aa) { + throw new Error("Account not found"); + } let rp = await getAccountReputations(username, 1); return { ...aa, ...rp[0] }; }; diff --git a/src/common/components/transfer-he/index.tsx b/src/common/components/transfer-he/index.tsx index bf0c12d8510..e96925ca245 100644 --- a/src/common/components/transfer-he/index.tsx +++ b/src/common/components/transfer-he/index.tsx @@ -662,7 +662,7 @@ export class Transfer extends BaseComponent {
- + { className={amount > balance && amountError ? "is-invalid" : ""} autoFocus={mode !== "transfer"} /> - {asset}
@@ -747,7 +746,10 @@ export class Transfer extends BaseComponent {
{/* Changed && to || since it just allows the form to submit anyway initially */} -
From 1d770b7872a637c5dd37529e12954abae4ed512f Mon Sep 17 00:00:00 2001 From: "ildar.timerbaev" Date: Thu, 27 Jun 2024 00:24:06 +0600 Subject: [PATCH 2/2] Updated tests snapshots --- .../comment/__snapshots__/index.spec.tsx.snap | 4 +-- .../__snapshots__/index.spec.tsx.snap | 25 ------------------- .../__snapshots__/index.spec.tsx.snap | 8 +++--- 3 files changed, 6 insertions(+), 31 deletions(-) diff --git a/src/common/components/comment/__snapshots__/index.spec.tsx.snap b/src/common/components/comment/__snapshots__/index.spec.tsx.snap index 1c946b46810..f52fa773e6b 100644 --- a/src/common/components/comment/__snapshots__/index.spec.tsx.snap +++ b/src/common/components/comment/__snapshots__/index.spec.tsx.snap @@ -220,7 +220,7 @@ exports[`(1) Default render 1`] = `
@@ -586,7 +586,7 @@ exports[`(2) Cancellable, in progress 1`] = `
diff --git a/src/common/components/transfer-he/__snapshots__/index.spec.tsx.snap b/src/common/components/transfer-he/__snapshots__/index.spec.tsx.snap index e73a2f1b9af..afd57790955 100644 --- a/src/common/components/transfer-he/__snapshots__/index.spec.tsx.snap +++ b/src/common/components/transfer-he/__snapshots__/index.spec.tsx.snap @@ -134,11 +134,6 @@ exports[`(1) Hive Engine - Transfer (1) Step 1 1`] = ` type="text" value="0.001" /> - - -
@@ -731,11 +726,6 @@ exports[`(2) Hive Engine - Delegate (1) Step 1 1`] = ` type="text" value="0.001" /> - - - @@ -1128,11 +1118,6 @@ exports[`(3) Hive Engine - Undelegate (1) Step 1 1`] = ` type="text" value="0.001" /> - - - @@ -1552,11 +1537,6 @@ exports[`(4) Hive Engine - Stake (1) Step 1 1`] = ` type="text" value="0.001" /> - - - @@ -1936,11 +1916,6 @@ exports[`(5) Hive Engine - Unstake (1) Step 1 1`] = ` type="text" value="0.001" /> - - - diff --git a/src/common/components/wallet-hive-engine/__snapshots__/index.spec.tsx.snap b/src/common/components/wallet-hive-engine/__snapshots__/index.spec.tsx.snap index 4410d83d7fb..440c46fe54b 100644 --- a/src/common/components/wallet-hive-engine/__snapshots__/index.spec.tsx.snap +++ b/src/common/components/wallet-hive-engine/__snapshots__/index.spec.tsx.snap @@ -240,7 +240,7 @@ exports[`(2) Render with some hive engine tokens 1`] = ` > - $NaN + $0.00 @@ -556,7 +556,7 @@ exports[`(3) Render with an unclaimed rewards 1`] = ` > - $NaN + $0.00 @@ -854,7 +854,7 @@ exports[`(4) Render an empty list if tokens equals zero 1`] = ` > - $NaN + $0.00 @@ -1041,7 +1041,7 @@ exports[`(5) usePrivate = false 1`] = ` > - $NaN + $0.00