diff --git a/packages/dapp-kit-react/src/DAppKitProvider.tsx b/packages/dapp-kit-react/src/DAppKitProvider.tsx index 530bf3d5..7f8a625c 100644 --- a/packages/dapp-kit-react/src/DAppKitProvider.tsx +++ b/packages/dapp-kit-react/src/DAppKitProvider.tsx @@ -10,7 +10,7 @@ import type { WalletSource } from '@vechain/dapp-kit'; import { DAppKitUI } from '@vechain/dapp-kit-ui'; import { subscribeKey } from 'valtio/vanilla/utils'; import type { DAppKitProviderOptions, DAppKitContext } from './types'; -import { Certificate } from 'thor-devkit'; +import * as ThorDevkit from 'thor-devkit'; /** * Context @@ -71,7 +71,9 @@ export const DAppKitProvider: React.FC = ({ connex.wallet.state.source, ); const [connectionCertificate, setConnectionCertificate] = - useState(connex.wallet.state.connectionCertificate); + useState( + connex.wallet.state.connectionCertificate, + ); useEffect(() => { const addressSub = subscribeKey(connex.wallet.state, 'address', (v) => { diff --git a/packages/dapp-kit-react/src/types.ts b/packages/dapp-kit-react/src/types.ts index e44a89e1..0bac2d26 100644 --- a/packages/dapp-kit-react/src/types.ts +++ b/packages/dapp-kit-react/src/types.ts @@ -1,6 +1,6 @@ /// import type React from 'react'; -import type { Certificate } from 'thor-devkit'; +import * as ThorDevkit from 'thor-devkit'; import type { ConnectResponse, WalletSource } from '@vechain/dapp-kit'; import { type DAppKitUIOptions } from '@vechain/dapp-kit-ui'; @@ -35,7 +35,7 @@ export interface DAppKitContext { connect: () => Promise; account: string | null; source: WalletSource | null; - connectionCertificate: Certificate | null; + connectionCertificate: ThorDevkit.Certificate | null; }; modal: { open: () => void; diff --git a/packages/dapp-kit-ui/package.json b/packages/dapp-kit-ui/package.json index 04084a62..db2f5c2d 100644 --- a/packages/dapp-kit-ui/package.json +++ b/packages/dapp-kit-ui/package.json @@ -34,6 +34,7 @@ "watch": "tsup --watch" }, "dependencies": { + "@vechain/connex": "2.1.0", "@vechain/dapp-kit": "*", "@vechain/picasso": "2.1.1", "@wagmi/core": "^1.4.5", @@ -53,6 +54,7 @@ "eslint": "^8.15.0", "parcel": "^2.10.2", "prettier": "^2.6.2", + "punycode": "^1.4.1", "tsup": "^7.2.0", "typechain": "^8.3.2", "typescript": "~5.2.0", diff --git a/packages/dapp-kit/src/classes/certificate-wallet.ts b/packages/dapp-kit/src/classes/certificate-wallet.ts index e23b9d4f..8203096a 100644 --- a/packages/dapp-kit/src/classes/certificate-wallet.ts +++ b/packages/dapp-kit/src/classes/certificate-wallet.ts @@ -1,4 +1,4 @@ -import { Certificate } from 'thor-devkit'; +import * as ThorDevkit from 'thor-devkit'; import type { BaseWallet, ConnectResponse, ConnexWallet } from '../types'; import { DEFAULT_CONNECT_CERT_MESSAGE } from '../constants'; @@ -24,7 +24,7 @@ class CertificateBasedWallet implements ConnexWallet { }; try { - Certificate.verify(connectionCertificate); + ThorDevkit.Certificate.verify(connectionCertificate); return { account: signer, diff --git a/packages/dapp-kit/src/classes/wallet-manager.ts b/packages/dapp-kit/src/classes/wallet-manager.ts index 0b7b2132..1526f21a 100644 --- a/packages/dapp-kit/src/classes/wallet-manager.ts +++ b/packages/dapp-kit/src/classes/wallet-manager.ts @@ -1,4 +1,4 @@ -import { Certificate } from 'thor-devkit'; +import * as ThorDevkit from 'thor-devkit'; import { proxy, subscribe } from 'valtio/vanilla'; import { subscribeKey } from 'valtio/vanilla/utils'; import type { @@ -83,7 +83,7 @@ class WalletManager { }; try { - Certificate.verify(connectionCertificate); + ThorDevkit.Certificate.verify(connectionCertificate); this.state.address = signer; this.state.connectionCertificate = connectionCertificate; return { diff --git a/packages/dapp-kit/src/types/types.d.ts b/packages/dapp-kit/src/types/types.d.ts index 1c341a96..8032a4e0 100644 --- a/packages/dapp-kit/src/types/types.d.ts +++ b/packages/dapp-kit/src/types/types.d.ts @@ -1,4 +1,4 @@ -import type { Certificate } from 'thor-devkit'; +import * as ThorDevkit from 'thor-devkit'; import type { WalletConnectOptions } from '@vechain/dapp-kit'; import type { LogLevel } from '../utils/logger'; @@ -53,14 +53,14 @@ type ConnexWallet = BaseWallet & { interface ConnectResponse { account: string; verified: boolean; - connectionCertificate?: Certificate; + connectionCertificate?: ThorDevkit.Certificate; } interface WalletManagerState { source: WalletSource | null; address: string | null; availableSources: WalletSource[]; - connectionCertificate: Certificate | null; + connectionCertificate: ThorDevkit.Certificate | null; } export type { diff --git a/packages/dapp-kit/src/utils/local-storage.ts b/packages/dapp-kit/src/utils/local-storage.ts index 038fbdd1..df2a38bc 100644 --- a/packages/dapp-kit/src/utils/local-storage.ts +++ b/packages/dapp-kit/src/utils/local-storage.ts @@ -1,4 +1,4 @@ -import type { Certificate } from 'thor-devkit'; +import * as ThorDevkit from 'thor-devkit'; import type { WalletSource } from '../types'; import { DAppKitLogger } from './logger'; @@ -26,7 +26,9 @@ const setAccount = (account: string | null): void => { } }; -const setConnectionCertificate = (certificate: Certificate | null): void => { +const setConnectionCertificate = ( + certificate: ThorDevkit.Certificate | null, +): void => { DAppKitLogger.debug( 'LocalStorage', 'setConnectionCertificate', @@ -59,14 +61,14 @@ const getAccount = (): string | null => { return account; }; -const getConnectionCertificate = (): Certificate | null => { +const getConnectionCertificate = (): ThorDevkit.Certificate | null => { const connectionCertificate = localStorage.getItem(CERTIFICATE_KEY); if (!connectionCertificate) { return null; } - return JSON.parse(connectionCertificate) as Certificate; + return JSON.parse(connectionCertificate) as ThorDevkit.Certificate; }; export const Storage = {