Skip to content

Commit

Permalink
Fix EVM display
Browse files Browse the repository at this point in the history
  • Loading branch information
BoThe1K committed Nov 17, 2023
1 parent 0b44946 commit 1df0938
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 11 deletions.
10 changes: 8 additions & 2 deletions apps/web-stratos/src/components/msg/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ const customTypeToModel = {
'/stratos.evm.v1.MsgEthereumTx': {
model: MODELS.MsgEthereumTx,
content: COMPONENTS.EthereumTx,
tagTheme: 'evm',
tagTheme: 'four',
tagDisplay: 'txEthereumTxLabel',
},
};
Expand Down Expand Up @@ -542,7 +542,8 @@ export const convertMsgsToModels = (
'@type': string;
}>;
logs?: Array<Log>;
} | null
} | null,
dynamicType?: boolean
) => {
const messages =
transaction?.messages?.map((msg: object, i: number) => {
Expand All @@ -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);
}) ?? [];

Expand Down
5 changes: 2 additions & 3 deletions apps/web-stratos/src/models/msg/evm/msg_ethereum_tx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/screens/block_details/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ const formatSignatures = (data: BlockDetailsQuery) => {
// ==========================
const formatTransactions = (data: BlockDetailsQuery, stateChange: Partial<BlockDetailState>) => {
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 ?? '';
Expand Down
6 changes: 3 additions & 3 deletions packages/ui/src/screens/transactions/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 1df0938

Please sign in to comment.