Skip to content

Commit

Permalink
feat: update query tx
Browse files Browse the repository at this point in the history
  • Loading branch information
thanhnv2303 committed Dec 12, 2022
1 parent 97eef87 commit e027271
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 3 deletions.
36 changes: 34 additions & 2 deletions src/lib/cosm/query_index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const rpcUrl = 'https://testnet.rpc.orai.io';
// const rpcUrl = "https://rpc-osmosis.keplr.app";
// const rpcUrl = 'https://osmosis-testnet-rpc.allthatnode.com:26657';
let provider;
let cosm;
let cosm: Cosm;
let wallet: DirectSecp256k1HdWallet;
let client;
let account: AccountData;
Expand Down Expand Up @@ -216,7 +216,7 @@ describe('Cosm test', async () => {

describe('Test distribution query', async () => {
it('should get distribution info', async function() {
const distribution : Distribution = cosm.cosmos.distribution;
const distribution: Distribution = cosm.cosmos.distribution;

const validatorDelegationsResponse = await cosm.cosmos.staking
.query.block(currentBlock - 100).ValidatorDelegations({ validatorAddr: validatorAddr });
Expand Down Expand Up @@ -289,4 +289,36 @@ describe('Cosm test', async () => {
// console.log(denom);
});
});

describe('Get txs', async () => {
it('should get blocks with txs', async function() {

let block = await cosm.cosmos.tx.query.GetBlockWithTxs({
height: Long.fromNumber(10159176),
pagination: {
key:Uint8Array.from([0,1]),
offset: Long.fromNumber(0),
limit: Long.fromNumber(100),
countTotal: true,
reverse: false
}
});
console.log(block);
});
it('should get txs by hash', async function() {

// tx transfer
let tx = await cosm.cosmos.tx.query.GetTx({
hash : "51EAEE06216802648BCE3D7ACE4FDADF845402251DE76D8065613E4AC97B63E7"
});
console.log(tx);

//tx
let tx2 = await cosm.cosmos.tx.query.GetTx({
hash : "739363AB226D5C4B8BD0C416EE9627A880FD5044F6EA25D20DA94C5510ECE938"
});
console.log(tx2);
});

});
});
4 changes: 3 additions & 1 deletion src/lib/cosmos/tx.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { Provider } from '../providers';

import {ServiceClientImpl} from "cosmjs-types/cosmos/tx/v1beta1/service"
import { App } from './app';

export class Tx extends App {
query :ServiceClientImpl;
constructor(provider: Provider) {
super(provider);
this.setQueryClient(ServiceClientImpl)
}
}

0 comments on commit e027271

Please sign in to comment.