Skip to content

Commit

Permalink
Merge pull request #57 from bandprotocol/patch/v2.5.0
Browse files Browse the repository at this point in the history
v2.5.0
  • Loading branch information
babybunn authored Dec 3, 2024
2 parents 2b3506b + 5beaab0 commit 41e786c
Show file tree
Hide file tree
Showing 1,225 changed files with 270,832 additions and 45,182 deletions.
8 changes: 8 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[submodule "proto/cosmos-proto"]
path = proto/cosmos-proto
url = https://github.com/cosmos/cosmos-proto.git
branch = main
[submodule "proto/chain"]
path = proto/chain
url = https://github.com/bandprotocol/chain.git
branch = master
33 changes: 2 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ BandChain.js is a library for interacting with BandChain in browser and Node.js

## 📦 Installation

BandChain.js is currently supported on NodeJS 16.x, and 18.x.
BandChain.js is currently supported on Node.js 16.x, and 18.x.

### NPM

Expand All @@ -26,33 +26,4 @@ yarn add @bandprotocol/bandchain.js

## Compatibility

Band 2.2.0, Cosmos SDK 0.44.0, IBC-go 1.1.0

## Usage

#### Retrieving Price Data

```js
const { Client } = require('@bandprotocol/bandchain.js')

// BandChain's Proof-of-Authority REST endpoint
const endpoint = 'https://laozi-testnet6.bandchain.org/grpc-web'
const client = new Client(endpoint)

// This example demonstrates how to query price data from
// Band's standard dataset
async function exampleGetReferenceData() {
const rate = await client.getReferenceData(
['BTC/USD', 'BTC/ETH', 'EUR/USD', 'EUR/ETH'],
3,
4,
)
return rate
}

;(async () => {
console.log(await exampleGetReferenceData())
})()
```

For more examples, please see [`example`](example/) folder.
BandChain v3.0.0, Cosmos SDK v0.50.0, IBC-go v8.5.2
61 changes: 29 additions & 32 deletions __tests__/client/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
QueryClient,
ServiceError,
UnaryResponse,
} from '../../proto/oracle/v1/query_pb_service'
} from '../../codegen/band/oracle/v1/query_pb_service'

import {
QueryDataSourceRequest,
Expand All @@ -19,7 +19,7 @@ import {
QueryRequestSearchRequest,
QueryRequestSearchResponse,
QueryRequestResponse,
} from '../../proto/oracle/v1/query_pb'
} from '../../codegen/band/oracle/v1/query_pb'
import {
DataSource,
OracleScript,
Expand All @@ -29,53 +29,53 @@ import {
Report,
RawReport,
Result,
} from '../../proto/oracle/v1/oracle_pb'
import { ServiceClient } from '../../proto/cosmos/base/tendermint/v1beta1/query_pb_service'
} from '../../codegen/band/oracle/v1/oracle_pb'
import { ServiceClient } from '../../codegen/cosmos/base/tendermint/v1beta1/query_pb_service'

import {
GetLatestBlockRequest,
GetLatestBlockResponse,
} from '../../proto/cosmos/base/tendermint/v1beta1/query_pb'
import { BlockID, Header } from '../../proto/tendermint/types/types_pb'
import { Block } from '../../proto/tendermint/types/block_pb'
} from '../../codegen/cosmos/base/tendermint/v1beta1/query_pb'
import { BlockID, Header } from '../../codegen/tendermint/types/types_pb'
import { Block } from '../../codegen/tendermint/types/block_pb'

import { QueryClient as AuthQueryClient } from '../../proto/cosmos/auth/v1beta1/query_pb_service'
import { QueryClient as QueryAllBalances } from '../../proto/cosmos/bank/v1beta1/query_pb_service'
import { QueryClient as AuthQueryClient } from '../../codegen/cosmos/auth/v1beta1/query_pb_service'
import { QueryClient as QueryAllBalances } from '../../codegen/cosmos/bank/v1beta1/query_pb_service'

import {
QueryAllBalancesRequest,
QueryAllBalancesResponse,
} from '../../proto/cosmos/bank/v1beta1/query_pb'
} from '../../codegen/cosmos/bank/v1beta1/query_pb'

import {
QueryAccountRequest,
QueryAccountResponse,
} from '../../proto/cosmos/auth/v1beta1/query_pb'
} from '../../codegen/cosmos/auth/v1beta1/query_pb'

