@wormhole-foundation/sdk-base
Advanced tools
Comparing version 1.1.1 to 1.1.2-alpha.0
@@ -66,5 +66,5 @@ export declare const chainIds: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 28, 29, 30, 32, 33, 34, 35, 36, 37, 38, 39, 40, 43, 44, 45, 46, 3104, 4000, 4001, 4002, 4003, 4004, 4005, 4006, 4007, 4008, 10002, 10003, 10004, 10005, 10006, 10007, 10008], chains: ["Solana", "Ethereum", "Terra", "Bsc", "Polygon", "Avalanche", "Oasis", "Algorand", "Aurora", "Fantom", "Karura", "Acala", "Klaytn", "Celo", "Near", "Moonbeam", "Neon", "Terra2", "Injective", "Osmosis", "Sui", "Aptos", "Arbitrum", "Optimism", "Gnosis", "Pythnet", "Xpla", "Btc", "Base", "Sei", "Rootstock", "Scroll", "Mantle", "Blast", "Xlayer", "Linea", "Berachain", "Seievm", "Snaxchain", "Unichain", "Worldchain", "Ink", "Wormchain", "Cosmoshub", "Evmos", "Kujira", "Neutron", "Celestia", "Stargaze", "Seda", "Dymension", "Provenance", "Sepolia", "ArbitrumSepolia", "BaseSepolia", "OptimismSepolia", "Holesky", "PolygonSepolia", "MonadDevnet"]; | ||
readonly has: (args_0: string) => boolean; | ||
readonly get: (args_0: string) => 3 | 1 | 2 | 5 | 6 | 4 | 22 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 23 | 24 | 25 | 26 | 28 | 29 | 30 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 43 | 44 | 45 | 46 | 3104 | 4000 | 4001 | 4002 | 4003 | 4004 | 4005 | 4006 | 4007 | 4008 | 10002 | 10003 | 10004 | 10005 | 10006 | 10007 | 10008 | undefined; | ||
readonly get: (args_0: string) => 3 | 1 | 2 | 5 | 22 | 4 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 23 | 24 | 25 | 26 | 28 | 29 | 30 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 43 | 44 | 45 | 46 | 3104 | 4000 | 4001 | 4002 | 4003 | 4004 | 4005 | 4006 | 4007 | 4008 | 10002 | 10003 | 10004 | 10005 | 10006 | 10007 | 10008 | undefined; | ||
}; | ||
export declare const chainIdToChain: (<const K1 extends 3 | 1 | 2 | 5 | 6 | 4 | 22 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 23 | 24 | 25 | 26 | 28 | 29 | 30 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 43 | 44 | 45 | 46 | 3104 | 4000 | 4001 | 4002 | 4003 | 4004 | 4005 | 4006 | 4007 | 4008 | 10002 | 10003 | 10004 | 10005 | 10006 | 10007 | 10008>(args_0: K1) => { | ||
export declare const chainIdToChain: (<const K1 extends 3 | 1 | 2 | 5 | 22 | 4 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 23 | 24 | 25 | 26 | 28 | 29 | 30 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 43 | 44 | 45 | 46 | 3104 | 4000 | 4001 | 4002 | 4003 | 4004 | 4005 | 4006 | 4007 | 4008 | 10002 | 10003 | 10004 | 10005 | 10006 | 10007 | 10008>(args_0: K1) => { | ||
readonly 1: "Solana"; | ||
@@ -134,3 +134,3 @@ readonly 2: "Ethereum"; | ||
export declare const isChain: (chain: string) => chain is "Solana" | "Ethereum" | "Terra" | "Bsc" | "Polygon" | "Avalanche" | "Oasis" | "Algorand" | "Aurora" | "Fantom" | "Karura" | "Acala" | "Klaytn" | "Celo" | "Near" | "Moonbeam" | "Neon" | "Terra2" | "Injective" | "Osmosis" | "Sui" | "Aptos" | "Arbitrum" | "Optimism" | "Gnosis" | "Pythnet" | "Xpla" | "Btc" | "Base" | "Sei" | "Rootstock" | "Scroll" | "Mantle" | "Blast" | "Xlayer" | "Linea" | "Berachain" | "Seievm" | "Snaxchain" | "Unichain" | "Worldchain" | "Ink" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Neutron" | "Celestia" | "Stargaze" | "Seda" | "Dymension" | "Provenance" | "Sepolia" | "ArbitrumSepolia" | "BaseSepolia" | "OptimismSepolia" | "Holesky" | "PolygonSepolia" | "MonadDevnet"; | ||
export declare const isChainId: (chainId: number) => chainId is 3 | 1 | 2 | 5 | 6 | 4 | 22 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 23 | 24 | 25 | 26 | 28 | 29 | 30 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 43 | 44 | 45 | 46 | 3104 | 4000 | 4001 | 4002 | 4003 | 4004 | 4005 | 4006 | 4007 | 4008 | 10002 | 10003 | 10004 | 10005 | 10006 | 10007 | 10008; | ||
export declare const isChainId: (chainId: number) => chainId is 3 | 1 | 2 | 5 | 22 | 4 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 23 | 24 | 25 | 26 | 28 | 29 | 30 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 43 | 44 | 45 | 46 | 3104 | 4000 | 4001 | 4002 | 4003 | 4004 | 4005 | 4006 | 4007 | 4008 | 10002 | 10003 | 10004 | 10005 | 10006 | 10007 | 10008; | ||
export declare function assertChainId(chainId: number): asserts chainId is ChainId; | ||
@@ -137,0 +137,0 @@ export declare function assertChain(chain: string): asserts chain is Chain; |
@@ -1,3 +0,2 @@ | ||
export declare const guardianKeys: ["0x58CC3AE5C097b213cE3c81979e1B9f9570746AA5", "0xfF6CB952589BDE862c25Ef4392132fb9D4A42157", "0x114De8460193bdf3A2fCf81f86a09765F4762fD1", "0x107A0086b32d7A0977926A205131d8731D39cbEB", "0x8C82B2fd82FaeD2711d59AF0F2499D16e726f6b2", "0x11b39756C042441BE6D8650b69b54EbE715E2343", "0x54Ce5B4D348fb74B958e8966e2ec3dBd4958a7cd", "0x15e7cAF07C4e3DC8e7C469f92C8Cd88FB8005a20", "0x74a3bf913953D695260D88BC1aA25A4eeE363ef0", "0x000aC0076727b35FBea2dAc28fEE5cCB0fEA768e", "0xAF45Ced136b9D9e24903464AE889F5C8a723FC14", "0xf93124b7c738843CBB89E864c862c38cddCccF95", "0xD2CC37A4dc036a8D232b48f62cDD4731412f4890", "0xDA798F6896A3331F64b48c12D1D57Fd9cbe70811", "0x71AA1BE1D36CaFE3867910F99C09e347899C19C3", "0x8192b6E7387CCd768277c17DAb1b7a5027c0b3Cf", "0x178e21ad2E77AE06711549CFBB1f9c7a9d8096e8", "0x5E1487F35515d02A92753504a8D75471b9f49EdB", "0x6FbEBc898F403E4773E95feB15E80C9A99c8348d", "0x13947Bd48b18E53fdAeEe77F3473391aC727C638"]; | ||
export declare const guardianNames: ["JumpCrypto", "Staked", "Figment", "ChainodeTech", "Inotel", "HashQuark", "Chainlayer", "xLabs", "Forbole", "StakingFund", "MoonletWallet", "P2PValidator", "01Node", "MCF", "Everstake", "ChorusOne", "Syncnode", "Triton", "StakingFacilities", "Testnet guardian"]; | ||
export declare const guardianKeys: ["0x58CC3AE5C097b213cE3c81979e1B9f9570746AA5", "0xfF6CB952589BDE862c25Ef4392132fb9D4A42157", "0x114De8460193bdf3A2fCf81f86a09765F4762fD1", "0x107A0086b32d7A0977926A205131d8731D39cbEB", "0x8C82B2fd82FaeD2711d59AF0F2499D16e726f6b2", "0x11b39756C042441BE6D8650b69b54EbE715E2343", "0x54Ce5B4D348fb74B958e8966e2ec3dBd4958a7cd", "0x15e7cAF07C4e3DC8e7C469f92C8Cd88FB8005a20", "0x74a3bf913953D695260D88BC1aA25A4eeE363ef0", "0x000aC0076727b35FBea2dAc28fEE5cCB0fEA768e", "0xAF45Ced136b9D9e24903464AE889F5C8a723FC14", "0xf93124b7c738843CBB89E864c862c38cddCccF95", "0xD2CC37A4dc036a8D232b48f62cDD4731412f4890", "0xDA798F6896A3331F64b48c12D1D57Fd9cbe70811", "0x71AA1BE1D36CaFE3867910F99C09e347899C19C3", "0x8192b6E7387CCd768277c17DAb1b7a5027c0b3Cf", "0x178e21ad2E77AE06711549CFBB1f9c7a9d8096e8", "0x5E1487F35515d02A92753504a8D75471b9f49EdB", "0x6FbEBc898F403E4773E95feB15E80C9A99c8348d", "0x13947Bd48b18E53fdAeEe77F3473391aC727C638"], guardianNames: ["JumpCrypto", "Staked", "Figment", "ChainodeTech", "Inotel", "HashQuark", "Chainlayer", "xLabs", "Forbole", "StakingFund", "MoonletWallet", "P2PValidator", "01Node", "MCF", "Everstake", "ChorusOne", "Syncnode", "Triton", "StakingFacilities", "Testnet guardian"]; | ||
export declare const guardianNameToKey: (<const K1 extends "Mainnet" | "Testnet", const K2 extends keyof { | ||
@@ -4,0 +3,0 @@ Mainnet: { |
"use strict"; | ||
var _a; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -34,4 +35,3 @@ exports.guardianAttestationEta = exports.devnetGuardianPrivateKey = exports.guardianKeyToName = exports.guardianNameToKey = exports.guardianNames = exports.guardianKeys = void 0; | ||
]; | ||
exports.guardianKeys = (0, index_js_1.column)((0, index_js_1.cartesianRightRecursive)(guardianKeyAndNameEntries), 1); | ||
exports.guardianNames = (0, index_js_1.column)((0, index_js_1.cartesianRightRecursive)(guardianKeyAndNameEntries), 2); | ||
_a = (0, index_js_1.filterIndexes)((0, index_js_1.zip)((0, index_js_1.cartesianRightRecursive)(guardianKeyAndNameEntries)), [1, 2]), exports.guardianKeys = _a[0], exports.guardianNames = _a[1]; | ||
exports.guardianNameToKey = (0, index_js_1.constMap)(guardianKeyAndNameEntries, [[0, 2], 1]); | ||
@@ -38,0 +38,0 @@ exports.guardianKeyToName = (0, index_js_1.constMap)(guardianKeyAndNameEntries, [1, [0, 2]]); |
@@ -1,30 +0,39 @@ | ||
import type { RoArray, RoArray2D, IsUnion } from './metaprogramming.js'; | ||
export declare const range: (length: number) => number[]; | ||
export type IndexEs = number | RoArray<number>; | ||
export type ElementIndexPairs<T extends RoArray> = [ | ||
import type { RoPair, RoTuple, RoArray, Extends, Xor, Not } from './metaprogramming.js'; | ||
export type RoTuple2D<T = unknown> = RoTuple<RoTuple<T>>; | ||
export type RoArray2D<T = unknown> = RoArray<RoArray<T>>; | ||
type TupleRangeImpl<L extends number, A extends number[] = []> = A["length"] extends L ? A : TupleRangeImpl<L, [...A, A["length"]]>; | ||
export type TupleRange<L extends number> = number extends L ? never : L extends any ? TupleRangeImpl<L> : never; | ||
export type Range<L extends number> = L extends any ? number extends L ? number[] : TupleRange<L> : never; | ||
export type TupleWithLength<T, L extends number> = TupleRange<L> extends infer R extends RoArray<number> ? [...{ | ||
[K in keyof R]: T; | ||
}] : never; | ||
export type RoTupleWithLength<T, L extends number> = Readonly<TupleWithLength<T, L>>; | ||
export declare const range: <const L extends number>(length: L) => Range<L>; | ||
export type IndexEs = number; | ||
export type HeadTail<T extends RoTuple, Head extends T[number], Tail extends RoTuple<T[number]>> = readonly [Head, ...Tail]; | ||
export type TupleEntries<T extends RoTuple> = [ | ||
...{ | ||
[K in keyof T]: K extends `${infer N extends number}` ? [T[K], N] : never; | ||
} | ||
]; | ||
export declare const elementIndexPairs: <const T extends RoArray>(arr: T) => [...{ [K in keyof T]: K extends `${infer N extends number}` ? [T[K], N] : never; }]; | ||
export type Entries<T extends RoArray> = [ | ||
...{ | ||
[K in keyof T]: K extends `${infer N extends number}` ? [N, T[K]] : never; | ||
} | ||
]; | ||
export declare const entries: <const T extends RoArray>(arr: T) => [...{ [K in keyof T]: K extends `${infer N extends number}` ? [N, T[K]] : never; }]; | ||
export type Flatten<T extends RoArray> = T extends readonly [infer Head, ...infer Tail extends RoArray] ? Head extends RoArray ? [...Head, ...Flatten<Tail>] : [Head, ...Flatten<Tail>] : []; | ||
export type InnerFlatten<T extends RoArray> = [ | ||
export type Entries<T extends RoArray> = T extends RoTuple ? TupleEntries<T> : T extends RoArray<infer U> ? [number, U][] : never; | ||
export declare function entries<const T extends RoTuple>(arr: T): TupleEntries<T>; | ||
export declare function entries<const T extends RoArray>(arr: T): Entries<T>; | ||
export type IsArray<T> = T extends RoArray<any> ? true : false; | ||
export type IsFlat<A extends RoArray> = true extends IsArray<A[number]> ? false : true; | ||
export type TupleFlatten<T extends RoTuple> = T extends HeadTail<T, infer Head, infer Tail> ? Head extends RoTuple ? [...Head, ...TupleFlatten<Tail>] : [Head, ...TupleFlatten<Tail>] : []; | ||
type StripArray<T> = T extends RoArray<infer E> ? E : T; | ||
export type Flatten<A extends RoArray> = A extends RoTuple ? TupleFlatten<A> : StripArray<A[number]>[]; | ||
export declare const flatten: <const A extends RoArray>(arr: A) => Flatten<A>; | ||
export type InnerFlatten<A extends RoArray> = [ | ||
...{ | ||
[K in keyof T]: K extends `${number}` ? T[K] extends RoArray ? Flatten<T[K]> : T[K] : never; | ||
[K in keyof A]: K extends `${number}` ? A[K] extends RoArray ? Flatten<A[K]> : A[K] : never; | ||
} | ||
]; | ||
export type IsFlat<T extends RoArray> = T extends readonly [infer Head, ...infer Tail extends RoArray] ? Head extends RoArray ? false : IsFlat<Tail> : true; | ||
export type Unflatten<T extends RoArray> = [ | ||
export type Unflatten<A extends RoArray> = [ | ||
...{ | ||
[K in keyof T]: K extends `${number}` ? [T[K]] : never; | ||
[K in keyof A]: K extends `${number}` ? [A[K]] : never; | ||
} | ||
]; | ||
export type AllSameLength<T extends RoArray2D, L extends number | void = void> = T extends readonly [infer Head extends RoArray, ...infer Tail extends RoArray2D] ? L extends void ? AllSameLength<Tail, Head["length"]> : Head["length"] extends L ? AllSameLength<Tail, L> : false : true; | ||
export type IsRectangular<T extends RoArray> = T extends RoArray2D ? AllSameLength<T> : IsFlat<T>; | ||
export type IsRectangular<T extends RoTuple> = T extends RoTuple2D ? T extends HeadTail<T, infer Head extends RoTuple, infer Tail extends RoTuple2D> ? Tail extends readonly [] ? true : Tail[number]["length"] extends Head["length"] ? true : false : true : true; | ||
export type Column<A extends RoArray2D, I extends number> = [ | ||
@@ -35,14 +44,21 @@ ...{ | ||
]; | ||
export declare const column: <const A extends RoArray2D, const I extends number>(tupArr: A, index: I) => [...{ [K in keyof A]: K extends `${number}` ? A[K][I] : never; }]; | ||
export type Zip<A extends RoArray2D> = A["length"] extends 0 ? [] : IsRectangular<A> extends true ? A[0] extends infer Head extends RoArray ? [ | ||
export declare const column: <const A extends RoArray2D<unknown>, const I extends number>(tupArr: A, index: I) => [...{ [K in keyof A]: K extends `${number}` ? A[K][I] : never; }]; | ||
export type TupleZip<T extends RoTuple2D> = IsRectangular<T> extends true ? T[0] extends infer Head extends RoTuple ? [ | ||
...{ | ||
[K in keyof Head]: K extends `${number}` ? [...{ | ||
[K2 in keyof A]: K extends keyof A[K2] ? A[K2][K] : never; | ||
[K2 in keyof T]: K extends keyof T[K2] ? T[K2][K] : never; | ||
}] : never; | ||
} | ||
] : [] : never; | ||
export declare const zip: <const Args extends RoArray2D>(arr: Args) => [Zip<Args>] extends [never] ? RoArray2D : Zip<Args>; | ||
export type OnlyIndexes<E extends RoArray, I extends IndexEs> = IsUnion<I> extends false ? I extends number ? OnlyIndexes<E, [I]> : I extends readonly [infer Head extends number, ...infer Tail extends RoArray<number>] ? E[Head] extends undefined ? OnlyIndexes<E, Tail> : [E[Head], ...OnlyIndexes<E, Tail>] : [] : never; | ||
type ExcludeIndexesImpl<T extends RoArray, C extends number> = T extends readonly [infer Head, ...infer Tail] ? Head extends readonly [infer I extends number, infer V] ? I extends C ? ExcludeIndexesImpl<Tail, C> : [V, ...ExcludeIndexesImpl<Tail, C>] : never : []; | ||
export type ExcludeIndexes<T extends RoArray, C extends IndexEs> = ExcludeIndexesImpl<Entries<T>, C extends RoArray<number> ? C[number] : C>; | ||
export type Zip<A extends RoArray2D> = A extends RoTuple2D ? TupleZip<A> : Flatten<A>[number][][]; | ||
export declare const zip: <const Args extends RoArray2D<unknown>>(arr: Args) => Zip<Args>; | ||
export type TuplePickWithOrder<A extends RoArray, I extends RoTuple<number>> = I extends HeadTail<I, infer Head, infer Tail> ? A[Head] extends undefined ? TuplePickWithOrder<A, Tail> : [A[Head], ...TuplePickWithOrder<A, Tail>] : []; | ||
export type PickWithOrder<A extends RoArray, I extends RoArray<number>> = [ | ||
A, | ||
I | ||
] extends [infer T extends RoTuple, infer TI extends RoTuple<number>] ? TuplePickWithOrder<T, TI> : A; | ||
export declare const pickWithOrder: <const A extends RoArray, const I extends RoArray<number>>(arr: A, indexes: I) => PickWithOrder<A, I>; | ||
type FilterIndexesImpl<T extends RoTuple, I extends IndexEs, E extends boolean> = T extends HeadTail<T, infer Head, infer Tail> ? Head extends RoPair<infer J extends number, infer V> ? Not<Xor<Not<E>, Extends<J, I>>> extends true ? [V, ...FilterIndexesImpl<Tail, I, E>] : FilterIndexesImpl<Tail, I, E> : never : []; | ||
export type FilterIndexes<A extends RoArray, I extends IndexEs, E extends boolean = false> = A extends infer T extends RoTuple ? FilterIndexesImpl<Entries<T>, I, E> : A; | ||
export declare const filterIndexes: <const T extends RoArray, const I extends RoArray<number>, const E extends boolean = false>(arr: T, indexes: I, exclude?: E) => FilterIndexes<T, I[number], E>; | ||
export type Cartesian<L, R> = L extends RoArray ? Flatten<[...{ | ||
@@ -49,0 +65,0 @@ [K in keyof L]: K extends `${number}` ? Cartesian<L[K], R> : never; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.zip = exports.column = exports.entries = exports.elementIndexPairs = exports.range = void 0; | ||
exports.filterIndexes = exports.pickWithOrder = exports.zip = exports.column = exports.flatten = exports.entries = exports.range = void 0; | ||
const range = (length) => [...Array(length).keys()]; | ||
exports.range = range; | ||
const elementIndexPairs = (arr) => (0, exports.range)(arr.length).map(i => [arr[i], i]); | ||
exports.elementIndexPairs = elementIndexPairs; | ||
const entries = (arr) => (0, exports.range)(arr.length).map(i => [i, arr[i]]); | ||
function entries(arr) { | ||
return [...arr.entries()]; | ||
} | ||
exports.entries = entries; | ||
const flatten = (arr) => arr.flat(); | ||
exports.flatten = flatten; | ||
const column = (tupArr, index) => tupArr.map((tuple) => tuple[index]); | ||
@@ -14,2 +16,9 @@ exports.column = column; | ||
exports.zip = zip; | ||
const pickWithOrder = (arr, indexes) => indexes.map((i) => arr[i]); | ||
exports.pickWithOrder = pickWithOrder; | ||
const filterIndexes = (arr, indexes, exclude) => { | ||
const indexSet = new Set(Array.isArray(indexes) ? indexes : [indexes]); | ||
return arr.filter((_, i) => indexSet.has(i) !== exclude); | ||
}; | ||
exports.filterIndexes = filterIndexes; | ||
//# sourceMappingURL=array.js.map |
@@ -5,6 +5,5 @@ export * from "./array.js"; | ||
export * from "./misc.js"; | ||
export * from "./layout/index.js"; | ||
export * from "./layout.js"; | ||
export * as amount from "./amount.js"; | ||
export * as layout from "./layout/index.js"; | ||
export * as encoding from "./encoding.js"; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -29,3 +29,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.encoding = exports.layout = exports.amount = void 0; | ||
exports.encoding = exports.amount = void 0; | ||
__exportStar(require("./array.js"), exports); | ||
@@ -35,6 +35,5 @@ __exportStar(require("./mapping.js"), exports); | ||
__exportStar(require("./misc.js"), exports); | ||
__exportStar(require("./layout/index.js"), exports); | ||
__exportStar(require("./layout.js"), exports); | ||
exports.amount = __importStar(require("./amount.js")); | ||
exports.layout = __importStar(require("./layout/index.js")); | ||
exports.encoding = __importStar(require("./encoding.js")); | ||
//# sourceMappingURL=index.js.map |
@@ -1,10 +0,10 @@ | ||
import type { IndexEs, Flatten, InnerFlatten, IsRectangular, Zip, Cartesian, OnlyIndexes, ExcludeIndexes, ElementIndexPairs } from './array.js'; | ||
import type { Widen, RoArray, RoArray2D, RoPair } from './metaprogramming.js'; | ||
export type ShallowMapping<M extends RoArray<readonly [PropertyKey, unknown]>> = { | ||
import type { RoTuple2D, HeadTail, Entries, Flatten, InnerFlatten, IsRectangular, TupleZip, Cartesian, TuplePickWithOrder } from './array.js'; | ||
import type { Widen, RoTuple, RoNeTuple, RoPair } from './metaprogramming.js'; | ||
export type ShallowMapping<M extends RoTuple<readonly [PropertyKey, unknown]>> = { | ||
readonly [E in M[number] as E[0]]: E[1]; | ||
}; | ||
export type MappableKey = PropertyKey | bigint | boolean; | ||
export type MapLevel<K extends MappableKey, V> = RoArray<RoPair<K, V>>; | ||
type MapLevelsTuple = readonly [MappableKey, ...RoArray<MappableKey>, unknown]; | ||
export type MapLevels<T extends MapLevelsTuple> = T extends readonly [infer Head extends MappableKey, ...infer Tail extends RoArray<unknown>] ? Tail extends MapLevelsTuple ? MapLevel<Head, MapLevels<Tail>> : MapLevel<Head, Tail[0]> : never; | ||
export type MapLevel<K extends MappableKey, V> = RoTuple<RoPair<K, V>>; | ||
type MapLevelsTuple = readonly [MappableKey, ...RoTuple<MappableKey>, unknown]; | ||
export type MapLevels<T extends MapLevelsTuple> = T extends HeadTail<T, infer Head extends MappableKey, infer Tail> ? Tail extends MapLevelsTuple ? MapLevel<Head, MapLevels<Tail>> : MapLevel<Head, Tail[0]> : never; | ||
type Depth = [never, 0, 1, 2, 3, 4]; | ||
@@ -14,57 +14,64 @@ type ToExtPropKey<T extends MappableKey> = T extends bigint ? `bigint(${T})` : T extends boolean ? `boolean(${T})` : T; | ||
type MappingEntry<V = unknown> = RoPair<MappableKey, V>; | ||
type MappingEntries<V = unknown> = RoArray<MappingEntry<V>>; | ||
type CombineKeyRowIndexes<K extends MappableKey, T extends MappingEntries<number>, IA extends RoArray<number>, //all values associated with K | ||
U extends MappingEntries<number> = []> = T extends readonly [ | ||
infer Head extends MappingEntry<number>, | ||
...infer Tail extends MappingEntries<number> | ||
] ? Head[0] extends K ? CombineKeyRowIndexes<K, Tail, [...IA, Head[1]], U> : CombineKeyRowIndexes<K, Tail, IA, [...U, Head]> : [IA, U]; | ||
type ToMapEntries<KCI extends MappingEntries<number>, M extends MappingEntries = []> = KCI extends readonly [infer Head, ...infer Tail extends MappingEntries<number>] ? Head extends RoPair<infer K extends MappableKey, infer V extends number> ? CombineKeyRowIndexes<K, Tail, [V]> extends RoPair<infer IA extends RoArray, infer KCIU extends MappingEntries<number>> ? ToMapEntries<KCIU, [...M, [K, IA]]> : never : never : M; | ||
type CartesianRightRecursive<M extends RoArray> = M extends MappingEntries<RoArray> ? Flatten<[ | ||
type MappingEntries<V = unknown> = RoTuple<MappingEntry<V>>; | ||
type CombineKeyRowIndexes<K extends MappableKey, T extends MappingEntries<number>, IA extends RoTuple<number>, //all values associated with K | ||
U extends MappingEntries<number> = []> = T extends HeadTail<T, infer Head, infer Tail> ? Head[0] extends K ? CombineKeyRowIndexes<K, Tail, [...IA, Head[1]], U> : CombineKeyRowIndexes<K, Tail, IA, [...U, Head]> : [IA, U]; | ||
type ToMapEntries<KCI extends MappingEntries<number>, M extends MappingEntries = []> = KCI extends HeadTail<KCI, infer Head, infer Tail> ? Head extends RoPair<infer K extends MappableKey, infer V extends number> ? CombineKeyRowIndexes<K, Tail, [V]> extends RoPair<infer IA extends RoTuple, infer KCIU extends MappingEntries<number>> ? ToMapEntries<KCIU, [...M, [K, IA]]> : never : never : M; | ||
type CartesianRightRecursive<M extends RoTuple> = M extends infer IM extends MappingEntries<RoTuple> ? Flatten<[ | ||
...{ | ||
[K in keyof M]: K extends `${number}` ? InnerFlatten<Cartesian<M[K][0], CartesianRightRecursive<M[K][1]>>> : never; | ||
[K in keyof IM]: K extends `${number}` ? InnerFlatten<Cartesian<IM[K][0], CartesianRightRecursive<IM[K][1]>>> : never; | ||
} | ||
]> : M extends MappingEntry<RoArray> ? Cartesian<M[0], M[1]> : M; | ||
type Shape = RoPair<IndexEs, IndexEs>; | ||
type CartesianSet<T = unknown> = RoArray2D<T>; | ||
type Transpose<T extends RoArray2D> = Zip<T>; | ||
type ProcessNextKeyColmn<KC extends CartesianSet<MappableKey>, VR extends RoArray> = KC["length"] extends 0 ? VR : ExcludeIndexes<KC, 0> extends infer KCR extends CartesianSet<MappableKey> ? ToMapEntries<ElementIndexPairs<KC[0]>> extends infer KRIA extends MappingEntries<RoArray<number>> ? [ | ||
]> : M extends infer IM extends MappingEntry<RoTuple> ? Cartesian<IM[0], IM[1]> : M; | ||
type Shape = RoPair<RoTuple<number>, RoTuple<number>>; | ||
type IndexLike = number | RoNeTuple<number>; | ||
type ShapeLike = RoPair<IndexLike, IndexLike>; | ||
type ShapeLikeToShape<S extends ShapeLike> = S extends RoPair<infer KC extends IndexLike, infer VC extends IndexLike> ? [KC extends number ? [KC] : KC, VC extends number ? [VC] : VC] : never; | ||
type CartesianSet<T = unknown> = RoTuple2D<T>; | ||
type Transpose<T extends RoTuple2D, E = unknown> = TupleZip<T> extends infer R extends RoTuple2D<E> ? R : never; | ||
type FlipInnerPair<T extends RoTuple<RoPair>> = [ | ||
...{ | ||
[K in keyof KRIA]: [ | ||
KRIA[K][0], | ||
ProcessNextKeyColmn<Transpose<OnlyIndexes<Transpose<KCR>, KRIA[K][1]>>, OnlyIndexes<VR, KRIA[K][1]>> | ||
[K in keyof T]: K extends `${number}` ? [T[K][1], T[K][0]] : never; | ||
} | ||
]; | ||
type KeyRowIndexes = MappingEntries<RoTuple<number>>; | ||
type KeyColumnToKeyRowIndexes<KC extends RoTuple<MappableKey>> = FlipInnerPair<Entries<KC>> extends infer FIP extends MappingEntries<number> ? ToMapEntries<FIP> : never; | ||
type ProcessNextKeyColmn<KC extends CartesianSet<MappableKey>, VR extends RoTuple> = KC extends HeadTail<KC, infer Head, infer Tail> ? KeyColumnToKeyRowIndexes<Exclude<Head, undefined>> extends infer KRI extends KeyRowIndexes ? [ | ||
...{ | ||
[K in keyof KRI]: [ | ||
KRI[K][0], | ||
ProcessNextKeyColmn<Transpose<TuplePickWithOrder<Transpose<Tail>, KRI[K][1]>, MappableKey>, TuplePickWithOrder<VR, KRI[K][1]>> | ||
]; | ||
} | ||
] : never : never; | ||
] : never : VR; | ||
type LeafValue<T = unknown> = RoPair<void, T>; | ||
type CombineValueColumnsToLeafValues<VC extends CartesianSet> = (VC["length"] extends 1 ? VC[0] : Transpose<VC>) extends infer VCT extends RoArray ? [...{ | ||
type CombineValueColumnsToLeafValues<VC extends CartesianSet> = (VC["length"] extends 1 ? VC[0] : Transpose<VC>) extends infer VCT extends RoTuple ? [...{ | ||
[K in keyof VCT]: K extends `${number}` ? LeafValue<VCT[K]> : never; | ||
}] : never; | ||
type SplitAndReorderKeyValueColumns<R extends CartesianSet, S extends Shape> = Transpose<R> extends infer C extends CartesianSet ? [OnlyIndexes<C, S[0]>, OnlyIndexes<C, S[1]>] : never; | ||
type UnwrapValuesIfAllAreSingletons<M extends MappingEntries, D extends Depth[number]> = D extends 1 ? M extends MappingEntries<readonly [LeafValue]> ? [...{ | ||
[K in keyof M]: K extends `${number}` ? [M[K][0], M[K][1][0][1]] : never; | ||
}] : void : M extends MappingEntries<MappingEntries> ? [ | ||
type SplitAndReorderKeyValueColumns<R extends CartesianSet, S extends Shape> = Transpose<R> extends infer C extends CartesianSet ? [TuplePickWithOrder<C, S[0]>, TuplePickWithOrder<C, S[1]>] : never; | ||
type UnwrapValuesIfAllAreSingletons<M extends MappingEntries, D extends Depth[number]> = D extends 1 ? M extends infer IM extends MappingEntries<readonly [LeafValue]> ? [...{ | ||
[K in keyof IM]: K extends `${number}` ? [M[K][0], M[K][1][0][1]] : never; | ||
}] : void : M extends infer IM extends MappingEntries<MappingEntries> ? [ | ||
...{ | ||
[K in keyof M]: K extends `${number}` ? [M[K][0], UnwrapValuesIfAllAreSingletons<M[K][1], Depth[D]>] : never; | ||
[K in keyof IM]: K extends `${number}` ? [IM[K][0], UnwrapValuesIfAllAreSingletons<IM[K][1], Depth[D]>] : never; | ||
} | ||
] extends infer U extends MappingEntries ? U : void : never; | ||
type MaybeUnwrapValuesIfAllAreSingletons<M extends MappingEntries, D extends Depth[number]> = UnwrapValuesIfAllAreSingletons<M, D> extends infer V extends MappingEntries ? V : M; | ||
type TransformMapping<M extends MappingEntries, S extends Shape | void = void> = CartesianRightRecursive<M> extends infer CRR extends RoArray2D ? IsRectangular<CRR> extends true ? CRR extends readonly [RoArray, ...RoArray2D] ? S extends Shape ? SplitAndReorderKeyValueColumns<CRR, S> extends [ | ||
type TransformMapping<M extends MappingEntries, S extends Shape | void = void> = CartesianRightRecursive<M> extends infer CRR extends RoTuple2D ? IsRectangular<CRR> extends true ? CRR extends RoNeTuple<RoTuple> ? S extends Shape ? SplitAndReorderKeyValueColumns<CRR, S> extends [ | ||
infer KC extends CartesianSet<MappableKey>, | ||
infer VC extends CartesianSet | ||
] ? KC["length"] extends Depth[number] ? CombineValueColumnsToLeafValues<VC> extends infer VR extends RoArray<LeafValue> ? ProcessNextKeyColmn<KC, VR> extends infer TM extends MappingEntries ? [MaybeUnwrapValuesIfAllAreSingletons<TM, KC["length"]>, KC["length"]] : never : never : never : never : CRR[0] extends readonly [...infer KC extends RoArray, unknown] ? KC["length"] extends Depth[number] ? [M, KC["length"]] : never : never : never : never : never; | ||
] ? KC["length"] extends infer D extends Depth[number] ? CombineValueColumnsToLeafValues<VC> extends infer VR extends RoTuple<LeafValue> ? ProcessNextKeyColmn<KC, VR> extends infer TM extends MappingEntries ? [MaybeUnwrapValuesIfAllAreSingletons<TM, D>, D] : never : never : never : never : CRR[0] extends readonly [...infer KC extends RoTuple, unknown] ? KC["length"] extends infer D extends Depth[number] ? [M, D] : never : never : never : never : never; | ||
type ObjectFromMappingEntries<M extends MappingEntries, D extends Depth[number]> = { | ||
[K in keyof M as (K extends `${number}` ? ToExtPropKey<M[K][0]> : never)]: M[K] extends infer ME extends MappingEntry ? ME[1] extends infer V ? D extends 1 ? V extends LeafValue<infer T> ? T : V extends RoArray<LeafValue> ? [...{ | ||
[K in keyof M as (K extends `${number}` ? ToExtPropKey<M[K][0]> : never)]: M[K] extends infer ME extends MappingEntry ? ME[1] extends infer V ? D extends 1 ? V extends LeafValue<infer T> ? T : V extends RoTuple<LeafValue> ? [...{ | ||
[K2 in keyof V]: K2 extends `${number}` ? V[K2][1] : never; | ||
}] : V : V extends MappingEntries ? ObjectFromMappingEntries<V, Depth[D]> : never : never : never; | ||
}; | ||
export type ToMappingAndDepth<M extends MappingEntries, S extends Shape | void | undefined> = TransformMapping<M, S extends undefined ? void : S> extends [ | ||
export type ToMappingAndDepth<M extends MappingEntries, S extends ShapeLike | undefined> = TransformMapping<M, S extends ShapeLike ? ShapeLikeToShape<S> : void> extends [ | ||
infer TM extends MappingEntries, | ||
infer D extends Depth[number] | ||
] ? [ObjectFromMappingEntries<TM, D>, D] : never; | ||
export type ToMapping<M extends MappingEntries, S extends Shape | void | undefined = undefined> = ToMappingAndDepth<M, S>[0]; | ||
export type ToMapping<M extends MappingEntries, S extends ShapeLike | undefined = undefined> = ToMappingAndDepth<M, S>[0]; | ||
type Mapped = { | ||
[key: PropertyKey]: unknown | Mapped; | ||
}; | ||
type RecursiveAccess<M, KA extends RoArray<MappableKey>> = KA extends readonly [infer Head extends MappableKey, ...infer Tail extends RoArray<MappableKey>] ? M extends Mapped ? RecursiveAccess<M[ToExtPropKey<Head>], Tail> : never : M; | ||
type GenericMappingFunc<M extends Mapped, D extends number> = D extends 1 ? <const K1 extends FromExtPropKey<keyof M>>(...args: [K1]) => RecursiveAccess<M, [K1]> : D extends 2 ? <const K1 extends FromExtPropKey<keyof M>, const K2 extends FromExtPropKey<keyof RecursiveAccess<M, [K1]>>>(...args: [K1, K2]) => RecursiveAccess<M, [K1, K2]> : D extends 3 ? <const K1 extends FromExtPropKey<keyof M>, const K2 extends FromExtPropKey<keyof RecursiveAccess<M, [K1]>>, const K3 extends FromExtPropKey<keyof RecursiveAccess<M, [K1, K2]>>>(...args: [K1, K2, K3]) => RecursiveAccess<M, [K1, K2, K3]> : D extends 4 ? <const K1 extends FromExtPropKey<keyof M>, const K2 extends FromExtPropKey<keyof RecursiveAccess<M, [K1]>>, const K3 extends FromExtPropKey<keyof RecursiveAccess<M, [K1, K2]>>, const K4 extends FromExtPropKey<keyof RecursiveAccess<M, [K1, K2, K3]>>>(...args: [K1, K2, K3, K4]) => RecursiveAccess<M, [K1, K2, K3, K4]> : never; | ||
type RecursiveAccess<M, KA extends RoTuple<MappableKey>> = KA extends HeadTail<KA, infer Head, infer Tail> ? M extends Mapped ? RecursiveAccess<M[ToExtPropKey<Head>], Tail> : never : M; | ||
type GenericMappingFunc<M extends Mapped, D extends number> = D extends 1 ? <const K1 extends FromExtPropKey<keyof M>>(...args: readonly [K1]) => RecursiveAccess<M, [K1]> : D extends 2 ? <const K1 extends FromExtPropKey<keyof M>, const K2 extends FromExtPropKey<keyof RecursiveAccess<M, [K1]>>>(...args: readonly [K1, K2]) => RecursiveAccess<M, [K1, K2]> : D extends 3 ? <const K1 extends FromExtPropKey<keyof M>, const K2 extends FromExtPropKey<keyof RecursiveAccess<M, [K1]>>, const K3 extends FromExtPropKey<keyof RecursiveAccess<M, [K1, K2]>>>(...args: readonly [K1, K2, K3]) => RecursiveAccess<M, [K1, K2, K3]> : D extends 4 ? <const K1 extends FromExtPropKey<keyof M>, const K2 extends FromExtPropKey<keyof RecursiveAccess<M, [K1]>>, const K3 extends FromExtPropKey<keyof RecursiveAccess<M, [K1, K2]>>, const K4 extends FromExtPropKey<keyof RecursiveAccess<M, [K1, K2, K3]>>>(...args: readonly [K1, K2, K3, K4]) => RecursiveAccess<M, [K1, K2, K3, K4]> : never; | ||
type SubMap<M extends Mapped, D extends number, K extends PropertyKey> = K extends keyof M ? M[K] extends Mapped ? ConstMap<M[K], Depth[D]> : never : never; | ||
@@ -81,3 +88,3 @@ type SubMapFunc<M extends Mapped, D extends number> = { | ||
]; | ||
type HasGetFuncs<M extends Mapped, D extends number> = WidenedParamsAndRet<M, D> extends [...infer P extends RoArray<unknown>, infer R] ? { | ||
type HasGetFuncs<M extends Mapped, D extends number> = WidenedParamsAndRet<M, D> extends [...infer P extends RoTuple<unknown>, infer R] ? { | ||
readonly has: (...args: P) => boolean; | ||
@@ -87,6 +94,6 @@ readonly get: (...args: P) => R | undefined; | ||
type ConstMap<M extends Mapped, D extends number> = D extends 1 ? GenericMappingFunc<M, D> & HasGetFuncs<M, D> : GenericMappingFunc<M, D> & HasGetFuncs<M, D> & SubMapFunc<M, D>; | ||
type ToConstMap<M extends MappingEntries, S extends Shape | undefined = undefined> = ToMappingAndDepth<M, S> extends [infer TM extends Mapped, infer D extends Depth[number]] ? ConstMap<TM, D> : never; | ||
export declare const cartesianRightRecursive: <const T extends RoArray>(arr: T) => CartesianRightRecursive<T>; | ||
export declare function constMap<const M extends MappingEntries, const S extends Shape | undefined = undefined>(mappingEntries: M, shape?: S): ToConstMap<M, S>; | ||
type ToConstMap<M extends MappingEntries, S extends ShapeLike | undefined = undefined> = ToMappingAndDepth<M, S> extends [infer TM extends Mapped, infer D extends Depth[number]] ? ConstMap<TM, D> : never; | ||
export declare const cartesianRightRecursive: <const T extends RoTuple>(arr: T) => CartesianRightRecursive<T>; | ||
export declare function constMap<const M extends MappingEntries, const S extends ShapeLike | undefined = undefined>(mappingEntries: M, shape?: S): ToConstMap<M, S>; | ||
export {}; | ||
//# sourceMappingURL=mapping.d.ts.map |
export type Extends<T, U> = [T] extends [U] ? true : false; | ||
export type Function<P extends any[] = any[], R = any> = (...args: P) => R; | ||
export type NeTuple<T = unknown> = [T, ...T[]]; | ||
export type Tuple<T = unknown> = NeTuple<T> | []; | ||
export type RoTuple<T = unknown> = Readonly<Tuple<T>>; | ||
export type RoNeTuple<T = unknown> = Readonly<NeTuple<T>>; | ||
export type RoArray<T = unknown> = readonly T[]; | ||
export type RoArray2D<T = unknown> = RoArray<RoArray<T>>; | ||
export type RoPair<T = unknown, U = unknown> = readonly [T, U]; | ||
export type Function<P extends RoArray<unknown> = RoArray<any>, R = unknown> = (...args: P) => R; | ||
export type Widen<T> = T extends string ? string : T extends number ? number : T extends boolean ? boolean : T extends bigint ? bigint : T extends object ? object : T; | ||
@@ -10,4 +13,7 @@ export type DefinedOrDefault<T, D> = undefined extends T ? D : NonNullable<T>; | ||
export type IsNever<T> = Extends<T, never>; | ||
export type And<T extends RoArray<boolean> | boolean, R extends boolean = true> = R extends true ? T extends RoArray<boolean> ? Extends<T[number], true> : Extends<T, true> : false; | ||
export type Not<B extends boolean> = B extends true ? false : true; | ||
export type And<T extends RoTuple<boolean> | boolean, R extends boolean = true> = R extends true ? T extends RoTuple<boolean> ? false extends T[number] ? false : true : T : false; | ||
export type Or<T extends RoTuple<boolean> | boolean, R extends boolean = false> = R extends false ? T extends RoTuple<boolean> ? true extends T[number] ? true : false : T : true; | ||
type XorImpl<T extends RoTuple<boolean>> = T extends readonly [infer First, infer Second, ...infer Tail extends RoArray<boolean>] ? XorImpl<[boolean extends First | Second ? true : false, ...Tail]> : T extends readonly [infer Final] ? Final : never; | ||
export type Xor<T extends RoTuple<boolean> | boolean, R extends boolean | undefined = undefined> = T extends RoTuple<boolean> ? [...T, ...(undefined extends R ? [] : [Exclude<R, undefined>])] extends infer V extends RoTuple<boolean> ? XorImpl<V> : never : boolean extends Exclude<R, undefined> | T ? true : false; | ||
export type ParseNumber<T> = T extends `${infer N extends number}` ? N : never; | ||
@@ -22,2 +28,3 @@ export type UnionToIntersection<U> = (U extends any ? (_: U) => void : never) extends ((_: infer I) => void) ? I : never; | ||
}; | ||
export {}; | ||
//# sourceMappingURL=metaprogramming.d.ts.map |
@@ -66,5 +66,5 @@ export declare const chainIds: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 28, 29, 30, 32, 33, 34, 35, 36, 37, 38, 39, 40, 43, 44, 45, 46, 3104, 4000, 4001, 4002, 4003, 4004, 4005, 4006, 4007, 4008, 10002, 10003, 10004, 10005, 10006, 10007, 10008], chains: ["Solana", "Ethereum", "Terra", "Bsc", "Polygon", "Avalanche", "Oasis", "Algorand", "Aurora", "Fantom", "Karura", "Acala", "Klaytn", "Celo", "Near", "Moonbeam", "Neon", "Terra2", "Injective", "Osmosis", "Sui", "Aptos", "Arbitrum", "Optimism", "Gnosis", "Pythnet", "Xpla", "Btc", "Base", "Sei", "Rootstock", "Scroll", "Mantle", "Blast", "Xlayer", "Linea", "Berachain", "Seievm", "Snaxchain", "Unichain", "Worldchain", "Ink", "Wormchain", "Cosmoshub", "Evmos", "Kujira", "Neutron", "Celestia", "Stargaze", "Seda", "Dymension", "Provenance", "Sepolia", "ArbitrumSepolia", "BaseSepolia", "OptimismSepolia", "Holesky", "PolygonSepolia", "MonadDevnet"]; | ||
readonly has: (args_0: string) => boolean; | ||
readonly get: (args_0: string) => 3 | 1 | 2 | 5 | 6 | 4 | 22 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 23 | 24 | 25 | 26 | 28 | 29 | 30 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 43 | 44 | 45 | 46 | 3104 | 4000 | 4001 | 4002 | 4003 | 4004 | 4005 | 4006 | 4007 | 4008 | 10002 | 10003 | 10004 | 10005 | 10006 | 10007 | 10008 | undefined; | ||
readonly get: (args_0: string) => 3 | 1 | 2 | 5 | 22 | 4 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 23 | 24 | 25 | 26 | 28 | 29 | 30 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 43 | 44 | 45 | 46 | 3104 | 4000 | 4001 | 4002 | 4003 | 4004 | 4005 | 4006 | 4007 | 4008 | 10002 | 10003 | 10004 | 10005 | 10006 | 10007 | 10008 | undefined; | ||
}; | ||
export declare const chainIdToChain: (<const K1 extends 3 | 1 | 2 | 5 | 6 | 4 | 22 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 23 | 24 | 25 | 26 | 28 | 29 | 30 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 43 | 44 | 45 | 46 | 3104 | 4000 | 4001 | 4002 | 4003 | 4004 | 4005 | 4006 | 4007 | 4008 | 10002 | 10003 | 10004 | 10005 | 10006 | 10007 | 10008>(args_0: K1) => { | ||
export declare const chainIdToChain: (<const K1 extends 3 | 1 | 2 | 5 | 22 | 4 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 23 | 24 | 25 | 26 | 28 | 29 | 30 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 43 | 44 | 45 | 46 | 3104 | 4000 | 4001 | 4002 | 4003 | 4004 | 4005 | 4006 | 4007 | 4008 | 10002 | 10003 | 10004 | 10005 | 10006 | 10007 | 10008>(args_0: K1) => { | ||
readonly 1: "Solana"; | ||
@@ -134,3 +134,3 @@ readonly 2: "Ethereum"; | ||
export declare const isChain: (chain: string) => chain is "Solana" | "Ethereum" | "Terra" | "Bsc" | "Polygon" | "Avalanche" | "Oasis" | "Algorand" | "Aurora" | "Fantom" | "Karura" | "Acala" | "Klaytn" | "Celo" | "Near" | "Moonbeam" | "Neon" | "Terra2" | "Injective" | "Osmosis" | "Sui" | "Aptos" | "Arbitrum" | "Optimism" | "Gnosis" | "Pythnet" | "Xpla" | "Btc" | "Base" | "Sei" | "Rootstock" | "Scroll" | "Mantle" | "Blast" | "Xlayer" | "Linea" | "Berachain" | "Seievm" | "Snaxchain" | "Unichain" | "Worldchain" | "Ink" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Neutron" | "Celestia" | "Stargaze" | "Seda" | "Dymension" | "Provenance" | "Sepolia" | "ArbitrumSepolia" | "BaseSepolia" | "OptimismSepolia" | "Holesky" | "PolygonSepolia" | "MonadDevnet"; | ||
export declare const isChainId: (chainId: number) => chainId is 3 | 1 | 2 | 5 | 6 | 4 | 22 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 23 | 24 | 25 | 26 | 28 | 29 | 30 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 43 | 44 | 45 | 46 | 3104 | 4000 | 4001 | 4002 | 4003 | 4004 | 4005 | 4006 | 4007 | 4008 | 10002 | 10003 | 10004 | 10005 | 10006 | 10007 | 10008; | ||
export declare const isChainId: (chainId: number) => chainId is 3 | 1 | 2 | 5 | 22 | 4 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 23 | 24 | 25 | 26 | 28 | 29 | 30 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 43 | 44 | 45 | 46 | 3104 | 4000 | 4001 | 4002 | 4003 | 4004 | 4005 | 4006 | 4007 | 4008 | 10002 | 10003 | 10004 | 10005 | 10006 | 10007 | 10008; | ||
export declare function assertChainId(chainId: number): asserts chainId is ChainId; | ||
@@ -137,0 +137,0 @@ export declare function assertChain(chain: string): asserts chain is Chain; |
@@ -1,3 +0,2 @@ | ||
export declare const guardianKeys: ["0x58CC3AE5C097b213cE3c81979e1B9f9570746AA5", "0xfF6CB952589BDE862c25Ef4392132fb9D4A42157", "0x114De8460193bdf3A2fCf81f86a09765F4762fD1", "0x107A0086b32d7A0977926A205131d8731D39cbEB", "0x8C82B2fd82FaeD2711d59AF0F2499D16e726f6b2", "0x11b39756C042441BE6D8650b69b54EbE715E2343", "0x54Ce5B4D348fb74B958e8966e2ec3dBd4958a7cd", "0x15e7cAF07C4e3DC8e7C469f92C8Cd88FB8005a20", "0x74a3bf913953D695260D88BC1aA25A4eeE363ef0", "0x000aC0076727b35FBea2dAc28fEE5cCB0fEA768e", "0xAF45Ced136b9D9e24903464AE889F5C8a723FC14", "0xf93124b7c738843CBB89E864c862c38cddCccF95", "0xD2CC37A4dc036a8D232b48f62cDD4731412f4890", "0xDA798F6896A3331F64b48c12D1D57Fd9cbe70811", "0x71AA1BE1D36CaFE3867910F99C09e347899C19C3", "0x8192b6E7387CCd768277c17DAb1b7a5027c0b3Cf", "0x178e21ad2E77AE06711549CFBB1f9c7a9d8096e8", "0x5E1487F35515d02A92753504a8D75471b9f49EdB", "0x6FbEBc898F403E4773E95feB15E80C9A99c8348d", "0x13947Bd48b18E53fdAeEe77F3473391aC727C638"]; | ||
export declare const guardianNames: ["JumpCrypto", "Staked", "Figment", "ChainodeTech", "Inotel", "HashQuark", "Chainlayer", "xLabs", "Forbole", "StakingFund", "MoonletWallet", "P2PValidator", "01Node", "MCF", "Everstake", "ChorusOne", "Syncnode", "Triton", "StakingFacilities", "Testnet guardian"]; | ||
export declare const guardianKeys: ["0x58CC3AE5C097b213cE3c81979e1B9f9570746AA5", "0xfF6CB952589BDE862c25Ef4392132fb9D4A42157", "0x114De8460193bdf3A2fCf81f86a09765F4762fD1", "0x107A0086b32d7A0977926A205131d8731D39cbEB", "0x8C82B2fd82FaeD2711d59AF0F2499D16e726f6b2", "0x11b39756C042441BE6D8650b69b54EbE715E2343", "0x54Ce5B4D348fb74B958e8966e2ec3dBd4958a7cd", "0x15e7cAF07C4e3DC8e7C469f92C8Cd88FB8005a20", "0x74a3bf913953D695260D88BC1aA25A4eeE363ef0", "0x000aC0076727b35FBea2dAc28fEE5cCB0fEA768e", "0xAF45Ced136b9D9e24903464AE889F5C8a723FC14", "0xf93124b7c738843CBB89E864c862c38cddCccF95", "0xD2CC37A4dc036a8D232b48f62cDD4731412f4890", "0xDA798F6896A3331F64b48c12D1D57Fd9cbe70811", "0x71AA1BE1D36CaFE3867910F99C09e347899C19C3", "0x8192b6E7387CCd768277c17DAb1b7a5027c0b3Cf", "0x178e21ad2E77AE06711549CFBB1f9c7a9d8096e8", "0x5E1487F35515d02A92753504a8D75471b9f49EdB", "0x6FbEBc898F403E4773E95feB15E80C9A99c8348d", "0x13947Bd48b18E53fdAeEe77F3473391aC727C638"], guardianNames: ["JumpCrypto", "Staked", "Figment", "ChainodeTech", "Inotel", "HashQuark", "Chainlayer", "xLabs", "Forbole", "StakingFund", "MoonletWallet", "P2PValidator", "01Node", "MCF", "Everstake", "ChorusOne", "Syncnode", "Triton", "StakingFacilities", "Testnet guardian"]; | ||
export declare const guardianNameToKey: (<const K1 extends "Mainnet" | "Testnet", const K2 extends keyof { | ||
@@ -4,0 +3,0 @@ Mainnet: { |
@@ -1,2 +0,2 @@ | ||
import { constMap, column, cartesianRightRecursive } from './../utils/index.js'; | ||
import { constMap, filterIndexes, zip, cartesianRightRecursive } from './../utils/index.js'; | ||
// prettier-ignore | ||
@@ -31,4 +31,3 @@ const guardianKeyAndNameEntries = [[ | ||
]; | ||
export const guardianKeys = column(cartesianRightRecursive(guardianKeyAndNameEntries), 1); | ||
export const guardianNames = column(cartesianRightRecursive(guardianKeyAndNameEntries), 2); | ||
export const [guardianKeys, guardianNames] = filterIndexes(zip(cartesianRightRecursive(guardianKeyAndNameEntries)), [1, 2]); | ||
export const guardianNameToKey = constMap(guardianKeyAndNameEntries, [[0, 2], 1]); | ||
@@ -35,0 +34,0 @@ export const guardianKeyToName = constMap(guardianKeyAndNameEntries, [1, [0, 2]]); |
@@ -1,30 +0,39 @@ | ||
import type { RoArray, RoArray2D, IsUnion } from './metaprogramming.js'; | ||
export declare const range: (length: number) => number[]; | ||
export type IndexEs = number | RoArray<number>; | ||
export type ElementIndexPairs<T extends RoArray> = [ | ||
import type { RoPair, RoTuple, RoArray, Extends, Xor, Not } from './metaprogramming.js'; | ||
export type RoTuple2D<T = unknown> = RoTuple<RoTuple<T>>; | ||
export type RoArray2D<T = unknown> = RoArray<RoArray<T>>; | ||
type TupleRangeImpl<L extends number, A extends number[] = []> = A["length"] extends L ? A : TupleRangeImpl<L, [...A, A["length"]]>; | ||
export type TupleRange<L extends number> = number extends L ? never : L extends any ? TupleRangeImpl<L> : never; | ||
export type Range<L extends number> = L extends any ? number extends L ? number[] : TupleRange<L> : never; | ||
export type TupleWithLength<T, L extends number> = TupleRange<L> extends infer R extends RoArray<number> ? [...{ | ||
[K in keyof R]: T; | ||
}] : never; | ||
export type RoTupleWithLength<T, L extends number> = Readonly<TupleWithLength<T, L>>; | ||
export declare const range: <const L extends number>(length: L) => Range<L>; | ||
export type IndexEs = number; | ||
export type HeadTail<T extends RoTuple, Head extends T[number], Tail extends RoTuple<T[number]>> = readonly [Head, ...Tail]; | ||
export type TupleEntries<T extends RoTuple> = [ | ||
...{ | ||
[K in keyof T]: K extends `${infer N extends number}` ? [T[K], N] : never; | ||
} | ||
]; | ||
export declare const elementIndexPairs: <const T extends RoArray>(arr: T) => [...{ [K in keyof T]: K extends `${infer N extends number}` ? [T[K], N] : never; }]; | ||
export type Entries<T extends RoArray> = [ | ||
...{ | ||
[K in keyof T]: K extends `${infer N extends number}` ? [N, T[K]] : never; | ||
} | ||
]; | ||
export declare const entries: <const T extends RoArray>(arr: T) => [...{ [K in keyof T]: K extends `${infer N extends number}` ? [N, T[K]] : never; }]; | ||
export type Flatten<T extends RoArray> = T extends readonly [infer Head, ...infer Tail extends RoArray] ? Head extends RoArray ? [...Head, ...Flatten<Tail>] : [Head, ...Flatten<Tail>] : []; | ||
export type InnerFlatten<T extends RoArray> = [ | ||
export type Entries<T extends RoArray> = T extends RoTuple ? TupleEntries<T> : T extends RoArray<infer U> ? [number, U][] : never; | ||
export declare function entries<const T extends RoTuple>(arr: T): TupleEntries<T>; | ||
export declare function entries<const T extends RoArray>(arr: T): Entries<T>; | ||
export type IsArray<T> = T extends RoArray<any> ? true : false; | ||
export type IsFlat<A extends RoArray> = true extends IsArray<A[number]> ? false : true; | ||
export type TupleFlatten<T extends RoTuple> = T extends HeadTail<T, infer Head, infer Tail> ? Head extends RoTuple ? [...Head, ...TupleFlatten<Tail>] : [Head, ...TupleFlatten<Tail>] : []; | ||
type StripArray<T> = T extends RoArray<infer E> ? E : T; | ||
export type Flatten<A extends RoArray> = A extends RoTuple ? TupleFlatten<A> : StripArray<A[number]>[]; | ||
export declare const flatten: <const A extends RoArray>(arr: A) => Flatten<A>; | ||
export type InnerFlatten<A extends RoArray> = [ | ||
...{ | ||
[K in keyof T]: K extends `${number}` ? T[K] extends RoArray ? Flatten<T[K]> : T[K] : never; | ||
[K in keyof A]: K extends `${number}` ? A[K] extends RoArray ? Flatten<A[K]> : A[K] : never; | ||
} | ||
]; | ||
export type IsFlat<T extends RoArray> = T extends readonly [infer Head, ...infer Tail extends RoArray] ? Head extends RoArray ? false : IsFlat<Tail> : true; | ||
export type Unflatten<T extends RoArray> = [ | ||
export type Unflatten<A extends RoArray> = [ | ||
...{ | ||
[K in keyof T]: K extends `${number}` ? [T[K]] : never; | ||
[K in keyof A]: K extends `${number}` ? [A[K]] : never; | ||
} | ||
]; | ||
export type AllSameLength<T extends RoArray2D, L extends number | void = void> = T extends readonly [infer Head extends RoArray, ...infer Tail extends RoArray2D] ? L extends void ? AllSameLength<Tail, Head["length"]> : Head["length"] extends L ? AllSameLength<Tail, L> : false : true; | ||
export type IsRectangular<T extends RoArray> = T extends RoArray2D ? AllSameLength<T> : IsFlat<T>; | ||
export type IsRectangular<T extends RoTuple> = T extends RoTuple2D ? T extends HeadTail<T, infer Head extends RoTuple, infer Tail extends RoTuple2D> ? Tail extends readonly [] ? true : Tail[number]["length"] extends Head["length"] ? true : false : true : true; | ||
export type Column<A extends RoArray2D, I extends number> = [ | ||
@@ -35,14 +44,21 @@ ...{ | ||
]; | ||
export declare const column: <const A extends RoArray2D, const I extends number>(tupArr: A, index: I) => [...{ [K in keyof A]: K extends `${number}` ? A[K][I] : never; }]; | ||
export type Zip<A extends RoArray2D> = A["length"] extends 0 ? [] : IsRectangular<A> extends true ? A[0] extends infer Head extends RoArray ? [ | ||
export declare const column: <const A extends RoArray2D<unknown>, const I extends number>(tupArr: A, index: I) => [...{ [K in keyof A]: K extends `${number}` ? A[K][I] : never; }]; | ||
export type TupleZip<T extends RoTuple2D> = IsRectangular<T> extends true ? T[0] extends infer Head extends RoTuple ? [ | ||
...{ | ||
[K in keyof Head]: K extends `${number}` ? [...{ | ||
[K2 in keyof A]: K extends keyof A[K2] ? A[K2][K] : never; | ||
[K2 in keyof T]: K extends keyof T[K2] ? T[K2][K] : never; | ||
}] : never; | ||
} | ||
] : [] : never; | ||
export declare const zip: <const Args extends RoArray2D>(arr: Args) => [Zip<Args>] extends [never] ? RoArray2D : Zip<Args>; | ||
export type OnlyIndexes<E extends RoArray, I extends IndexEs> = IsUnion<I> extends false ? I extends number ? OnlyIndexes<E, [I]> : I extends readonly [infer Head extends number, ...infer Tail extends RoArray<number>] ? E[Head] extends undefined ? OnlyIndexes<E, Tail> : [E[Head], ...OnlyIndexes<E, Tail>] : [] : never; | ||
type ExcludeIndexesImpl<T extends RoArray, C extends number> = T extends readonly [infer Head, ...infer Tail] ? Head extends readonly [infer I extends number, infer V] ? I extends C ? ExcludeIndexesImpl<Tail, C> : [V, ...ExcludeIndexesImpl<Tail, C>] : never : []; | ||
export type ExcludeIndexes<T extends RoArray, C extends IndexEs> = ExcludeIndexesImpl<Entries<T>, C extends RoArray<number> ? C[number] : C>; | ||
export type Zip<A extends RoArray2D> = A extends RoTuple2D ? TupleZip<A> : Flatten<A>[number][][]; | ||
export declare const zip: <const Args extends RoArray2D<unknown>>(arr: Args) => Zip<Args>; | ||
export type TuplePickWithOrder<A extends RoArray, I extends RoTuple<number>> = I extends HeadTail<I, infer Head, infer Tail> ? A[Head] extends undefined ? TuplePickWithOrder<A, Tail> : [A[Head], ...TuplePickWithOrder<A, Tail>] : []; | ||
export type PickWithOrder<A extends RoArray, I extends RoArray<number>> = [ | ||
A, | ||
I | ||
] extends [infer T extends RoTuple, infer TI extends RoTuple<number>] ? TuplePickWithOrder<T, TI> : A; | ||
export declare const pickWithOrder: <const A extends RoArray, const I extends RoArray<number>>(arr: A, indexes: I) => PickWithOrder<A, I>; | ||
type FilterIndexesImpl<T extends RoTuple, I extends IndexEs, E extends boolean> = T extends HeadTail<T, infer Head, infer Tail> ? Head extends RoPair<infer J extends number, infer V> ? Not<Xor<Not<E>, Extends<J, I>>> extends true ? [V, ...FilterIndexesImpl<Tail, I, E>] : FilterIndexesImpl<Tail, I, E> : never : []; | ||
export type FilterIndexes<A extends RoArray, I extends IndexEs, E extends boolean = false> = A extends infer T extends RoTuple ? FilterIndexesImpl<Entries<T>, I, E> : A; | ||
export declare const filterIndexes: <const T extends RoArray, const I extends RoArray<number>, const E extends boolean = false>(arr: T, indexes: I, exclude?: E) => FilterIndexes<T, I[number], E>; | ||
export type Cartesian<L, R> = L extends RoArray ? Flatten<[...{ | ||
@@ -49,0 +65,0 @@ [K in keyof L]: K extends `${number}` ? Cartesian<L[K], R> : never; |
export const range = (length) => [...Array(length).keys()]; | ||
export const elementIndexPairs = (arr) => range(arr.length).map(i => [arr[i], i]); | ||
export const entries = (arr) => range(arr.length).map(i => [i, arr[i]]); | ||
export function entries(arr) { | ||
return [...arr.entries()]; | ||
} | ||
export const flatten = (arr) => arr.flat(); | ||
export const column = (tupArr, index) => tupArr.map((tuple) => tuple[index]); | ||
export const zip = (arr) => range(arr[0].length).map(col => range(arr.length).map(row => arr[row][col])); | ||
export const pickWithOrder = (arr, indexes) => indexes.map((i) => arr[i]); | ||
export const filterIndexes = (arr, indexes, exclude) => { | ||
const indexSet = new Set(Array.isArray(indexes) ? indexes : [indexes]); | ||
return arr.filter((_, i) => indexSet.has(i) !== exclude); | ||
}; | ||
//# sourceMappingURL=array.js.map |
@@ -5,6 +5,5 @@ export * from "./array.js"; | ||
export * from "./misc.js"; | ||
export * from "./layout/index.js"; | ||
export * from "./layout.js"; | ||
export * as amount from "./amount.js"; | ||
export * as layout from "./layout/index.js"; | ||
export * as encoding from "./encoding.js"; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -5,6 +5,5 @@ export * from "./array.js"; | ||
export * from "./misc.js"; | ||
export * from "./layout/index.js"; | ||
export * from "./layout.js"; | ||
export * as amount from "./amount.js"; | ||
export * as layout from "./layout/index.js"; | ||
export * as encoding from "./encoding.js"; | ||
//# sourceMappingURL=index.js.map |
@@ -1,10 +0,10 @@ | ||
import type { IndexEs, Flatten, InnerFlatten, IsRectangular, Zip, Cartesian, OnlyIndexes, ExcludeIndexes, ElementIndexPairs } from './array.js'; | ||
import type { Widen, RoArray, RoArray2D, RoPair } from './metaprogramming.js'; | ||
export type ShallowMapping<M extends RoArray<readonly [PropertyKey, unknown]>> = { | ||
import type { RoTuple2D, HeadTail, Entries, Flatten, InnerFlatten, IsRectangular, TupleZip, Cartesian, TuplePickWithOrder } from './array.js'; | ||
import type { Widen, RoTuple, RoNeTuple, RoPair } from './metaprogramming.js'; | ||
export type ShallowMapping<M extends RoTuple<readonly [PropertyKey, unknown]>> = { | ||
readonly [E in M[number] as E[0]]: E[1]; | ||
}; | ||
export type MappableKey = PropertyKey | bigint | boolean; | ||
export type MapLevel<K extends MappableKey, V> = RoArray<RoPair<K, V>>; | ||
type MapLevelsTuple = readonly [MappableKey, ...RoArray<MappableKey>, unknown]; | ||
export type MapLevels<T extends MapLevelsTuple> = T extends readonly [infer Head extends MappableKey, ...infer Tail extends RoArray<unknown>] ? Tail extends MapLevelsTuple ? MapLevel<Head, MapLevels<Tail>> : MapLevel<Head, Tail[0]> : never; | ||
export type MapLevel<K extends MappableKey, V> = RoTuple<RoPair<K, V>>; | ||
type MapLevelsTuple = readonly [MappableKey, ...RoTuple<MappableKey>, unknown]; | ||
export type MapLevels<T extends MapLevelsTuple> = T extends HeadTail<T, infer Head extends MappableKey, infer Tail> ? Tail extends MapLevelsTuple ? MapLevel<Head, MapLevels<Tail>> : MapLevel<Head, Tail[0]> : never; | ||
type Depth = [never, 0, 1, 2, 3, 4]; | ||
@@ -14,57 +14,64 @@ type ToExtPropKey<T extends MappableKey> = T extends bigint ? `bigint(${T})` : T extends boolean ? `boolean(${T})` : T; | ||
type MappingEntry<V = unknown> = RoPair<MappableKey, V>; | ||
type MappingEntries<V = unknown> = RoArray<MappingEntry<V>>; | ||
type CombineKeyRowIndexes<K extends MappableKey, T extends MappingEntries<number>, IA extends RoArray<number>, //all values associated with K | ||
U extends MappingEntries<number> = []> = T extends readonly [ | ||
infer Head extends MappingEntry<number>, | ||
...infer Tail extends MappingEntries<number> | ||
] ? Head[0] extends K ? CombineKeyRowIndexes<K, Tail, [...IA, Head[1]], U> : CombineKeyRowIndexes<K, Tail, IA, [...U, Head]> : [IA, U]; | ||
type ToMapEntries<KCI extends MappingEntries<number>, M extends MappingEntries = []> = KCI extends readonly [infer Head, ...infer Tail extends MappingEntries<number>] ? Head extends RoPair<infer K extends MappableKey, infer V extends number> ? CombineKeyRowIndexes<K, Tail, [V]> extends RoPair<infer IA extends RoArray, infer KCIU extends MappingEntries<number>> ? ToMapEntries<KCIU, [...M, [K, IA]]> : never : never : M; | ||
type CartesianRightRecursive<M extends RoArray> = M extends MappingEntries<RoArray> ? Flatten<[ | ||
type MappingEntries<V = unknown> = RoTuple<MappingEntry<V>>; | ||
type CombineKeyRowIndexes<K extends MappableKey, T extends MappingEntries<number>, IA extends RoTuple<number>, //all values associated with K | ||
U extends MappingEntries<number> = []> = T extends HeadTail<T, infer Head, infer Tail> ? Head[0] extends K ? CombineKeyRowIndexes<K, Tail, [...IA, Head[1]], U> : CombineKeyRowIndexes<K, Tail, IA, [...U, Head]> : [IA, U]; | ||
type ToMapEntries<KCI extends MappingEntries<number>, M extends MappingEntries = []> = KCI extends HeadTail<KCI, infer Head, infer Tail> ? Head extends RoPair<infer K extends MappableKey, infer V extends number> ? CombineKeyRowIndexes<K, Tail, [V]> extends RoPair<infer IA extends RoTuple, infer KCIU extends MappingEntries<number>> ? ToMapEntries<KCIU, [...M, [K, IA]]> : never : never : M; | ||
type CartesianRightRecursive<M extends RoTuple> = M extends infer IM extends MappingEntries<RoTuple> ? Flatten<[ | ||
...{ | ||
[K in keyof M]: K extends `${number}` ? InnerFlatten<Cartesian<M[K][0], CartesianRightRecursive<M[K][1]>>> : never; | ||
[K in keyof IM]: K extends `${number}` ? InnerFlatten<Cartesian<IM[K][0], CartesianRightRecursive<IM[K][1]>>> : never; | ||
} | ||
]> : M extends MappingEntry<RoArray> ? Cartesian<M[0], M[1]> : M; | ||
type Shape = RoPair<IndexEs, IndexEs>; | ||
type CartesianSet<T = unknown> = RoArray2D<T>; | ||
type Transpose<T extends RoArray2D> = Zip<T>; | ||
type ProcessNextKeyColmn<KC extends CartesianSet<MappableKey>, VR extends RoArray> = KC["length"] extends 0 ? VR : ExcludeIndexes<KC, 0> extends infer KCR extends CartesianSet<MappableKey> ? ToMapEntries<ElementIndexPairs<KC[0]>> extends infer KRIA extends MappingEntries<RoArray<number>> ? [ | ||
]> : M extends infer IM extends MappingEntry<RoTuple> ? Cartesian<IM[0], IM[1]> : M; | ||
type Shape = RoPair<RoTuple<number>, RoTuple<number>>; | ||
type IndexLike = number | RoNeTuple<number>; | ||
type ShapeLike = RoPair<IndexLike, IndexLike>; | ||
type ShapeLikeToShape<S extends ShapeLike> = S extends RoPair<infer KC extends IndexLike, infer VC extends IndexLike> ? [KC extends number ? [KC] : KC, VC extends number ? [VC] : VC] : never; | ||
type CartesianSet<T = unknown> = RoTuple2D<T>; | ||
type Transpose<T extends RoTuple2D, E = unknown> = TupleZip<T> extends infer R extends RoTuple2D<E> ? R : never; | ||
type FlipInnerPair<T extends RoTuple<RoPair>> = [ | ||
...{ | ||
[K in keyof KRIA]: [ | ||
KRIA[K][0], | ||
ProcessNextKeyColmn<Transpose<OnlyIndexes<Transpose<KCR>, KRIA[K][1]>>, OnlyIndexes<VR, KRIA[K][1]>> | ||
[K in keyof T]: K extends `${number}` ? [T[K][1], T[K][0]] : never; | ||
} | ||
]; | ||
type KeyRowIndexes = MappingEntries<RoTuple<number>>; | ||
type KeyColumnToKeyRowIndexes<KC extends RoTuple<MappableKey>> = FlipInnerPair<Entries<KC>> extends infer FIP extends MappingEntries<number> ? ToMapEntries<FIP> : never; | ||
type ProcessNextKeyColmn<KC extends CartesianSet<MappableKey>, VR extends RoTuple> = KC extends HeadTail<KC, infer Head, infer Tail> ? KeyColumnToKeyRowIndexes<Exclude<Head, undefined>> extends infer KRI extends KeyRowIndexes ? [ | ||
...{ | ||
[K in keyof KRI]: [ | ||
KRI[K][0], | ||
ProcessNextKeyColmn<Transpose<TuplePickWithOrder<Transpose<Tail>, KRI[K][1]>, MappableKey>, TuplePickWithOrder<VR, KRI[K][1]>> | ||
]; | ||
} | ||
] : never : never; | ||
] : never : VR; | ||
type LeafValue<T = unknown> = RoPair<void, T>; | ||
type CombineValueColumnsToLeafValues<VC extends CartesianSet> = (VC["length"] extends 1 ? VC[0] : Transpose<VC>) extends infer VCT extends RoArray ? [...{ | ||
type CombineValueColumnsToLeafValues<VC extends CartesianSet> = (VC["length"] extends 1 ? VC[0] : Transpose<VC>) extends infer VCT extends RoTuple ? [...{ | ||
[K in keyof VCT]: K extends `${number}` ? LeafValue<VCT[K]> : never; | ||
}] : never; | ||
type SplitAndReorderKeyValueColumns<R extends CartesianSet, S extends Shape> = Transpose<R> extends infer C extends CartesianSet ? [OnlyIndexes<C, S[0]>, OnlyIndexes<C, S[1]>] : never; | ||
type UnwrapValuesIfAllAreSingletons<M extends MappingEntries, D extends Depth[number]> = D extends 1 ? M extends MappingEntries<readonly [LeafValue]> ? [...{ | ||
[K in keyof M]: K extends `${number}` ? [M[K][0], M[K][1][0][1]] : never; | ||
}] : void : M extends MappingEntries<MappingEntries> ? [ | ||
type SplitAndReorderKeyValueColumns<R extends CartesianSet, S extends Shape> = Transpose<R> extends infer C extends CartesianSet ? [TuplePickWithOrder<C, S[0]>, TuplePickWithOrder<C, S[1]>] : never; | ||
type UnwrapValuesIfAllAreSingletons<M extends MappingEntries, D extends Depth[number]> = D extends 1 ? M extends infer IM extends MappingEntries<readonly [LeafValue]> ? [...{ | ||
[K in keyof IM]: K extends `${number}` ? [M[K][0], M[K][1][0][1]] : never; | ||
}] : void : M extends infer IM extends MappingEntries<MappingEntries> ? [ | ||
...{ | ||
[K in keyof M]: K extends `${number}` ? [M[K][0], UnwrapValuesIfAllAreSingletons<M[K][1], Depth[D]>] : never; | ||
[K in keyof IM]: K extends `${number}` ? [IM[K][0], UnwrapValuesIfAllAreSingletons<IM[K][1], Depth[D]>] : never; | ||
} | ||
] extends infer U extends MappingEntries ? U : void : never; | ||
type MaybeUnwrapValuesIfAllAreSingletons<M extends MappingEntries, D extends Depth[number]> = UnwrapValuesIfAllAreSingletons<M, D> extends infer V extends MappingEntries ? V : M; | ||
type TransformMapping<M extends MappingEntries, S extends Shape | void = void> = CartesianRightRecursive<M> extends infer CRR extends RoArray2D ? IsRectangular<CRR> extends true ? CRR extends readonly [RoArray, ...RoArray2D] ? S extends Shape ? SplitAndReorderKeyValueColumns<CRR, S> extends [ | ||
type TransformMapping<M extends MappingEntries, S extends Shape | void = void> = CartesianRightRecursive<M> extends infer CRR extends RoTuple2D ? IsRectangular<CRR> extends true ? CRR extends RoNeTuple<RoTuple> ? S extends Shape ? SplitAndReorderKeyValueColumns<CRR, S> extends [ | ||
infer KC extends CartesianSet<MappableKey>, | ||
infer VC extends CartesianSet | ||
] ? KC["length"] extends Depth[number] ? CombineValueColumnsToLeafValues<VC> extends infer VR extends RoArray<LeafValue> ? ProcessNextKeyColmn<KC, VR> extends infer TM extends MappingEntries ? [MaybeUnwrapValuesIfAllAreSingletons<TM, KC["length"]>, KC["length"]] : never : never : never : never : CRR[0] extends readonly [...infer KC extends RoArray, unknown] ? KC["length"] extends Depth[number] ? [M, KC["length"]] : never : never : never : never : never; | ||
] ? KC["length"] extends infer D extends Depth[number] ? CombineValueColumnsToLeafValues<VC> extends infer VR extends RoTuple<LeafValue> ? ProcessNextKeyColmn<KC, VR> extends infer TM extends MappingEntries ? [MaybeUnwrapValuesIfAllAreSingletons<TM, D>, D] : never : never : never : never : CRR[0] extends readonly [...infer KC extends RoTuple, unknown] ? KC["length"] extends infer D extends Depth[number] ? [M, D] : never : never : never : never : never; | ||
type ObjectFromMappingEntries<M extends MappingEntries, D extends Depth[number]> = { | ||
[K in keyof M as (K extends `${number}` ? ToExtPropKey<M[K][0]> : never)]: M[K] extends infer ME extends MappingEntry ? ME[1] extends infer V ? D extends 1 ? V extends LeafValue<infer T> ? T : V extends RoArray<LeafValue> ? [...{ | ||
[K in keyof M as (K extends `${number}` ? ToExtPropKey<M[K][0]> : never)]: M[K] extends infer ME extends MappingEntry ? ME[1] extends infer V ? D extends 1 ? V extends LeafValue<infer T> ? T : V extends RoTuple<LeafValue> ? [...{ | ||
[K2 in keyof V]: K2 extends `${number}` ? V[K2][1] : never; | ||
}] : V : V extends MappingEntries ? ObjectFromMappingEntries<V, Depth[D]> : never : never : never; | ||
}; | ||
export type ToMappingAndDepth<M extends MappingEntries, S extends Shape | void | undefined> = TransformMapping<M, S extends undefined ? void : S> extends [ | ||
export type ToMappingAndDepth<M extends MappingEntries, S extends ShapeLike | undefined> = TransformMapping<M, S extends ShapeLike ? ShapeLikeToShape<S> : void> extends [ | ||
infer TM extends MappingEntries, | ||
infer D extends Depth[number] | ||
] ? [ObjectFromMappingEntries<TM, D>, D] : never; | ||
export type ToMapping<M extends MappingEntries, S extends Shape | void | undefined = undefined> = ToMappingAndDepth<M, S>[0]; | ||
export type ToMapping<M extends MappingEntries, S extends ShapeLike | undefined = undefined> = ToMappingAndDepth<M, S>[0]; | ||
type Mapped = { | ||
[key: PropertyKey]: unknown | Mapped; | ||
}; | ||
type RecursiveAccess<M, KA extends RoArray<MappableKey>> = KA extends readonly [infer Head extends MappableKey, ...infer Tail extends RoArray<MappableKey>] ? M extends Mapped ? RecursiveAccess<M[ToExtPropKey<Head>], Tail> : never : M; | ||
type GenericMappingFunc<M extends Mapped, D extends number> = D extends 1 ? <const K1 extends FromExtPropKey<keyof M>>(...args: [K1]) => RecursiveAccess<M, [K1]> : D extends 2 ? <const K1 extends FromExtPropKey<keyof M>, const K2 extends FromExtPropKey<keyof RecursiveAccess<M, [K1]>>>(...args: [K1, K2]) => RecursiveAccess<M, [K1, K2]> : D extends 3 ? <const K1 extends FromExtPropKey<keyof M>, const K2 extends FromExtPropKey<keyof RecursiveAccess<M, [K1]>>, const K3 extends FromExtPropKey<keyof RecursiveAccess<M, [K1, K2]>>>(...args: [K1, K2, K3]) => RecursiveAccess<M, [K1, K2, K3]> : D extends 4 ? <const K1 extends FromExtPropKey<keyof M>, const K2 extends FromExtPropKey<keyof RecursiveAccess<M, [K1]>>, const K3 extends FromExtPropKey<keyof RecursiveAccess<M, [K1, K2]>>, const K4 extends FromExtPropKey<keyof RecursiveAccess<M, [K1, K2, K3]>>>(...args: [K1, K2, K3, K4]) => RecursiveAccess<M, [K1, K2, K3, K4]> : never; | ||
type RecursiveAccess<M, KA extends RoTuple<MappableKey>> = KA extends HeadTail<KA, infer Head, infer Tail> ? M extends Mapped ? RecursiveAccess<M[ToExtPropKey<Head>], Tail> : never : M; | ||
type GenericMappingFunc<M extends Mapped, D extends number> = D extends 1 ? <const K1 extends FromExtPropKey<keyof M>>(...args: readonly [K1]) => RecursiveAccess<M, [K1]> : D extends 2 ? <const K1 extends FromExtPropKey<keyof M>, const K2 extends FromExtPropKey<keyof RecursiveAccess<M, [K1]>>>(...args: readonly [K1, K2]) => RecursiveAccess<M, [K1, K2]> : D extends 3 ? <const K1 extends FromExtPropKey<keyof M>, const K2 extends FromExtPropKey<keyof RecursiveAccess<M, [K1]>>, const K3 extends FromExtPropKey<keyof RecursiveAccess<M, [K1, K2]>>>(...args: readonly [K1, K2, K3]) => RecursiveAccess<M, [K1, K2, K3]> : D extends 4 ? <const K1 extends FromExtPropKey<keyof M>, const K2 extends FromExtPropKey<keyof RecursiveAccess<M, [K1]>>, const K3 extends FromExtPropKey<keyof RecursiveAccess<M, [K1, K2]>>, const K4 extends FromExtPropKey<keyof RecursiveAccess<M, [K1, K2, K3]>>>(...args: readonly [K1, K2, K3, K4]) => RecursiveAccess<M, [K1, K2, K3, K4]> : never; | ||
type SubMap<M extends Mapped, D extends number, K extends PropertyKey> = K extends keyof M ? M[K] extends Mapped ? ConstMap<M[K], Depth[D]> : never : never; | ||
@@ -81,3 +88,3 @@ type SubMapFunc<M extends Mapped, D extends number> = { | ||
]; | ||
type HasGetFuncs<M extends Mapped, D extends number> = WidenedParamsAndRet<M, D> extends [...infer P extends RoArray<unknown>, infer R] ? { | ||
type HasGetFuncs<M extends Mapped, D extends number> = WidenedParamsAndRet<M, D> extends [...infer P extends RoTuple<unknown>, infer R] ? { | ||
readonly has: (...args: P) => boolean; | ||
@@ -87,6 +94,6 @@ readonly get: (...args: P) => R | undefined; | ||
type ConstMap<M extends Mapped, D extends number> = D extends 1 ? GenericMappingFunc<M, D> & HasGetFuncs<M, D> : GenericMappingFunc<M, D> & HasGetFuncs<M, D> & SubMapFunc<M, D>; | ||
type ToConstMap<M extends MappingEntries, S extends Shape | undefined = undefined> = ToMappingAndDepth<M, S> extends [infer TM extends Mapped, infer D extends Depth[number]] ? ConstMap<TM, D> : never; | ||
export declare const cartesianRightRecursive: <const T extends RoArray>(arr: T) => CartesianRightRecursive<T>; | ||
export declare function constMap<const M extends MappingEntries, const S extends Shape | undefined = undefined>(mappingEntries: M, shape?: S): ToConstMap<M, S>; | ||
type ToConstMap<M extends MappingEntries, S extends ShapeLike | undefined = undefined> = ToMappingAndDepth<M, S> extends [infer TM extends Mapped, infer D extends Depth[number]] ? ConstMap<TM, D> : never; | ||
export declare const cartesianRightRecursive: <const T extends RoTuple>(arr: T) => CartesianRightRecursive<T>; | ||
export declare function constMap<const M extends MappingEntries, const S extends ShapeLike | undefined = undefined>(mappingEntries: M, shape?: S): ToConstMap<M, S>; | ||
export {}; | ||
//# sourceMappingURL=mapping.d.ts.map |
export type Extends<T, U> = [T] extends [U] ? true : false; | ||
export type Function<P extends any[] = any[], R = any> = (...args: P) => R; | ||
export type NeTuple<T = unknown> = [T, ...T[]]; | ||
export type Tuple<T = unknown> = NeTuple<T> | []; | ||
export type RoTuple<T = unknown> = Readonly<Tuple<T>>; | ||
export type RoNeTuple<T = unknown> = Readonly<NeTuple<T>>; | ||
export type RoArray<T = unknown> = readonly T[]; | ||
export type RoArray2D<T = unknown> = RoArray<RoArray<T>>; | ||
export type RoPair<T = unknown, U = unknown> = readonly [T, U]; | ||
export type Function<P extends RoArray<unknown> = RoArray<any>, R = unknown> = (...args: P) => R; | ||
export type Widen<T> = T extends string ? string : T extends number ? number : T extends boolean ? boolean : T extends bigint ? bigint : T extends object ? object : T; | ||
@@ -10,4 +13,7 @@ export type DefinedOrDefault<T, D> = undefined extends T ? D : NonNullable<T>; | ||
export type IsNever<T> = Extends<T, never>; | ||
export type And<T extends RoArray<boolean> | boolean, R extends boolean = true> = R extends true ? T extends RoArray<boolean> ? Extends<T[number], true> : Extends<T, true> : false; | ||
export type Not<B extends boolean> = B extends true ? false : true; | ||
export type And<T extends RoTuple<boolean> | boolean, R extends boolean = true> = R extends true ? T extends RoTuple<boolean> ? false extends T[number] ? false : true : T : false; | ||
export type Or<T extends RoTuple<boolean> | boolean, R extends boolean = false> = R extends false ? T extends RoTuple<boolean> ? true extends T[number] ? true : false : T : true; | ||
type XorImpl<T extends RoTuple<boolean>> = T extends readonly [infer First, infer Second, ...infer Tail extends RoArray<boolean>] ? XorImpl<[boolean extends First | Second ? true : false, ...Tail]> : T extends readonly [infer Final] ? Final : never; | ||
export type Xor<T extends RoTuple<boolean> | boolean, R extends boolean | undefined = undefined> = T extends RoTuple<boolean> ? [...T, ...(undefined extends R ? [] : [Exclude<R, undefined>])] extends infer V extends RoTuple<boolean> ? XorImpl<V> : never : boolean extends Exclude<R, undefined> | T ? true : false; | ||
export type ParseNumber<T> = T extends `${infer N extends number}` ? N : never; | ||
@@ -22,2 +28,3 @@ export type UnionToIntersection<U> = (U extends any ? (_: U) => void : never) extends ((_: infer I) => void) ? I : never; | ||
}; | ||
export {}; | ||
//# sourceMappingURL=metaprogramming.d.ts.map |
{ | ||
"name": "@wormhole-foundation/sdk-base", | ||
"version": "1.1.1", | ||
"version": "1.1.2-alpha.0", | ||
"repository": { | ||
@@ -119,3 +119,4 @@ "type": "git", | ||
"dependencies": { | ||
"@scure/base": "^1.1.3" | ||
"@scure/base": "^1.1.3", | ||
"binary-layout": "^1.0.3" | ||
}, | ||
@@ -122,0 +123,0 @@ "sideEffects": false, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4681
18
187
4106446
2
274
75191
2
1
260
0
+ Addedbinary-layout@^1.0.3
+ Addedbinary-layout@1.0.3(transitive)