-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.ts
34 lines (30 loc) · 960 Bytes
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { BlockchainSourceType } from '../types/IBlockchainSourceSubject';
import type { IBlockchainSourceSubject, ISourceSubject } from '../types/IBlockchainSourceSubject';
export const shrinkSubject = (subject: IBlockchainSourceSubject): IBlockchainSourceSubject => {
if (subject.type === BlockchainSourceType.BROADCAST) {
return {
type: BlockchainSourceType.BROADCAST,
blockchain: subject.blockchain,
id: subject.id,
feedId: subject.feedId,
sender: null,
};
} else {
return {
type: BlockchainSourceType.DIRECT,
blockchain: subject.blockchain,
id: subject.id,
feedId: subject.feedId,
recipient: subject.recipient,
sender: null,
};
}
};
export const expandSubject = (subject: ISourceSubject, blockchain: string, id: string) => ({
...subject,
blockchain,
id,
});
export const isWideSubject = (subject: IBlockchainSourceSubject) => {
return subject.type === BlockchainSourceType.DIRECT && !!subject.sender;
};