55 */
66
77const Web3Wrapper = require ( '../web3' ) ;
8+ const Debug = require ( 'debug' ) ;
89
910const artistTokenSc = require ( '../../build/contracts/ArtistToken.json' ) ;
1011const fundingPoolSc = require ( '../../build/contracts/FundingPool.json' ) ;
1112const wphtSc = require ( '../../build/contracts/WPHT.json' ) ;
13+ const logger = Debug ( 'ls-sdk:contract:artistToken' ) ;
1214
1315module . exports . deployFundingPool = async ( web3 , { from } ) => {
1416 Web3Wrapper . validator . validateAddress ( "from" , from ) ;
@@ -24,7 +26,7 @@ module.exports.deployFundingPool = async (web3, { from }) => {
2426 }
2527 ) ;
2628
27- console . log ( `FundingPool deployed at: ${ receipt . contractAddress } ` ) ;
29+ logger ( `FundingPool deployed at: ${ receipt . contractAddress } ` ) ;
2830
2931 return receipt ;
3032} ;
@@ -119,7 +121,7 @@ module.exports.deployArtistToken = async (
119121 }
120122 ) ;
121123
122- console . log ( `ArtistToken deployed at: ${ receipt . contractAddress } ` ) ;
124+ logger ( `ArtistToken deployed at: ${ receipt . contractAddress } ` ) ;
123125 return receipt ;
124126} ;
125127
@@ -137,7 +139,7 @@ module.exports.isArtistTokenHatched = async (web3, { artistTokenAddr }) => {
137139 }
138140 ) ;
139141
140- console . log ( `ArtistToken ${ artistTokenAddr } is hatched: ${ isHatched } ` ) ;
142+ logger ( `ArtistToken ${ artistTokenAddr } is hatched: ${ isHatched } ` ) ;
141143
142144 return isHatched ;
143145} ;
@@ -149,7 +151,7 @@ module.exports.hatchArtistToken = async (web3, { from, artistTokenAddr, wphtAddr
149151 Web3Wrapper . validator . validateWeiBn ( "amountWeiBn" , amountWeiBn ) ;
150152
151153 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 } ` ) ;
153155 if ( runDepositFirst ) {
154156 await Web3Wrapper . contractSendTx (
155157 web3 ,
@@ -195,7 +197,7 @@ module.exports.hatchArtistToken = async (web3, { from, artistTokenAddr, wphtAddr
195197 contributionInWPHT : hatchingAmountInPHT
196198 } ) ;
197199
198- console . log ( `Hatched completed, expected ${ expectedArtistTokens } ArtistTokens` ) ;
200+ logger ( `Hatched completed, expected ${ expectedArtistTokens } ArtistTokens` ) ;
199201 return receipt ;
200202} ;
201203
@@ -213,7 +215,7 @@ module.exports.getArtistTokenTotalSupply = async (web3, { artistTokenAddr }) =>
213215 }
214216 ) ;
215217
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` ) ;
217219
218220 return totalSupply ;
219221} ;
@@ -246,6 +248,19 @@ module.exports.transfer = async (web3, { artistTokenAddr, from, to, amountInBn }
246248 ) ;
247249} ;
248250
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+
249264module . exports . approve = async ( web3 , { artistTokenAddr, from, to, amountInBn } ) => {
250265 return await Web3Wrapper . contractSendTx (
251266 web3 ,
@@ -386,7 +401,7 @@ module.exports.getArtistTokenBalanceOf = async (web3, { artistTokenAddr, account
386401 }
387402 ) ;
388403
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 } ` ) ;
390405
391406 return Web3Wrapper . utils . toBN ( balance ) ;
392407} ;
@@ -438,7 +453,7 @@ module.exports.buyArtistTokens = async (web3, { from, artistTokenAddr, wphtAddr,
438453
439454 const tokens = receipt . events [ 'CurvedMint' ] . returnValues [ 'amount' ] ;
440455
441- console . log ( `Buyer ${ from } purchased ${ tokens . toString ( ) } ${ symbol } of ArtistToken ${ artistTokenAddr } ` ) ;
456+ logger ( `Buyer ${ from } purchased ${ tokens . toString ( ) } ${ symbol } of ArtistToken ${ artistTokenAddr } ` ) ;
442457
443458 return Web3Wrapper . utils . toBN ( tokens ) ;
444459} ;
@@ -465,7 +480,7 @@ module.exports.sellArtistTokens = async (web3, { from, artistTokenAddr, amountBn
465480
466481 const wphtReimbursement = receipt . events [ 'CurvedBurn' ] . returnValues [ 'reimbursement' ] ;
467482
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` ) ;
469484
470485 return wphtReimbursement ;
471486} ;
0 commit comments