UNPKG

@yoroi/types

Version:

The Yoroi Types package of Yoroi SDK

91 lines (86 loc) 3.03 kB
/** * Flowtype definitions for manager * Generated by Flowgen from a Typescript Definition * Flowgen v1.21.0 */ import { BehaviorSubject,Subject } from 'rxjs'; import { AppStorage } from '../app/storage'; declare export var NotificationTrigger: {| +TransactionReceived: "TransactionReceived",// "TransactionReceived" +RewardsUpdated: "RewardsUpdated",// "RewardsUpdated" +PrimaryTokenPriceChanged: "PrimaryTokenPriceChanged",// "PrimaryTokenPriceChanged" |}; export type NotificationManagerMakerProps = { eventsStorage: AppStorage<true, string>, configStorage: AppStorage<true, string>, subscriptions?: $Rest<{ [typeof NotificationTrigger$'TransactionReceived']: Subject<NotificationTransactionReceivedEvent>, [typeof NotificationTrigger$'RewardsUpdated']: Subject<NotificationRewardsUpdatedEvent>, [typeof NotificationTrigger$'PrimaryTokenPriceChanged']: Subject<NotificationPrimaryTokenPriceChangedEvent>,... }, {...}>, eventsLimit?: number,... };export type NotificationTransactionReceivedEvent = { trigger: typeof NotificationTrigger.'TransactionReceived', metadata: { walletId: string, previousTxsCounter: number, nextTxsCounter: number, txId: string, isSentByUser: boolean,... },... } & NotificationEventBase export type NotificationRewardsUpdatedEvent = { trigger: typeof NotificationTrigger.'RewardsUpdated', metadata: { walletId: string,... },... } & NotificationEventBase export type NotificationPrimaryTokenPriceChangedEvent = { trigger: typeof NotificationTrigger.'PrimaryTokenPriceChanged', metadata: { previousPrice: number, nextPrice: number,... },... } & NotificationEventBase export type NotificationGroup = "transaction-history" | "portfolio";export type NotificationEvent = NotificationTransactionReceivedEvent | NotificationPrimaryTokenPriceChangedEvent | NotificationRewardsUpdatedEvent;declare type NotificationEventId = number;declare interface NotificationEventBase { id: NotificationEventId, date: string, isRead: boolean, } export type NotificationConfig = { [typeof NotificationTrigger$'PrimaryTokenPriceChanged']: { notify: boolean, thresholdInPercent: number, interval: "24h" | "1h",... }, [typeof NotificationTrigger$'TransactionReceived']: { notify: boolean,... }, [typeof NotificationTrigger$'RewardsUpdated']: { notify: boolean,... },... };export type NotificationManager = { hydrate: () => void, unreadCounterByGroup$: BehaviorSubject<$ReadOnly<Map<NotificationGroup, number>>>, newEvents$: Subject<NotificationEvent>, events: { markAllAsRead: () => Promise<void>, markAsRead(id: NotificationEventId): Promise<void>, read: () => Promise<ReadonlyArray<NotificationEvent>>, push: (event: $ReadOnly<NotificationEvent>) => Promise<void>, clear: () => Promise<void>,... }, config: { read: () => Promise<$ReadOnly<NotificationConfig>>, save: (config: $ReadOnly<NotificationConfig>) => Promise<void>, reset: () => Promise<void>,... }, destroy: () => Promise<void>, clear: () => Promise<void>,... };