Skip to content

Commit

Permalink
fix: Fix domain issues, ABI parsing problems, and auto-fetch gasPrice…
Browse files Browse the repository at this point in the history
… for Simulation
  • Loading branch information
0xbe37e committed Oct 12, 2023
1 parent f4be20e commit 94428e3
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 9 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion manifest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default defineManifest((env: ConfigEnv) => {
matches: isDev
? [
'*://*.etherscan.io/*',
'*://cn.etherscan.com/*',
'*://*.etherscan.com/*',
'*://*.bscscan.com/*',
'*://*.polygonscan.com/*',
'*://*.snowtrace.io/*',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "metadock",
"version": "4.0.0",
"version": "4.0.1",
"repository": {
"type": "git",
"url": "https://github.com/blocksecteam/metadock.git"
Expand Down
19 changes: 16 additions & 3 deletions src/common/components/DrawerSimulation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ interface Props {
receiver: string
isProxy: boolean
signature?: string
gasPrice: string
readableInputs?: ReadableInputData[]
}

Expand All @@ -62,6 +63,7 @@ const DrawerSimulation: FC<Props> = ({
receiver,
sender,
isProxy,
gasPrice,
readableInputs = [],
signature
}) => {
Expand Down Expand Up @@ -91,6 +93,10 @@ const DrawerSimulation: FC<Props> = ({
}
})

const estimatedGas = Number.isNaN(gasPrice)
? '100'
: Math.ceil(Number(gasPrice) * (1 + 0.2)).toString()

const handleOk = debounce(() => {
form.validateFields().then(values => {
const params: SimulateTxParams = {
Expand All @@ -100,7 +106,7 @@ const DrawerSimulation: FC<Props> = ({
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) {
Expand Down Expand Up @@ -207,8 +213,15 @@ const DrawerSimulation: FC<Props> = ({
form.setFieldValue('useABI', true)
form.setFieldValue('function', functionValue)
const parameters: Record<string, any> = {}

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)
}
Expand Down Expand Up @@ -762,7 +775,7 @@ const DrawerSimulation: FC<Props> = ({
return value.replace(/[^\d{1,}\\.\d{1,}|\d{1,}]/g, '')
}}
>
<Input suffix="Gwei" placeholder="Default is 100" />
<Input suffix="Gwei" placeholder={`Default is ${estimatedGas}`} />
</Form.Item>
</Form>
<Button
Expand Down
3 changes: 3 additions & 0 deletions src/common/config/allowlist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@ export default {
],
ETHERSCAN_V2_MATCHES: [
'*://cn.etherscan.com/*',
'*://goto.etherscan.com/*',
'*://sepolia.etherscan.io/*',
'*://goerli.etherscan.io/*',
'*://cn.etherscan.com/*',
'*://etherscan.io/*',
'*://bscscan.com/*',
'*://goto.bscscan.com/*',
'*://www.bscscan.com/*',
'*://testnet.bscscan.com/*'
],
BTC_EXPLORER_MATCHES: ['*://explorer.btc.com/*'],
Expand Down
8 changes: 4 additions & 4 deletions src/common/constants/support.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ export interface ExtSupportWebsite {
export const EXT_SUPPORT_WEB_LIST: ExtSupportWebsite[] = [
{
name: 'BTC',
domains: ['btc.com', 'explorer.btc.com'],
domains: ['explorer.btc.com'],
href: 'https://explorer.btc.com/btc',
chain: 'btc',
siteName: 'SCAN',
logo: 'https://assets.blocksec.com/image/1671685360787-5.png'
},
{
name: 'ETH',
domains: ['etherscan.io', 'cn.etherscan.com'],
domains: ['etherscan.io', 'cn.etherscan.com', 'goto.etherscan.com'],
chainID: 1,
chain: 'eth',
siteName: 'SCAN',
Expand All @@ -52,7 +52,7 @@ export const EXT_SUPPORT_WEB_LIST: ExtSupportWebsite[] = [
{
name: 'BSC',
chainID: 56,
domains: ['bscscan.com', 'www.bscscan.com'],
domains: ['bscscan.com', 'www.bscscan.com', 'goto.bscscan.com'],
chain: 'bsc',
siteName: 'SCAN',
logo: 'https://assets.blocksec.com/image/1671685360787-4.png',
Expand Down Expand Up @@ -309,7 +309,7 @@ export const EXT_SUPPORT_WEB_LIST: ExtSupportWebsite[] = [
name: 'WEMIX',
chainID: 1111,
chain: 'wemix',
domains: ['wemixscan.com'],
domains: ['wemixscan.com', 'www.wemixscan.com'],
siteName: 'SCAN',
logo: 'https://assets.blocksec.com/image/1695197286815-6.png',
testNets: [
Expand Down
3 changes: 3 additions & 0 deletions src/content/etherscan/feat-scripts/transaction-simulator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,15 @@ const renderDrawer = ({
const func = $(`#${id}`).contents().find('#connectStatus').attr('onclick')
const sender = func ? pickAddress(func) : undefined

const gasPrice = $('#spanGasTooltip .gasPricePlaceHolder').text().trim()

const readableInputs = setupInputData(container)

const rootEl = $('<div></div>')
createRoot(rootEl[0]).render(
<DrawerSimulation
chain={chain}
gasPrice={gasPrice}
receiver={address}
sender={sender}
isProxy={isProxy}
Expand Down
3 changes: 3 additions & 0 deletions src/content/scans/feat-scripts/transaction-simulator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,15 @@ const renderDrawer = ({
const text = connectStatus.attr('onclick') || connectStatus.text()
const sender = text ? pickAddress(text) : undefined

const gasPrice = $('#spanGasTooltip .gasPricePlaceHolder').text().trim()

const readableInputs = setupInputData(container)

const rootEl = $('<div></div>')
createRoot(rootEl[0]).render(
<DrawerSimulation
chain={chain}
gasPrice={gasPrice}
receiver={address}
sender={sender}
isProxy={isProxy}
Expand Down

0 comments on commit 94428e3

Please sign in to comment.