Skip to content

Commit

Permalink
biome fix
Browse files Browse the repository at this point in the history
  • Loading branch information
yu23ki14 committed Jan 9, 2025
1 parent 3b4ea10 commit a62a41f
Show file tree
Hide file tree
Showing 66 changed files with 677 additions and 499 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"editor.formatOnSave": true,
"editor.defaultFormatter": "biomejs.biome",
"[typescript]": {
"editor.defaultFormatter": "biomejs.biome",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
}
Expand All @@ -10,6 +11,5 @@
"editor.defaultFormatter": "jebbs.plantuml"
},
"files.insertFinalNewline": true,
"files.trimFinalNewlines": true,
"files.trimTrailingWhitespace": true
}
8 changes: 7 additions & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@
"**/out",
"**/target",
"**/public",
"**/docs"
"**/docs",
"**/contract/artifacts",
"**/contract/cache",
"**/contract/test",
"**/subgraph/generated",
"**/subgraph/build",
"**/frontend/gql"
]
},
"formatter": {
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
},
"workspaces": ["pkgs/*"],
"scripts": {
"format": "npx biome check --write .",
"biome:format": "npx biome format --write .",
"biome:check": "npx biome check --apply .",
"frontend": "yarn workspace frontend",
"contract": "yarn workspace contract",
"cli": "yarn workspace cli",
Expand Down
2 changes: 1 addition & 1 deletion pkgs/cli/src/commands/hats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ hatsCommands
maxSupply,
eligibility: eligibility as Address,
toggle: toggle as Address,
mutable: mutable == "true",
mutable: mutable === "true",
imageURI,
});

Expand Down
4 changes: 2 additions & 2 deletions pkgs/cli/src/commands/pinata.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import fs from "fs";
import path from "path";
import fs from "node:fs";
import path from "node:path";
import { Command } from "commander";
import { PinataSDK } from "pinata-web3";
import { startLoading } from "../services/loading";
Expand Down
2 changes: 1 addition & 1 deletion pkgs/cli/src/modules/bigbang.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const bigbang = async (params: {
});
return decodedLog.eventName === "Executed";
} catch (error) {}
})!;
});

stop();

