Skip to content

Commit

Permalink
Merge branch 'main' into dev-2
Browse files Browse the repository at this point in the history
  • Loading branch information
arr00 authored Nov 28, 2023
2 parents 7672522 + 6a1d972 commit 80776e2
Show file tree
Hide file tree
Showing 10 changed files with 162 additions and 51 deletions.
48 changes: 27 additions & 21 deletions README.md

Large diffs are not rendered by default.

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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"deploy:mainnet:dry": "DRY_RUN=1 forge script ./deploy/Mainnet.s.sol -vvv --rpc-url $ETH_RPC_URL --via-ir --skip test --optimize --optimizer-runs 0 --ffi",
"deploy:base": "DRY_RUN=0 forge script ./deploy/Base.s.sol -vvv --rpc-url $BASE_RPC_URL --via-ir --broadcast --etherscan-api-key ${ETHERSCAN_API_KEY} --evm-version paris --skip test --optimize --optimizer-runs 0 --ffi --slow",
"deploy:base:dry": "DRY_RUN=1 forge script ./deploy/Base.s.sol -vvv --rpc-url $BASE_RPC_URL --via-ir --evm-version paris --skip test --optimize --optimizer-runs 0 --ffi",
"deploy:base-goerli": "DRY_RUN=0 forge script ./deploy/BaseGoerli.s.sol -vvv --rpc-url $BASE_GOERLI_RPC_URL --via-ir --broadcast --etherscan-api-key ${ETHERSCAN_API_KEY} --evm-version paris --skip test --optimize --optimizer-runs 0 --ffi --slow",
"deploy:base-goerli": "DRY_RUN=0 forge script ./deploy/BaseGoerli.s.sol -vvv --rpc-url $BASE_GOERLI_RPC_URL --via-ir --broadcast --etherscan-api-key $BASESCAN_API_KEY --evm-version paris --skip test --optimize --optimizer-runs 0 --ffi --slow",
"deploy:base-goerli:dry": "DRY_RUN=1 forge script ./deploy/BaseGoerli.s.sol -vvv --rpc-url $BASE_GOERLI_RPC_URL --via-ir --evm-version paris --skip test --optimize --optimizer-runs 0 --ffi",
"decode-revert": "node js/decode-revert.js",
"layout": "node js/gen-storage-layout.js",
Expand Down
1 change: 1 addition & 0 deletions test/crowdfund/InitialETHCrowdfund.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ contract InitialETHCrowdfundTestBase 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 @@ -77,6 +77,7 @@ contract PartyGovernanceNFTTestBase 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
96 changes: 84 additions & 12 deletions utils/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,19 @@ const rl = readline.createInterface({
output: process.stdout,
});

