Skip to content

Commit

Permalink
Update the Wallet API to support custom send transaction endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
zivkovicmilos committed Sep 6, 2023
1 parent cf2928b commit a0ea2ab
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gnolang/tm2-js-client",
"version": "1.0.5",
"version": "1.0.6",
"description": "Tendermint2 JS / TS Client",
"main": "./bin/index.js",
"repository": {
Expand Down
18 changes: 15 additions & 3 deletions src/wallet/wallet.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { Provider, Status, uint8ArrayToBase64 } from '../provider';
import {
Provider,
Status,
TransactionEndpoint,
uint8ArrayToBase64,
} from '../provider';
import { Signer } from './signer';
import { LedgerSigner } from './ledger';
import { KeySigner } from './key';
Expand Down Expand Up @@ -296,8 +301,15 @@ export class Wallet {
* The transaction needs to be signed beforehand.
* Returns the transaction hash (base-64)
* @param {Tx} tx the signed transaction
* @param {TransactionEndpoint} endpoint the transaction broadcast type (sync / commit).
* Defaults to broadcast_sync
*/
sendTransaction = async (tx: Tx): Promise<string> => {
sendTransaction = async (
tx: Tx,
endpoint?:
| TransactionEndpoint.BROADCAST_TX_SYNC
| TransactionEndpoint.BROADCAST_TX_COMMIT
): Promise<string> => {
if (!this.provider) {
throw new Error('provider not connected');
}
Expand All @@ -306,7 +318,7 @@ export class Wallet {
const encodedTx: string = uint8ArrayToBase64(Tx.encode(tx).finish());

// Send the encoded transaction
return this.provider.sendTransaction(encodedTx);
return this.provider.sendTransaction(encodedTx, endpoint);
};

/**
Expand Down

0 comments on commit a0ea2ab

Please sign in to comment.