generated from PolymeshAssociation/typescript-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 11
/
NumberedPortfolio.ts
52 lines (43 loc) · 1.13 KB
/
NumberedPortfolio.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
import BigNumber from 'bignumber.js';
import { Portfolio } from '~/api/entities';
import { deletePortfolio } from '~/api/procedures';
import { Context, TransactionQueue } from '~/base';
export interface UniqueIdentifiers {
did: string;
id: BigNumber;
}
/**
* Represents a numbered (non-default) Portfolio for an Identity
*/
export class NumberedPortfolio extends Portfolio {
/**
* @hidden
* Check if a value is of type [[UniqueIdentifiers]]
*/
public static isUniqueIdentifiers(identifier: unknown): identifier is UniqueIdentifiers {
const { did, id } = identifier as UniqueIdentifiers;
return typeof did === 'string' && id instanceof BigNumber;
}
/**
* portfolio identifier number
*/
public id: BigNumber;
/**
* @hidden
*/
public constructor(identifiers: UniqueIdentifiers, context: Context) {
super(identifiers, context);
const { id } = identifiers;
this.id = id;
}
/**
* Delete portfolio
*/
public async delete(): Promise<TransactionQueue<void>> {
const {
id,
owner: { did },
} = this;
return deletePortfolio.prepare({ did, id }, this.context);
}
}