-
Notifications
You must be signed in to change notification settings - Fork 26
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
5 changed files
with
128 additions
and
2 deletions.
There are no files selected for viewing
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,84 @@ | ||
import { useMantineColorScheme } from "@mantine/core"; | ||
import { | ||
RainbowKitProvider, | ||
connectorsForWallets, | ||
darkTheme, | ||
getDefaultWallets, | ||
lightTheme, | ||
} from "@rainbow-me/rainbowkit"; | ||
import { ThemeOptions } from "@rainbow-me/rainbowkit/dist/themes/baseTheme"; | ||
import "@rainbow-me/rainbowkit/styles.css"; | ||
import { | ||
argentWallet, | ||
ledgerWallet, | ||
trustWallet, | ||
} from "@rainbow-me/rainbowkit/wallets"; | ||
import { configureChains, createConfig, WagmiConfig } from "wagmi"; | ||
import { foundry, mainnet, sepolia } from "wagmi/chains"; | ||
import { publicProvider } from "wagmi/providers/public"; | ||
|
||
// only 1 chain is enabled, based on env var | ||
const { chains, publicClient, webSocketPublicClient } = configureChains( | ||
[foundry, mainnet, sepolia], | ||
[publicProvider()], | ||
); | ||
|
||
const projectId = "a6265c875f8a7513ac7c52362abf434b"; | ||
const { wallets } = getDefaultWallets({ | ||
appName: "CartesiScan", | ||
projectId, | ||
chains, | ||
}); | ||
|
||
const appInfo = { | ||
appName: "CartesiScan", | ||
learnMoreUrl: "https://cartesiscan.io", | ||
}; | ||
|
||
const connectors = connectorsForWallets([ | ||
...wallets, | ||
{ | ||
groupName: "Other", | ||
wallets: [ | ||
argentWallet({ chains, projectId }), | ||
trustWallet({ chains, projectId }), | ||
ledgerWallet({ chains, projectId }), | ||
], | ||
}, | ||
]); | ||
|
||
const wagmiConfig = createConfig({ | ||
autoConnect: true, | ||
connectors, | ||
publicClient, | ||
webSocketPublicClient, | ||
}); | ||
|
||
const WalletProvider = ({ children }: { children: React.ReactNode }) => { | ||
const scheme = useMantineColorScheme(); | ||
|
||
// XXX: make this match the mantine theme | ||
const themeOptions: ThemeOptions = { | ||
accentColor: "rgb(12, 133, 153)", | ||
borderRadius: "small", | ||
}; | ||
|
||
const walletTheme = | ||
scheme.colorScheme == "dark" | ||
? darkTheme(themeOptions) | ||
: lightTheme(themeOptions); | ||
|
||
return ( | ||
<WagmiConfig config={wagmiConfig}> | ||
<RainbowKitProvider | ||
appInfo={appInfo} | ||
chains={chains} | ||
theme={walletTheme} | ||
> | ||
{children} | ||
</RainbowKitProvider> | ||
</WagmiConfig> | ||
); | ||
}; | ||
|
||
export default WalletProvider; |
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,38 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
|
||
import { ConnectButton } from "@rainbow-me/rainbowkit"; | ||
|
||
const meta: Meta<typeof ConnectButton> = { | ||
component: ConnectButton, | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof ConnectButton>; | ||
|
||
export const Default: Story = { | ||
args: {}, | ||
}; | ||
|
||
export const NoBalance: Story = { | ||
args: { | ||
showBalance: false, | ||
}, | ||
}; | ||
|
||
export const IconChainStatus: Story = { | ||
args: { | ||
chainStatus: "icon", | ||
}, | ||
}; | ||
|
||
export const NameChainStatus: Story = { | ||
args: { | ||
chainStatus: "name", | ||
}, | ||
}; | ||
|
||
export const NoneChainStatus: Story = { | ||
args: { | ||
chainStatus: "none", | ||
}, | ||
}; |
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