Skip to content

Commit

Permalink
refactor: change wallet kit options
Browse files Browse the repository at this point in the history
  • Loading branch information
darrenvechain committed Nov 6, 2023
1 parent 43dbfd2 commit 60a46c3
Showing 1 changed file with 5 additions and 24 deletions.
29 changes: 5 additions & 24 deletions packages/vanilla-wallet-kit/src/client.ts
Original file line number Diff line number Diff line change
@@ -1,38 +1,19 @@
import type { WalletSource } from '@vechain/wallet-kit';
import { MultiWalletConnex } from '@vechain/wallet-kit';
import type { ConnexOptions } from '@vechain/wallet-kit/src';
import type { SourceInfo } from './constants';

export interface VechainWalletKitOptions {
connex?: MultiWalletConnex;
nodeUrl: string;
network: string; // TODO: add a type for this
walletConnectOptions: {
projectId: string;
metadata: {
name: string;
description: string;
url: string;
icons: string[];
};
};
onDisconnected: () => void;
}
export type VechainWalletKitOptions = MultiWalletConnex | ConnexOptions;

class VechainWalletKit {
connex: MultiWalletConnex;
account: string | null = null;

constructor(options: VechainWalletKitOptions) {
if (options.connex) {
this.connex = options.connex;
if ('thor' in options) {
this.connex = options;
} else {
this.connex = new MultiWalletConnex({
nodeUrl: options.nodeUrl,
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
genesis: options.network as any,
walletConnectOptions: options.walletConnectOptions,
onDisconnected: options.onDisconnected,
});
this.connex = new MultiWalletConnex(options);
}
}

Expand Down

0 comments on commit 60a46c3

Please sign in to comment.