Extend the SDK
import {
BTCProvider,
CosmosProvider,
TomoChain
} from '@tomo-inc/tomo-wallet-provider'
class XYZWallet extends BTCProvider {
constructor(chains: TomoChain[]) {
// @ts-ignore
const bitcoinNetworkProvider = window?.xyzWallet
if (!bitcoinNetworkProvider) {
throw new Error('XYZ Wallet not found')
}
super(chains, bitcoinNetworkProvider)
}
connectWallet = async (): Promise<this> => {
const accounts = await this.bitcoinNetworkProvider?.requestAccounts()
const address = accounts[0]
const publicKeyHex = await this.getPublicKeyHex()
if (!address || !publicKeyHex) {
throw new Error('Could not connect to XYZ Wallet')
}
return this
}
}
class ABCWallet extends CosmosProvider {
constructor(chains: TomoChain[]) {
// @ts-ignore
const cosmosProvider = window?.abcCosmos
if (!cosmosProvider) {
throw new Error('ABC Wallet not found')
}
super(chains, cosmosProvider)
}
}Last updated