-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathContractCreatorInfo.tsx
More file actions
77 lines (69 loc) · 2.25 KB
/
ContractCreatorInfo.tsx
File metadata and controls
77 lines (69 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import { FC } from 'react'
import { RuntimeScope } from '../../../types/searchScope'
import { useTranslation } from 'react-i18next'
import { TransactionLink } from '../Transactions/TransactionLink'
import {
Runtime,
useGetRuntimeAccountsAddress,
useGetRuntimeTransactionsTxHash,
} from '../../../oasis-nexus/api'
import { AccountLink } from './AccountLink'
import { Skeleton } from '@oasisprotocol/ui-library/src/components/ui/skeleton'
const TxSender: FC<{ scope: RuntimeScope; txHash: string; alwaysTrim?: boolean }> = ({
scope,
txHash,
alwaysTrim,
}) => {
const { t } = useTranslation()
const query = useGetRuntimeTransactionsTxHash(scope.network, scope.layer, txHash)
const tx = query.data?.data.transactions[0]
const senderAddress = tx?.signers[0].address_eth ?? tx?.signers[0].address
return query.isLoading ? (
<Skeleton className="w-1/4 h-4" />
) : senderAddress ? (
<AccountLink scope={scope} address={senderAddress} alwaysTrim={alwaysTrim} />
) : (
t('common.missing')
)
}
export const ContractCreatorInfo: FC<{
scope: RuntimeScope
isLoading?: boolean
creationTxHash: string | undefined
alwaysTrim?: boolean
}> = ({ scope, isLoading, creationTxHash, alwaysTrim }) => {
const { t } = useTranslation()
return isLoading ? (
<Skeleton className="w-1/4 h-4" />
) : creationTxHash === undefined ? (
t('common.missing')
) : (
<>
<TxSender scope={scope} txHash={creationTxHash} alwaysTrim={alwaysTrim} />
<div> {t('contract.createdAt')} </div>
<TransactionLink scope={scope} hash={creationTxHash} alwaysTrim={alwaysTrim} />
</>
)
}
export const DelayedContractCreatorInfo: FC<{
scope: RuntimeScope
contractOasisAddress: string | undefined
alwaysTrim?: boolean
}> = ({ scope, contractOasisAddress, alwaysTrim }) => {
const accountQuery = useGetRuntimeAccountsAddress(
scope.network,
scope.layer as Runtime,
contractOasisAddress!,
)
const account = accountQuery.data?.data
const contract = account?.evm_contract
const creationTxHash = contract?.eth_creation_tx || contract?.creation_tx
return (
<ContractCreatorInfo
scope={scope}
isLoading={accountQuery.isLoading}
creationTxHash={creationTxHash}
alwaysTrim={alwaysTrim}
/>
)
}