Skip to content

Commit

Permalink
don't send stakeOk as part of the stake data
Browse files Browse the repository at this point in the history
  • Loading branch information
PudgyPug authored and mhanson-github committed Aug 20, 2024
1 parent 3af415f commit b62e467
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions components/StakeForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ interface StakeData {
nominee: string;
stake: string;
timestamp: number;
stakeOk: boolean;
}

type StakeFormProps = {
Expand All @@ -39,14 +38,14 @@ export default function StakeForm({
const ethereum = window.ethereum;
const { writeStakeLog } = useTXLogs();
const [isLoading, setLoading] = useState(false);
const [isStakeOk, setStakeOk] = useState(true);
const [data, setData] = useState<StakeData>({
isInternalTx: true,
internalTXType: 6,
nominator: nominator.toLowerCase(),
nominee,
stake: requiredStake,
timestamp: Date.now(),
stakeOk: true,
});

const createStakeLog = (
Expand Down Expand Up @@ -82,10 +81,10 @@ export default function StakeForm({
console.log("BLOB: ", blobData);
console.log(stakeAmount,totalStaked);
const value = ethers.BigNumber.from(data.stake);

const totalStakeBigNumber = ethers.BigNumber.from(totalStaked);
const stakeAmountBigNumber = ethers.utils.parseUnits(stakeAmount, "ether")

console.log(totalStakeBigNumber, stakeAmountBigNumber)
if (totalStakeBigNumber.lt(stakeAmountBigNumber) && value.lt(stakeAmountBigNumber)) {
errorFlag = true;
Expand Down Expand Up @@ -155,14 +154,14 @@ export default function StakeForm({
setData({
...data,
stake,
stakeOk: true,
});
setStakeOk(true)
} catch (e) {
console.error(e);
setData({
...data,
stakeOk: false,
});
setStakeOk(false)
}
}

Expand Down Expand Up @@ -201,7 +200,7 @@ export default function StakeForm({
/>
<div
className={`flex items-center mb-5 ${
!data.stakeOk ? "text-red-500" : ""
!isStakeOk ? "text-red-500" : ""
}`}
>
<div className="ml-2 font-semibold">
Expand All @@ -214,7 +213,7 @@ export default function StakeForm({
onClick={async () => sendTransaction()}
isLoading={isLoading}
className={`btn btn-primary ${
isLoading || !data.stakeOk ? "btn-disabled" : ""
isLoading || !isStakeOk ? "btn-disabled" : ""
}`}
>
Stake
Expand Down

0 comments on commit b62e467

Please sign in to comment.