From 94428e37a8d33150dc048d8c1d83c7a339c8bacc Mon Sep 17 00:00:00 2001 From: cong_wang Date: Thu, 12 Oct 2023 16:19:13 +0800 Subject: [PATCH] fix: Fix domain issues, ABI parsing problems, and auto-fetch gasPrice for Simulation --- CHANGELOG.md | 6 ++++++ manifest.config.ts | 2 +- package.json | 2 +- .../components/DrawerSimulation/index.tsx | 19 ++++++++++++++++--- src/common/config/allowlist.ts | 3 +++ src/common/constants/support.ts | 8 ++++---- .../feat-scripts/transaction-simulator.tsx | 3 +++ .../feat-scripts/transaction-simulator.tsx | 3 +++ 8 files changed, 37 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d6f981..eece704 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +### v4.0.1 + +- [fix] Resolve domain matching issues +- [fix] Fix issue with ABI parameter parsing affecting Simulation functionality +- [feat] Auto-fetch gasPrice for Simulation + ### v4.0.0 - [feat] Add support for multiple new chains including Base, Linea, Polygon zkEVM diff --git a/manifest.config.ts b/manifest.config.ts index c4be8c0..575f6c5 100644 --- a/manifest.config.ts +++ b/manifest.config.ts @@ -24,7 +24,7 @@ export default defineManifest((env: ConfigEnv) => { matches: isDev ? [ '*://*.etherscan.io/*', - '*://cn.etherscan.com/*', + '*://*.etherscan.com/*', '*://*.bscscan.com/*', '*://*.polygonscan.com/*', '*://*.snowtrace.io/*', diff --git a/package.json b/package.json index 47c9625..f97bb4c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "metadock", - "version": "4.0.0", + "version": "4.0.1", "repository": { "type": "git", "url": "https://github.com/blocksecteam/metadock.git" diff --git a/src/common/components/DrawerSimulation/index.tsx b/src/common/components/DrawerSimulation/index.tsx index 0393f49..3b082ee 100644 --- a/src/common/components/DrawerSimulation/index.tsx +++ b/src/common/components/DrawerSimulation/index.tsx @@ -54,6 +54,7 @@ interface Props { receiver: string isProxy: boolean signature?: string + gasPrice: string readableInputs?: ReadableInputData[] } @@ -62,6 +63,7 @@ const DrawerSimulation: FC = ({ receiver, sender, isProxy, + gasPrice, readableInputs = [], signature }) => { @@ -91,6 +93,10 @@ const DrawerSimulation: FC = ({ } }) + const estimatedGas = Number.isNaN(gasPrice) + ? '100' + : Math.ceil(Number(gasPrice) * (1 + 0.2)).toString() + const handleOk = debounce(() => { form.validateFields().then(values => { const params: SimulateTxParams = { @@ -100,7 +106,7 @@ const DrawerSimulation: FC = ({ inputData: values.inputData, value: values.value || '0', gasLimit: Number(values.gasLimit) || 1000000, - gasPrice: values.gasPrice || '100', + gasPrice: values.gasPrice || estimatedGas, receiver: values.receiver || '' } if (!values.isPrerun) { @@ -207,8 +213,15 @@ const DrawerSimulation: FC = ({ form.setFieldValue('useABI', true) form.setFieldValue('function', functionValue) const parameters: Record = {} + + const funcName = signature.replace(/\([^)]*\)/g, '') + readableInputs.forEach(item => { - parameters[`${functionValue}_${item.argumentName}`] = item.value + if (funcName === item.argumentName) { + form.setFieldValue('value', item.value) + } else { + parameters[`${functionValue}_${item.argumentName}`] = item.value + } }) form.setFieldValue('parameters', parameters) } @@ -762,7 +775,7 @@ const DrawerSimulation: FC = ({ return value.replace(/[^\d{1,}\\.\d{1,}|\d{1,}]/g, '') }} > - +