Skip to content

Commit

Permalink
Merge pull request #143 from ubq-testing/claimUxImprovs
Browse files Browse the repository at this point in the history
  • Loading branch information
0x4007 authored Oct 30, 2023
2 parents cac5625 + dafd135 commit 021535d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@
"yaml": "^2.2.2"
},
"packageManager": "[email protected]"
}
}
6 changes: 6 additions & 0 deletions static/scripts/rewards/toaster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ export function resetClaimButton() {
claimButton.element.classList.remove("show-cl");
}

export function hideClaimButton() {
claimButton.element.disabled = true;
claimButton.element.classList.add("hide-cl");
claimButton.element.classList.remove("show-cl");
}

export function errorToast(error: any, errorMessage?: string) {
delete error.stack;
let ErrorData = JSON.stringify(error, null, 2);
Expand Down
10 changes: 7 additions & 3 deletions static/scripts/rewards/web3/withdraw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import { ethers } from "ethers";
import { permit2Abi } from "../abis";
import { permit2Address } from "../constants";
import { TxType } from "../render-transaction/tx-type";
import { toaster, resetClaimButton, errorToast, loadingClaimButton } from "../toaster";
import { toaster, resetClaimButton, errorToast, loadingClaimButton, hideClaimButton } from "../toaster";
import { app } from "../render-transaction";
import { shortenAddress } from "../render-transaction/insert-table-data";

export async function withdraw(signer: JsonRpcSigner, txData: TxType, errorMessage?: string) {
const permit2Contract = new ethers.Contract(permit2Address, permit2Abi, signer);
Expand All @@ -13,8 +15,10 @@ export async function withdraw(signer: JsonRpcSigner, txData: TxType, errorMessa
// get success message
toaster.create("info", `Transaction sent`);
tx.wait().then((receipt: any) => {
toaster.create("success", `Transaction pending: ${receipt?.transactionHash}`);
loadingClaimButton(false); // disables the claim button
toaster.create("success", `Claim Complete: ${receipt?.transactionHash}`);
const requestedAmountElement = document.getElementById("transferDetails.requestedAmount") as Element;
requestedAmountElement.innerHTML += " has been claimed!";
hideClaimButton();
});
})
.catch((error: any) => {
Expand Down

1 comment on commit 021535d

@ubiquibot
Copy link

@ubiquibot ubiquibot bot commented on 021535d Oct 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.