Skip to content

Commit

Permalink
added arcana
Browse files Browse the repository at this point in the history
  • Loading branch information
dinesh11515 committed Feb 7, 2023
1 parent 237fc7d commit c92efa4
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 9 deletions.
8 changes: 1 addition & 7 deletions frontend/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,7 @@ import { ProvideAuth } from "@arcana/auth-react";
const arcanaProvider = new AuthProvider(
"56639397ce14b62124c30a0679cc4642b1486386",
{
position: "left", // defaults to right
theme: "light", // defaults to dark
alwaysVisible: true, // defaults to true which is Full UI mode
chainConfig: {
chainId: "0x1",
rpcUrl: "https://rpc.testnet.mantle.xyz ",
},
alwaysVisible: true,
}
);

Expand Down
35 changes: 33 additions & 2 deletions frontend/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,40 @@ import { Auth, useAuth } from "@arcana/auth-react";

export default function Home() {
const auth = useAuth();
const provider = auth.provider;
console.log(provider, "provider");
const onLogin = async () => {
// Route to authenticated page
await auth.connect();
const provider = auth.provider;
try {
await auth.connect();
console.log(provider, "provider");
const chainId = 1;
console.log(chainId, "chainId");
await provider.request({
method: "wallet_switchEthereumChain",
params: [{ chainId: "0x5001" }],
});
} catch (e) {
if (e.code === 4902) {
await provider.request({
method: "wallet_addEthereumChain",
params: [
{
chainId: "0x5001",
chainName: "Mantle Testnet",
rpcUrls: ["https://rpc.testnet.mantle.xyz "],
nativeCurrency: {
name: "Mantle",
symbol: "BIT",
decimals: 18,
},
blockExplorerUrls: ["https://explorer.testnet.mantle.xyz/"],
},
],
});
}
console.log(e, "onLogin");
}
};
return (
<>
Expand Down

0 comments on commit c92efa4

Please sign in to comment.