@rhea-finance/cross-chain-aggregation-dex 2.0.7 → 2.0.9
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 +22 -9
- 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 +170 -36
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +165 -37
- package/dist/index.mjs.map +1 -1
- package/dist/{shared-COkGiqaz.d.mts → shared-DpC8G2U4.d.mts} +22 -9
- package/dist/{shared-COkGiqaz.d.ts → shared-DpC8G2U4.d.ts} +22 -9
- 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`.
|
|
@@ -802,7 +815,7 @@ await client.verifyHistoryAuthChallenge(rawVerifyRequest);
|
|
|
802
815
|
await client.getHistoryRaw(rawHistoryRequest);
|
|
803
816
|
```
|
|
804
817
|
|
|
805
|
-
The default reporting mode is `reportMode: "auto"`. If a swap succeeds but reporting fails, `result.report.status` is `"failed"` and a warning is emitted. The SDK does not throw a misleading swap failure. For manual reporting:
|
|
818
|
+
The default reporting mode is `reportMode: "auto"`. If a swap succeeds but reporting fails, `result.report.status` is `"failed"` and a warning is emitted. The SDK does not throw a misleading swap failure. When `waitFor: "completed"` requires order-status polling, the SDK still calls `POST /api/swap/report` first (even in `reportMode: "manual"`) so it can query status by the returned record id. For other manual reporting flows:
|
|
806
819
|
|
|
807
820
|
```ts
|
|
808
821
|
const client = new SwapClient({
|
|
@@ -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-DpC8G2U4.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-DpC8G2U4.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-DpC8G2U4.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-DpC8G2U4.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-DpC8G2U4.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-DpC8G2U4.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-DpC8G2U4.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-DpC8G2U4.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-DpC8G2U4.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-DpC8G2U4.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-DpC8G2U4.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-DpC8G2U4.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-DpC8G2U4.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-DpC8G2U4.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-DpC8G2U4.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-DpC8G2U4.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-DpC8G2U4.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-DpC8G2U4.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-DpC8G2U4.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-DpC8G2U4.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,86 @@ 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 record = reportData;
|
|
35
|
+
for (const key of ["id", "recordId", "record_id"]) {
|
|
36
|
+
const value = record[key];
|
|
37
|
+
if (value !== void 0 && value !== null) {
|
|
38
|
+
const normalized = String(value).trim();
|
|
39
|
+
if (normalized) return normalized;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return "";
|
|
43
|
+
}
|
|
44
|
+
function buildOrderStatusQuery(params) {
|
|
45
|
+
const normalizedRecordId = String(params.recordId ?? "").trim();
|
|
46
|
+
if (normalizedRecordId) {
|
|
47
|
+
return { recordId: normalizedRecordId };
|
|
48
|
+
}
|
|
49
|
+
const query = {};
|
|
50
|
+
const orderId = params.orderId?.trim();
|
|
51
|
+
const txHash = params.txHash?.trim();
|
|
52
|
+
if (orderId) {
|
|
53
|
+
query.orderId = orderId;
|
|
54
|
+
} else if (txHash) {
|
|
55
|
+
query.txHash = txHash;
|
|
56
|
+
}
|
|
57
|
+
const router = params.router?.trim();
|
|
58
|
+
if (router) query.router = router;
|
|
59
|
+
const chainId = params.chainId;
|
|
60
|
+
if (chainId !== void 0 && chainId !== null && String(chainId).trim() !== "") {
|
|
61
|
+
query.chainId = chainId;
|
|
62
|
+
}
|
|
63
|
+
return query;
|
|
64
|
+
}
|
|
65
|
+
function resolveOrderStatusLookup(input) {
|
|
66
|
+
const recordId = String(input.recordId ?? "").trim();
|
|
67
|
+
if (recordId) {
|
|
68
|
+
return { recordId };
|
|
69
|
+
}
|
|
70
|
+
const router = input.router?.trim();
|
|
71
|
+
const orderId = input.orderId?.trim();
|
|
72
|
+
const txHash = input.txHash?.trim();
|
|
73
|
+
const statusKey = orderId || txHash;
|
|
74
|
+
if (!statusKey || !router) return void 0;
|
|
75
|
+
const chainId = input.chainId !== void 0 && input.chainId !== null && String(input.chainId).trim() !== "" ? String(input.chainId).trim() : void 0;
|
|
76
|
+
return {
|
|
77
|
+
...orderId ? { orderId } : { txHash },
|
|
78
|
+
router,
|
|
79
|
+
...chainId ? { chainId } : {}
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
function assertOrderStatusParams(params) {
|
|
83
|
+
const lookup = resolveOrderStatusLookup(params);
|
|
84
|
+
if (!lookup) {
|
|
85
|
+
throw new SwapSdkError(
|
|
86
|
+
"INVALID_REQUEST",
|
|
87
|
+
"status",
|
|
88
|
+
"Order status requires recordId, or orderId/txHash with router"
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
return lookup;
|
|
92
|
+
}
|
|
93
|
+
function orderStatusParamsFromHistoryItem(item) {
|
|
94
|
+
const recordId = String(item.id ?? "").trim();
|
|
95
|
+
if (recordId) {
|
|
96
|
+
return { recordId };
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
...item.orderId ? { orderId: item.orderId } : {},
|
|
100
|
+
...item.sourceTxHash ? { txHash: item.sourceTxHash } : {},
|
|
101
|
+
...item.router ? { router: item.router } : {}
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
function resolveSourceTxHash(input) {
|
|
105
|
+
const direct = input.txHash?.trim();
|
|
106
|
+
if (direct) return direct;
|
|
107
|
+
const last = input.txHashes?.[input.txHashes.length - 1]?.trim();
|
|
108
|
+
return last || void 0;
|
|
109
|
+
}
|
|
110
|
+
|
|
31
111
|
// src/api/ApiClient.ts
|
|
32
112
|
var DEFAULT_RETRY = {
|
|
33
113
|
maxRetries: 2,
|
|
@@ -72,15 +152,26 @@ var ApiClient = class {
|
|
|
72
152
|
});
|
|
73
153
|
}
|
|
74
154
|
getOrderStatus(params, options = {}) {
|
|
155
|
+
const query = buildOrderStatusQuery(params);
|
|
156
|
+
if (!query.recordId && !query.orderId && !query.txHash) {
|
|
157
|
+
throw new SwapSdkError(
|
|
158
|
+
"INVALID_REQUEST",
|
|
159
|
+
"status",
|
|
160
|
+
"Order status requires recordId, or orderId/txHash with router"
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
if (!query.recordId && !query.router) {
|
|
164
|
+
throw new SwapSdkError(
|
|
165
|
+
"INVALID_REQUEST",
|
|
166
|
+
"status",
|
|
167
|
+
"Order status requires router when recordId is absent"
|
|
168
|
+
);
|
|
169
|
+
}
|
|
75
170
|
return this.request("/api/swap/order-status", "status", {
|
|
76
171
|
...options,
|
|
77
172
|
method: "GET",
|
|
78
173
|
retryableOperation: true,
|
|
79
|
-
query
|
|
80
|
-
orderId: params.orderId,
|
|
81
|
-
router: params.router,
|
|
82
|
-
chainId: params.chainId
|
|
83
|
-
}
|
|
174
|
+
query
|
|
84
175
|
});
|
|
85
176
|
}
|
|
86
177
|
report(body, options = {}) {
|
|
@@ -1981,9 +2072,13 @@ var McaSwapService = class {
|
|
|
1981
2072
|
onEvent: input.onEvent
|
|
1982
2073
|
});
|
|
1983
2074
|
if (input.quote.executionMode === "withdraw-near" && input.waitFor === "completed") {
|
|
1984
|
-
const
|
|
2075
|
+
const statusLookup = resolveOrderStatusLookup({
|
|
2076
|
+
recordId: result.report?.recordId,
|
|
1985
2077
|
orderId: nearStatusKey,
|
|
1986
|
-
router: input.quote.route.router
|
|
2078
|
+
router: input.quote.route.router
|
|
2079
|
+
}) ?? { orderId: nearStatusKey, router: input.quote.route.router };
|
|
2080
|
+
const status = await this.client.waitForOrder({
|
|
2081
|
+
...statusLookup,
|
|
1987
2082
|
...input.orderPolling,
|
|
1988
2083
|
signal: input.signal
|
|
1989
2084
|
});
|
|
@@ -2209,10 +2304,19 @@ var McaSwapService = class {
|
|
|
2209
2304
|
raw
|
|
2210
2305
|
};
|
|
2211
2306
|
emit({ type: "submitted", executionId, orderId });
|
|
2212
|
-
|
|
2307
|
+
const mustReportForStatus = input.waitFor === "completed";
|
|
2308
|
+
const shouldReportNow = this.reportMode !== "disabled" && (this.reportMode === "auto" || mustReportForStatus);
|
|
2309
|
+
let reportRecordId;
|
|
2310
|
+
if (shouldReportNow) {
|
|
2213
2311
|
try {
|
|
2214
|
-
await this.client.reportRaw(reportRequest, {
|
|
2215
|
-
|
|
2312
|
+
const reportData = await this.client.reportRaw(reportRequest, {
|
|
2313
|
+
signal: input.signal
|
|
2314
|
+
});
|
|
2315
|
+
reportRecordId = resolveSwapReportRecordId(reportData) || void 0;
|
|
2316
|
+
result.report = {
|
|
2317
|
+
status: "reported",
|
|
2318
|
+
...reportRecordId ? { recordId: reportRecordId } : {}
|
|
2319
|
+
};
|
|
2216
2320
|
} catch (error) {
|
|
2217
2321
|
const warning = {
|
|
2218
2322
|
code: "REPORT_FAILED",
|
|
@@ -2224,9 +2328,13 @@ var McaSwapService = class {
|
|
|
2224
2328
|
}
|
|
2225
2329
|
}
|
|
2226
2330
|
if (input.waitFor === "completed") {
|
|
2227
|
-
const
|
|
2331
|
+
const statusLookup = resolveOrderStatusLookup({
|
|
2332
|
+
recordId: reportRecordId ?? result.report?.recordId,
|
|
2228
2333
|
orderId,
|
|
2229
|
-
router
|
|
2334
|
+
router
|
|
2335
|
+
}) ?? { orderId, router };
|
|
2336
|
+
const status = await this.client.waitForOrder({
|
|
2337
|
+
...statusLookup,
|
|
2230
2338
|
...input.orderPolling,
|
|
2231
2339
|
signal: input.signal
|
|
2232
2340
|
});
|
|
@@ -2500,14 +2608,25 @@ var SwapClient = class {
|
|
|
2500
2608
|
executionId: build.executionId
|
|
2501
2609
|
});
|
|
2502
2610
|
}
|
|
2611
|
+
const waitsForCompletion = (input.waitFor ?? "submitted") === "completed";
|
|
2612
|
+
const requiresOrderStatus = build.isCrossChain || build.request?.confidentiality === "basic";
|
|
2503
2613
|
const reportRequest = this.createReportRequest(build, result);
|
|
2504
2614
|
if (reportRequest) {
|
|
2505
2615
|
this.reportRequests.set(build.executionId, reportRequest);
|
|
2506
2616
|
}
|
|
2507
|
-
|
|
2617
|
+
const mustReportForStatus = waitsForCompletion && requiresOrderStatus && Boolean(reportRequest);
|
|
2618
|
+
const shouldReportNow = Boolean(reportRequest) && this.reportMode !== "disabled" && (this.reportMode === "auto" || mustReportForStatus);
|
|
2619
|
+
let reportRecordId;
|
|
2620
|
+
if (shouldReportNow && reportRequest) {
|
|
2508
2621
|
try {
|
|
2509
|
-
await this.api.report(reportRequest, {
|
|
2510
|
-
|
|
2622
|
+
const reportData = await this.api.report(reportRequest, {
|
|
2623
|
+
signal: input.signal
|
|
2624
|
+
});
|
|
2625
|
+
reportRecordId = resolveSwapReportRecordId(reportData) || void 0;
|
|
2626
|
+
result.report = {
|
|
2627
|
+
status: "reported",
|
|
2628
|
+
...reportRecordId ? { recordId: reportRecordId } : {}
|
|
2629
|
+
};
|
|
2511
2630
|
} catch (error) {
|
|
2512
2631
|
const warning = {
|
|
2513
2632
|
code: "REPORT_FAILED",
|
|
@@ -2518,27 +2637,29 @@ var SwapClient = class {
|
|
|
2518
2637
|
emit({ type: "warning", executionId: build.executionId, warning });
|
|
2519
2638
|
}
|
|
2520
2639
|
}
|
|
2521
|
-
const
|
|
2522
|
-
|
|
2523
|
-
|
|
2640
|
+
const statusLookup = resolveOrderStatusLookup({
|
|
2641
|
+
recordId: reportRecordId ?? result.report?.recordId,
|
|
2642
|
+
orderId,
|
|
2643
|
+
txHash: resolveSourceTxHash(chainResult),
|
|
2644
|
+
router: orderRouter ?? build.router,
|
|
2645
|
+
chainId: orderChainId
|
|
2646
|
+
});
|
|
2647
|
+
if (waitsForCompletion && requiresOrderStatus && !statusLookup) {
|
|
2524
2648
|
throw new SwapSdkError(
|
|
2525
2649
|
"INVALID_API_RESPONSE",
|
|
2526
2650
|
"status",
|
|
2527
|
-
"Swap submitted, but
|
|
2651
|
+
"Swap submitted, but no report record id, status key, or source transaction hash is available",
|
|
2528
2652
|
{
|
|
2529
2653
|
details: {
|
|
2530
2654
|
executionId: build.executionId,
|
|
2531
|
-
...result.txHash ? { txHash: result.txHash } : {},
|
|
2532
2655
|
router: orderRouter ?? build.router
|
|
2533
2656
|
}
|
|
2534
2657
|
}
|
|
2535
2658
|
);
|
|
2536
2659
|
}
|
|
2537
|
-
if (waitsForCompletion &&
|
|
2660
|
+
if (waitsForCompletion && statusLookup) {
|
|
2538
2661
|
const status = await this.waitForOrder({
|
|
2539
|
-
|
|
2540
|
-
router: orderRouter ?? build.router,
|
|
2541
|
-
chainId: orderChainId,
|
|
2662
|
+
...statusLookup,
|
|
2542
2663
|
...input.orderPolling,
|
|
2543
2664
|
signal: input.signal
|
|
2544
2665
|
});
|
|
@@ -2576,21 +2697,22 @@ var SwapClient = class {
|
|
|
2576
2697
|
});
|
|
2577
2698
|
}
|
|
2578
2699
|
async getOrderStatus(input) {
|
|
2579
|
-
const
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
router: input.router,
|
|
2583
|
-
chainId: input.chainId
|
|
2584
|
-
},
|
|
2585
|
-
{ signal: input.signal }
|
|
2586
|
-
);
|
|
2700
|
+
const { signal, ...reference } = input;
|
|
2701
|
+
const lookup = assertOrderStatusParams(reference);
|
|
2702
|
+
const raw = await this.api.getOrderStatus(lookup, { signal });
|
|
2587
2703
|
return {
|
|
2588
|
-
|
|
2589
|
-
router: input.router,
|
|
2704
|
+
...lookup,
|
|
2705
|
+
...lookup.router || input.router ? { router: lookup.router ?? input.router } : {},
|
|
2590
2706
|
status: normalizeOrderStatus(raw),
|
|
2591
2707
|
raw
|
|
2592
2708
|
};
|
|
2593
2709
|
}
|
|
2710
|
+
async getHistoryOrderStatus(item, options = {}) {
|
|
2711
|
+
return this.getOrderStatus({
|
|
2712
|
+
...orderStatusParamsFromHistoryItem(item),
|
|
2713
|
+
signal: options.signal
|
|
2714
|
+
});
|
|
2715
|
+
}
|
|
2594
2716
|
async waitForOrder(input) {
|
|
2595
2717
|
const intervalMs = input.intervalMs ?? 5e3;
|
|
2596
2718
|
const timeoutMs = input.timeoutMs;
|
|
@@ -2627,7 +2749,7 @@ var SwapClient = class {
|
|
|
2627
2749
|
reportRaw(request, options = {}) {
|
|
2628
2750
|
return this.api.report(request, options);
|
|
2629
2751
|
}
|
|
2630
|
-
report(result) {
|
|
2752
|
+
async report(result) {
|
|
2631
2753
|
const managedReport = this.managedSwapFlow.reportIfManaged(result);
|
|
2632
2754
|
if (managedReport) return managedReport;
|
|
2633
2755
|
const request = this.reportRequests.get(result.executionId);
|
|
@@ -2638,7 +2760,13 @@ var SwapClient = class {
|
|
|
2638
2760
|
`No report context for execution ${result.executionId}`
|
|
2639
2761
|
);
|
|
2640
2762
|
}
|
|
2641
|
-
|
|
2763
|
+
const raw = await this.api.report(request);
|
|
2764
|
+
const recordId = resolveSwapReportRecordId(raw) || void 0;
|
|
2765
|
+
result.report = {
|
|
2766
|
+
status: "reported",
|
|
2767
|
+
...recordId ? { recordId } : {}
|
|
2768
|
+
};
|
|
2769
|
+
return raw;
|
|
2642
2770
|
}
|
|
2643
2771
|
retryReport(result) {
|
|
2644
2772
|
return this.report(result);
|
|
@@ -2800,8 +2928,10 @@ exports.SwapClient = SwapClient;
|
|
|
2800
2928
|
exports.SwapSdkError = SwapSdkError;
|
|
2801
2929
|
exports.asSwapSdkError = asSwapSdkError;
|
|
2802
2930
|
exports.assertBaseUnitAmount = assertBaseUnitAmount;
|
|
2931
|
+
exports.assertOrderStatusParams = assertOrderStatusParams;
|
|
2803
2932
|
exports.buildMcaWithdrawRelayerRequest = buildMcaWithdrawRelayerRequest;
|
|
2804
2933
|
exports.buildNearMcaWithdrawTransactions = buildNearMcaWithdrawTransactions;
|
|
2934
|
+
exports.buildOrderStatusQuery = buildOrderStatusQuery;
|
|
2805
2935
|
exports.createExecutionId = createExecutionId;
|
|
2806
2936
|
exports.extractMcaWithdrawBusiness = extractMcaWithdrawBusiness;
|
|
2807
2937
|
exports.extractMcaWithdrawDepositAddress = extractMcaWithdrawDepositAddress;
|
|
@@ -2818,10 +2948,14 @@ exports.normalizeHistoryStatus = normalizeHistoryStatus;
|
|
|
2818
2948
|
exports.normalizeMcaQuote = normalizeMcaQuote;
|
|
2819
2949
|
exports.normalizeOrderStatus = normalizeOrderStatus;
|
|
2820
2950
|
exports.normalizeQuote = normalizeQuote;
|
|
2951
|
+
exports.orderStatusParamsFromHistoryItem = orderStatusParamsFromHistoryItem;
|
|
2821
2952
|
exports.parseUnits = parseUnits;
|
|
2822
2953
|
exports.resolveMcaDecreaseCollateral = resolveMcaDecreaseCollateral;
|
|
2823
2954
|
exports.resolveMcaRequiredCollateralDecrease = resolveMcaRequiredCollateralDecrease;
|
|
2824
2955
|
exports.resolveMcaWithdrawPolicy = resolveMcaWithdrawPolicy;
|
|
2956
|
+
exports.resolveOrderStatusLookup = resolveOrderStatusLookup;
|
|
2957
|
+
exports.resolveSourceTxHash = resolveSourceTxHash;
|
|
2958
|
+
exports.resolveSwapReportRecordId = resolveSwapReportRecordId;
|
|
2825
2959
|
exports.selectMcaSigner = selectMcaSigner;
|
|
2826
2960
|
exports.serializeMcaQuoteRequest = serializeMcaQuoteRequest;
|
|
2827
2961
|
exports.serializeQuoteRequest = serializeQuoteRequest;
|