Skip to content

Commit

Permalink
Merge pull request #79 from dotbitHQ/develop
Browse files Browse the repository at this point in the history
feat: switch the Goerli test network to the Holesky test network.
  • Loading branch information
web3max authored Apr 12, 2024
2 parents d287381 + a60f0da commit 5d8c57a
Show file tree
Hide file tree
Showing 55 changed files with 660 additions and 31,048 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ node_modules
dist
dist-ssr
*.local
package-lock.json

# Editor directories and files
.vscode/*
Expand Down
62 changes: 17 additions & 45 deletions README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

- **支持的链**: Ethereum、BNB Smart Chain、Polygon、TRON、Dogecoin。
- **登录方式**: Passkey、Torus。
- **行业标准**: 我们依赖于 [viem](https://viem.sh/)[@wagmi/core](https://wagmi.sh/core/getting-started) 这是 Web3 中最常用的库。
- **行业标准**: 我们依赖于 [viem](https://viem.sh/)[@wagmi/core](https://wagmi.sh/core/getting-started)[@wagmi/connectors](https://wagmi.sh/core/api/connectors) 这是 Web3 中最常用的库。

[Documentation in English](README.md)

Expand All @@ -24,10 +24,10 @@

### 1. 安装:

安装 wallet-bridge 及其对等依赖项 [@wagmi/core](https://wagmi.sh/core/getting-started)[viem](https://viem.sh/).
安装 wallet-bridge 及其对等依赖.

```bash
yarn add wallet-bridge @wagmi/core viem
yarn add wallet-bridge@^1 @wagmi/core@^2 @wagmi/connectors@^4 viem@^2
```

### 2. 导入 Wallet:
Expand Down Expand Up @@ -61,36 +61,11 @@ const { Wallet } = await import('wallet-bridge')

```js
import { Wallet } from 'wallet-bridge'
import { bsc, bscTestnet, goerli, mainnet as ethereum, polygon, polygonMumbai } from '@wagmi/core/chains'
import { jsonRpcProvider } from '@wagmi/core/providers/jsonRpc'
import { configureChains, createConfig, InjectedConnector } from '@wagmi/core'
import { WalletConnectConnector } from '@wagmi/core/connectors/walletConnect'

const chainIdToRpc: { [chainId: number]: string | undefined } = {
[ethereum.id]: 'https://eth.public-rpc.com',
[goerli.id]: 'https://rpc.ankr.com/eth_goerli',
[bsc.id]: 'https://bscrpc.com',
[bscTestnet.id]: 'https://rpc.ankr.com/bsc_testnet_chapel',
[polygon.id]: 'https://polygon-rpc.com',
[polygonMumbai.id]: 'https://rpc.ankr.com/polygon_mumbai',
}

const { publicClient, chains } = configureChains(
[ethereum, goerli, bsc, bscTestnet, polygon, polygonMumbai],
[
jsonRpcProvider({
rpc(chain) {
return { http: chainIdToRpc[chain.id] || '' }
},
}),
],
)

const injectedConnector = new InjectedConnector({
chains,
})
import { createConfig, http } from '@wagmi/core'
import { bsc, bscTestnet, holesky, mainnet as ethereum, polygon, polygonMumbai } from '@wagmi/core/chains'
import { injected, walletConnect } from '@wagmi/connectors'

const walletConnectConnectorOptions = {
const walletConnectOptions = {
projectId: 'YOUR_PROJECT_ID', // Get projectId at https://cloud.walletconnect.com
metadata: {
name: '.bit',
Expand All @@ -100,20 +75,17 @@ const walletConnectConnectorOptions = {
},
}

const walletConnectConnectorShow = new WalletConnectConnector({
chains,
options: { ...walletConnectConnectorOptions, showQrModal: true },
})

const walletConnectConnectorHide = new WalletConnectConnector({
chains,
options: { ...walletConnectConnectorOptions, showQrModal: false },
})

const wagmiConfig = createConfig({
autoConnect: true,
connectors: [walletConnectConnectorShow, walletConnectConnectorHide, injectedConnector],
publicClient,
chains: [ethereum, holesky, bsc, bscTestnet, polygon, polygonMumbai],
transports: {
[ethereum.id]: http(),
[holesky.id]: http(),
[bsc.id]: http(),
[bscTestnet.id]: http(),
[polygon.id]: http(),
[polygonMumbai.id]: http(),
},
connectors: [injected(), walletConnect(walletConnectOptions)],
})

const wallet = new Wallet({
Expand Down
62 changes: 17 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

- **Supported Chains**: Ethereum, BNB Smart Chain, Polygon, TRON, Dogecoin.
- **Login Methods**: Passkey, Torus.
- **Industry Standard**: We rely on [viem](https://viem.sh/) and [@wagmi/core](https://wagmi.sh/core/getting-started), which are the most commonly used libraries in Web3.
- **Industry Standards**: We rely on [viem](https://viem.sh/), [@wagmi/core](https://wagmi.sh/core/getting-started), and [@wagmi/connectors](https://wagmi.sh/core/api/connectors), which are among the most commonly used libraries in Web3.

[中文文档](README-CN.md)

Expand All @@ -24,10 +24,10 @@

### 1. Installation:

Install wallet-bridge and its peer dependencies [@wagmi/core](https://wagmi.sh/core/getting-started) and [viem](https://viem.sh/).
Install wallet-bridge and its peer dependencies.

```bash
yarn add wallet-bridge @wagmi/core viem
yarn add wallet-bridge@^1 @wagmi/core@^2 @wagmi/connectors@^4 viem@^2
```

### 2. Import Wallet:
Expand Down Expand Up @@ -61,36 +61,11 @@ To create a new `Wallet` object, you can use its constructor and provide the fol

```js
import { Wallet } from 'wallet-bridge'
import { bsc, bscTestnet, goerli, mainnet as ethereum, polygon, polygonMumbai } from '@wagmi/core/chains'
import { jsonRpcProvider } from '@wagmi/core/providers/jsonRpc'
import { configureChains, createConfig, InjectedConnector } from '@wagmi/core'
import { WalletConnectConnector } from '@wagmi/core/connectors/walletConnect'

const chainIdToRpc: { [chainId: number]: string | undefined } = {
[ethereum.id]: 'https://eth.public-rpc.com',
[goerli.id]: 'https://rpc.ankr.com/eth_goerli',
[bsc.id]: 'https://bscrpc.com',
[bscTestnet.id]: 'https://rpc.ankr.com/bsc_testnet_chapel',
[polygon.id]: 'https://polygon-rpc.com',
[polygonMumbai.id]: 'https://rpc.ankr.com/polygon_mumbai',
}

const { publicClient, chains } = configureChains(
[ethereum, goerli, bsc, bscTestnet, polygon, polygonMumbai],
[
jsonRpcProvider({
rpc(chain) {
return { http: chainIdToRpc[chain.id] || '' }
},
}),
],
)

const injectedConnector = new InjectedConnector({
chains,
})
import { createConfig, http } from '@wagmi/core'
import { bsc, bscTestnet, holesky, mainnet as ethereum, polygon, polygonMumbai } from '@wagmi/core/chains'
import { injected, walletConnect } from '@wagmi/connectors'

const walletConnectConnectorOptions = {
const walletConnectOptions = {
projectId: 'YOUR_PROJECT_ID', // Get projectId at https://cloud.walletconnect.com
metadata: {
name: '.bit',
Expand All @@ -100,20 +75,17 @@ const walletConnectConnectorOptions = {
},
}

const walletConnectConnectorShow = new WalletConnectConnector({
chains,
options: { ...walletConnectConnectorOptions, showQrModal: true },
})

const walletConnectConnectorHide = new WalletConnectConnector({
chains,
options: { ...walletConnectConnectorOptions, showQrModal: false },
})

const wagmiConfig = createConfig({
autoConnect: true,
connectors: [walletConnectConnectorShow, walletConnectConnectorHide, injectedConnector],
publicClient,
chains: [ethereum, holesky, bsc, bscTestnet, polygon, polygonMumbai],
transports: {
[ethereum.id]: http(),
[holesky.id]: http(),
[bsc.id]: http(),
[bscTestnet.id]: http(),
[polygon.id]: http(),
[polygonMumbai.id]: http(),
},
connectors: [injected(), walletConnect(walletConnectOptions)],
})

const wallet = new Wallet({
Expand Down
Loading

0 comments on commit 5d8c57a

Please sign in to comment.