Skip to content

Commit 11de01a

Browse files
committed
Merge branch 'master' into 1064-wallet-estimate-transfer
2 parents b25358a + aa127f8 commit 11de01a

File tree

23 files changed

+635
-33
lines changed

23 files changed

+635
-33
lines changed

.changeset/chatty-grapes-hug.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@xchainjs/xchain-thornode': patch
3+
---
4+
5+
Thornode client updated to v1.128.1

.changeset/nervous-rules-travel.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@xchainjs/xchain-thorchain-query': patch
3+
---
4+
5+
New optional parameter `refundAddress` for `getSwapQuote` method

.changeset/selfish-pigs-punch.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@xchainjs/xchain-wallet': patch
3+
---
4+
5+
New mandatory parameter `chain` for `deposit` method

packages/xchain-bitcoin/CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## 0.23.13
4+
5+
### Patch Changes
6+
7+
- 0e07692: Ledger client method `getAddressAsync` with verify parameter
8+
39
## 0.23.12
410

511
### Patch Changes

packages/xchain-bitcoin/__e2e__/bitcoin-ledger-client.e2e.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import TransportNodeHid from '@ledgerhq/hw-transport-node-hid'
2-
import { Network, UtxoClientParams } from '@xchainjs/xchain-client'
2+
import { Network } from '@xchainjs/xchain-client'
33
import { assetAmount, assetToBase } from '@xchainjs/xchain-util'
4+
import { UtxoClientParams } from '@xchainjs/xchain-utxo'
45

