-
Notifications
You must be signed in to change notification settings - Fork 428
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: show message and domain hash (#4394)
Co-authored-by: Aaron Cook <[email protected]>
- Loading branch information
Showing
2 changed files
with
75 additions
and
7 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
src/components/transactions/TxDetails/Summary/SafeTxHashDataRow/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { TypedDataEncoder } from 'ethers' | ||
import { TxDataRow, generateDataRowValue } from '../TxDataRow' | ||
import { type SafeTransactionData, type SafeVersion } from '@safe-global/safe-core-sdk-types' | ||
import { getEip712TxTypes } from '@safe-global/protocol-kit/dist/src/utils' | ||
import useSafeAddress from '@/hooks/useSafeAddress' | ||
import useChainId from '@/hooks/useChainId' | ||
|
||
export const SafeTxHashDataRow = ({ | ||
safeTxHash, | ||
safeTxData, | ||
safeVersion, | ||
}: { | ||
safeTxHash: string | ||
safeTxData?: SafeTransactionData | ||
safeVersion: SafeVersion | ||
}) => { | ||
const chainId = useChainId() | ||
const safeAddress = useSafeAddress() | ||
const domainHash = TypedDataEncoder.hashDomain({ | ||
chainId, | ||
verifyingContract: safeAddress, | ||
}) | ||
const messageHash = safeTxData | ||
? TypedDataEncoder.hashStruct('SafeTx', { SafeTx: getEip712TxTypes(safeVersion).SafeTx }, safeTxData) | ||
: undefined | ||
|
||
return ( | ||
<> | ||
<TxDataRow datatestid="tx-safe-hash" title="safeTxHash:"> | ||
{generateDataRowValue(safeTxHash, 'hash')} | ||
</TxDataRow> | ||
<TxDataRow datatestid="tx-domain-hash" title="Domain hash:"> | ||
{generateDataRowValue(domainHash, 'hash')} | ||
</TxDataRow> | ||
{messageHash && ( | ||
<TxDataRow datatestid="tx-message-hash" title="Message hash:"> | ||
{generateDataRowValue(messageHash, 'hash')} | ||
</TxDataRow> | ||
)} | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters