import { Communicator } from '@coinbase/wallet-sdk/dist/core/communicator/Communicator'; import { ProviderEventEmitter, ProviderInterface, RequestArguments, } from './providers/base-provider'; // this class receive message via postMessage and send to prex-client export class WalletMessageCommunicator extends ProviderEventEmitter implements ProviderInterface { communicator: Communicator; constructor(url: string) { super(); this.communicator = new Communicator({ url, metadata: { appName: 'Prex', appLogoUrl: '', appChainIds: [] }, preference: { options: 'all' }, }); } public async request(args: RequestArguments): Promise { const id = crypto.randomUUID(); const response = await this.communicator.postRequestAndWaitForResponse({ id, data: args, }); return response.data; } async disconnect() { this.emit('disconnect'); } }