import { IErrorResponseData, INotification, IEnvelope } from '@iamo/notification'; import { IEnrichedTransactionParameters, IExportableTransactionParameters, ISignature, ITransactionParameters } from './Transaction'; import { IConnection } from './Connection'; import { IDataStorage } from '@iamo/utils'; import { Matrix } from '@iamo/notification'; export { IErrorResponseData, INotification, IEnvelope }; /** * Notification Data types */ export declare type NotificationData = INewTransactionMessageData | ISignRequestMessageData | ISignedMessageData | ITransactionSentMessageData | IOwnerInvitationMessageData | IOwnerInvitationResponseMessageData | IResponseToExternalInviteMessageData | IUpdateTransactionData | IErrorResponseData | IImportWalletData | IChallengedData | IOwnerRemovedData | ISignRequestRejectedMessageData; export interface INewTransactionMessageData { txParameters: ITransactionParameters; name?: string; txHash: string; instanceAddress: string; sigs?: ISignature[]; ethereumTxHash?: string; timestamp: number; description: string; } export declare type ProxyData = any; export interface IPrivacyWalletData { multisigAddress: string; name: string; accountSeparationModuleAddress?: string; derivationParameters: { privacyWalletIndex: number; controllerInstance: string; }; deploymentParameters: { nonce: number; salt: string; }; } export interface IImportWalletData { timestamp: number; privacyWallets: IPrivacyWalletData[]; controllerWalletAddress: string; } export interface IChallengedData { timestamp: number; challenger: string; nextOwner: string; } export interface IOwnerRemovedData { timestamp: number; walletAddress: string; ethereumTransactionHash: string; } export interface IUpdateTransactionData { timestamp: number; data: any; } export interface ISignRequestMessageData { txParameters: IExportableTransactionParameters; description?: string; timestamp: number; } export interface ISignedMessageData { txParameters: IExportableTransactionParameters; timestamp: number; } export interface ITransactionSentMessageData { txHash: string; instanceAddress: string; ethereumTxHash?: string; timestamp: number; } export interface IOwnerInvitationMessageData { txParameters: ITransactionParameters; name?: string; txHash: string; instanceAddress: string; sigs?: ISignature[]; ethereumTxHash?: string; timestamp: number; description: string; } export interface IOwnerInvitationResponseMessageData { txParameters: ITransactionParameters; instanceAddress: string; agreed: boolean; txHash: string; timestamp: number; description?: string; } export interface IResponseToExternalInviteMessageData { address: string; instanceAddress: string; newAccountIdentityAddress: string; newAccountENSName: string; keyRights: string; } export interface IPrivacyWalletCreatedData { timestamp: number; privacyWallet: IPrivacyWalletData; } export interface ISendDerivedAddressesData { timestamp: number; addresses: string[]; } export interface ISignRequestRejectedMessageData { txParameters: IExportableTransactionParameters; reason: string; timestamp: number; } export declare enum NotificationTypes { NewTransaction = "NewTransaction", SignRequest = "SignRequest", Signed = "Signed", TransactionSent = "TransactionSent", OwnerInvitation = "OwnerInvitation", OwnerInvitationResponse = "OwnerInvitationResponse", Error = "Error", ResponseToExternalInvite = "ResponseToExternalInvite", UpdateTransaction = "UpdateTransaction", ImportWallet = "ImportWallet", PrivacyWalletCreated = "PrivacyWalletCreated", SendDerivedAddresses = "SendDerivedAddresses", Challenged = "Challenged", OwnerRemoved = "OwnerRemoved", SignRequestRejected = "SignRequestRejected" } /** * Notification-class of the wallet */ export declare class Notification { connection: IConnection; /** * initializes the class * @param connection The backend connection object. */ constructor(connection: IConnection); /** * Create NewTransaction notification message body * @param txParameters The transaction-parameters * @param description The description * @returns The new INewTransactionMessageData-object */ createNewTransactionMessageData(txParameters: IEnrichedTransactionParameters, description?: string): INewTransactionMessageData; /** * Creates the message data for the notification that informs an account that they * have been challenged. * @param challenger The account initiating the challenge * @param nextOwner The key that will replace the challenged key * @returns The new IChallengedData-object */ createChallengeMessageData(challenger: string, nextOwner: string): IChallengedData; /** * Creates the message data for the notification that informs the owner is removed * @param walletAddress The wallet address that sent owner removed from * @param ethereumTransactionHash The transaction hash that owner was removed * @returns The new IOwnerRemovedData-object */ createOwnerRemovedMessageData(walletAddress: string, ethereumTransactionHash: string): IOwnerRemovedData; /** * Create UpdateTransaction notification message body * @param data The data for updating the transaction * @returns The IUpdateTransactionData-object */ createUpdateTransactionMessageData(data: any): IUpdateTransactionData; /** * Creates and formats ISendDerivedAddressesData to add to * sendDerivedAddress notification * @param addresses The list of derived addresses * @returns The ISendDerivedAddressesData-object */ createDerivedAddressData(addresses: string[]): ISendDerivedAddressesData; /** * Creates and formats the IPrivacyWalletCreatedData * @param privacyWallet The new Privacy Wallet * @returns The IPrivacyWalletCreatedData-object */ createPrivacyWalletCreationData(privacyWallet: IPrivacyWalletData): IPrivacyWalletCreatedData; /** * Creates ImportWallet notification body * @param privacyWallets An object containing any privacy wallet addresses to import * @param controllerWalletAddress The controller wallet to import * @returns The IImportWalletData-object */ createImportWalletData(privacyWallets: IPrivacyWalletData[], controllerWalletAddress: string): IImportWalletData; /** * Create SignRequest notification message body * @param txParameters The transaction-parameters * @param description The description * @returns The ISignRequestMessageData-object */ createSignRequestMessageData(txParameters: IExportableTransactionParameters, description?: string): ISignRequestMessageData; /** * Create Signed notification message body * @param txParameters The transaction-parameters * @returns The ISignedMessageData-object */ createSignedMessageData(txParameters: IExportableTransactionParameters): ISignedMessageData; /** * Create SignRequestRejected notification message body * @param txParameters The transaction-parameters * @param reason The reason * @returns The ISignRequestRejectedMessageData-object */ createSignRequestRejectedData(txParameters: IExportableTransactionParameters, reason: string): ISignRequestRejectedMessageData; /** * Create Sent notification message body * @param txParameters The transaction-parameters * @returns The ITransactionSentMessageData-object */ createTransactionSentMessageData(txParameters: IEnrichedTransactionParameters): ITransactionSentMessageData; /** * Creates external invite reponse data * @param address The new address to add * @param instanceAddress The address of the multisig * @param newAccountIdentityAddress The new owners identity address * @param newAccountENSName The new accounts ens name * @param keyRights The rights of the key * @returns The IResponseToExternalInviteMessageData-object */ createExternalInviteResponseData(address: string, instanceAddress: string, newAccountIdentityAddress: string, newAccountENSName: string, keyRights: string): IResponseToExternalInviteMessageData; /** * Create OwnerInvitation notification message body * @param txParameters The transaction-parameters * @param description The description * @returns The IOwnerInvitationMessageData-object */ createOwnerInvitationMessageData(txParameters: IEnrichedTransactionParameters, description: string): IOwnerInvitationMessageData; /** * Create OwnerInvitationResponse notification message body * @param invitationMessage The owner invitation message to answer * @param agreed The response of the invitation * @param description The description * @returns The IOwnerInvitationResponseMessageData-object */ createOwnerInvitationResponseMessageData(invitationMessage: IOwnerInvitationMessageData, agreed: boolean, description?: string): IOwnerInvitationResponseMessageData; /** * Create Error notification message body * @param txHash The transaction-hash * @param description The description * @returns The IErrorResponseData */ createErrorMessageData(txHash: string, description: string): IErrorResponseData; /** * Send a message to other user. * @param envelope The message data * @param txnId The identifier of the message * @param accessTokenRecovery The function to be called when sync failed */ sendNotification(envelope: IEnvelope, txnId: string, accessTokenRecovery: (error: Error) => Promise): Promise; /** * Retrieve all message history * @param address The target address. if it's not given, the defaultAccountAddress will be used. * @returns The array with INotification */ retrieveAllNotifications(address?: string): Promise; /** * Check if matrixId is address's matrix id. * @param matrixId The matrix id (@{address}:{serverURL}) * @param address The address * @returns true if the address is a matrix user */ isMatrixUser(matrixId: string, address: string): boolean; /** * Converts a matrixID to an address * @param matrixId The matrix id (@{address}:{serverURL}) * @returns The address */ toAddress(matrixId: string): string; /** * Replaces the data storage * @param newStorage The new arbitrarily storage */ setStorage(newStorage: IDataStorage): void; /** * Get the access token for matrix. * @param address The user address (0x....) * @param password The password * @returns The IMatrixRequest-object */ getMatrixAccessToken(address: string, password: string): Promise; /** * Checks if the owner already exists. * @param address The user address (0x....) * @returns true of the matrix user exists */ checkMatrixUserExist(address: string): Promise; /** * Creates the message data * @param to Where to send to * @param type The message type * @param txnHash The transaction-hash * @param data The data-body * @returns The IEnvelope-object */ createEnvelope(to: string, type: NotificationTypes, txnHash: string, data: any): IEnvelope; } export default Notification;