From b4e619ef690c950738786dcc6e3008e448429a1c Mon Sep 17 00:00:00 2001 From: Robi Date: Mon, 18 Nov 2024 10:43:34 +0100 Subject: [PATCH] feat: get order (#19) --- src/services/IntentService.ts | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/src/services/IntentService.ts b/src/services/IntentService.ts index 96eca6f..7d67f64 100644 --- a/src/services/IntentService.ts +++ b/src/services/IntentService.ts @@ -10,10 +10,18 @@ import { type IntentStatusRequest, type IntentStatusResponse, type GetChainConfigType, + type ChainConfig, } from "../types.js" import { chainConfig, supportedChains } from "../constants.js" import { isEvmChainConfig, isSuiChainConfig } from "../guards.js" -import { EvmProvider, SuiProvider, type GetChainProviderType } from "../entities/index.js" +import { + EvmProvider, + SuiProvider, + type GetChainProviderType, + SwapOrder, + type ChainProviderType, + type ChainProvider, +} from "../entities/index.js" import { EvmIntentService } from "./EvmIntentService.js" import { SuiIntentService } from "./SuiIntentService.js" import { SolverApiService } from "./SolverApiService.js" @@ -227,6 +235,29 @@ export class IntentService { } } + /** + * Retrieve Intent order + * @param txHash - Transaction hash + * @param chainConfig - chain config (EVM or SUI) + * @param provider - provider (EVM or SUI) + */ + static async getOrder( + txHash: string, + chainConfig: T, + provider: ChainProvider, + ): Promise> { + if (provider instanceof EvmProvider && isEvmChainConfig(chainConfig)) { + return EvmIntentService.getOrder(txHash as Address, chainConfig, provider) + } else if (provider instanceof SuiProvider && isSuiChainConfig(chainConfig)) { + return SuiIntentService.getOrder(txHash, chainConfig, provider) + } else { + return { + ok: false, + error: new Error("Provider and chainConfig miss match"), + } + } + } + /** * Get current intent status * @example