Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ensofinance/sdk",
"version": "2.2.1",
"version": "2.3.0",
"license": "MIT",
"description": "SDK for interacting with the Enso API",
"author": "Enso Finance",
Expand Down
38 changes: 36 additions & 2 deletions src/client.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import axios, { AxiosError, AxiosInstance, AxiosRequestConfig } from "axios";
import axios, { AxiosInstance, AxiosRequestConfig } from "axios";
import {
ActionData,
ApproveData,
ApproveParams,
BalanceParams,
BridgeStatusData,
BridgeStatusParams,
BundleAction,
BundleData,
BundleParams,
Expand Down Expand Up @@ -663,7 +665,9 @@ export class EnsoClient {
* }
* ]);
*/
public async getCcipRouter(params: CcipRouterParams): Promise<CcipRouterData> {
public async getCcipRouter(
params: CcipRouterParams,
): Promise<CcipRouterData> {
const url = "/ccip/router";

return this.request<CcipRouterData>({
Expand All @@ -673,6 +677,36 @@ export class EnsoClient {
});
}

/**
* Checks the status of a bridge transaction.
*
* Returns the current status of a cross-chain bridge transaction for the given protocol.
* Supports any bridge protocol that has a status endpoint (e.g. layerzero, ccip, relay).
*
* @param {BridgeStatusParams} params - Parameters for the bridge status check
* @returns {Promise<BridgeStatusData>} Bridge transaction status data
* @throws {Error} If the API request fails
*
* @example
* const status = await client.getBridgeStatus({
* bridgeProtocol: 'layerzero',
* chainId: 1,
* txHash: '0x123...'
* });
*/
public async getBridgeStatus(
params: BridgeStatusParams,
): Promise<BridgeStatusData> {
const { bridgeProtocol, ...queryParams } = params;
const url = `/${bridgeProtocol}/bridge/check`;

return this.request<BridgeStatusData>({
method: "GET",
url,
params: queryParams,
});
}

/**
* Validates route actions to ensure refundReceiver is set when destinationChainId is provided.
* @private
Expand Down
9 changes: 7 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import {
ApproveData,
ApproveParams,
BalanceParams,
BridgeStatusData,
BridgeStatusParams,
BundleAction,
BundleData,
BundleParams,
Expand All @@ -30,7 +32,7 @@ import {
StandardData,
TokenData,
TokenParams,
WalletBalance
WalletBalance,
} from "./types/types";

import { BridgeProtocol } from "./types/actions";
Expand All @@ -42,6 +44,8 @@ export type {
ApproveParams,
BalanceParams,
BridgeProtocol,
BridgeStatusData,
BridgeStatusParams,
BundleAction,
BundleData,
BundleParams,
Expand Down Expand Up @@ -70,4 +74,5 @@ export type {
WalletBalance,
};

export { EnsoClient } from "./client";
export { EnsoClient } from "./client";

30 changes: 30 additions & 0 deletions src/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,36 @@ interface PaginatedResult {
meta: PaginationMeta;
}

/**
* Parameters for checking bridge transaction status.
*/
export type BridgeStatusParams = {
/** Bridge protocol identifier (e.g. "layerzero", "stargate", "ccip", "relay") */
bridgeProtocol: string;
/** Chain ID of the source transaction */
chainId: number | string;
/** Transaction hash on the source chain */
txHash: string;
};

/**
* Bridge transaction status response.
*/
export type BridgeStatusData = {
/** Source chain ID */
sourceChainId: number;
/** Source transaction hash */
sourceTxHash: string;
/** Destination chain ID */
destinationChainId?: number;
/** Destination transaction hash */
destinationTxHash?: string;
/** Bridge status */
status: "pending" | "inflight" | "delivered" | "failed" | "unknown";
/** Error message if failed */
error?: string;
};

export type LayerZeroPoolParams = {
chainId: number | string;
token: Address;
Expand Down
Loading