Skip to content

Commit

Permalink
chore: validate caip address
Browse files Browse the repository at this point in the history
  • Loading branch information
magiziz committed Oct 15, 2024
1 parent 2680328 commit 4d542e8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/adapters/ethers/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -631,8 +631,9 @@ export class EthersAdapter {
if (provider) {
const { addresses, chainId } = await EthersHelpersUtil.getUserInfo(provider)
const firstAddress = addresses?.[0]
const caipAddress = `${this.chainNamespace}:${chainId}:${firstAddress}` as CaipAddress
const caipNetwork = this.caipNetworks.find(c => c.id === chainId) ?? this.caipNetworks[0]
const caipAddress =
`${this.chainNamespace}:${caipNetwork?.id}:${firstAddress}` as CaipAddress

if (firstAddress && caipNetwork) {
this.appKit?.setCaipNetwork(caipNetwork)
Expand Down
3 changes: 2 additions & 1 deletion packages/adapters/ethers5/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -607,8 +607,9 @@ export class Ethers5Adapter {
if (provider) {
const { addresses, chainId } = await EthersHelpersUtil.getUserInfo(provider)
const firstAddress = addresses?.[0]
const caipAddress = `${this.chainNamespace}:${chainId}:${firstAddress}` as CaipAddress
const caipNetwork = this.caipNetworks.find(c => c.id === chainId) ?? this.caipNetworks[0]
const caipAddress =
`${this.chainNamespace}:${caipNetwork?.id}:${firstAddress}` as CaipAddress

if (firstAddress && caipNetwork) {
this.appKit?.setCaipNetwork(caipNetwork)
Expand Down

0 comments on commit 4d542e8

Please sign in to comment.