Skip to content

Commit

Permalink
feat(PartyNFTRenderer): update renderer for add party cards (#320)
Browse files Browse the repository at this point in the history
* update renderer

* fix test log

* simply revert handling

* add testnet distributors to deploy constants

* add goerli v1 distributor

* give distributor more info

* chore: add line break custom description (#293)

---------

Co-authored-by: Arr00 <[email protected]>
  • Loading branch information
0xble and arr00 authored Nov 28, 2023
1 parent b437f3d commit 6a1d972
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 17 deletions.
44 changes: 34 additions & 10 deletions contracts/renderers/PartyNFTRenderer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ contract PartyNFTRenderer is RendererBase {
IMetadataRegistry1_1 constant OLD_METADATA_REGISTRY =
IMetadataRegistry1_1(0x175487875F0318EdbAB54BBA442fF53b36e96015);
/// @notice The old token distributor contract address.
address immutable OLD_TOKEN_DISTRIBUTOR;
address immutable TOKEN_DISTRIBUTOR_V1;
address immutable TOKEN_DISTRIBUTOR_V2;

/// @notice The base url for external URLs. External URL is BASE_EXTERNAL_URL + PARTY_ADDRESS
/// @dev First byte is the size of the data, the rest is the data (starting from MSB)
Expand All @@ -86,11 +87,13 @@ contract PartyNFTRenderer is RendererBase {
IGlobals globals,
RendererStorage rendererStorage,
IFont font,
address oldTokenDistributor,
address tokenDistributionV1,
address tokenDistributionV2,
string memory baseExternalURL
) RendererBase(globals, rendererStorage, font) {
IMPL = address(this);
OLD_TOKEN_DISTRIBUTOR = oldTokenDistributor;
TOKEN_DISTRIBUTOR_V1 = tokenDistributionV1;
TOKEN_DISTRIBUTOR_V2 = tokenDistributionV2;

bytes memory baseExternalURLBytes = bytes(baseExternalURL);
if (baseExternalURLBytes.length > 31) {
Expand Down Expand Up @@ -219,7 +222,7 @@ contract PartyNFTRenderer is RendererBase {
? generateDescription(PartyGovernanceNFT(address(this)).name(), tokenId)
: string.concat(
metadata.description,
" ",
"\\n\\n",
// Append default description.
generateDescription(
PartyGovernanceNFT(address(this)).name(),
Expand Down Expand Up @@ -659,14 +662,21 @@ contract PartyNFTRenderer is RendererBase {
if (address(this) == IMPL) return false;

// There will only be one distributor if old token distributor is not set
TokenDistributor[] memory distributors = new TokenDistributor[](1);
if (OLD_TOKEN_DISTRIBUTOR != address(0)) {
distributors = new TokenDistributor[](2);
distributors[1] = TokenDistributor(OLD_TOKEN_DISTRIBUTOR);
}
TokenDistributor[] memory distributors = new TokenDistributor[](3);
distributors[0] = TokenDistributor(
_GLOBALS.getAddress(LibGlobals.GLOBAL_TOKEN_DISTRIBUTOR)
);
uint256 l = 1;
if (TOKEN_DISTRIBUTOR_V2 != address(0)) {
distributors[l++] = TokenDistributor(TOKEN_DISTRIBUTOR_V2);
}
if (TOKEN_DISTRIBUTOR_V1 != address(0)) {
distributors[l++] = TokenDistributor(TOKEN_DISTRIBUTOR_V1);
}
assembly {
// Update length of `distributors`
mstore(distributors, l)
}

Party party = Party(payable(address(this)));
for (uint256 i; i < distributors.length; ++i) {
Expand All @@ -679,7 +689,21 @@ contract PartyNFTRenderer is RendererBase {
++distributionId
) {
if (!distributor.hasPartyTokenIdClaimed(party, tokenId, distributionId)) {
return true;
TokenDistributor.DistributionInfo memory info;
info.party = party;
info.distributionId = distributionId;
info.totalShares = 1; // low amount to avoid div by 0
info.memberSupply = 1e18; // arbitrary amount

// `TokenIdAboveMaxError` may prevent it from being claimed.
(bool success, bytes memory response) = address(distributor).staticcall(
abi.encodeCall(TokenDistributor.getClaimAmount, (info, tokenId))
);

if (success) {
uint128 amount = abi.decode(response, (uint128));
if (amount != 0) return true;
}
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion deploy/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,8 @@ abstract contract Deploy {
globals,
rendererStorage,
IFont(address(pixeldroidConsoleFont)),
deployConstants.oldTokenDistributor,
deployConstants.tokenDistributorV1,
deployConstants.tokenDistributorV2,
deployConstants.baseExternalURL
);
_trackDeployerGasAfter();
Expand Down
15 changes: 10 additions & 5 deletions deploy/LibDeployConstants.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ library LibDeployConstants {
string networkName;
address deployedNounsMarketWrapper;
uint96 contributionRouterInitialFee;
address oldTokenDistributor;
address tokenDistributorV1;
address tokenDistributorV2;
string baseExternalURL;
}

Expand Down Expand Up @@ -58,7 +59,8 @@ library LibDeployConstants {
networkName: "goerli",
deployedNounsMarketWrapper: 0x0000000000000000000000000000000000000000,
contributionRouterInitialFee: 0.00055 ether,
oldTokenDistributor: address(0),
tokenDistributorV1: 0xE6F58B31344404E3479d81fB8f9dD592feB37965,
tokenDistributorV2: 0x8714EA9C2BC5a8f2d26D7c3F86558331c16145B5,
baseExternalURL: "https://party.app/party/"
});

Expand Down Expand Up @@ -92,7 +94,8 @@ library LibDeployConstants {
networkName: "base-goerli",
deployedNounsMarketWrapper: 0x0000000000000000000000000000000000000000,
contributionRouterInitialFee: 0.00055 ether,
oldTokenDistributor: address(0),
tokenDistributorV1: address(0),
tokenDistributorV2: 0x55D2463cf5b6743F279Fe9BcbF32415f575B953d,
baseExternalURL: "https://base.party.app/party/"
});

Expand Down Expand Up @@ -126,7 +129,8 @@ library LibDeployConstants {
networkName: "mainnet",
deployedNounsMarketWrapper: 0x9319DAd8736D752C5c72DB229f8e1b280DC80ab1,
contributionRouterInitialFee: 0.00055 ether,
oldTokenDistributor: 0x1CA2007a81F8A7491BB6E11D8e357FD810896454,
tokenDistributorV1: 0x1CA2007a81F8A7491BB6E11D8e357FD810896454,
tokenDistributorV2: 0x49a3caab781f711aD74C9d2F34c3cbD835d6A608,
baseExternalURL: "https://party.app/party/"
});

Expand Down Expand Up @@ -160,7 +164,8 @@ library LibDeployConstants {
networkName: "base",
deployedNounsMarketWrapper: 0x0000000000000000000000000000000000000000,
contributionRouterInitialFee: 0.00055 ether,
oldTokenDistributor: address(0),
tokenDistributorV1: address(0),
tokenDistributorV2: 0xf0560F963538017CAA5081D96f839FE5D265acCB,
baseExternalURL: "https://base.party.app/party/"
});

Expand Down
2 changes: 1 addition & 1 deletion lib/party-addresses
Submodule party-addresses updated 29 files
+172 −0 abis/03416ef6.json
+714 −0 abis/42565cd9.json
+70 −0 abis/77e0ae27.json
+1,018 −0 abis/9041ed77.json
+121 −0 abis/a6c9ad6c.json
+4 −0 contracts/base-goerli/add_party_cards/AddPartyCardsAuthority.json
+4 −0 contracts/base-goerli/add_party_cards/TokenDistributor.json
+4 −0 contracts/base-goerli/efficient_providers/BasicMetadataProvider.json
+4 −0 contracts/base-goerli/efficient_providers/SSTORE2MetadataProvider.json
+6 −2 contracts/base-goerli/head.json
+4 −0 contracts/base-goerli/sell_memberships/SellPartyCardsAuthority.json
+4 −0 contracts/base/add_party_cards/AddPartyCardsAuthority.json
+4 −0 contracts/base/add_party_cards/TokenDistributor.json
+4 −0 contracts/base/efficient_providers/BasicMetadataProvider.json
+4 −0 contracts/base/efficient_providers/SSTORE2MetadataProvider.json
+5 −2 contracts/base/head.json
+4 −0 contracts/goerli/add_party_cards/AddPartyCardsAuthority.json
+4 −0 contracts/goerli/add_party_cards/TokenDistributor.json
+4 −0 contracts/goerli/efficient_providers/BasicMetadataProvider.json
+4 −0 contracts/goerli/efficient_providers/SSTORE2MetadataProvider.json
+6 −2 contracts/goerli/head.json
+4 −0 contracts/goerli/sell_memberships/SellPartyCardsAuthority.json
+4 −0 contracts/mainnet/add_party_cards/AddPartyCardsAuthority.json
+4 −0 contracts/mainnet/add_party_cards/TokenDistributor.json
+4 −0 contracts/mainnet/efficient_providers/BasicMetadataProvider.json
+4 −0 contracts/mainnet/efficient_providers/SSTORE2MetadataProvider.json
+5 −2 contracts/mainnet/head.json
+239 −0 deploy/efficient_providers.sol
+227 −0 deploy/sell_memberships.sol
1 change: 1 addition & 0 deletions test/crowdfund/InitialETHCrowdfund.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ contract InitialETHCrowdfundTest is LintJSON, TestUtils, ERC721Receiver {
nftRendererStorage,
font,
address(0),
address(0),
"https://party.app/party/"
);
tokenDistributor = new TokenDistributor(globals, 0);
Expand Down
1 change: 1 addition & 0 deletions test/party/PartyGovernanceNFT.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ contract PartyGovernanceNFTTest is LintJSON, TestUtils {
nftRendererStorage,
font,
address(0),
address(0),
"https://party.app/party/"
);
globalsAdmin.setGovernanceNftRendererAddress(address(nftRenderer));
Expand Down
1 change: 1 addition & 0 deletions test/utils/PartyGovernanceHelpers.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ contract PartyGovernanceHelpersTest is Test, TestUtils {
RendererStorage(address(0)),
IFont(address(0)),
address(0),
address(0),
"https://party.app/party/"
);
globalsAdmin.setGovernanceNftRendererAddress(address(nftRenderer));
Expand Down

0 comments on commit 6a1d972

Please sign in to comment.