Skip to content
This repository was archived by the owner on Apr 22, 2026. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,5 @@ yarn-error.log*
# typescript
*.tsbuildinfo
next-env.d.ts

.idea
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"lint": "next lint"
},
"dependencies": {
"@cometh/connect-hosted-sdk": "^0.1.0-dev.6",
"@cometh/hosted-sdk-ethers": "^0.1.0-dev.19",
"@radix-ui/react-icons": "^1.3.0",
"@radix-ui/react-slot": "^1.0.2",
"@types/node": "20.3.2",
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/ConnectWallet.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Icons } from "@/app/lib/ui/components";
import { CheckIcon } from "@radix-ui/react-icons";
import {ComethWallet} from "@cometh/connect-hosted-sdk";
import {ComethWallet} from "@cometh/hosted-sdk-ethers";

interface ConnectWalletProps {
connectionError: string | null;
Expand Down
40 changes: 23 additions & 17 deletions src/app/modules/wallet/hooks/useWalletAuth.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"use client";

import {useEffect, useState} from "react";
import {useState} from "react";
import {ethers} from "ethers";
import countContractAbi from "../../contract/counterABI.json";
import {ComethAuth, ComethWallet, ComethWalletSigner} from "@cometh/connect-hosted-sdk";
import {ComethAuth, ComethProvider, ComethWallet, DisplayMode} from "@cometh/hosted-sdk-ethers";
import {useWalletContext} from "@/app/modules/wallet/hooks/useWalletContext";

export function useWalletAuth() {
Expand All @@ -12,8 +12,8 @@ export function useWalletAuth() {
setWallet,
auth,
setAuth,
signer,
setSigner,
provider,
setProvider,
counterContract,
setCounterContract,
} = useWalletContext();
Expand All @@ -24,7 +24,8 @@ export function useWalletAuth() {

const apiKey = process.env.NEXT_PUBLIC_COMETH_API_KEY as string;
const connectUrl = process.env.NEXT_PUBLIC_COMETH_CONNECT_API_URL as string;
const oidcUrl = process.env.NEXT_PUBLIC_COMETH_OIDC_API_URL as string;
//const oidcUrl = process.env.NEXT_PUBLIC_COMETH_OIDC_API_URL as string;
const oidcAppUrl = process.env.NEXT_PUBLIC_COMETH_OIDC_APP_URL as string;
const counterContractAddress =
process.env.NEXT_PUBLIC_COUNTER_CONTRACT_ADDRESS ||
"0x4FbF9EE4B2AF774D4617eAb027ac2901a41a7b5F";
Expand All @@ -37,30 +38,35 @@ export function useWalletAuth() {
if (!apiKey) throw new Error("no apiKey provided");
setIsConnecting(true)
try {
const auth = new ComethAuth(apiKey, {
oidcUrl,
connectUrl
})
console.log('test: ', oidcAppUrl)
//const auth = new ComethAuth(apiKey, {
// oidcApiURI: oidcUrl,
// oidcAppURI: oidcAppUrl,
// display: DisplayMode.POPUP
//})
const wallet = new ComethWallet(apiKey, {
oidcUrl,
connectUrl
oidcAppURI: oidcAppUrl,
connectApiURI: connectUrl,
display: DisplayMode.POPUP
})
const signer = new ComethWalletSigner(wallet)
// we don't have login for now
//await auth.login()
// with final UI, should refactor to force display modal of wallet.connect if not signup
await wallet.connect()
const provider = new ComethProvider(wallet)
const counterContract = new ethers.Contract(
counterContractAddress,
countContractAbi,
signer
provider.signer
);
await auth.login()
// with final UI, should refactor to force display modal of wallet.connect if not signup
await wallet.connect()
setIsConnected(true);
setAuth(auth)
setWallet(wallet)
setSigner(signer)
setProvider(provider)
setCounterContract(counterContract)
console.log('setup sdks: ', wallet, auth)
} catch (e) {
console.error(e)
displayError((e as Error).message);
} finally {
setIsConnecting(false);
Expand Down
8 changes: 4 additions & 4 deletions src/app/modules/wallet/hooks/useWalletContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ export function useWalletContext() {
const {
wallet,
setWallet,
signer,
setSigner,
provider,
setProvider,
auth,
setAuth,
counterContract,
Expand All @@ -15,8 +15,8 @@ export function useWalletContext() {
return {
wallet,
setWallet,
signer,
setSigner,
provider,
setProvider,
auth,
setAuth,
counterContract,
Expand Down
16 changes: 8 additions & 8 deletions src/app/modules/wallet/services/context.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
"use client";
import {ComethAuth, ComethWallet, ComethWalletSigner} from "@cometh/connect-hosted-sdk";
import {ComethAuth, ComethProvider, ComethWallet} from "@cometh/hosted-sdk-ethers";
import {ethers} from "ethers";
import {createContext, Dispatch, SetStateAction, useState} from "react";

export const WalletContext = createContext<{
wallet: ComethWallet | null;
setWallet: Dispatch<SetStateAction<ComethWallet | null>>;
signer: ComethWalletSigner | null;
setSigner: Dispatch<SetStateAction<ComethWalletSigner | null>>;
provider: ComethProvider | null;
setProvider: Dispatch<SetStateAction<ComethProvider | null>>;
auth: ComethAuth | null;
setAuth: Dispatch<SetStateAction<ComethAuth | null>>;
counterContract: ethers.Contract | null;
Expand All @@ -16,8 +16,8 @@ export const WalletContext = createContext<{
wallet: null,
setWallet: () => {
},
signer: null,
setSigner: () => {
provider: null,
setProvider: () => {
},
auth: null,
setAuth: () => {
Expand All @@ -33,7 +33,7 @@ export function WalletProvider({
children: React.ReactNode;
}): JSX.Element {
const [wallet, setWallet] = useState<ComethWallet | null>(null);
const [signer, setSigner] = useState<ComethWalletSigner | null>(null);
const [provider, setProvider] = useState<ComethProvider | null>(null);
const [auth, setAuth] = useState<ComethAuth | null>(null);
const [counterContract, setCounterContract] =
useState<ethers.Contract | null>(null);
Expand All @@ -43,8 +43,8 @@ export function WalletProvider({
value={{
wallet,
setWallet,
signer,
setSigner,
provider,
setProvider,
auth,
setAuth,
counterContract,
Expand Down
11 changes: 6 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@
dependencies:
regenerator-runtime "^0.14.0"

"@cometh/connect-hosted-sdk@^0.1.0-dev.6":
version "0.1.0-dev.6"
resolved "https://registry.yarnpkg.com/@cometh/connect-hosted-sdk/-/connect-hosted-sdk-0.1.0-dev.6.tgz#c5c83aa74e2e53c8ad9f14fd20d96466467b3149"
integrity sha512-woDznAq8/0ne8praDliutQNwbHP8gY4/Z6Ja3EK/YM+kHXZQ4B51G4b9ekGyT6fLq+cnMOoi2FeMD/0NrTQs1w==
"@cometh/hosted-sdk-ethers@^0.1.0-dev.19":
version "0.1.0-dev.19"
resolved "https://registry.yarnpkg.com/@cometh/hosted-sdk-ethers/-/hosted-sdk-ethers-0.1.0-dev.19.tgz#1dbac0f2afe804a16d9a4f0c35d37fb23800e482"
integrity sha512-KJpd0VKkvAZVBYjNSn+6scWd3srTT61T31vVdHGtvnpJxT+mH82bXtJooseOu3qNoa361HhDfH53sIa5oL99DQ==
dependencies:
"@ethersproject/abstract-provider" "^5.7.0"
"@ethersproject/abstract-signer" "^5.7.0"
"@ethersproject/bignumber" "^5.7.0"
"@ethersproject/bytes" "^5.7.0"
"@ethersproject/providers" "^5.7.2"
"@ethersproject/transactions" "^5.7.0"
axios "^1.6.8"
ethers-multisend "^3.1.0"
Expand Down Expand Up @@ -256,7 +257,7 @@
dependencies:
"@ethersproject/logger" "^5.7.0"

"@ethersproject/providers@5.7.2":
"@ethersproject/providers@5.7.2", "@ethersproject/providers@^5.7.2":
version "5.7.2"
resolved "https://registry.yarnpkg.com/@ethersproject/providers/-/providers-5.7.2.tgz#f8b1a4f275d7ce58cf0a2eec222269a08beb18cb"
integrity sha512-g34EWZ1WWAVgr4aptGlVBF8mhl3VWjv+8hoAnzStu8Ah22VHBsuGzP17eb6xDVRzw895G4W7vvx60lFFur/1Rg==
Expand Down