pull/5217/head
aniket-engg 2 months ago committed by Aniket
parent 23c38fa7d2
commit 83fb45a35d
  1. 2
      libs/remix-ui/run-tab/src/lib/actions/actions.ts
  2. 3
      libs/remix-ui/run-tab/src/lib/actions/events.ts
  3. 2
      libs/remix-ui/run-tab/src/lib/actions/payload.ts
  4. 5
      libs/remix-ui/run-tab/src/lib/components/instanceContainerUI.tsx
  5. 22
      libs/remix-ui/run-tab/src/lib/components/universalDappUI.tsx
  6. 2
      libs/remix-ui/run-tab/src/lib/reducers/runTab.ts
  7. 10
      libs/remix-ui/run-tab/src/lib/types/index.ts

@ -69,7 +69,7 @@ export const updateGasPrice = (dispatch: React.Dispatch<any>, price: string) =>
dispatch(setGasPrice(price))
}
export const addInstance = (dispatch: React.Dispatch<any>, instance: { contractData?: ContractData, address: string, name: string, abi?: any, decodedResponse?: Record<number, any> }) => {
export const addInstance = (dispatch: React.Dispatch<any>, instance: { contractData?: ContractData, address: string, name: string, abi?: any, decodedResponse?: Record<number, any>, isPinned?: boolean, pinnedAt?: number, filePath?: string }) => {
instance.decodedResponse = {}
dispatch(addNewInstance(instance))
}

@ -191,7 +191,8 @@ const loadPinnedContracts = async (plugin, dispatch, dirName) => {
for (const file of filePaths) {
const pinnedContract = await plugin.call('fileManager', 'readFile', file)
const pinnedContractObj = JSON.parse(pinnedContract)
if (pinnedContractObj) addPinnedInstance(dispatch, pinnedContractObj)
pinnedContractObj.isPinned = true
if (pinnedContractObj) addInstance(dispatch, pinnedContractObj)
}
} catch (err) {
console.log(err)

@ -230,7 +230,7 @@ export const updateInstancesBalance = (instances: Array<{ contractData?: Contrac
}
}
export const addNewInstance = (instance: { contractData?: ContractData, address: string, name: string, abi?: any }) => {
export const addNewInstance = (instance: { contractData?: ContractData, address: string, name: string, abi?: any, isPinned?: boolean, pinnedAt?: number }) => {
return {
type: ADD_INSTANCE,
payload: instance

@ -32,7 +32,7 @@ export function InstanceContainerUI(props: InstanceContainerProps) {
) : null}
</div>
{props.pinnedInstances.instanceList.length > 0 ? (
{/* {props.pinnedInstances.instanceList.length > 0 ? (
<div>
{' '}
{props.pinnedInstances.instanceList.map((instance, index) => {
@ -59,7 +59,7 @@ export function InstanceContainerUI(props: InstanceContainerProps) {
)
})}
</div>
) : ''}
) : ''} */}
{instanceList.length > 0 ? (
<div>
@ -69,7 +69,6 @@ export function InstanceContainerUI(props: InstanceContainerProps) {
<UniversalDappUI
key={index}
instance={instance}
isPinnedContract={false}
context={props.getContext()}
removeInstance={props.removeInstance}
index={index}

@ -115,17 +115,17 @@ export function UniversalDappUI(props: UdappProps) {
}
const remove = async() => {
if (props.isPinnedContract) {
if (props.instance.isPinned) {
await unsavePinnedContract()
_paq.push(['trackEvent', 'udapp', 'pinContracts', 'unpinned'])
}
props.removeInstance(props.index, props.isPinnedContract, false)
props.removeInstance(props.index, props.instance.isPinned, false)
}
const deletePinnedContract = async() => {
await unsavePinnedContract()
_paq.push(['trackEvent', 'udapp', 'pinContracts', 'deletePinned'])
props.removeInstance(props.index, props.isPinnedContract, true)
props.removeInstance(props.index, props.instance.isPinned, true)
}
const pinContract = async() => {
@ -146,13 +146,13 @@ export function UniversalDappUI(props: UdappProps) {
}
const runTransaction = (lookupOnly, funcABI: FuncABI, valArr, inputsValues, funcIndex?: number) => {
if (props.isPinnedContract) _paq.push(['trackEvent', 'udapp', 'pinContracts', 'interactWithPinned'])
if (props.instance.isPinned) _paq.push(['trackEvent', 'udapp', 'pinContracts', 'interactWithPinned'])
const functionName = funcABI.type === 'function' ? funcABI.name : `(${funcABI.type})`
const logMsg = `${lookupOnly ? 'call' : 'transact'} to ${props.instance.name}.${functionName}`
props.runTransactions(
props.index,
props.isPinnedContract,
props.instance.isPinned,
lookupOnly,
funcABI,
inputsValues,
@ -248,7 +248,7 @@ export function UniversalDappUI(props: UdappProps) {
className={`instance udapp_instance udapp_run-instance border-dark ${toggleExpander ? 'udapp_hidesub' : 'bg-light'}`}
id={`instance${address}`}
data-shared="universalDappUiInstance"
data-id={props.isPinnedContract ? `pinnedInstance${address}` : `unpinnedInstance${address}`}
data-id={props.instance.isPinned ? `pinnedInstance${address}` : `unpinnedInstance${address}`}
>
<div className="udapp_title pb-0 alert alert-secondary">
<span data-id={`universalDappUiTitleExpander${props.index}`} className="btn udapp_titleExpander" onClick={toggleClass} style={{ padding: "0.45rem" }}>
@ -256,7 +256,7 @@ export function UniversalDappUI(props: UdappProps) {
</span>
<div className="input-group udapp_nameNbuts">
<div className="udapp_titleText input-group-prepend">
{ props.isPinnedContract ? ( <CustomTooltip placement="top" tooltipClasses="text-nowrap" tooltipId="udapp_udappUnpinTooltip" tooltipText={props.isPinnedContract ? `Contract: ${props.instance.name}, Address: ${address}, Pinned at: ${new Date(props.instance.pinnedAt).toLocaleString()}` : '' }>
{ props.instance.isPinned ? ( <CustomTooltip placement="top" tooltipClasses="text-nowrap" tooltipId="udapp_udappUnpinTooltip" tooltipText={props.instance.isPinned ? `Contract: ${props.instance.name}, Address: ${address}, Pinned at: ${new Date(props.instance.pinnedAt).toLocaleString()}` : '' }>
<span className="input-group-text udapp_spanTitleText">
{props.instance.name} at {shortenAddress(address)}
</span>
@ -267,7 +267,7 @@ export function UniversalDappUI(props: UdappProps) {
<div className="btn" style={{ padding: '0.15rem' }}>
<CopyToClipboard tip={intl.formatMessage({ id: 'udapp.copyAddress' })} content={address} direction={'top'} />
</div>
{ props.isPinnedContract ? ( <div className="btn" style={{ padding: '0.15rem', marginLeft: '-0.5rem' }}>
{ props.instance.isPinned ? ( <div className="btn" style={{ padding: '0.15rem', marginLeft: '-0.5rem' }}>
<CustomTooltip placement="top" tooltipClasses="text-nowrap" tooltipId="udapp_udappUnpinTooltip" tooltipText={<FormattedMessage id="udapp.tooltipTextUnpin" />}>
<i className="fas fa-thumbtack p-2" aria-hidden="true" data-id="universalDappUiUdappUnpin" onClick={remove}></i>
</CustomTooltip>
@ -278,7 +278,7 @@ export function UniversalDappUI(props: UdappProps) {
</div> )
}
</div>
{ props.isPinnedContract ? ( <div className="btn" style={{ padding: '0.15rem', marginLeft: '-0.5rem' }}>
{ props.instance.isPinned ? ( <div className="btn" style={{ padding: '0.15rem', marginLeft: '-0.5rem' }}>
<CustomTooltip placement="top" tooltipClasses="text-nowrap" tooltipId="udapp_udappDeleteTooltip" tooltipText={<FormattedMessage id="udapp.tooltipTextDelete" />}>
<i className="far fa-trash p-2" aria-hidden="true" data-id="universalDappUiUdappDelete" onClick={deletePinnedContract}></i>
</CustomTooltip>
@ -310,14 +310,14 @@ export function UniversalDappUI(props: UdappProps) {
)}
</div>
</div>
{ props.isPinnedContract && props.instance.pinnedAt ? (
{ props.instance.isPinned && props.instance.pinnedAt ? (
<div className="d-flex" data-id="instanceContractPinnedAt">
<label>
<b><FormattedMessage id="udapp.pinnedAt" />:</b> {(new Date(props.instance.pinnedAt)).toLocaleString()}
</label>
</div>
) : null }
{ props.isPinnedContract && props.instance.filePath ? (
{ props.instance.isPinned && props.instance.filePath ? (
<div className="d-flex" data-id="instanceContractFilePath" style={{ textAlign: "start", lineBreak: "anywhere" }}>
<label>
<b><FormattedMessage id="udapp.filePath" />:</b> {props.instance.filePath}

@ -488,7 +488,7 @@ export const runTabReducer = (state: RunTabState = runTabInitialState, action: A
}
case ADD_INSTANCE: {
const payload: { contractData: ContractData, address: string, name: string, abi?: any, decodedResponse?: Record<number, any> } = action.payload
const payload: { contractData?: ContractData, address: string, name: string, abi?: any, isPinned?: boolean, pinnedAt?: number } = action.payload
return {
...state,

@ -104,7 +104,9 @@ export interface RunTabState {
balance?: number,
name: string,
decodedResponse?: Record<number, any>,
abi?: any
abi?: any,
isPinned?: boolean,
pinnedAt?: number
}[],
error: string
},
@ -306,7 +308,10 @@ export interface InstanceContainerProps {
balance?: number,
name: string,
decodedResponse?: Record<number, any>,
abi?: any
abi?: any,
isPinned?: boolean,
pinnedAt?: number,
filePath?: string
}[],
error: string
},
@ -435,6 +440,7 @@ export interface UdappProps {
name: string,
decodedResponse?: Record<number, any>,
abi?: any,
isPinned?: boolean
pinnedAt?: number,
filePath?: string
},

Loading…
Cancel
Save