@rhea-finance/cross-chain-aggregation-dex 2.0.5 → 2.0.7
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 +148 -71
- package/dist/executors/aptos.d.mts +1 -1
- package/dist/executors/aptos.d.ts +1 -1
- package/dist/executors/aptos.js.map +1 -1
- 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.map +1 -1
- 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.map +1 -1
- 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.map +1 -1
- 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.map +1 -1
- 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.map +1 -1
- package/dist/executors/sui.mjs.map +1 -1
- package/dist/executors/tron.d.mts +1 -1
- package/dist/executors/tron.d.ts +1 -1
- package/dist/executors/tron.js.map +1 -1
- 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.map +1 -1
- package/dist/executors/zcash.mjs.map +1 -1
- package/dist/index.d.mts +40 -6
- package/dist/index.d.ts +40 -6
- package/dist/index.js +266 -47
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +265 -48
- package/dist/index.mjs.map +1 -1
- package/dist/{shared-DmMJXknE.d.mts → shared-COkGiqaz.d.mts} +30 -2
- package/dist/{shared-DmMJXknE.d.ts → shared-COkGiqaz.d.ts} +30 -2
- package/package.json +1 -1
|
@@ -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;AACjD,IAAA,OAAO,KAAK,OAAA,CAAQ,OAAA;AAAA,EACtB;AACF,CAAA;;;AC7BO,SAAS,oBAAA,CACd,aACA,OAAA,EAIA;AACA,EAAA,OAAO;AAAA,IACL,WAAA;AAAA,IACA,GAAI,OAAA,CAAQ,cAAA,GACR,EAAE,cAAA,EAAgB,MAAM,OAAA,CAAQ,cAAA,EAAgB,EAAE,GAClD,EAAC;AAAA,IACL,GAAI,QAAQ,WAAA,GACR;AAAA,MACE,aAAa,CACX,OAAA,EACA,YACG,OAAA,CAAQ,WAAA,CAAa,SAAS,OAAO;AAAA,QAE5C;AAAC,GACP;AACF;AAEO,SAAS,cAAA,CACd,MAAA,EACA,KAAA,GAAwB,MAAA,EAClB;AACN,EAAA,IAAI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M,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,YAAY,WAAA,EAAa;AACnC,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,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"]}
|
|
1
|
+
{"version":3,"sources":["../../src/core/errors.ts","../../src/executors/shared.ts","../../src/executors/zcash/index.ts"],"names":[],"mappings":";AA0CO,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;AACjD,IAAA,OAAO,KAAK,OAAA,CAAQ,OAAA;AAAA,EACtB;AACF,CAAA;;;AC9BO,SAAS,oBAAA,CACd,aACA,OAAA,EAIA;AACA,EAAA,OAAO;AAAA,IACL,WAAA;AAAA,IACA,GAAI,OAAA,CAAQ,cAAA,GACR,EAAE,cAAA,EAAgB,MAAM,OAAA,CAAQ,cAAA,EAAgB,EAAE,GAClD,EAAC;AAAA,IACL,GAAI,QAAQ,WAAA,GACR;AAAA,MACE,aAAa,CACX,OAAA,EACA,YACG,OAAA,CAAQ,WAAA,CAAa,SAAS,OAAO;AAAA,QAE5C;AAAC,GACP;AACF;AAEO,SAAS,cAAA,CACd,MAAA,EACA,KAAA,GAAwB,MAAA,EAClB;AACN,EAAA,IAAI,CAAC,QAAQ,OAAA,EAAS;AACtB,EAAA,MAAM,I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AA;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,YAAY,WAAA,EAAa;AACnC,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,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 | \"tokens\"\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,8 +1,8 @@
|
|
|
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, Q as QuoteRequest,
|
|
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 OrderStatusResult, F as WaitForOrderInput, G as SwapHistoryAuthProofRaw, N as NearTransaction, H as SwapMcaRelayerRequestRaw } from './shared-COkGiqaz.mjs';
|
|
2
|
+
export { ac as BuildContext, Z as ChainExecutionResult, a8 as DepositInfo, a4 as EvmApproval, a5 as EvmSigningRequest, a3 as EvmTx, _ as ExecutionContext, a0 as ExecutorIdentityProvider, a1 as ExecutorMessageSigner, $ as MessageSignOptions, a7 as OrderReference, X as OrderStatus, ab as RouteSummary, V as SignRequestPreview, a6 as SolanaMetadata, I as SwapApiResponse, J as SwapApiTokenMetaRaw, P as SwapBuildApproveRaw, aa as SwapExecution, R as SwapHistoryWalletChainFamilyRaw, L as SwapMcaSignerPayloadRaw, a9 as SwapReportContext, M as SwapSigningRequestRaw, K as SwapTokenListRowRaw, U as SwapWarning, T as TransactionConfirmation, a2 as assertBaseUnitAmount, Y as normalizeOrderStatus } from './shared-COkGiqaz.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
|
-
type SwapErrorStage = "quote" | "build" | "approve" | "sign" | "broadcast" | "submit" | "report" | "status" | "history";
|
|
5
|
+
type SwapErrorStage = "quote" | "build" | "approve" | "sign" | "broadcast" | "submit" | "report" | "status" | "tokens" | "history";
|
|
6
6
|
interface SwapSdkErrorOptions {
|
|
7
7
|
retryable?: boolean;
|
|
8
8
|
cause?: unknown;
|
|
@@ -68,6 +68,8 @@ declare class ApiClient {
|
|
|
68
68
|
getHistory(params: SwapHistoryParamsRaw, options?: ApiRequestOptions): Promise<SwapHistoryDataRaw>;
|
|
69
69
|
createHistoryAuthChallenge(body: SwapHistoryAuthChallengeRequestRaw, options?: ApiRequestOptions): Promise<SwapHistoryAuthChallengeRaw>;
|
|
70
70
|
verifyHistoryAuthChallenge(body: SwapHistoryAuthVerifyRequestRaw, options?: ApiRequestOptions): Promise<SwapHistoryAuthTokenRaw>;
|
|
71
|
+
getFromTokenRows(chainId: number, options?: ApiRequestOptions): Promise<SwapFromTokensDataRaw>;
|
|
72
|
+
getCrossChainToTokenRows(chainId: number, options?: ApiRequestOptions): Promise<SwapCrossChainToTokensDataRaw>;
|
|
71
73
|
private request;
|
|
72
74
|
private requestOnce;
|
|
73
75
|
private buildUrl;
|
|
@@ -204,12 +206,37 @@ interface SwapHistoryItem {
|
|
|
204
206
|
raw: SwapHistoryRecordRaw;
|
|
205
207
|
}
|
|
206
208
|
|
|
209
|
+
interface TokenListRequest {
|
|
210
|
+
/** Numeric ID accepted by the token-list endpoints. */
|
|
211
|
+
chainId: number;
|
|
212
|
+
}
|
|
213
|
+
interface SwapTokenListItem extends AssetRef {
|
|
214
|
+
chain: ChainRef;
|
|
215
|
+
/** Token identifier accepted by the unified quote API. */
|
|
216
|
+
address: string;
|
|
217
|
+
symbol: string;
|
|
218
|
+
decimals: number;
|
|
219
|
+
isNative: boolean;
|
|
220
|
+
tokenListChainId: number;
|
|
221
|
+
blockchain: string;
|
|
222
|
+
assetId: string;
|
|
223
|
+
contractAddress: string | null;
|
|
224
|
+
coinType: string | null;
|
|
225
|
+
name: string | null;
|
|
226
|
+
logoURI: string | null;
|
|
227
|
+
price: string | number | null;
|
|
228
|
+
priceUpdatedAt: number | null;
|
|
229
|
+
sources: string[];
|
|
230
|
+
raw: Record<string, unknown>;
|
|
231
|
+
}
|
|
232
|
+
|
|
207
233
|
interface SwapClientConfig extends ApiClientConfig {
|
|
208
|
-
maxQuoteAgeMs?: number | null;
|
|
209
234
|
reportMode?: "auto" | "manual" | "disabled";
|
|
210
235
|
executors?: readonly ChainExecutor[];
|
|
211
236
|
onEvent?: (event: SwapLifecycleEvent) => void;
|
|
212
237
|
now?: () => number;
|
|
238
|
+
/** Token-list cache lifetime in milliseconds. Defaults to 10 minutes; use 0 to disable. */
|
|
239
|
+
tokenListCacheTtlMs?: number;
|
|
213
240
|
}
|
|
214
241
|
interface BuildSwapInput {
|
|
215
242
|
quote: Quote;
|
|
@@ -225,12 +252,17 @@ declare class SwapClient {
|
|
|
225
252
|
private readonly now;
|
|
226
253
|
private readonly inFlight;
|
|
227
254
|
private readonly reportRequests;
|
|
255
|
+
private readonly tokenListCache;
|
|
256
|
+
private readonly tokenListInflight;
|
|
228
257
|
constructor(config: SwapClientConfig);
|
|
229
258
|
quoteRaw(request: SwapQuoteRequestRaw, options?: ApiRequestOptions): Promise<SwapQuoteDataRaw>;
|
|
230
259
|
quote(request: McaQuoteRequest, options?: ApiRequestOptions): Promise<McaQuote>;
|
|
231
260
|
quote(request: QuoteRequest, options?: ApiRequestOptions): Promise<Quote>;
|
|
232
261
|
private quoteStandard;
|
|
233
262
|
buildRaw(request: SwapBuildRequestRaw, options?: ApiRequestOptions): Promise<SwapBuildDataRaw>;
|
|
263
|
+
getFromTokens(request: TokenListRequest, options?: ApiRequestOptions): Promise<SwapTokenListItem[]>;
|
|
264
|
+
getCrossChainToTokens(request: TokenListRequest, options?: ApiRequestOptions): Promise<SwapTokenListItem[]>;
|
|
265
|
+
private loadTokenList;
|
|
234
266
|
buildSwap(input: BuildSwapInput): Promise<SwapBuild>;
|
|
235
267
|
private buildStandardSwap;
|
|
236
268
|
executeSwap(input: ExecuteSwapInput): Promise<SwapExecutionResult>;
|
|
@@ -254,7 +286,6 @@ declare class SwapClient {
|
|
|
254
286
|
authorizeConfidentialHistory(request: SwapHistoryAuthChallengeRequestRaw, signChallenge: (challenge: SwapHistoryAuthChallengeRaw) => SwapHistoryAuthProofRaw | Promise<SwapHistoryAuthProofRaw>, options?: ApiRequestOptions): Promise<SwapHistoryAuthTokenRaw>;
|
|
255
287
|
getHistory(request: HistoryRequest, options?: ApiRequestOptions): Promise<SwapHistoryPage>;
|
|
256
288
|
protected emit(event: SwapLifecycleEvent): void;
|
|
257
|
-
private assertQuoteFresh;
|
|
258
289
|
private createReportRequest;
|
|
259
290
|
}
|
|
260
291
|
|
|
@@ -271,6 +302,9 @@ declare function normalizeHistoryStatus(status: unknown): HistoryStatus;
|
|
|
271
302
|
declare function serializeQuoteRequest(request: QuoteRequest): SwapQuoteRequestRaw;
|
|
272
303
|
declare function normalizeQuote(request: QuoteRequest, raw: SwapQuoteDataRaw, receivedAt?: number): Quote;
|
|
273
304
|
|
|
305
|
+
declare function normalizeFromTokenList(raw: SwapFromTokensDataRaw, chainId: number): SwapTokenListItem[];
|
|
306
|
+
declare function normalizeCrossChainToTokenList(raw: SwapCrossChainToTokensDataRaw, chainId: number): SwapTokenListItem[];
|
|
307
|
+
|
|
274
308
|
interface ResolveMcaWithdrawPolicyInput {
|
|
275
309
|
/** Requested withdraw amount in Burrow internal decimals. */
|
|
276
310
|
amountBurrow: string;
|
|
@@ -344,4 +378,4 @@ declare function buildMcaWithdrawRelayerRequest(input: BuildMcaWithdrawRelayerRe
|
|
|
344
378
|
declare function parseUnits(value: string, decimals: number): BaseUnitAmount;
|
|
345
379
|
declare function formatUnits(value: BaseUnitAmount, decimals: number): string;
|
|
346
380
|
|
|
347
|
-
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, type SwapErrorCode, type SwapErrorStage, SwapExecutionResult, 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, WaitForOrderInput, WaitMode, asSwapSdkError, buildMcaWithdrawRelayerRequest, buildNearMcaWithdrawTransactions, createExecutionId, extractMcaWithdrawBusiness, extractMcaWithdrawDepositAddress, extractMcaWithdrawSignerWallet, formatMcaWallet, formatUnits, fromApiChain, isSameMcaSignerIdentity, normalizeBuild, normalizeHistory, normalizeHistoryStatus, normalizeMcaQuote, normalizeQuote, parseUnits, resolveMcaDecreaseCollateral, resolveMcaRequiredCollateralDecrease, resolveMcaWithdrawPolicy, selectMcaSigner, serializeMcaQuoteRequest, serializeQuoteRequest, toApiAssetAddress, toApiChain };
|
|
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
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, Q as QuoteRequest,
|
|
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 OrderStatusResult, F as WaitForOrderInput, G as SwapHistoryAuthProofRaw, N as NearTransaction, H as SwapMcaRelayerRequestRaw } from './shared-COkGiqaz.js';
|
|
2
|
+
export { ac as BuildContext, Z as ChainExecutionResult, a8 as DepositInfo, a4 as EvmApproval, a5 as EvmSigningRequest, a3 as EvmTx, _ as ExecutionContext, a0 as ExecutorIdentityProvider, a1 as ExecutorMessageSigner, $ as MessageSignOptions, a7 as OrderReference, X as OrderStatus, ab as RouteSummary, V as SignRequestPreview, a6 as SolanaMetadata, I as SwapApiResponse, J as SwapApiTokenMetaRaw, P as SwapBuildApproveRaw, aa as SwapExecution, R as SwapHistoryWalletChainFamilyRaw, L as SwapMcaSignerPayloadRaw, a9 as SwapReportContext, M as SwapSigningRequestRaw, K as SwapTokenListRowRaw, U as SwapWarning, T as TransactionConfirmation, a2 as assertBaseUnitAmount, Y as normalizeOrderStatus } from './shared-COkGiqaz.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
|
-
type SwapErrorStage = "quote" | "build" | "approve" | "sign" | "broadcast" | "submit" | "report" | "status" | "history";
|
|
5
|
+
type SwapErrorStage = "quote" | "build" | "approve" | "sign" | "broadcast" | "submit" | "report" | "status" | "tokens" | "history";
|
|
6
6
|
interface SwapSdkErrorOptions {
|
|
7
7
|
retryable?: boolean;
|
|
8
8
|
cause?: unknown;
|
|
@@ -68,6 +68,8 @@ declare class ApiClient {
|
|
|
68
68
|
getHistory(params: SwapHistoryParamsRaw, options?: ApiRequestOptions): Promise<SwapHistoryDataRaw>;
|
|
69
69
|
createHistoryAuthChallenge(body: SwapHistoryAuthChallengeRequestRaw, options?: ApiRequestOptions): Promise<SwapHistoryAuthChallengeRaw>;
|
|
70
70
|
verifyHistoryAuthChallenge(body: SwapHistoryAuthVerifyRequestRaw, options?: ApiRequestOptions): Promise<SwapHistoryAuthTokenRaw>;
|
|
71
|
+
getFromTokenRows(chainId: number, options?: ApiRequestOptions): Promise<SwapFromTokensDataRaw>;
|
|
72
|
+
getCrossChainToTokenRows(chainId: number, options?: ApiRequestOptions): Promise<SwapCrossChainToTokensDataRaw>;
|
|
71
73
|
private request;
|
|
72
74
|
private requestOnce;
|
|
73
75
|
private buildUrl;
|
|
@@ -204,12 +206,37 @@ interface SwapHistoryItem {
|
|
|
204
206
|
raw: SwapHistoryRecordRaw;
|
|
205
207
|
}
|
|
206
208
|
|
|
209
|
+
interface TokenListRequest {
|
|
210
|
+
/** Numeric ID accepted by the token-list endpoints. */
|
|
211
|
+
chainId: number;
|
|
212
|
+
}
|
|
213
|
+
interface SwapTokenListItem extends AssetRef {
|
|
214
|
+
chain: ChainRef;
|
|
215
|
+
/** Token identifier accepted by the unified quote API. */
|
|
216
|
+
address: string;
|
|
217
|
+
symbol: string;
|
|
218
|
+
decimals: number;
|
|
219
|
+
isNative: boolean;
|
|
220
|
+
tokenListChainId: number;
|
|
221
|
+
blockchain: string;
|
|
222
|
+
assetId: string;
|
|
223
|
+
contractAddress: string | null;
|
|
224
|
+
coinType: string | null;
|
|
225
|
+
name: string | null;
|
|
226
|
+
logoURI: string | null;
|
|
227
|
+
price: string | number | null;
|
|
228
|
+
priceUpdatedAt: number | null;
|
|
229
|
+
sources: string[];
|
|
230
|
+
raw: Record<string, unknown>;
|
|
231
|
+
}
|
|
232
|
+
|
|
207
233
|
interface SwapClientConfig extends ApiClientConfig {
|
|
208
|
-
maxQuoteAgeMs?: number | null;
|
|
209
234
|
reportMode?: "auto" | "manual" | "disabled";
|
|
210
235
|
executors?: readonly ChainExecutor[];
|
|
211
236
|
onEvent?: (event: SwapLifecycleEvent) => void;
|
|
212
237
|
now?: () => number;
|
|
238
|
+
/** Token-list cache lifetime in milliseconds. Defaults to 10 minutes; use 0 to disable. */
|
|
239
|
+
tokenListCacheTtlMs?: number;
|
|
213
240
|
}
|
|
214
241
|
interface BuildSwapInput {
|
|
215
242
|
quote: Quote;
|
|
@@ -225,12 +252,17 @@ declare class SwapClient {
|
|
|
225
252
|
private readonly now;
|
|
226
253
|
private readonly inFlight;
|
|
227
254
|
private readonly reportRequests;
|
|
255
|
+
private readonly tokenListCache;
|
|
256
|
+
private readonly tokenListInflight;
|
|
228
257
|
constructor(config: SwapClientConfig);
|
|
229
258
|
quoteRaw(request: SwapQuoteRequestRaw, options?: ApiRequestOptions): Promise<SwapQuoteDataRaw>;
|
|
230
259
|
quote(request: McaQuoteRequest, options?: ApiRequestOptions): Promise<McaQuote>;
|
|
231
260
|
quote(request: QuoteRequest, options?: ApiRequestOptions): Promise<Quote>;
|
|
232
261
|
private quoteStandard;
|
|
233
262
|
buildRaw(request: SwapBuildRequestRaw, options?: ApiRequestOptions): Promise<SwapBuildDataRaw>;
|
|
263
|
+
getFromTokens(request: TokenListRequest, options?: ApiRequestOptions): Promise<SwapTokenListItem[]>;
|
|
264
|
+
getCrossChainToTokens(request: TokenListRequest, options?: ApiRequestOptions): Promise<SwapTokenListItem[]>;
|
|
265
|
+
private loadTokenList;
|
|
234
266
|
buildSwap(input: BuildSwapInput): Promise<SwapBuild>;
|
|
235
267
|
private buildStandardSwap;
|
|
236
268
|
executeSwap(input: ExecuteSwapInput): Promise<SwapExecutionResult>;
|
|
@@ -254,7 +286,6 @@ declare class SwapClient {
|
|
|
254
286
|
authorizeConfidentialHistory(request: SwapHistoryAuthChallengeRequestRaw, signChallenge: (challenge: SwapHistoryAuthChallengeRaw) => SwapHistoryAuthProofRaw | Promise<SwapHistoryAuthProofRaw>, options?: ApiRequestOptions): Promise<SwapHistoryAuthTokenRaw>;
|
|
255
287
|
getHistory(request: HistoryRequest, options?: ApiRequestOptions): Promise<SwapHistoryPage>;
|
|
256
288
|
protected emit(event: SwapLifecycleEvent): void;
|
|
257
|
-
private assertQuoteFresh;
|
|
258
289
|
private createReportRequest;
|
|
259
290
|
}
|
|
260
291
|
|
|
@@ -271,6 +302,9 @@ declare function normalizeHistoryStatus(status: unknown): HistoryStatus;
|
|
|
271
302
|
declare function serializeQuoteRequest(request: QuoteRequest): SwapQuoteRequestRaw;
|
|
272
303
|
declare function normalizeQuote(request: QuoteRequest, raw: SwapQuoteDataRaw, receivedAt?: number): Quote;
|
|
273
304
|
|
|
305
|
+
declare function normalizeFromTokenList(raw: SwapFromTokensDataRaw, chainId: number): SwapTokenListItem[];
|
|
306
|
+
declare function normalizeCrossChainToTokenList(raw: SwapCrossChainToTokensDataRaw, chainId: number): SwapTokenListItem[];
|
|
307
|
+
|
|
274
308
|
interface ResolveMcaWithdrawPolicyInput {
|
|
275
309
|
/** Requested withdraw amount in Burrow internal decimals. */
|
|
276
310
|
amountBurrow: string;
|
|
@@ -344,4 +378,4 @@ declare function buildMcaWithdrawRelayerRequest(input: BuildMcaWithdrawRelayerRe
|
|
|
344
378
|
declare function parseUnits(value: string, decimals: number): BaseUnitAmount;
|
|
345
379
|
declare function formatUnits(value: BaseUnitAmount, decimals: number): string;
|
|
346
380
|
|
|
347
|
-
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, type SwapErrorCode, type SwapErrorStage, SwapExecutionResult, 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, WaitForOrderInput, WaitMode, asSwapSdkError, buildMcaWithdrawRelayerRequest, buildNearMcaWithdrawTransactions, createExecutionId, extractMcaWithdrawBusiness, extractMcaWithdrawDepositAddress, extractMcaWithdrawSignerWallet, formatMcaWallet, formatUnits, fromApiChain, isSameMcaSignerIdentity, normalizeBuild, normalizeHistory, normalizeHistoryStatus, normalizeMcaQuote, normalizeQuote, parseUnits, resolveMcaDecreaseCollateral, resolveMcaRequiredCollateralDecrease, resolveMcaWithdrawPolicy, selectMcaSigner, serializeMcaQuoteRequest, serializeQuoteRequest, toApiAssetAddress, toApiChain };
|
|
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 };
|