Skip to content

Commit

Permalink
feat: get order (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
R0bi7 authored Nov 18, 2024
1 parent 87a22a6 commit b4e619e
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion src/services/IntentService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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<T extends ChainConfig>(
txHash: string,
chainConfig: T,
provider: ChainProvider<T["chain"]["type"]>,
): Promise<Result<SwapOrder>> {
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
Expand Down

0 comments on commit b4e619e

Please sign in to comment.