Skip to content

Commit

Permalink
ALL-3288 Fix Stellar optional params (#1041)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hathoriel authored Jan 3, 2024
1 parent 721c3df commit 052f13b
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 32 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.36] - 2024.1.3
### Fixed
- Fix optional params for STELLAR network.

## [4.1.35] - 2024.1.3
### Added
- Added RPC support for the STELLAR network. Users can now make Stellar RPC calls using the `Network.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.35",
"version": "4.1.36",
"description": "Tatum JS SDK",
"author": "Tatum",
"repository": "https://github.com/tatumio/tatum-js",
Expand Down
28 changes: 14 additions & 14 deletions src/dto/rpc/StellarRpcSuite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1012,17 +1012,17 @@ export interface GetStrictReceivePaymentPathsParams {
sourceAssets?: string
destinationAssetType: string
destinationAssetIssuer?: string
destinationAssetCode: string
destinationAssetCode?: string
destinationAmount: string
}

export interface GetStrictSendPaymentPathsParams {
sourceAccount?: string
sourceAssets?: string
sourceAssetType?: string
sourceAssetType: string
sourceAssetIssuer?: string
sourceAssetCode?: string
sourceAmount?: string
sourceAmount: string
destinationAccount?: string
destinationAssets?: string
}
Expand All @@ -1045,7 +1045,7 @@ export interface GetTransactionsParams extends BaseParams {
}

export interface StellarRpcSuite {
getAccounts(params: GetAccountsParams): Promise<Links & Account>
getAccounts(params?: GetAccountsParams): Promise<Links & Account>
getAccount(params: GetAccountParams): Promise<Links & Account>
getAccountTransactions(params: GetAccountTransactionsParams): Promise<Transaction>
getAccountOperations(params: GetOperationsByAccountIdParams): Promise<OperationResponse>
Expand All @@ -1054,14 +1054,14 @@ export interface StellarRpcSuite {
getAccountOffers(params: GetOffersByAccountIdParams): Promise<OfferResponse>
getAccountTrades(params: GetAccountTradesParams): Promise<Trade>
getAccountData(params: GetAccountDataParams): Promise<{ value: string }>
getAssets(params: GetAssetsParams): Promise<Links & Asset>
getClaimableBalances(params: GetClaimableBalancesParams): Promise<ClaimableBalance>
getAssets(params?: GetAssetsParams): Promise<Links & Asset>
getClaimableBalances(params?: GetClaimableBalancesParams): Promise<ClaimableBalance>
getClaimableBalance(params: GetClaimableBalanceParams): Promise<RecordClaimableBalance>
getClaimableTransactions(params: GetClaimableTransactionsParams): Promise<Transaction>
getClaimableOperations(params: GetClaimableOperationsParams): Promise<Links & OperationResponse>
getEffects(params: GetEffectsParams): Promise<Effect>
getEffects(params?: GetEffectsParams): Promise<Effect>
getFeeStats(): Promise<FeeStats>
getLiquidityPools(params: GetLiquidityPoolsParams): Promise<LiquidityPools>
getLiquidityPools(params?: GetLiquidityPoolsParams): Promise<LiquidityPools>
getLiquidityPool(params: GetLiquidityPoolParams): Promise<RecordLiquidityPool>
getLiquidityPoolEffects(params: GetLiquidityPoolEffectsParams): Promise<Effect>
getLiquidityPoolTrades(params: GetLiquidityPoolTradesParams): Promise<Trade>
Expand All @@ -1072,21 +1072,21 @@ export interface StellarRpcSuite {
getLedgerPayments(params: GetLedgerPaymentsParams): Promise<Links & Payment>
getLedgerOperations(params: GetLedgerOperationsParams): Promise<Operation>
getLedgerEffects(params: GetLedgerEffectsParams): Promise<Array<Links & Effect>>
getLedgers(params: BaseParams): Promise<Ledger>
getOffers(params: GetOffersParams): Promise<Offer>
getLedgers(params?: BaseParams): Promise<Ledger>
getOffers(params?: GetOffersParams): Promise<Offer>
getOffer(params: GetOfferParams): Promise<Ledger>
getOfferTrades(params: GetOfferTradesParams): Promise<Trade>
getOrderBook(params: GetOrderBookParams): Promise<Order>
getTradeAggregations(params: GetTradeAggregationsParams): Promise<TradeAggregation>
getTrades(params: GetTradesParams): Promise<Links & Trade>
getTrades(params?: GetTradesParams): Promise<Links & Trade>
getTransaction(params: GetTransactionParams): Promise<Transaction>
getTransactionOperations(params: GetTransactionOperationsParams): Promise<Operation>
getTransactionEffects(params: GetTransactionEffectsParams): Promise<Links & Effect>
getTransactions(params: GetTransactionsParams): Promise<Links & Transaction>
getTransactions(params?: GetTransactionsParams): Promise<Links & Transaction>
getOperation(params: GetOperationParams): Promise<Operation>
getOperationEffects(params: GetOperationEffectsParams): Promise<Links & Effect>
getOperations(params: GetOperationsParams): Promise<Operation>
getPayments(params: GetPaymentsParams): Promise<Links & OperationResponse>
getOperations(params?: GetOperationsParams): Promise<Operation>
getPayments(params?: GetPaymentsParams): Promise<Links & OperationResponse>
getStrictReceivePaymentPaths(params: GetStrictReceivePaymentPathsParams): Promise<Path>
getStrictSendPaymentPaths(params: GetStrictSendPaymentPathsParams): Promise<Path>
submitTransaction(params: SubmitTransactionParams): Promise<SubmitTransaction>
Expand Down
18 changes: 18 additions & 0 deletions src/e2e/rpc/other/tatum.rpc.stellar.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,22 @@ describe('Stellar', () => {
const response = await tatum.rpc.getOffers({})
expect(response).toBeDefined()
})

it('should get strict send', async () => {
const response = await tatum.rpc.getStrictSendPaymentPaths({
sourceAssetType: 'native',
sourceAmount: '1',
destinationAccount: 'GB3LIKQ6GOJ6D4EYKVS47L2SBY66SJO4MN4CZCMUPNBUJ2L3PF62ECBA',
})
expect(response).toBeDefined()
})

it('should get strict receive', async () => {
const response = await tatum.rpc.getStrictReceivePaymentPaths({
destinationAssetType: 'native',
destinationAmount: '1',
sourceAssets: 'USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN',
})
expect(response).toBeDefined()
})
})
32 changes: 15 additions & 17 deletions src/service/rpc/other/AbstractStellarRpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export abstract class AbstractStellarRpc implements StellarRpcSuite {
return this.post(post)
}

getAccounts(params: GetAccountsParams): Promise<Links & Account> {
getAccounts(params?: GetAccountsParams): Promise<Links & Account> {
return this.sendGet({ path: '/accounts', queryParams: params as QueryParams })
}

Expand Down Expand Up @@ -159,11 +159,11 @@ export abstract class AbstractStellarRpc implements StellarRpcSuite {
return this.sendGet({ path: `/accounts/${accountId}/data/${rest.key}` })
}

getAssets(params: GetAssetsParams): Promise<Links & Asset> {
getAssets(params?: GetAssetsParams): Promise<Links & Asset> {
return this.sendGet({ path: '/assets', queryParams: params as QueryParams })
}

getClaimableBalances(params: GetClaimableBalancesParams): Promise<ClaimableBalance> {
getClaimableBalances(params?: GetClaimableBalancesParams): Promise<ClaimableBalance> {
return this.sendGet({ path: '/claimable_balances', queryParams: params as QueryParams })
}

Expand All @@ -181,15 +181,15 @@ export abstract class AbstractStellarRpc implements StellarRpcSuite {
return this.sendGet({ path: `/claimable_balances/${claimableBalanceId}/operations`, queryParams: rest })
}

getEffects(params: GetEffectsParams): Promise<Effect> {
getEffects(params?: GetEffectsParams): Promise<Effect> {
return this.sendGet({ path: '/effects', queryParams: params as QueryParams })
}

getFeeStats(): Promise<FeeStats> {
return this.sendGet({ path: '/fee_stats' })
}

getLiquidityPools(params: GetLiquidityPoolsParams): Promise<LiquidityPools> {
getLiquidityPools(params?: GetLiquidityPoolsParams): Promise<LiquidityPools> {
return this.sendGet({ path: '/liquidity_pools', queryParams: params as QueryParams })
}

Expand Down Expand Up @@ -243,11 +243,11 @@ export abstract class AbstractStellarRpc implements StellarRpcSuite {
return this.sendGet({ path: `/ledgers/${sequence}/effects`, queryParams: rest })
}

getLedgers(params: BaseParams): Promise<Ledger> {
getLedgers(params?: BaseParams): Promise<Ledger> {
return this.sendGet({ path: '/ledgers', queryParams: params as QueryParams })
}

getOffers(params: GetOffersParams): Promise<Offer> {
getOffers(params?: GetOffersParams): Promise<Offer> {
return this.sendGet({ path: '/offers', queryParams: params as QueryParams })
}

Expand All @@ -274,7 +274,7 @@ export abstract class AbstractStellarRpc implements StellarRpcSuite {
})
}

getTrades(params: GetTradesParams): Promise<Links & Trade> {
getTrades(params?: GetTradesParams): Promise<Links & Trade> {
return this.sendGet({ path: '/trades', queryParams: params as QueryParams })
}

Expand All @@ -293,7 +293,7 @@ export abstract class AbstractStellarRpc implements StellarRpcSuite {
return this.sendGet({ path: `/transactions/${transactionHash}/effects`, queryParams: rest })
}

getTransactions(params: GetTransactionsParams): Promise<Links & Transaction> {
getTransactions(params?: GetTransactionsParams): Promise<Links & Transaction> {
return this.sendGet({ path: '/transactions', queryParams: params as QueryParams })
}

Expand All @@ -307,27 +307,25 @@ export abstract class AbstractStellarRpc implements StellarRpcSuite {
return this.sendGet({ path: `/operations/${id}/effects`, queryParams: rest })
}

getOperations(params: GetOperationsParams): Promise<Operation> {
getOperations(params?: GetOperationsParams): Promise<Operation> {
return this.sendGet({ path: '/operations', queryParams: params as QueryParams })
}

getPayments(params: GetPaymentsParams): Promise<Links & OperationResponse> {
getPayments(params?: GetPaymentsParams): Promise<Links & OperationResponse> {
return this.sendGet({ path: '/payments', queryParams: params as QueryParams })
}

getStrictReceivePaymentPaths(params: GetStrictReceivePaymentPathsParams): Promise<Path> {
const { destinationAssetType, destinationAmount, ...rest } = params
return this.sendGet({
path: `/paths/strict-receive${destinationAssetType}${destinationAmount}`,
queryParams: rest,
path: `/paths/strict-receive`,
queryParams: params as unknown as QueryParams,
})
}

getStrictSendPaymentPaths(params: GetStrictSendPaymentPathsParams): Promise<Path> {
const { sourceAssetType, sourceAmount, ...rest } = params
return this.sendGet({
path: `/paths/strict-send${sourceAssetType}${sourceAmount}`,
queryParams: rest,
path: `/paths/strict-send`,
queryParams: params as unknown as QueryParams,
})
}

Expand Down

0 comments on commit 052f13b

Please sign in to comment.