Skip to content

Commit

Permalink
📍 adresGeçerli() hatasını düzelt ve test ekle
Browse files Browse the repository at this point in the history
  • Loading branch information
KimlikDAO-bot committed Apr 10, 2024
1 parent 80ef645 commit 4494ff5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
6 changes: 2 additions & 4 deletions ethereum/evm.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@ import { hex, hexten } from "../util/çevir";
*/
const adresDüzelt = (adres) => {
if (adres.length != 42 || !adres.startsWith("0x")) return null;
/** @type {string} */
let küçük = adres.slice(2).toLowerCase();
/** @const {string} */
const entropi = keccak256(küçük);
const entropi = keccak256(adres.slice(2).toLowerCase());
/** @type {boolean} */
let büyükVar = false;
/** @type {boolean} */
Expand Down Expand Up @@ -69,7 +67,7 @@ const adresGeçerli = (adres) => {
let c = adres.charCodeAt(i);
let e = entropi.charCodeAt(i);
if (65 <= c && c <= 90) {
if (c <= 55) return false;
if (e <= 55) return false;
} else if (97 <= c && c <= 122) {
if (e > 55) return false;
} else if (c < 48 || 57 < c) {
Expand Down
14 changes: 13 additions & 1 deletion ethereum/test/evm.compiled-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import evm from "/ethereum/evm";
import { assertEq } from "/testing/assert";
import { assert, assertEq } from "/testing/assert";

assertEq(evm.signerAddress(
evm.personalDigest("140e575468d2a8dcbcc437e0f12e37606491f1621fe71239b99b793cd590b7f4"),
Expand Down Expand Up @@ -56,3 +56,15 @@ assertEq(evm.signerAddress(
"728c381e23784ae164794f24bee158b569b20d17200315bcfacc7b6c0daae0601c")),
"0x79883d9acbc4abac6d2d216693f66fcc5a0bcbc1"
);

assertEq(evm.adresDüzelt("0xdDd1AC04c9251B74B0B30A20FC7cb26Eb62b1ddd"),
"0xdDd1AC04c9251B74B0B30A20FC7cb26Eb62b1ddd");

assertEq(evm.adresDüzelt("0xdDd1AC04c9251B74B0B30A20FC7cb26Eb62b1ddd".toLowerCase()),
"0xdDd1AC04c9251B74B0B30A20FC7cb26Eb62b1ddd");

assertEq(evm.adresDüzelt("0xdDd1AC04c9251B74B0B30A20FC7cb26Eb62b1dDd"), null);

assert(evm.adresGeçerli("0xdDd1AC04c9251B74B0B30A20FC7cb26Eb62b1ddd"));

assert(!evm.adresGeçerli("0xdDd1AC04c9251B74B0B30A20FC7cb26Eb62b1dDd"));

0 comments on commit 4494ff5

Please sign in to comment.