-
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.
feat: add testnet login and features
- Loading branch information
1 parent
e442b57
commit 253dcd0
Showing
10 changed files
with
326 additions
and
260 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { config } from "../config/Chain"; | ||
import Image from "next/image"; | ||
|
||
const checkKeplr = async () => { | ||
try { | ||
const keplr = window.keplr; | ||
if (!keplr) { | ||
throw new Error("Please install Keplr extension"); | ||
} | ||
} catch (err: unknown) { | ||
if (err instanceof Error) { | ||
console.log(err.message); | ||
} else { | ||
console.log("An unknown error occurred"); | ||
} | ||
} | ||
}; | ||
|
||
const addDevnetChain = async () => { | ||
try { | ||
await checkKeplr(); | ||
|
||
const chainId = "nillion-chain-testnet-1"; | ||
const keplr = window.keplr; | ||
if (!keplr) { | ||
throw new Error("Keplr not found"); | ||
} | ||
|
||
try { | ||
await keplr.getKey(chainId); | ||
console.log("Chain already exists in Keplr!"); | ||
} catch { | ||
console.log("Adding new chain to Keplr..."); | ||
await keplr.experimentalSuggestChain(config); | ||
} | ||
await keplr.enable(chainId); | ||
} catch (error: unknown) { | ||
console.error("Error:", error); | ||
if ( | ||
error instanceof Error && | ||
error.message.includes("chain not supported") | ||
) { | ||
console.log( | ||
"This chain needs to be manually added with chainInfo configuration", | ||
); | ||
} | ||
throw error; | ||
} | ||
}; | ||
|
||
export const AddTestnetChain: React.FC = () => { | ||
return ( | ||
<button | ||
onClick={addDevnetChain} | ||
className="px-4 py-2 border dark:bg-gray-100 border-gray-300 rounded text-white rounded hover:bg-gray-200 transition-colors mr-2 flex items-center" | ||
> | ||
<Image src="/nillion_n.png" alt="Nillion Icon" width={24} height={24} /> | ||
</button> | ||
); | ||
}; |
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.