Skip to content

Commit

Permalink
chore: immutable old token dst nft renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
arr00 committed Sep 7, 2023
1 parent fec79ba commit 7b0cab4
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 8 deletions.
15 changes: 11 additions & 4 deletions contracts/renderers/PartyNFTRenderer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion deploy/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion test/crowdfund/InitialETHCrowdfund.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion test/party/PartyGovernanceNFT.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down
7 changes: 6 additions & 1 deletion test/utils/PartyGovernanceHelpers.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 7b0cab4

Please sign in to comment.