Skip to content

Commit 3107b40

Browse files
author
Victor Wiebe
committed
feat: add issuance allowed and transfer frozen
1 parent 3368366 commit 3107b40

File tree

2 files changed

+55
-1
lines changed

2 files changed

+55
-1
lines changed

src/entities/SecurityToken/Issuance/Issuance.ts

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { SubModule } from '../SubModule';
22
import { FreezeIssuance, IssueTokens } from '../../../procedures';
3-
import { IssuanceDataEntry } from '../../../types';
3+
import { ErrorCode, IssuanceDataEntry } from '../../../types';
44
import { Offerings } from './Offerings';
55
import { SecurityToken } from '../SecurityToken';
66
import { Context } from '../../../Context';
7+
import { PolymathError } from '../../../PolymathError';
78

89
export class Issuance extends SubModule {
910
public offerings: Offerings;
@@ -48,4 +49,29 @@ export class Issuance extends SubModule {
4849
const procedure = new FreezeIssuance({ ...args, symbol }, this.context);
4950
return procedure.prepare();
5051
};
52+
53+
/**
54+
* Retrieve whether the issuance of tokens is allowed or not
55+
* Can be modified with `freeze`
56+
*/
57+
public allowed = async (): Promise<Boolean> => {
58+
const {
59+
context: { contractWrappers },
60+
securityToken: { symbol },
61+
} = this;
62+
63+
let securityTokenInstance;
64+
65+
try {
66+
securityTokenInstance = await contractWrappers.tokenFactory.getSecurityTokenInstanceFromTicker(
67+
symbol
68+
);
69+
} catch (err) {
70+
throw new PolymathError({
71+
code: ErrorCode.ProcedureValidationError,
72+
message: `There is no Security Token with symbol ${symbol}`,
73+
});
74+
}
75+
return securityTokenInstance.isIssuable();
76+
};
5177
}

src/entities/SecurityToken/Transfers/Transfers.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { SubModule } from '../SubModule';
22
import { Restrictions } from './Restrictions';
33
import { SecurityToken } from '../SecurityToken';
44
import { Context } from '../../../Context';
5+
import { PolymathError } from '../../../PolymathError';
6+
import { ErrorCode } from '../../../types';
57

68
export class Transfers extends SubModule {
79
public restrictions: Restrictions;
@@ -11,4 +13,30 @@ export class Transfers extends SubModule {
1113

1214
this.restrictions = new Restrictions(securityToken, context);
1315
}
16+
17+
/**
18+
* Retrieve whether the transfer of tokens is frozen or not
19+
* Can be modified with `freeze`
20+
*/
21+
public frozen = async (): Promise<Boolean> => {
22+
const {
23+
context: { contractWrappers },
24+
securityToken,
25+
} = this;
26+
27+
const { symbol } = securityToken;
28+
let securityTokenInstance;
29+
30+
try {
31+
securityTokenInstance = await contractWrappers.tokenFactory.getSecurityTokenInstanceFromTicker(
32+
symbol
33+
);
34+
} catch (err) {
35+
throw new PolymathError({
36+
code: ErrorCode.ProcedureValidationError,
37+
message: `There is no Security Token with symbol ${symbol}`,
38+
});
39+
}
40+
return securityTokenInstance.transfersFrozen();
41+
};
1442
}

0 commit comments

Comments
 (0)