FRE-600: Fix code review blockers

- Consolidated duplicate UndoManagers to single instance
- Fixed connection promise to only resolve on 'connected' status
- Fixed WebSocketProvider import (WebsocketProvider)
- Added proper doc.destroy() cleanup
- Renamed isPresenceInitialized property to avoid conflict

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
2026-04-25 00:08:01 -04:00
parent 65b552bb08
commit 7c684a42cc
48450 changed files with 5679671 additions and 383 deletions

63
node_modules/viem/actions/wallet/addChain.ts generated vendored Normal file
View File

@@ -0,0 +1,63 @@
import type { Account } from '../../accounts/types.js'
import type { Client } from '../../clients/createClient.js'
import type { Transport } from '../../clients/transports/createTransport.js'
import type { ErrorType } from '../../errors/utils.js'
import type { Chain } from '../../types/chain.js'
import type { RequestErrorType } from '../../utils/buildRequest.js'
import {
type NumberToHexErrorType,
numberToHex,
} from '../../utils/encoding/toHex.js'
export type AddChainParameters = {
/** The chain to add to the wallet. */
chain: Chain
}
export type AddChainErrorType =
| RequestErrorType
| NumberToHexErrorType
| ErrorType
/**
* Adds an EVM chain to the wallet.
*
* - Docs: https://viem.sh/docs/actions/wallet/addChain
* - JSON-RPC Methods: [`eth_addEthereumChain`](https://eips.ethereum.org/EIPS/eip-3085)
*
* @param client - Client to use
* @param parameters - {@link AddChainParameters}
*
* @example
* import { createWalletClient, custom } from 'viem'
* import { optimism } from 'viem/chains'
* import { addChain } from 'viem/wallet'
*
* const client = createWalletClient({
* transport: custom(window.ethereum),
* })
* await addChain(client, { chain: optimism })
*/
export async function addChain<
chain extends Chain | undefined,
account extends Account | undefined,
>(client: Client<Transport, chain, account>, { chain }: AddChainParameters) {
const { id, name, nativeCurrency, rpcUrls, blockExplorers } = chain
await client.request(
{
method: 'wallet_addEthereumChain',
params: [
{
chainId: numberToHex(id),
chainName: name,
nativeCurrency,
rpcUrls: rpcUrls.default.http,
blockExplorerUrls: blockExplorers
? Object.values(blockExplorers).map(({ url }) => url)
: undefined,
},
],
},
{ dedupe: true, retryCount: 0 },
)
}