From f89697a4f38b513d9ece739b99841e7b5c4db384 Mon Sep 17 00:00:00 2001 From: Victor Wiebe Date: Thu, 2 Jan 2020 13:02:34 -0800 Subject: [PATCH 01/43] refactor: add 32 char max validation to sdk --- src/procedures/AssignStoRole.ts | 2 ++ src/procedures/ModifyTieredStoData.ts | 4 +++- src/procedures/SetDocument.ts | 16 +++------------- src/procedures/__tests__/AssignStoRole.ts | 16 ++++++++++++++++ src/procedures/__tests__/SetDocument.ts | 4 ++-- src/utils/index.ts | 18 ++++++++++++++++++ 6 files changed, 44 insertions(+), 16 deletions(-) diff --git a/src/procedures/AssignStoRole.ts b/src/procedures/AssignStoRole.ts index 03b50bf..b2a00e7 100644 --- a/src/procedures/AssignStoRole.ts +++ b/src/procedures/AssignStoRole.ts @@ -8,6 +8,7 @@ import { StoRole, } from '../types'; import { PolymathError } from '../PolymathError'; +import { isValidBytes32CompliantString } from '~/utils'; export class AssignStoRole extends Procedure { public type = ProcedureType.AssignStoRole; @@ -66,6 +67,7 @@ export class AssignStoRole extends Procedure { }); } } else { + isValidBytes32CompliantString(description, 'description'); // Delegate not found. Add them here await this.addTransaction(permissionModule.addDelegate, { tag: PolyTransactionTag.ChangePermission, diff --git a/src/procedures/ModifyTieredStoData.ts b/src/procedures/ModifyTieredStoData.ts index fd84833..6fdc892 100644 --- a/src/procedures/ModifyTieredStoData.ts +++ b/src/procedures/ModifyTieredStoData.ts @@ -16,7 +16,7 @@ import { StoTier, } from '../types'; import { PolymathError } from '../PolymathError'; -import { areSameAddress } from '../utils'; +import { areSameAddress, isValidBytes32CompliantString } from '../utils'; import { SecurityToken, TieredSto } from '../entities'; import { TieredStoFactory } from '../entities/factories'; @@ -228,6 +228,8 @@ export class ModifyTieredStoData extends Procedure { public type = ProcedureType.SetDocument; @@ -31,19 +32,8 @@ export class SetDocument extends Procedure { }); } - if (name.length < 1 || name.length > 32) { - throw new PolymathError({ - code: ErrorCode.ProcedureValidationError, - message: `You must provide a valid name between 1 and 32 characters long`, - }); - } - - if (documentHash.length < 1 || documentHash.length > 32) { - throw new PolymathError({ - code: ErrorCode.ProcedureValidationError, - message: `You must provide a valid document hash between between 1 and 32 characters long`, - }); - } + isNotEmptyValidBytes32CompliantString(name, 'name'); + isNotEmptyValidBytes32CompliantString(documentHash, 'document hash'); /* * Transactions diff --git a/src/procedures/__tests__/AssignStoRole.ts b/src/procedures/__tests__/AssignStoRole.ts index b12aaa3..3df8b52 100644 --- a/src/procedures/__tests__/AssignStoRole.ts +++ b/src/procedures/__tests__/AssignStoRole.ts @@ -90,6 +90,22 @@ describe('AssignStoRole', () => { expect(addTransactionSpy.callCount).toEqual(2); }); + test('should throw error if the description is over 32 characters long', async () => { + target = new AssignStoRole( + { ...params, description: '0123456789012345678901234567890123456789' }, + contextMock.getMockInstance() + ); + gpmMock.mock('getAllDelegates', Promise.resolve([])); + + // Real call rejects + await expect(target.prepareTransactions()).rejects.toThrowError( + new PolymathError({ + code: ErrorCode.ProcedureValidationError, + message: `You must provide a valid description up to 32 characters long`, + }) + ); + }); + test('should add change permission transaction to the queue and use an operator role as param', async () => { target = new AssignStoRole( { ...params, role: StoRole.StoOperator }, diff --git a/src/procedures/__tests__/SetDocument.ts b/src/procedures/__tests__/SetDocument.ts index 78ce21d..1f5420b 100644 --- a/src/procedures/__tests__/SetDocument.ts +++ b/src/procedures/__tests__/SetDocument.ts @@ -129,7 +129,7 @@ describe('SetDocument', () => { await expect(target.prepareTransactions()).rejects.toThrowError( new PolymathError({ code: ErrorCode.ProcedureValidationError, - message: `You must provide a valid document hash between between 1 and 32 characters long`, + message: `You must provide a valid document hash between 1 and 32 characters long`, }) ); }); @@ -148,7 +148,7 @@ describe('SetDocument', () => { await expect(target.prepareTransactions()).rejects.toThrowError( new PolymathError({ code: ErrorCode.ProcedureValidationError, - message: `You must provide a valid document hash between between 1 and 32 characters long`, + message: `You must provide a valid document hash between 1 and 32 characters long`, }) ); }); diff --git a/src/utils/index.ts b/src/utils/index.ts index 2f45e25..6965ca3 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -51,6 +51,24 @@ export function areSameAddress(a: string, b: string) { return a.toUpperCase() === b.toUpperCase(); } +export function isValidBytes32CompliantString(value: string, variableName: string) { + if (value.length > 32) { + throw new PolymathError({ + code: ErrorCode.ProcedureValidationError, + message: `You must provide a valid ${variableName} up to 32 characters long`, + }); + } +} + +export function isNotEmptyValidBytes32CompliantString(value: string, variableName: string) { + if (value.length < 1 || value.length > 32) { + throw new PolymathError({ + code: ErrorCode.ProcedureValidationError, + message: `You must provide a valid ${variableName} between 1 and 32 characters long`, + }); + } +} + export function serialize(entityType: string, pojo: Pojo) { return Buffer.from(`${entityType}:${stringify(pojo)}`).toString('base64'); } From b178216075062374046e3a15a141c62e3e3b3804 Mon Sep 17 00:00:00 2001 From: Victor Wiebe Date: Fri, 3 Jan 2020 13:23:27 -0800 Subject: [PATCH 02/43] docs: fix sto entity comments --- src/entities/Sto.ts | 92 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 78 insertions(+), 14 deletions(-) diff --git a/src/entities/Sto.ts b/src/entities/Sto.ts index 71e8912..580d267 100644 --- a/src/entities/Sto.ts +++ b/src/entities/Sto.ts @@ -12,35 +12,85 @@ import { ModifyPreIssuing, } from '../procedures'; +/** + * Represents a unique sto + */ export interface UniqueIdentifiers { securityTokenId: string; stoType: StoType; address: string; } +/** + * Check if the provided value is of type [[UniqueIdentifiers]] + * + * @param identifiers - internal security token representation + */ function isUniqueIdentifiers(identifiers: any): identifiers is UniqueIdentifiers { const { securityTokenId, stoType, address } = identifiers; return typeof securityTokenId === 'string' && typeof address === 'string' && isStoType(stoType); } +/** + * Represents an sto + */ export interface Params { + /** + * symbol of security token + */ securityTokenSymbol: string; + /** + * start date of the sto + */ startDate: Date; + /** + * expiry date of the sto + */ endDate: Date; + /** + * currencies that can be used to fundraise in this sto + */ fundraiseCurrencies: Currency[]; + /** + * wallet address where raised funds will be stored + */ raisedFundsWallet: string; + /** + * wallet address where unsold tokens will be returned to + */ unsoldTokensWallet: string; + /** + * amount of tokens to be raised + */ raisedAmount: BigNumber; + /** + * amount of tokens that have been sold + */ soldTokensAmount: BigNumber; + /** + * number of investors in the sto + */ investorCount: number; + /** + * whether or not the sto is currently paused + */ isPaused: boolean; + /** + * whether or not the cap has been reached for the sto + */ capReached: boolean; + /** + * whether or not the sto has been finalized + */ isFinalized: boolean; preIssueAllowed: boolean; beneficialInvestmentsAllowed: boolean; } +/** + * Abstract class used as a base to manage sto functionalities + */ export abstract class Sto

extends Entity

{ public abstract uid: string; @@ -80,6 +130,11 @@ export abstract class Sto

extends Entity

{ protected context: Context; + /** + * Unserialize string to a Security Token object representation + * + * @param serialize - security token's serialized representation + */ public static unserialize(serialized: string) { const unserialized = unserialize(serialized); @@ -93,6 +148,9 @@ export abstract class Sto

extends Entity

{ return unserialized; } + /** + * Create a new sto instance + */ constructor(params: Params & UniqueIdentifiers, context: Context) { super(); @@ -137,7 +195,7 @@ export abstract class Sto

extends Entity

{ } /** - * Pauses the offering + * Pause the offering */ public pause = async () => { const { address: stoAddress, stoType, securityTokenSymbol: symbol } = this; @@ -151,7 +209,7 @@ export abstract class Sto

extends Entity

{ }; /** - * Unpauses the offering + * Unpause the offering */ public unpause = async () => { const { address: stoAddress, stoType, securityTokenSymbol: symbol } = this; @@ -165,7 +223,7 @@ export abstract class Sto

extends Entity

{ }; /** - * Finalizes the offering. The offering's treasury wallet (or the Security Token's treasury wallet if one was not specified for the offering) + * Finalize the offering. The offering's treasury wallet (or the Security Token's treasury wallet if one was not specified for the offering) * will receive the remaining unsold tokens. Throws an error if there are transfer restrictions which do not permit the wallet to receive that amount of tokens */ public finalize = async () => { @@ -177,7 +235,7 @@ export abstract class Sto

extends Entity

{ }; /** - * Enables all offered tokens to be issued instantly at STO start (default behavior is to issue on purchase) + * Enable all offered tokens to be issued instantly at STO start (default behavior is to issue on purchase) * Can be disabled *BEFORE* the STO starts by calling disallowPreIssuing */ public allowPreIssuing = async () => { @@ -192,7 +250,7 @@ export abstract class Sto

extends Entity

{ }; /** - * Disables pre-issuing of offered tokens at STO start (goes back to default behavior, which is to issue on purchase) + * Disable pre-issuing of offered tokens at STO start (goes back to default behavior, which is to issue on purchase) * Can be re-enabled *BEFORE* the STO starts by calling allowPreIssuing */ public disallowPreIssuing = async () => { @@ -207,7 +265,7 @@ export abstract class Sto

extends Entity

{ }; /** - * Enables a party to invest in the STO on behalf of another party + * Enable a party to invest in the STO on behalf of another party */ public allowBeneficialInvestments = async () => { const { address: stoAddress, stoType, securityTokenSymbol: symbol } = this; @@ -221,7 +279,7 @@ export abstract class Sto

extends Entity

{ }; /** - * Disables the possibility for a party to invest in the STO on behalf of another party + * Disable the possibility for a party to invest in the STO on behalf of another party */ public disallowBeneficialInvestments = async () => { const { address: stoAddress, stoType, securityTokenSymbol: symbol } = this; @@ -235,11 +293,11 @@ export abstract class Sto

extends Entity

{ }; /** - * Assigns a role on the STO to a delegate + * Assign a role on the STO to a delegate * - * @param delegateAddress wallet address of the delegate - * @param role role to assign - * @param description description of the delegate (defaults to empty string, is ignored if the delegate already exists) + * @param args.delegateAddress - wallet address of the delegate + * @param args.role - role to assign + * @param args.description - description of the delegate (defaults to empty string, is ignored if the delegate already exists) */ public assignRole = async (args: { delegateAddress: string; @@ -262,10 +320,10 @@ export abstract class Sto

extends Entity

{ }; /** - * Removes a role from a delegate + * Remove a role from a delegate * - * @param delegateAddress wallet address of the delegate - * @param role role to revoke + * @param args.delegateAddress - wallet address of the delegate + * @param args.role - role to revoke */ public revokeRole = async (args: { delegateAddress: string; role: StoRole }) => { const { securityTokenSymbol: symbol, address } = this; @@ -283,6 +341,9 @@ export abstract class Sto

extends Entity

{ return procedure.prepare(); }; + /** + * Convert entity to a POJO (Plain Old Javascript Object) + */ public toPojo() { const { uid, @@ -325,6 +386,9 @@ export abstract class Sto

extends Entity

{ }; } + /** + * Hydrating the entity + */ public _refresh(params: Partial) { const { securityTokenSymbol, From c255e20217a2e38744d2ac17690c1a8b4ce057c1 Mon Sep 17 00:00:00 2001 From: Victor Wiebe Date: Mon, 6 Jan 2020 07:48:16 -0800 Subject: [PATCH 03/43] fix: changes caught by Fede --- src/entities/Sto.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/entities/Sto.ts b/src/entities/Sto.ts index 580d267..c3a6f27 100644 --- a/src/entities/Sto.ts +++ b/src/entities/Sto.ts @@ -84,7 +84,13 @@ export interface Params { * whether or not the sto has been finalized */ isFinalized: boolean; + /** + * whether or not pre issuance is allowed for the sto + */ preIssueAllowed: boolean; + /** + * whether or not investments can be made on behalf of a beneficiary in the sto + */ beneficialInvestmentsAllowed: boolean; } @@ -131,7 +137,7 @@ export abstract class Sto

extends Entity

{ protected context: Context; /** - * Unserialize string to a Security Token object representation + * Unserialize string to a Security Token Offering object representation * * @param serialize - security token's serialized representation */ From ec6b2deecb801e6672d047dd488601652a3d3050 Mon Sep 17 00:00:00 2001 From: Victor Wiebe Date: Mon, 6 Jan 2020 09:54:08 -0800 Subject: [PATCH 04/43] docs: more documentation for sto entities --- src/entities/SimpleSto.ts | 32 ++++++++++- src/entities/Sto.ts | 2 + src/entities/TieredSto.ts | 118 +++++++++++++++++++++++++++++++------- 3 files changed, 127 insertions(+), 25 deletions(-) diff --git a/src/entities/SimpleSto.ts b/src/entities/SimpleSto.ts index 6d12176..598b3e1 100644 --- a/src/entities/SimpleSto.ts +++ b/src/entities/SimpleSto.ts @@ -14,13 +14,28 @@ import { Investment } from './Investment'; const { weiToValue } = conversionUtils; +/** + * Represents a simple sto + */ export interface Params extends StoParams { + /** + * cap for how many tokens can be sold + */ cap: BigNumber; + /** + * rate at which tokens will be sold + */ rate: BigNumber; } +/** + * Represents a unique sto + */ export { UniqueIdentifiers }; +/** + * Class used to manage a simple sto + */ export class SimpleSto extends Sto { public static generateId({ securityTokenId, stoType, address }: UniqueIdentifiers) { return serialize('simpleSto', { @@ -36,6 +51,11 @@ export class SimpleSto extends Sto { public rate: BigNumber; + /** + * Create a new simple sto instance + * @param params parameters for an sto and unique identifiers + * @param context the sdk is being used in + */ constructor(params: Params & UniqueIdentifiers, context: Context) { const { cap, rate, ...rest } = params; @@ -91,10 +111,10 @@ export class SimpleSto extends Sto { } /** - * Invests in the STO + * Invest in the STO * - * @param amount amount to spend - * @param beneficiary address that will receive the purchased tokens (defaults to current wallet, will fail if beneficial investments are not allowed for the STO, only applicable if the STO currency is ETH) + * @param args.amount - amount to spend + * @param args.beneficiary - address that will receive the purchased tokens (defaults to current wallet, will fail if beneficial investments are not allowed for the STO, only applicable if the STO currency is ETH) */ public async invest(args: { amount: BigNumber; beneficiary?: string }) { const { address: stoAddress, securityTokenSymbol: symbol } = this; @@ -104,6 +124,9 @@ export class SimpleSto extends Sto { return procedure.prepare(); } + /** + * Convert entity to a POJO (Plain Old Javascript Object) + */ public toPojo() { const stoPojo = super.toPojo(); const { cap, rate } = this; @@ -115,6 +138,9 @@ export class SimpleSto extends Sto { }; } + /** + * Hydrating the entity + */ public _refresh(params: Partial) { const { cap, rate, ...rest } = params; diff --git a/src/entities/Sto.ts b/src/entities/Sto.ts index c3a6f27..9661901 100644 --- a/src/entities/Sto.ts +++ b/src/entities/Sto.ts @@ -156,6 +156,8 @@ export abstract class Sto

extends Entity

{ /** * Create a new sto instance + * @param params parameters for an sto and unique identifiers + * @param context the sdk is being used in */ constructor(params: Params & UniqueIdentifiers, context: Context) { super(); diff --git a/src/entities/TieredSto.ts b/src/entities/TieredSto.ts index 7b2c9e6..7398cc9 100644 --- a/src/entities/TieredSto.ts +++ b/src/entities/TieredSto.ts @@ -18,39 +18,102 @@ import { Investment } from './Investment'; const { weiToValue } = conversionUtils; +/** + * Represents a unique sto + */ export { UniqueIdentifiers }; +/** + * Represents a tier in the tiered sto + */ export interface Tier { + /** + * total number of tokens that are available in the tier + */ tokensOnSale: BigNumber; + /** + * total number of tokens that have been sold + */ tokensSold: BigNumber; + /** + * price at which tokens will be sold within the tier + */ price: BigNumber; + /** + * total number of tokens that are available to be sold with a discount within the tier + */ tokensWithDiscount: BigNumber; + /** + * total number of tokens that have been sold with a discount within the tier + */ tokensSoldAtDiscount: BigNumber; + /** + * discounted price at which tokens will be sold within the tier + */ discountedPrice: BigNumber; } +/** + * Represents a tiered sto + */ export interface Params extends StoParams { + /** + * numerical identifier for the current tier + */ currentTier: number; + /** + * array of tier information + */ tiers: Tier[]; } +/** + * Represents a tiered sto's base parameters + */ interface BaseParams { + /** + * minimum amount of tokens that will be sold in the sto + */ minTokens: BigNumber; + /** + * amount of tokens that will be sold in the sto + */ amount: BigNumber; + /** + * currency type that will be used to raise funds in the sto + */ currency: Currency; + /** + * optional beneficiary address to send beneficial investments to + */ beneficiary?: string; } +/** + * Represents a tiered sto raising in stable coin with a stable coin address + */ interface InvestInStableCoinParams extends BaseParams { + /** + * currency to raise in stable coin + */ currency: Currency.StableCoin; + /** + * ethereum address for the stable coin in which funds will be raised + */ stableCoinAddress: string; } +/** + * Represents a tiered sto where funds are raised in other fund raise types + */ interface InvestInOtherParams extends BaseParams { currency: Currency.ETH | Currency.POLY; stableCoinAddress?: undefined; } +/** + * Used to manage a tiered sto + */ export class TieredSto extends Sto { public static generateId({ securityTokenId, stoType, address }: UniqueIdentifiers) { return serialize('tieredSto', { @@ -66,6 +129,11 @@ export class TieredSto extends Sto { public tiers: Tier[]; + /** + * Create a new tiered sto instance + * @param params parameters for an sto and unique identifiers + * @param context the sdk is being used in + */ constructor(params: Params & UniqueIdentifiers, context: Context) { const { currentTier, tiers, ...rest } = params; @@ -166,23 +234,23 @@ export class TieredSto extends Sto { /** * Modify STO parameters. Must be done before the STO starts * - * @param startDate date when the STO should start - * @param endDate date when the STO should end - * @param tiers tier information - * @param tiers[].tokensOnSale amount of tokens to be sold on that tier - * @param tiers[].price price of each token on that tier - * @param tiers[].tokensWithDiscount amount of tokens to be sold on that tier at a discount if paid in POLY (must be less than tokensOnSale, defaults to 0) - * @param tiers[].discountedPrice price of discounted tokens on that tier (defaults to 0) - * @param nonAccreditedInvestmentLimit maximum investment for non-accredited investors - * @param minimumInvestment minimum investment amount - * @param fundraiseCurrencies array of currencies in which the funds will be raised (ETH, POLY, StableCoin) - * @param raisedFundsWallet wallet address that will receive the funds that are being raised - * @param unsoldTokensWallet wallet address that will receive unsold tokens when the end date is reached - * @param stableCoinAddresses addresses of supported stablecoins - * @param customCurrency custom currency data. Allows the STO to raise funds pegged to a different currency. Optional, defaults to USD - * @param customCurrency.currencySymbol symbol of the custom currency (USD, CAD, EUR, etc. Default is USD) - * @param customCurrency.ethOracleAddress address of the oracle that states the price of ETH in the custom currency. Only required if raising funds in ETH - * @param customCurrency.polyOracleAddress address of the oracle that states the price of POLY in the custom currency. Only required if raising funds in POLY + * @param args.startDate - date when the STO should start + * @param args.endDate - date when the STO should end + * @param args.tiers - tier information + * @param args.tiers[].tokensOnSale - amount of tokens to be sold on that tier + * @param args.tiers[].price - price of each token on that tier + * @param args.tiers[].tokensWithDiscount - amount of tokens to be sold on that tier at a discount if paid in POLY (must be less than tokensOnSale, defaults to 0) + * @param args.tiers[].discountedPrice - price of discounted tokens on that tier (defaults to 0) + * @param args.nonAccreditedInvestmentLimit - maximum investment for non-accredited investors + * @param args.minimumInvestment - minimum investment amount + * @param args.fundraiseCurrencies - array of currencies in which the funds will be raised (ETH, POLY, StableCoin) + * @param args.raisedFundsWallet - wallet address that will receive the funds that are being raised + * @param args.unsoldTokensWallet - wallet address that will receive unsold tokens when the end date is reached + * @param args.stableCoinAddresses - addresses of supported stablecoins + * @param args.customCurrency - custom currency data. Allows the STO to raise funds pegged to a different currency. Optional, defaults to USD + * @param args.customCurrency.currencySymbol - symbol of the custom currency (USD, CAD, EUR, etc. Default is USD) + * @param args.customCurrency.ethOracleAddress - address of the oracle that states the price of ETH in the custom currency. Only required if raising funds in ETH + * @param args.customCurrency.polyOracleAddress - address of the oracle that states the price of POLY in the custom currency. Only required if raising funds in POLY */ public async modifyData(args: { startDate?: Date; @@ -215,11 +283,11 @@ export class TieredSto extends Sto { /** * Invest in the STO * - * @param minTokens sets a minimum amount of tokens to buy. If the amount sent yields less tokens at the current price, the transaction will revert - * @param amount amount to spend - * @param currency currency in which to buy the tokens - * @param stableCoinAddress address of the stable coin in which to pay (only applicable if currency is StableCoin) - * @param beneficiary address that will receive the purchased tokens (defaults to current wallet, will fail if beneficial investments are not allowed for the STO) + * @param args.minTokens - sets a minimum amount of tokens to buy. If the amount sent yields less tokens at the current price, the transaction will revert + * @param args.amount - amount to spend + * @param args.currency - currency in which to buy the tokens + * @param args.stableCoinAddress - address of the stable coin in which to pay (only applicable if currency is StableCoin) + * @param args.beneficiary - address that will receive the purchased tokens (defaults to current wallet, will fail if beneficial investments are not allowed for the STO) */ public async invest(args: { minTokens: BigNumber; @@ -239,6 +307,9 @@ export class TieredSto extends Sto { } /* eslint-enable no-dupe-class-members */ + /** + * Convert entity to a POJO (Plain Old Javascript Object) + */ public toPojo() { const stoPojo = super.toPojo(); const { currentTier, tiers } = this; @@ -250,6 +321,9 @@ export class TieredSto extends Sto { }; } + /** + * Hydrating the entity + */ public _refresh(params: Partial) { const { currentTier, tiers, ...rest } = params; From c563ada864af8c7f33b0a5391b454fadbad70020 Mon Sep 17 00:00:00 2001 From: Victor Wiebe Date: Mon, 6 Jan 2020 10:26:59 -0800 Subject: [PATCH 05/43] docs: add comment documentation to related factories --- src/entities/factories/SimpleStoFactory.ts | 8 ++++++++ src/entities/factories/TieredStoFactory.ts | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/src/entities/factories/SimpleStoFactory.ts b/src/entities/factories/SimpleStoFactory.ts index b38e3d6..033eee9 100644 --- a/src/entities/factories/SimpleStoFactory.ts +++ b/src/entities/factories/SimpleStoFactory.ts @@ -5,6 +5,9 @@ import { Currency } from '../../types'; import { SimpleSto, Params, UniqueIdentifiers } from '../SimpleSto'; import { SecurityToken } from '../SecurityToken'; +/** + * Factory generates information for a simple sto entity + */ export class SimpleStoFactory extends Factory { protected generateProperties = async (uid: string) => { const { securityTokenId, stoType, address } = SimpleSto.unserialize(uid); @@ -75,6 +78,11 @@ export class SimpleStoFactory extends Factory { protected generateProperties = async (uid: string) => { const { securityTokenId, stoType, address } = TieredSto.unserialize(uid); @@ -136,6 +139,11 @@ export class TieredStoFactory extends Factory Date: Mon, 6 Jan 2020 13:03:04 -0800 Subject: [PATCH 06/43] docs: add documentation for wallet, factory, queue --- src/entities/Entity.ts | 3 +++ src/entities/TransactionQueue.ts | 31 +++++++++++++++++++++++++ src/entities/Wallet.ts | 27 ++++++++++++++++++++- src/entities/factories/Factory.ts | 24 +++++++++++++++---- src/entities/factories/WalletFactory.ts | 7 ++++++ 5 files changed, 86 insertions(+), 6 deletions(-) diff --git a/src/entities/Entity.ts b/src/entities/Entity.ts index 4d78dc9..58a76e7 100644 --- a/src/entities/Entity.ts +++ b/src/entities/Entity.ts @@ -1,3 +1,6 @@ +/** + * Abstract class to create an entity with unique properties + */ export abstract class Entity { public abstract uid: string; diff --git a/src/entities/TransactionQueue.ts b/src/entities/TransactionQueue.ts index 3c552c4..3b7d2cd 100644 --- a/src/entities/TransactionQueue.ts +++ b/src/entities/TransactionQueue.ts @@ -19,9 +19,15 @@ enum Events { TransactionStatusChange = 'TransactionStatusChange', } +/** + * Class to manage procedural transaction queues + */ export class TransactionQueue extends Entity< void > { + /** + * Generate an ID for a transaction + */ public static generateId() { return serialize('transaction', { random: v4(), @@ -52,6 +58,14 @@ export class TransactionQueue { this.queue = [...this.transactions]; this.updateStatus(TransactionQueueStatus.Running); @@ -123,6 +143,10 @@ export class TransactionQueue void) { this.emitter.on(Events.StatusChange, listener); @@ -131,6 +155,10 @@ export class TransactionQueue void ) { @@ -182,5 +210,8 @@ export class TransactionQueue { public static generateId({ address }: UniqueIdentifiers) { return serialize('wallet', { @@ -24,6 +33,11 @@ export class Wallet extends Entity { }); } + /** + * Unserialize a serialized entity + * + * @param serialized string with entity information + */ public static unserialize(serialized: string) { const unserialized = unserialize(serialized); @@ -43,6 +57,11 @@ export class Wallet extends Entity { protected context: Context; + /** + * Create a wallet entity + * @param params unique params for wallet + * @param context the context in which the sdk will be used + */ constructor(params: Params, context: Context) { super(); @@ -55,6 +74,9 @@ export class Wallet extends Entity { }); } + /** + * Convert entity to a POJO (Plain Old Javascript Object) + */ public toPojo() { const { uid, address } = this; @@ -64,6 +86,9 @@ export class Wallet extends Entity { }; } + /** + * Hydrating the entity + */ public _refresh(params: Partial) { const { address } = params; @@ -91,7 +116,7 @@ export class Wallet extends Entity { /** * Retrieve the ERC20 balance of this particular wallet address * - * @param tokenAddress address of the ERC20 token contract + * @param args.tokenAddress - address of the ERC20 token contract */ public getErc20Balance = async (args: { tokenAddress: string }): Promise => { const { context, address } = this; diff --git a/src/entities/factories/Factory.ts b/src/entities/factories/Factory.ts index 6d44520..5584966 100644 --- a/src/entities/factories/Factory.ts +++ b/src/entities/factories/Factory.ts @@ -2,12 +2,18 @@ import { merge } from 'lodash'; import { Entity } from '../Entity'; import { Context } from '../../Context'; +/** + * Represents an entity + */ export interface EntityClass { new (params: T & U, context: Context): Entity; unserialize(uid: string): U; generateId(identifiers: U): string; } +/** + * Abstract representing a factory that will build up properties of an entity + */ export abstract class Factory, T extends any, U extends any> { public cache: { [key: string]: EntityType | undefined; @@ -19,6 +25,12 @@ export abstract class Factory, T extends any, U ext protected abstract generateProperties(uid: string): Promise; + /** + * Create a factory that can generate an entity + * + * @param eClass class defining the entity that will be created + * @param context the context in which the sdk will be used + */ constructor(eClass: EntityClass, context: Context) { this.Entity = eClass; this.context = context; @@ -40,11 +52,13 @@ export abstract class Factory, T extends any, U ext cache[uid] = instance; } else { - // TODO @monitz87: remove this as soon as we implement event-based refreshing of entities - // This line basically fetches the data again and again every time an entity is fetched, - // making the cache only good for having one central copy of each entity, but not for reducing - // the amount of requests. Once we start subscribing to relevant events in each factory and refreshing - // entities when they fire, this won't be necessary + /* + TODO @monitz87: remove this as soon as we implement event-based refreshing of entities + This line basically fetches the data again and again every time an entity is fetched, + making the cache only good for having one central copy of each entity, but not for reducing + the amount of requests. Once we start subscribing to relevant events in each factory and refreshing + entities when they fire, this won't be necessary + */ await this.refresh(uid); } diff --git a/src/entities/factories/WalletFactory.ts b/src/entities/factories/WalletFactory.ts index 443cd7a..07b875d 100644 --- a/src/entities/factories/WalletFactory.ts +++ b/src/entities/factories/WalletFactory.ts @@ -2,6 +2,9 @@ import { Factory } from './Factory'; import { Context } from '../../Context'; import { Wallet, Params, UniqueIdentifiers } from '../Wallet'; +/** + * Factory to generate properties for a wallet entity + */ export class WalletFactory extends Factory { protected generateProperties = async (uid: string) => { const { address } = Wallet.unserialize(uid); @@ -11,6 +14,10 @@ export class WalletFactory extends Factory { }; }; + /** + * Create a wallet factory + * @param context the context in which the sdk will be used + */ constructor(context: Context) { super(Wallet, context); } From d24a8475306ef239b0b4586eea3b84a6192f69ab Mon Sep 17 00:00:00 2001 From: Victor Wiebe Date: Tue, 7 Jan 2020 07:18:33 -0800 Subject: [PATCH 07/43] docs: document shareholder entity and factory --- src/entities/Shareholder.ts | 25 ++++++++++++++++++++ src/entities/factories/ShareholderFactory.ts | 8 +++++++ 2 files changed, 33 insertions(+) diff --git a/src/entities/Shareholder.ts b/src/entities/Shareholder.ts index 8ac00b4..c0835cd 100644 --- a/src/entities/Shareholder.ts +++ b/src/entities/Shareholder.ts @@ -4,6 +4,9 @@ import { serialize, unserialize } from '../utils'; import { PolymathError } from '../PolymathError'; import { ErrorCode } from '../types'; +/** + * Represents a unique shareholder for a specific security token + */ export interface UniqueIdentifiers { securityTokenId: string; address: string; @@ -15,6 +18,9 @@ function isUniqueIdentifiers(identifiers: any): identifiers is UniqueIdentifiers return typeof securityTokenId === 'string' && typeof address === 'string'; } +/** + * Represents information for a specific shareholder on a security token + */ export interface Params { securityTokenSymbol: string; canSendAfter: Date; @@ -25,6 +31,9 @@ export interface Params { balance: BigNumber; } +/** + * Used to manage a shareholder + */ export class Shareholder extends Entity { public static generateId({ securityTokenId, address }: UniqueIdentifiers) { return serialize('shareholder', { @@ -33,6 +42,11 @@ export class Shareholder extends Entity { }); } + /** + * Unserialize a serialized shareholder entity + * + * @param serialized string with shareholder entity information + */ public static unserialize(serialized: string) { const unserialized = unserialize(serialized); @@ -66,6 +80,11 @@ export class Shareholder extends Entity { public address: string; + /** + * Create a new shareholder instance + * @param params parameters for a shareholder and unique identifiers + * @param context the sdk is being used in + */ constructor(params: Params & UniqueIdentifiers) { super(); @@ -110,6 +129,9 @@ export class Shareholder extends Entity { return datesAreZero; } + /** + * Convert entity to a POJO (Plain Old Javascript Object) + */ public toPojo() { const { uid, @@ -138,6 +160,9 @@ export class Shareholder extends Entity { }; } + /** + * Hydrating the entity + */ public _refresh(params: Partial) { const { securityTokenSymbol, diff --git a/src/entities/factories/ShareholderFactory.ts b/src/entities/factories/ShareholderFactory.ts index 9ee4ac6..482daa5 100644 --- a/src/entities/factories/ShareholderFactory.ts +++ b/src/entities/factories/ShareholderFactory.ts @@ -6,6 +6,9 @@ import { PolymathError } from '../../PolymathError'; import { ErrorCode } from '../../types'; import { Shareholder, Params, UniqueIdentifiers } from '../Shareholder'; +/** + * Factory generates information for a shareholder entity + */ export class ShareholderFactory extends Factory { protected generateProperties = async (uid: string) => { const { @@ -54,6 +57,11 @@ export class ShareholderFactory extends Factory Date: Tue, 7 Jan 2020 08:23:17 -0800 Subject: [PATCH 08/43] docs: tax withholding entity and factory --- src/entities/TaxWithholding.ts | 26 ++++++++++++++++++- .../factories/TaxWithholdingFactory.ts | 9 ++++++- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/entities/TaxWithholding.ts b/src/entities/TaxWithholding.ts index c7ff277..8790351 100644 --- a/src/entities/TaxWithholding.ts +++ b/src/entities/TaxWithholding.ts @@ -3,6 +3,9 @@ import { serialize, unserialize } from '../utils'; import { ErrorCode } from '../types'; import { PolymathError } from '../PolymathError'; +/** + * Represents unique tax withholding properties for a specific security token holder + */ export interface UniqueIdentifiers { securityTokenId: string; shareholderAddress: string; @@ -18,11 +21,16 @@ function isUniqueIdentifiers(identifiers: any): identifiers is UniqueIdentifiers ); } +/** + * Represents information for tax withholding information for a security token + */ export interface Params { securityTokenSymbol: string; percentage: number; } - +/** + * Used to manage tax withholding amounts + */ export class TaxWithholding extends Entity { public static generateId({ securityTokenId, shareholderAddress }: UniqueIdentifiers) { return serialize('taxWithholding', { @@ -31,6 +39,11 @@ export class TaxWithholding extends Entity { }); } + /** + * Unserialize a serialized entity of tax withholding information + * + * @param serialized string with tax withholding information + */ public static unserialize(serialized: string) { const unserialized = unserialize(serialized); @@ -54,6 +67,11 @@ export class TaxWithholding extends Entity { public percentage: number; + /** + * Create a new tax withholding information instance + * @param params parameters for tax withholding and unique identifiers + * @param context the sdk is being used in + */ constructor(params: Params & UniqueIdentifiers) { super(); @@ -69,6 +87,9 @@ export class TaxWithholding extends Entity { }); } + /** + * Convert entity to a POJO (Plain Old Javascript Object) + */ public toPojo() { const { uid, securityTokenId, securityTokenSymbol, shareholderAddress, percentage } = this; @@ -81,6 +102,9 @@ export class TaxWithholding extends Entity { }; } + /** + * Hydrating the entity + */ public _refresh(params: Partial) { const { securityTokenSymbol, percentage } = params; diff --git a/src/entities/factories/TaxWithholdingFactory.ts b/src/entities/factories/TaxWithholdingFactory.ts index 7ab0c29..dd511c9 100644 --- a/src/entities/factories/TaxWithholdingFactory.ts +++ b/src/entities/factories/TaxWithholdingFactory.ts @@ -5,7 +5,9 @@ import { SecurityToken } from '../SecurityToken'; import { PolymathError } from '../../PolymathError'; import { ErrorCode } from '../../types'; import { TaxWithholding, Params, UniqueIdentifiers } from '../TaxWithholding'; - +/** + * Factory generates information for a tax withholding entity + */ export class TaxWithholdingFactory extends Factory { protected generateProperties = async (uid: string) => { const { @@ -64,6 +66,11 @@ export class TaxWithholdingFactory extends Factory Date: Tue, 7 Jan 2020 08:39:03 -0800 Subject: [PATCH 09/43] fix: use rimraf to assure cross platform compatibility --- package.json | 3 ++- yarn.lock | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 918fedf..7c0de1d 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "semantic-release": "semantic-release", "coveralls": "jest --coverage && cat ./coverage/lcov.info | coveralls", "lint": "eslint src --ext .ts", - "postinstall": "rm -rf ./node_modules/typedoc/node_modules/typescript" + "postinstall": "rimraf ./node_modules/typedoc/node_modules/typescript" }, "jest": { "moduleFileExtensions": [ @@ -107,6 +107,7 @@ "prettier-eslint-cli": "^4.7.1", "reflect-metadata": "^0.1.12", "regenerator-runtime": "^0.13.1", + "rimraf": "^3.0.0", "semantic-release": "^16.0.0-beta.18", "sinon": "^7.5.0", "ts-loader": "^5.3.3", diff --git a/yarn.lock b/yarn.lock index cf81542..4c971c1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -13480,6 +13480,13 @@ rimraf@2, rimraf@2.6.3, rimraf@^2.2.8, rimraf@^2.5.2, rimraf@^2.5.4, rimraf@^2.6 dependencies: glob "^7.1.3" +rimraf@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.0.tgz#614176d4b3010b75e5c390eb0ee96f6dc0cebb9b" + integrity sha512-NDGVxTsjqfunkds7CqsOiEnxln4Bo7Nddl3XhS4pXg5OzwkLqJ971ZVAAnB+DDLnF76N+VnDEiBHaVV8I06SUg== + dependencies: + glob "^7.1.3" + ripemd160@^2.0.0, ripemd160@^2.0.1: version "2.0.2" resolved "https://registry.yarnpkg.com/ripemd160/-/ripemd160-2.0.2.tgz#a1c1a6f624751577ba5d07914cbc92850585890c" From 2479ee8afe0e4b70a00cab4af3c9be661b932a9d Mon Sep 17 00:00:00 2001 From: Victor Wiebe Date: Tue, 7 Jan 2020 09:55:31 -0800 Subject: [PATCH 10/43] docs: investment and investment factory --- src/entities/Investment.ts | 25 +++++++++++++++++++++ src/entities/factories/InvestmentFactory.ts | 8 +++++++ 2 files changed, 33 insertions(+) diff --git a/src/entities/Investment.ts b/src/entities/Investment.ts index e7809cd..80bcbe8 100644 --- a/src/entities/Investment.ts +++ b/src/entities/Investment.ts @@ -4,6 +4,9 @@ import { serialize, unserialize } from '../utils'; import { PolymathError } from '../PolymathError'; import { ErrorCode } from '../types'; +/** + * Represents a unique shareholder for a specific investment + */ export interface UniqueIdentifiers { securityTokenId: string; stoId: string; @@ -18,6 +21,9 @@ function isUniqueIdentifiers(identifiers: any): identifiers is UniqueIdentifiers ); } +/** + * Represents information for a specific security token investment + */ export interface Params { securityTokenSymbol: string; address: string; @@ -25,6 +31,9 @@ export interface Params { investedFunds: BigNumber; } +/** + * Used to manage an investment in a security token + */ export class Investment extends Entity { public static generateId({ securityTokenId, stoId, index }: UniqueIdentifiers) { return serialize('investment', { @@ -34,6 +43,11 @@ export class Investment extends Entity { }); } + /** + * Unserialize a serialized investment entity + * + * @param serialized string with investment entity information + */ public static unserialize(serialized: string) { const unserialized = unserialize(serialized); @@ -63,6 +77,11 @@ export class Investment extends Entity { public investedFunds: BigNumber; + /** + * Create an investment instance + * @param params parameters defining an investment and unique identifiers + * @param context the sdk is being used in + */ constructor(params: Params & UniqueIdentifiers) { super(); @@ -90,6 +109,9 @@ export class Investment extends Entity { }); } + /** + * Convert entity to a POJO (Plain Old Javascript Object) + */ public toPojo() { const { uid, @@ -114,6 +136,9 @@ export class Investment extends Entity { }; } + /** + * Hydrating the entity + */ public _refresh(params: Partial) { const { securityTokenSymbol, address, investedFunds, tokenAmount } = params; diff --git a/src/entities/factories/InvestmentFactory.ts b/src/entities/factories/InvestmentFactory.ts index a6a8dba..789d49d 100644 --- a/src/entities/factories/InvestmentFactory.ts +++ b/src/entities/factories/InvestmentFactory.ts @@ -16,6 +16,9 @@ import { PolymathError } from '../../PolymathError'; const { weiToValue } = conversionUtils; +/** + * Factory generates information for an investment entity + */ export class InvestmentFactory extends Factory { protected generateProperties = async (uid: string) => { const { stoId, securityTokenId, index } = Investment.unserialize(uid); @@ -99,6 +102,11 @@ export class InvestmentFactory extends Factory Date: Tue, 7 Jan 2020 17:16:31 -0800 Subject: [PATCH 11/43] docs: finish more entity docs --- src/entities/Erc20TokenBalance.ts | 25 +++++++++++++++++++ src/entities/PolyTransaction.ts | 21 ++++++++++++++++ .../factories/Erc20TokenBalanceFactory.ts | 8 ++++++ 3 files changed, 54 insertions(+) diff --git a/src/entities/Erc20TokenBalance.ts b/src/entities/Erc20TokenBalance.ts index 4dc2c7b..f085b89 100644 --- a/src/entities/Erc20TokenBalance.ts +++ b/src/entities/Erc20TokenBalance.ts @@ -4,6 +4,9 @@ import { serialize, unserialize } from '../utils'; import { PolymathError } from '../PolymathError'; import { ErrorCode } from '../types'; +/** + * Represents the balance for an erc20 token holder + */ export interface UniqueIdentifiers { tokenAddress: string; walletAddress: string; @@ -15,11 +18,17 @@ function isUniqueIdentifiers(identifiers: any): identifiers is UniqueIdentifiers return typeof tokenAddress === 'string' && typeof walletAddress === 'string'; } +/** + * Represents information for an erc20 token holders balance + */ export interface Params { tokenSymbol: string | null; balance: BigNumber; } +/** + * Used to manage erc20 token holder balances + */ export class Erc20TokenBalance extends Entity { public static generateId({ tokenAddress, walletAddress }: UniqueIdentifiers) { return serialize('erc20TokenBalance', { @@ -28,6 +37,11 @@ export class Erc20TokenBalance extends Entity { }); } + /** + * Unserialize a serialized erc20 token balance + * + * @param serialized string with erc20 token balance entity information + */ public static unserialize(serialized: any) { const unserialized = unserialize(serialized); @@ -51,6 +65,11 @@ export class Erc20TokenBalance extends Entity { public balance: BigNumber; + /** + * Create an entity instance with erc20 token holder balance + * @param params parameters for an erc20 token balance and unique identifiers + * @param context the sdk is being used in + */ constructor(params: Params & UniqueIdentifiers) { super(); @@ -66,6 +85,9 @@ export class Erc20TokenBalance extends Entity { }); } + /** + * Convert entity to a POJO (Plain Old Javascript Object) + */ public toPojo() { const { uid, tokenSymbol, tokenAddress, balance, walletAddress } = this; @@ -78,6 +100,9 @@ export class Erc20TokenBalance extends Entity { }; } + /** + * Hydrating the entity + */ public _refresh(params: Partial) { const { tokenSymbol, balance } = params; diff --git a/src/entities/PolyTransaction.ts b/src/entities/PolyTransaction.ts index 4a29888..fbb1a60 100644 --- a/src/entities/PolyTransaction.ts +++ b/src/entities/PolyTransaction.ts @@ -27,6 +27,9 @@ const mapValuesDeep = ( mapValues(obj, (val, key) => (isPlainObject(val) ? mapValuesDeep(val, fn) : fn(val, key, obj))); // TODO @monitz87: Make properties private where appliccable +/** + * Class to manage poly transactions to interact with blockchain extrinsics + */ export class PolyTransaction extends Entity { public static generateId() { return serialize('transaction', { @@ -68,6 +71,11 @@ export class PolyTransaction extends E private emitter: EventEmitter; + /** + * Creates a poly transaction + * @param transaction specifications about the traction being made + * @param transactionQueue queue of pending transactions + */ constructor( transaction: TransactionSpec, transactionQueue: TransactionQueue @@ -90,6 +98,9 @@ export class PolyTransaction extends E this.uid = PolyTransaction.generateId(); } + /** + * Convert entity to a POJO (Plain Old Javascript Object) + */ public toPojo() { const { uid, status, tag, receipt, error, txHash, transactionQueue, args } = this; const transactionQueueUid = transactionQueue.uid; @@ -114,6 +125,9 @@ export class PolyTransaction extends E }; } + /** + * Run the poly tranasaction and update a transaction status + */ public async run() { try { const receipt = await this.internalRun(); @@ -139,6 +153,10 @@ export class PolyTransaction extends E await this.promise; } + /** + * Trigger change in status based on event + * @param listener transaction listener method + */ public onStatusChange = (listener: (transaction: this) => void) => { this.emitter.on(Event.StatusChange, listener); @@ -248,5 +266,8 @@ export class PolyTransaction extends E }) as T; } + /** + * Hydrating the entity + */ public _refresh() {} } diff --git a/src/entities/factories/Erc20TokenBalanceFactory.ts b/src/entities/factories/Erc20TokenBalanceFactory.ts index c16fc6d..d815d61 100644 --- a/src/entities/factories/Erc20TokenBalanceFactory.ts +++ b/src/entities/factories/Erc20TokenBalanceFactory.ts @@ -2,6 +2,9 @@ import { Factory } from './Factory'; import { Context } from '../../Context'; import { Erc20TokenBalance, Params, UniqueIdentifiers } from '../Erc20TokenBalance'; +/** + * Factory generates information for an erc20 token balance + */ export class Erc20TokenBalanceFactory extends Factory< Erc20TokenBalance, Params, @@ -21,6 +24,11 @@ export class Erc20TokenBalanceFactory extends Factory< return { tokenSymbol: symbol, balance }; }; + /** + * Creates an instance of the erc20 token balance factory + * + * @param context the context in which sdk will be used + */ constructor(context: Context) { super(Erc20TokenBalance, context); } From 46748e0b51ab77208f4ad930ea179ee974d5e6f5 Mon Sep 17 00:00:00 2001 From: Victor Wiebe Date: Wed, 8 Jan 2020 09:37:35 -0800 Subject: [PATCH 12/43] fix: documentation issues from review --- src/entities/SimpleSto.ts | 18 +++++--- src/entities/Sto.ts | 54 ++++++++++++++++++---- src/entities/TieredSto.ts | 47 +++++++++---------- src/entities/factories/SimpleStoFactory.ts | 4 +- src/entities/factories/TieredStoFactory.ts | 4 +- src/types/index.ts | 14 +++++- 6 files changed, 94 insertions(+), 47 deletions(-) diff --git a/src/entities/SimpleSto.ts b/src/entities/SimpleSto.ts index 598b3e1..585c667 100644 --- a/src/entities/SimpleSto.ts +++ b/src/entities/SimpleSto.ts @@ -15,7 +15,7 @@ import { Investment } from './Investment'; const { weiToValue } = conversionUtils; /** - * Represents a simple sto + * Properties that uniquely identify a simple sto */ export interface Params extends StoParams { /** @@ -28,9 +28,6 @@ export interface Params extends StoParams { rate: BigNumber; } -/** - * Represents a unique sto - */ export { UniqueIdentifiers }; /** @@ -45,16 +42,23 @@ export class SimpleSto extends Sto { }); } + /** + * Unique generated Tiered STO id + */ public uid: string; + /** + * Cap of total tokens that can be sold in sto + */ public cap: BigNumber; + /** + * Rate at which the tokens will be sold in sto + */ public rate: BigNumber; /** * Create a new simple sto instance - * @param params parameters for an sto and unique identifiers - * @param context the sdk is being used in */ constructor(params: Params & UniqueIdentifiers, context: Context) { const { cap, rate, ...rest } = params; @@ -139,7 +143,7 @@ export class SimpleSto extends Sto { } /** - * Hydrating the entity + * Hydrate the entity */ public _refresh(params: Partial) { const { cap, rate, ...rest } = params; diff --git a/src/entities/Sto.ts b/src/entities/Sto.ts index 06007b1..b8d0970 100644 --- a/src/entities/Sto.ts +++ b/src/entities/Sto.ts @@ -13,7 +13,7 @@ import { } from '../procedures'; /** - * Represents a unique sto + * Properties that uniquely identify an STO */ export interface UniqueIdentifiers { securityTokenId: string; @@ -23,8 +23,6 @@ export interface UniqueIdentifiers { /** * Check if the provided value is of type [[UniqueIdentifiers]] - * - * @param identifiers - internal security token representation */ function isUniqueIdentifiers(identifiers: any): identifiers is UniqueIdentifiers { const { securityTokenId, stoType, address } = identifiers; @@ -33,7 +31,7 @@ function isUniqueIdentifiers(identifiers: any): identifiers is UniqueIdentifiers } /** - * Represents an sto + * STO constructor parameters */ export interface Params { /** @@ -61,7 +59,7 @@ export interface Params { */ unsoldTokensWallet: string; /** - * amount of tokens to be raised + * funds that have been raised to this date */ raisedAmount: BigNumber; /** @@ -98,40 +96,82 @@ export interface Params { * Abstract class used as a base to manage sto functionalities */ export abstract class Sto

extends Entity

{ + /** + * Uniquely generated id for the STO + */ public abstract uid: string; + /** + * Ethereum address for the STO + */ public address: string; public securityTokenSymbol: string; public securityTokenId: string; + /** + * Type of STO setup + */ public stoType: StoType; public startDate: Date; public endDate: Date; + /** + * Wallet where funds raised will be forwarded to + */ public raisedFundsWallet: string; + /** + * Wallet where unsold tokens will be returned to + */ public unsoldTokensWallet: string; + /** + * Amount of funds that have been raised so far + */ public raisedAmount: BigNumber; + /** + * Total number of tokens that have been sold so far + */ public soldTokensAmount: BigNumber; + /** + * Number of investors that have purchased tokens in the STO + */ public investorCount: number; + /** + * Valid currencies that funds can be raised in + */ public fundraiseCurrencies: Currency[]; + /** + * Whether the STO is currently paused or not + */ public isPaused: boolean; + /** + * Whether the STO cap has been reached or not + */ public capReached: boolean; + /** + * Whether the STO has been finalized or not + */ public isFinalized: boolean; + /** + * Whether the preissuing of tokens is allowed or not + */ public preIssueAllowed: boolean; + /** + * Whether investments can be made on behalf of a beneficiary or not + */ public beneficialInvestmentsAllowed: boolean; protected context: Context; @@ -156,8 +196,6 @@ export abstract class Sto

extends Entity

{ /** * Create a new sto instance - * @param params parameters for an sto and unique identifiers - * @param context the sdk is being used in */ constructor(params: Params & UniqueIdentifiers, context: Context) { super(); @@ -395,7 +433,7 @@ export abstract class Sto

extends Entity

{ } /** - * Hydrating the entity + * Hydrate the entity */ public _refresh(params: Partial) { const { diff --git a/src/entities/TieredSto.ts b/src/entities/TieredSto.ts index 7398cc9..1f0a019 100644 --- a/src/entities/TieredSto.ts +++ b/src/entities/TieredSto.ts @@ -18,13 +18,10 @@ import { Investment } from './Investment'; const { weiToValue } = conversionUtils; -/** - * Represents a unique sto - */ export { UniqueIdentifiers }; /** - * Represents a tier in the tiered sto + * Unique properties of a tier in the tiered sto */ export interface Tier { /** @@ -40,25 +37,25 @@ export interface Tier { */ price: BigNumber; /** - * total number of tokens that are available to be sold with a discount within the tier + * total number of tokens that are available to be sold at a discount when paid in POLY */ tokensWithDiscount: BigNumber; /** - * total number of tokens that have been sold with a discount within the tier + * total number of tokens that have been sold at a discount */ tokensSoldAtDiscount: BigNumber; /** - * discounted price at which tokens will be sold within the tier + * discounted price at which tokens will be sold */ discountedPrice: BigNumber; } /** - * Represents a tiered sto + * Represents a Tiered STO */ export interface Params extends StoParams { /** - * numerical identifier for the current tier + * numerical identifier for the current tier index */ currentTier: number; /** @@ -68,9 +65,9 @@ export interface Params extends StoParams { } /** - * Represents a tiered sto's base parameters + * @hidden */ -interface BaseParams { +interface BaseInvestParams { /** * minimum amount of tokens that will be sold in the sto */ @@ -90,9 +87,9 @@ interface BaseParams { } /** - * Represents a tiered sto raising in stable coin with a stable coin address + * @hidden */ -interface InvestInStableCoinParams extends BaseParams { +interface InvestInStableCoinParams extends BaseInvestParams { /** * currency to raise in stable coin */ @@ -104,9 +101,9 @@ interface InvestInStableCoinParams extends BaseParams { } /** - * Represents a tiered sto where funds are raised in other fund raise types + * @hidden */ -interface InvestInOtherParams extends BaseParams { +interface InvestInOtherParams extends BaseInvestParams { currency: Currency.ETH | Currency.POLY; stableCoinAddress?: undefined; } @@ -123,16 +120,23 @@ export class TieredSto extends Sto { }); } + /** + * Unique generated Tiered STO id + */ public uid: string; + /** + * Index of the current active tier + */ public currentTier: number; + /** + * Array of tier information + */ public tiers: Tier[]; /** * Create a new tiered sto instance - * @param params parameters for an sto and unique identifiers - * @param context the sdk is being used in */ constructor(params: Params & UniqueIdentifiers, context: Context) { const { currentTier, tiers, ...rest } = params; @@ -237,10 +241,6 @@ export class TieredSto extends Sto { * @param args.startDate - date when the STO should start * @param args.endDate - date when the STO should end * @param args.tiers - tier information - * @param args.tiers[].tokensOnSale - amount of tokens to be sold on that tier - * @param args.tiers[].price - price of each token on that tier - * @param args.tiers[].tokensWithDiscount - amount of tokens to be sold on that tier at a discount if paid in POLY (must be less than tokensOnSale, defaults to 0) - * @param args.tiers[].discountedPrice - price of discounted tokens on that tier (defaults to 0) * @param args.nonAccreditedInvestmentLimit - maximum investment for non-accredited investors * @param args.minimumInvestment - minimum investment amount * @param args.fundraiseCurrencies - array of currencies in which the funds will be raised (ETH, POLY, StableCoin) @@ -248,9 +248,6 @@ export class TieredSto extends Sto { * @param args.unsoldTokensWallet - wallet address that will receive unsold tokens when the end date is reached * @param args.stableCoinAddresses - addresses of supported stablecoins * @param args.customCurrency - custom currency data. Allows the STO to raise funds pegged to a different currency. Optional, defaults to USD - * @param args.customCurrency.currencySymbol - symbol of the custom currency (USD, CAD, EUR, etc. Default is USD) - * @param args.customCurrency.ethOracleAddress - address of the oracle that states the price of ETH in the custom currency. Only required if raising funds in ETH - * @param args.customCurrency.polyOracleAddress - address of the oracle that states the price of POLY in the custom currency. Only required if raising funds in POLY */ public async modifyData(args: { startDate?: Date; @@ -322,7 +319,7 @@ export class TieredSto extends Sto { } /** - * Hydrating the entity + * Hydrate the entity */ public _refresh(params: Partial) { const { currentTier, tiers, ...rest } = params; diff --git a/src/entities/factories/SimpleStoFactory.ts b/src/entities/factories/SimpleStoFactory.ts index 033eee9..4e34bef 100644 --- a/src/entities/factories/SimpleStoFactory.ts +++ b/src/entities/factories/SimpleStoFactory.ts @@ -79,9 +79,7 @@ export class SimpleStoFactory extends Factory Date: Wed, 8 Jan 2020 11:23:04 -0800 Subject: [PATCH 13/43] docs: tx queue and index updated --- src/entities/TransactionQueue.ts | 64 +++++++++++++++++++++++++++++--- src/types/index.ts | 9 +++++ 2 files changed, 68 insertions(+), 5 deletions(-) diff --git a/src/entities/TransactionQueue.ts b/src/entities/TransactionQueue.ts index 3b7d2cd..d706f4b 100644 --- a/src/entities/TransactionQueue.ts +++ b/src/entities/TransactionQueue.ts @@ -34,28 +34,64 @@ export class TransactionQueue; + /** + * @hidden + */ private queue: PolyTransaction[] = []; + /** + * @hidden + */ private returnValue: MaybeResolver; + /** + * @hidden + */ private emitter: EventEmitter; /** @@ -144,8 +180,11 @@ export class TransactionQueue void) { this.emitter.on(Events.StatusChange, listener); @@ -156,8 +195,11 @@ export class TransactionQueue void @@ -169,10 +211,19 @@ export class TransactionQueue void = () => {}; + /** + * @hidden + */ protected reject: (reason?: any) => void = () => {}; + /** + * @hidden + */ private updateStatus = (status: TransactionQueueStatus) => { this.status = status; @@ -198,6 +249,9 @@ export class TransactionQueue Date: Wed, 8 Jan 2020 12:12:34 -0800 Subject: [PATCH 14/43] docs: make fixes based on review comments --- src/entities/Wallet.ts | 14 +++++++++----- src/entities/factories/Factory.ts | 18 ++++++++++++------ src/entities/factories/WalletFactory.ts | 1 - 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/entities/Wallet.ts b/src/entities/Wallet.ts index 104e2ef..1dc1759 100644 --- a/src/entities/Wallet.ts +++ b/src/entities/Wallet.ts @@ -6,7 +6,7 @@ import { ErrorCode } from '../types'; import { Context } from '../Context'; /** - * Represents a unique wallet + * Unique identifier for wallet address */ export interface UniqueIdentifiers { address: string; @@ -19,7 +19,7 @@ function isUniqueIdentifiers(identifier: any): identifier is UniqueIdentifiers { } /** - * Represents a wallet + * Properties that uniquely identify wallet */ export interface Params extends UniqueIdentifiers {} @@ -51,16 +51,20 @@ export class Wallet extends Entity { return unserialized; } + /** + * Unique generated wallet id + */ public uid: string; + /** + * Wallet address + */ public address: string; protected context: Context; /** * Create a wallet entity - * @param params unique params for wallet - * @param context the context in which the sdk will be used */ constructor(params: Params, context: Context) { super(); @@ -87,7 +91,7 @@ export class Wallet extends Entity { } /** - * Hydrating the entity + * Hydrate the entity */ public _refresh(params: Partial) { const { address } = params; diff --git a/src/entities/factories/Factory.ts b/src/entities/factories/Factory.ts index 5584966..1d0afbb 100644 --- a/src/entities/factories/Factory.ts +++ b/src/entities/factories/Factory.ts @@ -7,7 +7,15 @@ import { Context } from '../../Context'; */ export interface EntityClass { new (params: T & U, context: Context): Entity; + + /** + * unserialize serialized entity information + */ unserialize(uid: string): U; + + /** + * generate a unique identifier for an entity + */ generateId(identifiers: U): string; } @@ -28,8 +36,6 @@ export abstract class Factory, T extends any, U ext /** * Create a factory that can generate an entity * - * @param eClass class defining the entity that will be created - * @param context the context in which the sdk will be used */ constructor(eClass: EntityClass, context: Context) { this.Entity = eClass; @@ -37,7 +43,7 @@ export abstract class Factory, T extends any, U ext } /** - * Gets an entity from the cache. Fetches the necessary data to create it if it isn't cached, refreshes it if it is + * Get an entity from the cache. Fetches the necessary data to create it if it isn't cached, refreshes it if it is * * @param uid unique identifier for the entity */ @@ -66,7 +72,7 @@ export abstract class Factory, T extends any, U ext } /** - * Gets an entity from the cache. Creates it if it isn't cached, updates it if it is + * Get an entity from the cache. Creates it if it isn't cached, updates it if it is * * @param uid unique identifier for the entity * @param params constructor data for the entity @@ -88,7 +94,7 @@ export abstract class Factory, T extends any, U ext } /** - * Fetches the data for an entity and updates its properties + * Fetch the data for an entity and updates its properties * * @param uid unique identifier for the entity */ @@ -105,7 +111,7 @@ export abstract class Factory, T extends any, U ext } /** - * Updates an entity's properties in place + * Update an entity's properties in place * * @param uid unique identifier for the entity * @param params properties that should be updated diff --git a/src/entities/factories/WalletFactory.ts b/src/entities/factories/WalletFactory.ts index 07b875d..b0ec84d 100644 --- a/src/entities/factories/WalletFactory.ts +++ b/src/entities/factories/WalletFactory.ts @@ -16,7 +16,6 @@ export class WalletFactory extends Factory { /** * Create a wallet factory - * @param context the context in which the sdk will be used */ constructor(context: Context) { super(Wallet, context); From 88becbc76fc175353f5c525b27832a0a197ae1b7 Mon Sep 17 00:00:00 2001 From: Victor Wiebe Date: Wed, 8 Jan 2020 12:13:27 -0800 Subject: [PATCH 15/43] docs: extra documentation for Factory --- src/entities/factories/Factory.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/entities/factories/Factory.ts b/src/entities/factories/Factory.ts index 1d0afbb..60de3b6 100644 --- a/src/entities/factories/Factory.ts +++ b/src/entities/factories/Factory.ts @@ -29,8 +29,14 @@ export abstract class Factory, T extends any, U ext public context: Context; + /** + * Defined entity class + */ public Entity: EntityClass; + /** + * @hidden + */ protected abstract generateProperties(uid: string): Promise; /** From cfcc1a5e2c52ab5460a98f6aa01acba3f8e7294f Mon Sep 17 00:00:00 2001 From: Victor Wiebe Date: Wed, 8 Jan 2020 12:39:24 -0800 Subject: [PATCH 16/43] docs: make more documentation changes based on review --- src/entities/Erc20TokenBalance.ts | 20 ++++-- src/entities/Investment.ts | 26 ++++++-- src/entities/PolyTransaction.ts | 64 +++++++++++++++++-- src/entities/Shareholder.ts | 32 ++++++++-- src/entities/TaxWithholding.ts | 17 +++-- .../factories/Erc20TokenBalanceFactory.ts | 4 +- src/entities/factories/InvestmentFactory.ts | 4 +- src/entities/factories/ShareholderFactory.ts | 4 +- .../factories/TaxWithholdingFactory.ts | 5 +- 9 files changed, 138 insertions(+), 38 deletions(-) diff --git a/src/entities/Erc20TokenBalance.ts b/src/entities/Erc20TokenBalance.ts index f085b89..5c80a08 100644 --- a/src/entities/Erc20TokenBalance.ts +++ b/src/entities/Erc20TokenBalance.ts @@ -5,7 +5,7 @@ import { PolymathError } from '../PolymathError'; import { ErrorCode } from '../types'; /** - * Represents the balance for an erc20 token holder + * Unique properties to identify an erc20 token holder */ export interface UniqueIdentifiers { tokenAddress: string; @@ -19,7 +19,7 @@ function isUniqueIdentifiers(identifiers: any): identifiers is UniqueIdentifiers } /** - * Represents information for an erc20 token holders balance + * Unique properties including information for an erc20 token holders balance */ export interface Params { tokenSymbol: string | null; @@ -55,20 +55,30 @@ export class Erc20TokenBalance extends Entity { return unserialized; } + /** + * Unique generated identifier for an ERC20 token balance + */ public uid: string; public tokenSymbol: string | null; + /** + * Address of the security token + */ public tokenAddress: string; + /** + * Wallet address of the token holder + */ public walletAddress: string; + /** + * Total number of tokens belonging to token holder + */ public balance: BigNumber; /** * Create an entity instance with erc20 token holder balance - * @param params parameters for an erc20 token balance and unique identifiers - * @param context the sdk is being used in */ constructor(params: Params & UniqueIdentifiers) { super(); @@ -101,7 +111,7 @@ export class Erc20TokenBalance extends Entity { } /** - * Hydrating the entity + * Hydrate the entity */ public _refresh(params: Partial) { const { tokenSymbol, balance } = params; diff --git a/src/entities/Investment.ts b/src/entities/Investment.ts index 80bcbe8..8f2bcdf 100644 --- a/src/entities/Investment.ts +++ b/src/entities/Investment.ts @@ -5,7 +5,7 @@ import { PolymathError } from '../PolymathError'; import { ErrorCode } from '../types'; /** - * Represents a unique shareholder for a specific investment + * Properties unique to a shareholder for a specific STO investment */ export interface UniqueIdentifiers { securityTokenId: string; @@ -22,7 +22,7 @@ function isUniqueIdentifiers(identifiers: any): identifiers is UniqueIdentifiers } /** - * Represents information for a specific security token investment + * Represents information for a specific security token offering investment */ export interface Params { securityTokenSymbol: string; @@ -61,26 +61,42 @@ export class Investment extends Entity { return unserialized; } + /** + * Unique generated identifier for an investment + */ public uid: string; public securityTokenId: string; + /** + * Unique ID for the investment STO + */ public stoId: string; public securityTokenSymbol: string; + /** + * Wallet address of token holder + */ public address: string; + /** + * Index of the investment + */ public index: number; + /** + * Total amount of tokens involved in the investment + */ public tokenAmount: BigNumber; + /** + * Amount of funds used to make investment + */ public investedFunds: BigNumber; /** * Create an investment instance - * @param params parameters defining an investment and unique identifiers - * @param context the sdk is being used in */ constructor(params: Params & UniqueIdentifiers) { super(); @@ -137,7 +153,7 @@ export class Investment extends Entity { } /** - * Hydrating the entity + * Hydrate the entity */ public _refresh(params: Partial) { const { securityTokenSymbol, address, investedFunds, tokenAmount } = params; diff --git a/src/entities/PolyTransaction.ts b/src/entities/PolyTransaction.ts index fbb1a60..47748fe 100644 --- a/src/entities/PolyTransaction.ts +++ b/src/entities/PolyTransaction.ts @@ -37,30 +37,63 @@ export class PolyTransaction extends E }); } + /** + * Unique generated identifier of the poly transaction + */ public uid: string; + /** + * Current status of the transaction + */ public status: TransactionStatus = TransactionStatus.Idle; + /** + * Queue of pending transactions + */ public transactionQueue: TransactionQueue; + /** + * Promise for the poly transaction + */ public promise: Promise; + /** + * Optional error for the poly transaction + */ public error?: PolymathError; + /** + * Optional receipt for the poly transaction + */ public receipt?: TransactionReceiptWithDecodedLogs | string; + /** + * Poly transaction tag + */ public tag: PolyTransactionTag; + /** + * Optional transaction hash for a poly transaction + */ public txHash?: string; + /** + * Transaction specification arguments + */ public args: TransactionSpec['args']; + /** + * @hidden + */ protected method: TransactionSpec< Args, Values, TransactionReceiptWithDecodedLogs | string >['method']; + /** + * @hidden + */ private postResolvers: PostTransactionResolverArray< Values, TransactionReceiptWithDecodedLogs | string @@ -69,12 +102,13 @@ export class PolyTransaction extends E TransactionReceiptWithDecodedLogs | string >; + /** + * @hidden + */ private emitter: EventEmitter; /** * Creates a poly transaction - * @param transaction specifications about the traction being made - * @param transactionQueue queue of pending transactions */ constructor( transaction: TransactionSpec, @@ -154,8 +188,11 @@ export class PolyTransaction extends E } /** - * Trigger change in status based on event - * @param listener transaction listener method + * Subscribe to status changes + * + * @param listener - callback function that will be called whenever the status changes + * + * @returns unsubscribe function */ public onStatusChange = (listener: (transaction: this) => void) => { this.emitter.on(Event.StatusChange, listener); @@ -165,10 +202,19 @@ export class PolyTransaction extends E }; }; + /** + * @hidden + */ protected resolve: (val?: any) => void = () => {}; + /** + * @hidden + */ protected reject: (reason?: any) => void = () => {}; + /** + * @hidden + */ private async internalRun() { this.updateStatus(TransactionStatus.Unapproved); @@ -218,6 +264,9 @@ export class PolyTransaction extends E return result; } + /** + * @hidden + */ private updateStatus = (status: TransactionStatus) => { this.status = status; @@ -246,6 +295,9 @@ export class PolyTransaction extends E /* eslint-enable default-case */ }; + /** + * @hidden + */ private unwrapArg(arg: PostTransactionResolver | T) { if (isPostTransactionResolver(arg)) { return arg.result; @@ -254,7 +306,7 @@ export class PolyTransaction extends E } /** - * Picks all post-transaction resolvers and unwraps their values + * @hidden */ private unwrapArgs(args: TransactionSpec['args']) { return mapValues(args, (arg: any) => { @@ -267,7 +319,7 @@ export class PolyTransaction extends E } /** - * Hydrating the entity + * Hydrate the entity */ public _refresh() {} } diff --git a/src/entities/Shareholder.ts b/src/entities/Shareholder.ts index c0835cd..c3a715a 100644 --- a/src/entities/Shareholder.ts +++ b/src/entities/Shareholder.ts @@ -5,7 +5,7 @@ import { PolymathError } from '../PolymathError'; import { ErrorCode } from '../types'; /** - * Represents a unique shareholder for a specific security token + * Basic properties of a unique shareholder for a specific security token */ export interface UniqueIdentifiers { securityTokenId: string; @@ -19,7 +19,7 @@ function isUniqueIdentifiers(identifiers: any): identifiers is UniqueIdentifiers } /** - * Represents information for a specific shareholder on a security token + * Properties for a specific shareholder on a security token */ export interface Params { securityTokenSymbol: string; @@ -60,30 +60,52 @@ export class Shareholder extends Entity { return unserialized; } + /** + * Unique generated id for a shareholder + */ public uid: string; public securityTokenSymbol: string; public securityTokenId: string; + /** + * Date after which a shareholder can transfer tokens from their address + */ public canSendAfter: Date; + /** + * Date after which a shareholder can transfer tokens to their address + */ public canReceiveAfter: Date; + /** + * Date when kyc approval will expire + */ public kycExpiry: Date; + /** + * Whether shareholder is accredited or not + */ public isAccredited: boolean; + /** + * Whether shareholder can purchase from an STO or not + */ public canBuyFromSto: boolean; + /** + * Total security token balance of a shareholder + */ public balance: BigNumber; + /** + * Shareholder address + */ public address: string; /** * Create a new shareholder instance - * @param params parameters for a shareholder and unique identifiers - * @param context the sdk is being used in */ constructor(params: Params & UniqueIdentifiers) { super(); @@ -161,7 +183,7 @@ export class Shareholder extends Entity { } /** - * Hydrating the entity + * Hydrate the entity */ public _refresh(params: Partial) { const { diff --git a/src/entities/TaxWithholding.ts b/src/entities/TaxWithholding.ts index 8790351..0a9bdf2 100644 --- a/src/entities/TaxWithholding.ts +++ b/src/entities/TaxWithholding.ts @@ -4,7 +4,7 @@ import { ErrorCode } from '../types'; import { PolymathError } from '../PolymathError'; /** - * Represents unique tax withholding properties for a specific security token holder + * Properties unique to tax withholding properties for a specific security token holder */ export interface UniqueIdentifiers { securityTokenId: string; @@ -22,7 +22,7 @@ function isUniqueIdentifiers(identifiers: any): identifiers is UniqueIdentifiers } /** - * Represents information for tax withholding information for a security token + * Unique properties for tax withholding of a security token */ export interface Params { securityTokenSymbol: string; @@ -57,20 +57,27 @@ export class TaxWithholding extends Entity { return unserialized; } + /** + * Unique generated identifer for tax withholding entity + */ public uid: string; public securityTokenSymbol: string; public securityTokenId: string; + /** + * Shareholder address for tax withholding properties + */ public shareholderAddress: string; + /** + * Percentage of tax to be withheld + */ public percentage: number; /** * Create a new tax withholding information instance - * @param params parameters for tax withholding and unique identifiers - * @param context the sdk is being used in */ constructor(params: Params & UniqueIdentifiers) { super(); @@ -103,7 +110,7 @@ export class TaxWithholding extends Entity { } /** - * Hydrating the entity + * Hydrate the entity */ public _refresh(params: Partial) { const { securityTokenSymbol, percentage } = params; diff --git a/src/entities/factories/Erc20TokenBalanceFactory.ts b/src/entities/factories/Erc20TokenBalanceFactory.ts index d815d61..285226c 100644 --- a/src/entities/factories/Erc20TokenBalanceFactory.ts +++ b/src/entities/factories/Erc20TokenBalanceFactory.ts @@ -25,9 +25,7 @@ export class Erc20TokenBalanceFactory extends Factory< }; /** - * Creates an instance of the erc20 token balance factory - * - * @param context the context in which sdk will be used + * Create an instance of the erc20 token balance factory */ constructor(context: Context) { super(Erc20TokenBalance, context); diff --git a/src/entities/factories/InvestmentFactory.ts b/src/entities/factories/InvestmentFactory.ts index 789d49d..fe6254d 100644 --- a/src/entities/factories/InvestmentFactory.ts +++ b/src/entities/factories/InvestmentFactory.ts @@ -103,9 +103,7 @@ export class InvestmentFactory extends Factory Date: Mon, 13 Jan 2020 13:15:55 -0300 Subject: [PATCH 17/43] docs: modify max holder count docs --- src/procedures/ModifyMaxHolderCount.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/procedures/ModifyMaxHolderCount.ts b/src/procedures/ModifyMaxHolderCount.ts index 27f8eca..ffc82a5 100644 --- a/src/procedures/ModifyMaxHolderCount.ts +++ b/src/procedures/ModifyMaxHolderCount.ts @@ -8,9 +8,18 @@ import { } from '../types'; import { PolymathError } from '../PolymathError'; +/** + * Procedure that modifies the maximum amount of token holders for an STO + */ export class ModifyMaxHolderCount extends Procedure { public type = ProcedureType.ModifyMaxHolderCount; + /** + * - Sets the cap for the amount of token holders there can be + * + * Note that this procedure will fail if the security token symbol doesn't exist + * Note that this procedure will fail if the security token has disabled the ShareholderCountRestrictions feature + */ public async prepareTransactions() { const { symbol, maxHolderCount } = this.args; const { contractWrappers } = this.context; From be89525a276ab920d4be6ad0ec3d3dae49e2024c Mon Sep 17 00:00:00 2001 From: Shuffledex Date: Mon, 13 Jan 2020 14:17:43 -0300 Subject: [PATCH 18/43] docs: modify max holder percentage docs --- src/procedures/ModifyMaxHolderPercentage.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/procedures/ModifyMaxHolderPercentage.ts b/src/procedures/ModifyMaxHolderPercentage.ts index 965b67c..bdb1513 100644 --- a/src/procedures/ModifyMaxHolderPercentage.ts +++ b/src/procedures/ModifyMaxHolderPercentage.ts @@ -8,9 +8,18 @@ import { } from '../types'; import { PolymathError } from '../PolymathError'; +/** + * Procedure that modifies the maximum percentage that an individual token holder can hold + */ export class ModifyMaxHolderPercentage extends Procedure { public type = ProcedureType.ModifyMaxHolderPercentage; + /** + * - Set a new maximum percentage of token holders there can be + * + * Note that this procedure will fail if the security token symbol doesn't exist + * Note that this procedure will fail if the security token has disabled the PercentageOwnershipRestrictions feature + */ public async prepareTransactions() { const { symbol, maxHolderPercentage } = this.args; const { contractWrappers } = this.context; From 8436e186268d0afb40aa8d390e440cb2e8c0c4ec Mon Sep 17 00:00:00 2001 From: Shuffledex Date: Mon, 13 Jan 2020 15:20:24 -0300 Subject: [PATCH 19/43] docs: transfer security tokens comments --- src/procedures/TransferSecurityTokens.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/procedures/TransferSecurityTokens.ts b/src/procedures/TransferSecurityTokens.ts index 78ff6ce..f9d4d8e 100644 --- a/src/procedures/TransferSecurityTokens.ts +++ b/src/procedures/TransferSecurityTokens.ts @@ -10,6 +10,9 @@ import { PolymathError } from '../PolymathError'; import { SecurityToken, Shareholder } from '../entities'; import { Factories } from '../Context'; +/** + * @hidden + */ export const createTransferSecurityTokensResolver = ( factories: Factories, symbol: string, @@ -34,11 +37,14 @@ export const createTransferSecurityTokensResolver = ( }; /** - * Procedure to transfer security tokens. + * Procedure that transfer security tokens */ export class TransferSecurityTokens extends Procedure { public type = ProcedureType.TransferSecurityTokens; + /** + * @hidden + */ private checkTransferStatus( statusCode: TransferStatusCode, fromAddress: string, @@ -55,6 +61,11 @@ export class TransferSecurityTokens extends Procedure Date: Tue, 14 Jan 2020 06:23:19 -0800 Subject: [PATCH 20/43] docs: properties should start with lower case --- src/entities/SimpleSto.ts | 6 +++--- src/entities/Sto.ts | 26 +++++++++++++------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/entities/SimpleSto.ts b/src/entities/SimpleSto.ts index 585c667..b388c6d 100644 --- a/src/entities/SimpleSto.ts +++ b/src/entities/SimpleSto.ts @@ -43,17 +43,17 @@ export class SimpleSto extends Sto { } /** - * Unique generated Tiered STO id + * unique generated Tiered STO id */ public uid: string; /** - * Cap of total tokens that can be sold in sto + * cap of total tokens that can be sold in sto */ public cap: BigNumber; /** - * Rate at which the tokens will be sold in sto + * rate at which the tokens will be sold in sto */ public rate: BigNumber; diff --git a/src/entities/Sto.ts b/src/entities/Sto.ts index b8d0970..c840e58 100644 --- a/src/entities/Sto.ts +++ b/src/entities/Sto.ts @@ -102,7 +102,7 @@ export abstract class Sto

extends Entity

{ public abstract uid: string; /** - * Ethereum address for the STO + * ethereum address for the STO */ public address: string; @@ -111,7 +111,7 @@ export abstract class Sto

extends Entity

{ public securityTokenId: string; /** - * Type of STO setup + * type of STO setup */ public stoType: StoType; @@ -120,57 +120,57 @@ export abstract class Sto

extends Entity

{ public endDate: Date; /** - * Wallet where funds raised will be forwarded to + * wallet where funds raised will be forwarded to */ public raisedFundsWallet: string; /** - * Wallet where unsold tokens will be returned to + * wallet where unsold tokens will be returned to */ public unsoldTokensWallet: string; /** - * Amount of funds that have been raised so far + * amount of funds that have been raised so far */ public raisedAmount: BigNumber; /** - * Total number of tokens that have been sold so far + * total number of tokens that have been sold so far */ public soldTokensAmount: BigNumber; /** - * Number of investors that have purchased tokens in the STO + * number of investors that have purchased tokens in the STO */ public investorCount: number; /** - * Valid currencies that funds can be raised in + * valid currencies that funds can be raised in */ public fundraiseCurrencies: Currency[]; /** - * Whether the STO is currently paused or not + * whether the STO is currently paused or not */ public isPaused: boolean; /** - * Whether the STO cap has been reached or not + * whether the STO cap has been reached or not */ public capReached: boolean; /** - * Whether the STO has been finalized or not + * whether the STO has been finalized or not */ public isFinalized: boolean; /** - * Whether the preissuing of tokens is allowed or not + * whether the preissuing of tokens is allowed or not */ public preIssueAllowed: boolean; /** - * Whether investments can be made on behalf of a beneficiary or not + * whether investments can be made on behalf of a beneficiary or not */ public beneficialInvestmentsAllowed: boolean; From 87eddf4f28cc90ea5eb130f18822c08cc311f7be Mon Sep 17 00:00:00 2001 From: Victor Wiebe Date: Tue, 14 Jan 2020 06:27:57 -0800 Subject: [PATCH 21/43] docs: more review comments --- src/entities/Sto.ts | 6 +++--- src/entities/TieredSto.ts | 3 --- src/types/index.ts | 2 +- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/entities/Sto.ts b/src/entities/Sto.ts index c840e58..59bf941 100644 --- a/src/entities/Sto.ts +++ b/src/entities/Sto.ts @@ -120,7 +120,7 @@ export abstract class Sto

extends Entity

{ public endDate: Date; /** - * wallet where funds raised will be forwarded to + * wallet where raised funds will be forwarded to */ public raisedFundsWallet: string; @@ -145,7 +145,7 @@ export abstract class Sto

extends Entity

{ public investorCount: number; /** - * valid currencies that funds can be raised in + * types of currency in which funds can be raised */ public fundraiseCurrencies: Currency[]; @@ -165,7 +165,7 @@ export abstract class Sto

extends Entity

{ public isFinalized: boolean; /** - * whether the preissuing of tokens is allowed or not + * whether all tokens due to be sold are issued when the STO starts. If false, the appropriate amount of tokens are issued to the buyer whenever a sale is made */ public preIssueAllowed: boolean; diff --git a/src/entities/TieredSto.ts b/src/entities/TieredSto.ts index 020d8f5..9dccb79 100644 --- a/src/entities/TieredSto.ts +++ b/src/entities/TieredSto.ts @@ -20,9 +20,6 @@ const { weiToValue } = conversionUtils; export { UniqueIdentifiers }; -/** - * Unique properties of a tier in the tiered sto - */ export interface Tier { /** * total number of tokens that are available in the tier diff --git a/src/types/index.ts b/src/types/index.ts index deff1d8..b66cbfc 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -377,7 +377,7 @@ export interface StoTier { } /** - * Unique properties of a custom currency + * Custom currency in which a Tiered STO can raise funds */ export interface CustomCurrency { /** From a47af52e950cc45489b7fb24e91299700c359192 Mon Sep 17 00:00:00 2001 From: Victor Wiebe Date: Tue, 14 Jan 2020 09:34:57 -0800 Subject: [PATCH 22/43] fix: comments from review --- src/procedures/AssignStoRole.ts | 4 +-- src/procedures/ModifyTieredStoData.ts | 4 +-- src/procedures/SetDocument.ts | 6 ++-- src/utils/__tests__/utils.ts | 47 ++++++++++++++++++++++++++- src/utils/index.ts | 31 +++++++++++------- 5 files changed, 72 insertions(+), 20 deletions(-) diff --git a/src/procedures/AssignStoRole.ts b/src/procedures/AssignStoRole.ts index b2a00e7..4a683c8 100644 --- a/src/procedures/AssignStoRole.ts +++ b/src/procedures/AssignStoRole.ts @@ -8,7 +8,7 @@ import { StoRole, } from '../types'; import { PolymathError } from '../PolymathError'; -import { isValidBytes32CompliantString } from '~/utils'; +import { checkStringLength } from '../utils'; export class AssignStoRole extends Procedure { public type = ProcedureType.AssignStoRole; @@ -67,7 +67,7 @@ export class AssignStoRole extends Procedure { }); } } else { - isValidBytes32CompliantString(description, 'description'); + checkStringLength(description, 'description'); // Delegate not found. Add them here await this.addTransaction(permissionModule.addDelegate, { tag: PolyTransactionTag.ChangePermission, diff --git a/src/procedures/ModifyTieredStoData.ts b/src/procedures/ModifyTieredStoData.ts index 19792bd..f5682e1 100644 --- a/src/procedures/ModifyTieredStoData.ts +++ b/src/procedures/ModifyTieredStoData.ts @@ -15,7 +15,7 @@ import { Currency, } from '../types'; import { PolymathError } from '../PolymathError'; -import { areSameAddress, isValidBytes32CompliantString } from '../utils'; +import { areSameAddress, checkStringLength } from '../utils'; import { SecurityToken, TieredSto } from '../entities'; import { TieredStoFactory } from '../entities/factories'; @@ -219,7 +219,7 @@ export class ModifyTieredStoData extends Procedure { public type = ProcedureType.SetDocument; @@ -32,8 +32,8 @@ export class SetDocument extends Procedure { }); } - isNotEmptyValidBytes32CompliantString(name, 'name'); - isNotEmptyValidBytes32CompliantString(documentHash, 'document hash'); + checkStringLength(name, 'name', { minLength: 1, maxLength: 32 }); + checkStringLength(documentHash, 'document hash', { minLength: 1, maxLength: 32 }); /* * Transactions diff --git a/src/utils/__tests__/utils.ts b/src/utils/__tests__/utils.ts index d320551..c3c1e83 100644 --- a/src/utils/__tests__/utils.ts +++ b/src/utils/__tests__/utils.ts @@ -1,4 +1,6 @@ -import { serialize, unserialize } from '../index'; +import { checkStringLength, serialize, unserialize } from '../index'; +import { PolymathError } from '../../PolymathError'; +import { ErrorCode } from '../../types'; describe('serialize and unserialize', () => { const entityType = 'someEntity'; @@ -31,3 +33,46 @@ describe('serialize and unserialize', () => { expect(unserialize(serialize(entityType, inversePojo1))).toEqual(pojo1); }); }); + +describe('check string length', () => { + const testVariableType = 'myVar'; + + test('checkStringLength used on a non empty string, catches error above the default 32 characters', () => { + try { + checkStringLength('0123456789012345678901234567890123456789', testVariableType); + } catch (error) { + expect(error).toEqual( + new PolymathError({ + code: ErrorCode.ProcedureValidationError, + message: `You must provide a valid ${testVariableType} up to 32 characters long`, + }) + ); + } + }); + + test('checkStringLength used on an empty string, catches error due to not meeting custom requirement of 1 - 32 characters', () => { + try { + checkStringLength('', testVariableType, { minLength: 1, maxLength: 32 }); + } catch (error) { + expect(error).toEqual( + new PolymathError({ + code: ErrorCode.ProcedureValidationError, + message: `You must provide a valid ${testVariableType} between 1 and 32 characters long`, + }) + ); + } + }); + + test('checkStringLength used on a 6 character string, catches error due to not meeting custom requirement of 1 - 5 characters', () => { + try { + checkStringLength('0123456', testVariableType, { minLength: 1, maxLength: 5 }); + } catch (error) { + expect(error).toEqual( + new PolymathError({ + code: ErrorCode.ProcedureValidationError, + message: `You must provide a valid ${testVariableType} between 1 and 5 characters long`, + }) + ); + } + }); +}); diff --git a/src/utils/index.ts b/src/utils/index.ts index fe2a801..b012115 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -50,20 +50,27 @@ export function areSameAddress(a: string, b: string) { return a.toUpperCase() === b.toUpperCase(); } -export function isValidBytes32CompliantString(value: string, variableName: string) { - if (value.length > 32) { +/** + * Check the length of a given string to ensure it meets correct bounds + * @param value - the string itself + * @param variableName - the name of the variable associated to the string itself + * @param opts - optional min and max length of the string. Defaults to a minimum of 0 (empty string) and a maximum of 32 characters + */ +export function checkStringLength( + value: string, + variableName: string, + opts?: { minLength: number | undefined; maxLength: number } +) { + const minLength = opts && opts.minLength != undefined ? opts.minLength : 0; + const maxLength = opts ? opts.maxLength : 32; + if (value.length < minLength || value.length > maxLength) { throw new PolymathError({ code: ErrorCode.ProcedureValidationError, - message: `You must provide a valid ${variableName} up to 32 characters long`, - }); - } -} - -export function isNotEmptyValidBytes32CompliantString(value: string, variableName: string) { - if (value.length < 1 || value.length > 32) { - throw new PolymathError({ - code: ErrorCode.ProcedureValidationError, - message: `You must provide a valid ${variableName} between 1 and 32 characters long`, + message: `You must provide a valid ${variableName} ${ + opts && opts.minLength != undefined + ? `between ${minLength} and ${maxLength}` + : `up to ${maxLength}` + } characters long`, }); } } From b71a7609ad1829084b595194e67fcb14f0ccff46 Mon Sep 17 00:00:00 2001 From: Victor Wiebe Date: Tue, 14 Jan 2020 10:13:09 -0800 Subject: [PATCH 23/43] docs: fix based on review comments --- src/entities/Entity.ts | 2 +- src/entities/TransactionQueue.ts | 37 +++++++++++++++---------------- src/entities/Wallet.ts | 8 +++---- src/entities/factories/Factory.ts | 17 +++++++------- src/types/index.ts | 8 +++---- 5 files changed, 36 insertions(+), 36 deletions(-) diff --git a/src/entities/Entity.ts b/src/entities/Entity.ts index 58a76e7..af693f4 100644 --- a/src/entities/Entity.ts +++ b/src/entities/Entity.ts @@ -1,5 +1,5 @@ /** - * Abstract class to create an entity with unique properties + * Represents an object or resource in the Polymath Ecosystem with its own set of properties and functionality */ export abstract class Entity { public abstract uid: string; diff --git a/src/entities/TransactionQueue.ts b/src/entities/TransactionQueue.ts index d706f4b..723a8dd 100644 --- a/src/entities/TransactionQueue.ts +++ b/src/entities/TransactionQueue.ts @@ -26,51 +26,51 @@ export class TransactionQueue { /** - * Generate an ID for a transaction + * Generate UUID for this Transaction Queue */ public static generateId() { - return serialize('transaction', { + return serialize('transactionQueue', { random: v4(), }); } /** - * Type of entity + * type of entity */ public readonly entityType: string = 'transactionQueue'; /** - * Type of procedure being run + * type of procedure being run */ public procedureType: ProcedureType; /** - * Generated transaction queue unique identifier + * generated transaction queue unique identifier */ public uid: string; /** - * Array of poly transactions + * array of poly transactions */ public transactions: PolyTransaction[]; /** - * Status of the transaction queue + * status of the transaction queue */ public status: TransactionQueueStatus = TransactionQueueStatus.Idle; /** - * Arguments provided to the transaction queue + * arguments provided to the transaction queue */ public args: Args; /** - * Optional error information + * optional error information */ public error?: Error; /** - * Associated Fees for the transaction + * total cost of running the transactions in the queue. This does not include gas */ public fees: Fees; @@ -96,11 +96,10 @@ export class TransactionQueue { } /** - * Unique generated wallet id + * unique generated wallet id */ public uid: string; /** - * Wallet address + * wallet address */ public address: string; diff --git a/src/entities/factories/Factory.ts b/src/entities/factories/Factory.ts index 60de3b6..a7bad10 100644 --- a/src/entities/factories/Factory.ts +++ b/src/entities/factories/Factory.ts @@ -20,7 +20,9 @@ export interface EntityClass { } /** - * Abstract representing a factory that will build up properties of an entity + * Factories are tasked with creating instances of their corresponding Entity and managing the internal cache for that Entity type. + * So for example, the Security Token Factory is tasked with fetching necessary data to instance a Security Token, + * as well as fetching/refreshing the internal Security Token cache */ export abstract class Factory, T extends any, U extends any> { public cache: { @@ -30,7 +32,7 @@ export abstract class Factory, T extends any, U ext public context: Context; /** - * Defined entity class + * entity class that this Factory is in charge of generating and caching */ public Entity: EntityClass; @@ -41,7 +43,6 @@ export abstract class Factory, T extends any, U ext /** * Create a factory that can generate an entity - * */ constructor(eClass: EntityClass, context: Context) { this.Entity = eClass; @@ -80,8 +81,8 @@ export abstract class Factory, T extends any, U ext /** * Get an entity from the cache. Creates it if it isn't cached, updates it if it is * - * @param uid unique identifier for the entity - * @param params constructor data for the entity + * @param uid - unique identifier for the entity + * @param params - constructor data for the entity */ public create(uid: string, params: T) { const { cache, context } = this; @@ -102,7 +103,7 @@ export abstract class Factory, T extends any, U ext /** * Fetch the data for an entity and updates its properties * - * @param uid unique identifier for the entity + * @param uid - unique identifier for the entity */ public async refresh(uid: string) { const instance = this.cache[uid]; @@ -119,8 +120,8 @@ export abstract class Factory, T extends any, U ext /** * Update an entity's properties in place * - * @param uid unique identifier for the entity - * @param params properties that should be updated + * @param uid - unique identifier for the entity + * @param params - properties that should be updated */ public async update(uid: string, params: Partial) { const instance = this.cache[uid]; diff --git a/src/types/index.ts b/src/types/index.ts index abacd9e..04a6910 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -612,7 +612,7 @@ export interface ProcedureArguments { [ProcedureType.PullDividendPayment]: PullDividendPaymentProcedureArgs; [ProcedureType.SetDividendsWallet]: SetDividendsWalletProcedureArgs; // prettier-ignore - [ProcedureType.ModifyDividendsDefaultExclusionList]: + [ProcedureType.ModifyDividendsDefaultExclusionList]: ModifyDividendsDefaultExclusionListProcedureArgs; [ProcedureType.LaunchSimpleSto]: LaunchSimpleStoProcedureArgs; [ProcedureType.LaunchTieredSto]: LaunchTieredStoProcedureArgs; @@ -662,15 +662,15 @@ export enum TransactionQueueStatus { } /** - * Represents fees in poly and optional usd + * Fees associated with running a [[TransactionQueue]] */ export interface Fees { /** - * Usd Fee + * fees expressed in USD. Can be null if the Smart Contract doesn't specify one */ usd: BigNumber | null; /** - * Poly Fee + * fees expressed in POLY */ poly: BigNumber; } From 4f325628538c06d2fd7f1793108134ecd70151e6 Mon Sep 17 00:00:00 2001 From: Victor Wiebe Date: Tue, 14 Jan 2020 10:23:12 -0800 Subject: [PATCH 24/43] docs: make specific changes based on prior reviews --- src/entities/Erc20TokenBalance.ts | 10 +++++----- src/entities/Investment.ts | 16 +++++++-------- src/entities/PolyTransaction.ts | 18 ++++++++--------- src/entities/Shareholder.ts | 20 +++++++++---------- src/entities/TaxWithholding.ts | 9 +++++---- .../factories/Erc20TokenBalanceFactory.ts | 3 +++ src/entities/factories/InvestmentFactory.ts | 3 +++ src/entities/factories/ShareholderFactory.ts | 3 +++ .../factories/TaxWithholdingFactory.ts | 3 +++ 9 files changed, 49 insertions(+), 36 deletions(-) diff --git a/src/entities/Erc20TokenBalance.ts b/src/entities/Erc20TokenBalance.ts index 5c80a08..a0c80fd 100644 --- a/src/entities/Erc20TokenBalance.ts +++ b/src/entities/Erc20TokenBalance.ts @@ -40,7 +40,7 @@ export class Erc20TokenBalance extends Entity { /** * Unserialize a serialized erc20 token balance * - * @param serialized string with erc20 token balance entity information + * @param serialized - string with erc20 token balance entity information */ public static unserialize(serialized: any) { const unserialized = unserialize(serialized); @@ -56,24 +56,24 @@ export class Erc20TokenBalance extends Entity { } /** - * Unique generated identifier for an ERC20 token balance + * unique generated identifier for an ERC20 token balance */ public uid: string; public tokenSymbol: string | null; /** - * Address of the security token + * address of the security token */ public tokenAddress: string; /** - * Wallet address of the token holder + * wallet address of the token holder */ public walletAddress: string; /** - * Total number of tokens belonging to token holder + * total number of tokens belonging to token holder */ public balance: BigNumber; diff --git a/src/entities/Investment.ts b/src/entities/Investment.ts index 8f2bcdf..1fdf42f 100644 --- a/src/entities/Investment.ts +++ b/src/entities/Investment.ts @@ -22,7 +22,7 @@ function isUniqueIdentifiers(identifiers: any): identifiers is UniqueIdentifiers } /** - * Represents information for a specific security token offering investment + * Represents constructor parameters for specific security token offering investment */ export interface Params { securityTokenSymbol: string; @@ -46,7 +46,7 @@ export class Investment extends Entity { /** * Unserialize a serialized investment entity * - * @param serialized string with investment entity information + * @param serialized - string with investment entity information */ public static unserialize(serialized: string) { const unserialized = unserialize(serialized); @@ -62,36 +62,36 @@ export class Investment extends Entity { } /** - * Unique generated identifier for an investment + * unique generated identifier for an investment */ public uid: string; public securityTokenId: string; /** - * Unique ID for the investment STO + * unique ID for the investment STO */ public stoId: string; public securityTokenSymbol: string; /** - * Wallet address of token holder + * wallet address of token holder */ public address: string; /** - * Index of the investment + * index of the investment */ public index: number; /** - * Total amount of tokens involved in the investment + * total amount of tokens involved in the investment */ public tokenAmount: BigNumber; /** - * Amount of funds used to make investment + * amount of funds used to make investment */ public investedFunds: BigNumber; diff --git a/src/entities/PolyTransaction.ts b/src/entities/PolyTransaction.ts index 47748fe..3b97e46 100644 --- a/src/entities/PolyTransaction.ts +++ b/src/entities/PolyTransaction.ts @@ -38,47 +38,47 @@ export class PolyTransaction extends E } /** - * Unique generated identifier of the poly transaction + * unique generated identifier of the poly transaction */ public uid: string; /** - * Current status of the transaction + * current status of the transaction */ public status: TransactionStatus = TransactionStatus.Idle; /** - * Queue of pending transactions + * queue of pending transactions */ public transactionQueue: TransactionQueue; /** - * Promise for the poly transaction + * promise for the poly transaction */ public promise: Promise; /** - * Optional error for the poly transaction + * optional error for the poly transaction */ public error?: PolymathError; /** - * Optional receipt for the poly transaction + * optional receipt for the poly transaction */ public receipt?: TransactionReceiptWithDecodedLogs | string; /** - * Poly transaction tag + * poly transaction tag */ public tag: PolyTransactionTag; /** - * Optional transaction hash for a poly transaction + * optional transaction hash for a poly transaction */ public txHash?: string; /** - * Transaction specification arguments + * transaction specification arguments */ public args: TransactionSpec['args']; diff --git a/src/entities/Shareholder.ts b/src/entities/Shareholder.ts index c3a715a..aad7573 100644 --- a/src/entities/Shareholder.ts +++ b/src/entities/Shareholder.ts @@ -19,7 +19,7 @@ function isUniqueIdentifiers(identifiers: any): identifiers is UniqueIdentifiers } /** - * Properties for a specific shareholder on a security token + * Constructor properties for a specific shareholder on a security token */ export interface Params { securityTokenSymbol: string; @@ -45,7 +45,7 @@ export class Shareholder extends Entity { /** * Unserialize a serialized shareholder entity * - * @param serialized string with shareholder entity information + * @param serialized - string with shareholder entity information */ public static unserialize(serialized: string) { const unserialized = unserialize(serialized); @@ -61,7 +61,7 @@ export class Shareholder extends Entity { } /** - * Unique generated id for a shareholder + * unique generated id for a shareholder */ public uid: string; @@ -70,37 +70,37 @@ export class Shareholder extends Entity { public securityTokenId: string; /** - * Date after which a shareholder can transfer tokens from their address + * date after which a shareholder can transfer tokens from their address */ public canSendAfter: Date; /** - * Date after which a shareholder can transfer tokens to their address + * date after which a shareholder can transfer tokens to their address */ public canReceiveAfter: Date; /** - * Date when kyc approval will expire + * date when kyc approval will expire */ public kycExpiry: Date; /** - * Whether shareholder is accredited or not + * whether shareholder is accredited or not */ public isAccredited: boolean; /** - * Whether shareholder can purchase from an STO or not + * whether shareholder can purchase from an STO or not */ public canBuyFromSto: boolean; /** - * Total security token balance of a shareholder + * total security token balance of a shareholder */ public balance: BigNumber; /** - * Shareholder address + * shareholder address */ public address: string; diff --git a/src/entities/TaxWithholding.ts b/src/entities/TaxWithholding.ts index 0a9bdf2..ab69d76 100644 --- a/src/entities/TaxWithholding.ts +++ b/src/entities/TaxWithholding.ts @@ -28,6 +28,7 @@ export interface Params { securityTokenSymbol: string; percentage: number; } + /** * Used to manage tax withholding amounts */ @@ -42,7 +43,7 @@ export class TaxWithholding extends Entity { /** * Unserialize a serialized entity of tax withholding information * - * @param serialized string with tax withholding information + * @param serialized - string with tax withholding information */ public static unserialize(serialized: string) { const unserialized = unserialize(serialized); @@ -58,7 +59,7 @@ export class TaxWithholding extends Entity { } /** - * Unique generated identifer for tax withholding entity + * unique generated identifer for tax withholding entity */ public uid: string; @@ -67,12 +68,12 @@ export class TaxWithholding extends Entity { public securityTokenId: string; /** - * Shareholder address for tax withholding properties + * shareholder address for tax withholding properties */ public shareholderAddress: string; /** - * Percentage of tax to be withheld + * percentage of tax to be withheld */ public percentage: number; diff --git a/src/entities/factories/Erc20TokenBalanceFactory.ts b/src/entities/factories/Erc20TokenBalanceFactory.ts index 285226c..725a838 100644 --- a/src/entities/factories/Erc20TokenBalanceFactory.ts +++ b/src/entities/factories/Erc20TokenBalanceFactory.ts @@ -10,6 +10,9 @@ export class Erc20TokenBalanceFactory extends Factory< Params, UniqueIdentifiers > { + /** + * @hidden + */ protected generateProperties = async (uid: string) => { const { tokenAddress, walletAddress } = Erc20TokenBalance.unserialize(uid); diff --git a/src/entities/factories/InvestmentFactory.ts b/src/entities/factories/InvestmentFactory.ts index fe6254d..e48cfb0 100644 --- a/src/entities/factories/InvestmentFactory.ts +++ b/src/entities/factories/InvestmentFactory.ts @@ -20,6 +20,9 @@ const { weiToValue } = conversionUtils; * Factory generates information for an investment entity */ export class InvestmentFactory extends Factory { + /** + * @hidden + */ protected generateProperties = async (uid: string) => { const { stoId, securityTokenId, index } = Investment.unserialize(uid); diff --git a/src/entities/factories/ShareholderFactory.ts b/src/entities/factories/ShareholderFactory.ts index 20ed010..4ba2faf 100644 --- a/src/entities/factories/ShareholderFactory.ts +++ b/src/entities/factories/ShareholderFactory.ts @@ -10,6 +10,9 @@ import { Shareholder, Params, UniqueIdentifiers } from '../Shareholder'; * Factory generates information for a shareholder entity */ export class ShareholderFactory extends Factory { + /** + * @hidden + */ protected generateProperties = async (uid: string) => { const { context: { contractWrappers }, diff --git a/src/entities/factories/TaxWithholdingFactory.ts b/src/entities/factories/TaxWithholdingFactory.ts index f23a9a2..58da97b 100644 --- a/src/entities/factories/TaxWithholdingFactory.ts +++ b/src/entities/factories/TaxWithholdingFactory.ts @@ -10,6 +10,9 @@ import { TaxWithholding, Params, UniqueIdentifiers } from '../TaxWithholding'; * Factory generates information for a tax withholding entity */ export class TaxWithholdingFactory extends Factory { + /** + * @hidden + */ protected generateProperties = async (uid: string) => { const { context: { From 80ccf9d4e15ac4d1a29a0bd0499b79fe82b9e94b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jerem=C3=ADas=20D=C3=ADaz?= Date: Tue, 14 Jan 2020 15:55:29 -0300 Subject: [PATCH 25/43] Update src/entities/Sto.ts docs: fix grammatical error --- src/entities/Sto.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/entities/Sto.ts b/src/entities/Sto.ts index 59bf941..694074b 100644 --- a/src/entities/Sto.ts +++ b/src/entities/Sto.ts @@ -165,7 +165,7 @@ export abstract class Sto

extends Entity

{ public isFinalized: boolean; /** - * whether all tokens due to be sold are issued when the STO starts. If false, the appropriate amount of tokens are issued to the buyer whenever a sale is made + * whether all tokens due to be sold are issued when the STO starts. If false, the appropriate amount of tokens is issued to the buyer whenever a sale is made */ public preIssueAllowed: boolean; From 49a82a321c78e8055348110f91f85fc8ff732fc5 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Tue, 14 Jan 2020 19:05:11 +0000 Subject: [PATCH 26/43] chore(release): 2.0.1-beta.94 [skip ci] ## [2.0.1-beta.94](https://github.com/PolymathNetwork/polymath-sdk/compare/v2.0.1-beta.93@beta...v2.0.1-beta.94@beta) (2020-01-14) ### Bug Fixes * changes caught by Fede ([c255e20](https://github.com/PolymathNetwork/polymath-sdk/commit/c255e20)) * documentation issues from review ([46748e0](https://github.com/PolymathNetwork/polymath-sdk/commit/46748e0)) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 54cd8a1..746864c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@polymathnetwork/sdk", - "version": "2.0.1-beta.93", + "version": "2.0.1-beta.94", "description": "A Javascript SDK for interacting with the Polymath network for the browser and Node.js", "bugs": { "url": "https://github.com/PolymathNetwork/polymath-sdk/issues" From 140fbbe5d0730771ed34e9bf66c3145166ac9033 Mon Sep 17 00:00:00 2001 From: Federico Elgarte Date: Tue, 14 Jan 2020 16:18:18 -0300 Subject: [PATCH 27/43] Update src/procedures/ModifyMaxHolderCount.ts Co-Authored-By: Victor Vicente --- src/procedures/ModifyMaxHolderCount.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/procedures/ModifyMaxHolderCount.ts b/src/procedures/ModifyMaxHolderCount.ts index ffc82a5..0c8f5e6 100644 --- a/src/procedures/ModifyMaxHolderCount.ts +++ b/src/procedures/ModifyMaxHolderCount.ts @@ -9,7 +9,7 @@ import { import { PolymathError } from '../PolymathError'; /** - * Procedure that modifies the maximum amount of token holders for an STO + * Procedure that modifies the maximum amount of holders for the security token */ export class ModifyMaxHolderCount extends Procedure { public type = ProcedureType.ModifyMaxHolderCount; From 92b4b8cf3c75aca66b05babc442ac74236cd065d Mon Sep 17 00:00:00 2001 From: Federico Elgarte Date: Tue, 14 Jan 2020 16:18:25 -0300 Subject: [PATCH 28/43] Update src/procedures/ModifyMaxHolderCount.ts Co-Authored-By: Victor Vicente --- src/procedures/ModifyMaxHolderCount.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/procedures/ModifyMaxHolderCount.ts b/src/procedures/ModifyMaxHolderCount.ts index 0c8f5e6..3b126f2 100644 --- a/src/procedures/ModifyMaxHolderCount.ts +++ b/src/procedures/ModifyMaxHolderCount.ts @@ -15,7 +15,7 @@ export class ModifyMaxHolderCount extends Procedure Date: Tue, 14 Jan 2020 11:38:30 -0800 Subject: [PATCH 29/43] fix: comments based on review --- src/utils/__tests__/utils.ts | 8 ++++---- src/utils/index.ts | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/utils/__tests__/utils.ts b/src/utils/__tests__/utils.ts index c3c1e83..162f039 100644 --- a/src/utils/__tests__/utils.ts +++ b/src/utils/__tests__/utils.ts @@ -34,10 +34,10 @@ describe('serialize and unserialize', () => { }); }); -describe('check string length', () => { +describe('checkStringLength', () => { const testVariableType = 'myVar'; - test('checkStringLength used on a non empty string, catches error above the default 32 characters', () => { + test('throws an error when the string length exceeds the 32 character default', () => { try { checkStringLength('0123456789012345678901234567890123456789', testVariableType); } catch (error) { @@ -50,7 +50,7 @@ describe('check string length', () => { } }); - test('checkStringLength used on an empty string, catches error due to not meeting custom requirement of 1 - 32 characters', () => { + test('throws an error when the string length is lower than the supplied minimum', () => { try { checkStringLength('', testVariableType, { minLength: 1, maxLength: 32 }); } catch (error) { @@ -63,7 +63,7 @@ describe('check string length', () => { } }); - test('checkStringLength used on a 6 character string, catches error due to not meeting custom requirement of 1 - 5 characters', () => { + test('throws an error when the string length is higher than the supplied maximum', () => { try { checkStringLength('0123456', testVariableType, { minLength: 1, maxLength: 5 }); } catch (error) { diff --git a/src/utils/index.ts b/src/utils/index.ts index b012115..eab7a1a 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -52,6 +52,7 @@ export function areSameAddress(a: string, b: string) { /** * Check the length of a given string to ensure it meets correct bounds + * * @param value - the string itself * @param variableName - the name of the variable associated to the string itself * @param opts - optional min and max length of the string. Defaults to a minimum of 0 (empty string) and a maximum of 32 characters From 4663fbba329a023025f88d441d1e68207dc9ebda Mon Sep 17 00:00:00 2001 From: Victor Wiebe Date: Tue, 14 Jan 2020 12:16:05 -0800 Subject: [PATCH 30/43] refactor: checking string lengths now working under better logic --- src/utils/index.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/utils/index.ts b/src/utils/index.ts index eab7a1a..24eee80 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -60,17 +60,14 @@ export function areSameAddress(a: string, b: string) { export function checkStringLength( value: string, variableName: string, - opts?: { minLength: number | undefined; maxLength: number } + opts: { minLength?: number; maxLength: number } = { maxLength: 32 } ) { - const minLength = opts && opts.minLength != undefined ? opts.minLength : 0; - const maxLength = opts ? opts.maxLength : 32; + const { minLength = 0, maxLength } = opts; if (value.length < minLength || value.length > maxLength) { throw new PolymathError({ code: ErrorCode.ProcedureValidationError, message: `You must provide a valid ${variableName} ${ - opts && opts.minLength != undefined - ? `between ${minLength} and ${maxLength}` - : `up to ${maxLength}` + opts.minLength != undefined ? `between ${minLength} and ${maxLength}` : `up to ${maxLength}` } characters long`, }); } From 34e0981d5a7a55d1f28b17a390f296130edb4627 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jerem=C3=ADas=20D=C3=ADaz?= Date: Tue, 14 Jan 2020 18:17:45 -0300 Subject: [PATCH 31/43] docs: delete extra space --- src/entities/TransactionQueue.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/entities/TransactionQueue.ts b/src/entities/TransactionQueue.ts index 723a8dd..3cbc350 100644 --- a/src/entities/TransactionQueue.ts +++ b/src/entities/TransactionQueue.ts @@ -97,7 +97,7 @@ export class TransactionQueue Date: Tue, 14 Jan 2020 18:17:57 -0300 Subject: [PATCH 32/43] docs: add missing comma --- src/entities/factories/Factory.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/entities/factories/Factory.ts b/src/entities/factories/Factory.ts index a7bad10..b4c8338 100644 --- a/src/entities/factories/Factory.ts +++ b/src/entities/factories/Factory.ts @@ -21,7 +21,7 @@ export interface EntityClass { /** * Factories are tasked with creating instances of their corresponding Entity and managing the internal cache for that Entity type. - * So for example, the Security Token Factory is tasked with fetching necessary data to instance a Security Token, + * So, for example, the Security Token Factory is tasked with fetching necessary data to instance a Security Token, * as well as fetching/refreshing the internal Security Token cache */ export abstract class Factory, T extends any, U extends any> { From 95b176b4dde9f78a617b46dbb22de9edaf5bb207 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Tue, 14 Jan 2020 21:23:04 +0000 Subject: [PATCH 33/43] chore(release): 2.0.1-beta.95 [skip ci] ## [2.0.1-beta.95](https://github.com/PolymathNetwork/polymath-sdk/compare/v2.0.1-beta.94@beta...v2.0.1-beta.95@beta) (2020-01-14) ### Bug Fixes * comments based on review ([73f2acf](https://github.com/PolymathNetwork/polymath-sdk/commit/73f2acf)) * comments from review ([a47af52](https://github.com/PolymathNetwork/polymath-sdk/commit/a47af52)) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 746864c..1a67795 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@polymathnetwork/sdk", - "version": "2.0.1-beta.94", + "version": "2.0.1-beta.95", "description": "A Javascript SDK for interacting with the Polymath network for the browser and Node.js", "bugs": { "url": "https://github.com/PolymathNetwork/polymath-sdk/issues" From 8962561ca9f3f58a130e24f47acc73addbe37fbc Mon Sep 17 00:00:00 2001 From: Shuffledex Date: Wed, 15 Jan 2020 09:33:32 -0300 Subject: [PATCH 34/43] fix: comments improvements --- src/procedures/ModifyMaxHolderPercentage.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/procedures/ModifyMaxHolderPercentage.ts b/src/procedures/ModifyMaxHolderPercentage.ts index bdb1513..ecec7c1 100644 --- a/src/procedures/ModifyMaxHolderPercentage.ts +++ b/src/procedures/ModifyMaxHolderPercentage.ts @@ -15,10 +15,11 @@ export class ModifyMaxHolderPercentage extends Procedure Date: Wed, 15 Jan 2020 09:34:49 -0300 Subject: [PATCH 35/43] fix: add security token reference --- src/procedures/ModifyMaxHolderPercentage.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/procedures/ModifyMaxHolderPercentage.ts b/src/procedures/ModifyMaxHolderPercentage.ts index ecec7c1..592f4c3 100644 --- a/src/procedures/ModifyMaxHolderPercentage.ts +++ b/src/procedures/ModifyMaxHolderPercentage.ts @@ -15,7 +15,7 @@ export class ModifyMaxHolderPercentage extends Procedure Date: Wed, 15 Jan 2020 09:42:04 -0300 Subject: [PATCH 36/43] Update src/procedures/TransferSecurityTokens.ts Co-Authored-By: Victor Vicente --- src/procedures/TransferSecurityTokens.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/procedures/TransferSecurityTokens.ts b/src/procedures/TransferSecurityTokens.ts index f9d4d8e..048ca7e 100644 --- a/src/procedures/TransferSecurityTokens.ts +++ b/src/procedures/TransferSecurityTokens.ts @@ -62,7 +62,7 @@ export class TransferSecurityTokens extends Procedure Date: Wed, 15 Jan 2020 09:49:51 -0300 Subject: [PATCH 37/43] fix: feedback improvements --- src/procedures/TransferSecurityTokens.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/procedures/TransferSecurityTokens.ts b/src/procedures/TransferSecurityTokens.ts index 048ca7e..13cdc45 100644 --- a/src/procedures/TransferSecurityTokens.ts +++ b/src/procedures/TransferSecurityTokens.ts @@ -62,7 +62,8 @@ export class TransferSecurityTokens extends Procedure Date: Wed, 15 Jan 2020 09:50:13 -0300 Subject: [PATCH 38/43] fix: remove point --- src/procedures/TransferSecurityTokens.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/procedures/TransferSecurityTokens.ts b/src/procedures/TransferSecurityTokens.ts index 13cdc45..e482a00 100644 --- a/src/procedures/TransferSecurityTokens.ts +++ b/src/procedures/TransferSecurityTokens.ts @@ -62,7 +62,7 @@ export class TransferSecurityTokens extends Procedure Date: Wed, 15 Jan 2020 06:22:44 -0800 Subject: [PATCH 39/43] docs: fix review comments --- src/entities/Erc20TokenBalance.ts | 10 +++---- src/entities/Investment.ts | 22 +++++++------- src/entities/PolyTransaction.ts | 18 +++++------ src/entities/Shareholder.ts | 30 +++++++++---------- src/entities/TaxWithholding.ts | 13 ++++---- .../factories/Erc20TokenBalanceFactory.ts | 4 +-- src/entities/factories/InvestmentFactory.ts | 4 +-- src/entities/factories/ShareholderFactory.ts | 4 +-- .../factories/TaxWithholdingFactory.ts | 4 +-- 9 files changed, 53 insertions(+), 56 deletions(-) diff --git a/src/entities/Erc20TokenBalance.ts b/src/entities/Erc20TokenBalance.ts index a0c80fd..d2a4ecb 100644 --- a/src/entities/Erc20TokenBalance.ts +++ b/src/entities/Erc20TokenBalance.ts @@ -5,7 +5,7 @@ import { PolymathError } from '../PolymathError'; import { ErrorCode } from '../types'; /** - * Unique properties to identify an erc20 token holder + * Properties that uniquely identify an ERC20 token balance */ export interface UniqueIdentifiers { tokenAddress: string; @@ -19,7 +19,7 @@ function isUniqueIdentifiers(identifiers: any): identifiers is UniqueIdentifiers } /** - * Unique properties including information for an erc20 token holders balance + * Constructor parameters */ export interface Params { tokenSymbol: string | null; @@ -27,7 +27,7 @@ export interface Params { } /** - * Used to manage erc20 token holder balances + * Used to manage a ERC20 token balance */ export class Erc20TokenBalance extends Entity { public static generateId({ tokenAddress, walletAddress }: UniqueIdentifiers) { @@ -63,7 +63,7 @@ export class Erc20TokenBalance extends Entity { public tokenSymbol: string | null; /** - * address of the security token + * address of the ERC20 token */ public tokenAddress: string; @@ -78,7 +78,7 @@ export class Erc20TokenBalance extends Entity { public balance: BigNumber; /** - * Create an entity instance with erc20 token holder balance + * Create an ERC20 Token balance instance */ constructor(params: Params & UniqueIdentifiers) { super(); diff --git a/src/entities/Investment.ts b/src/entities/Investment.ts index 1fdf42f..a7bf5d5 100644 --- a/src/entities/Investment.ts +++ b/src/entities/Investment.ts @@ -5,7 +5,7 @@ import { PolymathError } from '../PolymathError'; import { ErrorCode } from '../types'; /** - * Properties unique to a shareholder for a specific STO investment + * Properties that uniquely identify an Investment */ export interface UniqueIdentifiers { securityTokenId: string; @@ -22,7 +22,7 @@ function isUniqueIdentifiers(identifiers: any): identifiers is UniqueIdentifiers } /** - * Represents constructor parameters for specific security token offering investment + * Constructor parameters */ export interface Params { securityTokenSymbol: string; @@ -32,7 +32,7 @@ export interface Params { } /** - * Used to manage an investment in a security token + * Used to manage an Investment in a Security Token Offering */ export class Investment extends Entity { public static generateId({ securityTokenId, stoId, index }: UniqueIdentifiers) { @@ -44,9 +44,9 @@ export class Investment extends Entity { } /** - * Unserialize a serialized investment entity + * Unserialize a serialized Investment entity * - * @param serialized - string with investment entity information + * @param serialized - string with Investment entity information */ public static unserialize(serialized: string) { const unserialized = unserialize(serialized); @@ -62,14 +62,14 @@ export class Investment extends Entity { } /** - * unique generated identifier for an investment + * unique generated identifier for an Investment */ public uid: string; public securityTokenId: string; /** - * unique ID for the investment STO + * unique ID for the Investment */ public stoId: string; @@ -81,22 +81,22 @@ export class Investment extends Entity { public address: string; /** - * index of the investment + * index of the Investment */ public index: number; /** - * total amount of tokens involved in the investment + * total amount of tokens involved in the Investment */ public tokenAmount: BigNumber; /** - * amount of funds used to make investment + * amount of funds used to make Investment */ public investedFunds: BigNumber; /** - * Create an investment instance + * Create an Investment instance */ constructor(params: Params & UniqueIdentifiers) { super(); diff --git a/src/entities/PolyTransaction.ts b/src/entities/PolyTransaction.ts index 3b97e46..2319316 100644 --- a/src/entities/PolyTransaction.ts +++ b/src/entities/PolyTransaction.ts @@ -28,7 +28,7 @@ const mapValuesDeep = ( // TODO @monitz87: Make properties private where appliccable /** - * Class to manage poly transactions to interact with blockchain extrinsics + * Wrapper class for a Polymath Transaction */ export class PolyTransaction extends Entity { public static generateId() { @@ -48,37 +48,37 @@ export class PolyTransaction extends E public status: TransactionStatus = TransactionStatus.Idle; /** - * queue of pending transactions + * transaction queue to which this transaction belongs */ public transactionQueue: TransactionQueue; /** - * promise for the poly transaction + * internal promise that resolves when the transaction has finished running */ public promise: Promise; /** - * optional error for the poly transaction + * stores errors thrown while running the transaction (if any) */ public error?: PolymathError; /** - * optional receipt for the poly transaction + * stores the transaction receipt (if successful) */ public receipt?: TransactionReceiptWithDecodedLogs | string; /** - * poly transaction tag + * type of transaction represented by this instance for display purposes */ public tag: PolyTransactionTag; /** - * optional transaction hash for a poly transaction + * transaction hash (available after running) */ public txHash?: string; /** - * transaction specification arguments + * arguments with which the transaction will be called */ public args: TransactionSpec['args']; @@ -160,7 +160,7 @@ export class PolyTransaction extends E } /** - * Run the poly tranasaction and update a transaction status + * Run the poly transaction and update the transaction status */ public async run() { try { diff --git a/src/entities/Shareholder.ts b/src/entities/Shareholder.ts index aad7573..e9b7e5f 100644 --- a/src/entities/Shareholder.ts +++ b/src/entities/Shareholder.ts @@ -5,7 +5,7 @@ import { PolymathError } from '../PolymathError'; import { ErrorCode } from '../types'; /** - * Basic properties of a unique shareholder for a specific security token + * Properties that uniquely identify a Shareholder of a specific Security Token */ export interface UniqueIdentifiers { securityTokenId: string; @@ -19,7 +19,7 @@ function isUniqueIdentifiers(identifiers: any): identifiers is UniqueIdentifiers } /** - * Constructor properties for a specific shareholder on a security token + * Constructor parameters */ export interface Params { securityTokenSymbol: string; @@ -32,7 +32,7 @@ export interface Params { } /** - * Used to manage a shareholder + * Used to manage a Shareholder */ export class Shareholder extends Entity { public static generateId({ securityTokenId, address }: UniqueIdentifiers) { @@ -43,9 +43,9 @@ export class Shareholder extends Entity { } /** - * Unserialize a serialized shareholder entity + * Unserialize a serialized Shareholder entity * - * @param serialized - string with shareholder entity information + * @param serialized - string with Shareholder entity information */ public static unserialize(serialized: string) { const unserialized = unserialize(serialized); @@ -61,7 +61,7 @@ export class Shareholder extends Entity { } /** - * unique generated id for a shareholder + * unique generated id for a Shareholder */ public uid: string; @@ -70,42 +70,42 @@ export class Shareholder extends Entity { public securityTokenId: string; /** - * date after which a shareholder can transfer tokens from their address + * date after which a Shareholder can transfer tokens from their address */ public canSendAfter: Date; /** - * date after which a shareholder can transfer tokens to their address + * date after which a Shareholder can transfer tokens to their address */ public canReceiveAfter: Date; /** - * date when kyc approval will expire + * date when the Shareholder's KYC will expire */ public kycExpiry: Date; /** - * whether shareholder is accredited or not + * whether the Shareholder is accredited or not */ public isAccredited: boolean; /** - * whether shareholder can purchase from an STO or not + * whether the Shareholder can purchase from an STO or not */ public canBuyFromSto: boolean; /** - * total security token balance of a shareholder + * total Security Token balance of the Shareholder */ public balance: BigNumber; /** - * shareholder address + * wallet address */ public address: string; /** - * Create a new shareholder instance + * Create a new Shareholder instance */ constructor(params: Params & UniqueIdentifiers) { super(); @@ -138,7 +138,7 @@ export class Shareholder extends Entity { } /** - * Checks if this shareholder's KYC has been manually revoked + * Checks if this Shareholder's KYC has been manually revoked */ public isRevoked() { const { canReceiveAfter, canSendAfter, kycExpiry } = this; diff --git a/src/entities/TaxWithholding.ts b/src/entities/TaxWithholding.ts index ab69d76..b4742c5 100644 --- a/src/entities/TaxWithholding.ts +++ b/src/entities/TaxWithholding.ts @@ -4,7 +4,7 @@ import { ErrorCode } from '../types'; import { PolymathError } from '../PolymathError'; /** - * Properties unique to tax withholding properties for a specific security token holder + * Properties that uniquely identify a Tax Withholding percentage */ export interface UniqueIdentifiers { securityTokenId: string; @@ -22,7 +22,7 @@ function isUniqueIdentifiers(identifiers: any): identifiers is UniqueIdentifiers } /** - * Unique properties for tax withholding of a security token + * Constructor parameters */ export interface Params { securityTokenSymbol: string; @@ -30,7 +30,7 @@ export interface Params { } /** - * Used to manage tax withholding amounts + * Represents the percentage that should be withheld from a Shareholder's dividend payment for tax purposes */ export class TaxWithholding extends Entity { public static generateId({ securityTokenId, shareholderAddress }: UniqueIdentifiers) { @@ -67,18 +67,15 @@ export class TaxWithholding extends Entity { public securityTokenId: string; - /** - * shareholder address for tax withholding properties - */ public shareholderAddress: string; /** - * percentage of tax to be withheld + * percentage of tax to be withheld (0 to 1) */ public percentage: number; /** - * Create a new tax withholding information instance + * Create a new tax withholding instance */ constructor(params: Params & UniqueIdentifiers) { super(); diff --git a/src/entities/factories/Erc20TokenBalanceFactory.ts b/src/entities/factories/Erc20TokenBalanceFactory.ts index 725a838..1c827a5 100644 --- a/src/entities/factories/Erc20TokenBalanceFactory.ts +++ b/src/entities/factories/Erc20TokenBalanceFactory.ts @@ -3,7 +3,7 @@ import { Context } from '../../Context'; import { Erc20TokenBalance, Params, UniqueIdentifiers } from '../Erc20TokenBalance'; /** - * Factory generates information for an erc20 token balance + * Factory generates information for an ERC20 Token Balance */ export class Erc20TokenBalanceFactory extends Factory< Erc20TokenBalance, @@ -28,7 +28,7 @@ export class Erc20TokenBalanceFactory extends Factory< }; /** - * Create an instance of the erc20 token balance factory + * Create an instance of the ERC20 Token Balance Factory */ constructor(context: Context) { super(Erc20TokenBalance, context); diff --git a/src/entities/factories/InvestmentFactory.ts b/src/entities/factories/InvestmentFactory.ts index e48cfb0..54b1e0f 100644 --- a/src/entities/factories/InvestmentFactory.ts +++ b/src/entities/factories/InvestmentFactory.ts @@ -17,7 +17,7 @@ import { PolymathError } from '../../PolymathError'; const { weiToValue } = conversionUtils; /** - * Factory generates information for an investment entity + * Factory generates information for an Investment entity */ export class InvestmentFactory extends Factory { /** @@ -106,7 +106,7 @@ export class InvestmentFactory extends Factory { /** @@ -61,7 +61,7 @@ export class ShareholderFactory extends Factory { /** @@ -71,7 +71,7 @@ export class TaxWithholdingFactory extends Factory Date: Wed, 15 Jan 2020 14:54:38 +0000 Subject: [PATCH 40/43] chore(release): 2.0.1-beta.96 [skip ci] ## [2.0.1-beta.96](https://github.com/PolymathNetwork/polymath-sdk/compare/v2.0.1-beta.95@beta...v2.0.1-beta.96@beta) (2020-01-15) ### Bug Fixes * use rimraf to assure cross platform compatibility ([941fb82](https://github.com/PolymathNetwork/polymath-sdk/commit/941fb82)) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6d2451e..0286ad3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@polymathnetwork/sdk", - "version": "2.0.1-beta.95", + "version": "2.0.1-beta.96", "description": "A Javascript SDK for interacting with the Polymath network for the browser and Node.js", "bugs": { "url": "https://github.com/PolymathNetwork/polymath-sdk/issues" From f58c201fb70b7cba9d240874926c18280eaa0783 Mon Sep 17 00:00:00 2001 From: Federico Elgarte Date: Wed, 15 Jan 2020 14:39:20 -0300 Subject: [PATCH 41/43] Update src/procedures/ModifyMaxHolderPercentage.ts Co-Authored-By: Victor Vicente --- src/procedures/ModifyMaxHolderPercentage.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/procedures/ModifyMaxHolderPercentage.ts b/src/procedures/ModifyMaxHolderPercentage.ts index 592f4c3..95227a2 100644 --- a/src/procedures/ModifyMaxHolderPercentage.ts +++ b/src/procedures/ModifyMaxHolderPercentage.ts @@ -15,7 +15,7 @@ export class ModifyMaxHolderPercentage extends Procedure Date: Wed, 15 Jan 2020 17:54:20 +0000 Subject: [PATCH 42/43] chore(release): 2.0.1-beta.97 [skip ci] ## [2.0.1-beta.97](https://github.com/PolymathNetwork/polymath-sdk/compare/v2.0.1-beta.96@beta...v2.0.1-beta.97@beta) (2020-01-15) ### Bug Fixes * add security token reference ([05f81d9](https://github.com/PolymathNetwork/polymath-sdk/commit/05f81d9)) * comments improvements ([8962561](https://github.com/PolymathNetwork/polymath-sdk/commit/8962561)) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0286ad3..9e5f957 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@polymathnetwork/sdk", - "version": "2.0.1-beta.96", + "version": "2.0.1-beta.97", "description": "A Javascript SDK for interacting with the Polymath network for the browser and Node.js", "bugs": { "url": "https://github.com/PolymathNetwork/polymath-sdk/issues" From 326ff979bb0563fa36e66aaf1feeb65b1b270b33 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Wed, 15 Jan 2020 20:23:38 +0000 Subject: [PATCH 43/43] chore(release): 2.0.1-beta.98 [skip ci] ## [2.0.1-beta.98](https://github.com/PolymathNetwork/polymath-sdk/compare/v2.0.1-beta.97@beta...v2.0.1-beta.98@beta) (2020-01-15) ### Bug Fixes * feedback improvements ([1a298b4](https://github.com/PolymathNetwork/polymath-sdk/commit/1a298b4)) * remove point ([df0d2e1](https://github.com/PolymathNetwork/polymath-sdk/commit/df0d2e1)) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9e5f957..c3d63c3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@polymathnetwork/sdk", - "version": "2.0.1-beta.97", + "version": "2.0.1-beta.98", "description": "A Javascript SDK for interacting with the Polymath network for the browser and Node.js", "bugs": { "url": "https://github.com/PolymathNetwork/polymath-sdk/issues"