56
import { ClientLedger } from '../src/clientLedger'
67
import {
@@ -39,12 +40,18 @@ describe('Bitcoin Client Ledger', () => {
3940
...defaultBTCParams,
4041
})
4142
})
42-
it('get address async', async () => {
43+
it('get address async without verification', async () => {
4344
const address = await btcClient.getAddressAsync()
4445
console.log('address', address)
4546
expect(address).toContain('b')
4647
})
4748

49+
it('get address async with verification', async () => {
50+
const address = await btcClient.getAddressAsync(0, true)
51+
console.log('address', address)
52+
expect(address).toContain('b')
53+
})
54+
4855
it('get balance', async () => {
4956
const address = await btcClient.getAddressAsync()
5057
const balance = await btcClient.getBalance(address)

packages/xchain-bitcoin/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@xchainjs/xchain-bitcoin",
3-
"version": "0.23.12",
3+
"version": "0.23.13",
44
"description": "Custom Bitcoin client and utilities used by XChainJS clients",
55
"keywords": [
66
"XChain",

packages/xchain-bitcoin/src/clientLedger.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ class ClientLedger extends Client {
3838
}
3939

4040
// Get the current address asynchronously
41-
async getAddressAsync(index = 0): Promise<Address> {
41+
async getAddressAsync(index = 0, verify = false): Promise<Address> {
4242
const app = await this.getApp()
4343
const result = await app.getWalletPublicKey(this.getFullDerivationPath(index), {
4444
format: 'bech32',
45-
verify: false,
45+
verify,
4646
})
4747
return result.bitcoinAddress
4848
}

packages/xchain-mayachain-amm/CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## 1.0.12
4+
5+
### Patch Changes
6+
7+
- Updated dependencies [0e07692]
8+
- @xchainjs/xchain-bitcoin@0.23.13
9+
310
## 1.0.11
411

512
### Patch Changes

packages/xchain-mayachain-amm/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@xchainjs/xchain-mayachain-amm",
3-
"version": "1.0.11",
3+
"version": "1.0.12",
44
"description": "module that exposes estimating & swapping cryptocurrency assets on mayachain",
55
"keywords": [
66
"MAYAChain",
@@ -46,7 +46,7 @@
4646
"devDependencies": {
4747
"@cosmos-client/core": "0.46.1",
4848
"@psf/bitcoincashjs-lib": "^4.0.3",
49-
"@xchainjs/xchain-bitcoin": "^0.23.12",
49+
"@xchainjs/xchain-bitcoin": "^0.23.13",
5050
"@xchainjs/xchain-client": "^0.16.2",
5151
"@xchainjs/xchain-crypto": "^0.3.1",
5252
"@xchainjs/xchain-dash": "^0.2.12",
@@ -70,7 +70,7 @@
7070
"peerDependencies": {
7171
"@cosmos-client/core": "0.46.1",
7272
"@psf/bitcoincashjs-lib": "^4.0.3",
73-
"@xchainjs/xchain-bitcoin": "^0.23.12",
73+
"@xchainjs/xchain-bitcoin": "^0.23.13",
7474
"@xchainjs/xchain-client": "^0.16.2",
7575
"@xchainjs/xchain-crypto": "^0.3.1",
7676
"@xchainjs/xchain-dash": "^0.2.12",

packages/xchain-mayachain-amm/src/mayachain-amm.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ export class MayachainAMM {
247247
*/
248248
private async doProtocolAssetSwap(amount: CryptoAmount, memo: string): Promise<TxSubmitted> {
249249
// Deposit the amount and return transaction hash and URL
250-
const hash = await this.wallet.deposit({ asset: amount.asset, amount: amount.baseAmount, memo })
250+
const hash = await this.wallet.deposit({ chain: MAYAChain, asset: amount.asset, amount: amount.baseAmount, memo })
251251

252252
return {
253253
hash,

packages/xchain-thorchain-amm/CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## 1.0.2
4+
5+
### Patch Changes
6+
7+
- Updated dependencies [0e07692]
8+
- @xchainjs/xchain-bitcoin@0.23.13
9+
310
## 1.0.1
411

512
### Patch Changes

packages/xchain-thorchain-amm/__e2e__/thorchain-swap-e2e.ts

+34-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { AssetAVAX, Client as AvaxClient, defaultAvaxParams } from '@xchainjs/xchain-avax'
2-
import { AssetBNB, Client as BnbClient } from '@xchainjs/xchain-binance'
2+
import { AssetBNB, BNBChain, Client as BnbClient } from '@xchainjs/xchain-binance'
33
import {
44
AssetBTC,
55
BTC_DECIMAL,
@@ -143,6 +143,17 @@ describe('ThorchainAmm e2e tests', () => {
143143
console.log(errors)
144144
})
145145

146+
it(`Should validate swap from synth BNB to BNB without errors`, async () => {
147+
const errors = await thorchainAmm.validateSwap({
148+
fromAsset: assetFromStringEx('BNB/BNB'),
149+
amount: new CryptoAmount(assetToBase(assetAmount('1')), assetFromStringEx('BNB/BNB')),
150+
destinationAddress: await wallet.getAddress(BNBChain),
151+
destinationAsset: assetFromStringEx('BNB.BNB'),
152+
})
153+
154+
console.log(errors)
155+
})
156+
146157
it(`Should validate swap from ATOM to synth ATOM with destination address error`, async () => {
147158
const errors = await thorchainAmm.validateSwap({
148159
fromAsset: AssetATOM,
@@ -200,6 +211,17 @@ describe('ThorchainAmm e2e tests', () => {
200211
printQuoteSwap(quoteSwap)
201212
})
202213

214+
it(`Should estimate swap from synth BNB to BNB without errors`, async () => {
215+
const estimatedSwap = await thorchainAmm.estimateSwap({
216+
fromAsset: assetFromStringEx('BNB/BNB'),
217+
amount: new CryptoAmount(assetToBase(assetAmount('1')), assetFromStringEx('BNB/BNB')),
218+
destinationAddress: await wallet.getAddress(BNBChain),
219+
destinationAsset: assetFromStringEx('BNB.BNB'),
220+
})
221+
222+
printQuoteSwap(estimatedSwap)
223+
})
224+
203225
it('Should do non protocol asset swap. ATOM -> BNB', async () => {
204226
const txSubmitted = await thorchainAmm.doSwap({
205227
fromAsset: AssetATOM,
@@ -222,6 +244,17 @@ describe('ThorchainAmm e2e tests', () => {
222244
console.log(txSubmitted)
223245
})
224246

247+
it(`Should do swap from synth BNB to BNB without errors`, async () => {
248+
const txSubmitted = await thorchainAmm.doSwap({
249+
fromAsset: assetFromStringEx('BNB/BNB'),
250+
amount: new CryptoAmount(assetToBase(assetAmount('1')), assetFromStringEx('BNB/BNB')),
251+
destinationAddress: await wallet.getAddress(BNBChain),
252+
destinationAsset: assetFromStringEx('BNB.BNB'),
253+
})
254+
255+
console.log(txSubmitted)
256+
})
257+
225258
it('Should check if Thorchain router is allowed to spend', async () => {
226259
const asset = assetFromStringEx('AVAX.USDC-0XB97EF9EF8734C71904D8002F8B6BC66DD9C48A6E')
227260

packages/xchain-thorchain-amm/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@xchainjs/xchain-thorchain-amm",
3-
"version": "1.0.1",
3+
"version": "1.0.2",
44
"description": "module that exposes estimating & swappping cryptocurrency assets on thorchain",
55
"keywords": [
66
"THORChain",
@@ -38,7 +38,7 @@
3838
"dependencies": {
3939
"@xchainjs/xchain-avax": "0.4.6",
4040
"@xchainjs/xchain-binance": "5.7.10",
41-
"@xchainjs/xchain-bitcoin": "0.23.12",
41+
"@xchainjs/xchain-bitcoin": "0.23.13",
4242
"@xchainjs/xchain-bitcoincash": "0.17.10",
4343
"@xchainjs/xchain-bsc": "0.4.7",
4444
"@xchainjs/xchain-cosmos": "1.0.1",

packages/xchain-thorchain-amm/src/thorchain-action.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,12 @@ export class ThorchainAction {
3232
}
3333

3434
private static async makeProtocolAction({ wallet, assetAmount, memo }: ProtocolActionParams): Promise<TxSubmitted> {
35-
const hash = await wallet.deposit({ asset: assetAmount.asset, amount: assetAmount.baseAmount, memo })
35+
const hash = await wallet.deposit({
36+
chain: THORChain,
37+
asset: assetAmount.asset,
38+
amount: assetAmount.baseAmount,
39+
memo,
40+
})
3641

3742
return {
3843
hash,

packages/xchain-thorchain-query/src/utils/thornode.ts

+2
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,7 @@ export class Thornode {
407407
affiliateBps?: number,
408408
affiliate?: string,
409409
height?: number,
410+
refundAddress?: string,
410411
): Promise<QuoteSwapResponse> {
411412
for (const api of this.quoteApi) {
412413
try {
@@ -417,6 +418,7 @@ export class Thornode {
417418
toAsset,
418419
amount,
419420
destinationAddress,
421+
refundAddress,
420422
streamingInterval,
421423
streamingQuantity,
422424
toleranceBps,

packages/xchain-thornode/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"prepublishOnly": "yarn build",
3131
"test": "jest --passWithNoTests",
3232
"generate:types": "yarn clean:types:thornode && yarn generate:types:thornode",
33-
"generate:types:thornode": "TS_POST_PROCESS_FILE=./node_modules/.bin/prettier openapi-generator-cli generate -i https://gitlab.com/thorchain/thornode/-/raw/release-1.126.0/openapi/openapi.yaml -g typescript-axios -o ./src/generated/thornodeApi --skip-validate-spec --generate-alias-as-model",
33+
"generate:types:thornode": "TS_POST_PROCESS_FILE=./node_modules/.bin/prettier openapi-generator-cli generate -i https://gitlab.com/thorchain/thornode/-/raw/release-1.128.1/openapi/openapi.yaml -g typescript-axios -o ./src/generated/thornodeApi --skip-validate-spec --generate-alias-as-model",
3434
"clean:types:thornode": "rimraf ./src/generated/thornodeApi"
3535
},
3636
"devDependencies": {
@@ -43,4 +43,4 @@
4343
"publishConfig": {
4444
"access": "public"
4545
}
46-
}
46+
}

0 commit comments

Comments
 (0)