Skip to content

Commit

Permalink
fix/AELF_24673724: Validation to check when to address and ledger add…
Browse files Browse the repository at this point in the history
…ress are same.
  • Loading branch information
Faizal-aelf committed Dec 4, 2023
1 parent 73d65e6 commit f1e8797
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion components/transactions/components/SendTransaction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,10 @@ function SendTransaction({
{
// eslint-disable-next-line no-unused-vars
async validator(_, value) {
validateAddress(value, chain);
const formattedAddress = validateAddress(value, chain);
if (formattedAddress === address) {
throw new Error("The sender and recipient address are identical");
}
return "";
},
},
Expand Down
1 change: 1 addition & 0 deletions utils/validateAddress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const validateAddress = (
if (!/^[a-zA-Z0-9]+$/.test(mid)) {
throw new Error("Oops! Please input a valid AELF network address!");
}
return mid;
} catch (err) {
throw new Error("Oops! Please input a valid AELF network address!");
}
Expand Down

0 comments on commit f1e8797

Please sign in to comment.