Skip to content

Commit ddfef56

Browse files
authored
Merge branch 'beta' into docs/set-dividends-wallet-procedure
2 parents c425565 + 275c597 commit ddfef56

20 files changed

+413
-184
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@polymathnetwork/sdk",
3-
"version": "2.0.1-beta.98",
3+
"version": "2.0.1-beta.103",
44
"description": "A Javascript SDK for interacting with the Polymath network for the browser and Node.js",
55
"bugs": {
66
"url": "https://github.com/PolymathNetwork/polymath-sdk/issues"

src/PolymathBase.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import { range, flatten } from 'lodash';
3737
import P from 'bluebird';
3838
import semver from 'semver';
3939
import { PolymathError } from './PolymathError';
40-
import { ErrorCode, SecurityTokenRole } from './types';
40+
import { ErrorCode, SecurityTokenRole, ShareholderBalance } from './types';
4141
import { ZERO_ADDRESS } from './utils/constants';
4242

4343
interface GetModuleAddressesByNameParams {
@@ -160,11 +160,6 @@ interface GetModuleFactoryAddressArgs {
160160
tokenAddress: string;
161161
}
162162

163-
export interface ShareholderBalance {
164-
balance: BigNumber;
165-
address: string;
166-
}
167-
168163
export interface BaseCheckpoint {
169164
index: number;
170165
totalSupply: BigNumber;

src/entities/Checkpoint.ts

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,68 @@ import { DividendDistribution } from './DividendDistribution';
55
import { ShareholderBalance, ErrorCode } from '../types';
66
import { PolymathError } from '../PolymathError';
77

8+
/**
9+
* Properties that uniquely identify a Checkpoint
10+
*/
811
export interface UniqueIdentifiers {
12+
/**
13+
* security token UUID
14+
*/
915
securityTokenId: string;
16+
/**
17+
* numerical index of the checkpoint. The higher the index, the more recent the checkpoint
18+
*/
1019
index: number;
1120
}
1221

22+
/**
23+
* Check if the provided value is of type [[UniqueIdentifiers]]
24+
*/
1325
function isUniqueIdentifiers(identifiers: any): identifiers is UniqueIdentifiers {
1426
const { securityTokenSymbol, index } = identifiers;
1527

1628
return typeof securityTokenSymbol === 'string' && typeof index === 'number';
1729
}
1830

31+
/**
32+
* Checkpoint constructor parameters
33+
*/
1934
export interface Params {
35+
/**
36+
* dividend distributions associated to this checkpoint
37+
*/
2038
dividendDistributions: DividendDistribution[];
39+
/**
40+
* symbol of the security token
41+
*/
2142
securityTokenSymbol: string;
43+
/**
44+
* shareholder balances at this specific Checkpoint
45+
*/
2246
shareholderBalances: ShareholderBalance[];
2347
totalSupply: BigNumber;
2448
createdAt: Date;
2549
}
2650

51+
/**
52+
* Represents a snapshot of the Security Token's supply and Shareholder balances at a certain point in time
53+
*/
2754
export class Checkpoint extends Entity<Params> {
55+
/**
56+
* Generate the Checkpoint's UUID from its identifying properties
57+
*/
2858
public static generateId({ securityTokenId, index }: UniqueIdentifiers) {
2959
return serialize('checkpoint', {
3060
securityTokenId,
3161
index,
3262
});
3363
}
3464

65+
/**
66+
* Unserialize string to Checkpoint object
67+
*
68+
* @param serialize - checkpoint serialized representation
69+
*/
3570
public static unserialize(serialized: string) {
3671
const unserialized = unserialize(serialized);
3772

@@ -47,20 +82,32 @@ export class Checkpoint extends Entity<Params> {
4782

4883
public uid: string;
4984

85+
/**
86+
* dividend distributions associated to this snapshot
87+
*/
5088
public dividendDistributions: DividendDistribution[];
5189

5290
public securityTokenSymbol: string;
5391

5492
public securityTokenId: string;
5593

94+
/**
95+
* numerical index of the checkpoint associated to this snapshot
96+
*/
5697
public index: number;
5798

99+
/**
100+
* shareholder balances at this specific checkpoint
101+
*/
58102
public shareholderBalances: ShareholderBalance[];
59103

60104
public totalSupply: BigNumber;
61105

62106
public createdAt: Date;
63107

108+
/**
109+
* Create a new Chekpoint instance
110+
*/
64111
constructor(params: Params & UniqueIdentifiers) {
65112
super();
66113

@@ -84,6 +131,9 @@ export class Checkpoint extends Entity<Params> {
84131
this.uid = Checkpoint.generateId({ securityTokenId, index });
85132
}
86133

134+
/**
135+
* Convert entity to a POJO (Plain Old Javascript Object)
136+
*/
87137
public toPojo() {
88138
const {
89139
uid,
@@ -108,6 +158,9 @@ export class Checkpoint extends Entity<Params> {
108158
};
109159
}
110160

161+
/**
162+
* Hydrate the entity
163+
*/
111164
public _refresh(params: Partial<Params>) {
112165
const {
113166
dividendDistributions,

src/entities/DividendDistribution.ts

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,23 @@ import { PushDividendPayment, WithdrawTaxes, PullDividendPayment } from '../proc
66
import { Context } from '../Context';
77
import { PolymathError } from '../PolymathError';
88

9+
/**
10+
* Properties that uniquely identify a Dividend Distribution
11+
*/
912
export interface UniqueIdentifiers {
13+
/**
14+
* security token UUID
15+
*/
1016
securityTokenId: string;
17+
/**
18+
* ordered index of the distribution
19+
*/
1120
index: number;
1221
}
1322

23+
/**
24+
* Check if the provided value is of type [[UniqueIdentifiers]]
25+
*/
1426
function isUniqueIdentifiers(identifiers: any): identifiers is UniqueIdentifiers {
1527
const { securityTokenId, checkpointId, index } = identifiers;
1628

@@ -21,31 +33,69 @@ function isUniqueIdentifiers(identifiers: any): identifiers is UniqueIdentifiers
2133
);
2234
}
2335

36+
/**
37+
* Dividend Distribution constructor parameters
38+
*/
2439
export interface Params {
2540
securityTokenSymbol: string;
2641
checkpointId: string;
42+
/**
43+
* date at which the dividend was created
44+
*/
2745
created: Date;
46+
/**
47+
* date after which dividend can be claimed
48+
*/
2849
maturity: Date;
50+
/**
51+
* date until which dividend can be claimed
52+
*/
2953
expiry: Date;
54+
/**
55+
* dividend amount
56+
*/
3057
amount: BigNumber;
58+
/**
59+
* amount of dividend claimed so far
60+
*/
3161
claimedAmount: BigNumber;
62+
/**
63+
* total supply at the associated checkpoint
64+
*/
3265
totalSupply: BigNumber;
66+
/**
67+
* true if expiry has passed and issuer has reclaimed remaining dividend
68+
*/
3369
reclaimed: boolean;
3470
totalWithheld: BigNumber;
3571
totalWithheldWithdrawn: BigNumber;
3672
shareholders: DividendShareholderStatus[];
3773
name: string;
74+
/**
75+
* symbol of the currency in which this dividend distribution is being paid
76+
*/
3877
currency: string | null;
3978
}
4079

80+
/**
81+
* Class used to manage the dividend distribution functionality
82+
*/
4183
export class DividendDistribution extends Entity<Params> {
84+
/**
85+
* Generate the Dividend Distribution's UUID from its identifying properties
86+
*/
4287
public static generateId({ securityTokenId, index }: UniqueIdentifiers) {
4388
return serialize('dividend', {
4489
securityTokenId,
4590
index,
4691
});
4792
}
4893

94+
/**
95+
* Unserialize string to a Dividend Distribution object representation
96+
*
97+
* @param serialize - Dividend Distribution's serialized representation
98+
*/
4999
public static unserialize(serialized: string) {
50100
const unserialized = unserialize(serialized);
51101

@@ -95,6 +145,9 @@ export class DividendDistribution extends Entity<Params> {
95145

96146
protected context: Context;
97147

148+
/**
149+
* Create a new Dividend Distribution instance
150+
*/
98151
constructor(params: Params & UniqueIdentifiers, context: Context) {
99152
super();
100153

@@ -186,6 +239,9 @@ export class DividendDistribution extends Entity<Params> {
186239
return procedure.prepare();
187240
};
188241

242+
/**
243+
* Convert entity to POJO (Plain Old Javascript Object)
244+
*/
189245
public toPojo() {
190246
const {
191247
uid,
@@ -228,6 +284,9 @@ export class DividendDistribution extends Entity<Params> {
228284
};
229285
}
230286

287+
/**
288+
* Hydrate the Dividend Distribution entity
289+
*/
231290
public _refresh(params: Partial<Params>) {
232291
const {
233292
securityTokenSymbol,

src/entities/SecurityToken/Controller.ts

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,14 @@ import {
88
SignDisableControllerAck,
99
} from '../../procedures';
1010

11+
/**
12+
* Namespace that handles all Controller related functionality
13+
*/
1114
export class Controller extends SubModule {
1215
/**
1316
* Set the address of the Security Token's Controller. The controller may perform forced transfers
17+
*
18+
* @param args.controller - security token's controller address
1419
*/
1520
public modifyController = async (args: { controller: string }) => {
1621
const { controller } = args;
@@ -23,7 +28,7 @@ export class Controller extends SubModule {
2328
/**
2429
* Permanently disable controller functionality
2530
*
26-
* @param signature optional signed data. If not passed, signing will be requested when the transaction queue is run. The data can be generated beforehand by the token owner calling `signDisableAck`
31+
* @param args.signature - optional signed data. If not passed, signing will be requested when the transaction queue is run. The data can be generated beforehand by the token owner calling `signDisableAck`
2732
*/
2833
public disable = async (args?: { signature?: string }) => {
2934
const { symbol } = this.securityToken;
@@ -35,11 +40,11 @@ export class Controller extends SubModule {
3540
* Perform a forced transfer of tokens from one address to another. You must be the
3641
* Security Token's controller to do this
3742
*
38-
* @param amount amount of tokens to be transferred
39-
* @param from address from which to transfer tokens
40-
* @param to address that will receive the tokens
41-
* @param reason optional message to describe why the transfer occurred
42-
* @param data optional data used to validate the transfer
43+
* @param args.amount - amount of tokens to be transferred
44+
* @param args.from - address from which to transfer tokens
45+
* @param args.to - address that will receive the tokens
46+
* @param args.reason - optional message to describe why the transfer occurred
47+
* @param args.data - optional data used to validate the transfer
4348
*/
4449
public transfer = async (args: {
4550
amount: BigNumber;
@@ -64,10 +69,10 @@ export class Controller extends SubModule {
6469
* This operation is subject to transfer restrictions and the amount is limited by the token holder's balance.
6570
* `balanceOf(tokenHolder)` tokens) and potentially also need to respect other transfer restrictions.
6671
*
67-
* @param amount of tokens to be redeemed
68-
* @param address of the token holder
69-
* @param reason optional message to describe why the redemption occurred
70-
* @param data optional data used to validate the transfer
72+
* @param args.amount - amount of tokens to be redeemed
73+
* @param args.address - address of the token holder
74+
* @param args.reason - optional message to describe why the redemption occurred
75+
* @param args.data - optional data used to validate the transfer
7176
*/
7277
public redeem = async (args: {
7378
amount: BigNumber;
@@ -85,7 +90,7 @@ export class Controller extends SubModule {
8590
/**
8691
* Generate a signature string that can be used to permanently disable the Security Token's controller functionality
8792
*
88-
* Note that only the owner's signature is valid for this operation
93+
* **Note that only the owner's signature is valid for this operation**
8994
*/
9095
public signDisableAck = async () => {
9196
const { symbol } = this.securityToken;

0 commit comments

Comments
 (0)