import { ServiceClient as TxServiceClient } from '../../proto/cosmos/tx/v1beta1/service_pb_service'
import { ServiceClient as TxServiceClient } from '../../codegen/cosmos/tx/v1beta1/service_pb_service'
import {
GetTxRequest,
GetTxResponse,
} from '../../proto/cosmos/tx/v1beta1/service_pb'
} from '../../codegen/cosmos/tx/v1beta1/service_pb'
import {
Tx,
TxBody,
AuthInfo,
SignerInfo,
} from '../../proto/cosmos/tx/v1beta1/tx_pb'
} from '../../codegen/cosmos/tx/v1beta1/tx_pb'
import { Any } from 'google-protobuf/google/protobuf/any_pb'
import { ABCIMessageLog } from '../../proto/cosmos/base/abci/v1beta1/abci_pb'
import { TxResponse } from '../../proto/cosmos/base/abci/v1beta1/abci_pb'
import { StringEvent } from '../../proto/cosmos/base/abci/v1beta1/abci_pb'
import { Attribute } from '../../proto/cosmos/base/abci/v1beta1/abci_pb'
import { SignMode } from '../../proto/cosmos/tx/signing/v1beta1/signing_pb'
import { ModeInfo, Fee } from '../../proto/cosmos/tx/v1beta1/tx_pb'

jest.mock('../../proto/oracle/v1/query_pb_service')
jest.mock('../../proto/cosmos/base/tendermint/v1beta1/query_pb_service')
jest.mock('../../proto/cosmos/auth/v1beta1/query_pb_service')
jest.mock('../../proto/cosmos/tx/v1beta1/service_pb_service')
jest.mock('../../proto/cosmos/bank/v1beta1/query_pb_service')
import { ABCIMessageLog } from '../../codegen/cosmos/base/abci/v1beta1/abci_pb'
import { TxResponse } from '../../codegen/cosmos/base/abci/v1beta1/abci_pb'
import { StringEvent } from '../../codegen/cosmos/base/abci/v1beta1/abci_pb'
import { Attribute } from '../../codegen/cosmos/base/abci/v1beta1/abci_pb'
import { SignMode } from '../../codegen/cosmos/tx/signing/v1beta1/signing_pb'
import { ModeInfo, Fee } from '../../codegen/cosmos/tx/v1beta1/tx_pb'

jest.mock('../../codegen/band/oracle/v1/query_pb_service')
jest.mock('../../codegen/cosmos/base/tendermint/v1beta1/query_pb_service')
jest.mock('../../codegen/cosmos/auth/v1beta1/query_pb_service')
jest.mock('../../codegen/cosmos/tx/v1beta1/service_pb_service')
jest.mock('../../codegen/cosmos/bank/v1beta1/query_pb_service')

const STATIC_DATE = 1625578450000
Date.now = jest.fn(() => STATIC_DATE)
Expand Down Expand Up @@ -849,9 +849,6 @@ describe('get latest request', () => {
'bandvaloper1e9sa38742tzhmandc4gkqve9zy8zc0yremaa3j',
'bandvaloper1l2hchtyawk9tk43zzjrzr2lcd0zyxngcjdsshe',
])
request.setTssGroupId(0)
request.setFeeLimitList([])
request.setRequester("")
request.setMinCount(3)
request.setRequestHeight(431790)
request.setRequestTime(1625547173)
Expand Down Expand Up @@ -951,12 +948,11 @@ describe('get latest request', () => {
'aHR0cHM6Ly91cy1ycGMuYmFuZGNoYWluLm9yZy9vcmFjbGUvcmVxdWVzdF9wcmljZXMgQlRDIEVUSA==',
},
],
requester: '',
executeGas: 1000000,
ibcChannel: undefined,
tssGroupId: 0,
requester: "",
feeLimitList: [],
signing: undefined
tssEncoder: 0,
},
reportsList: [
{
Expand Down Expand Up @@ -1005,6 +1001,7 @@ describe('get latest request', () => {
resolveStatus: 1,
result: 'AAAAAgAAH4lLo7MAAAACGsSNTYA==',
},
signing: undefined,
}
const response = await client.getLatestRequest(
43,
Expand Down
12 changes: 6 additions & 6 deletions __tests__/client/sendTx.test.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import { Client } from '../../src'
import { grpc } from '@improbable-eng/grpc-web'

import { ServiceClient as TxServiceClient } from '../../proto/cosmos/tx/v1beta1/service_pb_service'
import { ServiceClient as TxServiceClient } from '../../codegen/cosmos/tx/v1beta1/service_pb_service'
import {
ServiceError,
UnaryResponse,
} from '../../proto/oracle/v1/query_pb_service'
} from '../../codegen/band/oracle/v1/query_pb_service'

import {
BroadcastTxRequest,
BroadcastTxResponse,
} from '../../proto/cosmos/tx/v1beta1/service_pb'
import { TxResponse } from '../../proto/cosmos/base/abci/v1beta1/abci_pb'
} from '../../codegen/cosmos/tx/v1beta1/service_pb'
import { TxResponse } from '../../codegen/cosmos/base/abci/v1beta1/abci_pb'
import {
ABCIMessageLog,
StringEvent,
Attribute,
} from '../../proto/cosmos/base/abci/v1beta1/abci_pb'
} from '../../codegen/cosmos/base/abci/v1beta1/abci_pb'

jest.mock('../../proto/cosmos/tx/v1beta1/service_pb_service')
jest.mock('../../codegen/cosmos/tx/v1beta1/service_pb_service')

const MockedTxService = jest.mocked(TxServiceClient)

Expand Down
Loading

0 comments on commit 41e786c

Please sign in to comment.