@rhea-finance/cross-chain-aggregation-dex 2.0.1 → 2.0.3
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 +567 -206
- package/dist/executors/aptos.d.mts +3 -4
- package/dist/executors/aptos.d.ts +3 -4
- package/dist/executors/aptos.js +22 -2
- package/dist/executors/aptos.js.map +1 -1
- package/dist/executors/aptos.mjs +22 -2
- package/dist/executors/aptos.mjs.map +1 -1
- package/dist/executors/bitcoin.d.mts +3 -4
- package/dist/executors/bitcoin.d.ts +3 -4
- package/dist/executors/bitcoin.js +22 -2
- package/dist/executors/bitcoin.js.map +1 -1
- package/dist/executors/bitcoin.mjs +22 -2
- package/dist/executors/bitcoin.mjs.map +1 -1
- package/dist/executors/evm.d.mts +3 -4
- package/dist/executors/evm.d.ts +3 -4
- package/dist/executors/evm.js +29 -13
- package/dist/executors/evm.js.map +1 -1
- package/dist/executors/evm.mjs +29 -13
- package/dist/executors/evm.mjs.map +1 -1
- package/dist/executors/near.d.mts +3 -4
- package/dist/executors/near.d.ts +3 -4
- package/dist/executors/near.js +22 -2
- package/dist/executors/near.js.map +1 -1
- package/dist/executors/near.mjs +22 -2
- package/dist/executors/near.mjs.map +1 -1
- package/dist/executors/solana.d.mts +3 -4
- package/dist/executors/solana.d.ts +3 -4
- package/dist/executors/solana.js +22 -2
- package/dist/executors/solana.js.map +1 -1
- package/dist/executors/solana.mjs +22 -2
- package/dist/executors/solana.mjs.map +1 -1
- package/dist/executors/sui.d.mts +3 -4
- package/dist/executors/sui.d.ts +3 -4
- package/dist/executors/sui.js +22 -2
- package/dist/executors/sui.js.map +1 -1
- package/dist/executors/sui.mjs +22 -2
- package/dist/executors/sui.mjs.map +1 -1
- package/dist/executors/tron.d.mts +3 -4
- package/dist/executors/tron.d.ts +3 -4
- package/dist/executors/tron.js +22 -2
- package/dist/executors/tron.js.map +1 -1
- package/dist/executors/tron.mjs +22 -2
- package/dist/executors/tron.mjs.map +1 -1
- package/dist/executors/zcash.d.mts +4 -5
- package/dist/executors/zcash.d.ts +4 -5
- package/dist/executors/zcash.js +24 -10
- package/dist/executors/zcash.js.map +1 -1
- package/dist/executors/zcash.mjs +24 -10
- package/dist/executors/zcash.mjs.map +1 -1
- package/dist/index.d.mts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +59 -25
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +59 -25
- package/dist/index.mjs.map +1 -1
- package/dist/{registry-DRYUqs7T.d.mts → shared-BEZXY_BM.d.mts} +39 -12
- package/dist/{registry-DRYUqs7T.d.ts → shared-BEZXY_BM.d.ts} +39 -12
- package/package.json +4 -1
- package/dist/shared-BdH3hWuP.d.ts +0 -23
- package/dist/shared-BqpFeosz.d.mts +0 -23
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/errors.ts","../../src/executors/shared.ts","../../src/executors/zcash/index.ts"],"names":[],"mappings":";AAyCO,IAAM,YAAA,GAAN,cAA2B,KAAA,CAAM;AAAA,EAGtC,YACW,IAAA,EACA,KAAA,EACT,OAAA,EACS,OAAA,GAA+B,EAAC,EACzC;AACA,IAAA,KAAA,CAAM,OAAO,CAAA;AALJ,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AACA,IAAA,IAAA,CAAA,KAAA,GAAA,KAAA;AAEA,IAAA,IAAA,CAAA,OAAA,GAAA,OAAA;AANX,IAAA,IAAA,CAAS,IAAA,GAAO,cAAA;AASd,IAAA,MAAA,CAAO,cAAA,CAAe,IAAA,EAAM,GAAA,CAAA,MAAA,CAAW,SAAS,CAAA;AAAA,EAClD;AAAA,EAEA,IAAI,SAAA,GAAqB;AACvB,IAAA,OAAO,IAAA,CAAK,QAAQ,SAAA,IAAa,KAAA;AAAA,EACnC;AAAA,EAEA,IAAI,KAAA,GAAiB;AACnB,IAAA,OAAO,KAAK,OAAA,CAAQ,KAAA;AAAA,EACtB;AAAA,EAEA,IAAI,OAAA,GAA+C;AAC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AQ;AACtB,QAAA,MAAM,IAAI,YAAA;AAAA,UACR,kBAAA;AAAA,UACA,WAAA;AAAA,UACA;AAAA,SACF;AAAA,MACF;AACA,MAAA,OAAO,QAAQ,OAAA,EAAS,UAAA,CAAW,MAAA,EAAQ,UAAA,CAAW,KAAK,OAAO,CAAA;AAAA,IACpE;AAAA,GACF;AACF;AAEA,eAAe,OAAA,CACb,OAAA,EACA,MAAA,EACA,GAAA,EACA,OAAA,EAC+B;AAC/B,EAAA,IAAI,OAAA,CAAQ,OAAA,KAAY,WAAA,IAAe,CAAC,QAAQ,kBAAA,EAAoB;AAClE,IAAA,OAAO;AAAA,MACL,MAAA,EAAQ,WAAA;AAAA,MACR,MAAA;AAAA,MACA,GAAI,GAAA,KAAQ,MAAA,GAAY,EAAE,GAAA,KAAQ;AAAC,KACrC;AAAA,EACF;AACA,EAAA,IAAI;AACF,IAAA,MAAM,YAAA,GAAe,MAAM,OAAA,CAAQ,kBAAA,CAAmB,MAAA,EAAQ;AAAA,MAC5D,QAAQ,OAAA,CAAQ;AAAA,KACjB,CAAA;AACD,IAAA,OAAO;AAAA,MACL,MAAA,EAAQ,kBAAA;AAAA,MACR,MAAA;AAAA,MACA,KAAK,YAAA,IAAgB;AAAA,KACvB;AAAA,EACF,SAAS,KAAA,EAAO;AACd,IAAA,MAAM,gBAAA;AAAA,MACJ,KAAA;AAAA,MACA,OAAA;AAAA,MACA,WAAA;AAAA,MACA,kBAAA;AAAA,MACA;AAAA,KACF;AAAA,EACF;AACF","file":"zcash.mjs","sourcesContent":["export type SwapErrorCode =\n | \"HTTP_ERROR\"\n | \"API_ERROR\"\n | \"RATE_LIMITED\"\n | \"AUTH_FAILED\"\n | \"REQUEST_ABORTED\"\n | \"REQUEST_TIMEOUT\"\n | \"INVALID_REQUEST\"\n | \"INVALID_API_RESPONSE\"\n | \"QUOTE_EXPIRED\"\n | \"ROUTE_NOT_FOUND\"\n | \"EXECUTOR_NOT_FOUND\"\n | \"UNSUPPORTED_CHAIN\"\n | \"CHAIN_MISMATCH\"\n | \"INVALID_TRANSACTION\"\n | \"USER_REJECTED\"\n | \"INSUFFICIENT_BALANCE\"\n | \"APPROVAL_FAILED\"\n | \"SIGNING_FAILED\"\n | \"BROADCAST_FAILED\"\n | \"ORDER_SUBMIT_FAILED\"\n | \"ORDER_TIMEOUT\"\n | \"REPORT_FAILED\";\n\nexport type SwapErrorStage =\n | \"quote\"\n | \"build\"\n | \"approve\"\n | \"sign\"\n | \"broadcast\"\n | \"submit\"\n | \"report\"\n | \"status\"\n | \"history\";\n\nexport interface SwapSdkErrorOptions {\n retryable?: boolean;\n cause?: unknown;\n details?: Record<string, unknown>;\n}\n\nexport class SwapSdkError extends Error {\n readonly name = \"SwapSdkError\";\n\n constructor(\n readonly code: SwapErrorCode,\n readonly stage: SwapErrorStage,\n message: string,\n readonly options: SwapSdkErrorOptions = {}\n ) {\n super(message);\n Object.setPrototypeOf(this, new.target.prototype);\n }\n\n get retryable(): boolean {\n return this.options.retryable ?? false;\n }\n\n get cause(): unknown {\n return this.options.cause;\n }\n\n get details(): Record<string, unknown> | undefined {\n return this.options.details;\n }\n}\n\nexport function asSwapSdkError(\n error: unknown,\n stage: SwapErrorStage\n): SwapSdkError {\n if (error instanceof SwapSdkError) return error;\n\n const message = error instanceof Error ? error.message : String(error);\n return new SwapSdkError(\"API_ERROR\", stage, message, { cause: error });\n}\n","import {\n SwapSdkError,\n type SwapErrorCode,\n type SwapErrorStage,\n} from \"../core/errors\";\nimport type {\n ChainExecutor,\n ExecutionContext,\n MessageSignOptions,\n} from \"../core/registry\";\nimport type { ChainRef } from \"../types/chain\";\n\nexport interface TransactionSubmission {\n txHash: string;\n raw?: unknown;\n}\n\nexport interface TransferSubmission {\n txHash?: string;\n requiresUserAction?: boolean;\n raw?: unknown;\n}\n\nexport interface ExecutorErrorAdapter {\n isUserRejection?(error: unknown): boolean;\n /** Identity serialized as `mca.signer.identityKey` for MCA quotes. */\n getIdentityKey?(): string | Promise<string>;\n /**\n * Optional offline message signing for flows such as MCA relayer withdraw.\n * Chain transfer executors do not call this during normal swap execution.\n */\n signMessage?(\n message: string,\n options?: MessageSignOptions\n ): Promise<string>;\n}\n\nexport function exposeExecutorSigner(\n signerChain: string,\n adapter: ExecutorErrorAdapter\n): Pick<\n ChainExecutor,\n \"signerChain\" | \"getIdentityKey\" | \"signMessage\"\n> {\n return {\n signerChain,\n ...(adapter.getIdentityKey\n ? { getIdentityKey: () => adapter.getIdentityKey!() }\n : {}),\n ...(adapter.signMessage\n ? {\n signMessage: (\n message: string,\n options?: MessageSignOptions\n ) => adapter.signMessage!(message, options),\n }\n : {}),\n };\n}\n\nexport function throwIfAborted(\n signal: AbortSignal | undefined,\n stage: SwapErrorStage = \"sign\"\n): void {\n if (!signal?.aborted) return;\n throw new SwapSdkError(\"REQUEST_ABORTED\", stage, \"Execution was aborted\", {\n cause: signal.reason,\n });\n}\n\nexport function assertChain(\n expected: ChainRef,\n actual: ChainRef,\n stage: SwapErrorStage = \"sign\"\n): void {\n if (expected === actual) return;\n throw new SwapSdkError(\n \"CHAIN_MISMATCH\",\n stage,\n `Connected chain ${actual} does not match execution chain ${expected}`,\n { details: { expected, actual } }\n );\n}\n\nexport async function requestSignApproval(\n context: ExecutionContext,\n chain: ChainRef,\n kind: string,\n summary: Record<string, unknown>\n): Promise<void> {\n throwIfAborted(context.signal, \"sign\");\n await context.beforeSign?.({ chain, kind, summary });\n throwIfAborted(context.signal, \"sign\");\n}\n\nexport function mapExecutorError(\n error: unknown,\n adapter: ExecutorErrorAdapter,\n stage: SwapErrorStage,\n code: SwapErrorCode,\n message: string\n): SwapSdkError {\n if (error instanceof SwapSdkError) return error;\n if (isUserRejection(error, adapter)) {\n return new SwapSdkError(\"USER_REJECTED\", stage, \"User rejected the request\", {\n cause: error,\n });\n }\n return new SwapSdkError(code, stage, message, { cause: error });\n}\n\nfunction isUserRejection(\n error: unknown,\n adapter: ExecutorErrorAdapter\n): boolean {\n if (adapter.isUserRejection?.(error)) return true;\n if (typeof error !== \"object\" || error === null) return false;\n const code = \"code\" in error ? error.code : undefined;\n if (code === 4001 || code === \"ACTION_REJECTED\") return true;\n const message =\n \"message\" in error && typeof error.message === \"string\"\n ? error.message.toLowerCase()\n : \"\";\n return /user (rejected|denied)|request rejected|cancelled by user/.test(message);\n}\n","import { SwapSdkError } from \"../../core/errors\";\nimport type {\n ChainExecutionResult,\n ChainExecutor,\n ExecutionContext,\n} from \"../../core/registry\";\nimport type { ChainRef } from \"../../types/chain\";\nimport {\n assertChain,\n exposeExecutorSigner,\n mapExecutorError,\n requestSignApproval,\n throwIfAborted,\n type ExecutorErrorAdapter,\n type TransferSubmission,\n} from \"../shared\";\n\nexport interface ZcashWalletAdapter extends ExecutorErrorAdapter {\n getChain(): ChainRef | Promise<ChainRef>;\n isAddress(address: string): boolean;\n sendTransfer(input: {\n amount: string;\n depositAddress: string;\n decimals?: number;\n signal?: AbortSignal;\n }): Promise<TransferSubmission>;\n waitForTransaction?(\n txHash: string,\n options: { signal?: AbortSignal }\n ): Promise<unknown>;\n}\n\nexport function createZcashExecutor(\n adapter: ZcashWalletAdapter\n): ChainExecutor<\"zcash-transfer\"> {\n return {\n ...exposeExecutorSigner(\"zcash\", adapter),\n kinds: [\"zcash-transfer\"],\n\n async validate(execution, context) {\n throwIfAborted(context.signal, \"sign\");\n assertChain(execution.chain, await adapter.getChain());\n if (!adapter.isAddress(execution.depositAddress)) {\n throw new SwapSdkError(\n \"INVALID_TRANSACTION\",\n \"sign\",\n \"Invalid Zcash transparent deposit address\"\n );\n }\n },\n\n async execute(execution, context) {\n await requestSignApproval(context, execution.chain, execution.kind, {\n amount: execution.amount,\n depositAddress: execution.depositAddress,\n decimals: execution.decimals,\n });\n let submission: TransferSubmission;\n try {\n submission = await adapter.sendTransfer({\n amount: execution.amount,\n depositAddress: execution.depositAddress,\n ...(execution.decimals !== undefined\n ? { decimals: execution.decimals }\n : {}),\n signal: context.signal,\n });\n } catch (error) {\n throw mapExecutorError(\n error,\n adapter,\n \"broadcast\",\n \"BROADCAST_FAILED\",\n \"Failed to submit Zcash transfer\"\n );\n }\n if (submission.requiresUserAction) {\n return {\n status: \"requires-user-action\",\n ...(submission.raw !== undefined ? { raw: submission.raw } : {}),\n };\n }\n if (!submission.txHash) {\n throw new SwapSdkError(\n \"BROADCAST_FAILED\",\n \"broadcast\",\n \"Zcash wallet returned neither a transaction hash nor user action\"\n );\n }\n return confirm(adapter, submission.txHash, submission.raw, context);\n },\n };\n}\n\nasync function confirm(\n adapter: ZcashWalletAdapter,\n txHash: string,\n raw: unknown,\n context: ExecutionContext\n): Promise<ChainExecutionResult> {\n if (context.waitFor === \"submitted\" || !adapter.waitForTransaction) {\n return {\n status: \"submitted\",\n txHash,\n ...(raw !== undefined ? { raw } : {}),\n };\n }\n try {\n const confirmation = await adapter.waitForTransaction(txHash, {\n signal: context.signal,\n });\n return {\n status: \"source-confirmed\",\n txHash,\n raw: confirmation ?? raw,\n };\n } catch (error) {\n throw mapExecutorError(\n error,\n adapter,\n \"broadcast\",\n \"BROADCAST_FAILED\",\n \"Failed while confirming Zcash transfer\"\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/core/errors.ts","../../src/executors/shared.ts","../../src/executors/zcash/index.ts"],"names":[],"mappings":";AAyCO,IAAM,YAAA,GAAN,cAA2B,KAAA,CAAM;AAAA,EAGtC,YACW,IAAA,EACA,KAAA,EACT,OAAA,EACS,OAAA,GAA+B,EAAC,EACzC;AACA,IAAA,KAAA,CAAM,OAAO,CAAA;AALJ,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AACA,IAAA,IAAA,CAAA,KAAA,GAAA,KAAA;AAEA,IAAA,IAAA,CAAA,OAAA,GAAA,OAAA;AANX,IAAA,IAAA,CAAS,IAAA,GAAO,cAAA;AASd,IAAA,MAAA,CAAO,cAAA,CAAe,IAAA,EAAM,GAAA,CAAA,MAAA,CAAW,SAAS,CAAA;AAAA,EAClD;AAAA,EAEA,IAAI,SA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MAC5D,QAAQ,OAAA,CAAQ;AAAA,KACjB,CAAA;AACD,IAAA,MAAM,eAAA,GAAkB,2BAA2B,YAAA,EAAc;AAAA,MAC/D,IAAA,EAAM,kBAAA;AAAA,MACN,KAAA,EAAO,WAAA;AAAA,MACP,OAAA,EAAS;AAAA,KACV,CAAA;AACD,IAAA,OAAO;AAAA,MACL,MAAA,EAAQ,kBAAA;AAAA,MACR,MAAA;AAAA,MACA,KAAK,eAAA,IAAmB;AAAA,KAC1B;AAAA,EACF,SAAS,KAAA,EAAO;AACd,IAAA,MAAM,gBAAA;AAAA,MACJ,KAAA;AAAA,MACA,OAAA;AAAA,MACA,WAAA;AAAA,MACA,kBAAA;AAAA,MACA;AAAA,KACF;AAAA,EACF;AACF","file":"zcash.mjs","sourcesContent":["export type SwapErrorCode =\n | \"HTTP_ERROR\"\n | \"API_ERROR\"\n | \"RATE_LIMITED\"\n | \"AUTH_FAILED\"\n | \"REQUEST_ABORTED\"\n | \"REQUEST_TIMEOUT\"\n | \"INVALID_REQUEST\"\n | \"INVALID_API_RESPONSE\"\n | \"QUOTE_EXPIRED\"\n | \"ROUTE_NOT_FOUND\"\n | \"EXECUTOR_NOT_FOUND\"\n | \"UNSUPPORTED_CHAIN\"\n | \"CHAIN_MISMATCH\"\n | \"INVALID_TRANSACTION\"\n | \"USER_REJECTED\"\n | \"INSUFFICIENT_BALANCE\"\n | \"APPROVAL_FAILED\"\n | \"SIGNING_FAILED\"\n | \"BROADCAST_FAILED\"\n | \"ORDER_SUBMIT_FAILED\"\n | \"ORDER_TIMEOUT\"\n | \"REPORT_FAILED\";\n\nexport type SwapErrorStage =\n | \"quote\"\n | \"build\"\n | \"approve\"\n | \"sign\"\n | \"broadcast\"\n | \"submit\"\n | \"report\"\n | \"status\"\n | \"history\";\n\nexport interface SwapSdkErrorOptions {\n retryable?: boolean;\n cause?: unknown;\n details?: Record<string, unknown>;\n}\n\nexport class SwapSdkError extends Error {\n readonly name = \"SwapSdkError\";\n\n constructor(\n readonly code: SwapErrorCode,\n readonly stage: SwapErrorStage,\n message: string,\n readonly options: SwapSdkErrorOptions = {}\n ) {\n super(message);\n Object.setPrototypeOf(this, new.target.prototype);\n }\n\n get retryable(): boolean {\n return this.options.retryable ?? false;\n }\n\n get cause(): unknown {\n return this.options.cause;\n }\n\n get details(): Record<string, unknown> | undefined {\n return this.options.details;\n }\n}\n\nexport function asSwapSdkError(\n error: unknown,\n stage: SwapErrorStage\n): SwapSdkError {\n if (error instanceof SwapSdkError) return error;\n\n const message = error instanceof Error ? error.message : String(error);\n return new SwapSdkError(\"API_ERROR\", stage, message, { cause: error });\n}\n","import {\n SwapSdkError,\n type SwapErrorCode,\n type SwapErrorStage,\n} from \"../core/errors\";\nimport type {\n ChainExecutor,\n ExecutionContext,\n MessageSignOptions,\n} from \"../core/registry\";\nimport type { ChainRef } from \"../types/chain\";\n\nexport interface TransactionSubmission {\n txHash: string;\n raw?: unknown;\n}\n\nexport interface TransactionConfirmation {\n status: \"confirmed\" | \"failed\";\n raw?: unknown;\n}\n\nexport interface ExecutorErrorAdapter {\n isUserRejection?(error: unknown): boolean;\n /** Identity serialized as `mca.signer.identityKey` for MCA quotes. */\n getIdentityKey?(): string | Promise<string>;\n /**\n * Optional offline message signing for flows such as MCA relayer withdraw.\n * Chain transfer executors do not call this during normal swap execution.\n */\n signMessage?(\n message: string,\n options?: MessageSignOptions\n ): Promise<string>;\n}\n\nexport function exposeExecutorSigner(\n signerChain: string,\n adapter: ExecutorErrorAdapter\n): Pick<\n ChainExecutor,\n \"signerChain\" | \"getIdentityKey\" | \"signMessage\"\n> {\n return {\n signerChain,\n ...(adapter.getIdentityKey\n ? { getIdentityKey: () => adapter.getIdentityKey!() }\n : {}),\n ...(adapter.signMessage\n ? {\n signMessage: (\n message: string,\n options?: MessageSignOptions\n ) => adapter.signMessage!(message, options),\n }\n : {}),\n };\n}\n\nexport function throwIfAborted(\n signal: AbortSignal | undefined,\n stage: SwapErrorStage = \"sign\"\n): void {\n if (!signal?.aborted) return;\n throw new SwapSdkError(\"REQUEST_ABORTED\", stage, \"Execution was aborted\", {\n cause: signal.reason,\n });\n}\n\nexport function assertChain(\n expected: ChainRef,\n actual: ChainRef,\n stage: SwapErrorStage = \"sign\"\n): void {\n if (expected === actual) return;\n throw new SwapSdkError(\n \"CHAIN_MISMATCH\",\n stage,\n `Connected chain ${actual} does not match execution chain ${expected}`,\n { details: { expected, actual } }\n );\n}\n\nexport async function requestSignApproval(\n context: ExecutionContext,\n chain: ChainRef,\n kind: string,\n summary: Record<string, unknown>\n): Promise<void> {\n throwIfAborted(context.signal, \"sign\");\n await context.beforeSign?.({ chain, kind, summary });\n throwIfAborted(context.signal, \"sign\");\n}\n\nexport function mapExecutorError(\n error: unknown,\n adapter: ExecutorErrorAdapter,\n stage: SwapErrorStage,\n code: SwapErrorCode,\n message: string\n): SwapSdkError {\n if (error instanceof SwapSdkError) return error;\n if (isUserRejection(error, adapter)) {\n return new SwapSdkError(\"USER_REJECTED\", stage, \"User rejected the request\", {\n cause: error,\n });\n }\n return new SwapSdkError(code, stage, message, { cause: error });\n}\n\nexport function assertTransactionConfirmed(\n confirmation: TransactionConfirmation,\n options: {\n code: SwapErrorCode;\n stage: SwapErrorStage;\n message: string;\n }\n): unknown {\n if (confirmation?.status === \"confirmed\") {\n return confirmation.raw;\n }\n const status =\n confirmation &&\n typeof confirmation === \"object\" &&\n \"status\" in confirmation\n ? String(confirmation.status)\n : \"missing\";\n throw new SwapSdkError(\n options.code,\n options.stage,\n `${options.message}: wallet confirmation status is ${status}`,\n {\n cause:\n confirmation &&\n typeof confirmation === \"object\" &&\n \"raw\" in confirmation\n ? confirmation.raw\n : confirmation,\n details: { confirmationStatus: status },\n }\n );\n}\n\nfunction isUserRejection(\n error: unknown,\n adapter: ExecutorErrorAdapter\n): boolean {\n if (adapter.isUserRejection?.(error)) return true;\n if (typeof error !== \"object\" || error === null) return false;\n const code = \"code\" in error ? error.code : undefined;\n if (code === 4001 || code === \"ACTION_REJECTED\") return true;\n const message =\n \"message\" in error && typeof error.message === \"string\"\n ? error.message.toLowerCase()\n : \"\";\n return /user (rejected|denied)|request rejected|cancelled by user/.test(message);\n}\n","import { SwapSdkError } from \"../../core/errors\";\nimport type {\n ChainExecutionResult,\n ChainExecutor,\n ExecutionContext,\n} from \"../../core/registry\";\nimport type { ChainRef } from \"../../types/chain\";\nimport {\n assertTransactionConfirmed,\n assertChain,\n exposeExecutorSigner,\n mapExecutorError,\n requestSignApproval,\n throwIfAborted,\n type ExecutorErrorAdapter,\n type TransactionConfirmation,\n type TransactionSubmission,\n} from \"../shared\";\n\nexport interface ZcashWalletAdapter extends ExecutorErrorAdapter {\n getChain(): ChainRef | Promise<ChainRef>;\n isAddress(address: string): boolean;\n sendTransfer(input: {\n amount: string;\n depositAddress: string;\n decimals?: number;\n signal?: AbortSignal;\n }): Promise<TransactionSubmission>;\n waitForTransaction(\n txHash: string,\n options: { signal?: AbortSignal }\n ): Promise<TransactionConfirmation>;\n}\n\nexport function createZcashExecutor(\n adapter: ZcashWalletAdapter\n): ChainExecutor<\"zcash-transfer\"> {\n return {\n ...exposeExecutorSigner(\"zcash\", adapter),\n kinds: [\"zcash-transfer\"],\n\n async validate(execution, context) {\n throwIfAborted(context.signal, \"sign\");\n assertChain(execution.chain, await adapter.getChain());\n if (!adapter.isAddress(execution.depositAddress)) {\n throw new SwapSdkError(\n \"INVALID_TRANSACTION\",\n \"sign\",\n \"Invalid Zcash transparent deposit address\"\n );\n }\n },\n\n async execute(execution, context) {\n await requestSignApproval(context, execution.chain, execution.kind, {\n amount: execution.amount,\n depositAddress: execution.depositAddress,\n decimals: execution.decimals,\n });\n let submission: TransactionSubmission;\n try {\n submission = await adapter.sendTransfer({\n amount: execution.amount,\n depositAddress: execution.depositAddress,\n ...(execution.decimals !== undefined\n ? { decimals: execution.decimals }\n : {}),\n signal: context.signal,\n });\n } catch (error) {\n throw mapExecutorError(\n error,\n adapter,\n \"broadcast\",\n \"BROADCAST_FAILED\",\n \"Failed to submit Zcash transfer\"\n );\n }\n if (!submission.txHash?.trim()) {\n throw new SwapSdkError(\n \"BROADCAST_FAILED\",\n \"broadcast\",\n \"Zcash wallet returned no transaction hash\"\n );\n }\n return confirm(adapter, submission.txHash, submission.raw, context);\n },\n };\n}\n\nasync function confirm(\n adapter: ZcashWalletAdapter,\n txHash: string,\n raw: unknown,\n context: ExecutionContext\n): Promise<ChainExecutionResult> {\n if (context.waitFor === \"submitted\") {\n return {\n status: \"submitted\",\n txHash,\n ...(raw !== undefined ? { raw } : {}),\n };\n }\n try {\n const confirmation = await adapter.waitForTransaction(txHash, {\n signal: context.signal,\n });\n const confirmationRaw = assertTransactionConfirmed(confirmation, {\n code: \"BROADCAST_FAILED\",\n stage: \"broadcast\",\n message: \"Zcash transaction failed\",\n });\n return {\n status: \"source-confirmed\",\n txHash,\n raw: confirmationRaw ?? raw,\n };\n } catch (error) {\n throw mapExecutorError(\n error,\n adapter,\n \"broadcast\",\n \"BROADCAST_FAILED\",\n \"Failed while confirming Zcash transfer\"\n );\n }\n}\n"]}
|
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, Q as QuoteRequest, l as Quote, m as SwapMcaPayloadRaw, W as WaitMode, n as SwapLifecycleEvent, o as SwapExecutionResult, C as ChainRef, A as AssetRef, B as BaseUnitAmount, p as SwapHistoryRecordRaw, q as ChainExecutor, E as ExecutorRegistry, r as SwapBuild, s as ExecuteSwapInput, t as SwapInput,
|
|
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, Q as QuoteRequest, l as Quote, m as SwapMcaPayloadRaw, W as WaitMode, O as OrderPollingOptions, n as SwapLifecycleEvent, o as SwapExecutionResult, C as ChainRef, A as AssetRef, B as BaseUnitAmount, p as SwapHistoryRecordRaw, q as ChainExecutor, E as ExecutorRegistry, r as SwapBuild, s as ExecuteSwapInput, t as SwapInput, u as OrderStatusResult, v as WaitForOrderInput, N as NearTransaction, w as SwapMcaRelayerRequestRaw } from './shared-BEZXY_BM.mjs';
|
|
2
|
+
export { a3 as BuildContext, K as ChainExecutionResult, $ as DepositInfo, X as EvmApproval, Y as EvmSigningRequest, V as EvmTx, L as ExecutionContext, P as ExecutorIdentityProvider, R as ExecutorMessageSigner, M as MessageSignOptions, _ as OrderReference, I as OrderStatus, a2 as RouteSummary, H as SignRequestPreview, Z as SolanaMetadata, x as SwapApiResponse, y as SwapApiTokenMetaRaw, F as SwapBuildApproveRaw, a1 as SwapExecution, z as SwapMcaSignerPayloadRaw, a0 as SwapReportContext, D as SwapSigningRequestRaw, G as SwapWarning, T as TransactionConfirmation, U as assertBaseUnitAmount, J as normalizeOrderStatus } from './shared-BEZXY_BM.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" | "history";
|
|
@@ -140,6 +140,7 @@ type McaQuote = McaDepositQuote | McaWithdrawNearQuote | McaWithdrawRelayerQuote
|
|
|
140
140
|
interface McaSwapInput {
|
|
141
141
|
quote: McaQuote;
|
|
142
142
|
waitFor?: WaitMode;
|
|
143
|
+
orderPolling?: OrderPollingOptions;
|
|
143
144
|
signal?: AbortSignal;
|
|
144
145
|
idempotencyKey?: string;
|
|
145
146
|
onEvent?: (event: SwapLifecycleEvent) => void;
|
|
@@ -303,4 +304,4 @@ declare function buildMcaWithdrawRelayerRequest(input: BuildMcaWithdrawRelayerRe
|
|
|
303
304
|
declare function parseUnits(value: string, decimals: number): BaseUnitAmount;
|
|
304
305
|
declare function formatUnits(value: BaseUnitAmount, decimals: number): string;
|
|
305
306
|
|
|
306
|
-
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, OrderStatusResult, Quote, QuoteRequest, type ResolveMcaWithdrawPolicyInput, type RetryConfig, type SdkLogEntry, type SdkLogLevel, type SdkLogger, SwapBuild, SwapBuildDataRaw, SwapBuildRequestRaw, SwapClient, type SwapClientConfig, type SwapErrorCode, type SwapErrorStage, SwapExecutionResult, SwapHistoryDataRaw, type SwapHistoryItem, type SwapHistoryPage, SwapHistoryParamsRaw, SwapHistoryRecordRaw, SwapInput, SwapLifecycleEvent, SwapMcaPayloadRaw, SwapMcaRelayerRequestRaw, SwapOrderStatusDataRaw, SwapOrderStatusParamsRaw, SwapOrderSubmitDataRaw, SwapOrderSubmitRequestRaw, SwapQuoteDataRaw, SwapQuoteRequestRaw, SwapReportDataRaw, SwapReportRequestRaw, SwapSdkError, type SwapSdkErrorOptions, WaitForOrderInput, WaitMode, asSwapSdkError, buildMcaWithdrawRelayerRequest, buildNearMcaWithdrawTransactions, createExecutionId, extractMcaWithdrawBusiness, extractMcaWithdrawDepositAddress, extractMcaWithdrawSignerWallet, formatMcaWallet, formatUnits, fromApiChain, isSameMcaSignerIdentity, normalizeBuild, normalizeHistory, normalizeHistoryStatus, normalizeMcaQuote, normalizeQuote, parseUnits, resolveMcaWithdrawPolicy, selectMcaSigner, serializeMcaQuoteRequest, serializeQuoteRequest, toApiAssetAddress, toApiChain };
|
|
307
|
+
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 ResolveMcaWithdrawPolicyInput, type RetryConfig, type SdkLogEntry, type SdkLogLevel, type SdkLogger, SwapBuild, SwapBuildDataRaw, SwapBuildRequestRaw, SwapClient, type SwapClientConfig, type SwapErrorCode, type SwapErrorStage, SwapExecutionResult, SwapHistoryDataRaw, type SwapHistoryItem, type SwapHistoryPage, SwapHistoryParamsRaw, SwapHistoryRecordRaw, SwapInput, SwapLifecycleEvent, SwapMcaPayloadRaw, SwapMcaRelayerRequestRaw, SwapOrderStatusDataRaw, SwapOrderStatusParamsRaw, SwapOrderSubmitDataRaw, SwapOrderSubmitRequestRaw, SwapQuoteDataRaw, SwapQuoteRequestRaw, SwapReportDataRaw, SwapReportRequestRaw, SwapSdkError, type SwapSdkErrorOptions, WaitForOrderInput, WaitMode, asSwapSdkError, buildMcaWithdrawRelayerRequest, buildNearMcaWithdrawTransactions, createExecutionId, extractMcaWithdrawBusiness, extractMcaWithdrawDepositAddress, extractMcaWithdrawSignerWallet, formatMcaWallet, formatUnits, fromApiChain, isSameMcaSignerIdentity, normalizeBuild, normalizeHistory, normalizeHistoryStatus, normalizeMcaQuote, normalizeQuote, parseUnits, resolveMcaWithdrawPolicy, 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, Q as QuoteRequest, l as Quote, m as SwapMcaPayloadRaw, W as WaitMode, n as SwapLifecycleEvent, o as SwapExecutionResult, C as ChainRef, A as AssetRef, B as BaseUnitAmount, p as SwapHistoryRecordRaw, q as ChainExecutor, E as ExecutorRegistry, r as SwapBuild, s as ExecuteSwapInput, t as SwapInput,
|
|
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, Q as QuoteRequest, l as Quote, m as SwapMcaPayloadRaw, W as WaitMode, O as OrderPollingOptions, n as SwapLifecycleEvent, o as SwapExecutionResult, C as ChainRef, A as AssetRef, B as BaseUnitAmount, p as SwapHistoryRecordRaw, q as ChainExecutor, E as ExecutorRegistry, r as SwapBuild, s as ExecuteSwapInput, t as SwapInput, u as OrderStatusResult, v as WaitForOrderInput, N as NearTransaction, w as SwapMcaRelayerRequestRaw } from './shared-BEZXY_BM.js';
|
|
2
|
+
export { a3 as BuildContext, K as ChainExecutionResult, $ as DepositInfo, X as EvmApproval, Y as EvmSigningRequest, V as EvmTx, L as ExecutionContext, P as ExecutorIdentityProvider, R as ExecutorMessageSigner, M as MessageSignOptions, _ as OrderReference, I as OrderStatus, a2 as RouteSummary, H as SignRequestPreview, Z as SolanaMetadata, x as SwapApiResponse, y as SwapApiTokenMetaRaw, F as SwapBuildApproveRaw, a1 as SwapExecution, z as SwapMcaSignerPayloadRaw, a0 as SwapReportContext, D as SwapSigningRequestRaw, G as SwapWarning, T as TransactionConfirmation, U as assertBaseUnitAmount, J as normalizeOrderStatus } from './shared-BEZXY_BM.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" | "history";
|
|
@@ -140,6 +140,7 @@ type McaQuote = McaDepositQuote | McaWithdrawNearQuote | McaWithdrawRelayerQuote
|
|
|
140
140
|
interface McaSwapInput {
|
|
141
141
|
quote: McaQuote;
|
|
142
142
|
waitFor?: WaitMode;
|
|
143
|
+
orderPolling?: OrderPollingOptions;
|
|
143
144
|
signal?: AbortSignal;
|
|
144
145
|
idempotencyKey?: string;
|
|
145
146
|
onEvent?: (event: SwapLifecycleEvent) => void;
|
|
@@ -303,4 +304,4 @@ declare function buildMcaWithdrawRelayerRequest(input: BuildMcaWithdrawRelayerRe
|
|
|
303
304
|
declare function parseUnits(value: string, decimals: number): BaseUnitAmount;
|
|
304
305
|
declare function formatUnits(value: BaseUnitAmount, decimals: number): string;
|
|
305
306
|
|
|
306
|
-
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, OrderStatusResult, Quote, QuoteRequest, type ResolveMcaWithdrawPolicyInput, type RetryConfig, type SdkLogEntry, type SdkLogLevel, type SdkLogger, SwapBuild, SwapBuildDataRaw, SwapBuildRequestRaw, SwapClient, type SwapClientConfig, type SwapErrorCode, type SwapErrorStage, SwapExecutionResult, SwapHistoryDataRaw, type SwapHistoryItem, type SwapHistoryPage, SwapHistoryParamsRaw, SwapHistoryRecordRaw, SwapInput, SwapLifecycleEvent, SwapMcaPayloadRaw, SwapMcaRelayerRequestRaw, SwapOrderStatusDataRaw, SwapOrderStatusParamsRaw, SwapOrderSubmitDataRaw, SwapOrderSubmitRequestRaw, SwapQuoteDataRaw, SwapQuoteRequestRaw, SwapReportDataRaw, SwapReportRequestRaw, SwapSdkError, type SwapSdkErrorOptions, WaitForOrderInput, WaitMode, asSwapSdkError, buildMcaWithdrawRelayerRequest, buildNearMcaWithdrawTransactions, createExecutionId, extractMcaWithdrawBusiness, extractMcaWithdrawDepositAddress, extractMcaWithdrawSignerWallet, formatMcaWallet, formatUnits, fromApiChain, isSameMcaSignerIdentity, normalizeBuild, normalizeHistory, normalizeHistoryStatus, normalizeMcaQuote, normalizeQuote, parseUnits, resolveMcaWithdrawPolicy, selectMcaSigner, serializeMcaQuoteRequest, serializeQuoteRequest, toApiAssetAddress, toApiChain };
|
|
307
|
+
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 ResolveMcaWithdrawPolicyInput, type RetryConfig, type SdkLogEntry, type SdkLogLevel, type SdkLogger, SwapBuild, SwapBuildDataRaw, SwapBuildRequestRaw, SwapClient, type SwapClientConfig, type SwapErrorCode, type SwapErrorStage, SwapExecutionResult, SwapHistoryDataRaw, type SwapHistoryItem, type SwapHistoryPage, SwapHistoryParamsRaw, SwapHistoryRecordRaw, SwapInput, SwapLifecycleEvent, SwapMcaPayloadRaw, SwapMcaRelayerRequestRaw, SwapOrderStatusDataRaw, SwapOrderStatusParamsRaw, SwapOrderSubmitDataRaw, SwapOrderSubmitRequestRaw, SwapQuoteDataRaw, SwapQuoteRequestRaw, SwapReportDataRaw, SwapReportRequestRaw, SwapSdkError, type SwapSdkErrorOptions, WaitForOrderInput, WaitMode, asSwapSdkError, buildMcaWithdrawRelayerRequest, buildNearMcaWithdrawTransactions, createExecutionId, extractMcaWithdrawBusiness, extractMcaWithdrawDepositAddress, extractMcaWithdrawSignerWallet, formatMcaWallet, formatUnits, fromApiChain, isSameMcaSignerIdentity, normalizeBuild, normalizeHistory, normalizeHistoryStatus, normalizeMcaQuote, normalizeQuote, parseUnits, resolveMcaWithdrawPolicy, selectMcaSigner, serializeMcaQuoteRequest, serializeQuoteRequest, toApiAssetAddress, toApiChain };
|
package/dist/index.js
CHANGED
|
@@ -303,7 +303,11 @@ var ApiClient = class {
|
|
|
303
303
|
}
|
|
304
304
|
}
|
|
305
305
|
isEnvelope(value) {
|
|
306
|
-
|
|
306
|
+
if (typeof value !== "object" || value === null) return false;
|
|
307
|
+
if (!("code" in value) || typeof value.code !== "number") return false;
|
|
308
|
+
if (!("msg" in value) || typeof value.msg !== "string") return false;
|
|
309
|
+
if (value.code === 0 && !("data" in value)) return false;
|
|
310
|
+
return true;
|
|
307
311
|
}
|
|
308
312
|
readMessage(value) {
|
|
309
313
|
if (typeof value !== "object" || value === null || !("msg" in value)) {
|
|
@@ -512,16 +516,37 @@ function unsupportedChain(chain) {
|
|
|
512
516
|
var decimalStringSchema = zod.z.string().regex(/^(0|[1-9]\d*)$/);
|
|
513
517
|
var nonEmptyStringSchema = zod.z.string().trim().min(1);
|
|
514
518
|
var hexDataSchema = zod.z.string().regex(/^0x(?:[0-9a-fA-F]{2})*$/);
|
|
515
|
-
|
|
519
|
+
zod.z.number().int().positive();
|
|
520
|
+
var evmChainIdSchema = zod.z.preprocess((value) => {
|
|
521
|
+
if (typeof value !== "string") return value;
|
|
522
|
+
const normalized = value.trim();
|
|
523
|
+
if (!/^(?:[1-9]\d*|0x[0-9a-fA-F]+)$/.test(normalized)) {
|
|
524
|
+
return value;
|
|
525
|
+
}
|
|
526
|
+
try {
|
|
527
|
+
const parsed = BigInt(normalized);
|
|
528
|
+
return parsed <= BigInt(Number.MAX_SAFE_INTEGER) ? Number(parsed) : value;
|
|
529
|
+
} catch {
|
|
530
|
+
return value;
|
|
531
|
+
}
|
|
532
|
+
}, zod.z.number().int().positive().max(Number.MAX_SAFE_INTEGER));
|
|
516
533
|
var evmQuantitySchema = zod.z.string().regex(/^(?:0|[1-9]\d*|0x[0-9a-fA-F]+)$/).transform(
|
|
517
534
|
(value) => value.startsWith("0x") ? BigInt(value).toString() : value
|
|
518
535
|
);
|
|
536
|
+
var optionalEvmQuantitySchema = zod.z.preprocess(
|
|
537
|
+
(value) => value === null || value === void 0 || value === "" ? void 0 : value,
|
|
538
|
+
evmQuantitySchema.optional()
|
|
539
|
+
);
|
|
519
540
|
var evmTxSchema = zod.z.object({
|
|
520
541
|
to: nonEmptyStringSchema,
|
|
521
542
|
data: hexDataSchema,
|
|
522
543
|
value: evmQuantitySchema,
|
|
523
|
-
gasLimit:
|
|
524
|
-
|
|
544
|
+
gasLimit: optionalEvmQuantitySchema,
|
|
545
|
+
gasPrice: optionalEvmQuantitySchema,
|
|
546
|
+
maxFeePerGas: optionalEvmQuantitySchema,
|
|
547
|
+
maxPriorityFeePerGas: optionalEvmQuantitySchema,
|
|
548
|
+
from: nonEmptyStringSchema.optional(),
|
|
549
|
+
chainId: evmChainIdSchema
|
|
525
550
|
});
|
|
526
551
|
|
|
527
552
|
// src/normalizers/build.ts
|
|
@@ -546,7 +571,7 @@ var signingRequestSchema = zod.z.object({
|
|
|
546
571
|
type: nonEmptyStringSchema,
|
|
547
572
|
router: nonEmptyStringSchema,
|
|
548
573
|
quoteId: nonEmptyStringSchema,
|
|
549
|
-
chainId:
|
|
574
|
+
chainId: evmChainIdSchema,
|
|
550
575
|
signingScheme: zod.z.string().optional(),
|
|
551
576
|
typedData: zod.z.object({
|
|
552
577
|
domain: zod.z.record(zod.z.string(), zod.z.unknown()),
|
|
@@ -752,11 +777,20 @@ function normalizeEvmApproval(raw, chain) {
|
|
|
752
777
|
assertEvmChainId(chain, approveTx.chainId);
|
|
753
778
|
return {
|
|
754
779
|
tx: approveTx,
|
|
755
|
-
spender: nonEmptyStringSchema.parse(raw.approve.spender)
|
|
780
|
+
spender: readErc20ApproveSpender(approveTx.data) ?? nonEmptyStringSchema.parse(raw.approve.spender)
|
|
756
781
|
};
|
|
757
782
|
}
|
|
758
783
|
return void 0;
|
|
759
784
|
}
|
|
785
|
+
function readErc20ApproveSpender(data) {
|
|
786
|
+
const normalized = data.toLowerCase();
|
|
787
|
+
if (!normalized.startsWith("0x095ea7b3") || normalized.length < 10 + 64) {
|
|
788
|
+
return void 0;
|
|
789
|
+
}
|
|
790
|
+
const addressWord = normalized.slice(10, 10 + 64);
|
|
791
|
+
if (!/^[0-9a-f]{64}$/.test(addressWord)) return void 0;
|
|
792
|
+
return `0x${addressWord.slice(24)}`;
|
|
793
|
+
}
|
|
760
794
|
function laneFromChainType(chainType, fromChain) {
|
|
761
795
|
const normalized = chainType.toLowerCase();
|
|
762
796
|
const aliases = {
|
|
@@ -772,7 +806,9 @@ function laneFromChainType(chainType, fromChain) {
|
|
|
772
806
|
zec: "zcash",
|
|
773
807
|
sui: "sui"
|
|
774
808
|
};
|
|
775
|
-
if (normalized === "cross-chain"
|
|
809
|
+
if (normalized === "cross-chain" || normalized === "utxo") {
|
|
810
|
+
return laneFromChain(fromChain);
|
|
811
|
+
}
|
|
776
812
|
const lane = aliases[normalized];
|
|
777
813
|
if (!lane) {
|
|
778
814
|
throw new SwapSdkError(
|
|
@@ -1639,6 +1675,7 @@ var McaSwapService = class {
|
|
|
1639
1675
|
const result = await this.client.executeSwap({
|
|
1640
1676
|
build,
|
|
1641
1677
|
waitFor: input.quote.executionMode === "withdraw-near" && input.waitFor === "completed" ? "source-confirmed" : input.waitFor,
|
|
1678
|
+
orderPolling: input.orderPolling,
|
|
1642
1679
|
signal: input.signal,
|
|
1643
1680
|
onEvent: input.onEvent
|
|
1644
1681
|
});
|
|
@@ -1646,6 +1683,7 @@ var McaSwapService = class {
|
|
|
1646
1683
|
const status = await this.client.waitForOrder({
|
|
1647
1684
|
orderId: nearStatusKey,
|
|
1648
1685
|
router: input.quote.route.router,
|
|
1686
|
+
...input.orderPolling,
|
|
1649
1687
|
signal: input.signal
|
|
1650
1688
|
});
|
|
1651
1689
|
this.emitEvent(
|
|
@@ -1887,6 +1925,7 @@ var McaSwapService = class {
|
|
|
1887
1925
|
const status = await this.client.waitForOrder({
|
|
1888
1926
|
orderId,
|
|
1889
1927
|
router,
|
|
1928
|
+
...input.orderPolling,
|
|
1890
1929
|
signal: input.signal
|
|
1891
1930
|
});
|
|
1892
1931
|
emit({ type: "order-status", executionId, status: status.status });
|
|
@@ -2110,24 +2149,17 @@ var SwapClient = class {
|
|
|
2110
2149
|
report: { status: "skipped" },
|
|
2111
2150
|
raw: chainResult.raw ?? build.raw
|
|
2112
2151
|
};
|
|
2113
|
-
|
|
2152
|
+
emit({
|
|
2153
|
+
type: "submitted",
|
|
2154
|
+
executionId: build.executionId,
|
|
2155
|
+
...chainResult.txHash ? { txHash: chainResult.txHash } : {},
|
|
2156
|
+
...orderId ? { orderId } : {}
|
|
2157
|
+
});
|
|
2158
|
+
if (chainResult.status === "source-confirmed") {
|
|
2114
2159
|
emit({
|
|
2115
|
-
type: "
|
|
2160
|
+
type: "source-confirmed",
|
|
2116
2161
|
executionId: build.executionId
|
|
2117
2162
|
});
|
|
2118
|
-
} else {
|
|
2119
|
-
emit({
|
|
2120
|
-
type: "submitted",
|
|
2121
|
-
executionId: build.executionId,
|
|
2122
|
-
...chainResult.txHash ? { txHash: chainResult.txHash } : {},
|
|
2123
|
-
...orderId ? { orderId } : {}
|
|
2124
|
-
});
|
|
2125
|
-
if (chainResult.status === "source-confirmed") {
|
|
2126
|
-
emit({
|
|
2127
|
-
type: "source-confirmed",
|
|
2128
|
-
executionId: build.executionId
|
|
2129
|
-
});
|
|
2130
|
-
}
|
|
2131
2163
|
}
|
|
2132
2164
|
const reportRequest = this.createReportRequest(build, result);
|
|
2133
2165
|
if (reportRequest) {
|
|
@@ -2152,6 +2184,7 @@ var SwapClient = class {
|
|
|
2152
2184
|
orderId,
|
|
2153
2185
|
router: orderRouter ?? build.router,
|
|
2154
2186
|
chainId: orderChainId,
|
|
2187
|
+
...input.orderPolling,
|
|
2155
2188
|
signal: input.signal
|
|
2156
2189
|
});
|
|
2157
2190
|
result.status = status.status === "unknown" || status.status === "pending" ? "processing" : status.status;
|
|
@@ -2181,6 +2214,7 @@ var SwapClient = class {
|
|
|
2181
2214
|
return this.executeSwap({
|
|
2182
2215
|
build,
|
|
2183
2216
|
waitFor: regularInput.waitFor,
|
|
2217
|
+
orderPolling: regularInput.orderPolling,
|
|
2184
2218
|
signal: regularInput.signal,
|
|
2185
2219
|
onEvent: regularInput.onEvent,
|
|
2186
2220
|
beforeSign: regularInput.beforeSign
|
|
@@ -2204,8 +2238,8 @@ var SwapClient = class {
|
|
|
2204
2238
|
}
|
|
2205
2239
|
async waitForOrder(input) {
|
|
2206
2240
|
const intervalMs = input.intervalMs ?? 5e3;
|
|
2207
|
-
const timeoutMs = input.timeoutMs
|
|
2208
|
-
const startedAt = this.now();
|
|
2241
|
+
const timeoutMs = input.timeoutMs;
|
|
2242
|
+
const startedAt = timeoutMs === void 0 ? void 0 : this.now();
|
|
2209
2243
|
for (; ; ) {
|
|
2210
2244
|
if (input.signal?.aborted) {
|
|
2211
2245
|
throw new SwapSdkError(
|
|
@@ -2218,7 +2252,7 @@ var SwapClient = class {
|
|
|
2218
2252
|
if (result.status === "completed" || result.status === "failed" || result.status === "refunded" || result.status === "expired") {
|
|
2219
2253
|
return result;
|
|
2220
2254
|
}
|
|
2221
|
-
if (this.now() - startedAt >= timeoutMs) {
|
|
2255
|
+
if (timeoutMs !== void 0 && startedAt !== void 0 && this.now() - startedAt >= timeoutMs) {
|
|
2222
2256
|
throw new SwapSdkError(
|
|
2223
2257
|
"ORDER_TIMEOUT",
|
|
2224
2258
|
"status",
|