Skip to content

Commit

Permalink
fix: return original tx req in broadcastTx
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronCQL committed Oct 16, 2023
1 parent f5a344e commit 0b13831
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Changelog

## `v0.0.36` [breaking change]
## `v0.0.37` [breaking change]

### Features

Expand Down
6 changes: 3 additions & 3 deletions examples/solid-vite/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,12 @@ const App: Component = () => {
const fee = await wallet.estimateFee(tx);
console.log("Tx fee:", fee);

const res = await wallet.broadcastTx(tx, fee);
console.log("Tx result:", res);
const { txResponse } = await wallet.broadcastTx(tx, fee);
console.log("Tx result:", txResponse);

alert(
"Broadcast success!\n\nTx hash: " +
res.txhash +
txResponse.txhash +
"\n\nCheck console logs for details."
);
} catch (err) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cosmes",
"version": "0.0.36",
"version": "0.0.37",
"private": false,
"packageManager": "[email protected]",
"sideEffects": false,
Expand Down
9 changes: 4 additions & 5 deletions src/wallet/wallets/ConnectedWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
import {
CosmosBaseV1beta1Coin as Coin,
CosmosTxV1beta1Fee as Fee,
CosmosBaseAbciV1beta1TxResponse as TxResponse,
CosmosTxV1beta1GetTxResponse as GetTxResponse,
} from "cosmes/protobufs";

import type { WalletName } from "../constants/WalletName";
Expand Down Expand Up @@ -159,7 +159,7 @@ export abstract class ConnectedWallet {
unsignedTx: UnsignedTx,
fee: Fee,
{ maxAttempts, intervalSeconds }: PollTxOptions = {}
): Promise<PlainMessage<TxResponse>> {
): Promise<Required<PlainMessage<GetTxResponse>>> {
const { accountNumber, sequence } = await this.getAuthInfo(true);
const hash = await this.signAndBroadcastTx(
unsignedTx,
Expand All @@ -170,12 +170,11 @@ export abstract class ConnectedWallet {
// Greedily increment the sequence for the next tx. This may result in the wrong
// sequence, but if `estimateFee` was called prior to this, it will be corrected
this.sequence = sequence + 1n;
const { txResponse } = await pollTx(this.rpc, {
return pollTx(this.rpc, {
hash,
maxAttempts,
intervalSeconds,
});
return txResponse;
}

/**
Expand All @@ -186,7 +185,7 @@ export abstract class ConnectedWallet {
unsignedTx: UnsignedTx,
feeMultiplier = 1.4,
pollOpts: PollTxOptions = {}
): Promise<PlainMessage<TxResponse>> {
): Promise<Required<PlainMessage<GetTxResponse>>> {
const fee = await this.estimateFee(unsignedTx, feeMultiplier);
return this.broadcastTx(unsignedTx, fee, pollOpts);
}
Expand Down

0 comments on commit 0b13831

Please sign in to comment.