Skip to content

Commit

Permalink
Fix/publish (#162)
Browse files Browse the repository at this point in the history
* fix(publish): artifact

* feat(match): version
  • Loading branch information
cgilbe27 authored Jun 15, 2023
1 parent 97b5126 commit 14e4ebf
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 34 deletions.
4 changes: 4 additions & 0 deletions packages/indexer-nibi/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline

- .

## v0.19.14

- Match version

## v0.6.1

- feat(perpLeaderboard): Add perp leaderboard query
Expand Down
2 changes: 1 addition & 1 deletion packages/indexer-nibi/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@nibiruchain/indexer-nibi",
"description": "GraphQL API client for the Nibiru Chain indexer (heart-monitor)",
"version": "0.6.1",
"version": "0.19.14",
"license": "MIT",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
107 changes: 74 additions & 33 deletions packages/nibijs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,32 @@ The official TypeScript SDK for the Nibiru blockchain
<a target="_blank" href="https://github.com/NibiruChain/ts-sdk/blob/main/LICENSE">
<img src="https://img.shields.io/npm/l/express.svg?color=050505" style="height: 20px">
</a>
<a target="_blank" href="https://discord.gg/sgPw8ZYfpQ">
<img src="https://dcbadge.vercel.app/api/server/sgPw8ZYfpQ?style=flat" style="height: 20px">
<a target="_blank" href="https://discord.gg/nibirufi">
<img src="https://dcbadge.vercel.app/api/server/nibirufi?style=flat" style="height: 20px">
</a>

</div>

The NibiJS (`@nibiruchain/nibijs`) package makes it possible to interact with Nibiru from a Node.js or browser environment. `nibijs` provides simple abstractions for core data structures, serialization, key management, API requests, and the submission of transactions.
The NibiJS (`@nibiruchain/nibijs`) package makes it possible to interact with Nibiru from a Node.js or browser environment. `nibijs` provides simple abstractions for core data structures, serialization, key management, API requests, and the submission of transactions.

The `nibijs` source code can be found in the ["packages" directory](https://github.com/NibiruChain/ts-sdk/tree/main/packages). The types and classes generated from Nibiru's `.proto` files are inside a separate `npm` package called `@nibiruchain/protojs`.
The `nibijs` source code can be found in the ["packages" directory](https://github.com/NibiruChain/ts-sdk/tree/main/packages). The types and classes generated from Nibiru's `.proto` files are inside a separate `npm` package called `@nibiruchain/protojs`.

#### Table of Contents

- [Installation](#installation)
- [Usage](#usage)
- [Example: Creating a wallet](#example-creating-a-wallet)
- [Example: Querying](#example-querying)
- [Example: Sending funds](#example-sending-funds)
- [Example: Transaction with arbitrary messages](#example-transaction-with-arbitrary-messages)
- [Codebase structure](#codebase-structure)
- [Development Quick Start](#development-quick-start)
- [🔓 License](#-license)

To learn more about Nibiru, see [docs.nibiru.fi](https://docs.nibiru.fi)
To learn more about Nibiru, see [docs.nibiru.fi](https://docs.nibiru.fi)

---

## Installation
## Installation

[@nibiruchain/nibijs][npm-nibijs] is available on the npm registry.

Expand All @@ -51,14 +55,15 @@ To learn more about Nibiru, see [docs.nibiru.fi](https://docs.nibiru.fi)
npm install @nibiruchain/nibijs # or yarn add
```

## Usage
## Usage

The entrypoint for `nibijs` is the `Sdk` object, which is meant to mimic the root of a command line interface. It can be used for both queries and transactions.

#### Example: Creating a wallet

```js
import { newRandomWallet, WalletHD } from "@nibiruchain/nibijs/dist/tx"
import { newRandomWallet, WalletHD } from "@nibiruchain/nibijs"

const wallet: WalletHD = await newRandomWallet()
const [{ address }] = await wallet.getAccounts()

Expand All @@ -70,37 +75,62 @@ console.log("address: ", address)
#### Example: Querying

```js
import { Testnet, newSdk } from "@nibiruchain/nibijs"
const sdk = newSdk(Testnet, myMnemonic)
import {
IncentivizedTestent,
NibiruQueryClient,
NibiruSigningClient,
} from "@nibiruchain/nibijs"

const TEST_CHAIN = IncentivizedTestent(1)
const queryClient = await NibiruQueryClient.connect(TEST_CHAIN.endptTm)

const balances = await sdk.query.bank.allBalances(address)
console.log("balances: %o", balances)
const perpParamsResp = await queryClient.nibiruExtensions.perp.params()
console.log("perpParams: %o", perpParamsResp)

const allPools = await sdk.query.vpool.allPools()
const allPools = await queryClient.nibiruExtensions.vpool.allPools()
console.log("allPools: %o", allPools)

const blockHeight = 1
const block = sdk.tmClient.block(blockHeight)
const block = await queryClient.getBlock(blockHeight)
```

#### Example: Sending funds

```js
import { Testnet, newSdk, newCoins, Coin } from "@nibiruchain/nibijs"
const sdk = newSdk(Testnet, myMnemonic)
import {
Coin,
NibiruSigningClient,
newCoins,
newSignerFromMnemonic,
} from "@nibiruchain/nibijs"

const signer = await newSignerFromMnemonic(mnemonic!)
const signingClient = await NibiruSigningClient.connectWithSigner(
TEST_CHAIN.endptTm,
signer,
)
const [{ address: fromAddr }] = await signer.getAccounts()

const tokens: Coin[] = newCoins(5, "unibi")
const toAddr: string = "..." // bech32 address of the receiving party
let txResp = sdk.tx.sendTokens(toAddr, tokens)
const txResp = await signingClient.sendTokens(fromAddr, toAddr, tokens, "auto")
```

#### Example: Transaction with arbitrary messages

```js
import { Testnet, newSdk, newCoins, Coin, DeliverTxResponse } from "@nibiruchain/nibijs"
import { Msg } from "@nibiruchain/nibijs/msg"

const sdk = newSdk(Testnet, myMnemonic)
let msgs: TxMessage[] = [
import { IncentivizedTestent, NibiruSigningClient, newCoin } from "@nibiruchain/nibijs"
import { Msg, TxMessage } from "@nibiruchain/nibijs/dist/msg"

const signer = await newSignerFromMnemonic(mnemonic!)
signer.getAccounts()
const signingClient = await NibiruSigningClient.connectWithSigner(
TEST_CHAIN.endptTm,
signer,
)
const [{ address: fromAddr }] = await signer.getAccounts()
const pair = "ubtc:unusd"
const msgs: TxMessage[] = [
Msg.perp.openPosition({
tokenPair: pair,
baseAssetAmountLimit: 0,
Expand All @@ -114,19 +144,25 @@ let msgs: TxMessage[] = [
tokenPair: pair,
margin: newCoin("20", "unusd"),
}),
Msg.perp.removeMargin({
tokenPair: pair,
sender: fromAddr,
margin: newCoin("5", "unusd"),
}),
// final margin value of 10 (open) + 20 (add) - 5 (remove) = 25
]
let txResp: DeliverTxResponse = await sdk.tx.signAndBroadcast(...msgs)
const txResp = await signingClient.signAndBroadcast(fromAddr, msgs, "auto")
```

## Codebase structure

| Directories of `@nibiruchain/nibijs` | Purpose/Utility |
| :-------- | -------- |
| `common` | home to several commonly needed types, constants and configurations such as Network.
| `msg` | Implements functions for creating messages (`Msg`s). These are objects that trigger state-transitions and get wrapped into transactions.
| `query` | For querying state via the consensus engine of a full-node and the application blockchain interface (ABCI).
| `tx` | For signing and to submitting transactions given a set of `Msg` objects.
| `wallet` | A simple wrapper around the Keplr wallet. This module will grow as support is added for other wallets (like MetaMask). |
| Directories of `@nibiruchain/nibijs` | Purpose/Utility |
| :----------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| `common` | home to several commonly needed types, constants and configurations such as Network. |
| `msg` | Implements functions for creating messages (`Msg`s). These are objects that trigger state-transitions and get wrapped into transactions. |
| `query` | For querying state via the consensus engine of a full-node and the application blockchain interface (ABCI). |
| `tx` | For signing and to submitting transactions given a set of `Msg` objects. |
| `wallet` | A simple wrapper around the Keplr wallet. This module will grow as support is added for other wallets (like MetaMask). |

`@nibiruchain/protojs` provides types generated from the protocol buffers of the Cosmos-SDK, Tendermint Core, and Nibiru Chain. For most use cases, it won't be necessary to interact with this layer.

Expand All @@ -138,23 +174,28 @@ let txResp: DeliverTxResponse = await sdk.tx.signAndBroadcast(...msgs)
TODO
-->

## Development Quick Start
## Development Quick Start

1. First install yarn.

```sh
npm install -g yarn
```

2. Then, install package dependencies. At the root of the repository, run
2. Then, install package dependencies. At the root of the repository, run

```sh
yarn
```

3. Lastly, compile the code in each package.

```sh
yarn build
```

See [HACKING.md](https://github.com/NibiruChain/ts-sdk/blob/main/HACKING.md) for the full development guide. It includes instructions on:

1. Running tests
2. Generating code for the @nibiruchain/protojs package
3. Generating documentation in HTML or Markdown from the comments of @nibiruchain/nibijs
Expand Down

0 comments on commit 14e4ebf

Please sign in to comment.