@avalabs/fusion-sdk 0.26.1 → 0.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/constants.cjs +1 -1
- package/dist/constants.cjs.map +1 -1
- package/dist/constants.d.cts +32 -1
- package/dist/constants.d.ts +32 -1
- package/dist/constants.js +1 -1
- package/dist/constants.js.map +1 -1
- package/dist/errors.cjs +1 -1
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.cts +2 -0
- package/dist/errors.d.ts +2 -0
- package/dist/errors.js +1 -1
- package/dist/errors.js.map +1 -1
- package/dist/mod.cjs +1 -1
- package/dist/mod.d.cts +5 -3
- package/dist/mod.d.ts +5 -3
- package/dist/mod.js +1 -1
- package/dist/transfer-service/_evm-errors.cjs.map +1 -1
- package/dist/transfer-service/_evm-errors.js.map +1 -1
- package/dist/transfer-service/avalanche-cct/_handlers/get-bridgeable-assets.cjs +1 -1
- package/dist/transfer-service/avalanche-cct/_handlers/get-bridgeable-assets.js +1 -1
- package/dist/transfer-service/avalanche-cct/avalanche-cct-service.cjs +1 -1
- package/dist/transfer-service/avalanche-cct/avalanche-cct-service.js +1 -1
- package/dist/transfer-service/avalanche-cct/get-recovered-atomic-amount.cjs +2 -0
- package/dist/transfer-service/avalanche-cct/get-recovered-atomic-amount.cjs.map +1 -0
- package/dist/transfer-service/avalanche-cct/get-recovered-atomic-amount.d.cts +33 -0
- package/dist/transfer-service/avalanche-cct/get-recovered-atomic-amount.d.ts +33 -0
- package/dist/transfer-service/avalanche-cct/get-recovered-atomic-amount.js +2 -0
- package/dist/transfer-service/avalanche-cct/get-recovered-atomic-amount.js.map +1 -0
- package/dist/transfer-service/markr/_api.cjs +1 -1
- package/dist/transfer-service/markr/_api.js +1 -1
- package/dist/transfer-service/markr/_handlers/estimate-native-fee.cjs +1 -1
- package/dist/transfer-service/markr/_handlers/estimate-native-fee.cjs.map +1 -1
- package/dist/transfer-service/markr/_handlers/estimate-native-fee.js +1 -1
- package/dist/transfer-service/markr/_handlers/estimate-native-fee.js.map +1 -1
- package/dist/transfer-service/markr/_handlers/transfer-asset-hyperliquid-withdraw.cjs +1 -1
- package/dist/transfer-service/markr/_handlers/transfer-asset-hyperliquid-withdraw.js +1 -1
- package/dist/transfer-service/markr/_handlers/transfer-asset.cjs +1 -1
- package/dist/transfer-service/markr/_handlers/transfer-asset.cjs.map +1 -1
- package/dist/transfer-service/markr/_handlers/transfer-asset.js +1 -1
- package/dist/transfer-service/markr/_handlers/transfer-asset.js.map +1 -1
- package/dist/transfer-service/markr/_hyperevm.cjs +2 -0
- package/dist/transfer-service/markr/_hyperevm.cjs.map +1 -0
- package/dist/transfer-service/markr/_hyperevm.js +2 -0
- package/dist/transfer-service/markr/_hyperevm.js.map +1 -0
- package/dist/transfer-service/markr/_hyperliquid-eip712.d.ts +1 -0
- package/dist/transfer-service/markr/_hyperliquid-l1-action.cjs +2 -0
- package/dist/transfer-service/markr/_hyperliquid-l1-action.cjs.map +1 -0
- package/dist/transfer-service/markr/_hyperliquid-l1-action.d.cts +60 -0
- package/dist/transfer-service/markr/_hyperliquid-l1-action.d.ts +60 -0
- package/dist/transfer-service/markr/_hyperliquid-l1-action.js +2 -0
- package/dist/transfer-service/markr/_hyperliquid-l1-action.js.map +1 -0
- package/dist/transfer-service/markr/_hyperliquid-schema.d.cts +8 -0
- package/dist/transfer-service/markr/_hyperliquid-schema.d.ts +10 -0
- package/dist/transfer-service/markr/_hyperliquid.d.ts +1 -0
- package/dist/transfer-service/markr/recurring/_api.cjs +1 -1
- package/dist/transfer-service/markr/recurring/_api.js +1 -1
- package/dist/type-guards.cjs +1 -1
- package/dist/type-guards.cjs.map +1 -1
- package/dist/type-guards.d.cts +13 -1
- package/dist/type-guards.d.ts +13 -1
- package/dist/type-guards.js +1 -1
- package/dist/type-guards.js.map +1 -1
- package/package.json +2 -1
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","names":[],"sources":["../src/errors.ts"],"sourcesContent":["export enum ErrorCode {\n NOT_IMPLEMENTED = 5_000,\n SERVICE_NOT_AVAILABLE = 5_001,\n INITIALIZATION_FAILED = 5_002,\n INVALID_PARAMS = 5_003,\n TIMEOUT = 5_004,\n VIEM_ERROR = 5_005,\n TRANSACTION_REVERTED = 5_006,\n NOTARIZATION_FAILED = 5_007,\n SIGNING_FAILED = 5_008,\n SOLANA_ERROR = 5_009,\n /** Hyperliquid `withdrawable` dropped below the requested amount between authorize and sendAsset. */\n HL_WITHDRAWABLE_DROPPED = 5_010,\n /** Markr's `/swap` returned an `hyperliquid-withdraw` variant whose `protocolVersion` is unknown to this SDK release. */\n HL_UNSUPPORTED_PROTOCOL_VERSION = 5_011,\n /** Hyperliquid `/exchange` returned `{ status: \"err\" }`. */\n HL_EXCHANGE_REJECTED = 5_012,\n UNKNOWN = 5_999,\n}\n\nexport enum ErrorReason {\n /** the provided asset is not supported by the bridge */\n ASSET_NOT_SUPPORTED = 'ASSET_NOT_SUPPORTED',\n /** the provided source or target chain is not supported by the bridge */\n CHAIN_NOT_SUPPORTED = 'CHAIN_NOT_SUPPORTED',\n /** error while fetching or parsing the config */\n CONFIG_NOT_AVAILABLE = 'CONFIG_NOT_AVAILABLE',\n /** required confirmation count of the source or target chain is unknown */\n CONFIRMATION_COUNT_UNKNOWN = 'CONFIRMATION_COUNT_UNKNOWN',\n /** service is being initialized more than once */\n DUPLICATE_SERVICE_INITIALIZATION = 'DUPLICATE_SERVICE_INITIALIZATION',\n /** bridge does not support specified environment */\n ENVIRONMENT_NOT_SUPPORTED = 'ENVIRONMENT_NOT_SUPPORTED',\n /** provided source and target chains are the same */\n IDENTICAL_CHAINS_PROVIDED = 'IDENTICAL_CHAINS_PROVIDED',\n /** the sender or recipient address is incorrect */\n INCORRECT_ADDRESS_PROVIDED = 'INCORRECT_ADDRESS_PROVIDED',\n /** the transfer amount is incorrect (e.g.: lesser than or equal to zero) */\n INCORRECT_AMOUNT_PROVIDED = 'INCORRECT_AMOUNT_PROVIDED',\n /** the transaction is not hex */\n INCORRECT_HASH_PROVIDED = 'INCORRECT_HASH_PROVIDED',\n /** The provided provider is incorrect type (Provider VS BitcoinProvider) */\n INCORRECT_PROVIDER_PROVIDED = 'INCORRECT_PROVIDER_PROVIDED',\n /** The provided signer is incorrect type */\n INCORRECT_SIGNER_PROVIDED = 'INCORRECT_SIGNER_PROVIDED',\n /** the sourceTxHash or targetTxHash is incorrect */\n INCORRECT_TXHASH_PROVIDED = 'INCORRECT_TXHASH_PROVIDED',\n /** generic error with the params */\n INVALID_PARAMS = 'INVALID_PARAMS',\n /** ServiceType requested not available */\n SERVICE_TYPE_NOT_CONFIGURED = 'SERVICE_TYPE_NOT_CONFIGURED',\n /** generic, not specified error */\n UNKNOWN = 'UNKNOWN',\n /** error when the address has token approvals for addresses involved in the multichain incident */\n VULNERABLE_TOKEN_APPROVAL_ADDRESS = 'VULNERABLE_TOKEN_APPROVAL_ADDRESS',\n /** error when warden config was not found or it is over the mismatch threshold */\n WARDEN_CONFIG_MISMATCH = 'WARDEN_CONFIG_MISMATCH',\n /** fetched warden config does not contain network IDs */\n WARDEN_CONFIG_MISSING_NETWORK = 'WARDEN_CONFIG_MISSING_NETWORK',\n /** address is blocked */\n ADDRESS_IS_BLOCKED = 'ADDRESS_IS_BLOCKED',\n /** Quote expired */\n QUOTE_EXPIRED = 'QUOTE_EXPIRED',\n /**\n * The on-chain `WAVAX.deposit{value}()` transaction the SDK signed as the\n * first leg of a native-input recurring schedule was mined as reverted —\n * the user does not hold the wrapped balance the downstream `createOrder`\n * needs, so the schedule was not created.\n */\n NATIVE_WRAP_REVERTED = 'NATIVE_WRAP_REVERTED',\n /**\n * Markr's `/recurring/swap` response shape did not agree with the cached\n * quote's `tokenIn` — e.g. native input returned without a wrap step, an\n * ERC-20 input returned with one, or `createOrder` is missing entirely.\n * Signing the response as-is would broadcast a mismatched flow (charge\n * native the user didn't authorize, or skip a wrap they needed), so the\n * SDK refuses. See `details` on the thrown `SdkError` for which variant\n * fired.\n */\n RECURRING_SWAP_RESPONSE_INCONSISTENT = 'RECURRING_SWAP_RESPONSE_INCONSISTENT',\n}\n\nexport class SdkError extends Error {\n override name = 'SdkError';\n\n constructor(\n message: string,\n public code: ErrorCode,\n public options?: {\n cause?: unknown;\n details?: string;\n },\n ) {\n super(message, { cause: options?.cause });\n }\n\n walk(): Error;\n walk(fn: (err: unknown) => boolean): Error | null;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n walk(fn?: any): any {\n return walkError(this, fn);\n }\n}\n\nfunction walkError(err: unknown): unknown;\nfunction walkError(err: unknown, fn: (err: unknown) => boolean): unknown | null;\nfunction walkError(err: unknown, fn?: ((err: unknown) => boolean) | undefined): unknown | null;\nfunction walkError(err: unknown, fn?: ((err: unknown) => boolean) | undefined): unknown | null {\n if (fn?.(err)) {\n return err;\n }\n\n if (err && typeof err === 'object' && 'cause' in err && err.cause !== undefined) {\n return walkError(err.cause, fn);\n }\n\n return fn ? null : err;\n}\n\nexport function isSdkError(error: unknown): error is SdkError {\n return error instanceof SdkError;\n}\n\nexport class HttpError extends Error {\n override name = 'HttpError';\n\n readonly status: number;\n readonly statusText: string;\n readonly response: Response;\n readonly data?: unknown;\n\n constructor(message: string, response: Response, data?: unknown) {\n super(message);\n this.name = 'HttpError';\n this.status = response.status;\n this.statusText = response.statusText;\n this.response = response;\n this.data = data;\n }\n}\n\nexport function isHttpError(error: unknown): error is HttpError {\n return error instanceof HttpError;\n}\n\nexport class TimeoutError extends Error {\n override name = 'TimeoutError';\n\n constructor(message = 'Request timed out.') {\n super(message);\n this.name = 'TimeoutError';\n }\n}\n\nexport function isTimeoutError(error: unknown): error is TimeoutError {\n return error instanceof TimeoutError;\n}\n\nexport class AbortedError extends Error {\n override name = 'AbortedError';\n\n constructor(message = 'Operation was aborted.') {\n super(message);\n this.name = 'AbortedError';\n }\n}\n\nexport function isAbortedError(error: unknown): error is AbortedError {\n return error instanceof AbortedError;\n}\n\nexport class ResponseValidationError extends Error {\n override name = 'ResponseValidationError';\n\n readonly issues?: unknown;\n readonly rawResponse?: unknown;\n\n constructor(message = 'Response validation failed.', issues?: unknown, rawResponse?: unknown) {\n super(message);\n this.name = 'ResponseValidationError';\n this.issues = issues;\n this.rawResponse = rawResponse;\n }\n}\n\nexport function isResponseValidationError(error: unknown): error is ResponseValidationError {\n return error instanceof ResponseValidationError;\n}\n\nexport class ServiceInitializationError extends SdkError {\n override name = 'ServiceInitializationError';\n\n constructor(message: string = ErrorReason.UNKNOWN, details?: string, cause?: unknown) {\n super(message, ErrorCode.INITIALIZATION_FAILED, { cause, details });\n }\n}\n\nexport function isServiceInitializationError(error: unknown): error is ServiceInitializationError {\n return error instanceof ServiceInitializationError;\n}\n\nexport class ServiceUnavailableError extends SdkError {\n override name = 'ServiceUnavailableError';\n\n constructor(message: string = ErrorReason.UNKNOWN, details?: string) {\n super(message, ErrorCode.SERVICE_NOT_AVAILABLE, { details });\n }\n}\n\nexport function isServiceUnavailableError(error: unknown): error is ServiceUnavailableError {\n return error instanceof ServiceUnavailableError;\n}\n\nexport class InsufficientFundsError extends SdkError {\n override name = 'InsufficientFundsError';\n public insufficientTokenWasNative: boolean;\n\n constructor({\n cause,\n details,\n errorCode,\n insufficientTokenWasNative,\n }: {\n errorCode: ErrorCode.VIEM_ERROR | ErrorCode.SOLANA_ERROR;\n details?: string;\n cause?: unknown;\n insufficientTokenWasNative: boolean;\n }) {\n super(\n insufficientTokenWasNative\n ? 'Insufficient native funds to cover the fee.'\n : 'Insufficient token funds to estimate the fee.',\n errorCode,\n { cause, details },\n );\n this.insufficientTokenWasNative = insufficientTokenWasNative;\n }\n}\n\nexport function isInsufficientFundsError(error: unknown): error is InsufficientFundsError {\n return error instanceof InsufficientFundsError;\n}\n\nexport interface EstimateNativeFeeErrorDetails {\n /** Human-readable reason from `Error(string)` or `Panic(uint256)`. */\n reason?: string;\n /** Custom error name from the ABI, e.g. `\"SlippageTooHigh\"`. */\n errorName?: string;\n /** Decoded arguments from the custom error. */\n args?: readonly unknown[];\n /** Raw revert data (hex). */\n data?: `0x${string}`;\n}\n\nexport class EstimateNativeFeeError extends SdkError {\n override name = 'EstimateNativeFeeError';\n public details: EstimateNativeFeeErrorDetails | undefined;\n public tx: string | { account: `0x${string}`; to: `0x${string}`; data: `0x${string}`; value?: bigint };\n\n constructor({\n cause,\n details,\n errorCode,\n message = 'Failed to estimate native fee for quote.',\n tx,\n }: {\n cause?: unknown;\n details?: EstimateNativeFeeErrorDetails;\n errorCode: ErrorCode.VIEM_ERROR | ErrorCode.SOLANA_ERROR;\n message?: string;\n tx: string | { account: `0x${string}`; to: `0x${string}`; data: `0x${string}`; value?: bigint };\n }) {\n super(message, errorCode, { cause });\n this.details = details;\n this.tx = tx;\n }\n\n /**\n * Helper method to check if the error was caused by insufficient funds to cover the fee.\n * Note that this is a heuristic based on the error details and may not be 100% accurate in all cases.\n * Use with caution and consider inspecting the error details for more context.\n */\n public causedByInsufficientFunds(): boolean {\n return isInsufficientFundsError(this.cause);\n }\n}\n\nexport function isEstimateNativeFeeError(error: unknown): error is EstimateNativeFeeError {\n return error instanceof EstimateNativeFeeError;\n}\n\nexport class InvalidParamsError extends SdkError {\n override name = 'InvalidParamsError';\n\n constructor(message: string = ErrorReason.INVALID_PARAMS, details?: string) {\n super(message, ErrorCode.INVALID_PARAMS, { details });\n }\n}\n\nexport function isInvalidParamsError(error: unknown): error is InvalidParamsError {\n return error instanceof InvalidParamsError;\n}\n\n/**\n * @internal\n *\n * Error to indicate that a functionality has not yet been implemented.\n * Do not export from entrypoint.\n */\nexport class NotImplementedError extends SdkError {\n constructor() {\n super('This functionality is not yet implemented.', ErrorCode.NOT_IMPLEMENTED);\n }\n}\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"errors.js","names":[],"sources":["../src/errors.ts"],"sourcesContent":["export enum ErrorCode {\n NOT_IMPLEMENTED = 5_000,\n SERVICE_NOT_AVAILABLE = 5_001,\n INITIALIZATION_FAILED = 5_002,\n INVALID_PARAMS = 5_003,\n TIMEOUT = 5_004,\n VIEM_ERROR = 5_005,\n TRANSACTION_REVERTED = 5_006,\n NOTARIZATION_FAILED = 5_007,\n SIGNING_FAILED = 5_008,\n SOLANA_ERROR = 5_009,\n /** Hyperliquid `withdrawable` dropped below the requested amount between authorize and sendAsset. */\n HL_WITHDRAWABLE_DROPPED = 5_010,\n /** Markr's `/swap` returned an `hyperliquid-withdraw` variant whose `protocolVersion` is unknown to this SDK release. */\n HL_UNSUPPORTED_PROTOCOL_VERSION = 5_011,\n /** Hyperliquid `/exchange` returned `{ status: \"err\" }`. */\n HL_EXCHANGE_REJECTED = 5_012,\n /** Enabling HyperEVM big blocks (`evmUserModify`) failed or was rejected by Hyperliquid. */\n HL_BIG_BLOCKS_FAILED = 5_013,\n UNKNOWN = 5_999,\n}\n\nexport enum ErrorReason {\n /** the provided asset is not supported by the bridge */\n ASSET_NOT_SUPPORTED = 'ASSET_NOT_SUPPORTED',\n /** the provided source or target chain is not supported by the bridge */\n CHAIN_NOT_SUPPORTED = 'CHAIN_NOT_SUPPORTED',\n /** error while fetching or parsing the config */\n CONFIG_NOT_AVAILABLE = 'CONFIG_NOT_AVAILABLE',\n /** required confirmation count of the source or target chain is unknown */\n CONFIRMATION_COUNT_UNKNOWN = 'CONFIRMATION_COUNT_UNKNOWN',\n /** service is being initialized more than once */\n DUPLICATE_SERVICE_INITIALIZATION = 'DUPLICATE_SERVICE_INITIALIZATION',\n /** bridge does not support specified environment */\n ENVIRONMENT_NOT_SUPPORTED = 'ENVIRONMENT_NOT_SUPPORTED',\n /** provided source and target chains are the same */\n IDENTICAL_CHAINS_PROVIDED = 'IDENTICAL_CHAINS_PROVIDED',\n /** the sender or recipient address is incorrect */\n INCORRECT_ADDRESS_PROVIDED = 'INCORRECT_ADDRESS_PROVIDED',\n /** the transfer amount is incorrect (e.g.: lesser than or equal to zero) */\n INCORRECT_AMOUNT_PROVIDED = 'INCORRECT_AMOUNT_PROVIDED',\n /** the transaction is not hex */\n INCORRECT_HASH_PROVIDED = 'INCORRECT_HASH_PROVIDED',\n /** The provided provider is incorrect type (Provider VS BitcoinProvider) */\n INCORRECT_PROVIDER_PROVIDED = 'INCORRECT_PROVIDER_PROVIDED',\n /** The provided signer is incorrect type */\n INCORRECT_SIGNER_PROVIDED = 'INCORRECT_SIGNER_PROVIDED',\n /** the sourceTxHash or targetTxHash is incorrect */\n INCORRECT_TXHASH_PROVIDED = 'INCORRECT_TXHASH_PROVIDED',\n /** generic error with the params */\n INVALID_PARAMS = 'INVALID_PARAMS',\n /** ServiceType requested not available */\n SERVICE_TYPE_NOT_CONFIGURED = 'SERVICE_TYPE_NOT_CONFIGURED',\n /** generic, not specified error */\n UNKNOWN = 'UNKNOWN',\n /** error when the address has token approvals for addresses involved in the multichain incident */\n VULNERABLE_TOKEN_APPROVAL_ADDRESS = 'VULNERABLE_TOKEN_APPROVAL_ADDRESS',\n /** error when warden config was not found or it is over the mismatch threshold */\n WARDEN_CONFIG_MISMATCH = 'WARDEN_CONFIG_MISMATCH',\n /** fetched warden config does not contain network IDs */\n WARDEN_CONFIG_MISSING_NETWORK = 'WARDEN_CONFIG_MISSING_NETWORK',\n /** address is blocked */\n ADDRESS_IS_BLOCKED = 'ADDRESS_IS_BLOCKED',\n /** Quote expired */\n QUOTE_EXPIRED = 'QUOTE_EXPIRED',\n /**\n * The on-chain `WAVAX.deposit{value}()` transaction the SDK signed as the\n * first leg of a native-input recurring schedule was mined as reverted —\n * the user does not hold the wrapped balance the downstream `createOrder`\n * needs, so the schedule was not created.\n */\n NATIVE_WRAP_REVERTED = 'NATIVE_WRAP_REVERTED',\n /**\n * Markr's `/recurring/swap` response shape did not agree with the cached\n * quote's `tokenIn` — e.g. native input returned without a wrap step, an\n * ERC-20 input returned with one, or `createOrder` is missing entirely.\n * Signing the response as-is would broadcast a mismatched flow (charge\n * native the user didn't authorize, or skip a wrap they needed), so the\n * SDK refuses. See `details` on the thrown `SdkError` for which variant\n * fired.\n */\n RECURRING_SWAP_RESPONSE_INCONSISTENT = 'RECURRING_SWAP_RESPONSE_INCONSISTENT',\n}\n\nexport class SdkError extends Error {\n override name = 'SdkError';\n\n constructor(\n message: string,\n public code: ErrorCode,\n public options?: {\n cause?: unknown;\n details?: string;\n },\n ) {\n super(message, { cause: options?.cause });\n }\n\n walk(): Error;\n walk(fn: (err: unknown) => boolean): Error | null;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n walk(fn?: any): any {\n return walkError(this, fn);\n }\n}\n\nfunction walkError(err: unknown): unknown;\nfunction walkError(err: unknown, fn: (err: unknown) => boolean): unknown | null;\nfunction walkError(err: unknown, fn?: ((err: unknown) => boolean) | undefined): unknown | null;\nfunction walkError(err: unknown, fn?: ((err: unknown) => boolean) | undefined): unknown | null {\n if (fn?.(err)) {\n return err;\n }\n\n if (err && typeof err === 'object' && 'cause' in err && err.cause !== undefined) {\n return walkError(err.cause, fn);\n }\n\n return fn ? null : err;\n}\n\nexport function isSdkError(error: unknown): error is SdkError {\n return error instanceof SdkError;\n}\n\nexport class HttpError extends Error {\n override name = 'HttpError';\n\n readonly status: number;\n readonly statusText: string;\n readonly response: Response;\n readonly data?: unknown;\n\n constructor(message: string, response: Response, data?: unknown) {\n super(message);\n this.name = 'HttpError';\n this.status = response.status;\n this.statusText = response.statusText;\n this.response = response;\n this.data = data;\n }\n}\n\nexport function isHttpError(error: unknown): error is HttpError {\n return error instanceof HttpError;\n}\n\nexport class TimeoutError extends Error {\n override name = 'TimeoutError';\n\n constructor(message = 'Request timed out.') {\n super(message);\n this.name = 'TimeoutError';\n }\n}\n\nexport function isTimeoutError(error: unknown): error is TimeoutError {\n return error instanceof TimeoutError;\n}\n\nexport class AbortedError extends Error {\n override name = 'AbortedError';\n\n constructor(message = 'Operation was aborted.') {\n super(message);\n this.name = 'AbortedError';\n }\n}\n\nexport function isAbortedError(error: unknown): error is AbortedError {\n return error instanceof AbortedError;\n}\n\nexport class ResponseValidationError extends Error {\n override name = 'ResponseValidationError';\n\n readonly issues?: unknown;\n readonly rawResponse?: unknown;\n\n constructor(message = 'Response validation failed.', issues?: unknown, rawResponse?: unknown) {\n super(message);\n this.name = 'ResponseValidationError';\n this.issues = issues;\n this.rawResponse = rawResponse;\n }\n}\n\nexport function isResponseValidationError(error: unknown): error is ResponseValidationError {\n return error instanceof ResponseValidationError;\n}\n\nexport class ServiceInitializationError extends SdkError {\n override name = 'ServiceInitializationError';\n\n constructor(message: string = ErrorReason.UNKNOWN, details?: string, cause?: unknown) {\n super(message, ErrorCode.INITIALIZATION_FAILED, { cause, details });\n }\n}\n\nexport function isServiceInitializationError(error: unknown): error is ServiceInitializationError {\n return error instanceof ServiceInitializationError;\n}\n\nexport class ServiceUnavailableError extends SdkError {\n override name = 'ServiceUnavailableError';\n\n constructor(message: string = ErrorReason.UNKNOWN, details?: string) {\n super(message, ErrorCode.SERVICE_NOT_AVAILABLE, { details });\n }\n}\n\nexport function isServiceUnavailableError(error: unknown): error is ServiceUnavailableError {\n return error instanceof ServiceUnavailableError;\n}\n\nexport class InsufficientFundsError extends SdkError {\n override name = 'InsufficientFundsError';\n public insufficientTokenWasNative: boolean;\n\n constructor({\n cause,\n details,\n errorCode,\n insufficientTokenWasNative,\n }: {\n errorCode: ErrorCode.VIEM_ERROR | ErrorCode.SOLANA_ERROR;\n details?: string;\n cause?: unknown;\n insufficientTokenWasNative: boolean;\n }) {\n super(\n insufficientTokenWasNative\n ? 'Insufficient native funds to cover the fee.'\n : 'Insufficient token funds to estimate the fee.',\n errorCode,\n { cause, details },\n );\n this.insufficientTokenWasNative = insufficientTokenWasNative;\n }\n}\n\nexport function isInsufficientFundsError(error: unknown): error is InsufficientFundsError {\n return error instanceof InsufficientFundsError;\n}\n\nexport interface EstimateNativeFeeErrorDetails {\n /** Human-readable reason from `Error(string)` or `Panic(uint256)`. */\n reason?: string;\n /** Custom error name from the ABI, e.g. `\"SlippageTooHigh\"`. */\n errorName?: string;\n /** Decoded arguments from the custom error. */\n args?: readonly unknown[];\n /** Raw revert data (hex). */\n data?: `0x${string}`;\n}\n\nexport class EstimateNativeFeeError extends SdkError {\n override name = 'EstimateNativeFeeError';\n public details: EstimateNativeFeeErrorDetails | undefined;\n public tx: string | { account: `0x${string}`; to: `0x${string}`; data: `0x${string}`; value?: bigint };\n\n constructor({\n cause,\n details,\n errorCode,\n message = 'Failed to estimate native fee for quote.',\n tx,\n }: {\n cause?: unknown;\n details?: EstimateNativeFeeErrorDetails;\n errorCode: ErrorCode.VIEM_ERROR | ErrorCode.SOLANA_ERROR;\n message?: string;\n tx: string | { account: `0x${string}`; to: `0x${string}`; data: `0x${string}`; value?: bigint };\n }) {\n super(message, errorCode, { cause });\n this.details = details;\n this.tx = tx;\n }\n\n /**\n * Helper method to check if the error was caused by insufficient funds to cover the fee.\n * Note that this is a heuristic based on the error details and may not be 100% accurate in all cases.\n * Use with caution and consider inspecting the error details for more context.\n */\n public causedByInsufficientFunds(): boolean {\n return isInsufficientFundsError(this.cause);\n }\n}\n\nexport function isEstimateNativeFeeError(error: unknown): error is EstimateNativeFeeError {\n return error instanceof EstimateNativeFeeError;\n}\n\nexport class InvalidParamsError extends SdkError {\n override name = 'InvalidParamsError';\n\n constructor(message: string = ErrorReason.INVALID_PARAMS, details?: string) {\n super(message, ErrorCode.INVALID_PARAMS, { details });\n }\n}\n\nexport function isInvalidParamsError(error: unknown): error is InvalidParamsError {\n return error instanceof InvalidParamsError;\n}\n\n/**\n * @internal\n *\n * Error to indicate that a functionality has not yet been implemented.\n * Do not export from entrypoint.\n */\nexport class NotImplementedError extends SdkError {\n constructor() {\n super('This functionality is not yet implemented.', ErrorCode.NOT_IMPLEMENTED);\n }\n}\n"],"mappings":"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"}
|
package/dist/mod.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./constants.cjs`),t=require(`./errors.cjs`),n=require(`./type-guards.cjs`),r=require(`./transfer-manager.cjs`),i=require(`./utils/caip.cjs`),a=require(`./utils/bridgeable-assets.cjs`),
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./constants.cjs`),t=require(`./errors.cjs`),n=require(`./type-guards.cjs`),r=require(`./transfer-manager.cjs`),i=require(`./utils/caip.cjs`),a=require(`./transfer-service/markr/_hyperliquid-l1-action.cjs`),o=require(`./utils/bridgeable-assets.cjs`),s=require(`./utils/destination-chains.cjs`),c=require(`./utils/price-impact.cjs`),l=require(`./utils/transfer-utils.cjs`),u=require(`./transfer-service/avalanche-cct/get-recovered-atomic-amount.cjs`),d=require(`./transfer-service/markr/recurring/types.cjs`),f=require(`./transfer-service/markr/recurring/_frequency.cjs`),p=require(`./transfer-service/_evm-approval.cjs`);exports.AVALANCHE_CAIP2_TO_BLOCKCHAIN_ID_BY_NETWORK=e.AVALANCHE_CAIP2_TO_BLOCKCHAIN_ID_BY_NETWORK,exports.AVALANCHE_FUJI_CHAIN=e.AVALANCHE_FUJI_CHAIN,exports.AVALANCHE_FUJI_P_CHAIN=e.AVALANCHE_FUJI_P_CHAIN,exports.AVALANCHE_FUJI_X_CHAIN=e.AVALANCHE_FUJI_X_CHAIN,exports.AVALANCHE_MAINNET_CHAIN=e.AVALANCHE_MAINNET_CHAIN,exports.AVALANCHE_MAINNET_P_CHAIN=e.AVALANCHE_MAINNET_P_CHAIN,exports.AVALANCHE_MAINNET_X_CHAIN=e.AVALANCHE_MAINNET_X_CHAIN,exports.AbortedError=t.AbortedError,exports.ApprovalRevertedError=p.ApprovalRevertedError,exports.AvalancheChainIds=e.AvalancheChainIds,exports.AvalancheFujiBlockchainChainIds=e.AvalancheFujiBlockchainChainIds,exports.AvalancheFujiBlockchainIds=e.AvalancheFujiBlockchainIds,exports.AvalancheMainnetBlockchainChainIds=e.AvalancheMainnetBlockchainChainIds,exports.AvalancheMainnetBlockchainIds=e.AvalancheMainnetBlockchainIds,exports.BITCOIN_MAINNET_CHAIN=e.BITCOIN_MAINNET_CHAIN,exports.BITCOIN_TESTNET_CHAIN=e.BITCOIN_TESTNET_CHAIN,exports.BTC_SERVICE_TYPES=e.BTC_SERVICE_TYPES,exports.BaseChainIds=e.BaseChainIds,exports.BitcoinChainIds=e.BitcoinChainIds,exports.Blockchain=e.Blockchain,exports.ERC_ZERO_ADDRESS=e.ERC_ZERO_ADDRESS,exports.ETHEREUM_MAINNET_CHAIN=e.ETHEREUM_MAINNET_CHAIN,exports.ETHEREUM_SEPOLIA_CHAIN=e.ETHEREUM_SEPOLIA_CHAIN,exports.EVM_SERVICE_TYPES=e.EVM_SERVICE_TYPES,exports.Environment=e.Environment,exports.ErrorCode=t.ErrorCode,exports.ErrorReason=t.ErrorReason,exports.EstimateNativeFeeError=t.EstimateNativeFeeError,exports.EthereumChainIds=e.EthereumChainIds,exports.EvmChainId=e.EvmChainId,exports.FEE_RATE_TIER_TO_BITCOIN=e.FEE_RATE_TIER_TO_BITCOIN,exports.HYPEREVM_BIG_BLOCK_GAS_LIMIT=e.HYPEREVM_BIG_BLOCK_GAS_LIMIT,exports.HYPEREVM_CHAIN_ID=e.HYPEREVM_CHAIN_ID,exports.HYPEREVM_SMALL_BLOCK_GAS_LIMIT=e.HYPEREVM_SMALL_BLOCK_GAS_LIMIT,exports.HttpError=t.HttpError,exports.HyperEvmChainIds=e.HyperEvmChainIds,exports.HyperliquidChainIds=e.HyperliquidChainIds,exports.InsufficientFundsError=t.InsufficientFundsError,exports.InvalidParamsError=t.InvalidParamsError,exports.NATIVE_AVAX=e.NATIVE_AVAX,exports.NATIVE_ETH=e.NATIVE_ETH,exports.NATIVE_SOL_ADDRESS=e.NATIVE_SOL_ADDRESS,exports.PolygonChainIds=e.PolygonChainIds,exports.RECURRING_FREQUENCY_UNITS=d.RECURRING_FREQUENCY_UNITS,exports.RECURRING_FREQUENCY_VALUE_MAX=f.RECURRING_FREQUENCY_VALUE_MAX,exports.RECURRING_UNLIMITED_ORDERS_SENTINEL=d.RECURRING_UNLIMITED_ORDERS_SENTINEL,exports.RecurringEligibilityReason=d.RecurringEligibilityReason,exports.RecurringOrderStatus=d.RecurringOrderStatus,exports.ResponseValidationError=t.ResponseValidationError,exports.SOLANA_DEVNET_CHAIN=e.SOLANA_DEVNET_CHAIN,exports.SOLANA_MAINNET_CHAIN=e.SOLANA_MAINNET_CHAIN,exports.SdkError=t.SdkError,exports.ServiceInitializationError=t.ServiceInitializationError,exports.ServiceType=e.ServiceType,exports.ServiceUnavailableError=t.ServiceUnavailableError,exports.SolanaChainIds=e.SolanaChainIds,exports.TimeoutError=t.TimeoutError,exports.TokenType=e.TokenType,exports.TransferSignatureReason=e.TransferSignatureReason,exports.buildEvmUserModifyAction=a.buildEvmUserModifyAction,exports.caip2ToEip155ChainId=i.caip2ToEip155ChainId,exports.caip2ToEip155HexChainId=i.caip2ToEip155HexChainId,exports.calculatePriceImpactFromQuote=c.calculatePriceImpactFromQuote,exports.compareDestinationChains=s.compareDestinationChains,exports.createTransferManager=r.createTransferManager,exports.dedupeBridgeableAssets=o.dedupeBridgeableAssets,exports.deriveIntervalSeconds=f.deriveIntervalSeconds,exports.eip155ChainIdToCaip2=i.eip155ChainIdToCaip2,exports.enableHyperEvmBigBlocks=a.enableHyperEvmBigBlocks,exports.getDestinationChainPriority=s.getDestinationChainPriority,exports.getRecoveredAtomicAmount=u.getRecoveredAtomicAmount,exports.isAbortedError=t.isAbortedError,exports.isCaip2ChainId=i.isCaip2ChainId,exports.isEnvironment=n.isEnvironment,exports.isErc20Asset=n.isErc20Asset,exports.isEstimateNativeFeeError=t.isEstimateNativeFeeError,exports.isEvmBridgeInitializer=n.isEvmBridgeInitializer,exports.isHttpError=t.isHttpError,exports.isInsufficientFundsError=t.isInsufficientFundsError,exports.isInvalidParamsError=t.isInvalidParamsError,exports.isLombardServiceInitializer=n.isLombardServiceInitializer,exports.isMarkrServiceInitializer=n.isMarkrServiceInitializer,exports.isNativeAsset=n.isNativeAsset,exports.isQuote=n.isQuote,exports.isResponseValidationError=t.isResponseValidationError,exports.isSdkError=t.isSdkError,exports.isServiceInitializationError=t.isServiceInitializationError,exports.isServiceInitializer=n.isServiceInitializer,exports.isServiceUnavailableError=t.isServiceUnavailableError,exports.isSplAsset=n.isSplAsset,exports.isTimeoutError=t.isTimeoutError,exports.isTransfer=n.isTransfer,exports.parseTransfer=l.parseTransfer,exports.sortDestinationChains=s.sortDestinationChains,exports.splitCaip2ChainId=i.splitCaip2ChainId,exports.stringifyTransfer=l.stringifyTransfer,exports.validateFrequency=f.validateFrequency;
|
package/dist/mod.d.cts
CHANGED
|
@@ -2,7 +2,7 @@ import { Caip10AccountId, Caip2ChainId } from "./types/caip.cjs";
|
|
|
2
2
|
import { BitcoinFeeRateTier, BitcoinFunctions, BitcoinInputUTXO, BitcoinInputUTXOWithOptionalScript, BitcoinOutputUTXO, BitcoinTx } from "./types/bitcoin.cjs";
|
|
3
3
|
import { Chain } from "./types/chain.cjs";
|
|
4
4
|
import { FeeRateTier } from "./types/fee.cjs";
|
|
5
|
-
import { AVALANCHE_CAIP2_TO_BLOCKCHAIN_ID_BY_NETWORK, AVALANCHE_FUJI_CHAIN, AVALANCHE_FUJI_P_CHAIN, AVALANCHE_FUJI_X_CHAIN, AVALANCHE_MAINNET_CHAIN, AVALANCHE_MAINNET_P_CHAIN, AVALANCHE_MAINNET_X_CHAIN, AvalancheBlockchainAlias, AvalancheChainIds, AvalancheFujiBlockchainChainIds, AvalancheFujiBlockchainIds, AvalancheMainnetBlockchainChainIds, AvalancheMainnetBlockchainIds, BITCOIN_MAINNET_CHAIN, BITCOIN_TESTNET_CHAIN, BTC_SERVICE_TYPES, BaseChainIds, BitcoinChainIds, Blockchain, ERC_ZERO_ADDRESS, ETHEREUM_MAINNET_CHAIN, ETHEREUM_SEPOLIA_CHAIN, EVM_SERVICE_TYPES, Environment, EthereumChainIds, EvmChainId, FEE_RATE_TIER_TO_BITCOIN, HyperliquidChainIds, NATIVE_AVAX, NATIVE_ETH, NATIVE_SOL_ADDRESS, PolygonChainIds, SOLANA_DEVNET_CHAIN, SOLANA_MAINNET_CHAIN, ServiceType, SolanaChainIds, TokenType, TransferSignatureReason } from "./constants.cjs";
|
|
5
|
+
import { AVALANCHE_CAIP2_TO_BLOCKCHAIN_ID_BY_NETWORK, AVALANCHE_FUJI_CHAIN, AVALANCHE_FUJI_P_CHAIN, AVALANCHE_FUJI_X_CHAIN, AVALANCHE_MAINNET_CHAIN, AVALANCHE_MAINNET_P_CHAIN, AVALANCHE_MAINNET_X_CHAIN, AvalancheBlockchainAlias, AvalancheChainIds, AvalancheFujiBlockchainChainIds, AvalancheFujiBlockchainIds, AvalancheMainnetBlockchainChainIds, AvalancheMainnetBlockchainIds, BITCOIN_MAINNET_CHAIN, BITCOIN_TESTNET_CHAIN, BTC_SERVICE_TYPES, BaseChainIds, BitcoinChainIds, Blockchain, ERC_ZERO_ADDRESS, ETHEREUM_MAINNET_CHAIN, ETHEREUM_SEPOLIA_CHAIN, EVM_SERVICE_TYPES, Environment, EthereumChainIds, EvmChainId, FEE_RATE_TIER_TO_BITCOIN, HYPEREVM_BIG_BLOCK_GAS_LIMIT, HYPEREVM_CHAIN_ID, HYPEREVM_SMALL_BLOCK_GAS_LIMIT, HyperEvmChainIds, HyperliquidChainIds, NATIVE_AVAX, NATIVE_ETH, NATIVE_SOL_ADDRESS, PolygonChainIds, SOLANA_DEVNET_CHAIN, SOLANA_MAINNET_CHAIN, ServiceType, SolanaChainIds, TokenType, TransferSignatureReason } from "./constants.cjs";
|
|
6
6
|
import { Asset, AssetWithExtras, BridgeableAsset, BridgeableUiAsset, ChainAssetMap, DestinationInfo, Erc20Asset, NativeAsset, SplAsset, TransferableAsset } from "./types/asset.cjs";
|
|
7
7
|
import { Quote, QuoteFee, QuoteFeeFundingModel, QuoteFeeToken, QuoteFeeType, QuoteFees, QuoterDonePayload, QuoterDonePayloadNoEligibleServices, QuoterDonePayloadNoQuotes, QuoterDonePayloadUnsubscribed, QuoterDoneReason, QuoterEventArgs, QuoterEventHandler, QuoterInterface, QuoterProps, QuotesTuple, ServiceQuoteEventArgs, ServiceQuoteEventHandler } from "./types/quote.cjs";
|
|
8
8
|
import { ArrayElement, Brand, DeepMutable, Fetch, Mutable } from "./types/utility-types.cjs";
|
|
@@ -14,14 +14,16 @@ import { BtcDispatch, BtcSign, BtcSigner, BtcTransactionRequest, EvmDispatch, Ev
|
|
|
14
14
|
import { AssetSearchQuery, AvalancheCctInitializer, AvalancheSendTxFunction, AvalancheSendTxParams, EstimateNativeFeeOptions, EvmServiceInitializer, GasSettings, GetBridgeableAssetsProps, GetBridgeableAssetsResult, GetMinimumTransferAmountProps, GetSupportedChainsResult, LombardServiceInitializer, MarkrServiceInitializer, MutableGetSupportedChainsResult, NativeFeeEstimate, ServiceInitializer, ServiceQuoteOptions, TrackTransferProps, TransferAssetProps, TransferService } from "./types/service.cjs";
|
|
15
15
|
import { CheckRecurringEligibilityParams, ListRecurringOrdersParams, ListRecurringOrdersResponse, RECURRING_FREQUENCY_UNITS, RECURRING_UNLIMITED_ORDERS_SENTINEL, RecurringChainInfoEntry, RecurringChainInfoMap, RecurringEligibility, RecurringEligibilityReason, RecurringExecuteFirstFillParams, RecurringExecuteOrderActionParams, RecurringExecuteResult, RecurringFrequency, RecurringFrequencyUnit, RecurringNamespace, RecurringNamespaceCheckEligibilityParams, RecurringNamespaceQuoteParams, RecurringOrder, RecurringOrderFailure, RecurringOrderStatus, RecurringQuoteFee, RecurringQuoteFeeType, RecurringQuoteParams, RecurringQuoteResponse, RecurringSwapParams } from "./transfer-service/markr/recurring/types.cjs";
|
|
16
16
|
import { AssetBridgeMap, CreateTransferManagerOptions, ServiceStatus, ServiceStatusBaseRecord, ServiceStatusErrorRecord, ServiceStatusInitializedRecord, ServiceStatusRecord, ServiceStatusUnsupportedEnvironmentRecord, TransferManager, TransferManagerStatus, TransferManagerStatusServicesRecord } from "./types/transfer-manager.cjs";
|
|
17
|
-
import { isEnvironment, isErc20Asset, isEvmBridgeInitializer, isLombardServiceInitializer, isMarkrServiceInitializer, isNativeAsset, isServiceInitializer, isSplAsset } from "./type-guards.cjs";
|
|
17
|
+
import { isEnvironment, isErc20Asset, isEvmBridgeInitializer, isLombardServiceInitializer, isMarkrServiceInitializer, isNativeAsset, isQuote, isServiceInitializer, isSplAsset, isTransfer } from "./type-guards.cjs";
|
|
18
18
|
import { createTransferManager } from "./transfer-manager.cjs";
|
|
19
|
+
import { EnableHyperEvmBigBlocksParams, EvmUserModifyAction, buildEvmUserModifyAction, enableHyperEvmBigBlocks } from "./transfer-service/markr/_hyperliquid-l1-action.cjs";
|
|
19
20
|
import { caip2ToEip155ChainId, caip2ToEip155HexChainId, eip155ChainIdToCaip2, isCaip2ChainId, splitCaip2ChainId } from "./utils/caip.cjs";
|
|
20
21
|
import { dedupeBridgeableAssets } from "./utils/bridgeable-assets.cjs";
|
|
21
22
|
import { DestinationChainSortInput, compareDestinationChains, getDestinationChainPriority, sortDestinationChains } from "./utils/destination-chains.cjs";
|
|
22
23
|
import { calculatePriceImpactFromQuote } from "./utils/price-impact.cjs";
|
|
23
24
|
import { parseTransfer, stringifyTransfer } from "./utils/transfer-utils.cjs";
|
|
25
|
+
import { getRecoveredAtomicAmount } from "./transfer-service/avalanche-cct/get-recovered-atomic-amount.cjs";
|
|
24
26
|
import { MarkrService } from "./transfer-service/markr/markr-service.cjs";
|
|
25
27
|
import { FrequencyValidationResult, RECURRING_FREQUENCY_VALUE_MAX, deriveIntervalSeconds, validateFrequency } from "./transfer-service/markr/recurring/_frequency.cjs";
|
|
26
28
|
import { ApprovalRevertedError } from "./transfer-service/_evm-approval.cjs";
|
|
27
|
-
export { AVALANCHE_CAIP2_TO_BLOCKCHAIN_ID_BY_NETWORK, AVALANCHE_FUJI_CHAIN, AVALANCHE_FUJI_P_CHAIN, AVALANCHE_FUJI_X_CHAIN, AVALANCHE_MAINNET_CHAIN, AVALANCHE_MAINNET_P_CHAIN, AVALANCHE_MAINNET_X_CHAIN, AbortedError, ApprovalRevertedError, ArrayElement, Asset, AssetBridgeMap, AssetSearchQuery, AssetWithExtras, AvalancheBlockchainAlias, AvalancheCctInitializer, AvalancheChainIds, AvalancheFujiBlockchainChainIds, AvalancheFujiBlockchainIds, AvalancheMainnetBlockchainChainIds, AvalancheMainnetBlockchainIds, AvalancheSendTxFunction, AvalancheSendTxParams, BITCOIN_MAINNET_CHAIN, BITCOIN_TESTNET_CHAIN, BTC_SERVICE_TYPES, BaseChainIds, BitcoinChainIds, BitcoinFeeRateTier, BitcoinFunctions, BitcoinInputUTXO, BitcoinInputUTXOWithOptionalScript, BitcoinOutputUTXO, BitcoinTx, Blockchain, Brand, BridgeableAsset, BridgeableUiAsset, BtcDispatch, BtcSign, BtcSigner, BtcTransactionRequest, Caip10AccountId, Caip2ChainId, Chain, ChainAssetMap, type CheckRecurringEligibilityParams, CompletedTransfer, CreateTransferManagerOptions, DeepMutable, type DestinationChainSortInput, DestinationInfo, ERC_ZERO_ADDRESS, ETHEREUM_MAINNET_CHAIN, ETHEREUM_SEPOLIA_CHAIN, EVM_SERVICE_TYPES, Environment, Erc20Asset, ErrorCode, ErrorReason, EstimateNativeFeeError, type EstimateNativeFeeErrorDetails, EstimateNativeFeeOptions, EthereumChainIds, EvmChainId, EvmDispatch, EvmServiceInitializer, EvmSign, EvmSignBatch, EvmSignMessage, EvmSignTypedData, EvmSigner, EvmSignerWithMessage, EvmTransactionRequest, EvmTypedData, FEE_RATE_TIER_TO_BITCOIN, FailedTransfer, FeeRateTier, Fetch, type FrequencyValidationResult, GasSettings, type GetAtomicUtxosCallback, GetBridgeableAssetsProps, GetBridgeableAssetsResult, type GetCoreEthAddressCallback, GetMinimumTransferAmountProps, GetSupportedChainsResult, type GetUtxosCallback, type GetWalletAddressesForChainAliasCallback, type GetWalletChangeAddressForChainAliasCallback, Hex, HttpError, HyperliquidChainIds, InsufficientFundsError, InvalidParamsError, type ListRecurringOrdersParams, type ListRecurringOrdersResponse, LombardServiceInitializer, type MarkrService, MarkrServiceInitializer, Mutable, MutableGetSupportedChainsResult, NATIVE_AVAX, NATIVE_ETH, NATIVE_SOL_ADDRESS, NativeAsset, NativeFeeEstimate, PolygonChainIds, Quote, QuoteFee, QuoteFeeFundingModel, QuoteFeeToken, QuoteFeeType, QuoteFees, QuoterDonePayload, QuoterDonePayloadNoEligibleServices, QuoterDonePayloadNoQuotes, QuoterDonePayloadUnsubscribed, QuoterDoneReason, QuoterEventArgs, QuoterEventHandler, QuoterInterface, QuoterProps, QuotesTuple, RECURRING_FREQUENCY_UNITS, RECURRING_FREQUENCY_VALUE_MAX, RECURRING_UNLIMITED_ORDERS_SENTINEL, type RecurringChainInfoEntry, type RecurringChainInfoMap, type RecurringEligibility, RecurringEligibilityReason, type RecurringExecuteFirstFillParams, type RecurringExecuteOrderActionParams, type RecurringExecuteResult, type RecurringFrequency, type RecurringFrequencyUnit, type RecurringNamespace, type RecurringNamespaceCheckEligibilityParams, type RecurringNamespaceQuoteParams, type RecurringOrder, type RecurringOrderFailure, RecurringOrderStatus, type RecurringQuoteFee, type RecurringQuoteFeeType, type RecurringQuoteParams, type RecurringQuoteResponse, type RecurringSwapParams, RefundedTransfer, ResponseValidationError, SOLANA_DEVNET_CHAIN, SOLANA_MAINNET_CHAIN, SdkError, ServiceInitializationError, ServiceInitializer, ServiceQuoteEventArgs, ServiceQuoteEventHandler, ServiceQuoteOptions, ServiceStatus, ServiceStatusBaseRecord, ServiceStatusErrorRecord, ServiceStatusInitializedRecord, ServiceStatusRecord, ServiceStatusUnsupportedEnvironmentRecord, ServiceType, ServiceUnavailableError, SolanaChainIds, SolanaSendOptions, SolanaSign, SolanaSigner, SolanaTransactionParams, SourceCompletedTransfer, SourcePendingTransfer, SplAsset, TargetPendingTransfer, TimeoutError, TokenType, TrackTransferProps, Transfer, TransferAssetProps, TransferBase, TransferManager, TransferManagerStatus, TransferManagerStatusServicesRecord, TransferService, TransferSignatureReason, TransferSourceProgress, TransferStatus, TransferStepDetails, TransferTargetProgress, TransferableAsset, caip2ToEip155ChainId, caip2ToEip155HexChainId, calculatePriceImpactFromQuote, compareDestinationChains, createTransferManager, dedupeBridgeableAssets, deriveIntervalSeconds, eip155ChainIdToCaip2, getDestinationChainPriority, isAbortedError, isCaip2ChainId, isEnvironment, isErc20Asset, isEstimateNativeFeeError, isEvmBridgeInitializer, isHttpError, isInsufficientFundsError, isInvalidParamsError, isLombardServiceInitializer, isMarkrServiceInitializer, isNativeAsset, isResponseValidationError, isSdkError, isServiceInitializationError, isServiceInitializer, isServiceUnavailableError, isSplAsset, isTimeoutError, parseTransfer, sortDestinationChains, splitCaip2ChainId, stringifyTransfer, validateFrequency };
|
|
29
|
+
export { AVALANCHE_CAIP2_TO_BLOCKCHAIN_ID_BY_NETWORK, AVALANCHE_FUJI_CHAIN, AVALANCHE_FUJI_P_CHAIN, AVALANCHE_FUJI_X_CHAIN, AVALANCHE_MAINNET_CHAIN, AVALANCHE_MAINNET_P_CHAIN, AVALANCHE_MAINNET_X_CHAIN, AbortedError, ApprovalRevertedError, ArrayElement, Asset, AssetBridgeMap, AssetSearchQuery, AssetWithExtras, AvalancheBlockchainAlias, AvalancheCctInitializer, AvalancheChainIds, AvalancheFujiBlockchainChainIds, AvalancheFujiBlockchainIds, AvalancheMainnetBlockchainChainIds, AvalancheMainnetBlockchainIds, AvalancheSendTxFunction, AvalancheSendTxParams, BITCOIN_MAINNET_CHAIN, BITCOIN_TESTNET_CHAIN, BTC_SERVICE_TYPES, BaseChainIds, BitcoinChainIds, BitcoinFeeRateTier, BitcoinFunctions, BitcoinInputUTXO, BitcoinInputUTXOWithOptionalScript, BitcoinOutputUTXO, BitcoinTx, Blockchain, Brand, BridgeableAsset, BridgeableUiAsset, BtcDispatch, BtcSign, BtcSigner, BtcTransactionRequest, Caip10AccountId, Caip2ChainId, Chain, ChainAssetMap, type CheckRecurringEligibilityParams, CompletedTransfer, CreateTransferManagerOptions, DeepMutable, type DestinationChainSortInput, DestinationInfo, ERC_ZERO_ADDRESS, ETHEREUM_MAINNET_CHAIN, ETHEREUM_SEPOLIA_CHAIN, EVM_SERVICE_TYPES, type EnableHyperEvmBigBlocksParams, Environment, Erc20Asset, ErrorCode, ErrorReason, EstimateNativeFeeError, type EstimateNativeFeeErrorDetails, EstimateNativeFeeOptions, EthereumChainIds, EvmChainId, EvmDispatch, EvmServiceInitializer, EvmSign, EvmSignBatch, EvmSignMessage, EvmSignTypedData, EvmSigner, EvmSignerWithMessage, EvmTransactionRequest, EvmTypedData, type EvmUserModifyAction, FEE_RATE_TIER_TO_BITCOIN, FailedTransfer, FeeRateTier, Fetch, type FrequencyValidationResult, GasSettings, type GetAtomicUtxosCallback, GetBridgeableAssetsProps, GetBridgeableAssetsResult, type GetCoreEthAddressCallback, GetMinimumTransferAmountProps, GetSupportedChainsResult, type GetUtxosCallback, type GetWalletAddressesForChainAliasCallback, type GetWalletChangeAddressForChainAliasCallback, HYPEREVM_BIG_BLOCK_GAS_LIMIT, HYPEREVM_CHAIN_ID, HYPEREVM_SMALL_BLOCK_GAS_LIMIT, Hex, HttpError, HyperEvmChainIds, HyperliquidChainIds, InsufficientFundsError, InvalidParamsError, type ListRecurringOrdersParams, type ListRecurringOrdersResponse, LombardServiceInitializer, type MarkrService, MarkrServiceInitializer, Mutable, MutableGetSupportedChainsResult, NATIVE_AVAX, NATIVE_ETH, NATIVE_SOL_ADDRESS, NativeAsset, NativeFeeEstimate, PolygonChainIds, Quote, QuoteFee, QuoteFeeFundingModel, QuoteFeeToken, QuoteFeeType, QuoteFees, QuoterDonePayload, QuoterDonePayloadNoEligibleServices, QuoterDonePayloadNoQuotes, QuoterDonePayloadUnsubscribed, QuoterDoneReason, QuoterEventArgs, QuoterEventHandler, QuoterInterface, QuoterProps, QuotesTuple, RECURRING_FREQUENCY_UNITS, RECURRING_FREQUENCY_VALUE_MAX, RECURRING_UNLIMITED_ORDERS_SENTINEL, type RecurringChainInfoEntry, type RecurringChainInfoMap, type RecurringEligibility, RecurringEligibilityReason, type RecurringExecuteFirstFillParams, type RecurringExecuteOrderActionParams, type RecurringExecuteResult, type RecurringFrequency, type RecurringFrequencyUnit, type RecurringNamespace, type RecurringNamespaceCheckEligibilityParams, type RecurringNamespaceQuoteParams, type RecurringOrder, type RecurringOrderFailure, RecurringOrderStatus, type RecurringQuoteFee, type RecurringQuoteFeeType, type RecurringQuoteParams, type RecurringQuoteResponse, type RecurringSwapParams, RefundedTransfer, ResponseValidationError, SOLANA_DEVNET_CHAIN, SOLANA_MAINNET_CHAIN, SdkError, ServiceInitializationError, ServiceInitializer, ServiceQuoteEventArgs, ServiceQuoteEventHandler, ServiceQuoteOptions, ServiceStatus, ServiceStatusBaseRecord, ServiceStatusErrorRecord, ServiceStatusInitializedRecord, ServiceStatusRecord, ServiceStatusUnsupportedEnvironmentRecord, ServiceType, ServiceUnavailableError, SolanaChainIds, SolanaSendOptions, SolanaSign, SolanaSigner, SolanaTransactionParams, SourceCompletedTransfer, SourcePendingTransfer, SplAsset, TargetPendingTransfer, TimeoutError, TokenType, TrackTransferProps, Transfer, TransferAssetProps, TransferBase, TransferManager, TransferManagerStatus, TransferManagerStatusServicesRecord, TransferService, TransferSignatureReason, TransferSourceProgress, TransferStatus, TransferStepDetails, TransferTargetProgress, TransferableAsset, buildEvmUserModifyAction, caip2ToEip155ChainId, caip2ToEip155HexChainId, calculatePriceImpactFromQuote, compareDestinationChains, createTransferManager, dedupeBridgeableAssets, deriveIntervalSeconds, eip155ChainIdToCaip2, enableHyperEvmBigBlocks, getDestinationChainPriority, getRecoveredAtomicAmount, isAbortedError, isCaip2ChainId, isEnvironment, isErc20Asset, isEstimateNativeFeeError, isEvmBridgeInitializer, isHttpError, isInsufficientFundsError, isInvalidParamsError, isLombardServiceInitializer, isMarkrServiceInitializer, isNativeAsset, isQuote, isResponseValidationError, isSdkError, isServiceInitializationError, isServiceInitializer, isServiceUnavailableError, isSplAsset, isTimeoutError, isTransfer, parseTransfer, sortDestinationChains, splitCaip2ChainId, stringifyTransfer, validateFrequency };
|
package/dist/mod.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Caip10AccountId, Caip2ChainId } from "./types/caip.js";
|
|
|
2
2
|
import { BitcoinFeeRateTier, BitcoinFunctions, BitcoinInputUTXO, BitcoinInputUTXOWithOptionalScript, BitcoinOutputUTXO, BitcoinTx } from "./types/bitcoin.js";
|
|
3
3
|
import { Chain } from "./types/chain.js";
|
|
4
4
|
import { FeeRateTier } from "./types/fee.js";
|
|
5
|
-
import { AVALANCHE_CAIP2_TO_BLOCKCHAIN_ID_BY_NETWORK, AVALANCHE_FUJI_CHAIN, AVALANCHE_FUJI_P_CHAIN, AVALANCHE_FUJI_X_CHAIN, AVALANCHE_MAINNET_CHAIN, AVALANCHE_MAINNET_P_CHAIN, AVALANCHE_MAINNET_X_CHAIN, AvalancheBlockchainAlias, AvalancheChainIds, AvalancheFujiBlockchainChainIds, AvalancheFujiBlockchainIds, AvalancheMainnetBlockchainChainIds, AvalancheMainnetBlockchainIds, BITCOIN_MAINNET_CHAIN, BITCOIN_TESTNET_CHAIN, BTC_SERVICE_TYPES, BaseChainIds, BitcoinChainIds, Blockchain, ERC_ZERO_ADDRESS, ETHEREUM_MAINNET_CHAIN, ETHEREUM_SEPOLIA_CHAIN, EVM_SERVICE_TYPES, Environment, EthereumChainIds, EvmChainId, FEE_RATE_TIER_TO_BITCOIN, HyperliquidChainIds, NATIVE_AVAX, NATIVE_ETH, NATIVE_SOL_ADDRESS, PolygonChainIds, SOLANA_DEVNET_CHAIN, SOLANA_MAINNET_CHAIN, ServiceType, SolanaChainIds, TokenType, TransferSignatureReason } from "./constants.js";
|
|
5
|
+
import { AVALANCHE_CAIP2_TO_BLOCKCHAIN_ID_BY_NETWORK, AVALANCHE_FUJI_CHAIN, AVALANCHE_FUJI_P_CHAIN, AVALANCHE_FUJI_X_CHAIN, AVALANCHE_MAINNET_CHAIN, AVALANCHE_MAINNET_P_CHAIN, AVALANCHE_MAINNET_X_CHAIN, AvalancheBlockchainAlias, AvalancheChainIds, AvalancheFujiBlockchainChainIds, AvalancheFujiBlockchainIds, AvalancheMainnetBlockchainChainIds, AvalancheMainnetBlockchainIds, BITCOIN_MAINNET_CHAIN, BITCOIN_TESTNET_CHAIN, BTC_SERVICE_TYPES, BaseChainIds, BitcoinChainIds, Blockchain, ERC_ZERO_ADDRESS, ETHEREUM_MAINNET_CHAIN, ETHEREUM_SEPOLIA_CHAIN, EVM_SERVICE_TYPES, Environment, EthereumChainIds, EvmChainId, FEE_RATE_TIER_TO_BITCOIN, HYPEREVM_BIG_BLOCK_GAS_LIMIT, HYPEREVM_CHAIN_ID, HYPEREVM_SMALL_BLOCK_GAS_LIMIT, HyperEvmChainIds, HyperliquidChainIds, NATIVE_AVAX, NATIVE_ETH, NATIVE_SOL_ADDRESS, PolygonChainIds, SOLANA_DEVNET_CHAIN, SOLANA_MAINNET_CHAIN, ServiceType, SolanaChainIds, TokenType, TransferSignatureReason } from "./constants.js";
|
|
6
6
|
import { Asset, AssetWithExtras, BridgeableAsset, BridgeableUiAsset, ChainAssetMap, DestinationInfo, Erc20Asset, NativeAsset, SplAsset, TransferableAsset } from "./types/asset.js";
|
|
7
7
|
import { Quote, QuoteFee, QuoteFeeFundingModel, QuoteFeeToken, QuoteFeeType, QuoteFees, QuoterDonePayload, QuoterDonePayloadNoEligibleServices, QuoterDonePayloadNoQuotes, QuoterDonePayloadUnsubscribed, QuoterDoneReason, QuoterEventArgs, QuoterEventHandler, QuoterInterface, QuoterProps, QuotesTuple, ServiceQuoteEventArgs, ServiceQuoteEventHandler } from "./types/quote.js";
|
|
8
8
|
import { ArrayElement, Brand, DeepMutable, Fetch, Mutable } from "./types/utility-types.js";
|
|
@@ -14,14 +14,16 @@ import { BtcDispatch, BtcSign, BtcSigner, BtcTransactionRequest, EvmDispatch, Ev
|
|
|
14
14
|
import { AssetSearchQuery, AvalancheCctInitializer, AvalancheSendTxFunction, AvalancheSendTxParams, EstimateNativeFeeOptions, EvmServiceInitializer, GasSettings, GetBridgeableAssetsProps, GetBridgeableAssetsResult, GetMinimumTransferAmountProps, GetSupportedChainsResult, LombardServiceInitializer, MarkrServiceInitializer, MutableGetSupportedChainsResult, NativeFeeEstimate, ServiceInitializer, ServiceQuoteOptions, TrackTransferProps, TransferAssetProps, TransferService } from "./types/service.js";
|
|
15
15
|
import { CheckRecurringEligibilityParams, ListRecurringOrdersParams, ListRecurringOrdersResponse, RECURRING_FREQUENCY_UNITS, RECURRING_UNLIMITED_ORDERS_SENTINEL, RecurringChainInfoEntry, RecurringChainInfoMap, RecurringEligibility, RecurringEligibilityReason, RecurringExecuteFirstFillParams, RecurringExecuteOrderActionParams, RecurringExecuteResult, RecurringFrequency, RecurringFrequencyUnit, RecurringNamespace, RecurringNamespaceCheckEligibilityParams, RecurringNamespaceQuoteParams, RecurringOrder, RecurringOrderFailure, RecurringOrderStatus, RecurringQuoteFee, RecurringQuoteFeeType, RecurringQuoteParams, RecurringQuoteResponse, RecurringSwapParams } from "./transfer-service/markr/recurring/types.js";
|
|
16
16
|
import { AssetBridgeMap, CreateTransferManagerOptions, ServiceStatus, ServiceStatusBaseRecord, ServiceStatusErrorRecord, ServiceStatusInitializedRecord, ServiceStatusRecord, ServiceStatusUnsupportedEnvironmentRecord, TransferManager, TransferManagerStatus, TransferManagerStatusServicesRecord } from "./types/transfer-manager.js";
|
|
17
|
-
import { isEnvironment, isErc20Asset, isEvmBridgeInitializer, isLombardServiceInitializer, isMarkrServiceInitializer, isNativeAsset, isServiceInitializer, isSplAsset } from "./type-guards.js";
|
|
17
|
+
import { isEnvironment, isErc20Asset, isEvmBridgeInitializer, isLombardServiceInitializer, isMarkrServiceInitializer, isNativeAsset, isQuote, isServiceInitializer, isSplAsset, isTransfer } from "./type-guards.js";
|
|
18
18
|
import { createTransferManager } from "./transfer-manager.js";
|
|
19
|
+
import { EnableHyperEvmBigBlocksParams, EvmUserModifyAction, buildEvmUserModifyAction, enableHyperEvmBigBlocks } from "./transfer-service/markr/_hyperliquid-l1-action.js";
|
|
19
20
|
import { caip2ToEip155ChainId, caip2ToEip155HexChainId, eip155ChainIdToCaip2, isCaip2ChainId, splitCaip2ChainId } from "./utils/caip.js";
|
|
20
21
|
import { dedupeBridgeableAssets } from "./utils/bridgeable-assets.js";
|
|
21
22
|
import { DestinationChainSortInput, compareDestinationChains, getDestinationChainPriority, sortDestinationChains } from "./utils/destination-chains.js";
|
|
22
23
|
import { calculatePriceImpactFromQuote } from "./utils/price-impact.js";
|
|
23
24
|
import { parseTransfer, stringifyTransfer } from "./utils/transfer-utils.js";
|
|
25
|
+
import { getRecoveredAtomicAmount } from "./transfer-service/avalanche-cct/get-recovered-atomic-amount.js";
|
|
24
26
|
import { MarkrService } from "./transfer-service/markr/markr-service.js";
|
|
25
27
|
import { FrequencyValidationResult, RECURRING_FREQUENCY_VALUE_MAX, deriveIntervalSeconds, validateFrequency } from "./transfer-service/markr/recurring/_frequency.js";
|
|
26
28
|
import { ApprovalRevertedError } from "./transfer-service/_evm-approval.js";
|
|
27
|
-
export { AVALANCHE_CAIP2_TO_BLOCKCHAIN_ID_BY_NETWORK, AVALANCHE_FUJI_CHAIN, AVALANCHE_FUJI_P_CHAIN, AVALANCHE_FUJI_X_CHAIN, AVALANCHE_MAINNET_CHAIN, AVALANCHE_MAINNET_P_CHAIN, AVALANCHE_MAINNET_X_CHAIN, AbortedError, ApprovalRevertedError, ArrayElement, Asset, AssetBridgeMap, AssetSearchQuery, AssetWithExtras, AvalancheBlockchainAlias, AvalancheCctInitializer, AvalancheChainIds, AvalancheFujiBlockchainChainIds, AvalancheFujiBlockchainIds, AvalancheMainnetBlockchainChainIds, AvalancheMainnetBlockchainIds, AvalancheSendTxFunction, AvalancheSendTxParams, BITCOIN_MAINNET_CHAIN, BITCOIN_TESTNET_CHAIN, BTC_SERVICE_TYPES, BaseChainIds, BitcoinChainIds, BitcoinFeeRateTier, BitcoinFunctions, BitcoinInputUTXO, BitcoinInputUTXOWithOptionalScript, BitcoinOutputUTXO, BitcoinTx, Blockchain, Brand, BridgeableAsset, BridgeableUiAsset, BtcDispatch, BtcSign, BtcSigner, BtcTransactionRequest, Caip10AccountId, Caip2ChainId, Chain, ChainAssetMap, type CheckRecurringEligibilityParams, CompletedTransfer, CreateTransferManagerOptions, DeepMutable, type DestinationChainSortInput, DestinationInfo, ERC_ZERO_ADDRESS, ETHEREUM_MAINNET_CHAIN, ETHEREUM_SEPOLIA_CHAIN, EVM_SERVICE_TYPES, Environment, Erc20Asset, ErrorCode, ErrorReason, EstimateNativeFeeError, type EstimateNativeFeeErrorDetails, EstimateNativeFeeOptions, EthereumChainIds, EvmChainId, EvmDispatch, EvmServiceInitializer, EvmSign, EvmSignBatch, EvmSignMessage, EvmSignTypedData, EvmSigner, EvmSignerWithMessage, EvmTransactionRequest, EvmTypedData, FEE_RATE_TIER_TO_BITCOIN, FailedTransfer, FeeRateTier, Fetch, type FrequencyValidationResult, GasSettings, type GetAtomicUtxosCallback, GetBridgeableAssetsProps, GetBridgeableAssetsResult, type GetCoreEthAddressCallback, GetMinimumTransferAmountProps, GetSupportedChainsResult, type GetUtxosCallback, type GetWalletAddressesForChainAliasCallback, type GetWalletChangeAddressForChainAliasCallback, Hex, HttpError, HyperliquidChainIds, InsufficientFundsError, InvalidParamsError, type ListRecurringOrdersParams, type ListRecurringOrdersResponse, LombardServiceInitializer, type MarkrService, MarkrServiceInitializer, Mutable, MutableGetSupportedChainsResult, NATIVE_AVAX, NATIVE_ETH, NATIVE_SOL_ADDRESS, NativeAsset, NativeFeeEstimate, PolygonChainIds, Quote, QuoteFee, QuoteFeeFundingModel, QuoteFeeToken, QuoteFeeType, QuoteFees, QuoterDonePayload, QuoterDonePayloadNoEligibleServices, QuoterDonePayloadNoQuotes, QuoterDonePayloadUnsubscribed, QuoterDoneReason, QuoterEventArgs, QuoterEventHandler, QuoterInterface, QuoterProps, QuotesTuple, RECURRING_FREQUENCY_UNITS, RECURRING_FREQUENCY_VALUE_MAX, RECURRING_UNLIMITED_ORDERS_SENTINEL, type RecurringChainInfoEntry, type RecurringChainInfoMap, type RecurringEligibility, RecurringEligibilityReason, type RecurringExecuteFirstFillParams, type RecurringExecuteOrderActionParams, type RecurringExecuteResult, type RecurringFrequency, type RecurringFrequencyUnit, type RecurringNamespace, type RecurringNamespaceCheckEligibilityParams, type RecurringNamespaceQuoteParams, type RecurringOrder, type RecurringOrderFailure, RecurringOrderStatus, type RecurringQuoteFee, type RecurringQuoteFeeType, type RecurringQuoteParams, type RecurringQuoteResponse, type RecurringSwapParams, RefundedTransfer, ResponseValidationError, SOLANA_DEVNET_CHAIN, SOLANA_MAINNET_CHAIN, SdkError, ServiceInitializationError, ServiceInitializer, ServiceQuoteEventArgs, ServiceQuoteEventHandler, ServiceQuoteOptions, ServiceStatus, ServiceStatusBaseRecord, ServiceStatusErrorRecord, ServiceStatusInitializedRecord, ServiceStatusRecord, ServiceStatusUnsupportedEnvironmentRecord, ServiceType, ServiceUnavailableError, SolanaChainIds, SolanaSendOptions, SolanaSign, SolanaSigner, SolanaTransactionParams, SourceCompletedTransfer, SourcePendingTransfer, SplAsset, TargetPendingTransfer, TimeoutError, TokenType, TrackTransferProps, Transfer, TransferAssetProps, TransferBase, TransferManager, TransferManagerStatus, TransferManagerStatusServicesRecord, TransferService, TransferSignatureReason, TransferSourceProgress, TransferStatus, TransferStepDetails, TransferTargetProgress, TransferableAsset, caip2ToEip155ChainId, caip2ToEip155HexChainId, calculatePriceImpactFromQuote, compareDestinationChains, createTransferManager, dedupeBridgeableAssets, deriveIntervalSeconds, eip155ChainIdToCaip2, getDestinationChainPriority, isAbortedError, isCaip2ChainId, isEnvironment, isErc20Asset, isEstimateNativeFeeError, isEvmBridgeInitializer, isHttpError, isInsufficientFundsError, isInvalidParamsError, isLombardServiceInitializer, isMarkrServiceInitializer, isNativeAsset, isResponseValidationError, isSdkError, isServiceInitializationError, isServiceInitializer, isServiceUnavailableError, isSplAsset, isTimeoutError, parseTransfer, sortDestinationChains, splitCaip2ChainId, stringifyTransfer, validateFrequency };
|
|
29
|
+
export { AVALANCHE_CAIP2_TO_BLOCKCHAIN_ID_BY_NETWORK, AVALANCHE_FUJI_CHAIN, AVALANCHE_FUJI_P_CHAIN, AVALANCHE_FUJI_X_CHAIN, AVALANCHE_MAINNET_CHAIN, AVALANCHE_MAINNET_P_CHAIN, AVALANCHE_MAINNET_X_CHAIN, AbortedError, ApprovalRevertedError, ArrayElement, Asset, AssetBridgeMap, AssetSearchQuery, AssetWithExtras, AvalancheBlockchainAlias, AvalancheCctInitializer, AvalancheChainIds, AvalancheFujiBlockchainChainIds, AvalancheFujiBlockchainIds, AvalancheMainnetBlockchainChainIds, AvalancheMainnetBlockchainIds, AvalancheSendTxFunction, AvalancheSendTxParams, BITCOIN_MAINNET_CHAIN, BITCOIN_TESTNET_CHAIN, BTC_SERVICE_TYPES, BaseChainIds, BitcoinChainIds, BitcoinFeeRateTier, BitcoinFunctions, BitcoinInputUTXO, BitcoinInputUTXOWithOptionalScript, BitcoinOutputUTXO, BitcoinTx, Blockchain, Brand, BridgeableAsset, BridgeableUiAsset, BtcDispatch, BtcSign, BtcSigner, BtcTransactionRequest, Caip10AccountId, Caip2ChainId, Chain, ChainAssetMap, type CheckRecurringEligibilityParams, CompletedTransfer, CreateTransferManagerOptions, DeepMutable, type DestinationChainSortInput, DestinationInfo, ERC_ZERO_ADDRESS, ETHEREUM_MAINNET_CHAIN, ETHEREUM_SEPOLIA_CHAIN, EVM_SERVICE_TYPES, type EnableHyperEvmBigBlocksParams, Environment, Erc20Asset, ErrorCode, ErrorReason, EstimateNativeFeeError, type EstimateNativeFeeErrorDetails, EstimateNativeFeeOptions, EthereumChainIds, EvmChainId, EvmDispatch, EvmServiceInitializer, EvmSign, EvmSignBatch, EvmSignMessage, EvmSignTypedData, EvmSigner, EvmSignerWithMessage, EvmTransactionRequest, EvmTypedData, type EvmUserModifyAction, FEE_RATE_TIER_TO_BITCOIN, FailedTransfer, FeeRateTier, Fetch, type FrequencyValidationResult, GasSettings, type GetAtomicUtxosCallback, GetBridgeableAssetsProps, GetBridgeableAssetsResult, type GetCoreEthAddressCallback, GetMinimumTransferAmountProps, GetSupportedChainsResult, type GetUtxosCallback, type GetWalletAddressesForChainAliasCallback, type GetWalletChangeAddressForChainAliasCallback, HYPEREVM_BIG_BLOCK_GAS_LIMIT, HYPEREVM_CHAIN_ID, HYPEREVM_SMALL_BLOCK_GAS_LIMIT, Hex, HttpError, HyperEvmChainIds, HyperliquidChainIds, InsufficientFundsError, InvalidParamsError, type ListRecurringOrdersParams, type ListRecurringOrdersResponse, LombardServiceInitializer, type MarkrService, MarkrServiceInitializer, Mutable, MutableGetSupportedChainsResult, NATIVE_AVAX, NATIVE_ETH, NATIVE_SOL_ADDRESS, NativeAsset, NativeFeeEstimate, PolygonChainIds, Quote, QuoteFee, QuoteFeeFundingModel, QuoteFeeToken, QuoteFeeType, QuoteFees, QuoterDonePayload, QuoterDonePayloadNoEligibleServices, QuoterDonePayloadNoQuotes, QuoterDonePayloadUnsubscribed, QuoterDoneReason, QuoterEventArgs, QuoterEventHandler, QuoterInterface, QuoterProps, QuotesTuple, RECURRING_FREQUENCY_UNITS, RECURRING_FREQUENCY_VALUE_MAX, RECURRING_UNLIMITED_ORDERS_SENTINEL, type RecurringChainInfoEntry, type RecurringChainInfoMap, type RecurringEligibility, RecurringEligibilityReason, type RecurringExecuteFirstFillParams, type RecurringExecuteOrderActionParams, type RecurringExecuteResult, type RecurringFrequency, type RecurringFrequencyUnit, type RecurringNamespace, type RecurringNamespaceCheckEligibilityParams, type RecurringNamespaceQuoteParams, type RecurringOrder, type RecurringOrderFailure, RecurringOrderStatus, type RecurringQuoteFee, type RecurringQuoteFeeType, type RecurringQuoteParams, type RecurringQuoteResponse, type RecurringSwapParams, RefundedTransfer, ResponseValidationError, SOLANA_DEVNET_CHAIN, SOLANA_MAINNET_CHAIN, SdkError, ServiceInitializationError, ServiceInitializer, ServiceQuoteEventArgs, ServiceQuoteEventHandler, ServiceQuoteOptions, ServiceStatus, ServiceStatusBaseRecord, ServiceStatusErrorRecord, ServiceStatusInitializedRecord, ServiceStatusRecord, ServiceStatusUnsupportedEnvironmentRecord, ServiceType, ServiceUnavailableError, SolanaChainIds, SolanaSendOptions, SolanaSign, SolanaSigner, SolanaTransactionParams, SourceCompletedTransfer, SourcePendingTransfer, SplAsset, TargetPendingTransfer, TimeoutError, TokenType, TrackTransferProps, Transfer, TransferAssetProps, TransferBase, TransferManager, TransferManagerStatus, TransferManagerStatusServicesRecord, TransferService, TransferSignatureReason, TransferSourceProgress, TransferStatus, TransferStepDetails, TransferTargetProgress, TransferableAsset, buildEvmUserModifyAction, caip2ToEip155ChainId, caip2ToEip155HexChainId, calculatePriceImpactFromQuote, compareDestinationChains, createTransferManager, dedupeBridgeableAssets, deriveIntervalSeconds, eip155ChainIdToCaip2, enableHyperEvmBigBlocks, getDestinationChainPriority, getRecoveredAtomicAmount, isAbortedError, isCaip2ChainId, isEnvironment, isErc20Asset, isEstimateNativeFeeError, isEvmBridgeInitializer, isHttpError, isInsufficientFundsError, isInvalidParamsError, isLombardServiceInitializer, isMarkrServiceInitializer, isNativeAsset, isQuote, isResponseValidationError, isSdkError, isServiceInitializationError, isServiceInitializer, isServiceUnavailableError, isSplAsset, isTimeoutError, isTransfer, parseTransfer, sortDestinationChains, splitCaip2ChainId, stringifyTransfer, validateFrequency };
|
package/dist/mod.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{AVALANCHE_CAIP2_TO_BLOCKCHAIN_ID_BY_NETWORK as e,AVALANCHE_FUJI_CHAIN as t,AVALANCHE_FUJI_P_CHAIN as n,AVALANCHE_FUJI_X_CHAIN as r,AVALANCHE_MAINNET_CHAIN as i,AVALANCHE_MAINNET_P_CHAIN as a,AVALANCHE_MAINNET_X_CHAIN as o,AvalancheChainIds as s,AvalancheFujiBlockchainChainIds as c,AvalancheFujiBlockchainIds as l,AvalancheMainnetBlockchainChainIds as u,AvalancheMainnetBlockchainIds as d,BITCOIN_MAINNET_CHAIN as f,BITCOIN_TESTNET_CHAIN as p,BTC_SERVICE_TYPES as m,BaseChainIds as h,BitcoinChainIds as g,Blockchain as _,ERC_ZERO_ADDRESS as v,ETHEREUM_MAINNET_CHAIN as y,ETHEREUM_SEPOLIA_CHAIN as b,EVM_SERVICE_TYPES as x,Environment as S,EthereumChainIds as C,EvmChainId as w,FEE_RATE_TIER_TO_BITCOIN as T,
|
|
1
|
+
import{AVALANCHE_CAIP2_TO_BLOCKCHAIN_ID_BY_NETWORK as e,AVALANCHE_FUJI_CHAIN as t,AVALANCHE_FUJI_P_CHAIN as n,AVALANCHE_FUJI_X_CHAIN as r,AVALANCHE_MAINNET_CHAIN as i,AVALANCHE_MAINNET_P_CHAIN as a,AVALANCHE_MAINNET_X_CHAIN as o,AvalancheChainIds as s,AvalancheFujiBlockchainChainIds as c,AvalancheFujiBlockchainIds as l,AvalancheMainnetBlockchainChainIds as u,AvalancheMainnetBlockchainIds as d,BITCOIN_MAINNET_CHAIN as f,BITCOIN_TESTNET_CHAIN as p,BTC_SERVICE_TYPES as m,BaseChainIds as h,BitcoinChainIds as g,Blockchain as _,ERC_ZERO_ADDRESS as v,ETHEREUM_MAINNET_CHAIN as y,ETHEREUM_SEPOLIA_CHAIN as b,EVM_SERVICE_TYPES as x,Environment as S,EthereumChainIds as C,EvmChainId as w,FEE_RATE_TIER_TO_BITCOIN as T,HYPEREVM_BIG_BLOCK_GAS_LIMIT as E,HYPEREVM_CHAIN_ID as D,HYPEREVM_SMALL_BLOCK_GAS_LIMIT as O,HyperEvmChainIds as k,HyperliquidChainIds as A,NATIVE_AVAX as j,NATIVE_ETH as M,NATIVE_SOL_ADDRESS as N,PolygonChainIds as P,SOLANA_DEVNET_CHAIN as F,SOLANA_MAINNET_CHAIN as I,ServiceType as L,SolanaChainIds as R,TokenType as z,TransferSignatureReason as B}from"./constants.js";import{AbortedError as V,ErrorCode as H,ErrorReason as U,EstimateNativeFeeError as W,HttpError as G,InsufficientFundsError as K,InvalidParamsError as q,ResponseValidationError as J,SdkError as Y,ServiceInitializationError as X,ServiceUnavailableError as Z,TimeoutError as Q,isAbortedError as $,isEstimateNativeFeeError as ee,isHttpError as te,isInsufficientFundsError as ne,isInvalidParamsError as re,isResponseValidationError as ie,isSdkError as ae,isServiceInitializationError as oe,isServiceUnavailableError as se,isTimeoutError as ce}from"./errors.js";import{isEnvironment as le,isErc20Asset as ue,isEvmBridgeInitializer as de,isLombardServiceInitializer as fe,isMarkrServiceInitializer as pe,isNativeAsset as me,isQuote as he,isServiceInitializer as ge,isSplAsset as _e,isTransfer as ve}from"./type-guards.js";import{createTransferManager as ye}from"./transfer-manager.js";import{caip2ToEip155ChainId as be,caip2ToEip155HexChainId as xe,eip155ChainIdToCaip2 as Se,isCaip2ChainId as Ce,splitCaip2ChainId as we}from"./utils/caip.js";import{buildEvmUserModifyAction as Te,enableHyperEvmBigBlocks as Ee}from"./transfer-service/markr/_hyperliquid-l1-action.js";import{dedupeBridgeableAssets as De}from"./utils/bridgeable-assets.js";import{compareDestinationChains as Oe,getDestinationChainPriority as ke,sortDestinationChains as Ae}from"./utils/destination-chains.js";import{calculatePriceImpactFromQuote as je}from"./utils/price-impact.js";import{parseTransfer as Me,stringifyTransfer as Ne}from"./utils/transfer-utils.js";import{getRecoveredAtomicAmount as Pe}from"./transfer-service/avalanche-cct/get-recovered-atomic-amount.js";import{RECURRING_FREQUENCY_UNITS as Fe,RECURRING_UNLIMITED_ORDERS_SENTINEL as Ie,RecurringEligibilityReason as Le,RecurringOrderStatus as Re}from"./transfer-service/markr/recurring/types.js";import{RECURRING_FREQUENCY_VALUE_MAX as ze,deriveIntervalSeconds as Be,validateFrequency as Ve}from"./transfer-service/markr/recurring/_frequency.js";import{ApprovalRevertedError as He}from"./transfer-service/_evm-approval.js";export{e as AVALANCHE_CAIP2_TO_BLOCKCHAIN_ID_BY_NETWORK,t as AVALANCHE_FUJI_CHAIN,n as AVALANCHE_FUJI_P_CHAIN,r as AVALANCHE_FUJI_X_CHAIN,i as AVALANCHE_MAINNET_CHAIN,a as AVALANCHE_MAINNET_P_CHAIN,o as AVALANCHE_MAINNET_X_CHAIN,V as AbortedError,He as ApprovalRevertedError,s as AvalancheChainIds,c as AvalancheFujiBlockchainChainIds,l as AvalancheFujiBlockchainIds,u as AvalancheMainnetBlockchainChainIds,d as AvalancheMainnetBlockchainIds,f as BITCOIN_MAINNET_CHAIN,p as BITCOIN_TESTNET_CHAIN,m as BTC_SERVICE_TYPES,h as BaseChainIds,g as BitcoinChainIds,_ as Blockchain,v as ERC_ZERO_ADDRESS,y as ETHEREUM_MAINNET_CHAIN,b as ETHEREUM_SEPOLIA_CHAIN,x as EVM_SERVICE_TYPES,S as Environment,H as ErrorCode,U as ErrorReason,W as EstimateNativeFeeError,C as EthereumChainIds,w as EvmChainId,T as FEE_RATE_TIER_TO_BITCOIN,E as HYPEREVM_BIG_BLOCK_GAS_LIMIT,D as HYPEREVM_CHAIN_ID,O as HYPEREVM_SMALL_BLOCK_GAS_LIMIT,G as HttpError,k as HyperEvmChainIds,A as HyperliquidChainIds,K as InsufficientFundsError,q as InvalidParamsError,j as NATIVE_AVAX,M as NATIVE_ETH,N as NATIVE_SOL_ADDRESS,P as PolygonChainIds,Fe as RECURRING_FREQUENCY_UNITS,ze as RECURRING_FREQUENCY_VALUE_MAX,Ie as RECURRING_UNLIMITED_ORDERS_SENTINEL,Le as RecurringEligibilityReason,Re as RecurringOrderStatus,J as ResponseValidationError,F as SOLANA_DEVNET_CHAIN,I as SOLANA_MAINNET_CHAIN,Y as SdkError,X as ServiceInitializationError,L as ServiceType,Z as ServiceUnavailableError,R as SolanaChainIds,Q as TimeoutError,z as TokenType,B as TransferSignatureReason,Te as buildEvmUserModifyAction,be as caip2ToEip155ChainId,xe as caip2ToEip155HexChainId,je as calculatePriceImpactFromQuote,Oe as compareDestinationChains,ye as createTransferManager,De as dedupeBridgeableAssets,Be as deriveIntervalSeconds,Se as eip155ChainIdToCaip2,Ee as enableHyperEvmBigBlocks,ke as getDestinationChainPriority,Pe as getRecoveredAtomicAmount,$ as isAbortedError,Ce as isCaip2ChainId,le as isEnvironment,ue as isErc20Asset,ee as isEstimateNativeFeeError,de as isEvmBridgeInitializer,te as isHttpError,ne as isInsufficientFundsError,re as isInvalidParamsError,fe as isLombardServiceInitializer,pe as isMarkrServiceInitializer,me as isNativeAsset,he as isQuote,ie as isResponseValidationError,ae as isSdkError,oe as isServiceInitializationError,ge as isServiceInitializer,se as isServiceUnavailableError,_e as isSplAsset,ce as isTimeoutError,ve as isTransfer,Me as parseTransfer,Ae as sortDestinationChains,we as splitCaip2ChainId,Ne as stringifyTransfer,Ve as validateFrequency};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_evm-errors.cjs","names":["z","BaseError","EstimateNativeFeeError","InsufficientFundsError","ErrorCode"],"sources":["../../src/transfer-service/_evm-errors.ts"],"sourcesContent":["/**\n * @module\n * @internal\n *\n * Shared utility for EVM gas estimation with revert recovery.\n */\nimport { BaseError, decodeErrorResult, type Abi, type Hex } from 'viem';\nimport { z } from 'zod';\nimport {\n type EstimateNativeFeeErrorDetails,\n ErrorCode,\n EstimateNativeFeeError,\n InsufficientFundsError,\n} from '../errors';\n\nconst HexDataSchema = z.object({ data: z.string().startsWith('0x') as unknown as z.ZodType<Hex> });\nconst HexCauseSchema = z.object({ cause: HexDataSchema });\n\n/**\n * Safely parse a hex `data` field from an unknown value using zod.\n */\nfunction parseHexData(value: unknown): Hex | undefined {\n return HexDataSchema.safeParse(value).data?.data;\n}\n\n/**\n * Walk an error hierarchy and extract the first hex-encoded `data` field.\n */\nfunction extractRawHexData(error: unknown): Hex | undefined {\n if (error instanceof BaseError) {\n let found: Hex | undefined;\n error.walk((e) => {\n const parsed = parseHexData(e);\n if (!found && parsed) found = parsed;\n return false;\n });\n if (found) return found;\n }\n\n return parseHexData(error) ?? HexCauseSchema.safeParse(error).data?.cause.data;\n}\n\n/**\n * Extract revert data from an error and decode it best-effort against an ABI.\n *\n * Built-in `Error(string)` and `Panic(uint256)` are always decoded regardless\n * of the ABI provided — viem merges them automatically.\n */\nfunction extractRevertWithAbi(error: unknown, abi: Abi): EstimateNativeFeeErrorDetails | undefined {\n const raw = extractRawHexData(error);\n if (!raw || raw === '0x') return undefined;\n\n const result: EstimateNativeFeeErrorDetails = { data: raw };\n\n try {\n const decoded = decodeErrorResult({ abi, data: raw });\n result.errorName = decoded.errorName;\n if (decoded.args && decoded.args.length > 0) result.args = decoded.args;\n if (decoded.errorName === 'Error' && decoded.args?.[0] != null) {\n result.reason = String(decoded.args[0]);\n }\n } catch {\n // Couldn't decode — return raw data only\n }\n\n return result;\n}\n\n/**\n * Format revert data into a human-readable suffix for error detail strings.\n */\nfunction formatRevertSuffix(revert: EstimateNativeFeeErrorDetails): string | undefined {\n if (revert.reason) {\n return revert.reason;\n }\n\n if (revert.errorName) {\n const formattedArgs = revert.args && revert.args.length > 0 ? `(${revert.args.map(String).join(', ')})` : '()';\n return `${revert.errorName}${formattedArgs}`;\n }\n\n return undefined;\n}\n\nconst INSUFFICIENT_BALANCE_REGEX =\n /insuff(?:icient|icent).*?(?:balance|funds?)|(?:balance|funds?).*?insuff(?:icient|icent)|transfer amount exceeds balance/i;\nconst NATIVE_FUNDS_REGEX = /insufficient funds for gas|intrinsic transaction cost|fee cap/i;\n\n/**\n * Collect all readable error messages from an error chain.\n */\nfunction getErrorMessages(error: unknown): readonly string[] {\n const messages: string[] = [];\n const seen = new Set<unknown>();\n\n const visit = (value: unknown): void => {\n if (!value || seen.has(value)) {\n return;\n }\n\n seen.add(value);\n\n if (value instanceof BaseError) {\n value.walk((walked) => {\n if (walked instanceof Error && walked.message) {\n messages.push(walked.message);\n }\n return false;\n });\n } else if (value instanceof Error && value.message) {\n messages.push(value.message);\n }\n\n if (typeof value === 'object' && 'message' in value) {\n const maybeMessage = value.message;\n if (typeof maybeMessage === 'string' && maybeMessage.length > 0) {\n messages.push(maybeMessage);\n }\n }\n\n if (typeof value === 'object' && 'cause' in value) {\n visit(value.cause);\n }\n };\n\n visit(error);\n\n return messages;\n}\n\nfunction containsInsufficientBalanceText(value: string | undefined): boolean {\n return typeof value === 'string' && INSUFFICIENT_BALANCE_REGEX.test(value);\n}\n\nfunction containsNativeFundsText(value: string | undefined): boolean {\n return typeof value === 'string' && NATIVE_FUNDS_REGEX.test(value);\n}\n\nfunction isInsufficientBalanceFailure(details: EstimateNativeFeeErrorDetails | undefined, error: unknown): boolean {\n if (containsInsufficientBalanceText(details?.reason) || containsInsufficientBalanceText(details?.errorName)) {\n return true;\n }\n\n return getErrorMessages(error).some((message) => containsInsufficientBalanceText(message));\n}\n\nfunction isNativeFundsFailure(details: EstimateNativeFeeErrorDetails | undefined, error: unknown): boolean {\n if (containsNativeFundsText(details?.reason)) {\n return true;\n }\n\n return getErrorMessages(error).some((message) => containsNativeFundsText(message));\n}\n\n/** Minimal client interface for gas estimation with revert recovery. */\ninterface GasEstimationClient {\n estimateGas(params: {\n account: `0x${string}`;\n to: `0x${string}`;\n data: `0x${string}`;\n value?: bigint;\n }): Promise<bigint>;\n call(params: {
|
|
1
|
+
{"version":3,"file":"_evm-errors.cjs","names":["z","BaseError","EstimateNativeFeeError","InsufficientFundsError","ErrorCode"],"sources":["../../src/transfer-service/_evm-errors.ts"],"sourcesContent":["/**\n * @module\n * @internal\n *\n * Shared utility for EVM gas estimation with revert recovery.\n */\nimport { BaseError, decodeErrorResult, type Abi, type Hex } from 'viem';\nimport { z } from 'zod';\nimport {\n type EstimateNativeFeeErrorDetails,\n ErrorCode,\n EstimateNativeFeeError,\n InsufficientFundsError,\n} from '../errors';\n\nconst HexDataSchema = z.object({ data: z.string().startsWith('0x') as unknown as z.ZodType<Hex> });\nconst HexCauseSchema = z.object({ cause: HexDataSchema });\n\n/**\n * Safely parse a hex `data` field from an unknown value using zod.\n */\nfunction parseHexData(value: unknown): Hex | undefined {\n return HexDataSchema.safeParse(value).data?.data;\n}\n\n/**\n * Walk an error hierarchy and extract the first hex-encoded `data` field.\n */\nfunction extractRawHexData(error: unknown): Hex | undefined {\n if (error instanceof BaseError) {\n let found: Hex | undefined;\n error.walk((e) => {\n const parsed = parseHexData(e);\n if (!found && parsed) found = parsed;\n return false;\n });\n if (found) return found;\n }\n\n return parseHexData(error) ?? HexCauseSchema.safeParse(error).data?.cause.data;\n}\n\n/**\n * Extract revert data from an error and decode it best-effort against an ABI.\n *\n * Built-in `Error(string)` and `Panic(uint256)` are always decoded regardless\n * of the ABI provided — viem merges them automatically.\n */\nfunction extractRevertWithAbi(error: unknown, abi: Abi): EstimateNativeFeeErrorDetails | undefined {\n const raw = extractRawHexData(error);\n if (!raw || raw === '0x') return undefined;\n\n const result: EstimateNativeFeeErrorDetails = { data: raw };\n\n try {\n const decoded = decodeErrorResult({ abi, data: raw });\n result.errorName = decoded.errorName;\n if (decoded.args && decoded.args.length > 0) result.args = decoded.args;\n if (decoded.errorName === 'Error' && decoded.args?.[0] != null) {\n result.reason = String(decoded.args[0]);\n }\n } catch {\n // Couldn't decode — return raw data only\n }\n\n return result;\n}\n\n/**\n * Format revert data into a human-readable suffix for error detail strings.\n */\nfunction formatRevertSuffix(revert: EstimateNativeFeeErrorDetails): string | undefined {\n if (revert.reason) {\n return revert.reason;\n }\n\n if (revert.errorName) {\n const formattedArgs = revert.args && revert.args.length > 0 ? `(${revert.args.map(String).join(', ')})` : '()';\n return `${revert.errorName}${formattedArgs}`;\n }\n\n return undefined;\n}\n\nconst INSUFFICIENT_BALANCE_REGEX =\n /insuff(?:icient|icent).*?(?:balance|funds?)|(?:balance|funds?).*?insuff(?:icient|icent)|transfer amount exceeds balance/i;\nconst NATIVE_FUNDS_REGEX = /insufficient funds for gas|intrinsic transaction cost|fee cap/i;\n\n/**\n * Collect all readable error messages from an error chain.\n */\nfunction getErrorMessages(error: unknown): readonly string[] {\n const messages: string[] = [];\n const seen = new Set<unknown>();\n\n const visit = (value: unknown): void => {\n if (!value || seen.has(value)) {\n return;\n }\n\n seen.add(value);\n\n if (value instanceof BaseError) {\n value.walk((walked) => {\n if (walked instanceof Error && walked.message) {\n messages.push(walked.message);\n }\n return false;\n });\n } else if (value instanceof Error && value.message) {\n messages.push(value.message);\n }\n\n if (typeof value === 'object' && 'message' in value) {\n const maybeMessage = value.message;\n if (typeof maybeMessage === 'string' && maybeMessage.length > 0) {\n messages.push(maybeMessage);\n }\n }\n\n if (typeof value === 'object' && 'cause' in value) {\n visit(value.cause);\n }\n };\n\n visit(error);\n\n return messages;\n}\n\nfunction containsInsufficientBalanceText(value: string | undefined): boolean {\n return typeof value === 'string' && INSUFFICIENT_BALANCE_REGEX.test(value);\n}\n\nfunction containsNativeFundsText(value: string | undefined): boolean {\n return typeof value === 'string' && NATIVE_FUNDS_REGEX.test(value);\n}\n\nfunction isInsufficientBalanceFailure(details: EstimateNativeFeeErrorDetails | undefined, error: unknown): boolean {\n if (containsInsufficientBalanceText(details?.reason) || containsInsufficientBalanceText(details?.errorName)) {\n return true;\n }\n\n return getErrorMessages(error).some((message) => containsInsufficientBalanceText(message));\n}\n\nfunction isNativeFundsFailure(details: EstimateNativeFeeErrorDetails | undefined, error: unknown): boolean {\n if (containsNativeFundsText(details?.reason)) {\n return true;\n }\n\n return getErrorMessages(error).some((message) => containsNativeFundsText(message));\n}\n\n/** Minimal client interface for gas estimation with revert recovery. */\ninterface GasEstimationClient {\n estimateGas(params: {\n account: `0x${string}`;\n to: `0x${string}`;\n data: `0x${string}`;\n value?: bigint;\n /** Gas limit for `eth_estimateGas` (JSON-RPC `gas` field). */\n gas?: bigint;\n }): Promise<bigint>;\n call(params: {\n account: `0x${string}`;\n to: `0x${string}`;\n data: `0x${string}`;\n value?: bigint;\n /** Gas limit for `eth_call` (JSON-RPC `gas` field). */\n gas?: bigint;\n }): Promise<unknown>;\n}\n\n/**\n * Estimate gas for a pre-encoded transaction, falling back to `eth_call`\n * to recover revert data when the RPC strips it from `eth_estimateGas`.\n *\n * The ABI is used **only** for best-effort error decoding on the failure\n * path — never for encoding or decoding calldata. Built-in `Error(string)`\n * and `Panic(uint256)` are always decoded regardless of the ABI.\n *\n * @throws {EstimateNativeFeeError} with structured {@link EstimateNativeFeeErrorDetails}\n * on failure. Zero overhead on the happy path.\n */\nexport async function estimateGasWithRevert(\n client: GasEstimationClient,\n params: { account: `0x${string}`; to: `0x${string}`; data: `0x${string}`; value?: bigint; gas?: bigint },\n abi: Abi,\n message: string,\n): Promise<bigint> {\n try {\n return await client.estimateGas(params);\n } catch (estimateError) {\n let details = extractRevertWithAbi(estimateError, abi);\n\n // If the RPC stripped revert data, use eth_call to recover it.\n if (!details?.reason && !details?.errorName) {\n try {\n await client.call(params);\n } catch (callError) {\n details = extractRevertWithAbi(callError, abi) ?? details;\n }\n }\n\n const suffix = details ? formatRevertSuffix(details) : undefined;\n const enrichedMessage = suffix ? `${message} Revert: ${suffix}.` : message;\n\n const cause = isInsufficientBalanceFailure(details, estimateError)\n ? new InsufficientFundsError({\n cause: estimateError,\n details: enrichedMessage,\n errorCode: ErrorCode.VIEM_ERROR,\n insufficientTokenWasNative: isNativeFundsFailure(details, estimateError),\n })\n : estimateError;\n\n throw new EstimateNativeFeeError({\n cause,\n details: details,\n errorCode: ErrorCode.VIEM_ERROR,\n message: enrichedMessage,\n tx: params,\n });\n }\n}\n"],"mappings":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_evm-errors.js","names":[],"sources":["../../src/transfer-service/_evm-errors.ts"],"sourcesContent":["/**\n * @module\n * @internal\n *\n * Shared utility for EVM gas estimation with revert recovery.\n */\nimport { BaseError, decodeErrorResult, type Abi, type Hex } from 'viem';\nimport { z } from 'zod';\nimport {\n type EstimateNativeFeeErrorDetails,\n ErrorCode,\n EstimateNativeFeeError,\n InsufficientFundsError,\n} from '../errors';\n\nconst HexDataSchema = z.object({ data: z.string().startsWith('0x') as unknown as z.ZodType<Hex> });\nconst HexCauseSchema = z.object({ cause: HexDataSchema });\n\n/**\n * Safely parse a hex `data` field from an unknown value using zod.\n */\nfunction parseHexData(value: unknown): Hex | undefined {\n return HexDataSchema.safeParse(value).data?.data;\n}\n\n/**\n * Walk an error hierarchy and extract the first hex-encoded `data` field.\n */\nfunction extractRawHexData(error: unknown): Hex | undefined {\n if (error instanceof BaseError) {\n let found: Hex | undefined;\n error.walk((e) => {\n const parsed = parseHexData(e);\n if (!found && parsed) found = parsed;\n return false;\n });\n if (found) return found;\n }\n\n return parseHexData(error) ?? HexCauseSchema.safeParse(error).data?.cause.data;\n}\n\n/**\n * Extract revert data from an error and decode it best-effort against an ABI.\n *\n * Built-in `Error(string)` and `Panic(uint256)` are always decoded regardless\n * of the ABI provided — viem merges them automatically.\n */\nfunction extractRevertWithAbi(error: unknown, abi: Abi): EstimateNativeFeeErrorDetails | undefined {\n const raw = extractRawHexData(error);\n if (!raw || raw === '0x') return undefined;\n\n const result: EstimateNativeFeeErrorDetails = { data: raw };\n\n try {\n const decoded = decodeErrorResult({ abi, data: raw });\n result.errorName = decoded.errorName;\n if (decoded.args && decoded.args.length > 0) result.args = decoded.args;\n if (decoded.errorName === 'Error' && decoded.args?.[0] != null) {\n result.reason = String(decoded.args[0]);\n }\n } catch {\n // Couldn't decode — return raw data only\n }\n\n return result;\n}\n\n/**\n * Format revert data into a human-readable suffix for error detail strings.\n */\nfunction formatRevertSuffix(revert: EstimateNativeFeeErrorDetails): string | undefined {\n if (revert.reason) {\n return revert.reason;\n }\n\n if (revert.errorName) {\n const formattedArgs = revert.args && revert.args.length > 0 ? `(${revert.args.map(String).join(', ')})` : '()';\n return `${revert.errorName}${formattedArgs}`;\n }\n\n return undefined;\n}\n\nconst INSUFFICIENT_BALANCE_REGEX =\n /insuff(?:icient|icent).*?(?:balance|funds?)|(?:balance|funds?).*?insuff(?:icient|icent)|transfer amount exceeds balance/i;\nconst NATIVE_FUNDS_REGEX = /insufficient funds for gas|intrinsic transaction cost|fee cap/i;\n\n/**\n * Collect all readable error messages from an error chain.\n */\nfunction getErrorMessages(error: unknown): readonly string[] {\n const messages: string[] = [];\n const seen = new Set<unknown>();\n\n const visit = (value: unknown): void => {\n if (!value || seen.has(value)) {\n return;\n }\n\n seen.add(value);\n\n if (value instanceof BaseError) {\n value.walk((walked) => {\n if (walked instanceof Error && walked.message) {\n messages.push(walked.message);\n }\n return false;\n });\n } else if (value instanceof Error && value.message) {\n messages.push(value.message);\n }\n\n if (typeof value === 'object' && 'message' in value) {\n const maybeMessage = value.message;\n if (typeof maybeMessage === 'string' && maybeMessage.length > 0) {\n messages.push(maybeMessage);\n }\n }\n\n if (typeof value === 'object' && 'cause' in value) {\n visit(value.cause);\n }\n };\n\n visit(error);\n\n return messages;\n}\n\nfunction containsInsufficientBalanceText(value: string | undefined): boolean {\n return typeof value === 'string' && INSUFFICIENT_BALANCE_REGEX.test(value);\n}\n\nfunction containsNativeFundsText(value: string | undefined): boolean {\n return typeof value === 'string' && NATIVE_FUNDS_REGEX.test(value);\n}\n\nfunction isInsufficientBalanceFailure(details: EstimateNativeFeeErrorDetails | undefined, error: unknown): boolean {\n if (containsInsufficientBalanceText(details?.reason) || containsInsufficientBalanceText(details?.errorName)) {\n return true;\n }\n\n return getErrorMessages(error).some((message) => containsInsufficientBalanceText(message));\n}\n\nfunction isNativeFundsFailure(details: EstimateNativeFeeErrorDetails | undefined, error: unknown): boolean {\n if (containsNativeFundsText(details?.reason)) {\n return true;\n }\n\n return getErrorMessages(error).some((message) => containsNativeFundsText(message));\n}\n\n/** Minimal client interface for gas estimation with revert recovery. */\ninterface GasEstimationClient {\n estimateGas(params: {\n account: `0x${string}`;\n to: `0x${string}`;\n data: `0x${string}`;\n value?: bigint;\n }): Promise<bigint>;\n call(params: {
|
|
1
|
+
{"version":3,"file":"_evm-errors.js","names":[],"sources":["../../src/transfer-service/_evm-errors.ts"],"sourcesContent":["/**\n * @module\n * @internal\n *\n * Shared utility for EVM gas estimation with revert recovery.\n */\nimport { BaseError, decodeErrorResult, type Abi, type Hex } from 'viem';\nimport { z } from 'zod';\nimport {\n type EstimateNativeFeeErrorDetails,\n ErrorCode,\n EstimateNativeFeeError,\n InsufficientFundsError,\n} from '../errors';\n\nconst HexDataSchema = z.object({ data: z.string().startsWith('0x') as unknown as z.ZodType<Hex> });\nconst HexCauseSchema = z.object({ cause: HexDataSchema });\n\n/**\n * Safely parse a hex `data` field from an unknown value using zod.\n */\nfunction parseHexData(value: unknown): Hex | undefined {\n return HexDataSchema.safeParse(value).data?.data;\n}\n\n/**\n * Walk an error hierarchy and extract the first hex-encoded `data` field.\n */\nfunction extractRawHexData(error: unknown): Hex | undefined {\n if (error instanceof BaseError) {\n let found: Hex | undefined;\n error.walk((e) => {\n const parsed = parseHexData(e);\n if (!found && parsed) found = parsed;\n return false;\n });\n if (found) return found;\n }\n\n return parseHexData(error) ?? HexCauseSchema.safeParse(error).data?.cause.data;\n}\n\n/**\n * Extract revert data from an error and decode it best-effort against an ABI.\n *\n * Built-in `Error(string)` and `Panic(uint256)` are always decoded regardless\n * of the ABI provided — viem merges them automatically.\n */\nfunction extractRevertWithAbi(error: unknown, abi: Abi): EstimateNativeFeeErrorDetails | undefined {\n const raw = extractRawHexData(error);\n if (!raw || raw === '0x') return undefined;\n\n const result: EstimateNativeFeeErrorDetails = { data: raw };\n\n try {\n const decoded = decodeErrorResult({ abi, data: raw });\n result.errorName = decoded.errorName;\n if (decoded.args && decoded.args.length > 0) result.args = decoded.args;\n if (decoded.errorName === 'Error' && decoded.args?.[0] != null) {\n result.reason = String(decoded.args[0]);\n }\n } catch {\n // Couldn't decode — return raw data only\n }\n\n return result;\n}\n\n/**\n * Format revert data into a human-readable suffix for error detail strings.\n */\nfunction formatRevertSuffix(revert: EstimateNativeFeeErrorDetails): string | undefined {\n if (revert.reason) {\n return revert.reason;\n }\n\n if (revert.errorName) {\n const formattedArgs = revert.args && revert.args.length > 0 ? `(${revert.args.map(String).join(', ')})` : '()';\n return `${revert.errorName}${formattedArgs}`;\n }\n\n return undefined;\n}\n\nconst INSUFFICIENT_BALANCE_REGEX =\n /insuff(?:icient|icent).*?(?:balance|funds?)|(?:balance|funds?).*?insuff(?:icient|icent)|transfer amount exceeds balance/i;\nconst NATIVE_FUNDS_REGEX = /insufficient funds for gas|intrinsic transaction cost|fee cap/i;\n\n/**\n * Collect all readable error messages from an error chain.\n */\nfunction getErrorMessages(error: unknown): readonly string[] {\n const messages: string[] = [];\n const seen = new Set<unknown>();\n\n const visit = (value: unknown): void => {\n if (!value || seen.has(value)) {\n return;\n }\n\n seen.add(value);\n\n if (value instanceof BaseError) {\n value.walk((walked) => {\n if (walked instanceof Error && walked.message) {\n messages.push(walked.message);\n }\n return false;\n });\n } else if (value instanceof Error && value.message) {\n messages.push(value.message);\n }\n\n if (typeof value === 'object' && 'message' in value) {\n const maybeMessage = value.message;\n if (typeof maybeMessage === 'string' && maybeMessage.length > 0) {\n messages.push(maybeMessage);\n }\n }\n\n if (typeof value === 'object' && 'cause' in value) {\n visit(value.cause);\n }\n };\n\n visit(error);\n\n return messages;\n}\n\nfunction containsInsufficientBalanceText(value: string | undefined): boolean {\n return typeof value === 'string' && INSUFFICIENT_BALANCE_REGEX.test(value);\n}\n\nfunction containsNativeFundsText(value: string | undefined): boolean {\n return typeof value === 'string' && NATIVE_FUNDS_REGEX.test(value);\n}\n\nfunction isInsufficientBalanceFailure(details: EstimateNativeFeeErrorDetails | undefined, error: unknown): boolean {\n if (containsInsufficientBalanceText(details?.reason) || containsInsufficientBalanceText(details?.errorName)) {\n return true;\n }\n\n return getErrorMessages(error).some((message) => containsInsufficientBalanceText(message));\n}\n\nfunction isNativeFundsFailure(details: EstimateNativeFeeErrorDetails | undefined, error: unknown): boolean {\n if (containsNativeFundsText(details?.reason)) {\n return true;\n }\n\n return getErrorMessages(error).some((message) => containsNativeFundsText(message));\n}\n\n/** Minimal client interface for gas estimation with revert recovery. */\ninterface GasEstimationClient {\n estimateGas(params: {\n account: `0x${string}`;\n to: `0x${string}`;\n data: `0x${string}`;\n value?: bigint;\n /** Gas limit for `eth_estimateGas` (JSON-RPC `gas` field). */\n gas?: bigint;\n }): Promise<bigint>;\n call(params: {\n account: `0x${string}`;\n to: `0x${string}`;\n data: `0x${string}`;\n value?: bigint;\n /** Gas limit for `eth_call` (JSON-RPC `gas` field). */\n gas?: bigint;\n }): Promise<unknown>;\n}\n\n/**\n * Estimate gas for a pre-encoded transaction, falling back to `eth_call`\n * to recover revert data when the RPC strips it from `eth_estimateGas`.\n *\n * The ABI is used **only** for best-effort error decoding on the failure\n * path — never for encoding or decoding calldata. Built-in `Error(string)`\n * and `Panic(uint256)` are always decoded regardless of the ABI.\n *\n * @throws {EstimateNativeFeeError} with structured {@link EstimateNativeFeeErrorDetails}\n * on failure. Zero overhead on the happy path.\n */\nexport async function estimateGasWithRevert(\n client: GasEstimationClient,\n params: { account: `0x${string}`; to: `0x${string}`; data: `0x${string}`; value?: bigint; gas?: bigint },\n abi: Abi,\n message: string,\n): Promise<bigint> {\n try {\n return await client.estimateGas(params);\n } catch (estimateError) {\n let details = extractRevertWithAbi(estimateError, abi);\n\n // If the RPC stripped revert data, use eth_call to recover it.\n if (!details?.reason && !details?.errorName) {\n try {\n await client.call(params);\n } catch (callError) {\n details = extractRevertWithAbi(callError, abi) ?? details;\n }\n }\n\n const suffix = details ? formatRevertSuffix(details) : undefined;\n const enrichedMessage = suffix ? `${message} Revert: ${suffix}.` : message;\n\n const cause = isInsufficientBalanceFailure(details, estimateError)\n ? new InsufficientFundsError({\n cause: estimateError,\n details: enrichedMessage,\n errorCode: ErrorCode.VIEM_ERROR,\n insufficientTokenWasNative: isNativeFundsFailure(details, estimateError),\n })\n : estimateError;\n\n throw new EstimateNativeFeeError({\n cause,\n details: details,\n errorCode: ErrorCode.VIEM_ERROR,\n message: enrichedMessage,\n tx: params,\n });\n }\n}\n"],"mappings":"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"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require(`../../../constants.cjs`),t=require(
|
|
1
|
+
const e=require(`../../../constants.cjs`),t=require(`../constants.cjs`),n=require(`../../../utils/asset-id.cjs`),r=({assets:e,limit:t,page:n})=>{let r=(n-1)*t,i=e.slice(r,r+t),a=r+i.length<e.length;return{assets:i,meta:{currentPage:n,hasMore:a,...a?{nextPage:n+1}:{}}}};function i({environment:i}){return async({sourceAsset:a,sourceChainId:o,targetChainId:s,limit:c,page:l})=>{let u=c??100,d=l??1;if(a.type!==e.TokenType.NATIVE||!(i===e.Environment.PROD||i===e.Environment.TEST))return r({assets:[],limit:u,page:d});let f=Object.values(i===e.Environment.PROD?e.AvalancheMainnetBlockchainChainIds:e.AvalancheFujiBlockchainChainIds);if(!f.includes(o)||!f.includes(s)||o===s)return r({assets:[],limit:u,page:d});let p=o===e.AvalancheMainnetBlockchainChainIds.C||o===e.AvalancheFujiBlockchainChainIds.C?t.AVALANCHE_PX_CHAIN_NATIVE_ASSET:t.AVALANCHE_C_CHAIN_NATIVE_ASSET;return r({assets:[{id:n.getAssetId(s,p),...p,bridgeProviders:[e.ServiceType.AVALANCHE_CCT]}],limit:u,page:d})}}exports.getBridgeableAssetsFactory=i;
|
|
2
2
|
//# sourceMappingURL=get-bridgeable-assets.cjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{AvalancheFujiBlockchainChainIds as e,AvalancheMainnetBlockchainChainIds as t,Environment as n,ServiceType as r,TokenType as i}from"../../../constants.js";import{
|
|
1
|
+
import{AvalancheFujiBlockchainChainIds as e,AvalancheMainnetBlockchainChainIds as t,Environment as n,ServiceType as r,TokenType as i}from"../../../constants.js";import{AVALANCHE_C_CHAIN_NATIVE_ASSET as a,AVALANCHE_PX_CHAIN_NATIVE_ASSET as o}from"../constants.js";import{getAssetId as s}from"../../../utils/asset-id.js";const c=({assets:e,limit:t,page:n})=>{let r=(n-1)*t,i=e.slice(r,r+t),a=r+i.length<e.length;return{assets:i,meta:{currentPage:n,hasMore:a,...a?{nextPage:n+1}:{}}}};function l({environment:l}){return async({sourceAsset:u,sourceChainId:d,targetChainId:f,limit:p,page:m})=>{let h=p??100,g=m??1;if(u.type!==i.NATIVE||!(l===n.PROD||l===n.TEST))return c({assets:[],limit:h,page:g});let _=Object.values(l===n.PROD?t:e);if(!_.includes(d)||!_.includes(f)||d===f)return c({assets:[],limit:h,page:g});let v=d===t.C||d===e.C?o:a;return c({assets:[{id:s(f,v),...v,bridgeProviders:[r.AVALANCHE_CCT]}],limit:h,page:g})}}export{l as getBridgeableAssetsFactory};
|
|
2
2
|
//# sourceMappingURL=get-bridgeable-assets.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../constants.cjs`),t=require(`../../errors.cjs`),n=require(`./
|
|
1
|
+
require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../constants.cjs`),t=require(`../../errors.cjs`),n=require(`./_utils.cjs`),r=require(`./_handlers/analyze-support.cjs`),i=require(`./_handlers/get-bridgeable-assets.cjs`),a=require(`./_handlers/get-minimum-transfer-amount.cjs`),o=require(`./_handlers/get-supported-chains.cjs`),s=require(`./_handlers/stream-quotes.cjs`),c=require(`./_handlers/transfer-asset.cjs`),l=require(`./_handlers/estimate-native-fee.cjs`),u=require(`./_handlers/track-transfer.cjs`);let d=require(`@avalabs/avalanchejs`);async function f({avalancheSendTx:f,environment:p,getCoreEthAddress:m,getAtomicUtxos:h,getUtxos:g,getWalletAddressesForChainAlias:_,getWalletChangeAddressForChainAlias:v}){let y,b;try{y=n.getAvalancheApiUrl(p),b=await d.Context.getContextFromURI(y)}catch(e){throw new t.ServiceInitializationError(`Failed to initialize Avalanche CCT context.`,void 0,e)}return{analyzeSupport:r.analyzeSupportFactory({environment:p}),estimateNativeFee:l.estimateNativeFeeFactory({ajsContext:b,environment:p,getAtomicUtxos:h,getUtxos:g}),getAssets:async()=>{throw new t.NotImplementedError},getBridgeableAssets:i.getBridgeableAssetsFactory({environment:p}),getMinimumTransferAmount:a.getMinimumTransferAmountFactory({environment:p,getAtomicUtxos:h}),getSupportedChains:o.getSupportedChainsFactory({environment:p}),streamQuotes:s.streamQuotesFactory({environment:p,getAtomicUtxos:h}),trackTransfer:u.trackTransferFactory({environment:p}),transferAsset:c.transferAssetFactory({ajsContext:b,avalancheSendTx:f,environment:p,getCoreEthAddress:m,getAtomicUtxos:h,getUtxos:g,getWalletAddressesForChainAlias:_,getWalletChangeAddressForChainAlias:v}),type:e.ServiceType.AVALANCHE_CCT}}exports.createAvalancheCctService=f;
|
|
2
2
|
//# sourceMappingURL=avalanche-cct-service.cjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ServiceType as e}from"../../constants.js";import{NotImplementedError as t,ServiceInitializationError as n}from"../../errors.js";import{
|
|
1
|
+
import{ServiceType as e}from"../../constants.js";import{NotImplementedError as t,ServiceInitializationError as n}from"../../errors.js";import{getAvalancheApiUrl as r}from"./_utils.js";import{analyzeSupportFactory as i}from"./_handlers/analyze-support.js";import{getBridgeableAssetsFactory as a}from"./_handlers/get-bridgeable-assets.js";import{getMinimumTransferAmountFactory as o}from"./_handlers/get-minimum-transfer-amount.js";import{getSupportedChainsFactory as s}from"./_handlers/get-supported-chains.js";import{streamQuotesFactory as c}from"./_handlers/stream-quotes.js";import{transferAssetFactory as l}from"./_handlers/transfer-asset.js";import{estimateNativeFeeFactory as u}from"./_handlers/estimate-native-fee.js";import{trackTransferFactory as d}from"./_handlers/track-transfer.js";import{Context as f}from"@avalabs/avalanchejs";async function p({avalancheSendTx:p,environment:m,getCoreEthAddress:h,getAtomicUtxos:g,getUtxos:_,getWalletAddressesForChainAlias:v,getWalletChangeAddressForChainAlias:y}){let b,x;try{b=r(m),x=await f.getContextFromURI(b)}catch(e){throw new n(`Failed to initialize Avalanche CCT context.`,void 0,e)}return{analyzeSupport:i({environment:m}),estimateNativeFee:u({ajsContext:x,environment:m,getAtomicUtxos:g,getUtxos:_}),getAssets:async()=>{throw new t},getBridgeableAssets:a({environment:m}),getMinimumTransferAmount:o({environment:m,getAtomicUtxos:g}),getSupportedChains:s({environment:m}),streamQuotes:c({environment:m,getAtomicUtxos:g}),trackTransfer:d({environment:m}),transferAsset:l({ajsContext:x,avalancheSendTx:p,environment:m,getCoreEthAddress:h,getAtomicUtxos:g,getUtxos:_,getWalletAddressesForChainAlias:v,getWalletChangeAddressForChainAlias:y}),type:e.AVALANCHE_CCT}}export{p as createAvalancheCctService};
|
|
2
2
|
//# sourceMappingURL=avalanche-cct-service.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require(`../../constants.cjs`),t=require(`../../type-guards.cjs`),n=require(`./_utils.cjs`);function r(r){let i=t.isQuote(r);if((i?r.serviceType:r.type)!==e.ServiceType.AVALANCHE_CCT)return null;let a=i?r.assetIn:r.sourceAsset,o=i?r.assetOut:r.targetAsset;if(!t.isNativeAsset(a)||!t.isNativeAsset(o))return null;let s=n.getOutputAmountForAvalancheCct({amountIn:r.amountIn,sourceAsset:a,targetAsset:o}),c=r.amountOut-s;return c>0n?c:0n}exports.getRecoveredAtomicAmount=r;
|
|
2
|
+
//# sourceMappingURL=get-recovered-atomic-amount.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-recovered-atomic-amount.cjs","names":["isQuote","ServiceType","isNativeAsset","getOutputAmountForAvalancheCct"],"sources":["../../../src/transfer-service/avalanche-cct/get-recovered-atomic-amount.ts"],"sourcesContent":["import { ServiceType } from '../../constants';\nimport { isNativeAsset, isQuote } from '../../type-guards';\nimport type { Quote } from '../../types/quote';\nimport type { Transfer } from '../../types/transfer';\nimport { getOutputAmountForAvalancheCct } from './_utils';\n\n/**\n * For an `AVALANCHE_CCT` quote or transfer, returns the portion of `amountOut`\n * that comes from AVAX recovered from a previous incomplete cross-chain transfer,\n * i.e. stuck atomic UTXOs the import leg sweeps in alongside the newly-transferred\n * amount.\n *\n * Accepts a `Quote` (swap screen, from the live quote) or a `Transfer` (status /\n * success screen, from the tracked transfer) since both carry the same amounts\n * and source/target assets.\n *\n * Derived entirely from the input: `amountOut` minus the newly-transferred\n * `amountIn` scaled from the source asset's decimals to the target's. The scaling\n * matters because CCT crosses chains with different native decimals (C-Chain AVAX\n * is 18, P/X AVAX is 9), so a raw `amountOut - amountIn` would be wrong on any\n * route involving C-Chain.\n *\n * Returns:\n * - `null` for non-CCT inputs (the concept does not apply)\n * - `0n` for a CCT input that recovered nothing\n * - a positive `bigint` (target-asset smallest units) otherwise\n *\n * Relies on the CCT invariant that `amountOut === scale(amountIn) + recovered`\n * with nothing netted out (CCT quotes carry no fees). If a CCT fee is ever\n * introduced it will surface in `fees`, and this must account for it.\n */\nexport function getRecoveredAtomicAmount(quoteOrTransfer: Quote | Transfer): bigint | null {\n const isQuoteInput = isQuote(quoteOrTransfer);\n const serviceType = isQuoteInput ? quoteOrTransfer.serviceType : quoteOrTransfer.type;\n if (serviceType !== ServiceType.AVALANCHE_CCT) {\n return null;\n }\n\n const sourceAsset = isQuoteInput ? quoteOrTransfer.assetIn : quoteOrTransfer.sourceAsset;\n const targetAsset = isQuoteInput ? quoteOrTransfer.assetOut : quoteOrTransfer.targetAsset;\n\n // CCT only ever moves native AVAX. Bail on anything else (this also narrows\n // `Asset` to `NativeAsset` for the decimal scaler).\n if (!isNativeAsset(sourceAsset) || !isNativeAsset(targetAsset)) {\n return null;\n }\n\n const newlyTransferredOut = getOutputAmountForAvalancheCct({\n amountIn: quoteOrTransfer.amountIn,\n sourceAsset,\n targetAsset,\n });\n\n const recovered = quoteOrTransfer.amountOut - newlyTransferredOut;\n return recovered > 0n ? recovered : 0n;\n}\n"],"mappings":"oGA+BA,SAAgB,EAAyB,EAAkD,CACzF,IAAM,EAAeA,EAAAA,QAAQ,EAAgB,CAE7C,IADoB,EAAe,EAAgB,YAAc,EAAgB,QAC7DC,EAAAA,YAAY,cAC9B,OAAO,KAGT,IAAM,EAAc,EAAe,EAAgB,QAAU,EAAgB,YACvE,EAAc,EAAe,EAAgB,SAAW,EAAgB,YAI9E,GAAI,CAACC,EAAAA,cAAc,EAAY,EAAI,CAACA,EAAAA,cAAc,EAAY,CAC5D,OAAO,KAGT,IAAM,EAAsBC,EAAAA,+BAA+B,CACzD,SAAU,EAAgB,SAC1B,cACA,cACD,CAAC,CAEI,EAAY,EAAgB,UAAY,EAC9C,OAAO,EAAY,GAAK,EAAY"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Quote } from "../../types/quote.cjs";
|
|
2
|
+
import { Transfer } from "../../types/transfer.cjs";
|
|
3
|
+
|
|
4
|
+
//#region src/transfer-service/avalanche-cct/get-recovered-atomic-amount.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* For an `AVALANCHE_CCT` quote or transfer, returns the portion of `amountOut`
|
|
7
|
+
* that comes from AVAX recovered from a previous incomplete cross-chain transfer,
|
|
8
|
+
* i.e. stuck atomic UTXOs the import leg sweeps in alongside the newly-transferred
|
|
9
|
+
* amount.
|
|
10
|
+
*
|
|
11
|
+
* Accepts a `Quote` (swap screen, from the live quote) or a `Transfer` (status /
|
|
12
|
+
* success screen, from the tracked transfer) since both carry the same amounts
|
|
13
|
+
* and source/target assets.
|
|
14
|
+
*
|
|
15
|
+
* Derived entirely from the input: `amountOut` minus the newly-transferred
|
|
16
|
+
* `amountIn` scaled from the source asset's decimals to the target's. The scaling
|
|
17
|
+
* matters because CCT crosses chains with different native decimals (C-Chain AVAX
|
|
18
|
+
* is 18, P/X AVAX is 9), so a raw `amountOut - amountIn` would be wrong on any
|
|
19
|
+
* route involving C-Chain.
|
|
20
|
+
*
|
|
21
|
+
* Returns:
|
|
22
|
+
* - `null` for non-CCT inputs (the concept does not apply)
|
|
23
|
+
* - `0n` for a CCT input that recovered nothing
|
|
24
|
+
* - a positive `bigint` (target-asset smallest units) otherwise
|
|
25
|
+
*
|
|
26
|
+
* Relies on the CCT invariant that `amountOut === scale(amountIn) + recovered`
|
|
27
|
+
* with nothing netted out (CCT quotes carry no fees). If a CCT fee is ever
|
|
28
|
+
* introduced it will surface in `fees`, and this must account for it.
|
|
29
|
+
*/
|
|
30
|
+
declare function getRecoveredAtomicAmount(quoteOrTransfer: Quote | Transfer): bigint | null;
|
|
31
|
+
//#endregion
|
|
32
|
+
export { getRecoveredAtomicAmount };
|
|
33
|
+
//# sourceMappingURL=get-recovered-atomic-amount.d.cts.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Quote } from "../../types/quote.js";
|
|
2
|
+
import { Transfer } from "../../types/transfer.js";
|
|
3
|
+
|
|
4
|
+
//#region src/transfer-service/avalanche-cct/get-recovered-atomic-amount.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* For an `AVALANCHE_CCT` quote or transfer, returns the portion of `amountOut`
|
|
7
|
+
* that comes from AVAX recovered from a previous incomplete cross-chain transfer,
|
|
8
|
+
* i.e. stuck atomic UTXOs the import leg sweeps in alongside the newly-transferred
|
|
9
|
+
* amount.
|
|
10
|
+
*
|
|
11
|
+
* Accepts a `Quote` (swap screen, from the live quote) or a `Transfer` (status /
|
|
12
|
+
* success screen, from the tracked transfer) since both carry the same amounts
|
|
13
|
+
* and source/target assets.
|
|
14
|
+
*
|
|
15
|
+
* Derived entirely from the input: `amountOut` minus the newly-transferred
|
|
16
|
+
* `amountIn` scaled from the source asset's decimals to the target's. The scaling
|
|
17
|
+
* matters because CCT crosses chains with different native decimals (C-Chain AVAX
|
|
18
|
+
* is 18, P/X AVAX is 9), so a raw `amountOut - amountIn` would be wrong on any
|
|
19
|
+
* route involving C-Chain.
|
|
20
|
+
*
|
|
21
|
+
* Returns:
|
|
22
|
+
* - `null` for non-CCT inputs (the concept does not apply)
|
|
23
|
+
* - `0n` for a CCT input that recovered nothing
|
|
24
|
+
* - a positive `bigint` (target-asset smallest units) otherwise
|
|
25
|
+
*
|
|
26
|
+
* Relies on the CCT invariant that `amountOut === scale(amountIn) + recovered`
|
|
27
|
+
* with nothing netted out (CCT quotes carry no fees). If a CCT fee is ever
|
|
28
|
+
* introduced it will surface in `fees`, and this must account for it.
|
|
29
|
+
*/
|
|
30
|
+
declare function getRecoveredAtomicAmount(quoteOrTransfer: Quote | Transfer): bigint | null;
|
|
31
|
+
//#endregion
|
|
32
|
+
export { getRecoveredAtomicAmount };
|
|
33
|
+
//# sourceMappingURL=get-recovered-atomic-amount.d.ts.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{ServiceType as e}from"../../constants.js";import{isNativeAsset as t,isQuote as n}from"../../type-guards.js";import{getOutputAmountForAvalancheCct as r}from"./_utils.js";function i(i){let a=n(i);if((a?i.serviceType:i.type)!==e.AVALANCHE_CCT)return null;let o=a?i.assetIn:i.sourceAsset,s=a?i.assetOut:i.targetAsset;if(!t(o)||!t(s))return null;let c=r({amountIn:i.amountIn,sourceAsset:o,targetAsset:s}),l=i.amountOut-c;return l>0n?l:0n}export{i as getRecoveredAtomicAmount};
|
|
2
|
+
//# sourceMappingURL=get-recovered-atomic-amount.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-recovered-atomic-amount.js","names":[],"sources":["../../../src/transfer-service/avalanche-cct/get-recovered-atomic-amount.ts"],"sourcesContent":["import { ServiceType } from '../../constants';\nimport { isNativeAsset, isQuote } from '../../type-guards';\nimport type { Quote } from '../../types/quote';\nimport type { Transfer } from '../../types/transfer';\nimport { getOutputAmountForAvalancheCct } from './_utils';\n\n/**\n * For an `AVALANCHE_CCT` quote or transfer, returns the portion of `amountOut`\n * that comes from AVAX recovered from a previous incomplete cross-chain transfer,\n * i.e. stuck atomic UTXOs the import leg sweeps in alongside the newly-transferred\n * amount.\n *\n * Accepts a `Quote` (swap screen, from the live quote) or a `Transfer` (status /\n * success screen, from the tracked transfer) since both carry the same amounts\n * and source/target assets.\n *\n * Derived entirely from the input: `amountOut` minus the newly-transferred\n * `amountIn` scaled from the source asset's decimals to the target's. The scaling\n * matters because CCT crosses chains with different native decimals (C-Chain AVAX\n * is 18, P/X AVAX is 9), so a raw `amountOut - amountIn` would be wrong on any\n * route involving C-Chain.\n *\n * Returns:\n * - `null` for non-CCT inputs (the concept does not apply)\n * - `0n` for a CCT input that recovered nothing\n * - a positive `bigint` (target-asset smallest units) otherwise\n *\n * Relies on the CCT invariant that `amountOut === scale(amountIn) + recovered`\n * with nothing netted out (CCT quotes carry no fees). If a CCT fee is ever\n * introduced it will surface in `fees`, and this must account for it.\n */\nexport function getRecoveredAtomicAmount(quoteOrTransfer: Quote | Transfer): bigint | null {\n const isQuoteInput = isQuote(quoteOrTransfer);\n const serviceType = isQuoteInput ? quoteOrTransfer.serviceType : quoteOrTransfer.type;\n if (serviceType !== ServiceType.AVALANCHE_CCT) {\n return null;\n }\n\n const sourceAsset = isQuoteInput ? quoteOrTransfer.assetIn : quoteOrTransfer.sourceAsset;\n const targetAsset = isQuoteInput ? quoteOrTransfer.assetOut : quoteOrTransfer.targetAsset;\n\n // CCT only ever moves native AVAX. Bail on anything else (this also narrows\n // `Asset` to `NativeAsset` for the decimal scaler).\n if (!isNativeAsset(sourceAsset) || !isNativeAsset(targetAsset)) {\n return null;\n }\n\n const newlyTransferredOut = getOutputAmountForAvalancheCct({\n amountIn: quoteOrTransfer.amountIn,\n sourceAsset,\n targetAsset,\n });\n\n const recovered = quoteOrTransfer.amountOut - newlyTransferredOut;\n return recovered > 0n ? recovered : 0n;\n}\n"],"mappings":"gLA+BA,SAAgB,EAAyB,EAAkD,CACzF,IAAM,EAAe,EAAQ,EAAgB,CAE7C,IADoB,EAAe,EAAgB,YAAc,EAAgB,QAC7D,EAAY,cAC9B,OAAO,KAGT,IAAM,EAAc,EAAe,EAAgB,QAAU,EAAgB,YACvE,EAAc,EAAe,EAAgB,SAAW,EAAgB,YAI9E,GAAI,CAAC,EAAc,EAAY,EAAI,CAAC,EAAc,EAAY,CAC5D,OAAO,KAGT,IAAM,EAAsB,EAA+B,CACzD,SAAU,EAAgB,SAC1B,cACA,cACD,CAAC,CAEI,EAAY,EAAgB,UAAY,EAC9C,OAAO,EAAY,GAAK,EAAY"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require(`../../errors.cjs`),t=require(
|
|
1
|
+
const e=require(`../../errors.cjs`),t=require(`../fetch-utilities.cjs`),n=require(`./_schema.cjs`);function r(e){if(e)return{Authorization:`Bearer ${e}`}}async function i({apiBaseUrl:i,apiToken:a,fetch:o}){let s=`/info/chains`,c=await t.fetchJson(t.combineUrlPathnames(i,s),{headers:r(a),fetch:o}),l=n.SupportedChainsResponseSchema.safeParse(c);if(!l.success)throw new e.ResponseValidationError(`Invalid response from Markr "${s}" endpoint.`,l.error.issues);return l.data}async function a({apiBaseUrl:i,apiToken:a,fetch:o},s){let c=`/tokens/${s}/list`,l=await t.fetchJson(t.combineUrlPathnames(i,c),{headers:r(a),fetch:o}),u=n.TokenListResponseSchema.safeParse(l);if(!u.success)throw new e.ResponseValidationError(`Invalid response from Markr "${c}" endpoint.`,u.error.issues);return u.data}async function o({apiBaseUrl:i,apiToken:a,fetch:o},s,{onDone:c,onError:l,onQuote:u,signal:d}){let f=`/quote`,p=t.combineUrlPathnames(i,f),m=[];try{for await(let i of t.fetchEventStream(p,{body:JSON.stringify(s),fetch:o,headers:r(a),signal:d})){let t=n.QuoteResponseSchema.safeParse(JSON.parse(i.data));if(!t.success){l(new e.ResponseValidationError(`Invalid quote data received from Markr "${f}" endpoint.`,t.error.issues));continue}`done`in t.data?c():(u(t.data),m.push(t.data))}}catch(e){e instanceof Error?l(e):l(Error(`An unknown error occurred during the quote stream.`,{cause:e})),c()}return m}async function s({apiBaseUrl:i,apiToken:a,fetch:o},s){let c=`/swap`,l=await t.fetchJson(t.combineUrlPathnames(i,c),{body:JSON.stringify(s),fetch:o,headers:r(a),method:`POST`}),u=n.SwapResponseSchema.safeParse(l);if(!u.success)throw new e.ResponseValidationError(`Invalid response from Markr "${c}" endpoint.`,u.error.issues);return u.data}async function c({apiBaseUrl:i,apiToken:a,fetch:o}){let s=`/info/partner`,c=await t.fetchJson(t.combineUrlPathnames(i,s),{headers:r(a),fetch:o}),l=n.PartnerInfoResponseSchema.safeParse(c);if(!l.success)throw new e.ResponseValidationError(`Invalid response from Markr "${s}" endpoint.`,l.error.issues);return l.data}async function l({apiBaseUrl:i,apiToken:a,fetch:o},s,{signal:c}={}){let l=`/cross-chain/status/${s}`,u=await t.fetchJson(t.combineUrlPathnames(i,l),{headers:r(a),fetch:o,retries:10,retryOn(t){let n=(t.init.method??`GET`).toUpperCase();if(![`GET`,`HEAD`,`OPTIONS`,`TRACE`].includes(n))return!1;if(t.error)return!(t.error instanceof e.AbortedError);let r=t.response?.status??0;return r===404||r===408||r===425||r===429||r>=500&&r<=599},signal:c}),d=n.CrossChainStatusResponseSchema.safeParse(u);if(!d.success)throw new e.ResponseValidationError(`Invalid response from Markr "${l}" endpoint.`,d.error.issues,u);return d.data}async function u({apiBaseUrl:i,apiToken:a,fetch:o},{chainId:s,crossChainSwap:c,quoteId:l}){let u=`/spender-address?${new URLSearchParams({chainId:String(s),cross:c?`true`:`false`,uuid:l}).toString()}`,d=await t.fetchJson(t.combineUrlPathnames(i,u),{headers:r(a),fetch:o}),f=n.SpenderAddressResponseSchema.safeParse(d);if(!f.success)throw new e.ResponseValidationError(`Invalid response from Markr "${u}" endpoint.`,f.error.issues);return f.data}async function d({apiBaseUrl:i,apiToken:a,fetch:o},s,{signal:c}={}){let l=`/authorize`,u=await t.fetchJson(t.combineUrlPathnames(i,l),{body:JSON.stringify(s),fetch:o,headers:r(a),method:`POST`,signal:c}),d=n.MarkrAuthorizeResponseSchema.safeParse(u);if(!d.success)throw new e.ResponseValidationError(`Invalid response from Markr "${l}" endpoint.`,d.error.issues)}exports.getAuthHeaders=r,exports.markrGetCrossChainStatus=l,exports.markrGetInfoChains=i,exports.markrGetPartnerInfo=c,exports.markrGetSpenderAddress=u,exports.markrGetTokenList=a,exports.markrPostAuthorize=d,exports.markrStreamQuote=o,exports.markrSwap=s;
|
|
2
2
|
//# sourceMappingURL=_api.cjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{AbortedError as e,ResponseValidationError as t}from"../../errors.js";import{
|
|
1
|
+
import{AbortedError as e,ResponseValidationError as t}from"../../errors.js";import{combineUrlPathnames as n,fetchEventStream as r,fetchJson as i}from"../fetch-utilities.js";import{CrossChainStatusResponseSchema as a,MarkrAuthorizeResponseSchema as o,PartnerInfoResponseSchema as s,QuoteResponseSchema as c,SpenderAddressResponseSchema as l,SupportedChainsResponseSchema as u,SwapResponseSchema as d,TokenListResponseSchema as f}from"./_schema.js";function p(e){if(e)return{Authorization:`Bearer ${e}`}}async function m({apiBaseUrl:e,apiToken:r,fetch:a}){let o=`/info/chains`,s=await i(n(e,o),{headers:p(r),fetch:a}),c=u.safeParse(s);if(!c.success)throw new t(`Invalid response from Markr "${o}" endpoint.`,c.error.issues);return c.data}async function h({apiBaseUrl:e,apiToken:r,fetch:a},o){let s=`/tokens/${o}/list`,c=await i(n(e,s),{headers:p(r),fetch:a}),l=f.safeParse(c);if(!l.success)throw new t(`Invalid response from Markr "${s}" endpoint.`,l.error.issues);return l.data}async function g({apiBaseUrl:e,apiToken:i,fetch:a},o,{onDone:s,onError:l,onQuote:u,signal:d}){let f=`/quote`,m=n(e,f),h=[];try{for await(let e of r(m,{body:JSON.stringify(o),fetch:a,headers:p(i),signal:d})){let n=c.safeParse(JSON.parse(e.data));if(!n.success){l(new t(`Invalid quote data received from Markr "${f}" endpoint.`,n.error.issues));continue}`done`in n.data?s():(u(n.data),h.push(n.data))}}catch(e){e instanceof Error?l(e):l(Error(`An unknown error occurred during the quote stream.`,{cause:e})),s()}return h}async function _({apiBaseUrl:e,apiToken:r,fetch:a},o){let s=`/swap`,c=await i(n(e,s),{body:JSON.stringify(o),fetch:a,headers:p(r),method:`POST`}),l=d.safeParse(c);if(!l.success)throw new t(`Invalid response from Markr "${s}" endpoint.`,l.error.issues);return l.data}async function v({apiBaseUrl:e,apiToken:r,fetch:a}){let o=`/info/partner`,c=await i(n(e,o),{headers:p(r),fetch:a}),l=s.safeParse(c);if(!l.success)throw new t(`Invalid response from Markr "${o}" endpoint.`,l.error.issues);return l.data}async function y({apiBaseUrl:r,apiToken:o,fetch:s},c,{signal:l}={}){let u=`/cross-chain/status/${c}`,d=await i(n(r,u),{headers:p(o),fetch:s,retries:10,retryOn(t){let n=(t.init.method??`GET`).toUpperCase();if(![`GET`,`HEAD`,`OPTIONS`,`TRACE`].includes(n))return!1;if(t.error)return!(t.error instanceof e);let r=t.response?.status??0;return r===404||r===408||r===425||r===429||r>=500&&r<=599},signal:l}),f=a.safeParse(d);if(!f.success)throw new t(`Invalid response from Markr "${u}" endpoint.`,f.error.issues,d);return f.data}async function b({apiBaseUrl:e,apiToken:r,fetch:a},{chainId:o,crossChainSwap:s,quoteId:c}){let u=`/spender-address?${new URLSearchParams({chainId:String(o),cross:s?`true`:`false`,uuid:c}).toString()}`,d=await i(n(e,u),{headers:p(r),fetch:a}),f=l.safeParse(d);if(!f.success)throw new t(`Invalid response from Markr "${u}" endpoint.`,f.error.issues);return f.data}async function x({apiBaseUrl:e,apiToken:r,fetch:a},s,{signal:c}={}){let l=`/authorize`,u=await i(n(e,l),{body:JSON.stringify(s),fetch:a,headers:p(r),method:`POST`,signal:c}),d=o.safeParse(u);if(!d.success)throw new t(`Invalid response from Markr "${l}" endpoint.`,d.error.issues)}export{p as getAuthHeaders,y as markrGetCrossChainStatus,m as markrGetInfoChains,v as markrGetPartnerInfo,b as markrGetSpenderAddress,h as markrGetTokenList,x as markrPostAuthorize,g as markrStreamQuote,_ as markrSwap};
|
|
2
2
|
//# sourceMappingURL=_api.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
require(`../../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../../errors.cjs`),t=require(`../../../utils/caip.cjs`),n=require(`../../_utils.cjs`),r=require(`../../_evm-errors.cjs`),i=require(`../../../_utils/chain.cjs`),a=require(`../../_evm-gas.cjs`),o=require(`../_api.cjs`),s=require(`../_utils.cjs`),c=require(`../_type-guards.cjs`),l=require(`../../../utils/solana.cjs`);let
|
|
1
|
+
require(`../../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../../errors.cjs`),t=require(`../../../utils/caip.cjs`),n=require(`../../_utils.cjs`),r=require(`../../_evm-errors.cjs`),i=require(`../../../_utils/chain.cjs`),a=require(`../../_evm-gas.cjs`),o=require(`../_api.cjs`),s=require(`../_utils.cjs`),c=require(`../_type-guards.cjs`),l=require(`../../../utils/solana.cjs`),u=require(`../_hyperevm.cjs`);let d=require(`viem`),f=require(`@solana/kit`);function p(t){return async(n,r)=>{if(i.isEvmNamespace(n.sourceChain.chainId))return await m(n,r,t);if(i.isSolanaNamespace(n.sourceChain.chainId))return await h(n,r,t);throw new e.InvalidParamsError(e.ErrorReason.INVALID_PARAMS,`Unsupported source chain namespace for estimateNativeFee: ${n.sourceChain.chainId}`)}}async function m(i,l,{apiOptions:f,appId:p}){if(!(0,d.isAddress)(i.fromAddress))throw new e.InvalidParamsError(e.ErrorReason.INVALID_PARAMS,`Invalid fromAddress: ${i.fromAddress}`);let m=n.getEvmClientForChain({chain:i.sourceChain}),h=s.assetToAddressString(i.assetIn,i.sourceChain.chainId);if(!(0,d.isAddress)(h))throw new e.SdkError(e.ErrorReason.INVALID_PARAMS,e.ErrorCode.INVALID_PARAMS,{details:`assetIn address is not a valid EVM address. Can not call estimateGas.`});let _=s.isTokenAddressNative(h),v=i.sourceChain.chainId.toLowerCase()!==i.targetChain.chainId.toLowerCase(),y=i.amountIn+s.getAdditiveSourceAssetFeeAmount(i),b=0n;if(!_){let n,{address:a}=await o.markrGetSpenderAddress(f,{chainId:t.caip2ToEip155ChainId(i.sourceChain.chainId),crossChainSwap:v,quoteId:i.id});try{n=await m.readContract({address:h,abi:d.erc20Abi,functionName:`allowance`,args:[i.fromAddress,a]})}catch(t){throw new e.SdkError(`Error during allowance check`,e.ErrorCode.VIEM_ERROR,{cause:t,details:`Failed to read ERC20 allowance for Markr spender.`})}n<y&&(b=await r.estimateGasWithRevert(m,{account:i.fromAddress,to:h,data:(0,d.encodeFunctionData)({abi:d.erc20Abi,functionName:`approve`,args:[a,y]})},d.erc20Abi,`Failed to estimate gas for ERC20 approval transaction.`))}let x=b>0n,S=s.calculateMarkrMinimumAmountOut({amountOut:i.amountOut,assetOut:i.assetOut,slippageBps:i.slippageBps}),C=await o.markrSwap(f,{amountIn:i.amountIn.toString(),appId:p,minAmountOut:S.toString(),tokenIn:h,tokenOut:s.assetToAddressString(i.assetOut,i.targetChain.chainId),uuid:i.id});if(!c.isEvmSwapResponse(C)){let t=c.isSolanaSwapResponse(C)?C.chainType:c.isHyperliquidWithdrawSwapResponse(C)?C.type:`unknown`;throw new e.SdkError(e.ErrorReason.CHAIN_NOT_SUPPORTED,e.ErrorCode.INVALID_PARAMS,{details:`Received non-EVM swap response from Markr. Expected EVM transaction data for gas estimation, but got response variant "${t}".`})}let w=0n;w=x?i.gasEstimate||700000n:await g({crossChain:v,fromAddress:i.fromAddress,gasLimit:u._getGasLimit(i),sourceClient:m,swap:C});let T=await a.estimateEvmFeesPerGas(m,i.sourceChain,l?.overrides?.feeRateTier),E=l?.overrides?.maxFeePerGas??T.maxFeePerGas,D=l?.overrides?.maxPriorityFeePerGas??T.maxPriorityFeePerGas,O=(w+b)*E;return{asset:i.sourceChain.networkToken,totalFee:n.applyFeeUnitsBpsMargin(O,l?.feeUnitsMarginBps),totalFeeWithoutMargin:O,meta:{approvalFee:x?b*E:void 0,maxFeePerGas:E,maxPriorityFeePerGas:D}}}async function h(t,r,{apiOptions:i,appId:a}){let u=s.assetToAddressString(t.assetIn,t.sourceChain.chainId);if(!(0,f.isAddress)(u))throw new e.SdkError(e.ErrorReason.INVALID_PARAMS,e.ErrorCode.INVALID_PARAMS,{details:`assetIn address is not a valid Solana address. Can not call estimateGas.`});let d=s.getAdditiveSourceNativeAssetFeeAmount(t),p=t.amountIn+d,m=s.calculateMarkrMinimumAmountOut({amountOut:t.amountOut,assetOut:t.assetOut,slippageBps:t.slippageBps}),h=await o.markrSwap(i,{amountIn:t.amountIn.toString(),appId:a,minAmountOut:m.toString(),tokenIn:u,tokenOut:s.assetToAddressString(t.assetOut,t.targetChain.chainId),userPublicKey:t.fromAddress,uuid:t.id});if(!c.isSolanaSwapResponse(h))throw new e.SdkError(e.ErrorReason.CHAIN_NOT_SUPPORTED,e.ErrorCode.INVALID_PARAMS,{details:`Received non-Solana swap response from Markr. Expected Solana transaction data for fee estimation.`});let{baseFeeLamports:g,priorityFeeLamports:_,...v}=await l.estimateSolanaFee(n.getSolanaRpcForChain({chain:t.sourceChain}),h.swapTransaction),y=v.feePayerBalanceDiffLamports-p;return{asset:t.sourceChain.networkToken,totalFee:n.applyFeeUnitsBpsMargin(y,r?.feeUnitsMarginBps),totalFeeWithoutMargin:y,meta:{...v,baseFee:g,priorityFee:_}}}async function g({crossChain:e,feeUnitsMarginBps:t,fromAddress:i,gasLimit:a,sourceClient:o,swap:c}){let l=await s.getMarkrSwapWrapperAbi(e);return n.applyFeeUnitsBpsMargin(await r.estimateGasWithRevert(o,{account:i,to:c.to,data:c.data,value:c.value,...a===void 0?{}:{gas:a}},l,`Failed to estimate gas for Markr swap transaction.`),t)}exports._estimateGasFromSwapResponse=g,exports.estimateNativeFeeFactory=p;
|
|
2
2
|
//# sourceMappingURL=estimate-native-fee.cjs.map
|