Skip to content
This repository has been archived by the owner on Jul 6, 2022. It is now read-only.

Commit

Permalink
Merge d660e61 into 063851e
Browse files Browse the repository at this point in the history
  • Loading branch information
VictorVicente committed Sep 24, 2019
2 parents 063851e + d660e61 commit cdff881
Show file tree
Hide file tree
Showing 151 changed files with 14,108 additions and 8,768 deletions.
2 changes: 2 additions & 0 deletions .eslintrc.js
Expand Up @@ -23,6 +23,8 @@ module.exports = {
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-namespace': 'off',
'@typescript-eslint/no-empty-interface': 'off',
'@typescript-eslint/camelcase': 'off',
'@typescript-eslint/class-name-casing': 'off',
"import/prefer-default-export": 'off',
'jest/expect-expect': 'error',
'jest/no-empty-title': 'warn',
Expand Down
108 changes: 0 additions & 108 deletions examples/addInvestorToWhitelist.ts

This file was deleted.

39 changes: 39 additions & 0 deletions examples/addInvestorsToWhitelist.ts
@@ -0,0 +1,39 @@
import { PolymathAPI, ModuleName, TransactionParams } from '../src';
import { moduleInstancesLookup } from './modules';
import { GeneralTransferManagerEvents_3_0_0 } from '@polymathnetwork/abi-wrappers';

/**
* Adds investors to a security token's whitelist. Requires that a valid security token has been generated previously.
* @param polymathAPI Reference to polymathAPI instance.
* @param ticker Ticker of the Security Tokens
* @param modifyKYCDataMultiParams Investors KYC Data Params
*/
export const addInvestorsToWhitelist = async (
polymathAPI: PolymathAPI,
ticker: string,
modifyKYCDataMultiParams: TransactionParams.GeneralTransferManager.ModifyKYCDataMulti,
) => {
// Get general TM module instance
const generalTM = (await moduleInstancesLookup(polymathAPI, {
ticker,
moduleName: ModuleName.GeneralTransferManager,
}))[0];

// Subscribe to event
await generalTM.subscribeAsync({
eventName: GeneralTransferManagerEvents_3_0_0.ModifyKYCData,
indexFilterValues: {},
callback: async (error: any, log: any) => {
if (error) {
console.log(error);
} else {
console.log('Whitelist modified successfully', log);
}
},
});

// Publish kyc data to whitelist in general transfer manager
await generalTM.modifyKYCDataMulti(modifyKYCDataMultiParams);

console.log('KYC data:', await generalTM.getAllKYCData());
};
4 changes: 2 additions & 2 deletions examples/blacklistTransferManager.ts
Expand Up @@ -2,7 +2,7 @@ import { RedundantSubprovider, RPCSubprovider, Web3ProviderEngine } from '@0x/su
import ModuleFactoryWrapper from '../src/contract_wrappers/modules/module_factory_wrapper';
import { ApiConstructorParams, PolymathAPI } from '../src/PolymathAPI';
import { ModuleName, ModuleType } from '../src';
import { BigNumber, ModuleRegistryEvents, BlacklistTransferManagerEvents } from '@polymathnetwork/abi-wrappers';
import { BigNumber, BlacklistTransferManagerEvents_3_0_0 } from '@polymathnetwork/abi-wrappers';

// This file acts as a valid sandbox for using a blacklist restriction transfer manager module on an unlocked node (like ganache)
window.addEventListener('load', async () => {
Expand Down Expand Up @@ -123,7 +123,7 @@ window.addEventListener('load', async () => {

// Subscribe to event of addblacklisttype
await blacklistTM.subscribeAsync({
eventName: BlacklistTransferManagerEvents.AddBlacklistType,
eventName: BlacklistTransferManagerEvents_3_0_0.AddBlacklistType,
indexFilterValues: {},
callback: async (error, log) => {
if (error) {
Expand Down
7 changes: 4 additions & 3 deletions examples/cappedSTO.ts
@@ -1,5 +1,5 @@
import { RedundantSubprovider, RPCSubprovider, Web3ProviderEngine } from '@0x/subproviders';
import { ModuleRegistryEvents, BigNumber, CappedSTOEvents } from '@polymathnetwork/abi-wrappers';
import { ModuleRegistryEvents_3_0_0, BigNumber, CappedSTOEvents_3_0_0 } from '@polymathnetwork/abi-wrappers';
import ModuleFactoryWrapper from '../src/contract_wrappers/modules/module_factory_wrapper';
import { ApiConstructorParams, PolymathAPI } from '../src/PolymathAPI';
import { CappedSTOFundRaiseType, ModuleName, ModuleType } from '../src';
Expand Down Expand Up @@ -92,7 +92,7 @@ window.addEventListener('load', async () => {
});

await polymathAPI.moduleRegistry.subscribeAsync({
eventName: ModuleRegistryEvents.ModuleRegistered,
eventName: ModuleRegistryEvents_3_0_0.ModuleRegistered,
indexFilterValues: {},
callback: async (error, log) => {
if (error) {
Expand Down Expand Up @@ -136,6 +136,7 @@ window.addEventListener('load', async () => {
rate: new BigNumber(10),
fundRaiseType: CappedSTOFundRaiseType.ETH,
fundsReceiver: await polymathAPI.getAccount(),
treasuryWallet: myAddress
},
});

Expand All @@ -156,7 +157,7 @@ window.addEventListener('load', async () => {

// Subscribe to event of token purchase
await cappedSTO.subscribeAsync({
eventName: CappedSTOEvents.TokenPurchase,
eventName: CappedSTOEvents_3_0_0.TokenPurchase,
indexFilterValues: {},
callback: async (error, log) => {
if (error) {
Expand Down
6 changes: 3 additions & 3 deletions examples/countTransferManager.ts
@@ -1,5 +1,5 @@
import { RedundantSubprovider, RPCSubprovider, Web3ProviderEngine } from '@0x/subproviders';
import { CountTransferManagerEvents, BigNumber } from '@polymathnetwork/abi-wrappers';
import { CountTransferManagerEvents_3_0_0, BigNumber } from '@polymathnetwork/abi-wrappers';
import ModuleFactoryWrapper from '../src/contract_wrappers/modules/module_factory_wrapper';
import { ApiConstructorParams, PolymathAPI } from '../src/PolymathAPI';
import { bytes32ToString } from '../src/utils/convert';
Expand Down Expand Up @@ -156,9 +156,9 @@ window.addEventListener('load', async () => {

// Subscribe to event of modify holder count
await countTM.subscribeAsync({
eventName: CountTransferManagerEvents.ModifyHolderCount,
eventName: CountTransferManagerEvents_3_0_0.ModifyHolderCount,
indexFilterValues: {},
callback: async (error, log) => {
callback: async (error: any, log: any) => {
if (error) {
console.log(error);
} else {
Expand Down
4 changes: 2 additions & 2 deletions examples/erc20Dividend.ts
@@ -1,5 +1,5 @@
import { RedundantSubprovider, RPCSubprovider, Web3ProviderEngine } from '@0x/subproviders';
import { ERC20DividendCheckpointEvents, BigNumber } from '@polymathnetwork/abi-wrappers';
import { ERC20DividendCheckpointEvents_3_0_0, BigNumber } from '@polymathnetwork/abi-wrappers';
import { ApiConstructorParams, PolymathAPI } from '../src/PolymathAPI';
import { ModuleName, ModuleType } from '../src';
import ModuleFactoryWrapper from '../src/contract_wrappers/modules/module_factory_wrapper';
Expand Down Expand Up @@ -186,7 +186,7 @@ window.addEventListener('load', async () => {

// Subscribe to event of update dividend dates
await erc20DividendCheckpoint.subscribeAsync({
eventName: ERC20DividendCheckpointEvents.UpdateDividendDates,
eventName: ERC20DividendCheckpointEvents_3_0_0.UpdateDividendDates,
indexFilterValues: {},
callback: async (error, log) => {
if (error) {
Expand Down
4 changes: 2 additions & 2 deletions examples/etherDividend.ts
@@ -1,5 +1,5 @@
import { RedundantSubprovider, RPCSubprovider, Web3ProviderEngine } from '@0x/subproviders';
import { EtherDividendCheckpointEvents, BigNumber } from '@polymathnetwork/abi-wrappers';
import { EtherDividendCheckpointEvents_3_0_0, BigNumber } from '@polymathnetwork/abi-wrappers';
import { ApiConstructorParams, PolymathAPI } from '../src/PolymathAPI';
import { ModuleName, ModuleType } from '../src';
import ModuleFactoryWrapper from '../src/contract_wrappers/modules/module_factory_wrapper';
Expand Down Expand Up @@ -183,7 +183,7 @@ window.addEventListener('load', async () => {

// Subscribe to event of update dividend dates
await etherDividendCheckpoint.subscribeAsync({
eventName: EtherDividendCheckpointEvents.UpdateDividendDates,
eventName: EtherDividendCheckpointEvents_3_0_0.UpdateDividendDates,
indexFilterValues: {},
callback: async (error, log) => {
if (error) {
Expand Down
4 changes: 2 additions & 2 deletions examples/generalPermissionManager.ts
@@ -1,5 +1,5 @@
import { RedundantSubprovider, RPCSubprovider, Web3ProviderEngine } from '@0x/subproviders';
import { GeneralPermissionManagerEvents, BigNumber } from '@polymathnetwork/abi-wrappers';
import { GeneralPermissionManagerEvents_3_0_0, BigNumber } from '@polymathnetwork/abi-wrappers';
import ModuleFactoryWrapper from '../src/contract_wrappers/modules/module_factory_wrapper';
import { ApiConstructorParams, PolymathAPI } from '../src/PolymathAPI';
import { ModuleName, ModuleType, Perm, TransferType } from '../src';
Expand Down Expand Up @@ -109,7 +109,7 @@ window.addEventListener('load', async () => {

// Subscribe to event of add delegate
await generalPM.subscribeAsync({
eventName: GeneralPermissionManagerEvents.AddDelegate,
eventName: GeneralPermissionManagerEvents_3_0_0.AddDelegate,
indexFilterValues: {},
callback: async (error, log) => {
if (error) {
Expand Down
4 changes: 2 additions & 2 deletions examples/generalTransferManager.ts
@@ -1,5 +1,5 @@
import { RedundantSubprovider, RPCSubprovider, Web3ProviderEngine } from '@0x/subproviders';
import { GeneralTransferManagerEvents, BigNumber } from '@polymathnetwork/abi-wrappers';
import { GeneralTransferManagerEvents_3_0_0, BigNumber } from '@polymathnetwork/abi-wrappers';
import { ApiConstructorParams, PolymathAPI } from '../src/PolymathAPI';
import { ModuleName, TransferType } from '../src';

Expand Down Expand Up @@ -78,7 +78,7 @@ window.addEventListener('load', async () => {
// Modify transfer requirements
// Subscribe to event of modify transfer requirements
await generalTM.subscribeAsync({
eventName: GeneralTransferManagerEvents.ModifyTransferRequirements,
eventName: GeneralTransferManagerEvents_3_0_0.ModifyTransferRequirements,
indexFilterValues: {},
callback: async (error, log) => {
if (error) {
Expand Down
48 changes: 48 additions & 0 deletions examples/issueTokenToInvestor.ts
@@ -0,0 +1,48 @@
import { PolymathAPI, ModuleName, TransactionParams } from '../src';
import { moduleInstancesLookup } from './modules';
import { SecurityTokenEvents_3_0_0 } from '@polymathnetwork/abi-wrappers/lib/src';

/**
* Mints the token to a specific investor. Requires a valid security token and no transfer restrictions impeding the issuance.
* @param polymathAPI Reference to polymathAPI instance.
* @param ticker Ticker of the Security Token
* @param issueMultiParams Transaction params for issuing to multiple investors.
*/
export const issueTokenToInvestors = async (
polymathAPI: PolymathAPI,
ticker: string,
issueMultiParams: TransactionParams.SecurityToken.IssueMulti,
) => {
const tokenAddress = await polymathAPI.securityTokenRegistry.getSecurityTokenAddress({ ticker: ticker! });
const tickerSecurityTokenInstance = await polymathAPI.tokenFactory.getSecurityTokenInstanceFromAddress(tokenAddress);

// Subscribe to event
await tickerSecurityTokenInstance.subscribeAsync({
eventName: SecurityTokenEvents_3_0_0.Issued,
indexFilterValues: {},
callback: async (error: any, log: any) => {
if (error) {
console.log(error);
} else {
console.log('Tokens issued successfully', log);
}
},
});

// Get general TM module instance
const generalTM = (await moduleInstancesLookup(polymathAPI, {
ticker,
moduleName: ModuleName.GeneralTransferManager,
}))[0];
const listInvestors = await generalTM.getAllKYCData();
const found = listInvestors.find(function(addr: { investor: any }) {
return issueMultiParams.investors.includes(addr.investor);
});
// If the investors are in the whitelist, go ahead and issue multi with the params passed in.
if (found) {
await tickerSecurityTokenInstance.issueMulti(issueMultiParams);
console.log('Tokens issued');
} else {
console.log('Please make sure beneficiary address has been whitelisted');
}
};

0 comments on commit cdff881

Please sign in to comment.