diff --git a/packages/abi/src/util/address.spec.ts b/packages/abi/src/util/address.spec.ts index fe30b9d3..0ecea23a 100644 --- a/packages/abi/src/util/address.spec.ts +++ b/packages/abi/src/util/address.spec.ts @@ -80,6 +80,10 @@ describe('util/address', () => { expect(toChecksumAddress(undefined)).toEqual(''); }); + it('returns empty when null address specified', () => { + expect(toChecksumAddress(null)).toEqual(''); + }); + it('returns empty on invalid address structure', () => { expect(toChecksumAddress('0xnotaddress')).toEqual(''); }); diff --git a/packages/abi/src/util/address.ts b/packages/abi/src/util/address.ts index a6bf84d1..ede99c09 100644 --- a/packages/abi/src/util/address.ts +++ b/packages/abi/src/util/address.ts @@ -55,8 +55,8 @@ export const isAddress = (address?: string) => { * * @param address - The address to convert. */ -export const toChecksumAddress = (address: string = '') => { - const _address = address.toLowerCase(); +export const toChecksumAddress = (address?: string | null) => { + const _address = (address || '').toLowerCase(); if (!isAddress(_address)) { return '';