From 8dede4081b5befbe027034f2c4d062a107b09c96 Mon Sep 17 00:00:00 2001 From: Kevin Yang <5478483+k-yang@users.noreply.github.com> Date: Thu, 23 Mar 2023 11:18:38 -0500 Subject: [PATCH] refactor(nibijs)!: inherit from StargateClient directly (#111) * refactor: use cosmjs extensions * refactor: replace queryCmd with inherited StargateClient * chore: re-generate docs * fix: tests broken by change * chore: remove unused file * fix: use better operator for waiting for next block --- packages/nibijs/docs/classes/CustomChain.md | 26 +-- packages/nibijs/docs/classes/MsgFactory.md | 12 +- .../nibijs/docs/classes/NibiruQueryClient.md | 115 ++++++++++ packages/nibijs/docs/classes/QueryCmd.md | 106 --------- packages/nibijs/docs/classes/Sdk.md | 35 +-- packages/nibijs/docs/classes/TxCmd.md | 42 ++-- packages/nibijs/docs/enums/BECH32_PREFIX.md | 14 +- packages/nibijs/docs/enums/Signer.md | 6 +- packages/nibijs/docs/interfaces/Chain.md | 14 +- .../nibijs/docs/interfaces/ChainIdParts.md | 8 +- packages/nibijs/docs/interfaces/CoinMap.md | 2 +- packages/nibijs/docs/interfaces/IEventLog.md | 6 +- packages/nibijs/docs/interfaces/IQueryCmd.md | 70 ------ packages/nibijs/docs/interfaces/ISdk.md | 25 +-- .../nibijs/docs/interfaces/MsgTypeUrls.md | 2 +- packages/nibijs/docs/interfaces/TxMessage.md | 2 +- packages/nibijs/docs/intro.md | 2 +- packages/nibijs/docs/modules.md | 173 ++++----------- packages/nibijs/package.json | 4 +- packages/nibijs/src/chain/types.ts | 6 +- packages/nibijs/src/query/distribution.ts | 118 ---------- packages/nibijs/src/query/gov.ts | 129 ----------- packages/nibijs/src/query/query.ts | 120 ++++------- packages/nibijs/src/query/staking.ts | 203 ------------------ packages/nibijs/src/sdk.ts | 21 +- packages/nibijs/src/test/chain.test.ts | 2 +- packages/nibijs/src/test/faucet.test.ts | 26 +-- packages/nibijs/src/test/helpers.ts | 3 +- packages/nibijs/src/test/query.test.ts | 90 ++++---- packages/nibijs/src/test/tx.test.ts | 12 +- packages/nibijs/src/tx/tx.ts | 40 ++-- 31 files changed, 383 insertions(+), 1051 deletions(-) create mode 100644 packages/nibijs/docs/classes/NibiruQueryClient.md delete mode 100644 packages/nibijs/docs/classes/QueryCmd.md delete mode 100644 packages/nibijs/docs/interfaces/IQueryCmd.md delete mode 100644 packages/nibijs/src/query/distribution.ts delete mode 100644 packages/nibijs/src/query/gov.ts delete mode 100644 packages/nibijs/src/query/staking.ts diff --git a/packages/nibijs/docs/classes/CustomChain.md b/packages/nibijs/docs/classes/CustomChain.md index ae370e54..dfdc4013 100644 --- a/packages/nibijs/docs/classes/CustomChain.md +++ b/packages/nibijs/docs/classes/CustomChain.md @@ -1,4 +1,4 @@ -[NibiJS Documentation - v0.19.2](../intro.md) / [Exports](../modules.md) / CustomChain +[NibiJS Documentation - v0.19.5](../intro.md) / [Exports](../modules.md) / CustomChain # Class: CustomChain @@ -56,7 +56,7 @@ Chain #### Defined in -[chain/chain.ts:55](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/chain/chain.ts#L55) +[chain/chain.ts:55](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/chain/chain.ts#L55) ## Properties @@ -72,7 +72,7 @@ chainId: identifier for the chain #### Defined in -[chain/chain.ts:47](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/chain/chain.ts#L47) +[chain/chain.ts:47](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/chain/chain.ts#L47) ___ @@ -82,7 +82,7 @@ ___ #### Defined in -[chain/chain.ts:48](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/chain/chain.ts#L48) +[chain/chain.ts:48](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/chain/chain.ts#L48) ___ @@ -96,7 +96,7 @@ ___ #### Defined in -[chain/chain.ts:53](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/chain/chain.ts#L53) +[chain/chain.ts:53](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/chain/chain.ts#L53) ___ @@ -112,7 +112,7 @@ endptGrpc: endpoint for the gRPC gateway. Usually on port 9090. #### Defined in -[chain/chain.ts:51](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/chain/chain.ts#L51) +[chain/chain.ts:51](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/chain/chain.ts#L51) ___ @@ -128,7 +128,7 @@ endptRest: endpoint for the REST server. Also, the LCD endpoint. #### Defined in -[chain/chain.ts:50](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/chain/chain.ts#L50) +[chain/chain.ts:50](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/chain/chain.ts#L50) ___ @@ -144,7 +144,7 @@ endptTm: endpoint for the Tendermint RPC server. Usually on port 26657. #### Defined in -[chain/chain.ts:49](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/chain/chain.ts#L49) +[chain/chain.ts:49](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/chain/chain.ts#L49) ___ @@ -158,7 +158,7 @@ ___ #### Defined in -[chain/chain.ts:52](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/chain/chain.ts#L52) +[chain/chain.ts:52](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/chain/chain.ts#L52) ## Methods @@ -172,7 +172,7 @@ ___ #### Defined in -[chain/chain.ts:80](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/chain/chain.ts#L80) +[chain/chain.ts:80](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/chain/chain.ts#L80) ___ @@ -186,7 +186,7 @@ ___ #### Defined in -[chain/chain.ts:75](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/chain/chain.ts#L75) +[chain/chain.ts:75](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/chain/chain.ts#L75) ___ @@ -200,7 +200,7 @@ ___ #### Defined in -[chain/chain.ts:70](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/chain/chain.ts#L70) +[chain/chain.ts:70](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/chain/chain.ts#L70) ___ @@ -220,4 +220,4 @@ ___ #### Defined in -[chain/chain.ts:63](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/chain/chain.ts#L63) +[chain/chain.ts:63](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/chain/chain.ts#L63) diff --git a/packages/nibijs/docs/classes/MsgFactory.md b/packages/nibijs/docs/classes/MsgFactory.md index b8274184..e0bb862a 100644 --- a/packages/nibijs/docs/classes/MsgFactory.md +++ b/packages/nibijs/docs/classes/MsgFactory.md @@ -1,4 +1,4 @@ -[NibiJS Documentation - v0.19.2](../intro.md) / [Exports](../modules.md) / MsgFactory +[NibiJS Documentation - v0.19.5](../intro.md) / [Exports](../modules.md) / MsgFactory # Class: MsgFactory @@ -30,7 +30,7 @@ #### Defined in -[msg/index.ts:8](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/msg/index.ts#L8) +[msg/index.ts:8](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/msg/index.ts#L8) ___ @@ -40,7 +40,7 @@ ___ #### Defined in -[msg/index.ts:16](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/msg/index.ts#L16) +[msg/index.ts:16](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/msg/index.ts#L16) ___ @@ -50,7 +50,7 @@ ___ #### Defined in -[msg/index.ts:12](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/msg/index.ts#L12) +[msg/index.ts:12](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/msg/index.ts#L12) ___ @@ -60,7 +60,7 @@ ___ #### Defined in -[msg/index.ts:10](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/msg/index.ts#L10) +[msg/index.ts:10](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/msg/index.ts#L10) ___ @@ -70,4 +70,4 @@ ___ #### Defined in -[msg/index.ts:14](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/msg/index.ts#L14) +[msg/index.ts:14](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/msg/index.ts#L14) diff --git a/packages/nibijs/docs/classes/NibiruQueryClient.md b/packages/nibijs/docs/classes/NibiruQueryClient.md new file mode 100644 index 00000000..3d88b559 --- /dev/null +++ b/packages/nibijs/docs/classes/NibiruQueryClient.md @@ -0,0 +1,115 @@ +[NibiJS Documentation - v0.19.5](../intro.md) / [Exports](../modules.md) / NibiruQueryClient + +# Class: NibiruQueryClient + +## Hierarchy + +- `StargateClient` + + ↳ **`NibiruQueryClient`** + +## Table of contents + +### Constructors + +- [constructor](NibiruQueryClient.md#constructor) + +### Properties + +- [nibiruExtensions](NibiruQueryClient.md#nibiruextensions) + +### Methods + +- [waitForHeight](NibiruQueryClient.md#waitforheight) +- [waitForNextBlock](NibiruQueryClient.md#waitfornextblock) +- [connect](NibiruQueryClient.md#connect) + +## Constructors + +### constructor + +• `Protected` **new NibiruQueryClient**(`tmClient`, `options`) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `tmClient` | `Tendermint34Client` | +| `options` | `StargateClientOptions` | + +#### Overrides + +StargateClient.constructor + +#### Defined in + +[query/query.ts:40](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/query/query.ts#L40) + +## Properties + +### nibiruExtensions + +• `Readonly` **nibiruExtensions**: [`NibiruExtensions`](../modules.md#nibiruextensions) + +#### Defined in + +[query/query.ts:30](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/query/query.ts#L30) + +## Methods + +### waitForHeight + +▸ **waitForHeight**(`height`): `Promise`<`void`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `height` | `number` | + +#### Returns + +`Promise`<`void`\> + +#### Defined in + +[query/query.ts:55](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/query/query.ts#L55) + +___ + +### waitForNextBlock + +▸ **waitForNextBlock**(): `Promise`<`void`\> + +#### Returns + +`Promise`<`void`\> + +#### Defined in + +[query/query.ts:63](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/query/query.ts#L63) + +___ + +### connect + +▸ `Static` **connect**(`endpoint`, `options?`): `Promise`<[`NibiruQueryClient`](NibiruQueryClient.md)\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `endpoint` | `string` | +| `options` | `StargateClientOptions` | + +#### Returns + +`Promise`<[`NibiruQueryClient`](NibiruQueryClient.md)\> + +#### Overrides + +StargateClient.connect + +#### Defined in + +[query/query.ts:32](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/query/query.ts#L32) diff --git a/packages/nibijs/docs/classes/QueryCmd.md b/packages/nibijs/docs/classes/QueryCmd.md deleted file mode 100644 index 973ab0e5..00000000 --- a/packages/nibijs/docs/classes/QueryCmd.md +++ /dev/null @@ -1,106 +0,0 @@ -[NibiJS Documentation - v0.19.2](../intro.md) / [Exports](../modules.md) / QueryCmd - -# Class: QueryCmd - -## Implements - -- [`IQueryCmd`](../interfaces/IQueryCmd.md) - -## Table of contents - -### Constructors - -- [constructor](QueryCmd.md#constructor) - -### Properties - -- [chain](QueryCmd.md#chain) -- [client](QueryCmd.md#client) -- [tmClient](QueryCmd.md#tmclient) - -### Methods - -- [disconnect](QueryCmd.md#disconnect) - -## Constructors - -### constructor - -• **new QueryCmd**(`tmClient`, `chain`) - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `tmClient` | `Tendermint34Client` | -| `chain` | [`Chain`](../interfaces/Chain.md) | - -#### Defined in - -[query/query.ts:79](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/query/query.ts#L79) - -## Properties - -### chain - -• **chain**: [`Chain`](../interfaces/Chain.md) - -The chain to which this query client corresponds. -E.g. nibiru-testnet-1, nibiru-localnet-42 - -#### Implementation of - -[IQueryCmd](../interfaces/IQueryCmd.md).[chain](../interfaces/IQueryCmd.md#chain) - -#### Defined in - -[query/query.ts:77](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/query/query.ts#L77) - -___ - -### client - -• **client**: [`ExtendedQueryClient`](../modules.md#extendedqueryclient) - -An ExtendedQueryClient is the closest analogy to the query command of nibid CLI. -It contains queries for all of the active modules of Nibiru Chain. - -#### Implementation of - -[IQueryCmd](../interfaces/IQueryCmd.md).[client](../interfaces/IQueryCmd.md#client) - -#### Defined in - -[query/query.ts:73](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/query/query.ts#L73) - -___ - -### tmClient - -• **tmClient**: `Tendermint34Client` - -#### Implementation of - -[IQueryCmd](../interfaces/IQueryCmd.md).[tmClient](../interfaces/IQueryCmd.md#tmclient) - -#### Defined in - -[query/query.ts:75](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/query/query.ts#L75) - -## Methods - -### disconnect - -▸ **disconnect**(): `void` - -#### Returns - -`void` - -#### Implementation of - -IQueryCmd.disconnect - -#### Defined in - -[query/query.ts:96](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/query/query.ts#L96) diff --git a/packages/nibijs/docs/classes/Sdk.md b/packages/nibijs/docs/classes/Sdk.md index 0974e949..6d021deb 100644 --- a/packages/nibijs/docs/classes/Sdk.md +++ b/packages/nibijs/docs/classes/Sdk.md @@ -1,4 +1,4 @@ -[NibiJS Documentation - v0.19.2](../intro.md) / [Exports](../modules.md) / Sdk +[NibiJS Documentation - v0.19.5](../intro.md) / [Exports](../modules.md) / Sdk # Class: Sdk @@ -40,8 +40,7 @@ let txResp = sdk.tx.sendTokens(toAddr, tokens) ### Properties - [chain](Sdk.md#chain) -- [query](Sdk.md#query) -- [tmClient](Sdk.md#tmclient) +- [queryClient](Sdk.md#queryclient) - [tx](Sdk.md#tx) ## Constructors @@ -58,12 +57,12 @@ Creates an instance of Sdk. | :------ | :------ | | `args` | `Object` | | `args.chain` | [`Chain`](../interfaces/Chain.md) | -| `args.queryCmd` | [`IQueryCmd`](../interfaces/IQueryCmd.md) | +| `args.queryClient` | [`NibiruQueryClient`](NibiruQueryClient.md) | | `args.txCmd` | [`TxCmd`](TxCmd.md) | #### Defined in -[sdk.ts:71](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/sdk.ts#L71) +[sdk.ts:67](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/sdk.ts#L67) ## Properties @@ -77,35 +76,21 @@ Creates an instance of Sdk. #### Defined in -[sdk.ts:57](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/sdk.ts#L57) +[sdk.ts:55](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/sdk.ts#L55) ___ -### query +### queryClient -• **query**: [`ExtendedQueryClient`](../modules.md#extendedqueryclient) +• **queryClient**: [`NibiruQueryClient`](NibiruQueryClient.md) #### Implementation of -[ISdk](../interfaces/ISdk.md).[query](../interfaces/ISdk.md#query) +[ISdk](../interfaces/ISdk.md).[queryClient](../interfaces/ISdk.md#queryclient) #### Defined in -[sdk.ts:61](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/sdk.ts#L61) - -___ - -### tmClient - -• **tmClient**: `Tendermint34Client` - -#### Implementation of - -[ISdk](../interfaces/ISdk.md).[tmClient](../interfaces/ISdk.md#tmclient) - -#### Defined in - -[sdk.ts:63](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/sdk.ts#L63) +[sdk.ts:59](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/sdk.ts#L59) ___ @@ -119,4 +104,4 @@ ___ #### Defined in -[sdk.ts:59](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/sdk.ts#L59) +[sdk.ts:57](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/sdk.ts#L57) diff --git a/packages/nibijs/docs/classes/TxCmd.md b/packages/nibijs/docs/classes/TxCmd.md index c8aa2f50..9644da7b 100644 --- a/packages/nibijs/docs/classes/TxCmd.md +++ b/packages/nibijs/docs/classes/TxCmd.md @@ -1,4 +1,4 @@ -[NibiJS Documentation - v0.19.2](../intro.md) / [Exports](../modules.md) / TxCmd +[NibiJS Documentation - v0.19.5](../intro.md) / [Exports](../modules.md) / TxCmd # Class: TxCmd @@ -19,6 +19,7 @@ TxCmd is analagous to the 'nibid tx' command of the nibid CLI. - [directSigner](TxCmd.md#directsigner) - [fee](TxCmd.md#fee) - [gasPrice](TxCmd.md#gasprice) +- [queryClient](TxCmd.md#queryclient) ### Methods @@ -34,7 +35,7 @@ TxCmd is analagous to the 'nibid tx' command of the nibid CLI. ### constructor -• **new TxCmd**(`client`, `directSigner`, `chain`, `gasPrice?`) +• **new TxCmd**(`client`, `directSigner`, `chain`, `queryClient`, `gasPrice?`) #### Parameters @@ -43,11 +44,12 @@ TxCmd is analagous to the 'nibid tx' command of the nibid CLI. | `client` | `SigningStargateClient` | | `directSigner` | `OfflineDirectSigner` | | `chain` | [`Chain`](../interfaces/Chain.md) | +| `queryClient` | [`NibiruQueryClient`](NibiruQueryClient.md) | | `gasPrice?` | `Coin` | #### Defined in -[tx/tx.ts:49](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/tx/tx.ts#L49) +[tx/tx.ts:46](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/tx/tx.ts#L46) ## Properties @@ -57,7 +59,7 @@ TxCmd is analagous to the 'nibid tx' command of the nibid CLI. #### Defined in -[tx/tx.ts:41](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/tx/tx.ts#L41) +[tx/tx.ts:40](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/tx/tx.ts#L40) ___ @@ -67,7 +69,7 @@ ___ #### Defined in -[tx/tx.ts:39](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/tx/tx.ts#L39) +[tx/tx.ts:39](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/tx/tx.ts#L39) ___ @@ -77,7 +79,7 @@ ___ #### Defined in -[tx/tx.ts:45](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/tx/tx.ts#L45) +[tx/tx.ts:41](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/tx/tx.ts#L41) ___ @@ -87,7 +89,7 @@ ___ #### Defined in -[tx/tx.ts:43](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/tx/tx.ts#L43) +[tx/tx.ts:44](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/tx/tx.ts#L44) ___ @@ -97,7 +99,17 @@ ___ #### Defined in -[tx/tx.ts:47](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/tx/tx.ts#L47) +[tx/tx.ts:42](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/tx/tx.ts#L42) + +___ + +### queryClient + +• **queryClient**: [`NibiruQueryClient`](NibiruQueryClient.md) + +#### Defined in + +[tx/tx.ts:43](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/tx/tx.ts#L43) ## Methods @@ -117,7 +129,7 @@ ___ #### Defined in -[tx/tx.ts:108](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/tx/tx.ts#L108) +[tx/tx.ts:107](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/tx/tx.ts#L107) ___ @@ -131,7 +143,7 @@ ___ #### Defined in -[tx/tx.ts:137](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/tx/tx.ts#L137) +[tx/tx.ts:136](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/tx/tx.ts#L136) ___ @@ -151,7 +163,7 @@ ___ #### Defined in -[tx/tx.ts:99](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/tx/tx.ts#L99) +[tx/tx.ts:98](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/tx/tx.ts#L98) ___ @@ -172,7 +184,7 @@ ___ #### Defined in -[tx/tx.ts:131](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/tx/tx.ts#L131) +[tx/tx.ts:130](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/tx/tx.ts#L130) ___ @@ -192,7 +204,7 @@ ___ #### Defined in -[tx/tx.ts:80](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/tx/tx.ts#L80) +[tx/tx.ts:79](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/tx/tx.ts#L79) ___ @@ -219,7 +231,7 @@ returns an estimate of how many gas units are required. #### Defined in -[tx/tx.ts:75](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/tx/tx.ts#L75) +[tx/tx.ts:74](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/tx/tx.ts#L74) ___ @@ -240,4 +252,4 @@ ___ #### Defined in -[tx/tx.ts:62](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/tx/tx.ts#L62) +[tx/tx.ts:61](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/tx/tx.ts#L61) diff --git a/packages/nibijs/docs/enums/BECH32_PREFIX.md b/packages/nibijs/docs/enums/BECH32_PREFIX.md index 32287f30..c6329304 100644 --- a/packages/nibijs/docs/enums/BECH32_PREFIX.md +++ b/packages/nibijs/docs/enums/BECH32_PREFIX.md @@ -1,4 +1,4 @@ -[NibiJS Documentation - v0.19.2](../intro.md) / [Exports](../modules.md) / BECH32\_PREFIX +[NibiJS Documentation - v0.19.5](../intro.md) / [Exports](../modules.md) / BECH32\_PREFIX # Enumeration: BECH32\_PREFIX @@ -23,7 +23,7 @@ ADDR defines the Bech32 prefix of an account address #### Defined in -[tx/signer.ts:12](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/tx/signer.ts#L12) +[tx/signer.ts:12](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/tx/signer.ts#L12) ___ @@ -35,7 +35,7 @@ ADDR_VAL defines the Bech32 prefix of an validator's operator address #### Defined in -[tx/signer.ts:14](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/tx/signer.ts#L14) +[tx/signer.ts:14](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/tx/signer.ts#L14) ___ @@ -47,7 +47,7 @@ ADDR_VALCONS defines the Bech32 prefix of a consensus node address #### Defined in -[tx/signer.ts:16](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/tx/signer.ts#L16) +[tx/signer.ts:16](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/tx/signer.ts#L16) ___ @@ -59,7 +59,7 @@ PUB defines the Bech32 prefix of an account's public key #### Defined in -[tx/signer.ts:18](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/tx/signer.ts#L18) +[tx/signer.ts:18](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/tx/signer.ts#L18) ___ @@ -71,7 +71,7 @@ PUB_VAL defines the Bech32 prefix of an validator's operator public key #### Defined in -[tx/signer.ts:20](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/tx/signer.ts#L20) +[tx/signer.ts:20](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/tx/signer.ts#L20) ___ @@ -83,4 +83,4 @@ PUB_VALCONS defines the Bech32 prefix of a consensus node public key #### Defined in -[tx/signer.ts:22](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/tx/signer.ts#L22) +[tx/signer.ts:22](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/tx/signer.ts#L22) diff --git a/packages/nibijs/docs/enums/Signer.md b/packages/nibijs/docs/enums/Signer.md index 7e4af8dd..5f14df27 100644 --- a/packages/nibijs/docs/enums/Signer.md +++ b/packages/nibijs/docs/enums/Signer.md @@ -1,4 +1,4 @@ -[NibiJS Documentation - v0.19.2](../intro.md) / [Exports](../modules.md) / Signer +[NibiJS Documentation - v0.19.5](../intro.md) / [Exports](../modules.md) / Signer # Enumeration: Signer @@ -17,7 +17,7 @@ #### Defined in -[tx/signer.ts:71](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/tx/signer.ts#L71) +[tx/signer.ts:71](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/tx/signer.ts#L71) ___ @@ -27,4 +27,4 @@ ___ #### Defined in -[tx/signer.ts:70](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/tx/signer.ts#L70) +[tx/signer.ts:70](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/tx/signer.ts#L70) diff --git a/packages/nibijs/docs/interfaces/Chain.md b/packages/nibijs/docs/interfaces/Chain.md index cf7547f0..24dc728d 100644 --- a/packages/nibijs/docs/interfaces/Chain.md +++ b/packages/nibijs/docs/interfaces/Chain.md @@ -1,4 +1,4 @@ -[NibiJS Documentation - v0.19.2](../intro.md) / [Exports](../modules.md) / Chain +[NibiJS Documentation - v0.19.5](../intro.md) / [Exports](../modules.md) / Chain # Interface: Chain @@ -40,7 +40,7 @@ chainId: identifier for the chain #### Defined in -[chain/chain.ts:25](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/chain/chain.ts#L25) +[chain/chain.ts:25](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/chain/chain.ts#L25) ___ @@ -50,7 +50,7 @@ ___ #### Defined in -[chain/chain.ts:26](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/chain/chain.ts#L26) +[chain/chain.ts:26](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/chain/chain.ts#L26) ___ @@ -62,7 +62,7 @@ endptGrpc: endpoint for the gRPC gateway. Usually on port 9090. #### Defined in -[chain/chain.ts:23](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/chain/chain.ts#L23) +[chain/chain.ts:23](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/chain/chain.ts#L23) ___ @@ -74,7 +74,7 @@ endptRest: endpoint for the REST server. Also, the LCD endpoint. #### Defined in -[chain/chain.ts:21](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/chain/chain.ts#L21) +[chain/chain.ts:21](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/chain/chain.ts#L21) ___ @@ -86,7 +86,7 @@ endptTm: endpoint for the Tendermint RPC server. Usually on port 26657. #### Defined in -[chain/chain.ts:19](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/chain/chain.ts#L19) +[chain/chain.ts:19](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/chain/chain.ts#L19) ___ @@ -96,4 +96,4 @@ ___ #### Defined in -[chain/chain.ts:27](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/chain/chain.ts#L27) +[chain/chain.ts:27](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/chain/chain.ts#L27) diff --git a/packages/nibijs/docs/interfaces/ChainIdParts.md b/packages/nibijs/docs/interfaces/ChainIdParts.md index 4f9fb7f3..8ce279e8 100644 --- a/packages/nibijs/docs/interfaces/ChainIdParts.md +++ b/packages/nibijs/docs/interfaces/ChainIdParts.md @@ -1,4 +1,4 @@ -[NibiJS Documentation - v0.19.2](../intro.md) / [Exports](../modules.md) / ChainIdParts +[NibiJS Documentation - v0.19.5](../intro.md) / [Exports](../modules.md) / ChainIdParts # Interface: ChainIdParts @@ -18,7 +18,7 @@ #### Defined in -[chain/chain.ts:41](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/chain/chain.ts#L41) +[chain/chain.ts:41](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/chain/chain.ts#L41) ___ @@ -28,7 +28,7 @@ ___ #### Defined in -[chain/chain.ts:42](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/chain/chain.ts#L42) +[chain/chain.ts:42](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/chain/chain.ts#L42) ___ @@ -38,4 +38,4 @@ ___ #### Defined in -[chain/chain.ts:43](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/chain/chain.ts#L43) +[chain/chain.ts:43](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/chain/chain.ts#L43) diff --git a/packages/nibijs/docs/interfaces/CoinMap.md b/packages/nibijs/docs/interfaces/CoinMap.md index 7cbf48c5..def3c165 100644 --- a/packages/nibijs/docs/interfaces/CoinMap.md +++ b/packages/nibijs/docs/interfaces/CoinMap.md @@ -1,4 +1,4 @@ -[NibiJS Documentation - v0.19.2](../intro.md) / [Exports](../modules.md) / CoinMap +[NibiJS Documentation - v0.19.5](../intro.md) / [Exports](../modules.md) / CoinMap # Interface: CoinMap diff --git a/packages/nibijs/docs/interfaces/IEventLog.md b/packages/nibijs/docs/interfaces/IEventLog.md index b914c6f7..42911b8a 100644 --- a/packages/nibijs/docs/interfaces/IEventLog.md +++ b/packages/nibijs/docs/interfaces/IEventLog.md @@ -1,4 +1,4 @@ -[NibiJS Documentation - v0.19.2](../intro.md) / [Exports](../modules.md) / IEventLog +[NibiJS Documentation - v0.19.5](../intro.md) / [Exports](../modules.md) / IEventLog # Interface: IEventLog @@ -17,7 +17,7 @@ #### Defined in -[chain/types.ts:49](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/chain/types.ts#L49) +[chain/types.ts:49](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/chain/types.ts#L49) ___ @@ -27,4 +27,4 @@ ___ #### Defined in -[chain/types.ts:48](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/chain/types.ts#L48) +[chain/types.ts:48](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/chain/types.ts#L48) diff --git a/packages/nibijs/docs/interfaces/IQueryCmd.md b/packages/nibijs/docs/interfaces/IQueryCmd.md deleted file mode 100644 index 829694c5..00000000 --- a/packages/nibijs/docs/interfaces/IQueryCmd.md +++ /dev/null @@ -1,70 +0,0 @@ -[NibiJS Documentation - v0.19.2](../intro.md) / [Exports](../modules.md) / IQueryCmd - -# Interface: IQueryCmd - -## Implemented by - -- [`QueryCmd`](../classes/QueryCmd.md) - -## Table of contents - -### Properties - -- [chain](IQueryCmd.md#chain) -- [client](IQueryCmd.md#client) -- [disconnect](IQueryCmd.md#disconnect) -- [tmClient](IQueryCmd.md#tmclient) - -## Properties - -### chain - -• **chain**: [`Chain`](Chain.md) - -The chain to which this query client corresponds. -E.g. nibiru-testnet-1, nibiru-localnet-42 - -#### Defined in - -[query/query.ts:38](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/query/query.ts#L38) - -___ - -### client - -• **client**: [`ExtendedQueryClient`](../modules.md#extendedqueryclient) - -An ExtendedQueryClient is the closest analogy to the query command of nibid CLI. -It contains queries for all of the active modules of Nibiru Chain. - -#### Defined in - -[query/query.ts:34](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/query/query.ts#L34) - -___ - -### disconnect - -• **disconnect**: () => `void` - -#### Type declaration - -▸ (): `void` - -##### Returns - -`void` - -#### Defined in - -[query/query.ts:39](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/query/query.ts#L39) - -___ - -### tmClient - -• **tmClient**: `Tendermint34Client` - -#### Defined in - -[query/query.ts:35](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/query/query.ts#L35) diff --git a/packages/nibijs/docs/interfaces/ISdk.md b/packages/nibijs/docs/interfaces/ISdk.md index 21a79ce5..fa94c793 100644 --- a/packages/nibijs/docs/interfaces/ISdk.md +++ b/packages/nibijs/docs/interfaces/ISdk.md @@ -1,4 +1,4 @@ -[NibiJS Documentation - v0.19.2](../intro.md) / [Exports](../modules.md) / ISdk +[NibiJS Documentation - v0.19.5](../intro.md) / [Exports](../modules.md) / ISdk # Interface: ISdk @@ -11,8 +11,7 @@ ### Properties - [chain](ISdk.md#chain) -- [query](ISdk.md#query) -- [tmClient](ISdk.md#tmclient) +- [queryClient](ISdk.md#queryclient) - [tx](ISdk.md#tx) ## Properties @@ -23,27 +22,17 @@ #### Defined in -[sdk.ts:28](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/sdk.ts#L28) +[sdk.ts:27](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/sdk.ts#L27) ___ -### query +### queryClient -• **query**: [`ExtendedQueryClient`](../modules.md#extendedqueryclient) +• **queryClient**: [`NibiruQueryClient`](../classes/NibiruQueryClient.md) #### Defined in -[sdk.ts:30](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/sdk.ts#L30) - -___ - -### tmClient - -• **tmClient**: `Tendermint34Client` - -#### Defined in - -[sdk.ts:31](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/sdk.ts#L31) +[sdk.ts:29](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/sdk.ts#L29) ___ @@ -53,4 +42,4 @@ ___ #### Defined in -[sdk.ts:29](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/sdk.ts#L29) +[sdk.ts:28](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/sdk.ts#L28) diff --git a/packages/nibijs/docs/interfaces/MsgTypeUrls.md b/packages/nibijs/docs/interfaces/MsgTypeUrls.md index 7cda4307..d1768df8 100644 --- a/packages/nibijs/docs/interfaces/MsgTypeUrls.md +++ b/packages/nibijs/docs/interfaces/MsgTypeUrls.md @@ -1,4 +1,4 @@ -[NibiJS Documentation - v0.19.2](../intro.md) / [Exports](../modules.md) / MsgTypeUrls +[NibiJS Documentation - v0.19.5](../intro.md) / [Exports](../modules.md) / MsgTypeUrls # Interface: MsgTypeUrls diff --git a/packages/nibijs/docs/interfaces/TxMessage.md b/packages/nibijs/docs/interfaces/TxMessage.md index 8bfcd551..7f0dedad 100644 --- a/packages/nibijs/docs/interfaces/TxMessage.md +++ b/packages/nibijs/docs/interfaces/TxMessage.md @@ -1,4 +1,4 @@ -[NibiJS Documentation - v0.19.2](../intro.md) / [Exports](../modules.md) / TxMessage +[NibiJS Documentation - v0.19.5](../intro.md) / [Exports](../modules.md) / TxMessage # Interface: TxMessage diff --git a/packages/nibijs/docs/intro.md b/packages/nibijs/docs/intro.md index eeda1c8e..fa02e397 100644 --- a/packages/nibijs/docs/intro.md +++ b/packages/nibijs/docs/intro.md @@ -1,4 +1,4 @@ -NibiJS Documentation - v0.19.2 / [Exports](modules.md) +NibiJS Documentation - v0.19.5 / [Exports](modules.md)

diff --git a/packages/nibijs/docs/modules.md b/packages/nibijs/docs/modules.md index 95942f59..786396fa 100644 --- a/packages/nibijs/docs/modules.md +++ b/packages/nibijs/docs/modules.md @@ -1,6 +1,6 @@ -[NibiJS Documentation - v0.19.2](intro.md) / Exports +[NibiJS Documentation - v0.19.5](intro.md) / Exports -# NibiJS Documentation - v0.19.2 +# NibiJS Documentation - v0.19.5 ## Table of contents @@ -13,7 +13,7 @@ - [CustomChain](classes/CustomChain.md) - [MsgFactory](classes/MsgFactory.md) -- [QueryCmd](classes/QueryCmd.md) +- [NibiruQueryClient](classes/NibiruQueryClient.md) - [Sdk](classes/Sdk.md) - [TxCmd](classes/TxCmd.md) @@ -23,7 +23,6 @@ - [ChainIdParts](interfaces/ChainIdParts.md) - [CoinMap](interfaces/CoinMap.md) - [IEventLog](interfaces/IEventLog.md) -- [IQueryCmd](interfaces/IQueryCmd.md) - [ISdk](interfaces/ISdk.md) - [MsgTypeUrls](interfaces/MsgTypeUrls.md) - [TxMessage](interfaces/TxMessage.md) @@ -32,12 +31,10 @@ - [Address](modules.md#address) - [CosmosSigner](modules.md#cosmossigner) -- [ExtendedQueryClient](modules.md#extendedqueryclient) +- [NibiruExtensions](modules.md#nibiruextensions) ### Variables -- [CHAOSNET\_CONFIG](modules.md#chaosnet_config) -- [Chaosnet](modules.md#chaosnet) - [INT\_MULT](modules.md#int_mult) - [Localnet](modules.md#localnet) - [Msg](modules.md#msg) @@ -57,7 +54,6 @@ - [isRestEndptValid](modules.md#isrestendptvalid) - [newCoinMapFromCoins](modules.md#newcoinmapfromcoins) - [newDevnet](modules.md#newdevnet) -- [newQueryCmd](modules.md#newquerycmd) - [newRandomWallet](modules.md#newrandomwallet) - [newSdk](modules.md#newsdk) - [newSignerFromKeplr](modules.md#newsignerfromkeplr) @@ -68,8 +64,6 @@ - [toSdkDec](modules.md#tosdkdec) - [toSdkInt](modules.md#tosdkint) - [useFaucet](modules.md#usefaucet) -- [waitForBlockHeight](modules.md#waitforblockheight) -- [waitForNextBlock](modules.md#waitfornextblock) ## Type Aliases @@ -79,7 +73,7 @@ #### Defined in -[tx/tx.ts:26](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/tx/tx.ts#L26) +[tx/tx.ts:26](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/tx/tx.ts#L26) ___ @@ -89,60 +83,27 @@ ___ #### Defined in -[tx/tx.ts:27](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/tx/tx.ts#L27) +[tx/tx.ts:27](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/tx/tx.ts#L27) ___ -### ExtendedQueryClient +### NibiruExtensions -Ƭ **ExtendedQueryClient**: `BankExtension` & `QueryClient` & `AuthExtension` & `SpotExtension` & `PerpExtension` & `VpoolExtension` & `OracleExtension` & `EpochsExtension` & `StakingExtension` & `DistributionExtension` +Ƭ **NibiruExtensions**: `QueryClient` & `SpotExtension` & `PerpExtension` & `VpoolExtension` & `OracleExtension` & `EpochsExtension` & `DistributionExtension` & `GovExtension` & `StakingExtension` #### Defined in -[query/query.ts:18](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/query/query.ts#L18) +[query/query.ts:19](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/query/query.ts#L19) ## Variables -### CHAOSNET\_CONFIG - -• `Const` **CHAOSNET\_CONFIG**: `Object` - -#### Type declaration - -| Name | Type | -| :------ | :------ | -| `grpcPort` | `number` | -| `host` | `undefined` \| `string` | -| `lcdPort` | `number` | -| `tmPort` | `number` | - -#### Defined in - -[chain/chain.ts:102](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/chain/chain.ts#L102) - -___ - -### Chaosnet - -• `Const` **Chaosnet**: [`Chain`](interfaces/Chain.md) - -Chaosnet is a private chain with trading bots, an oracle, and a node -running an updated version of Nibiru. This environment is useful for live -testing. - -#### Defined in - -[chain/chain.ts:114](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/chain/chain.ts#L114) - -___ - ### INT\_MULT • `Const` **INT\_MULT**: ``1000000`` #### Defined in -[chain/parse.ts:4](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/chain/parse.ts#L4) +[chain/parse.ts:4](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/chain/parse.ts#L4) ___ @@ -152,7 +113,7 @@ ___ #### Defined in -[chain/chain.ts:86](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/chain/chain.ts#L86) +[chain/chain.ts:86](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/chain/chain.ts#L86) ___ @@ -162,7 +123,7 @@ ___ #### Defined in -[msg/index.ts:19](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/msg/index.ts#L19) +[msg/index.ts:19](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/msg/index.ts#L19) ## Functions @@ -183,7 +144,7 @@ ___ #### Defined in -[chain/types.ts:27](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/chain/types.ts#L27) +[chain/types.ts:27](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/chain/types.ts#L27) ___ @@ -203,7 +164,7 @@ ___ #### Defined in -[chain/parse.ts:176](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/chain/parse.ts#L176) +[chain/parse.ts:176](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/chain/parse.ts#L176) ___ @@ -223,7 +184,7 @@ ___ #### Defined in -[chain/parse.ts:99](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/chain/parse.ts#L99) +[chain/parse.ts:99](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/chain/parse.ts#L99) ___ @@ -243,7 +204,7 @@ ___ #### Defined in -[chain/parse.ts:158](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/chain/parse.ts#L158) +[chain/parse.ts:158](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/chain/parse.ts#L158) ___ @@ -263,7 +224,7 @@ ___ #### Defined in -[chain/parse.ts:152](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/chain/parse.ts#L152) +[chain/parse.ts:152](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/chain/parse.ts#L152) ___ @@ -283,7 +244,7 @@ ___ #### Defined in -[wallet/keplr.ts:9](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/wallet/keplr.ts#L9) +[wallet/keplr.ts:9](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/wallet/keplr.ts#L9) ___ @@ -297,7 +258,7 @@ ___ #### Defined in -[tx/signer.ts:28](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/tx/signer.ts#L28) +[tx/signer.ts:28](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/tx/signer.ts#L28) ___ @@ -323,7 +284,7 @@ ___ #### Defined in -[chain/types.ts:13](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/chain/types.ts#L13) +[chain/types.ts:13](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/chain/types.ts#L13) ___ @@ -346,7 +307,7 @@ obj is Chain #### Defined in -[chain/chain.ts:34](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/chain/chain.ts#L34) +[chain/chain.ts:34](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/chain/chain.ts#L34) ___ @@ -366,7 +327,7 @@ ___ #### Defined in -[chain/chain.ts:134](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/chain/chain.ts#L134) +[chain/chain.ts:113](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/chain/chain.ts#L113) ___ @@ -386,7 +347,7 @@ ___ #### Defined in -[chain/chain.ts:143](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/chain/chain.ts#L143) +[chain/chain.ts:122](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/chain/chain.ts#L122) ___ @@ -398,7 +359,7 @@ ___ | Name | Type | | :------ | :------ | -| `coins` | `Coin`[] | +| `coins` | readonly `Coin`[] | #### Returns @@ -406,7 +367,7 @@ ___ #### Defined in -[chain/types.ts:39](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/chain/types.ts#L39) +[chain/types.ts:39](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/chain/types.ts#L39) ___ @@ -426,27 +387,7 @@ ___ #### Defined in -[chain/chain.ts:98](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/chain/chain.ts#L98) - -___ - -### newQueryCmd - -▸ **newQueryCmd**(`chain`): `Promise`<[`QueryCmd`](classes/QueryCmd.md)\> - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `chain` | [`Chain`](interfaces/Chain.md) | - -#### Returns - -`Promise`<[`QueryCmd`](classes/QueryCmd.md)\> - -#### Defined in - -[query/query.ts:101](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/query/query.ts#L101) +[chain/chain.ts:98](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/chain/chain.ts#L98) ___ @@ -473,7 +414,7 @@ A wallet for protobuf based signing using SIGN_MODE_DIRECT. #### Defined in -[tx/signer.ts:62](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/tx/signer.ts#L62) +[tx/signer.ts:62](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/tx/signer.ts#L62) ___ @@ -499,7 +440,7 @@ mnemonic. The querier and Tendermint client will still function normally. #### Defined in -[sdk.ts:21](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/sdk.ts#L21) +[sdk.ts:20](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/sdk.ts#L20) ___ @@ -520,7 +461,7 @@ ___ #### Defined in -[tx/signer.ts:47](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/tx/signer.ts#L47) +[tx/signer.ts:47](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/tx/signer.ts#L47) ___ @@ -547,7 +488,7 @@ A wallet for protobuf based signing using SIGN_MODE_DIRECT #### Defined in -[tx/signer.ts:40](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/tx/signer.ts#L40) +[tx/signer.ts:40](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/tx/signer.ts#L40) ___ @@ -567,7 +508,7 @@ ___ #### Defined in -[chain/chain.ts:94](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/chain/chain.ts#L94) +[chain/chain.ts:94](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/chain/chain.ts#L94) ___ @@ -589,7 +530,7 @@ ___ #### Defined in -[tx/tx.ts:149](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/tx/tx.ts#L149) +[tx/tx.ts:148](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/tx/tx.ts#L148) ___ @@ -609,7 +550,7 @@ ___ #### Defined in -[chain/chain.ts:123](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/chain/chain.ts#L123) +[chain/chain.ts:102](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/chain/chain.ts#L102) ___ @@ -638,7 +579,7 @@ ref: Reimplementation of cosmos-sdk/types/decimal.go #### Defined in -[chain/parse.ts:25](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/chain/parse.ts#L25) +[chain/parse.ts:25](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/chain/parse.ts#L25) ___ @@ -658,7 +599,7 @@ ___ #### Defined in -[chain/parse.ts:148](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/chain/parse.ts#L148) +[chain/parse.ts:148](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/chain/parse.ts#L148) ___ @@ -687,46 +628,4 @@ Sends 10 NIBI and 100 NUSD to the given address from the testnet faucet. #### Defined in -[chain/useFaucet.ts:7](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/chain/useFaucet.ts#L7) - -___ - -### waitForBlockHeight - -▸ **waitForBlockHeight**(`args`): `Promise`<`void`\> - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `args` | `Object` | -| `args.chain` | [`Chain`](interfaces/Chain.md) | -| `args.height` | `number` | - -#### Returns - -`Promise`<`void`\> - -#### Defined in - -[query/query.ts:54](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/query/query.ts#L54) - -___ - -### waitForNextBlock - -▸ **waitForNextBlock**(`chain`): `Promise`<`void`\> - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `chain` | [`Chain`](interfaces/Chain.md) | - -#### Returns - -`Promise`<`void`\> - -#### Defined in - -[query/query.ts:42](https://github.com/NibiruChain/ts-sdk/blob/3ddfae4/packages/nibijs/src/query/query.ts#L42) +[chain/useFaucet.ts:7](https://github.com/NibiruChain/ts-sdk/blob/75477c4/packages/nibijs/src/chain/useFaucet.ts#L7) diff --git a/packages/nibijs/package.json b/packages/nibijs/package.json index 385311fe..90d38752 100644 --- a/packages/nibijs/package.json +++ b/packages/nibijs/package.json @@ -1,7 +1,7 @@ { "name": "@nibiruchain/nibijs", "description": "The TypeScript SDK for the Nibiru blockchain.", - "version": "0.19.4", + "version": "0.19.5", "license": "MIT", "main": "dist/index.js", "types": "dist/index.d.ts", @@ -41,4 +41,4 @@ "typedoc-plugin-markdown": "^3.14.0" }, "gitHead": "4da45aaaf65a44e6b4edc0b5d11ea1083229f977" -} +} \ No newline at end of file diff --git a/packages/nibijs/src/chain/types.ts b/packages/nibijs/src/chain/types.ts index 91605339..7d12ab4c 100644 --- a/packages/nibijs/src/chain/types.ts +++ b/packages/nibijs/src/chain/types.ts @@ -1,10 +1,10 @@ import { AccountData, + Coin, coin as newCoin, coins as newCoins, - parseCoins, - Coin, DirectSecp256k1HdWallet as WalletHD, + parseCoins, } from "@cosmjs/proto-signing" import { instanceOfError } from "./error" @@ -36,7 +36,7 @@ export interface CoinMap { } // TODO test -export function newCoinMapFromCoins(coins: Coin[]): CoinMap { +export function newCoinMapFromCoins(coins: readonly Coin[]): CoinMap { const coinMap: CoinMap = {} for (const coin of coins) { coinMap[coin.denom] = parseInt(coin.amount) diff --git a/packages/nibijs/src/query/distribution.ts b/packages/nibijs/src/query/distribution.ts deleted file mode 100644 index da49d46d..00000000 --- a/packages/nibijs/src/query/distribution.ts +++ /dev/null @@ -1,118 +0,0 @@ -/* eslint-disable @typescript-eslint/naming-convention */ -import * as pb from "@nibiruchain/protojs/dist/cosmos/distribution/v1beta1/query" -import Long from "long" - -import { - createPagination, - createProtobufRpcClient, - QueryClient, -} from "@cosmjs/stargate" - -export interface DistributionExtension { - /** distrbution: query extension for the distribution module. The distribution - * module manages the distribution mechanism for passively distributing - * staking rewards to validators and delegators. - */ - readonly distribution: { - communityPool: () => Promise - delegationRewards: ( - delegatorAddress: string, - validatorAddress: string, - ) => Promise - - /** Returns the rewards (Coin[]) accrued from all delegations for the given - * delegator address. */ - delegationTotalRewards: ( - delegatorAddress: string, - ) => Promise - delegatorValidators: ( - delegatorAddress: string, - ) => Promise - delegatorWithdrawAddress: ( - delegatorAddress: string, - ) => Promise - /** Returns the module parameters for the distribution module. */ - params: () => Promise - validatorCommission: ( - validatorAddress: string, - ) => Promise - validatorOutstandingRewards: ( - validatorAddress: string, - ) => Promise - validatorSlashes: ( - validatorAddress: string, - startingHeight: number, - endingHeight: number, - paginationKey?: Uint8Array, - ) => Promise - } -} - -export function setupDistributionExtension(base: QueryClient): DistributionExtension { - const rpc = createProtobufRpcClient(base) - const queryService = new pb.QueryClientImpl(rpc) - - return { - distribution: { - communityPool: async () => { - const response = await queryService.CommunityPool({}) - return response - }, - delegationRewards: async (delegatorAddress: string, validatorAddress: string) => { - const response = await queryService.DelegationRewards({ - delegatorAddress, - validatorAddress, - }) - return response - }, - delegationTotalRewards: async (delegatorAddress: string) => { - const response = await queryService.DelegationTotalRewards({ - delegatorAddress, - }) - return response - }, - delegatorValidators: async (delegatorAddress: string) => { - const response = await queryService.DelegatorValidators({ - delegatorAddress, - }) - return response - }, - delegatorWithdrawAddress: async (delegatorAddress: string) => { - const response = await queryService.DelegatorWithdrawAddress({ - delegatorAddress, - }) - return response - }, - params: async () => { - const response = await queryService.Params({}) - return response - }, - validatorCommission: async (validatorAddress: string) => { - const response = await queryService.ValidatorCommission({ - validatorAddress, - }) - return response - }, - validatorOutstandingRewards: async (validatorAddress: string) => { - const response = await queryService.ValidatorOutstandingRewards({ - validatorAddress, - }) - return response - }, - validatorSlashes: async ( - validatorAddress: string, - startingHeight: number, - endingHeight: number, - paginationKey?: Uint8Array, - ) => { - const response = await queryService.ValidatorSlashes({ - validatorAddress, - startingHeight: Long.fromNumber(startingHeight, true), - endingHeight: Long.fromNumber(endingHeight, true), - pagination: createPagination(paginationKey), - }) - return response - }, - }, - } -} diff --git a/packages/nibijs/src/query/gov.ts b/packages/nibijs/src/query/gov.ts deleted file mode 100644 index 6a972e67..00000000 --- a/packages/nibijs/src/query/gov.ts +++ /dev/null @@ -1,129 +0,0 @@ -import { - createPagination, - createProtobufRpcClient, - GovParamsType, - QueryClient, -} from "@cosmjs/stargate" -import * as cosmosGovQuery from "@nibiruchain/protojs/dist/cosmos/gov/v1beta1/query" -import { ProposalStatus } from "@nibiruchain/protojs/src/cosmos/gov/v1beta1/gov" -import Long from "long" - -export interface GovExtension { - gov: Readonly<{ - params: (paramsType: GovParamsType) => Promise - proposal: (proposalId: number) => Promise - proposals: ( - status: ProposalStatus, - voter: string, - depositor: string, - pagination?: Uint8Array, - ) => Promise - vote: ( - proposalId: number, - voter: string, - ) => Promise - votes: ( - proposalId: number, - pagination?: Uint8Array, - ) => Promise - deposit: ( - proposalId: number, - depositor: string, - ) => Promise - deposits: ( - proposalId: number, - pagination?: Uint8Array, - ) => Promise - tallyResult: ( - proposalId: number, - ) => Promise - }> -} - -export function setupGovExtension(base: QueryClient): GovExtension { - const rpcClient = createProtobufRpcClient(base) - const queryService = new cosmosGovQuery.QueryClientImpl(rpcClient) - - return { - gov: { - proposal: async ( - proposalId: number, - ): Promise => { - const response = await queryService.Proposal({ - proposalId: Long.fromValue(proposalId), - }) - return response - }, - proposals: async ( - status: ProposalStatus, - voter: string, - depositor: string, - pagination?: Uint8Array, - ): Promise => { - const response = await queryService.Proposals({ - proposalStatus: status, - voter, - depositor, - pagination: createPagination(pagination), - }) - return response - }, - vote: async ( - proposalId: number, - voter: string, - ): Promise => { - const response = await queryService.Vote({ - proposalId: Long.fromValue(proposalId), - voter, - }) - return response - }, - votes: async ( - proposalId: number, - pagination?: Uint8Array, - ): Promise => { - const response = await queryService.Votes({ - proposalId: Long.fromValue(proposalId), - pagination: createPagination(pagination), - }) - return response - }, - params: async ( - paramsType: GovParamsType, - ): Promise => { - const response = await queryService.Params({ - paramsType, - }) - return response - }, - deposit: async ( - proposalId: number, - depositor: string, - ): Promise => { - const response = await queryService.Deposit({ - proposalId: Long.fromValue(proposalId), - depositor, - }) - return response - }, - deposits: async ( - proposalId: number, - pagination?: Uint8Array, - ): Promise => { - const response = await queryService.Deposits({ - proposalId: Long.fromValue(proposalId), - pagination: createPagination(pagination), - }) - return response - }, - tallyResult: async ( - proposalId: number, - ): Promise => { - const response = await queryService.TallyResult({ - proposalId: Long.fromValue(proposalId), - }) - return response - }, - }, - } -} diff --git a/packages/nibijs/src/query/query.ts b/packages/nibijs/src/query/query.ts index 48f4d959..1f19e356 100644 --- a/packages/nibijs/src/query/query.ts +++ b/packages/nibijs/src/query/query.ts @@ -1,107 +1,71 @@ import { + DistributionExtension, + GovExtension, QueryClient, - setupBankExtension, - setupAuthExtension, - BankExtension, - AuthExtension, + setupDistributionExtension, + setupGovExtension, + setupStakingExtension, + StakingExtension, + StargateClient, + StargateClientOptions, } from "@cosmjs/stargate" import { Tendermint34Client } from "@cosmjs/tendermint-rpc" -import { Chain } from "../chain" -import { setupSpotExtension, SpotExtension } from "./spot" import { EpochsExtension, setupEpochsExtension } from "./epochs" -import { setupPerpExtension, PerpExtension } from "./perp" import { OracleExtension, setupOracleExtension } from "./oracle" -import { setupStakingExtension, StakingExtension } from "./staking" +import { PerpExtension, setupPerpExtension } from "./perp" +import { setupSpotExtension, SpotExtension } from "./spot" import { setupVpoolExtension, VpoolExtension } from "./vpool" -import { DistributionExtension, setupDistributionExtension } from "./distribution" -import { GovExtension, setupGovExtension } from "./gov" -export type ExtendedQueryClient = BankExtension & - QueryClient & - AuthExtension & +export type NibiruExtensions = QueryClient & SpotExtension & PerpExtension & VpoolExtension & OracleExtension & EpochsExtension & - StakingExtension & DistributionExtension & - GovExtension + GovExtension & + StakingExtension -export interface IQueryCmd { - /** - * An ExtendedQueryClient is the closest analogy to the query command of nibid CLI. - * It contains queries for all of the active modules of Nibiru Chain. - */ - client: ExtendedQueryClient - tmClient: Tendermint34Client - /** The chain to which this query client corresponds. - * E.g. nibiru-testnet-1, nibiru-localnet-42 */ - chain: Chain - disconnect: () => void -} +export class NibiruQueryClient extends StargateClient { + public readonly nibiruExtensions: NibiruExtensions -export async function waitForNextBlock(chain: Chain): Promise { - const queryCmd = await newQueryCmd(chain) - const getLatestBlockHeight = async () => - (await queryCmd.tmClient.abciInfo()).lastBlockHeight - const startBlock = await getLatestBlockHeight() - while (startBlock! >= (await getLatestBlockHeight())!) { - await new Promise((resolve): void => { - setTimeout(resolve, 300) - }) + public static async connect( + endpoint: string, + options: StargateClientOptions = {}, + ): Promise { + const tmClient = await Tendermint34Client.connect(endpoint) + return new NibiruQueryClient(tmClient, options) } -} -export async function waitForBlockHeight(args: { - chain: Chain - height: number -}): Promise { - const { chain, height } = args - const queryCmd = await newQueryCmd(chain) - const getLatestBlockHeight = async () => - (await queryCmd.tmClient.abciInfo()).lastBlockHeight - - if (!(height < (await getLatestBlockHeight())!)) { - while ((await getLatestBlockHeight())! < height) { - await new Promise((resolve): void => { - setTimeout(resolve, 300) - }) - } - } -} - -export class QueryCmd implements IQueryCmd { - client: ExtendedQueryClient - - tmClient: Tendermint34Client - - chain: Chain - - constructor(tmClient: Tendermint34Client, chain: Chain) { - this.tmClient = tmClient - this.chain = chain - this.client = QueryClient.withExtensions( + protected constructor(tmClient: Tendermint34Client, options: StargateClientOptions) { + super(tmClient, options) + this.nibiruExtensions = QueryClient.withExtensions( tmClient, - setupBankExtension, - setupAuthExtension, - setupSpotExtension, + setupEpochsExtension, + setupOracleExtension, setupPerpExtension, + setupSpotExtension, setupVpoolExtension, - setupOracleExtension, - setupEpochsExtension, - setupStakingExtension, setupDistributionExtension, setupGovExtension, + setupStakingExtension, ) } - disconnect = (): void => { - this.tmClient.disconnect() + public async waitForHeight(height: number) { + while ((await this.getHeight()) < height) { + await new Promise((resolve) => { + setTimeout(resolve, 300) + }) + } } -} -export async function newQueryCmd(chain: Chain): Promise { - const tmClient = await Tendermint34Client.connect(chain.endptTm) - return new QueryCmd(tmClient, chain) + public async waitForNextBlock() { + const currentHeight = await this.getHeight() + while (currentHeight >= (await this.getHeight())) { + await new Promise((resolve) => { + setTimeout(resolve, 300) + }) + } + } } diff --git a/packages/nibijs/src/query/staking.ts b/packages/nibijs/src/query/staking.ts deleted file mode 100644 index 75056275..00000000 --- a/packages/nibijs/src/query/staking.ts +++ /dev/null @@ -1,203 +0,0 @@ -/* eslint-disable @typescript-eslint/naming-convention */ -import * as pb from "@nibiruchain/protojs/dist/cosmos/staking/v1beta1/query" -import { BondStatus } from "cosmjs-types/cosmos/staking/v1beta1/staking" -import Long from "long" - -import { - createPagination, - createProtobufRpcClient, - QueryClient, -} from "@cosmjs/stargate" - -// It's an enum in Go and a string in the protobuf API. "BOND_STATUS_UNSPECIFIED" -// is excluded and "" is supported instead 🤷. -// -// String values: https://github.com/cosmos/cosmos-sdk/blob/v0.45.5/x/staking/types/staking.pb.go#L57-L62 -// Validation: https://github.com/cosmos/cosmos-sdk/blob/v0.45.5/x/staking/keeper/grpc_query.go#L29-L32 -export type BondStatusString = - | keyof Pick< - typeof BondStatus, - "BOND_STATUS_BONDED" | "BOND_STATUS_UNBONDED" | "BOND_STATUS_UNBONDING" - > - | "" - -export interface StakingExtension { - readonly staking: Readonly<{ - delegation: ( - delegatorAddress: string, - validatorAddress: string, - ) => Promise - delegatorDelegations: ( - delegatorAddress: string, - paginationKey?: Uint8Array, - ) => Promise - delegatorUnbondingDelegations: ( - delegatorAddress: string, - paginationKey?: Uint8Array, - ) => Promise - delegatorValidator: ( - delegatorAddress: string, - validatorAddress: string, - ) => Promise - delegatorValidators: ( - delegatorAddress: string, - paginationKey?: Uint8Array, - ) => Promise - historicalInfo: (height: number) => Promise - params: () => Promise - pool: () => Promise - redelegations: ( - delegatorAddress: string, - sourceValidatorAddress: string, - destinationValidatorAddress: string, - paginationKey?: Uint8Array, - ) => Promise - unbondingDelegation: ( - delegatorAddress: string, - validatorAddress: string, - ) => Promise - validator: (validatorAddress: string) => Promise - validatorDelegations: ( - validatorAddress: string, - paginationKey?: Uint8Array, - ) => Promise - validators: ( - status: BondStatusString, - paginationKey?: Uint8Array, - ) => Promise - validatorUnbondingDelegations: ( - validatorAddress: string, - paginationKey?: Uint8Array, - ) => Promise - }> -} - -export function setupStakingExtension(base: QueryClient): StakingExtension { - // Use this service to get easy typed access to query methods - // This cannot be used for proof verification - const rpc = createProtobufRpcClient(base) - const queryService = new pb.QueryClientImpl(rpc) - - return { - staking: { - delegation: async (delegatorAddress: string, validatorAddress: string) => { - const response = await queryService.Delegation({ - delegatorAddr: delegatorAddress, - validatorAddr: validatorAddress, - }) - return response - }, - delegatorDelegations: async ( - delegatorAddress: string, - paginationKey?: Uint8Array, - ) => { - const response = await queryService.DelegatorDelegations({ - delegatorAddr: delegatorAddress, - pagination: createPagination(paginationKey), - }) - return response - }, - delegatorUnbondingDelegations: async ( - delegatorAddress: string, - paginationKey?: Uint8Array, - ) => { - const response = await queryService.DelegatorUnbondingDelegations({ - delegatorAddr: delegatorAddress, - pagination: createPagination(paginationKey), - }) - return response - }, - delegatorValidator: async ( - delegatorAddress: string, - validatorAddress: string, - ) => { - const response = await queryService.DelegatorValidator({ - delegatorAddr: delegatorAddress, - validatorAddr: validatorAddress, - }) - return response - }, - delegatorValidators: async ( - delegatorAddress: string, - paginationKey?: Uint8Array, - ) => { - const response = await queryService.DelegatorValidators({ - delegatorAddr: delegatorAddress, - pagination: createPagination(paginationKey), - }) - return response - }, - historicalInfo: async (height: number) => { - const response = await queryService.HistoricalInfo({ - height: Long.fromNumber(height, true), - }) - return response - }, - params: async () => { - const response = await queryService.Params({}) - return response - }, - pool: async () => { - const response = await queryService.Pool({}) - return response - }, - redelegations: async ( - delegatorAddress: string, - sourceValidatorAddress: string, - destinationValidatorAddress: string, - paginationKey?: Uint8Array, - ) => { - const response = await queryService.Redelegations({ - delegatorAddr: delegatorAddress, - srcValidatorAddr: sourceValidatorAddress, - dstValidatorAddr: destinationValidatorAddress, - pagination: createPagination(paginationKey), - }) - return response - }, - unbondingDelegation: async ( - delegatorAddress: string, - validatorAddress: string, - ) => { - const response = await queryService.UnbondingDelegation({ - delegatorAddr: delegatorAddress, - validatorAddr: validatorAddress, - }) - return response - }, - validator: async (validatorAddress: string) => { - const response = await queryService.Validator({ - validatorAddr: validatorAddress, - }) - return response - }, - validatorDelegations: async ( - validatorAddress: string, - paginationKey?: Uint8Array, - ) => { - const response = await queryService.ValidatorDelegations({ - validatorAddr: validatorAddress, - pagination: createPagination(paginationKey), - }) - return response - }, - validators: async (status: BondStatusString, paginationKey?: Uint8Array) => { - const response = await queryService.Validators({ - status, - pagination: createPagination(paginationKey), - }) - return response - }, - validatorUnbondingDelegations: async ( - validatorAddress: string, - paginationKey?: Uint8Array, - ) => { - const response = await queryService.ValidatorUnbondingDelegations({ - validatorAddr: validatorAddress, - pagination: createPagination(paginationKey), - }) - return response - }, - }, - } -} diff --git a/packages/nibijs/src/sdk.ts b/packages/nibijs/src/sdk.ts index b3d36265..81b4e884 100644 --- a/packages/nibijs/src/sdk.ts +++ b/packages/nibijs/src/sdk.ts @@ -3,9 +3,8 @@ * Nibiru TypeScript SDK. The SDK is accessible from the 'newSdk' function. * */ -import { Tendermint34Client } from "@cosmjs/tendermint-rpc" import { Chain } from "./chain" -import { ExtendedQueryClient, IQueryCmd, newQueryCmd } from "./query" +import { NibiruQueryClient } from "./query" import { CosmosSigner, newTxCmd, TxCmd } from "./tx" /** @@ -20,15 +19,14 @@ import { CosmosSigner, newTxCmd, TxCmd } from "./tx" */ export async function newSdk(chain: Chain, signer: CosmosSigner): Promise { const txCmd = await newTxCmd(chain, signer) - const queryCmd = await newQueryCmd(chain) - return new Sdk({ chain, txCmd, queryCmd }) + const queryClient = await NibiruQueryClient.connect(chain.endptTm) + return new Sdk({ chain, txCmd, queryClient }) } export interface ISdk { chain: Chain tx: TxCmd - query: ExtendedQueryClient - tmClient: Tendermint34Client + queryClient: NibiruQueryClient } /** @@ -58,9 +56,7 @@ export class Sdk implements ISdk { tx: TxCmd - query: ExtendedQueryClient - - tmClient: Tendermint34Client + queryClient: NibiruQueryClient /** * Creates an instance of Sdk. @@ -68,11 +64,10 @@ export class Sdk implements ISdk { * @constructor * @param {{ chain: Chain; txCmd: TxCmd; query: IQueryCmd }} args */ - constructor(args: { chain: Chain; txCmd: TxCmd; queryCmd: IQueryCmd }) { - const { chain, txCmd, queryCmd } = args + constructor(args: { chain: Chain; txCmd: TxCmd; queryClient: NibiruQueryClient }) { + const { chain, txCmd, queryClient } = args this.chain = chain this.tx = txCmd - this.query = queryCmd.client - this.tmClient = queryCmd.tmClient + this.queryClient = queryClient } } diff --git a/packages/nibijs/src/test/chain.test.ts b/packages/nibijs/src/test/chain.test.ts index 596078fb..bff3203f 100644 --- a/packages/nibijs/src/test/chain.test.ts +++ b/packages/nibijs/src/test/chain.test.ts @@ -1,5 +1,6 @@ import { SigningStargateClient } from "@cosmjs/stargate" import { + assert, Chain, Coin, CoinMap, @@ -8,7 +9,6 @@ import { newCoin, newCoinMapFromCoins, queryChainIdWithRest, - assert, } from "../chain" import { TEST_CHAIN } from "./helpers" diff --git a/packages/nibijs/src/test/faucet.test.ts b/packages/nibijs/src/test/faucet.test.ts index b24cb197..4a6d7749 100644 --- a/packages/nibijs/src/test/faucet.test.ts +++ b/packages/nibijs/src/test/faucet.test.ts @@ -1,4 +1,4 @@ -import { DeliverTxResponse, assertIsDeliverTxSuccess } from "@cosmjs/stargate" +import { assertIsDeliverTxSuccess, DeliverTxResponse } from "@cosmjs/stargate" import { Chain, CoinMap, @@ -9,12 +9,12 @@ import { useFaucet, WalletHD, } from "../chain" -import { newQueryCmd, waitForBlockHeight, waitForNextBlock } from "../query" -import { newRandomWallet, newSignerFromMnemonic } from "../tx" -import { ISdk, newSdk } from "../sdk" +import { instanceOfError } from "../chain/error" import { Msg } from "../msg" +import { NibiruQueryClient } from "../query" +import { ISdk, newSdk } from "../sdk" +import { newRandomWallet, newSignerFromMnemonic } from "../tx" import { expectTxToSucceed, prettyTmLogs, TEST_CHAIN, TxLog } from "./helpers" -import { instanceOfError } from "../chain/error" const chain: Chain = TEST_CHAIN @@ -32,7 +32,7 @@ test("faucet utility works", async () => { const signer = await newSignerFromMnemonic(valMnemonic!) const sdk = await newSdk(chain, signer) const [{ address: fromAddr }] = await signer.getAccounts() - await waitForNextBlock(chain) + await sdk.queryClient.waitForNextBlock() let txResp: DeliverTxResponse | Error = await sdk.tx.signAndBroadcast( Msg.bank.Send(fromAddr, toAddr, newCoins(5, "unibi")), ) @@ -50,13 +50,11 @@ test("faucet utility works", async () => { walletSdk, } = await setupFaucetTest() - const queryCmd = await newQueryCmd(chain) + const queryClient = await NibiruQueryClient.connect(chain.endptTm) const expectFaucetRequestSucceeds = async (): Promise => { - await waitForBlockHeight({ chain, height: setupBlockHeight + 1 }) - const balancesStart = newCoinMapFromCoins( - await queryCmd.client.bank.allBalances(address), - ) + await walletSdk.queryClient.waitForNextBlock() + const balancesStart = newCoinMapFromCoins(await queryClient.getAllBalances(address)) const faucetResp = await useFaucet({ address, chain, @@ -74,10 +72,8 @@ test("faucet utility works", async () => { } const expectBalancesToIncreaseByFaucetAmt = async (balancesStart: CoinMap) => { - await waitForNextBlock(chain) - const balances = newCoinMapFromCoins( - await queryCmd.client.bank.allBalances(address), - ) + await walletSdk.queryClient.waitForNextBlock() + const balances = newCoinMapFromCoins(await queryClient.getAllBalances(address)) // Expect to receive 10 NIBI and 100 NUSD if (balances.unusd === undefined) balances.unusd = 0 if (balances.unibi === undefined) balances.unibi = 0 diff --git a/packages/nibijs/src/test/helpers.ts b/packages/nibijs/src/test/helpers.ts index 4aa7f0ec..e77b465c 100644 --- a/packages/nibijs/src/test/helpers.ts +++ b/packages/nibijs/src/test/helpers.ts @@ -1,5 +1,4 @@ -import { assertIsDeliverTxSuccess, DeliverTxResponse } from "@cosmjs/stargate" -import { Block } from "@cosmjs/tendermint-rpc" +import { assertIsDeliverTxSuccess, Block, DeliverTxResponse } from "@cosmjs/stargate" import { Chain, CustomChain } from "../chain" export const TEST_CHAIN = new CustomChain({ nickname: "itn", number: 1 }) // v0.19.2 diff --git a/packages/nibijs/src/test/query.test.ts b/packages/nibijs/src/test/query.test.ts index 2c55a3e2..5d47ff3f 100644 --- a/packages/nibijs/src/test/query.test.ts +++ b/packages/nibijs/src/test/query.test.ts @@ -1,7 +1,7 @@ +import { Block } from "@cosmjs/stargate" import fetch from "cross-fetch" -import { BlockResponse } from "@cosmjs/tendermint-rpc" import Long from "long" -import { newQueryCmd } from "../query" +import { NibiruQueryClient } from "../query" import { TEST_CHAIN, validateBlock, validateBlockFromJsonRpc } from "./helpers" const TEST_ADDRESS = "nibi1khwntys59nwxl906p8rl68ky3d5tzuk7hp4syc" @@ -12,9 +12,9 @@ interface BlockResp { describe("connections", () => { test("query command is able to fetch latest block", async () => { - const queryCmd = await newQueryCmd(TEST_CHAIN) - const blockResp: BlockResponse = await queryCmd.tmClient.block() - validateBlock(blockResp.block, TEST_CHAIN) + const queryClient = await NibiruQueryClient.connect(TEST_CHAIN.endptTm) + const blockResp: Block = await queryClient.getBlock() + validateBlock(blockResp, TEST_CHAIN) }) test("tendermint rpc url returns block with GET", async () => { @@ -39,8 +39,8 @@ describe("connections", () => { describe("x/bank queries", () => { test("query bank balance", async () => { - const { client, disconnect } = await newQueryCmd(TEST_CHAIN) - const balances = await client.bank.allBalances(TEST_ADDRESS) + const queryClient = await NibiruQueryClient.connect(TEST_CHAIN.endptTm) + const balances = await queryClient.getAllBalances(TEST_ADDRESS) expect(balances.length).toBeGreaterThan(0) const amount: number = +balances[0].amount @@ -49,14 +49,13 @@ describe("x/bank queries", () => { const balanceDenoms: string[] = balances.map((coin) => coin.denom) expect(balanceDenoms).toContain("unibi") - disconnect() }) }) describe("x/spot queries", () => { test("query spot params", async () => { - const { client, disconnect } = await newQueryCmd(TEST_CHAIN) - const { params } = await client.spot.params() + const queryClient = await NibiruQueryClient.connect(TEST_CHAIN.endptTm) + const { params } = await queryClient.nibiruExtensions.spot.params() const fields: string[] = [ "poolCreationFee", "startingPoolNumber", @@ -67,7 +66,6 @@ describe("x/spot queries", () => { } expect(params?.whitelistedAsset.length).toBeGreaterThan(0) expect(params?.whitelistedAsset[0]).not.toBe("") - disconnect() }) }) @@ -76,8 +74,8 @@ describe("x/vpool queries", () => { test( "query all pools", async () => { - const { client: query } = await newQueryCmd(TEST_CHAIN) - const queryResp = await query.vpool.allPools() + const queryClient = await NibiruQueryClient.connect(TEST_CHAIN.endptTm) + const queryResp = await queryClient.nibiruExtensions.vpool.allPools() expect(queryResp.pools.length).toBeGreaterThan(0) expect(queryResp.prices).toHaveLength(queryResp.pools.length) }, @@ -87,12 +85,13 @@ describe("x/vpool queries", () => { test( "nibid query vpool prices", async () => { - const { client: query } = await newQueryCmd(TEST_CHAIN) - const { priceInQuoteDenom: basePrice } = await query.vpool.basePrice({ - pair: "ubtc:unusd", - goLong: true, - baseAssetAmount: 1_000, - }) + const queryClient = await NibiruQueryClient.connect(TEST_CHAIN.endptTm) + const { priceInQuoteDenom: basePrice } = + await queryClient.nibiruExtensions.vpool.basePrice({ + pair: "ubtc:unusd", + goLong: true, + baseAssetAmount: 1_000, + }) expect(basePrice.length).toBeGreaterThan(0) expect(parseFloat(basePrice)).toBeGreaterThan(0) }, @@ -102,8 +101,8 @@ describe("x/vpool queries", () => { describe("x/perp queries", () => { test("perp params - client.perp.params", async () => { - const { client, disconnect } = await newQueryCmd(TEST_CHAIN) - const { params } = await client.perp.params() + const queryClient = await NibiruQueryClient.connect(TEST_CHAIN.endptTm) + const { params } = await queryClient.nibiruExtensions.perp.params() expect(params).not.toBeNull() const fields: string[] = [ "stopped", @@ -116,32 +115,33 @@ describe("x/perp queries", () => { for (const field of fields) { expect(params).toHaveProperty(field) } - disconnect() }) test("nibid query perp funding-rates", async () => { - const { client, disconnect } = await newQueryCmd(TEST_CHAIN) - const premiumFractions = await client.perp.premiumFractions({ pair: "ubtc:unusd" }) + const queryClient = await NibiruQueryClient.connect(TEST_CHAIN.endptTm) + const premiumFractions = await queryClient.nibiruExtensions.perp.premiumFractions({ + pair: "ubtc:unusd", + }) expect(premiumFractions).not.toBeNull() - disconnect() }) test("nibid query perp metrics", async () => { - const { client, disconnect } = await newQueryCmd(TEST_CHAIN) - const { metrics } = await client.perp.metrics({ pair: "ubtc:unusd" }) + const queryClient = await NibiruQueryClient.connect(TEST_CHAIN.endptTm) + const { metrics } = await queryClient.nibiruExtensions.perp.metrics({ + pair: "ubtc:unusd", + }) expect(metrics).not.toBeNull() const metricsAttrs = ["volumeQuote", "volumeBase", "netSize", "pair"] metricsAttrs.forEach((attr) => { expect(metrics).toHaveProperty(attr) }) - disconnect() }) }) describe("x/oracle queries", () => { test("query active oracles", async () => { - const { client: query } = await newQueryCmd(TEST_CHAIN) - const { actives } = await query.oracle.actives() + const queryClient = await NibiruQueryClient.connect(TEST_CHAIN.endptTm) + const { actives } = await queryClient.nibiruExtensions.oracle.actives() expect(actives.length).toBeGreaterThan(0) expect(actives.length).toBeGreaterThan(0) const pair = actives[0] @@ -149,15 +149,15 @@ describe("x/oracle queries", () => { }) test("query oracle params", async () => { - const { client: query } = await newQueryCmd(TEST_CHAIN) - const { params: moduleParams } = await query.oracle.params() + const queryClient = await NibiruQueryClient.connect(TEST_CHAIN.endptTm) + const { params: moduleParams } = await queryClient.nibiruExtensions.oracle.params() expect(moduleParams).toBeDefined() expect(moduleParams!.whitelist.length).toBeGreaterThan(0) }) test("query exchange rates", async () => { - const { client: query } = await newQueryCmd(TEST_CHAIN) - const exhangeRateMap = await query.oracle.exchangeRates() + const queryClient = await NibiruQueryClient.connect(TEST_CHAIN.endptTm) + const exhangeRateMap = await queryClient.nibiruExtensions.oracle.exchangeRates() expect(Object.keys(exhangeRateMap).length).toBeGreaterThan(0) for (const pair in exhangeRateMap) { const exchangeRate = exhangeRateMap[pair] @@ -174,13 +174,15 @@ describe("x/epochs queries", () => { test( "query epochs info and current epoch", async () => { - const { client: query } = await newQueryCmd(TEST_CHAIN) - const infoResp = await query.epochs.epochsInfo() + const queryClient = await NibiruQueryClient.connect(TEST_CHAIN.endptTm) + const infoResp = await queryClient.nibiruExtensions.epochs.epochsInfo() expect(infoResp).toHaveProperty("epochs") expect(infoResp.epochs.length).toBeGreaterThan(0) const epochId = infoResp.epochs[0].identifier - const currentEpochResp = await query.epochs.currentEpoch({ identifier: epochId }) + const currentEpochResp = await queryClient.nibiruExtensions.epochs.currentEpoch({ + identifier: epochId, + }) expect(Long.isLong(currentEpochResp.currentEpoch)).toBeTruthy() }, timeoutMs, @@ -189,8 +191,10 @@ describe("x/epochs queries", () => { describe("x/staking module queries", () => { test("query bonded validators", async () => { - const { client: query } = await newQueryCmd(TEST_CHAIN) - const infoResp = await query.staking.validators("BOND_STATUS_BONDED") + const queryClient = await NibiruQueryClient.connect(TEST_CHAIN.endptTm) + const infoResp = await queryClient.nibiruExtensions.staking.validators( + "BOND_STATUS_BONDED", + ) expect(infoResp).toHaveProperty("validators") expect(infoResp.validators.length).toBeGreaterThan(0) }) @@ -198,8 +202,8 @@ describe("x/staking module queries", () => { describe("distribution module queries", () => { test("distribution params", async () => { - const { client: query } = await newQueryCmd(TEST_CHAIN) - const resp = await query.distribution.params() + const queryClient = await NibiruQueryClient.connect(TEST_CHAIN.endptTm) + const resp = await queryClient.nibiruExtensions.distribution.params() const { params } = resp expect(params).toBeDefined() const properties: string[] = [ @@ -216,8 +220,8 @@ describe("distribution module queries", () => { describe("gov module queries", () => { test("gov params", async () => { - const { client: query } = await newQueryCmd(TEST_CHAIN) - const resp = await query.gov.params("voting") + const queryClient = await NibiruQueryClient.connect(TEST_CHAIN.endptTm) + const resp = await queryClient.nibiruExtensions.gov.params("voting") const { votingParams } = resp expect(votingParams).toBeDefined() const properties: string[] = ["votingPeriod"] diff --git a/packages/nibijs/src/test/tx.test.ts b/packages/nibijs/src/test/tx.test.ts index d84b57da..3ca54a9e 100644 --- a/packages/nibijs/src/test/tx.test.ts +++ b/packages/nibijs/src/test/tx.test.ts @@ -9,18 +9,18 @@ * - bank module | TODO MultiSend * - Msg.bank.Send */ -import * as dotenv from "dotenv" import { DeliverTxResponse } from "@cosmjs/stargate" import { QueryPositionResponse } from "@nibiruchain/protojs/dist/perp/v1/query" import { PoolType } from "@nibiruchain/protojs/dist/spot/v1/pool" +import * as dotenv from "dotenv" import { event2KeyValue } from "../chain" +import { instanceOfError, PerpErrors, raises } from "../chain/error" import { AccountData, go, newCoin, newCoins, WalletHD } from "../chain/types" import { Msg, TxMessage } from "../msg" -import { newRandomWallet, newSignerFromMnemonic } from "../tx" -import { newSdk } from "../sdk" import { PerpMsgTypeUrls } from "../msg/perp" +import { newSdk } from "../sdk" +import { newRandomWallet, newSignerFromMnemonic } from "../tx" import { expectTxToSucceed, prettyTmLogs, TEST_CHAIN, TxLog } from "./helpers" -import { instanceOfError, PerpErrors, raises } from "../chain/error" dotenv.config() // yarn add -D dotenv @@ -147,7 +147,7 @@ describe("nibid tx perp", () => { const sdk = await newSdk(chain, signer) const [{ address: fromAddr }] = await sdk.tx.getAccounts() // Query and validate the trader's position - const queryPositions = await sdk.query.perp.positions({ + const queryPositions = await sdk.queryClient.nibiruExtensions.perp.positions({ trader: fromAddr, }) queryPositions.positions.forEach((position) => { @@ -168,7 +168,7 @@ describe("nibid tx perp", () => { const sdk = await newSdk(chain, signer) const [{ address: fromAddr }] = await sdk.tx.getAccounts() const { res: resp, err } = await go( - sdk.query.perp.position({ + sdk.queryClient.nibiruExtensions.perp.position({ pair, trader: fromAddr, }), diff --git a/packages/nibijs/src/tx/tx.ts b/packages/nibijs/src/tx/tx.ts index 255d8829..dec2dc11 100644 --- a/packages/nibijs/src/tx/tx.ts +++ b/packages/nibijs/src/tx/tx.ts @@ -1,11 +1,3 @@ -import { - SigningStargateClient, - calculateFee, - GasPrice, - StdFee, - DeliverTxResponse, - SigningStargateClientOptions, -} from "@cosmjs/stargate" import { AccountData, Coin, @@ -14,14 +6,22 @@ import { OfflineSigner, Registry, } from "@cosmjs/proto-signing" +import { + calculateFee, + DeliverTxResponse, + GasPrice, + SigningStargateClient, + SigningStargateClientOptions, + StdFee, +} from "@cosmjs/stargate" import { Chain, go } from "../chain" -import { registerTypes as registerSpot } from "../msg/spot" +import { ErrorTxBroadcast, ErrorTxSimulation, instanceOfError } from "../chain/error" +import { BankMsgs } from "../msg/bank" import { registerTypes as registerPerp } from "../msg/perp" -import { getRegistry } from "./signer" +import { registerTypes as registerSpot } from "../msg/spot" import { TxMessage } from "../msg/types" -import { waitForNextBlock } from "../query" -import { BankMsgs } from "../msg/bank" -import { ErrorTxBroadcast, ErrorTxSimulation, instanceOfError } from "../chain/error" +import { NibiruQueryClient } from "../query" +import { getRegistry } from "./signer" export type Address = string export type CosmosSigner = @@ -37,22 +37,21 @@ export type CosmosSigner = */ export class TxCmd { client: SigningStargateClient - chain: Chain - - fee?: StdFee - directSigner: OfflineDirectSigner - gasPrice: string + queryClient: NibiruQueryClient + fee?: StdFee constructor( client: SigningStargateClient, directSigner: OfflineDirectSigner, chain: Chain, + queryClient: NibiruQueryClient, gasPrice?: Coin, ) { this.client = client + this.queryClient = queryClient this.chain = chain this.directSigner = directSigner this.fee = undefined @@ -118,7 +117,7 @@ export class TxCmd { let { err } = await go(addSimulatedFeeToCmd()) // If an error occurs, try waiting another block for account sequence problems if (err) { - await waitForNextBlock(this.chain) + await this.queryClient.waitForNextBlock() ;({ err } = await go(addSimulatedFeeToCmd())) } } @@ -166,7 +165,8 @@ export async function newTxCmd( signer, sgOptions, ) - return new TxCmd(client, signer, chain, gasPriceCoin) + const queryClient = await NibiruQueryClient.connect(chain.endptTm) + return new TxCmd(client, signer, chain, queryClient, gasPriceCoin) } function coinToGasPrice(coin: Coin): GasPrice {