Skip to content

Commit 3a83a47

Browse files
authored
Merge branch 'beta' into docs/reserve-security-token-procedure
2 parents ee597eb + fdcd846 commit 3a83a47

38 files changed

+1868
-197
lines changed

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@polymathnetwork/sdk",
3-
"version": "2.0.1-beta.91",
3+
"version": "2.0.1-beta.97",
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"
@@ -25,7 +25,7 @@
2525
"semantic-release": "semantic-release",
2626
"coveralls": "jest --coverage && cat ./coverage/lcov.info | coveralls",
2727
"lint": "eslint src --ext .ts",
28-
"postinstall": "rm -rf ./node_modules/typedoc/node_modules/typescript"
28+
"postinstall": "rimraf ./node_modules/typedoc/node_modules/typescript"
2929
},
3030
"jest": {
3131
"moduleFileExtensions": [
@@ -107,6 +107,7 @@
107107
"prettier-eslint-cli": "^4.7.1",
108108
"reflect-metadata": "^0.1.12",
109109
"regenerator-runtime": "^0.13.1",
110+
"rimraf": "^3.0.0",
110111
"semantic-release": "^16.0.0-beta.18",
111112
"sinon": "^7.5.0",
112113
"ts-loader": "^5.3.3",

src/entities/Entity.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
/**
2+
* Represents an object or resource in the Polymath Ecosystem with its own set of properties and functionality
3+
*/
14
export abstract class Entity<Params> {
25
public abstract uid: string;
36

src/entities/Erc20TokenBalance.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ import { serialize, unserialize } from '../utils';
44
import { PolymathError } from '../PolymathError';
55
import { ErrorCode } from '../types';
66

7+
/**
8+
* Properties that uniquely identify an ERC20 token balance
9+
*/
710
export interface UniqueIdentifiers {
811
tokenAddress: string;
912
walletAddress: string;
@@ -15,11 +18,17 @@ function isUniqueIdentifiers(identifiers: any): identifiers is UniqueIdentifiers
1518
return typeof tokenAddress === 'string' && typeof walletAddress === 'string';
1619
}
1720

21+
/**
22+
* Constructor parameters
23+
*/
1824
export interface Params {
1925
tokenSymbol: string | null;
2026
balance: BigNumber;
2127
}
2228

29+
/**
30+
* Used to manage a ERC20 token balance
31+
*/
2332
export class Erc20TokenBalance extends Entity<Params> {
2433
public static generateId({ tokenAddress, walletAddress }: UniqueIdentifiers) {
2534
return serialize('erc20TokenBalance', {
@@ -28,6 +37,11 @@ export class Erc20TokenBalance extends Entity<Params> {
2837
});
2938
}
3039

40+
/**
41+
* Unserialize a serialized erc20 token balance
42+
*
43+
* @param serialized - string with erc20 token balance entity information
44+
*/
3145
public static unserialize(serialized: any) {
3246
const unserialized = unserialize(serialized);
3347

@@ -41,16 +55,31 @@ export class Erc20TokenBalance extends Entity<Params> {
4155
return unserialized;
4256
}
4357

58+
/**
59+
* unique generated identifier for an ERC20 token balance
60+
*/
4461
public uid: string;
4562

4663
public tokenSymbol: string | null;
4764

65+
/**
66+
* address of the ERC20 token
67+
*/
4868
public tokenAddress: string;
4969

70+
/**
71+
* wallet address of the token holder
72+
*/
5073
public walletAddress: string;
5174

75+
/**
76+
* total number of tokens belonging to token holder
77+
*/
5278
public balance: BigNumber;
5379

80+
/**
81+
* Create an ERC20 Token balance instance
82+
*/
5483
constructor(params: Params & UniqueIdentifiers) {
5584
super();
5685

@@ -66,6 +95,9 @@ export class Erc20TokenBalance extends Entity<Params> {
6695
});
6796
}
6897

98+
/**
99+
* Convert entity to a POJO (Plain Old Javascript Object)
100+
*/
69101
public toPojo() {
70102
const { uid, tokenSymbol, tokenAddress, balance, walletAddress } = this;
71103

@@ -78,6 +110,9 @@ export class Erc20TokenBalance extends Entity<Params> {
78110
};
79111
}
80112

113+
/**
114+
* Hydrate the entity
115+
*/
81116
public _refresh(params: Partial<Params>) {
82117
const { tokenSymbol, balance } = params;
83118

src/entities/Investment.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ import { serialize, unserialize } from '../utils';
44
import { PolymathError } from '../PolymathError';
55
import { ErrorCode } from '../types';
66

7+
/**
8+
* Properties that uniquely identify an Investment
9+
*/
710
export interface UniqueIdentifiers {
811
securityTokenId: string;
912
stoId: string;
@@ -18,13 +21,19 @@ function isUniqueIdentifiers(identifiers: any): identifiers is UniqueIdentifiers
1821
);
1922
}
2023

24+
/**
25+
* Constructor parameters
26+
*/
2127
export interface Params {
2228
securityTokenSymbol: string;
2329
address: string;
2430
tokenAmount: BigNumber;
2531
investedFunds: BigNumber;
2632
}
2733

34+
/**
35+
* Used to manage an Investment in a Security Token Offering
36+
*/
2837
export class Investment extends Entity<Params> {
2938
public static generateId({ securityTokenId, stoId, index }: UniqueIdentifiers) {
3039
return serialize('investment', {
@@ -34,6 +43,11 @@ export class Investment extends Entity<Params> {
3443
});
3544
}
3645

46+
/**
47+
* Unserialize a serialized Investment entity
48+
*
49+
* @param serialized - string with Investment entity information
50+
*/
3751
public static unserialize(serialized: string) {
3852
const unserialized = unserialize(serialized);
3953

@@ -47,22 +61,43 @@ export class Investment extends Entity<Params> {
4761
return unserialized;
4862
}
4963

64+
/**
65+
* unique generated identifier for an Investment
66+
*/
5067
public uid: string;
5168

5269
public securityTokenId: string;
5370

71+
/**
72+
* unique ID for the Investment
73+
*/
5474
public stoId: string;
5575

5676
public securityTokenSymbol: string;
5777

78+
/**
79+
* wallet address of token holder
80+
*/
5881
public address: string;
5982

83+
/**
84+
* index of the Investment
85+
*/
6086
public index: number;
6187

88+
/**
89+
* total amount of tokens involved in the Investment
90+
*/
6291
public tokenAmount: BigNumber;
6392

93+
/**
94+
* amount of funds used to make Investment
95+
*/
6496
public investedFunds: BigNumber;
6597

98+
/**
99+
* Create an Investment instance
100+
*/
66101
constructor(params: Params & UniqueIdentifiers) {
67102
super();
68103

@@ -90,6 +125,9 @@ export class Investment extends Entity<Params> {
90125
});
91126
}
92127

128+
/**
129+
* Convert entity to a POJO (Plain Old Javascript Object)
130+
*/
93131
public toPojo() {
94132
const {
95133
uid,
@@ -114,6 +152,9 @@ export class Investment extends Entity<Params> {
114152
};
115153
}
116154

155+
/**
156+
* Hydrate the entity
157+
*/
117158
public _refresh(params: Partial<Params>) {
118159
const { securityTokenSymbol, address, investedFunds, tokenAmount } = params;
119160

0 commit comments

Comments
 (0)