diff --git a/plugin/src/atoms/compilation.ts b/plugin/src/atoms/compilation.ts index 15957004..5a8e9697 100644 --- a/plugin/src/atoms/compilation.ts +++ b/plugin/src/atoms/compilation.ts @@ -2,29 +2,14 @@ import { atom } from 'jotai' const statusAtom = atom('Compiling....') -const currentFilenameAtom = atom('') - -const isCompilingAtom = atom(false) - -const isValidSolidityAtom = atom(false) - -const noFileSelectedAtom = atom(false) - const hashDirAtom = atom('') -const tomlPathsAtom = atom([]) - -const activeTomlPathAtom = atom('') +const isCompilingAtom = atom(false) type CompilationKeys = 'status' - | 'currentFilename' | 'isCompiling' - | 'isValidSolidity' - | 'noFileSelected' | 'hashDir' - | 'tomlPaths' - | 'activeTomlPath' interface SetCompilationValue { key: CompilationKeys @@ -35,13 +20,8 @@ const compilationAtom = atom( (get) => { return { status: get(statusAtom), - currentFilename: get(currentFilenameAtom), isCompiling: get(isCompilingAtom), - isValidSolidity: get(isValidSolidityAtom), - noFileSelected: get(noFileSelectedAtom), - hashDir: get(hashDirAtom), - tomlPaths: get(tomlPathsAtom), - activeTomlPath: get(activeTomlPathAtom) + hashDir: get(hashDirAtom) } }, (_get, set, newValue: SetCompilationValue) => { @@ -49,40 +29,20 @@ const compilationAtom = atom( case 'status': typeof newValue?.value === 'string' && set(statusAtom, newValue?.value) break - case 'currentFilename': - typeof newValue?.value === 'string' && set(currentFilenameAtom, newValue?.value) - break case 'isCompiling': typeof newValue?.value === 'boolean' && set(isCompilingAtom, newValue?.value) break - case 'isValidSolidity': - typeof newValue?.value === 'boolean' && set(isValidSolidityAtom, newValue?.value) - break - case 'noFileSelected': - typeof newValue?.value === 'boolean' && set(noFileSelectedAtom, newValue?.value) - break case 'hashDir': typeof newValue?.value === 'string' && set(hashDirAtom, newValue?.value) break - case 'tomlPaths': - Array.isArray(newValue?.value) && set(tomlPathsAtom, newValue?.value) - break - case 'activeTomlPath': - typeof newValue?.value === 'string' && set(activeTomlPathAtom, newValue?.value) - break } } ) export { statusAtom, - currentFilenameAtom, isCompilingAtom, - isValidSolidityAtom, - noFileSelectedAtom, hashDirAtom, - tomlPathsAtom, - activeTomlPathAtom, compilationAtom, type SetCompilationValue, type CompilationKeys diff --git a/plugin/src/atoms/verification.ts b/plugin/src/atoms/verification.ts index b7f4aea6..e83b3b81 100644 --- a/plugin/src/atoms/verification.ts +++ b/plugin/src/atoms/verification.ts @@ -2,29 +2,11 @@ import { atom } from 'jotai' const statusAtom = atom('Verifying...') -const currentFilenameAtom = atom('') - const isVerifyingAtom = atom(false) -const isValidSolidityAtom = atom(false) - -const noFileSelectedAtom = atom(false) - -const hashDirAtom = atom('') - -const tomlPathsAtom = atom([]) - -const activeTomlPathAtom = atom('') - type VerificationKeys = 'status' - | 'currentFilename' | 'isVerifying' - | 'isValidSolidity' - | 'noFileSelected' - | 'hashDir' - | 'tomlPaths' - | 'activeTomlPath' interface SetVerificationValue { key: VerificationKeys @@ -35,13 +17,7 @@ const verificationAtom = atom( (get) => { return { status: get(statusAtom), - currentFilename: get(currentFilenameAtom), - isVerifying: get(isVerifyingAtom), - isValidSolidity: get(isValidSolidityAtom), - noFileSelected: get(noFileSelectedAtom), - hashDir: get(hashDirAtom), - tomlPaths: get(tomlPathsAtom), - activeTomlPath: get(activeTomlPathAtom) + isVerifying: get(isVerifyingAtom) } }, (_get, set, newValue: SetVerificationValue) => { @@ -49,40 +25,16 @@ const verificationAtom = atom( case 'status': typeof newValue?.value === 'string' && set(statusAtom, newValue?.value) break - case 'currentFilename': - typeof newValue?.value === 'string' && set(currentFilenameAtom, newValue?.value) - break case 'isVerifying': typeof newValue?.value === 'boolean' && set(isVerifyingAtom, newValue?.value) break - case 'isValidSolidity': - typeof newValue?.value === 'boolean' && set(isValidSolidityAtom, newValue?.value) - break - case 'noFileSelected': - typeof newValue?.value === 'boolean' && set(noFileSelectedAtom, newValue?.value) - break - case 'hashDir': - typeof newValue?.value === 'string' && set(hashDirAtom, newValue?.value) - break - case 'tomlPaths': - Array.isArray(newValue?.value) && set(tomlPathsAtom, newValue?.value) - break - case 'activeTomlPath': - typeof newValue?.value === 'string' && set(activeTomlPathAtom, newValue?.value) - break } } ) export { statusAtom, - currentFilenameAtom, isVerifyingAtom, - isValidSolidityAtom, - noFileSelectedAtom, - hashDirAtom, - tomlPathsAtom, - activeTomlPathAtom, verificationAtom, type SetVerificationValue, type VerificationKeys diff --git a/plugin/src/components/DevnetAccountSelector/index.tsx b/plugin/src/components/DevnetAccountSelector/index.tsx index 09475428..256dffb5 100644 --- a/plugin/src/components/DevnetAccountSelector/index.tsx +++ b/plugin/src/components/DevnetAccountSelector/index.tsx @@ -83,20 +83,20 @@ const DevnetAccountSelector: React.FC = () => { `❗️ Server ${devnet.name} - ${devnet.url} is not healthy or not reachable at the moment` ) } catch (e) { - console.log(e) + console.error(e) } } useEffect(() => { updateAccountBalances().catch((e) => { - console.log(e) + console.error(e) }) }, [transactions]) useEffect(() => { if (!isDevnetAlive) { notifyDevnetStatus().catch((e) => { - console.log(e) + console.error(e) }) } }, [isDevnetAlive]) diff --git a/plugin/src/components/FunctionalInput/index.tsx b/plugin/src/components/FunctionalInput/index.tsx index f6e0d7f0..d7df5359 100644 --- a/plugin/src/components/FunctionalInput/index.tsx +++ b/plugin/src/components/FunctionalInput/index.tsx @@ -1,10 +1,11 @@ // A component that reads the compiled contracts from the context and displays them in a select import React, { useEffect, useState } from 'react' +import * as zksync from 'zksync-ethers' import { generateInputName } from '../../utils/utils' import { type AbiElement, type Input } from '../../types/contracts' import InputField from '../InputField' -import { Contract } from 'ethers' +import { ethers } from 'ethers' import { mockManualChain, type Transaction } from '../../types/transaction' import { useAtom, useAtomValue } from 'jotai' import { deployedSelectedContractAtom } from '../../atoms/deployedContracts' @@ -31,6 +32,7 @@ const MethodInput: React.FC = ({ element }: CompiledCont const provider = useAtomValue(providerAtom) const [inputs, setInputs] = useState([]) + const [value, setValue] = useState('') const callContract = async (): Promise => { if (selectedContract == null) { @@ -45,8 +47,7 @@ const MethodInput: React.FC = ({ element }: CompiledCont } const contractAddress = selectedContract.address - const contract = new Contract(contractAddress, selectedContract.abi, account) - .connect(account) + const contract = new zksync.Contract(contractAddress, selectedContract.abi, account) const method = contract[element.name] @@ -56,6 +57,10 @@ const MethodInput: React.FC = ({ element }: CompiledCont title: `Executing "${element.name}" method!` }) + if (element.stateMutability === 'payable') { + const options: any = { value: ethers.utils.parseEther(value) } + inputs.push(options) + } const result = await method(...inputs) remixClient.emit('statusChanged', { @@ -71,7 +76,8 @@ const MethodInput: React.FC = ({ element }: CompiledCont txId: result.hash, env, chain: (env !== 'manual' ? walletClient?.chain : mockManualChain), - provider + provider, + value } setTransactions([transaction, ...transactions]) @@ -117,6 +123,17 @@ const MethodInput: React.FC = ({ element }: CompiledCont `}> {element.name} + { + element.stateMutability === 'payable' + ? { setValue(newValue) } } + /> + : <> + } { element.inputs.map((input: Input, index: number) => void @@ -42,12 +43,10 @@ const Deployment: React.FC = ({ setActiveTab }) => { const [inputs, setInputs] = useState([]) const [shouldRunVerification, setShouldRunVerification] = useState(false) - const { - currentFilename, - hashDir, - isValidSolidity, - isVerifying - } = useAtomValue(verificationAtom) + const { isVerifying } = useAtomValue(verificationAtom) + const isValidSolidity = useAtomValue(isValidSolidityAtom) + const currentFilename = useAtomValue(currentFilenameAtom) + const hashDir = useAtomValue(hashDirAtom) const setStatus = useSetAtom(deployStatusAtom) @@ -308,7 +307,8 @@ const Deployment: React.FC = ({ setActiveTab }) => { txId: txHash, env, chain: (env !== 'manual' ? walletClient?.chain : mockManualChain), - provider + provider, + value: undefined } setTransactions([transaction, ...transactions]) @@ -348,9 +348,7 @@ const Deployment: React.FC = ({ setActiveTab }) => {