Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add bigbang #129

Merged
merged 1 commit into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ These solutions were combined with ideas from [Hats Protocol](https://www.hatspr

| ContractAddress | Name | Memo |
| ------------------------------------------ | ----------------------- | ---- |
| 0xf1af43dfca3fde2e73379d8f9da29513c1da8d87 | BigBang | |
| 0x5d7a64Cc808294C516076d371685ed4E6aDd6337 | BigBang | |
| 0xb8f7ca7a5b1e457b8735884419e114f90d53e1d5 | FractionToken | |
| 0x8da1c0864962c5e26c99cf839b0dc48e39104568 | SplitsCreatorFactory | |
| 0xda9fbab4436e4124cd6ee6864d4b46d0dd412414 | SplitsCreatorIMPL | |
Expand Down
228 changes: 228 additions & 0 deletions pkgs/cli/src/abi/bigbang.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,228 @@
export const BIGBANG_ABI = [
{
inputs: [
{
internalType: "address",
name: "_trustedForwarder",
type: "address",
},
{
internalType: "address",
name: "_hatsAddress",
type: "address",
},
{
internalType: "address",
name: "_hatsModuleFactory",
type: "address",
},
{
internalType: "address",
name: "_hatsTimeFrameModule_IMPL",
type: "address",
},
{
internalType: "address",
name: "_splitsCreatorFactory",
type: "address",
},
{
internalType: "address",
name: "_splitFactoryV2",
type: "address",
},
{
internalType: "address",
name: "_fractionToken",
type: "address",
},
],
stateMutability: "nonpayable",
type: "constructor",
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "address",
name: "owner",
type: "address",
},
{
indexed: true,
internalType: "uint256",
name: "topHatId",
type: "uint256",
},
{
indexed: false,
internalType: "address",
name: "hatsTimeFrameModule",
type: "address",
},
{
indexed: false,
internalType: "address",
name: "splitCreator",
type: "address",
},
],
name: "Executed",
type: "event",
},
{
inputs: [],
name: "Hats",
outputs: [
{
internalType: "contract IHats",
name: "",
type: "address",
},
],
stateMutability: "view",
type: "function",
},
{
inputs: [],
name: "HatsModuleFactory",
outputs: [
{
internalType: "contract IHatsModuleFactory",
name: "",
type: "address",
},
],
stateMutability: "view",
type: "function",
},
{
inputs: [],
name: "HatsTimeFrameModule_IMPL",
outputs: [
{
internalType: "address",
name: "",
type: "address",
},
],
stateMutability: "view",
type: "function",
},
{
inputs: [],
name: "SplitsCreatorFactory",
outputs: [
{
internalType: "contract ISplitsCreatorFactory",
name: "",
type: "address",
},
],
stateMutability: "view",
type: "function",
},
{
inputs: [
{
internalType: "address",
name: "_owner",
type: "address",
},
{
internalType: "string",
name: "_topHatDetails",
type: "string",
},
{
internalType: "string",
name: "_topHatImageURI",
type: "string",
},
{
internalType: "string",
name: "_hatterHatDetails",
type: "string",
},
{
internalType: "string",
name: "_hatterHatImageURI",
type: "string",
},
{
internalType: "address",
name: "_trustedForwarder",
type: "address",
},
],
name: "bigbang",
outputs: [
{
internalType: "uint256",
name: "",
type: "uint256",
},
],
stateMutability: "nonpayable",
type: "function",
},
{
inputs: [],
name: "fractionToken",
outputs: [
{
internalType: "address",
name: "",
type: "address",
},
],
stateMutability: "view",
type: "function",
},
{
inputs: [
{
internalType: "address",
name: "forwarder",
type: "address",
},
],
name: "isTrustedForwarder",
outputs: [
{
internalType: "bool",
name: "",
type: "bool",
},
],
stateMutability: "view",
type: "function",
},
{
inputs: [],
name: "splitFactoryV2",
outputs: [
{
internalType: "address",
name: "",
type: "address",
},
],
stateMutability: "view",
type: "function",
},
{
inputs: [],
name: "trustedForwarder",
outputs: [
{
internalType: "address",
name: "",
type: "address",
},
],
stateMutability: "view",
type: "function",
},
] as const;
35 changes: 35 additions & 0 deletions pkgs/cli/src/commands/bigbang.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { Command } from "commander";
import { bigbang } from "../modules/bigbang";
import { zeroAddress } from "viem";

