diff --git a/packages/foundry/package.json b/packages/foundry/package.json index 9bf2836..883439c 100644 --- a/packages/foundry/package.json +++ b/packages/foundry/package.json @@ -1,6 +1,7 @@ { "name": "@se-2/foundry", "version": "0.0.1", + "type": "module", "scripts": { "account": "node script/ListAccount.js", "chain": "anvil --config-out localhost.json", diff --git a/packages/foundry/script/generateTsAbis.js b/packages/foundry/script/generateTsAbis.js index 699c914..0184352 100644 --- a/packages/foundry/script/generateTsAbis.js +++ b/packages/foundry/script/generateTsAbis.js @@ -1,8 +1,16 @@ -const fs = require("fs"); -const path = require("path"); -//@ts-expect-error This script runs after `forge deploy` therefore its deterministic that it will present -// const deployments = require("../deployments.json"); -const prettier = require("prettier"); +import { + readdirSync, + statSync, + readFileSync, + existsSync, + mkdirSync, + writeFileSync, +} from "fs"; +import { join, dirname } from "path"; +import { fileURLToPath } from "url"; +import { format } from "prettier"; + +const __dirname = dirname(fileURLToPath(import.meta.url)); const generatedContractComment = ` /** @@ -12,23 +20,23 @@ const generatedContractComment = ` `; function getDirectories(path) { - return fs.readdirSync(path).filter(function (file) { - return fs.statSync(path + "/" + file).isDirectory(); + return readdirSync(path).filter(function (file) { + return statSync(path + "/" + file).isDirectory(); }); } function getFiles(path) { - return fs.readdirSync(path).filter(function (file) { - return fs.statSync(path + "/" + file).isFile(); + return readdirSync(path).filter(function (file) { + return statSync(path + "/" + file).isFile(); }); } function getArtifactOfContract(contractName) { - const current_path_to_artifacts = path.join( + const current_path_to_artifacts = join( __dirname, "..", `out/${contractName}.sol` ); const artifactJson = JSON.parse( - fs.readFileSync(`${current_path_to_artifacts}/${contractName}.json`) + readFileSync(`${current_path_to_artifacts}/${contractName}.json`) ); return artifactJson; @@ -68,12 +76,12 @@ function getInheritedFunctions(mainArtifact) { } function main() { - const current_path_to_broadcast = path.join( + const current_path_to_broadcast = join( __dirname, "..", "broadcast/Deploy.s.sol" ); - const current_path_to_deployments = path.join(__dirname, "..", "deployments"); + const current_path_to_deployments = join(__dirname, "..", "deployments"); const chains = getDirectories(current_path_to_broadcast); const Deploymentchains = getFiles(current_path_to_deployments); @@ -84,7 +92,7 @@ function main() { if (!chain.endsWith(".json")) return; chain = chain.slice(0, -5); var deploymentObject = JSON.parse( - fs.readFileSync(`${current_path_to_deployments}/${chain}.json`) + readFileSync(`${current_path_to_deployments}/${chain}.json`) ); deployments[chain] = deploymentObject; }); @@ -94,7 +102,7 @@ function main() { chains.forEach((chain) => { allGeneratedContracts[chain] = {}; const broadCastObject = JSON.parse( - fs.readFileSync(`${current_path_to_broadcast}/${chain}/run-latest.json`) + readFileSync(`${current_path_to_broadcast}/${chain}/run-latest.json`) ); const transactionsCreate = broadCastObject.transactions.filter( (transaction) => transaction.transactionType == "CREATE" @@ -125,12 +133,12 @@ function main() { "" ); - if (!fs.existsSync(TARGET_DIR)) { - fs.mkdirSync(TARGET_DIR); + if (!existsSync(TARGET_DIR)) { + mkdirSync(TARGET_DIR); } - fs.writeFileSync( + writeFileSync( `${TARGET_DIR}deployedContracts.ts`, - prettier.format( + format( `${generatedContractComment} import { GenericContractsDeclaration } from "~~/utils/scaffold-eth/contract"; \n\n const deployedContracts = {${fileContent}} as const; \n\n export default deployedContracts satisfies GenericContractsDeclaration`, { @@ -145,4 +153,4 @@ try { } catch (error) { console.error(error); process.exitCode = 1; -} +} \ No newline at end of file diff --git a/packages/nextjs/contracts/deployedContracts.ts b/packages/nextjs/contracts/deployedContracts.ts index 62216e6..a47e94c 100644 --- a/packages/nextjs/contracts/deployedContracts.ts +++ b/packages/nextjs/contracts/deployedContracts.ts @@ -7,7 +7,7 @@ import { GenericContractsDeclaration } from "~~/utils/scaffold-eth/contract"; const deployedContracts = { 31337: { ReputationTokens: { - address: "0x7bc06c482dead17c0e297afbc32f6e63d3846650", + address: "0x8bee2037448f096900fd9affc427d38ae6cc0350", abi: [ { type: "constructor", @@ -1410,7 +1410,7 @@ const deployedContracts = { }, }, ReputationFaucet: { - address: "0x922d6956c99e12dfeb3224dea977d0939758a1fe", + address: "0xe1708fa6bb2844d5384613ef0846f9bc1e8ec55e", abi: [ { type: "constructor", @@ -1535,7 +1535,7 @@ const deployedContracts = { }, }, Hats: { - address: "0x21df544947ba3e8b3c32561399e88b52dc8b2823", + address: "0x683d9cdd3239e0e01e8dc6315fa50ad92ab71d2d", abi: [ { type: "constructor", @@ -3496,7 +3496,7 @@ const deployedContracts = { }, }, MultiClaimsHatter: { - address: "0xdc11f7e700a4c898ae5caddb1082cffa76512add", + address: "0x71a0b8a2245a9770a4d887ce1e4ecc6c1d4ff28c", abi: [ { type: "constructor", @@ -3822,7 +3822,7 @@ const deployedContracts = { }, }, ActiveModule: { - address: "0x36b58f5c1969b7b6591d752ea6f5486d069010ab", + address: "0xae120f0df055428e45b264e7794a18c54a2a3faf", abi: [ { type: "function", @@ -3852,7 +3852,7 @@ const deployedContracts = { inheritedFunctions: {}, }, ERC1155EligibiltiyModule: { - address: "0x202cce504e04bed6fc0521238ddf04bc9e8e15ab", + address: "0x01e21d7b8c39dc4c764c19b308bd8b14b1ba139e", abi: [ { type: "constructor", @@ -3903,7 +3903,7 @@ const deployedContracts = { inheritedFunctions: {}, }, ReputationTokensUpgradeable: { - address: "0xbec49fa140acaa83533fb00a2bb19bddd0290f25", + address: "0x547382c0d1b23f707918d3c83a77317b71aa8470", abi: [ { type: "function", @@ -5326,7 +5326,7 @@ const deployedContracts = { }, }, ReputationTokensFactory: { - address: "0xd84379ceae14aa33c123af12424a37803f885889", + address: "0x7c8baafa542c57ff9b2b90612bf8ab9e86e22c09", abi: [ { type: "constructor", @@ -5699,7 +5699,15 @@ const deployedContracts = { inputs: [], }, ], - inheritedFunctions: {}, + inheritedFunctions: { + DEFAULT_ADMIN_ROLE: "lib/openzeppelin-contracts/contracts/access/AccessControl.sol", + getRoleAdmin: "lib/openzeppelin-contracts/contracts/access/AccessControl.sol", + grantRole: "lib/openzeppelin-contracts/contracts/access/AccessControl.sol", + hasRole: "lib/openzeppelin-contracts/contracts/access/AccessControl.sol", + renounceRole: "lib/openzeppelin-contracts/contracts/access/AccessControl.sol", + revokeRole: "lib/openzeppelin-contracts/contracts/access/AccessControl.sol", + supportsInterface: "lib/openzeppelin-contracts/contracts/access/AccessControl.sol", + }, }, }, } as const;