import { Methods } from '../communication/methods'; import { SafeInfo, ChainInfo, SendTransactionsResponse, EnvironmentInfo, AddressBookItem, SignMessageResponse, } from './sdk'; import { GatewayTransactionDetails, SafeBalances } from './gateway'; import { Permission } from './permissions'; export type RequestId = string; export type InterfaceMessageEvent = MessageEvent; export interface MethodToResponse { [Methods.sendTransactions]: SendTransactionsResponse; [Methods.rpcCall]: unknown; [Methods.getSafeInfo]: SafeInfo; [Methods.getChainInfo]: ChainInfo; [Methods.getTxBySafeTxHash]: GatewayTransactionDetails; [Methods.getSafeBalances]: SafeBalances[]; [Methods.signMessage]: SignMessageResponse; [Methods.signTypedMessage]: SignMessageResponse; [Methods.getEnvironmentInfo]: EnvironmentInfo; [Methods.getOffChainSignature]: string; [Methods.requestAddressBook]: AddressBookItem[]; [Methods.wallet_getPermissions]: Permission[]; [Methods.wallet_requestPermissions]: Permission[]; } export type SDKRequestData = { id: RequestId; params: P; env: { sdkVersion: string; }; method: M; }; export type SDKMessageEvent = MessageEvent; export type ErrorResponse = { id: RequestId; success: false; error: string; version?: string; }; export type SuccessResponse = { id: RequestId; data: T; version?: string; success: true; }; export type Response = ErrorResponse | SuccessResponse; export interface Communicator { send(method: M, params: P): Promise>; }