Expand Down
11 changes: 7 additions & 4 deletions pkgs/cli/src/modules/fractiontoken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,17 @@ export const sendFractionToken = async (
hatId: bigint,
amount: bigint,
) => {
if (!walletClient.account) {
throw new Error("Wallet is not connected");
}
const stop = startLoading();
const tokenId = await getTokenId(hatId, walletClient.account?.address!);
const tokenId = await getTokenId(hatId, walletClient.account.address);

const { request } = await publicClient.simulateContract({
...fractionTokenBaseConfig,
account: walletClient.account,
functionName: "safeTransferFrom",
args: [walletClient.account?.address!, to, tokenId, amount, "" as any],
args: [walletClient.account.address, to, tokenId, amount, "0x"],
});
const transactionHash = await walletClient.writeContract(request);

Expand All @@ -60,8 +63,8 @@ export const sendFractionToken = async (
console.log(
decodeEventLog({
abi: fractionTokenBaseConfig.abi,
data: log!.data,
topics: log!.topics,
data: log.data,
topics: log.topics,
}),
);
}
Expand Down
4 changes: 2 additions & 2 deletions pkgs/cli/src/services/pinata.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { existsSync, readFileSync, writeFileSync } from "fs";
import path from "path";
import { existsSync, readFileSync, writeFileSync } from "node:fs";
import path from "node:path";
const pinataPath = path.join(__dirname, "pinata.json");

export interface Pinata {
Expand Down
4 changes: 2 additions & 2 deletions pkgs/cli/src/services/wallet.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { existsSync, readFileSync, writeFileSync } from "fs";
import path from "path";
import { existsSync, readFileSync, writeFileSync } from "node:fs";
import path from "node:path";
import type { Hex } from "viem";
import { privateKeyToAccount, privateKeyToAddress } from "viem/accounts";
import { setWallet } from "../modules/viem";
Expand Down
23 changes: 12 additions & 11 deletions pkgs/contract/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import "@nomicfoundation/hardhat-ethers";
import "@nomicfoundation/hardhat-toolbox-viem";
import "@nomicfoundation/hardhat-viem";
import "@openzeppelin/hardhat-upgrades";
import fs from "fs";
import fs from "node:fs";
import * as dotenv from "dotenv";
import "hardhat-gas-reporter";
import path from "path";
import path from "node:path";
import type { HardhatUserConfig } from "hardhat/config";

dotenv.config();
Expand All @@ -22,14 +22,15 @@ const {
const SKIP_LOAD = process.env.SKIP_LOAD === "true";
if (!SKIP_LOAD) {
const taskPaths = ["", "utils", "ens", "BigBang", "HatsTimeFrameModule"];
taskPaths.forEach((folder) => {
for (const folder of taskPaths) {
const tasksPath = path.join(__dirname, "tasks", folder);
fs.readdirSync(tasksPath)
.filter((_path) => _path.includes(".ts"))
.forEach((task) => {
require(`${tasksPath}/${task}`);
});
});
const taskFiles = fs
.readdirSync(tasksPath)
.filter((_path) => _path.includes(".ts"));
for (const task of taskFiles) {
require(`${tasksPath}/${task}`);
}
}
}

const config: HardhatUserConfig = {
Expand Down Expand Up @@ -61,8 +62,8 @@ const config: HardhatUserConfig = {
},
etherscan: {
apiKey: {
sepolia: ETHERSCAN_API_KEY!,
holesky: ETHERSCAN_API_KEY!,
sepolia: ETHERSCAN_API_KEY ?? "",
holesky: ETHERSCAN_API_KEY ?? "",
},
},
gasReporter: {
Expand Down
5 changes: 3 additions & 2 deletions pkgs/contract/helpers/deploy/FractionToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ export type FractionToken = Awaited<

export const deployFractionToken = async (
uri: string,
tokenSupply = 10000n,
tokenSupply: bigint,
hatsContractAddress: Address,
) => {
const _tokenSupply = !tokenSupply ? 10000n : tokenSupply;
const fractionToken = await ethers.getContractFactory("FractionToken");
const _FractionToken = await upgrades.deployProxy(
fractionToken,
[uri, tokenSupply, hatsContractAddress],
[uri, _tokenSupply, hatsContractAddress],
{
initializer: "initialize",
},
Expand Down
4 changes: 2 additions & 2 deletions pkgs/contract/helpers/deploy/contractJsonIgnitionHelper.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import fs from "fs";
import path from "path";
import fs from "node:fs";
import path from "node:path";

/**
* デプロイされたアドレス情報をjsonファイルから取得するヘルパーメソッド
Expand Down
16 changes: 8 additions & 8 deletions pkgs/contract/helpers/deploy/contractsJsonHelper.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import fs from "fs";
import fs from "node:fs";
import jsonfile from "jsonfile";

const BASE_PATH = "outputs";
Expand Down Expand Up @@ -38,7 +38,7 @@ const resetContractAddressesJson = ({ network }: { network: string }): void => {
fileName,
getFilePath({
network: network,
basePath: `./tmp`,
basePath: "./tmp",
suffix: strDate,
}),
);
Expand All @@ -59,15 +59,15 @@ const _updateJson = ({
}: {
group: string;
name: string | null;
value: any;
obj: any;
value: Record<string, string> | string;
obj: Record<string, Record<string, string>>;
}) => {
if (obj[group] === undefined) obj[group] = {};
if (name === null) {
obj[group] = value;
obj[group] = value as Record<string, string>;
} else {
if (obj[group][name] === undefined) obj[group][name] = {};
obj[group][name] = value;
if (obj[group][name] === undefined) obj[group][name] = "";
obj[group][name] = JSON.stringify(value);
}
};

Expand Down Expand Up @@ -104,7 +104,7 @@ const writeValueToGroup = ({
fileName,
}: {
group: string;
value: any;
value: Record<string, string> | string;
fileName: string;
}) => {
try {
Expand Down
4 changes: 2 additions & 2 deletions pkgs/contract/helpers/upgrade/bigbang.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ export const upgradeBigBang = async (
// 新しいコントラクトのファクトリーを取得
const BigBang_Mock_v2 = await ethers.getContractFactory(contractName);
// アップグレードを実行
const _BigBang = (await upgrades.upgradeProxy(
const _BigBang = await upgrades.upgradeProxy(
contractAddress,
BigBang_Mock_v2,
)) as any;
);

const address = _BigBang.target;

Expand Down
2 changes: 1 addition & 1 deletion pkgs/contract/helpers/upgrade/fractionToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type { Address } from "viem";
export const upgradeFractionToken = async (
contractAddress: string,
contractName: string,
params?: any[],
params?: unknown[],
) => {
// 新しいコントラクトのファクトリーを取得
const FractionToken = await ethers.getContractFactory(contractName);
Expand Down
1 change: 0 additions & 1 deletion pkgs/contract/helpers/upgrade/splitsCreatorFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import type { Address } from "viem";
export async function upgradeSplitsCreatorFacotry(
contractAddress: string,
contractName: string,
params: any[],
) {
// 新しいコントラクトのファクトリーを取得
const SplitsCreator_Mock_v2 = await ethers.getContractFactory(contractName);
Expand Down
6 changes: 3 additions & 3 deletions pkgs/contract/helpers/util/sqrt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ export function sqrt(y: bigint): bigint {
x = (y / x + x) / 2n;
}
return z;
} else if (y !== 0n) {
}
if (y !== 0n) {
return 1n;
} else {
return 0n;
}
return 0n;
}
1 change: 1 addition & 0 deletions pkgs/contract/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"@openzeppelin/hardhat-upgrades": "^3.5.0",
"@types/chai": "^4.2.0",
"@types/chai-as-promised": "^7.1.6",
"@types/jsonfile": "^6.1.4",
"@types/mocha": ">=9.1.0",
"chai": "^4.2.0",
"dotenv": "^16.4.5",
Expand Down
75 changes: 44 additions & 31 deletions pkgs/contract/tasks/BigBang/bigbang.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ import { task } from "hardhat/config";
import type { HardhatRuntimeEnvironment } from "hardhat/types";
import { loadDeployedContractAddresses } from "../../helpers/deploy/contractsJsonHelper";

interface BigBangTaskArgs {
owner: string;
tophatdetails: string;
tophatimageuri: string;
hatterhatdetails: string;
hatterhatimageuri: string;
}

/**
* 【Task】execute bigbang method
*/
Expand All @@ -11,34 +19,39 @@ task("bigbang", "bigbang")
.addParam("tophatimageuri", "The image URI of the topHat.")
.addParam("hatterhatdetails", "The details of the hatterHat.")
.addParam("hatterhatimageuri", "The image URI of the hatterHat.")
.addParam("forwarder", "The address of the trusted forwarder.")
.setAction(async (taskArgs: any, hre: HardhatRuntimeEnvironment) => {
console.log(
"################################### [START] ###################################",
);
const [bobWalletClient] = await hre.viem.getWalletClients();

// BigBangコントラクトのアドレスをjsonファイルから取得してくる。
const {
contracts: { BigBang },
} = loadDeployedContractAddresses(hre.network.name);

// create BigBang instance
const bigbang = await hre.viem.getContractAt("BigBang", BigBang);

// call bigbang method
const tx = await bigbang.write.bigbang([
bobWalletClient.account?.address!,
taskArgs.tophatdetails,
taskArgs.tophatimageuri,
taskArgs.hatterhatdetails,
taskArgs.hatterhatimageuri,
taskArgs.forwarder,
]);

console.log(`tx: ${tx}`);

console.log(
"################################### [END] ###################################",
);
});
.setAction(
async (taskArgs: BigBangTaskArgs, hre: HardhatRuntimeEnvironment) => {
console.log(
"################################### [START] ###################################",
);
const [bobWalletClient] = await hre.viem.getWalletClients();

// BigBangコントラクトのアドレスをjsonファイルから取得してくる。
const {
contracts: { BigBang },
} = loadDeployedContractAddresses(hre.network.name);

// create BigBang instance
const bigbang = await hre.viem.getContractAt("BigBang", BigBang);

const address = bobWalletClient.account?.address;
if (!address) {
throw new Error("Wallet client account address is undefined");
}

// call bigbang method
const tx = await bigbang.write.bigbang([
address,
taskArgs.tophatdetails,
taskArgs.tophatimageuri,
taskArgs.hatterhatdetails,
taskArgs.hatterhatimageuri,
]);

console.log(`tx: ${tx}`);

console.log(
"################################### [END] ###################################",
);
},
);
Loading

0 comments on commit a62a41f

Please sign in to comment.