Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into verbs-spend-or-burn…
Browse files Browse the repository at this point in the history
…-excess-eth-every-n-auctions
  • Loading branch information
davidbrai committed Oct 25, 2023
2 parents 5d1bea6 + 31b2a95 commit 3c7725f
Show file tree
Hide file tree
Showing 20 changed files with 2,006 additions and 180 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

30 changes: 29 additions & 1 deletion packages/nouns-contracts/contracts/NounsArt.sol
Original file line number Diff line number Diff line change
Expand Up @@ -330,10 +330,38 @@ contract NounsArt is INounsArt {
/**
* @notice Get the number of available Noun `backgrounds`.
*/
function backgroundsCount() public view override returns (uint256) {
function backgroundCount() external view returns (uint256) {
return backgrounds.length;
}

/**
* @notice Get the number of available Noun `bodies`.
*/
function bodyCount() external view returns (uint256) {
return bodiesTrait.storedImagesCount;
}

/**
* @notice Get the number of available Noun `accessories`.
*/
function accessoryCount() external view returns (uint256) {
return accessoriesTrait.storedImagesCount;
}

/**
* @notice Get the number of available Noun `heads`.
*/
function headCount() external view returns (uint256) {
return headsTrait.storedImagesCount;
}

/**
* @notice Get the number of available Noun `glasses`.
*/
function glassesCount() external view returns (uint256) {
return glassesTrait.storedImagesCount;
}

/**
* @notice Get a head image bytes (RLE-encoded).
*/
Expand Down
10 changes: 5 additions & 5 deletions packages/nouns-contracts/contracts/NounsDescriptorV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -103,35 +103,35 @@ contract NounsDescriptorV2 is INounsDescriptorV2, Ownable {
* @notice Get the number of available Noun `backgrounds`.
*/
function backgroundCount() external view override returns (uint256) {
return art.backgroundsCount();
return art.backgroundCount();
}

/**
* @notice Get the number of available Noun `bodies`.
*/
function bodyCount() external view override returns (uint256) {
return art.getBodiesTrait().storedImagesCount;
return art.bodyCount();
}

/**
* @notice Get the number of available Noun `accessories`.
*/
function accessoryCount() external view override returns (uint256) {
return art.getAccessoriesTrait().storedImagesCount;
return art.accessoryCount();
}

/**
* @notice Get the number of available Noun `heads`.
*/
function headCount() external view override returns (uint256) {
return art.getHeadsTrait().storedImagesCount;
return art.headCount();
}

/**
* @notice Get the number of available Noun `glasses`.
*/
function glassesCount() external view override returns (uint256) {
return art.getGlassesTrait().storedImagesCount;
return art.glassesCount();
}

/**
Expand Down
11 changes: 9 additions & 2 deletions packages/nouns-contracts/contracts/interfaces/INounsArt.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

pragma solidity ^0.8.6;

import { Inflate } from '../libs/Inflate.sol';
import { IInflator } from './IInflator.sol';

interface INounsArt {
Expand Down Expand Up @@ -130,7 +129,15 @@ interface INounsArt {
uint16 imageCount
) external;

function backgroundsCount() external view returns (uint256);
function backgroundCount() external view returns (uint256);

function bodyCount() external view returns (uint256);

function accessoryCount() external view returns (uint256);

function headCount() external view returns (uint256);

function glassesCount() external view returns (uint256);

function backgrounds(uint256 index) external view returns (string memory);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.15;

import 'forge-std/Script.sol';
import { NounsDescriptorV2 } from '../contracts/NounsDescriptorV2.sol';
import { ISVGRenderer } from '../contracts/interfaces/ISVGRenderer.sol';
import { IInflator } from '../contracts/interfaces/IInflator.sol';
import { INounsArt } from '../contracts/interfaces/INounsArt.sol';
import { NounsArt } from '../contracts/NounsArt.sol';

contract UpgradeDescriptorV2PopulateArtFromExisting is Script {
NounsDescriptorV2 public constant EXISTING_DESCRIPTOR = NounsDescriptorV2(0x6229c811D04501523C6058bfAAc29c91bb586268);
ISVGRenderer public constant EXISTING_RENDERER = ISVGRenderer(0x81d94554A4b072BFcd850205f0c79e97c92aab56);
IInflator public constant EXISTING_INFLATOR = IInflator(0xa2acee85Cd81c42BcAa1FeFA8eD2516b68872Dbe);
NounsArt public constant EXISTING_ART = NounsArt(0x48A7C62e2560d1336869D6550841222942768C49);

function run() external {
uint256 upgraderKey = vm.envUint('UPGRADER_KEY');
address upgrader = vm.addr(upgraderKey);

address palettePointer = EXISTING_ART.palettesPointers(0);

uint256 backgroundCount = EXISTING_DESCRIPTOR.backgroundCount();
string[] memory backgrounds = new string[](backgroundCount);
for (uint256 i = 0; i < backgroundCount; i++) {
backgrounds[i] = EXISTING_ART.backgrounds(i);
}

INounsArt.Trait memory bodies = EXISTING_ART.getBodiesTrait();
INounsArt.Trait memory accessories = EXISTING_ART.getAccessoriesTrait();
INounsArt.Trait memory heads = EXISTING_ART.getHeadsTrait();
INounsArt.Trait memory glasses = EXISTING_ART.getGlassesTrait();

INounsArt predictedArt = INounsArt(computeCreateAddress(upgrader, vm.getNonce(upgrader) + 1));

vm.startBroadcast(upgraderKey);

// Deploy new contracts
NounsDescriptorV2 descriptor = new NounsDescriptorV2(predictedArt, EXISTING_RENDERER);
new NounsArt(address(descriptor), EXISTING_INFLATOR);

// Populate new art contract using existing pointers
descriptor.setPalettePointer(0, palettePointer);
descriptor.addManyBackgrounds(backgrounds);

for (uint256 i = 0; i < bodies.storagePages.length; i++) {
descriptor.addBodiesFromPointer(
bodies.storagePages[i].pointer,
bodies.storagePages[i].decompressedLength,
bodies.storagePages[i].imageCount
);
}
for (uint256 i = 0; i < accessories.storagePages.length; i++) {
descriptor.addAccessoriesFromPointer(
accessories.storagePages[i].pointer,
accessories.storagePages[i].decompressedLength,
accessories.storagePages[i].imageCount
);
}
for (uint256 i = 0; i < heads.storagePages.length; i++) {
descriptor.addHeadsFromPointer(
heads.storagePages[i].pointer,
heads.storagePages[i].decompressedLength,
heads.storagePages[i].imageCount
);
}
for (uint256 i = 0; i < glasses.storagePages.length; i++) {
descriptor.addGlassesFromPointer(
glasses.storagePages[i].pointer,
glasses.storagePages[i].decompressedLength,
glasses.storagePages[i].imageCount
);
}
vm.stopBroadcast();
}
}
4 changes: 2 additions & 2 deletions packages/nouns-contracts/test/foundry/NounsArt.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ contract NounsArtTest is Test, DescriptorHelpers {

art.addBackground('ffffff');

assertEq(art.backgroundsCount(), 1);
assertEq(art.backgroundCount(), 1);
assertEq(art.backgrounds(0), 'ffffff');
}

Expand All @@ -122,7 +122,7 @@ contract NounsArtTest is Test, DescriptorHelpers {
vm.prank(descriptor);
art.addManyBackgrounds(bgs);

assertEq(art.backgroundsCount(), 2);
assertEq(art.backgroundCount(), 2);
assertEq(art.backgrounds(0), 'ffffff');
assertEq(art.backgrounds(1), '000000');
}
Expand Down
36 changes: 10 additions & 26 deletions packages/nouns-contracts/test/foundry/NounsDescriptorV2.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -133,49 +133,33 @@ contract NounsDescriptorV2Test is Test {
}

function testBackgroundCountUsesArt() public {
vm.mockCall(address(art), abi.encodeWithSelector(NounsArt.backgroundsCount.selector), abi.encode(42));
vm.mockCall(address(art), abi.encodeWithSelector(NounsArt.backgroundCount.selector), abi.encode(42));
assertEq(descriptor.backgroundCount(), 42);
vm.clearMockedCalls();
}

function testBodyCountUsesArt() public {
vm.mockCall(
address(art),
abi.encodeWithSelector(NounsArt.getBodiesTrait.selector),
abi.encode(INounsArt.Trait({ storedImagesCount: 42, storagePages: new INounsArt.NounArtStoragePage[](0) }))
);
vm.prank(address(descriptor));
art.addBodiesFromPointer(address(0), 1, 42);
assertEq(descriptor.bodyCount(), 42);
vm.clearMockedCalls();
}

function testAccessoryCountUsesArt() public {
vm.mockCall(
address(art),
abi.encodeWithSelector(NounsArt.getAccessoriesTrait.selector),
abi.encode(INounsArt.Trait({ storedImagesCount: 42, storagePages: new INounsArt.NounArtStoragePage[](0) }))
);
vm.prank(address(descriptor));
art.addAccessoriesFromPointer(address(0), 1, 42);
assertEq(descriptor.accessoryCount(), 42);
vm.clearMockedCalls();
}

function testHeadCountUsesArt() public {
vm.mockCall(
address(art),
abi.encodeWithSelector(NounsArt.getHeadsTrait.selector),
abi.encode(INounsArt.Trait({ storedImagesCount: 42, storagePages: new INounsArt.NounArtStoragePage[](0) }))
);
vm.prank(address(descriptor));
art.addHeadsFromPointer(address(0), 1, 42);
assertEq(descriptor.headCount(), 42);
vm.clearMockedCalls();
}

function testGlassesCountUsesArt() public {
vm.mockCall(
address(art),
abi.encodeWithSelector(NounsArt.getGlassesTrait.selector),
abi.encode(INounsArt.Trait({ storedImagesCount: 42, storagePages: new INounsArt.NounArtStoragePage[](0) }))
);
vm.prank(address(descriptor));
art.addGlassesFromPointer(address(0), 1, 42);
assertEq(descriptor.glassesCount(), 42);
vm.clearMockedCalls();
}

function testAddManyBackgroundsUsesArt() public {
Expand Down Expand Up @@ -477,7 +461,7 @@ contract NounsDescriptorV2Test is Test {
}

function _makeArtGettersNotRevert() internal {
vm.mockCall(address(art), abi.encodeWithSelector(NounsArt.backgroundsCount.selector), abi.encode(123));
vm.mockCall(address(art), abi.encodeWithSelector(INounsArt.backgroundCount.selector), abi.encode(123));
vm.mockCall(address(art), abi.encodeWithSelector(INounsArt.backgrounds.selector), abi.encode('return value'));
vm.mockCall(address(art), abi.encodeWithSelector(INounsArt.bodies.selector), abi.encode('return value'));
vm.mockCall(address(art), abi.encodeWithSelector(INounsArt.accessories.selector), abi.encode('return value'));
Expand Down
2 changes: 1 addition & 1 deletion packages/nouns-subgraph/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"mustache": "mustache"
},
"devDependencies": {
"@graphprotocol/graph-cli": "0.47.1",
"@graphprotocol/graph-cli": "0.51.0",
"@graphprotocol/graph-ts": "0.31.0",
"mustache": "4.2.0",
"matchstick-as": "0.5.0"
Expand Down
39 changes: 39 additions & 0 deletions packages/nouns-subgraph/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,9 @@ type Proposal @entity {
"Total supply when this proposal was created"
totalSupply: BigInt!

"Adjusted total supply when this proposal was created"
adjustedTotalSupply: BigInt!

"Dynamic quorum param snapshot: min quorum basis points"
minQuorumVotesBPS: Int!

Expand All @@ -280,6 +283,30 @@ type Proposal @entity {

"The block at which voting balance snapshots are taken for this proposal"
voteSnapshotBlock: BigInt!

"The block number at which this proposal was canceled"
canceledBlock: BigInt

"The timestamp when this proposal was canceled"
canceledTimestamp: BigInt

"The block number at which this proposal was executed"
executedBlock: BigInt

"The timestamp when this proposal was executed"
executedTimestamp: BigInt

"The block number at which this proposal was vetoed"
vetoedBlock: BigInt

"The timestamp when this proposal was vetoed"
vetoedTimestamp: BigInt

"The block number at which this proposal was queued"
queuedBlock: BigInt

"The timestamp when this proposal was queued"
queuedTimestamp: BigInt
}

type ProposalVersion @entity(immutable: true) {
Expand All @@ -288,6 +315,9 @@ type ProposalVersion @entity(immutable: true) {
"The proposal that was updated"
proposal: Proposal!

"The block number of the update"
createdBlock: BigInt!

"The block timestamp of the update"
createdAt: BigInt!

Expand Down Expand Up @@ -343,6 +373,9 @@ type Vote @entity {

"Block number of vote"
blockNumber: BigInt!

"The timestamp of the block the vote is in"
blockTimestamp: BigInt!
}

type Governance @entity {
Expand Down Expand Up @@ -520,6 +553,12 @@ type ProposalCandidateSignature @entity {

"Whether this signature has been canceled"
canceled: Boolean!

"The signature's creation timestamp"
createdTimestamp: BigInt!

"The signature's creation block"
createdBlock: BigInt!
}

type ProposalFeedback @entity(immutable: true) {
Expand Down
4 changes: 4 additions & 0 deletions packages/nouns-subgraph/src/custom-types/ParsedProposalV3.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { BigInt, Bytes } from '@graphprotocol/graph-ts';
import {
NounsDAO,
ProposalCreatedWithRequirements,
ProposalCreatedWithRequirements1,
} from '../types/NounsDAO/NounsDAO';
Expand All @@ -26,6 +27,7 @@ export class ParsedProposalV3 {
title: string = '';
status: string = '';
signers: string[] = [];
adjustedTotalSupply: BigInt = BIGINT_ZERO;

static fromV1Event(event: ProposalCreatedWithRequirements1): ParsedProposalV3 {
const proposal = new ParsedProposalV3();
Expand Down Expand Up @@ -54,6 +56,7 @@ export class ParsedProposalV3 {

static fromV3Event(event: ProposalCreatedWithRequirements): ParsedProposalV3 {
const proposal = new ParsedProposalV3();
const nounsDAO = NounsDAO.bind(event.address);

proposal.id = event.params.id.toString();
proposal.proposer = event.params.proposer.toHexString();
Expand All @@ -79,6 +82,7 @@ export class ParsedProposalV3 {
}

proposal.updatePeriodEndBlock = event.params.updatePeriodEndBlock;
proposal.adjustedTotalSupply = nounsDAO.adjustedTotalSupply();

return proposal;
}
Expand Down
2 changes: 2 additions & 0 deletions packages/nouns-subgraph/src/nouns-dao-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ export function handleSignatureAdded(event: SignatureAdded): void {
candidateSig.encodedProposalHash = event.params.encodedPropHash;
candidateSig.sigDigest = event.params.sigDigest;
candidateSig.reason = event.params.reason;
candidateSig.createdBlock = event.block.number;
candidateSig.createdTimestamp = event.block.timestamp;

candidateSig.save();
}
Expand Down
Loading

0 comments on commit 3c7725f

Please sign in to comment.