Skip to content

Commit

Permalink
Fixed hive engine transfer account checking for existence
Browse files Browse the repository at this point in the history
  • Loading branch information
dkildar committed Jun 26, 2024
1 parent fdcd701 commit 40bf5f3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 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
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

0 comments on commit 40bf5f3

Please sign in to comment.