diff --git a/packages/utils/src/type-checks.ts b/packages/utils/src/type-checks.ts index ed9ec2eea..3d42997ca 100644 --- a/packages/utils/src/type-checks.ts +++ b/packages/utils/src/type-checks.ts @@ -21,6 +21,7 @@ const supportedTypes = [ "bigint", "stringified-bigint", "hexadecimal", + "bignumber", "bignumberish" ] as const @@ -185,6 +186,8 @@ export function isType(value: any, type: SupportedType): boolean { return isStringifiedBigInt(value) case "hexadecimal": return isHexadecimal(value) + case "bignumber": + return isBigNumber(value) case "bignumberish": return isBigNumberish(value) default: diff --git a/packages/utils/tests/type-checks.test.ts b/packages/utils/tests/type-checks.test.ts index b8801866e..a4bb6f1c7 100644 --- a/packages/utils/tests/type-checks.test.ts +++ b/packages/utils/tests/type-checks.test.ts @@ -129,6 +129,9 @@ describe("# type-checks", () => { expect(isType(BigInt(1), "bigint")).toBeTruthy() expect(isType("1242342342342342", "stringified-bigint")).toBeTruthy() expect(isType("0x12", "hexadecimal")).toBeTruthy() + expect(isType(BigInt(1), "bignumber")).toBeTruthy() + expect(isType("123", "bignumber")).toBeTruthy() + expect(isType("0xa123", "bignumber")).toBeTruthy() expect(isType(1, "bignumberish")).toBeTruthy() }) @@ -143,6 +146,8 @@ describe("# type-checks", () => { expect(isType(1, "bigint")).toBeFalsy() expect(isType(1, "stringified-bigint")).toBeFalsy() expect(isType(1, "hexadecimal")).toBeFalsy() + expect(isType(1, "bignumber")).toBeFalsy() + expect(isType("string", "bignumber")).toBeFalsy() expect(isType("string", "bignumberish")).toBeFalsy() expect(isType(1, "type" as any)).toBeFalsy() })