diff --git a/packages/dapp-kit-react/package.json b/packages/dapp-kit-react/package.json
index e12c8830..ea8f0137 100644
--- a/packages/dapp-kit-react/package.json
+++ b/packages/dapp-kit-react/package.json
@@ -1,6 +1,7 @@
{
"name": "@vechain/dapp-kit-react",
"version": "1.1.1",
+ "private": false,
"homepage": "https://github.com/vechain/vechain-dapp-kit",
"repository": "github:vechain/vechain-dapp-kit",
"license": "MIT",
diff --git a/packages/dapp-kit-react/src/DAppKitProvider/DAppKitProvider.tsx b/packages/dapp-kit-react/src/DAppKitProvider/DAppKitProvider.tsx
index d3c66cbf..cf8acbef 100644
--- a/packages/dapp-kit-react/src/DAppKitProvider/DAppKitProvider.tsx
+++ b/packages/dapp-kit-react/src/DAppKitProvider/DAppKitProvider.tsx
@@ -79,7 +79,6 @@ export const DAppKitProviderData = ({
const closeModal = useCallback(() => {
DAppKitUI.modal.close();
}, []);
-
const onModalConnected = useCallback(
(callback: (address: string | null) => void) =>
DAppKitUI.modal.onConnectionStatusChange(callback),
@@ -181,4 +180,4 @@ export const DAppKitProvider = ({
return (
{children}
);
-};
\ No newline at end of file
+};
diff --git a/packages/dapp-kit-react/src/DAppKitProvider/hooks/useThor.test.tsx b/packages/dapp-kit-react/src/DAppKitProvider/hooks/useThor.test.tsx
new file mode 100644
index 00000000..3a8a161f
--- /dev/null
+++ b/packages/dapp-kit-react/src/DAppKitProvider/hooks/useThor.test.tsx
@@ -0,0 +1,21 @@
+import { describe, it, expect } from 'vitest';
+import { renderHook } from '@testing-library/react';
+import { useThor } from '../..';
+import { wrapper } from '../../../test';
+
+describe('useConnex', () => {
+ it('connex should get initialised', () => {
+ const { result } = renderHook(() => useThor(), { wrapper });
+
+ expect(result.current).toBeDefined();
+ expect(result.current.thor.genesis.id).toBe(
+ '0x00000000851caf3cfdb6e899cf5958bfb1ac3413d346d43539627e6be7ec1b4a',
+ );
+ });
+
+ it('should throw an error when used outside of DAppKitProvider', () => {
+ expect(() => renderHook(() => useThor())).toThrow(
+ '"useConnex" must be used within a ConnexProvider',
+ );
+ });
+});
diff --git a/packages/dapp-kit-react/src/hooks/useVechainDomain/constants.ts b/packages/dapp-kit-react/src/hooks/useVechainDomain/constants.ts
new file mode 100644
index 00000000..2a5b50e9
--- /dev/null
+++ b/packages/dapp-kit-react/src/hooks/useVechainDomain/constants.ts
@@ -0,0 +1,7 @@
+/**
+ * The VNS resolver addresses
+ */
+export const VNS_RESOLVER = {
+ main: '0xA11413086e163e41901bb81fdc5617c975Fa5a1A',
+ test: '0xc403b8EA53F707d7d4de095f0A20bC491Cf2bc94',
+};
diff --git a/packages/dapp-kit/src/classes/wc-wallet.ts b/packages/dapp-kit/src/classes/wc-wallet.ts
new file mode 100644
index 00000000..6ef1ef10
--- /dev/null
+++ b/packages/dapp-kit/src/classes/wc-wallet.ts
@@ -0,0 +1,39 @@
+import { ethers } from 'ethers';
+import type { ConnectResponse, ConnexWallet, WCSigner } from '../types';
+import { SignTypedDataOptions } from '../types/types';
+
+class WCWallet implements ConnexWallet {
+ constructor(private readonly signer: WCSigner) {}
+
+ connect = async (): Promise => {
+ const account = await this.signer.connect();
+
+ return {
+ account,
+ verified: false,
+ };
+ };
+
+ signCert = (
+ msg: Connex.Vendor.CertMessage,
+ options: Connex.Signer.CertOptions,
+ ): Promise =>
+ this.signer.signCert(msg, options);
+
+ signTx = (
+ msg: Connex.Vendor.TxMessage,
+ options: Connex.Signer.TxOptions,
+ ): Promise => this.signer.signTx(msg, options);
+
+ signTypedData = async (
+ _domain: ethers.TypedDataDomain,
+ _types: Record,
+ _value: Record,
+ _options?: SignTypedDataOptions,
+ ): Promise =>
+ this.signer.signTypedData(_domain, _types, _value, _options);
+
+ disconnect = (): Promise => this.signer.disconnect();
+}
+
+export { WCWallet };
diff --git a/packages/dapp-kit/src/utils/convert-vendor-to-signer.ts b/packages/dapp-kit/src/utils/convert-vendor-to-signer.ts
new file mode 100644
index 00000000..3a3fb42c
--- /dev/null
+++ b/packages/dapp-kit/src/utils/convert-vendor-to-signer.ts
@@ -0,0 +1,76 @@
+import { ExpandedConnexSigner } from '../types/types';
+import { DAppKitLogger } from './logger';
+
+export const convertVendorToSigner = (
+ vendor: Connex.Vendor,
+): ExpandedConnexSigner => {
+ return {
+ signTx: (msg, options): Promise => {
+ const service = vendor.sign('tx', msg);
+
+ if (options.gas) {
+ service.gas(options.gas);
+ }
+
+ if (options.signer) {
+ service.signer(options.signer);
+ }
+
+ if (options.dependsOn) {
+ service.dependsOn(options.dependsOn);
+ }
+
+ if (options.link) {
+ service.link(options.link);
+ }
+
+ if (options.comment) {
+ service.comment(options.comment);
+ }
+
+ if (options.delegator) {
+ service.delegate(
+ options.delegator.url,
+ options.delegator.signer,
+ );
+ }
+
+ if (options.onAccepted) {
+ service.accepted(options.onAccepted);
+ }
+
+ DAppKitLogger.debug('vendor', 'signTx', {
+ messages: msg.length,
+ options,
+ });
+
+ return service.request();
+ },
+
+ signCert: (msg, options): Promise => {
+ const service = vendor.sign('cert', msg);
+
+ if (options.signer) {
+ service.signer(options.signer);
+ }
+
+ if (options.link) {
+ service.link(options.link);
+ }
+
+ if (options.onAccepted) {
+ service.accepted(options.onAccepted);
+ }
+
+ DAppKitLogger.debug('vendor', 'signCert', {
+ message: msg,
+ options,
+ });
+
+ return service.request();
+ },
+ signTypedData(_domain, _types, _value, _options) {
+ throw new Error('Sign typed data it is not available with sync2');
+ },
+ };
+};
diff --git a/packages/dapp-kit/src/utils/create-wallet.ts b/packages/dapp-kit/src/utils/create-wallet.ts
index e4dbe870..8b3921da 100644
--- a/packages/dapp-kit/src/utils/create-wallet.ts
+++ b/packages/dapp-kit/src/utils/create-wallet.ts
@@ -70,7 +70,10 @@ export const createWallet = ({
throw e;
});
- return new CertificateBasedWallet(signer, connectionCertificate);
+ return new CertificateBasedWallet(
+ signer as BaseWallet,
+ connectionCertificate,
+ );
}
case 'wallet-connect': {
if (!walletConnectOptions) {
diff --git a/packages/dapp-kit/test/utils/signer.test.ts b/packages/dapp-kit/test/utils/signer.test.ts
index 9c90a1d5..da7b3664 100644
--- a/packages/dapp-kit/test/utils/signer.test.ts
+++ b/packages/dapp-kit/test/utils/signer.test.ts
@@ -5,6 +5,7 @@ import type { WCModal, WCSigner } from '../../src';
import { createWcClient, createWcSigner } from '../../src';
import { mockedSignClient } from '../helpers/mocked-sign-client';
import { address } from '../helpers/mocked-signer';
+import { typedData } from '../fixture';
vi.spyOn(SignClient, 'init').mockResolvedValue(mockedSignClient);
@@ -68,6 +69,18 @@ describe('createWcSigner', () => {
expect(certRes).toBeDefined();
});
+ it('can sign typed data', async () => {
+ const signer = createNewSignClient();
+
+ const signedData = await signer.signTypedData(
+ typedData.domain,
+ typedData.types,
+ typedData.value,
+ );
+
+ expect(signedData).toBeDefined();
+ });
+
it('can disconnect', async () => {
const signer = createNewSignClient();
diff --git a/packages/dapp-kit/test/wallet-manager.test.ts b/packages/dapp-kit/test/wallet-manager.test.ts
index 9a0d5838..063513be 100644
--- a/packages/dapp-kit/test/wallet-manager.test.ts
+++ b/packages/dapp-kit/test/wallet-manager.test.ts
@@ -61,6 +61,20 @@ describe('WalletManager', () => {
});
});
+ describe('signTypedData', () => {
+ it('should sign the typedData', async () => {
+ const walletManager = newWalletManager();
+ walletManager.setSource('veworld');
+ const res = await walletManager.signTypedData(
+ typedData.domain,
+ typedData.types,
+ typedData.value,
+ );
+
+ expect(res).toBeDefined();
+ });
+ });
+
describe('disconnect', () => {
it('is not connected', async () => {
const walletManager = newWalletManager();
diff --git a/scripts/prepare-packages.ts b/scripts/prepare-packages.ts
index 00f75e3c..6414da4b 100644
--- a/scripts/prepare-packages.ts
+++ b/scripts/prepare-packages.ts
@@ -50,8 +50,8 @@ const preparePackages = async () => {
console.log(' - ✅ Removed!');
console.log(' Build:');
- console.log(' - 📦 Building packages...');
- await exec('yarn install && yarn install:all');
+ console.log(' - 📦 Install dependencies and build packages...');
+ await exec('yarn install:all');
console.log(' - ✅ Built!');
console.log(' Test:');