@yoroi/types
Version:
The Yoroi Types package of Yoroi SDK
125 lines (120 loc) • 3.96 kB
Flow
/**
* 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"
+Push: "Push",// "Push"
+Banner: "Banner",// "Banner"
|};
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>,
[typeof NotificationTrigger$'Push']: Subject<PushNotificationEvent>,
[typeof NotificationTrigger$'Banner']: Subject<BannerNotificationEvent>,...
}, {...}>,
eventsLimit?: number,...
};export type BannerNotificationEvent = {
trigger: typeof
NotificationTrigger.'Banner',
metadata: {
title: string,
body: string,
data?: {[key: string]: mixed, ...},...
},...
} & NotificationEventBase
export type PushNotificationEvent = {
trigger: typeof
NotificationTrigger.'Push',
metadata: {
title: string,
body: string,
data?: {[key: string]: mixed, ...},...
},...
} & NotificationEventBase
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" | "push";export type NotificationEvent = NotificationTransactionReceivedEvent
| NotificationPrimaryTokenPriceChangedEvent
| NotificationRewardsUpdatedEvent
| PushNotificationEvent
| BannerNotificationEvent;declare type NotificationEventId = number;declare interface NotificationEventBase {
id: NotificationEventId,
date: string,
isRead: boolean,
} export type NotificationConfig = {
displayDuration: number,
[typeof NotificationTrigger$'Push']: {
notify: boolean,...
},
[typeof NotificationTrigger$'PrimaryTokenPriceChanged']: {
notify: boolean,
thresholdInPercent: number,
interval: "24h" | "1h",...
},
[typeof NotificationTrigger$'TransactionReceived']: {
notify: boolean,...
},
[typeof NotificationTrigger$'RewardsUpdated']: {
notify: boolean,...
},
[typeof NotificationTrigger$'Banner']: {
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>,
remove(id: NotificationEventId): Promise<$ReadOnlyArray<NotificationEvent>>,
read: () => Promise<$ReadOnlyArray<NotificationEvent>>,
push: (event: $ReadOnly<NotificationEvent>) => Promise<void>,
clear: () => Promise<void>,...
},
config: {
read: () => Promise<$ReadOnly<NotificationConfig>>,
save: (config: $ReadOnly<$Rest<NotificationConfig, {...}>>) => Promise<void>,
reset: () => Promise<void>,...
},
destroy: () => Promise<void>,
clear: () => Promise<void>,...
};