More wallets with Tomo Connect
diff --git a/src/context/Chain.context.tsx b/src/context/Chain.context.tsx
index 6e4451b..698fcae 100644
--- a/src/context/Chain.context.tsx
+++ b/src/context/Chain.context.tsx
@@ -28,8 +28,8 @@ interface ProviderProps {
}
export interface Connectors {
- BTC: WalletConnector<"BTC", IBTCProvider> | null;
- BBN: WalletConnector<"BBN", IBBNProvider> | null;
+ BTC: WalletConnector<"BTC", IBTCProvider, BTCConfig> | null;
+ BBN: WalletConnector<"BBN", IBBNProvider, BBNConfig> | null;
}
const defaultState: Connectors = {
diff --git a/src/core/WalletConnector.ts b/src/core/WalletConnector.ts
index 2fa61ab..4199931 100644
--- a/src/core/WalletConnector.ts
+++ b/src/core/WalletConnector.ts
@@ -10,7 +10,7 @@ export interface ConnectorEvents
{
error: (error: Error) => void;
}
-export class WalletConnector implements IConnector {
+export class WalletConnector implements IConnector {
private _connectedWallet: Wallet | null = null;
private _ee = createNanoEvents>();
@@ -19,6 +19,7 @@ export class WalletConnector implements I
public readonly name: string,
public readonly icon: string,
public readonly wallets: Wallet[],
+ public readonly config: C,
) {}
get connectedWallet() {
@@ -53,7 +54,7 @@ export class WalletConnector implements I
}
clone() {
- return new WalletConnector(this.id, this.name, this.icon, this.wallets);
+ return new WalletConnector(this.id, this.name, this.icon, this.wallets, this.config);
}
on>(name: K, handler: ConnectorEvents[K]) {
diff --git a/src/core/index.ts b/src/core/index.ts
index 0334abf..498b353 100644
--- a/src/core/index.ts
+++ b/src/core/index.ts
@@ -67,12 +67,12 @@ export const createWalletConnector = async ,
context: any,
config: C,
-): Promise> => {
+): Promise> => {
const wallets: Wallet[] = [];
for (const walletMetadata of metadata.wallets) {
wallets.push(await createWallet(walletMetadata, context, config));
}
- return new WalletConnector(metadata.chain, metadata.name, metadata.icon, wallets);
+ return new WalletConnector(metadata.chain, metadata.name, metadata.icon, wallets, config);
};
diff --git a/src/core/types.ts b/src/core/types.ts
index 0156857..a501c01 100644
--- a/src/core/types.ts
+++ b/src/core/types.ts
@@ -76,14 +76,16 @@ export interface IWallet
{
label: string;
}
-export interface IChain {
+export interface IChain {
id: K;
name: string;
icon: string;
wallets: IWallet[];
+ config: C;
}
-export interface IConnector extends IChain {
+export interface IConnector
+ extends IChain {
connect(wallet: string | IWallet): Promise | null>;
disconnect(): Promise;
on(event: string, cb: (wallet: IWallet) => void): () => void;