From e6548999f4bff1ebf9a0ca8737c53b79f1069070 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 28 Sep 2022 13:00:21 +0200 Subject: [PATCH] add sync action in udapp --- .../remix-ide/src/app/files/foundry-handle.js | 2 +- .../remix-ide/src/app/files/hardhat-handle.js | 2 +- .../remix-ide/src/app/files/truffle-handle.js | 2 +- .../run-tab/src/lib/actions/deploy.ts | 12 +++ .../remix-ui/run-tab/src/lib/actions/index.ts | 5 +- .../src/lib/components/contractDropdownUI.tsx | 12 ++- libs/remix-ui/run-tab/src/lib/run-tab.tsx | 4 +- libs/remix-ui/run-tab/src/lib/types/index.ts | 1 + .../run-tab/src/lib/types/run-tab.d.ts | 1 + libs/remixd/src/services/hardhatClient.ts | 76 ++++++++++--------- package.json | 2 +- 11 files changed, 77 insertions(+), 42 deletions(-) diff --git a/apps/remix-ide/src/app/files/foundry-handle.js b/apps/remix-ide/src/app/files/foundry-handle.js index 3d9091f6fc..cf20f03e79 100644 --- a/apps/remix-ide/src/app/files/foundry-handle.js +++ b/apps/remix-ide/src/app/files/foundry-handle.js @@ -5,7 +5,7 @@ const profile = { name: 'foundry', displayName: 'Foundry', url: 'ws://127.0.0.1:65525', - methods: [], + methods: ['sync'], description: 'Using Remixd daemon, allow to access foundry API', kind: 'other', version: packageJson.version diff --git a/apps/remix-ide/src/app/files/hardhat-handle.js b/apps/remix-ide/src/app/files/hardhat-handle.js index e9e8b770ef..7b64f489dc 100644 --- a/apps/remix-ide/src/app/files/hardhat-handle.js +++ b/apps/remix-ide/src/app/files/hardhat-handle.js @@ -5,7 +5,7 @@ const profile = { name: 'hardhat', displayName: 'Hardhat', url: 'ws://127.0.0.1:65522', - methods: ['compile'], + methods: ['compile', 'sync'], description: 'Using Remixd daemon, allow to access hardhat API', kind: 'other', version: packageJson.version diff --git a/apps/remix-ide/src/app/files/truffle-handle.js b/apps/remix-ide/src/app/files/truffle-handle.js index 8ef51ffcd1..bdeed78592 100644 --- a/apps/remix-ide/src/app/files/truffle-handle.js +++ b/apps/remix-ide/src/app/files/truffle-handle.js @@ -5,7 +5,7 @@ const profile = { name: 'truffle', displayName: 'truffle', url: 'ws://127.0.0.1:65524', - methods: ['compile'], + methods: ['compile', 'sync'], description: 'Using Remixd daemon, allow to access truffle API', kind: 'other', version: packageJson.version diff --git a/libs/remix-ui/run-tab/src/lib/actions/deploy.ts b/libs/remix-ui/run-tab/src/lib/actions/deploy.ts index caf8e6de8a..31ddc10d0f 100644 --- a/libs/remix-ui/run-tab/src/lib/actions/deploy.ts +++ b/libs/remix-ui/run-tab/src/lib/actions/deploy.ts @@ -244,6 +244,18 @@ export const getContext = (plugin: RunTab) => { return plugin.blockchain.context() } +export const syncContractsInternal = async (plugin: RunTab) => { + if (await plugin.call('manager', 'isActive', 'truffle')) { + plugin.call('truffle', 'sync') + } + if (await plugin.call('manager', 'isActive', 'hardhat')) { + plugin.call('hardhat', 'sync') + } + if (await plugin.call('manager', 'isActive', 'foundry')) { + plugin.call('foundry', 'sync') + } +} + export const runTransactions = ( plugin: RunTab, dispatch: React.Dispatch, diff --git a/libs/remix-ui/run-tab/src/lib/actions/index.ts b/libs/remix-ui/run-tab/src/lib/actions/index.ts index f61de6ebd8..88ab644592 100644 --- a/libs/remix-ui/run-tab/src/lib/actions/index.ts +++ b/libs/remix-ui/run-tab/src/lib/actions/index.ts @@ -6,7 +6,7 @@ import { createNewBlockchainAccount, fillAccountsList, setExecutionContext, sign import { clearInstances, clearPopUp, removeInstance, setAccount, setGasFee, setMatchPassphrasePrompt, setNetworkNameFromProvider, setPassphrasePrompt, setSelectedContract, setSendTransactionValue, setUnit, updateBaseFeePerGas, updateConfirmSettings, updateGasPrice, updateGasPriceStatus, updateMaxFee, updateMaxPriorityFee, updateScenarioPath } from './actions' -import { createInstance, getContext, getFuncABIInputs, getSelectedContract, loadAddress, runTransactions, updateInstanceBalance } from './deploy' +import { createInstance, getContext, getFuncABIInputs, getSelectedContract, loadAddress, runTransactions, updateInstanceBalance, syncContractsInternal } from './deploy' import { CompilerAbstract as CompilerAbstractType } from '@remix-project/remix-solidity-ts' import { ContractData, FuncABI } from "@remix-project/core-plugin" import { DeployMode, MainnetPrompt } from '../types' @@ -60,4 +60,5 @@ export const runScenario = (liveMode: boolean, gasEstimationPrompt: (msg: string export const setScenarioPath = (path: string) => updateScenarioPath(dispatch, path) export const getFuncABIValues = (funcABI: FuncABI) => getFuncABIInputs(plugin, funcABI) export const setNetworkName = (networkName: string) => setNetworkNameFromProvider(dispatch, networkName) -export const updateSelectedContract = (contractName) => setSelectedContract(dispatch, contractName) \ No newline at end of file +export const updateSelectedContract = (contractName) => setSelectedContract(dispatch, contractName) +export const syncContracts = () => syncContractsInternal(plugin) \ No newline at end of file diff --git a/libs/remix-ui/run-tab/src/lib/components/contractDropdownUI.tsx b/libs/remix-ui/run-tab/src/lib/components/contractDropdownUI.tsx index 224785890c..03ade973ae 100644 --- a/libs/remix-ui/run-tab/src/lib/components/contractDropdownUI.tsx +++ b/libs/remix-ui/run-tab/src/lib/components/contractDropdownUI.tsx @@ -5,6 +5,7 @@ import { ContractData, FuncABI } from '@remix-project/core-plugin' import * as ethJSUtil from 'ethereumjs-util' import { ContractGUI } from './contractGUI' import { deployWithProxyMsg, upgradeWithProxyMsg } from '@remix-ui/helper' +import { OverlayTrigger, Tooltip } from 'react-bootstrap' export function ContractDropdownUI (props: ContractDropdownProps) { const [abiLabel, setAbiLabel] = useState<{ @@ -229,7 +230,16 @@ export function ContractDropdownUI (props: ContractDropdownProps) {
- { Object.keys(props.contracts.contractList).length > 0 && compilationSource !== '' && } + { Object.keys(props.contracts.contractList).length > 0 && compilationSource !== '' && } + + Remix is currently connected to an external framework. Click here to import contract compiled from that framework. + + }> + +