-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
15,446 additions
and
7,880 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { | ||
connectorsForWallets, | ||
getDefaultWallets, | ||
} from "@rainbow-me/rainbowkit"; | ||
import { trustWallet } from "@rainbow-me/rainbowkit/wallets"; | ||
import { mainnet } from "@wagmi/core/chains"; | ||
import type { Config } from "@wagmi/core"; | ||
import { http, fallback } from "@wagmi/core"; | ||
import { createConfig } from "wagmi"; | ||
import { demoConnector } from "./demoConnector"; | ||
import { isAppEnvDemo } from "./env"; | ||
|
||
// Required field as of WalletConnect v2. | ||
// Replace with your project id: https://www.rainbowkit.com/docs/migration-guide#2-supply-a-walletconnect-cloud-projectid | ||
const projectId = import.meta.env.VITE_PROJECT_ID || "ADD_PROJECT_ID_HERE"; | ||
const appName = "XMTP Inbox Web"; | ||
|
||
const { wallets } = getDefaultWallets({ | ||
appName, | ||
projectId, | ||
}); | ||
|
||
const connectors = connectorsForWallets( | ||
[ | ||
...wallets, | ||
{ | ||
groupName: "Other", | ||
wallets: [trustWallet], | ||
}, | ||
], | ||
{ | ||
appName, | ||
projectId, | ||
}, | ||
); | ||
|
||
const transports = { | ||
[mainnet.id]: fallback([ | ||
http( | ||
`https://mainnet.infura.io/v3/${import.meta.env.VITE_INFURA_ID ?? ""}`, | ||
), | ||
http(), | ||
]), | ||
}; | ||
|
||
let config: Config; | ||
|
||
export const getWagmiConfig = () => { | ||
if (!config) { | ||
if (isAppEnvDemo()) { | ||
config = createConfig({ | ||
connectors: [demoConnector], | ||
chains: [mainnet], | ||
transports, | ||
}); | ||
} else { | ||
config = createConfig({ | ||
connectors, | ||
chains: [mainnet], | ||
transports, | ||
}); | ||
} | ||
} | ||
return config; | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { createConnector } from "wagmi"; | ||
import { mainnet } from "viem/chains"; | ||
import randomWalletClient from "./createRandomWallet"; | ||
|
||
// wagmi connector for demos | ||
export const demoConnector = createConnector(() => ({ | ||
id: "demoConnector", | ||
name: "Demo Connector", | ||
type: "demo", | ||
// eslint-disable-next-line @typescript-eslint/require-await | ||
async connect() { | ||
return { | ||
accounts: [randomWalletClient.account.address], | ||
chainId: mainnet.id, | ||
}; | ||
}, | ||
// eslint-disable-next-line @typescript-eslint/no-empty-function | ||
async disconnect() {}, | ||
// eslint-disable-next-line @typescript-eslint/require-await | ||
async getAccounts() { | ||
return [randomWalletClient.account.address]; | ||
}, | ||
// eslint-disable-next-line @typescript-eslint/require-await | ||
async getClient() { | ||
return randomWalletClient; | ||
}, | ||
// eslint-disable-next-line @typescript-eslint/require-await | ||
async getChainId() { | ||
return mainnet.id; | ||
}, | ||
// eslint-disable-next-line @typescript-eslint/require-await | ||
async isAuthorized() { | ||
return true; | ||
}, | ||
onAccountsChanged() {}, | ||
onChainChanged() {}, | ||
// eslint-disable-next-line @typescript-eslint/no-empty-function | ||
async onDisconnect() {}, | ||
// eslint-disable-next-line @typescript-eslint/no-empty-function | ||
async getProvider() {}, | ||
})); |
This file was deleted.
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
Oops, something went wrong.