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 all 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
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
**/node_modules/**
packages/**/lib/**
packages/xchain-thorchain/src/types/proto/**
39 changes: 32 additions & 7 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,60 @@
"ecmaVersion": 2018,
"sourceType": "module"
},
"plugins": ["prettier", "ordered-imports"],
"plugins": [
"prettier",
"ordered-imports"
],
"extends": [
"plugin:@typescript-eslint/recommended",
"prettier/@typescript-eslint",
"plugin:prettier/recommended",
"plugin:ordered-imports/recommended"
],
"ignorePatterns": "**/*.d.ts",
"rules": {
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-use-before-define": "warn",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/ban-ts-ignore": "off",
"@typescript-eslint/no-unused-vars": ["error", { "varsIgnorePattern": "^_", "argsIgnorePattern": "^_" }],
"@typescript-eslint/no-unused-vars": [
"error",
{
"varsIgnorePattern": "^_",
"argsIgnorePattern": "^_"
}
],
"@typescript-eslint/no-var-requires": "off",
"no-duplicate-imports": "error",
"no-undef": "off",
"ordered-imports/ordered-imports": [
"error",
{
"symbols-first": false,
"declaration-ordering": ["source", "lowercase-last"],
"declaration-ordering": [
"source",
"lowercase-last"
],
"specifier-ordering": "lowercase-last",
"group-ordering": [
{ "name": "parent directories", "match": "^\\.\\.", "order": 30 },
{ "name": "current directory", "match": "^\\.", "order": 40 },
{ "name": "third-party", "match": ".*", "order": 10 }
{
"name": "parent directories",
"match": "^\\.\\.",
"order": 30
},
{
"name": "current directory",
"match": "^\\.",
"order": 40
},
{
"name": "third-party",
"match": ".*",
"order": 10
}
]
}
]
}
}
}
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(60000)
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@
"tslib": "^2.1.0",
"typescript": "^4.2.3"
}
}
}
9 changes: 9 additions & 0 deletions packages/xchain-cosmos/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# v.0.17.0 (2022-03-13)

- upgraded to "@cosmos-client/core": "0.44.4"
- xchain-cosmos and xchain-thorchain now extend BaseXChainClient

## Breaking changes

- Remove `minheight` and `maxheight` params from `CosmosSDKClient.searchTx` (params were removed from the API)

# v.0.16.1 (2022-02-04)

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

let xchainClient: CosmosClient = 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 res = await xchainClient.transfer(transferTx)
expect(res.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', 6),
recipient: addressTo,
memo: 'Hi!',
}
const txHash = await xchainClient.transfer(transferTx)
expect(txHash.length).toBeGreaterThan(0)

// Wait 35 seconds for the tx to process
await delay(35 * 1000)

const txResult = await xchainClient.getSDKClient().txsHashGet(txHash)
expect(txResult.raw_log).toEqual('failed to execute message; message index: 0: 0xxx is smaller than 100xxx: insufficient funds')

} catch (error) {
throw error
}
})
})
Loading