1- import classNames from 'classnames' ;
21import { useRef , useState } from 'react' ;
32import { formatUnits } from 'viem' ;
43import { mainnet } from 'viem/chains' ;
54import { useChains } from 'wagmi' ;
6- import { Accordion , AlertCard , Button , Dropdown , Icon , IconType , invariant , Link , LinkBase } from '../../../../../core' ;
7- import { ChainEntityType , useBlockExplorer } from '../../../../hooks' ;
8- import { addressUtils } from '../../../../utils' ;
5+ import { Accordion , AlertCard , Button , Dropdown , IconType , invariant } from '../../../../../core' ;
96import { useGukModulesContext } from '../../../gukModulesProvider' ;
7+ import { SmartContractFunctionDataListItem } from '../../../smartContract/smartContractFunctionDataListItem' ;
108import { ProposalActionsDecoder , ProposalActionsDecoderView } from '../proposalActionsDecoder' ;
119import { ProposalActionsDecoderMode } from '../proposalActionsDecoder/proposalActionsDecoder.api' ;
1210import type { IProposalAction } from '../proposalActionsDefinitions' ;
@@ -40,7 +38,6 @@ export const ProposalActionsItem = <TAction extends IProposalAction = IProposalA
4038 ) ;
4139
4240 const { copy } = useGukModulesContext ( ) ;
43- const { buildEntityUrl } = useBlockExplorer ( { chainId } ) ;
4441
4542 const chains = useChains ( ) ;
4643 const chain = chains . find ( ( chain ) => chain . id === chainId ) ;
@@ -70,11 +67,6 @@ export const ProposalActionsItem = <TAction extends IProposalAction = IProposalA
7067 const displayValueWarning = action . value !== '0' && action . data !== '0x' ;
7168 const formattedValue = formatUnits ( BigInt ( action . value ) , 18 ) ;
7269
73- const displayWarningFeedback = displayValueWarning || ! isAbiAvailable ;
74- const functionNameStyle = displayWarningFeedback ? 'text-warning-800' : 'text-neutral-800' ;
75-
76- const targetAddressUrl = buildEntityUrl ( { type : ChainEntityType . ADDRESS , id : action . to } ) ;
77-
7870 const viewModes = [
7971 { mode : 'BASIC' as const , disabled : ! supportsBasicView } ,
8072 { mode : ProposalActionsDecoderView . DECODED , disabled : ! supportsDecodedView } ,
@@ -88,36 +80,16 @@ export const ProposalActionsItem = <TAction extends IProposalAction = IProposalA
8880 return (
8981 < Accordion . Item value = { value ?? index . toString ( ) } ref = { itemRef } >
9082 < Accordion . ItemHeader className = "min-w-0" >
91- < div className = "flex min-w-0 flex-col items-start gap-1 md:gap-1.5" >
92- < div className = "flex w-full flex-row items-center gap-2" >
93- < p
94- className = { classNames (
95- 'truncate text-base leading-tight font-normal md:text-lg' ,
96- functionNameStyle ,
97- ) }
98- >
99- { action . inputData ?. function ?? copy . proposalActionsItem . notVerified . function }
100- </ p >
101- { displayWarningFeedback && (
102- < Icon icon = { IconType . WARNING } size = "md" className = "text-warning-500" />
103- ) }
104- </ div >
105- < LinkBase
106- className = "flex w-full items-center gap-2 md:gap-3"
107- href = { targetAddressUrl }
108- target = "_blank"
109- >
110- < p className = "truncate text-sm leading-tight font-normal text-neutral-500 md:text-base" >
111- { action . inputData ?. contract ?? copy . proposalActionsItem . notVerified . contract }
112- </ p >
113- { /* Using solution from https://kizu.dev/nested-links/ to nest anchor tags */ }
114- < object type = "unknown" >
115- < Link className = "shrink-0" href = { targetAddressUrl } isExternal = { true } >
116- { addressUtils . truncateAddress ( action . to ) }
117- </ Link >
118- </ object >
119- </ LinkBase >
120- </ div >
83+ < SmartContractFunctionDataListItem . Structure
84+ functionName = { action . inputData ?. function }
85+ contractName = { action . inputData ?. contract }
86+ contractAddress = { action . to }
87+ functionParameters = { action . inputData ?. parameters }
88+ chainId = { chainId }
89+ className = "w-full bg-transparent"
90+ asChild = { true }
91+ displayWarning = { displayValueWarning }
92+ />
12193 </ Accordion . ItemHeader >
12294 < Accordion . ItemContent forceMount = { editMode ? true : undefined } >
12395 < div className = "flex flex-col items-start gap-y-6 self-start md:gap-y-8" >
0 commit comments