Skip to content

Commit

Permalink
Refactor address validation: update isAddress method to return Contra…
Browse files Browse the repository at this point in the history
…ctAddress type for improved type safety
  • Loading branch information
yavrsky committed Jan 9, 2025
1 parent a1e10e1 commit 042560e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion typescript/ethers-v5/src/ethers5Adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import {
FunctionCall
} from "@skalenetwork/skale-contracts";
import { BaseContract, ethers } from "ethers";
import {
ContractAddress
} from "@skalenetwork/skale-contracts/lib/domain/types";
import { Provider } from "@ethersproject/providers";


Expand Down Expand Up @@ -47,7 +50,7 @@ export class Ethers5Adapter implements Adapter<BaseContract> {
}

// eslint-disable-next-line class-methods-use-this
isAddress (value: string): boolean {
isAddress (value: string): value is ContractAddress {
return ethers.utils.isAddress(value);
}
}
5 changes: 4 additions & 1 deletion typescript/ethers-v6/src/ethers6Adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import {
FunctionCall
} from "@skalenetwork/skale-contracts";
import { BaseContract, Provider, ethers } from "ethers";
import {
ContractAddress
} from "@skalenetwork/skale-contracts/lib/domain/types";


export class Ethers6Adapter implements Adapter<BaseContract> {
Expand Down Expand Up @@ -46,7 +49,7 @@ export class Ethers6Adapter implements Adapter<BaseContract> {
}

// eslint-disable-next-line class-methods-use-this
isAddress (value: string): boolean {
isAddress (value: string): value is ContractAddress {
return ethers.isAddress(value);
}
}

0 comments on commit 042560e

Please sign in to comment.