mirror of
https://github.com/sonr-io/sonr.git
synced 2026-08-03 18:01:39 +00:00
22 lines
589 B
TypeScript
22 lines
589 B
TypeScript
import {
|
|
type CosmosTxV1beta1GetTxResponse as GetTxResponse,
|
|
CosmosTxV1beta1ServiceGetTxService as GetTxService,
|
|
} from '@sonr.io/es/protobufs';
|
|
|
|
import { RpcClient } from '../clients/RpcClient';
|
|
|
|
export type GetTxParams = {
|
|
hash: string;
|
|
};
|
|
|
|
/**
|
|
* Returns the tx matching the given hash. Throws if the tx is not found.
|
|
*/
|
|
export async function getTx(endpoint: string, params: GetTxParams) {
|
|
const res = await RpcClient.query(endpoint, GetTxService, params);
|
|
if (!res.tx || !res.txResponse) {
|
|
throw new Error('Tx not found');
|
|
}
|
|
return res as Required<GetTxResponse>;
|
|
}
|