Skip to content

Commit

Permalink
fix: update error formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
ariesgun committed Oct 25, 2024
1 parent eb07da2 commit 2eab98d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion static/scripts/rewards/web3/erc20-permit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export async function transferFromPermit(permit2Contract: Contract, reward: Perm
buttonController.showMakeClaim();
} else {
const { errorname, message } = decodeError(permit2Contract, e);
console.error(`Error in permitTransferFrom: ${errorname} [ ${message} ]`);
console.error(`Error in permitTransferFrom: ${errorname} ${message}`);
errorToast(e, e.reason);
}
}
Expand Down
2 changes: 1 addition & 1 deletion static/scripts/rewards/web3/erc721-permit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export function claimErc721PermitHandler(reward: ERC721Permit) {
buttonController.showMakeClaim();
} else {
const { errorname, message } = decodeError(nftContract, e);
console.error(`Error claiming NFT: ${errorname} [ ${message} ]`);
console.error(`Error claiming NFT: ${errorname} ${message}`);
errorToast(e, e.reason);
}
} else if (typeof error === "string") {
Expand Down
4 changes: 3 additions & 1 deletion static/scripts/rewards/web3/error-decoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ export function decodeError(contract: Contract, err: MetaMaskError) {
const res = iface.decodeErrorResult(selecter, errordata);
const errorfragments = iface.getError(selecter);

let message;
let message = "";
if (errorfragments.inputs.length > 0) {
message += "[ ";
message = errorfragments.inputs
.map((input, index) => {
return `${input.name}: ${res[index].toString()}`;
})
.join(", ");
message += " ]";
}

return {
Expand Down

0 comments on commit 2eab98d

Please sign in to comment.