Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to @cosmos-client v0.44.4: Prepare for TC hard-fork/Cosmos SDK upgrade #501

Merged
merged 19 commits into from
Mar 19, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The interface is [defined here.](https://github.com/xchainjs/xchainjs-lib/blob/m

The interface supports as a minimum the following functions for each blockchain:

1. Initialise with a valid BIP39 phrase and specified network (testnet/stagenet/mainnet)
1. Initialise with a valid BIP39 phrase and specified network (testnet/mainnet)
2. Get the address, with support for BIP44 path derivations (default is Index 0)
3. Get the balance (UTXO or account-based)
4. Get transaction history for that address
Expand Down Expand Up @@ -55,6 +55,8 @@ export PHRASE="secret phrase here"
yarn e2e
```

### `unit`

## Development

`lerna bootstrap`
Expand Down
1 change: 1 addition & 0 deletions jest.setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
jest.setTimeout(30000)
8 changes: 8 additions & 0 deletions packages/xchain-cosmos/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# v.0.10.0 (2022-03-13)
veado marked this conversation as resolved.
Show resolved Hide resolved

- upgraded to "@cosmos-client/core": "0.44.4"

## Breaking changes

- Remove ``
veado marked this conversation as resolved.
Show resolved Hide resolved

# v.0.16.1 (2022-02-04)

- Use latest axios@0.25.0
Expand Down
74 changes: 74 additions & 0 deletions packages/xchain-cosmos/__e2e__/cosmos-client.e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import { Network, TxParams, XChainClient } from '@xchainjs/xchain-client'
import { Client as CosmosClient } from '@xchainjs/xchain-cosmos'
import { Chain, assetToString, baseAmount } from '@xchainjs/xchain-util'

let xchainClient: XChainClient = new CosmosClient({})

describe('Cosmos Integration Tests', () => {
beforeEach(() => {
const settings = { network: Network.Testnet, phrase: process.env.PHRASE }
xchainClient = new CosmosClient(settings)
})
it('should fetch cosmos balances', async () => {
const address = xchainClient.getAddress(0)
const balances = await xchainClient.getBalance(address)

balances.forEach((bal) => {
console.log(`${assetToString(bal.asset)} = ${bal.amount.amount()}`)
})
expect(balances.length).toBeGreaterThan(0)
})

it('should generate cosmos addreses', async () => {
const address0 = xchainClient.getAddress(0)
const address1 = xchainClient.getAddress(1)

expect(address0.length).toBeGreaterThan(0)
expect(address0.startsWith('cosmos')).toBeTruthy()

expect(address1.length).toBeGreaterThan(0)
expect(address1.startsWith('cosmos')).toBeTruthy()
})
it('should xfer uatom from wallet 0 -> 1, with a memo', async () => {
try {
const addressTo = xchainClient.getAddress(1)
const transferTx: TxParams = {
walletIndex: 0,
asset: { chain: Chain.Cosmos, ticker: 'ATOM', symbol: 'uatom', synth: false },
amount: baseAmount('100', 6),
recipient: addressTo,
memo: 'Hi!',
}
const hash = await xchainClient.transfer(transferTx)
expect(hash.length).toBeGreaterThan(0)

} catch (error) {
throw error
}
})
it('should fetch cosmos txs', async () => {
const address = xchainClient.getAddress(0)
const txPage = await xchainClient.getTransactions({ address })

expect(txPage.total).toBeGreaterThan(0)
expect(txPage.txs.length).toBeGreaterThan(0)
})
it('should fail xfer xxx from wallet 0 -> 1', async () => {
try {
const addressTo = xchainClient.getAddress(0)
const transferTx: TxParams = {
walletIndex: 1,
asset: { chain: Chain.Cosmos, ticker: 'GAIA', symbol: 'xxx', synth: false },
amount: baseAmount('100'),
recipient: addressTo,
memo: 'Hi!',
}
await xchainClient.transfer(transferTx)
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (e: any) {
expect(e.message).toEqual(
'Error broadcasting: failed to execute message; message index: 0: 0xxx is smaller than 100xxx: insufficient funds',
)
}
})
})
Loading