simplify implementation for lowlevel icon

pull/5370/head
Joseph Izang 11 months ago committed by Aniket
parent 1d12e87f2b
commit 479690a157
  1. 17
      libs/remix-ui/run-tab/src/lib/actions/account.ts
  2. 2
      libs/remix-ui/run-tab/src/lib/components/contractDropdownUI.tsx
  3. 2
      libs/remix-ui/run-tab/src/lib/components/contractGUI.tsx
  4. 1
      libs/remix-ui/run-tab/src/lib/components/instanceContainerUI.tsx
  5. 22
      libs/remix-ui/run-tab/src/lib/components/lowlevelInteractionIcon.tsx
  6. 9
      libs/remix-ui/run-tab/src/lib/components/universalDappUI.tsx
  7. 3
      libs/remix-ui/run-tab/src/lib/run-tab.tsx
  8. 6
      libs/remix-ui/run-tab/src/lib/types/index.ts

@ -101,20 +101,3 @@ export const signMessageWithAddress = (plugin: RunTab, dispatch: React.Dispatch<
dispatch(displayNotification('Signed Message', modalContent(msgHash, signedData), 'OK', null, () => {}, null))
})
}
export const extractCompilerVersion = (runTab: RunTabState, dispatch: React.Dispatch<any>) =>
{
const runtabState = Object.entries(runTab['contracts'] ?? {})
const contractList = runtabState[0] ?? {}
const contractNameHolder = runtabState[4] ?? ['currentName', '']
const contractName = contractNameHolder[1] ?? ''
const currentObj = contractList[1] ?? {}
const currObjDetails = currentObj[contractName as string] ?? {}
const currObjDetailsLength = currObjDetails.length -1
const alias = currObjDetails[currObjDetailsLength]['alias'] ?? ''
const serializeTarget = currObjDetails[currObjDetailsLength]?.compiler?.data?.contracts[contractName as string][alias]?.metadata ?? ''
const obj = (serializeTarget as string).length > 0 ? JSON.parse(serializeTarget) : {}
const version = obj?.compiler?.version ?? ''
const compilerVersion = `v${version?.split('+commit')[0]}` ?? 'v'
dispatch({ type: 'EXTRACT_COMPILER_VERSION', payload: {compilerVersion, runTab }})
}

