@avalabs/fusion-sdk 0.22.0 → 0.23.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/constants.cjs +1 -1
- package/dist/constants.cjs.map +1 -1
- package/dist/constants.d.cts +18 -2
- package/dist/constants.d.ts +18 -2
- package/dist/constants.js +1 -1
- package/dist/constants.js.map +1 -1
- package/dist/mod.cjs +1 -1
- package/dist/mod.d.cts +3 -2
- package/dist/mod.d.ts +3 -2
- package/dist/mod.js +1 -1
- package/dist/transfer-service/markr/recurring/_frequency.cjs.map +1 -1
- package/dist/transfer-service/markr/recurring/_frequency.d.cts +1 -1
- package/dist/transfer-service/markr/recurring/_frequency.d.ts +1 -1
- package/dist/transfer-service/markr/recurring/_frequency.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/types.cjs.map +1 -1
- package/dist/transfer-service/markr/recurring/types.d.cts +16 -0
- package/dist/transfer-service/markr/recurring/types.d.ts +16 -0
- package/dist/transfer-service/markr/recurring/types.js.map +1 -1
- package/dist/types/transfer.d.cts +8 -0
- package/dist/types/transfer.d.ts +8 -0
- package/dist/utils/destination-chains.cjs +2 -0
- package/dist/utils/destination-chains.cjs.map +1 -0
- package/dist/utils/destination-chains.d.cts +52 -0
- package/dist/utils/destination-chains.d.ts +52 -0
- package/dist/utils/destination-chains.js +2 -0
- package/dist/utils/destination-chains.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
//#region src/utils/destination-chains.d.ts
|
|
2
|
+
type ChainIdentifier = number | string;
|
|
3
|
+
/**
|
|
4
|
+
* Chain shape accepted by the destination chain sorting utilities.
|
|
5
|
+
*
|
|
6
|
+
* Supports Fusion `Chain` objects (`chainId`, `chainName`) and app-level chain
|
|
7
|
+
* info objects (`universalChainId`, `name`).
|
|
8
|
+
*/
|
|
9
|
+
type DestinationChainSortInput = Readonly<{
|
|
10
|
+
chainId?: ChainIdentifier;
|
|
11
|
+
chainName?: string;
|
|
12
|
+
name?: string;
|
|
13
|
+
universalChainId?: ChainIdentifier;
|
|
14
|
+
}> & ({
|
|
15
|
+
readonly chainId: ChainIdentifier;
|
|
16
|
+
} | {
|
|
17
|
+
readonly universalChainId: ChainIdentifier;
|
|
18
|
+
});
|
|
19
|
+
/**
|
|
20
|
+
* Returns the deterministic display priority for a destination chain.
|
|
21
|
+
*
|
|
22
|
+
* Lower values sort first. Numeric chain IDs are treated as EIP-155 IDs.
|
|
23
|
+
*
|
|
24
|
+
* Priority order:
|
|
25
|
+
* C-Chain, P-Chain, X-Chain, Ethereum, Bitcoin/BVM, Solana, Base, Polygon, then unknown chains.
|
|
26
|
+
*
|
|
27
|
+
* @param chain - Chain object, CAIP-2 chain ID, or numeric EIP-155 chain ID to prioritize.
|
|
28
|
+
* @returns Numeric priority used by {@link compareDestinationChains}.
|
|
29
|
+
*/
|
|
30
|
+
declare const getDestinationChainPriority: (chain: DestinationChainSortInput | ChainIdentifier) => number;
|
|
31
|
+
/**
|
|
32
|
+
* Compares two destination chains using shared Fusion SDK destination ordering.
|
|
33
|
+
*
|
|
34
|
+
* Sorts by priority first, then by display name, then by chain ID for a stable tie-breaker.
|
|
35
|
+
*
|
|
36
|
+
* @param a - First chain to compare.
|
|
37
|
+
* @param b - Second chain to compare.
|
|
38
|
+
* @returns Negative when `a` sorts first, positive when `b` sorts first, or zero when equivalent.
|
|
39
|
+
*/
|
|
40
|
+
declare const compareDestinationChains: <TChain extends DestinationChainSortInput>(a: TChain, b: TChain) => number;
|
|
41
|
+
/**
|
|
42
|
+
* Returns a new array of destination chains sorted with {@link compareDestinationChains}.
|
|
43
|
+
*
|
|
44
|
+
* The input array is not mutated.
|
|
45
|
+
*
|
|
46
|
+
* @param chains - Destination chains to sort.
|
|
47
|
+
* @returns Sorted copy of the provided chains.
|
|
48
|
+
*/
|
|
49
|
+
declare const sortDestinationChains: <TChain extends DestinationChainSortInput>(chains: readonly TChain[]) => readonly TChain[];
|
|
50
|
+
//#endregion
|
|
51
|
+
export { DestinationChainSortInput, compareDestinationChains, getDestinationChainPriority, sortDestinationChains };
|
|
52
|
+
//# sourceMappingURL=destination-chains.d.cts.map
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
//#region src/utils/destination-chains.d.ts
|
|
2
|
+
type ChainIdentifier = number | string;
|
|
3
|
+
/**
|
|
4
|
+
* Chain shape accepted by the destination chain sorting utilities.
|
|
5
|
+
*
|
|
6
|
+
* Supports Fusion `Chain` objects (`chainId`, `chainName`) and app-level chain
|
|
7
|
+
* info objects (`universalChainId`, `name`).
|
|
8
|
+
*/
|
|
9
|
+
type DestinationChainSortInput = Readonly<{
|
|
10
|
+
chainId?: ChainIdentifier;
|
|
11
|
+
chainName?: string;
|
|
12
|
+
name?: string;
|
|
13
|
+
universalChainId?: ChainIdentifier;
|
|
14
|
+
}> & ({
|
|
15
|
+
readonly chainId: ChainIdentifier;
|
|
16
|
+
} | {
|
|
17
|
+
readonly universalChainId: ChainIdentifier;
|
|
18
|
+
});
|
|
19
|
+
/**
|
|
20
|
+
* Returns the deterministic display priority for a destination chain.
|
|
21
|
+
*
|
|
22
|
+
* Lower values sort first. Numeric chain IDs are treated as EIP-155 IDs.
|
|
23
|
+
*
|
|
24
|
+
* Priority order:
|
|
25
|
+
* C-Chain, P-Chain, X-Chain, Ethereum, Bitcoin/BVM, Solana, Base, Polygon, then unknown chains.
|
|
26
|
+
*
|
|
27
|
+
* @param chain - Chain object, CAIP-2 chain ID, or numeric EIP-155 chain ID to prioritize.
|
|
28
|
+
* @returns Numeric priority used by {@link compareDestinationChains}.
|
|
29
|
+
*/
|
|
30
|
+
declare const getDestinationChainPriority: (chain: DestinationChainSortInput | ChainIdentifier) => number;
|
|
31
|
+
/**
|
|
32
|
+
* Compares two destination chains using shared Fusion SDK destination ordering.
|
|
33
|
+
*
|
|
34
|
+
* Sorts by priority first, then by display name, then by chain ID for a stable tie-breaker.
|
|
35
|
+
*
|
|
36
|
+
* @param a - First chain to compare.
|
|
37
|
+
* @param b - Second chain to compare.
|
|
38
|
+
* @returns Negative when `a` sorts first, positive when `b` sorts first, or zero when equivalent.
|
|
39
|
+
*/
|
|
40
|
+
declare const compareDestinationChains: <TChain extends DestinationChainSortInput>(a: TChain, b: TChain) => number;
|
|
41
|
+
/**
|
|
42
|
+
* Returns a new array of destination chains sorted with {@link compareDestinationChains}.
|
|
43
|
+
*
|
|
44
|
+
* The input array is not mutated.
|
|
45
|
+
*
|
|
46
|
+
* @param chains - Destination chains to sort.
|
|
47
|
+
* @returns Sorted copy of the provided chains.
|
|
48
|
+
*/
|
|
49
|
+
declare const sortDestinationChains: <TChain extends DestinationChainSortInput>(chains: readonly TChain[]) => readonly TChain[];
|
|
50
|
+
//#endregion
|
|
51
|
+
export { DestinationChainSortInput, compareDestinationChains, getDestinationChainPriority, sortDestinationChains };
|
|
52
|
+
//# sourceMappingURL=destination-chains.d.ts.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{AvalancheChainIds as e,AvalancheFujiBlockchainChainIds as t,AvalancheMainnetBlockchainChainIds as n,BaseChainIds as r,BitcoinChainIds as i,EthereumChainIds as a,PolygonChainIds as o,SolanaChainIds as s}from"../constants.js";const c=e=>typeof e==`number`?`eip155:${e}`:e,l=e=>{let t=e.universalChainId??e.chainId;return t===void 0?``:c(t)},u=(e,t=l(e))=>e.name??e.chainName??t,d=t=>t===e.MAINNET||t===e.FUJI,f=e=>e===n.P||e===t.P,p=e=>e===n.X||e===t.X,m=e=>e===a.MAINNET||e===a.SEPOLIA,h=e=>e===i.MAINNET||e===i.TESTNET,g=e=>e===s.MAINNET||e===s.DEVNET,_=e=>e===r.MAINNET||e===r.SEPOLIA,v=e=>e===o.MAINNET||e===o.AMOY,y=e=>{let t=typeof e==`object`?l(e):c(e);return d(t)?0:f(t)?1:p(t)?2:m(t)?3:h(t)?4:g(t)?5:_(t)?6:v(t)?7:8},b=(e,t)=>e===t?0:e<t?-1:1,x=(e,t)=>{let n=l(e),r=l(t),i=y(n)-y(r);if(i!==0)return i;let a=u(e,n).localeCompare(u(t,r),`en-US`);return a===0?b(n,r):a},S=e=>[...e].sort(x);export{x as compareDestinationChains,y as getDestinationChainPriority,S as sortDestinationChains};
|
|
2
|
+
//# sourceMappingURL=destination-chains.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"destination-chains.js","names":[],"sources":["../../src/utils/destination-chains.ts"],"sourcesContent":["import {\n AvalancheChainIds,\n AvalancheFujiBlockchainChainIds,\n AvalancheMainnetBlockchainChainIds,\n BaseChainIds,\n BitcoinChainIds,\n EthereumChainIds,\n PolygonChainIds,\n SolanaChainIds,\n} from '../constants';\n\ntype ChainIdentifier = number | string;\n\n/**\n * Chain shape accepted by the destination chain sorting utilities.\n *\n * Supports Fusion `Chain` objects (`chainId`, `chainName`) and app-level chain\n * info objects (`universalChainId`, `name`).\n */\nexport type DestinationChainSortInput = Readonly<{\n chainId?: ChainIdentifier;\n chainName?: string;\n name?: string;\n universalChainId?: ChainIdentifier;\n}> &\n ({ readonly chainId: ChainIdentifier } | { readonly universalChainId: ChainIdentifier });\n\nconst DESTINATION_CHAIN_SORT_LOCALE = 'en-US';\n\nconst asCaip2ChainId = (chainId: ChainIdentifier): string => {\n return typeof chainId === 'number' ? `eip155:${chainId}` : chainId;\n};\n\nconst getDestinationChainId = (chain: DestinationChainSortInput): string => {\n const chainId = chain.universalChainId ?? chain.chainId;\n\n return chainId === undefined ? '' : asCaip2ChainId(chainId);\n};\n\nconst getDestinationChainName = (chain: DestinationChainSortInput, chainId = getDestinationChainId(chain)): string => {\n return chain.name ?? chain.chainName ?? chainId;\n};\n\nconst isCChainId = (chainId: string): boolean => {\n return chainId === AvalancheChainIds.MAINNET || chainId === AvalancheChainIds.FUJI;\n};\n\nconst isPChainId = (chainId: string): boolean => {\n return chainId === AvalancheMainnetBlockchainChainIds.P || chainId === AvalancheFujiBlockchainChainIds.P;\n};\n\nconst isXChainId = (chainId: string): boolean => {\n return chainId === AvalancheMainnetBlockchainChainIds.X || chainId === AvalancheFujiBlockchainChainIds.X;\n};\n\nconst isEthereumChainId = (chainId: string): boolean => {\n return chainId === EthereumChainIds.MAINNET || chainId === EthereumChainIds.SEPOLIA;\n};\n\nconst isBitcoinChainId = (chainId: string): boolean => {\n return chainId === BitcoinChainIds.MAINNET || chainId === BitcoinChainIds.TESTNET;\n};\n\nconst isSolanaChainId = (chainId: string): boolean => {\n return chainId === SolanaChainIds.MAINNET || chainId === SolanaChainIds.DEVNET;\n};\n\nconst isBaseChainId = (chainId: string): boolean => {\n return chainId === BaseChainIds.MAINNET || chainId === BaseChainIds.SEPOLIA;\n};\n\nconst isPolygonChainId = (chainId: string): boolean => {\n return chainId === PolygonChainIds.MAINNET || chainId === PolygonChainIds.AMOY;\n};\n\n/**\n * Returns the deterministic display priority for a destination chain.\n *\n * Lower values sort first. Numeric chain IDs are treated as EIP-155 IDs.\n *\n * Priority order:\n * C-Chain, P-Chain, X-Chain, Ethereum, Bitcoin/BVM, Solana, Base, Polygon, then unknown chains.\n *\n * @param chain - Chain object, CAIP-2 chain ID, or numeric EIP-155 chain ID to prioritize.\n * @returns Numeric priority used by {@link compareDestinationChains}.\n */\nexport const getDestinationChainPriority = (chain: DestinationChainSortInput | ChainIdentifier): number => {\n const chainId = typeof chain === 'object' ? getDestinationChainId(chain) : asCaip2ChainId(chain);\n\n if (isCChainId(chainId)) {\n return 0;\n }\n if (isPChainId(chainId)) {\n return 1;\n }\n if (isXChainId(chainId)) {\n return 2;\n }\n if (isEthereumChainId(chainId)) {\n return 3;\n }\n if (isBitcoinChainId(chainId)) {\n return 4;\n }\n if (isSolanaChainId(chainId)) {\n return 5;\n }\n if (isBaseChainId(chainId)) {\n return 6;\n }\n if (isPolygonChainId(chainId)) {\n return 7;\n }\n\n return 8;\n};\n\nconst compareLexically = (a: string, b: string): number => (a === b ? 0 : a < b ? -1 : 1);\n\n/**\n * Compares two destination chains using shared Fusion SDK destination ordering.\n *\n * Sorts by priority first, then by display name, then by chain ID for a stable tie-breaker.\n *\n * @param a - First chain to compare.\n * @param b - Second chain to compare.\n * @returns Negative when `a` sorts first, positive when `b` sorts first, or zero when equivalent.\n */\nexport const compareDestinationChains = <TChain extends DestinationChainSortInput>(a: TChain, b: TChain): number => {\n const aChainId = getDestinationChainId(a);\n const bChainId = getDestinationChainId(b);\n const priorityDifference = getDestinationChainPriority(aChainId) - getDestinationChainPriority(bChainId);\n\n if (priorityDifference !== 0) {\n return priorityDifference;\n }\n\n // Names are user-facing labels, so locale-aware ordering is still appropriate here.\n const nameDifference = getDestinationChainName(a, aChainId).localeCompare(\n getDestinationChainName(b, bChainId),\n DESTINATION_CHAIN_SORT_LOCALE,\n );\n\n if (nameDifference !== 0) {\n return nameDifference;\n }\n\n // Chain IDs are technical identifiers, so use raw lexical ordering for a deterministic final tie-breaker.\n return compareLexically(aChainId, bChainId);\n};\n\n/**\n * Returns a new array of destination chains sorted with {@link compareDestinationChains}.\n *\n * The input array is not mutated.\n *\n * @param chains - Destination chains to sort.\n * @returns Sorted copy of the provided chains.\n */\nexport const sortDestinationChains = <TChain extends DestinationChainSortInput>(\n chains: readonly TChain[],\n): readonly TChain[] => {\n return [...chains].sort(compareDestinationChains);\n};\n"],"mappings":"uOA2BA,MAEM,EAAkB,GACf,OAAO,GAAY,SAAW,UAAU,IAAY,EAGvD,EAAyB,GAA6C,CAC1E,IAAM,EAAU,EAAM,kBAAoB,EAAM,QAEhD,OAAO,IAAY,IAAA,GAAY,GAAK,EAAe,EAAQ,EAGvD,GAA2B,EAAkC,EAAU,EAAsB,EAAM,GAChG,EAAM,MAAQ,EAAM,WAAa,EAGpC,EAAc,GACX,IAAY,EAAkB,SAAW,IAAY,EAAkB,KAG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