-
Notifications
You must be signed in to change notification settings - Fork 434
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #804 from nounsDAO/soli-optimize-trait-count-getters
Optimize Art Contract Trait Count Getters
- Loading branch information
Showing
8 changed files
with
1,595 additions
and
36 deletions.
There are no files selected for viewing
732 changes: 732 additions & 0 deletions
732
...ontracts/broadcast/UpgradeDescriptorV2PopulateArtFromExisting.s.sol/1/run-1696560894.json
Large diffs are not rendered by default.
Oops, something went wrong.
732 changes: 732 additions & 0 deletions
732
...ns-contracts/broadcast/UpgradeDescriptorV2PopulateArtFromExisting.s.sol/1/run-latest.json
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
packages/nouns-contracts/script/UpgradeDescriptorV2PopulateArtFromExisting.s.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters