5
5
*/
6
6
7
7
const Web3Wrapper = require ( '../web3' ) ;
8
+ const Debug = require ( 'debug' ) ;
8
9
9
10
const artistTokenSc = require ( '../../build/contracts/ArtistToken.json' ) ;
10
11
const fundingPoolSc = require ( '../../build/contracts/FundingPool.json' ) ;
11
12
const wphtSc = require ( '../../build/contracts/WPHT.json' ) ;
13
+ const logger = Debug ( 'ls-sdk:contract:artistToken' ) ;
12
14
13
15
module . exports . deployFundingPool = async ( web3 , { from } ) => {
14
16
Web3Wrapper . validator . validateAddress ( "from" , from ) ;
@@ -24,7 +26,7 @@ module.exports.deployFundingPool = async (web3, { from }) => {
24
26
}
25
27
) ;
26
28
27
- console . log ( `FundingPool deployed at: ${ receipt . contractAddress } ` ) ;
29
+ logger ( `FundingPool deployed at: ${ receipt . contractAddress } ` ) ;
28
30
29
31
return receipt ;
30
32
} ;
@@ -119,7 +121,7 @@ module.exports.deployArtistToken = async (
119
121
}
120
122
) ;
121
123
122
- console . log ( `ArtistToken deployed at: ${ receipt . contractAddress } ` ) ;
124
+ logger ( `ArtistToken deployed at: ${ receipt . contractAddress } ` ) ;
123
125
return receipt ;
124
126
} ;
125
127
@@ -137,7 +139,7 @@ module.exports.isArtistTokenHatched = async (web3, { artistTokenAddr }) => {
137
139
}
138
140
) ;
139
141
140
- console . log ( `ArtistToken ${ artistTokenAddr } is hatched: ${ isHatched } ` ) ;
142
+ logger ( `ArtistToken ${ artistTokenAddr } is hatched: ${ isHatched } ` ) ;
141
143
142
144
return isHatched ;
143
145
} ;
@@ -149,7 +151,7 @@ module.exports.hatchArtistToken = async (web3, { from, artistTokenAddr, wphtAddr
149
151
Web3Wrapper . validator . validateWeiBn ( "amountWeiBn" , amountWeiBn ) ;
150
152
151
153
const hatchingAmountInPHT = Web3Wrapper . utils . toPht ( amountWeiBn ) ;
152
- console . log ( `Hatcher ${ from } sent a hatch worth of ${ hatchingAmountInPHT } PHT to artist token ${ artistTokenAddr } ` ) ;
154
+ logger ( `Hatcher ${ from } sent a hatch worth of ${ hatchingAmountInPHT } PHT to artist token ${ artistTokenAddr } ` ) ;
153
155
if ( runDepositFirst ) {
154
156
await Web3Wrapper . contractSendTx (
155
157
web3 ,
@@ -195,7 +197,7 @@ module.exports.hatchArtistToken = async (web3, { from, artistTokenAddr, wphtAddr
195
197
contributionInWPHT : hatchingAmountInPHT
196
198
} ) ;
197
199
198
- console . log ( `Hatched completed, expected ${ expectedArtistTokens } ArtistTokens` ) ;
200
+ logger ( `Hatched completed, expected ${ expectedArtistTokens } ArtistTokens` ) ;
199
201
return receipt ;
200
202
} ;
201
203
@@ -213,7 +215,7 @@ module.exports.getArtistTokenTotalSupply = async (web3, { artistTokenAddr }) =>
213
215
}
214
216
) ;
215
217
216
- console . log ( `ArtistToken ${ artistTokenAddr } total supply is: ${ Web3Wrapper . utils . wei2pht ( totalSupply ) } PHT` ) ;
218
+ logger ( `ArtistToken ${ artistTokenAddr } total supply is: ${ Web3Wrapper . utils . wei2pht ( totalSupply ) } PHT` ) ;
217
219
218
220
return totalSupply ;
219
221
} ;
@@ -246,6 +248,19 @@ module.exports.transfer = async (web3, { artistTokenAddr, from, to, amountInBn }
246
248
) ;
247
249
} ;
248
250
251
+ module . exports . transferOwnership = async ( web3 , { artistTokenAddr, from, newOwnerAddr} ) => {
252
+ return await Web3Wrapper . contractSendTx (
253
+ web3 ,
254
+ {
255
+ to : artistTokenAddr ,
256
+ from : from ,
257
+ method : 'transferOwnership' ,
258
+ abi : artistTokenSc . abi ,
259
+ params : [ newOwnerAddr ]
260
+ }
261
+ ) ;
262
+ } ;
263
+
249
264
module . exports . approve = async ( web3 , { artistTokenAddr, from, to, amountInBn } ) => {
250
265
return await Web3Wrapper . contractSendTx (
251
266
web3 ,
@@ -386,7 +401,7 @@ module.exports.getArtistTokenBalanceOf = async (web3, { artistTokenAddr, account
386
401
}
387
402
) ;
388
403
389
- console . log ( `Account ${ accountAddr } has ${ Web3Wrapper . utils . wei2pht ( balance . toString ( ) ) } ${ symbol } of ArtistToken ${ artistTokenAddr } ` ) ;
404
+ logger ( `Account ${ accountAddr } has ${ Web3Wrapper . utils . wei2pht ( balance . toString ( ) ) } ${ symbol } of ArtistToken ${ artistTokenAddr } ` ) ;
390
405
391
406
return Web3Wrapper . utils . toBN ( balance ) ;
392
407
} ;
@@ -438,7 +453,7 @@ module.exports.buyArtistTokens = async (web3, { from, artistTokenAddr, wphtAddr,
438
453
439
454
const tokens = receipt . events [ 'CurvedMint' ] . returnValues [ 'amount' ] ;
440
455
441
- console . log ( `Buyer ${ from } purchased ${ tokens . toString ( ) } ${ symbol } of ArtistToken ${ artistTokenAddr } ` ) ;
456
+ logger ( `Buyer ${ from } purchased ${ tokens . toString ( ) } ${ symbol } of ArtistToken ${ artistTokenAddr } ` ) ;
442
457
443
458
return Web3Wrapper . utils . toBN ( tokens ) ;
444
459
} ;
@@ -465,7 +480,7 @@ module.exports.sellArtistTokens = async (web3, { from, artistTokenAddr, amountBn
465
480
466
481
const wphtReimbursement = receipt . events [ 'CurvedBurn' ] . returnValues [ 'reimbursement' ] ;
467
482
468
- console . log ( `Account ${ from } sold ${ Web3Wrapper . utils . wei2pht ( amountBn . toString ( ) ) } ${ symbol } of ArtistToken ${ artistTokenAddr } for ${ Web3Wrapper . utils . wei2pht ( wphtReimbursement . toString ( ) ) } WPHT` ) ;
483
+ logger ( `Account ${ from } sold ${ Web3Wrapper . utils . wei2pht ( amountBn . toString ( ) ) } ${ symbol } of ArtistToken ${ artistTokenAddr } for ${ Web3Wrapper . utils . wei2pht ( wphtReimbursement . toString ( ) ) } WPHT` ) ;
469
484
470
485
return wphtReimbursement ;
471
486
} ;
0 commit comments