-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
74 changed files
with
1,757 additions
and
462 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 46 additions & 13 deletions
59
...ures/cross-chain/calculation-manager/providers/cbridge/cbridge-cross-chain-api-service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,64 @@ | ||
// @ts-ignore | ||
import { getRequestOptions } from 'cbridge-revert-manager'; | ||
import { Injector } from 'src/core/injector/injector'; | ||
import { CbridgeEstimateAmountRequest } from 'src/features/cross-chain/calculation-manager/providers/cbridge/models/cbridge-estimate-amount-request'; | ||
import { CbridgeEstimateAmountResponse } from 'src/features/cross-chain/calculation-manager/providers/cbridge/models/cbridge-estimate-amount-response'; | ||
import { CbridgeStatusResponse } from 'src/features/cross-chain/calculation-manager/providers/cbridge/models/cbridge-status-response'; | ||
import { CbridgeTransferConfigsResponse } from 'src/features/cross-chain/calculation-manager/providers/cbridge/models/cbridge-transfer-configs-response'; | ||
|
||
export class CbridgeCrossChainApiService { | ||
public static readonly apiEndpoint = 'https://cbridge-prod2.celer.app/v2/'; | ||
private static readonly apiEndpoint = 'https://cbridge-prod2.celer.app/v2/'; | ||
|
||
public static async getTransferConfigs(): Promise<CbridgeTransferConfigsResponse> { | ||
private static readonly testnetApiEndpoint = 'https://cbridge-v2-test.celer.network/v2/'; | ||
|
||
public static async getTransferConfigs(options: { | ||
useTestnet: boolean; | ||
}): Promise<CbridgeTransferConfigsResponse> { | ||
const apiUrl = options.useTestnet | ||
? CbridgeCrossChainApiService.testnetApiEndpoint | ||
: CbridgeCrossChainApiService.apiEndpoint; | ||
return Injector.httpClient.get<CbridgeTransferConfigsResponse>( | ||
`${CbridgeCrossChainApiService.apiEndpoint}getTransferConfigs` | ||
`${apiUrl}getTransferConfigs` | ||
); | ||
} | ||
|
||
public static async fetchEstimateAmount( | ||
requestParams: CbridgeEstimateAmountRequest | ||
requestParams: CbridgeEstimateAmountRequest, | ||
options: { useTestnet: boolean } | ||
): Promise<CbridgeEstimateAmountResponse> { | ||
return Injector.httpClient.get<CbridgeEstimateAmountResponse>( | ||
`${CbridgeCrossChainApiService.apiEndpoint}estimateAmt`, | ||
{ params: { ...requestParams } } | ||
); | ||
const apiUrl = options.useTestnet | ||
? CbridgeCrossChainApiService.testnetApiEndpoint | ||
: CbridgeCrossChainApiService.apiEndpoint; | ||
return Injector.httpClient.get<CbridgeEstimateAmountResponse>(`${apiUrl}estimateAmt`, { | ||
params: { ...requestParams } | ||
}); | ||
} | ||
|
||
public static async fetchTradeStatus(transferId: string): Promise<CbridgeStatusResponse> { | ||
return Injector.httpClient.post<CbridgeStatusResponse>( | ||
`${CbridgeCrossChainApiService.apiEndpoint}getTransferStatus`, | ||
{ transfer_id: transferId } | ||
); | ||
public static async fetchTradeStatus( | ||
transferId: string, | ||
options: { | ||
useTestnet: boolean; | ||
} | ||
): Promise<CbridgeStatusResponse> { | ||
const apiUrl = options.useTestnet | ||
? CbridgeCrossChainApiService.testnetApiEndpoint | ||
: CbridgeCrossChainApiService.apiEndpoint; | ||
return Injector.httpClient.post<CbridgeStatusResponse>(`${apiUrl}getTransferStatus`, { | ||
transfer_id: transferId | ||
}); | ||
} | ||
|
||
public static async withdrawLiquidity( | ||
transferId: string, | ||
estimatedReceivedAmt: string, | ||
options: { | ||
useTestnet: boolean; | ||
} | ||
): Promise<void> { | ||
const apiUrl = options.useTestnet | ||
? CbridgeCrossChainApiService.testnetApiEndpoint | ||
: CbridgeCrossChainApiService.apiEndpoint; | ||
const body: object = await getRequestOptions(transferId, estimatedReceivedAmt); | ||
return Injector.httpClient.post(`${apiUrl}withdrawLiquidity`, body); | ||
} | ||
} |
Oops, something went wrong.