Skip to content

Commit

Permalink
deployed contract. updated script to have preminter as address
Browse files Browse the repository at this point in the history
  • Loading branch information
oveddan committed Jun 13, 2023
1 parent 33d7642 commit 9d8e204
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 31 deletions.
7 changes: 4 additions & 3 deletions addresses/999.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"FACTORY_PROXY": "0x6a357139C1bcDcf0B3AB9bC447932dDdcb956703",
"FIXED_PRICE_SALE_STRATEGY": "0xd81351363b7d80b06E4Ec4De7989f0f91e41A846",
"MERKLE_MINT_SALE_STRATEGY": "0x2c4457D38A329526063b26a2bB2C31B61553Aa98",
"PREMINTER": "0xAa2c4F9e2EB8c94bcf12771bb09f7B1cc8486D12",
"REDEEM_MINTER_FACTORY": "0x27817bAef1341De9Ad04097Bbba4Ea8dA32c8552",
"timestamp": 1684354070,
"commit": "8f9a781"
}
"timestamp": 1686690340,
"commit": "33d7642"
}
31 changes: 20 additions & 11 deletions package/preminter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ describe("ZoraCreator1155Preminter", () => {
contractAdmin: creatorAccount,
contractURI: "ipfs://asdfasdfasdf",
contractName: "My fun NFT",

};

const tokenConfig: TokenCreationConfig = {
Expand All @@ -123,7 +122,7 @@ describe("ZoraCreator1155Preminter", () => {
royaltyMintSchedule: 30,
royaltyBPS: 200,
royaltyRecipient: creatorAccount,
uid: 1n
uid: 1n,
};

const signedMessage = await walletClient.signTypedData({
Expand All @@ -149,13 +148,11 @@ describe("ZoraCreator1155Preminter", () => {
it<TestContext>(
"can sign and mint multiple tokens",
async ({ preminterAddress, zoraMintFee }) => {

// setup contract and token creation parameters
const contractConfig: ContractCreationConfig = {
contractAdmin: creatorAccount,
contractURI: "ipfs://asdfasdfasdf",
contractName: "My fun NFT",

};

const tokenConfig: TokenCreationConfig = {
Expand All @@ -167,7 +164,7 @@ describe("ZoraCreator1155Preminter", () => {
royaltyMintSchedule: 30,
royaltyBPS: 200,
royaltyRecipient: creatorAccount,
uid: 1n
uid: 1n,
};

// have creator sign the message to create the contract
Expand All @@ -188,7 +185,7 @@ describe("ZoraCreator1155Preminter", () => {
const valueToSend =
(zoraMintFee + tokenConfig.pricePerToken) * quantityToMint;

const comment = 'I love this!';
const comment = "I love this!";

// now have the collector execute the first signed message;
// it should create the contract, the token,
Expand All @@ -200,7 +197,13 @@ describe("ZoraCreator1155Preminter", () => {
functionName: "premint",
account: collectorAccount,
address: preminterAddress,
args: [contractConfig, tokenConfig, signedMessage, quantityToMint, comment],
args: [
contractConfig,
tokenConfig,
signedMessage,
quantityToMint,
comment,
],
value: valueToSend,
});

Expand All @@ -216,8 +219,8 @@ describe("ZoraCreator1155Preminter", () => {
abi: preminterAbi,
address: preminterAddress,
functionName: "contractDataHash",
args: [contractConfig]
})
args: [contractConfig],
});

const createdContractAddress = await publicClient.readContract({
abi: preminterAbi,
Expand All @@ -242,7 +245,7 @@ describe("ZoraCreator1155Preminter", () => {
...tokenConfig,
tokenURI: "ipfs://tokenIpfsId2",
pricePerToken: parseEther("0.05"),
uid: 2n
uid: 2n,
};

const signedMessage2 = await walletClient.signTypedData({
Expand All @@ -266,7 +269,13 @@ describe("ZoraCreator1155Preminter", () => {
functionName: "premint",
account: collectorAccount,
address: preminterAddress,
args: [contractConfig, tokenConfig2, signedMessage2, quantityToMint2, comment],
args: [
contractConfig,
tokenConfig2,
signedMessage2,
quantityToMint2,
comment,
],
value: valueToSend2,
});

Expand Down
8 changes: 3 additions & 5 deletions package/preminter.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { Address } from "abitype";
import { ExtractAbiFunction, AbiParametersToPrimitiveTypes } from "abitype";
import { zoraCreator1155PreminterABI as preminterAbi } from "./wagmiGenerated";
import {
TypedDataDefinition,
} from "viem";
import { TypedDataDefinition } from "viem";

type PreminterHashInputs = ExtractAbiFunction<
typeof preminterAbi,
Expand Down Expand Up @@ -37,7 +35,7 @@ export const preminterTypedDataDefinition = ({
ContractCreationConfig: [
{ name: "contractAdmin", type: "address" },
{ name: "contractURI", type: "string" },
{ name: "contractName", type: "string" }
{ name: "contractName", type: "string" },
],
TokenCreationConfig: [
{ name: "tokenURI", type: "string" },
Expand All @@ -48,7 +46,7 @@ export const preminterTypedDataDefinition = ({
{ name: "royaltyMintSchedule", type: "uint32" },
{ name: "royaltyBPS", type: "uint32" },
{ name: "royaltyRecipient", type: "address" },
{ name: 'uid', type: 'uint256'}
{ name: "uid", type: "uint256" },
],
};

Expand Down
4 changes: 2 additions & 2 deletions script/DeployPreminter.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ contract DeployPreminter is ZoraDeployerBase {
function run() public returns (string memory) {
Deployment memory deployment = getDeployment();

address deployer = vm.envAddress("DEPLOYER");
uint256 deployerPrivateKey = vm.envUint("DEPLOYER_PRIVATE_KEY");

ZoraCreator1155FactoryImpl factory = ZoraCreator1155FactoryImpl(deployment.factoryProxy);

IMinter1155 fixedPricedMinter = factory.fixedPriceMinter();

vm.startBroadcast(deployer);
vm.startBroadcast(deployerPrivateKey);

ZoraCreator1155Preminter preminter = new ZoraCreator1155Preminter();
preminter.initialize(factory, fixedPricedMinter);
Expand Down
18 changes: 10 additions & 8 deletions script/copy-deployed-contracts.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ import { writeFile, readFile } from "fs/promises";
import esMain from "es-main";
import { glob } from "glob";

async function copyEnvironmentRunFiles(isDeploy) {
async function copyEnvironmentRunFiles(scriptName) {
const latestFiles = await glob(
isDeploy
? "broadcast/Deploy.s.sol/*/run-latest.json"
: "broadcast/Upgrade.s.sol/*/run-latest.json"
`broadcast/${scriptName}/*/run-latest.json`
);

for (const file of latestFiles) {
Expand Down Expand Up @@ -41,9 +39,13 @@ async function copyEnvironmentRunFiles(isDeploy) {

if (esMain(import.meta)) {
const command = process.argv[2];
let deploy = false;
if (command === "deploy") {
deploy = true;
let scriptName = 'Deploy.s.sol';

if (command === "upgrade"){
scriptName = 'Upgrade.s.sol';
} else if (command === 'deploy-premint') {
scriptName = 'DeployPreminter.s.sol'
}
await copyEnvironmentRunFiles(deploy);

await copyEnvironmentRunFiles(scriptName);
}
6 changes: 4 additions & 2 deletions wagmi.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ const getAddresses = () => {
const addAddress = (
contractName: ContractNames,
chainId: number,
address: Address
address?: Address
) => {
if (!address) return;
if (!addresses[contractName]) {
addresses[contractName] = {};
}
Expand All @@ -56,7 +57,7 @@ const getAddresses = () => {
"1155_IMPL": Address;
FACTORY_IMPL: Address;
FACTORY_PROXY: Address;
PREMINTER: Address;
PREMINTER?: Address;
};

const chainId = parseInt(addressesFile.split(".")[0]);
Expand All @@ -81,6 +82,7 @@ const getAddresses = () => {
chainId,
jsonAddress.REDEEM_MINTER_FACTORY
);
addAddress("ZoraCreator1155Preminter", chainId, jsonAddress.PREMINTER);
}

return addresses;
Expand Down

0 comments on commit 9d8e204

Please sign in to comment.