@@ -15,7 +15,7 @@ const {
15
15
builtTruffleContractLoader,
16
16
sendGovernanceAction,
17
17
} = require ( "./libs/common" ) ;
18
- const { ethers } = require ( "ethers" ) ;
18
+ const { ethers} = require ( "ethers" ) ;
19
19
20
20
let resetSuperfluidFramework ;
21
21
let resolver ;
@@ -95,11 +95,11 @@ async function deployContractIfCodeChanged(
95
95
* (overriding env: ENABLE_APP_WHITELISTING)
96
96
* @param {boolean } options.resetSuperfluidFramework Reset the superfluid framework deployment
97
97
* (overriding env: RESET_SUPERFLUID_FRAMEWORK)
98
- * @param {boolean } options.protocolReleaseVersion Specify the protocol release version to be used
98
+ * @param {string } options.protocolReleaseVersion Specify the protocol release version to be used
99
99
* (overriding env: RELEASE_VERSION)
100
- * @param {boolean } options.outputFile Name of file where to log addresses of newly deployed contracts
100
+ * @param {string } options.outputFile Name of file where to log addresses of newly deployed contracts
101
101
* (overriding env: OUTPUT_FILE)
102
- * @param {boolean } options.cfaHookContract Address of the contract to be set up as CFA hooks receiver
102
+ * @param {Address } options.cfaHookContract Address of the contract to be set up as CFA hooks receiver
103
103
* (overriding env: CFA_HOOK_CONTRACT)
104
104
*
105
105
* Usage: npx truffle exec ops-scripts/deploy-framework.js
@@ -415,6 +415,7 @@ module.exports = eval(`(${S.toString()})({skipArgv: true})`)(async function (
415
415
} else {
416
416
contract . link ( externalLibraryName , externalLibrary . address ) ;
417
417
}
418
+ console . log ( externalLibraryName , "address" , externalLibrary . address ) ;
418
419
return externalLibrary ;
419
420
} ;
420
421
@@ -448,7 +449,7 @@ module.exports = eval(`(${S.toString()})({skipArgv: true})`)(async function (
448
449
) ( superfluid . address , ida . address ) ;
449
450
} else {
450
451
// NOTE that we are reusing the existing deployed external library
451
- // here as an optimization, this assumes that we do not change the
452
+ // here as an optimization, this assumes that we do not change the
452
453
// library code.
453
454
// link library in order to avoid spurious code change detections
454
455
let slotsBitmapLibraryAddress = ZERO_ADDRESS ;
@@ -557,17 +558,35 @@ module.exports = eval(`(${S.toString()})({skipArgv: true})`)(async function (
557
558
agreementsToUpdate . push ( idaNewLogicAddress ) ;
558
559
}
559
560
560
- // deploy new super token factory logic
561
+ // deploy new super token factory logic (depends on SuperToken logic, which links to nft deployer library)
561
562
const SuperTokenFactoryLogic = useMocks
562
563
? SuperTokenFactoryMock
563
564
: SuperTokenFactory ;
564
565
565
566
const SuperTokenLogic = useMocks ? SuperTokenMock : SuperToken ;
567
+
568
+ let superfluidNFTDeployerLibraryAddress = ZERO_ADDRESS ;
569
+
566
570
const factoryAddress = await superfluid . getSuperTokenFactory . call ( ) ;
571
+ if ( factoryAddress !== ZERO_ADDRESS ) {
572
+ const factoryContract = await SuperTokenFactoryLogic . at ( factoryAddress ) ;
573
+ const superTokenContract = await SuperToken . at (
574
+ await factoryContract . getSuperTokenLogic . call ( )
575
+ ) ;
576
+
577
+ try {
578
+ superfluidNFTDeployerLibraryAddress =
579
+ await superTokenContract . SUPERFLUID_NFT_DEPLOYER_LIBRARY_ADDRESS . call ( ) ;
580
+ } catch {
581
+ console . warn (
582
+ "SUPERFLUID_NFT_DEPLOYER_LIBRARY_ADDRESS does not exist on SuperToken contract yet - deployment required."
583
+ ) ;
584
+ }
585
+ }
567
586
568
- // deploy new SuperfluidNFTDeployerLibrary if factory is not deployed
587
+ // deploy new SuperfluidNFTDeployerLibrary if it is not deployed
569
588
// link it to SuperToken logic contract
570
- if ( factoryAddress === ZERO_ADDRESS ) {
589
+ if ( superfluidNFTDeployerLibraryAddress === ZERO_ADDRESS ) {
571
590
await deployExternalLibraryAndLink (
572
591
SuperfluidNFTDeployerLibrary ,
573
592
"SuperfluidNFTDeployerLibrary" ,
@@ -579,29 +598,32 @@ module.exports = eval(`(${S.toString()})({skipArgv: true})`)(async function (
579
598
// here as an optimization, this assumes that we do not change the
580
599
// library code.
581
600
// link existing deployed external library to SuperToken logic contract
582
- let superfluidNFTDeployerLibraryAddress = ZERO_ADDRESS ;
601
+
583
602
try {
584
- // get factory contract
585
- const factoryContract = await SuperTokenFactoryLogic . at (
586
- factoryAddress
587
- ) ;
588
- const superTokenContract = await SuperToken . at (
589
- await factoryContract . getSuperTokenLogic . call ( )
590
- ) ;
591
- superfluidNFTDeployerLibraryAddress =
592
- await superTokenContract . SUPERFLUID_NFT_DEPLOYER_LIBRARY_ADDRESS . call ( ) ;
593
- if ( process . env . IS_HARDHAT ) {
594
- if ( superfluidNFTDeployerLibraryAddress !== ZERO_ADDRESS ) {
603
+ // if the library is not deployed, deploy it and link it to SuperToken logic contract
604
+ if ( superfluidNFTDeployerLibraryAddress === ZERO_ADDRESS ) {
605
+ const superfluidNFTDeployerLibrary =
606
+ await deployExternalLibraryAndLink (
607
+ SuperfluidNFTDeployerLibrary ,
608
+ "SuperfluidNFTDeployerLibrary" ,
609
+ "SUPERFLUID_NFT_DEPLOYER_LIBRARY_ADDRESS" ,
610
+ SuperTokenLogic
611
+ ) ;
612
+ superfluidNFTDeployerLibraryAddress =
613
+ superfluidNFTDeployerLibrary . address ;
614
+ // else link the preexisting contract
615
+ } else {
616
+ if ( process . env . IS_HARDHAT ) {
595
617
const lib = await SuperfluidNFTDeployerLibrary . at (
596
618
superfluidNFTDeployerLibraryAddress
597
619
) ;
598
620
SuperTokenLogic . link ( lib ) ;
621
+ } else {
622
+ SuperTokenLogic . link (
623
+ "SuperfluidNFTDeployerLibrary" ,
624
+ superfluidNFTDeployerLibraryAddress
625
+ ) ;
599
626
}
600
- } else {
601
- SuperTokenLogic . link (
602
- "SuperfluidNFTDeployerLibrary" ,
603
- superfluidNFTDeployerLibraryAddress
604
- ) ;
605
627
}
606
628
} catch ( e ) {
607
629
console . warn (
@@ -615,17 +637,21 @@ module.exports = eval(`(${S.toString()})({skipArgv: true})`)(async function (
615
637
web3 ,
616
638
SuperTokenFactoryLogic ,
617
639
async ( ) => {
640
+ console . log ( "checking if SuperTokenFactory needs to be redeployed..." ) ;
618
641
// check if super token factory or super token logic changed
619
642
try {
620
643
if ( factoryAddress === ZERO_ADDRESS ) return true ;
621
644
const factory = await SuperTokenFactoryLogic . at ( factoryAddress ) ;
645
+ console . log ( " factory.getSuperTokenLogic.call()" ) ;
622
646
const superTokenLogicAddress =
623
647
await factory . getSuperTokenLogic . call ( ) ;
624
648
const superTokenLogic = await SuperTokenLogic . at (
625
649
superTokenLogicAddress
626
650
) ;
651
+ console . log ( " superTokenLogic.CONSTANT_OUTFLOW_NFT_LOGIC()" ) ;
627
652
const constantOutflowNFTLogicAddress =
628
653
await superTokenLogic . CONSTANT_OUTFLOW_NFT_LOGIC ( ) ;
654
+ console . log ( " superTokenLogic.CONSTANT_INFLOW_NFT_LOGIC()" ) ;
629
655
const constantInflowNFTLogicAddress =
630
656
await superTokenLogic . CONSTANT_INFLOW_NFT_LOGIC ( ) ;
631
657
const superTokenFactoryCodeChanged = await codeChanged (
@@ -665,7 +691,7 @@ module.exports = eval(`(${S.toString()})({skipArgv: true})`)(async function (
665
691
superTokenFactoryCodeChanged || superTokenLogicCodeChanged
666
692
) ;
667
693
} catch ( e ) {
668
- console . log ( e . toString ( ) ) ;
694
+ console . log ( ` re-deploying SuperTokenFactory because checks didn't pass ${ e . toString ( ) } ` ) ;
669
695
// recreate contract on any errors
670
696
return true ;
671
697
}
@@ -690,11 +716,15 @@ module.exports = eval(`(${S.toString()})({skipArgv: true})`)(async function (
690
716
ConstantOutflowNFT . new ,
691
717
"ConstantOutflowNFT.new"
692
718
) ( cfaV1Address ) ;
719
+ output += `CONSTANT_OUTFLOW_NFT_LOGIC_ADDRESS=${ constantOutflowNFTLogic . address } \n` ;
720
+
693
721
// deploy constant inflow nft logic contract
694
722
const constantInflowNFTLogic = await web3tx (
695
723
ConstantInflowNFT . new ,
696
724
"ConstantInflowNFT.new"
697
725
) ( cfaV1Address ) ;
726
+ output += `CONSTANT_INFLOW_NFT_LOGIC_ADDRESS=${ constantInflowNFTLogic . address } \n` ;
727
+
698
728
// deploy super token logic contract
699
729
// it now takes the nft logic contracts as parameters
700
730
const superTokenLogic = useMocks
@@ -709,6 +739,10 @@ module.exports = eval(`(${S.toString()})({skipArgv: true})`)(async function (
709
739
constantOutflowNFTLogic . address ,
710
740
constantInflowNFTLogic . address
711
741
) ;
742
+
743
+ console . log ( `SuperToken new logic code address ${ superTokenLogic . address } ` ) ;
744
+ output += `SUPERFLUID_SUPER_TOKEN_LOGIC=${ superTokenLogic . address } \n` ;
745
+
712
746
superTokenFactoryLogic = await web3tx (
713
747
SuperTokenFactoryLogic . new ,
714
748
"SuperTokenFactoryLogic.new"
0 commit comments