Skip to content

Commit

Permalink
fix: ensure account addresses are checksummed
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderwende committed Dec 8, 2023
1 parent da08e88 commit 2833871
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/connection/providers/browser/provider.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { providers } from 'ethers';
import { providers, utils } from 'ethers';
import { ListenerManager, schedule } from '../../../utils/index.js';
import { ERRORS } from '../../errors.js';
import { CONNECTION_EVENTS, type Account, type ConnectionEvents, type ConnectionProvider } from '../../interfaces.js';
Expand Down Expand Up @@ -101,6 +101,9 @@ export class BrowserConnectionProvider implements ConnectionProvider {

// lookup ens names for connected accounts
const accounts = await Promise.all<Account>(addresses.map(async (address) => {
// checksum the address
address = utils.getAddress(address);
// lookup the ens name for the address
const ensAddress = await provider.lookupAddress(address)
.catch((error) => {
console.warn(`ENS lookup failed for ${ address }: `, error);
Expand Down
5 changes: 3 additions & 2 deletions src/connection/providers/mock/provider.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Provider } from '@ethersproject/abstract-provider';
import { Signer } from '@ethersproject/abstract-signer';
import { BigNumber } from 'ethers';
import { BigNumber, utils } from 'ethers';
import { ListenerManager, schedule } from '../../../utils/index.js';
import { CONNECTION_EVENTS, type ConnectionEvents, type ConnectionProvider } from '../../interfaces.js';
import { DEFAULT_CONNECTION_OPTIONS, MockConnection, MockConnectionOptions } from './connection.js';
Expand Down Expand Up @@ -79,7 +79,8 @@ export class MockConnectionProvider implements ConnectionProvider {
name: connectionOptions.networkName,
},
account: {
address: connectionOptions.address,
// ensure address is checksummed
address: utils.getAddress(connectionOptions.address),
ensAddress: connectionOptions.ensAddress,
},
provider,
Expand Down

0 comments on commit 2833871

Please sign in to comment.