diff --git a/src/CardanoPeerConnect.ts b/src/CardanoPeerConnect.ts index 8882c16..6c32fd2 100644 --- a/src/CardanoPeerConnect.ts +++ b/src/CardanoPeerConnect.ts @@ -97,9 +97,7 @@ export default abstract class CardanoPeerConnect { this.DAppDiscoveryMeerkat = new Meerkat({ announce: this.announceEndpoints, seed: - this.discoverySeed ?? - AutoConnectHelper.getWalletAutoDiscoverySeed() ?? - undefined, + this.discoverySeed ? this.discoverySeed : undefined, loggingEnabled: true, }).setMaxListeners(20); diff --git a/src/DAppPeerConnect.ts b/src/DAppPeerConnect.ts index 42b1267..3a44b02 100644 --- a/src/DAppPeerConnect.ts +++ b/src/DAppPeerConnect.ts @@ -27,7 +27,7 @@ export default class DAppPeerConnect { protected identicon: string | null = null; - protected onConnect?: (address: string) => void; + protected onConnect?: (address: string, walletInfo?: IWalletInfo) => void; protected onDisconnect?: (address: string) => void; protected onApiEject?: (name: string, address: string) => void; protected onApiInject?: (name: string, address: string) => void; @@ -204,7 +204,8 @@ export default class DAppPeerConnect { if (!this.connectedWallet) { const connectWallet = ( granted: boolean, - allowAutoConnect: boolean = false + allowAutoConnect: boolean = false, + connectedWalletInfo?: IWalletInfo ) => { if (walletInfo.requestAutoconnect && granted && allowAutoConnect) { AutoConnectHelper.addAutoConnectId(address); @@ -227,7 +228,7 @@ export default class DAppPeerConnect { this.generateIdenticon(); if (this.onConnect) { - this.onConnect(address); + this.onConnect(address, connectedWalletInfo); } } else { callback({ @@ -245,13 +246,10 @@ export default class DAppPeerConnect { if (typeof verifyConnection !== 'undefined') { if (AutoConnectHelper.isAutoConnectId(address)) { - connectWallet(true); + connectWallet(true, true, walletInfo); } else { verifyConnection( - { - ...walletInfo, - address: address, - }, + walletInfo, connectWallet ); } @@ -452,6 +450,12 @@ export default class DAppPeerConnect { `injected api of ${args.api.name} into window.cardano` ); + callback({ + dApp: this.dAppInfo, + connected: true, + error: false + }); + if (onApiInject) { onApiInject(args.api.name, address); } diff --git a/src/types.ts b/src/types.ts index b8811c9..8bb3203 100644 --- a/src/types.ts +++ b/src/types.ts @@ -85,9 +85,9 @@ export interface DAppPeerConnectParameters { loggingEnabled?: boolean; verifyConnection?: ( walletInfo: IWalletInfo, - callback: (granted: boolean, allowAutoConnect: boolean) => void + callback: (granted: boolean, allowAutoConnect: boolean, walletInfo?: IWalletInfo) => void ) => void; - onConnect?: (address: string) => void; + onConnect?: (address: string, walletInfo?: IWalletInfo) => void; onDisconnect?: (address: string) => void; onApiEject?: (name: string, address: string) => void; onApiInject?: (name: string, address: string) => void;