Skip to content

Commit

Permalink
update txn endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
Hemanthghs committed Sep 21, 2024
1 parent d50a50e commit b51271d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ const DialogTxInstantiateStatus = ({ chainID }: { chainID: string }) => {
<div className="grid grid-cols-2 gap-6">
<TxnInfoCard name="Code ID">
<div className="text-b1">{txResponse?.codeId || '-'}</div>
{txResponse?.codeId ? (
<Copy content={txResponse?.codeId} />
) : null}
</TxnInfoCard>
<TxnInfoCard name="Contract Address">
<div className="text-b1">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ const DialogTxUploadCodeStatus = ({ chainID }: { chainID: string }) => {
<div className="space-y-6">
<TxnInfoCard name="Code ID">
<div className="text-b1">{txResponse?.codeId || '-'}</div>
{txResponse?.codeId ? (
<Copy content={txResponse?.codeId} />
) : null}
</TxnInfoCard>
<TxnInfoCard name="Txn Hash">
<div className="text-b1">
Expand Down
35 changes: 22 additions & 13 deletions frontend/src/store/features/cosmwasm/cosmwasmSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { createAsyncThunk, createSlice, PayloadAction } from '@reduxjs/toolkit';
import { cloneDeep } from 'lodash';
import { setError } from '../common/commonSlice';
import axios from 'axios';
import { cleanURL, trackEvent } from '@/utils/util';
import { addChainIDParam, cleanURL, trackEvent } from '@/utils/util';
import { parseTxResult } from '@/utils/signing';
import { getCodes, getContractsByCode } from './cosmwasmService';
import { FAILED, SUCCESS } from '@/utils/constants';
Expand Down Expand Up @@ -226,17 +226,20 @@ export const executeContract = createAsyncThunk(
async (data: ExecuteContractInputs, { rejectWithValue, dispatch }) => {
try {
const response = await data.getExecutionOutput(data);
const txn = await axios.get(
cleanURL(data.baseURLs[0]) + '/cosmos/tx/v1beta1/txs/' + response.txHash
);
let txnUrl =
cleanURL(data.baseURLs[0]) +
'/cosmos/tx/v1beta1/txs/' +
response.txHash;
txnUrl = addChainIDParam(txnUrl, data.chainID);
const txn = await axios.get(txnUrl);
const {
code,
transactionHash,
fee = [],
memo = '',
rawLog = '',
} = parseTxResult(txn?.data?.tx_response);
if(code === 0) {
if (code === 0) {
trackEvent('COSMWASM', 'EXECUTE_CONTRACT', SUCCESS);
} else {
trackEvent('COSMWASM', 'EXECUTE_CONTRACT', FAILED);
Expand Down Expand Up @@ -264,17 +267,20 @@ export const uploadCode = createAsyncThunk(
async (data: UploadCodeInputs, { rejectWithValue, dispatch }) => {
try {
const response = await data.uploadContract(data);
const txn = await axios.get(
cleanURL(data.baseURLs[0]) + '/cosmos/tx/v1beta1/txs/' + response.txHash
);
let txnUrl =
cleanURL(data.baseURLs[0]) +
'/cosmos/tx/v1beta1/txs/' +
response.txHash;
txnUrl = addChainIDParam(txnUrl, data.chainID);
const txn = await axios.get(txnUrl);
const {
code,
transactionHash,
fee = [],
memo = '',
rawLog = '',
} = parseTxResult(txn?.data?.tx_response);
if(code === 0) {
if (code === 0) {
trackEvent('COSMWASM', 'UPLOAD_CODE', SUCCESS);
} else {
trackEvent('COSMWASM', 'UPLOAD_CODE', FAILED);
Expand Down Expand Up @@ -309,17 +315,20 @@ export const txInstantiateContract = createAsyncThunk(
async (data: InstantiateContractInputs, { rejectWithValue, dispatch }) => {
try {
const response = await data.instantiateContract(data);
const txn = await axios.get(
cleanURL(data.baseURLs[0]) + '/cosmos/tx/v1beta1/txs/' + response.txHash
);
let txnUrl =
cleanURL(data.baseURLs[0]) +
'/cosmos/tx/v1beta1/txs/' +
response.txHash;
txnUrl = addChainIDParam(txnUrl, data.chainID);
const txn = await axios.get(txnUrl);
const {
code,
transactionHash,
fee = [],
memo = '',
rawLog = '',
} = parseTxResult(txn?.data?.tx_response);
if(code === 0) {
if (code === 0) {
trackEvent('COSMWASM', 'INSTANTIATE_CONTRACT', SUCCESS);
} else {
trackEvent('COSMWASM', 'INSTANTIATE_CONTRACT', FAILED);
Expand Down

0 comments on commit b51271d

Please sign in to comment.