@avalabs/fusion-sdk 0.23.1 → 0.25.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/errors.cjs +1 -1
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.cts +18 -1
- package/dist/errors.d.ts +18 -1
- package/dist/errors.js +1 -1
- package/dist/errors.js.map +1 -1
- package/dist/quoter/quoter.cjs.map +1 -1
- package/dist/quoter/quoter.d.cts +3 -1
- package/dist/quoter/quoter.d.ts +3 -1
- package/dist/quoter/quoter.js.map +1 -1
- package/dist/transfer-service/markr/_handlers/stream-quotes.cjs +1 -1
- package/dist/transfer-service/markr/_handlers/stream-quotes.cjs.map +1 -1
- package/dist/transfer-service/markr/_handlers/stream-quotes.js +1 -1
- package/dist/transfer-service/markr/_handlers/stream-quotes.js.map +1 -1
- package/dist/transfer-service/markr/_schema.cjs +1 -1
- package/dist/transfer-service/markr/_schema.cjs.map +1 -1
- package/dist/transfer-service/markr/_schema.js +1 -1
- package/dist/transfer-service/markr/_schema.js.map +1 -1
- package/dist/transfer-service/markr/_utils.cjs +1 -1
- package/dist/transfer-service/markr/_utils.cjs.map +1 -1
- package/dist/transfer-service/markr/_utils.js +1 -1
- package/dist/transfer-service/markr/_utils.js.map +1 -1
- package/dist/transfer-service/markr/recurring/_api.cjs +1 -1
- package/dist/transfer-service/markr/recurring/_api.cjs.map +1 -1
- package/dist/transfer-service/markr/recurring/_api.js +1 -1
- package/dist/transfer-service/markr/recurring/_api.js.map +1 -1
- package/dist/transfer-service/markr/recurring/_chain-info.cjs +1 -1
- package/dist/transfer-service/markr/recurring/_chain-info.cjs.map +1 -1
- package/dist/transfer-service/markr/recurring/_chain-info.js +1 -1
- package/dist/transfer-service/markr/recurring/_chain-info.js.map +1 -1
- package/dist/transfer-service/markr/recurring/_eligibility.cjs +1 -1
- package/dist/transfer-service/markr/recurring/_eligibility.cjs.map +1 -1
- package/dist/transfer-service/markr/recurring/_eligibility.js +1 -1
- package/dist/transfer-service/markr/recurring/_eligibility.js.map +1 -1
- package/dist/transfer-service/markr/recurring/_namespace.cjs +1 -1
- package/dist/transfer-service/markr/recurring/_namespace.cjs.map +1 -1
- package/dist/transfer-service/markr/recurring/_namespace.js +1 -1
- package/dist/transfer-service/markr/recurring/_namespace.js.map +1 -1
- package/dist/transfer-service/markr/recurring/_schema.cjs +1 -1
- package/dist/transfer-service/markr/recurring/_schema.cjs.map +1 -1
- package/dist/transfer-service/markr/recurring/_schema.js +1 -1
- package/dist/transfer-service/markr/recurring/_schema.js.map +1 -1
- package/dist/transfer-service/markr/recurring/types.cjs +1 -1
- package/dist/transfer-service/markr/recurring/types.cjs.map +1 -1
- package/dist/transfer-service/markr/recurring/types.d.cts +32 -23
- package/dist/transfer-service/markr/recurring/types.d.ts +32 -23
- package/dist/transfer-service/markr/recurring/types.js +1 -1
- package/dist/transfer-service/markr/recurring/types.js.map +1 -1
- package/dist/types/service.d.cts +3 -1
- package/dist/types/service.d.ts +3 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream-quotes.cjs","names":["markrStreamQuote","isEvmNamespace","caip2ToEip155ChainId","assetToAddressString","quoteFromMarkrQuoteResponseData","isSolanaNamespace","
|
|
1
|
+
{"version":3,"file":"stream-quotes.cjs","names":["markrStreamQuote","isEvmNamespace","caip2ToEip155ChainId","assetToAddressString","quoteFromMarkrQuoteResponseData","isSolanaNamespace","InvalidParamsError","ErrorReason","isEvmAddress","isSolAddress"],"sources":["../../../../src/transfer-service/markr/_handlers/stream-quotes.ts"],"sourcesContent":["import { caip2ToEip155ChainId } from '../../../utils/caip';\nimport type { ServiceQuoteOptions, TransferService } from '../../../types/service';\nimport { markrStreamQuote, type ApiOptions, type MarkrStreamQuoteParams } from '../_api';\nimport { assetToAddressString, quoteFromMarkrQuoteResponseData } from '../_utils';\nimport { isEvmNamespace, isSolanaNamespace } from '../../../_utils/chain';\nimport { isEvmAddress } from '../../../utils/evm-address';\nimport { isSolAddress } from '../../../utils/sol-address';\nimport { ErrorReason, InvalidParamsError } from '../../../errors';\n\nexport interface StreamQuotesFactoryConfig {\n apiOptions: ApiOptions;\n appId: string;\n partnerFeeBps: number;\n}\n\nexport function streamQuotesFactory({\n apiOptions,\n appId,\n partnerFeeBps,\n}: StreamQuotesFactoryConfig): TransferService['streamQuotes'] {\n return (props, handler, options) => {\n const ac = new AbortController();\n const { userEvmAddress, userSolanaAddress, validationError } = _validateAndGetUserAddresses(props, options);\n\n if (validationError) {\n handler('error', validationError);\n handler('done');\n\n return {\n cancel: () => {},\n };\n }\n\n void markrStreamQuote(\n apiOptions,\n {\n amount: props.amount.toString(),\n // Forwarded only when the caller pins one; otherwise Markr races every aggregator.\n aggregator: props.aggregator,\n appId,\n chainId: isEvmNamespace(props.sourceChain.chainId)\n ? caip2ToEip155ChainId(props.sourceChain.chainId)\n : props.sourceChain.chainId,\n // For cross-chain requests, destinationChainId is required.\n // Use EVM numeric chain IDs for EVM targets and CAIP-2 IDs for non-EVM targets.\n destinationChainId:\n props.sourceChain.chainId !== props.targetChain.chainId\n ? isEvmNamespace(props.targetChain.chainId)\n ? caip2ToEip155ChainId(props.targetChain.chainId)\n : props.targetChain.chainId\n : undefined,\n slippage: props.slippageBps,\n tokenIn: assetToAddressString(props.sourceAsset, props.sourceChain.chainId),\n tokenInDecimals: props.sourceAsset.decimals,\n tokenOut: assetToAddressString(props.targetAsset, props.targetChain.chainId),\n tokenOutDecimals: props.targetAsset.decimals,\n userEvmAddress,\n userSolanaAddress,\n },\n {\n onDone: () => {\n if (!ac.signal.aborted) {\n handler('done');\n }\n },\n onError: (error) => {\n if (!ac.signal.aborted) {\n handler('error', error);\n handler('done');\n }\n },\n onQuote: (data) => {\n if (!ac.signal.aborted) {\n handler('quote', quoteFromMarkrQuoteResponseData(data, props, partnerFeeBps));\n }\n },\n signal: ac.signal,\n },\n );\n\n return {\n cancel: () => {\n ac.abort();\n },\n };\n };\n}\n\nexport function _validateAndGetUserAddresses(\n props: Parameters<TransferService['streamQuotes']>[0],\n options?: ServiceQuoteOptions,\n): Pick<MarkrStreamQuoteParams, 'userEvmAddress' | 'userSolanaAddress'> & { validationError?: InvalidParamsError } {\n const isCrossChainSwap = props.sourceChain.chainId !== props.targetChain.chainId;\n const isSameChainSwap = !isCrossChainSwap;\n const sourceIsEvm = isEvmNamespace(props.sourceChain.chainId);\n const targetIsEvm = isEvmNamespace(props.targetChain.chainId);\n const sourceIsSolana = isSolanaNamespace(props.sourceChain.chainId);\n const targetIsSolana = isSolanaNamespace(props.targetChain.chainId);\n const dangerouslyAllowAddressMismatch = options?.dangerouslyAllowAddressMismatch === true;\n const addressesMismatch = props.fromAddress !== props.toAddress;\n\n const invalidParams = (details: string) => ({\n userEvmAddress: undefined,\n userSolanaAddress: undefined,\n validationError: new InvalidParamsError(ErrorReason.INVALID_PARAMS, details),\n });\n\n if (sourceIsEvm && !isEvmAddress(props.fromAddress)) {\n return invalidParams('Invalid fromAddress for EVM source chain.');\n }\n\n if (targetIsEvm && !isEvmAddress(props.toAddress)) {\n return invalidParams('Invalid toAddress for EVM target chain.');\n }\n\n if (sourceIsSolana && !isSolAddress(props.fromAddress)) {\n return invalidParams('Invalid fromAddress for Solana source chain.');\n }\n\n if (targetIsSolana && !isSolAddress(props.toAddress)) {\n return invalidParams('Invalid toAddress for Solana target chain.');\n }\n\n const isSameNamespaceCrossChainSwap =\n isCrossChainSwap && ((sourceIsEvm && targetIsEvm) || (sourceIsSolana && targetIsSolana));\n\n if (isSameNamespaceCrossChainSwap && addressesMismatch && !dangerouslyAllowAddressMismatch) {\n return invalidParams('fromAddress and toAddress must match for same-namespace cross-chain swaps.');\n }\n\n if (isSameChainSwap) {\n if (addressesMismatch && !dangerouslyAllowAddressMismatch) {\n return invalidParams('fromAddress and toAddress must match for same-chain swaps.');\n }\n\n if (!dangerouslyAllowAddressMismatch) {\n return {\n userEvmAddress: undefined,\n userSolanaAddress: undefined,\n };\n }\n }\n\n const userEvmAddress =\n targetIsEvm && isEvmAddress(props.toAddress)\n ? props.toAddress\n : sourceIsEvm && isEvmAddress(props.fromAddress)\n ? props.fromAddress\n : undefined;\n\n const userSolanaAddress =\n targetIsSolana && isSolAddress(props.toAddress)\n ? props.toAddress\n : sourceIsSolana && isSolAddress(props.fromAddress)\n ? props.fromAddress\n : undefined;\n\n return {\n userEvmAddress,\n userSolanaAddress,\n };\n}\n"],"mappings":"+PAeA,SAAgB,EAAoB,CAClC,aACA,QACA,iBAC6D,CAC7D,OAAQ,EAAO,EAAS,IAAY,CAClC,IAAM,EAAK,IAAI,gBACT,CAAE,iBAAgB,oBAAmB,mBAAoB,EAA6B,EAAO,EAAQ,CA0D3G,OAxDI,GACF,EAAQ,QAAS,EAAgB,CACjC,EAAQ,OAAO,CAER,CACL,WAAc,GACf,GAGEA,EAAAA,iBACH,EACA,CACE,OAAQ,EAAM,OAAO,UAAU,CAE/B,WAAY,EAAM,WAClB,QACA,QAASC,EAAAA,eAAe,EAAM,YAAY,QAAQ,CAC9CC,EAAAA,qBAAqB,EAAM,YAAY,QAAQ,CAC/C,EAAM,YAAY,QAGtB,mBACE,EAAM,YAAY,UAAY,EAAM,YAAY,QAI5C,IAAA,GAHAD,EAAAA,eAAe,EAAM,YAAY,QAAQ,CACvCC,EAAAA,qBAAqB,EAAM,YAAY,QAAQ,CAC/C,EAAM,YAAY,QAE1B,SAAU,EAAM,YAChB,QAASC,EAAAA,qBAAqB,EAAM,YAAa,EAAM,YAAY,QAAQ,CAC3E,gBAAiB,EAAM,YAAY,SACnC,SAAUA,EAAAA,qBAAqB,EAAM,YAAa,EAAM,YAAY,QAAQ,CAC5E,iBAAkB,EAAM,YAAY,SACpC,iBACA,oBACD,CACD,CACE,WAAc,CACP,EAAG,OAAO,SACb,EAAQ,OAAO,EAGnB,QAAU,GAAU,CACb,EAAG,OAAO,UACb,EAAQ,QAAS,EAAM,CACvB,EAAQ,OAAO,GAGnB,QAAU,GAAS,CACZ,EAA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AAM,UACN,GAAeA,EAAAA,aAAa,EAAM,YAAY,CAC9C,EAAM,YACN,IAAA,GAWJ,kBARA,GAAkBC,EAAAA,aAAa,EAAM,UAAU,CAC3C,EAAM,UACN,GAAkBA,EAAAA,aAAa,EAAM,YAAY,CACjD,EAAM,YACN,IAAA,GAKL"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ErrorReason as e,InvalidParamsError as t}from"../../../errors.js";import{caip2ToEip155ChainId as n}from"../../../utils/caip.js";import{isEvmNamespace as r,isSolanaNamespace as i}from"../../../_utils/chain.js";import{isEvmAddress as a}from"../../../utils/evm-address.js";import{markrStreamQuote as o}from"../_api.js";import{isSolAddress as s}from"../../../utils/sol-address.js";import{assetToAddressString as c,quoteFromMarkrQuoteResponseData as l}from"../_utils.js";function u({apiOptions:e,appId:t,partnerFeeBps:i}){return(a,s,u)=>{let f=new AbortController,{userEvmAddress:p,userSolanaAddress:m,validationError:h}=d(a,u);return h?(s(`error`,h),s(`done`),{cancel:()=>{}}):(o(e,{amount:a.amount.toString(),aggregator:a.aggregator,appId:t,chainId:r(a.sourceChain.chainId)?n(a.sourceChain.chainId):a.sourceChain.chainId,destinationChainId:a.sourceChain.chainId===a.targetChain.chainId?void 0:r(a.targetChain.chainId)?n(a.targetChain.chainId):a.targetChain.chainId,slippage:a.slippageBps,tokenIn:c(a.sourceAsset,a.sourceChain.chainId),tokenInDecimals:a.sourceAsset.decimals,tokenOut:c(a.targetAsset,a.targetChain.chainId),tokenOutDecimals:a.targetAsset.decimals,userEvmAddress:p,userSolanaAddress:m},{onDone:()=>{f.signal.aborted||s(`done`)},onError:e=>{f.signal.aborted||(s(`error`,e),s(`done`))},onQuote:e=>{f.signal.aborted||s(`quote`,l(e,a,i))},signal:f.signal}),{cancel:()=>{f.abort()}})}}function d(n,o){let c=n.sourceChain.chainId!==n.targetChain.chainId,l=r(n.sourceChain.chainId),
|
|
1
|
+
import{ErrorReason as e,InvalidParamsError as t}from"../../../errors.js";import{caip2ToEip155ChainId as n}from"../../../utils/caip.js";import{isEvmNamespace as r,isSolanaNamespace as i}from"../../../_utils/chain.js";import{isEvmAddress as a}from"../../../utils/evm-address.js";import{markrStreamQuote as o}from"../_api.js";import{isSolAddress as s}from"../../../utils/sol-address.js";import{assetToAddressString as c,quoteFromMarkrQuoteResponseData as l}from"../_utils.js";function u({apiOptions:e,appId:t,partnerFeeBps:i}){return(a,s,u)=>{let f=new AbortController,{userEvmAddress:p,userSolanaAddress:m,validationError:h}=d(a,u);return h?(s(`error`,h),s(`done`),{cancel:()=>{}}):(o(e,{amount:a.amount.toString(),aggregator:a.aggregator,appId:t,chainId:r(a.sourceChain.chainId)?n(a.sourceChain.chainId):a.sourceChain.chainId,destinationChainId:a.sourceChain.chainId===a.targetChain.chainId?void 0:r(a.targetChain.chainId)?n(a.targetChain.chainId):a.targetChain.chainId,slippage:a.slippageBps,tokenIn:c(a.sourceAsset,a.sourceChain.chainId),tokenInDecimals:a.sourceAsset.decimals,tokenOut:c(a.targetAsset,a.targetChain.chainId),tokenOutDecimals:a.targetAsset.decimals,userEvmAddress:p,userSolanaAddress:m},{onDone:()=>{f.signal.aborted||s(`done`)},onError:e=>{f.signal.aborted||(s(`error`,e),s(`done`))},onQuote:e=>{f.signal.aborted||s(`quote`,l(e,a,i))},signal:f.signal}),{cancel:()=>{f.abort()}})}}function d(n,o){let c=n.sourceChain.chainId!==n.targetChain.chainId,l=!c,u=r(n.sourceChain.chainId),d=r(n.targetChain.chainId),f=i(n.sourceChain.chainId),p=i(n.targetChain.chainId),m=o?.dangerouslyAllowAddressMismatch===!0,h=n.fromAddress!==n.toAddress,g=n=>({userEvmAddress:void 0,userSolanaAddress:void 0,validationError:new t(e.INVALID_PARAMS,n)});if(u&&!a(n.fromAddress))return g(`Invalid fromAddress for EVM source chain.`);if(d&&!a(n.toAddress))return g(`Invalid toAddress for EVM target chain.`);if(f&&!s(n.fromAddress))return g(`Invalid fromAddress for Solana source chain.`);if(p&&!s(n.toAddress))return g(`Invalid toAddress for Solana target chain.`);if(c&&(u&&d||f&&p)&&h&&!m)return g(`fromAddress and toAddress must match for same-namespace cross-chain swaps.`);if(l){if(h&&!m)return g(`fromAddress and toAddress must match for same-chain swaps.`);if(!m)return{userEvmAddress:void 0,userSolanaAddress:void 0}}return{userEvmAddress:d&&a(n.toAddress)?n.toAddress:u&&a(n.fromAddress)?n.fromAddress:void 0,userSolanaAddress:p&&s(n.toAddress)?n.toAddress:f&&s(n.fromAddress)?n.fromAddress:void 0}}export{u as streamQuotesFactory};
|
|
2
2
|
//# sourceMappingURL=stream-quotes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream-quotes.js","names":[],"sources":["../../../../src/transfer-service/markr/_handlers/stream-quotes.ts"],"sourcesContent":["import { caip2ToEip155ChainId } from '../../../utils/caip';\nimport type { ServiceQuoteOptions, TransferService } from '../../../types/service';\nimport { markrStreamQuote, type ApiOptions, type MarkrStreamQuoteParams } from '../_api';\nimport { assetToAddressString, quoteFromMarkrQuoteResponseData } from '../_utils';\nimport { isEvmNamespace, isSolanaNamespace } from '../../../_utils/chain';\nimport { isEvmAddress } from '../../../utils/evm-address';\nimport { isSolAddress } from '../../../utils/sol-address';\nimport { ErrorReason, InvalidParamsError } from '../../../errors';\n\nexport interface StreamQuotesFactoryConfig {\n apiOptions: ApiOptions;\n appId: string;\n partnerFeeBps: number;\n}\n\nexport function streamQuotesFactory({\n apiOptions,\n appId,\n partnerFeeBps,\n}: StreamQuotesFactoryConfig): TransferService['streamQuotes'] {\n return (props, handler, options) => {\n const ac = new AbortController();\n const { userEvmAddress, userSolanaAddress, validationError } = _validateAndGetUserAddresses(props, options);\n\n if (validationError) {\n handler('error', validationError);\n handler('done');\n\n return {\n cancel: () => {},\n };\n }\n\n void markrStreamQuote(\n apiOptions,\n {\n amount: props.amount.toString(),\n // Forwarded only when the caller pins one; otherwise Markr races every aggregator.\n aggregator: props.aggregator,\n appId,\n chainId: isEvmNamespace(props.sourceChain.chainId)\n ? caip2ToEip155ChainId(props.sourceChain.chainId)\n : props.sourceChain.chainId,\n // For cross-chain requests, destinationChainId is required.\n // Use EVM numeric chain IDs for EVM targets and CAIP-2 IDs for non-EVM targets.\n destinationChainId:\n props.sourceChain.chainId !== props.targetChain.chainId\n ? isEvmNamespace(props.targetChain.chainId)\n ? caip2ToEip155ChainId(props.targetChain.chainId)\n : props.targetChain.chainId\n : undefined,\n slippage: props.slippageBps,\n tokenIn: assetToAddressString(props.sourceAsset, props.sourceChain.chainId),\n tokenInDecimals: props.sourceAsset.decimals,\n tokenOut: assetToAddressString(props.targetAsset, props.targetChain.chainId),\n tokenOutDecimals: props.targetAsset.decimals,\n userEvmAddress,\n userSolanaAddress,\n },\n {\n onDone: () => {\n if (!ac.signal.aborted) {\n handler('done');\n }\n },\n onError: (error) => {\n if (!ac.signal.aborted) {\n handler('error', error);\n handler('done');\n }\n },\n onQuote: (data) => {\n if (!ac.signal.aborted) {\n handler('quote', quoteFromMarkrQuoteResponseData(data, props, partnerFeeBps));\n }\n },\n signal: ac.signal,\n },\n );\n\n return {\n cancel: () => {\n ac.abort();\n },\n };\n };\n}\n\nexport function _validateAndGetUserAddresses(\n props: Parameters<TransferService['streamQuotes']>[0],\n options?: ServiceQuoteOptions,\n): Pick<MarkrStreamQuoteParams, 'userEvmAddress' | 'userSolanaAddress'> & { validationError?: InvalidParamsError } {\n const isCrossChainSwap = props.sourceChain.chainId !== props.targetChain.chainId;\n const sourceIsEvm = isEvmNamespace(props.sourceChain.chainId);\n const targetIsEvm = isEvmNamespace(props.targetChain.chainId);\n const sourceIsSolana = isSolanaNamespace(props.sourceChain.chainId);\n const targetIsSolana = isSolanaNamespace(props.targetChain.chainId);\n
|
|
1
|
+
{"version":3,"file":"stream-quotes.js","names":[],"sources":["../../../../src/transfer-service/markr/_handlers/stream-quotes.ts"],"sourcesContent":["import { caip2ToEip155ChainId } from '../../../utils/caip';\nimport type { ServiceQuoteOptions, TransferService } from '../../../types/service';\nimport { markrStreamQuote, type ApiOptions, type MarkrStreamQuoteParams } from '../_api';\nimport { assetToAddressString, quoteFromMarkrQuoteResponseData } from '../_utils';\nimport { isEvmNamespace, isSolanaNamespace } from '../../../_utils/chain';\nimport { isEvmAddress } from '../../../utils/evm-address';\nimport { isSolAddress } from '../../../utils/sol-address';\nimport { ErrorReason, InvalidParamsError } from '../../../errors';\n\nexport interface StreamQuotesFactoryConfig {\n apiOptions: ApiOptions;\n appId: string;\n partnerFeeBps: number;\n}\n\nexport function streamQuotesFactory({\n apiOptions,\n appId,\n partnerFeeBps,\n}: StreamQuotesFactoryConfig): TransferService['streamQuotes'] {\n return (props, handler, options) => {\n const ac = new AbortController();\n const { userEvmAddress, userSolanaAddress, validationError } = _validateAndGetUserAddresses(props, options);\n\n if (validationError) {\n handler('error', validationError);\n handler('done');\n\n return {\n cancel: () => {},\n };\n }\n\n void markrStreamQuote(\n apiOptions,\n {\n amount: props.amount.toString(),\n // Forwarded only when the caller pins one; otherwise Markr races every aggregator.\n aggregator: props.aggregator,\n appId,\n chainId: isEvmNamespace(props.sourceChain.chainId)\n ? caip2ToEip155ChainId(props.sourceChain.chainId)\n : props.sourceChain.chainId,\n // For cross-chain requests, destinationChainId is required.\n // Use EVM numeric chain IDs for EVM targets and CAIP-2 IDs for non-EVM targets.\n destinationChainId:\n props.sourceChain.chainId !== props.targetChain.chainId\n ? isEvmNamespace(props.targetChain.chainId)\n ? caip2ToEip155ChainId(props.targetChain.chainId)\n : props.targetChain.chainId\n : undefined,\n slippage: props.slippageBps,\n tokenIn: assetToAddressString(props.sourceAsset, props.sourceChain.chainId),\n tokenInDecimals: props.sourceAsset.decimals,\n tokenOut: assetToAddressString(props.targetAsset, props.targetChain.chainId),\n tokenOutDecimals: props.targetAsset.decimals,\n userEvmAddress,\n userSolanaAddress,\n },\n {\n onDone: () => {\n if (!ac.signal.aborted) {\n handler('done');\n }\n },\n onError: (error) => {\n if (!ac.signal.aborted) {\n handler('error', error);\n handler('done');\n }\n },\n onQuote: (data) => {\n if (!ac.signal.aborted) {\n handler('quote', quoteFromMarkrQuoteResponseData(data, props, partnerFeeBps));\n }\n },\n signal: ac.signal,\n },\n );\n\n return {\n cancel: () => {\n ac.abort();\n },\n };\n };\n}\n\nexport function _validateAndGetUserAddresses(\n props: Parameters<TransferService['streamQuotes']>[0],\n options?: ServiceQuoteOptions,\n): Pick<MarkrStreamQuoteParams, 'userEvmAddress' | 'userSolanaAddress'> & { validationError?: InvalidParamsError } {\n const isCrossChainSwap = props.sourceChain.chainId !== props.targetChain.chainId;\n const isSameChainSwap = !isCrossChainSwap;\n const sourceIsEvm = isEvmNamespace(props.sourceChain.chainId);\n const targetIsEvm = isEvmNamespace(props.targetChain.chainId);\n const sourceIsSolana = isSolanaNamespace(props.sourceChain.chainId);\n const targetIsSolana = isSolanaNamespace(props.targetChain.chainId);\n const dangerouslyAllowAddressMismatch = options?.dangerouslyAllowAddressMismatch === true;\n const addressesMismatch = props.fromAddress !== props.toAddress;\n\n const invalidParams = (details: string) => ({\n userEvmAddress: undefined,\n userSolanaAddress: undefined,\n validationError: new InvalidParamsError(ErrorReason.INVALID_PARAMS, details),\n });\n\n if (sourceIsEvm && !isEvmAddress(props.fromAddress)) {\n return invalidParams('Invalid fromAddress for EVM source chain.');\n }\n\n if (targetIsEvm && !isEvmAddress(props.toAddress)) {\n return invalidParams('Invalid toAddress for EVM target chain.');\n }\n\n if (sourceIsSolana && !isSolAddress(props.fromAddress)) {\n return invalidParams('Invalid fromAddress for Solana source chain.');\n }\n\n if (targetIsSolana && !isSolAddress(props.toAddress)) {\n return invalidParams('Invalid toAddress for Solana target chain.');\n }\n\n const isSameNamespaceCrossChainSwap =\n isCrossChainSwap && ((sourceIsEvm && targetIsEvm) || (sourceIsSolana && targetIsSolana));\n\n if (isSameNamespaceCrossChainSwap && addressesMismatch && !dangerouslyAllowAddressMismatch) {\n return invalidParams('fromAddress and toAddress must match for same-namespace cross-chain swaps.');\n }\n\n if (isSameChainSwap) {\n if (addressesMismatch && !dangerouslyAllowAddressMismatch) {\n return invalidParams('fromAddress and toAddress must match for same-chain swaps.');\n }\n\n if (!dangerouslyAllowAddressMismatch) {\n return {\n userEvmAddress: undefined,\n userSolanaAddress: undefined,\n };\n }\n }\n\n const userEvmAddress =\n targetIsEvm && isEvmAddress(props.toAddress)\n ? props.toAddress\n : sourceIsEvm && isEvmAddress(props.fromAddress)\n ? props.fromAddress\n : undefined;\n\n const userSolanaAddress =\n targetIsSolana && isSolAddress(props.toAddress)\n ? props.toAddress\n : sourceIsSolana && isSolAddress(props.fromAddress)\n ? props.fromAddress\n : undefined;\n\n return {\n userEvmAddress,\n userSolanaAddress,\n };\n}\n"],"mappings":"ydAeA,SAAgB,EAAoB,CAClC,aACA,QACA,iBAC6D,CAC7D,OAAQ,EAAO,EAAS,IAAY,CAClC,IAAM,EAAK,IAAI,gBACT,CAAE,iBAAgB,oBAAmB,mBAAoB,EAA6B,EAAO,EAAQ,CA0D3G,OAxDI,GACF,EAAQ,QAAS,EAAgB,CACjC,EAAQ,OAAO,CAER,CACL,WAAc,GACf,GAGE,EACH,EACA,CACE,OAAQ,EAAM,OAAO,UAAU,CAE/B,WAAY,EAAM,WAClB,QACA,QAAS,EAAe,EAAM,YAAY,QAAQ,CAC9C,EAAqB,EAAM,YAAY,QAAQ,CAC/C,EAAM,YAAY,QAGtB,mBACE,EAAM,YAAY,UAAY,EAAM,YAAY,QAI5C,IAAA,GAHA,EAAe,EAAM,YAAY,QAAQ,CACvC,EAAqB,EAAM,YAAY,QAAQ,CAC/C,EAAM,YAAY,QAE1B,SAAU,EAAM,YAChB,QAAS,EAAqB,EAAM,YAAa,EAAM,YAAY,QAAQ,CAC3E,gBAAiB,EAAM,YAAY,SACnC,SAAU,EAAqB,EAAM,YAAa,EAAM,YAAY,QAAQ,CAC5E,iBAAkB,EAAM,YAAY,SACpC,iBACA,oBACD,CACD,CACE,WAAc,CACP,EAAG,OAAO,SACb,EAAQ,OAAO,EAGnB,QAAU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,UACN,GAAe,EAAa,EAAM,YAAY,CAC9C,EAAM,YACN,IAAA,GAWJ,kBARA,GAAkB,EAAa,EAAM,UAAU,CAC3C,EAAM,UACN,GAAkB,EAAa,EAAM,YAAY,CACjD,EAAM,YACN,IAAA,GAKL"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../utils/caip.cjs`),t=require(`../service-schemas.cjs`);let n=require(`zod`);const r=n.z.string().refine(t=>e.isCaip2ChainId(t),{message:`Invalid CAIP-2 chain ID`}).transform(e=>e),i=n.z.object({chainId:n.z.union([n.z.number(),n.z.string()]),chainType:n.z.string(),enabled_services:n.z.array(n.z.enum([`cross-chain-swap`,`cross-chain-quote`,`quote`,`swap`,`token-list`])),logo_url:n.z.url(),name:n.z.string(),lanes:n.z.array(n.z.union([n.z.coerce.number().int().nonnegative(),r]))}),a=i.extend({chainId:n.z.coerce.number().int().nonnegative(),chainType:n.z.literal(`evm`),router:t.EvmAddressSchema.optional(),wrapped_token:t.EvmAddressSchema.optional(),recurring:n.z.object({minFrequencySeconds:n.z.number().int().nonnegative()
|
|
1
|
+
require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../utils/caip.cjs`),t=require(`../service-schemas.cjs`);let n=require(`zod`);const r=n.z.string().refine(t=>e.isCaip2ChainId(t),{message:`Invalid CAIP-2 chain ID`}).transform(e=>e),i=n.z.object({chainId:n.z.union([n.z.number(),n.z.string()]),chainType:n.z.string(),enabled_services:n.z.array(n.z.enum([`cross-chain-swap`,`cross-chain-quote`,`quote`,`swap`,`token-list`])),logo_url:n.z.url(),name:n.z.string(),lanes:n.z.array(n.z.union([n.z.coerce.number().int().nonnegative(),r]))}),a=i.extend({chainId:n.z.coerce.number().int().nonnegative(),chainType:n.z.literal(`evm`),router:t.EvmAddressSchema.optional(),wrapped_token:t.EvmAddressSchema.optional(),recurring:n.z.object({minFrequencySeconds:n.z.number().int().nonnegative()}).optional()}),o=i.extend({chainId:n.z.string().refine(t=>e.isCaip2ChainId(t)&&t.startsWith(`solana:`),{error:`Is not a valid Solana CAIP-2 ID`}).transform(e=>e),chainType:n.z.literal(`svm`)}),s=n.z.array(n.z.union([a,o,i.refine(e=>e.chainType!==`evm`&&e.chainType!==`svm`,`Known chain types must match their expected schema`)])),c=n.z.array(n.z.object({address:t.EvmAddressSchema,decimals:n.z.number().int().nonnegative().max(18),logo_url:n.z.url(),name:n.z.string(),symbol:n.z.string()})),l=n.z.union([t.EvmAddressSchema,t.SolAddressSchema,t.HyperliquidAddressSchema]),u=n.z.union([n.z.object({aggregator:n.z.object({id:n.z.string(),logo_url:n.z.url(),name:n.z.string()}),amountIn:n.z.coerce.bigint().nonnegative(),amountOut:n.z.coerce.bigint().nonnegative(),chainId:n.z.union([n.z.number().int().nonnegative(),r]),expiredAt:n.z.number().int().nonnegative(),fees:n.z.array(n.z.object({type:n.z.enum([`protocol`,`gas`,`bridge`,`slippage`,`swap`,`other`,`relay`]),name:n.z.string(),amount:n.z.coerce.bigint().nonnegative(),token:n.z.object({chainId:n.z.union([n.z.number().int().nonnegative(),r]),address:l}),extra:n.z.union([n.z.boolean(),n.z.record(n.z.string(),n.z.unknown())]).optional()})).optional(),gasEstimate:n.z.coerce.bigint().nonnegative().optional(),recommendedSlippage:n.z.number().int().nonnegative(),tokenIn:l,tokenInDecimals:n.z.number().int().nonnegative().max(18),tokenOut:l,tokenOutDecimals:n.z.number().int().nonnegative().max(18),uuid:n.z.uuid()}),n.z.object({done:n.z.literal(!0)})]),d=n.z.object({data:t.HexSchema,to:t.EvmAddressSchema,value:n.z.coerce.bigint().nonnegative(),from:t.EvmAddressSchema.optional()}),f=n.z.object({chainType:n.z.literal(`svm`),swapTransaction:n.z.base64()}),p=n.z.object({hyperliquidChain:n.z.string().min(1),destination:t.EvmAddressSchema,sourceDex:n.z.string(),destinationDex:n.z.string(),token:n.z.string().min(1),amount:n.z.string().regex(/^\d+(\.\d+)?$/,`amount must be a positive decimal string`),fromSubAccount:n.z.string()}),m=n.z.object({signatureKind:n.z.literal(`eip712`),domain:n.z.object({name:n.z.string().min(1),version:n.z.string().min(1),chainId:n.z.number().int().nonnegative(),verifyingContract:t.EvmAddressSchema}),types:n.z.record(n.z.string(),n.z.array(n.z.object({name:n.z.string(),type:n.z.string()}))),primaryType:n.z.string().min(1),value:n.z.object({wallet:t.EvmAddressSchema,chainId:n.z.string().min(1),id:t.HashSchema,nonce:n.z.number().int().nonnegative()}).loose()}),h=n.z.object({endpoint:n.z.string().min(1),method:n.z.string().min(1),body:n.z.object({type:n.z.string().min(1),id:t.HashSchema,nonce:n.z.number().int().nonnegative(),wallet:t.EvmAddressSchema,walletChainId:n.z.number().int().nonnegative(),signatureChainId:n.z.number().int().nonnegative()}).loose()}),g=n.z.object({type:n.z.literal(`hyperliquid-withdraw`),protocolVersion:n.z.number().int().positive(),nonce:n.z.string().regex(/^\d+$/,`nonce must be a decimal string`),id:t.HashSchema,requestId:t.HashSchema,parameters:p,sign:m.optional(),authorize:h.optional()}),_=n.z.union([d,f,g]),v=n.z.unknown().refine(e=>!(typeof e==`object`&&e&&`error`in e&&typeof e.error==`string`),{message:`Markr /authorize returned an error envelope despite 2xx status.`}),y=n.z.object({fee:n.z.int().nonnegative(),name:n.z.string()}),b=/[zZ]|[+-]\d{2}:?\d{2}$/,x=n.z.iso.datetime({local:!0}).refine(e=>{let t=b.test(e)?e:`${e}Z`;return n.z.iso.datetime().safeParse(t).success},{error:`Invalid ISO-8601 datetime (must be valid with timezone, or local assumed UTC)`}).transform(e=>b.test(e)?e:`${e}Z`),S=n.z.object({messageId:n.z.string().nullable(),status:n.z.enum([`pending`,`committed`,`pending_execution`,`completed`,`failed`,`refunded`,`unknown`]),description:n.z.string(),sourceChain:n.z.object({name:n.z.string(),transactionHash:n.z.union([t.HashSchema,t.SolSignatureSchema]),timestamp:x,finalized:x.or(n.z.boolean()).nullable()}),destinationChain:n.z.object({name:n.z.string().nullable(),transactionHash:n.z.union([t.HashSchema,t.SolSignatureSchema]).nullable(),bridgeHash:n.z.union([t.HashSchema,t.SolSignatureSchema]).nullable().optional(),timestamp:x.nullable(),finalized:x.nullable()}),progress:n.z.object({committed:n.z.boolean(),commitTimestamp:x.nullable().optional(),executed:n.z.boolean()}),fees:n.z.object({token:n.z.union([t.EvmAddressSchema,t.SolAddressSchema]).nullable(),amount:n.z.coerce.bigint().nonnegative().nullable()}).nullable(),transferredTokens:n.z.array(n.z.object({token:n.z.union([t.EvmAddressSchema,t.SolAddressSchema]),amount:n.z.coerce.bigint().nonnegative()})),debug:n.z.looseObject({messageId:n.z.string(),status:n.z.string(),destinationChain:n.z.string(),destinationTxHash:n.z.string(),relayTxHash:n.z.string(),retryCount:n.z.number().int().nonnegative(),lastRetryAt:n.z.iso.datetime(),sourceChain:n.z.string(),sourceTxHash:n.z.string(),createdAt:n.z.iso.datetime()}).partial().nullable().optional()}),C=n.z.object({address:t.EvmAddressSchema});exports.CrossChainStatusResponseSchema=S,exports.MarkrAuthorizeResponseSchema=v,exports.PartnerInfoResponseSchema=y,exports.QuoteResponseSchema=u,exports.SpenderAddressResponseSchema=C,exports.SupportedChainsResponseSchema=s,exports.SwapResponseSchema=_,exports.TokenListResponseSchema=c,exports.WrappedSwapTransactionResponseSchema=d;
|
|
2
2
|
//# sourceMappingURL=_schema.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_schema.cjs","names":["z","isCaip2ChainId","EvmAddressSchema","SolAddressSchema","HyperliquidAddressSchema","HexSchema","HashSchema","SolSignatureSchema"],"sources":["../../../src/transfer-service/markr/_schema.ts"],"sourcesContent":["import type { Signature, Address as SolAddress } from '@solana/kit';\nimport type { Address as EvmAddress, Hash } from 'viem';\nimport { z } from 'zod';\nimport type { Caip2ChainId } from '../../types/caip';\nimport type { Hex } from '../../types/signer';\nimport { isCaip2ChainId } from '../../utils/caip';\nimport {\n EvmAddressSchema,\n HashSchema,\n HexSchema,\n HyperliquidAddressSchema,\n SolAddressSchema,\n SolSignatureSchema,\n} from '../service-schemas';\n\ninterface SupportedChainsResponseItemBase {\n chainId: number | string;\n chainType: string;\n /** Available services on the chain. Each service has specific functionality */\n enabled_services: Array<'cross-chain-swap' | 'cross-chain-quote' | 'quote' | 'swap' | 'token-list'>;\n /** Chain logo URL */\n logo_url: string;\n /** Chain display name */\n name: string;\n /**\n * List of chain IDs that this chain can swap to via cross-chain aggregators.\n *\n * Empty array means no cross-chain routes available.\n */\n lanes: ReadonlyArray<number | Caip2ChainId>;\n}\n\nexport interface SupportedChainsResponseItemEvm extends SupportedChainsResponseItemBase {\n /** Chain identifier */\n chainId: number;\n /** Chain virtual machine type */\n chainType: 'evm';\n /** Router contract address */\n router?: EvmAddress;\n /** Native token wrapped contract address */\n wrapped_token?: EvmAddress;\n /**\n * Recurring-swap (DCA) capability metadata for this chain. Absent when the\n * orchestrator does not enable recurring swaps for the chain.\n *\n * @see https://orchestrator-docs.markr.io/#/Recurring%20Swaps\n */\n recurring?: {\n /** Lower bound for `intervalSeconds` accepted by `/recurring/quote`. */\n minFrequencySeconds: number;\n supportedTokens: ReadonlyArray<{\n address: EvmAddress;\n /** Smallest-unit decimal string — per-order minimum input. */\n minimumAmount: string;\n }>;\n };\n}\n\nexport interface SupportedChainsResponseItemSvm extends SupportedChainsResponseItemBase {\n /** Chain identifier */\n chainId: Caip2ChainId;\n /** Chain virtual machine type */\n chainType: 'svm';\n}\n\nexport type SupportedChainsResponse = Array<\n SupportedChainsResponseItemEvm | SupportedChainsResponseItemSvm | SupportedChainsResponseItemBase\n>;\n\nexport const Caip2ChainIdSchema: z.ZodType<Caip2ChainId> = z\n .string()\n .refine((value) => isCaip2ChainId(value), {\n message: 'Invalid CAIP-2 chain ID',\n })\n .transform((value) => value as Caip2ChainId);\n\nconst SupportedChainsResponseItemBaseSchema = z.object({\n chainId: z.union([z.number(), z.string()]),\n chainType: z.string(),\n enabled_services: z.array(z.enum(['cross-chain-swap', 'cross-chain-quote', 'quote', 'swap', 'token-list'])),\n logo_url: z.url(),\n name: z.string(),\n lanes: z.array(z.union([z.coerce.number().int().nonnegative(), Caip2ChainIdSchema])),\n});\n\nconst SupportedChainsResponseItemEvmSchema: z.ZodType<SupportedChainsResponseItemEvm> =\n SupportedChainsResponseItemBaseSchema.extend({\n chainId: z.coerce.number().int().nonnegative(),\n chainType: z.literal('evm'),\n router: EvmAddressSchema.optional(),\n wrapped_token: EvmAddressSchema.optional(),\n recurring: z\n .object({\n minFrequencySeconds: z.number().int().nonnegative(),\n supportedTokens: z.array(\n z.object({\n address: EvmAddressSchema,\n // Decimal string — must be `BigInt()`-parseable (see\n // checkRecurringEligibility's `BigInt(minimumAmount)` call).\n minimumAmount: z.string().regex(/^\\d+$/, 'minimumAmount must be a decimal string'),\n }),\n ),\n })\n .optional(),\n });\n\nconst SupportedChainsResponseItemSvmSchema: z.ZodType<SupportedChainsResponseItemSvm> =\n SupportedChainsResponseItemBaseSchema.extend({\n chainId: z\n .string()\n .refine((value) => isCaip2ChainId(value) && value.startsWith('solana:'), {\n error: 'Is not a valid Solana CAIP-2 ID',\n })\n .transform((value) => value as Caip2ChainId),\n chainType: z.literal('svm'),\n });\n\n/**\n * Schema for the response from Markr's /info/chains endpoint.\n *\n * @see https://orchestrator-docs.markr.io/#/paths/~1info~1chains/get\n */\nexport const SupportedChainsResponseSchema: z.ZodType<SupportedChainsResponse> = z.array(\n z.union([\n SupportedChainsResponseItemEvmSchema,\n SupportedChainsResponseItemSvmSchema,\n SupportedChainsResponseItemBaseSchema.refine(\n (item) => item.chainType !== 'evm' && item.chainType !== 'svm',\n 'Known chain types must match their expected schema',\n ),\n ]),\n);\n\nexport type TokenListResponse = Array<{\n address: EvmAddress;\n decimals: number;\n logo_url: string;\n name: string;\n symbol: string;\n}>;\n\n/**\n * Schema for the response Markr's /tokens/{chainId}/list endpoint.\n *\n * @see https://orchestrator-docs.markr.io/#/paths/~1tokens~1%7BchainId%7D~1list/get\n */\nexport const TokenListResponseSchema: z.ZodType<TokenListResponse> = z.array(\n z.object({\n address: EvmAddressSchema,\n decimals: z.number().int().nonnegative().max(18),\n logo_url: z.url(),\n name: z.string(),\n symbol: z.string(),\n }),\n);\n\nexport interface QuoteResponseData {\n aggregator: {\n id: string;\n logo_url: string;\n name: string;\n };\n amountIn: bigint;\n amountOut: bigint;\n /** Chain identifier (number for EVM chains, CAIP-2 ID for SVM chains) */\n chainId: number | Caip2ChainId;\n expiredAt: number;\n /**\n * Fee breakdown for cross-chain bridge transactions.\n *\n * Only included in quotes from cross-chain aggregators (DeBridge, LiFi).\n */\n fees?: ReadonlyArray<{\n type: 'protocol' | 'gas' | 'bridge' | 'slippage' | 'swap' | 'other' | 'relay';\n /** Human-readable fee name */\n name: string;\n /** Fee amount in token's smallest unit */\n amount: bigint;\n /**\n * Docs document `extra` as `boolean or object`. The boolean form is the\n * legacy \"additive one-time charge\" flag; the object form is reserved\n * for future structured metadata. Consumers should treat any truthy\n * value as \"this fee is on top of the input amount and must be balance-\n * checked separately.\"\n */\n extra?: boolean | Record<string, unknown>;\n /** Token the fee is deducted from */\n token: {\n /** Chain ID where fee is deducted */\n chainId: number | Caip2ChainId;\n /** Token address (EVM hex or Solana base58) */\n address: EvmAddress | SolAddress;\n };\n }>;\n gasEstimate?: bigint;\n recommendedSlippage: number;\n /** Input token address (EVM hex or Solana base58) */\n tokenIn: EvmAddress | SolAddress;\n tokenInDecimals: number;\n /** Output token address (EVM hex or Solana base58) */\n tokenOut: EvmAddress | SolAddress;\n tokenOutDecimals: number;\n uuid: string;\n}\n\nexport interface QuoteResponseDataDone {\n done: true;\n}\n\nexport type QuoteResponse = QuoteResponseData | QuoteResponseDataDone;\n\nconst MarkrQuoteTokenAddressSchema = z.union([EvmAddressSchema, SolAddressSchema, HyperliquidAddressSchema]);\n\n/**\n * Schema for the response from Markr's /quote endpoint.\n *\n * @see https://orchestrator-docs.markr.io/#/paths/~1quote/post\n */\nexport const QuoteResponseSchema: z.ZodType<QuoteResponse> = z.union([\n z.object({\n aggregator: z.object({\n id: z.string(),\n logo_url: z.url(),\n name: z.string(),\n }),\n amountIn: z.coerce.bigint().nonnegative(),\n amountOut: z.coerce.bigint().nonnegative(),\n chainId: z.union([z.number().int().nonnegative(), Caip2ChainIdSchema]),\n /**\n * Unix time in seconds when the quote expires.\n */\n expiredAt: z.number().int().nonnegative(),\n fees: z\n .array(\n z.object({\n type: z.enum(['protocol', 'gas', 'bridge', 'slippage', 'swap', 'other', 'relay']),\n name: z.string(),\n amount: z.coerce.bigint().nonnegative(),\n token: z.object({\n chainId: z.union([z.number().int().nonnegative(), Caip2ChainIdSchema]),\n address: MarkrQuoteTokenAddressSchema,\n }),\n // Docs: `extra: boolean or object` — accept both. The boolean form\n // is the legacy \"is this an additive one-time charge\" flag; the\n // object form is reserved for future structured metadata.\n extra: z.union([z.boolean(), z.record(z.string(), z.unknown())]).optional(),\n }),\n )\n .optional(),\n /**\n * Estimated gas for the swap transaction.\n * Markr estimates already include a buffer.\n *\n * The API docs do not specify this field as optional, but in practice it can be missing.\n */\n gasEstimate: z.coerce.bigint().nonnegative().optional(),\n /** Recommended slippage in basis points. */\n recommendedSlippage: z.number().int().nonnegative(),\n tokenIn: MarkrQuoteTokenAddressSchema,\n tokenInDecimals: z.number().int().nonnegative().max(18),\n tokenOut: MarkrQuoteTokenAddressSchema,\n tokenOutDecimals: z.number().int().nonnegative().max(18),\n uuid: z.uuid(),\n }),\n z.object({\n done: z.literal(true),\n }),\n]);\n\n/**\n * Response type for Markr's /swap, /recurring/swap, and\n * /recurring/orders/{orderId}/cancel endpoints — all return the same\n * `WrappedTransaction` calldata shape per the orchestrator docs.\n *\n * @see https://orchestrator-docs.markr.io/#/paths/~1swap/post\n */\nexport interface WrappedSwapTransactionResponse {\n data: Hex;\n to: EvmAddress;\n value: bigint;\n /**\n * Sender address per the docs' `WrappedTransaction` schema. Optional in\n * the SDK because the caller (the wallet broadcasting the TX) already\n * knows their own from-address and the field has historically been\n * dropped on parse without consumer impact.\n */\n from?: EvmAddress;\n}\n\nexport const WrappedSwapTransactionResponseSchema: z.ZodType<WrappedSwapTransactionResponse> = z.object({\n data: HexSchema,\n to: EvmAddressSchema,\n value: z.coerce.bigint().nonnegative(),\n from: EvmAddressSchema.optional(),\n});\n\n/**\n * Solana swap transaction (returned for SVM chains).\n */\nexport interface SolanaSwapTransactionResponse {\n /** Chain type identifier */\n chainType: 'svm';\n /** Base64-encoded Solana transaction to be signed and sent by the client */\n swapTransaction: string;\n}\n\nexport const SolanaSwapTransactionResponseSchema: z.ZodType<SolanaSwapTransactionResponse> = z.object({\n chainType: z.literal('svm'),\n swapTransaction: z.base64(),\n});\n\n/**\n * `sendAsset` action parameters Relay produces for the deposit step.\n *\n * These are the exact strings the SDK must (a) include in the EIP-712 message\n * it signs and (b) submit verbatim as the `action` body to HL `/exchange`.\n * Keeping them pre-formatted by Relay (rather than reconstructed by the SDK)\n * eliminates drift — notably on `amount`, which Relay formats at the spot\n * token's display precision (e.g. `\"0.200000\"` for USDC, not the perps-side\n * `\"0.20000000\"`). Any mismatch between what we sign / submit and what Relay\n * recorded in the order makes Relay's indexer skip the on-chain `sendAsset`.\n */\nexport interface HyperliquidSendAssetParameters {\n /** `\"Mainnet\"` or `\"Testnet\"`. */\n hyperliquidChain: string;\n /** Relay's HL custodian — where the sendAsset transfers to. */\n destination: EvmAddress;\n /** Currently always `\"\"` for non-DEX withdrawals. */\n sourceDex: string;\n /** Currently always `\"\"` for non-DEX withdrawals. */\n destinationDex: string;\n /** HL `\"{symbol}:{spotEvmContract}\"` (e.g. `\"USDC:0x6d1e…054\"`). */\n token: string;\n /** Human-readable decimal, Relay-formatted at the spot token's display precision. */\n amount: string;\n /** Currently always `\"\"` for non-sub-account withdrawals. */\n fromSubAccount: string;\n}\n\nconst HyperliquidSendAssetParametersSchema: z.ZodType<HyperliquidSendAssetParameters> = z.object({\n hyperliquidChain: z.string().min(1),\n destination: EvmAddressSchema,\n sourceDex: z.string(),\n destinationDex: z.string(),\n token: z.string().min(1),\n amount: z.string().regex(/^\\d+(\\.\\d+)?$/, 'amount must be a positive decimal string'),\n fromSubAccount: z.string(),\n});\n\n/**\n * Pass-through EIP-712 envelope Relay returns inside the v2 swap response.\n *\n * The SDK no longer hardcodes Relay's `RelayNonceMapping` schema — instead it\n * forwards `domain` / `types` / `primaryType` / `value` to the wallet's typed-\n * data signer verbatim. Future Relay-side schema additions (e.g. `depositor`\n * was added in v2) propagate automatically without an SDK release.\n */\nexport interface RelayEip712SignEnvelope {\n signatureKind: 'eip712';\n domain: {\n name: string;\n version: string;\n chainId: number;\n verifyingContract: EvmAddress;\n };\n types: Record<string, ReadonlyArray<{ name: string; type: string }>>;\n primaryType: string;\n /** Relay binds at minimum these fields; additional keys (e.g. `depositor`) are forwarded verbatim. */\n value: {\n wallet: EvmAddress;\n chainId: string;\n id: Hex;\n nonce: number;\n [key: string]: unknown;\n };\n}\n\nconst RelayEip712SignEnvelopeSchema: z.ZodType<RelayEip712SignEnvelope> = z.object({\n signatureKind: z.literal('eip712'),\n domain: z.object({\n name: z.string().min(1),\n version: z.string().min(1),\n chainId: z.number().int().nonnegative(),\n verifyingContract: EvmAddressSchema,\n }),\n types: z.record(z.string(), z.array(z.object({ name: z.string(), type: z.string() }))),\n primaryType: z.string().min(1),\n value: z\n .object({\n wallet: EvmAddressSchema,\n chainId: z.string().min(1),\n id: HashSchema,\n nonce: z.number().int().nonnegative(),\n })\n .loose(),\n});\n\n/**\n * Pass-through `/authorize` POST body Relay returns inside the v2 swap response.\n *\n * The SDK forwards `body` verbatim to Markr (which forwards verbatim to Relay).\n * Markr only normalizes `nonce` to a JSON number on the wire; everything else\n * is untouched, so new fields Relay adds are not rejected.\n */\nexport interface RelayAuthorizeEnvelope {\n endpoint: string;\n method: string;\n body: {\n type: string;\n id: Hex;\n nonce: number;\n wallet: EvmAddress;\n walletChainId: number;\n signatureChainId: number;\n [key: string]: unknown;\n };\n}\n\nconst RelayAuthorizeEnvelopeSchema: z.ZodType<RelayAuthorizeEnvelope> = z.object({\n endpoint: z.string().min(1),\n method: z.string().min(1),\n body: z\n .object({\n type: z.string().min(1),\n id: HashSchema,\n nonce: z.number().int().nonnegative(),\n wallet: EvmAddressSchema,\n walletChainId: z.number().int().nonnegative(),\n signatureChainId: z.number().int().nonnegative(),\n })\n .loose(),\n});\n\n/**\n * Hyperliquid 2-phase withdrawal variant (source chain = `eip155:1337`).\n *\n * Markr returns:\n * - the dynamic envelope (`nonce`, `id`, `requestId`) used for the authorize\n * signature and status polling, and\n * - the full `parameters` object Relay produced for the deposit step's\n * `sendAsset` action, which the SDK signs verbatim and submits to HL.\n *\n * Starting at `protocolVersion: 2`, Relay's full EIP-712 envelope (`sign`) and\n * the `/authorize` POST body (`authorize`) are passed through verbatim — the\n * SDK no longer reconstructs Relay's schemas, so additive Relay changes (e.g.\n * `depositor` field) flow through without an SDK release.\n *\n * Important: `id` and `requestId` are TWO DIFFERENT bytes32s.\n * - `id` is the **order id** — it goes into the EIP-712 `NonceMapping`\n * message and Relay's `/authorize` POST body. Sourced from\n * `steps[0].items[0].data.sign.value.id` (== `data.post.body.id` ==\n * `protocol.v2.orderId`).\n * - `requestId` is the **tracking id** used only for\n * `/intents/status/v3?requestId=…` polling. Sourced from\n * `steps[0].requestId`.\n *\n * Swapping these two looks superficially correct (both are `0x{64hex}`) but\n * makes the on-chain `sendAsset` un-matchable by Relay's indexer.\n *\n * The SDK pins the static HL-side `SendAsset` shape (which HL owns) as a\n * constant in `_hyperliquid-eip712.ts`. Relay's nonce-mapping shape is now\n * dynamic via the `sign` envelope.\n */\nexport interface HyperliquidWithdrawSwapResponse {\n type: 'hyperliquid-withdraw';\n /** SDK validates against `SUPPORTED_HL_PROTOCOL_VERSIONS`; bumps when Relay/HL EIP-712 schemas change. */\n protocolVersion: number;\n /** Shared between authorize + sendAsset signatures; uint64 decimal string. */\n nonce: string;\n /** Order id signed inside the `NonceMapping` message and posted to `/authorize`. */\n id: Hex;\n /** Tracking id for cross-chain status polling (`/intents/status/v3?requestId=…`). */\n requestId: Hex;\n /** Relay-canonical `sendAsset` action parameters; signed and submitted verbatim. */\n parameters: HyperliquidSendAssetParameters;\n /** Relay's full EIP-712 nonce-mapping envelope. v2+. */\n sign?: RelayEip712SignEnvelope;\n /** Relay's `/authorize` POST descriptor (we forward `body` verbatim). v2+. */\n authorize?: RelayAuthorizeEnvelope;\n}\n\nexport const HyperliquidWithdrawSwapResponseSchema: z.ZodType<HyperliquidWithdrawSwapResponse> = z.object({\n type: z.literal('hyperliquid-withdraw'),\n protocolVersion: z.number().int().positive(),\n nonce: z.string().regex(/^\\d+$/, 'nonce must be a decimal string'),\n id: HashSchema,\n requestId: HashSchema,\n parameters: HyperliquidSendAssetParametersSchema,\n sign: RelayEip712SignEnvelopeSchema.optional(),\n authorize: RelayAuthorizeEnvelopeSchema.optional(),\n});\n\nexport type SwapResponse =\n | WrappedSwapTransactionResponse\n | SolanaSwapTransactionResponse\n | HyperliquidWithdrawSwapResponse;\n\nexport const SwapResponseSchema: z.ZodType<SwapResponse> = z.union([\n WrappedSwapTransactionResponseSchema,\n SolanaSwapTransactionResponseSchema,\n HyperliquidWithdrawSwapResponseSchema,\n]);\n\n/**\n * Markr `/authorize` response.\n *\n * The success body is documented as opaque, so we only assert that:\n * 1. the parsed JSON isn't an error envelope (`{ error: \"...\" }`) — Markr's\n * upstream (Relay) can return a 200 with an error payload when the\n * authorize is rejected after HTTP success;\n * 2. nothing else, by design — schema bumps when Markr publishes a spec.\n */\nexport const MarkrAuthorizeResponseSchema: z.ZodType<unknown> = z\n .unknown()\n .refine(\n (data) =>\n !(\n data !== null &&\n typeof data === 'object' &&\n 'error' in data &&\n typeof (data as { error: unknown }).error === 'string'\n ),\n { message: 'Markr /authorize returned an error envelope despite 2xx status.' },\n );\n\nexport interface PartnerInfoResponse {\n /**\n * The partner fee in basis points collected on each swap.\n */\n fee: number;\n name: string;\n}\n\nexport const PartnerInfoResponseSchema: z.ZodType<PartnerInfoResponse> = z.object({\n fee: z.int().nonnegative(),\n name: z.string(),\n});\n\n/**\n * If the destination token is USDC, the flow is:\n * - pending -> committed -> completed\n *\n * If the destination token is not USDC, the flow is:\n * - pending -> committed -> pending_execution -> completed\n *\n * If the transaction fails at any point, the status will be 'failed'.\n */\nexport type CrossChainStatus =\n | /** Transaction submitted to CCIP */\n 'pending'\n /** Message committed, awaiting execution on destination chain */\n | 'committed'\n /** Message received on destination, swap pending execution by relayer */\n | 'pending_execution'\n /** Message executed successfully on destination chain */\n | 'completed'\n /** Swap expired, and funds were refunded (CCIP only) */\n | 'refunded'\n /** Execution failed */\n | 'failed'\n /** Unknown state */\n | 'unknown';\n\nexport interface CrossChainStatusResponse {\n /**\n * Cross-chain transaction identifier.\n *\n * For CCIP: The CCIP message ID.\n * For DeBridge: The DeBridge order ID.\n */\n messageId: string | null;\n /** Current status of the cross-chain transaction. */\n status: CrossChainStatus;\n /** Human-readable status description */\n description: string;\n /** Source chain information */\n sourceChain: {\n /** Source chain network name */\n name: string;\n /** Source chain transaction hash */\n transactionHash: Hash | Signature;\n /** Transaction timestamp on source chain (ISO 8601) */\n timestamp: string;\n /** When the source transaction was finalized (ISO 8601) */\n finalized: string | boolean | null;\n };\n /** Destination chain information */\n destinationChain: {\n /** Destination chain network name */\n name: string | null;\n /**\n * Destination chain tx hash.\n *\n * - For direct transfers (USDC -> USDC): The CCIP bridge transaction hash.\n * - For successful swaps: The actual swap transaction hash from the relayer.\n * - For pending swaps: null (swap not yet executed).\n */\n transactionHash: Hash | Signature | null;\n /**\n * CCIP bridge tx hash (only present for swaps, not direct transfers).\n *\n * This is the transaction that delivered USDC to the destination chain via CCIP.\n * The `transactionHash` field contains the subsequent swap transaction.\n */\n bridgeHash?: Hash | Signature | null;\n /** Transaction timestamp on destination chain (null if not yet executed) (ISO 8601) */\n timestamp: string | null;\n /** When the destination transaction was finalized (null if not yet executed) (ISO 8601) */\n finalized: string | null;\n };\n /** Transaction progress information */\n progress: {\n /** Whether the message has been committed on destination chain */\n committed: boolean;\n /** When the message was committed (null if not committed) (ISO 8601) */\n commitTimestamp?: string | null;\n /** Whether the message has been executed on destination chain */\n executed: boolean;\n };\n /** Fee information */\n fees: {\n /** Fee token address */\n token: EvmAddress | SolAddress | null;\n /** Fee amount in wei */\n amount: bigint | null;\n } | null;\n /** Tokens transferred in this cross-chain transaction */\n transferredTokens: ReadonlyArray<{\n /** Token address */\n token: EvmAddress | SolAddress;\n /** Token amount */\n amount: bigint;\n }>;\n /**\n * Debug information from Markr transaction API (only present for swaps that have been executed).\n *\n * Contains detailed information about the relayer execution, retry attempts, and transaction details.\n */\n debug?: Partial<{\n /** CCIP message ID */\n messageId: string;\n /** Execution status from relayer */\n status: string;\n /** Destination chain name */\n destinationChain: string;\n /** Destination swap transaction hash */\n destinationTxHash: string;\n /** Relay transaction hash */\n relayTxHash: string;\n /** Number of retry attempts */\n retryCount: number;\n /** Timestamp of last retry attempt (ISO 8601) */\n lastRetryAt: string;\n /** Source chain name */\n sourceChain: string;\n /** Source transaction hash */\n sourceTxHash: string;\n /** When the record was created (ISO 8601) */\n createdAt: string;\n }> | null;\n}\n\nconst ISO_8601_TIMEZONE_DESIGNATOR_REGEX = /[zZ]|[+-]\\d{2}:?\\d{2}$/;\n\n// Markr API returns ISO-8601 datetime strings that are sometimes missing a timezone designator (\"local\" ISO).\n// We assume these are meant to be UTC and append 'Z' if missing, then validate as strict ISO-8601 with timezone.\nconst datetime = z.iso\n .datetime({ local: true })\n .refine(\n (value) => {\n // Accept at least local ISO format\n // If missing timezone, treat as UTC\n const hasTimezone = ISO_8601_TIMEZONE_DESIGNATOR_REGEX.test(value);\n const isoString = hasTimezone ? value : `${value}Z`;\n // Validate as strict ISO-8601 with timezone\n return z.iso.datetime().safeParse(isoString).success;\n },\n {\n error: 'Invalid ISO-8601 datetime (must be valid with timezone, or local assumed UTC)',\n },\n )\n .transform((value) => {\n const hasTimezone = ISO_8601_TIMEZONE_DESIGNATOR_REGEX.test(value);\n return hasTimezone ? value : `${value}Z`;\n });\n\nexport const CrossChainStatusResponseSchema: z.ZodType<CrossChainStatusResponse> = z.object({\n messageId: z.string().nullable(),\n status: z.enum(['pending', 'committed', 'pending_execution', 'completed', 'failed', 'refunded', 'unknown']),\n description: z.string(),\n sourceChain: z.object({\n name: z.string(),\n transactionHash: z.union([HashSchema, SolSignatureSchema]),\n timestamp: datetime,\n finalized: datetime.or(z.boolean()).nullable(),\n }),\n destinationChain: z.object({\n name: z.string().nullable(),\n transactionHash: z.union([HashSchema, SolSignatureSchema]).nullable(),\n bridgeHash: z.union([HashSchema, SolSignatureSchema]).nullable().optional(),\n timestamp: datetime.nullable(),\n finalized: datetime.nullable(),\n }),\n progress: z.object({\n committed: z.boolean(),\n commitTimestamp: datetime.nullable().optional(),\n executed: z.boolean(),\n }),\n fees: z\n .object({\n token: z.union([EvmAddressSchema, SolAddressSchema]).nullable(),\n amount: z.coerce.bigint().nonnegative().nullable(),\n })\n .nullable(),\n transferredTokens: z.array(\n z.object({\n token: z.union([EvmAddressSchema, SolAddressSchema]),\n amount: z.coerce.bigint().nonnegative(),\n }),\n ),\n debug: z\n .looseObject({\n messageId: z.string(),\n status: z.string(),\n destinationChain: z.string(),\n destinationTxHash: z.string(),\n relayTxHash: z.string(),\n retryCount: z.number().int().nonnegative(),\n lastRetryAt: z.iso.datetime(),\n sourceChain: z.string(),\n sourceTxHash: z.string(),\n createdAt: z.iso.datetime(),\n })\n .partial()\n .nullable()\n .optional(),\n});\n\nexport interface SpenderAddressResponse {\n address: EvmAddress;\n}\n\nexport const SpenderAddressResponseSchema: z.ZodType<SpenderAddressResponse> = z.object({\n address: EvmAddressSchema,\n});\n"],"mappings":"iJAqEA,MAAa,EAA8CA,EAAAA,EACxD,QAAQ,CACR,OAAQ,GAAUC,EAAAA,eAAe,EAAM,CAAE,CACxC,QAAS,0BACV,CAAC,CACD,UAAW,GAAU,EAAsB,CAExC,EAAwCD,EAAAA,EAAE,OAAO,CACrD,QAASA,EAAAA,EAAE,MAAM,CAACA,EAAAA,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mBA,EAAAA,EAAE,QAAQ,CAC7B,YAAaA,EAAAA,EAAE,QAAQ,CACvB,WAAYA,EAAAA,EAAE,QAAQ,CAAC,KAAK,CAAC,aAAa,CAC1C,YAAaA,EAAAA,EAAE,IAAI,UAAU,CAC7B,YAAaA,EAAAA,EAAE,QAAQ,CACvB,aAAcA,EAAAA,EAAE,QAAQ,CACxB,UAAWA,EAAAA,EAAE,IAAI,UAAU,CAC5B,CAAC,CACD,SAAS,CACT,UAAU,CACV,UAAU,CACd,CAAC,CAMW,EAAkEA,EAAAA,EAAE,OAAO,CACtF,QAASE,EAAAA,iBACV,CAAC"}
|
|
1
|
+
{"version":3,"file":"_schema.cjs","names":["z","isCaip2ChainId","EvmAddressSchema","SolAddressSchema","HyperliquidAddressSchema","HexSchema","HashSchema","SolSignatureSchema"],"sources":["../../../src/transfer-service/markr/_schema.ts"],"sourcesContent":["import type { Signature, Address as SolAddress } from '@solana/kit';\nimport type { Address as EvmAddress, Hash } from 'viem';\nimport { z } from 'zod';\nimport type { Caip2ChainId } from '../../types/caip';\nimport type { Hex } from '../../types/signer';\nimport { isCaip2ChainId } from '../../utils/caip';\nimport {\n EvmAddressSchema,\n HashSchema,\n HexSchema,\n HyperliquidAddressSchema,\n SolAddressSchema,\n SolSignatureSchema,\n} from '../service-schemas';\n\ninterface SupportedChainsResponseItemBase {\n chainId: number | string;\n chainType: string;\n /** Available services on the chain. Each service has specific functionality */\n enabled_services: Array<'cross-chain-swap' | 'cross-chain-quote' | 'quote' | 'swap' | 'token-list'>;\n /** Chain logo URL */\n logo_url: string;\n /** Chain display name */\n name: string;\n /**\n * List of chain IDs that this chain can swap to via cross-chain aggregators.\n *\n * Empty array means no cross-chain routes available.\n */\n lanes: ReadonlyArray<number | Caip2ChainId>;\n}\n\nexport interface SupportedChainsResponseItemEvm extends SupportedChainsResponseItemBase {\n /** Chain identifier */\n chainId: number;\n /** Chain virtual machine type */\n chainType: 'evm';\n /** Router contract address */\n router?: EvmAddress;\n /** Native token wrapped contract address */\n wrapped_token?: EvmAddress;\n /**\n * Recurring-swap (DCA) capability metadata for this chain. Absent when the\n * orchestrator does not enable recurring swaps for the chain.\n *\n * @see https://orchestrator-docs.markr.io/#/Recurring%20Swaps\n */\n recurring?: {\n /** Lower bound for `intervalSeconds` accepted by `/recurring/quote`. */\n minFrequencySeconds: number;\n };\n}\n\nexport interface SupportedChainsResponseItemSvm extends SupportedChainsResponseItemBase {\n /** Chain identifier */\n chainId: Caip2ChainId;\n /** Chain virtual machine type */\n chainType: 'svm';\n}\n\nexport type SupportedChainsResponse = Array<\n SupportedChainsResponseItemEvm | SupportedChainsResponseItemSvm | SupportedChainsResponseItemBase\n>;\n\nexport const Caip2ChainIdSchema: z.ZodType<Caip2ChainId> = z\n .string()\n .refine((value) => isCaip2ChainId(value), {\n message: 'Invalid CAIP-2 chain ID',\n })\n .transform((value) => value as Caip2ChainId);\n\nconst SupportedChainsResponseItemBaseSchema = z.object({\n chainId: z.union([z.number(), z.string()]),\n chainType: z.string(),\n enabled_services: z.array(z.enum(['cross-chain-swap', 'cross-chain-quote', 'quote', 'swap', 'token-list'])),\n logo_url: z.url(),\n name: z.string(),\n lanes: z.array(z.union([z.coerce.number().int().nonnegative(), Caip2ChainIdSchema])),\n});\n\nconst SupportedChainsResponseItemEvmSchema: z.ZodType<SupportedChainsResponseItemEvm> =\n SupportedChainsResponseItemBaseSchema.extend({\n chainId: z.coerce.number().int().nonnegative(),\n chainType: z.literal('evm'),\n router: EvmAddressSchema.optional(),\n wrapped_token: EvmAddressSchema.optional(),\n recurring: z\n .object({\n minFrequencySeconds: z.number().int().nonnegative(),\n })\n .optional(),\n });\n\nconst SupportedChainsResponseItemSvmSchema: z.ZodType<SupportedChainsResponseItemSvm> =\n SupportedChainsResponseItemBaseSchema.extend({\n chainId: z\n .string()\n .refine((value) => isCaip2ChainId(value) && value.startsWith('solana:'), {\n error: 'Is not a valid Solana CAIP-2 ID',\n })\n .transform((value) => value as Caip2ChainId),\n chainType: z.literal('svm'),\n });\n\n/**\n * Schema for the response from Markr's /info/chains endpoint.\n *\n * @see https://orchestrator-docs.markr.io/#/paths/~1info~1chains/get\n */\nexport const SupportedChainsResponseSchema: z.ZodType<SupportedChainsResponse> = z.array(\n z.union([\n SupportedChainsResponseItemEvmSchema,\n SupportedChainsResponseItemSvmSchema,\n SupportedChainsResponseItemBaseSchema.refine(\n (item) => item.chainType !== 'evm' && item.chainType !== 'svm',\n 'Known chain types must match their expected schema',\n ),\n ]),\n);\n\nexport type TokenListResponse = Array<{\n address: EvmAddress;\n decimals: number;\n logo_url: string;\n name: string;\n symbol: string;\n}>;\n\n/**\n * Schema for the response Markr's /tokens/{chainId}/list endpoint.\n *\n * @see https://orchestrator-docs.markr.io/#/paths/~1tokens~1%7BchainId%7D~1list/get\n */\nexport const TokenListResponseSchema: z.ZodType<TokenListResponse> = z.array(\n z.object({\n address: EvmAddressSchema,\n decimals: z.number().int().nonnegative().max(18),\n logo_url: z.url(),\n name: z.string(),\n symbol: z.string(),\n }),\n);\n\nexport interface QuoteResponseData {\n aggregator: {\n id: string;\n logo_url: string;\n name: string;\n };\n amountIn: bigint;\n amountOut: bigint;\n /** Chain identifier (number for EVM chains, CAIP-2 ID for SVM chains) */\n chainId: number | Caip2ChainId;\n expiredAt: number;\n /**\n * Fee breakdown for cross-chain bridge transactions.\n *\n * Only included in quotes from cross-chain aggregators (DeBridge, LiFi).\n */\n fees?: ReadonlyArray<{\n type: 'protocol' | 'gas' | 'bridge' | 'slippage' | 'swap' | 'other' | 'relay';\n /** Human-readable fee name */\n name: string;\n /** Fee amount in token's smallest unit */\n amount: bigint;\n /**\n * Docs document `extra` as `boolean or object`. The boolean form is the\n * legacy \"additive one-time charge\" flag; the object form is reserved\n * for future structured metadata. Consumers should treat any truthy\n * value as \"this fee is on top of the input amount and must be balance-\n * checked separately.\"\n */\n extra?: boolean | Record<string, unknown>;\n /** Token the fee is deducted from */\n token: {\n /** Chain ID where fee is deducted */\n chainId: number | Caip2ChainId;\n /** Token address (EVM hex or Solana base58) */\n address: EvmAddress | SolAddress;\n };\n }>;\n gasEstimate?: bigint;\n recommendedSlippage: number;\n /** Input token address (EVM hex or Solana base58) */\n tokenIn: EvmAddress | SolAddress;\n tokenInDecimals: number;\n /** Output token address (EVM hex or Solana base58) */\n tokenOut: EvmAddress | SolAddress;\n tokenOutDecimals: number;\n uuid: string;\n}\n\nexport interface QuoteResponseDataDone {\n done: true;\n}\n\nexport type QuoteResponse = QuoteResponseData | QuoteResponseDataDone;\n\nconst MarkrQuoteTokenAddressSchema = z.union([EvmAddressSchema, SolAddressSchema, HyperliquidAddressSchema]);\n\n/**\n * Schema for the response from Markr's /quote endpoint.\n *\n * @see https://orchestrator-docs.markr.io/#/paths/~1quote/post\n */\nexport const QuoteResponseSchema: z.ZodType<QuoteResponse> = z.union([\n z.object({\n aggregator: z.object({\n id: z.string(),\n logo_url: z.url(),\n name: z.string(),\n }),\n amountIn: z.coerce.bigint().nonnegative(),\n amountOut: z.coerce.bigint().nonnegative(),\n chainId: z.union([z.number().int().nonnegative(), Caip2ChainIdSchema]),\n /**\n * Unix time in seconds when the quote expires.\n */\n expiredAt: z.number().int().nonnegative(),\n fees: z\n .array(\n z.object({\n type: z.enum(['protocol', 'gas', 'bridge', 'slippage', 'swap', 'other', 'relay']),\n name: z.string(),\n amount: z.coerce.bigint().nonnegative(),\n token: z.object({\n chainId: z.union([z.number().int().nonnegative(), Caip2ChainIdSchema]),\n address: MarkrQuoteTokenAddressSchema,\n }),\n // Docs: `extra: boolean or object` — accept both. The boolean form\n // is the legacy \"is this an additive one-time charge\" flag; the\n // object form is reserved for future structured metadata.\n extra: z.union([z.boolean(), z.record(z.string(), z.unknown())]).optional(),\n }),\n )\n .optional(),\n /**\n * Estimated gas for the swap transaction.\n * Markr estimates already include a buffer.\n *\n * The API docs do not specify this field as optional, but in practice it can be missing.\n */\n gasEstimate: z.coerce.bigint().nonnegative().optional(),\n /** Recommended slippage in basis points. */\n recommendedSlippage: z.number().int().nonnegative(),\n tokenIn: MarkrQuoteTokenAddressSchema,\n tokenInDecimals: z.number().int().nonnegative().max(18),\n tokenOut: MarkrQuoteTokenAddressSchema,\n tokenOutDecimals: z.number().int().nonnegative().max(18),\n uuid: z.uuid(),\n }),\n z.object({\n done: z.literal(true),\n }),\n]);\n\n/**\n * Response type for Markr's /swap, /recurring/swap, and\n * /recurring/orders/{orderId}/cancel endpoints — all return the same\n * `WrappedTransaction` calldata shape per the orchestrator docs.\n *\n * @see https://orchestrator-docs.markr.io/#/paths/~1swap/post\n */\nexport interface WrappedSwapTransactionResponse {\n data: Hex;\n to: EvmAddress;\n value: bigint;\n /**\n * Sender address per the docs' `WrappedTransaction` schema. Optional in\n * the SDK because the caller (the wallet broadcasting the TX) already\n * knows their own from-address and the field has historically been\n * dropped on parse without consumer impact.\n */\n from?: EvmAddress;\n}\n\nexport const WrappedSwapTransactionResponseSchema: z.ZodType<WrappedSwapTransactionResponse> = z.object({\n data: HexSchema,\n to: EvmAddressSchema,\n value: z.coerce.bigint().nonnegative(),\n from: EvmAddressSchema.optional(),\n});\n\n/**\n * Solana swap transaction (returned for SVM chains).\n */\nexport interface SolanaSwapTransactionResponse {\n /** Chain type identifier */\n chainType: 'svm';\n /** Base64-encoded Solana transaction to be signed and sent by the client */\n swapTransaction: string;\n}\n\nexport const SolanaSwapTransactionResponseSchema: z.ZodType<SolanaSwapTransactionResponse> = z.object({\n chainType: z.literal('svm'),\n swapTransaction: z.base64(),\n});\n\n/**\n * `sendAsset` action parameters Relay produces for the deposit step.\n *\n * These are the exact strings the SDK must (a) include in the EIP-712 message\n * it signs and (b) submit verbatim as the `action` body to HL `/exchange`.\n * Keeping them pre-formatted by Relay (rather than reconstructed by the SDK)\n * eliminates drift — notably on `amount`, which Relay formats at the spot\n * token's display precision (e.g. `\"0.200000\"` for USDC, not the perps-side\n * `\"0.20000000\"`). Any mismatch between what we sign / submit and what Relay\n * recorded in the order makes Relay's indexer skip the on-chain `sendAsset`.\n */\nexport interface HyperliquidSendAssetParameters {\n /** `\"Mainnet\"` or `\"Testnet\"`. */\n hyperliquidChain: string;\n /** Relay's HL custodian — where the sendAsset transfers to. */\n destination: EvmAddress;\n /** Currently always `\"\"` for non-DEX withdrawals. */\n sourceDex: string;\n /** Currently always `\"\"` for non-DEX withdrawals. */\n destinationDex: string;\n /** HL `\"{symbol}:{spotEvmContract}\"` (e.g. `\"USDC:0x6d1e…054\"`). */\n token: string;\n /** Human-readable decimal, Relay-formatted at the spot token's display precision. */\n amount: string;\n /** Currently always `\"\"` for non-sub-account withdrawals. */\n fromSubAccount: string;\n}\n\nconst HyperliquidSendAssetParametersSchema: z.ZodType<HyperliquidSendAssetParameters> = z.object({\n hyperliquidChain: z.string().min(1),\n destination: EvmAddressSchema,\n sourceDex: z.string(),\n destinationDex: z.string(),\n token: z.string().min(1),\n amount: z.string().regex(/^\\d+(\\.\\d+)?$/, 'amount must be a positive decimal string'),\n fromSubAccount: z.string(),\n});\n\n/**\n * Pass-through EIP-712 envelope Relay returns inside the v2 swap response.\n *\n * The SDK no longer hardcodes Relay's `RelayNonceMapping` schema — instead it\n * forwards `domain` / `types` / `primaryType` / `value` to the wallet's typed-\n * data signer verbatim. Future Relay-side schema additions (e.g. `depositor`\n * was added in v2) propagate automatically without an SDK release.\n */\nexport interface RelayEip712SignEnvelope {\n signatureKind: 'eip712';\n domain: {\n name: string;\n version: string;\n chainId: number;\n verifyingContract: EvmAddress;\n };\n types: Record<string, ReadonlyArray<{ name: string; type: string }>>;\n primaryType: string;\n /** Relay binds at minimum these fields; additional keys (e.g. `depositor`) are forwarded verbatim. */\n value: {\n wallet: EvmAddress;\n chainId: string;\n id: Hex;\n nonce: number;\n [key: string]: unknown;\n };\n}\n\nconst RelayEip712SignEnvelopeSchema: z.ZodType<RelayEip712SignEnvelope> = z.object({\n signatureKind: z.literal('eip712'),\n domain: z.object({\n name: z.string().min(1),\n version: z.string().min(1),\n chainId: z.number().int().nonnegative(),\n verifyingContract: EvmAddressSchema,\n }),\n types: z.record(z.string(), z.array(z.object({ name: z.string(), type: z.string() }))),\n primaryType: z.string().min(1),\n value: z\n .object({\n wallet: EvmAddressSchema,\n chainId: z.string().min(1),\n id: HashSchema,\n nonce: z.number().int().nonnegative(),\n })\n .loose(),\n});\n\n/**\n * Pass-through `/authorize` POST body Relay returns inside the v2 swap response.\n *\n * The SDK forwards `body` verbatim to Markr (which forwards verbatim to Relay).\n * Markr only normalizes `nonce` to a JSON number on the wire; everything else\n * is untouched, so new fields Relay adds are not rejected.\n */\nexport interface RelayAuthorizeEnvelope {\n endpoint: string;\n method: string;\n body: {\n type: string;\n id: Hex;\n nonce: number;\n wallet: EvmAddress;\n walletChainId: number;\n signatureChainId: number;\n [key: string]: unknown;\n };\n}\n\nconst RelayAuthorizeEnvelopeSchema: z.ZodType<RelayAuthorizeEnvelope> = z.object({\n endpoint: z.string().min(1),\n method: z.string().min(1),\n body: z\n .object({\n type: z.string().min(1),\n id: HashSchema,\n nonce: z.number().int().nonnegative(),\n wallet: EvmAddressSchema,\n walletChainId: z.number().int().nonnegative(),\n signatureChainId: z.number().int().nonnegative(),\n })\n .loose(),\n});\n\n/**\n * Hyperliquid 2-phase withdrawal variant (source chain = `eip155:1337`).\n *\n * Markr returns:\n * - the dynamic envelope (`nonce`, `id`, `requestId`) used for the authorize\n * signature and status polling, and\n * - the full `parameters` object Relay produced for the deposit step's\n * `sendAsset` action, which the SDK signs verbatim and submits to HL.\n *\n * Starting at `protocolVersion: 2`, Relay's full EIP-712 envelope (`sign`) and\n * the `/authorize` POST body (`authorize`) are passed through verbatim — the\n * SDK no longer reconstructs Relay's schemas, so additive Relay changes (e.g.\n * `depositor` field) flow through without an SDK release.\n *\n * Important: `id` and `requestId` are TWO DIFFERENT bytes32s.\n * - `id` is the **order id** — it goes into the EIP-712 `NonceMapping`\n * message and Relay's `/authorize` POST body. Sourced from\n * `steps[0].items[0].data.sign.value.id` (== `data.post.body.id` ==\n * `protocol.v2.orderId`).\n * - `requestId` is the **tracking id** used only for\n * `/intents/status/v3?requestId=…` polling. Sourced from\n * `steps[0].requestId`.\n *\n * Swapping these two looks superficially correct (both are `0x{64hex}`) but\n * makes the on-chain `sendAsset` un-matchable by Relay's indexer.\n *\n * The SDK pins the static HL-side `SendAsset` shape (which HL owns) as a\n * constant in `_hyperliquid-eip712.ts`. Relay's nonce-mapping shape is now\n * dynamic via the `sign` envelope.\n */\nexport interface HyperliquidWithdrawSwapResponse {\n type: 'hyperliquid-withdraw';\n /** SDK validates against `SUPPORTED_HL_PROTOCOL_VERSIONS`; bumps when Relay/HL EIP-712 schemas change. */\n protocolVersion: number;\n /** Shared between authorize + sendAsset signatures; uint64 decimal string. */\n nonce: string;\n /** Order id signed inside the `NonceMapping` message and posted to `/authorize`. */\n id: Hex;\n /** Tracking id for cross-chain status polling (`/intents/status/v3?requestId=…`). */\n requestId: Hex;\n /** Relay-canonical `sendAsset` action parameters; signed and submitted verbatim. */\n parameters: HyperliquidSendAssetParameters;\n /** Relay's full EIP-712 nonce-mapping envelope. v2+. */\n sign?: RelayEip712SignEnvelope;\n /** Relay's `/authorize` POST descriptor (we forward `body` verbatim). v2+. */\n authorize?: RelayAuthorizeEnvelope;\n}\n\nexport const HyperliquidWithdrawSwapResponseSchema: z.ZodType<HyperliquidWithdrawSwapResponse> = z.object({\n type: z.literal('hyperliquid-withdraw'),\n protocolVersion: z.number().int().positive(),\n nonce: z.string().regex(/^\\d+$/, 'nonce must be a decimal string'),\n id: HashSchema,\n requestId: HashSchema,\n parameters: HyperliquidSendAssetParametersSchema,\n sign: RelayEip712SignEnvelopeSchema.optional(),\n authorize: RelayAuthorizeEnvelopeSchema.optional(),\n});\n\nexport type SwapResponse =\n | WrappedSwapTransactionResponse\n | SolanaSwapTransactionResponse\n | HyperliquidWithdrawSwapResponse;\n\nexport const SwapResponseSchema: z.ZodType<SwapResponse> = z.union([\n WrappedSwapTransactionResponseSchema,\n SolanaSwapTransactionResponseSchema,\n HyperliquidWithdrawSwapResponseSchema,\n]);\n\n/**\n * Markr `/authorize` response.\n *\n * The success body is documented as opaque, so we only assert that:\n * 1. the parsed JSON isn't an error envelope (`{ error: \"...\" }`) — Markr's\n * upstream (Relay) can return a 200 with an error payload when the\n * authorize is rejected after HTTP success;\n * 2. nothing else, by design — schema bumps when Markr publishes a spec.\n */\nexport const MarkrAuthorizeResponseSchema: z.ZodType<unknown> = z\n .unknown()\n .refine(\n (data) =>\n !(\n data !== null &&\n typeof data === 'object' &&\n 'error' in data &&\n typeof (data as { error: unknown }).error === 'string'\n ),\n { message: 'Markr /authorize returned an error envelope despite 2xx status.' },\n );\n\nexport interface PartnerInfoResponse {\n /**\n * The partner fee in basis points collected on each swap.\n */\n fee: number;\n name: string;\n}\n\nexport const PartnerInfoResponseSchema: z.ZodType<PartnerInfoResponse> = z.object({\n fee: z.int().nonnegative(),\n name: z.string(),\n});\n\n/**\n * If the destination token is USDC, the flow is:\n * - pending -> committed -> completed\n *\n * If the destination token is not USDC, the flow is:\n * - pending -> committed -> pending_execution -> completed\n *\n * If the transaction fails at any point, the status will be 'failed'.\n */\nexport type CrossChainStatus =\n | /** Transaction submitted to CCIP */\n 'pending'\n /** Message committed, awaiting execution on destination chain */\n | 'committed'\n /** Message received on destination, swap pending execution by relayer */\n | 'pending_execution'\n /** Message executed successfully on destination chain */\n | 'completed'\n /** Swap expired, and funds were refunded (CCIP only) */\n | 'refunded'\n /** Execution failed */\n | 'failed'\n /** Unknown state */\n | 'unknown';\n\nexport interface CrossChainStatusResponse {\n /**\n * Cross-chain transaction identifier.\n *\n * For CCIP: The CCIP message ID.\n * For DeBridge: The DeBridge order ID.\n */\n messageId: string | null;\n /** Current status of the cross-chain transaction. */\n status: CrossChainStatus;\n /** Human-readable status description */\n description: string;\n /** Source chain information */\n sourceChain: {\n /** Source chain network name */\n name: string;\n /** Source chain transaction hash */\n transactionHash: Hash | Signature;\n /** Transaction timestamp on source chain (ISO 8601) */\n timestamp: string;\n /** When the source transaction was finalized (ISO 8601) */\n finalized: string | boolean | null;\n };\n /** Destination chain information */\n destinationChain: {\n /** Destination chain network name */\n name: string | null;\n /**\n * Destination chain tx hash.\n *\n * - For direct transfers (USDC -> USDC): The CCIP bridge transaction hash.\n * - For successful swaps: The actual swap transaction hash from the relayer.\n * - For pending swaps: null (swap not yet executed).\n */\n transactionHash: Hash | Signature | null;\n /**\n * CCIP bridge tx hash (only present for swaps, not direct transfers).\n *\n * This is the transaction that delivered USDC to the destination chain via CCIP.\n * The `transactionHash` field contains the subsequent swap transaction.\n */\n bridgeHash?: Hash | Signature | null;\n /** Transaction timestamp on destination chain (null if not yet executed) (ISO 8601) */\n timestamp: string | null;\n /** When the destination transaction was finalized (null if not yet executed) (ISO 8601) */\n finalized: string | null;\n };\n /** Transaction progress information */\n progress: {\n /** Whether the message has been committed on destination chain */\n committed: boolean;\n /** When the message was committed (null if not committed) (ISO 8601) */\n commitTimestamp?: string | null;\n /** Whether the message has been executed on destination chain */\n executed: boolean;\n };\n /** Fee information */\n fees: {\n /** Fee token address */\n token: EvmAddress | SolAddress | null;\n /** Fee amount in wei */\n amount: bigint | null;\n } | null;\n /** Tokens transferred in this cross-chain transaction */\n transferredTokens: ReadonlyArray<{\n /** Token address */\n token: EvmAddress | SolAddress;\n /** Token amount */\n amount: bigint;\n }>;\n /**\n * Debug information from Markr transaction API (only present for swaps that have been executed).\n *\n * Contains detailed information about the relayer execution, retry attempts, and transaction details.\n */\n debug?: Partial<{\n /** CCIP message ID */\n messageId: string;\n /** Execution status from relayer */\n status: string;\n /** Destination chain name */\n destinationChain: string;\n /** Destination swap transaction hash */\n destinationTxHash: string;\n /** Relay transaction hash */\n relayTxHash: string;\n /** Number of retry attempts */\n retryCount: number;\n /** Timestamp of last retry attempt (ISO 8601) */\n lastRetryAt: string;\n /** Source chain name */\n sourceChain: string;\n /** Source transaction hash */\n sourceTxHash: string;\n /** When the record was created (ISO 8601) */\n createdAt: string;\n }> | null;\n}\n\nconst ISO_8601_TIMEZONE_DESIGNATOR_REGEX = /[zZ]|[+-]\\d{2}:?\\d{2}$/;\n\n// Markr API returns ISO-8601 datetime strings that are sometimes missing a timezone designator (\"local\" ISO).\n// We assume these are meant to be UTC and append 'Z' if missing, then validate as strict ISO-8601 with timezone.\nconst datetime = z.iso\n .datetime({ local: true })\n .refine(\n (value) => {\n // Accept at least local ISO format\n // If missing timezone, treat as UTC\n const hasTimezone = ISO_8601_TIMEZONE_DESIGNATOR_REGEX.test(value);\n const isoString = hasTimezone ? value : `${value}Z`;\n // Validate as strict ISO-8601 with timezone\n return z.iso.datetime().safeParse(isoString).success;\n },\n {\n error: 'Invalid ISO-8601 datetime (must be valid with timezone, or local assumed UTC)',\n },\n )\n .transform((value) => {\n const hasTimezone = ISO_8601_TIMEZONE_DESIGNATOR_REGEX.test(value);\n return hasTimezone ? value : `${value}Z`;\n });\n\nexport const CrossChainStatusResponseSchema: z.ZodType<CrossChainStatusResponse> = z.object({\n messageId: z.string().nullable(),\n status: z.enum(['pending', 'committed', 'pending_execution', 'completed', 'failed', 'refunded', 'unknown']),\n description: z.string(),\n sourceChain: z.object({\n name: z.string(),\n transactionHash: z.union([HashSchema, SolSignatureSchema]),\n timestamp: datetime,\n finalized: datetime.or(z.boolean()).nullable(),\n }),\n destinationChain: z.object({\n name: z.string().nullable(),\n transactionHash: z.union([HashSchema, SolSignatureSchema]).nullable(),\n bridgeHash: z.union([HashSchema, SolSignatureSchema]).nullable().optional(),\n timestamp: datetime.nullable(),\n finalized: datetime.nullable(),\n }),\n progress: z.object({\n committed: z.boolean(),\n commitTimestamp: datetime.nullable().optional(),\n executed: z.boolean(),\n }),\n fees: z\n .object({\n token: z.union([EvmAddressSchema, SolAddressSchema]).nullable(),\n amount: z.coerce.bigint().nonnegative().nullable(),\n })\n .nullable(),\n transferredTokens: z.array(\n z.object({\n token: z.union([EvmAddressSchema, SolAddressSchema]),\n amount: z.coerce.bigint().nonnegative(),\n }),\n ),\n debug: z\n .looseObject({\n messageId: z.string(),\n status: z.string(),\n destinationChain: z.string(),\n destinationTxHash: z.string(),\n relayTxHash: z.string(),\n retryCount: z.number().int().nonnegative(),\n lastRetryAt: z.iso.datetime(),\n sourceChain: z.string(),\n sourceTxHash: z.string(),\n createdAt: z.iso.datetime(),\n })\n .partial()\n .nullable()\n .optional(),\n});\n\nexport interface SpenderAddressResponse {\n address: EvmAddress;\n}\n\nexport const SpenderAddressResponseSchema: z.ZodType<SpenderAddressResponse> = z.object({\n address: EvmAddressSchema,\n});\n"],"mappings":"iJAgEA,MAAa,EAA8CA,EAAAA,EACxD,QAAQ,CACR,OAAQ,GAAUC,EAAAA,eAAe,EAAM,CAAE,CACxC,QAAS,0BACV,CAAC,CACD,UAAW,GAAU,EAAsB,CAExC,EAAwCD,EAAAA,EAAE,OAAO,CACrD,QAASA,EAAAA,EAAE,MAAM,CAACA,EAAAA,EAAE,QAAQ,CAAEA,EAAAA,EAAE,QAAQ,CAAC,CAAC,CAC1C,UAAWA,EAAAA,EAAE,QAAQ,CACrB,iBAAkBA,EAAAA,EAAE,MAAMA,EAAAA,EAAE,KAAK,CAAC,mBAAoB,oBAAqB,QAAS,OAAQ,aAAa,CAAC,CAAC,CAC3G,SAAUA,EAAAA,EAAE,KAAK,CACjB,KAAMA,EAAAA,EAAE,QAAQ,CAChB,MAAOA,EAAAA,EAAE,MAAMA,EAAAA,EAAE,MAAM,CAACA,EAAAA,EAAE,OAAO,QAAQ,CAAC,KAAK,CAAC,aAAa,CAAE,EAAmB,CAAC,CAAC,CACrF,CAAC,CAEI,EACJ,EAAsC,OAAO,CAC3C,QAASA,EAAAA,EAAE,OAAO,QAAQ,CAAC,KAAK,CAAC,aAAa,CAC9C,UAAWA,EAAAA,EAAE,QAAQ,MAAM,CAC3B,OAAQE,EAAAA,iBAAiB,UAAU,CACnC,cAAeA,EAAAA,iBAAiB,UAAU,CAC1C,UAAWF,EAAAA,EACR,OAAO,CACN,oBAAqBA,EAAAA,EAAE,QAAQ,CAAC,KAAK,CAAC,aAAa,CACpD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UAAU,CACnD,CAAC,CACD,UAAU,CACb,kBAAmBA,EAAAA,EAAE,MACnBA,EAAAA,EAAE,OAAO,CACP,MAAOA,EAAAA,EAAE,MAAM,CAACE,EAAAA,iBAAkBC,EAAAA,iBAAiB,CAAC,CACpD,OAAQH,EAAAA,EAAE,OAAO,QAAQ,CAAC,aAAa,CACxC,CAAC,CACH,CACD,MAAOA,EAAAA,EACJ,YAAY,CACX,UAAWA,EAAAA,EAAE,QAAQ,CACrB,OAAQA,EAAAA,EAAE,QAAQ,CAClB,iBAAkBA,EAAAA,EAAE,QAAQ,CAC5B,kBAAmBA,EAAAA,EAAE,QAAQ,CAC7B,YAAaA,EAAAA,EAAE,QAAQ,CACvB,WAAYA,EAAAA,EAAE,QAAQ,CAAC,KAAK,CAAC,aAAa,CAC1C,YAAaA,EAAAA,EAAE,IAAI,UAAU,CAC7B,YAAaA,EAAAA,EAAE,QAAQ,CACvB,aAAcA,EAAAA,EAAE,QAAQ,CACxB,UAAWA,EAAAA,EAAE,IAAI,UAAU,CAC5B,CAAC,CACD,SAAS,CACT,UAAU,CACV,UAAU,CACd,CAAC,CAMW,EAAkEA,EAAAA,EAAE,OAAO,CACtF,QAASE,EAAAA,iBACV,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{isCaip2ChainId as e}from"../../utils/caip.js";import{EvmAddressSchema as t,HashSchema as n,HexSchema as r,HyperliquidAddressSchema as i,SolAddressSchema as a,SolSignatureSchema as o}from"../service-schemas.js";import{z as s}from"zod";const c=s.string().refine(t=>e(t),{message:`Invalid CAIP-2 chain ID`}).transform(e=>e),l=s.object({chainId:s.union([s.number(),s.string()]),chainType:s.string(),enabled_services:s.array(s.enum([`cross-chain-swap`,`cross-chain-quote`,`quote`,`swap`,`token-list`])),logo_url:s.url(),name:s.string(),lanes:s.array(s.union([s.coerce.number().int().nonnegative(),c]))}),u=l.extend({chainId:s.coerce.number().int().nonnegative(),chainType:s.literal(`evm`),router:t.optional(),wrapped_token:t.optional(),recurring:s.object({minFrequencySeconds:s.number().int().nonnegative()
|
|
1
|
+
import{isCaip2ChainId as e}from"../../utils/caip.js";import{EvmAddressSchema as t,HashSchema as n,HexSchema as r,HyperliquidAddressSchema as i,SolAddressSchema as a,SolSignatureSchema as o}from"../service-schemas.js";import{z as s}from"zod";const c=s.string().refine(t=>e(t),{message:`Invalid CAIP-2 chain ID`}).transform(e=>e),l=s.object({chainId:s.union([s.number(),s.string()]),chainType:s.string(),enabled_services:s.array(s.enum([`cross-chain-swap`,`cross-chain-quote`,`quote`,`swap`,`token-list`])),logo_url:s.url(),name:s.string(),lanes:s.array(s.union([s.coerce.number().int().nonnegative(),c]))}),u=l.extend({chainId:s.coerce.number().int().nonnegative(),chainType:s.literal(`evm`),router:t.optional(),wrapped_token:t.optional(),recurring:s.object({minFrequencySeconds:s.number().int().nonnegative()}).optional()}),d=l.extend({chainId:s.string().refine(t=>e(t)&&t.startsWith(`solana:`),{error:`Is not a valid Solana CAIP-2 ID`}).transform(e=>e),chainType:s.literal(`svm`)}),f=s.array(s.union([u,d,l.refine(e=>e.chainType!==`evm`&&e.chainType!==`svm`,`Known chain types must match their expected schema`)])),p=s.array(s.object({address:t,decimals:s.number().int().nonnegative().max(18),logo_url:s.url(),name:s.string(),symbol:s.string()})),m=s.union([t,a,i]),h=s.union([s.object({aggregator:s.object({id:s.string(),logo_url:s.url(),name:s.string()}),amountIn:s.coerce.bigint().nonnegative(),amountOut:s.coerce.bigint().nonnegative(),chainId:s.union([s.number().int().nonnegative(),c]),expiredAt:s.number().int().nonnegative(),fees:s.array(s.object({type:s.enum([`protocol`,`gas`,`bridge`,`slippage`,`swap`,`other`,`relay`]),name:s.string(),amount:s.coerce.bigint().nonnegative(),token:s.object({chainId:s.union([s.number().int().nonnegative(),c]),address:m}),extra:s.union([s.boolean(),s.record(s.string(),s.unknown())]).optional()})).optional(),gasEstimate:s.coerce.bigint().nonnegative().optional(),recommendedSlippage:s.number().int().nonnegative(),tokenIn:m,tokenInDecimals:s.number().int().nonnegative().max(18),tokenOut:m,tokenOutDecimals:s.number().int().nonnegative().max(18),uuid:s.uuid()}),s.object({done:s.literal(!0)})]),g=s.object({data:r,to:t,value:s.coerce.bigint().nonnegative(),from:t.optional()}),_=s.object({chainType:s.literal(`svm`),swapTransaction:s.base64()}),v=s.object({hyperliquidChain:s.string().min(1),destination:t,sourceDex:s.string(),destinationDex:s.string(),token:s.string().min(1),amount:s.string().regex(/^\d+(\.\d+)?$/,`amount must be a positive decimal string`),fromSubAccount:s.string()}),y=s.object({signatureKind:s.literal(`eip712`),domain:s.object({name:s.string().min(1),version:s.string().min(1),chainId:s.number().int().nonnegative(),verifyingContract:t}),types:s.record(s.string(),s.array(s.object({name:s.string(),type:s.string()}))),primaryType:s.string().min(1),value:s.object({wallet:t,chainId:s.string().min(1),id:n,nonce:s.number().int().nonnegative()}).loose()}),b=s.object({endpoint:s.string().min(1),method:s.string().min(1),body:s.object({type:s.string().min(1),id:n,nonce:s.number().int().nonnegative(),wallet:t,walletChainId:s.number().int().nonnegative(),signatureChainId:s.number().int().nonnegative()}).loose()}),x=s.object({type:s.literal(`hyperliquid-withdraw`),protocolVersion:s.number().int().positive(),nonce:s.string().regex(/^\d+$/,`nonce must be a decimal string`),id:n,requestId:n,parameters:v,sign:y.optional(),authorize:b.optional()}),S=s.union([g,_,x]),C=s.unknown().refine(e=>!(typeof e==`object`&&e&&`error`in e&&typeof e.error==`string`),{message:`Markr /authorize returned an error envelope despite 2xx status.`}),w=s.object({fee:s.int().nonnegative(),name:s.string()}),T=/[zZ]|[+-]\d{2}:?\d{2}$/,E=s.iso.datetime({local:!0}).refine(e=>{let t=T.test(e)?e:`${e}Z`;return s.iso.datetime().safeParse(t).success},{error:`Invalid ISO-8601 datetime (must be valid with timezone, or local assumed UTC)`}).transform(e=>T.test(e)?e:`${e}Z`),D=s.object({messageId:s.string().nullable(),status:s.enum([`pending`,`committed`,`pending_execution`,`completed`,`failed`,`refunded`,`unknown`]),description:s.string(),sourceChain:s.object({name:s.string(),transactionHash:s.union([n,o]),timestamp:E,finalized:E.or(s.boolean()).nullable()}),destinationChain:s.object({name:s.string().nullable(),transactionHash:s.union([n,o]).nullable(),bridgeHash:s.union([n,o]).nullable().optional(),timestamp:E.nullable(),finalized:E.nullable()}),progress:s.object({committed:s.boolean(),commitTimestamp:E.nullable().optional(),executed:s.boolean()}),fees:s.object({token:s.union([t,a]).nullable(),amount:s.coerce.bigint().nonnegative().nullable()}).nullable(),transferredTokens:s.array(s.object({token:s.union([t,a]),amount:s.coerce.bigint().nonnegative()})),debug:s.looseObject({messageId:s.string(),status:s.string(),destinationChain:s.string(),destinationTxHash:s.string(),relayTxHash:s.string(),retryCount:s.number().int().nonnegative(),lastRetryAt:s.iso.datetime(),sourceChain:s.string(),sourceTxHash:s.string(),createdAt:s.iso.datetime()}).partial().nullable().optional()}),O=s.object({address:t});export{D as CrossChainStatusResponseSchema,C as MarkrAuthorizeResponseSchema,w as PartnerInfoResponseSchema,h as QuoteResponseSchema,O as SpenderAddressResponseSchema,f as SupportedChainsResponseSchema,S as SwapResponseSchema,p as TokenListResponseSchema,g as WrappedSwapTransactionResponseSchema};
|
|
2
2
|
//# sourceMappingURL=_schema.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_schema.js","names":[],"sources":["../../../src/transfer-service/markr/_schema.ts"],"sourcesContent":["import type { Signature, Address as SolAddress } from '@solana/kit';\nimport type { Address as EvmAddress, Hash } from 'viem';\nimport { z } from 'zod';\nimport type { Caip2ChainId } from '../../types/caip';\nimport type { Hex } from '../../types/signer';\nimport { isCaip2ChainId } from '../../utils/caip';\nimport {\n EvmAddressSchema,\n HashSchema,\n HexSchema,\n HyperliquidAddressSchema,\n SolAddressSchema,\n SolSignatureSchema,\n} from '../service-schemas';\n\ninterface SupportedChainsResponseItemBase {\n chainId: number | string;\n chainType: string;\n /** Available services on the chain. Each service has specific functionality */\n enabled_services: Array<'cross-chain-swap' | 'cross-chain-quote' | 'quote' | 'swap' | 'token-list'>;\n /** Chain logo URL */\n logo_url: string;\n /** Chain display name */\n name: string;\n /**\n * List of chain IDs that this chain can swap to via cross-chain aggregators.\n *\n * Empty array means no cross-chain routes available.\n */\n lanes: ReadonlyArray<number | Caip2ChainId>;\n}\n\nexport interface SupportedChainsResponseItemEvm extends SupportedChainsResponseItemBase {\n /** Chain identifier */\n chainId: number;\n /** Chain virtual machine type */\n chainType: 'evm';\n /** Router contract address */\n router?: EvmAddress;\n /** Native token wrapped contract address */\n wrapped_token?: EvmAddress;\n /**\n * Recurring-swap (DCA) capability metadata for this chain. Absent when the\n * orchestrator does not enable recurring swaps for the chain.\n *\n * @see https://orchestrator-docs.markr.io/#/Recurring%20Swaps\n */\n recurring?: {\n /** Lower bound for `intervalSeconds` accepted by `/recurring/quote`. */\n minFrequencySeconds: number;\n supportedTokens: ReadonlyArray<{\n address: EvmAddress;\n /** Smallest-unit decimal string — per-order minimum input. */\n minimumAmount: string;\n }>;\n };\n}\n\nexport interface SupportedChainsResponseItemSvm extends SupportedChainsResponseItemBase {\n /** Chain identifier */\n chainId: Caip2ChainId;\n /** Chain virtual machine type */\n chainType: 'svm';\n}\n\nexport type SupportedChainsResponse = Array<\n SupportedChainsResponseItemEvm | SupportedChainsResponseItemSvm | SupportedChainsResponseItemBase\n>;\n\nexport const Caip2ChainIdSchema: z.ZodType<Caip2ChainId> = z\n .string()\n .refine((value) => isCaip2ChainId(value), {\n message: 'Invalid CAIP-2 chain ID',\n })\n .transform((value) => value as Caip2ChainId);\n\nconst SupportedChainsResponseItemBaseSchema = z.object({\n chainId: z.union([z.number(), z.string()]),\n chainType: z.string(),\n enabled_services: z.array(z.enum(['cross-chain-swap', 'cross-chain-quote', 'quote', 'swap', 'token-list'])),\n logo_url: z.url(),\n name: z.string(),\n lanes: z.array(z.union([z.coerce.number().int().nonnegative(), Caip2ChainIdSchema])),\n});\n\nconst SupportedChainsResponseItemEvmSchema: z.ZodType<SupportedChainsResponseItemEvm> =\n SupportedChainsResponseItemBaseSchema.extend({\n chainId: z.coerce.number().int().nonnegative(),\n chainType: z.literal('evm'),\n router: EvmAddressSchema.optional(),\n wrapped_token: EvmAddressSchema.optional(),\n recurring: z\n .object({\n minFrequencySeconds: z.number().int().nonnegative(),\n supportedTokens: z.array(\n z.object({\n address: EvmAddressSchema,\n // Decimal string — must be `BigInt()`-parseable (see\n // checkRecurringEligibility's `BigInt(minimumAmount)` call).\n minimumAmount: z.string().regex(/^\\d+$/, 'minimumAmount must be a decimal string'),\n }),\n ),\n })\n .optional(),\n });\n\nconst SupportedChainsResponseItemSvmSchema: z.ZodType<SupportedChainsResponseItemSvm> =\n SupportedChainsResponseItemBaseSchema.extend({\n chainId: z\n .string()\n .refine((value) => isCaip2ChainId(value) && value.startsWith('solana:'), {\n error: 'Is not a valid Solana CAIP-2 ID',\n })\n .transform((value) => value as Caip2ChainId),\n chainType: z.literal('svm'),\n });\n\n/**\n * Schema for the response from Markr's /info/chains endpoint.\n *\n * @see https://orchestrator-docs.markr.io/#/paths/~1info~1chains/get\n */\nexport const SupportedChainsResponseSchema: z.ZodType<SupportedChainsResponse> = z.array(\n z.union([\n SupportedChainsResponseItemEvmSchema,\n SupportedChainsResponseItemSvmSchema,\n SupportedChainsResponseItemBaseSchema.refine(\n (item) => item.chainType !== 'evm' && item.chainType !== 'svm',\n 'Known chain types must match their expected schema',\n ),\n ]),\n);\n\nexport type TokenListResponse = Array<{\n address: EvmAddress;\n decimals: number;\n logo_url: string;\n name: string;\n symbol: string;\n}>;\n\n/**\n * Schema for the response Markr's /tokens/{chainId}/list endpoint.\n *\n * @see https://orchestrator-docs.markr.io/#/paths/~1tokens~1%7BchainId%7D~1list/get\n */\nexport const TokenListResponseSchema: z.ZodType<TokenListResponse> = z.array(\n z.object({\n address: EvmAddressSchema,\n decimals: z.number().int().nonnegative().max(18),\n logo_url: z.url(),\n name: z.string(),\n symbol: z.string(),\n }),\n);\n\nexport interface QuoteResponseData {\n aggregator: {\n id: string;\n logo_url: string;\n name: string;\n };\n amountIn: bigint;\n amountOut: bigint;\n /** Chain identifier (number for EVM chains, CAIP-2 ID for SVM chains) */\n chainId: number | Caip2ChainId;\n expiredAt: number;\n /**\n * Fee breakdown for cross-chain bridge transactions.\n *\n * Only included in quotes from cross-chain aggregators (DeBridge, LiFi).\n */\n fees?: ReadonlyArray<{\n type: 'protocol' | 'gas' | 'bridge' | 'slippage' | 'swap' | 'other' | 'relay';\n /** Human-readable fee name */\n name: string;\n /** Fee amount in token's smallest unit */\n amount: bigint;\n /**\n * Docs document `extra` as `boolean or object`. The boolean form is the\n * legacy \"additive one-time charge\" flag; the object form is reserved\n * for future structured metadata. Consumers should treat any truthy\n * value as \"this fee is on top of the input amount and must be balance-\n * checked separately.\"\n */\n extra?: boolean | Record<string, unknown>;\n /** Token the fee is deducted from */\n token: {\n /** Chain ID where fee is deducted */\n chainId: number | Caip2ChainId;\n /** Token address (EVM hex or Solana base58) */\n address: EvmAddress | SolAddress;\n };\n }>;\n gasEstimate?: bigint;\n recommendedSlippage: number;\n /** Input token address (EVM hex or Solana base58) */\n tokenIn: EvmAddress | SolAddress;\n tokenInDecimals: number;\n /** Output token address (EVM hex or Solana base58) */\n tokenOut: EvmAddress | SolAddress;\n tokenOutDecimals: number;\n uuid: string;\n}\n\nexport interface QuoteResponseDataDone {\n done: true;\n}\n\nexport type QuoteResponse = QuoteResponseData | QuoteResponseDataDone;\n\nconst MarkrQuoteTokenAddressSchema = z.union([EvmAddressSchema, SolAddressSchema, HyperliquidAddressSchema]);\n\n/**\n * Schema for the response from Markr's /quote endpoint.\n *\n * @see https://orchestrator-docs.markr.io/#/paths/~1quote/post\n */\nexport const QuoteResponseSchema: z.ZodType<QuoteResponse> = z.union([\n z.object({\n aggregator: z.object({\n id: z.string(),\n logo_url: z.url(),\n name: z.string(),\n }),\n amountIn: z.coerce.bigint().nonnegative(),\n amountOut: z.coerce.bigint().nonnegative(),\n chainId: z.union([z.number().int().nonnegative(), Caip2ChainIdSchema]),\n /**\n * Unix time in seconds when the quote expires.\n */\n expiredAt: z.number().int().nonnegative(),\n fees: z\n .array(\n z.object({\n type: z.enum(['protocol', 'gas', 'bridge', 'slippage', 'swap', 'other', 'relay']),\n name: z.string(),\n amount: z.coerce.bigint().nonnegative(),\n token: z.object({\n chainId: z.union([z.number().int().nonnegative(), Caip2ChainIdSchema]),\n address: MarkrQuoteTokenAddressSchema,\n }),\n // Docs: `extra: boolean or object` — accept both. The boolean form\n // is the legacy \"is this an additive one-time charge\" flag; the\n // object form is reserved for future structured metadata.\n extra: z.union([z.boolean(), z.record(z.string(), z.unknown())]).optional(),\n }),\n )\n .optional(),\n /**\n * Estimated gas for the swap transaction.\n * Markr estimates already include a buffer.\n *\n * The API docs do not specify this field as optional, but in practice it can be missing.\n */\n gasEstimate: z.coerce.bigint().nonnegative().optional(),\n /** Recommended slippage in basis points. */\n recommendedSlippage: z.number().int().nonnegative(),\n tokenIn: MarkrQuoteTokenAddressSchema,\n tokenInDecimals: z.number().int().nonnegative().max(18),\n tokenOut: MarkrQuoteTokenAddressSchema,\n tokenOutDecimals: z.number().int().nonnegative().max(18),\n uuid: z.uuid(),\n }),\n z.object({\n done: z.literal(true),\n }),\n]);\n\n/**\n * Response type for Markr's /swap, /recurring/swap, and\n * /recurring/orders/{orderId}/cancel endpoints — all return the same\n * `WrappedTransaction` calldata shape per the orchestrator docs.\n *\n * @see https://orchestrator-docs.markr.io/#/paths/~1swap/post\n */\nexport interface WrappedSwapTransactionResponse {\n data: Hex;\n to: EvmAddress;\n value: bigint;\n /**\n * Sender address per the docs' `WrappedTransaction` schema. Optional in\n * the SDK because the caller (the wallet broadcasting the TX) already\n * knows their own from-address and the field has historically been\n * dropped on parse without consumer impact.\n */\n from?: EvmAddress;\n}\n\nexport const WrappedSwapTransactionResponseSchema: z.ZodType<WrappedSwapTransactionResponse> = z.object({\n data: HexSchema,\n to: EvmAddressSchema,\n value: z.coerce.bigint().nonnegative(),\n from: EvmAddressSchema.optional(),\n});\n\n/**\n * Solana swap transaction (returned for SVM chains).\n */\nexport interface SolanaSwapTransactionResponse {\n /** Chain type identifier */\n chainType: 'svm';\n /** Base64-encoded Solana transaction to be signed and sent by the client */\n swapTransaction: string;\n}\n\nexport const SolanaSwapTransactionResponseSchema: z.ZodType<SolanaSwapTransactionResponse> = z.object({\n chainType: z.literal('svm'),\n swapTransaction: z.base64(),\n});\n\n/**\n * `sendAsset` action parameters Relay produces for the deposit step.\n *\n * These are the exact strings the SDK must (a) include in the EIP-712 message\n * it signs and (b) submit verbatim as the `action` body to HL `/exchange`.\n * Keeping them pre-formatted by Relay (rather than reconstructed by the SDK)\n * eliminates drift — notably on `amount`, which Relay formats at the spot\n * token's display precision (e.g. `\"0.200000\"` for USDC, not the perps-side\n * `\"0.20000000\"`). Any mismatch between what we sign / submit and what Relay\n * recorded in the order makes Relay's indexer skip the on-chain `sendAsset`.\n */\nexport interface HyperliquidSendAssetParameters {\n /** `\"Mainnet\"` or `\"Testnet\"`. */\n hyperliquidChain: string;\n /** Relay's HL custodian — where the sendAsset transfers to. */\n destination: EvmAddress;\n /** Currently always `\"\"` for non-DEX withdrawals. */\n sourceDex: string;\n /** Currently always `\"\"` for non-DEX withdrawals. */\n destinationDex: string;\n /** HL `\"{symbol}:{spotEvmContract}\"` (e.g. `\"USDC:0x6d1e…054\"`). */\n token: string;\n /** Human-readable decimal, Relay-formatted at the spot token's display precision. */\n amount: string;\n /** Currently always `\"\"` for non-sub-account withdrawals. */\n fromSubAccount: string;\n}\n\nconst HyperliquidSendAssetParametersSchema: z.ZodType<HyperliquidSendAssetParameters> = z.object({\n hyperliquidChain: z.string().min(1),\n destination: EvmAddressSchema,\n sourceDex: z.string(),\n destinationDex: z.string(),\n token: z.string().min(1),\n amount: z.string().regex(/^\\d+(\\.\\d+)?$/, 'amount must be a positive decimal string'),\n fromSubAccount: z.string(),\n});\n\n/**\n * Pass-through EIP-712 envelope Relay returns inside the v2 swap response.\n *\n * The SDK no longer hardcodes Relay's `RelayNonceMapping` schema — instead it\n * forwards `domain` / `types` / `primaryType` / `value` to the wallet's typed-\n * data signer verbatim. Future Relay-side schema additions (e.g. `depositor`\n * was added in v2) propagate automatically without an SDK release.\n */\nexport interface RelayEip712SignEnvelope {\n signatureKind: 'eip712';\n domain: {\n name: string;\n version: string;\n chainId: number;\n verifyingContract: EvmAddress;\n };\n types: Record<string, ReadonlyArray<{ name: string; type: string }>>;\n primaryType: string;\n /** Relay binds at minimum these fields; additional keys (e.g. `depositor`) are forwarded verbatim. */\n value: {\n wallet: EvmAddress;\n chainId: string;\n id: Hex;\n nonce: number;\n [key: string]: unknown;\n };\n}\n\nconst RelayEip712SignEnvelopeSchema: z.ZodType<RelayEip712SignEnvelope> = z.object({\n signatureKind: z.literal('eip712'),\n domain: z.object({\n name: z.string().min(1),\n version: z.string().min(1),\n chainId: z.number().int().nonnegative(),\n verifyingContract: EvmAddressSchema,\n }),\n types: z.record(z.string(), z.array(z.object({ name: z.string(), type: z.string() }))),\n primaryType: z.string().min(1),\n value: z\n .object({\n wallet: EvmAddressSchema,\n chainId: z.string().min(1),\n id: HashSchema,\n nonce: z.number().int().nonnegative(),\n })\n .loose(),\n});\n\n/**\n * Pass-through `/authorize` POST body Relay returns inside the v2 swap response.\n *\n * The SDK forwards `body` verbatim to Markr (which forwards verbatim to Relay).\n * Markr only normalizes `nonce` to a JSON number on the wire; everything else\n * is untouched, so new fields Relay adds are not rejected.\n */\nexport interface RelayAuthorizeEnvelope {\n endpoint: string;\n method: string;\n body: {\n type: string;\n id: Hex;\n nonce: number;\n wallet: EvmAddress;\n walletChainId: number;\n signatureChainId: number;\n [key: string]: unknown;\n };\n}\n\nconst RelayAuthorizeEnvelopeSchema: z.ZodType<RelayAuthorizeEnvelope> = z.object({\n endpoint: z.string().min(1),\n method: z.string().min(1),\n body: z\n .object({\n type: z.string().min(1),\n id: HashSchema,\n nonce: z.number().int().nonnegative(),\n wallet: EvmAddressSchema,\n walletChainId: z.number().int().nonnegative(),\n signatureChainId: z.number().int().nonnegative(),\n })\n .loose(),\n});\n\n/**\n * Hyperliquid 2-phase withdrawal variant (source chain = `eip155:1337`).\n *\n * Markr returns:\n * - the dynamic envelope (`nonce`, `id`, `requestId`) used for the authorize\n * signature and status polling, and\n * - the full `parameters` object Relay produced for the deposit step's\n * `sendAsset` action, which the SDK signs verbatim and submits to HL.\n *\n * Starting at `protocolVersion: 2`, Relay's full EIP-712 envelope (`sign`) and\n * the `/authorize` POST body (`authorize`) are passed through verbatim — the\n * SDK no longer reconstructs Relay's schemas, so additive Relay changes (e.g.\n * `depositor` field) flow through without an SDK release.\n *\n * Important: `id` and `requestId` are TWO DIFFERENT bytes32s.\n * - `id` is the **order id** — it goes into the EIP-712 `NonceMapping`\n * message and Relay's `/authorize` POST body. Sourced from\n * `steps[0].items[0].data.sign.value.id` (== `data.post.body.id` ==\n * `protocol.v2.orderId`).\n * - `requestId` is the **tracking id** used only for\n * `/intents/status/v3?requestId=…` polling. Sourced from\n * `steps[0].requestId`.\n *\n * Swapping these two looks superficially correct (both are `0x{64hex}`) but\n * makes the on-chain `sendAsset` un-matchable by Relay's indexer.\n *\n * The SDK pins the static HL-side `SendAsset` shape (which HL owns) as a\n * constant in `_hyperliquid-eip712.ts`. Relay's nonce-mapping shape is now\n * dynamic via the `sign` envelope.\n */\nexport interface HyperliquidWithdrawSwapResponse {\n type: 'hyperliquid-withdraw';\n /** SDK validates against `SUPPORTED_HL_PROTOCOL_VERSIONS`; bumps when Relay/HL EIP-712 schemas change. */\n protocolVersion: number;\n /** Shared between authorize + sendAsset signatures; uint64 decimal string. */\n nonce: string;\n /** Order id signed inside the `NonceMapping` message and posted to `/authorize`. */\n id: Hex;\n /** Tracking id for cross-chain status polling (`/intents/status/v3?requestId=…`). */\n requestId: Hex;\n /** Relay-canonical `sendAsset` action parameters; signed and submitted verbatim. */\n parameters: HyperliquidSendAssetParameters;\n /** Relay's full EIP-712 nonce-mapping envelope. v2+. */\n sign?: RelayEip712SignEnvelope;\n /** Relay's `/authorize` POST descriptor (we forward `body` verbatim). v2+. */\n authorize?: RelayAuthorizeEnvelope;\n}\n\nexport const HyperliquidWithdrawSwapResponseSchema: z.ZodType<HyperliquidWithdrawSwapResponse> = z.object({\n type: z.literal('hyperliquid-withdraw'),\n protocolVersion: z.number().int().positive(),\n nonce: z.string().regex(/^\\d+$/, 'nonce must be a decimal string'),\n id: HashSchema,\n requestId: HashSchema,\n parameters: HyperliquidSendAssetParametersSchema,\n sign: RelayEip712SignEnvelopeSchema.optional(),\n authorize: RelayAuthorizeEnvelopeSchema.optional(),\n});\n\nexport type SwapResponse =\n | WrappedSwapTransactionResponse\n | SolanaSwapTransactionResponse\n | HyperliquidWithdrawSwapResponse;\n\nexport const SwapResponseSchema: z.ZodType<SwapResponse> = z.union([\n WrappedSwapTransactionResponseSchema,\n SolanaSwapTransactionResponseSchema,\n HyperliquidWithdrawSwapResponseSchema,\n]);\n\n/**\n * Markr `/authorize` response.\n *\n * The success body is documented as opaque, so we only assert that:\n * 1. the parsed JSON isn't an error envelope (`{ error: \"...\" }`) — Markr's\n * upstream (Relay) can return a 200 with an error payload when the\n * authorize is rejected after HTTP success;\n * 2. nothing else, by design — schema bumps when Markr publishes a spec.\n */\nexport const MarkrAuthorizeResponseSchema: z.ZodType<unknown> = z\n .unknown()\n .refine(\n (data) =>\n !(\n data !== null &&\n typeof data === 'object' &&\n 'error' in data &&\n typeof (data as { error: unknown }).error === 'string'\n ),\n { message: 'Markr /authorize returned an error envelope despite 2xx status.' },\n );\n\nexport interface PartnerInfoResponse {\n /**\n * The partner fee in basis points collected on each swap.\n */\n fee: number;\n name: string;\n}\n\nexport const PartnerInfoResponseSchema: z.ZodType<PartnerInfoResponse> = z.object({\n fee: z.int().nonnegative(),\n name: z.string(),\n});\n\n/**\n * If the destination token is USDC, the flow is:\n * - pending -> committed -> completed\n *\n * If the destination token is not USDC, the flow is:\n * - pending -> committed -> pending_execution -> completed\n *\n * If the transaction fails at any point, the status will be 'failed'.\n */\nexport type CrossChainStatus =\n | /** Transaction submitted to CCIP */\n 'pending'\n /** Message committed, awaiting execution on destination chain */\n | 'committed'\n /** Message received on destination, swap pending execution by relayer */\n | 'pending_execution'\n /** Message executed successfully on destination chain */\n | 'completed'\n /** Swap expired, and funds were refunded (CCIP only) */\n | 'refunded'\n /** Execution failed */\n | 'failed'\n /** Unknown state */\n | 'unknown';\n\nexport interface CrossChainStatusResponse {\n /**\n * Cross-chain transaction identifier.\n *\n * For CCIP: The CCIP message ID.\n * For DeBridge: The DeBridge order ID.\n */\n messageId: string | null;\n /** Current status of the cross-chain transaction. */\n status: CrossChainStatus;\n /** Human-readable status description */\n description: string;\n /** Source chain information */\n sourceChain: {\n /** Source chain network name */\n name: string;\n /** Source chain transaction hash */\n transactionHash: Hash | Signature;\n /** Transaction timestamp on source chain (ISO 8601) */\n timestamp: string;\n /** When the source transaction was finalized (ISO 8601) */\n finalized: string | boolean | null;\n };\n /** Destination chain information */\n destinationChain: {\n /** Destination chain network name */\n name: string | null;\n /**\n * Destination chain tx hash.\n *\n * - For direct transfers (USDC -> USDC): The CCIP bridge transaction hash.\n * - For successful swaps: The actual swap transaction hash from the relayer.\n * - For pending swaps: null (swap not yet executed).\n */\n transactionHash: Hash | Signature | null;\n /**\n * CCIP bridge tx hash (only present for swaps, not direct transfers).\n *\n * This is the transaction that delivered USDC to the destination chain via CCIP.\n * The `transactionHash` field contains the subsequent swap transaction.\n */\n bridgeHash?: Hash | Signature | null;\n /** Transaction timestamp on destination chain (null if not yet executed) (ISO 8601) */\n timestamp: string | null;\n /** When the destination transaction was finalized (null if not yet executed) (ISO 8601) */\n finalized: string | null;\n };\n /** Transaction progress information */\n progress: {\n /** Whether the message has been committed on destination chain */\n committed: boolean;\n /** When the message was committed (null if not committed) (ISO 8601) */\n commitTimestamp?: string | null;\n /** Whether the message has been executed on destination chain */\n executed: boolean;\n };\n /** Fee information */\n fees: {\n /** Fee token address */\n token: EvmAddress | SolAddress | null;\n /** Fee amount in wei */\n amount: bigint | null;\n } | null;\n /** Tokens transferred in this cross-chain transaction */\n transferredTokens: ReadonlyArray<{\n /** Token address */\n token: EvmAddress | SolAddress;\n /** Token amount */\n amount: bigint;\n }>;\n /**\n * Debug information from Markr transaction API (only present for swaps that have been executed).\n *\n * Contains detailed information about the relayer execution, retry attempts, and transaction details.\n */\n debug?: Partial<{\n /** CCIP message ID */\n messageId: string;\n /** Execution status from relayer */\n status: string;\n /** Destination chain name */\n destinationChain: string;\n /** Destination swap transaction hash */\n destinationTxHash: string;\n /** Relay transaction hash */\n relayTxHash: string;\n /** Number of retry attempts */\n retryCount: number;\n /** Timestamp of last retry attempt (ISO 8601) */\n lastRetryAt: string;\n /** Source chain name */\n sourceChain: string;\n /** Source transaction hash */\n sourceTxHash: string;\n /** When the record was created (ISO 8601) */\n createdAt: string;\n }> | null;\n}\n\nconst ISO_8601_TIMEZONE_DESIGNATOR_REGEX = /[zZ]|[+-]\\d{2}:?\\d{2}$/;\n\n// Markr API returns ISO-8601 datetime strings that are sometimes missing a timezone designator (\"local\" ISO).\n// We assume these are meant to be UTC and append 'Z' if missing, then validate as strict ISO-8601 with timezone.\nconst datetime = z.iso\n .datetime({ local: true })\n .refine(\n (value) => {\n // Accept at least local ISO format\n // If missing timezone, treat as UTC\n const hasTimezone = ISO_8601_TIMEZONE_DESIGNATOR_REGEX.test(value);\n const isoString = hasTimezone ? value : `${value}Z`;\n // Validate as strict ISO-8601 with timezone\n return z.iso.datetime().safeParse(isoString).success;\n },\n {\n error: 'Invalid ISO-8601 datetime (must be valid with timezone, or local assumed UTC)',\n },\n )\n .transform((value) => {\n const hasTimezone = ISO_8601_TIMEZONE_DESIGNATOR_REGEX.test(value);\n return hasTimezone ? value : `${value}Z`;\n });\n\nexport const CrossChainStatusResponseSchema: z.ZodType<CrossChainStatusResponse> = z.object({\n messageId: z.string().nullable(),\n status: z.enum(['pending', 'committed', 'pending_execution', 'completed', 'failed', 'refunded', 'unknown']),\n description: z.string(),\n sourceChain: z.object({\n name: z.string(),\n transactionHash: z.union([HashSchema, SolSignatureSchema]),\n timestamp: datetime,\n finalized: datetime.or(z.boolean()).nullable(),\n }),\n destinationChain: z.object({\n name: z.string().nullable(),\n transactionHash: z.union([HashSchema, SolSignatureSchema]).nullable(),\n bridgeHash: z.union([HashSchema, SolSignatureSchema]).nullable().optional(),\n timestamp: datetime.nullable(),\n finalized: datetime.nullable(),\n }),\n progress: z.object({\n committed: z.boolean(),\n commitTimestamp: datetime.nullable().optional(),\n executed: z.boolean(),\n }),\n fees: z\n .object({\n token: z.union([EvmAddressSchema, SolAddressSchema]).nullable(),\n amount: z.coerce.bigint().nonnegative().nullable(),\n })\n .nullable(),\n transferredTokens: z.array(\n z.object({\n token: z.union([EvmAddressSchema, SolAddressSchema]),\n amount: z.coerce.bigint().nonnegative(),\n }),\n ),\n debug: z\n .looseObject({\n messageId: z.string(),\n status: z.string(),\n destinationChain: z.string(),\n destinationTxHash: z.string(),\n relayTxHash: z.string(),\n retryCount: z.number().int().nonnegative(),\n lastRetryAt: z.iso.datetime(),\n sourceChain: z.string(),\n sourceTxHash: z.string(),\n createdAt: z.iso.datetime(),\n })\n .partial()\n .nullable()\n .optional(),\n});\n\nexport interface SpenderAddressResponse {\n address: EvmAddress;\n}\n\nexport const SpenderAddressResponseSchema: z.ZodType<SpenderAddressResponse> = z.object({\n address: EvmAddressSchema,\n});\n"],"mappings":"iPAqEA,MAAa,EAA8C,EACxD,QAAQ,CACR,OAAQ,GAAU,EAAe,EAAM,CAAE,CACxC,QAAS,0BACV,CAAC,CACD,UAAW,GAAU,EAAsB,CAExC,EAAwC,EAAE,OAAO,CACrD,QAAS,EAAE,MAAM,CAAC,EAAE,QAAQ,CAAE,EAAE,QAAQ,CAAC,CAAC,CAC1C,UAAW,EAAE,QAAQ,CACrB,iBAAkB,EAAE,MAAM,EAAE,KAAK,CAAC,mBAAoB,oBAAqB,QAAS,OAAQ,aAAa,CAAC,CAAC,CAC3G,SAAU,EAAE,KAAK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CACtF,QAAS,EACV,CAAC"}
|
|
1
|
+
{"version":3,"file":"_schema.js","names":[],"sources":["../../../src/transfer-service/markr/_schema.ts"],"sourcesContent":["import type { Signature, Address as SolAddress } from '@solana/kit';\nimport type { Address as EvmAddress, Hash } from 'viem';\nimport { z } from 'zod';\nimport type { Caip2ChainId } from '../../types/caip';\nimport type { Hex } from '../../types/signer';\nimport { isCaip2ChainId } from '../../utils/caip';\nimport {\n EvmAddressSchema,\n HashSchema,\n HexSchema,\n HyperliquidAddressSchema,\n SolAddressSchema,\n SolSignatureSchema,\n} from '../service-schemas';\n\ninterface SupportedChainsResponseItemBase {\n chainId: number | string;\n chainType: string;\n /** Available services on the chain. Each service has specific functionality */\n enabled_services: Array<'cross-chain-swap' | 'cross-chain-quote' | 'quote' | 'swap' | 'token-list'>;\n /** Chain logo URL */\n logo_url: string;\n /** Chain display name */\n name: string;\n /**\n * List of chain IDs that this chain can swap to via cross-chain aggregators.\n *\n * Empty array means no cross-chain routes available.\n */\n lanes: ReadonlyArray<number | Caip2ChainId>;\n}\n\nexport interface SupportedChainsResponseItemEvm extends SupportedChainsResponseItemBase {\n /** Chain identifier */\n chainId: number;\n /** Chain virtual machine type */\n chainType: 'evm';\n /** Router contract address */\n router?: EvmAddress;\n /** Native token wrapped contract address */\n wrapped_token?: EvmAddress;\n /**\n * Recurring-swap (DCA) capability metadata for this chain. Absent when the\n * orchestrator does not enable recurring swaps for the chain.\n *\n * @see https://orchestrator-docs.markr.io/#/Recurring%20Swaps\n */\n recurring?: {\n /** Lower bound for `intervalSeconds` accepted by `/recurring/quote`. */\n minFrequencySeconds: number;\n };\n}\n\nexport interface SupportedChainsResponseItemSvm extends SupportedChainsResponseItemBase {\n /** Chain identifier */\n chainId: Caip2ChainId;\n /** Chain virtual machine type */\n chainType: 'svm';\n}\n\nexport type SupportedChainsResponse = Array<\n SupportedChainsResponseItemEvm | SupportedChainsResponseItemSvm | SupportedChainsResponseItemBase\n>;\n\nexport const Caip2ChainIdSchema: z.ZodType<Caip2ChainId> = z\n .string()\n .refine((value) => isCaip2ChainId(value), {\n message: 'Invalid CAIP-2 chain ID',\n })\n .transform((value) => value as Caip2ChainId);\n\nconst SupportedChainsResponseItemBaseSchema = z.object({\n chainId: z.union([z.number(), z.string()]),\n chainType: z.string(),\n enabled_services: z.array(z.enum(['cross-chain-swap', 'cross-chain-quote', 'quote', 'swap', 'token-list'])),\n logo_url: z.url(),\n name: z.string(),\n lanes: z.array(z.union([z.coerce.number().int().nonnegative(), Caip2ChainIdSchema])),\n});\n\nconst SupportedChainsResponseItemEvmSchema: z.ZodType<SupportedChainsResponseItemEvm> =\n SupportedChainsResponseItemBaseSchema.extend({\n chainId: z.coerce.number().int().nonnegative(),\n chainType: z.literal('evm'),\n router: EvmAddressSchema.optional(),\n wrapped_token: EvmAddressSchema.optional(),\n recurring: z\n .object({\n minFrequencySeconds: z.number().int().nonnegative(),\n })\n .optional(),\n });\n\nconst SupportedChainsResponseItemSvmSchema: z.ZodType<SupportedChainsResponseItemSvm> =\n SupportedChainsResponseItemBaseSchema.extend({\n chainId: z\n .string()\n .refine((value) => isCaip2ChainId(value) && value.startsWith('solana:'), {\n error: 'Is not a valid Solana CAIP-2 ID',\n })\n .transform((value) => value as Caip2ChainId),\n chainType: z.literal('svm'),\n });\n\n/**\n * Schema for the response from Markr's /info/chains endpoint.\n *\n * @see https://orchestrator-docs.markr.io/#/paths/~1info~1chains/get\n */\nexport const SupportedChainsResponseSchema: z.ZodType<SupportedChainsResponse> = z.array(\n z.union([\n SupportedChainsResponseItemEvmSchema,\n SupportedChainsResponseItemSvmSchema,\n SupportedChainsResponseItemBaseSchema.refine(\n (item) => item.chainType !== 'evm' && item.chainType !== 'svm',\n 'Known chain types must match their expected schema',\n ),\n ]),\n);\n\nexport type TokenListResponse = Array<{\n address: EvmAddress;\n decimals: number;\n logo_url: string;\n name: string;\n symbol: string;\n}>;\n\n/**\n * Schema for the response Markr's /tokens/{chainId}/list endpoint.\n *\n * @see https://orchestrator-docs.markr.io/#/paths/~1tokens~1%7BchainId%7D~1list/get\n */\nexport const TokenListResponseSchema: z.ZodType<TokenListResponse> = z.array(\n z.object({\n address: EvmAddressSchema,\n decimals: z.number().int().nonnegative().max(18),\n logo_url: z.url(),\n name: z.string(),\n symbol: z.string(),\n }),\n);\n\nexport interface QuoteResponseData {\n aggregator: {\n id: string;\n logo_url: string;\n name: string;\n };\n amountIn: bigint;\n amountOut: bigint;\n /** Chain identifier (number for EVM chains, CAIP-2 ID for SVM chains) */\n chainId: number | Caip2ChainId;\n expiredAt: number;\n /**\n * Fee breakdown for cross-chain bridge transactions.\n *\n * Only included in quotes from cross-chain aggregators (DeBridge, LiFi).\n */\n fees?: ReadonlyArray<{\n type: 'protocol' | 'gas' | 'bridge' | 'slippage' | 'swap' | 'other' | 'relay';\n /** Human-readable fee name */\n name: string;\n /** Fee amount in token's smallest unit */\n amount: bigint;\n /**\n * Docs document `extra` as `boolean or object`. The boolean form is the\n * legacy \"additive one-time charge\" flag; the object form is reserved\n * for future structured metadata. Consumers should treat any truthy\n * value as \"this fee is on top of the input amount and must be balance-\n * checked separately.\"\n */\n extra?: boolean | Record<string, unknown>;\n /** Token the fee is deducted from */\n token: {\n /** Chain ID where fee is deducted */\n chainId: number | Caip2ChainId;\n /** Token address (EVM hex or Solana base58) */\n address: EvmAddress | SolAddress;\n };\n }>;\n gasEstimate?: bigint;\n recommendedSlippage: number;\n /** Input token address (EVM hex or Solana base58) */\n tokenIn: EvmAddress | SolAddress;\n tokenInDecimals: number;\n /** Output token address (EVM hex or Solana base58) */\n tokenOut: EvmAddress | SolAddress;\n tokenOutDecimals: number;\n uuid: string;\n}\n\nexport interface QuoteResponseDataDone {\n done: true;\n}\n\nexport type QuoteResponse = QuoteResponseData | QuoteResponseDataDone;\n\nconst MarkrQuoteTokenAddressSchema = z.union([EvmAddressSchema, SolAddressSchema, HyperliquidAddressSchema]);\n\n/**\n * Schema for the response from Markr's /quote endpoint.\n *\n * @see https://orchestrator-docs.markr.io/#/paths/~1quote/post\n */\nexport const QuoteResponseSchema: z.ZodType<QuoteResponse> = z.union([\n z.object({\n aggregator: z.object({\n id: z.string(),\n logo_url: z.url(),\n name: z.string(),\n }),\n amountIn: z.coerce.bigint().nonnegative(),\n amountOut: z.coerce.bigint().nonnegative(),\n chainId: z.union([z.number().int().nonnegative(), Caip2ChainIdSchema]),\n /**\n * Unix time in seconds when the quote expires.\n */\n expiredAt: z.number().int().nonnegative(),\n fees: z\n .array(\n z.object({\n type: z.enum(['protocol', 'gas', 'bridge', 'slippage', 'swap', 'other', 'relay']),\n name: z.string(),\n amount: z.coerce.bigint().nonnegative(),\n token: z.object({\n chainId: z.union([z.number().int().nonnegative(), Caip2ChainIdSchema]),\n address: MarkrQuoteTokenAddressSchema,\n }),\n // Docs: `extra: boolean or object` — accept both. The boolean form\n // is the legacy \"is this an additive one-time charge\" flag; the\n // object form is reserved for future structured metadata.\n extra: z.union([z.boolean(), z.record(z.string(), z.unknown())]).optional(),\n }),\n )\n .optional(),\n /**\n * Estimated gas for the swap transaction.\n * Markr estimates already include a buffer.\n *\n * The API docs do not specify this field as optional, but in practice it can be missing.\n */\n gasEstimate: z.coerce.bigint().nonnegative().optional(),\n /** Recommended slippage in basis points. */\n recommendedSlippage: z.number().int().nonnegative(),\n tokenIn: MarkrQuoteTokenAddressSchema,\n tokenInDecimals: z.number().int().nonnegative().max(18),\n tokenOut: MarkrQuoteTokenAddressSchema,\n tokenOutDecimals: z.number().int().nonnegative().max(18),\n uuid: z.uuid(),\n }),\n z.object({\n done: z.literal(true),\n }),\n]);\n\n/**\n * Response type for Markr's /swap, /recurring/swap, and\n * /recurring/orders/{orderId}/cancel endpoints — all return the same\n * `WrappedTransaction` calldata shape per the orchestrator docs.\n *\n * @see https://orchestrator-docs.markr.io/#/paths/~1swap/post\n */\nexport interface WrappedSwapTransactionResponse {\n data: Hex;\n to: EvmAddress;\n value: bigint;\n /**\n * Sender address per the docs' `WrappedTransaction` schema. Optional in\n * the SDK because the caller (the wallet broadcasting the TX) already\n * knows their own from-address and the field has historically been\n * dropped on parse without consumer impact.\n */\n from?: EvmAddress;\n}\n\nexport const WrappedSwapTransactionResponseSchema: z.ZodType<WrappedSwapTransactionResponse> = z.object({\n data: HexSchema,\n to: EvmAddressSchema,\n value: z.coerce.bigint().nonnegative(),\n from: EvmAddressSchema.optional(),\n});\n\n/**\n * Solana swap transaction (returned for SVM chains).\n */\nexport interface SolanaSwapTransactionResponse {\n /** Chain type identifier */\n chainType: 'svm';\n /** Base64-encoded Solana transaction to be signed and sent by the client */\n swapTransaction: string;\n}\n\nexport const SolanaSwapTransactionResponseSchema: z.ZodType<SolanaSwapTransactionResponse> = z.object({\n chainType: z.literal('svm'),\n swapTransaction: z.base64(),\n});\n\n/**\n * `sendAsset` action parameters Relay produces for the deposit step.\n *\n * These are the exact strings the SDK must (a) include in the EIP-712 message\n * it signs and (b) submit verbatim as the `action` body to HL `/exchange`.\n * Keeping them pre-formatted by Relay (rather than reconstructed by the SDK)\n * eliminates drift — notably on `amount`, which Relay formats at the spot\n * token's display precision (e.g. `\"0.200000\"` for USDC, not the perps-side\n * `\"0.20000000\"`). Any mismatch between what we sign / submit and what Relay\n * recorded in the order makes Relay's indexer skip the on-chain `sendAsset`.\n */\nexport interface HyperliquidSendAssetParameters {\n /** `\"Mainnet\"` or `\"Testnet\"`. */\n hyperliquidChain: string;\n /** Relay's HL custodian — where the sendAsset transfers to. */\n destination: EvmAddress;\n /** Currently always `\"\"` for non-DEX withdrawals. */\n sourceDex: string;\n /** Currently always `\"\"` for non-DEX withdrawals. */\n destinationDex: string;\n /** HL `\"{symbol}:{spotEvmContract}\"` (e.g. `\"USDC:0x6d1e…054\"`). */\n token: string;\n /** Human-readable decimal, Relay-formatted at the spot token's display precision. */\n amount: string;\n /** Currently always `\"\"` for non-sub-account withdrawals. */\n fromSubAccount: string;\n}\n\nconst HyperliquidSendAssetParametersSchema: z.ZodType<HyperliquidSendAssetParameters> = z.object({\n hyperliquidChain: z.string().min(1),\n destination: EvmAddressSchema,\n sourceDex: z.string(),\n destinationDex: z.string(),\n token: z.string().min(1),\n amount: z.string().regex(/^\\d+(\\.\\d+)?$/, 'amount must be a positive decimal string'),\n fromSubAccount: z.string(),\n});\n\n/**\n * Pass-through EIP-712 envelope Relay returns inside the v2 swap response.\n *\n * The SDK no longer hardcodes Relay's `RelayNonceMapping` schema — instead it\n * forwards `domain` / `types` / `primaryType` / `value` to the wallet's typed-\n * data signer verbatim. Future Relay-side schema additions (e.g. `depositor`\n * was added in v2) propagate automatically without an SDK release.\n */\nexport interface RelayEip712SignEnvelope {\n signatureKind: 'eip712';\n domain: {\n name: string;\n version: string;\n chainId: number;\n verifyingContract: EvmAddress;\n };\n types: Record<string, ReadonlyArray<{ name: string; type: string }>>;\n primaryType: string;\n /** Relay binds at minimum these fields; additional keys (e.g. `depositor`) are forwarded verbatim. */\n value: {\n wallet: EvmAddress;\n chainId: string;\n id: Hex;\n nonce: number;\n [key: string]: unknown;\n };\n}\n\nconst RelayEip712SignEnvelopeSchema: z.ZodType<RelayEip712SignEnvelope> = z.object({\n signatureKind: z.literal('eip712'),\n domain: z.object({\n name: z.string().min(1),\n version: z.string().min(1),\n chainId: z.number().int().nonnegative(),\n verifyingContract: EvmAddressSchema,\n }),\n types: z.record(z.string(), z.array(z.object({ name: z.string(), type: z.string() }))),\n primaryType: z.string().min(1),\n value: z\n .object({\n wallet: EvmAddressSchema,\n chainId: z.string().min(1),\n id: HashSchema,\n nonce: z.number().int().nonnegative(),\n })\n .loose(),\n});\n\n/**\n * Pass-through `/authorize` POST body Relay returns inside the v2 swap response.\n *\n * The SDK forwards `body` verbatim to Markr (which forwards verbatim to Relay).\n * Markr only normalizes `nonce` to a JSON number on the wire; everything else\n * is untouched, so new fields Relay adds are not rejected.\n */\nexport interface RelayAuthorizeEnvelope {\n endpoint: string;\n method: string;\n body: {\n type: string;\n id: Hex;\n nonce: number;\n wallet: EvmAddress;\n walletChainId: number;\n signatureChainId: number;\n [key: string]: unknown;\n };\n}\n\nconst RelayAuthorizeEnvelopeSchema: z.ZodType<RelayAuthorizeEnvelope> = z.object({\n endpoint: z.string().min(1),\n method: z.string().min(1),\n body: z\n .object({\n type: z.string().min(1),\n id: HashSchema,\n nonce: z.number().int().nonnegative(),\n wallet: EvmAddressSchema,\n walletChainId: z.number().int().nonnegative(),\n signatureChainId: z.number().int().nonnegative(),\n })\n .loose(),\n});\n\n/**\n * Hyperliquid 2-phase withdrawal variant (source chain = `eip155:1337`).\n *\n * Markr returns:\n * - the dynamic envelope (`nonce`, `id`, `requestId`) used for the authorize\n * signature and status polling, and\n * - the full `parameters` object Relay produced for the deposit step's\n * `sendAsset` action, which the SDK signs verbatim and submits to HL.\n *\n * Starting at `protocolVersion: 2`, Relay's full EIP-712 envelope (`sign`) and\n * the `/authorize` POST body (`authorize`) are passed through verbatim — the\n * SDK no longer reconstructs Relay's schemas, so additive Relay changes (e.g.\n * `depositor` field) flow through without an SDK release.\n *\n * Important: `id` and `requestId` are TWO DIFFERENT bytes32s.\n * - `id` is the **order id** — it goes into the EIP-712 `NonceMapping`\n * message and Relay's `/authorize` POST body. Sourced from\n * `steps[0].items[0].data.sign.value.id` (== `data.post.body.id` ==\n * `protocol.v2.orderId`).\n * - `requestId` is the **tracking id** used only for\n * `/intents/status/v3?requestId=…` polling. Sourced from\n * `steps[0].requestId`.\n *\n * Swapping these two looks superficially correct (both are `0x{64hex}`) but\n * makes the on-chain `sendAsset` un-matchable by Relay's indexer.\n *\n * The SDK pins the static HL-side `SendAsset` shape (which HL owns) as a\n * constant in `_hyperliquid-eip712.ts`. Relay's nonce-mapping shape is now\n * dynamic via the `sign` envelope.\n */\nexport interface HyperliquidWithdrawSwapResponse {\n type: 'hyperliquid-withdraw';\n /** SDK validates against `SUPPORTED_HL_PROTOCOL_VERSIONS`; bumps when Relay/HL EIP-712 schemas change. */\n protocolVersion: number;\n /** Shared between authorize + sendAsset signatures; uint64 decimal string. */\n nonce: string;\n /** Order id signed inside the `NonceMapping` message and posted to `/authorize`. */\n id: Hex;\n /** Tracking id for cross-chain status polling (`/intents/status/v3?requestId=…`). */\n requestId: Hex;\n /** Relay-canonical `sendAsset` action parameters; signed and submitted verbatim. */\n parameters: HyperliquidSendAssetParameters;\n /** Relay's full EIP-712 nonce-mapping envelope. v2+. */\n sign?: RelayEip712SignEnvelope;\n /** Relay's `/authorize` POST descriptor (we forward `body` verbatim). v2+. */\n authorize?: RelayAuthorizeEnvelope;\n}\n\nexport const HyperliquidWithdrawSwapResponseSchema: z.ZodType<HyperliquidWithdrawSwapResponse> = z.object({\n type: z.literal('hyperliquid-withdraw'),\n protocolVersion: z.number().int().positive(),\n nonce: z.string().regex(/^\\d+$/, 'nonce must be a decimal string'),\n id: HashSchema,\n requestId: HashSchema,\n parameters: HyperliquidSendAssetParametersSchema,\n sign: RelayEip712SignEnvelopeSchema.optional(),\n authorize: RelayAuthorizeEnvelopeSchema.optional(),\n});\n\nexport type SwapResponse =\n | WrappedSwapTransactionResponse\n | SolanaSwapTransactionResponse\n | HyperliquidWithdrawSwapResponse;\n\nexport const SwapResponseSchema: z.ZodType<SwapResponse> = z.union([\n WrappedSwapTransactionResponseSchema,\n SolanaSwapTransactionResponseSchema,\n HyperliquidWithdrawSwapResponseSchema,\n]);\n\n/**\n * Markr `/authorize` response.\n *\n * The success body is documented as opaque, so we only assert that:\n * 1. the parsed JSON isn't an error envelope (`{ error: \"...\" }`) — Markr's\n * upstream (Relay) can return a 200 with an error payload when the\n * authorize is rejected after HTTP success;\n * 2. nothing else, by design — schema bumps when Markr publishes a spec.\n */\nexport const MarkrAuthorizeResponseSchema: z.ZodType<unknown> = z\n .unknown()\n .refine(\n (data) =>\n !(\n data !== null &&\n typeof data === 'object' &&\n 'error' in data &&\n typeof (data as { error: unknown }).error === 'string'\n ),\n { message: 'Markr /authorize returned an error envelope despite 2xx status.' },\n );\n\nexport interface PartnerInfoResponse {\n /**\n * The partner fee in basis points collected on each swap.\n */\n fee: number;\n name: string;\n}\n\nexport const PartnerInfoResponseSchema: z.ZodType<PartnerInfoResponse> = z.object({\n fee: z.int().nonnegative(),\n name: z.string(),\n});\n\n/**\n * If the destination token is USDC, the flow is:\n * - pending -> committed -> completed\n *\n * If the destination token is not USDC, the flow is:\n * - pending -> committed -> pending_execution -> completed\n *\n * If the transaction fails at any point, the status will be 'failed'.\n */\nexport type CrossChainStatus =\n | /** Transaction submitted to CCIP */\n 'pending'\n /** Message committed, awaiting execution on destination chain */\n | 'committed'\n /** Message received on destination, swap pending execution by relayer */\n | 'pending_execution'\n /** Message executed successfully on destination chain */\n | 'completed'\n /** Swap expired, and funds were refunded (CCIP only) */\n | 'refunded'\n /** Execution failed */\n | 'failed'\n /** Unknown state */\n | 'unknown';\n\nexport interface CrossChainStatusResponse {\n /**\n * Cross-chain transaction identifier.\n *\n * For CCIP: The CCIP message ID.\n * For DeBridge: The DeBridge order ID.\n */\n messageId: string | null;\n /** Current status of the cross-chain transaction. */\n status: CrossChainStatus;\n /** Human-readable status description */\n description: string;\n /** Source chain information */\n sourceChain: {\n /** Source chain network name */\n name: string;\n /** Source chain transaction hash */\n transactionHash: Hash | Signature;\n /** Transaction timestamp on source chain (ISO 8601) */\n timestamp: string;\n /** When the source transaction was finalized (ISO 8601) */\n finalized: string | boolean | null;\n };\n /** Destination chain information */\n destinationChain: {\n /** Destination chain network name */\n name: string | null;\n /**\n * Destination chain tx hash.\n *\n * - For direct transfers (USDC -> USDC): The CCIP bridge transaction hash.\n * - For successful swaps: The actual swap transaction hash from the relayer.\n * - For pending swaps: null (swap not yet executed).\n */\n transactionHash: Hash | Signature | null;\n /**\n * CCIP bridge tx hash (only present for swaps, not direct transfers).\n *\n * This is the transaction that delivered USDC to the destination chain via CCIP.\n * The `transactionHash` field contains the subsequent swap transaction.\n */\n bridgeHash?: Hash | Signature | null;\n /** Transaction timestamp on destination chain (null if not yet executed) (ISO 8601) */\n timestamp: string | null;\n /** When the destination transaction was finalized (null if not yet executed) (ISO 8601) */\n finalized: string | null;\n };\n /** Transaction progress information */\n progress: {\n /** Whether the message has been committed on destination chain */\n committed: boolean;\n /** When the message was committed (null if not committed) (ISO 8601) */\n commitTimestamp?: string | null;\n /** Whether the message has been executed on destination chain */\n executed: boolean;\n };\n /** Fee information */\n fees: {\n /** Fee token address */\n token: EvmAddress | SolAddress | null;\n /** Fee amount in wei */\n amount: bigint | null;\n } | null;\n /** Tokens transferred in this cross-chain transaction */\n transferredTokens: ReadonlyArray<{\n /** Token address */\n token: EvmAddress | SolAddress;\n /** Token amount */\n amount: bigint;\n }>;\n /**\n * Debug information from Markr transaction API (only present for swaps that have been executed).\n *\n * Contains detailed information about the relayer execution, retry attempts, and transaction details.\n */\n debug?: Partial<{\n /** CCIP message ID */\n messageId: string;\n /** Execution status from relayer */\n status: string;\n /** Destination chain name */\n destinationChain: string;\n /** Destination swap transaction hash */\n destinationTxHash: string;\n /** Relay transaction hash */\n relayTxHash: string;\n /** Number of retry attempts */\n retryCount: number;\n /** Timestamp of last retry attempt (ISO 8601) */\n lastRetryAt: string;\n /** Source chain name */\n sourceChain: string;\n /** Source transaction hash */\n sourceTxHash: string;\n /** When the record was created (ISO 8601) */\n createdAt: string;\n }> | null;\n}\n\nconst ISO_8601_TIMEZONE_DESIGNATOR_REGEX = /[zZ]|[+-]\\d{2}:?\\d{2}$/;\n\n// Markr API returns ISO-8601 datetime strings that are sometimes missing a timezone designator (\"local\" ISO).\n// We assume these are meant to be UTC and append 'Z' if missing, then validate as strict ISO-8601 with timezone.\nconst datetime = z.iso\n .datetime({ local: true })\n .refine(\n (value) => {\n // Accept at least local ISO format\n // If missing timezone, treat as UTC\n const hasTimezone = ISO_8601_TIMEZONE_DESIGNATOR_REGEX.test(value);\n const isoString = hasTimezone ? value : `${value}Z`;\n // Validate as strict ISO-8601 with timezone\n return z.iso.datetime().safeParse(isoString).success;\n },\n {\n error: 'Invalid ISO-8601 datetime (must be valid with timezone, or local assumed UTC)',\n },\n )\n .transform((value) => {\n const hasTimezone = ISO_8601_TIMEZONE_DESIGNATOR_REGEX.test(value);\n return hasTimezone ? value : `${value}Z`;\n });\n\nexport const CrossChainStatusResponseSchema: z.ZodType<CrossChainStatusResponse> = z.object({\n messageId: z.string().nullable(),\n status: z.enum(['pending', 'committed', 'pending_execution', 'completed', 'failed', 'refunded', 'unknown']),\n description: z.string(),\n sourceChain: z.object({\n name: z.string(),\n transactionHash: z.union([HashSchema, SolSignatureSchema]),\n timestamp: datetime,\n finalized: datetime.or(z.boolean()).nullable(),\n }),\n destinationChain: z.object({\n name: z.string().nullable(),\n transactionHash: z.union([HashSchema, SolSignatureSchema]).nullable(),\n bridgeHash: z.union([HashSchema, SolSignatureSchema]).nullable().optional(),\n timestamp: datetime.nullable(),\n finalized: datetime.nullable(),\n }),\n progress: z.object({\n committed: z.boolean(),\n commitTimestamp: datetime.nullable().optional(),\n executed: z.boolean(),\n }),\n fees: z\n .object({\n token: z.union([EvmAddressSchema, SolAddressSchema]).nullable(),\n amount: z.coerce.bigint().nonnegative().nullable(),\n })\n .nullable(),\n transferredTokens: z.array(\n z.object({\n token: z.union([EvmAddressSchema, SolAddressSchema]),\n amount: z.coerce.bigint().nonnegative(),\n }),\n ),\n debug: z\n .looseObject({\n messageId: z.string(),\n status: z.string(),\n destinationChain: z.string(),\n destinationTxHash: z.string(),\n relayTxHash: z.string(),\n retryCount: z.number().int().nonnegative(),\n lastRetryAt: z.iso.datetime(),\n sourceChain: z.string(),\n sourceTxHash: z.string(),\n createdAt: z.iso.datetime(),\n })\n .partial()\n .nullable()\n .optional(),\n});\n\nexport interface SpenderAddressResponse {\n address: EvmAddress;\n}\n\nexport const SpenderAddressResponseSchema: z.ZodType<SpenderAddressResponse> = z.object({\n address: EvmAddressSchema,\n});\n"],"mappings":"iPAgEA,MAAa,EAA8C,EACxD,QAAQ,CACR,OAAQ,GAAU,EAAe,EAAM,CAAE,CACxC,QAAS,0BACV,CAAC,CACD,UAAW,GAAU,EAAsB,CAExC,EAAwC,EAA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xB,UAAW,EAAE,IAAI,UAAU,CAC5B,CAAC,CACD,SAAS,CACT,UAAU,CACV,UAAU,CACd,CAAC,CAMW,EAAkE,EAAE,OAAO,CACtF,QAAS,EACV,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../constants.cjs`),t=require(`../../errors.cjs`),n=require(`../../utils/caip.cjs`),r=require(`../../_utils/chain.cjs`),i=require(`../../utils/evm-address.cjs`),a=require(`../../_utils/math.cjs`),o=require(`./_api.cjs`),s=require(`../../utils/sol-address.cjs`);let c=require(`viem`);function l(e,t,n){let r=e.get(t),i=e.get(n);return!r||!i?!1:t===n?r.swapEnabled:r.crossChainSwapEnabled&&r.crossChainTargetChainIds.has(n)}async function u(e,r=!1){let i=new Map;try{let t=(await o.markrGetInfoChains(e)).filter(e=>e.chainType===`evm`||e.chainType===`svm`);for(let e of t){let t=typeof e.chainId==`number`?n.eip155ChainIdToCaip2(e.chainId):e.chainId,a=e.enabled_services.includes(`cross-chain-quote`)&&e.enabled_services.includes(`cross-chain-swap`),o=e.enabled_services.includes(`quote`)&&e.enabled_services.includes(`swap`),s=new Set;for(let r of e.lanes){let e=typeof r==`number`?n.eip155ChainIdToCaip2(r):r;e!==t&&s.add(e)}let c=r?!1:a,l=c?s:new Set;if(!o&&l.size===0)continue;let u=e.chainType===`evm`&&e.recurring?{minFrequencySeconds:e.recurring.minFrequencySeconds,
|
|
1
|
+
require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../constants.cjs`),t=require(`../../errors.cjs`),n=require(`../../utils/caip.cjs`),r=require(`../../_utils/chain.cjs`),i=require(`../../utils/evm-address.cjs`),a=require(`../../_utils/math.cjs`),o=require(`./_api.cjs`),s=require(`../../utils/sol-address.cjs`);let c=require(`viem`);function l(e,t,n){let r=e.get(t),i=e.get(n);return!r||!i?!1:t===n?r.swapEnabled:r.crossChainSwapEnabled&&r.crossChainTargetChainIds.has(n)}async function u(e,r=!1){let i=new Map;try{let t=(await o.markrGetInfoChains(e)).filter(e=>e.chainType===`evm`||e.chainType===`svm`);for(let e of t){let t=typeof e.chainId==`number`?n.eip155ChainIdToCaip2(e.chainId):e.chainId,a=e.enabled_services.includes(`cross-chain-quote`)&&e.enabled_services.includes(`cross-chain-swap`),o=e.enabled_services.includes(`quote`)&&e.enabled_services.includes(`swap`),s=new Set;for(let r of e.lanes){let e=typeof r==`number`?n.eip155ChainIdToCaip2(r):r;e!==t&&s.add(e)}let c=r?!1:a,l=c?s:new Set;if(!o&&l.size===0)continue;let u=e.chainType===`evm`&&e.recurring?{minFrequencySeconds:e.recurring.minFrequencySeconds}:void 0,d=e.chainType===`evm`?e.wrapped_token:void 0;i.set(t,{chainId:e.chainId,crossChainSwapEnabled:c,crossChainTargetChainIds:l,swapEnabled:o,tokenList:e.enabled_services.includes(`token-list`),...d?{wrappedNativeAddress:d}:{},...u?{recurring:u}:{}})}}catch(e){throw new t.SdkError(t.ErrorReason.UNKNOWN,t.ErrorCode.INITIALIZATION_FAILED,{cause:e,details:`Failed to fetch supported chains from Markr API.`})}return i}async function d(e,t){let n=new Map;for(let[r,i]of t.entries())if(typeof i.chainId==`number`&&i.tokenList&&(i.crossChainSwapEnabled||i.swapEnabled))try{let t=o.markrGetTokenList(e,i.chainId);n.set(r,t)}catch{}return n}function f(e){return e===`0x0000000000000000000000000000000000000000`||e===`11111111111111111111111111111111`}function p(t,n){return t.type===e.TokenType.NATIVE?r.isSolanaNamespace(n)?e.NATIVE_SOL_ADDRESS:e.ERC_ZERO_ADDRESS:t.address}function m({amountOut:e,assetOut:t,slippageBps:n}){let r=a.calculateMinimumAmountOut({amountOut:e,assetOut:t,slippageBps:n});return e>0n&&r===0n?1n:r}function h({assetIn:t,fees:n,sourceChain:r},i=3e3){return n.reduce((n,i)=>i.fundingModel!==`additive`||i.chainId!==r.chainId?n:t.type===e.TokenType.NATIVE?i.token.type===e.TokenType.NATIVE?n+i.amount:n:t.type===e.TokenType.ERC20?i.token.type===e.TokenType.ERC20&&(0,c.isAddressEqual)(i.token.address,t.address)?n+i.amount:n:i.token.type===e.TokenType.SPL&&i.token.address===t.address?n+i.amount:n,0n)*BigInt(1e4+i)/10000n}function g({fees:t,sourceChain:n}){return t.reduce((t,r)=>r.fundingModel!==`additive`||r.chainId!==n.chainId?t:r.token.type===e.TokenType.NATIVE?t+r.amount:t,0n)}function _(t,n,r){let i=t.amountOut*BigInt(r)/10000n,a=t.amountOut-i,o=[...y(t.fees),{type:`partner`,fundingModel:`included`,name:`Core Fee`,amount:i,chainId:n.targetChain.chainId,token:b(n.targetAsset)}];return{aggregator:{id:t.aggregator.id,logoUrl:t.aggregator.logo_url,name:t.aggregator.name},amountIn:t.amountIn,amountOut:a,assetIn:n.sourceAsset,assetOut:n.targetAsset,expiresAt:t.expiredAt,fees:o,fromAddress:n.fromAddress,gasEstimate:t.gasEstimate,id:t.uuid,partnerFeeBps:r,serviceType:e.ServiceType.MARKR,slippageBps:n.slippageBps??t.recommendedSlippage,sourceChain:n.sourceChain,targetChain:n.targetChain,toAddress:n.toAddress}}async function v(e){try{return(await o.markrGetPartnerInfo(e)).fee}catch(e){throw new t.SdkError(t.ErrorReason.UNKNOWN,t.ErrorCode.INITIALIZATION_FAILED,{cause:e,details:`Failed to fetch partner info from Markr API.`})}}function y(t){if(!t)return[];let r=[];for(let a of t){let t=typeof a.token.chainId==`number`?n.eip155ChainIdToCaip2(a.token.chainId):a.token.chainId,o;f(a.token.address)?o={type:e.TokenType.NATIVE}:i.isEvmAddress(a.token.address)?o={type:e.TokenType.ERC20,address:a.token.address}:s.isSolAddress(a.token.address)&&(o={type:e.TokenType.SPL,address:a.token.address}),o&&r.push({type:a.type,fundingModel:a.extra?`additive`:`included`,name:a.name,amount:a.amount,chainId:t,token:o})}return r}function b(t){return t.type===e.TokenType.NATIVE?{type:e.TokenType.NATIVE}:t.type===e.TokenType.SPL?{type:e.TokenType.SPL,address:t.address}:{type:e.TokenType.ERC20,address:t.address}}async function x(e){return e?(await Promise.resolve().then(()=>require(`./_abis/cross-chain-swap-wrapper-abi.cjs`))).MARKR_CROSS_CHAIN_SWAP_WRAPPER_ABI:(await Promise.resolve().then(()=>require(`./_abis/swap-wrapper-abi.cjs`))).MARKR_SWAP_WRAPPER_ABI}exports.assetToAddressString=p,exports.calculateMarkrMinimumAmountOut=m,exports.getAdditiveSourceAssetFeeAmount=h,exports.getAdditiveSourceNativeAssetFeeAmount=g,exports.getMarkrSwapWrapperAbi=x,exports.getPartnerFeeBps=v,exports.getSupportedChains=u,exports.getSupportedTokens=d,exports.isRouteSupported=l,exports.isTokenAddressNative=f,exports.quoteFromMarkrQuoteResponseData=_;
|
|
2
2
|
//# sourceMappingURL=_utils.cjs.map
|