Skip to content

Commit

Permalink
fix: build issues
Browse files Browse the repository at this point in the history
  • Loading branch information
crypblizz8 committed Nov 7, 2024
1 parent a57141a commit 55e0d46
Show file tree
Hide file tree
Showing 7 changed files with 690 additions and 60 deletions.
6 changes: 5 additions & 1 deletion examples/nextjs/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
{
"extends": ["next/core-web-vitals", "next/typescript"]
"extends": ["next/core-web-vitals", "next/typescript"],
"rules": {
"@typescript-eslint/no-empty-interface": "off",
"@typescript-eslint/no-empty-object-type": "off"
}
}
39 changes: 24 additions & 15 deletions examples/nextjs/app/components/KeplrWallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ import { useState } from "react";
import { useNillionAuth, UserCredentials } from "@nillion/client-react-hooks";
import { config } from "../config/Chain";
import Image from "next/image";
import { Window as KeplrWindow } from "@keplr-wallet/types";

declare global {
interface Window extends KeplrWindow {}
}

const SEED = "example-secret-seed";

Expand All @@ -15,8 +20,8 @@ const KeplrWalletConnector = () => {

const checkKeplr = async () => {
try {
//@ts-ignore
if (!window.keplr) {
const keplr = window.keplr;
if (!keplr) {
throw new Error("Please install Keplr extension");
}
} catch (err:unknown) {
Expand All @@ -33,38 +38,42 @@ const KeplrWalletConnector = () => {
await checkKeplr();

const chainId = "nillion-chain-testnet-1";

const keplr = window.keplr;
if (!keplr) {
throw new Error("Keplr not found");
}

try {
//@ts-ignore
await window.keplr.getKey(chainId);
await keplr.getKey(chainId);
console.log("Chain already exists in Keplr!");
} catch {
// If getKey fails, chain isn't added yet
console.log("Adding new chain to Keplr...");
//@ts-ignore
await window.keplr.experimentalSuggestChain(config);
await keplr.experimentalSuggestChain(config);
}
//@ts-ignore
await window.keplr.enable(chainId);
await keplr.enable(chainId);
} catch (error:unknown) {
console.error("Error:", error);
//@ts-ignore
if (error.message.includes("chain not supported")) {
if (error instanceof Error && error.message.includes("chain not supported")) {
console.log("This chain needs to be manually added with chainInfo configuration");
}
throw error;
}
};

const handleLogin = async () => {
try {
setIsLoading(true);
await checkKeplr();

const chainId = "nillion-chain-testnet-1";
await addDevnetChain();
//@ts-ignore
const offlineSigner = window.keplr.getOfflineSigner(chainId);

const keplr = window.keplr;
if (!keplr) {
throw new Error("Keplr not found");
}

const offlineSigner = keplr.getOfflineSigner(chainId);
const accounts = await offlineSigner.getAccounts();

if (!accounts || accounts.length === 0) {
Expand Down
2 changes: 1 addition & 1 deletion examples/nextjs/app/components/TestNetContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const TestNetContent = () => {
<code className="bg-gray-200 text-gray-800 dark:bg-gray-700 dark:text-gray-200 rounded-md p-1 mx-1">
ClientWrapper.tsx
</code>
to "photon"
to &quot;photon&quot;
</li>
<li className="mb-2">
Ensure you have a Keplr Wallet
Expand Down
2 changes: 0 additions & 2 deletions examples/nextjs/app/components/WelcomeContent.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import Image from "next/image";

export const WelcomeContent = () => {
return (
<div className="max-w-4xl">
Expand Down
Loading

0 comments on commit 55e0d46

Please sign in to comment.