-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from ChanX21/feat/integrate-web3auth
Integrated Web3Auth with the Rainbow Kit SDK inside scaffold ETH
- Loading branch information
Showing
9 changed files
with
29,085 additions
and
139 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
packages/nextjs/services/web3/RainbowWeb3authConnector.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { Wallet, WalletDetailsParams } from "@rainbow-me/rainbowkit"; | ||
import { CHAIN_NAMESPACES, WEB3AUTH_NETWORK } from "@web3auth/base"; | ||
import { EthereumPrivateKeyProvider } from "@web3auth/ethereum-provider"; | ||
import { Web3Auth } from "@web3auth/modal"; | ||
import { Web3AuthConnector } from "@web3auth/web3auth-wagmi-connector"; | ||
import { createConnector as createWagmiConnector } from "wagmi"; | ||
|
||
const clientId = "BCWDe7_V6ITJzkvM_FTvM6P5t_xoEVpWzTuSnlCEDIEkeIeEWh9e4Hczzwpz4I1hciWCL2YC2CTRJ2vPEvjX1Cw"; // get from https://dashboard.web3auth.io | ||
|
||
const chainConfig = { | ||
chainNamespace: CHAIN_NAMESPACES.EIP155, | ||
chainId: "0xaa36a7", | ||
rpcTarget: "https://rpc.ankr.com/eth_sepolia", | ||
// Avoid using public rpcTarget in production. | ||
// Use services like Infura, Quicknode etc | ||
displayName: "Ethereum Sepolia Testnet", | ||
blockExplorerUrl: "https://sepolia.etherscan.io", | ||
ticker: "ETH", | ||
tickerName: "Ethereum", | ||
logo: "https://cryptologos.cc/logos/ethereum-eth-logo.png", | ||
}; | ||
|
||
const privateKeyProvider = new EthereumPrivateKeyProvider({ | ||
config: { chainConfig }, | ||
}); | ||
|
||
const web3AuthInstance = new Web3Auth({ | ||
clientId, | ||
web3AuthNetwork: WEB3AUTH_NETWORK.SAPPHIRE_DEVNET, | ||
privateKeyProvider, | ||
}); | ||
|
||
export const rainbowWeb3AuthConnector = (): Wallet => ({ | ||
id: "web3auth", | ||
name: "web3auth", | ||
rdns: "web3auth", | ||
iconUrl: "https://web3auth.io/images/web3authlog.png", | ||
iconBackground: "#fff", | ||
installed: true, | ||
downloadUrls: {}, | ||
createConnector: (walletDetails: WalletDetailsParams) => | ||
createWagmiConnector(config => ({ | ||
...Web3AuthConnector({ | ||
web3AuthInstance, | ||
})(config), | ||
...walletDetails, | ||
})), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.