Skip to content

Commit 46ca8e8

Browse files
authored
Merge pull request #2065 from oasisprotocol/lw/evm-params
Display evm_fn_params in transaction details
2 parents 30dc3e4 + 051203c commit 46ca8e8

File tree

7 files changed

+36
-1
lines changed

7 files changed

+36
-1
lines changed

.changelog/2065.feature.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Display evm_fn_params in transaction details

.eslintrc.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ const config = {
3535
name: 'date-fns/formatDistanceToNow',
3636
message: 'Use formatDistanceToNow from dateFormatter.ts instead.',
3737
},
38+
{
39+
name: 'js-yaml',
40+
message: "Use 'yamlDump' instead.",
41+
},
3842
],
3943
patterns: [
4044
{

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
"bip39": "^3.1.0",
6565
"date-fns": "3.6.0",
6666
"i18next": "23.16.8",
67+
"js-yaml": "^4.1.0",
6768
"monaco-editor": "^0.52.2",
6869
"react": "18.3.1",
6970
"react-dom": "18.3.1",
@@ -80,6 +81,7 @@
8081
"@testing-library/jest-dom": "^6.6.3",
8182
"@testing-library/react": "^16.3.0",
8283
"@testing-library/user-event": "14.5.2",
84+
"@types/js-yaml": "^4.0.9",
8385
"@types/node": "20.17.24",
8486
"@types/node-fetch": "2.6.12",
8587
"@types/react": "18.3.19",

src/app/components/LongDataDisplay/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ export const LongDataDisplay: FC<{ data: string; fontWeight?: number; collapsedL
6868
display: '-webkit-box',
6969
WebkitLineClamp: isExpanded ? 'none' : collapsedLinesNumber,
7070
WebkitBoxOrient: 'vertical',
71+
whiteSpace: 'pre-wrap',
7172
}}
7273
>
7374
{data}

src/app/pages/RuntimeTransactionDetailPage/index.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import Link from '@mui/material/Link'
4444
import { Link as RouterLink } from 'react-router-dom'
4545
import { RouteUtils } from '../../utils/route-utils'
4646
import Tooltip from '@mui/material/Tooltip'
47+
import { yamlDump } from '../../utils/yamlDump'
4748

4849
export const RuntimeTransactionDetailPage: FC = () => {
4950
const { t } = useTranslation()
@@ -179,7 +180,18 @@ export const RuntimeTransactionDetailView: FC<{
179180
<dd>
180181
<RuntimeTransactionMethod transaction={transaction} />
181182
</dd>
182-
183+
{transaction.evm_fn_params && (
184+
<>
185+
<dt>{t('transactions.method.evm.call')}</dt>
186+
<dd>
187+
<LongDataDisplay
188+
data={`${transaction.evm_fn_name}(\n${yamlDump(transaction.evm_fn_params.map(a => ({ [a.name]: a.value })))})`}
189+
collapsedLinesNumber={8}
190+
fontWeight={400}
191+
/>
192+
</dd>
193+
</>
194+
)}
183195
<dt>{t('transactions.encryption.format')}</dt>
184196
<dd>
185197
<TransactionEncryptionStatus envelope={envelope} withText={true} />

src/app/utils/yamlDump.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// eslint-disable-next-line no-restricted-imports
2+
import { dump } from 'js-yaml'
3+
4+
export function yamlDump(obj: any) {
5+
return dump(obj, {
6+
replacer: (k, v) => {
7+
return v
8+
},
9+
})
10+
}

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2385,6 +2385,11 @@
23852385
resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.7.tgz#4158d3105276773d5b7695cd4834b1722e4f37a8"
23862386
integrity sha512-w28IoSUCJpidD/TGviZwwMJckNESJZXFu7NBZ5YJ4mEUnNraUn9Pm8HSZm/jDF1pDWYKspWE7oVphigUPRakIQ==
23872387

2388+
"@types/js-yaml@^4.0.9":
2389+
version "4.0.9"
2390+
resolved "https://registry.yarnpkg.com/@types/js-yaml/-/js-yaml-4.0.9.tgz#cd82382c4f902fed9691a2ed79ec68c5898af4c2"
2391+
integrity sha512-k4MGaQl5TGo/iipqb2UDG2UwjXziSWkh0uysQelTlJpX1qGlpUZYm8PnO4DxG1qBomtJUdYJ6qR6xdIah10JLg==
2392+
23882393
"@types/json-schema@^7.0.9":
23892394
version "7.0.12"
23902395
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.12.tgz#d70faba7039d5fca54c83c7dbab41051d2b6f6cb"

0 commit comments

Comments
 (0)