async function run(command: string) {
async function run(command: string, { captureOutput = false, throwOnError = true } = {}) {
const result = childProcess.spawnSync(command, [], {
shell: true,
stdio: "inherit",
stdio: captureOutput ? "pipe" : "inherit",
});

if (result.status !== 0) {
if (throwOnError && result.status !== 0) {
throw new Error(`Command "${command}" failed with status code ${result.status}`);
}

return result.stdout;
if (captureOutput) {
return result.stdout.toString().trim();
}
}

async function confirm(question: string, defaultValue?: boolean): Promise<boolean> {
Expand Down Expand Up @@ -337,6 +339,74 @@ async function main() {
process.exit(1);
}

// Get name of remote branch current branch is tracking
const currentBranch = await run("git rev-parse --abbrev-ref HEAD", {
captureOutput: true,
throwOnError: false,
});

if (currentBranch) {
const remoteBranch = `origin/${currentBranch}`;

// Get number of commits current branch is ahead and behind remote branch
const [numOfCommitsBehind, numOfCommitsAhead] = (
await run(`git rev-list --left-right --count ${remoteBranch}...HEAD`, {
captureOutput: true,
})
)
.split("\t")
.map(Number);

// If current branch is behind remote branch, prompt to pull latest changes
if (numOfCommitsBehind > 0) {
console.warn(
(
(numOfCommitsBehind > 1 ? `${numOfCommitsBehind} commits` : `1 commit`) +
" behind remote."
).yellow,
);

if (await confirm("Do you want to pull latest changes?", true)) {
await run(`git pull origin ${currentBranch}`);
}
}

// If current branch is ahead of remote branch, prompt to confirm whether to continue
if (numOfCommitsAhead > 0) {
console.warn(
(
(numOfCommitsAhead > 1 ? `${numOfCommitsAhead} commits` : `1 commit`) +
" ahead of remote."
).yellow,
);

if (!(await confirm("Do you want to continue?", false))) {
process.exit(0);
}
}
}

// Get private key of deployer address
const privateKey = process.env.PRIVATE_KEY;
if (!privateKey) {
console.error("Missing PRIVATE_KEY environment variable.");
process.exit(1);
}

// Check that deployer address is expected address
const deployerAddress = await run(`cast wallet address ${privateKey}`, {
captureOutput: true,
});
const expectedDeployerAddress = "0x0e63D6f414b40BaFCa676810ef1aBf05ECc8E459";
if (deployerAddress !== expectedDeployerAddress) {
console.warn(
`Deployer address is ${deployerAddress}, expected ${expectedDeployerAddress}.`.yellow,
);
if (!(await confirm("Do you want to continue?", false))) {
process.exit(0);
}
}

if (
await confirm(
"Do you want to set contract variables to their existing addresses in Deploy.s.sol?",
Expand All @@ -349,6 +419,10 @@ async function main() {
console.warn("Remember to unset variables for contracts that are going to be deployed!".yellow);
}

await confirm("Have you updated Deploy.sol to only deploy the contracts you want?", true);

await confirm("Are there no other changes that should be included into this deploy?", true);

if (
await confirm(
"Do you want to check that deploy script variable names match contract names?",
Expand All @@ -358,12 +432,11 @@ async function main() {
await checkDeployContractVariables();
}

await confirm("Have you updated Deploy.sol to only deploy the contracts you want?", true);

// Run dry run deploy and check that it succeeded
let dryRunSucceeded = false;
while (!dryRunSucceeded) {
if (await confirm("Do dry run?", true)) {
await run(`yarn deploy:${chain}:dry --private-key ${process.env.PRIVATE_KEY}`);
await run(`yarn deploy:${chain}:dry --private-key ${privateKey}`);
await run("yarn lint:fix > /dev/null");
await checksumAddresses(`deploy/cache/${chain}.json`);

Expand All @@ -374,8 +447,6 @@ async function main() {
break;
}

await confirm("Was the deployer the expected address?", true);

await confirm(
`Does deploy/cache/${chain}.json only contain addresses for contracts that changed?`,
true,
Expand All @@ -384,10 +455,8 @@ async function main() {
await confirm("Were ABI files in deploy/cache/abis created or changed as you expected?", true);
}

await confirm("Are there no other changes that should be included into this deploy?", true);

if (await confirm("Run deploy?", true)) {
run(`yarn deploy:${chain} --private-key ${process.env.PRIVATE_KEY}`);
run(`yarn deploy:${chain} --private-key ${privateKey}`);
await run("yarn lint:fix > /dev/null");
await checksumAddresses(`deploy/cache/${chain}.json`);

Expand All @@ -409,6 +478,9 @@ async function main() {
release_name = await new Promise<string>(resolve =>
rl.question("What is the release name? ", resolve),
);

// Format the release name to be lowercase and replace spaces and dashes with underscores
release_name = release_name.trim().toLowerCase().replace(/[\s-]/g, "_");
}

if (await confirm("Copy deploy script to party-addresses?", false)) {
Expand Down

0 comments on commit 80776e2

Please sign in to comment.