From 011d30550f525952af90df0b94b0a1ba1d891ee4 Mon Sep 17 00:00:00 2001 From: Jongwon Park Date: Fri, 26 Jan 2024 17:02:29 -0800 Subject: [PATCH] fix: remove unused files & modify script/configs --- Makefile | 18 +- hardhat.config.js | 72 ---- hardhat.config.ts | 3 - .../foundry/post-deployment/Integration.s.sol | 322 ------------------ .../post-deployment/00-combined-flow.ts | 74 ---- .../hardhat/post-deployment/00-mint-mock.ts | 21 -- .../post-deployment/01-create-ipaccounts.ts | 0 .../post-deployment/02-create-policies.ts | 0 .../post-deployment/03-create-licenses.ts | 0 .../post-deployment/04-link-ipaccounts.ts | 0 .../post-deployment/05-tag-ipaccounts.ts | 0 .../post-deployment/99-revert-chain.ts | 19 -- .../hardhat/post-deployment/combined-flow.ts | 121 ------- script/hardhat/post-deployment/flow.ts | 0 script/hardhat/post-deployment/read-chain.ts | 43 --- .../hardhat/post-deployment/verify-hardhat.ts | 0 .../post-deployment/verify-tenderly.ts | 148 -------- 17 files changed, 8 insertions(+), 833 deletions(-) delete mode 100644 hardhat.config.js delete mode 100644 script/foundry/post-deployment/Integration.s.sol delete mode 100644 script/hardhat/post-deployment/00-combined-flow.ts delete mode 100644 script/hardhat/post-deployment/00-mint-mock.ts delete mode 100644 script/hardhat/post-deployment/01-create-ipaccounts.ts delete mode 100644 script/hardhat/post-deployment/02-create-policies.ts delete mode 100644 script/hardhat/post-deployment/03-create-licenses.ts delete mode 100644 script/hardhat/post-deployment/04-link-ipaccounts.ts delete mode 100644 script/hardhat/post-deployment/05-tag-ipaccounts.ts delete mode 100644 script/hardhat/post-deployment/99-revert-chain.ts delete mode 100644 script/hardhat/post-deployment/combined-flow.ts delete mode 100644 script/hardhat/post-deployment/flow.ts delete mode 100644 script/hardhat/post-deployment/read-chain.ts delete mode 100644 script/hardhat/post-deployment/verify-hardhat.ts delete mode 100644 script/hardhat/post-deployment/verify-tenderly.ts diff --git a/Makefile b/Makefile index 784f8d617..61d747749 100644 --- a/Makefile +++ b/Makefile @@ -33,12 +33,18 @@ snapshot :; forge snapshot slither :; slither ./contracts -format :; npx prettier --write contracts/**/*.sol && npx prettier --write contracts/*.sol +# glob doesn't work for nested folders, so we do it manually +format: + npx prettier --write contracts/*.sol + npx prettier --write contracts/**/*.sol + npx prettier --write contracts/**/**/*.sol + npx prettier --write contracts/**/**/**/*.sol + npx prettier --write contracts/**/**/**/**/*.sol coverage: mkdir -p coverage forge coverage --report lcov --fork-url https://rpc.ankr.com/eth --fork-block-number 19042069 - lcov --remove lcov.info -o lcov.info 'test/*' + lcov --remove lcov.info -o lcov.info 'test/*' 'script/*' 'contracts/mocks/*' genhtml lcov.info --output-dir coverage abi: @@ -77,11 +83,3 @@ deploy-tenderly: rm -rf deployments/hardhat/*.json npx hardhat run script/hardhat/post-deployment/99-revert-chain.ts --network tenderly npx hardhat run script/hardhat/deployment/00-deploy-main.ts --network tenderly - -verify-access-controller: - forge verify-contract \ - --chain sepolia \ - --etherscan-api-key ${ETHERSCAN_API_KEY} \ - --watch 0xB76441f5802DBfA7244C904871F3747E371C3C78 \ - --libraries contracts/lib/registries/IPAccountChecker.sol:IPAccountChecker:0x4a2C3Fb88aCe93224A496749Ff6c5D4Ef6Db443b \ - contracts/AccessController.sol:AccessController \ No newline at end of file diff --git a/hardhat.config.js b/hardhat.config.js deleted file mode 100644 index e699e4233..000000000 --- a/hardhat.config.js +++ /dev/null @@ -1,72 +0,0 @@ -require("dotenv").config() -require("hardhat-deploy") - -require("@nomiclabs/hardhat-etherscan") -require("@nomiclabs/hardhat-waffle") -require("hardhat-gas-reporter") -require("solidity-coverage") -require("@nomiclabs/hardhat-ethers") -require("@nomiclabs/hardhat-etherscan") -require("@openzeppelin/hardhat-upgrades") -require("@nomicfoundation/hardhat-foundry") - -// This is a sample Hardhat task. To learn how to create your own go to -// https://hardhat.org/guides/create-task.html -// eslint-disable-next-line no-undef -task("accounts", "Prints the list of accounts", async (taskArgs, hre) => { - const accounts = await hre.ethers.getSigners() - - for (const account of accounts) { - console.log(account.address) - } -}) - -// You need to export an object to set up your config -// Go to https://hardhat.org/config/ to learn more - -/** - * @type import('hardhat/config').HardhatUserConfig - */ -module.exports = { - networks: { - mainnet: { - url: process.env.MAINNET_URL || "", - chainId: 1, - accounts: [ - process.env.MAINNET_PRIVATEKEY || "0x1234567890123456789012345678901234567890123456789012345678901234", - ], - }, - goerli: { - url: process.env.GOERLI_URL || "", - chainId: 5, - accounts: [ - process.env.GOERLI_PRIVATEKEY || "0x1234567890123456789012345678901234567890123456789012345678901234", - ], - }, - }, - gasReporter: { - enabled: process.env.REPORT_GAS !== undefined, - currency: "USD", - }, - solidity: { - version: "0.8.18", - settings: { - optimizer: { - enabled: true, - runs: 2000, - }, - }, - }, - etherscan: { - apiKey: `${process.env.ETHERSCAN_API_KEY}`, - }, - paths: { - sources: "./contracts", - tests: "./test", - cache: "./cache", - artifacts: "./artifacts", - }, - mocha: { - timeout: 20000, - }, -} diff --git a/hardhat.config.ts b/hardhat.config.ts index 77a027610..5f2dbd265 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -35,9 +35,6 @@ const COINMARKETCAP_API_KEY = process.env.COINMARKETCAP_API_KEY || "key" const config: HardhatUserConfig = { solidity: { compilers: [ - { - version: "0.8.18", - }, { version: "0.8.23", }, diff --git a/script/foundry/post-deployment/Integration.s.sol b/script/foundry/post-deployment/Integration.s.sol deleted file mode 100644 index 7998d608e..000000000 --- a/script/foundry/post-deployment/Integration.s.sol +++ /dev/null @@ -1,322 +0,0 @@ -/* solhint-disable no-console */ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.23; - -import { Script } from "forge-std/Script.sol"; -import { Test } from "forge-std/Test.sol"; -import { stdJson } from "forge-std/StdJson.sol"; - -import { EnumerableSet } from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; -import { ERC6551Registry } from "lib/reference/src/ERC6551Registry.sol"; -import { IERC6551Account } from "lib/reference/src/interfaces/IERC6551Account.sol"; - -import { AccessController } from "contracts/AccessController.sol"; -import { IPAccountImpl } from "contracts/IPAccountImpl.sol"; -import { IIPAccount } from "contracts/interfaces/IIPAccount.sol"; -import { IParamVerifier } from "contracts/interfaces/licensing/IParamVerifier.sol"; -import { Licensing } from "contracts/lib/Licensing.sol"; -import { RegistrationModule } from "contracts/modules/RegistrationModule.sol"; -import { DisputeModule } from "contracts/modules/dispute-module/DisputeModule.sol"; -import { TaggingModule } from "contracts/modules/tagging/TaggingModule.sol"; -import { IPAccountRegistry } from "contracts/registries/IPAccountRegistry.sol"; -import { LicenseRegistry } from "contracts/registries/LicenseRegistry.sol"; -import { ModuleRegistry } from "contracts/registries/ModuleRegistry.sol"; -import { IPResolver } from "contracts/resolvers/IPResolver.sol"; - -import { MockERC20 } from "test/foundry/mocks/MockERC20.sol"; -import { MockERC721 } from "test/foundry/mocks/MockERC721.sol"; -import { MockModule } from "test/foundry/mocks/MockModule.sol"; -import { MockIParamVerifier } from "test/foundry/mocks/licensing/MockParamVerifier.sol"; -import { MintPaymentVerifier } from "test/foundry/mocks/licensing/MintPaymentVerifier.sol"; -import { Users, UsersLib } from "test/foundry/utils/Users.sol"; -// script -import { StringUtil } from "script/foundry/utils/StringUtil.sol"; -import { BroadcastManager } from "script/foundry/utils/BroadcastManager.s.sol"; -import { JsonDeploymentHandler } from "script/foundry/utils/JsonDeploymentHandler.s.sol"; - -contract Integration is Script, BroadcastManager, JsonDeploymentHandler { - using StringUtil for uint256; - using stdJson for string; - - using EnumerableSet for EnumerableSet.UintSet; - - AccessController internal accessController = AccessController(0x97738c808F032226B26bF3d292261976c7c6D530); - ERC6551Registry internal erc6551Registry = ERC6551Registry(0x000000006551c19487814612e58FE06813775758); - IPAccountImpl internal ipacctImpl = IPAccountImpl(payable(0x97527BB0435B28836489ac3E1577cA1e2a099371)); - IPAccountRegistry internal ipacctRegistry = IPAccountRegistry(0x12054FC0F26F979b271dE691358FeDCF5a1DAe65); - LicenseRegistry internal licenseRegistry = LicenseRegistry(0xe2Cb2839a1840F3f6bfC2d5508B4a60bF81C1738); - ModuleRegistry internal moduleRegistry = ModuleRegistry(0xE48ce7F62Ddcc0339b0B4ca56A600aA31bc4479c); - DisputeModule internal disputeModule = DisputeModule(0x9e94233357f3Ff8FEc75E45cF759f48937CA985d); - RegistrationModule internal registrationModule = RegistrationModule(0x72632232caBF975dA1AedCB46062844E16234713); - IPResolver internal ipResolver = IPResolver(0x88f3a4cc4Eaa2433c44A7c502C7AbBd2C76b03e2); - TaggingModule internal taggingModule = TaggingModule(0xC00744062741d2256e13a267aa9f30d186bfF610); - // RegistrationModule internal registrationModule = new RegistrationModule( - // address(accessController), - // address(ipacctRegistry), - // address(moduleRegistry), - // address(licenseRegistry), - // address(0x000000006551c19487814612e58FE06813775758) - // ); - - // Sepolia mock tokens - MockERC20 internal mockToken = MockERC20(0xeA12CB8429736Db937d6C727b003a9D94cCf5DF3); - MockERC721 internal nft = MockERC721(0xB464F4582e62F6eB3CF506E4135f92BD198EB03E); - // MockIParamVerifier public mockLicenseVerifier = new MockIParamVerifier(); - // MintPaymentVerifier internal mintPaymentVerifier; - - // IPAccounts - mapping(address userAddr => mapping(MockERC721 nft => mapping(uint256 tokenId => address ipId))) internal ipacct; - - // NFT Token IDs List by User - mapping(address userAddr => mapping(MockERC721 nft => uint256[] tokenIds)) internal token; - - // NFT Token IDs Set by User - mapping(address userAddr => mapping(MockERC721 nft => EnumerableSet.UintSet tokenIdSet)) internal tokenSet; - - mapping(string frameworkName => Licensing.FrameworkCreationParams) internal licenseFwCreations; - - mapping(string frameworkName => uint256 frameworkId) internal licenseFwIds; - mapping(uint256 frameworkId => string frameworkName) internal licenseFwNames; // reverse of licenseFwIds - - mapping(string policyName => Licensing.Policy) internal policy; - - mapping(string policyName => mapping(address userAddr => uint256 policyId)) internal policyIds; - - mapping(address userAddr => mapping(uint256 policyId => uint256 licenseId)) internal licenseIds; - - mapping(address userAddr => uint256 balance) internal mockTokenBalanceBefore; - - mapping(address userAddr => uint256 balance) internal mockTokenBalanceAfter; - - address internal admin; - - constructor() JsonDeploymentHandler("pd-integration") {} - - function setUp() public { - // accessController.initialize(address(ipacctRegistry), address(moduleRegistry)); - // moduleRegistry.registerModule("REGISTRATION_MODULE", address(registrationModule)); - // moduleRegistry.registerModule("METADATA_RESOLVER_MODULE", address(ipResolver)); - // moduleRegistry.registerModule("TAGGING_MODULE", address(taggingModule)); - } - - function run() public { - _beginBroadcast(); - - admin = deployer; - - taggingModule.setTag("luxury", ipacctRegistry.ipAccount(block.chainid, address(nft), 1)); - taggingModule.setTag("authentic", ipacctRegistry.ipAccount(block.chainid, address(nft), 2)); - taggingModule.setTag("premium", ipacctRegistry.ipAccount(block.chainid, address(nft), 3)); - - // uint256 id1 = mintNFT(admin, nft); - // uint256 id2 = mintNFT(admin, nft); - // uint256 id3 = mintNFT(admin, nft); - // uint256 id4 = mintNFT(admin, nft); - - // // registerIPAccount(admin, nft, token[admin][nft][0]); - // // registerIPAccount(admin, nft, token[admin][nft][1]); - // registrationModule.registerRootIp(0, address(nft), id1); - - // // wildcard allow - // IIPAccount(payable(getIpId(admin, nft, 1))).execute( - // address(accessController), - // 0, - // abi.encodeWithSignature( - // "setPermission(address,address,address,bytes4,uint8)", - // getIpId(admin, nft, 1), - // admin, - // address(0), - // bytes4(0), - // 1 // AccessPermission.ALLOW - // ) - // ); - - // /*/////////////////////////////////////////////////////////////// - // CREATE LICENSE FRAMEWORKS - // ////////////////////////////////////////////////////////////////*/ - - // // All trues for MockVerifier means it will always return true on condition checks - // bytes[] memory byteValueTrue = new bytes[](1); - // byteValueTrue[0] = abi.encode(true); - - // // Licensing.FrameworkCreationParams memory fwAllTrue = Licensing.FrameworkCreationParams({ - // // mintingParamVerifiers: new IParamVerifier[](1), - // // mintingParamDefaultValues: byteValueTrue, - // // activationParamVerifiers: new IParamVerifier[](1), - // // activationParamDefaultValues: byteValueTrue, - // // defaultNeedsActivation: true, - // // linkParentParamVerifiers: new IParamVerifier[](1), - // // linkParentParamDefaultValues: byteValueTrue, - // // licenseUrl: "https://very-nice-verifier-license.com" - // // }); - // Licensing.FrameworkCreationParams memory fwAllTrue = Licensing.FrameworkCreationParams({ - // mintingParamVerifiers: new IParamVerifier[](0), - // mintingParamDefaultValues: new bytes[](0), - // // mintingParamDefaultValues: byteValueTrue, - // activationParamVerifiers: new IParamVerifier[](0), - // activationParamDefaultValues: new bytes[](0), - // // activationParamDefaultValues: byteValueTrue, - // defaultNeedsActivation: true, - // linkParentParamVerifiers: new IParamVerifier[](0), - // linkParentParamDefaultValues: new bytes[](0), - // // linkParentParamDefaultValues: byteValueTrue, - // licenseUrl: "https://very-nice-verifier-license.com" - // }); - - // // fwAllTrue.mintingParamVerifiers[0] = mockLicenseVerifier; - // // fwAllTrue.activationParamVerifiers[0] = mockLicenseVerifier; - // // fwAllTrue.linkParentParamVerifiers[0] = mockLicenseVerifier; - - // Licensing.FrameworkCreationParams memory fwMintPayment = Licensing.FrameworkCreationParams({ - // mintingParamVerifiers: new IParamVerifier[](0), - // mintingParamDefaultValues: new bytes[](0), - // // mintingParamVerifiers: new IParamVerifier[](1), - // // mintingParamDefaultValues: byteValueTrue, // value here doesn't matter for MintPaymentVerifier - // activationParamVerifiers: new IParamVerifier[](0), - // activationParamDefaultValues: new bytes[](0), - // defaultNeedsActivation: false, - // linkParentParamVerifiers: new IParamVerifier[](0), - // linkParentParamDefaultValues: new bytes[](0), - // licenseUrl: "https://expensive-minting-license.com" - // }); - - // // fwMintPayment.mintingParamVerifiers[0] = mintPaymentVerifier; - - // addLicenseFramework("all_true", fwAllTrue); - // addLicenseFramework("mint_payment", fwMintPayment); - - // // /*/////////////////////////////////////////////////////////////// - // // CREATE POLICIES - // // ////////////////////////////////////////////////////////////////*/ - - // policy["test_true"] = Licensing.Policy({ - // frameworkId: licenseFwIds["all_true"], - // mintingParamValues: new bytes[](0), - // activationParamValues: new bytes[](0), - // needsActivation: true, - // linkParentParamValues: new bytes[](0) - // }); - - // policy["expensive_mint"] = Licensing.Policy({ - // frameworkId: licenseFwIds["mint_payment"], - // mintingParamValues: new bytes[](0), - // activationParamValues: new bytes[](0), - // needsActivation: false, - // linkParentParamValues: new bytes[](0) - // }); - - // (uint256 policyId_test_true, ) = licenseRegistry.addPolicy(policy["test_true"]); - // (uint256 policyId_exp_mint, ) = licenseRegistry.addPolicy(policy["expensive_mint"]); - - // /*/////////////////////////////////////////////////////////////// - // ADD POLICIES TO IPACCOUNTS - // ////////////////////////////////////////////////////////////////*/ - - // attachPolicyToIPID(getIpId(admin, nft, 1), "test_true"); - // attachPolicyToIPID(getIpId(admin, nft, 2), "expensive_mint"); - - // registrationModule.registerRootIp(0, address(nft), 1); - // registrationModule.registerDerivativeIP - - // /*/////////////////////////////////////////////////////////////// - // MINT LICENSES ON POLICIES - // ////////////////////////////////////////////////////////////////*/ - - // Licensing.License memory licenseData = Licensing.License({ - // policyId: policyIds["test_true"][getIpId(admin, nft, 1)], - // licensorIpIds: new address[](1) - // }); - // licenseData.licensorIpIds[0] = getIpId(admin, nft, 1); - - // // Mints 1 license for policy "test_true" on NFT id 1 IPAccount - // licenseIds[admin][policyIds["test_true"][getIpId(admin, nft, 1)]] = licenseRegistry.mintLicense( - // licenseData, - // 1, - // admin - // ); - - // /*/////////////////////////////////////////////////////////////// - // LINK IPACCOUNTS TO PARENTS USING LICENSES - // ////////////////////////////////////////////////////////////////*/ - - // // Activate above license on NFT id 2 IPAccount, linking as child to NFT id 1 IPAccount - - // licenseRegistry.linkIpToParent( - // licenseIds[admin][policyIds["test_true"][getIpId(admin, nft, 1)]], - // getIpId(admin, nft, 2), - // admin - // ); - _endBroadcast(); - } - - function mintNFT(address to, MockERC721 mnft) internal returns (uint256 tokenId) { - tokenId = mnft.mint(to); - token[to][mnft].push(tokenId); - tokenSet[to][mnft].add(tokenId); - } - - function transferNFT(address from, address to, MockERC721 mnft, uint256 tokenId) internal { - removeIdFromTokenData(from, mnft, tokenId); - token[to][mnft].push(tokenId); - tokenSet[to][mnft].add(tokenId); - mnft.transferFrom(from, to, tokenId); - } - - function removeIdFromTokenData(address user, MockERC721 mnft, uint256 tokenId) internal { - uint256[] storage arr = token[user][mnft]; - require(tokenSet[user][mnft].contains(tokenId), "tokenId not found in tokenSet"); - uint256 index = tokenId - 1; // tokenId starts from 1 - require(index < arr.length, "tokenId index out of range"); - // remove certain index from array while maintaing order - for (uint256 i = index; i < arr.length - 1; ++i) { - arr[i] = arr[i + 1]; - } - arr.pop(); - // delete arr[arr.length - 1]; - // arr.length--; - tokenSet[user][mnft].remove(tokenId); - } - - function registerIPAccount(address user, MockERC721 mnft, uint256 tokenId) public returns (address ipId) { - ipId = ipacctRegistry.registerIpAccount(block.chainid, address(mnft), tokenId); - ipacct[user][mnft][tokenId] = ipId; - } - - function getIpId(address user, MockERC721 mnft, uint256 tokenId) public view returns (address ipId) { - require(mnft.ownerOf(tokenId) == user, "getIpId: not owner"); - ipId = ipacct[user][mnft][tokenId]; - require(ipId == ipacctRegistry.ipAccount(block.chainid, address(mnft), tokenId)); - } - - function addLicenseFramework( - string memory name, - Licensing.FrameworkCreationParams memory params - ) public returns (uint256 fwId) { - require(licenseFwIds[name] == 0, "Framework already exists"); - licenseFwCreations[name] = params; - fwId = licenseRegistry.addLicenseFramework(params); - - licenseFwIds[name] = fwId; - licenseFwNames[fwId] = name; - } - - function attachPolicyToIPID( - address ipId, - string memory policyName - ) public returns (uint256 policyId, bool isNew, uint256 indexOnIpId) { - (policyId, isNew, indexOnIpId) = licenseRegistry.addPolicyToIp(ipId, policy[policyName]); - policyIds[policyName][ipId] = policyId; - } - - function attachPolicyAndMintLicenseForIPID( - address ipId, - string memory policyName, - address licensee, - uint256 amount - ) public returns (uint256 licenseId) { - (uint256 policyId, bool isNew, uint256 indexOnIpId) = attachPolicyToIPID(ipId, policyName); - address[] memory licensorIpIds = new address[](1); - licenseId = licenseRegistry.mintLicense(policyId, licensorIpIds, amount, licensee); - licenseIds[licensee][policyId] = licenseId; - } -} diff --git a/script/hardhat/post-deployment/00-combined-flow.ts b/script/hardhat/post-deployment/00-combined-flow.ts deleted file mode 100644 index 27d44547d..000000000 --- a/script/hardhat/post-deployment/00-combined-flow.ts +++ /dev/null @@ -1,74 +0,0 @@ -import type { AddressLike, BytesLike, ContractTransactionReceipt } from "ethers" -import hre from "hardhat" -import { DeployResult } from "hardhat-deploy/dist/types" - -import * as deployedAll from "../../out/all.json" -import { type DeployedContracts, getDeployedContracts } from "../utils/deployed" -import { MockAsset } from "../utils/mock-assets" -import { Licensing } from "../../../typechain/contracts/registries/LicenseRegistry" - -async function runCombinedFlow() { - const { deployments, getNamedAccounts, network, ethers } = hre - const { deployer } = await getNamedAccounts() - const deployerSigner = await ethers.getSigner(deployer) - const chainId = network.config.chainId as number - - const c = getDeployedContracts(deployerSigner) - const ma = new MockAsset(deployerSigner) - - await ma.mint20(deployer, 100) - let tokenId = await ma.mint721(deployer) - - // grant access control - // register IPAccount through registration module - _createLicenseFrameworks(c, { - licenseUrl: "https://example.com/license/{id}.json", - }) - // create policy from framework - // attach policy to IPAccount - // mint licenses - // link IPAccounts to parents using licenses - - let tx = await c.IPRecordRegistry.createIPAccount(chainId, ma.addr.MockNFT, tokenId) - console.log(tx) -} - -interface CreateLicenseFrameworkParams { - minting?: { - paramVerifiers: AddressLike[] - paramDefaultValues: BytesLike[] - } - activation?: { - paramVerifiers: AddressLike[] - paramDefaultValues: BytesLike[] - } - linkParent?: { - paramVerifiers: AddressLike[] - paramDefaultValues: BytesLike[] - } - defaultNeedsActivation?: boolean - licenseUrl: string -} - -async function _createLicenseFrameworks(c: DeployedContracts, p: CreateLicenseFrameworkParams) { - const fwParams: Licensing.FrameworkCreationParamsStruct = { - mintingParamVerifiers: p.minting?.paramVerifiers || [], - mintingParamDefaultValues: p.minting?.paramDefaultValues || [], - activationParamVerifiers: p.activation?.paramVerifiers || [], - activationParamDefaultValues: p.activation?.paramDefaultValues || [], - defaultNeedsActivation: p.defaultNeedsActivation || false, - linkParentParamVerifiers: p.linkParent?.paramVerifiers || [], - linkParentParamDefaultValues: p.linkParent?.paramDefaultValues || [], - licenseUrl: p.licenseUrl, - } - - const txRes = await c.LicenseRegistry.addLicenseFramework(fwParams) - const receipt = await txRes.wait() as ContractTransactionReceipt - receipt.logs.find((l) => l.topics[0] === c.LicenseRegistry.interface.getEvent("LicenseFrameworkCreated").topicHash) - const event = receipt.events?.find((e) => e.event === "LicenseFrameworkCreated") -} - -runCombinedFlow().catch((error) => { - console.error(error) - process.exitCode = 1 -}) diff --git a/script/hardhat/post-deployment/00-mint-mock.ts b/script/hardhat/post-deployment/00-mint-mock.ts deleted file mode 100644 index 93ece3309..000000000 --- a/script/hardhat/post-deployment/00-mint-mock.ts +++ /dev/null @@ -1,21 +0,0 @@ -import hre from "hardhat" - -import * as mockAddresses from "../../out/mock.json" -import { MockERC20__factory, MockERC721__factory } from "../../../typechain" - -async function runFlow() { - const { getNamedAccounts, ethers } = hre - const { deployer } = await getNamedAccounts() - const deployerSigner = await ethers.getSigner(deployer) - - const MockToken = MockERC20__factory.connect(mockAddresses.MockToken, deployerSigner) - const MockNFT = MockERC721__factory.connect(mockAddresses.MockNFT, deployerSigner) - - await MockToken.mint(deployer, 100 * (await MockToken.decimals())) - await MockNFT.mint(deployer) -} - -runFlow().catch((error) => { - console.error(error) - process.exitCode = 1 -}) diff --git a/script/hardhat/post-deployment/01-create-ipaccounts.ts b/script/hardhat/post-deployment/01-create-ipaccounts.ts deleted file mode 100644 index e69de29bb..000000000 diff --git a/script/hardhat/post-deployment/02-create-policies.ts b/script/hardhat/post-deployment/02-create-policies.ts deleted file mode 100644 index e69de29bb..000000000 diff --git a/script/hardhat/post-deployment/03-create-licenses.ts b/script/hardhat/post-deployment/03-create-licenses.ts deleted file mode 100644 index e69de29bb..000000000 diff --git a/script/hardhat/post-deployment/04-link-ipaccounts.ts b/script/hardhat/post-deployment/04-link-ipaccounts.ts deleted file mode 100644 index e69de29bb..000000000 diff --git a/script/hardhat/post-deployment/05-tag-ipaccounts.ts b/script/hardhat/post-deployment/05-tag-ipaccounts.ts deleted file mode 100644 index e69de29bb..000000000 diff --git a/script/hardhat/post-deployment/99-revert-chain.ts b/script/hardhat/post-deployment/99-revert-chain.ts deleted file mode 100644 index d74a86e47..000000000 --- a/script/hardhat/post-deployment/99-revert-chain.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { JsonRpcProvider } from "ethers" -import hre from "hardhat" -import { DeployResult, DeployOptions } from "hardhat-deploy/dist/types" - -import * as checkpointJson from "../../out/checkpoint.json" - -async function revertChainToCheckpoint() { - const provider = new JsonRpcProvider((hre.network.config as { url: string }).url) - const checkpoint = checkpointJson.checkpoint - - await provider.send("evm_revert", [checkpoint]) - - console.log(`Reverted to checkpoint: ${checkpoint}`) -} - -revertChainToCheckpoint().catch((error) => { - console.error(error) - process.exitCode = 1 -}) diff --git a/script/hardhat/post-deployment/combined-flow.ts b/script/hardhat/post-deployment/combined-flow.ts deleted file mode 100644 index 87c2b90f6..000000000 --- a/script/hardhat/post-deployment/combined-flow.ts +++ /dev/null @@ -1,121 +0,0 @@ -import type { AddressLike, BaseContract, BytesLike, ContractTransactionReceipt, EventLog } from "ethers" -import hre from "hardhat" - -import * as deployedAll from "../../out/all.json" -import { type DeployedContracts, getDeployedContracts } from "../utils/deployed" -import { MockAsset } from "../utils/mock-assets" -import { Licensing } from "../../../typechain/contracts/registries/LicenseRegistry" -import { TypedEvent, TypedEventFilter } from "../utils/interfaces" - -async function runCombinedFlow() { - const { deployments, getNamedAccounts, network, ethers } = hre - const { deployer } = await getNamedAccounts() - const deployerSigner = await ethers.getSigner(deployer) - const chainId = network.config.chainId as number - - const c = getDeployedContracts(deployerSigner) - const ma = new MockAsset(deployerSigner) - - await ma.mint20(deployer, 100) - let tokenId = await ma.mint721(deployer) - - // grant access control - // register IPAccount through registration module - _createLicenseFrameworks(c, { - licenseUrl: "https://example.com/license/{id}.json", - }) - // create policy from framework - // attach policy to IPAccount - // mint licenses - // link IPAccounts to parents using licenses - - let tx = await c.IPRecordRegistry.createIPAccount(chainId, ma.addr.MockNFT, tokenId) - console.log(tx) -} - -interface CreateLicenseFrameworkParams { - minting?: { - paramVerifiers: AddressLike[] - paramDefaultValues: BytesLike[] - } - activation?: { - paramVerifiers: AddressLike[] - paramDefaultValues: BytesLike[] - } - linkParent?: { - paramVerifiers: AddressLike[] - paramDefaultValues: BytesLike[] - } - defaultNeedsActivation?: boolean - licenseUrl: string -} - -async function _createLicenseFrameworks(c: DeployedContracts, p: CreateLicenseFrameworkParams) { - const fwParams: Licensing.FrameworkCreationParamsStruct = { - mintingParamVerifiers: p.minting?.paramVerifiers || [], - mintingParamDefaultValues: p.minting?.paramDefaultValues || [], - activationParamVerifiers: p.activation?.paramVerifiers || [], - activationParamDefaultValues: p.activation?.paramDefaultValues || [], - defaultNeedsActivation: p.defaultNeedsActivation || false, - linkParentParamVerifiers: p.linkParent?.paramVerifiers || [], - linkParentParamDefaultValues: p.linkParent?.paramDefaultValues || [], - licenseUrl: p.licenseUrl, - } - - const txRes = await c.LicenseRegistry.addLicenseFramework(fwParams) - const receipt = (await txRes.wait()) as ContractTransactionReceipt - - // c.LicenseRegistry.filters["LicenseFrameworkCreated(address,uint256,tuple)"] - // const events = await c.LicenseRegistry.queryTransaction(txRes.hash) - // c.LicenseRegistry.interface.parseLog(receipt.logs[0]) - // c.LicenseRegistry.interface.decodeEventLog("LicenseFrameworkCreated", receipt.logs[0].data, receipt.logs[0].topics) - - const events = receipt.logs.map((log) => - c.LicenseRegistry.interface.parseLog({ topics: log.topics as string[], data: log.data }) - ) - - console.dir(receipt.logs) - console.log("====================================") - console.dir(events) -} - -// export function matchEvents( -// events: EventLog[], -// contract: BaseContract, -// eventFilter: TypedEventFilter> -// ): TypedEvent[] { -// const topics = eventFilter.topics || [] -// return events -// .filter((ev) => matchTopics(topics, ev.topics)) -// .map((ev) => { -// const args = contract.interface.parseLog(ev).args -// const result: TypedEvent = { -// ...ev, -// args: args as TArgsArray & TArgsObject, -// } -// return result -// }) -// } - -// function matchTopics(filter: TopicFilter | undefined, value: Array): boolean { -// // Implement the logic for topic filtering as described here: -// // https://docs.ethers.io/v5/concepts/events/#events--filters -// if (!filter) { -// return false -// } -// for (let i = 0; i < filter.length; i++) { -// const f = filter[i] -// const v = value[i] -// if (typeof f == "string") { -// if (f !== v) return false -// } else { -// if (f.indexOf(v) === -1) return false -// } -// } -// return true -// } - -runCombinedFlow().catch((error) => { - console.error(error) - process.exitCode = 1 -}) diff --git a/script/hardhat/post-deployment/flow.ts b/script/hardhat/post-deployment/flow.ts deleted file mode 100644 index e69de29bb..000000000 diff --git a/script/hardhat/post-deployment/read-chain.ts b/script/hardhat/post-deployment/read-chain.ts deleted file mode 100644 index ede92505e..000000000 --- a/script/hardhat/post-deployment/read-chain.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { - JsonRpcProvider, - type AddressLike, - type BaseContract, - type BytesLike, - type ContractTransactionReceipt, - type EventLog, - keccak256, - hexlify, -} from "ethers" -import hre from "hardhat" - -import * as deployedAll from "../../out/all.json" -import { type DeployedContracts, getDeployedContracts } from "../utils/deployed" -import { MockAsset } from "../utils/mock-assets" -import { Licensing } from "../../../typechain/contracts/registries/LicenseRegistry" - -async function runReadChain() { - const { deployments, getNamedAccounts, network, ethers } = hre - const { deployer } = await getNamedAccounts() - const deployerSigner = await ethers.getSigner(deployer) - const chainId = network.config.chainId as number - - const provider = new JsonRpcProvider((network.config as { url: string }).url) - - const c = getDeployedContracts(deployerSigner) - - const txHash = "0xd8f41fad8851dc30d92d7fd4566d4c9280d02f01089f186326ccf9c8cddb483e" - const receipt = await provider.getTransactionReceipt(txHash) as ContractTransactionReceipt - - const topicHash = keccak256(hexlify("IPAccountRegistered(address,address,uint256,address,address)")) - - console.log('topicHash', topicHash) - - console.dir(receipt.logs) - // console.log("====================================") - -} - -runReadChain().catch((error) => { - console.error(error) - process.exitCode = 1 -}) diff --git a/script/hardhat/post-deployment/verify-hardhat.ts b/script/hardhat/post-deployment/verify-hardhat.ts deleted file mode 100644 index e69de29bb..000000000 diff --git a/script/hardhat/post-deployment/verify-tenderly.ts b/script/hardhat/post-deployment/verify-tenderly.ts deleted file mode 100644 index aba3dc581..000000000 --- a/script/hardhat/post-deployment/verify-tenderly.ts +++ /dev/null @@ -1,148 +0,0 @@ -import { readFileSync } from "fs" -import { tenderly } from "hardhat" - -import * as addr from "../../../deployments/deployment-1.json" - -require("dotenv").config() - -async function main() { - const ERC6551_REGISTRY = "0x000000006551c19487814612e58FE06813775758" - - if (!process.env.TENDERLY_FORK_RPC_URL) throw new Error("TENDERLY_FORK_RPC_URL not set") - const TENDERLY_FORK_ID = process.env.TENDERLY_FORK_RPC_URL.split("/").pop() ?? "" - - const _contracts = [ - { - address: addr.AccessController, - name: "AccessController", - // libraries: { - // name1: addr.AccessControlLibrary, - // } - }, - { - address: addr.IPAccountImpl, - name: "IPAccountImpl", - }, - { - address: addr.ModuleRegistry, - name: "ModuleRegistry", - }, - - { - address: addr.LicenseRegistry, - name: "LicenseRegistry", - arguments: ["https://example.com/{id}.json"], - }, - - { - address: addr.IPAccountRegistry, - name: "IPAccountRegistry", - arguments: [ERC6551_REGISTRY, addr.AccessController, addr.IPAccountImpl], - }, - - { - address: addr.IPRecordRegistry, - name: "IPRecordRegistry", - arguments: [addr.ModuleRegistry, addr.IPAccountRegistry], - }, - - { - address: addr.IPMetadataResolver, - name: "IPMetadataResolver", - arguments: [addr.AccessController, addr.IPRecordRegistry, addr.IPAccountRegistry, addr.LicenseRegistry], - }, - - { - address: addr.RegistrationModule, - name: "RegistrationModule", - arguments: [ - addr.AccessController, - addr.IPRecordRegistry, - addr.IPAccountRegistry, - addr.LicenseRegistry, - addr.IPMetadataResolver, - ], - }, - - { - address: addr.TaggingModule, - name: "TaggingModule", - }, - - { - address: addr.RoyaltyModule, - name: "RoyaltyModule", - }, - - { - address: addr.DisputeModule, - name: "DisputeModule", - }, - ] - - // tenderly.verify( - // _contracts.map((c) => ({ - // ...c, - // compiler: { - // version: "0.8.23", - // settings: { - // optimizer: { - // enabled: true, - // runs: 20000, - // }, - // }, - // }, - // })) - // ) - - const contracts = [ - // TenderlyContract[] (https://github.com/Tenderly/hardhat-tenderly/blob/b2a7831388f064483234d0583d7baeea599d332f/packages/tenderly-core/src/internal/core/types/Contract.ts#L16C18-L16C34) - // { - // contractName: "AccessController", - // source: readFileSync("contracts/AccessController.sol", "utf-8").toString(), - // sourcePath: "AccessController.sol", - // networks: { - // [TENDERLY_FORK_ID]: { - // address: addr.AccessController, - // links: {}, - // }, - // }, - // }, - { - contractName: "IPAccountImpl", - source: readFileSync("contracts/IPAccountImpl.sol", "utf-8").toString(), - sourcePath: "IPAccountImpl.sol", - networks: { - [TENDERLY_FORK_ID]: { - address: addr.IPAccountImpl, - links: {}, - }, - }, - }, - ] - - const request = { - // TenderlyForkContractUploadRequest (https://github.com/Tenderly/hardhat-tenderly/blob/b2a7831388f064483234d0583d7baeea599d332f/packages/tenderly-core/src/internal/core/types/Requests.ts#L13) - root: "", - config: { - // TenderlyContractConfig (https://github.com/Tenderly/hardhat-tenderly/blob/b2a7831388f064483234d0583d7baeea599d332f/packages/tenderly-core/src/internal/core/types/Contract.ts#L4) - compiler_version: "0.8.23", - optimizations_used: true, - optimizations_count: 20000, - evm_version: "default", - }, - contracts, - } - - tenderly.verifyForkAPI( - request, - process.env.TENDERLY_PROJECT_SLUG ?? "", - process.env.TENDERLY_USERNAME ?? "", - TENDERLY_FORK_ID - ) -} - -main().catch((error) => { - console.error(error) - process.exitCode = 1 -})