From fe3f39f39ae1c0e68b2d36b84beea93924cf66b5 Mon Sep 17 00:00:00 2001 From: schmanu Date: Fri, 3 May 2024 12:58:57 +0200 Subject: [PATCH] feat: fetch contract info for contract interactions --- package.json | 2 +- src/components/common/NamedAddress/index.tsx | 21 +++++++++++++++++++ .../DecodedData/SingleTxDecoded/index.tsx | 4 ++-- .../TxDetails/TxData/DecodedData/index.tsx | 4 ++-- .../SwapOrderConfirmationView/index.tsx | 14 +++---------- yarn.lock | 8 +++---- 6 files changed, 33 insertions(+), 20 deletions(-) create mode 100644 src/components/common/NamedAddress/index.tsx diff --git a/package.json b/package.json index 64889f6926..1d91b2450e 100644 --- a/package.json +++ b/package.json @@ -63,7 +63,7 @@ "@safe-global/safe-core-sdk": "^3.3.5", "@safe-global/safe-core-sdk-utils": "^1.7.4", "@safe-global/safe-ethers-lib": "^1.9.4", - "@safe-global/safe-gateway-typescript-sdk": "3.21.0-alpha.3", + "@safe-global/safe-gateway-typescript-sdk": "3.21.1", "@safe-global/safe-modules-deployments": "^1.2.0", "@sentry/react": "^7.91.0", "@spindl-xyz/attribution-lite": "^1.4.0", diff --git a/src/components/common/NamedAddress/index.tsx b/src/components/common/NamedAddress/index.tsx new file mode 100644 index 0000000000..ef467044cb --- /dev/null +++ b/src/components/common/NamedAddress/index.tsx @@ -0,0 +1,21 @@ +import useAsync from '@/hooks/useAsync' +import useChainId from '@/hooks/useChainId' +import { getContract } from '@safe-global/safe-gateway-typescript-sdk' +import EthHashInfo from '../EthHashInfo' +import type { EthHashInfoProps } from '../EthHashInfo/SrcEthHashInfo' + +const NamedAddressInfo = ({ address, name, customAvatar, ...props }: EthHashInfoProps) => { + const chainId = useChainId() + const [contract] = useAsync(() => getContract(chainId, address), [address, chainId]) + + return ( + + ) +} + +export default NamedAddressInfo diff --git a/src/components/transactions/TxDetails/TxData/DecodedData/SingleTxDecoded/index.tsx b/src/components/transactions/TxDetails/TxData/DecodedData/SingleTxDecoded/index.tsx index d04b43ca1f..7dcb5103c7 100644 --- a/src/components/transactions/TxDetails/TxData/DecodedData/SingleTxDecoded/index.tsx +++ b/src/components/transactions/TxDetails/TxData/DecodedData/SingleTxDecoded/index.tsx @@ -13,7 +13,7 @@ import accordionCss from '@/styles/accordion.module.css' import CodeIcon from '@mui/icons-material/Code' import { DelegateCallWarning } from '@/components/transactions/Warning' import { InfoDetails } from '@/components/transactions/InfoDetails' -import EthHashInfo from '@/components/common/EthHashInfo' +import NamedAddressInfo from '@/components/common/NamedAddress' type SingleTxDecodedProps = { tx: InternalTransaction @@ -74,7 +74,7 @@ export const SingleTxDecoded = ({ {isDelegateCall && } {!isSpendingLimitMethod && ( - { return ( <> - , - + , receiver && owner !== receiver ? ( <> diff --git a/yarn.lock b/yarn.lock index 985b249033..9cd3a71f0c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4336,10 +4336,10 @@ "@safe-global/safe-core-sdk-utils" "^1.7.4" ethers "5.7.2" -"@safe-global/safe-gateway-typescript-sdk@3.21.0-alpha.3": - version "3.21.0-alpha.3" - resolved "https://registry.yarnpkg.com/@safe-global/safe-gateway-typescript-sdk/-/safe-gateway-typescript-sdk-3.21.0-alpha.3.tgz#21e0f01e9fbc6cff504fa9c7f957c27877b3f982" - integrity sha512-31xjB8VYUMsJ9akBd30YqHt4mreAwF5Kwbfa0LO0lE5L/DvfIwYiK/VB9uMse3LF/gVKKVOu9TIxKkaTsh9Y5w== +"@safe-global/safe-gateway-typescript-sdk@3.21.1": + version "3.21.1" + resolved "https://registry.yarnpkg.com/@safe-global/safe-gateway-typescript-sdk/-/safe-gateway-typescript-sdk-3.21.1.tgz#984ec2d3d4211caf6a96786ab922b39909093538" + integrity sha512-7nakIjcRSs6781LkizYpIfXh1DYlkUDqyALciqz/BjFU/S97sVjZdL4cuKsG9NEarytE+f6p0Qbq2Bo1aocVUA== "@safe-global/safe-gateway-typescript-sdk@^3.5.3": version "3.19.0"