From 7b0cab4a6eac82ae8b576994480253cbc117792a Mon Sep 17 00:00:00 2001 From: Arr00 <13561405+arr00@users.noreply.github.com> Date: Thu, 7 Sep 2023 12:59:41 -0400 Subject: [PATCH] chore: immutable old token dst nft renderer --- contracts/renderers/PartyNFTRenderer.sol | 15 +++++++++++---- deploy/Deploy.s.sol | 3 ++- test/crowdfund/InitialETHCrowdfund.t.sol | 2 +- test/party/PartyGovernanceNFT.t.sol | 2 +- test/utils/PartyGovernanceHelpers.t.sol | 7 ++++++- 5 files changed, 21 insertions(+), 8 deletions(-) diff --git a/contracts/renderers/PartyNFTRenderer.sol b/contracts/renderers/PartyNFTRenderer.sol index a14c0f47..fcdbf4c2 100644 --- a/contracts/renderers/PartyNFTRenderer.sol +++ b/contracts/renderers/PartyNFTRenderer.sol @@ -74,13 +74,16 @@ contract PartyNFTRenderer is RendererBase { address constant PARTYSTAR_CROWDFUND_ADDRESS = 0x0Bf08f7b6474C2aCCB9b9e325acb6FbcC682dE82; IMetadataRegistry1_1 constant OLD_METADATA_REGISTRY = IMetadataRegistry1_1(0x175487875F0318EdbAB54BBA442fF53b36e96015); + address immutable OLD_TOKEN_DISTRIBUTOR; constructor( IGlobals globals, RendererStorage rendererStorage, - IFont font + IFont font, + address oldTokenDistributor ) RendererBase(globals, rendererStorage, font) { IMPL = address(this); + OLD_TOKEN_DISTRIBUTOR = oldTokenDistributor; } function royaltyInfo( @@ -626,12 +629,16 @@ contract PartyNFTRenderer is RendererBase { function hasUnclaimedDistribution(uint256 tokenId) private view returns (bool) { if (address(this) == IMPL) return false; - TokenDistributor[] memory distributors = new TokenDistributor[](2); + // There will only be one distributor if old token distributor is not set + TokenDistributor[] memory distributors = OLD_TOKEN_DISTRIBUTOR != address(0) + ? new TokenDistributor[](2) + : new TokenDistributor[](1); distributors[0] = TokenDistributor( _GLOBALS.getAddress(LibGlobals.GLOBAL_TOKEN_DISTRIBUTOR) ); - // Address of the old token distributor contract. - distributors[1] = TokenDistributor(0x1CA2007a81F8A7491BB6E11D8e357FD810896454); + if (OLD_TOKEN_DISTRIBUTOR != address(0)) { + distributors[1] = TokenDistributor(OLD_TOKEN_DISTRIBUTOR); + } Party party = Party(payable(address(this))); for (uint256 i; i < distributors.length; ++i) { diff --git a/deploy/Deploy.s.sol b/deploy/Deploy.s.sol index f66a8c98..674a055b 100644 --- a/deploy/Deploy.s.sol +++ b/deploy/Deploy.s.sol @@ -316,7 +316,8 @@ abstract contract Deploy { partyNFTRenderer = new PartyNFTRenderer( globals, rendererStorage, - IFont(address(pixeldroidConsoleFont)) + IFont(address(pixeldroidConsoleFont)), + 0x1CA2007a81F8A7491BB6E11D8e357FD810896454 // Old token distributor ); _trackDeployerGasAfter(); console.log(" Deployed - PartyNFTRenderer", address(partyNFTRenderer)); diff --git a/test/crowdfund/InitialETHCrowdfund.t.sol b/test/crowdfund/InitialETHCrowdfund.t.sol index 7e8533ce..1b79abf6 100644 --- a/test/crowdfund/InitialETHCrowdfund.t.sol +++ b/test/crowdfund/InitialETHCrowdfund.t.sol @@ -48,7 +48,7 @@ contract InitialETHCrowdfundTest is LintJSON, TestUtils, ERC721Receiver { // Upload font on-chain PixeldroidConsoleFont font = new PixeldroidConsoleFont(); nftRendererStorage = new RendererStorage(address(this)); - nftRenderer = new PartyNFTRenderer(globals, nftRendererStorage, font); + nftRenderer = new PartyNFTRenderer(globals, nftRendererStorage, font, address(0)); tokenDistributor = new TokenDistributor(globals, 0); globals.setAddress(LibGlobals.GLOBAL_GOVERNANCE_NFT_RENDER_IMPL, address(nftRenderer)); diff --git a/test/party/PartyGovernanceNFT.t.sol b/test/party/PartyGovernanceNFT.t.sol index add98d19..239d2c6f 100644 --- a/test/party/PartyGovernanceNFT.t.sol +++ b/test/party/PartyGovernanceNFT.t.sol @@ -65,7 +65,7 @@ contract PartyGovernanceNFTTest is LintJSON, TestUtils { // Upload font on-chain PixeldroidConsoleFont font = new PixeldroidConsoleFont(); nftRendererStorage = new RendererStorage(address(this)); - nftRenderer = new PartyNFTRenderer(globals, nftRendererStorage, font); + nftRenderer = new PartyNFTRenderer(globals, nftRendererStorage, font, address(0)); globalsAdmin.setGovernanceNftRendererAddress(address(nftRenderer)); globalsAdmin.setRendererStorage(address(nftRendererStorage)); diff --git a/test/utils/PartyGovernanceHelpers.t.sol b/test/utils/PartyGovernanceHelpers.t.sol index 38354ea5..6b44f1cf 100644 --- a/test/utils/PartyGovernanceHelpers.t.sol +++ b/test/utils/PartyGovernanceHelpers.t.sol @@ -38,7 +38,12 @@ contract PartyGovernanceHelpersTest is Test, TestUtils { eng = new DummySimpleProposalEngineImpl(); globalsAdmin.setProposalEng(address(eng)); - nftRenderer = new PartyNFTRenderer(globals, RendererStorage(address(0)), IFont(address(0))); + nftRenderer = new PartyNFTRenderer( + globals, + RendererStorage(address(0)), + IFont(address(0)), + address(0) + ); globalsAdmin.setGovernanceNftRendererAddress(address(nftRenderer)); partyFactory = new PartyFactory(globals);