diff --git a/.gitignore b/.gitignore index 7f3e74d..d66b82a 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ test*.ts test*.js test*.cjs .env +index.html # Editor directories and files .vscode/* diff --git a/packages/networks/bitcoin/package.json b/packages/networks/bitcoin/package.json index 3a3c087..c87491d 100644 --- a/packages/networks/bitcoin/package.json +++ b/packages/networks/bitcoin/package.json @@ -1,6 +1,6 @@ { "name": "@multiplechain/bitcoin", - "version": "0.4.1", + "version": "0.4.2", "type": "module", "main": "dist/index.cjs", "module": "dist/index.es.js", @@ -72,7 +72,7 @@ "url": "https://github.com/MultipleChain/js/issues" }, "dependencies": { - "@multiplechain/types": "^0.1.63", + "@multiplechain/types": "^0.1.64", "@multiplechain/utils": "^0.1.21", "axios": "^1.6.8", "bitcore-lib": "^10.0.28", diff --git a/packages/networks/bitcoin/pnpm-lock.yaml b/packages/networks/bitcoin/pnpm-lock.yaml index 549f09d..faefe4f 100644 --- a/packages/networks/bitcoin/pnpm-lock.yaml +++ b/packages/networks/bitcoin/pnpm-lock.yaml @@ -6,8 +6,8 @@ settings: dependencies: '@multiplechain/types': - specifier: ^0.1.63 - version: 0.1.63 + specifier: ^0.1.64 + version: 0.1.64 '@multiplechain/utils': specifier: ^0.1.21 version: 0.1.21 @@ -34,8 +34,8 @@ devDependencies: packages: - /@multiplechain/types@0.1.63: - resolution: {integrity: sha512-4C201vUsN6F1S/M7vT+GZS0wTdKGZXHqn4YmC6ouC8n0uxMCEFdI2sSCadyHKFKG5OBPo16X1oFCX9MVwPqMoA==} + /@multiplechain/types@0.1.64: + resolution: {integrity: sha512-euzFLiq18L3SCqN9mLY2GKEkaJhTFcBg7Ono/yqN87IT5qlZ1Xqzk2jcWvRcnlN3O5wL15QLKS+e2C11DKeXOA==} dev: false /@multiplechain/utils@0.1.21: diff --git a/packages/networks/bitcoin/src/browser/Wallet.ts b/packages/networks/bitcoin/src/browser/Wallet.ts index 7520be9..f4e4f82 100644 --- a/packages/networks/bitcoin/src/browser/Wallet.ts +++ b/packages/networks/bitcoin/src/browser/Wallet.ts @@ -12,7 +12,7 @@ import { import { Provider } from '../services/Provider.ts' import type { TransactionSigner } from '../services/TransactionSigner.ts' -export interface BitcoinWalletAdapter { +export interface WalletProvider { getAddress: () => Promise signMessage: (message: string) => Promise sendBitcoin: (to: string, amount: number) => Promise @@ -33,12 +33,12 @@ const rejectMap = (error: any, reject: (a: any) => any): any => { return reject(error) } -type WalletAdapter = WalletAdapterInterface +type WalletAdapter = WalletAdapterInterface -export class Wallet implements WalletInterface { +export class Wallet implements WalletInterface { adapter: WalletAdapter - walletProvider: BitcoinWalletAdapter + walletProvider: WalletProvider networkProvider: Provider diff --git a/packages/networks/bitcoin/src/browser/adapters/Leather.ts b/packages/networks/bitcoin/src/browser/adapters/Leather.ts index f2863af..33faa06 100644 --- a/packages/networks/bitcoin/src/browser/adapters/Leather.ts +++ b/packages/networks/bitcoin/src/browser/adapters/Leather.ts @@ -1,8 +1,8 @@ import icons from './icons.ts' +import type { WalletProvider } from '../Wallet.ts' import { WalletPlatformEnum } from '@multiplechain/types' -import type { WalletAdapterInterface } from '@multiplechain/types' -import type { BitcoinWalletAdapter } from '../Wallet.ts' import type { Provider } from '../../services/Provider.ts' +import type { WalletAdapterInterface } from '@multiplechain/types' declare global { interface Window { @@ -16,23 +16,24 @@ declare global { } let connected = false +let walletProvider: WalletProvider | undefined -const Leather: WalletAdapterInterface = { +const Leather: WalletAdapterInterface = { id: 'leather', name: 'Leather', icon: icons.Leather, - provider: window.LeatherProvider, + provider: walletProvider, platforms: [WalletPlatformEnum.BROWSER], downloadLink: 'https://leather.io/install-extension', isDetected: () => Boolean(window.LeatherProvider), isConnected: async () => connected, - connect: async (provider?: Provider): Promise => { + connect: async (provider?: Provider): Promise => { return await new Promise((resolve, reject) => { const leather = window.LeatherProvider const network = provider !== undefined && provider?.isTestnet() ? 'testnet' : 'mainnet' - const walletAdapter: BitcoinWalletAdapter = { + const _walletProvider: WalletProvider = { on: (event, callback) => { if (window.btc?.listen !== undefined) { window.btc.listen(event, callback) @@ -71,7 +72,7 @@ const Leather: WalletAdapterInterface = { getAddress: async () => '' } - const connect = async (): Promise => { + const connect = async (): Promise => { const addresses = ( await leather.request('getAddresses', { network @@ -83,18 +84,18 @@ const Leather: WalletAdapterInterface = { // for ordinals & BRC-20 integrations // const ordinals = addresses.find(address => address.type == 'p2tr'); - walletAdapter.getAddress = async () => { + _walletProvider.getAddress = async () => { return bitcoin.address } - return walletAdapter + return _walletProvider } try { connect() - .then((walletAdapter) => { + .then(() => { connected = true - resolve(walletAdapter) + resolve((walletProvider = _walletProvider)) }) .catch(reject) } catch (error) { diff --git a/packages/networks/bitcoin/src/browser/adapters/UniSat.ts b/packages/networks/bitcoin/src/browser/adapters/UniSat.ts index a285d5c..6f7c29c 100644 --- a/packages/networks/bitcoin/src/browser/adapters/UniSat.ts +++ b/packages/networks/bitcoin/src/browser/adapters/UniSat.ts @@ -1,6 +1,6 @@ import icons from './icons.ts' +import type { WalletProvider } from '../Wallet.ts' import { WalletPlatformEnum } from '@multiplechain/types' -import type { BitcoinWalletAdapter } from '../Wallet.ts' import type { Provider } from '../../services/Provider.ts' import type { WalletAdapterInterface } from '@multiplechain/types' @@ -18,20 +18,22 @@ declare global { } } -const UniSat: WalletAdapterInterface = { +let walletProvider: WalletProvider | undefined + +const UniSat: WalletAdapterInterface = { id: 'unisat', name: 'UniSat', icon: icons.UniSat, - provider: window.unisat, + provider: walletProvider, platforms: [WalletPlatformEnum.BROWSER], downloadLink: 'https://unisat.io/download', isDetected: () => Boolean(window.unisat?.requestAccounts), isConnected: async () => window?.unisat?._isConnected ?? false, - connect: async (provider?: Provider): Promise => { + connect: async (provider?: Provider): Promise => { return await new Promise((resolve, reject) => { const network = provider !== undefined && provider?.isTestnet() ? 'testnet' : 'livenet' - const walletAdapter: BitcoinWalletAdapter = { + const _walletProvider: WalletProvider = { on: window.unisat.on, signMessage: window.unisat.signMessage, sendBitcoin: window.unisat.sendBitcoin, @@ -47,7 +49,7 @@ const UniSat: WalletAdapterInterface = { window.unisat .switchNetwork(network) .then(() => { - resolve(walletAdapter) + resolve((walletProvider = _walletProvider)) }) .catch(reject) }) diff --git a/packages/networks/bitcoin/src/browser/adapters/Xverse.ts b/packages/networks/bitcoin/src/browser/adapters/Xverse.ts index a6cdde8..f7f6b63 100644 --- a/packages/networks/bitcoin/src/browser/adapters/Xverse.ts +++ b/packages/networks/bitcoin/src/browser/adapters/Xverse.ts @@ -1,5 +1,6 @@ import icons from './icons.ts' -import type { BitcoinWalletAdapter } from '../Wallet.ts' +import type { WalletProvider } from '../Wallet.ts' +import type { Provider } from '../../services/Provider.ts' import { ErrorTypeEnum, WalletPlatformEnum, @@ -12,30 +13,30 @@ import { signMessage, AddressPurpose } from 'sats-connect' -import type { Provider } from '../../services/Provider.ts' let connected = false +let walletProvider: WalletProvider | undefined -const Xverse: WalletAdapterInterface = { +const Xverse: WalletAdapterInterface = { id: 'xverse', name: 'Xverse', icon: icons.Xverse, - provider: window.XverseProviders?.BitcoinProvider, + provider: walletProvider, platforms: [WalletPlatformEnum.BROWSER, WalletPlatformEnum.MOBILE], downloadLink: 'https://www.xverse.app/download', isDetected: () => Boolean(window.XverseProviders?.BitcoinProvider), isConnected: async () => connected, - connect: async (provider?: Provider): Promise => { + connect: async (provider?: Provider): Promise => { return await new Promise((resolve, reject) => { const type = provider !== undefined && provider?.isTestnet() ? BitcoinNetworkType.Testnet : BitcoinNetworkType.Mainnet - const walletAdapter: BitcoinWalletAdapter = { + const _walletProvider: WalletProvider = { on: (_event: string, _callback: (data: any) => void) => {}, signMessage: async (message: string) => { - const address = await walletAdapter.getAddress() + const address = await _walletProvider.getAddress() return await new Promise((resolve, reject) => { signMessage({ payload: { @@ -55,7 +56,7 @@ const Xverse: WalletAdapterInterface = { }) }, sendBitcoin: async (to: string, amount: number) => { - const senderAddress = await walletAdapter.getAddress() + const senderAddress = await _walletProvider.getAddress() return await new Promise((resolve, reject) => { sendBtcTransaction({ payload: { @@ -82,7 +83,7 @@ const Xverse: WalletAdapterInterface = { getAddress: async () => '' } - const connect = async (): Promise => { + const connect = async (): Promise => { return await new Promise((resolve, reject) => { try { getAddress({ @@ -107,11 +108,11 @@ const Xverse: WalletAdapterInterface = { return } - walletAdapter.getAddress = async () => { + _walletProvider.getAddress = async () => { return bitcoin.address } - resolve(walletAdapter) + resolve(_walletProvider) }, onCancel: () => { reject(ErrorTypeEnum.WALLET_REQUEST_REJECTED) @@ -125,9 +126,9 @@ const Xverse: WalletAdapterInterface = { try { connect() - .then((walletAdapter) => { + .then(() => { connected = true - resolve(walletAdapter) + resolve((walletProvider = _walletProvider)) }) .catch(reject) } catch (error) { diff --git a/packages/networks/bitcoin/src/browser/index.ts b/packages/networks/bitcoin/src/browser/index.ts index 0695fc8..d1b6c70 100644 --- a/packages/networks/bitcoin/src/browser/index.ts +++ b/packages/networks/bitcoin/src/browser/index.ts @@ -1,5 +1,5 @@ import type { Provider } from 'sats-connect' -import { Wallet, type BitcoinWalletAdapter } from './Wallet.ts' +import { Wallet, type WalletProvider } from './Wallet.ts' import * as adapterList from './adapters/index.ts' import type { WalletAdapterListType, @@ -7,10 +7,10 @@ import type { RegisterWalletAdapterType } from '@multiplechain/types' -const adapters: WalletAdapterListType = {} +const adapters: WalletAdapterListType = {} -const registerAdapter: RegisterWalletAdapterType = ( - adapter: WalletAdapterInterface +const registerAdapter: RegisterWalletAdapterType = ( + adapter: WalletAdapterInterface ): void => { if (Object.values(adapters).find((a) => a.id === adapter.id) !== undefined) { throw new Error(`Adapter with id ${adapter.id} already exists`) diff --git a/packages/networks/boilerplate/package.json b/packages/networks/boilerplate/package.json index 144af60..e17cc80 100644 --- a/packages/networks/boilerplate/package.json +++ b/packages/networks/boilerplate/package.json @@ -72,7 +72,7 @@ "url": "https://github.com/MultipleChain/js/issues" }, "dependencies": { - "@multiplechain/types": "^0.1.63", + "@multiplechain/types": "^0.1.64", "@multiplechain/utils": "^0.1.21" } } \ No newline at end of file diff --git a/packages/networks/boilerplate/pnpm-lock.yaml b/packages/networks/boilerplate/pnpm-lock.yaml index c63ee4e..88414c2 100644 --- a/packages/networks/boilerplate/pnpm-lock.yaml +++ b/packages/networks/boilerplate/pnpm-lock.yaml @@ -6,16 +6,16 @@ settings: dependencies: '@multiplechain/types': - specifier: ^0.1.63 - version: 0.1.63 + specifier: ^0.1.64 + version: 0.1.64 '@multiplechain/utils': specifier: ^0.1.21 version: 0.1.21 packages: - /@multiplechain/types@0.1.63: - resolution: {integrity: sha512-4C201vUsN6F1S/M7vT+GZS0wTdKGZXHqn4YmC6ouC8n0uxMCEFdI2sSCadyHKFKG5OBPo16X1oFCX9MVwPqMoA==} + /@multiplechain/types@0.1.64: + resolution: {integrity: sha512-euzFLiq18L3SCqN9mLY2GKEkaJhTFcBg7Ono/yqN87IT5qlZ1Xqzk2jcWvRcnlN3O5wL15QLKS+e2C11DKeXOA==} dev: false /@multiplechain/utils@0.1.21: diff --git a/packages/networks/evm-chains/package.json b/packages/networks/evm-chains/package.json index 25493ca..471c7a5 100644 --- a/packages/networks/evm-chains/package.json +++ b/packages/networks/evm-chains/package.json @@ -1,6 +1,6 @@ { "name": "@multiplechain/evm-chains", - "version": "0.4.0", + "version": "0.4.1", "type": "module", "main": "dist/index.cjs", "module": "dist/index.es.js", @@ -75,7 +75,7 @@ "url": "https://github.com/MultipleChain/js/issues" }, "dependencies": { - "@multiplechain/types": "^0.1.63", + "@multiplechain/types": "^0.1.64", "@multiplechain/utils": "^0.1.21", "@wagmi/chains": "^1.8.0", "@walletconnect/ethereum-provider": "^2.12.2", diff --git a/packages/networks/evm-chains/pnpm-lock.yaml b/packages/networks/evm-chains/pnpm-lock.yaml index 9d29756..dfd8dcc 100644 --- a/packages/networks/evm-chains/pnpm-lock.yaml +++ b/packages/networks/evm-chains/pnpm-lock.yaml @@ -6,8 +6,8 @@ settings: dependencies: '@multiplechain/types': - specifier: ^0.1.63 - version: 0.1.63 + specifier: ^0.1.64 + version: 0.1.64 '@multiplechain/utils': specifier: ^0.1.21 version: 0.1.21 @@ -239,8 +239,8 @@ packages: tslib: 2.4.0 dev: false - /@multiplechain/types@0.1.63: - resolution: {integrity: sha512-4C201vUsN6F1S/M7vT+GZS0wTdKGZXHqn4YmC6ouC8n0uxMCEFdI2sSCadyHKFKG5OBPo16X1oFCX9MVwPqMoA==} + /@multiplechain/types@0.1.64: + resolution: {integrity: sha512-euzFLiq18L3SCqN9mLY2GKEkaJhTFcBg7Ono/yqN87IT5qlZ1Xqzk2jcWvRcnlN3O5wL15QLKS+e2C11DKeXOA==} dev: false /@multiplechain/utils@0.1.21: diff --git a/packages/networks/evm-chains/src/browser/adapters/MetaMask.ts b/packages/networks/evm-chains/src/browser/adapters/MetaMask.ts index 061c8c4..1a8aa43 100644 --- a/packages/networks/evm-chains/src/browser/adapters/MetaMask.ts +++ b/packages/networks/evm-chains/src/browser/adapters/MetaMask.ts @@ -10,8 +10,8 @@ const MetaMask: WalletAdapterInterface = { id: 'metamask', name: 'MetaMask', icon: icons.metaMask, - provider: window.ethereum, downloadLink: 'https://metamask.io/download/', + provider: window.ethereum as unknown as WindowEthereum, platforms: [WalletPlatformEnum.BROWSER, WalletPlatformEnum.MOBILE], isDetected: () => Boolean((window?.ethereum as unknown as WindowEthereum).isMetaMask), createDeepLink: (url: string): string => `https://metamask.app.link/dapp/${url}`, diff --git a/packages/networks/solana/package.json b/packages/networks/solana/package.json index bfd85ef..aac734e 100644 --- a/packages/networks/solana/package.json +++ b/packages/networks/solana/package.json @@ -1,6 +1,6 @@ { "name": "@multiplechain/solana", - "version": "0.4.0", + "version": "0.4.1", "type": "module", "main": "dist/index.cjs", "module": "dist/index.es.js", @@ -74,7 +74,7 @@ "dependencies": { "@metaplex-foundation/js": "^0.20.1", "@multiplechain/solana-walletconnect": "^0.1.1", - "@multiplechain/types": "^0.1.63", + "@multiplechain/types": "^0.1.64", "@multiplechain/utils": "^0.1.21", "@solana/spl-token": "^0.4.6", "@solana/spl-token-metadata": "^0.1.4", diff --git a/packages/networks/solana/pnpm-lock.yaml b/packages/networks/solana/pnpm-lock.yaml index 6244306..d956d19 100644 --- a/packages/networks/solana/pnpm-lock.yaml +++ b/packages/networks/solana/pnpm-lock.yaml @@ -12,8 +12,8 @@ dependencies: specifier: ^0.1.1 version: 0.1.1(@solana/web3.js@1.91.8)(vite@5.2.11) '@multiplechain/types': - specifier: ^0.1.63 - version: 0.1.63 + specifier: ^0.1.64 + version: 0.1.64 '@multiplechain/utils': specifier: ^0.1.21 version: 0.1.21 @@ -935,8 +935,8 @@ packages: - vite dev: false - /@multiplechain/types@0.1.63: - resolution: {integrity: sha512-4C201vUsN6F1S/M7vT+GZS0wTdKGZXHqn4YmC6ouC8n0uxMCEFdI2sSCadyHKFKG5OBPo16X1oFCX9MVwPqMoA==} + /@multiplechain/types@0.1.64: + resolution: {integrity: sha512-euzFLiq18L3SCqN9mLY2GKEkaJhTFcBg7Ono/yqN87IT5qlZ1Xqzk2jcWvRcnlN3O5wL15QLKS+e2C11DKeXOA==} dev: false /@multiplechain/utils@0.1.21: diff --git a/packages/networks/solana/src/browser/Wallet.ts b/packages/networks/solana/src/browser/Wallet.ts index 1e3e2f7..ec49f2b 100644 --- a/packages/networks/solana/src/browser/Wallet.ts +++ b/packages/networks/solana/src/browser/Wallet.ts @@ -11,8 +11,8 @@ import { } from '@multiplechain/types' import { Provider } from '../services/Provider.ts' import type { - BaseMessageSignerWalletAdapter, - WalletAdapterEvents + WalletAdapterEvents, + BaseMessageSignerWalletAdapter } from '@solana/wallet-adapter-base' import { base58Encode } from '@multiplechain/utils' import type { TransactionSigner } from '../services/TransactionSigner.ts' @@ -76,14 +76,14 @@ const rejectMap = (error: any, reject: (a: any) => any): any => { return reject(error) } -export type WalletAdapter = BaseMessageSignerWalletAdapter +export type WalletProvider = BaseMessageSignerWalletAdapter -type WalletAdapterType = WalletAdapterInterface +type WalletAdapterType = WalletAdapterInterface -export class Wallet implements WalletInterface { +export class Wallet implements WalletInterface { adapter: WalletAdapterType - walletProvider: WalletAdapter + walletProvider: WalletProvider networkProvider: Provider @@ -156,7 +156,7 @@ export class Wallet implements WalletInterface { - this.walletProvider = provider as BaseMessageSignerWalletAdapter + this.walletProvider = provider this.on('error', (error) => rejectMap(error, this.currentReject)) resolve(await this.getAddress()) }) diff --git a/packages/networks/solana/src/browser/adapters/BitgetWallet.ts b/packages/networks/solana/src/browser/adapters/BitgetWallet.ts index 8badf80..88e22a6 100644 --- a/packages/networks/solana/src/browser/adapters/BitgetWallet.ts +++ b/packages/networks/solana/src/browser/adapters/BitgetWallet.ts @@ -1,4 +1,4 @@ -import type { WalletAdapter } from '../Wallet.ts' +import type { WalletProvider } from '../Wallet.ts' import { WalletPlatformEnum } from '@multiplechain/types' import type { Provider } from '../../services/Provider.ts' import { WalletReadyState } from '@solana/wallet-adapter-base' @@ -7,11 +7,11 @@ import type { WalletAdapterInterface } from '@multiplechain/types' const bitget = new BitgetWalletAdapter() -const BitgetWallet: WalletAdapterInterface = { +const BitgetWallet: WalletAdapterInterface = { id: 'bitgetwallet', name: bitget.name, icon: bitget.icon, - provider: bitget, + provider: bitget as WalletProvider, platforms: [WalletPlatformEnum.BROWSER, WalletPlatformEnum.MOBILE], downloadLink: 'https://web3.bitget.com/en/wallet-download?type=3', createDeepLink(url: string): string { @@ -22,9 +22,9 @@ const BitgetWallet: WalletAdapterInterface = { disconnect: async () => { await bitget.disconnect() }, - connect: async (): Promise => { + connect: async (): Promise => { await bitget.connect() - return bitget as WalletAdapter + return bitget as WalletProvider } } diff --git a/packages/networks/solana/src/browser/adapters/CoinbaseWallet.ts b/packages/networks/solana/src/browser/adapters/CoinbaseWallet.ts index c199ec4..b1d5bfd 100644 --- a/packages/networks/solana/src/browser/adapters/CoinbaseWallet.ts +++ b/packages/networks/solana/src/browser/adapters/CoinbaseWallet.ts @@ -1,4 +1,4 @@ -import type { WalletAdapter } from '../Wallet.ts' +import type { WalletProvider } from '../Wallet.ts' import { WalletPlatformEnum } from '@multiplechain/types' import type { Provider } from '../../services/Provider.ts' import { WalletReadyState } from '@solana/wallet-adapter-base' @@ -7,7 +7,7 @@ import { CoinbaseWalletAdapter } from '@solana/wallet-adapter-coinbase' const coinbase = new CoinbaseWalletAdapter() -const CoinbaseWallet: WalletAdapterInterface = { +const CoinbaseWallet: WalletAdapterInterface = { id: 'coinbasewallet', name: coinbase.name, icon: coinbase.icon, @@ -22,7 +22,7 @@ const CoinbaseWallet: WalletAdapterInterface = { disconnect: async () => { await coinbase.disconnect() }, - connect: async (): Promise => { + connect: async (): Promise => { await coinbase.connect() return coinbase } diff --git a/packages/networks/solana/src/browser/adapters/Phantom.ts b/packages/networks/solana/src/browser/adapters/Phantom.ts index 3ee1669..02e026e 100644 --- a/packages/networks/solana/src/browser/adapters/Phantom.ts +++ b/packages/networks/solana/src/browser/adapters/Phantom.ts @@ -1,4 +1,4 @@ -import type { WalletAdapter } from '../Wallet.ts' +import type { WalletProvider } from '../Wallet.ts' import { WalletPlatformEnum } from '@multiplechain/types' import type { Provider } from '../../services/Provider.ts' import type { WalletAdapterInterface } from '@multiplechain/types' @@ -17,7 +17,7 @@ declare global { } } -const Phantom: WalletAdapterInterface = { +const Phantom: WalletAdapterInterface = { id: 'phantom', name: phantomAdapter.name, icon: phantomAdapter.icon, @@ -35,7 +35,7 @@ const Phantom: WalletAdapterInterface = { disconnect: async () => { await phantomAdapter.disconnect() }, - connect: async (): Promise => { + connect: async (): Promise => { await phantomAdapter.connect() return phantomAdapter } diff --git a/packages/networks/solana/src/browser/adapters/Slope.ts b/packages/networks/solana/src/browser/adapters/Slope.ts index 23dcdac..abcc16c 100644 --- a/packages/networks/solana/src/browser/adapters/Slope.ts +++ b/packages/networks/solana/src/browser/adapters/Slope.ts @@ -1,4 +1,4 @@ -import type { WalletAdapter } from '../Wallet.ts' +import type { WalletProvider } from '../Wallet.ts' import { WalletPlatformEnum } from '@multiplechain/types' import type { Provider } from '../../services/Provider.ts' import { WalletReadyState } from '@solana/wallet-adapter-base' @@ -7,11 +7,11 @@ import type { WalletAdapterInterface } from '@multiplechain/types' const slope = new SlopeWalletAdapter() -const Slope: WalletAdapterInterface = { +const Slope: WalletAdapterInterface = { id: 'slope', name: slope.name, icon: slope.icon, - provider: slope, + provider: slope as WalletProvider, platforms: [WalletPlatformEnum.BROWSER], downloadLink: 'https://www.slope.finance/', isDetected: () => slope.readyState === WalletReadyState.Installed, @@ -19,9 +19,9 @@ const Slope: WalletAdapterInterface = { disconnect: async () => { await slope.disconnect() }, - connect: async (): Promise => { + connect: async (): Promise => { await slope.connect() - return slope as WalletAdapter + return slope as WalletProvider } } diff --git a/packages/networks/solana/src/browser/adapters/Solflare.ts b/packages/networks/solana/src/browser/adapters/Solflare.ts index c9b1fe3..77cfc64 100644 --- a/packages/networks/solana/src/browser/adapters/Solflare.ts +++ b/packages/networks/solana/src/browser/adapters/Solflare.ts @@ -1,4 +1,4 @@ -import type { WalletAdapter } from '../Wallet.ts' +import type { WalletProvider } from '../Wallet.ts' import { WalletPlatformEnum } from '@multiplechain/types' import type { Provider } from '../../services/Provider.ts' import type { WalletAdapterInterface } from '@multiplechain/types' @@ -15,7 +15,7 @@ declare global { } } -const Solflare: WalletAdapterInterface = { +const Solflare: WalletAdapterInterface = { id: 'solflare', name: solflare.name, icon: solflare.icon, @@ -30,7 +30,7 @@ const Solflare: WalletAdapterInterface = { disconnect: async () => { await solflare.disconnect() }, - connect: async (provider?: Provider): Promise => { + connect: async (provider?: Provider): Promise => { const solflare = new SolflareWalletAdapter({ network: provider !== undefined && provider?.isTestnet() diff --git a/packages/networks/solana/src/browser/adapters/TokenPocket.ts b/packages/networks/solana/src/browser/adapters/TokenPocket.ts index 6e596eb..507b39c 100644 --- a/packages/networks/solana/src/browser/adapters/TokenPocket.ts +++ b/packages/networks/solana/src/browser/adapters/TokenPocket.ts @@ -1,4 +1,4 @@ -import type { WalletAdapter } from '../Wallet.ts' +import type { WalletProvider } from '../Wallet.ts' import { WalletPlatformEnum } from '@multiplechain/types' import type { Provider } from '../../services/Provider.ts' import { WalletReadyState } from '@solana/wallet-adapter-base' @@ -7,11 +7,11 @@ import { TokenPocketWalletAdapter } from '@solana/wallet-adapter-tokenpocket' const tokenPocket = new TokenPocketWalletAdapter() -const TokenPocket: WalletAdapterInterface = { +const TokenPocket: WalletAdapterInterface = { id: 'tokenpocket', name: tokenPocket.name, icon: tokenPocket.icon, - provider: tokenPocket, + provider: tokenPocket as WalletProvider, platforms: [WalletPlatformEnum.MOBILE], downloadLink: 'https://www.tokenpocket.pro/en/download/app', createDeepLink(url: string): string { @@ -29,9 +29,9 @@ const TokenPocket: WalletAdapterInterface = { disconnect: async () => { await tokenPocket.disconnect() }, - connect: async (): Promise => { + connect: async (): Promise => { await tokenPocket.connect() - return tokenPocket as WalletAdapter + return tokenPocket as WalletProvider } } diff --git a/packages/networks/solana/src/browser/adapters/TrustWallet.ts b/packages/networks/solana/src/browser/adapters/TrustWallet.ts index 0dc4b89..737f40f 100644 --- a/packages/networks/solana/src/browser/adapters/TrustWallet.ts +++ b/packages/networks/solana/src/browser/adapters/TrustWallet.ts @@ -1,4 +1,4 @@ -import type { WalletAdapter } from '../Wallet.ts' +import type { WalletProvider } from '../Wallet.ts' import { WalletPlatformEnum } from '@multiplechain/types' import type { Provider } from '../../services/Provider.ts' import { WalletReadyState } from '@solana/wallet-adapter-base' @@ -10,11 +10,11 @@ const trustIcon = const trust = new TrustWalletAdapter() -const TrustWallet: WalletAdapterInterface = { +const TrustWallet: WalletAdapterInterface = { id: 'trustwallet', name: 'TrustWallet', icon: trustIcon, - provider: trust, + provider: trust as WalletProvider, platforms: [WalletPlatformEnum.BROWSER, WalletPlatformEnum.MOBILE], downloadLink: 'https://trustwallet.com/download', isDetected: () => trust.readyState === WalletReadyState.Installed, @@ -22,9 +22,9 @@ const TrustWallet: WalletAdapterInterface = { disconnect: async () => { await trust.disconnect() }, - connect: async (): Promise => { + connect: async (): Promise => { await trust.connect() - return trust as WalletAdapter + return trust as WalletProvider } } diff --git a/packages/networks/solana/src/browser/adapters/WalletConnect.ts b/packages/networks/solana/src/browser/adapters/WalletConnect.ts index 9546d84..455fb91 100644 --- a/packages/networks/solana/src/browser/adapters/WalletConnect.ts +++ b/packages/networks/solana/src/browser/adapters/WalletConnect.ts @@ -1,4 +1,4 @@ -import type { WalletAdapter } from '../Wallet.ts' +import type { WalletProvider } from '../Wallet.ts' import type { Provider } from '../../services/Provider.ts' import { WalletAdapterNetwork } from '@solana/wallet-adapter-base' import { ErrorTypeEnum, WalletPlatformEnum } from '@multiplechain/types' @@ -9,9 +9,9 @@ const icon = 'data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxLjEiIGJhc2VQcm9maWxlPSJiYXNpYyIgaWQ9IkxheWVyXzEiCgkgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeD0iMHB4IiB5PSIwcHgiIHZpZXdCb3g9IjAgMCAzODcuNiAyMzcuNiIKCSB4bWw6c3BhY2U9InByZXNlcnZlIj4KPHBhdGggaWQ9IldhbGxldENvbm5lY3RfMDAwMDAwNzM3MDMwNjM0MzgyMjA2NDI3MzAwMDAwMDI5MTc3MTc1NTIyMzY0NzI0OTZfIiBmaWxsPSIjM0I5OUZDIiBkPSJNNzkuNCw0Ni40CgljNjMuMi02MS45LDE2NS43LTYxLjksMjI4LjksMGw3LjYsNy40YzMuMiwzLjEsMy4yLDguMSwwLDExLjJsLTI2LDI1LjVjLTEuNiwxLjUtNC4xLDEuNS01LjcsMGwtMTAuNS0xMC4zCgljLTQ0LjEtNDMuMi0xMTUuNi00My4yLTE1OS43LDBsLTExLjIsMTFjLTEuNiwxLjUtNC4xLDEuNS01LjcsMEw3MSw2NS44Yy0zLjItMy4xLTMuMi04LjEsMC0xMS4yTDc5LjQsNDYuNHogTTM2Mi4xLDk5LjFsMjMuMiwyMi43CgljMy4yLDMuMSwzLjIsOC4xLDAsMTEuMkwyODAuOCwyMzUuM2MtMy4yLDMuMS04LjMsMy4xLTExLjQsMGMwLDAsMCwwLDAsMGwtNzQuMS03Mi42Yy0wLjgtMC44LTIuMS0wLjgtMi45LDBjMCwwLDAsMCwwLDAKCWwtNzQuMSw3Mi42Yy0zLjIsMy4xLTguMywzLjEtMTEuNCwwYzAsMCwwLDAsMCwwTDIuNCwxMzNjLTMuMi0zLjEtMy4yLTguMSwwLTExLjJsMjMuMi0yMi43YzMuMi0zLjEsOC4zLTMuMSwxMS40LDBsNzQuMSw3Mi42CgljMC44LDAuOCwyLjEsMC44LDIuOSwwYzAsMCwwLDAsMCwwbDc0LjEtNzIuNmMzLjItMy4xLDguMy0zLjEsMTEuNCwwYzAsMCwwLDAsMCwwbDc0LjEsNzIuNmMwLjgsMC44LDIuMSwwLjgsMi45LDBsNzQuMS03Mi42CglDMzUzLjgsOTYsMzU4LjksOTYsMzYyLjEsOTkuMXoiLz4KPC9zdmc+' let isConnected = false -let walletProvider: WalletConnectWalletAdapter | undefined +let walletProvider: WalletProvider | undefined -const WalletConnect: WalletAdapterInterface = { +const WalletConnect: WalletAdapterInterface = { icon, id: 'walletconnect', name: 'WalletConnect', @@ -30,7 +30,7 @@ const WalletConnect: WalletAdapterInterface = { localStorage.removeItem('WALLETCONNECT_DEEPLINK_CHOICE') indexedDB.deleteDatabase('WALLET_CONNECT_V2_INDEXED_DB') }, - connect: async (provider?: Provider, config?: ConnectConfig): Promise => { + connect: async (provider?: Provider, config?: ConnectConfig): Promise => { if (provider === undefined) { throw new Error(ErrorTypeEnum.PROVIDER_IS_REQUIRED) } diff --git a/packages/networks/solana/src/browser/adapters/Web3Modal.ts b/packages/networks/solana/src/browser/adapters/Web3Modal.ts index dab5ccc..1e5d205 100644 --- a/packages/networks/solana/src/browser/adapters/Web3Modal.ts +++ b/packages/networks/solana/src/browser/adapters/Web3Modal.ts @@ -1,9 +1,8 @@ import type { Metadata } from '@web3modal/core' -import type { WalletAdapter } from '../Wallet.ts' +import type { WalletProvider } from '../Wallet.ts' import type { Provider } from '../../services/Provider.ts' import { solana, solanaDevnet } from '@web3modal/solana/chains' import { ErrorTypeEnum, WalletPlatformEnum } from '@multiplechain/types' -import type { BaseMessageSignerWalletAdapter } from '@solana/wallet-adapter-base' import type { ProviderInterface, WalletAdapterInterface } from '@multiplechain/types' import { createWeb3Modal, @@ -20,11 +19,11 @@ export interface Web3ModalConfig extends Web3ModalOptions { } export interface Web3ModalAdapterInterface - extends Omit, 'connect'> { + extends Omit, 'connect'> { connect: ( provider?: ProviderInterface, config?: Web3ModalConfig | object - ) => Promise + ) => Promise } interface Chain { @@ -38,11 +37,9 @@ interface Chain { let modal: Web3ModalType let currentNetwork: Chain let clickedAnyWallet = false -let walletProvider: BaseMessageSignerWalletAdapter | undefined +let walletProvider: WalletProvider | undefined let connectRejectMethod: (reason?: any) => void -let connectResolveMethod: ( - value: BaseMessageSignerWalletAdapter | PromiseLike -) => void +let connectResolveMethod: (value: WalletProvider | PromiseLike) => void const web3Modal = (config: Web3ModalConfig): Web3ModalType => { if (modal !== undefined) { @@ -107,7 +104,7 @@ const web3Modal = (config: Web3ModalConfig): Web3ModalType => { } // @ts-expect-error this provider methods enought for our needs - connectResolveMethod((walletProvider = ctx.provider as BaseMessageSignerWalletAdapter)) + connectResolveMethod((walletProvider = ctx.provider as WalletProvider)) }) return modal @@ -150,7 +147,7 @@ const Web3Modal: Web3ModalAdapterInterface = { connect: async ( provider?: ProviderInterface, _config?: Web3ModalConfig | object - ): Promise => { + ): Promise => { const config = _config as Web3ModalConfig if (provider === undefined) { diff --git a/packages/networks/solana/src/browser/index.ts b/packages/networks/solana/src/browser/index.ts index 6439a63..8de2ab5 100644 --- a/packages/networks/solana/src/browser/index.ts +++ b/packages/networks/solana/src/browser/index.ts @@ -1,5 +1,5 @@ import type { Provider } from '../services/Provider.ts' -import { Wallet, type WalletAdapter } from './Wallet.ts' +import { Wallet, type WalletProvider } from './Wallet.ts' import * as adapterList from './adapters/index.ts' import type { WalletAdapterListType, @@ -7,10 +7,10 @@ import type { RegisterWalletAdapterType } from '@multiplechain/types' -const adapters: WalletAdapterListType = {} +const adapters: WalletAdapterListType = {} -const registerAdapter: RegisterWalletAdapterType = ( - adapter: WalletAdapterInterface +const registerAdapter: RegisterWalletAdapterType = ( + adapter: WalletAdapterInterface ): void => { if (Object.values(adapters).find((a) => a.id === adapter.id) !== undefined) { throw new Error(`Adapter with id ${adapter.id} already exists`) diff --git a/packages/networks/tron/package.json b/packages/networks/tron/package.json index f786a5c..9755b27 100644 --- a/packages/networks/tron/package.json +++ b/packages/networks/tron/package.json @@ -1,6 +1,6 @@ { "name": "@multiplechain/tron", - "version": "0.4.1", + "version": "0.4.2", "type": "module", "main": "dist/index.cjs", "module": "dist/index.es.js", @@ -74,7 +74,7 @@ "dependencies": { "@beycandeveloper/tron-tx-decoder": "^2.0.5", "@multiplechain/tron-walletconnect": "^0.1.0", - "@multiplechain/types": "^0.1.63", + "@multiplechain/types": "^0.1.64", "@multiplechain/utils": "^0.1.21", "@noble/secp256k1": "^1.7.1", "@tronweb3/tronwallet-adapter-bitkeep": "^1.1.1", diff --git a/packages/networks/tron/pnpm-lock.yaml b/packages/networks/tron/pnpm-lock.yaml index 0382b6f..49769e5 100644 --- a/packages/networks/tron/pnpm-lock.yaml +++ b/packages/networks/tron/pnpm-lock.yaml @@ -12,8 +12,8 @@ dependencies: specifier: ^0.1.0 version: 0.1.0(typescript@5.4.5) '@multiplechain/types': - specifier: ^0.1.63 - version: 0.1.63 + specifier: ^0.1.64 + version: 0.1.64 '@multiplechain/utils': specifier: ^0.1.21 version: 0.1.21 @@ -348,8 +348,8 @@ packages: - vite dev: false - /@multiplechain/types@0.1.63: - resolution: {integrity: sha512-4C201vUsN6F1S/M7vT+GZS0wTdKGZXHqn4YmC6ouC8n0uxMCEFdI2sSCadyHKFKG5OBPo16X1oFCX9MVwPqMoA==} + /@multiplechain/types@0.1.64: + resolution: {integrity: sha512-euzFLiq18L3SCqN9mLY2GKEkaJhTFcBg7Ono/yqN87IT5qlZ1Xqzk2jcWvRcnlN3O5wL15QLKS+e2C11DKeXOA==} dev: false /@multiplechain/utils@0.1.21: diff --git a/packages/networks/tron/src/browser/Wallet.ts b/packages/networks/tron/src/browser/Wallet.ts index f642975..bbd381d 100644 --- a/packages/networks/tron/src/browser/Wallet.ts +++ b/packages/networks/tron/src/browser/Wallet.ts @@ -13,7 +13,7 @@ import { Provider } from '../services/Provider.ts' import type { TransactionSigner } from '../services/TransactionSigner.ts' import type { Adapter, AdapterEvents } from '@tronweb3/tronwallet-abstract-adapter' -export interface CustomAdapter extends Adapter { +export interface WalletProvider extends Adapter { network?: () => Promise } @@ -49,16 +49,16 @@ const rejectMap = (error: any, reject: (a: any) => any): any => { return reject(error) } -type WalletAdapter = WalletAdapterInterface & { +type WalletAdapter = WalletAdapterInterface & { provider?: - | CustomAdapter + | WalletProvider | { on: (eventName: string, callback: (...args: any[]) => void) => void } } -export class Wallet implements WalletInterface { +export class Wallet implements WalletInterface { adapter: WalletAdapter - walletProvider: CustomAdapter + walletProvider: WalletProvider networkProvider: Provider diff --git a/packages/networks/tron/src/browser/adapters/BitgetWallet.ts b/packages/networks/tron/src/browser/adapters/BitgetWallet.ts index e600591..c8b97e6 100644 --- a/packages/networks/tron/src/browser/adapters/BitgetWallet.ts +++ b/packages/networks/tron/src/browser/adapters/BitgetWallet.ts @@ -1,4 +1,4 @@ -import type { CustomAdapter } from '../Wallet.ts' +import type { WalletProvider } from '../Wallet.ts' import { WalletPlatformEnum } from '@multiplechain/types' import type { Provider } from '../../services/Provider.ts' import type { WalletAdapterInterface } from '@multiplechain/types' @@ -14,7 +14,7 @@ declare global { } } -const BitgetWallet: WalletAdapterInterface = { +const BitgetWallet: WalletAdapterInterface = { id: 'bitgetwallet', name: 'BitgetWallet', icon: walletProvider.icon, @@ -26,7 +26,7 @@ const BitgetWallet: WalletAdapterInterface = { }, isDetected: () => Boolean(window.bitkeep?.tronLink), isConnected: () => Boolean(walletProvider.connected), - connect: async (): Promise => { + connect: async (): Promise => { return await new Promise((resolve, reject) => { try { walletProvider diff --git a/packages/networks/tron/src/browser/adapters/OkxWallet.ts b/packages/networks/tron/src/browser/adapters/OkxWallet.ts index 4c2aaff..4ba229d 100644 --- a/packages/networks/tron/src/browser/adapters/OkxWallet.ts +++ b/packages/networks/tron/src/browser/adapters/OkxWallet.ts @@ -1,4 +1,4 @@ -import type { CustomAdapter } from '../Wallet.ts' +import type { WalletProvider } from '../Wallet.ts' import { WalletPlatformEnum } from '@multiplechain/types' import type { Provider } from '../../services/Provider.ts' import type { WalletAdapterInterface } from '@multiplechain/types' @@ -6,7 +6,7 @@ import { OkxWalletAdapter } from '@tronweb3/tronwallet-adapter-okxwallet' const walletProvider = new OkxWalletAdapter() -const OkxWallet: WalletAdapterInterface = { +const OkxWallet: WalletAdapterInterface = { id: 'okxwallet', name: 'OkxWallet', icon: walletProvider.icon, @@ -18,13 +18,13 @@ const OkxWallet: WalletAdapterInterface = { }, isDetected: () => Boolean(window.okxwallet?.tronLink), isConnected: () => Boolean(walletProvider.connected), - connect: async (): Promise => { + connect: async (): Promise => { return await new Promise((resolve, reject) => { try { walletProvider .connect() .then(async () => { - resolve(walletProvider as CustomAdapter) + resolve(walletProvider) }) .catch((error) => { reject(error) diff --git a/packages/networks/tron/src/browser/adapters/TokenPocket.ts b/packages/networks/tron/src/browser/adapters/TokenPocket.ts index 9e4ee19..ce2099f 100644 --- a/packages/networks/tron/src/browser/adapters/TokenPocket.ts +++ b/packages/networks/tron/src/browser/adapters/TokenPocket.ts @@ -1,4 +1,4 @@ -import type { CustomAdapter } from '../Wallet.ts' +import type { WalletProvider } from '../Wallet.ts' import { WalletPlatformEnum } from '@multiplechain/types' import type { Provider } from '../../services/Provider.ts' import type { WalletAdapterInterface } from '@multiplechain/types' @@ -14,7 +14,7 @@ declare global { } } -const TokenPocket: WalletAdapterInterface = { +const TokenPocket: WalletAdapterInterface = { id: 'tokenpocket', name: 'TokenPocket', icon: walletProvider.icon, @@ -33,13 +33,13 @@ const TokenPocket: WalletAdapterInterface = { }, isDetected: () => Boolean(window.tokenpocket?.tron), isConnected: () => Boolean(walletProvider.connected), - connect: async (): Promise => { + connect: async (): Promise => { return await new Promise((resolve, reject) => { try { walletProvider .connect() .then(async () => { - resolve(walletProvider as CustomAdapter) + resolve(walletProvider) }) .catch((error) => { reject(error) diff --git a/packages/networks/tron/src/browser/adapters/TronLink.ts b/packages/networks/tron/src/browser/adapters/TronLink.ts index e81a8f1..fda6ef0 100644 --- a/packages/networks/tron/src/browser/adapters/TronLink.ts +++ b/packages/networks/tron/src/browser/adapters/TronLink.ts @@ -1,5 +1,5 @@ import { sleep } from '@multiplechain/utils' -import type { CustomAdapter } from '../Wallet.ts' +import type { WalletProvider } from '../Wallet.ts' import type { Provider } from '../../services/Provider.ts' import type { WalletAdapterInterface } from '@multiplechain/types' import { TronLinkAdapter } from '@tronweb3/tronwallet-adapter-tronlink' @@ -7,7 +7,7 @@ import { ErrorTypeEnum, WalletPlatformEnum } from '@multiplechain/types' const walletProvider = new TronLinkAdapter() -const TronLink: WalletAdapterInterface = { +const TronLink: WalletAdapterInterface = { id: 'tronlink', name: 'TronLink', icon: walletProvider.icon, @@ -27,7 +27,7 @@ const TronLink: WalletAdapterInterface = { }, isDetected: () => Boolean(window.tronLink), isConnected: () => Boolean(walletProvider.connected), - connect: async (provider?: Provider): Promise => { + connect: async (provider?: Provider): Promise => { if (provider === undefined) { throw new Error(ErrorTypeEnum.PROVIDER_IS_REQUIRED) } diff --git a/packages/networks/tron/src/browser/adapters/WalletConnect.ts b/packages/networks/tron/src/browser/adapters/WalletConnect.ts index 4d0c0c4..23ed80b 100644 --- a/packages/networks/tron/src/browser/adapters/WalletConnect.ts +++ b/packages/networks/tron/src/browser/adapters/WalletConnect.ts @@ -1,4 +1,4 @@ -import type { CustomAdapter } from '../Wallet.ts' +import type { WalletProvider } from '../Wallet.ts' import type { Provider } from '../../services/Provider.ts' import { ErrorTypeEnum, WalletPlatformEnum } from '@multiplechain/types' import { WalletConnectAdapter } from '@multiplechain/tron-walletconnect' @@ -8,9 +8,9 @@ const icon = 'data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxLjEiIGJhc2VQcm9maWxlPSJiYXNpYyIgaWQ9IkxheWVyXzEiCgkgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeD0iMHB4IiB5PSIwcHgiIHZpZXdCb3g9IjAgMCAzODcuNiAyMzcuNiIKCSB4bWw6c3BhY2U9InByZXNlcnZlIj4KPHBhdGggaWQ9IldhbGxldENvbm5lY3RfMDAwMDAwNzM3MDMwNjM0MzgyMjA2NDI3MzAwMDAwMDI5MTc3MTc1NTIyMzY0NzI0OTZfIiBmaWxsPSIjM0I5OUZDIiBkPSJNNzkuNCw0Ni40CgljNjMuMi02MS45LDE2NS43LTYxLjksMjI4LjksMGw3LjYsNy40YzMuMiwzLjEsMy4yLDguMSwwLDExLjJsLTI2LDI1LjVjLTEuNiwxLjUtNC4xLDEuNS01LjcsMGwtMTAuNS0xMC4zCgljLTQ0LjEtNDMuMi0xMTUuNi00My4yLTE1OS43LDBsLTExLjIsMTFjLTEuNiwxLjUtNC4xLDEuNS01LjcsMEw3MSw2NS44Yy0zLjItMy4xLTMuMi04LjEsMC0xMS4yTDc5LjQsNDYuNHogTTM2Mi4xLDk5LjFsMjMuMiwyMi43CgljMy4yLDMuMSwzLjIsOC4xLDAsMTEuMkwyODAuOCwyMzUuM2MtMy4yLDMuMS04LjMsMy4xLTExLjQsMGMwLDAsMCwwLDAsMGwtNzQuMS03Mi42Yy0wLjgtMC44LTIuMS0wLjgtMi45LDBjMCwwLDAsMCwwLDAKCWwtNzQuMSw3Mi42Yy0zLjIsMy4xLTguMywzLjEtMTEuNCwwYzAsMCwwLDAsMCwwTDIuNCwxMzNjLTMuMi0zLjEtMy4yLTguMSwwLTExLjJsMjMuMi0yMi43YzMuMi0zLjEsOC4zLTMuMSwxMS40LDBsNzQuMSw3Mi42CgljMC44LDAuOCwyLjEsMC44LDIuOSwwYzAsMCwwLDAsMCwwbDc0LjEtNzIuNmMzLjItMy4xLDguMy0zLjEsMTEuNCwwYzAsMCwwLDAsMCwwbDc0LjEsNzIuNmMwLjgsMC44LDIuMSwwLjgsMi45LDBsNzQuMS03Mi42CglDMzUzLjgsOTYsMzU4LjksOTYsMzYyLjEsOTkuMXoiLz4KPC9zdmc+' let isConnected = false -let walletProvider: WalletConnectAdapter | undefined +let walletProvider: WalletProvider | undefined -const WalletConnect: WalletAdapterInterface = { +const WalletConnect: WalletAdapterInterface = { icon, id: 'walletconnect', name: 'WalletConnect', @@ -29,7 +29,7 @@ const WalletConnect: WalletAdapterInterface = { localStorage.removeItem('WALLETCONNECT_DEEPLINK_CHOICE') indexedDB.deleteDatabase('WALLET_CONNECT_V2_INDEXED_DB') }, - connect: async (provider?: Provider, config?: WalletConnectConfig): Promise => { + connect: async (provider?: Provider, config?: WalletConnectConfig): Promise => { return await new Promise((resolve, reject) => { if (provider === undefined) { throw new Error(ErrorTypeEnum.PROVIDER_IS_REQUIRED) @@ -63,8 +63,7 @@ const WalletConnect: WalletAdapterInterface = { .connect() .then(async () => { isConnected = true - walletProvider = walletConnect - resolve(walletConnect as CustomAdapter) + resolve((walletProvider = walletConnect)) }) .catch((error) => { reject(error) diff --git a/packages/networks/tron/src/browser/index.ts b/packages/networks/tron/src/browser/index.ts index 54b38fb..8de2ab5 100644 --- a/packages/networks/tron/src/browser/index.ts +++ b/packages/networks/tron/src/browser/index.ts @@ -1,5 +1,5 @@ import type { Provider } from '../services/Provider.ts' -import { Wallet, type CustomAdapter } from './Wallet.ts' +import { Wallet, type WalletProvider } from './Wallet.ts' import * as adapterList from './adapters/index.ts' import type { WalletAdapterListType, @@ -7,10 +7,10 @@ import type { RegisterWalletAdapterType } from '@multiplechain/types' -const adapters: WalletAdapterListType = {} +const adapters: WalletAdapterListType = {} -const registerAdapter: RegisterWalletAdapterType = ( - adapter: WalletAdapterInterface +const registerAdapter: RegisterWalletAdapterType = ( + adapter: WalletAdapterInterface ): void => { if (Object.values(adapters).find((a) => a.id === adapter.id) !== undefined) { throw new Error(`Adapter with id ${adapter.id} already exists`)