@yoroi/types
Version:
The Yoroi Types package of Yoroi SDK
82 lines • 3.01 kB
TypeScript
import { BehaviorSubject, Subject } from 'rxjs';
import { AppStorage } from '../app/storage';
export declare enum NotificationTrigger {
'TransactionReceived' = "TransactionReceived",
'RewardsUpdated' = "RewardsUpdated",
'PrimaryTokenPriceChanged' = "PrimaryTokenPriceChanged"
}
export type NotificationManagerMakerProps = {
eventsStorage: AppStorage<true, string>;
configStorage: AppStorage<true, string>;
subscriptions?: Partial<{
[NotificationTrigger.TransactionReceived]: Subject<NotificationTransactionReceivedEvent>;
[NotificationTrigger.RewardsUpdated]: Subject<NotificationRewardsUpdatedEvent>;
[NotificationTrigger.PrimaryTokenPriceChanged]: Subject<NotificationPrimaryTokenPriceChangedEvent>;
}>;
eventsLimit?: number;
};
export interface NotificationTransactionReceivedEvent extends NotificationEventBase {
trigger: NotificationTrigger.TransactionReceived;
metadata: {
walletId: string;
previousTxsCounter: number;
nextTxsCounter: number;
txId: string;
isSentByUser: boolean;
};
}
export interface NotificationRewardsUpdatedEvent extends NotificationEventBase {
trigger: NotificationTrigger.RewardsUpdated;
metadata: {
walletId: string;
};
}
export interface NotificationPrimaryTokenPriceChangedEvent extends NotificationEventBase {
trigger: NotificationTrigger.PrimaryTokenPriceChanged;
metadata: {
previousPrice: number;
nextPrice: number;
};
}
export type NotificationGroup = 'transaction-history' | 'portfolio';
export type NotificationEvent = NotificationTransactionReceivedEvent | NotificationPrimaryTokenPriceChangedEvent | NotificationRewardsUpdatedEvent;
type NotificationEventId = number;
interface NotificationEventBase {
id: NotificationEventId;
date: string;
isRead: boolean;
}
export type NotificationConfig = {
[NotificationTrigger.PrimaryTokenPriceChanged]: {
notify: boolean;
thresholdInPercent: number;
interval: '24h' | '1h';
};
[NotificationTrigger.TransactionReceived]: {
notify: boolean;
};
[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>;
};
export {};
//# sourceMappingURL=manager.d.ts.map