Skip to content

Commit

Permalink
fix(wagmi): Remove trust wallet chain checking (#7421)
Browse files Browse the repository at this point in the history
<!--
Before opening a pull request, please read the [contributing
guidelines](https://github.com/pancakeswap/pancake-frontend/blob/develop/CONTRIBUTING.md)
first
-->

<!--
copilot:all
-->
### <samp>🤖 Generated by Copilot at 17be510</samp>

### Summary
🧹🔥🔄

<!--
1. 🧹 - This emoji can be used to indicate that the code was cleaned up
or refactored, as it suggests sweeping away the dust or clutter.
2. 🔥 - This emoji can be used to indicate that the code was simplified
or removed unnecessary parts, as it suggests burning away the excess or
unwanted elements.
3. 🔄 - This emoji can be used to indicate that the code was renamed or
changed in some way, as it suggests rotating or updating something.
-->
Refactored the `TrustWalletConnector` class in `trustWallet.ts` to
improve readability and remove unnecessary code.

> _We're trimming down the code, me hearties, yo ho ho_
> _We're tossing out the junk that we don't need to know_
> _We're renaming `options` to `config`, that's the plan_
> _We're working on the `TrustWalletConnector`, yes we can_

### Walkthrough
* Remove unused and redundant `mappingNetwork` object from
`trustWallet.ts`
([link](https://github.com/pancakeswap/pancake-frontend/pull/7421/files?diff=unified&w=0#diff-5e4f26574d007c8c9ac7a365a57f0c7ada4afe65e1e49a1e42f27856c6f745baL16-L22))
* Rename `_chains` parameter to `chains` for clarity and consistency in
`TrustWalletConnector` constructor
([link](https://github.com/pancakeswap/pancake-frontend/pull/7421/files?diff=unified&w=0#diff-5e4f26574d007c8c9ac7a365a57f0c7ada4afe65e1e49a1e42f27856c6f745baL60-R53))
* Eliminate unnecessary `chains` variable declaration and assignment in
`TrustWalletConnector` constructor
([link](https://github.com/pancakeswap/pancake-frontend/pull/7421/files?diff=unified&w=0#diff-5e4f26574d007c8c9ac7a365a57f0c7ada4afe65e1e49a1e42f27856c6f745baL74-R67))
  • Loading branch information
0xjojoex authored Jul 26, 2023
1 parent 1b5050b commit 23fc46f
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions packages/wagmi/connectors/trustWallet/trustWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,6 @@ declare global {
}
}

const mappingNetwork: Record<number, string> = {
1: 'eth-mainnet',
5: 'eth-goerli',
56: 'bsc-mainnet',
97: 'bsc-testnet',
}

export function getTrustWalletProvider(): WindowProvider | undefined {
const isTrustWallet = (ethereum: NonNullable<Window['ethereum']>) => {
// Identify if Trust Wallet injected provider is present.
Expand Down Expand Up @@ -57,7 +50,7 @@ export class TrustWalletConnector extends InjectedConnector {
readonly id = 'trustWallet'

constructor({
chains: _chains,
chains,
options: _options,
}: {
chains?: Chain[]
Expand All @@ -71,7 +64,7 @@ export class TrustWalletConnector extends InjectedConnector {
shimDisconnect: _options?.shimDisconnect ?? false,
shimChainChangedDisconnect: _options?.shimChainChangedDisconnect ?? true,
}
const chains = _chains?.filter((c) => !!mappingNetwork[c.id])

super({
chains,
options,
Expand Down

0 comments on commit 23fc46f

Please sign in to comment.