Skip to content

Commit

Permalink
progress on factory interactions
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobHomanics committed May 27, 2024
1 parent 0a9c4ea commit eb9a86d
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 46 deletions.
15 changes: 7 additions & 8 deletions packages/foundry/script/DeployFactory.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ pragma solidity ^0.8.19;
import {console} from "forge-std/console.sol";

import {ScaffoldETHDeploy} from "./DeployHelpers.s.sol";
import {ReputationTokensFactory} from
"@atxdao/contracts/reputation/ReputationTokensFactory.sol";
import {ReputationTokensUpgradeable} from
"@atxdao/contracts/reputation/ReputationTokensUpgradeable.sol";
import {ReputationTokensFactory} from "@atxdao/contracts/reputation/ReputationTokensFactory.sol";
import {ReputationTokensUpgradeable} from "@atxdao/contracts/reputation/ReputationTokensUpgradeable.sol";

contract DeployFactoryScript is ScaffoldETHDeploy {
error InvalidPrivateKey(string);
Expand All @@ -28,9 +26,10 @@ contract DeployFactoryScript is ScaffoldETHDeploy {
admins[0] = deployerPubKey;
admins[1] = controller;

ReputationTokensUpgradeable implementation =
new ReputationTokensUpgradeable();
ReputationTokensFactory factory =
new ReputationTokensFactory(admins, admins, address(implementation));
ReputationTokensUpgradeable implementation = new ReputationTokensUpgradeable();
ReputationTokensFactory factory = new ReputationTokensFactory(
admins,
address(implementation)
);
}
}
32 changes: 32 additions & 0 deletions packages/nextjs/app/factory/_components/Factory.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,43 @@
"use client";

import { useAccount } from "wagmi";
import { useScaffoldWatchContractEvent, useScaffoldWriteContract } from "~~/hooks/scaffold-eth";

export function Factory() {
const account = useAccount();

const { writeContractAsync: writeFactoryAsync } = useScaffoldWriteContract("ReputationTokensFactory");

useScaffoldWatchContractEvent({
contractName: "ReputationTokensFactory",
eventName: "CreatedNewInstance",
// The onLogs function is called whenever a GreetingChange event is emitted by the contract.
// Parameters emitted by the event can be destructed using the below example
// for this example: event GreetingChange(address greetingSetter, string newGreeting, bool premium, uint256 value);
onLogs: logs => {
logs.map(log => {
const { instance } = log.args;
console.log("📡 Factory create", instance);
});
},
});

return (
<>
<div className="py-5 space-y-5 flex flex-col justify-center items-center bg-primary bg-[length:100%_100%] py-1 px-5 sm:px-0 lg:py-auto max-w-[100vw] ">
<div className="flex flex-row justify-center items-center">
<div className="flex flex-col justify-center items-center">
<button
className="btn btn-secondary"
onClick={async () => {
await writeFactoryAsync({
functionName: "createNewInstance",
args: [account?.address, [account.address!]],
});
}}
>
Create Reputation Smart Contract
</button>
<p>{"hello"}</p>
</div>
</div>
Expand Down
74 changes: 37 additions & 37 deletions packages/nextjs/contracts/deployedContracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { GenericContractsDeclaration } from "~~/utils/scaffold-eth/contract";
const deployedContracts = {
31337: {
ReputationTokens: {
address: "0x5FbDB2315678afecb367f032d93F642f64180aa3",
address: "0x9e545e3c0baab3e08cdfd552c960a1050f373042",
abi: [
{
type: "constructor",
Expand Down Expand Up @@ -1447,7 +1447,7 @@ const deployedContracts = {
},
},
ReputationFaucet: {
address: "0x8A791620dd6260079BF849Dc5567aDC3F2FdC318",
address: "0x99bba657f2bbc93c02d617f8ba121cb8fc104acf",
abi: [
{
type: "constructor",
Expand Down Expand Up @@ -1572,7 +1572,7 @@ const deployedContracts = {
},
},
Hats: {
address: "0x3Aa5ebB10DC797CAC828524e59A333d0A371443c",
address: "0xb7278a61aa25c888815afc32ad3cc52ff24fe575",
abi: [
{
type: "constructor",
Expand Down Expand Up @@ -3533,7 +3533,7 @@ const deployedContracts = {
},
},
MultiClaimsHatter: {
address: "0x4ed7c70F96B99c776995fB64377f0d4aB3B0e1C1",
address: "0x2bdcc0de6be1f7d2ee689a0342d76f52e8efaba3",
abi: [
{
type: "constructor",
Expand Down Expand Up @@ -3859,7 +3859,7 @@ const deployedContracts = {
},
},
ActiveModule: {
address: "0xa85233C63b9Ee964Add6F2cffe00Fd84eb32338f",
address: "0x7bc06c482dead17c0e297afbc32f6e63d3846650",
abi: [
{
type: "function",
Expand Down Expand Up @@ -3889,7 +3889,7 @@ const deployedContracts = {
inheritedFunctions: {},
},
ERC1155EligibiltiyModule: {
address: "0x09635F643e140090A9A8Dcd712eD6285858ceBef",
address: "0xcbeaf3bde82155f56486fb5a1072cb8baaf547cc",
abi: [
{
type: "constructor",
Expand Down Expand Up @@ -3940,7 +3940,7 @@ const deployedContracts = {
inheritedFunctions: {},
},
ReputationTokensUpgradeable: {
address: "0xc3e53F4d16Ae77Db1c982e75a937B9f60FE63690",
address: "0x922d6956c99e12dfeb3224dea977d0939758a1fe",
abi: [
{
type: "function",
Expand Down Expand Up @@ -5400,7 +5400,7 @@ const deployedContracts = {
},
},
ReputationTokensFactory: {
address: "0x84eA74d481Ee0A5332c457a4d796187F6Ba67fEB",
address: "0x5081a39b8a5f0e35a8d959395a630b68b74dd30f",
abi: [
{
type: "constructor",
Expand All @@ -5411,12 +5411,7 @@ const deployedContracts = {
internalType: "address[]",
},
{
name: "_controllers",
type: "address[]",
internalType: "address[]",
},
{
name: "_implementation",
name: "implementation",
type: "address",
internalType: "address",
},
Expand Down Expand Up @@ -5547,19 +5542,6 @@ const deployedContracts = {
],
stateMutability: "view",
},
{
type: "function",
name: "implementation",
inputs: [],
outputs: [
{
name: "",
type: "address",
internalType: "address",
},
],
stateMutability: "view",
},
{
type: "function",
name: "instances",
Expand Down Expand Up @@ -5615,6 +5597,32 @@ const deployedContracts = {
outputs: [],
stateMutability: "nonpayable",
},
{
type: "function",
name: "s_implementation",
inputs: [],
outputs: [
{
name: "",
type: "address",
internalType: "address",
},
],
stateMutability: "view",
},
{
type: "function",
name: "setImplementation",
inputs: [
{
name: "implementation",
type: "address",
internalType: "address",
},
],
outputs: [],
stateMutability: "nonpayable",
},
{
type: "function",
name: "supportsInterface",
Expand All @@ -5639,7 +5647,7 @@ const deployedContracts = {
name: "CreatedNewInstance",
inputs: [
{
name: "",
name: "instance",
type: "address",
indexed: false,
internalType: "address",
Expand Down Expand Up @@ -5749,15 +5757,7 @@ const deployedContracts = {
inputs: [],
},
],
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",
},
inheritedFunctions: {},
},
},
} as const;
Expand Down

0 comments on commit eb9a86d

Please sign in to comment.