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

feat: tx evm #1188

Merged
merged 8 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from 7 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
18 changes: 17 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,23 @@
"plugin:storybook/recommended"
],
"rules": {
"@typescript-eslint/no-unused-vars": "off",
// eslint basic
"no-undef": "off",
"no-console": "error",
"no-unused-vars": "off",
"strict": ["error", "global"],
"consistent-return": "error",
"no-else-return": "error",
"no-param-reassign": [
"error",
{ "props": true, "ignorePropertyModificationsFor": ["acc"] }
],
"no-use-before-define": "error",
"object-shorthand": "error",
"prefer-const": "error",
"eqeqeq": "error",
"semi": "error",

"@typescript-eslint/no-empty-object-type": "off",
"sonarjs/no-duplicate-string": ["error", { "threshold": 3 }],
"sonarjs/cognitive-complexity": ["error", 27],
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Features

- [#1188](https://github.com/alleslabs/celatone-frontend/pull/1188) Add request and simulate evm tx
- [#1192](https://github.com/alleslabs/celatone-frontend/pull/1192) Add fixed bytes hex address util
- [#1189](https://github.com/alleslabs/celatone-frontend/pull/1189) Add constructor args to EVM contract verify page
- [#1187](https://github.com/alleslabs/celatone-frontend/pull/1187) Add onboarding section to EVM contract details page and add EVM contract verify page
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
"build-storybook": "storybook build"
},
"dependencies": {
"@alleslabs/shared": "1.0.0-dev6",
"@alleslabs/legacy-bcs": "0.0.3",
"@alleslabs/shared": "1.0.0-dev6",
"@amplitude/analytics-browser": "^2.3.3",
"@amplitude/analytics-types": "^2.3.0",
"@amplitude/plugin-user-agent-enrichment-browser": "^1.0.0",
Expand Down Expand Up @@ -72,9 +72,9 @@
"@emotion/react": "^11.11.3",
"@emotion/styled": "^11.11.0",
"@hookform/resolvers": "^3.9.0",
"@initia/initia.js": "0.2.24",
"@initia/initia.js": "0.2.26",
"@initia/initia.proto": "0.2.4",
"@initia/react-wallet-widget": "^0.191.0",
"@initia/react-wallet-widget": "0.193.0",
"@interchain-ui/react": "1.23.9",
"@monaco-editor/react": "^4.6.0",
"@rjsf/chakra-ui": "v5.18.1",
Expand Down Expand Up @@ -103,6 +103,7 @@
"chartjs-plugin-crosshair": "^2.0.0",
"cosmjs-types": "^0.9.0",
"dayjs": "^1.11.6",
"ethers": "^6.13.5",
"file-saver": "^2.0.5",
"framer-motion": "^11.0.3",
"js-base64": "^3.7.4",
Expand Down
79 changes: 46 additions & 33 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/lib/amplitude/Amplitude.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-use-before-define */
import { createInstance, Identify } from "@amplitude/analytics-browser";
import type { BrowserClient } from "@amplitude/analytics-types";
import { userAgentEnrichmentPlugin } from "@amplitude/plugin-user-agent-enrichment-browser";
Expand Down
1 change: 1 addition & 0 deletions src/lib/app-fns/tx/common/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from "./catchTxError";
export * from "./post";
export * from "./postEvm";
export * from "./sending";
20 changes: 5 additions & 15 deletions src/lib/app-fns/tx/common/post.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import type {
DeliverTxResponse,
ExecuteResult,
InstantiateResult,
UploadResult,
} from "@cosmjs/cosmwasm-stargate";
import type { DeliverTxResponse } from "@cosmjs/cosmwasm-stargate";
import { isDeliverTxFailure } from "@cosmjs/stargate";

import { EstimatedFeeRender } from "lib/components/EstimatedFeeRender";
Expand All @@ -12,14 +7,7 @@ import type { TxResultRendering } from "lib/types";
import { TxStreamPhase } from "lib/types";
import { feeFromStr } from "lib/utils";

// TODO: We'll use only DeliverTxResponse later.
type TxResult =
| UploadResult
| InstantiateResult
| ExecuteResult
| DeliverTxResponse;

interface PostTxParams<T extends TxResult> {
interface PostTxParams<T extends DeliverTxResponse> {
postFn: () => Promise<T>;
}

Expand All @@ -30,7 +18,9 @@ function createDeliverTxResponseErrorMessage(
return `Error when broadcasting tx ${result.transactionHash} at height ${result.height}. Code: ${result.code}; Raw log: ${result.rawLog}`;
}

export const postTx = <T extends TxResult>({ postFn }: PostTxParams<T>) => {
export const postTx = <T extends DeliverTxResponse>({
postFn,
}: PostTxParams<T>) => {
return () =>
postFn().then(
// NOTE: only shown if there is a wait for the next step
Expand Down
48 changes: 48 additions & 0 deletions src/lib/app-fns/tx/common/postEvm.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { EstimatedFeeEvmRender } from "lib/components/EstimatedFeeEvmRender";
import { ExplorerLink } from "lib/components/ExplorerLink";
import { TxReceiptJsonRpc } from "lib/services/types";
import type { TxResultRendering } from "lib/types";
import { TxStreamPhase } from "lib/types";

interface PostEvmTxParams<T extends TxReceiptJsonRpc> {
postFn: () => Promise<T>;
}

export const postEvmTx = <T extends TxReceiptJsonRpc>({
postFn,
}: PostEvmTxParams<T>) => {
return () =>
postFn().then((txResult) => {
return {
value: txResult,
phase: TxStreamPhase.BROADCAST,
receipts: [
{
title: "Tx Hash",
html: (
<ExplorerLink
type="evm_tx_hash"
value={txResult.transactionHash}
openNewTab
/>
),
},
{
title: "Tx Fee",
// TODO: Implement event/rawlog attribute picker
html: (
<EstimatedFeeEvmRender
gasPrice={txResult.effectiveGasPrice}
gasUsed={txResult.gasUsed}
loading={false}
/>
),
},
],
receiptInfo: {
header: "Sending Transaction",
},
actionVariant: "sending",
} as TxResultRendering<T>;
});
};
Loading
Loading