Skip to content

Commit

Permalink
okb support
Browse files Browse the repository at this point in the history
  • Loading branch information
channing-magiceden committed Feb 25, 2024
1 parent 4eac692 commit d6147b9
Show file tree
Hide file tree
Showing 8 changed files with 826 additions and 27 deletions.
706 changes: 706 additions & 0 deletions contracts/Animal.sol

Large diffs are not rendered by default.

46 changes: 46 additions & 0 deletions contracts/AnimalRoyalties.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//SPDX-License-Identifier: MIT

pragma solidity ^0.8.4;

import {ERC2981, UpdatableRoyalties} from "./royalties/UpdatableRoyalties.sol";
import {Animal, ERC721ACQueryable, IERC721A} from "./Animal.sol";

/**
* @title AnimalRoyalties
*/
contract AnimalRoyalties is Animal, UpdatableRoyalties {
constructor(
string memory collectionName,
string memory collectionSymbol,
string memory tokenURISuffix,
uint256 maxMintableSupply,
uint256 globalWalletLimit,
address cosigner,
uint64 timestampExpirySeconds,
address mintCurrency,
address royaltyReceiver,
uint96 royaltyFeeNumerator
)
Animal(
collectionName,
collectionSymbol,
tokenURISuffix,
maxMintableSupply,
globalWalletLimit,
cosigner,
timestampExpirySeconds,
mintCurrency
)
UpdatableRoyalties(royaltyReceiver, royaltyFeeNumerator)
{}

function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(ERC2981, ERC721ACQueryable, IERC721A)
returns (bool)
{
return super.supportsInterface(interfaceId);
}
}
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
},
"devDependencies": {
"@ethersproject/abstract-provider": "^5.7.0",
"@ethersproject/solidity": "^5.7.0",
"@nomicfoundation/hardhat-network-helpers": "^1.0.6",
"@nomiclabs/hardhat-ethers": "^2.1.1",
"@nomiclabs/hardhat-etherscan": "^3.1.0",
Expand Down
6 changes: 4 additions & 2 deletions scripts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@ export const deploy = async (
let contractName: string = ContractDetails.ERC721M.name;

if (args.useerc721c && args.useerc2198) {
contractName = ContractDetails.ERC721CMRoyalties.name;
contractName = 'AnimalRoyalties';
//contractName = ContractDetails.ERC721CMRoyalties.name;
} else if (args.useerc721c) {
contractName = ContractDetails.ERC721CM.name;
contractName = 'Animal';
//contractName = ContractDetails.ERC721CM.name;
} else if (args.useoperatorfilterer) {
if (args.increasesupply) {
contractName = ContractDetails.ERC721MIncreasableOperatorFilterer.name;
Expand Down
82 changes: 57 additions & 25 deletions scripts/setStages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { MerkleTree } from 'merkletreejs';
import fs from 'fs';
import { ContractDetails } from './common/constants';
import { estimateGas } from './utils/helper';
import { keccak256 } from '@ethersproject/solidity';

export interface ISetStagesParams {
stages: string;
Expand All @@ -18,6 +19,7 @@ interface StageConfig {
walletLimit?: number;
maxSupply?: number;
whitelistPath?: string;
variableLimitPath?: string;
}

export const setStages = async (
Expand All @@ -39,33 +41,63 @@ export const setStages = async (
}
const merkleRoots = await Promise.all(
stagesConfig.map((stage) => {
if (!stage.whitelistPath) {
return ethers.utils.hexZeroPad('0x', 32);
}
const whitelist = JSON.parse(
fs.readFileSync(stage.whitelistPath, 'utf-8'),
);

// Clean up whitelist
const filteredWhitelist= whitelist.filter((address: string) => ethers.utils.isAddress(address));
console.log(`Filtered whitelist: ${filteredWhitelist.length} addresses. ${whitelist.length - filteredWhitelist.length} invalid addresses removed.`);
const invalidWhitelist= whitelist.filter((address: string) => !ethers.utils.isAddress(address));
console.log(`❌ Invalid whitelist: ${invalidWhitelist.length} addresses.\r\n${invalidWhitelist.join(', \r\n')}`);

if (invalidWhitelist.length > 0) {
console.log(`🔄 🚨 updating whitelist file: ${stage.whitelistPath}`);
fs.writeFileSync(stage.whitelistPath, JSON.stringify(filteredWhitelist, null, 2))
if (stage.whitelistPath) {
const whitelist = JSON.parse(
fs.readFileSync(stage.whitelistPath, 'utf-8'),
);

// Clean up whitelist
const filteredWhitelist= whitelist.filter((address: string) => ethers.utils.isAddress(address));
console.log(`Filtered whitelist: ${filteredWhitelist.length} addresses. ${whitelist.length - filteredWhitelist.length} invalid addresses removed.`);
const invalidWhitelist= whitelist.filter((address: string) => !ethers.utils.isAddress(address));
console.log(`❌ Invalid whitelist: ${invalidWhitelist.length} addresses.\r\n${invalidWhitelist.join(', \r\n')}`);

if (invalidWhitelist.length > 0) {
console.log(`🔄 🚨 updating whitelist file: ${stage.whitelistPath}`);
fs.writeFileSync(stage.whitelistPath, JSON.stringify(filteredWhitelist, null, 2))
}

const mt = new MerkleTree(
filteredWhitelist.map(ethers.utils.getAddress),
ethers.utils.keccak256,
{
sortPairs: true,
hashLeaves: true,
},
);
return mt.getHexRoot();
} else if (stage.variableLimitPath) {
const leaves: any[] = [];
const file = fs.readFileSync(stage.variableLimitPath, 'utf-8');
file.split('\n').filter(line => line).forEach(line => {
const [addressStr, limitStr] = line.split(',');
const address = ethers.utils.getAddress(addressStr.toLowerCase().trim());
const limit = parseInt(limitStr, 10)

const digest = keccak256(
[
'address',
'uint32',
],
[
address,
limit,
],
);
leaves.push(digest);
});
const mt = new MerkleTree(
leaves,
ethers.utils.keccak256,
{
sortPairs: true,
hashLeaves: true,
},
);
return mt.getHexRoot();
}

const mt = new MerkleTree(
filteredWhitelist.map(ethers.utils.getAddress),
ethers.utils.keccak256,
{
sortPairs: true,
hashLeaves: true,
},
);
return mt.getHexRoot();
return ethers.utils.hexZeroPad('0x', 32);
}),
);

Expand Down
9 changes: 9 additions & 0 deletions stages.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[
{
"price": "0.00",
"walletLimit": 100,
"startDate": "2024-02-25T08:45:00.000Z",
"endDate": "2024-12-20T00:00:01.000Z",
"variableLimitPath": "/Users/channingmao/Documents/MagicEden/magiceden-oss/erc721m/variableWalletLimit.txt"
}
]
2 changes: 2 additions & 0 deletions variableWalletLimit.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
0xef59F379B48f2E92aBD94ADcBf714D170967925D, 99
0x9aE2DF1709FF8BccFc3B24623f84f7d919cb0a71, 12

0 comments on commit d6147b9

Please sign in to comment.