type ConnectEventSuccess = {
  event: "connect";
  id: number; // increasing event counter
  payload: {
    items: ConnectItemReply[];
    device: DeviceInfo;
  };
};
type DeviceInfo = {
  platform: "iphone" | "ipad" | "android" | "windows" | "mac" | "linux";
  appName: string; // e.g. "Tonkeeper"
  appVersion: string; // e.g. "2.3.367"
  maxProtocolVersion: number;
  features: Feature[]; // list of supported features and methods in RPC
  // Currently there is only one feature -- 'SendTransaction';
};
type Feature = { name: "SendTransaction"; maxMessages: number }; // maxMessages is maximum number of messages in one SendTransaction that the wallet support
type ConnectItemReply = TonAddressItemReply | TonProofItemReply;
// Untrusted data returned by the wallet.
// If you need a guarantee that the user owns this address and public key, you need to additionally request a ton_proof.
type TonAddressItemReply = {
  name: "ton_addr";
  address: string; // TON address raw (0:<hex>)
  network: NETWORK; // network global_id
  publicKey: string; // HEX string without 0x
  walletStateInit: string; // Base64 (not url safe) encoded stateinit cell for the wallet contract
};
type TonProofItemReply = TonProofItemReplySuccess | TonProofItemReplyError;
type TonProofItemReplySuccess = {
  name: "ton_proof";
  proof: {
    timestamp: number; // 64-bit unix epoch time of the signing operation (seconds)
    domain: {
      lengthBytes: number; // AppDomain Length
      value: string; // app domain name (as url part, without encoding)
    };
    signature: string; // base64-encoded signature
    payload: string; // payload from the request
  };
};
type TonProofItemReplyError = {
  name: "ton_addr";
  error: {
    code: ConnectItemErrorCode;
    message?: string;
  };
};