@hashgraph/hedera-wallet-connect
Version:
A library to facilitate integrating Hedera with WalletConnect
33 lines (32 loc) • 1.2 kB
JavaScript
import { ConstantsUtil } from '@reown/appkit-common';
import { PresetsUtil } from '@reown/appkit-utils';
import { createNamespaces } from '../utils';
export class HederaConnector {
constructor({ provider, caipNetworks, namespace }) {
this.id = ConstantsUtil.CONNECTOR_ID.WALLET_CONNECT;
this.name = PresetsUtil.ConnectorNamesMap[ConstantsUtil.CONNECTOR_ID.WALLET_CONNECT];
this.type = 'WALLET_CONNECT';
this.imageId = PresetsUtil.ConnectorImageIds[ConstantsUtil.CONNECTOR_ID.WALLET_CONNECT];
this.caipNetworks = caipNetworks;
this.provider = provider;
this.chain = namespace;
}
get chains() {
return this.caipNetworks;
}
async connectWalletConnect() {
const namespaces = createNamespaces(this.caipNetworks);
const connectParams = { optionalNamespaces: namespaces };
await this.provider.connect(connectParams);
return {
clientId: await this.provider.client.core.crypto.getClientId(),
session: this.provider.session,
};
}
async disconnect() {
await this.provider.disconnect();
}
async authenticate() {
return false;
}
}