Skip to content

Commit

Permalink
ALL-3288 Fix Stellar get strict (#1043)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hathoriel authored Jan 5, 2024
1 parent 052f13b commit 99129cc
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 18 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
6 changes: 3 additions & 3 deletions src/dto/rpc/StellarRpcSuite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1009,7 +1009,7 @@ export interface GetPaymentsParams extends BaseParams {

export interface GetStrictReceivePaymentPathsParams {
sourceAccount?: string
sourceAssets?: string
sourceAssets?: string[]
destinationAssetType: string
destinationAssetIssuer?: string
destinationAssetCode?: string
Expand All @@ -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 {
Expand Down
47 changes: 35 additions & 12 deletions src/e2e/rpc/other/tatum.rpc.stellar.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})
})
16 changes: 14 additions & 2 deletions src/service/rpc/other/AbstractStellarRpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,16 +316,28 @@ export abstract class AbstractStellarRpc implements StellarRpcSuite {
}

getStrictReceivePaymentPaths(params: GetStrictReceivePaymentPathsParams): Promise<Path> {
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<Path> {
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 }),
},
})
}

Expand Down

0 comments on commit 99129cc

Please sign in to comment.