generated from PolymeshAssociation/typescript-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 11
/
types.ts
133 lines (118 loc) · 3.12 KB
/
types.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
import BigNumber from 'bignumber.js';
import {
DefaultPortfolio,
FungibleAsset,
Identity,
Instruction,
Nft,
NumberedPortfolio,
Venue,
} from '~/internal';
import { EventIdentifier, NftCollection } from '~/types';
export enum InstructionStatus {
Pending = 'Pending',
Failed = 'Failed',
Success = 'Success',
Rejected = 'Rejected',
}
export enum InstructionType {
SettleOnAffirmation = 'SettleOnAffirmation',
SettleOnBlock = 'SettleOnBlock',
SettleManual = 'SettleManual',
}
export type InstructionEndCondition =
| {
type: InstructionType.SettleOnAffirmation;
}
| {
type: InstructionType.SettleOnBlock;
endBlock: BigNumber;
}
| {
type: InstructionType.SettleManual;
endAfterBlock: BigNumber;
};
export type InstructionDetails = {
status: InstructionStatus;
createdAt: Date;
/**
* Date at which the trade was agreed upon (optional, for offchain trades)
*/
tradeDate: Date | null;
/**
* Date at which the trade was executed (optional, for offchain trades)
*/
valueDate: Date | null;
venue: Venue;
memo: string | null;
} & InstructionEndCondition;
export interface FungibleLeg {
from: DefaultPortfolio | NumberedPortfolio;
to: DefaultPortfolio | NumberedPortfolio;
amount: BigNumber;
asset: FungibleAsset;
}
export interface NftLeg {
from: DefaultPortfolio | NumberedPortfolio;
to: DefaultPortfolio | NumberedPortfolio;
nfts: Nft[];
asset: NftCollection;
}
export type Leg = FungibleLeg | NftLeg;
export enum AffirmationStatus {
Unknown = 'Unknown',
Pending = 'Pending',
Affirmed = 'Affirmed',
}
export interface InstructionAffirmation {
identity: Identity;
status: AffirmationStatus;
}
export type InstructionStatusResult =
| {
status: InstructionStatus.Pending;
}
| {
status: Exclude<InstructionStatus, InstructionStatus.Pending>;
eventIdentifier: EventIdentifier;
};
export type MediatorAffirmation = {
identity: Identity;
status: AffirmationStatus;
/**
* Affirmations may have an expiration time
*/
expiry?: Date;
};
export interface GroupedInstructions {
/**
* Instructions that have already been affirmed by the Identity
*/
affirmed: Instruction[];
/**
* Instructions that still need to be affirmed/rejected by the Identity
*/
pending: Instruction[];
/**
* Instructions that failed in their execution (can be rescheduled).
* This group supersedes the other three, so for example, a failed Instruction
* might also belong in the `affirmed` group, but it will only be included in this one
*/
failed: Instruction[];
}
export type InstructionsByStatus = GroupedInstructions & {
/**
* Instructions that have one or more legs already affirmed, but still need to be one or more legs to be affirmed/rejected by the Identity
*/
partiallyAffirmed: Instruction[];
};
export interface GroupedInvolvedInstructions {
/**
* Instructions where the Identity is the custodian of the leg portfolios
*/
custodied: GroupedInstructions;
/**
* Instructions where the Identity is the owner of the leg portfolios
*/
owned: Omit<GroupedInstructions, 'affirmed'>;
}