From 1df0938001615ff000a44ce72154818b74e6454c Mon Sep 17 00:00:00 2001 From: BoThe1K Date: Fri, 17 Nov 2023 17:35:11 +0100 Subject: [PATCH] Fix EVM display --- apps/web-stratos/src/components/msg/utils.tsx | 10 ++++++++-- apps/web-stratos/src/models/msg/evm/msg_ethereum_tx.ts | 5 ++--- .../src/screens/home/components/transactions/hooks.ts | 6 ++++-- packages/ui/src/screens/block_details/hooks.ts | 2 +- packages/ui/src/screens/transactions/hooks.ts | 6 +++--- 5 files changed, 18 insertions(+), 11 deletions(-) diff --git a/apps/web-stratos/src/components/msg/utils.tsx b/apps/web-stratos/src/components/msg/utils.tsx index 5c8793c054..7ce5ffee79 100644 --- a/apps/web-stratos/src/components/msg/utils.tsx +++ b/apps/web-stratos/src/components/msg/utils.tsx @@ -464,7 +464,7 @@ const customTypeToModel = { '/stratos.evm.v1.MsgEthereumTx': { model: MODELS.MsgEthereumTx, content: COMPONENTS.EthereumTx, - tagTheme: 'evm', + tagTheme: 'four', tagDisplay: 'txEthereumTxLabel', }, }; @@ -542,7 +542,8 @@ export const convertMsgsToModels = ( '@type': string; }>; logs?: Array; - } | null + } | null, + dynamicType?: boolean ) => { const messages = transaction?.messages?.map((msg: object, i: number) => { @@ -555,6 +556,11 @@ export const convertMsgsToModels = ( const log = transaction?.logs?.[i]; return MODELS.MsgWithdrawValidatorCommission.fromJson(msg, log); } + if (dynamicType) { + if (model === MODELS.MsgEthereumTx) { + return model.fromJson(msg, '/stratos.evm.v1.MsgEvmTx'); + } + } return model.fromJson(msg); }) ?? []; diff --git a/apps/web-stratos/src/models/msg/evm/msg_ethereum_tx.ts b/apps/web-stratos/src/models/msg/evm/msg_ethereum_tx.ts index afa4d4ead6..35492b5c4f 100644 --- a/apps/web-stratos/src/models/msg/evm/msg_ethereum_tx.ts +++ b/apps/web-stratos/src/models/msg/evm/msg_ethereum_tx.ts @@ -34,11 +34,10 @@ class MsgEthereumTx { } // eslint-disable-next-line @typescript-eslint/no-explicit-any - static fromJson(json: any) { + static fromJson(json: any, type?: string) { return new MsgEthereumTx({ json, - // type: json['@type'], - type: '/stratos.evm.v1.MsgEvmTx', // NOTE: For removing ethereum name from type + type: type ?? json['@type'], data: json?.data, size: json?.size, hash: json?.hash, diff --git a/apps/web-stratos/src/screens/home/components/transactions/hooks.ts b/apps/web-stratos/src/screens/home/components/transactions/hooks.ts index b121113c97..b609ad7257 100644 --- a/apps/web-stratos/src/screens/home/components/transactions/hooks.ts +++ b/apps/web-stratos/src/screens/home/components/transactions/hooks.ts @@ -6,12 +6,14 @@ import { } from '@/graphql/types/general_types'; import type { TransactionsState } from '@/screens/home/components/transactions/types'; import { convertMsgType } from '@/utils/convert_msg_type'; +import { convertMsgsToModels } from '@/components/msg/utils'; const formatTransactions = (data: TransactionsListenerSubscription) => data.transactions?.map((x) => { + const messages = convertMsgsToModels(x, true); const msgType = - x.messages?.map((eachMsg: object) => { - const eachMsgType = R.pathOr('none type', ['@type'], eachMsg); + messages?.map((eachMsg: object) => { + const eachMsgType = R.pathOr('none type', ['type'], eachMsg); return eachMsgType ?? ''; }) ?? []; const convertedMsgType = convertMsgType(msgType); diff --git a/packages/ui/src/screens/block_details/hooks.ts b/packages/ui/src/screens/block_details/hooks.ts index 4334e56161..5a3ca6eb17 100644 --- a/packages/ui/src/screens/block_details/hooks.ts +++ b/packages/ui/src/screens/block_details/hooks.ts @@ -90,7 +90,7 @@ const formatSignatures = (data: BlockDetailsQuery) => { // ========================== const formatTransactions = (data: BlockDetailsQuery, stateChange: Partial) => { const transactions = data.transaction.map((x) => { - const messages = convertMsgsToModels(x); + const messages = convertMsgsToModels(x, true); const msgType = messages.map((eachMsg) => { const eachMsgType = eachMsg?.type ?? 'none type'; return eachMsgType ?? ''; diff --git a/packages/ui/src/screens/transactions/hooks.ts b/packages/ui/src/screens/transactions/hooks.ts index 72c3fe7565..9eb8324703 100644 --- a/packages/ui/src/screens/transactions/hooks.ts +++ b/packages/ui/src/screens/transactions/hooks.ts @@ -27,10 +27,10 @@ const formatTransactions = (data: TransactionsListenerSubscription): Transaction } return formattedData.map((x) => { - const messages = convertMsgsToModels(x); + const messages = convertMsgsToModels(x, true); const msgType = - x.messages?.map((eachMsg: unknown) => { - const eachMsgType = R.pathOr('none type', ['@type'], eachMsg); + messages?.map((eachMsg: unknown) => { + const eachMsgType = R.pathOr('none type', ['type'], eachMsg); return eachMsgType ?? ''; }) ?? []; const convertedMsgType = convertMsgType(msgType);