export const bigbangCommands = new Command();

bigbangCommands
.name("bigbang")
.description("This is a CLI bigbang for toban project")
.version("1.0.0");

bigbangCommands
.command("create")
.description("Create project")
.requiredOption("-o, --owner <owner>", "Owner")
.requiredOption("-td, --topHatDetails <topHatDetails>", "Top hat details")
.requiredOption("-ti, --topHatImageURI <topHatImageURI>", "Top hat image URI")
.option("-hd, --hatterHatDetails <hatterHatDetails>", "Hatter hat details")
.option(
"-hi, --hatterHatImageURI <hatterHatImageURI>",
"Hatter hat image URI"
)
.option("-f, --trustedForwarder <trustedForwarder>", "Trusted forwarder")
.action(async (options) => {
const hash = await bigbang({
owner: options.owner,
topHatDetails: options.topHatDetails,
topHatImageURI: options.topHatImageURI,
hatterHatDetails: options.hatterHatDetails || "",
hatterHatImageURI: options.hatterHatImageURI || "",
trustedForwarder: options.trustedForwarder || zeroAddress,
});

console.log(`Transaction hash: ${hash}`);
});
6 changes: 6 additions & 0 deletions pkgs/cli/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Address } from "viem";
import { HATS_ABI } from "./abi/hats";
import { HATS_TIME_FRAME_MODULE_ABI } from "./abi/hatsTimeFrameModule";
import { BIGBANG_ABI } from "./abi/bigbang";

export const skipPreActionCommands = ["wallet>add", "wallet>list"];

Expand All @@ -13,3 +14,8 @@ export const hatsTimeFrameContractBaseConfig = {
address: "0xd4a66507ea8c8382fa8474ed6cae4163676a434a" as Address,
abi: HATS_TIME_FRAME_MODULE_ABI,
};

export const bigbangContractBaseConfig = {
address: "0x5d7a64Cc808294C516076d371685ed4E6aDd6337" as Address,
abi: BIGBANG_ABI,
};
2 changes: 2 additions & 0 deletions pkgs/cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { PublicClient, WalletClient } from "viem";
import { getPublicClient } from "./modules/viem";
import { getWalletClient } from "./services/wallet";
import { skipPreActionCommands } from "./config";
import { bigbangCommands } from "./commands/bigbang";

export const rootProgram = new Command();

Expand All @@ -29,6 +30,7 @@ rootProgram
}
});

rootProgram.addCommand(bigbangCommands);
rootProgram.addCommand(hatsCommands);
rootProgram.addCommand(walletCommands);

Expand Down
37 changes: 37 additions & 0 deletions pkgs/cli/src/modules/bigbang.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// ###############################################################
// Write with viem
// ###############################################################

import { Address } from "viem";
import { publicClient, walletClient } from "..";
import { bigbangContractBaseConfig } from "../config";

/**
* プロジェクト作成
*/

export const bigbang = async (params: {
owner: Address;
topHatDetails: string;
topHatImageURI: string;
hatterHatDetails: string;
hatterHatImageURI: string;
trustedForwarder: Address;
}) => {
const { request } = await publicClient.simulateContract({
...bigbangContractBaseConfig,
account: walletClient.account,
functionName: "bigbang",
args: [
params.owner,
params.topHatDetails,
params.topHatImageURI,
params.hatterHatDetails,
params.hatterHatImageURI,
params.trustedForwarder,
],
});
const transactionHash = await walletClient.writeContract(request);

return transactionHash;
};
Loading