Skip to content

Commit

Permalink
Merge pull request #1620 from ecency/bugfix/hive-engine-check-account
Browse files Browse the repository at this point in the history
Fixed hive engine transfer account checking for existence
  • Loading branch information
feruzm authored Jun 26, 2024
2 parents fdcd701 + 1d770b7 commit 422cf97
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 36 deletions.
8 changes: 6 additions & 2 deletions src/common/api/hive.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -147,6 +147,7 @@ export interface Reputations {
account: string;
reputation: number;
}

interface ApiError {
error: string;
data: any;
Expand Down Expand Up @@ -288,6 +289,9 @@ export const getAccounts = (usernames: string[]): Promise<FullAccount[]> => {

export const getAccount = async (username: string): Promise<FullAccount> => {
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] };
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ exports[`(1) Default render 1`] = `
</div>
<div
className="editor-tool"
id="editor-tool-emoji-picker-f1601f2b-75bc-473e-b659-2525491c76ab"
id="editor-tool-emoji-picker-b4042e26-e45c-4b7d-a94a-bfb60c4f6527"
role="none"
title="Emoji"
>
Expand Down Expand Up @@ -586,7 +586,7 @@ exports[`(2) Cancellable, in progress 1`] = `
</div>
<div
className="editor-tool"
id="editor-tool-emoji-picker-7005da35-392b-43e6-b1b6-870862697a79"
id="editor-tool-emoji-picker-ef341785-4ebe-4d75-9b1e-f7206c6582a4"
role="none"
title="Emoji"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,6 @@ exports[`(1) Hive Engine - Transfer (1) Step 1 1`] = `
type="text"
value="0.001"
/>
<span
className="balance-num align-self-center ml-1"
>
</span>
</div>
</div>
</div>
Expand Down Expand Up @@ -731,11 +726,6 @@ exports[`(2) Hive Engine - Delegate (1) Step 1 1`] = `
type="text"
value="0.001"
/>
<span
className="balance-num align-self-center ml-1"
>
</span>
</div>
</div>
</div>
Expand Down Expand Up @@ -1128,11 +1118,6 @@ exports[`(3) Hive Engine - Undelegate (1) Step 1 1`] = `
type="text"
value="0.001"
/>
<span
className="balance-num align-self-center ml-1"
>
</span>
</div>
</div>
</div>
Expand Down Expand Up @@ -1552,11 +1537,6 @@ exports[`(4) Hive Engine - Stake (1) Step 1 1`] = `
type="text"
value="0.001"
/>
<span
className="balance-num align-self-center ml-1"
>
</span>
</div>
</div>
</div>
Expand Down Expand Up @@ -1936,11 +1916,6 @@ exports[`(5) Hive Engine - Unstake (1) Step 1 1`] = `
type="text"
value="0.001"
/>
<span
className="balance-num align-self-center ml-1"
>
</span>
</div>
</div>
</div>
Expand Down
8 changes: 5 additions & 3 deletions src/common/components/transfer-he/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ export class Transfer extends BaseComponent<Props, State> {
<label>{_t("transfer.amount")}</label>
</div>
<div className="col-span-12 sm:col-span-10 flex items-center">
<InputGroup prepend="#">
<InputGroup prepend="#" append={asset}>
<FormControl
type="text"
placeholder={_t("transfer.amount-placeholder")}
Expand All @@ -671,7 +671,6 @@ export class Transfer extends BaseComponent<Props, State> {
className={amount > balance && amountError ? "is-invalid" : ""}
autoFocus={mode !== "transfer"}
/>
<span className="balance-num align-self-center ml-1">{asset}</span>
</InputGroup>
</div>
</div>
Expand Down Expand Up @@ -747,7 +746,10 @@ export class Transfer extends BaseComponent<Props, State> {
<div className="grid items-center grid-cols-12 mb-4">
<div className="col-span-12 sm:col-span-10 sm:col-start-3">
{/* Changed && to || since it just allows the form to submit anyway initially */}
<Button onClick={this.next} disabled={!this.canSubmit() || amount > balance}>
<Button
onClick={this.next}
disabled={!this.canSubmit() || amount > balance || !!toError}
>
{_t("g.next")}
</Button>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ exports[`(2) Render with some hive engine tokens 1`] = `
>
<span>
$NaN
$0.00
</span>
</div>
Expand Down Expand Up @@ -556,7 +556,7 @@ exports[`(3) Render with an unclaimed rewards 1`] = `
>
<span>
$NaN
$0.00
</span>
</div>
Expand Down Expand Up @@ -854,7 +854,7 @@ exports[`(4) Render an empty list if tokens equals zero 1`] = `
>
<span>
$NaN
$0.00
</span>
</div>
Expand Down Expand Up @@ -1041,7 +1041,7 @@ exports[`(5) usePrivate = false 1`] = `
>
<span>
$NaN
$0.00
</span>
</div>
Expand Down

0 comments on commit 422cf97

Please sign in to comment.