From 99129ccc5f94336c4edd92e9afeb8f1263a84335 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Kotol?= Date: Fri, 5 Jan 2024 11:38:16 +0100 Subject: [PATCH] ALL-3288 Fix Stellar get strict (#1043) --- CHANGELOG.md | 4 ++ package.json | 2 +- src/dto/rpc/StellarRpcSuite.ts | 6 +-- src/e2e/rpc/other/tatum.rpc.stellar.spec.ts | 47 +++++++++++++++------ src/service/rpc/other/AbstractStellarRpc.ts | 16 ++++++- 5 files changed, 57 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a8c6d3f8f..2e3cd3140 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## [4.1.37] - 2024.1.5 +### Fixed +- Fix get strict methods params for STELLAR network. + ## [4.1.36] - 2024.1.3 ### Fixed - Fix optional params for STELLAR network. diff --git a/package.json b/package.json index 69b919887..9efc2a1b6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@tatumio/tatum", - "version": "4.1.36", + "version": "4.1.37", "description": "Tatum JS SDK", "author": "Tatum", "repository": "https://github.com/tatumio/tatum-js", diff --git a/src/dto/rpc/StellarRpcSuite.ts b/src/dto/rpc/StellarRpcSuite.ts index 7cb7e1354..e61dd59be 100644 --- a/src/dto/rpc/StellarRpcSuite.ts +++ b/src/dto/rpc/StellarRpcSuite.ts @@ -1009,7 +1009,7 @@ export interface GetPaymentsParams extends BaseParams { export interface GetStrictReceivePaymentPathsParams { sourceAccount?: string - sourceAssets?: string + sourceAssets?: string[] destinationAssetType: string destinationAssetIssuer?: string destinationAssetCode?: string @@ -1018,13 +1018,13 @@ export interface GetStrictReceivePaymentPathsParams { export interface GetStrictSendPaymentPathsParams { sourceAccount?: string - sourceAssets?: string + sourceAssets?: string[] sourceAssetType: string sourceAssetIssuer?: string sourceAssetCode?: string sourceAmount: string destinationAccount?: string - destinationAssets?: string + destinationAssets?: string[] } export interface SubmitTransactionParams { diff --git a/src/e2e/rpc/other/tatum.rpc.stellar.spec.ts b/src/e2e/rpc/other/tatum.rpc.stellar.spec.ts index 508e3641d..0c1e35f48 100644 --- a/src/e2e/rpc/other/tatum.rpc.stellar.spec.ts +++ b/src/e2e/rpc/other/tatum.rpc.stellar.spec.ts @@ -49,21 +49,44 @@ describe('Stellar', () => { expect(response).toBeDefined() }) - it('should get strict send', async () => { - const response = await tatum.rpc.getStrictSendPaymentPaths({ - sourceAssetType: 'native', - sourceAmount: '1', - destinationAccount: 'GB3LIKQ6GOJ6D4EYKVS47L2SBY66SJO4MN4CZCMUPNBUJ2L3PF62ECBA', + describe('should get strict send', () => { + it('destinationAccount', async () => { + const response = await tatum.rpc.getStrictSendPaymentPaths({ + sourceAssetType: 'native', + sourceAmount: '1', + destinationAccount: 'GB3LIKQ6GOJ6D4EYKVS47L2SBY66SJO4MN4CZCMUPNBUJ2L3PF62ECBA', + }) + expect(response).toBeDefined() + }) + + it('destinationAssets', async () => { + const response = await tatum.rpc.getStrictSendPaymentPaths({ + sourceAssetType: 'native', + sourceAmount: '1', + sourceAssets: ['USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN'], + destinationAssets: ['USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN'], + }) + expect(response).toBeDefined() }) - expect(response).toBeDefined() }) - it('should get strict receive', async () => { - const response = await tatum.rpc.getStrictReceivePaymentPaths({ - destinationAssetType: 'native', - destinationAmount: '1', - sourceAssets: 'USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN', + describe('should get strict receive', () => { + it('sourceAssets', async () => { + const response = await tatum.rpc.getStrictReceivePaymentPaths({ + destinationAssetType: 'native', + destinationAmount: '1', + sourceAssets: ['USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN'], + }) + expect(response).toBeDefined() + }) + + it('sourceAccount', async () => { + const response = await tatum.rpc.getStrictReceivePaymentPaths({ + destinationAssetType: 'native', + destinationAmount: '1', + sourceAccount: 'GB3LIKQ6GOJ6D4EYKVS47L2SBY66SJO4MN4CZCMUPNBUJ2L3PF62ECBA', + }) + expect(response).toBeDefined() }) - expect(response).toBeDefined() }) }) diff --git a/src/service/rpc/other/AbstractStellarRpc.ts b/src/service/rpc/other/AbstractStellarRpc.ts index 617b2bc14..a50d69730 100644 --- a/src/service/rpc/other/AbstractStellarRpc.ts +++ b/src/service/rpc/other/AbstractStellarRpc.ts @@ -316,16 +316,28 @@ export abstract class AbstractStellarRpc implements StellarRpcSuite { } getStrictReceivePaymentPaths(params: GetStrictReceivePaymentPathsParams): Promise { + const { sourceAssets, ...rest } = params + const sourceAssetsString = sourceAssets?.join(',') return this.sendGet({ path: `/paths/strict-receive`, - queryParams: params as unknown as QueryParams, + queryParams: { + ...rest, + ...(sourceAssetsString && { sourceAssets: sourceAssetsString }), + }, }) } getStrictSendPaymentPaths(params: GetStrictSendPaymentPathsParams): Promise { + const { destinationAssets, sourceAssets, ...rest } = params + const destinationAssetsString = destinationAssets?.join(',') + const sourceAssetsString = sourceAssets?.join(',') return this.sendGet({ path: `/paths/strict-send`, - queryParams: params as unknown as QueryParams, + queryParams: { + ...rest, + ...(destinationAssetsString && { destinationAssets: destinationAssetsString }), + ...(sourceAssetsString && { sourceAssets: sourceAssetsString }), + }, }) }