Skip to content

Commit

Permalink
Merge pull request #7 from daenamkim/noissue-lowercase-address
Browse files Browse the repository at this point in the history
Return lowercase accounts instead of the checksummed
  • Loading branch information
cawabunga authored Aug 24, 2023
2 parents e59e27a + a52b32e commit 5e8918f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions src/Web3ProviderBackend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ export class Web3ProviderBackend extends EventEmitter implements IWeb3Provider {
return this.waitAuthorization(
{ method, params },
async () => {
const accounts = await Promise.all(this.#wallets.map((wallet) => wallet.getAddress()))
const accounts = await Promise.all(
this.#wallets.map(async (wallet) => (await wallet.getAddress()).toLowerCase())
)
this.emit('accountsChanged', accounts)
return accounts
},
Expand All @@ -104,7 +106,9 @@ export class Web3ProviderBackend extends EventEmitter implements IWeb3Provider {

case 'eth_accounts': {
if (this._authorizedRequests['eth_requestAccounts']) {
return await Promise.all(this.#wallets.map((wallet) => wallet.getAddress()))
return await Promise.all(
this.#wallets.map(async (wallet) => (await wallet.getAddress()).toLowerCase())
)
}
return []
}
Expand Down Expand Up @@ -327,7 +331,7 @@ export class Web3ProviderBackend extends EventEmitter implements IWeb3Provider {
this.#wallets = privateKeys.map((key) => new ethers.Wallet(key))
this.emit(
'accountsChanged',
await Promise.all(this.#wallets.map((wallet) => wallet.getAddress()))
await Promise.all(this.#wallets.map(async (wallet) => (await wallet.getAddress()).toLowerCase()))
)
}

Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const test = base.extend<{
],

accounts: async ({ signers }, use) => {
await use(signers.map((k) => new ethers.Wallet(k).address))
await use(signers.map((k) => new ethers.Wallet(k).address.toLowerCase()))
},

injectWeb3Provider: async ({ page, signers }, use) => {
Expand Down

0 comments on commit 5e8918f

Please sign in to comment.