@rhea-finance/cross-chain-aggregation-dex 2.0.7 → 2.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -8
- package/dist/executors/aptos.d.mts +1 -1
- package/dist/executors/aptos.d.ts +1 -1
- package/dist/executors/bitcoin.d.mts +1 -1
- package/dist/executors/bitcoin.d.ts +1 -1
- package/dist/executors/evm.d.mts +1 -1
- package/dist/executors/evm.d.ts +1 -1
- package/dist/executors/near.d.mts +1 -1
- package/dist/executors/near.d.ts +1 -1
- package/dist/executors/solana.d.mts +1 -1
- package/dist/executors/solana.d.ts +1 -1
- package/dist/executors/sui.d.mts +1 -1
- package/dist/executors/sui.d.ts +1 -1
- package/dist/executors/tron.d.mts +1 -1
- package/dist/executors/tron.d.ts +1 -1
- package/dist/executors/zcash.d.mts +1 -1
- package/dist/executors/zcash.d.ts +1 -1
- package/dist/index.d.mts +25 -7
- package/dist/index.d.ts +25 -7
- package/dist/index.js +155 -32
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +150 -33
- package/dist/index.mjs.map +1 -1
- package/dist/{shared-COkGiqaz.d.mts → shared-BWv_QHdw.d.mts} +18 -7
- package/dist/{shared-COkGiqaz.d.ts → shared-BWv_QHdw.d.ts} +18 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -382,7 +382,7 @@ if (result.status === "completed") {
|
|
|
382
382
|
}
|
|
383
383
|
```
|
|
384
384
|
|
|
385
|
-
`"completed"` polls the order-status API
|
|
385
|
+
`"completed"` polls the order-status API after reporting when possible. The SDK prefers the `recordId` returned by `POST /api/swap/report` (same as multi-chain Trade), and only falls back to `orderId`/`router`/`chainId` or source `txHash` when no record id is available. Confidential swaps also require order-status polling when they are same-chain. For confidential Near Intents builds, the SDK uses `deposit.orderId` when present and otherwise uses `deposit.depositAddress` as the status key. If a cross-chain or confidential swap provides none of these identifiers, the SDK throws `INVALID_API_RESPONSE` at the `status` stage instead of treating source-chain confirmation as completion.
|
|
386
386
|
|
|
387
387
|
The default polling interval is 5 seconds. There is no default polling timeout, so polling continues until the order reaches a terminal state or the supplied `AbortSignal` is aborted.
|
|
388
388
|
|
|
@@ -390,28 +390,41 @@ Set `orderPolling.timeoutMs` only when the application needs a time limit. An ex
|
|
|
390
390
|
|
|
391
391
|
### 3.5 Check final delivery status
|
|
392
392
|
|
|
393
|
-
If the swap first returns with `"submitted"`,
|
|
393
|
+
If the swap first returns with `"submitted"`, poll manually with the report record id when available:
|
|
394
394
|
|
|
395
395
|
```ts
|
|
396
|
-
if (result.
|
|
396
|
+
if (result.report?.recordId) {
|
|
397
|
+
const finalStatus = await client.waitForOrder({
|
|
398
|
+
recordId: result.report.recordId,
|
|
399
|
+
intervalMs: 5000,
|
|
400
|
+
timeoutMs: 600000,
|
|
401
|
+
});
|
|
402
|
+
console.log(finalStatus.status);
|
|
403
|
+
} else if (result.orderId) {
|
|
397
404
|
const finalStatus = await client.waitForOrder({
|
|
398
405
|
orderId: result.orderId,
|
|
399
406
|
router: result.router,
|
|
400
407
|
intervalMs: 5000,
|
|
401
408
|
timeoutMs: 600000,
|
|
402
409
|
});
|
|
403
|
-
|
|
404
410
|
console.log(finalStatus.status);
|
|
405
411
|
}
|
|
406
412
|
```
|
|
407
413
|
|
|
414
|
+
For history rows, refresh delivery status with the same record id:
|
|
415
|
+
|
|
416
|
+
```ts
|
|
417
|
+
const status = await client.getHistoryOrderStatus(historyItem);
|
|
418
|
+
```
|
|
419
|
+
|
|
408
420
|
For a single status request:
|
|
409
421
|
|
|
410
422
|
```ts
|
|
411
|
-
const status = await client.getOrderStatus(
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
}
|
|
423
|
+
const status = await client.getOrderStatus(
|
|
424
|
+
result.report?.recordId
|
|
425
|
+
? { recordId: result.report.recordId }
|
|
426
|
+
: { orderId: result.orderId!, router: result.router }
|
|
427
|
+
);
|
|
415
428
|
```
|
|
416
429
|
|
|
417
430
|
Terminal statuses are `completed`, `failed`, `refunded`, and `expired`.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ad as ExecutorErrorAdapter, C as ChainRef, ae as TransactionSubmission, T as TransactionConfirmation, w as ChainExecutor } from '../shared-
|
|
1
|
+
import { ad as ExecutorErrorAdapter, C as ChainRef, ae as TransactionSubmission, T as TransactionConfirmation, w as ChainExecutor } from '../shared-BWv_QHdw.mjs';
|
|
2
2
|
|
|
3
3
|
interface AptosWalletAdapter extends ExecutorErrorAdapter {
|
|
4
4
|
getChain(): ChainRef | Promise<ChainRef>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ad as ExecutorErrorAdapter, C as ChainRef, ae as TransactionSubmission, T as TransactionConfirmation, w as ChainExecutor } from '../shared-
|
|
1
|
+
import { ad as ExecutorErrorAdapter, C as ChainRef, ae as TransactionSubmission, T as TransactionConfirmation, w as ChainExecutor } from '../shared-BWv_QHdw.js';
|
|
2
2
|
|
|
3
3
|
interface AptosWalletAdapter extends ExecutorErrorAdapter {
|
|
4
4
|
getChain(): ChainRef | Promise<ChainRef>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ad as ExecutorErrorAdapter, C as ChainRef, ae as TransactionSubmission, T as TransactionConfirmation, w as ChainExecutor } from '../shared-
|
|
1
|
+
import { ad as ExecutorErrorAdapter, C as ChainRef, ae as TransactionSubmission, T as TransactionConfirmation, w as ChainExecutor } from '../shared-BWv_QHdw.mjs';
|
|
2
2
|
|
|
3
3
|
interface BitcoinWalletAdapter extends ExecutorErrorAdapter {
|
|
4
4
|
getChain(): ChainRef | Promise<ChainRef>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ad as ExecutorErrorAdapter, C as ChainRef, ae as TransactionSubmission, T as TransactionConfirmation, w as ChainExecutor } from '../shared-
|
|
1
|
+
import { ad as ExecutorErrorAdapter, C as ChainRef, ae as TransactionSubmission, T as TransactionConfirmation, w as ChainExecutor } from '../shared-BWv_QHdw.js';
|
|
2
2
|
|
|
3
3
|
interface BitcoinWalletAdapter extends ExecutorErrorAdapter {
|
|
4
4
|
getChain(): ChainRef | Promise<ChainRef>;
|
package/dist/executors/evm.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ad as ExecutorErrorAdapter,
|
|
1
|
+
import { ad as ExecutorErrorAdapter, a4 as EvmTx, ae as TransactionSubmission, a6 as EvmSigningRequest, a5 as EvmApproval, T as TransactionConfirmation, w as ChainExecutor } from '../shared-BWv_QHdw.mjs';
|
|
2
2
|
|
|
3
3
|
interface EvmWalletAdapter extends ExecutorErrorAdapter {
|
|
4
4
|
sendTransaction(tx: EvmTx, options: {
|
package/dist/executors/evm.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ad as ExecutorErrorAdapter,
|
|
1
|
+
import { ad as ExecutorErrorAdapter, a4 as EvmTx, ae as TransactionSubmission, a6 as EvmSigningRequest, a5 as EvmApproval, T as TransactionConfirmation, w as ChainExecutor } from '../shared-BWv_QHdw.js';
|
|
2
2
|
|
|
3
3
|
interface EvmWalletAdapter extends ExecutorErrorAdapter {
|
|
4
4
|
sendTransaction(tx: EvmTx, options: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ad as ExecutorErrorAdapter, C as ChainRef, N as NearTransaction, T as TransactionConfirmation, w as ChainExecutor } from '../shared-
|
|
1
|
+
import { ad as ExecutorErrorAdapter, C as ChainRef, N as NearTransaction, T as TransactionConfirmation, w as ChainExecutor } from '../shared-BWv_QHdw.mjs';
|
|
2
2
|
|
|
3
3
|
interface NearWalletAdapter extends ExecutorErrorAdapter {
|
|
4
4
|
getChain(): ChainRef | Promise<ChainRef>;
|
package/dist/executors/near.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ad as ExecutorErrorAdapter, C as ChainRef, N as NearTransaction, T as TransactionConfirmation, w as ChainExecutor } from '../shared-
|
|
1
|
+
import { ad as ExecutorErrorAdapter, C as ChainRef, N as NearTransaction, T as TransactionConfirmation, w as ChainExecutor } from '../shared-BWv_QHdw.js';
|
|
2
2
|
|
|
3
3
|
interface NearWalletAdapter extends ExecutorErrorAdapter {
|
|
4
4
|
getChain(): ChainRef | Promise<ChainRef>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ad as ExecutorErrorAdapter, C as ChainRef,
|
|
1
|
+
import { ad as ExecutorErrorAdapter, C as ChainRef, a7 as SolanaMetadata, ae as TransactionSubmission, T as TransactionConfirmation, w as ChainExecutor } from '../shared-BWv_QHdw.mjs';
|
|
2
2
|
|
|
3
3
|
interface SolanaWalletAdapter extends ExecutorErrorAdapter {
|
|
4
4
|
getChain(): ChainRef | Promise<ChainRef>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ad as ExecutorErrorAdapter, C as ChainRef,
|
|
1
|
+
import { ad as ExecutorErrorAdapter, C as ChainRef, a7 as SolanaMetadata, ae as TransactionSubmission, T as TransactionConfirmation, w as ChainExecutor } from '../shared-BWv_QHdw.js';
|
|
2
2
|
|
|
3
3
|
interface SolanaWalletAdapter extends ExecutorErrorAdapter {
|
|
4
4
|
getChain(): ChainRef | Promise<ChainRef>;
|
package/dist/executors/sui.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ad as ExecutorErrorAdapter, C as ChainRef, ae as TransactionSubmission, T as TransactionConfirmation, w as ChainExecutor } from '../shared-
|
|
1
|
+
import { ad as ExecutorErrorAdapter, C as ChainRef, ae as TransactionSubmission, T as TransactionConfirmation, w as ChainExecutor } from '../shared-BWv_QHdw.mjs';
|
|
2
2
|
|
|
3
3
|
interface SuiWalletAdapter extends ExecutorErrorAdapter {
|
|
4
4
|
getChain(): ChainRef | Promise<ChainRef>;
|
package/dist/executors/sui.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ad as ExecutorErrorAdapter, C as ChainRef, ae as TransactionSubmission, T as TransactionConfirmation, w as ChainExecutor } from '../shared-
|
|
1
|
+
import { ad as ExecutorErrorAdapter, C as ChainRef, ae as TransactionSubmission, T as TransactionConfirmation, w as ChainExecutor } from '../shared-BWv_QHdw.js';
|
|
2
2
|
|
|
3
3
|
interface SuiWalletAdapter extends ExecutorErrorAdapter {
|
|
4
4
|
getChain(): ChainRef | Promise<ChainRef>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ad as ExecutorErrorAdapter, C as ChainRef, ae as TransactionSubmission, T as TransactionConfirmation, w as ChainExecutor } from '../shared-
|
|
1
|
+
import { ad as ExecutorErrorAdapter, C as ChainRef, ae as TransactionSubmission, T as TransactionConfirmation, w as ChainExecutor } from '../shared-BWv_QHdw.mjs';
|
|
2
2
|
|
|
3
3
|
interface TronWalletAdapter extends ExecutorErrorAdapter {
|
|
4
4
|
getChain(): ChainRef | Promise<ChainRef>;
|
package/dist/executors/tron.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ad as ExecutorErrorAdapter, C as ChainRef, ae as TransactionSubmission, T as TransactionConfirmation, w as ChainExecutor } from '../shared-
|
|
1
|
+
import { ad as ExecutorErrorAdapter, C as ChainRef, ae as TransactionSubmission, T as TransactionConfirmation, w as ChainExecutor } from '../shared-BWv_QHdw.js';
|
|
2
2
|
|
|
3
3
|
interface TronWalletAdapter extends ExecutorErrorAdapter {
|
|
4
4
|
getChain(): ChainRef | Promise<ChainRef>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ad as ExecutorErrorAdapter, C as ChainRef, ae as TransactionSubmission, T as TransactionConfirmation, w as ChainExecutor } from '../shared-
|
|
1
|
+
import { ad as ExecutorErrorAdapter, C as ChainRef, ae as TransactionSubmission, T as TransactionConfirmation, w as ChainExecutor } from '../shared-BWv_QHdw.mjs';
|
|
2
2
|
|
|
3
3
|
interface ZcashWalletAdapter extends ExecutorErrorAdapter {
|
|
4
4
|
getChain(): ChainRef | Promise<ChainRef>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ad as ExecutorErrorAdapter, C as ChainRef, ae as TransactionSubmission, T as TransactionConfirmation, w as ChainExecutor } from '../shared-
|
|
1
|
+
import { ad as ExecutorErrorAdapter, C as ChainRef, ae as TransactionSubmission, T as TransactionConfirmation, w as ChainExecutor } from '../shared-BWv_QHdw.js';
|
|
2
2
|
|
|
3
3
|
interface ZcashWalletAdapter extends ExecutorErrorAdapter {
|
|
4
4
|
getChain(): ChainRef | Promise<ChainRef>;
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as SwapQuoteRequestRaw, a as SwapQuoteDataRaw, b as SwapBuildRequestRaw, c as SwapBuildDataRaw, d as SwapOrderSubmitRequestRaw, e as SwapOrderSubmitDataRaw, f as SwapOrderStatusParamsRaw, g as SwapOrderStatusDataRaw, h as SwapReportRequestRaw, i as SwapReportDataRaw, j as SwapHistoryParamsRaw, k as SwapHistoryDataRaw, l as SwapHistoryAuthChallengeRequestRaw, m as SwapHistoryAuthChallengeRaw, n as SwapHistoryAuthVerifyRequestRaw, o as SwapHistoryAuthTokenRaw, p as SwapFromTokensDataRaw, q as SwapCrossChainToTokensDataRaw, Q as QuoteRequest, r as Quote, s as SwapMcaPayloadRaw, W as WaitMode, O as OrderPollingOptions, t as SwapLifecycleEvent, u as SwapExecutionResult, C as ChainRef, A as AssetRef, B as BaseUnitAmount, v as SwapHistoryRecordRaw, w as ChainExecutor, E as ExecutorRegistry, x as SwapBuild, y as ExecuteSwapInput, z as SwapInput, D as
|
|
2
|
-
export { ac as BuildContext,
|
|
1
|
+
import { S as SwapQuoteRequestRaw, a as SwapQuoteDataRaw, b as SwapBuildRequestRaw, c as SwapBuildDataRaw, d as SwapOrderSubmitRequestRaw, e as SwapOrderSubmitDataRaw, f as SwapOrderStatusParamsRaw, g as SwapOrderStatusDataRaw, h as SwapReportRequestRaw, i as SwapReportDataRaw, j as SwapHistoryParamsRaw, k as SwapHistoryDataRaw, l as SwapHistoryAuthChallengeRequestRaw, m as SwapHistoryAuthChallengeRaw, n as SwapHistoryAuthVerifyRequestRaw, o as SwapHistoryAuthTokenRaw, p as SwapFromTokensDataRaw, q as SwapCrossChainToTokensDataRaw, Q as QuoteRequest, r as Quote, s as SwapMcaPayloadRaw, W as WaitMode, O as OrderPollingOptions, t as SwapLifecycleEvent, u as SwapExecutionResult, C as ChainRef, A as AssetRef, B as BaseUnitAmount, v as SwapHistoryRecordRaw, w as ChainExecutor, E as ExecutorRegistry, x as SwapBuild, y as ExecuteSwapInput, z as SwapInput, D as OrderReference, F as OrderStatusResult, G as WaitForOrderInput, H as SwapHistoryAuthProofRaw, N as NearTransaction, I as SwapMcaRelayerRequestRaw } from './shared-BWv_QHdw.mjs';
|
|
2
|
+
export { ac as BuildContext, _ as ChainExecutionResult, a8 as DepositInfo, a5 as EvmApproval, a6 as EvmSigningRequest, a4 as EvmTx, $ as ExecutionContext, a1 as ExecutorIdentityProvider, a2 as ExecutorMessageSigner, a0 as MessageSignOptions, Y as OrderStatus, ab as RouteSummary, X as SignRequestPreview, a7 as SolanaMetadata, J as SwapApiResponse, K as SwapApiTokenMetaRaw, R as SwapBuildApproveRaw, aa as SwapExecution, U as SwapHistoryWalletChainFamilyRaw, M as SwapMcaSignerPayloadRaw, a9 as SwapReportContext, P as SwapSigningRequestRaw, L as SwapTokenListRowRaw, V as SwapWarning, T as TransactionConfirmation, a3 as assertBaseUnitAmount, Z as normalizeOrderStatus } from './shared-BWv_QHdw.mjs';
|
|
3
3
|
|
|
4
4
|
type SwapErrorCode = "HTTP_ERROR" | "API_ERROR" | "RATE_LIMITED" | "AUTH_FAILED" | "REQUEST_ABORTED" | "REQUEST_TIMEOUT" | "INVALID_REQUEST" | "INVALID_API_RESPONSE" | "QUOTE_EXPIRED" | "ROUTE_NOT_FOUND" | "EXECUTOR_NOT_FOUND" | "UNSUPPORTED_CHAIN" | "CHAIN_MISMATCH" | "INVALID_TRANSACTION" | "USER_REJECTED" | "INSUFFICIENT_BALANCE" | "APPROVAL_FAILED" | "SIGNING_FAILED" | "BROADCAST_FAILED" | "ORDER_SUBMIT_FAILED" | "ORDER_TIMEOUT" | "REPORT_FAILED";
|
|
5
5
|
type SwapErrorStage = "quote" | "build" | "approve" | "sign" | "broadcast" | "submit" | "report" | "status" | "tokens" | "history";
|
|
@@ -268,10 +268,10 @@ declare class SwapClient {
|
|
|
268
268
|
executeSwap(input: ExecuteSwapInput): Promise<SwapExecutionResult>;
|
|
269
269
|
swap(input: McaSwapInput): Promise<McaSwapResult>;
|
|
270
270
|
swap(input: SwapInput): Promise<SwapExecutionResult>;
|
|
271
|
-
getOrderStatus(input: {
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
271
|
+
getOrderStatus(input: OrderReference & {
|
|
272
|
+
signal?: AbortSignal;
|
|
273
|
+
}): Promise<OrderStatusResult>;
|
|
274
|
+
getHistoryOrderStatus(item: Pick<SwapHistoryItem, "id" | "orderId" | "router" | "sourceTxHash">, options?: {
|
|
275
275
|
signal?: AbortSignal;
|
|
276
276
|
}): Promise<OrderStatusResult>;
|
|
277
277
|
waitForOrder(input: WaitForOrderInput): Promise<OrderStatusResult>;
|
|
@@ -375,7 +375,25 @@ interface BuildMcaWithdrawRelayerRequestInput {
|
|
|
375
375
|
}
|
|
376
376
|
declare function buildMcaWithdrawRelayerRequest(input: BuildMcaWithdrawRelayerRequestInput): SwapBuildRequestRaw;
|
|
377
377
|
|
|
378
|
+
declare function resolveSwapReportRecordId(reportData: unknown): string;
|
|
379
|
+
type OrderStatusLookup = OrderReference;
|
|
380
|
+
/** Matches multi-chain-lending `resolveSwapOrderStatusQuery` query shape. */
|
|
381
|
+
declare function buildOrderStatusQuery(params: SwapOrderStatusParamsRaw): Record<string, string | number>;
|
|
382
|
+
declare function resolveOrderStatusLookup(input: {
|
|
383
|
+
recordId?: string | number;
|
|
384
|
+
orderId?: string;
|
|
385
|
+
txHash?: string;
|
|
386
|
+
router?: string;
|
|
387
|
+
chainId?: string | number;
|
|
388
|
+
}): OrderReference | undefined;
|
|
389
|
+
declare function assertOrderStatusParams(params: SwapOrderStatusParamsRaw | OrderReference): OrderReference;
|
|
390
|
+
declare function orderStatusParamsFromHistoryItem(item: Pick<SwapHistoryItem, "id" | "orderId" | "router" | "sourceTxHash">): OrderReference;
|
|
391
|
+
declare function resolveSourceTxHash(input: {
|
|
392
|
+
txHash?: string;
|
|
393
|
+
txHashes?: string[];
|
|
394
|
+
}): string | undefined;
|
|
395
|
+
|
|
378
396
|
declare function parseUnits(value: string, decimals: number): BaseUnitAmount;
|
|
379
397
|
declare function formatUnits(value: BaseUnitAmount, decimals: number): string;
|
|
380
398
|
|
|
381
|
-
export { ApiClient, type ApiClientConfig, type ApiRequestOptions, AssetRef, BaseUnitAmount, type BuildMcaWithdrawRelayerRequestInput, type BuildNearMcaWithdrawTransactionsInput, type BuildSwapInput, ChainExecutor, ChainRef, DEFAULT_MCA_SIGNER_PRIORITY, ExecuteSwapInput, ExecutorRegistry, type ExtractMcaWithdrawDepositAddressInput, type HistoryRequest, type HistoryStatus, type McaDepositCollateral, type McaDepositQuote, type McaDepositQuoteRequest, type McaFlow, type McaQuote, type McaQuoteRequest, type McaSignerChain, type McaSignerIdentity, type McaSwapInput, type McaSwapResult, type McaWalletDescriptor, type McaWalletKey, type McaWithdrawCollateral, type McaWithdrawNearQuote, type McaWithdrawQuoteRequest, type McaWithdrawRelayerQuote, NearTransaction, OrderPollingOptions, OrderStatusResult, Quote, QuoteRequest, type ResolveMcaRequiredCollateralDecreaseInput, type ResolveMcaWithdrawPolicyInput, type RetryConfig, type SdkLogEntry, type SdkLogLevel, type SdkLogger, SwapBuild, SwapBuildDataRaw, SwapBuildRequestRaw, SwapClient, type SwapClientConfig, SwapCrossChainToTokensDataRaw, type SwapErrorCode, type SwapErrorStage, SwapExecutionResult, SwapFromTokensDataRaw, SwapHistoryAuthChallengeRaw, SwapHistoryAuthChallengeRequestRaw, SwapHistoryAuthProofRaw, SwapHistoryAuthTokenRaw, SwapHistoryAuthVerifyRequestRaw, SwapHistoryDataRaw, type SwapHistoryItem, type SwapHistoryPage, SwapHistoryParamsRaw, SwapHistoryRecordRaw, SwapInput, SwapLifecycleEvent, SwapMcaPayloadRaw, SwapMcaRelayerRequestRaw, SwapOrderStatusDataRaw, SwapOrderStatusParamsRaw, SwapOrderSubmitDataRaw, SwapOrderSubmitRequestRaw, SwapQuoteDataRaw, SwapQuoteRequestRaw, SwapReportDataRaw, SwapReportRequestRaw, SwapSdkError, type SwapSdkErrorOptions, type SwapTokenListItem, type TokenListRequest, WaitForOrderInput, WaitMode, asSwapSdkError, buildMcaWithdrawRelayerRequest, buildNearMcaWithdrawTransactions, createExecutionId, extractMcaWithdrawBusiness, extractMcaWithdrawDepositAddress, extractMcaWithdrawSignerWallet, formatMcaWallet, formatUnits, fromApiChain, isSameMcaSignerIdentity, normalizeBuild, normalizeCrossChainToTokenList, normalizeFromTokenList, normalizeHistory, normalizeHistoryStatus, normalizeMcaQuote, normalizeQuote, parseUnits, resolveMcaDecreaseCollateral, resolveMcaRequiredCollateralDecrease, resolveMcaWithdrawPolicy, selectMcaSigner, serializeMcaQuoteRequest, serializeQuoteRequest, toApiAssetAddress, toApiChain };
|
|
399
|
+
export { ApiClient, type ApiClientConfig, type ApiRequestOptions, AssetRef, BaseUnitAmount, type BuildMcaWithdrawRelayerRequestInput, type BuildNearMcaWithdrawTransactionsInput, type BuildSwapInput, ChainExecutor, ChainRef, DEFAULT_MCA_SIGNER_PRIORITY, ExecuteSwapInput, ExecutorRegistry, type ExtractMcaWithdrawDepositAddressInput, type HistoryRequest, type HistoryStatus, type McaDepositCollateral, type McaDepositQuote, type McaDepositQuoteRequest, type McaFlow, type McaQuote, type McaQuoteRequest, type McaSignerChain, type McaSignerIdentity, type McaSwapInput, type McaSwapResult, type McaWalletDescriptor, type McaWalletKey, type McaWithdrawCollateral, type McaWithdrawNearQuote, type McaWithdrawQuoteRequest, type McaWithdrawRelayerQuote, NearTransaction, OrderPollingOptions, OrderReference, type OrderStatusLookup, OrderStatusResult, Quote, QuoteRequest, type ResolveMcaRequiredCollateralDecreaseInput, type ResolveMcaWithdrawPolicyInput, type RetryConfig, type SdkLogEntry, type SdkLogLevel, type SdkLogger, SwapBuild, SwapBuildDataRaw, SwapBuildRequestRaw, SwapClient, type SwapClientConfig, SwapCrossChainToTokensDataRaw, type SwapErrorCode, type SwapErrorStage, SwapExecutionResult, SwapFromTokensDataRaw, SwapHistoryAuthChallengeRaw, SwapHistoryAuthChallengeRequestRaw, SwapHistoryAuthProofRaw, SwapHistoryAuthTokenRaw, SwapHistoryAuthVerifyRequestRaw, SwapHistoryDataRaw, type SwapHistoryItem, type SwapHistoryPage, SwapHistoryParamsRaw, SwapHistoryRecordRaw, SwapInput, SwapLifecycleEvent, SwapMcaPayloadRaw, SwapMcaRelayerRequestRaw, SwapOrderStatusDataRaw, SwapOrderStatusParamsRaw, SwapOrderSubmitDataRaw, SwapOrderSubmitRequestRaw, SwapQuoteDataRaw, SwapQuoteRequestRaw, SwapReportDataRaw, SwapReportRequestRaw, SwapSdkError, type SwapSdkErrorOptions, type SwapTokenListItem, type TokenListRequest, WaitForOrderInput, WaitMode, asSwapSdkError, assertOrderStatusParams, buildMcaWithdrawRelayerRequest, buildNearMcaWithdrawTransactions, buildOrderStatusQuery, createExecutionId, extractMcaWithdrawBusiness, extractMcaWithdrawDepositAddress, extractMcaWithdrawSignerWallet, formatMcaWallet, formatUnits, fromApiChain, isSameMcaSignerIdentity, normalizeBuild, normalizeCrossChainToTokenList, normalizeFromTokenList, normalizeHistory, normalizeHistoryStatus, normalizeMcaQuote, normalizeQuote, orderStatusParamsFromHistoryItem, parseUnits, resolveMcaDecreaseCollateral, resolveMcaRequiredCollateralDecrease, resolveMcaWithdrawPolicy, resolveOrderStatusLookup, resolveSourceTxHash, resolveSwapReportRecordId, selectMcaSigner, serializeMcaQuoteRequest, serializeQuoteRequest, toApiAssetAddress, toApiChain };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as SwapQuoteRequestRaw, a as SwapQuoteDataRaw, b as SwapBuildRequestRaw, c as SwapBuildDataRaw, d as SwapOrderSubmitRequestRaw, e as SwapOrderSubmitDataRaw, f as SwapOrderStatusParamsRaw, g as SwapOrderStatusDataRaw, h as SwapReportRequestRaw, i as SwapReportDataRaw, j as SwapHistoryParamsRaw, k as SwapHistoryDataRaw, l as SwapHistoryAuthChallengeRequestRaw, m as SwapHistoryAuthChallengeRaw, n as SwapHistoryAuthVerifyRequestRaw, o as SwapHistoryAuthTokenRaw, p as SwapFromTokensDataRaw, q as SwapCrossChainToTokensDataRaw, Q as QuoteRequest, r as Quote, s as SwapMcaPayloadRaw, W as WaitMode, O as OrderPollingOptions, t as SwapLifecycleEvent, u as SwapExecutionResult, C as ChainRef, A as AssetRef, B as BaseUnitAmount, v as SwapHistoryRecordRaw, w as ChainExecutor, E as ExecutorRegistry, x as SwapBuild, y as ExecuteSwapInput, z as SwapInput, D as
|
|
2
|
-
export { ac as BuildContext,
|
|
1
|
+
import { S as SwapQuoteRequestRaw, a as SwapQuoteDataRaw, b as SwapBuildRequestRaw, c as SwapBuildDataRaw, d as SwapOrderSubmitRequestRaw, e as SwapOrderSubmitDataRaw, f as SwapOrderStatusParamsRaw, g as SwapOrderStatusDataRaw, h as SwapReportRequestRaw, i as SwapReportDataRaw, j as SwapHistoryParamsRaw, k as SwapHistoryDataRaw, l as SwapHistoryAuthChallengeRequestRaw, m as SwapHistoryAuthChallengeRaw, n as SwapHistoryAuthVerifyRequestRaw, o as SwapHistoryAuthTokenRaw, p as SwapFromTokensDataRaw, q as SwapCrossChainToTokensDataRaw, Q as QuoteRequest, r as Quote, s as SwapMcaPayloadRaw, W as WaitMode, O as OrderPollingOptions, t as SwapLifecycleEvent, u as SwapExecutionResult, C as ChainRef, A as AssetRef, B as BaseUnitAmount, v as SwapHistoryRecordRaw, w as ChainExecutor, E as ExecutorRegistry, x as SwapBuild, y as ExecuteSwapInput, z as SwapInput, D as OrderReference, F as OrderStatusResult, G as WaitForOrderInput, H as SwapHistoryAuthProofRaw, N as NearTransaction, I as SwapMcaRelayerRequestRaw } from './shared-BWv_QHdw.js';
|
|
2
|
+
export { ac as BuildContext, _ as ChainExecutionResult, a8 as DepositInfo, a5 as EvmApproval, a6 as EvmSigningRequest, a4 as EvmTx, $ as ExecutionContext, a1 as ExecutorIdentityProvider, a2 as ExecutorMessageSigner, a0 as MessageSignOptions, Y as OrderStatus, ab as RouteSummary, X as SignRequestPreview, a7 as SolanaMetadata, J as SwapApiResponse, K as SwapApiTokenMetaRaw, R as SwapBuildApproveRaw, aa as SwapExecution, U as SwapHistoryWalletChainFamilyRaw, M as SwapMcaSignerPayloadRaw, a9 as SwapReportContext, P as SwapSigningRequestRaw, L as SwapTokenListRowRaw, V as SwapWarning, T as TransactionConfirmation, a3 as assertBaseUnitAmount, Z as normalizeOrderStatus } from './shared-BWv_QHdw.js';
|
|
3
3
|
|
|
4
4
|
type SwapErrorCode = "HTTP_ERROR" | "API_ERROR" | "RATE_LIMITED" | "AUTH_FAILED" | "REQUEST_ABORTED" | "REQUEST_TIMEOUT" | "INVALID_REQUEST" | "INVALID_API_RESPONSE" | "QUOTE_EXPIRED" | "ROUTE_NOT_FOUND" | "EXECUTOR_NOT_FOUND" | "UNSUPPORTED_CHAIN" | "CHAIN_MISMATCH" | "INVALID_TRANSACTION" | "USER_REJECTED" | "INSUFFICIENT_BALANCE" | "APPROVAL_FAILED" | "SIGNING_FAILED" | "BROADCAST_FAILED" | "ORDER_SUBMIT_FAILED" | "ORDER_TIMEOUT" | "REPORT_FAILED";
|
|
5
5
|
type SwapErrorStage = "quote" | "build" | "approve" | "sign" | "broadcast" | "submit" | "report" | "status" | "tokens" | "history";
|
|
@@ -268,10 +268,10 @@ declare class SwapClient {
|
|
|
268
268
|
executeSwap(input: ExecuteSwapInput): Promise<SwapExecutionResult>;
|
|
269
269
|
swap(input: McaSwapInput): Promise<McaSwapResult>;
|
|
270
270
|
swap(input: SwapInput): Promise<SwapExecutionResult>;
|
|
271
|
-
getOrderStatus(input: {
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
271
|
+
getOrderStatus(input: OrderReference & {
|
|
272
|
+
signal?: AbortSignal;
|
|
273
|
+
}): Promise<OrderStatusResult>;
|
|
274
|
+
getHistoryOrderStatus(item: Pick<SwapHistoryItem, "id" | "orderId" | "router" | "sourceTxHash">, options?: {
|
|
275
275
|
signal?: AbortSignal;
|
|
276
276
|
}): Promise<OrderStatusResult>;
|
|
277
277
|
waitForOrder(input: WaitForOrderInput): Promise<OrderStatusResult>;
|
|
@@ -375,7 +375,25 @@ interface BuildMcaWithdrawRelayerRequestInput {
|
|
|
375
375
|
}
|
|
376
376
|
declare function buildMcaWithdrawRelayerRequest(input: BuildMcaWithdrawRelayerRequestInput): SwapBuildRequestRaw;
|
|
377
377
|
|
|
378
|
+
declare function resolveSwapReportRecordId(reportData: unknown): string;
|
|
379
|
+
type OrderStatusLookup = OrderReference;
|
|
380
|
+
/** Matches multi-chain-lending `resolveSwapOrderStatusQuery` query shape. */
|
|
381
|
+
declare function buildOrderStatusQuery(params: SwapOrderStatusParamsRaw): Record<string, string | number>;
|
|
382
|
+
declare function resolveOrderStatusLookup(input: {
|
|
383
|
+
recordId?: string | number;
|
|
384
|
+
orderId?: string;
|
|
385
|
+
txHash?: string;
|
|
386
|
+
router?: string;
|
|
387
|
+
chainId?: string | number;
|
|
388
|
+
}): OrderReference | undefined;
|
|
389
|
+
declare function assertOrderStatusParams(params: SwapOrderStatusParamsRaw | OrderReference): OrderReference;
|
|
390
|
+
declare function orderStatusParamsFromHistoryItem(item: Pick<SwapHistoryItem, "id" | "orderId" | "router" | "sourceTxHash">): OrderReference;
|
|
391
|
+
declare function resolveSourceTxHash(input: {
|
|
392
|
+
txHash?: string;
|
|
393
|
+
txHashes?: string[];
|
|
394
|
+
}): string | undefined;
|
|
395
|
+
|
|
378
396
|
declare function parseUnits(value: string, decimals: number): BaseUnitAmount;
|
|
379
397
|
declare function formatUnits(value: BaseUnitAmount, decimals: number): string;
|
|
380
398
|
|
|
381
|
-
export { ApiClient, type ApiClientConfig, type ApiRequestOptions, AssetRef, BaseUnitAmount, type BuildMcaWithdrawRelayerRequestInput, type BuildNearMcaWithdrawTransactionsInput, type BuildSwapInput, ChainExecutor, ChainRef, DEFAULT_MCA_SIGNER_PRIORITY, ExecuteSwapInput, ExecutorRegistry, type ExtractMcaWithdrawDepositAddressInput, type HistoryRequest, type HistoryStatus, type McaDepositCollateral, type McaDepositQuote, type McaDepositQuoteRequest, type McaFlow, type McaQuote, type McaQuoteRequest, type McaSignerChain, type McaSignerIdentity, type McaSwapInput, type McaSwapResult, type McaWalletDescriptor, type McaWalletKey, type McaWithdrawCollateral, type McaWithdrawNearQuote, type McaWithdrawQuoteRequest, type McaWithdrawRelayerQuote, NearTransaction, OrderPollingOptions, OrderStatusResult, Quote, QuoteRequest, type ResolveMcaRequiredCollateralDecreaseInput, type ResolveMcaWithdrawPolicyInput, type RetryConfig, type SdkLogEntry, type SdkLogLevel, type SdkLogger, SwapBuild, SwapBuildDataRaw, SwapBuildRequestRaw, SwapClient, type SwapClientConfig, SwapCrossChainToTokensDataRaw, type SwapErrorCode, type SwapErrorStage, SwapExecutionResult, SwapFromTokensDataRaw, SwapHistoryAuthChallengeRaw, SwapHistoryAuthChallengeRequestRaw, SwapHistoryAuthProofRaw, SwapHistoryAuthTokenRaw, SwapHistoryAuthVerifyRequestRaw, SwapHistoryDataRaw, type SwapHistoryItem, type SwapHistoryPage, SwapHistoryParamsRaw, SwapHistoryRecordRaw, SwapInput, SwapLifecycleEvent, SwapMcaPayloadRaw, SwapMcaRelayerRequestRaw, SwapOrderStatusDataRaw, SwapOrderStatusParamsRaw, SwapOrderSubmitDataRaw, SwapOrderSubmitRequestRaw, SwapQuoteDataRaw, SwapQuoteRequestRaw, SwapReportDataRaw, SwapReportRequestRaw, SwapSdkError, type SwapSdkErrorOptions, type SwapTokenListItem, type TokenListRequest, WaitForOrderInput, WaitMode, asSwapSdkError, buildMcaWithdrawRelayerRequest, buildNearMcaWithdrawTransactions, createExecutionId, extractMcaWithdrawBusiness, extractMcaWithdrawDepositAddress, extractMcaWithdrawSignerWallet, formatMcaWallet, formatUnits, fromApiChain, isSameMcaSignerIdentity, normalizeBuild, normalizeCrossChainToTokenList, normalizeFromTokenList, normalizeHistory, normalizeHistoryStatus, normalizeMcaQuote, normalizeQuote, parseUnits, resolveMcaDecreaseCollateral, resolveMcaRequiredCollateralDecrease, resolveMcaWithdrawPolicy, selectMcaSigner, serializeMcaQuoteRequest, serializeQuoteRequest, toApiAssetAddress, toApiChain };
|
|
399
|
+
export { ApiClient, type ApiClientConfig, type ApiRequestOptions, AssetRef, BaseUnitAmount, type BuildMcaWithdrawRelayerRequestInput, type BuildNearMcaWithdrawTransactionsInput, type BuildSwapInput, ChainExecutor, ChainRef, DEFAULT_MCA_SIGNER_PRIORITY, ExecuteSwapInput, ExecutorRegistry, type ExtractMcaWithdrawDepositAddressInput, type HistoryRequest, type HistoryStatus, type McaDepositCollateral, type McaDepositQuote, type McaDepositQuoteRequest, type McaFlow, type McaQuote, type McaQuoteRequest, type McaSignerChain, type McaSignerIdentity, type McaSwapInput, type McaSwapResult, type McaWalletDescriptor, type McaWalletKey, type McaWithdrawCollateral, type McaWithdrawNearQuote, type McaWithdrawQuoteRequest, type McaWithdrawRelayerQuote, NearTransaction, OrderPollingOptions, OrderReference, type OrderStatusLookup, OrderStatusResult, Quote, QuoteRequest, type ResolveMcaRequiredCollateralDecreaseInput, type ResolveMcaWithdrawPolicyInput, type RetryConfig, type SdkLogEntry, type SdkLogLevel, type SdkLogger, SwapBuild, SwapBuildDataRaw, SwapBuildRequestRaw, SwapClient, type SwapClientConfig, SwapCrossChainToTokensDataRaw, type SwapErrorCode, type SwapErrorStage, SwapExecutionResult, SwapFromTokensDataRaw, SwapHistoryAuthChallengeRaw, SwapHistoryAuthChallengeRequestRaw, SwapHistoryAuthProofRaw, SwapHistoryAuthTokenRaw, SwapHistoryAuthVerifyRequestRaw, SwapHistoryDataRaw, type SwapHistoryItem, type SwapHistoryPage, SwapHistoryParamsRaw, SwapHistoryRecordRaw, SwapInput, SwapLifecycleEvent, SwapMcaPayloadRaw, SwapMcaRelayerRequestRaw, SwapOrderStatusDataRaw, SwapOrderStatusParamsRaw, SwapOrderSubmitDataRaw, SwapOrderSubmitRequestRaw, SwapQuoteDataRaw, SwapQuoteRequestRaw, SwapReportDataRaw, SwapReportRequestRaw, SwapSdkError, type SwapSdkErrorOptions, type SwapTokenListItem, type TokenListRequest, WaitForOrderInput, WaitMode, asSwapSdkError, assertOrderStatusParams, buildMcaWithdrawRelayerRequest, buildNearMcaWithdrawTransactions, buildOrderStatusQuery, createExecutionId, extractMcaWithdrawBusiness, extractMcaWithdrawDepositAddress, extractMcaWithdrawSignerWallet, formatMcaWallet, formatUnits, fromApiChain, isSameMcaSignerIdentity, normalizeBuild, normalizeCrossChainToTokenList, normalizeFromTokenList, normalizeHistory, normalizeHistoryStatus, normalizeMcaQuote, normalizeQuote, orderStatusParamsFromHistoryItem, parseUnits, resolveMcaDecreaseCollateral, resolveMcaRequiredCollateralDecrease, resolveMcaWithdrawPolicy, resolveOrderStatusLookup, resolveSourceTxHash, resolveSwapReportRecordId, selectMcaSigner, serializeMcaQuoteRequest, serializeQuoteRequest, toApiAssetAddress, toApiChain };
|
package/dist/index.js
CHANGED
|
@@ -28,6 +28,79 @@ function asSwapSdkError(error, stage) {
|
|
|
28
28
|
return new SwapSdkError("API_ERROR", stage, message, { cause: error });
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
// src/utils/orderStatus.ts
|
|
32
|
+
function resolveSwapReportRecordId(reportData) {
|
|
33
|
+
if (!reportData || typeof reportData !== "object") return "";
|
|
34
|
+
const id = reportData.id;
|
|
35
|
+
return id === void 0 || id === null ? "" : String(id).trim();
|
|
36
|
+
}
|
|
37
|
+
function buildOrderStatusQuery(params) {
|
|
38
|
+
const normalizedRecordId = String(params.recordId ?? "").trim();
|
|
39
|
+
if (normalizedRecordId) {
|
|
40
|
+
return { recordId: normalizedRecordId };
|
|
41
|
+
}
|
|
42
|
+
const query = {};
|
|
43
|
+
const orderId = params.orderId?.trim();
|
|
44
|
+
const txHash = params.txHash?.trim();
|
|
45
|
+
if (orderId) {
|
|
46
|
+
query.orderId = orderId;
|
|
47
|
+
} else if (txHash) {
|
|
48
|
+
query.txHash = txHash;
|
|
49
|
+
}
|
|
50
|
+
const router = params.router?.trim();
|
|
51
|
+
if (router) query.router = router;
|
|
52
|
+
const chainId = params.chainId;
|
|
53
|
+
if (chainId !== void 0 && chainId !== null && String(chainId).trim() !== "") {
|
|
54
|
+
query.chainId = chainId;
|
|
55
|
+
}
|
|
56
|
+
return query;
|
|
57
|
+
}
|
|
58
|
+
function resolveOrderStatusLookup(input) {
|
|
59
|
+
const recordId = String(input.recordId ?? "").trim();
|
|
60
|
+
if (recordId) {
|
|
61
|
+
return { recordId };
|
|
62
|
+
}
|
|
63
|
+
const router = input.router?.trim();
|
|
64
|
+
const orderId = input.orderId?.trim();
|
|
65
|
+
const txHash = input.txHash?.trim();
|
|
66
|
+
const statusKey = orderId || txHash;
|
|
67
|
+
if (!statusKey || !router) return void 0;
|
|
68
|
+
const chainId = input.chainId !== void 0 && input.chainId !== null && String(input.chainId).trim() !== "" ? String(input.chainId).trim() : void 0;
|
|
69
|
+
return {
|
|
70
|
+
...orderId ? { orderId } : { txHash },
|
|
71
|
+
router,
|
|
72
|
+
...chainId ? { chainId } : {}
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function assertOrderStatusParams(params) {
|
|
76
|
+
const lookup = resolveOrderStatusLookup(params);
|
|
77
|
+
if (!lookup) {
|
|
78
|
+
throw new SwapSdkError(
|
|
79
|
+
"INVALID_REQUEST",
|
|
80
|
+
"status",
|
|
81
|
+
"Order status requires recordId, or orderId/txHash with router"
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
return lookup;
|
|
85
|
+
}
|
|
86
|
+
function orderStatusParamsFromHistoryItem(item) {
|
|
87
|
+
const recordId = String(item.id ?? "").trim();
|
|
88
|
+
if (recordId) {
|
|
89
|
+
return { recordId };
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
...item.orderId ? { orderId: item.orderId } : {},
|
|
93
|
+
...item.sourceTxHash ? { txHash: item.sourceTxHash } : {},
|
|
94
|
+
...item.router ? { router: item.router } : {}
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
function resolveSourceTxHash(input) {
|
|
98
|
+
const direct = input.txHash?.trim();
|
|
99
|
+
if (direct) return direct;
|
|
100
|
+
const last = input.txHashes?.[input.txHashes.length - 1]?.trim();
|
|
101
|
+
return last || void 0;
|
|
102
|
+
}
|
|
103
|
+
|
|
31
104
|
// src/api/ApiClient.ts
|
|
32
105
|
var DEFAULT_RETRY = {
|
|
33
106
|
maxRetries: 2,
|
|
@@ -72,15 +145,26 @@ var ApiClient = class {
|
|
|
72
145
|
});
|
|
73
146
|
}
|
|
74
147
|
getOrderStatus(params, options = {}) {
|
|
148
|
+
const query = buildOrderStatusQuery(params);
|
|
149
|
+
if (!query.recordId && !query.orderId && !query.txHash) {
|
|
150
|
+
throw new SwapSdkError(
|
|
151
|
+
"INVALID_REQUEST",
|
|
152
|
+
"status",
|
|
153
|
+
"Order status requires recordId, or orderId/txHash with router"
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
if (!query.recordId && !query.router) {
|
|
157
|
+
throw new SwapSdkError(
|
|
158
|
+
"INVALID_REQUEST",
|
|
159
|
+
"status",
|
|
160
|
+
"Order status requires router when recordId is absent"
|
|
161
|
+
);
|
|
162
|
+
}
|
|
75
163
|
return this.request("/api/swap/order-status", "status", {
|
|
76
164
|
...options,
|
|
77
165
|
method: "GET",
|
|
78
166
|
retryableOperation: true,
|
|
79
|
-
query
|
|
80
|
-
orderId: params.orderId,
|
|
81
|
-
router: params.router,
|
|
82
|
-
chainId: params.chainId
|
|
83
|
-
}
|
|
167
|
+
query
|
|
84
168
|
});
|
|
85
169
|
}
|
|
86
170
|
report(body, options = {}) {
|
|
@@ -1981,9 +2065,13 @@ var McaSwapService = class {
|
|
|
1981
2065
|
onEvent: input.onEvent
|
|
1982
2066
|
});
|
|
1983
2067
|
if (input.quote.executionMode === "withdraw-near" && input.waitFor === "completed") {
|
|
1984
|
-
const
|
|
2068
|
+
const statusLookup = resolveOrderStatusLookup({
|
|
2069
|
+
recordId: result.report?.recordId,
|
|
1985
2070
|
orderId: nearStatusKey,
|
|
1986
|
-
router: input.quote.route.router
|
|
2071
|
+
router: input.quote.route.router
|
|
2072
|
+
}) ?? { orderId: nearStatusKey, router: input.quote.route.router };
|
|
2073
|
+
const status = await this.client.waitForOrder({
|
|
2074
|
+
...statusLookup,
|
|
1987
2075
|
...input.orderPolling,
|
|
1988
2076
|
signal: input.signal
|
|
1989
2077
|
});
|
|
@@ -2209,10 +2297,17 @@ var McaSwapService = class {
|
|
|
2209
2297
|
raw
|
|
2210
2298
|
};
|
|
2211
2299
|
emit({ type: "submitted", executionId, orderId });
|
|
2300
|
+
let reportRecordId;
|
|
2212
2301
|
if (this.reportMode === "auto") {
|
|
2213
2302
|
try {
|
|
2214
|
-
await this.client.reportRaw(reportRequest, {
|
|
2215
|
-
|
|
2303
|
+
const reportData = await this.client.reportRaw(reportRequest, {
|
|
2304
|
+
signal: input.signal
|
|
2305
|
+
});
|
|
2306
|
+
reportRecordId = resolveSwapReportRecordId(reportData) || void 0;
|
|
2307
|
+
result.report = {
|
|
2308
|
+
status: "reported",
|
|
2309
|
+
...reportRecordId ? { recordId: reportRecordId } : {}
|
|
2310
|
+
};
|
|
2216
2311
|
} catch (error) {
|
|
2217
2312
|
const warning = {
|
|
2218
2313
|
code: "REPORT_FAILED",
|
|
@@ -2224,9 +2319,13 @@ var McaSwapService = class {
|
|
|
2224
2319
|
}
|
|
2225
2320
|
}
|
|
2226
2321
|
if (input.waitFor === "completed") {
|
|
2227
|
-
const
|
|
2322
|
+
const statusLookup = resolveOrderStatusLookup({
|
|
2323
|
+
recordId: reportRecordId ?? result.report?.recordId,
|
|
2228
2324
|
orderId,
|
|
2229
|
-
router
|
|
2325
|
+
router
|
|
2326
|
+
}) ?? { orderId, router };
|
|
2327
|
+
const status = await this.client.waitForOrder({
|
|
2328
|
+
...statusLookup,
|
|
2230
2329
|
...input.orderPolling,
|
|
2231
2330
|
signal: input.signal
|
|
2232
2331
|
});
|
|
@@ -2504,10 +2603,17 @@ var SwapClient = class {
|
|
|
2504
2603
|
if (reportRequest) {
|
|
2505
2604
|
this.reportRequests.set(build.executionId, reportRequest);
|
|
2506
2605
|
}
|
|
2606
|
+
let reportRecordId;
|
|
2507
2607
|
if (this.reportMode === "auto" && reportRequest) {
|
|
2508
2608
|
try {
|
|
2509
|
-
await this.api.report(reportRequest, {
|
|
2510
|
-
|
|
2609
|
+
const reportData = await this.api.report(reportRequest, {
|
|
2610
|
+
signal: input.signal
|
|
2611
|
+
});
|
|
2612
|
+
reportRecordId = resolveSwapReportRecordId(reportData) || void 0;
|
|
2613
|
+
result.report = {
|
|
2614
|
+
status: "reported",
|
|
2615
|
+
...reportRecordId ? { recordId: reportRecordId } : {}
|
|
2616
|
+
};
|
|
2511
2617
|
} catch (error) {
|
|
2512
2618
|
const warning = {
|
|
2513
2619
|
code: "REPORT_FAILED",
|
|
@@ -2520,25 +2626,29 @@ var SwapClient = class {
|
|
|
2520
2626
|
}
|
|
2521
2627
|
const waitsForCompletion = (input.waitFor ?? "submitted") === "completed";
|
|
2522
2628
|
const requiresOrderStatus = build.isCrossChain || build.request?.confidentiality === "basic";
|
|
2523
|
-
|
|
2629
|
+
const statusLookup = resolveOrderStatusLookup({
|
|
2630
|
+
recordId: reportRecordId ?? result.report?.recordId,
|
|
2631
|
+
orderId,
|
|
2632
|
+
txHash: resolveSourceTxHash(chainResult),
|
|
2633
|
+
router: orderRouter ?? build.router,
|
|
2634
|
+
chainId: orderChainId
|
|
2635
|
+
});
|
|
2636
|
+
if (waitsForCompletion && requiresOrderStatus && !statusLookup) {
|
|
2524
2637
|
throw new SwapSdkError(
|
|
2525
2638
|
"INVALID_API_RESPONSE",
|
|
2526
2639
|
"status",
|
|
2527
|
-
"Swap submitted, but
|
|
2640
|
+
"Swap submitted, but no report record id, status key, or source transaction hash is available",
|
|
2528
2641
|
{
|
|
2529
2642
|
details: {
|
|
2530
2643
|
executionId: build.executionId,
|
|
2531
|
-
...result.txHash ? { txHash: result.txHash } : {},
|
|
2532
2644
|
router: orderRouter ?? build.router
|
|
2533
2645
|
}
|
|
2534
2646
|
}
|
|
2535
2647
|
);
|
|
2536
2648
|
}
|
|
2537
|
-
if (waitsForCompletion &&
|
|
2649
|
+
if (waitsForCompletion && statusLookup) {
|
|
2538
2650
|
const status = await this.waitForOrder({
|
|
2539
|
-
|
|
2540
|
-
router: orderRouter ?? build.router,
|
|
2541
|
-
chainId: orderChainId,
|
|
2651
|
+
...statusLookup,
|
|
2542
2652
|
...input.orderPolling,
|
|
2543
2653
|
signal: input.signal
|
|
2544
2654
|
});
|
|
@@ -2576,21 +2686,22 @@ var SwapClient = class {
|
|
|
2576
2686
|
});
|
|
2577
2687
|
}
|
|
2578
2688
|
async getOrderStatus(input) {
|
|
2579
|
-
const
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
router: input.router,
|
|
2583
|
-
chainId: input.chainId
|
|
2584
|
-
},
|
|
2585
|
-
{ signal: input.signal }
|
|
2586
|
-
);
|
|
2689
|
+
const { signal, ...reference } = input;
|
|
2690
|
+
const lookup = assertOrderStatusParams(reference);
|
|
2691
|
+
const raw = await this.api.getOrderStatus(lookup, { signal });
|
|
2587
2692
|
return {
|
|
2588
|
-
|
|
2589
|
-
router: input.router,
|
|
2693
|
+
...lookup,
|
|
2694
|
+
...lookup.router || input.router ? { router: lookup.router ?? input.router } : {},
|
|
2590
2695
|
status: normalizeOrderStatus(raw),
|
|
2591
2696
|
raw
|
|
2592
2697
|
};
|
|
2593
2698
|
}
|
|
2699
|
+
async getHistoryOrderStatus(item, options = {}) {
|
|
2700
|
+
return this.getOrderStatus({
|
|
2701
|
+
...orderStatusParamsFromHistoryItem(item),
|
|
2702
|
+
signal: options.signal
|
|
2703
|
+
});
|
|
2704
|
+
}
|
|
2594
2705
|
async waitForOrder(input) {
|
|
2595
2706
|
const intervalMs = input.intervalMs ?? 5e3;
|
|
2596
2707
|
const timeoutMs = input.timeoutMs;
|
|
@@ -2627,7 +2738,7 @@ var SwapClient = class {
|
|
|
2627
2738
|
reportRaw(request, options = {}) {
|
|
2628
2739
|
return this.api.report(request, options);
|
|
2629
2740
|
}
|
|
2630
|
-
report(result) {
|
|
2741
|
+
async report(result) {
|
|
2631
2742
|
const managedReport = this.managedSwapFlow.reportIfManaged(result);
|
|
2632
2743
|
if (managedReport) return managedReport;
|
|
2633
2744
|
const request = this.reportRequests.get(result.executionId);
|
|
@@ -2638,7 +2749,13 @@ var SwapClient = class {
|
|
|
2638
2749
|
`No report context for execution ${result.executionId}`
|
|
2639
2750
|
);
|
|
2640
2751
|
}
|
|
2641
|
-
|
|
2752
|
+
const raw = await this.api.report(request);
|
|
2753
|
+
const recordId = resolveSwapReportRecordId(raw) || void 0;
|
|
2754
|
+
result.report = {
|
|
2755
|
+
status: "reported",
|
|
2756
|
+
...recordId ? { recordId } : {}
|
|
2757
|
+
};
|
|
2758
|
+
return raw;
|
|
2642
2759
|
}
|
|
2643
2760
|
retryReport(result) {
|
|
2644
2761
|
return this.report(result);
|
|
@@ -2800,8 +2917,10 @@ exports.SwapClient = SwapClient;
|
|
|
2800
2917
|
exports.SwapSdkError = SwapSdkError;
|
|
2801
2918
|
exports.asSwapSdkError = asSwapSdkError;
|
|
2802
2919
|
exports.assertBaseUnitAmount = assertBaseUnitAmount;
|
|
2920
|
+
exports.assertOrderStatusParams = assertOrderStatusParams;
|
|
2803
2921
|
exports.buildMcaWithdrawRelayerRequest = buildMcaWithdrawRelayerRequest;
|
|
2804
2922
|
exports.buildNearMcaWithdrawTransactions = buildNearMcaWithdrawTransactions;
|
|
2923
|
+
exports.buildOrderStatusQuery = buildOrderStatusQuery;
|
|
2805
2924
|
exports.createExecutionId = createExecutionId;
|
|
2806
2925
|
exports.extractMcaWithdrawBusiness = extractMcaWithdrawBusiness;
|
|
2807
2926
|
exports.extractMcaWithdrawDepositAddress = extractMcaWithdrawDepositAddress;
|
|
@@ -2818,10 +2937,14 @@ exports.normalizeHistoryStatus = normalizeHistoryStatus;
|
|
|
2818
2937
|
exports.normalizeMcaQuote = normalizeMcaQuote;
|
|
2819
2938
|
exports.normalizeOrderStatus = normalizeOrderStatus;
|
|
2820
2939
|
exports.normalizeQuote = normalizeQuote;
|
|
2940
|
+
exports.orderStatusParamsFromHistoryItem = orderStatusParamsFromHistoryItem;
|
|
2821
2941
|
exports.parseUnits = parseUnits;
|
|
2822
2942
|
exports.resolveMcaDecreaseCollateral = resolveMcaDecreaseCollateral;
|
|
2823
2943
|
exports.resolveMcaRequiredCollateralDecrease = resolveMcaRequiredCollateralDecrease;
|
|
2824
2944
|
exports.resolveMcaWithdrawPolicy = resolveMcaWithdrawPolicy;
|
|
2945
|
+
exports.resolveOrderStatusLookup = resolveOrderStatusLookup;
|
|
2946
|
+
exports.resolveSourceTxHash = resolveSourceTxHash;
|
|
2947
|
+
exports.resolveSwapReportRecordId = resolveSwapReportRecordId;
|
|
2825
2948
|
exports.selectMcaSigner = selectMcaSigner;
|
|
2826
2949
|
exports.serializeMcaQuoteRequest = serializeMcaQuoteRequest;
|
|
2827
2950
|
exports.serializeQuoteRequest = serializeQuoteRequest;
|