@web3modal/wagmi
Advanced tools
Comparing version 3.0.0-alpha.1 to 3.0.0-alpha.2
import { connect, disconnect, fetchBalance, fetchEnsAvatar, fetchEnsName, getAccount, getNetwork, switchNetwork, watchAccount, watchNetwork } from '@wagmi/core'; | ||
import { mainnet } from '@wagmi/core/chains'; | ||
import { Web3ModalScaffold } from '@web3modal/scaffold'; | ||
import { ADD_CHAIN_METHOD, INJECTED_ID, NAMESPACE, NAME_MAP, TYPE_MAP, VERSION, WALLET_CHOICE_KEY, WALLET_CONNECT_ID } from './utils/constants.js'; | ||
import { NetworkImageIds } from './utils/presets.js'; | ||
import { ADD_CHAIN_METHOD, INJECTED_CONNECTOR_ID, NAMESPACE, VERSION, WALLET_CHOICE_KEY, WALLET_CONNECT_CONNECTOR_ID } from './utils/constants.js'; | ||
import { ConnectorExplorerIds, ConnectorImageIds, ConnectorNamesMap, ConnectorTypesMap, NetworkImageIds } from './utils/presets.js'; | ||
export class Web3Modal extends Web3ModalScaffold { | ||
@@ -15,3 +15,3 @@ constructor(options) { | ||
} | ||
if (!wagmiConfig.connectors.find(c => c.id === WALLET_CONNECT_ID)) { | ||
if (!wagmiConfig.connectors.find(c => c.id === WALLET_CONNECT_CONNECTOR_ID)) { | ||
throw new Error('web3modal:constructor - WalletConnectConnector is required'); | ||
@@ -28,4 +28,4 @@ } | ||
const walletChoice = localStorage.getItem(WALLET_CHOICE_KEY); | ||
if (walletChoice?.includes(WALLET_CONNECT_ID)) { | ||
const connector = wagmiConfig.connectors.find(c => c.id === WALLET_CONNECT_ID); | ||
if (walletChoice?.includes(WALLET_CONNECT_CONNECTOR_ID)) { | ||
const connector = wagmiConfig.connectors.find(c => c.id === WALLET_CONNECT_CONNECTOR_ID); | ||
if (!connector) { | ||
@@ -48,3 +48,3 @@ throw new Error('networkControllerClient:getApprovedCaipNetworks - connector is undefined'); | ||
connectWalletConnect: async (onUri) => { | ||
const connector = wagmiConfig.connectors.find(c => c.id === WALLET_CONNECT_ID); | ||
const connector = wagmiConfig.connectors.find(c => c.id === WALLET_CONNECT_CONNECTOR_ID); | ||
if (!connector) { | ||
@@ -71,3 +71,3 @@ throw new Error('connectionControllerClient:getWalletConnectUri - connector is undefined'); | ||
connectInjected: async () => { | ||
const connector = wagmiConfig.connectors.find(c => c.id === INJECTED_ID); | ||
const connector = wagmiConfig.connectors.find(c => c.id === INJECTED_CONNECTOR_ID); | ||
if (!connector) { | ||
@@ -157,6 +157,8 @@ throw new Error('connectionControllerClient:connectInjected - connector is undefined'); | ||
syncConnectors(connectors) { | ||
const w3mConnectors = connectors.map(connector => ({ | ||
id: connector.id, | ||
name: NAME_MAP[connector.id] ?? connector.name, | ||
type: TYPE_MAP[connector.id] ?? 'EXTERNAL' | ||
const w3mConnectors = connectors.map(({ id, name }) => ({ | ||
id, | ||
explorerId: ConnectorExplorerIds[id], | ||
imageId: ConnectorImageIds[id], | ||
name: ConnectorNamesMap[id] ?? name, | ||
type: ConnectorTypesMap[id] ?? 'EXTERNAL' | ||
})); | ||
@@ -163,0 +165,0 @@ this.setConnectors(w3mConnectors ?? []); |
@@ -1,11 +0,7 @@ | ||
export const WALLET_CONNECT_ID = 'walletConnect'; | ||
export const INJECTED_ID = 'injected'; | ||
export const WALLET_CONNECT_CONNECTOR_ID = 'walletConnect'; | ||
export const INJECTED_CONNECTOR_ID = 'injected'; | ||
export const COINBASE_CONNECTOR_ID = 'coinbaseWallet'; | ||
export const SAFE_CONNECTOR_ID = 'safe'; | ||
export const LEDGER_CONNECTOR_ID = 'ledger'; | ||
export const NAMESPACE = 'eip155'; | ||
export const NAME_MAP = { | ||
[INJECTED_ID]: 'Extension Wallet' | ||
}; | ||
export const TYPE_MAP = { | ||
[WALLET_CONNECT_ID]: 'WALLET_CONNECT', | ||
[INJECTED_ID]: 'INJECTED' | ||
}; | ||
export const ADD_CHAIN_METHOD = 'wallet_addEthereumChain'; | ||
@@ -15,3 +11,3 @@ export const WALLET_CHOICE_KEY = 'wagmi.wallet'; | ||
export const BLOCKCHAIN_WSS_API = 'wss://rpc.walletconnect.com'; | ||
export const VERSION = '3.0.0-alpha.1'; | ||
export const VERSION = '3.0.0-alpha.2'; | ||
//# sourceMappingURL=constants.js.map |
@@ -0,1 +1,2 @@ | ||
import { COINBASE_CONNECTOR_ID, INJECTED_CONNECTOR_ID, LEDGER_CONNECTOR_ID, SAFE_CONNECTOR_ID, WALLET_CONNECT_CONNECTOR_ID } from './constants.js'; | ||
export const NetworkImageIds = { | ||
@@ -18,2 +19,21 @@ 1: '692ed6ba-e569-459a-556a-776476829e00', | ||
}; | ||
export const ConnectorImageIds = { | ||
[COINBASE_CONNECTOR_ID]: '0c2840c3-5b04-4c44-9661-fbd4b49e1800', | ||
[SAFE_CONNECTOR_ID]: '461db637-8616-43ce-035a-d89b8a1d5800', | ||
[LEDGER_CONNECTOR_ID]: '54a1aa77-d202-4f8d-0fb2-5d2bb6db0300', | ||
[WALLET_CONNECT_CONNECTOR_ID]: 'ef1a1fcf-7fe8-4d69-bd6d-fda1345b4400', | ||
[INJECTED_CONNECTOR_ID]: 'b2e6085e-8306-47fd-1a87-14bbd434f400' | ||
}; | ||
export const ConnectorExplorerIds = { | ||
[COINBASE_CONNECTOR_ID]: 'fd20dc426fb37566d803205b19bbc1d4096b248ac04548e3cfb6b3a38bd033aa', | ||
[SAFE_CONNECTOR_ID]: '225affb176778569276e484e1b92637ad061b01e13a048b35a9d280c3b58970f', | ||
[LEDGER_CONNECTOR_ID]: '19177a98252e07ddfc9af2083ba8e07ef627cb6103467ffebb3f8f4205fd7927' | ||
}; | ||
export const ConnectorNamesMap = { | ||
[INJECTED_CONNECTOR_ID]: 'Extension Wallet' | ||
}; | ||
export const ConnectorTypesMap = { | ||
[INJECTED_CONNECTOR_ID]: 'INJECTED', | ||
[WALLET_CONNECT_CONNECTOR_ID]: 'WALLET_CONNECT' | ||
}; | ||
//# sourceMappingURL=presets.js.map |
@@ -16,2 +16,3 @@ import { BLOCKCHAIN_HTTP_API, BLOCKCHAIN_WSS_API, NAMESPACE } from './constants.js'; | ||
324, | ||
8453, | ||
43114, | ||
@@ -21,3 +22,3 @@ 80001, | ||
7777777, | ||
8453 | ||
11155111 | ||
]; | ||
@@ -24,0 +25,0 @@ if (!supportedHttp.includes(chain.id)) { |
@@ -1,7 +0,7 @@ | ||
import type { ConnectorType } from '@web3modal/scaffold'; | ||
export declare const WALLET_CONNECT_ID = "walletConnect"; | ||
export declare const INJECTED_ID = "injected"; | ||
export declare const WALLET_CONNECT_CONNECTOR_ID = "walletConnect"; | ||
export declare const INJECTED_CONNECTOR_ID = "injected"; | ||
export declare const COINBASE_CONNECTOR_ID = "coinbaseWallet"; | ||
export declare const SAFE_CONNECTOR_ID = "safe"; | ||
export declare const LEDGER_CONNECTOR_ID = "ledger"; | ||
export declare const NAMESPACE = "eip155"; | ||
export declare const NAME_MAP: Record<string, string>; | ||
export declare const TYPE_MAP: Record<string, ConnectorType>; | ||
export declare const ADD_CHAIN_METHOD = "wallet_addEthereumChain"; | ||
@@ -11,2 +11,2 @@ export declare const WALLET_CHOICE_KEY = "wagmi.wallet"; | ||
export declare const BLOCKCHAIN_WSS_API = "wss://rpc.walletconnect.com"; | ||
export declare const VERSION = "3.0.0-alpha.1"; | ||
export declare const VERSION = "3.0.0-alpha.2"; |
@@ -1,1 +0,6 @@ | ||
export declare const NetworkImageIds: Record<string, string | undefined>; | ||
import type { ConnectorType } from '@web3modal/scaffold'; | ||
export declare const NetworkImageIds: Record<string, string>; | ||
export declare const ConnectorImageIds: Record<string, string>; | ||
export declare const ConnectorExplorerIds: Record<string, string>; | ||
export declare const ConnectorNamesMap: Record<string, string>; | ||
export declare const ConnectorTypesMap: Record<string, ConnectorType>; |
{ | ||
"name": "@web3modal/wagmi", | ||
"version": "3.0.0-alpha.1", | ||
"version": "3.0.0-alpha.2", | ||
"type": "module", | ||
"main": "./dist/esm/index.js", | ||
"types": "./dist/types/index.d.ts", | ||
"main": "./dist/esm/exports/index.js", | ||
"types": "./dist/types/exports/index.d.ts", | ||
"files": [ | ||
@@ -12,12 +12,12 @@ "dist" | ||
".": { | ||
"import": "./dist/esm/index.js", | ||
"types": "./dist/types/index.d.ts" | ||
"import": "./dist/esm/exports/index.js", | ||
"types": "./dist/types/exports/index.d.ts" | ||
}, | ||
"./react": { | ||
"import": "./dist/esm/src/react.js", | ||
"types": "./dist/types/src/react.d.ts" | ||
"import": "./dist/esm/exports/react.js", | ||
"types": "./dist/types/exports/react.d.ts" | ||
}, | ||
"./vue": { | ||
"import": "./dist/esm/src/vue.js", | ||
"types": "./dist/types/src/vue.d.ts" | ||
"import": "./dist/esm/exports/vue.js", | ||
"types": "./dist/types/exports/vue.d.ts" | ||
} | ||
@@ -27,4 +27,3 @@ }, | ||
"build:clean": "rm -rf dist", | ||
"build:dist": "tsc --build", | ||
"build": "npm run build:clean; npm run build:dist", | ||
"build": "npm run build:clean; tsc --build", | ||
"watch": "npm run build:clean; tsc --watch", | ||
@@ -34,3 +33,4 @@ "typecheck": "tsc --noEmit" | ||
"dependencies": { | ||
"@web3modal/scaffold": "3.0.0-alpha.1" | ||
"@web3modal/polyfills": "3.0.0-alpha.1", | ||
"@web3modal/scaffold": "3.0.0-alpha.2" | ||
}, | ||
@@ -37,0 +37,0 @@ "peerDependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
265236
30
438
7
+ Added@web3modal/core@3.0.0-alpha.2(transitive)
+ Added@web3modal/polyfills@3.0.0-alpha.1(transitive)
+ Added@web3modal/scaffold@3.0.0-alpha.2(transitive)
+ Added@web3modal/ui@3.0.0-alpha.2(transitive)
+ Addedbase64-js@1.5.1(transitive)
+ Addedbuffer@6.0.3(transitive)
+ Addedieee754@1.2.1(transitive)
- Removed@web3modal/core@3.0.0-alpha.1(transitive)
- Removed@web3modal/scaffold@3.0.0-alpha.1(transitive)
- Removed@web3modal/ui@3.0.0-alpha.1(transitive)