From e3efb2ba1eb6d6c2faa8c6b96f255747f14189cc Mon Sep 17 00:00:00 2001 From: MattWong-ca Date: Mon, 18 Nov 2024 00:13:52 +0700 Subject: [PATCH 1/6] Fix pipeline for Axelar --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 8b860fb..f740bb5 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # FIL-Frame 🚀 +# This is a test to make sure CI/CD is working Tutorial video: https://youtu.be/dzg7ygwAp1Q From 14f25a471c633acccc476f4542afe96a2ea486b4 Mon Sep 17 00:00:00 2001 From: MattWong-ca Date: Sun, 24 Nov 2024 18:47:40 -0500 Subject: [PATCH 2/6] run CI for all branches --- .github/workflows/lint.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index d710f3d..fb3f094 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -3,10 +3,10 @@ name: Lint on: push: branches: - - main + - '*' pull_request: branches: - - main + - '*' jobs: ci: From 0ad9ad0207d93a28b12939a5a8abecdfaaac12ee Mon Sep 17 00:00:00 2001 From: MattWong-ca Date: Sun, 24 Nov 2024 19:00:07 -0500 Subject: [PATCH 3/6] remove old deploy scripts --- .../hardhat/deploy/00_deploy_your_contract.ts | 6 --- packages/hardhat/scripts/deploy.ts | 23 ----------- packages/hardhat/scripts/deployFactory.ts | 32 ---------------- .../hardhat/scripts/deployYourContract.ts | 38 ------------------- 4 files changed, 99 deletions(-) delete mode 100644 packages/hardhat/scripts/deploy.ts delete mode 100644 packages/hardhat/scripts/deployFactory.ts delete mode 100644 packages/hardhat/scripts/deployYourContract.ts diff --git a/packages/hardhat/deploy/00_deploy_your_contract.ts b/packages/hardhat/deploy/00_deploy_your_contract.ts index 2a1c651..52e55a2 100644 --- a/packages/hardhat/deploy/00_deploy_your_contract.ts +++ b/packages/hardhat/deploy/00_deploy_your_contract.ts @@ -45,12 +45,6 @@ const deploySendMessage: DeployFunction = async function ( console.log("🚀 SendMessage deployed at: ", SendMessage.address); const SendMessageAddress = SendMessage.address; - // Get the deployed contract to interact with it after deploying. - const sendMessage = await hre.ethers.getContractAt( - "SendMessage", - SendMessageAddress - ); - // Check if the --verify flag is present const shouldVerify = process.env.VERIFY === "true"; diff --git a/packages/hardhat/scripts/deploy.ts b/packages/hardhat/scripts/deploy.ts deleted file mode 100644 index 7c27b5c..0000000 --- a/packages/hardhat/scripts/deploy.ts +++ /dev/null @@ -1,23 +0,0 @@ -async function main() { - const SendMessage = await hre.ethers.getContractFactory("SendMessage"); - const sendMessage = await SendMessage.deploy( - // 1. Uncomment to deploy on Filecoin Calibration - // "0x999117D44220F33e0441fbAb2A5aDB8FF485c54D", - // "0xbE406F0189A0B4cf3A05C286473D23791Dd44Cc6" - - // 2. Uncomment to deploy on Ethereum Sepolia - // "0xe432150cce91c13a887f7D836923d5597adD8E31", - // "0xbE406F0189A0B4cf3A05C286473D23791Dd44Cc6" - ); - - await sendMessage.waitForDeployment(); - - console.log(`SendMessage contract deployed to ${await sendMessage.getAddress()}`); -} - -// We recommend this pattern to be able to use async/await everywhere -// and properly handle errors. -main().catch((error) => { - console.error(error); - process.exitCode = 1; -}); diff --git a/packages/hardhat/scripts/deployFactory.ts b/packages/hardhat/scripts/deployFactory.ts deleted file mode 100644 index 7d9d47a..0000000 --- a/packages/hardhat/scripts/deployFactory.ts +++ /dev/null @@ -1,32 +0,0 @@ -const hre = require('hardhat'); -const { ethers } = require('ethers'); -require('dotenv').config(); - -/* For deploying contracts to the same address on different chains: -* 1. Deploy YourContractFactory: `npx hardhat run --network scripts/deployFactory.ts` -* 2. Copy and paste the address you see in the console output into the deployYourContract.ts file -* 3. Deploy YourContract: `npx hardhat run --network scripts/deployYourContract.ts` -*/ -const provider = new ethers.JsonRpcProvider(process.env.RPC_URL); // Change this to same url as in hardhat.config.ts -const signer = new ethers.Wallet(process.env.DEPLOYER_PRIVATE_KEY, provider); - -async function deployContractFactory() { - try { - const ContractFactory = await hre.ethers.getContractFactory('YourContractFactory', signer); - - console.log('Deploying YourContractFactory...'); - const factory = await ContractFactory.deploy(); - await factory.waitForDeployment(); - - console.log('ContractFactory deployed to:', factory.target); - return factory.target; - } catch (err) { - console.error('Error in deployContractFactory:', err); - } -} - -async function mainfunction() { - await deployContractFactory(); -} - -mainfunction().catch(err => console.error('Error in main function:', err)); \ No newline at end of file diff --git a/packages/hardhat/scripts/deployYourContract.ts b/packages/hardhat/scripts/deployYourContract.ts deleted file mode 100644 index 5fb1234..0000000 --- a/packages/hardhat/scripts/deployYourContract.ts +++ /dev/null @@ -1,38 +0,0 @@ -require('dotenv').config(); - -const contractFactoryAddress = ''; // Fill this after running deployFactory.ts -const deployerAddress = signer.address; -const deployerBytes = ethers.getBytes(deployerAddress).slice(0, 20); -const randomString = "gmrandomstring"; // This value must change on every deployment -const randomBytes = ethers.toUtf8Bytes(randomString); -const concatenatedBytes = ethers.concat([deployerBytes, randomBytes]); -const salt = ethers.keccak256(concatenatedBytes); - -async function deployYourContract() { - try { - const ContractFactory = await hre.ethers.getContractAt('YourContractFactory', contractFactoryAddress, signer); - // Compute expected address before deployment - const expectedAddress = await ContractFactory.computeTokenAddress(salt); - console.log('Expected YourContract address:', expectedAddress); - - // Deploying YourContract using ContractFactory - const txn = await ContractFactory.deployContract(salt); - await txn.wait() - const tokenAddress = await ContractFactory.latestTokenAddress() - console.log('Deployed YourContract address:', tokenAddress); - if (expectedAddress == tokenAddress) { - console.log("Expected and deployed address match, CREATE2 functionality verified!"); - } else { - console.error("Mismatch in expected and deployed addresses!"); - } - - } catch (err) { - console.error('Error in deployYourContract:', err); - } -} - -async function mainfxn() { - await deployYourContract(); -} - -mainfxn().catch(err => console.error('Error in main function:', err)); \ No newline at end of file From 83264f0a90d32ecc2e3fcdfd734704ee5d20f973 Mon Sep 17 00:00:00 2001 From: MattWong-ca Date: Sun, 24 Nov 2024 19:06:45 -0500 Subject: [PATCH 4/6] remove duplicate CI --- .github/workflows/lint.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index fb3f094..decf4fd 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -6,7 +6,7 @@ on: - '*' pull_request: branches: - - '*' + - main jobs: ci: From 01cc49e96b636fbdab5b2dfba95437d9bb39ebd9 Mon Sep 17 00:00:00 2001 From: MattWong-ca Date: Sun, 24 Nov 2024 19:23:43 -0500 Subject: [PATCH 5/6] remove lighthouse code, fix CI errors --- packages/nextjs/app/axelar/page.tsx | 6 +- .../_components/WriteContractFunctionForm.tsx | 207 ------------------ packages/nextjs/hooks/lighthouse/index.ts | 58 ----- 3 files changed, 3 insertions(+), 268 deletions(-) delete mode 100644 packages/nextjs/app/dealClient/_components/WriteContractFunctionForm.tsx delete mode 100644 packages/nextjs/hooks/lighthouse/index.ts diff --git a/packages/nextjs/app/axelar/page.tsx b/packages/nextjs/app/axelar/page.tsx index 3609e83..694e564 100644 --- a/packages/nextjs/app/axelar/page.tsx +++ b/packages/nextjs/app/axelar/page.tsx @@ -5,9 +5,9 @@ import deployedContracts from "../../contracts/deployedContracts"; import { ethers } from "ethers"; import { useWriteContract } from "wagmi"; -const FIL_CONTRACT_ADDRESS = deployedContracts[314159].SendMessage.address; -const ETH_CONTRACT_ADDRESS = deployedContracts[11155111].SendMessage.address; -const ABI = deployedContracts[11155111].SendMessage.abi; +const FIL_CONTRACT_ADDRESS = (deployedContracts as any)[314159].SendMessage.address; +const ETH_CONTRACT_ADDRESS = (deployedContracts as any)[11155111].SendMessage.address; +const ABI = (deployedContracts as any)[11155111].SendMessage.abi; const AxelarPage: React.FC = () => { const [message, setMessage] = useState(""); diff --git a/packages/nextjs/app/dealClient/_components/WriteContractFunctionForm.tsx b/packages/nextjs/app/dealClient/_components/WriteContractFunctionForm.tsx deleted file mode 100644 index 7c00ece..0000000 --- a/packages/nextjs/app/dealClient/_components/WriteContractFunctionForm.tsx +++ /dev/null @@ -1,207 +0,0 @@ -"use client"; - -import { useMemo, useState } from "react"; -import { useEffect } from "react"; -import { DealInputs, createDealObject, getDefaultDealInputs } from "../utils"; -import { Abi, AbiFunction } from "abitype"; -import { JsonView, allExpanded, darkStyles } from "react-json-view-lite"; -import "react-json-view-lite/dist/index.css"; -import { Address, TransactionReceipt } from "viem"; -import { useAccount, useWaitForTransactionReceipt, useWriteContract } from "wagmi"; -import { - ContractInput, - TxReceipt, - getFunctionInputKey, - getInitialFormState, - getParsedContractFunctionArgs, - transformAbiFunction, -} from "~~/app/debug/_components/contract"; -import { InheritanceTooltip } from "~~/app/debug/_components/contract/InheritanceTooltip"; -import { IntegerInput } from "~~/components/fil-frame"; -import { useTransactor } from "~~/hooks/fil-frame"; -import { useTargetNetwork } from "~~/hooks/fil-frame/useTargetNetwork"; -import { DealInfoData } from "~~/hooks/lighthouse/useUpload"; - -type WriteContractFunctionProps = { - abi: Abi; - abiFunction: AbiFunction; - onChange: () => void; - contractAddress: Address; - inheritedFrom?: string; - dealParams?: DealInfoData; -}; - -export const WriteContractFunctionForm = ({ - abi, - abiFunction, - onChange, - contractAddress, - inheritedFrom, - dealParams, -}: WriteContractFunctionProps) => { - const [form, setForm] = useState>(() => getInitialFormState(abiFunction)); - const [txValue, setTxValue] = useState(""); - const { chain } = useAccount(); - const writeTxn = useTransactor(); - const { targetNetwork } = useTargetNetwork(); - const writeDisabled = !chain || chain?.id !== targetNetwork.id; - - const { data: result, isPending, writeContractAsync } = useWriteContract(); - - const handleWrite = async () => { - if (writeContractAsync) { - try { - const makeWriteWithParams = () => - writeContractAsync({ - address: contractAddress, - functionName: abiFunction.name, - abi: abi, - args: getParsedContractFunctionArgs(form), - value: BigInt(txValue), - }); - await writeTxn(makeWriteWithParams); - onChange(); - } catch (e: any) { - console.error("⚡️ ~ file: WriteOnlyFunctionForm.tsx:handleWrite ~ error", e); - } - } - }; - - const [displayedTxResult, setDisplayedTxResult] = useState(); - const { data: txResult } = useWaitForTransactionReceipt({ - hash: result, - }); - useEffect(() => { - setDisplayedTxResult(txResult); - }, [txResult]); - - // TODO use `useMemo` to optimize also update in ReadOnlyFunctionForm - const transformedFunction = transformAbiFunction(abiFunction); - const inputs = transformedFunction.inputs.map((input, inputIndex) => { - const key = getFunctionInputKey(abiFunction.name, input, inputIndex); - return ( - { - setDisplayedTxResult(undefined); - setForm(updatedFormValue); - }} - form={form} - stateObjectKey={key} - paramType={input} - /> - ); - }); - const zeroInputs = inputs.length === 0 && abiFunction.stateMutability !== "payable"; - const defaultDealInputs = useMemo(() => getDefaultDealInputs(dealParams), [dealParams]); - const [dealInputs, setDealInputs] = useState(defaultDealInputs); - - const setFormValue = () => { - const dealObject = createDealObject(dealInputs); - setForm(prevForm => ({ - ...prevForm, - ["makeDealProposal_deal_struct DealRequest_tuple"]: JSON.stringify(dealObject), - })); - }; - - useEffect(() => { - setFormValue(); - }, [dealParams]); - const handleInputChange = (e: React.ChangeEvent) => { - const { name, value, type, checked } = e.target; - setDealInputs(prevInputs => ({ - ...prevInputs, - [name]: type === "checkbox" ? checked : value, - })); - }; - return ( -
-
-

