-
Notifications
You must be signed in to change notification settings - Fork 5
/
CountRestrictions.ts
50 lines (44 loc) · 1.5 KB
/
CountRestrictions.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
import { ModuleName } from '@polymathnetwork/contract-wrappers';
import { ErrorCode } from '../../../../types';
import { ModifyMaxHolderCount } from '../../../../procedures';
import { SubModule } from '../../SubModule';
import { PolymathError } from '../../../../PolymathError';
export class CountRestrictions extends SubModule {
/**
* Modify the maximum amount of shareholders allowed to hold the token at once
*
* @param maxHolderCount limit to the amount of concurrent shareholders
*/
public modifyMaxHolderCount = async (args: { maxHolderCount: number }) => {
const procedure = new ModifyMaxHolderCount(
{
symbol: this.securityToken.symbol,
...args,
},
this.context
);
return procedure.prepare();
};
/**
* Retrieve the maximum amonut of shareholders allowed to hold the token at once.
* Can be modified with `modifyMaxHolderCount`
*/
public getMaxHolderCount = async () => {
const {
context: { contractWrappers },
securityToken,
} = this;
const { symbol } = securityToken;
const countTransferManagerModule = (await contractWrappers.getAttachedModules(
{ moduleName: ModuleName.CountTransferManager, symbol },
{ unarchived: true }
))[0];
if (!countTransferManagerModule) {
throw new PolymathError({
code: ErrorCode.FeatureNotEnabled,
message: 'You must enable the ShareholderCountRestrictions Feature',
});
}
return countTransferManagerModule.maxHolderCount();
};
}