@rhea-finance/cross-chain-aggregation-dex 2.1.6 → 2.1.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/dist/executors/aptos.d.mts +1 -1
- package/dist/executors/aptos.d.ts +1 -1
- package/dist/executors/aptos.js +2 -0
- package/dist/executors/aptos.js.map +1 -1
- package/dist/executors/aptos.mjs +2 -0
- package/dist/executors/aptos.mjs.map +1 -1
- package/dist/executors/bitcoin.d.mts +1 -1
- package/dist/executors/bitcoin.d.ts +1 -1
- package/dist/executors/bitcoin.js +2 -0
- package/dist/executors/bitcoin.js.map +1 -1
- package/dist/executors/bitcoin.mjs +2 -0
- package/dist/executors/bitcoin.mjs.map +1 -1
- package/dist/executors/evm.d.mts +1 -1
- package/dist/executors/evm.d.ts +1 -1
- package/dist/executors/evm.js +2 -0
- package/dist/executors/evm.js.map +1 -1
- package/dist/executors/evm.mjs +2 -0
- package/dist/executors/evm.mjs.map +1 -1
- package/dist/executors/near.d.mts +1 -1
- package/dist/executors/near.d.ts +1 -1
- package/dist/executors/near.js +2 -0
- package/dist/executors/near.js.map +1 -1
- package/dist/executors/near.mjs +2 -0
- package/dist/executors/near.mjs.map +1 -1
- package/dist/executors/solana.d.mts +1 -1
- package/dist/executors/solana.d.ts +1 -1
- package/dist/executors/solana.js +2 -0
- package/dist/executors/solana.js.map +1 -1
- package/dist/executors/solana.mjs +2 -0
- package/dist/executors/solana.mjs.map +1 -1
- package/dist/executors/sui.d.mts +1 -1
- package/dist/executors/sui.d.ts +1 -1
- package/dist/executors/sui.js +2 -0
- package/dist/executors/sui.js.map +1 -1
- package/dist/executors/sui.mjs +2 -0
- package/dist/executors/sui.mjs.map +1 -1
- package/dist/executors/tron.d.mts +8 -2
- package/dist/executors/tron.d.ts +8 -2
- package/dist/executors/tron.js +157 -39
- package/dist/executors/tron.js.map +1 -1
- package/dist/executors/tron.mjs +157 -39
- package/dist/executors/tron.mjs.map +1 -1
- package/dist/executors/zcash.d.mts +1 -1
- package/dist/executors/zcash.d.ts +1 -1
- package/dist/executors/zcash.js +2 -0
- package/dist/executors/zcash.js.map +1 -1
- package/dist/executors/zcash.mjs +2 -0
- package/dist/executors/zcash.mjs.map +1 -1
- package/dist/index.d.mts +16 -3
- package/dist/index.d.ts +16 -3
- package/dist/index.js +175 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +173 -14
- package/dist/index.mjs.map +1 -1
- package/dist/{shared-DpC8G2U4.d.mts → shared-v1w63b8X.d.mts} +20 -1
- package/dist/{shared-DpC8G2U4.d.ts → shared-v1w63b8X.d.ts} +20 -1
- package/package.json +1 -1
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 OrderReference, F as OrderStatusResult, G as WaitForOrderInput, H as SwapHistoryAuthProofRaw, N as NearTransaction, I as SwapMcaRelayerRequestRaw } from './shared-
|
|
2
|
-
export {
|
|
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-v1w63b8X.js';
|
|
2
|
+
export { ae as BuildContext, _ as ChainExecutionResult, aa 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, ad as RouteSummary, X as SignRequestPreview, a7 as SolanaMetadata, J as SwapApiResponse, K as SwapApiTokenMetaRaw, R as SwapBuildApproveRaw, ac as SwapExecution, U as SwapHistoryWalletChainFamilyRaw, M as SwapMcaSignerPayloadRaw, ab as SwapReportContext, P as SwapSigningRequestRaw, L as SwapTokenListRowRaw, V as SwapWarning, T as TransactionConfirmation, a9 as TronApproval, a8 as TronUnsignedTransaction, a3 as assertBaseUnitAmount, Z as normalizeOrderStatus } from './shared-v1w63b8X.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";
|
|
@@ -42,6 +42,8 @@ interface ApiClientConfig {
|
|
|
42
42
|
headers?: Record<string, string> | (() => Record<string, string> | Promise<Record<string, string>>);
|
|
43
43
|
timeoutMs?: number;
|
|
44
44
|
logger?: SdkLogger;
|
|
45
|
+
/** Dump catch-site errors to console. Default false. */
|
|
46
|
+
debugCatchLogging?: boolean;
|
|
45
47
|
}
|
|
46
48
|
interface ApiRequestOptions {
|
|
47
49
|
signal?: AbortSignal;
|
|
@@ -279,6 +281,17 @@ declare class SwapClient {
|
|
|
279
281
|
private createReportRequest;
|
|
280
282
|
}
|
|
281
283
|
|
|
284
|
+
/**
|
|
285
|
+
* Debug helper: dump SDK catch sites to the console (browser / Node).
|
|
286
|
+
* Off by default — enable via {@link setSdkCatchLogging} or
|
|
287
|
+
* `SwapClient({ debugCatchLogging: true })`.
|
|
288
|
+
* Filter DevTools by `[cross-chain-aggregation-dex]`.
|
|
289
|
+
*/
|
|
290
|
+
/** Enable or disable catch-site console dumping. Default: off. */
|
|
291
|
+
declare function setSdkCatchLogging(enabled: boolean): void;
|
|
292
|
+
declare function isSdkCatchLoggingEnabled(): boolean;
|
|
293
|
+
declare function logSdkCaughtError(scope: string, error: unknown): void;
|
|
294
|
+
|
|
282
295
|
declare function normalizeBuild(raw: SwapBuildDataRaw, executionId?: string, request?: SwapBuildRequestRaw): SwapBuild;
|
|
283
296
|
declare function createExecutionId(): string;
|
|
284
297
|
|
|
@@ -396,4 +409,4 @@ declare function resolveSourceTxHash(input: {
|
|
|
396
409
|
declare function parseUnits(value: string, decimals: number): BaseUnitAmount;
|
|
397
410
|
declare function formatUnits(value: BaseUnitAmount, decimals: number): string;
|
|
398
411
|
|
|
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 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, shouldPollSwapOrderStatus, toApiAssetAddress, toApiChain };
|
|
412
|
+
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 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, isSdkCatchLoggingEnabled, logSdkCaughtError, normalizeBuild, normalizeCrossChainToTokenList, normalizeFromTokenList, normalizeHistory, normalizeHistoryStatus, normalizeMcaQuote, normalizeQuote, orderStatusParamsFromHistoryItem, parseUnits, resolveMcaDecreaseCollateral, resolveMcaRequiredCollateralDecrease, resolveMcaWithdrawPolicy, resolveOrderStatusLookup, resolveSourceTxHash, resolveSwapReportRecordId, selectMcaSigner, serializeMcaQuoteRequest, serializeQuoteRequest, setSdkCatchLogging, shouldPollSwapOrderStatus, toApiAssetAddress, toApiChain };
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,68 @@
|
|
|
2
2
|
|
|
3
3
|
var zod = require('zod');
|
|
4
4
|
|
|
5
|
+
// src/core/catchLog.ts
|
|
6
|
+
var MAX_CAUSE_DEPTH = 8;
|
|
7
|
+
var catchLoggingEnabled = false;
|
|
8
|
+
function setSdkCatchLogging(enabled) {
|
|
9
|
+
catchLoggingEnabled = Boolean(enabled);
|
|
10
|
+
}
|
|
11
|
+
function isSdkCatchLoggingEnabled() {
|
|
12
|
+
return catchLoggingEnabled;
|
|
13
|
+
}
|
|
14
|
+
function readProp(value, key) {
|
|
15
|
+
if (typeof value !== "object" || value === null) return void 0;
|
|
16
|
+
return Reflect.get(value, key);
|
|
17
|
+
}
|
|
18
|
+
function redactSensitive(text) {
|
|
19
|
+
return text.replace(/(https?:\/\/[^\s?'"`]+)\?[^\s'"`]*/gi, "$1?[redacted]");
|
|
20
|
+
}
|
|
21
|
+
function serializeCaughtError(error, depth = 0) {
|
|
22
|
+
if (error === null || error === void 0) {
|
|
23
|
+
return { value: error };
|
|
24
|
+
}
|
|
25
|
+
if (typeof error !== "object") {
|
|
26
|
+
return {
|
|
27
|
+
value: typeof error === "string" ? redactSensitive(error) : error
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
const name = typeof readProp(error, "name") === "string" ? readProp(error, "name") : void 0;
|
|
31
|
+
const message = typeof readProp(error, "message") === "string" ? redactSensitive(readProp(error, "message")) : void 0;
|
|
32
|
+
const code = readProp(error, "code");
|
|
33
|
+
const stage = readProp(error, "stage");
|
|
34
|
+
const details = readProp(error, "details");
|
|
35
|
+
const stack = typeof readProp(error, "stack") === "string" ? redactSensitive(readProp(error, "stack")) : void 0;
|
|
36
|
+
const options = readProp(error, "options");
|
|
37
|
+
const optionsCause = typeof options === "object" && options !== null ? Reflect.get(options, "cause") : void 0;
|
|
38
|
+
const directCause = readProp(error, "cause");
|
|
39
|
+
const cause = optionsCause ?? directCause;
|
|
40
|
+
const out = {
|
|
41
|
+
...name ? { name } : {},
|
|
42
|
+
...message !== void 0 ? { message } : {},
|
|
43
|
+
...code !== void 0 ? { code } : {},
|
|
44
|
+
...stage !== void 0 ? { stage } : {},
|
|
45
|
+
...details !== void 0 ? { details } : {},
|
|
46
|
+
...stack ? { stack } : {}
|
|
47
|
+
};
|
|
48
|
+
if (cause !== void 0 && depth < MAX_CAUSE_DEPTH) {
|
|
49
|
+
out.cause = serializeCaughtError(cause, depth + 1);
|
|
50
|
+
} else if (Object.keys(out).length === 0) {
|
|
51
|
+
try {
|
|
52
|
+
out.raw = JSON.parse(
|
|
53
|
+
redactSensitive(JSON.stringify(error) ?? "null")
|
|
54
|
+
);
|
|
55
|
+
} catch {
|
|
56
|
+
out.raw = redactSensitive(String(error));
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return out;
|
|
60
|
+
}
|
|
61
|
+
function logSdkCaughtError(scope, error) {
|
|
62
|
+
if (!catchLoggingEnabled) return;
|
|
63
|
+
const payload = serializeCaughtError(error);
|
|
64
|
+
console.error(`[cross-chain-aggregation-dex] catch:${scope}`, payload);
|
|
65
|
+
}
|
|
66
|
+
|
|
5
67
|
// src/core/errors.ts
|
|
6
68
|
var SwapSdkError = class extends Error {
|
|
7
69
|
constructor(code, stage, message, options = {}) {
|
|
@@ -23,6 +85,7 @@ var SwapSdkError = class extends Error {
|
|
|
23
85
|
}
|
|
24
86
|
};
|
|
25
87
|
function asSwapSdkError(error, stage) {
|
|
88
|
+
logSdkCaughtError(`asSwapSdkError:${stage}`, error);
|
|
26
89
|
if (error instanceof SwapSdkError) return error;
|
|
27
90
|
const message = error instanceof Error ? error.message : String(error);
|
|
28
91
|
return new SwapSdkError("API_ERROR", stage, message, { cause: error });
|
|
@@ -120,6 +183,9 @@ var ApiClient = class {
|
|
|
120
183
|
constructor(config) {
|
|
121
184
|
this.config = config;
|
|
122
185
|
this.baseUrl = config.baseUrl.replace(/\/$/, "");
|
|
186
|
+
if (config.debugCatchLogging !== void 0) {
|
|
187
|
+
setSdkCatchLogging(config.debugCatchLogging);
|
|
188
|
+
}
|
|
123
189
|
const fetchImpl = config.fetch ?? globalThis.fetch;
|
|
124
190
|
if (typeof fetchImpl !== "function") {
|
|
125
191
|
throw new SwapSdkError(
|
|
@@ -302,6 +368,7 @@ var ApiClient = class {
|
|
|
302
368
|
}
|
|
303
369
|
return parsed.data;
|
|
304
370
|
} catch (error) {
|
|
371
|
+
logSdkCaughtError("api/ApiClient.ts", error);
|
|
305
372
|
if (error instanceof SwapSdkError) throw error;
|
|
306
373
|
if (controller.signal.aborted) {
|
|
307
374
|
throw new SwapSdkError(
|
|
@@ -362,6 +429,7 @@ var ApiClient = class {
|
|
|
362
429
|
try {
|
|
363
430
|
return text ? JSON.parse(text) : {};
|
|
364
431
|
} catch (error) {
|
|
432
|
+
logSdkCaughtError("api/ApiClient.ts", error);
|
|
365
433
|
throw new SwapSdkError(
|
|
366
434
|
status >= 400 ? "HTTP_ERROR" : "INVALID_API_RESPONSE",
|
|
367
435
|
stage,
|
|
@@ -655,10 +723,23 @@ var transferBaseSchema = zod.z.object({
|
|
|
655
723
|
amount: decimalStringSchema,
|
|
656
724
|
depositAddress: nonEmptyStringSchema
|
|
657
725
|
});
|
|
658
|
-
var
|
|
726
|
+
var tronTransferSchema = transferBaseSchema.extend({
|
|
659
727
|
tokenAddress: zod.z.string().optional(),
|
|
660
728
|
standard: zod.z.string().optional()
|
|
661
729
|
});
|
|
730
|
+
var tronUnsignedTxSchema = zod.z.object({
|
|
731
|
+
txID: nonEmptyStringSchema,
|
|
732
|
+
raw_data: zod.z.record(zod.z.string(), zod.z.unknown()),
|
|
733
|
+
raw_data_hex: nonEmptyStringSchema,
|
|
734
|
+
visible: zod.z.boolean().optional()
|
|
735
|
+
}).passthrough();
|
|
736
|
+
var tronRawDataTxSchema = tronUnsignedTxSchema.extend({
|
|
737
|
+
format: zod.z.string().optional(),
|
|
738
|
+
approveTxID: zod.z.string().optional(),
|
|
739
|
+
approve_raw_data: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
|
|
740
|
+
approve_raw_data_hex: zod.z.string().optional(),
|
|
741
|
+
approveVisible: zod.z.boolean().optional()
|
|
742
|
+
}).passthrough();
|
|
662
743
|
var bitcoinTxSchema = transferBaseSchema.extend({
|
|
663
744
|
feeRate: zod.z.number().positive().optional()
|
|
664
745
|
});
|
|
@@ -700,6 +781,7 @@ function normalizeBuild(raw, executionId = createExecutionId(), request) {
|
|
|
700
781
|
raw
|
|
701
782
|
};
|
|
702
783
|
} catch (error) {
|
|
784
|
+
logSdkCaughtError("normalizers/build.ts", error);
|
|
703
785
|
if (error instanceof SwapSdkError) throw error;
|
|
704
786
|
throw invalidBuild(error);
|
|
705
787
|
}
|
|
@@ -741,18 +823,8 @@ function normalizeExecution(raw, lane, chain) {
|
|
|
741
823
|
transactions: Array.isArray(transactions) ? transactions : [transactions]
|
|
742
824
|
};
|
|
743
825
|
}
|
|
744
|
-
case "tron":
|
|
745
|
-
|
|
746
|
-
assertKind(tx.kind, ["tron_transfer"]);
|
|
747
|
-
return {
|
|
748
|
-
kind: "tron-transfer",
|
|
749
|
-
chain,
|
|
750
|
-
amount: tx.amount,
|
|
751
|
-
depositAddress: tx.depositAddress,
|
|
752
|
-
...tx.tokenAddress ? { tokenAddress: tx.tokenAddress } : {},
|
|
753
|
-
...tx.standard ? { standard: tx.standard } : {}
|
|
754
|
-
};
|
|
755
|
-
}
|
|
826
|
+
case "tron":
|
|
827
|
+
return normalizeTronExecution(raw, chain);
|
|
756
828
|
case "bitcoin": {
|
|
757
829
|
const tx = bitcoinTxSchema.parse(raw.tx);
|
|
758
830
|
assertKind(tx.kind, ["btc_transfer", "utxo_transfer"]);
|
|
@@ -824,6 +896,82 @@ function normalizeEvmApproval(raw, chain) {
|
|
|
824
896
|
}
|
|
825
897
|
return void 0;
|
|
826
898
|
}
|
|
899
|
+
function normalizeTronExecution(raw, chain) {
|
|
900
|
+
if (isTronRawDataTx(raw.tx)) {
|
|
901
|
+
const tx2 = tronRawDataTxSchema.parse(raw.tx);
|
|
902
|
+
const transaction = toTronUnsignedTransaction(tx2);
|
|
903
|
+
const approval = normalizeTronApproval(tx2, raw);
|
|
904
|
+
return {
|
|
905
|
+
kind: "tron-transaction",
|
|
906
|
+
chain,
|
|
907
|
+
format: normalizeTronFormat(tx2.format),
|
|
908
|
+
transaction,
|
|
909
|
+
...approval ? { approval } : {}
|
|
910
|
+
};
|
|
911
|
+
}
|
|
912
|
+
const tx = tronTransferSchema.parse(raw.tx);
|
|
913
|
+
assertKind(tx.kind, ["tron_transfer"]);
|
|
914
|
+
return {
|
|
915
|
+
kind: "tron-transfer",
|
|
916
|
+
chain,
|
|
917
|
+
amount: tx.amount,
|
|
918
|
+
depositAddress: tx.depositAddress,
|
|
919
|
+
...tx.tokenAddress ? { tokenAddress: tx.tokenAddress } : {},
|
|
920
|
+
...tx.standard ? { standard: tx.standard } : {}
|
|
921
|
+
};
|
|
922
|
+
}
|
|
923
|
+
function isTronRawDataTx(value) {
|
|
924
|
+
if (typeof value !== "object" || value === null) return false;
|
|
925
|
+
const format = Reflect.get(value, "format");
|
|
926
|
+
if (typeof format === "string" && format.toLowerCase() === "tron-raw-data") {
|
|
927
|
+
return true;
|
|
928
|
+
}
|
|
929
|
+
return typeof Reflect.get(value, "txID") === "string" && typeof Reflect.get(value, "raw_data_hex") === "string" && typeof Reflect.get(value, "raw_data") === "object" && Reflect.get(value, "raw_data") !== null;
|
|
930
|
+
}
|
|
931
|
+
function normalizeTronFormat(format) {
|
|
932
|
+
const normalized = format?.trim();
|
|
933
|
+
return normalized && normalized.length > 0 ? normalized : "tron-raw-data";
|
|
934
|
+
}
|
|
935
|
+
function toTronUnsignedTransaction(value) {
|
|
936
|
+
const {
|
|
937
|
+
txID,
|
|
938
|
+
raw_data,
|
|
939
|
+
raw_data_hex,
|
|
940
|
+
visible,
|
|
941
|
+
format: _format,
|
|
942
|
+
approveTxID: _approveTxID,
|
|
943
|
+
approve_raw_data: _approveRawData,
|
|
944
|
+
approve_raw_data_hex: _approveRawDataHex,
|
|
945
|
+
approveVisible: _approveVisible,
|
|
946
|
+
approve_payload: _approvePayload,
|
|
947
|
+
approveTxId: _approveTxId,
|
|
948
|
+
...rest
|
|
949
|
+
} = value;
|
|
950
|
+
return {
|
|
951
|
+
...rest,
|
|
952
|
+
txID,
|
|
953
|
+
raw_data,
|
|
954
|
+
raw_data_hex,
|
|
955
|
+
...visible === void 0 ? {} : { visible }
|
|
956
|
+
};
|
|
957
|
+
}
|
|
958
|
+
function normalizeTronApproval(tx, raw) {
|
|
959
|
+
if (typeof tx.approveTxID === "string" && tx.approveTxID.trim() && tx.approve_raw_data && typeof tx.approve_raw_data_hex === "string" && tx.approve_raw_data_hex.trim()) {
|
|
960
|
+
return {
|
|
961
|
+
transaction: {
|
|
962
|
+
txID: tx.approveTxID.trim(),
|
|
963
|
+
raw_data: tx.approve_raw_data,
|
|
964
|
+
raw_data_hex: tx.approve_raw_data_hex.trim(),
|
|
965
|
+
visible: tx.approveVisible ?? false
|
|
966
|
+
}
|
|
967
|
+
};
|
|
968
|
+
}
|
|
969
|
+
if (raw.approve?.tx && isTronRawDataTx(raw.approve.tx)) {
|
|
970
|
+
const approveTx = tronUnsignedTxSchema.parse(raw.approve.tx);
|
|
971
|
+
return { transaction: toTronUnsignedTransaction(approveTx) };
|
|
972
|
+
}
|
|
973
|
+
return void 0;
|
|
974
|
+
}
|
|
827
975
|
function readErc20ApproveSpender(data) {
|
|
828
976
|
const normalized = data.toLowerCase();
|
|
829
977
|
if (!normalized.startsWith("0x095ea7b3") || normalized.length < 10 + 64) {
|
|
@@ -1133,6 +1281,7 @@ function validateResponseAmount(value, field) {
|
|
|
1133
1281
|
try {
|
|
1134
1282
|
return assertBaseUnitAmount(value);
|
|
1135
1283
|
} catch (error) {
|
|
1284
|
+
logSdkCaughtError("normalizers/quote.ts", error);
|
|
1136
1285
|
throw invalidQuote(`Quote response has invalid ${field}`, error);
|
|
1137
1286
|
}
|
|
1138
1287
|
}
|
|
@@ -1895,6 +2044,7 @@ function normalizeDeposit2(value) {
|
|
|
1895
2044
|
try {
|
|
1896
2045
|
return parseUnits(decimal, 24);
|
|
1897
2046
|
} catch (error) {
|
|
2047
|
+
logSdkCaughtError("mca/withdraw.ts", error);
|
|
1898
2048
|
throw new SwapSdkError(
|
|
1899
2049
|
"INVALID_API_RESPONSE",
|
|
1900
2050
|
"build",
|
|
@@ -2116,6 +2266,7 @@ var McaSwapService = class {
|
|
|
2116
2266
|
}
|
|
2117
2267
|
})).trim();
|
|
2118
2268
|
} catch (error) {
|
|
2269
|
+
logSdkCaughtError("mca/McaSwapService.ts", error);
|
|
2119
2270
|
if (error instanceof SwapSdkError) throw error;
|
|
2120
2271
|
throw new SwapSdkError(
|
|
2121
2272
|
"SIGNING_FAILED",
|
|
@@ -2205,6 +2356,7 @@ var McaSwapService = class {
|
|
|
2205
2356
|
...reportRecordId ? { recordId: reportRecordId } : {}
|
|
2206
2357
|
};
|
|
2207
2358
|
} catch (error) {
|
|
2359
|
+
logSdkCaughtError("mca/McaSwapService.ts", error);
|
|
2208
2360
|
const warning = {
|
|
2209
2361
|
code: "REPORT_FAILED",
|
|
2210
2362
|
message: "MCA withdraw submitted but report failed",
|
|
@@ -2239,6 +2391,7 @@ var McaSwapService = class {
|
|
|
2239
2391
|
}
|
|
2240
2392
|
return result;
|
|
2241
2393
|
} catch (error) {
|
|
2394
|
+
logSdkCaughtError("mca/McaSwapService.ts", error);
|
|
2242
2395
|
const sdkError = asSwapSdkError(error, "submit");
|
|
2243
2396
|
emit({ type: "failed", executionId, error: sdkError });
|
|
2244
2397
|
throw sdkError;
|
|
@@ -2249,6 +2402,7 @@ var McaSwapService = class {
|
|
|
2249
2402
|
try {
|
|
2250
2403
|
identityKey = (await provider.getIdentityKey()).trim();
|
|
2251
2404
|
} catch (error) {
|
|
2405
|
+
logSdkCaughtError("mca/McaSwapService.ts", error);
|
|
2252
2406
|
if (error instanceof SwapSdkError) throw error;
|
|
2253
2407
|
throw new SwapSdkError(
|
|
2254
2408
|
"SIGNING_FAILED",
|
|
@@ -2310,6 +2464,9 @@ var SwapClient = class {
|
|
|
2310
2464
|
this.reportRequests = /* @__PURE__ */ new Map();
|
|
2311
2465
|
this.tokenListCache = /* @__PURE__ */ new Map();
|
|
2312
2466
|
this.tokenListInflight = /* @__PURE__ */ new Map();
|
|
2467
|
+
if (config.debugCatchLogging !== void 0) {
|
|
2468
|
+
setSdkCatchLogging(config.debugCatchLogging);
|
|
2469
|
+
}
|
|
2313
2470
|
this.config = config;
|
|
2314
2471
|
this.api = new ApiClient(config);
|
|
2315
2472
|
this.registry = new ExecutorRegistry(config.executors ?? []);
|
|
@@ -2515,6 +2672,7 @@ var SwapClient = class {
|
|
|
2515
2672
|
...reportRecordId ? { recordId: reportRecordId } : {}
|
|
2516
2673
|
};
|
|
2517
2674
|
} catch (error) {
|
|
2675
|
+
logSdkCaughtError("client/SwapClient.ts", error);
|
|
2518
2676
|
const warning = {
|
|
2519
2677
|
code: "REPORT_FAILED",
|
|
2520
2678
|
message: "Swap submitted but report failed",
|
|
@@ -2560,6 +2718,7 @@ var SwapClient = class {
|
|
|
2560
2718
|
}
|
|
2561
2719
|
return result;
|
|
2562
2720
|
} catch (error) {
|
|
2721
|
+
logSdkCaughtError("client/SwapClient.ts", error);
|
|
2563
2722
|
const sdkError = asSwapSdkError(error, "broadcast");
|
|
2564
2723
|
emit({ type: "failed", executionId: build.executionId, error: sdkError });
|
|
2565
2724
|
throw sdkError;
|
|
@@ -2830,6 +2989,8 @@ exports.formatMcaWallet = formatMcaWallet;
|
|
|
2830
2989
|
exports.formatUnits = formatUnits;
|
|
2831
2990
|
exports.fromApiChain = fromApiChain;
|
|
2832
2991
|
exports.isSameMcaSignerIdentity = isSameMcaSignerIdentity;
|
|
2992
|
+
exports.isSdkCatchLoggingEnabled = isSdkCatchLoggingEnabled;
|
|
2993
|
+
exports.logSdkCaughtError = logSdkCaughtError;
|
|
2833
2994
|
exports.normalizeBuild = normalizeBuild;
|
|
2834
2995
|
exports.normalizeCrossChainToTokenList = normalizeCrossChainToTokenList;
|
|
2835
2996
|
exports.normalizeFromTokenList = normalizeFromTokenList;
|
|
@@ -2849,6 +3010,7 @@ exports.resolveSwapReportRecordId = resolveSwapReportRecordId;
|
|
|
2849
3010
|
exports.selectMcaSigner = selectMcaSigner;
|
|
2850
3011
|
exports.serializeMcaQuoteRequest = serializeMcaQuoteRequest;
|
|
2851
3012
|
exports.serializeQuoteRequest = serializeQuoteRequest;
|
|
3013
|
+
exports.setSdkCatchLogging = setSdkCatchLogging;
|
|
2852
3014
|
exports.shouldPollSwapOrderStatus = shouldPollSwapOrderStatus;
|
|
2853
3015
|
exports.toApiAssetAddress = toApiAssetAddress;
|
|
2854
3016
|
exports.toApiChain = toApiChain;
|