- {abiFunction.name} - -

- - - - - - {abiFunction.stateMutability === "payable" ? ( -
-
- payable value - wei -
- { - setDisplayedTxResult(undefined); - setTxValue(updatedTxValue); - }} - placeholder="value (wei)" - /> -
- ) : null} -
- {!zeroInputs && ( -
- {displayedTxResult ? : null} -
- )} -
- -
-
-
- {zeroInputs && txResult ? ( -
- -
- ) : null} -
- ); -}; - -const DealForm = ({ - dealInputs, - handleInputChange, -}: { - dealInputs: DealInputs; - handleInputChange: (e: React.ChangeEvent) => void; -}) => { - const handleDurationChange = (e: React.ChangeEvent) => { - const months = Math.max(7, Math.min(36, Number(e.target.value))); - const endEpoch = dealInputs.start_epoch + months * 43200; - handleInputChange({ - ...e, - // @ts-ignore: number to string conversion - target: { ...e.target, name: "end_epoch", value: endEpoch }, - }); - }; - - return ( -
- -
- ); -}; diff --git a/packages/nextjs/hooks/lighthouse/index.ts b/packages/nextjs/hooks/lighthouse/index.ts deleted file mode 100644 index a030532..0000000 --- a/packages/nextjs/hooks/lighthouse/index.ts +++ /dev/null @@ -1,58 +0,0 @@ -import { generate, recoverKey, recoverShards, saveShards } from "@lighthouse-web3/kavach"; -import lighthouse from "@lighthouse-web3/sdk"; - -type accessControlConditions = any; - -export const uploadFilesEncrypted = async ( - files: File[], - apiKey: string, - userAddress: string, - jwt: string, - conditions?: accessControlConditions[], - aggregator?: string, -) => { - let cid = await _uploadFilesEncrypted(files, apiKey, userAddress, jwt); - if (conditions?.length === 0 || !conditions || !aggregator) { - return cid; - } - cid = await applyAccessConditions(cid, userAddress, jwt, conditions, aggregator); - return cid; -}; - -export const uploadFiles = async (files: File[], apiKey: string) => { - const output = await lighthouse.upload(files, apiKey); - return output.data.Hash; -}; - -/* Deploy file along with encryption */ -export const _uploadFilesEncrypted = async (files: File[], apiKey: string, userAddress: string, jwt: string) => { - const output = await lighthouse.uploadEncrypted(files, apiKey, userAddress, jwt); - console.log("output", output.data[0].Hash); - - const { keyShards } = await generate(); - - await saveShards(userAddress, output.data[0].Hash, jwt, keyShards); - - return output.data[0].Hash; -}; - -export const decrypt = async (cid: string, userAddress: string, jwt: string) => { - let decrypted; - const { shards } = await recoverShards(userAddress, cid, jwt, 3); - try { - const { masterKey } = await recoverKey(shards); - decrypted = await lighthouse.decryptFile(cid, masterKey); - } catch {} - return decrypted; -}; - -export const applyAccessConditions = async ( - cid: string, - address: string, - jwt: string, - conditions: accessControlConditions[], - aggregator: string, -) => { - const response = await lighthouse.applyAccessCondition(address, cid, jwt, conditions, aggregator); - return response.data.cid; -}; From c2529dfee0727dde73e66811fad3ba98bcb61ac4 Mon Sep 17 00:00:00 2001 From: MattWong-ca Date: Sun, 24 Nov 2024 19:32:50 -0500 Subject: [PATCH 6/6] remove comment --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index f740bb5..8b860fb 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ # FIL-Frame 🚀 -# This is a test to make sure CI/CD is working Tutorial video: https://youtu.be/dzg7ygwAp1Q