@@ -4,7 +4,7 @@ import { ApiConstructorParams, PolymathAPI } from '../src/PolymathAPI';
4
4
import { ModuleName , ModuleType } from '../src' ;
5
5
import ModuleFactoryWrapper from '../src/contract_wrappers/modules/module_factory_wrapper' ;
6
6
7
- // This file acts as a valid sandbox for adding a erc20Dividend module on an unlocked node (like ganache)
7
+ // This file acts as a valid sandbox for adding a erc20Dividend module on an unlocked node (like ganache)
8
8
9
9
window . addEventListener ( 'load' , async ( ) => {
10
10
// Setup the redundant provider
@@ -62,7 +62,6 @@ window.addEventListener('load', async () => {
62
62
// Create a Security Token Instance
63
63
const tickerSecurityTokenInstance = await polymathAPI . tokenFactory . getSecurityTokenInstanceFromTicker ( ticker ! ) ;
64
64
65
- const moduleStringName = 'ERC20DividendCheckpoint' ;
66
65
const moduleName = ModuleName . ERC20DividendCheckpoint ;
67
66
const modules = await polymathAPI . moduleRegistry . getModulesByType ( {
68
67
moduleType : ModuleType . Dividends ,
@@ -78,13 +77,13 @@ window.addEventListener('load', async () => {
78
77
names . push ( instanceFactory . name ( ) ) ;
79
78
} ) ;
80
79
const resultNames = await Promise . all ( names ) ;
81
- const index = resultNames . indexOf ( moduleStringName ) ;
80
+ const index = resultNames . indexOf ( moduleName ) ;
82
81
83
82
// Get setup cost
84
83
const factory = await polymathAPI . moduleFactory . getModuleFactory ( modules [ index ] ) ;
85
84
const setupCost = await factory . setupCostInPoly ( ) ;
86
85
87
- // Call to add etherdividend module
86
+ // Call to add erc20 dividend module
88
87
await tickerSecurityTokenInstance . addModule ( {
89
88
moduleName,
90
89
address : modules [ index ] ,
@@ -96,7 +95,7 @@ window.addEventListener('load', async () => {
96
95
} ,
97
96
} ) ;
98
97
99
- // Get module for ether dividend checkpoint and address for module
98
+ // Get module for erc20 dividend checkpoint and address for module
100
99
const erc20DividendAddress = ( await tickerSecurityTokenInstance . getModulesByName ( {
101
100
moduleName : ModuleName . ERC20DividendCheckpoint ,
102
101
} ) ) [ 0 ] ;
@@ -115,24 +114,6 @@ window.addEventListener('load', async () => {
115
114
address : generalTMAddress ,
116
115
} ) ;
117
116
118
- // Add owner address in the whitelist to allow issue tokens
119
- await generalTM . modifyKYCData ( {
120
- investor : myAddress ,
121
- canSendAfter : new Date ( ) ,
122
- canReceiveAfter : new Date ( ) ,
123
- expiryTime : new Date ( 2020 , 0 ) ,
124
- txData : {
125
- from : await polymathAPI . getAccount ( ) ,
126
- } ,
127
- } ) ;
128
-
129
- // Mint yourself some tokens and make some transfers
130
- await tickerSecurityTokenInstance . issue ( {
131
- investor : myAddress ,
132
- value : new BigNumber ( 50 ) ,
133
- data : '0x00' ,
134
- } ) ;
135
-
136
117
await polymathAPI . polyToken . approve ( {
137
118
spender : erc20DividendAddress ,
138
119
value : new BigNumber ( 4 ) ,
@@ -152,11 +133,14 @@ window.addEventListener('load', async () => {
152
133
expiryTime : [ new Date ( 2020 , 0 ) , new Date ( 2020 , 0 ) , new Date ( 2020 , 0 ) ] ,
153
134
} ) ;
154
135
155
- await tickerSecurityTokenInstance . transfer ( { to : randomInvestors [ 0 ] , value : new BigNumber ( 10 ) } ) ;
156
- await tickerSecurityTokenInstance . transfer ( { to : randomInvestors [ 1 ] , value : new BigNumber ( 20 ) } ) ;
157
- await tickerSecurityTokenInstance . transfer ( { to : randomInvestors [ 2 ] , value : new BigNumber ( 20 ) } ) ;
136
+ // Mint yourself some tokens and make some transfers
137
+ await tickerSecurityTokenInstance . issueMulti ( {
138
+ investors : randomInvestors ,
139
+ values : [ new BigNumber ( 10 ) , new BigNumber ( 20 ) , new BigNumber ( 20 ) ] ,
140
+ } ) ;
158
141
159
142
// Create Dividends
143
+ // A checkpoint is created behind the scenes
160
144
await erc20DividendCheckpoint . createDividendWithExclusions ( {
161
145
name : 'MyDividend1' ,
162
146
amount : new BigNumber ( 1 ) ,
@@ -166,9 +150,10 @@ window.addEventListener('load', async () => {
166
150
excluded : [ randomInvestors [ 1 ] , randomInvestors [ 2 ] ] ,
167
151
} ) ;
168
152
169
- // Create a checkpoint
153
+ // Create another checkpoint
170
154
await tickerSecurityTokenInstance . createCheckpoint ( { } ) ;
171
155
156
+ // Using the most recent checkpoint
172
157
await erc20DividendCheckpoint . createDividendWithCheckpointAndExclusions ( {
173
158
name : 'MyDividend2' ,
174
159
amount : new BigNumber ( 1 ) ,
@@ -187,13 +172,14 @@ window.addEventListener('load', async () => {
187
172
maturity : new Date ( 2018 , 1 ) ,
188
173
} ) ;
189
174
175
+ // Another checkpoint was created behind the scenes
190
176
await erc20DividendCheckpoint . createDividendWithCheckpoint ( {
191
177
name : 'MyDividend4' ,
192
178
amount : new BigNumber ( 1 ) ,
193
179
token : await polymathAPI . polyToken . address ( ) ,
194
180
expiry : new Date ( 2035 , 2 ) ,
195
181
maturity : new Date ( 2018 , 1 ) ,
196
- checkpointId : 1 ,
182
+ checkpointId : 2 ,
197
183
} ) ;
198
184
199
185
console . log ( '4 types of erc20 dividends created' ) ;
0 commit comments