Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: tx logs and stone-12-1 #751

Merged
merged 6 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Bug fixes

- [#751](https://github.com/alleslabs/celatone-frontend/pull/751) Fix fail txs should have no logs and remove stone-12-1

## v1.5.1

### Improvements
Expand Down
56 changes: 3 additions & 53 deletions src/config/chain/initia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const INITIA_CHAIN_CONFIGS: ChainConfigs = {
"mahalo-1": {
chain: "initia",
registryChainName: "initiadevnet1",
prettyName: "Initia Closed Testnet 1",
prettyName: "Initia Devnet 1",
lcd: "https://lcd.mahalo-1.initia.xyz",
rpc: "https://rpc.mahalo-1.initia.xyz:443",
indexer: "https://mahalo-1-graphql.alleslabs.dev/v1/graphql",
Expand Down Expand Up @@ -60,7 +60,7 @@ export const INITIA_CHAIN_CONFIGS: ChainConfigs = {
"minimove-1": {
chain: "initia",
registryChainName: "minitiamovedevnet1",
prettyName: "Minitia Move Closed Testnet 1",
prettyName: "Minitia Move Devnet 1",
lcd: "https://lcd.minimove-1.initia.xyz",
rpc: "https://rpc.minimove-1.initia.xyz:443",
indexer: "https://minimove-1-graphql.alleslabs.dev/v1/graphql",
Expand Down Expand Up @@ -110,7 +110,7 @@ export const INITIA_CHAIN_CONFIGS: ChainConfigs = {
"miniwasm-1": {
chain: "initia",
registryChainName: "minitiawasmdevnet1",
prettyName: "Minitia Wasm Closed Testnet 1",
prettyName: "Minitia Wasm Devnet 1",
lcd: "https://lcd.miniwasm-1.initia.xyz",
rpc: "https://rpc.miniwasm-1.initia.xyz:443",
indexer: "https://miniwasm-1-graphql.alleslabs.dev/v1/graphql",
Expand Down Expand Up @@ -156,56 +156,6 @@ export const INITIA_CHAIN_CONFIGS: ChainConfigs = {
},
extra: { disableDelegation: true },
},
"stone-12-1": {
chain: "initia",
registryChainName: "initiatestnet12-1",
prettyName: "Initia Testnet 12-1",
lcd: "https://next-stone-rest.initia.tech",
rpc: "https://next-stone-rpc.initia.tech:443",
indexer: "https://stone-12-1-nft-graphql.alleslabs.dev/v1/graphql",
wallets: [...initiaWallets, ...keplrWallets],
features: {
faucet: {
enabled: true,
url: process.env.NEXT_PUBLIC_INITIA_TESTNET_FAUCET_URL ?? "",
},
wasm: {
enabled: false,
},
move: {
enabled: true,
moduleMaxFileSize: 1_048_576,
decodeApi: INITIA_DECODER,
verify: "https://stone-compiler.initia.tech/contracts/verify",
},
pool: {
enabled: false,
},
publicProject: {
enabled: true,
},
gov: {
enabled: true,
hideOpenProposal: true,
},
nft: {
enabled: true,
},
},
gas: {
gasPrice: {
tokenPerGas: 0.151,
denom: "uinit",
},
gasAdjustment: 1.5,
maxGasLimit: 25_000_000,
},
explorerLink: {
validator: "https://next.app.initia.tech/validator",
proposal: "https://next.app.initia.tech/proposal",
},
extra: {},
},
"stone-13": {
chain: "initia",
registryChainName: "initiatestnet13",
Expand Down
47 changes: 0 additions & 47 deletions src/lib/chain-registry/initiatestnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,53 +136,6 @@ export const initiatestnet: Chain[] = [
],
},
},
{
$schema: CHAIN_SCHEMA,
chain_name: "initiatestnet12-1",
status: "live",
network_type: "testnet",
pretty_name: "Initia Testnet 12-1",
chain_id: "stone-12-1",
bech32_prefix: "init",
daemon_name: "initiad",
node_home: NODE_HOME,
key_algos: ["secp256k1"],
slip44: 118,
fees: {
fee_tokens: [
{
denom: "uinit",
fixed_min_gas_price: 0,
low_gas_price: 0.151,
average_gas_price: 0.151,
high_gas_price: 0.151,
},
],
},
staking: {
staking_tokens: [
{
denom: "uinit",
},
],
},
logo_URIs: {
png: "",
svg: "",
},
apis: {
rpc: [
{
address: "https://next-stone-rpc.initia.tech:443",
},
],
rest: [
{
address: "https://next-stone-rest.initia.tech",
},
],
},
},
songwongtp marked this conversation as resolved.
Show resolved Hide resolved
{
$schema: CHAIN_SCHEMA,
chain_name: "initiatestnet13",
Expand Down
4 changes: 2 additions & 2 deletions src/lib/pages/tx-details/components/MessageSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ export const MessageSection = ({ txData }: MessageSectionProps) => {
</Flex>
{messages.map((msg, idx) => (
<TxMessage
key={msg.type + msg.value + logs[idx].msg_index.toString()}
key={msg.type + msg.value + idx.toString()}
msgBody={msg}
log={logs[idx]}
log={logs.find((log) => log.msg_index === idx)}
songwongtp marked this conversation as resolved.
Show resolved Hide resolved
isSingleMsg={messages.length === 1}
/>
))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const TxMsgExpand = ({

const { "@type": type, ...body } = msgBody;
const isIBC =
Boolean(log.events.find((event) => event.type === "send_packet")) ||
Boolean(log?.events.find((event) => event.type === "send_packet")) ||
songwongtp marked this conversation as resolved.
Show resolved Hide resolved
type.startsWith("/ibc");
const isOpinit = Boolean(type.startsWith("/opinit"));

Expand Down
3 changes: 2 additions & 1 deletion src/lib/pages/tx-details/components/tx-message/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ import type { logs } from "@cosmjs/stargate";
import { useState } from "react";

import type { MsgBody } from "lib/services/tx";
import type { Option } from "lib/types";

import { TxMsgDetails } from "./TxMsgDetails";
import { TxMsgExpand } from "./TxMsgExpand";

export interface TxMsgData {
msgBody: MsgBody;
log: logs.Log;
log: Option<logs.Log>;
isSingleMsg?: boolean;
}

Expand Down
42 changes: 23 additions & 19 deletions src/lib/utils/tx/extractTxLogs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,31 @@ import type { Event, logs } from "@cosmjs/stargate";

import type { TxResponse } from "lib/services/tx";

interface Log extends logs.Log {
events: Event[];
}

export const extractTxLogs = (txData: TxResponse): logs.Log[] => {
const msgLogs = txData.tx.body.messages.map((_, idx) => ({
msg_index: idx,
log: "",
events: [] as Event[],
}));
if (txData.logs.length > 0) return txData.logs;

const logs: Record<string, Log> = {};
txData.events.forEach((event) => {
const index = event.attributes.find(
(attr) => attr.key === "msg_index"
)?.value;
if (index) {
if (!logs[index])
logs[index] = {
msg_index: Number(index),
log: "",
events: [],
};

if (txData.logs.length > 0)
txData.logs.forEach((log) =>
msgLogs[log.msg_index].events.push(...log.events)
);
else
txData.events.forEach((event) => {
const attribute = event.attributes.find(
(attr) => attr.key === "msg_index"
);
if (attribute) {
const index = Number(attribute.value);
msgLogs[index].events.push(event);
}
});
logs[index].events.push(event);
}
});

const msgLogs = Object.values(logs);
msgLogs.sort((a, b) => a.msg_index - b.msg_index);
return msgLogs;
};
Loading