@ -481,8 +481,6 @@ export function ContractDropdownUI(props: ContractDropdownProps) {
isValidProxyUpgrade={isValidProxyUpgrade}
modal={props.modal}
disabled={props.selectedAccount === ''}
dispatch={props.stateDispatch}
runTabState={props.runTabState}
/>
<div className="d-flex py-1 align-items-center custom-control custom-checkbox">
<input

@ -6,7 +6,6 @@ import {ContractGUIProps} from '../types'
import {CopyToClipboard} from '@remix-ui/clipboard'
import {CustomTooltip, ProxyAddressToggle, ProxyDropdownMenu, shortenDate, shortenProxyAddress, unavailableProxyLayoutMsg, upgradeReportMsg} from '@remix-ui/helper'
import {Dropdown} from 'react-bootstrap'
import { extractCompilerVersion } from '../actions/account'
const txFormat = remixLib.execution.txFormat
const txHelper = remixLib.execution.txHelper
@ -174,7 +173,6 @@ export function ContractGUI(props: ContractGUIProps) {
}
const handleActionClick = async () => {
extractCompilerVersion(props.runTabState, props.dispatch)
if (deployState.deploy) {
const proxyInitializeString = getMultiValsString(initializeFields.current)
props.clickCallBack(props.initializerOptions.inputs.inputs, proxyInitializeString, ['Deploy with Proxy'])

@ -39,7 +39,6 @@ export function InstanceContainerUI(props: InstanceContainerProps) {
{props.instances.instanceList.map((instance, index) => {
return (
<UniversalDappUI
state={props.state}
key={index}
instance={instance}
context={props.getContext()}

@ -1,22 +0,0 @@
import { CustomTooltip } from '@remix-ui/helper'
import React, { useEffect, useState } from 'react'
import { FormattedMessage } from 'react-intl'
import { RunTabState } from '../types'
export type LowLevelInteractionIconProps = {
plugin: RunTabState
}
export function LowLevelInteractionIcon (props: LowLevelInteractionIconProps) {
const [version, setVersion] = useState(props.plugin.compilerVersion ?? '')
return (
<>
<CustomTooltip placement={'bottom-end'} tooltipClasses="text-wrap" tooltipId="receiveEthDocstoolTip" tooltipText={<FormattedMessage id="udapp.tooltipText8" />}>
<a href={`https://solidity.readthedocs.io/en/${version}/contracts.html#receive-ether-function`} target="_blank" rel="noreferrer">
<i aria-hidden="true" className="fas fa-info my-2 mr-1"></i>
</a>
</CustomTooltip>
</>
)
}

@ -10,7 +10,6 @@ import {ContractGUI} from './contractGUI'
import {TreeView, TreeViewItem} from '@remix-ui/tree-view'
import {BN} from 'bn.js'
import {CustomTooltip, is0XPrefixed, isHexadecimal, isNumeric, shortenAddress} from '@remix-ui/helper'
import { LowLevelInteractionIcon } from './lowlevelInteractionIcon'
const txHelper = remixLib.execution.txHelper
@ -25,6 +24,8 @@ export function UniversalDappUI(props: UdappProps) {
const [evmBC, setEvmBC] = useState(null)
const [instanceBalance, setInstanceBalance] = useState(0)
const getVersion = () => window.location.href.split('=')[5].split('+')[0].split('-')[1]
useEffect(() => {
if (!props.instance.abi) {
const abi = txHelper.sortAbiFunction(props.instance.contractData.abi)
@ -285,7 +286,11 @@ export function UniversalDappUI(props: UdappProps) {
<div className="py-2 border-top d-flex justify-content-start flex-grow-1">
<FormattedMessage id="udapp.lowLevelInteractions" />
</div>
<LowLevelInteractionIcon plugin={props.state} />
<CustomTooltip placement={'bottom-end'} tooltipClasses="text-wrap" tooltipId="receiveEthDocstoolTip" tooltipText={<FormattedMessage id="udapp.tooltipText8" />}>
<a href={`https://solidity.readthedocs.io/en/${getVersion()}/contracts.html#receive-ether-function`} target="_blank" rel="noreferrer">
<i aria-hidden="true" className="fas fa-info my-2 mr-1"></i>
</a>
</CustomTooltip>
</div>
<div className="d-flex flex-column align-items-start">
<label className="">CALLDATA</label>

@ -299,8 +299,6 @@ export function RunTabUI(props: RunTabProps) {
isValidProxyAddress={isValidProxyAddress}
isValidProxyUpgrade={isValidProxyUpgrade}
proxy={runTab.proxy}
stateDispatch={dispatch}
runTabState={runTab}
/>
<RecorderUI
plugin={plugin}
@ -324,7 +322,6 @@ export function RunTabUI(props: RunTabProps) {
runTransactions={executeTransactions}
sendValue={runTab.sendValue}
getFuncABIInputs={getFuncABIValues}
state={runTab}
/>
</div>
</div>

@ -225,8 +225,6 @@ export type MainnetPrompt = (
) => JSX.Element
export interface ContractDropdownProps {
stateDispatch: React.Dispatch<any>,
runTabState: RunTabState,
selectedAccount: string,
exEnvironment: string,
contracts: {
@ -286,7 +284,6 @@ export interface RecorderProps {
}
export interface InstanceContainerProps {
state: RunTabState,
instances: {
instanceList: {
contractData?: ContractData,
@ -373,8 +370,6 @@ export interface ContractGUIProps {
isValidProxyAddress?: (address: string) => Promise<boolean>,
isValidProxyUpgrade?: (proxyAddress: string) => Promise<LayoutCompatibilityReport | { ok: boolean, pass: boolean, warning: boolean }>,
modal?: (title: string, message: string | JSX.Element, okLabel: string, okFn: () => void, cancelLabel?: string, cancelFn?: () => void, okBtnClass?: string, cancelBtnClass?: string) => void
dispatch?: React.Dispatch<any>
runTabState?: RunTabState
}
export interface MainnetProps {
network: Network,
@ -402,7 +397,6 @@ export interface UdappProps {
decodedResponse?: Record<number, any>,
abi?: any
},
state: RunTabState,
context: 'memory' | 'blockchain',
removeInstance: (index: number) => void,
index: number,

Loading…
Cancel
Save