Socket
Socket
Sign inDemoInstall

@wormhole-foundation/sdk-base

Package Overview
Dependencies
Maintainers
4
Versions
239
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wormhole-foundation/sdk-base - npm Package Compare versions

Comparing version 0.1.8-beta.5 to 0.1.8-beta.6

6

dist/cjs/constants/chains.d.ts

@@ -1,2 +0,2 @@

export declare const chains: readonly ["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", "Wormchain", "Cosmoshub", "Evmos", "Kujira", "Sepolia"], chainIds: readonly [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, 3104, 4000, 4001, 4002, 10002];
export declare const 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", "Wormchain", "Cosmoshub", "Evmos", "Kujira", "Sepolia"], 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, 3104, 4000, 4001, 4002, 10002];
export type ChainName = (typeof chains)[number];

@@ -13,7 +13,7 @@ export type ChainId = (typeof chainIds)[number];

};
export declare const chainIdToChain: (<K1 extends 3 | 1 | 5 | 2 | 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 | 3104 | 4000 | 4001 | 4002 | 10002>(args_0: K1) => (K1 extends bigint | boolean | PropertyKey ? import("..").AssertType<K1 extends bigint ? `bigint(${K1})` : K1 extends boolean ? `boolean(${K1})` : K1, PropertyKey> : never) extends 3 | 1 | 5 | 2 | 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 | 3104 | 4000 | 4001 | 4002 | 10002 ? import("../utils/mapping").ObjectFromMappingEntries<[readonly [1, readonly [readonly ["Solana"]]], readonly [2, readonly [readonly ["Ethereum"]]], readonly [3, readonly [readonly ["Terra"]]], readonly [4, readonly [readonly ["Bsc"]]], readonly [5, readonly [readonly ["Polygon"]]], readonly [6, readonly [readonly ["Avalanche"]]], readonly [7, readonly [readonly ["Oasis"]]], readonly [8, readonly [readonly ["Algorand"]]], readonly [9, readonly [readonly ["Aurora"]]], readonly [10, readonly [readonly ["Fantom"]]], readonly [11, readonly [readonly ["Karura"]]], readonly [12, readonly [readonly ["Acala"]]], readonly [13, readonly [readonly ["Klaytn"]]], readonly [14, readonly [readonly ["Celo"]]], readonly [15, readonly [readonly ["Near"]]], readonly [16, readonly [readonly ["Moonbeam"]]], readonly [17, readonly [readonly ["Neon"]]], readonly [18, readonly [readonly ["Terra2"]]], readonly [19, readonly [readonly ["Injective"]]], readonly [20, readonly [readonly ["Osmosis"]]], readonly [21, readonly [readonly ["Sui"]]], readonly [22, readonly [readonly ["Aptos"]]], readonly [23, readonly [readonly ["Arbitrum"]]], readonly [24, readonly [readonly ["Optimism"]]], readonly [25, readonly [readonly ["Gnosis"]]], readonly [26, readonly [readonly ["Pythnet"]]], readonly [28, readonly [readonly ["Xpla"]]], readonly [29, readonly [readonly ["Btc"]]], readonly [30, readonly [readonly ["Base"]]], readonly [32, readonly [readonly ["Sei"]]], readonly [33, readonly [readonly ["Rootstock"]]], readonly [3104, readonly [readonly ["Wormchain"]]], readonly [4000, readonly [readonly ["Cosmoshub"]]], readonly [4001, readonly [readonly ["Evmos"]]], readonly [4002, readonly [readonly ["Kujira"]]], readonly [10002, readonly [readonly ["Sepolia"]]]]>[(3 | 1 | 5 | 2 | 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 | 3104 | 4000 | 4001 | 4002 | 10002) & (K1 extends bigint | boolean | PropertyKey ? import("..").AssertType<K1 extends bigint ? `bigint(${K1})` : K1 extends boolean ? `boolean(${K1})` : K1, PropertyKey> : never)] extends {
export declare const chainIdToChain: (<K1 extends 3 | 1 | 5 | 2 | 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 | 3104 | 4000 | 4001 | 4002 | 10002>(args_0: K1) => (K1 extends bigint | boolean | PropertyKey ? import("..").AssertType<K1 extends bigint ? `bigint(${K1})` : K1 extends boolean ? `boolean(${K1})` : K1, PropertyKey> : never) extends 3 | 1 | 5 | 2 | 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 | 3104 | 4000 | 4001 | 4002 | 10002 ? import("../utils/mapping").ObjectFromMappingEntries<[readonly [1, [["Solana"]]], readonly [2, [["Ethereum"]]], readonly [3, [["Terra"]]], readonly [4, [["Bsc"]]], readonly [5, [["Polygon"]]], readonly [6, [["Avalanche"]]], readonly [7, [["Oasis"]]], readonly [8, [["Algorand"]]], readonly [9, [["Aurora"]]], readonly [10, [["Fantom"]]], readonly [11, [["Karura"]]], readonly [12, [["Acala"]]], readonly [13, [["Klaytn"]]], readonly [14, [["Celo"]]], readonly [15, [["Near"]]], readonly [16, [["Moonbeam"]]], readonly [17, [["Neon"]]], readonly [18, [["Terra2"]]], readonly [19, [["Injective"]]], readonly [20, [["Osmosis"]]], readonly [21, [["Sui"]]], readonly [22, [["Aptos"]]], readonly [23, [["Arbitrum"]]], readonly [24, [["Optimism"]]], readonly [25, [["Gnosis"]]], readonly [26, [["Pythnet"]]], readonly [28, [["Xpla"]]], readonly [29, [["Btc"]]], readonly [30, [["Base"]]], readonly [32, [["Sei"]]], readonly [33, [["Rootstock"]]], readonly [3104, [["Wormchain"]]], readonly [4000, [["Cosmoshub"]]], readonly [4001, [["Evmos"]]], readonly [4002, [["Kujira"]]], readonly [10002, [["Sepolia"]]]]>[(3 | 1 | 5 | 2 | 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 | 3104 | 4000 | 4001 | 4002 | 10002) & (K1 extends bigint | boolean | PropertyKey ? import("..").AssertType<K1 extends bigint ? `bigint(${K1})` : K1 extends boolean ? `boolean(${K1})` : K1, PropertyKey> : never)] extends {
[key: string]: unknown;
[key: number]: unknown;
[key: symbol]: unknown;
} ? import("../utils/mapping").ObjectFromMappingEntries<[readonly [1, readonly [readonly ["Solana"]]], readonly [2, readonly [readonly ["Ethereum"]]], readonly [3, readonly [readonly ["Terra"]]], readonly [4, readonly [readonly ["Bsc"]]], readonly [5, readonly [readonly ["Polygon"]]], readonly [6, readonly [readonly ["Avalanche"]]], readonly [7, readonly [readonly ["Oasis"]]], readonly [8, readonly [readonly ["Algorand"]]], readonly [9, readonly [readonly ["Aurora"]]], readonly [10, readonly [readonly ["Fantom"]]], readonly [11, readonly [readonly ["Karura"]]], readonly [12, readonly [readonly ["Acala"]]], readonly [13, readonly [readonly ["Klaytn"]]], readonly [14, readonly [readonly ["Celo"]]], readonly [15, readonly [readonly ["Near"]]], readonly [16, readonly [readonly ["Moonbeam"]]], readonly [17, readonly [readonly ["Neon"]]], readonly [18, readonly [readonly ["Terra2"]]], readonly [19, readonly [readonly ["Injective"]]], readonly [20, readonly [readonly ["Osmosis"]]], readonly [21, readonly [readonly ["Sui"]]], readonly [22, readonly [readonly ["Aptos"]]], readonly [23, readonly [readonly ["Arbitrum"]]], readonly [24, readonly [readonly ["Optimism"]]], readonly [25, readonly [readonly ["Gnosis"]]], readonly [26, readonly [readonly ["Pythnet"]]], readonly [28, readonly [readonly ["Xpla"]]], readonly [29, readonly [readonly ["Btc"]]], readonly [30, readonly [readonly ["Base"]]], readonly [32, readonly [readonly ["Sei"]]], readonly [33, readonly [readonly ["Rootstock"]]], readonly [3104, readonly [readonly ["Wormchain"]]], readonly [4000, readonly [readonly ["Cosmoshub"]]], readonly [4001, readonly [readonly ["Evmos"]]], readonly [4002, readonly [readonly ["Kujira"]]], readonly [10002, readonly [readonly ["Sepolia"]]]]>[(3 | 1 | 5 | 2 | 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 | 3104 | 4000 | 4001 | 4002 | 10002) & (K1 extends bigint | boolean | PropertyKey ? import("..").AssertType<K1 extends bigint ? `bigint(${K1})` : K1 extends boolean ? `boolean(${K1})` : K1, PropertyKey> : never)] : import("../utils/mapping").ObjectFromMappingEntries<[readonly [1, readonly [readonly ["Solana"]]], readonly [2, readonly [readonly ["Ethereum"]]], readonly [3, readonly [readonly ["Terra"]]], readonly [4, readonly [readonly ["Bsc"]]], readonly [5, readonly [readonly ["Polygon"]]], readonly [6, readonly [readonly ["Avalanche"]]], readonly [7, readonly [readonly ["Oasis"]]], readonly [8, readonly [readonly ["Algorand"]]], readonly [9, readonly [readonly ["Aurora"]]], readonly [10, readonly [readonly ["Fantom"]]], readonly [11, readonly [readonly ["Karura"]]], readonly [12, readonly [readonly ["Acala"]]], readonly [13, readonly [readonly ["Klaytn"]]], readonly [14, readonly [readonly ["Celo"]]], readonly [15, readonly [readonly ["Near"]]], readonly [16, readonly [readonly ["Moonbeam"]]], readonly [17, readonly [readonly ["Neon"]]], readonly [18, readonly [readonly ["Terra2"]]], readonly [19, readonly [readonly ["Injective"]]], readonly [20, readonly [readonly ["Osmosis"]]], readonly [21, readonly [readonly ["Sui"]]], readonly [22, readonly [readonly ["Aptos"]]], readonly [23, readonly [readonly ["Arbitrum"]]], readonly [24, readonly [readonly ["Optimism"]]], readonly [25, readonly [readonly ["Gnosis"]]], readonly [26, readonly [readonly ["Pythnet"]]], readonly [28, readonly [readonly ["Xpla"]]], readonly [29, readonly [readonly ["Btc"]]], readonly [30, readonly [readonly ["Base"]]], readonly [32, readonly [readonly ["Sei"]]], readonly [33, readonly [readonly ["Rootstock"]]], readonly [3104, readonly [readonly ["Wormchain"]]], readonly [4000, readonly [readonly ["Cosmoshub"]]], readonly [4001, readonly [readonly ["Evmos"]]], readonly [4002, readonly [readonly ["Kujira"]]], readonly [10002, readonly [readonly ["Sepolia"]]]]>[(3 | 1 | 5 | 2 | 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 | 3104 | 4000 | 4001 | 4002 | 10002) & (K1 extends bigint | boolean | PropertyKey ? import("..").AssertType<K1 extends bigint ? `bigint(${K1})` : K1 extends boolean ? `boolean(${K1})` : K1, PropertyKey> : never)] : never) & {
} ? import("../utils/mapping").ObjectFromMappingEntries<[readonly [1, [["Solana"]]], readonly [2, [["Ethereum"]]], readonly [3, [["Terra"]]], readonly [4, [["Bsc"]]], readonly [5, [["Polygon"]]], readonly [6, [["Avalanche"]]], readonly [7, [["Oasis"]]], readonly [8, [["Algorand"]]], readonly [9, [["Aurora"]]], readonly [10, [["Fantom"]]], readonly [11, [["Karura"]]], readonly [12, [["Acala"]]], readonly [13, [["Klaytn"]]], readonly [14, [["Celo"]]], readonly [15, [["Near"]]], readonly [16, [["Moonbeam"]]], readonly [17, [["Neon"]]], readonly [18, [["Terra2"]]], readonly [19, [["Injective"]]], readonly [20, [["Osmosis"]]], readonly [21, [["Sui"]]], readonly [22, [["Aptos"]]], readonly [23, [["Arbitrum"]]], readonly [24, [["Optimism"]]], readonly [25, [["Gnosis"]]], readonly [26, [["Pythnet"]]], readonly [28, [["Xpla"]]], readonly [29, [["Btc"]]], readonly [30, [["Base"]]], readonly [32, [["Sei"]]], readonly [33, [["Rootstock"]]], readonly [3104, [["Wormchain"]]], readonly [4000, [["Cosmoshub"]]], readonly [4001, [["Evmos"]]], readonly [4002, [["Kujira"]]], readonly [10002, [["Sepolia"]]]]>[(3 | 1 | 5 | 2 | 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 | 3104 | 4000 | 4001 | 4002 | 10002) & (K1 extends bigint | boolean | PropertyKey ? import("..").AssertType<K1 extends bigint ? `bigint(${K1})` : K1 extends boolean ? `boolean(${K1})` : K1, PropertyKey> : never)] : import("../utils/mapping").ObjectFromMappingEntries<[readonly [1, [["Solana"]]], readonly [2, [["Ethereum"]]], readonly [3, [["Terra"]]], readonly [4, [["Bsc"]]], readonly [5, [["Polygon"]]], readonly [6, [["Avalanche"]]], readonly [7, [["Oasis"]]], readonly [8, [["Algorand"]]], readonly [9, [["Aurora"]]], readonly [10, [["Fantom"]]], readonly [11, [["Karura"]]], readonly [12, [["Acala"]]], readonly [13, [["Klaytn"]]], readonly [14, [["Celo"]]], readonly [15, [["Near"]]], readonly [16, [["Moonbeam"]]], readonly [17, [["Neon"]]], readonly [18, [["Terra2"]]], readonly [19, [["Injective"]]], readonly [20, [["Osmosis"]]], readonly [21, [["Sui"]]], readonly [22, [["Aptos"]]], readonly [23, [["Arbitrum"]]], readonly [24, [["Optimism"]]], readonly [25, [["Gnosis"]]], readonly [26, [["Pythnet"]]], readonly [28, [["Xpla"]]], readonly [29, [["Btc"]]], readonly [30, [["Base"]]], readonly [32, [["Sei"]]], readonly [33, [["Rootstock"]]], readonly [3104, [["Wormchain"]]], readonly [4000, [["Cosmoshub"]]], readonly [4001, [["Evmos"]]], readonly [4002, [["Kujira"]]], readonly [10002, [["Sepolia"]]]]>[(3 | 1 | 5 | 2 | 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 | 3104 | 4000 | 4001 | 4002 | 10002) & (K1 extends bigint | boolean | PropertyKey ? import("..").AssertType<K1 extends bigint ? `bigint(${K1})` : K1 extends boolean ? `boolean(${K1})` : K1, PropertyKey> : never)] : never) & {
get: (args_0: number) => "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" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Sepolia" | undefined;

@@ -20,0 +20,0 @@ has: (args_0: number) => boolean;

import { Network } from "./networks";
import { Chain, ChainName } from "./chains";
export declare const circleChains: readonly ["Ethereum", "Avalanche", "Optimism", "Arbitrum", "Base"], circleChainIds: readonly [0, 1, 2, 3, 6];
export declare const circleChains: ["Ethereum", "Avalanche", "Optimism", "Arbitrum", "Base"], circleChainIds: [0, 1, 2, 3, 6];
export type CircleChainName = (typeof circleChains)[number];
export type CircleChainId = (typeof circleChainIds)[number];
export declare const circleNetworks: readonly ["Mainnet", "Testnet"], _: readonly [readonly [readonly ["Ethereum", "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"], readonly ["Avalanche", "0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e"], readonly ["Arbitrum", "0xaf88d065e77c8cC2239327C5EDb3A432268e5831"], readonly ["Optimism", "0x179522635726710dd7d2035a81d856de4aa7836c"], readonly ["Base", "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913"]], readonly [readonly ["Avalanche", "0x5425890298aed601595a70AB815c96711a31Bc65"], readonly ["Arbitrum", "0xfd064A18f3BF249cf1f87FC203E90D8f650f2d63"], readonly ["Ethereum", "0x07865c6e87b9f70255377e024ace6630c1eaa37f"], readonly ["Optimism", "0xe05606174bac4A6364B31bd0eCA4bf4dD368f8C6"], readonly ["Base", "0xf175520c52418dfe19c8098071a252da48cd1c19"]]];
export declare const circleNetworks: ["Mainnet", "Testnet"], _: [readonly [readonly ["Ethereum", "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"], readonly ["Avalanche", "0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e"], readonly ["Arbitrum", "0xaf88d065e77c8cC2239327C5EDb3A432268e5831"], readonly ["Optimism", "0x179522635726710dd7d2035a81d856de4aa7836c"], readonly ["Base", "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913"]], readonly [readonly ["Avalanche", "0x5425890298aed601595a70AB815c96711a31Bc65"], readonly ["Arbitrum", "0xfd064A18f3BF249cf1f87FC203E90D8f650f2d63"], readonly ["Ethereum", "0x07865c6e87b9f70255377e024ace6630c1eaa37f"], readonly ["Optimism", "0xe05606174bac4A6364B31bd0eCA4bf4dD368f8C6"], readonly ["Base", "0xf175520c52418dfe19c8098071a252da48cd1c19"]]];
export type CircleNetwork = (typeof circleNetworks)[number];

@@ -16,7 +16,7 @@ export declare const circleChainId: (<K1 extends "Ethereum" | "Avalanche" | "Arbitrum" | "Optimism" | "Base">(args_0: K1) => (K1 extends bigint | boolean | PropertyKey ? import("../utils").AssertType<K1 extends bigint ? `bigint(${K1})` : K1 extends boolean ? `boolean(${K1})` : K1, PropertyKey> : never) extends "Ethereum" | "Avalanche" | "Arbitrum" | "Optimism" | "Base" ? import("../utils").ObjectFromMappingEntries<readonly [readonly ["Ethereum", 0], readonly ["Avalanche", 1], readonly ["Optimism", 2], readonly ["Arbitrum", 3], readonly ["Base", 6]]>[("Ethereum" | "Avalanche" | "Arbitrum" | "Optimism" | "Base") & (K1 extends bigint | boolean | PropertyKey ? import("../utils").AssertType<K1 extends bigint ? `bigint(${K1})` : K1 extends boolean ? `boolean(${K1})` : K1, PropertyKey> : never)] extends {

};
export declare const circleChainIdToChainName: (<K1 extends 0 | 3 | 1 | 2 | 6>(args_0: K1) => (K1 extends bigint | boolean | PropertyKey ? import("../utils").AssertType<K1 extends bigint ? `bigint(${K1})` : K1 extends boolean ? `boolean(${K1})` : K1, PropertyKey> : never) extends 0 | 3 | 1 | 2 | 6 ? import("../utils").ObjectFromMappingEntries<[readonly [0, readonly [readonly ["Ethereum"]]], readonly [1, readonly [readonly ["Avalanche"]]], readonly [2, readonly [readonly ["Optimism"]]], readonly [3, readonly [readonly ["Arbitrum"]]], readonly [6, readonly [readonly ["Base"]]]]>[(0 | 3 | 1 | 2 | 6) & (K1 extends bigint | boolean | PropertyKey ? import("../utils").AssertType<K1 extends bigint ? `bigint(${K1})` : K1 extends boolean ? `boolean(${K1})` : K1, PropertyKey> : never)] extends {
export declare const circleChainIdToChainName: (<K1 extends 0 | 3 | 1 | 2 | 6>(args_0: K1) => (K1 extends bigint | boolean | PropertyKey ? import("../utils").AssertType<K1 extends bigint ? `bigint(${K1})` : K1 extends boolean ? `boolean(${K1})` : K1, PropertyKey> : never) extends 0 | 3 | 1 | 2 | 6 ? import("../utils").ObjectFromMappingEntries<[readonly [0, [["Ethereum"]]], readonly [1, [["Avalanche"]]], readonly [2, [["Optimism"]]], readonly [3, [["Arbitrum"]]], readonly [6, [["Base"]]]]>[(0 | 3 | 1 | 2 | 6) & (K1 extends bigint | boolean | PropertyKey ? import("../utils").AssertType<K1 extends bigint ? `bigint(${K1})` : K1 extends boolean ? `boolean(${K1})` : K1, PropertyKey> : never)] extends {
[key: string]: unknown;
[key: number]: unknown;
[key: symbol]: unknown;
} ? import("../utils").ObjectFromMappingEntries<[readonly [0, readonly [readonly ["Ethereum"]]], readonly [1, readonly [readonly ["Avalanche"]]], readonly [2, readonly [readonly ["Optimism"]]], readonly [3, readonly [readonly ["Arbitrum"]]], readonly [6, readonly [readonly ["Base"]]]]>[(0 | 3 | 1 | 2 | 6) & (K1 extends bigint | boolean | PropertyKey ? import("../utils").AssertType<K1 extends bigint ? `bigint(${K1})` : K1 extends boolean ? `boolean(${K1})` : K1, PropertyKey> : never)] : import("../utils").ObjectFromMappingEntries<[readonly [0, readonly [readonly ["Ethereum"]]], readonly [1, readonly [readonly ["Avalanche"]]], readonly [2, readonly [readonly ["Optimism"]]], readonly [3, readonly [readonly ["Arbitrum"]]], readonly [6, readonly [readonly ["Base"]]]]>[(0 | 3 | 1 | 2 | 6) & (K1 extends bigint | boolean | PropertyKey ? import("../utils").AssertType<K1 extends bigint ? `bigint(${K1})` : K1 extends boolean ? `boolean(${K1})` : K1, PropertyKey> : never)] : never) & {
} ? import("../utils").ObjectFromMappingEntries<[readonly [0, [["Ethereum"]]], readonly [1, [["Avalanche"]]], readonly [2, [["Optimism"]]], readonly [3, [["Arbitrum"]]], readonly [6, [["Base"]]]]>[(0 | 3 | 1 | 2 | 6) & (K1 extends bigint | boolean | PropertyKey ? import("../utils").AssertType<K1 extends bigint ? `bigint(${K1})` : K1 extends boolean ? `boolean(${K1})` : K1, PropertyKey> : never)] : import("../utils").ObjectFromMappingEntries<[readonly [0, [["Ethereum"]]], readonly [1, [["Avalanche"]]], readonly [2, [["Optimism"]]], readonly [3, [["Arbitrum"]]], readonly [6, [["Base"]]]]>[(0 | 3 | 1 | 2 | 6) & (K1 extends bigint | boolean | PropertyKey ? import("../utils").AssertType<K1 extends bigint ? `bigint(${K1})` : K1 extends boolean ? `boolean(${K1})` : K1, PropertyKey> : never)] : never) & {
get: (args_0: number) => "Ethereum" | "Avalanche" | "Arbitrum" | "Optimism" | "Base" | undefined;

@@ -23,0 +23,0 @@ has: (args_0: number) => boolean;

@@ -9,10 +9,10 @@ import { ChainName } from "./chains";

} ? import("../utils").ObjectFromMappingEntries<readonly [readonly ["Evm", readonly ["Acala", "Arbitrum", "Aurora", "Avalanche", "Base", "Bsc", "Celo", "Ethereum", "Fantom", "Gnosis", "Karura", "Klaytn", "Moonbeam", "Neon", "Oasis", "Optimism", "Polygon", "Rootstock", "Sepolia"]], readonly ["Solana", readonly ["Solana", "Pythnet"]], readonly ["Cosmwasm", readonly ["Cosmoshub", "Evmos", "Injective", "Kujira", "Osmosis", "Sei", "Terra", "Terra2", "Wormchain", "Xpla"]], readonly ["Btc", readonly ["Btc"]], readonly ["Algorand", readonly ["Algorand"]], readonly ["Sui", readonly ["Sui"]], readonly ["Aptos", readonly ["Aptos"]], readonly ["Near", readonly ["Near"]]]>[("Solana" | "Algorand" | "Near" | "Sui" | "Aptos" | "Btc" | "Evm" | "Cosmwasm") & (K1 extends bigint | boolean | PropertyKey ? import("../utils").AssertType<K1 extends bigint ? `bigint(${K1})` : K1 extends boolean ? `boolean(${K1})` : K1, PropertyKey> : never)] : import("../utils").ObjectFromMappingEntries<readonly [readonly ["Evm", readonly ["Acala", "Arbitrum", "Aurora", "Avalanche", "Base", "Bsc", "Celo", "Ethereum", "Fantom", "Gnosis", "Karura", "Klaytn", "Moonbeam", "Neon", "Oasis", "Optimism", "Polygon", "Rootstock", "Sepolia"]], readonly ["Solana", readonly ["Solana", "Pythnet"]], readonly ["Cosmwasm", readonly ["Cosmoshub", "Evmos", "Injective", "Kujira", "Osmosis", "Sei", "Terra", "Terra2", "Wormchain", "Xpla"]], readonly ["Btc", readonly ["Btc"]], readonly ["Algorand", readonly ["Algorand"]], readonly ["Sui", readonly ["Sui"]], readonly ["Aptos", readonly ["Aptos"]], readonly ["Near", readonly ["Near"]]]>[("Solana" | "Algorand" | "Near" | "Sui" | "Aptos" | "Btc" | "Evm" | "Cosmwasm") & (K1 extends bigint | boolean | PropertyKey ? import("../utils").AssertType<K1 extends bigint ? `bigint(${K1})` : K1 extends boolean ? `boolean(${K1})` : K1, PropertyKey> : never)] : never) & {
get: (args_0: string) => readonly ["Algorand"] | readonly ["Near"] | readonly ["Sui"] | readonly ["Aptos"] | readonly ["Btc"] | readonly ["Acala", "Arbitrum", "Aurora", "Avalanche", "Base", "Bsc", "Celo", "Ethereum", "Fantom", "Gnosis", "Karura", "Klaytn", "Moonbeam", "Neon", "Oasis", "Optimism", "Polygon", "Rootstock", "Sepolia"] | readonly ["Solana", "Pythnet"] | readonly ["Cosmoshub", "Evmos", "Injective", "Kujira", "Osmosis", "Sei", "Terra", "Terra2", "Wormchain", "Xpla"] | undefined;
get: (args_0: string) => readonly ["Acala", "Arbitrum", "Aurora", "Avalanche", "Base", "Bsc", "Celo", "Ethereum", "Fantom", "Gnosis", "Karura", "Klaytn", "Moonbeam", "Neon", "Oasis", "Optimism", "Polygon", "Rootstock", "Sepolia"] | readonly ["Solana", "Pythnet"] | readonly ["Cosmoshub", "Evmos", "Injective", "Kujira", "Osmosis", "Sei", "Terra", "Terra2", "Wormchain", "Xpla"] | readonly ["Btc"] | readonly ["Algorand"] | readonly ["Sui"] | readonly ["Aptos"] | readonly ["Near"] | undefined;
has: (args_0: string) => boolean;
};
export declare const chainToPlatform: (<K1 extends "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" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Sepolia">(args_0: K1) => (K1 extends bigint | boolean | PropertyKey ? import("../utils").AssertType<K1 extends bigint ? `bigint(${K1})` : K1 extends boolean ? `boolean(${K1})` : K1, PropertyKey> : never) extends "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" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Sepolia" ? import("../utils").ObjectFromMappingEntries<[readonly ["Acala", readonly [readonly ["Evm"]]], readonly ["Arbitrum", readonly [readonly ["Evm"]]], readonly ["Aurora", readonly [readonly ["Evm"]]], readonly ["Avalanche", readonly [readonly ["Evm"]]], readonly ["Base", readonly [readonly ["Evm"]]], readonly ["Bsc", readonly [readonly ["Evm"]]], readonly ["Celo", readonly [readonly ["Evm"]]], readonly ["Ethereum", readonly [readonly ["Evm"]]], readonly ["Fantom", readonly [readonly ["Evm"]]], readonly ["Gnosis", readonly [readonly ["Evm"]]], readonly ["Karura", readonly [readonly ["Evm"]]], readonly ["Klaytn", readonly [readonly ["Evm"]]], readonly ["Moonbeam", readonly [readonly ["Evm"]]], readonly ["Neon", readonly [readonly ["Evm"]]], readonly ["Oasis", readonly [readonly ["Evm"]]], readonly ["Optimism", readonly [readonly ["Evm"]]], readonly ["Polygon", readonly [readonly ["Evm"]]], readonly ["Rootstock", readonly [readonly ["Evm"]]], readonly ["Sepolia", readonly [readonly ["Evm"]]], readonly ["Solana", readonly [readonly ["Solana"]]], readonly ["Pythnet", readonly [readonly ["Solana"]]], readonly ["Cosmoshub", readonly [readonly ["Cosmwasm"]]], readonly ["Evmos", readonly [readonly ["Cosmwasm"]]], readonly ["Injective", readonly [readonly ["Cosmwasm"]]], readonly ["Kujira", readonly [readonly ["Cosmwasm"]]], readonly ["Osmosis", readonly [readonly ["Cosmwasm"]]], readonly ["Sei", readonly [readonly ["Cosmwasm"]]], readonly ["Terra", readonly [readonly ["Cosmwasm"]]], readonly ["Terra2", readonly [readonly ["Cosmwasm"]]], readonly ["Wormchain", readonly [readonly ["Cosmwasm"]]], readonly ["Xpla", readonly [readonly ["Cosmwasm"]]], readonly ["Btc", readonly [readonly ["Btc"]]], readonly ["Algorand", readonly [readonly ["Algorand"]]], readonly ["Sui", readonly [readonly ["Sui"]]], readonly ["Aptos", readonly [readonly ["Aptos"]]], readonly ["Near", readonly [readonly ["Near"]]]]>[("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" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Sepolia") & (K1 extends bigint | boolean | PropertyKey ? import("../utils").AssertType<K1 extends bigint ? `bigint(${K1})` : K1 extends boolean ? `boolean(${K1})` : K1, PropertyKey> : never)] extends {
export declare const chainToPlatform: (<K1 extends "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" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Sepolia">(args_0: K1) => (K1 extends bigint | boolean | PropertyKey ? import("../utils").AssertType<K1 extends bigint ? `bigint(${K1})` : K1 extends boolean ? `boolean(${K1})` : K1, PropertyKey> : never) extends "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" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Sepolia" ? import("../utils").ObjectFromMappingEntries<[readonly ["Acala", [["Evm"]]], readonly ["Arbitrum", [["Evm"]]], readonly ["Aurora", [["Evm"]]], readonly ["Avalanche", [["Evm"]]], readonly ["Base", [["Evm"]]], readonly ["Bsc", [["Evm"]]], readonly ["Celo", [["Evm"]]], readonly ["Ethereum", [["Evm"]]], readonly ["Fantom", [["Evm"]]], readonly ["Gnosis", [["Evm"]]], readonly ["Karura", [["Evm"]]], readonly ["Klaytn", [["Evm"]]], readonly ["Moonbeam", [["Evm"]]], readonly ["Neon", [["Evm"]]], readonly ["Oasis", [["Evm"]]], readonly ["Optimism", [["Evm"]]], readonly ["Polygon", [["Evm"]]], readonly ["Rootstock", [["Evm"]]], readonly ["Sepolia", [["Evm"]]], readonly ["Solana", [["Solana"]]], readonly ["Pythnet", [["Solana"]]], readonly ["Cosmoshub", [["Cosmwasm"]]], readonly ["Evmos", [["Cosmwasm"]]], readonly ["Injective", [["Cosmwasm"]]], readonly ["Kujira", [["Cosmwasm"]]], readonly ["Osmosis", [["Cosmwasm"]]], readonly ["Sei", [["Cosmwasm"]]], readonly ["Terra", [["Cosmwasm"]]], readonly ["Terra2", [["Cosmwasm"]]], readonly ["Wormchain", [["Cosmwasm"]]], readonly ["Xpla", [["Cosmwasm"]]], readonly ["Btc", [["Btc"]]], readonly ["Algorand", [["Algorand"]]], readonly ["Sui", [["Sui"]]], readonly ["Aptos", [["Aptos"]]], readonly ["Near", [["Near"]]]]>[("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" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Sepolia") & (K1 extends bigint | boolean | PropertyKey ? import("../utils").AssertType<K1 extends bigint ? `bigint(${K1})` : K1 extends boolean ? `boolean(${K1})` : K1, PropertyKey> : never)] extends {
[key: string]: unknown;
[key: number]: unknown;
[key: symbol]: unknown;
} ? import("../utils").ObjectFromMappingEntries<[readonly ["Acala", readonly [readonly ["Evm"]]], readonly ["Arbitrum", readonly [readonly ["Evm"]]], readonly ["Aurora", readonly [readonly ["Evm"]]], readonly ["Avalanche", readonly [readonly ["Evm"]]], readonly ["Base", readonly [readonly ["Evm"]]], readonly ["Bsc", readonly [readonly ["Evm"]]], readonly ["Celo", readonly [readonly ["Evm"]]], readonly ["Ethereum", readonly [readonly ["Evm"]]], readonly ["Fantom", readonly [readonly ["Evm"]]], readonly ["Gnosis", readonly [readonly ["Evm"]]], readonly ["Karura", readonly [readonly ["Evm"]]], readonly ["Klaytn", readonly [readonly ["Evm"]]], readonly ["Moonbeam", readonly [readonly ["Evm"]]], readonly ["Neon", readonly [readonly ["Evm"]]], readonly ["Oasis", readonly [readonly ["Evm"]]], readonly ["Optimism", readonly [readonly ["Evm"]]], readonly ["Polygon", readonly [readonly ["Evm"]]], readonly ["Rootstock", readonly [readonly ["Evm"]]], readonly ["Sepolia", readonly [readonly ["Evm"]]], readonly ["Solana", readonly [readonly ["Solana"]]], readonly ["Pythnet", readonly [readonly ["Solana"]]], readonly ["Cosmoshub", readonly [readonly ["Cosmwasm"]]], readonly ["Evmos", readonly [readonly ["Cosmwasm"]]], readonly ["Injective", readonly [readonly ["Cosmwasm"]]], readonly ["Kujira", readonly [readonly ["Cosmwasm"]]], readonly ["Osmosis", readonly [readonly ["Cosmwasm"]]], readonly ["Sei", readonly [readonly ["Cosmwasm"]]], readonly ["Terra", readonly [readonly ["Cosmwasm"]]], readonly ["Terra2", readonly [readonly ["Cosmwasm"]]], readonly ["Wormchain", readonly [readonly ["Cosmwasm"]]], readonly ["Xpla", readonly [readonly ["Cosmwasm"]]], readonly ["Btc", readonly [readonly ["Btc"]]], readonly ["Algorand", readonly [readonly ["Algorand"]]], readonly ["Sui", readonly [readonly ["Sui"]]], readonly ["Aptos", readonly [readonly ["Aptos"]]], readonly ["Near", readonly [readonly ["Near"]]]]>[("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" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Sepolia") & (K1 extends bigint | boolean | PropertyKey ? import("../utils").AssertType<K1 extends bigint ? `bigint(${K1})` : K1 extends boolean ? `boolean(${K1})` : K1, PropertyKey> : never)] : import("../utils").ObjectFromMappingEntries<[readonly ["Acala", readonly [readonly ["Evm"]]], readonly ["Arbitrum", readonly [readonly ["Evm"]]], readonly ["Aurora", readonly [readonly ["Evm"]]], readonly ["Avalanche", readonly [readonly ["Evm"]]], readonly ["Base", readonly [readonly ["Evm"]]], readonly ["Bsc", readonly [readonly ["Evm"]]], readonly ["Celo", readonly [readonly ["Evm"]]], readonly ["Ethereum", readonly [readonly ["Evm"]]], readonly ["Fantom", readonly [readonly ["Evm"]]], readonly ["Gnosis", readonly [readonly ["Evm"]]], readonly ["Karura", readonly [readonly ["Evm"]]], readonly ["Klaytn", readonly [readonly ["Evm"]]], readonly ["Moonbeam", readonly [readonly ["Evm"]]], readonly ["Neon", readonly [readonly ["Evm"]]], readonly ["Oasis", readonly [readonly ["Evm"]]], readonly ["Optimism", readonly [readonly ["Evm"]]], readonly ["Polygon", readonly [readonly ["Evm"]]], readonly ["Rootstock", readonly [readonly ["Evm"]]], readonly ["Sepolia", readonly [readonly ["Evm"]]], readonly ["Solana", readonly [readonly ["Solana"]]], readonly ["Pythnet", readonly [readonly ["Solana"]]], readonly ["Cosmoshub", readonly [readonly ["Cosmwasm"]]], readonly ["Evmos", readonly [readonly ["Cosmwasm"]]], readonly ["Injective", readonly [readonly ["Cosmwasm"]]], readonly ["Kujira", readonly [readonly ["Cosmwasm"]]], readonly ["Osmosis", readonly [readonly ["Cosmwasm"]]], readonly ["Sei", readonly [readonly ["Cosmwasm"]]], readonly ["Terra", readonly [readonly ["Cosmwasm"]]], readonly ["Terra2", readonly [readonly ["Cosmwasm"]]], readonly ["Wormchain", readonly [readonly ["Cosmwasm"]]], readonly ["Xpla", readonly [readonly ["Cosmwasm"]]], readonly ["Btc", readonly [readonly ["Btc"]]], readonly ["Algorand", readonly [readonly ["Algorand"]]], readonly ["Sui", readonly [readonly ["Sui"]]], readonly ["Aptos", readonly [readonly ["Aptos"]]], readonly ["Near", readonly [readonly ["Near"]]]]>[("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" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Sepolia") & (K1 extends bigint | boolean | PropertyKey ? import("../utils").AssertType<K1 extends bigint ? `bigint(${K1})` : K1 extends boolean ? `boolean(${K1})` : K1, PropertyKey> : never)] : never) & {
} ? import("../utils").ObjectFromMappingEntries<[readonly ["Acala", [["Evm"]]], readonly ["Arbitrum", [["Evm"]]], readonly ["Aurora", [["Evm"]]], readonly ["Avalanche", [["Evm"]]], readonly ["Base", [["Evm"]]], readonly ["Bsc", [["Evm"]]], readonly ["Celo", [["Evm"]]], readonly ["Ethereum", [["Evm"]]], readonly ["Fantom", [["Evm"]]], readonly ["Gnosis", [["Evm"]]], readonly ["Karura", [["Evm"]]], readonly ["Klaytn", [["Evm"]]], readonly ["Moonbeam", [["Evm"]]], readonly ["Neon", [["Evm"]]], readonly ["Oasis", [["Evm"]]], readonly ["Optimism", [["Evm"]]], readonly ["Polygon", [["Evm"]]], readonly ["Rootstock", [["Evm"]]], readonly ["Sepolia", [["Evm"]]], readonly ["Solana", [["Solana"]]], readonly ["Pythnet", [["Solana"]]], readonly ["Cosmoshub", [["Cosmwasm"]]], readonly ["Evmos", [["Cosmwasm"]]], readonly ["Injective", [["Cosmwasm"]]], readonly ["Kujira", [["Cosmwasm"]]], readonly ["Osmosis", [["Cosmwasm"]]], readonly ["Sei", [["Cosmwasm"]]], readonly ["Terra", [["Cosmwasm"]]], readonly ["Terra2", [["Cosmwasm"]]], readonly ["Wormchain", [["Cosmwasm"]]], readonly ["Xpla", [["Cosmwasm"]]], readonly ["Btc", [["Btc"]]], readonly ["Algorand", [["Algorand"]]], readonly ["Sui", [["Sui"]]], readonly ["Aptos", [["Aptos"]]], readonly ["Near", [["Near"]]]]>[("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" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Sepolia") & (K1 extends bigint | boolean | PropertyKey ? import("../utils").AssertType<K1 extends bigint ? `bigint(${K1})` : K1 extends boolean ? `boolean(${K1})` : K1, PropertyKey> : never)] : import("../utils").ObjectFromMappingEntries<[readonly ["Acala", [["Evm"]]], readonly ["Arbitrum", [["Evm"]]], readonly ["Aurora", [["Evm"]]], readonly ["Avalanche", [["Evm"]]], readonly ["Base", [["Evm"]]], readonly ["Bsc", [["Evm"]]], readonly ["Celo", [["Evm"]]], readonly ["Ethereum", [["Evm"]]], readonly ["Fantom", [["Evm"]]], readonly ["Gnosis", [["Evm"]]], readonly ["Karura", [["Evm"]]], readonly ["Klaytn", [["Evm"]]], readonly ["Moonbeam", [["Evm"]]], readonly ["Neon", [["Evm"]]], readonly ["Oasis", [["Evm"]]], readonly ["Optimism", [["Evm"]]], readonly ["Polygon", [["Evm"]]], readonly ["Rootstock", [["Evm"]]], readonly ["Sepolia", [["Evm"]]], readonly ["Solana", [["Solana"]]], readonly ["Pythnet", [["Solana"]]], readonly ["Cosmoshub", [["Cosmwasm"]]], readonly ["Evmos", [["Cosmwasm"]]], readonly ["Injective", [["Cosmwasm"]]], readonly ["Kujira", [["Cosmwasm"]]], readonly ["Osmosis", [["Cosmwasm"]]], readonly ["Sei", [["Cosmwasm"]]], readonly ["Terra", [["Cosmwasm"]]], readonly ["Terra2", [["Cosmwasm"]]], readonly ["Wormchain", [["Cosmwasm"]]], readonly ["Xpla", [["Cosmwasm"]]], readonly ["Btc", [["Btc"]]], readonly ["Algorand", [["Algorand"]]], readonly ["Sui", [["Sui"]]], readonly ["Aptos", [["Aptos"]]], readonly ["Near", [["Near"]]]]>[("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" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Sepolia") & (K1 extends bigint | boolean | PropertyKey ? import("../utils").AssertType<K1 extends bigint ? `bigint(${K1})` : K1 extends boolean ? `boolean(${K1})` : K1, PropertyKey> : never)] : never) & {
get: (args_0: string) => "Solana" | "Algorand" | "Near" | "Sui" | "Aptos" | "Btc" | "Evm" | "Cosmwasm" | undefined;

@@ -19,0 +19,0 @@ has: (args_0: string) => boolean;

@@ -1,4 +0,4 @@

export declare const protocols: readonly ["WormholeCore", "TokenBridge", "AutomaticTokenBridge", "CircleBridge", "AutomaticCircleBridge", "Relayer", "NftBridge"];
export declare const protocols: readonly ["CoreBridge", "TokenBridge", "NftBridge", "Relayer", "CCTP"];
export type ProtocolName = (typeof protocols)[number];
export declare const isProtocolName: (protocol: string) => protocol is "WormholeCore" | "TokenBridge" | "AutomaticTokenBridge" | "CircleBridge" | "AutomaticCircleBridge" | "Relayer" | "NftBridge";
export declare const isProtocolName: (protocol: string) => protocol is "CoreBridge" | "TokenBridge" | "NftBridge" | "Relayer" | "CCTP";
//# sourceMappingURL=protocols.d.ts.map

@@ -22,3 +22,3 @@ "use strict";

* With all of this in mind: What should we name modules here?
* My preferred choice would be ["Wormholecore", "TokenBridge", "NftBridge", "Relayer"]
* My preferred choice would be ["CoreBridge", "TokenBridge", "NftBridge", "Relayer"]
* but ["Core", "TokenBridge", "NFTBridge", "WormholeRelayer"] seems to be more consistent given

@@ -30,10 +30,7 @@ * current naming "conventions"

exports.protocols = [
"WormholeCore",
"CoreBridge",
"TokenBridge",
"AutomaticTokenBridge",
"CircleBridge",
"AutomaticCircleBridge",
"NftBridge",
"Relayer",
// not implemented
"NftBridge",
"CCTP",
];

@@ -40,0 +37,0 @@ const isProtocolName = (protocol) => exports.protocols.includes(protocol);

import { ParseNumber, RoArray, RoArray2D } from "./metaprogramming";
export type IndexEs = number | RoArray<number>;
export declare const range: (length: number) => number[];
export type Entries<T extends RoArray> = readonly [...{
[K in keyof T]: K extends `${number}` ? [T[K], ParseNumber<K>] : never;
}];
export type Entries<T extends RoArray> = [
...{
[K in keyof T]: K extends `${number}` ? [T[K], ParseNumber<K>] : never;
}
];
export type Flatten<T extends RoArray> = T extends readonly [infer Head, ...infer Tail] ? Head extends RoArray ? [...Head, ...Flatten<Tail>] : [Head, ...Flatten<Tail>] : [];

@@ -16,3 +18,3 @@ export type InnerFlatten<T extends RoArray> = [

...{
[K in keyof T]: K extends `${number}` ? readonly [T[K]] : never;
[K in keyof T]: K extends `${number}` ? [T[K]] : never;
}

@@ -30,3 +32,3 @@ ];

...{
[K in keyof Head]: K extends `${number}` ? readonly [...{
[K in keyof Head]: K extends `${number}` ? [...{
[K2 in keyof A]: K extends keyof A[K2] ? A[K2][K] : never;

@@ -43,5 +45,5 @@ }] : never;

}]> : R extends RoArray ? [...{
[K in keyof R]: K extends `${number}` ? readonly [L, R[K]] : never;
[K in keyof R]: K extends `${number}` ? [L, R[K]] : never;
}] : [L, R];
export {};
//# sourceMappingURL=array.d.ts.map

@@ -38,18 +38,16 @@ "use strict";

switch (item.binary) {
case "object": {
return internalDeserializeLayout(item.layout, encoded, offset);
}
case "array": {
let ret = [];
if (item.lengthSize !== undefined) {
const [length, newOffset] = deserializeUint(encoded, offset, item.lengthSize);
offset = newOffset;
for (let i = 0; i < length; ++i)
[ret[i], offset] = internalDeserializeLayout(item.layout, encoded, offset);
case "uint": {
const [value, newOffset] = deserializeUint(encoded, offset, item.size);
if ((0, layout_1.isUintType)(item.custom)) {
(0, utils_1.checkUintEquals)(item.custom, value);
return [item.custom, newOffset];
}
else {
while (offset < encoded.length)
[ret[ret.length], offset] = internalDeserializeLayout(item.layout, encoded, offset);
if ((0, layout_1.isUintType)(item?.custom?.from)) {
(0, utils_1.checkUintEquals)(item.custom.from, value);
return [item.custom.to, newOffset];
}
return [ret, offset];
return [
item.custom !== undefined ? item.custom.to(value) : value,
newOffset
];
}

@@ -92,15 +90,39 @@ case "bytes": {

}
case "uint": {
const [value, newOffset] = deserializeUint(encoded, offset, item.size);
if ((0, layout_1.isUintType)(item.custom)) {
(0, utils_1.checkUintEquals)(item.custom, value);
return [item.custom, newOffset];
case "array": {
let ret = [];
const { arrayItem } = item;
const deserializeArrayItem = (index) => {
const [deserializedItem, newOffset] = deserializeLayoutItem({ name: `${item.name}[${index}]`, ...arrayItem }, encoded, offset);
ret.push(deserializedItem);
offset = newOffset;
};
if (item.lengthSize !== undefined) {
const [length, newOffset] = deserializeUint(encoded, offset, item.lengthSize);
offset = newOffset;
for (let i = 0; i < length; ++i)
deserializeArrayItem(i);
}
if ((0, layout_1.isUintType)(item?.custom?.from)) {
(0, utils_1.checkUintEquals)(item.custom.from, value);
return [item.custom.to, newOffset];
}
else
while (offset < encoded.length)
deserializeArrayItem(ret.length);
return [ret, offset];
}
case "object": {
return internalDeserializeLayout(item.layout, encoded, offset);
}
case "switch": {
const [id, newOffset] = deserializeUint(encoded, offset, item.idSize);
const { idLayoutPairs } = item;
if (idLayoutPairs.length === 0)
throw new Error(`switch item '${item.name}' has no idLayoutPairs`);
const hasPlainIds = typeof idLayoutPairs[0][0] === "number";
const pair = idLayoutPairs.find(([idOrConversionId]) => hasPlainIds ? idOrConversionId === id : (idOrConversionId)[0] === id);
if (pair === undefined)
throw new Error(`unknown id value: ${id}`);
const [idOrConversionId, idLayout] = pair;
const [decoded, nextOffset] = internalDeserializeLayout(idLayout, encoded, newOffset);
return [
item.custom !== undefined ? item.custom.to(value) : value,
newOffset
{ [item.idTag ?? "id"]: hasPlainIds ? id : idOrConversionId[1],
...decoded },
nextOffset
];

@@ -107,0 +129,0 @@ }

@@ -29,8 +29,15 @@ "use strict";

switch (item.binary) {
case "object": {
return createLayoutMeta(item.layout, offset, fixedBytes);
case "uint": {
const fixedVal = (0, layout_1.isUintType)(item.custom)
? item.custom
: (0, layout_1.isUintType)(item?.custom?.from)
? item.custom.from
: null;
if (fixedVal !== null) {
const serialized = new Uint8Array(item.size);
(0, serialize_1.serializeUint)(serialized, 0, fixedVal, item.size);
return knownFixed(item.size, serialized);
}
return [item.size, item.size];
}
case "array": {
return [item.lengthSize !== undefined ? item.lengthSize : 0, Infinity];
}
case "bytes": {

@@ -48,15 +55,66 @@ if ("size" in item && item.size !== undefined)

}
case "uint": {
const fixedVal = (0, layout_1.isUintType)(item.custom)
? item.custom
: (0, layout_1.isUintType)(item?.custom?.from)
? item.custom.from
: null;
if (fixedVal !== null) {
const serialized = new Uint8Array(item.size);
(0, serialize_1.serializeUint)(serialized, 0, fixedVal, item.size);
return knownFixed(item.size, serialized);
}
return [item.size, item.size];
case "array": {
return [item.lengthSize !== undefined ? item.lengthSize : 0, Infinity];
}
case "object": {
return createLayoutMeta(item.layout, offset, fixedBytes);
}
case "switch": {
const caseFixedBytes = item.idLayoutPairs.map(_ => []);
const { idSize } = item;
const caseBounds = item.idLayoutPairs.map(([idOrConversionId, layout], caseIndex) => {
const idVal = Array.isArray(idOrConversionId) ? idOrConversionId[0] : idOrConversionId;
if (offset !== null) {
const serializedId = new Uint8Array(idSize);
(0, serialize_1.serializeUint)(serializedId, 0, idVal, idSize);
caseFixedBytes[caseIndex].push([0, serializedId]);
}
const ret = createLayoutMeta(layout, offset ? idSize : null, caseFixedBytes[caseIndex]);
return [ret[0] + idSize, ret[1] + idSize];
});
if (offset !== null)
//find bytes that have the same value across all cases (turning this into a lambda to enable
// early return from inner loops)
(() => {
//constrain search to the minimum length of all cases
const minLen = Math.min(...caseFixedBytes.map(fbs => fbs.at(-1)[0] + fbs.at(-1)[1].length));
//keep track of the current index in each case's fixed bytes array
const itIndexes = caseFixedBytes.map(_ => 0);
for (let bytePos = 0; bytePos < minLen;) {
let byteVal = null;
let caseIndex = 0;
while (caseIndex < caseFixedBytes.length) {
let curItIndex = itIndexes[caseIndex];
const curFixedBytes = caseFixedBytes[caseIndex];
const [curOffset, curSerialized] = curFixedBytes[curItIndex];
if (curOffset + curSerialized.length <= bytePos) {
//no fixed byte at this position in this case
++curItIndex;
if (curItIndex === curFixedBytes.length)
return; //we have exhausted all fixed bytes in at least one case
itIndexes[caseIndex] = curItIndex;
//jump to the next possible bytePos given the fixed bytes of the current case index
bytePos = curFixedBytes[curItIndex][0];
break;
}
const curByteVal = curSerialized[bytePos - curOffset];
if (byteVal === null)
byteVal = curByteVal;
if (curByteVal !== byteVal)
break;
caseIndex++;
}
//only if we made it through all cases without breaking do we have a fixed byte
// and hence add it to the list of fixed bytes
if (caseIndex === caseFixedBytes.length) {
fixedBytes.push([offset + bytePos, new Uint8Array([byteVal])]);
++bytePos;
}
}
})();
return [
Math.min(...caseBounds.map(([lower]) => lower)),
Math.max(...caseBounds.map(([_, upper]) => upper))
];
}
}

@@ -63,0 +121,0 @@ }

@@ -1,18 +0,24 @@

import { Layout, LayoutItem, ObjectLayoutItem, ArrayLayoutItem, LayoutToType, PrimitiveType, FixedConversion } from "./layout";
type FilterFixedItem<I extends LayoutItem> = I extends {
import { Layout, LayoutItem, NamedLayoutItem, UintLayoutItem, BytesLayoutItem, ObjectLayoutItem, ArrayLayoutItem, SwitchLayoutItem, LayoutToType, PrimitiveType, FixedConversion } from "./layout";
type IsNever<T> = [T] extends [never] ? true : false;
type IsEmpty<T> = IsNever<T> extends false ? T extends readonly [unknown, ...unknown[]] ? false : true : true;
type IdLayoutPair = readonly [unknown, Layout];
type FilterItemsOfIdLayoutPairs<ILA extends readonly IdLayoutPair[], Fixed extends boolean> = ILA extends readonly [infer H extends IdLayoutPair, ...infer T extends readonly IdLayoutPair[]] ? FilterItemsOfLayout<H[1], Fixed> extends infer L ? IsEmpty<L> extends false ? [[H[0], L], ...FilterItemsOfIdLayoutPairs<T, Fixed>] : FilterItemsOfIdLayoutPairs<T, Fixed> : never : [];
type FilterItem<I extends LayoutItem, Fixed extends boolean> = [
I
] extends [UintLayoutItem | BytesLayoutItem] ? I extends {
custom: PrimitiveType | FixedConversion<PrimitiveType, any>;
} ? I : I extends ObjectLayoutItem | ArrayLayoutItem ? FixedItemsOfLayout<I["layout"]> extends readonly LayoutItem[] ? [FixedItemsOfLayout<I["layout"]>[number]] extends [never] ? never : {
readonly [K in keyof I]: K extends "layout" ? FixedItemsOfLayout<I["layout"]> : I[K];
} : never : never;
export type FixedItemsOfLayout<L extends Layout> = L extends readonly [infer H extends LayoutItem, ...infer T] ? [FilterFixedItem<H>] extends [never] ? T extends Layout ? FixedItemsOfLayout<T> : readonly [] : T extends Layout ? readonly [FilterFixedItem<H>, ...FixedItemsOfLayout<T>] : readonly [FilterFixedItem<H>] : readonly [];
export declare const fixedItemsOfLayout: <L extends Layout>(layout: L) => FixedItemsOfLayout<L>;
type FilterDynamicItem<I extends LayoutItem> = I extends {
custom: PrimitiveType | FixedConversion<PrimitiveType, any>;
} ? never : I extends ObjectLayoutItem | ArrayLayoutItem ? DynamicItemsOfLayout<I["layout"]> extends readonly LayoutItem[] ? [DynamicItemsOfLayout<I["layout"]>[number]] extends [never] ? never : {
readonly [K in keyof I]: K extends "layout" ? DynamicItemsOfLayout<I["layout"]> : I[K];
} : never : I;
export type DynamicItemsOfLayout<L extends Layout> = L extends readonly [infer H extends LayoutItem, ...infer T] ? [FilterDynamicItem<H>] extends [never] ? T extends Layout ? DynamicItemsOfLayout<T> : readonly [] : T extends Layout ? readonly [FilterDynamicItem<H>, ...DynamicItemsOfLayout<T>] : readonly [FilterDynamicItem<H>] : readonly [];
export declare const dynamicItemsOfLayout: <L extends Layout>(layout: L) => DynamicItemsOfLayout<L>;
export declare const addFixedValues: <L extends Layout>(layout: L, dynamicValues: LayoutToType<DynamicItemsOfLayout<L>>) => LayoutToType<L>;
} ? Fixed extends true ? I : never : Fixed extends true ? never : I : [I] extends [ArrayLayoutItem] ? FilterItem<I["arrayItem"], Fixed> extends infer LI ? {
readonly [K in keyof I]: K extends "arrayItem" ? LI : I[K];
} : never : [I] extends [ObjectLayoutItem] ? FilterItemsOfLayout<I["layout"], Fixed> extends infer L ? IsEmpty<L> extends false ? {
readonly [K in keyof I]: K extends "layout" ? L : I[K];
} : never : never : [I] extends [SwitchLayoutItem] ? {
readonly [K in keyof I]: K extends "idLayoutPairs" ? FilterItemsOfIdLayoutPairs<I["idLayoutPairs"], Fixed> : I[K];
} : never;
type FilterItemsOfLayout<L extends Layout, Fixed extends boolean> = L extends readonly [infer H extends NamedLayoutItem, ...infer T extends Layout] ? FilterItem<H, Fixed> extends infer I extends NamedLayoutItem ? IsNever<I> extends false ? [I, ...FilterItemsOfLayout<T, Fixed>] : FilterItemsOfLayout<T, Fixed> : never : [];
export type FixedItemsOfLayout<L extends Layout> = FilterItemsOfLayout<L, true>;
export type DynamicItemsOfLayout<L extends Layout> = FilterItemsOfLayout<L, false>;
export declare const fixedItemsOfLayout: <L extends Layout>(layout: L) => FilterItemsOfLayout<L, true>;
export declare const dynamicItemsOfLayout: <L extends Layout>(layout: L) => FilterItemsOfLayout<L, false>;
export declare function addFixedValues<L extends Layout>(layout: L, dynamicValues: LayoutToType<DynamicItemsOfLayout<L>>): LayoutToType<L>;
export {};
//# sourceMappingURL=fixedDynamic.d.ts.map

@@ -5,50 +5,78 @@ "use strict";

const layout_1 = require("./layout");
const fixedItemsOfLayout = (layout) => layout.reduce((acc, item) => {
if (item["custom"] !== undefined && ((0, layout_1.isPrimitiveType)(item["custom"]) || (0, layout_1.isPrimitiveType)(item["custom"].from)))
return [...acc, item];
if (item.binary === "array" || item.binary === "object") {
const fixedItems = (0, exports.fixedItemsOfLayout)(item.layout);
if (fixedItems.length > 0)
return [...acc, { ...item, layout: fixedItems }];
function filterItem(item, fixed) {
switch (item.binary) {
case "uint":
case "bytes": {
const isFixedItem = item["custom"] !== undefined && ((0, layout_1.isPrimitiveType)(item["custom"]) || (0, layout_1.isPrimitiveType)(item["custom"].from));
return (fixed && isFixedItem || !fixed && !isFixedItem) ? item : null;
}
case "array": {
const filtered = filterItem(item.arrayItem, fixed);
return (filtered !== null) ? { ...item, arrayItem: filtered } : null;
}
case "object": {
const filteredItems = filterItemsOfLayout(item.layout, fixed);
return (filteredItems.length > 0) ? { ...item, layout: filteredItems } : null;
}
case "switch": {
const filteredIdLayoutPairs = item.idLayoutPairs.reduce((acc, [idOrConversionId, idLayout]) => {
const filteredItems = filterItemsOfLayout(idLayout, fixed);
return filteredItems.length > 0
? [...acc, [idOrConversionId, filteredItems]]
: acc;
}, []);
return { ...item, idLayoutPairs: filteredIdLayoutPairs };
}
}
return acc;
}, []);
}
function filterItemsOfLayout(layout, fixed) {
return layout.reduce((acc, item) => {
const filtered = filterItem(item, fixed);
return filtered !== null ? [...acc, filtered] : acc;
}, []);
}
const fixedItemsOfLayout = (layout) => filterItemsOfLayout(layout, true);
exports.fixedItemsOfLayout = fixedItemsOfLayout;
const dynamicItemsOfLayout = (layout) => layout.reduce((acc, item) => {
if (item["custom"] === undefined || !((0, layout_1.isPrimitiveType)(item["custom"]) || (0, layout_1.isPrimitiveType)(item["custom"].from)))
return [...acc, item];
if (item.binary === "array" || item.binary === "object") {
const dynamicItems = (0, exports.dynamicItemsOfLayout)(item.layout);
if (dynamicItems.length > 0)
return [...acc, { ...item, layout: dynamicItems }];
}
return acc;
}, []);
const dynamicItemsOfLayout = (layout) => filterItemsOfLayout(layout, false);
exports.dynamicItemsOfLayout = dynamicItemsOfLayout;
const addFixedValues = (layout, dynamicValues) => {
function addFixedValues(layout, dynamicValues) {
const ret = {};
for (const item of layout) {
if (item.binary === "object") {
const subDynamicValues = ((item.name in dynamicValues)
? dynamicValues[item.name]
: {});
ret[item.name] = (0, exports.addFixedValues)(item.layout, subDynamicValues);
const fromDynamic = () => dynamicValues[item.name];
switch (item.binary) {
case "uint":
case "bytes": {
if (!item?.omit)
ret[item.name] = (item.custom !== undefined &&
((0, layout_1.isPrimitiveType)(item.custom) || (0, layout_1.isPrimitiveType)(item.custom.from))) ? ((0, layout_1.isPrimitiveType)(item.custom) ? item.custom : item.custom.to)
: fromDynamic();
break;
}
case "array": {
if (item.name in dynamicValues) {
ret[item.name] = (item.arrayItem.binary !== "object")
? fromDynamic()
: fromDynamic().map(element => addFixedValues(item.arrayItem.layout, element));
}
break;
}
case "object": {
const subDynamicValues = ((item.name in dynamicValues) ? fromDynamic() : {});
ret[item.name] = addFixedValues(item.layout, subDynamicValues);
break;
}
case "switch": {
const id = fromDynamic()[item.idTag ?? "id"];
const [_, idLayout] = item.idLayoutPairs.find(([idOrConversionId]) => (Array.isArray(idOrConversionId) ? idOrConversionId[1] : idOrConversionId) == id);
ret[item.name] = {
[item.idTag ?? "id"]: id,
...addFixedValues(idLayout, fromDynamic())
};
break;
}
}
else if (item.binary === "array") {
const subDynamicValues = ((item.name in dynamicValues)
? dynamicValues[item.name]
: []);
ret[item.name] = subDynamicValues.map(element => (0, exports.addFixedValues)(item.layout, element));
}
else if (item.custom !== undefined &&
((0, layout_1.isPrimitiveType)(item.custom) || (0, layout_1.isPrimitiveType)(item.custom.from))) {
if (!item?.omit)
ret[item.name] = (0, layout_1.isPrimitiveType)(item.custom) ? item.custom : item.custom.to;
}
else
ret[item.name] = dynamicValues[item.name];
}
return ret;
};
}
exports.addFixedValues = addFixedValues;
//# sourceMappingURL=fixedDynamic.js.map

@@ -1,2 +0,2 @@

export { Layout, LayoutItem, UintLayoutItem, BytesLayoutItem, FixedPrimitiveBytesLayoutItem, FixedValueBytesLayoutItem, FixedSizeBytesLayoutItem, LengthPrefixedBytesLayoutItem, ArrayLayoutItem, ObjectLayoutItem, LayoutToType, LayoutItemToType, FixedConversion, CustomConversion, } from "./layout";
export { Layout, LayoutItem, NamedLayoutItem, UintLayoutItem, BytesLayoutItem, FixedPrimitiveBytesLayoutItem, FixedValueBytesLayoutItem, FixedSizeBytesLayoutItem, LengthPrefixedBytesLayoutItem, ArrayLayoutItem, ObjectLayoutItem, LayoutToType, LayoutItemToType, FixedConversion, CustomConversion, } from "./layout";
export { serializeLayout } from "./serialize";

@@ -3,0 +3,0 @@ export { deserializeLayout } from "./deserialize";

@@ -7,3 +7,3 @@ export type UintType = number | bigint;

export declare const isPrimitiveType: (x: any) => x is PrimitiveType;
export type BinaryLiterals = "uint" | "bytes" | "array" | "object";
export type BinaryLiterals = "uint" | "bytes" | "array" | "object" | "switch";
export type NumberSize = 1 | 2 | 3 | 4 | 5 | 6;

@@ -21,3 +21,2 @@ export declare const numberMaxSize = 6;

interface LayoutItemBase<BL extends BinaryLiterals> {
readonly name: string;
readonly binary: BL;

@@ -54,3 +53,3 @@ }

readonly lengthSize?: NumberSize;
readonly layout: Layout;
readonly arrayItem: LayoutItem;
}

@@ -60,8 +59,19 @@ export interface ObjectLayoutItem extends LayoutItemBase<"object"> {

}
type PlainId = number;
type ConversionId = readonly [number, unknown];
type IdLayoutPair<Id extends PlainId | ConversionId, L extends Layout = Layout> = readonly [Id, L];
export interface SwitchLayoutItem extends LayoutItemBase<"switch"> {
readonly idTag?: string;
readonly idSize: NumberSize;
readonly idLayoutPairs: readonly IdLayoutPair<PlainId>[] | readonly IdLayoutPair<ConversionId>[];
}
export type UintLayoutItem = PrimitiveFixedUintLayoutItem<number> | OptionalToFromUintLayoutItem<number> | PrimitiveFixedUintLayoutItem<bigint> | OptionalToFromUintLayoutItem<bigint>;
export type BytesLayoutItem = FixedPrimitiveBytesLayoutItem | FixedValueBytesLayoutItem | FixedSizeBytesLayoutItem | LengthPrefixedBytesLayoutItem;
export type LayoutItem = UintLayoutItem | BytesLayoutItem | ArrayLayoutItem | ObjectLayoutItem;
export type Layout = readonly LayoutItem[];
export type LayoutItem = UintLayoutItem | BytesLayoutItem | ArrayLayoutItem | ObjectLayoutItem | SwitchLayoutItem;
export type NamedLayoutItem = LayoutItem & {
readonly name: string;
};
export type Layout = readonly NamedLayoutItem[];
type NameOrOmitted<T extends {
name: PropertyKey;
name: string;
}> = T extends {

@@ -73,6 +83,11 @@ omit: true;

};
type MaybeConvert<Id extends PlainId | ConversionId> = Id extends readonly [number, infer Converted] ? Converted : Id;
type IdLayoutPairArray = readonly IdLayoutPair<number>[] | readonly IdLayoutPair<ConversionId>[];
type IdLayoutPairsToTypeUnion<T extends IdLayoutPairArray, IdTag extends string> = T extends readonly [infer Head, ...infer Tail extends IdLayoutPairArray] ? Head extends IdLayoutPair<infer MaybeConversionId, infer L extends Layout> ? MaybeConvert<MaybeConversionId> extends infer Id ? LayoutToType<L> extends infer LT extends object ? {
readonly [K in IdTag | keyof LT]: K extends keyof LT ? LT[K] : Id;
} | IdLayoutPairsToTypeUnion<Tail, IdTag> : never : never : never : never;
export type LayoutItemToType<I extends LayoutItem> = [
I
] extends [ArrayLayoutItem] ? LayoutToType<I["layout"]>[] : [I] extends [ObjectLayoutItem] ? LayoutToType<I["layout"]> : [I] extends [UintLayoutItem] ? I["custom"] extends UintType ? I["custom"] : I["custom"] extends CustomConversion<any, infer ToType> ? ToType : I["custom"] extends FixedConversion<any, infer ToType> ? ToType : UintSizeToPrimitive<I["size"]> : [I] extends [BytesLayoutItem] ? I["custom"] extends CustomConversion<BytesType, infer ToType> ? ToType : I["custom"] extends FixedConversion<BytesType, infer ToType> ? ToType : BytesType : never;
] extends [UintLayoutItem] ? I["custom"] extends UintType ? I["custom"] : I["custom"] extends CustomConversion<infer FromType extends UintType, infer ToType> ? ToType : I["custom"] extends FixedConversion<infer FromType extends UintType, infer ToType> ? ToType : UintSizeToPrimitive<I["size"]> : [I] extends [BytesLayoutItem] ? I["custom"] extends CustomConversion<BytesType, infer ToType> ? ToType : I["custom"] extends FixedConversion<BytesType, infer ToType> ? ToType : BytesType : [I] extends [ArrayLayoutItem] ? readonly LayoutItemToType<I["arrayItem"]>[] : [I] extends [ObjectLayoutItem] ? LayoutToType<I["layout"]> : [I] extends [SwitchLayoutItem] ? IdLayoutPairsToTypeUnion<I["idLayoutPairs"], I["idTag"] extends string ? I["idTag"] : "id"> : never;
export {};
//# sourceMappingURL=layout.d.ts.map
"use strict";
//TODO:
// * implement a switch layout item that maps different values (versions) to different sublayouts
Object.defineProperty(exports, "__esModule", { value: true });

@@ -5,0 +3,0 @@ exports.numberMaxSize = exports.isPrimitiveType = exports.isBytesType = exports.isUintType = void 0;

@@ -13,34 +13,45 @@ "use strict";

exports.serializeLayout = serializeLayout;
const calcLayoutSize = (layout, data) => layout.reduce((acc, item) => {
const findIdLayoutPair = (item, data) => {
const id = data[item.idTag ?? "id"];
return item.idLayoutPairs.find(([idOrConversionId]) => (Array.isArray(idOrConversionId) ? idOrConversionId[1] : idOrConversionId) == id);
};
const withIgnoredName = (item) => ({ ...item, name: "ignored" });
const calcItemSize = (item, data) => {
switch (item.binary) {
case "object": {
return acc + calcLayoutSize(item.layout, data[item.name]);
case "uint": {
return item.size;
}
case "array": {
if (item.lengthSize !== undefined)
acc += item.lengthSize;
const narrowedData = data[item.name];
for (let i = 0; i < narrowedData.length; ++i)
acc += calcLayoutSize(item.layout, narrowedData[i]);
return acc;
}
case "bytes": {
if ((0, layout_1.isBytesType)(item.custom))
return acc + item.custom.length;
return item.custom.length;
if ((0, layout_1.isBytesType)(item?.custom?.from))
return acc + item.custom.from.length;
item = item;
return item.custom.from.length;
if ("size" in item && item.size !== undefined)
return acc + item.size;
return item.size;
let size = 0;
if (item?.lengthSize !== undefined)
size += item.lengthSize;
return size + ((item.custom !== undefined)
? item.custom.from(data)
: data).length;
}
case "array": {
let size = 0;
if (item.lengthSize !== undefined)
acc += item.lengthSize;
return acc + ((item.custom !== undefined)
? item.custom.from(data[item.name])
: data[item.name]).length;
size += item.lengthSize;
const narrowedData = data;
for (let i = 0; i < narrowedData.length; ++i)
size += calcItemSize(withIgnoredName(item.arrayItem), narrowedData[i]);
return size;
}
case "uint": {
return acc + item.size;
case "object": {
return calcLayoutSize(item.layout, data);
}
case "switch": {
const [_, layout] = findIdLayoutPair(item, data);
return item.idSize + calcLayoutSize(layout, data);
}
}
}, 0);
};
const calcLayoutSize = (layout, data) => layout.reduce((acc, item) => acc + calcItemSize(item, data[item.name]), 0);
//Wormhole uses big endian by default for all uints

@@ -64,5 +75,11 @@ //endianess can be easily added to UintLayout items if necessary

switch (item.binary) {
case "switch": {
const [idOrConversionId, layout] = findIdLayoutPair(item, data);
const idNum = (Array.isArray(idOrConversionId) ? idOrConversionId[0] : idOrConversionId);
offset = serializeUint(encoded, offset, idNum, item.idSize);
offset = serializeLayout(layout, data, encoded, offset);
break;
}
case "object": {
for (const i of item.layout)
offset = serializeLayoutItem(i, data[i.name], encoded, offset);
offset = serializeLayout(item.layout, data, encoded, offset);
break;

@@ -74,3 +91,3 @@ }

for (let i = 0; i < data.length; ++i)
offset = serializeLayout(item.layout, data[i], encoded, offset);
offset = serializeLayoutItem(withIgnoredName(item.arrayItem), data[i], encoded, offset);
break;

@@ -77,0 +94,0 @@ }

@@ -1,2 +0,2 @@

export declare const chains: readonly ["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", "Wormchain", "Cosmoshub", "Evmos", "Kujira", "Sepolia"], chainIds: readonly [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, 3104, 4000, 4001, 4002, 10002];
export declare const 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", "Wormchain", "Cosmoshub", "Evmos", "Kujira", "Sepolia"], 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, 3104, 4000, 4001, 4002, 10002];
export type ChainName = (typeof chains)[number];

@@ -13,7 +13,7 @@ export type ChainId = (typeof chainIds)[number];

};
export declare const chainIdToChain: (<K1 extends 3 | 1 | 5 | 2 | 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 | 3104 | 4000 | 4001 | 4002 | 10002>(args_0: K1) => (K1 extends bigint | boolean | PropertyKey ? import("..").AssertType<K1 extends bigint ? `bigint(${K1})` : K1 extends boolean ? `boolean(${K1})` : K1, PropertyKey> : never) extends 3 | 1 | 5 | 2 | 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 | 3104 | 4000 | 4001 | 4002 | 10002 ? import("../utils/mapping").ObjectFromMappingEntries<[readonly [1, readonly [readonly ["Solana"]]], readonly [2, readonly [readonly ["Ethereum"]]], readonly [3, readonly [readonly ["Terra"]]], readonly [4, readonly [readonly ["Bsc"]]], readonly [5, readonly [readonly ["Polygon"]]], readonly [6, readonly [readonly ["Avalanche"]]], readonly [7, readonly [readonly ["Oasis"]]], readonly [8, readonly [readonly ["Algorand"]]], readonly [9, readonly [readonly ["Aurora"]]], readonly [10, readonly [readonly ["Fantom"]]], readonly [11, readonly [readonly ["Karura"]]], readonly [12, readonly [readonly ["Acala"]]], readonly [13, readonly [readonly ["Klaytn"]]], readonly [14, readonly [readonly ["Celo"]]], readonly [15, readonly [readonly ["Near"]]], readonly [16, readonly [readonly ["Moonbeam"]]], readonly [17, readonly [readonly ["Neon"]]], readonly [18, readonly [readonly ["Terra2"]]], readonly [19, readonly [readonly ["Injective"]]], readonly [20, readonly [readonly ["Osmosis"]]], readonly [21, readonly [readonly ["Sui"]]], readonly [22, readonly [readonly ["Aptos"]]], readonly [23, readonly [readonly ["Arbitrum"]]], readonly [24, readonly [readonly ["Optimism"]]], readonly [25, readonly [readonly ["Gnosis"]]], readonly [26, readonly [readonly ["Pythnet"]]], readonly [28, readonly [readonly ["Xpla"]]], readonly [29, readonly [readonly ["Btc"]]], readonly [30, readonly [readonly ["Base"]]], readonly [32, readonly [readonly ["Sei"]]], readonly [33, readonly [readonly ["Rootstock"]]], readonly [3104, readonly [readonly ["Wormchain"]]], readonly [4000, readonly [readonly ["Cosmoshub"]]], readonly [4001, readonly [readonly ["Evmos"]]], readonly [4002, readonly [readonly ["Kujira"]]], readonly [10002, readonly [readonly ["Sepolia"]]]]>[(3 | 1 | 5 | 2 | 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 | 3104 | 4000 | 4001 | 4002 | 10002) & (K1 extends bigint | boolean | PropertyKey ? import("..").AssertType<K1 extends bigint ? `bigint(${K1})` : K1 extends boolean ? `boolean(${K1})` : K1, PropertyKey> : never)] extends {
export declare const chainIdToChain: (<K1 extends 3 | 1 | 5 | 2 | 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 | 3104 | 4000 | 4001 | 4002 | 10002>(args_0: K1) => (K1 extends bigint | boolean | PropertyKey ? import("..").AssertType<K1 extends bigint ? `bigint(${K1})` : K1 extends boolean ? `boolean(${K1})` : K1, PropertyKey> : never) extends 3 | 1 | 5 | 2 | 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 | 3104 | 4000 | 4001 | 4002 | 10002 ? import("../utils/mapping").ObjectFromMappingEntries<[readonly [1, [["Solana"]]], readonly [2, [["Ethereum"]]], readonly [3, [["Terra"]]], readonly [4, [["Bsc"]]], readonly [5, [["Polygon"]]], readonly [6, [["Avalanche"]]], readonly [7, [["Oasis"]]], readonly [8, [["Algorand"]]], readonly [9, [["Aurora"]]], readonly [10, [["Fantom"]]], readonly [11, [["Karura"]]], readonly [12, [["Acala"]]], readonly [13, [["Klaytn"]]], readonly [14, [["Celo"]]], readonly [15, [["Near"]]], readonly [16, [["Moonbeam"]]], readonly [17, [["Neon"]]], readonly [18, [["Terra2"]]], readonly [19, [["Injective"]]], readonly [20, [["Osmosis"]]], readonly [21, [["Sui"]]], readonly [22, [["Aptos"]]], readonly [23, [["Arbitrum"]]], readonly [24, [["Optimism"]]], readonly [25, [["Gnosis"]]], readonly [26, [["Pythnet"]]], readonly [28, [["Xpla"]]], readonly [29, [["Btc"]]], readonly [30, [["Base"]]], readonly [32, [["Sei"]]], readonly [33, [["Rootstock"]]], readonly [3104, [["Wormchain"]]], readonly [4000, [["Cosmoshub"]]], readonly [4001, [["Evmos"]]], readonly [4002, [["Kujira"]]], readonly [10002, [["Sepolia"]]]]>[(3 | 1 | 5 | 2 | 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 | 3104 | 4000 | 4001 | 4002 | 10002) & (K1 extends bigint | boolean | PropertyKey ? import("..").AssertType<K1 extends bigint ? `bigint(${K1})` : K1 extends boolean ? `boolean(${K1})` : K1, PropertyKey> : never)] extends {
[key: string]: unknown;
[key: number]: unknown;
[key: symbol]: unknown;
} ? import("../utils/mapping").ObjectFromMappingEntries<[readonly [1, readonly [readonly ["Solana"]]], readonly [2, readonly [readonly ["Ethereum"]]], readonly [3, readonly [readonly ["Terra"]]], readonly [4, readonly [readonly ["Bsc"]]], readonly [5, readonly [readonly ["Polygon"]]], readonly [6, readonly [readonly ["Avalanche"]]], readonly [7, readonly [readonly ["Oasis"]]], readonly [8, readonly [readonly ["Algorand"]]], readonly [9, readonly [readonly ["Aurora"]]], readonly [10, readonly [readonly ["Fantom"]]], readonly [11, readonly [readonly ["Karura"]]], readonly [12, readonly [readonly ["Acala"]]], readonly [13, readonly [readonly ["Klaytn"]]], readonly [14, readonly [readonly ["Celo"]]], readonly [15, readonly [readonly ["Near"]]], readonly [16, readonly [readonly ["Moonbeam"]]], readonly [17, readonly [readonly ["Neon"]]], readonly [18, readonly [readonly ["Terra2"]]], readonly [19, readonly [readonly ["Injective"]]], readonly [20, readonly [readonly ["Osmosis"]]], readonly [21, readonly [readonly ["Sui"]]], readonly [22, readonly [readonly ["Aptos"]]], readonly [23, readonly [readonly ["Arbitrum"]]], readonly [24, readonly [readonly ["Optimism"]]], readonly [25, readonly [readonly ["Gnosis"]]], readonly [26, readonly [readonly ["Pythnet"]]], readonly [28, readonly [readonly ["Xpla"]]], readonly [29, readonly [readonly ["Btc"]]], readonly [30, readonly [readonly ["Base"]]], readonly [32, readonly [readonly ["Sei"]]], readonly [33, readonly [readonly ["Rootstock"]]], readonly [3104, readonly [readonly ["Wormchain"]]], readonly [4000, readonly [readonly ["Cosmoshub"]]], readonly [4001, readonly [readonly ["Evmos"]]], readonly [4002, readonly [readonly ["Kujira"]]], readonly [10002, readonly [readonly ["Sepolia"]]]]>[(3 | 1 | 5 | 2 | 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 | 3104 | 4000 | 4001 | 4002 | 10002) & (K1 extends bigint | boolean | PropertyKey ? import("..").AssertType<K1 extends bigint ? `bigint(${K1})` : K1 extends boolean ? `boolean(${K1})` : K1, PropertyKey> : never)] : import("../utils/mapping").ObjectFromMappingEntries<[readonly [1, readonly [readonly ["Solana"]]], readonly [2, readonly [readonly ["Ethereum"]]], readonly [3, readonly [readonly ["Terra"]]], readonly [4, readonly [readonly ["Bsc"]]], readonly [5, readonly [readonly ["Polygon"]]], readonly [6, readonly [readonly ["Avalanche"]]], readonly [7, readonly [readonly ["Oasis"]]], readonly [8, readonly [readonly ["Algorand"]]], readonly [9, readonly [readonly ["Aurora"]]], readonly [10, readonly [readonly ["Fantom"]]], readonly [11, readonly [readonly ["Karura"]]], readonly [12, readonly [readonly ["Acala"]]], readonly [13, readonly [readonly ["Klaytn"]]], readonly [14, readonly [readonly ["Celo"]]], readonly [15, readonly [readonly ["Near"]]], readonly [16, readonly [readonly ["Moonbeam"]]], readonly [17, readonly [readonly ["Neon"]]], readonly [18, readonly [readonly ["Terra2"]]], readonly [19, readonly [readonly ["Injective"]]], readonly [20, readonly [readonly ["Osmosis"]]], readonly [21, readonly [readonly ["Sui"]]], readonly [22, readonly [readonly ["Aptos"]]], readonly [23, readonly [readonly ["Arbitrum"]]], readonly [24, readonly [readonly ["Optimism"]]], readonly [25, readonly [readonly ["Gnosis"]]], readonly [26, readonly [readonly ["Pythnet"]]], readonly [28, readonly [readonly ["Xpla"]]], readonly [29, readonly [readonly ["Btc"]]], readonly [30, readonly [readonly ["Base"]]], readonly [32, readonly [readonly ["Sei"]]], readonly [33, readonly [readonly ["Rootstock"]]], readonly [3104, readonly [readonly ["Wormchain"]]], readonly [4000, readonly [readonly ["Cosmoshub"]]], readonly [4001, readonly [readonly ["Evmos"]]], readonly [4002, readonly [readonly ["Kujira"]]], readonly [10002, readonly [readonly ["Sepolia"]]]]>[(3 | 1 | 5 | 2 | 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 | 3104 | 4000 | 4001 | 4002 | 10002) & (K1 extends bigint | boolean | PropertyKey ? import("..").AssertType<K1 extends bigint ? `bigint(${K1})` : K1 extends boolean ? `boolean(${K1})` : K1, PropertyKey> : never)] : never) & {
} ? import("../utils/mapping").ObjectFromMappingEntries<[readonly [1, [["Solana"]]], readonly [2, [["Ethereum"]]], readonly [3, [["Terra"]]], readonly [4, [["Bsc"]]], readonly [5, [["Polygon"]]], readonly [6, [["Avalanche"]]], readonly [7, [["Oasis"]]], readonly [8, [["Algorand"]]], readonly [9, [["Aurora"]]], readonly [10, [["Fantom"]]], readonly [11, [["Karura"]]], readonly [12, [["Acala"]]], readonly [13, [["Klaytn"]]], readonly [14, [["Celo"]]], readonly [15, [["Near"]]], readonly [16, [["Moonbeam"]]], readonly [17, [["Neon"]]], readonly [18, [["Terra2"]]], readonly [19, [["Injective"]]], readonly [20, [["Osmosis"]]], readonly [21, [["Sui"]]], readonly [22, [["Aptos"]]], readonly [23, [["Arbitrum"]]], readonly [24, [["Optimism"]]], readonly [25, [["Gnosis"]]], readonly [26, [["Pythnet"]]], readonly [28, [["Xpla"]]], readonly [29, [["Btc"]]], readonly [30, [["Base"]]], readonly [32, [["Sei"]]], readonly [33, [["Rootstock"]]], readonly [3104, [["Wormchain"]]], readonly [4000, [["Cosmoshub"]]], readonly [4001, [["Evmos"]]], readonly [4002, [["Kujira"]]], readonly [10002, [["Sepolia"]]]]>[(3 | 1 | 5 | 2 | 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 | 3104 | 4000 | 4001 | 4002 | 10002) & (K1 extends bigint | boolean | PropertyKey ? import("..").AssertType<K1 extends bigint ? `bigint(${K1})` : K1 extends boolean ? `boolean(${K1})` : K1, PropertyKey> : never)] : import("../utils/mapping").ObjectFromMappingEntries<[readonly [1, [["Solana"]]], readonly [2, [["Ethereum"]]], readonly [3, [["Terra"]]], readonly [4, [["Bsc"]]], readonly [5, [["Polygon"]]], readonly [6, [["Avalanche"]]], readonly [7, [["Oasis"]]], readonly [8, [["Algorand"]]], readonly [9, [["Aurora"]]], readonly [10, [["Fantom"]]], readonly [11, [["Karura"]]], readonly [12, [["Acala"]]], readonly [13, [["Klaytn"]]], readonly [14, [["Celo"]]], readonly [15, [["Near"]]], readonly [16, [["Moonbeam"]]], readonly [17, [["Neon"]]], readonly [18, [["Terra2"]]], readonly [19, [["Injective"]]], readonly [20, [["Osmosis"]]], readonly [21, [["Sui"]]], readonly [22, [["Aptos"]]], readonly [23, [["Arbitrum"]]], readonly [24, [["Optimism"]]], readonly [25, [["Gnosis"]]], readonly [26, [["Pythnet"]]], readonly [28, [["Xpla"]]], readonly [29, [["Btc"]]], readonly [30, [["Base"]]], readonly [32, [["Sei"]]], readonly [33, [["Rootstock"]]], readonly [3104, [["Wormchain"]]], readonly [4000, [["Cosmoshub"]]], readonly [4001, [["Evmos"]]], readonly [4002, [["Kujira"]]], readonly [10002, [["Sepolia"]]]]>[(3 | 1 | 5 | 2 | 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 | 3104 | 4000 | 4001 | 4002 | 10002) & (K1 extends bigint | boolean | PropertyKey ? import("..").AssertType<K1 extends bigint ? `bigint(${K1})` : K1 extends boolean ? `boolean(${K1})` : K1, PropertyKey> : never)] : never) & {
get: (args_0: number) => "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" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Sepolia" | undefined;

@@ -20,0 +20,0 @@ has: (args_0: number) => boolean;

import { Network } from "./networks";
import { Chain, ChainName } from "./chains";
export declare const circleChains: readonly ["Ethereum", "Avalanche", "Optimism", "Arbitrum", "Base"], circleChainIds: readonly [0, 1, 2, 3, 6];
export declare const circleChains: ["Ethereum", "Avalanche", "Optimism", "Arbitrum", "Base"], circleChainIds: [0, 1, 2, 3, 6];
export type CircleChainName = (typeof circleChains)[number];
export type CircleChainId = (typeof circleChainIds)[number];
export declare const circleNetworks: readonly ["Mainnet", "Testnet"], _: readonly [readonly [readonly ["Ethereum", "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"], readonly ["Avalanche", "0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e"], readonly ["Arbitrum", "0xaf88d065e77c8cC2239327C5EDb3A432268e5831"], readonly ["Optimism", "0x179522635726710dd7d2035a81d856de4aa7836c"], readonly ["Base", "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913"]], readonly [readonly ["Avalanche", "0x5425890298aed601595a70AB815c96711a31Bc65"], readonly ["Arbitrum", "0xfd064A18f3BF249cf1f87FC203E90D8f650f2d63"], readonly ["Ethereum", "0x07865c6e87b9f70255377e024ace6630c1eaa37f"], readonly ["Optimism", "0xe05606174bac4A6364B31bd0eCA4bf4dD368f8C6"], readonly ["Base", "0xf175520c52418dfe19c8098071a252da48cd1c19"]]];
export declare const circleNetworks: ["Mainnet", "Testnet"], _: [readonly [readonly ["Ethereum", "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"], readonly ["Avalanche", "0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e"], readonly ["Arbitrum", "0xaf88d065e77c8cC2239327C5EDb3A432268e5831"], readonly ["Optimism", "0x179522635726710dd7d2035a81d856de4aa7836c"], readonly ["Base", "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913"]], readonly [readonly ["Avalanche", "0x5425890298aed601595a70AB815c96711a31Bc65"], readonly ["Arbitrum", "0xfd064A18f3BF249cf1f87FC203E90D8f650f2d63"], readonly ["Ethereum", "0x07865c6e87b9f70255377e024ace6630c1eaa37f"], readonly ["Optimism", "0xe05606174bac4A6364B31bd0eCA4bf4dD368f8C6"], readonly ["Base", "0xf175520c52418dfe19c8098071a252da48cd1c19"]]];
export type CircleNetwork = (typeof circleNetworks)[number];

@@ -16,7 +16,7 @@ export declare const circleChainId: (<K1 extends "Ethereum" | "Avalanche" | "Arbitrum" | "Optimism" | "Base">(args_0: K1) => (K1 extends bigint | boolean | PropertyKey ? import("../utils").AssertType<K1 extends bigint ? `bigint(${K1})` : K1 extends boolean ? `boolean(${K1})` : K1, PropertyKey> : never) extends "Ethereum" | "Avalanche" | "Arbitrum" | "Optimism" | "Base" ? import("../utils").ObjectFromMappingEntries<readonly [readonly ["Ethereum", 0], readonly ["Avalanche", 1], readonly ["Optimism", 2], readonly ["Arbitrum", 3], readonly ["Base", 6]]>[("Ethereum" | "Avalanche" | "Arbitrum" | "Optimism" | "Base") & (K1 extends bigint | boolean | PropertyKey ? import("../utils").AssertType<K1 extends bigint ? `bigint(${K1})` : K1 extends boolean ? `boolean(${K1})` : K1, PropertyKey> : never)] extends {

};
export declare const circleChainIdToChainName: (<K1 extends 0 | 3 | 1 | 2 | 6>(args_0: K1) => (K1 extends bigint | boolean | PropertyKey ? import("../utils").AssertType<K1 extends bigint ? `bigint(${K1})` : K1 extends boolean ? `boolean(${K1})` : K1, PropertyKey> : never) extends 0 | 3 | 1 | 2 | 6 ? import("../utils").ObjectFromMappingEntries<[readonly [0, readonly [readonly ["Ethereum"]]], readonly [1, readonly [readonly ["Avalanche"]]], readonly [2, readonly [readonly ["Optimism"]]], readonly [3, readonly [readonly ["Arbitrum"]]], readonly [6, readonly [readonly ["Base"]]]]>[(0 | 3 | 1 | 2 | 6) & (K1 extends bigint | boolean | PropertyKey ? import("../utils").AssertType<K1 extends bigint ? `bigint(${K1})` : K1 extends boolean ? `boolean(${K1})` : K1, PropertyKey> : never)] extends {
export declare const circleChainIdToChainName: (<K1 extends 0 | 3 | 1 | 2 | 6>(args_0: K1) => (K1 extends bigint | boolean | PropertyKey ? import("../utils").AssertType<K1 extends bigint ? `bigint(${K1})` : K1 extends boolean ? `boolean(${K1})` : K1, PropertyKey> : never) extends 0 | 3 | 1 | 2 | 6 ? import("../utils").ObjectFromMappingEntries<[readonly [0, [["Ethereum"]]], readonly [1, [["Avalanche"]]], readonly [2, [["Optimism"]]], readonly [3, [["Arbitrum"]]], readonly [6, [["Base"]]]]>[(0 | 3 | 1 | 2 | 6) & (K1 extends bigint | boolean | PropertyKey ? import("../utils").AssertType<K1 extends bigint ? `bigint(${K1})` : K1 extends boolean ? `boolean(${K1})` : K1, PropertyKey> : never)] extends {
[key: string]: unknown;
[key: number]: unknown;
[key: symbol]: unknown;
} ? import("../utils").ObjectFromMappingEntries<[readonly [0, readonly [readonly ["Ethereum"]]], readonly [1, readonly [readonly ["Avalanche"]]], readonly [2, readonly [readonly ["Optimism"]]], readonly [3, readonly [readonly ["Arbitrum"]]], readonly [6, readonly [readonly ["Base"]]]]>[(0 | 3 | 1 | 2 | 6) & (K1 extends bigint | boolean | PropertyKey ? import("../utils").AssertType<K1 extends bigint ? `bigint(${K1})` : K1 extends boolean ? `boolean(${K1})` : K1, PropertyKey> : never)] : import("../utils").ObjectFromMappingEntries<[readonly [0, readonly [readonly ["Ethereum"]]], readonly [1, readonly [readonly ["Avalanche"]]], readonly [2, readonly [readonly ["Optimism"]]], readonly [3, readonly [readonly ["Arbitrum"]]], readonly [6, readonly [readonly ["Base"]]]]>[(0 | 3 | 1 | 2 | 6) & (K1 extends bigint | boolean | PropertyKey ? import("../utils").AssertType<K1 extends bigint ? `bigint(${K1})` : K1 extends boolean ? `boolean(${K1})` : K1, PropertyKey> : never)] : never) & {
} ? import("../utils").ObjectFromMappingEntries<[readonly [0, [["Ethereum"]]], readonly [1, [["Avalanche"]]], readonly [2, [["Optimism"]]], readonly [3, [["Arbitrum"]]], readonly [6, [["Base"]]]]>[(0 | 3 | 1 | 2 | 6) & (K1 extends bigint | boolean | PropertyKey ? import("../utils").AssertType<K1 extends bigint ? `bigint(${K1})` : K1 extends boolean ? `boolean(${K1})` : K1, PropertyKey> : never)] : import("../utils").ObjectFromMappingEntries<[readonly [0, [["Ethereum"]]], readonly [1, [["Avalanche"]]], readonly [2, [["Optimism"]]], readonly [3, [["Arbitrum"]]], readonly [6, [["Base"]]]]>[(0 | 3 | 1 | 2 | 6) & (K1 extends bigint | boolean | PropertyKey ? import("../utils").AssertType<K1 extends bigint ? `bigint(${K1})` : K1 extends boolean ? `boolean(${K1})` : K1, PropertyKey> : never)] : never) & {
get: (args_0: number) => "Ethereum" | "Avalanche" | "Arbitrum" | "Optimism" | "Base" | undefined;

@@ -23,0 +23,0 @@ has: (args_0: number) => boolean;

@@ -9,10 +9,10 @@ import { ChainName } from "./chains";

} ? import("../utils").ObjectFromMappingEntries<readonly [readonly ["Evm", readonly ["Acala", "Arbitrum", "Aurora", "Avalanche", "Base", "Bsc", "Celo", "Ethereum", "Fantom", "Gnosis", "Karura", "Klaytn", "Moonbeam", "Neon", "Oasis", "Optimism", "Polygon", "Rootstock", "Sepolia"]], readonly ["Solana", readonly ["Solana", "Pythnet"]], readonly ["Cosmwasm", readonly ["Cosmoshub", "Evmos", "Injective", "Kujira", "Osmosis", "Sei", "Terra", "Terra2", "Wormchain", "Xpla"]], readonly ["Btc", readonly ["Btc"]], readonly ["Algorand", readonly ["Algorand"]], readonly ["Sui", readonly ["Sui"]], readonly ["Aptos", readonly ["Aptos"]], readonly ["Near", readonly ["Near"]]]>[("Solana" | "Algorand" | "Near" | "Sui" | "Aptos" | "Btc" | "Evm" | "Cosmwasm") & (K1 extends bigint | boolean | PropertyKey ? import("../utils").AssertType<K1 extends bigint ? `bigint(${K1})` : K1 extends boolean ? `boolean(${K1})` : K1, PropertyKey> : never)] : import("../utils").ObjectFromMappingEntries<readonly [readonly ["Evm", readonly ["Acala", "Arbitrum", "Aurora", "Avalanche", "Base", "Bsc", "Celo", "Ethereum", "Fantom", "Gnosis", "Karura", "Klaytn", "Moonbeam", "Neon", "Oasis", "Optimism", "Polygon", "Rootstock", "Sepolia"]], readonly ["Solana", readonly ["Solana", "Pythnet"]], readonly ["Cosmwasm", readonly ["Cosmoshub", "Evmos", "Injective", "Kujira", "Osmosis", "Sei", "Terra", "Terra2", "Wormchain", "Xpla"]], readonly ["Btc", readonly ["Btc"]], readonly ["Algorand", readonly ["Algorand"]], readonly ["Sui", readonly ["Sui"]], readonly ["Aptos", readonly ["Aptos"]], readonly ["Near", readonly ["Near"]]]>[("Solana" | "Algorand" | "Near" | "Sui" | "Aptos" | "Btc" | "Evm" | "Cosmwasm") & (K1 extends bigint | boolean | PropertyKey ? import("../utils").AssertType<K1 extends bigint ? `bigint(${K1})` : K1 extends boolean ? `boolean(${K1})` : K1, PropertyKey> : never)] : never) & {
get: (args_0: string) => readonly ["Algorand"] | readonly ["Near"] | readonly ["Sui"] | readonly ["Aptos"] | readonly ["Btc"] | readonly ["Acala", "Arbitrum", "Aurora", "Avalanche", "Base", "Bsc", "Celo", "Ethereum", "Fantom", "Gnosis", "Karura", "Klaytn", "Moonbeam", "Neon", "Oasis", "Optimism", "Polygon", "Rootstock", "Sepolia"] | readonly ["Solana", "Pythnet"] | readonly ["Cosmoshub", "Evmos", "Injective", "Kujira", "Osmosis", "Sei", "Terra", "Terra2", "Wormchain", "Xpla"] | undefined;
get: (args_0: string) => readonly ["Acala", "Arbitrum", "Aurora", "Avalanche", "Base", "Bsc", "Celo", "Ethereum", "Fantom", "Gnosis", "Karura", "Klaytn", "Moonbeam", "Neon", "Oasis", "Optimism", "Polygon", "Rootstock", "Sepolia"] | readonly ["Solana", "Pythnet"] | readonly ["Cosmoshub", "Evmos", "Injective", "Kujira", "Osmosis", "Sei", "Terra", "Terra2", "Wormchain", "Xpla"] | readonly ["Btc"] | readonly ["Algorand"] | readonly ["Sui"] | readonly ["Aptos"] | readonly ["Near"] | undefined;
has: (args_0: string) => boolean;
};
export declare const chainToPlatform: (<K1 extends "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" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Sepolia">(args_0: K1) => (K1 extends bigint | boolean | PropertyKey ? import("../utils").AssertType<K1 extends bigint ? `bigint(${K1})` : K1 extends boolean ? `boolean(${K1})` : K1, PropertyKey> : never) extends "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" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Sepolia" ? import("../utils").ObjectFromMappingEntries<[readonly ["Acala", readonly [readonly ["Evm"]]], readonly ["Arbitrum", readonly [readonly ["Evm"]]], readonly ["Aurora", readonly [readonly ["Evm"]]], readonly ["Avalanche", readonly [readonly ["Evm"]]], readonly ["Base", readonly [readonly ["Evm"]]], readonly ["Bsc", readonly [readonly ["Evm"]]], readonly ["Celo", readonly [readonly ["Evm"]]], readonly ["Ethereum", readonly [readonly ["Evm"]]], readonly ["Fantom", readonly [readonly ["Evm"]]], readonly ["Gnosis", readonly [readonly ["Evm"]]], readonly ["Karura", readonly [readonly ["Evm"]]], readonly ["Klaytn", readonly [readonly ["Evm"]]], readonly ["Moonbeam", readonly [readonly ["Evm"]]], readonly ["Neon", readonly [readonly ["Evm"]]], readonly ["Oasis", readonly [readonly ["Evm"]]], readonly ["Optimism", readonly [readonly ["Evm"]]], readonly ["Polygon", readonly [readonly ["Evm"]]], readonly ["Rootstock", readonly [readonly ["Evm"]]], readonly ["Sepolia", readonly [readonly ["Evm"]]], readonly ["Solana", readonly [readonly ["Solana"]]], readonly ["Pythnet", readonly [readonly ["Solana"]]], readonly ["Cosmoshub", readonly [readonly ["Cosmwasm"]]], readonly ["Evmos", readonly [readonly ["Cosmwasm"]]], readonly ["Injective", readonly [readonly ["Cosmwasm"]]], readonly ["Kujira", readonly [readonly ["Cosmwasm"]]], readonly ["Osmosis", readonly [readonly ["Cosmwasm"]]], readonly ["Sei", readonly [readonly ["Cosmwasm"]]], readonly ["Terra", readonly [readonly ["Cosmwasm"]]], readonly ["Terra2", readonly [readonly ["Cosmwasm"]]], readonly ["Wormchain", readonly [readonly ["Cosmwasm"]]], readonly ["Xpla", readonly [readonly ["Cosmwasm"]]], readonly ["Btc", readonly [readonly ["Btc"]]], readonly ["Algorand", readonly [readonly ["Algorand"]]], readonly ["Sui", readonly [readonly ["Sui"]]], readonly ["Aptos", readonly [readonly ["Aptos"]]], readonly ["Near", readonly [readonly ["Near"]]]]>[("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" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Sepolia") & (K1 extends bigint | boolean | PropertyKey ? import("../utils").AssertType<K1 extends bigint ? `bigint(${K1})` : K1 extends boolean ? `boolean(${K1})` : K1, PropertyKey> : never)] extends {
export declare const chainToPlatform: (<K1 extends "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" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Sepolia">(args_0: K1) => (K1 extends bigint | boolean | PropertyKey ? import("../utils").AssertType<K1 extends bigint ? `bigint(${K1})` : K1 extends boolean ? `boolean(${K1})` : K1, PropertyKey> : never) extends "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" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Sepolia" ? import("../utils").ObjectFromMappingEntries<[readonly ["Acala", [["Evm"]]], readonly ["Arbitrum", [["Evm"]]], readonly ["Aurora", [["Evm"]]], readonly ["Avalanche", [["Evm"]]], readonly ["Base", [["Evm"]]], readonly ["Bsc", [["Evm"]]], readonly ["Celo", [["Evm"]]], readonly ["Ethereum", [["Evm"]]], readonly ["Fantom", [["Evm"]]], readonly ["Gnosis", [["Evm"]]], readonly ["Karura", [["Evm"]]], readonly ["Klaytn", [["Evm"]]], readonly ["Moonbeam", [["Evm"]]], readonly ["Neon", [["Evm"]]], readonly ["Oasis", [["Evm"]]], readonly ["Optimism", [["Evm"]]], readonly ["Polygon", [["Evm"]]], readonly ["Rootstock", [["Evm"]]], readonly ["Sepolia", [["Evm"]]], readonly ["Solana", [["Solana"]]], readonly ["Pythnet", [["Solana"]]], readonly ["Cosmoshub", [["Cosmwasm"]]], readonly ["Evmos", [["Cosmwasm"]]], readonly ["Injective", [["Cosmwasm"]]], readonly ["Kujira", [["Cosmwasm"]]], readonly ["Osmosis", [["Cosmwasm"]]], readonly ["Sei", [["Cosmwasm"]]], readonly ["Terra", [["Cosmwasm"]]], readonly ["Terra2", [["Cosmwasm"]]], readonly ["Wormchain", [["Cosmwasm"]]], readonly ["Xpla", [["Cosmwasm"]]], readonly ["Btc", [["Btc"]]], readonly ["Algorand", [["Algorand"]]], readonly ["Sui", [["Sui"]]], readonly ["Aptos", [["Aptos"]]], readonly ["Near", [["Near"]]]]>[("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" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Sepolia") & (K1 extends bigint | boolean | PropertyKey ? import("../utils").AssertType<K1 extends bigint ? `bigint(${K1})` : K1 extends boolean ? `boolean(${K1})` : K1, PropertyKey> : never)] extends {
[key: string]: unknown;
[key: number]: unknown;
[key: symbol]: unknown;
} ? import("../utils").ObjectFromMappingEntries<[readonly ["Acala", readonly [readonly ["Evm"]]], readonly ["Arbitrum", readonly [readonly ["Evm"]]], readonly ["Aurora", readonly [readonly ["Evm"]]], readonly ["Avalanche", readonly [readonly ["Evm"]]], readonly ["Base", readonly [readonly ["Evm"]]], readonly ["Bsc", readonly [readonly ["Evm"]]], readonly ["Celo", readonly [readonly ["Evm"]]], readonly ["Ethereum", readonly [readonly ["Evm"]]], readonly ["Fantom", readonly [readonly ["Evm"]]], readonly ["Gnosis", readonly [readonly ["Evm"]]], readonly ["Karura", readonly [readonly ["Evm"]]], readonly ["Klaytn", readonly [readonly ["Evm"]]], readonly ["Moonbeam", readonly [readonly ["Evm"]]], readonly ["Neon", readonly [readonly ["Evm"]]], readonly ["Oasis", readonly [readonly ["Evm"]]], readonly ["Optimism", readonly [readonly ["Evm"]]], readonly ["Polygon", readonly [readonly ["Evm"]]], readonly ["Rootstock", readonly [readonly ["Evm"]]], readonly ["Sepolia", readonly [readonly ["Evm"]]], readonly ["Solana", readonly [readonly ["Solana"]]], readonly ["Pythnet", readonly [readonly ["Solana"]]], readonly ["Cosmoshub", readonly [readonly ["Cosmwasm"]]], readonly ["Evmos", readonly [readonly ["Cosmwasm"]]], readonly ["Injective", readonly [readonly ["Cosmwasm"]]], readonly ["Kujira", readonly [readonly ["Cosmwasm"]]], readonly ["Osmosis", readonly [readonly ["Cosmwasm"]]], readonly ["Sei", readonly [readonly ["Cosmwasm"]]], readonly ["Terra", readonly [readonly ["Cosmwasm"]]], readonly ["Terra2", readonly [readonly ["Cosmwasm"]]], readonly ["Wormchain", readonly [readonly ["Cosmwasm"]]], readonly ["Xpla", readonly [readonly ["Cosmwasm"]]], readonly ["Btc", readonly [readonly ["Btc"]]], readonly ["Algorand", readonly [readonly ["Algorand"]]], readonly ["Sui", readonly [readonly ["Sui"]]], readonly ["Aptos", readonly [readonly ["Aptos"]]], readonly ["Near", readonly [readonly ["Near"]]]]>[("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" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Sepolia") & (K1 extends bigint | boolean | PropertyKey ? import("../utils").AssertType<K1 extends bigint ? `bigint(${K1})` : K1 extends boolean ? `boolean(${K1})` : K1, PropertyKey> : never)] : import("../utils").ObjectFromMappingEntries<[readonly ["Acala", readonly [readonly ["Evm"]]], readonly ["Arbitrum", readonly [readonly ["Evm"]]], readonly ["Aurora", readonly [readonly ["Evm"]]], readonly ["Avalanche", readonly [readonly ["Evm"]]], readonly ["Base", readonly [readonly ["Evm"]]], readonly ["Bsc", readonly [readonly ["Evm"]]], readonly ["Celo", readonly [readonly ["Evm"]]], readonly ["Ethereum", readonly [readonly ["Evm"]]], readonly ["Fantom", readonly [readonly ["Evm"]]], readonly ["Gnosis", readonly [readonly ["Evm"]]], readonly ["Karura", readonly [readonly ["Evm"]]], readonly ["Klaytn", readonly [readonly ["Evm"]]], readonly ["Moonbeam", readonly [readonly ["Evm"]]], readonly ["Neon", readonly [readonly ["Evm"]]], readonly ["Oasis", readonly [readonly ["Evm"]]], readonly ["Optimism", readonly [readonly ["Evm"]]], readonly ["Polygon", readonly [readonly ["Evm"]]], readonly ["Rootstock", readonly [readonly ["Evm"]]], readonly ["Sepolia", readonly [readonly ["Evm"]]], readonly ["Solana", readonly [readonly ["Solana"]]], readonly ["Pythnet", readonly [readonly ["Solana"]]], readonly ["Cosmoshub", readonly [readonly ["Cosmwasm"]]], readonly ["Evmos", readonly [readonly ["Cosmwasm"]]], readonly ["Injective", readonly [readonly ["Cosmwasm"]]], readonly ["Kujira", readonly [readonly ["Cosmwasm"]]], readonly ["Osmosis", readonly [readonly ["Cosmwasm"]]], readonly ["Sei", readonly [readonly ["Cosmwasm"]]], readonly ["Terra", readonly [readonly ["Cosmwasm"]]], readonly ["Terra2", readonly [readonly ["Cosmwasm"]]], readonly ["Wormchain", readonly [readonly ["Cosmwasm"]]], readonly ["Xpla", readonly [readonly ["Cosmwasm"]]], readonly ["Btc", readonly [readonly ["Btc"]]], readonly ["Algorand", readonly [readonly ["Algorand"]]], readonly ["Sui", readonly [readonly ["Sui"]]], readonly ["Aptos", readonly [readonly ["Aptos"]]], readonly ["Near", readonly [readonly ["Near"]]]]>[("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" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Sepolia") & (K1 extends bigint | boolean | PropertyKey ? import("../utils").AssertType<K1 extends bigint ? `bigint(${K1})` : K1 extends boolean ? `boolean(${K1})` : K1, PropertyKey> : never)] : never) & {
} ? import("../utils").ObjectFromMappingEntries<[readonly ["Acala", [["Evm"]]], readonly ["Arbitrum", [["Evm"]]], readonly ["Aurora", [["Evm"]]], readonly ["Avalanche", [["Evm"]]], readonly ["Base", [["Evm"]]], readonly ["Bsc", [["Evm"]]], readonly ["Celo", [["Evm"]]], readonly ["Ethereum", [["Evm"]]], readonly ["Fantom", [["Evm"]]], readonly ["Gnosis", [["Evm"]]], readonly ["Karura", [["Evm"]]], readonly ["Klaytn", [["Evm"]]], readonly ["Moonbeam", [["Evm"]]], readonly ["Neon", [["Evm"]]], readonly ["Oasis", [["Evm"]]], readonly ["Optimism", [["Evm"]]], readonly ["Polygon", [["Evm"]]], readonly ["Rootstock", [["Evm"]]], readonly ["Sepolia", [["Evm"]]], readonly ["Solana", [["Solana"]]], readonly ["Pythnet", [["Solana"]]], readonly ["Cosmoshub", [["Cosmwasm"]]], readonly ["Evmos", [["Cosmwasm"]]], readonly ["Injective", [["Cosmwasm"]]], readonly ["Kujira", [["Cosmwasm"]]], readonly ["Osmosis", [["Cosmwasm"]]], readonly ["Sei", [["Cosmwasm"]]], readonly ["Terra", [["Cosmwasm"]]], readonly ["Terra2", [["Cosmwasm"]]], readonly ["Wormchain", [["Cosmwasm"]]], readonly ["Xpla", [["Cosmwasm"]]], readonly ["Btc", [["Btc"]]], readonly ["Algorand", [["Algorand"]]], readonly ["Sui", [["Sui"]]], readonly ["Aptos", [["Aptos"]]], readonly ["Near", [["Near"]]]]>[("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" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Sepolia") & (K1 extends bigint | boolean | PropertyKey ? import("../utils").AssertType<K1 extends bigint ? `bigint(${K1})` : K1 extends boolean ? `boolean(${K1})` : K1, PropertyKey> : never)] : import("../utils").ObjectFromMappingEntries<[readonly ["Acala", [["Evm"]]], readonly ["Arbitrum", [["Evm"]]], readonly ["Aurora", [["Evm"]]], readonly ["Avalanche", [["Evm"]]], readonly ["Base", [["Evm"]]], readonly ["Bsc", [["Evm"]]], readonly ["Celo", [["Evm"]]], readonly ["Ethereum", [["Evm"]]], readonly ["Fantom", [["Evm"]]], readonly ["Gnosis", [["Evm"]]], readonly ["Karura", [["Evm"]]], readonly ["Klaytn", [["Evm"]]], readonly ["Moonbeam", [["Evm"]]], readonly ["Neon", [["Evm"]]], readonly ["Oasis", [["Evm"]]], readonly ["Optimism", [["Evm"]]], readonly ["Polygon", [["Evm"]]], readonly ["Rootstock", [["Evm"]]], readonly ["Sepolia", [["Evm"]]], readonly ["Solana", [["Solana"]]], readonly ["Pythnet", [["Solana"]]], readonly ["Cosmoshub", [["Cosmwasm"]]], readonly ["Evmos", [["Cosmwasm"]]], readonly ["Injective", [["Cosmwasm"]]], readonly ["Kujira", [["Cosmwasm"]]], readonly ["Osmosis", [["Cosmwasm"]]], readonly ["Sei", [["Cosmwasm"]]], readonly ["Terra", [["Cosmwasm"]]], readonly ["Terra2", [["Cosmwasm"]]], readonly ["Wormchain", [["Cosmwasm"]]], readonly ["Xpla", [["Cosmwasm"]]], readonly ["Btc", [["Btc"]]], readonly ["Algorand", [["Algorand"]]], readonly ["Sui", [["Sui"]]], readonly ["Aptos", [["Aptos"]]], readonly ["Near", [["Near"]]]]>[("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" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Sepolia") & (K1 extends bigint | boolean | PropertyKey ? import("../utils").AssertType<K1 extends bigint ? `bigint(${K1})` : K1 extends boolean ? `boolean(${K1})` : K1, PropertyKey> : never)] : never) & {
get: (args_0: string) => "Solana" | "Algorand" | "Near" | "Sui" | "Aptos" | "Btc" | "Evm" | "Cosmwasm" | undefined;

@@ -19,0 +19,0 @@ has: (args_0: string) => boolean;

@@ -1,4 +0,4 @@

export declare const protocols: readonly ["WormholeCore", "TokenBridge", "AutomaticTokenBridge", "CircleBridge", "AutomaticCircleBridge", "Relayer", "NftBridge"];
export declare const protocols: readonly ["CoreBridge", "TokenBridge", "NftBridge", "Relayer", "CCTP"];
export type ProtocolName = (typeof protocols)[number];
export declare const isProtocolName: (protocol: string) => protocol is "WormholeCore" | "TokenBridge" | "AutomaticTokenBridge" | "CircleBridge" | "AutomaticCircleBridge" | "Relayer" | "NftBridge";
export declare const isProtocolName: (protocol: string) => protocol is "CoreBridge" | "TokenBridge" | "NftBridge" | "Relayer" | "CCTP";
//# sourceMappingURL=protocols.d.ts.map

@@ -21,3 +21,3 @@ /* TODO:

* With all of this in mind: What should we name modules here?
* My preferred choice would be ["Wormholecore", "TokenBridge", "NftBridge", "Relayer"]
* My preferred choice would be ["CoreBridge", "TokenBridge", "NftBridge", "Relayer"]
* but ["Core", "TokenBridge", "NFTBridge", "WormholeRelayer"] seems to be more consistent given

@@ -27,12 +27,9 @@ * current naming "conventions"

export const protocols = [
"WormholeCore",
"CoreBridge",
"TokenBridge",
"AutomaticTokenBridge",
"CircleBridge",
"AutomaticCircleBridge",
"NftBridge",
"Relayer",
// not implemented
"NftBridge",
"CCTP",
];
export const isProtocolName = (protocol) => protocols.includes(protocol);
//# sourceMappingURL=protocols.js.map
import { ParseNumber, RoArray, RoArray2D } from "./metaprogramming";
export type IndexEs = number | RoArray<number>;
export declare const range: (length: number) => number[];
export type Entries<T extends RoArray> = readonly [...{
[K in keyof T]: K extends `${number}` ? [T[K], ParseNumber<K>] : never;
}];
export type Entries<T extends RoArray> = [
...{
[K in keyof T]: K extends `${number}` ? [T[K], ParseNumber<K>] : never;
}
];
export type Flatten<T extends RoArray> = T extends readonly [infer Head, ...infer Tail] ? Head extends RoArray ? [...Head, ...Flatten<Tail>] : [Head, ...Flatten<Tail>] : [];

@@ -16,3 +18,3 @@ export type InnerFlatten<T extends RoArray> = [

...{
[K in keyof T]: K extends `${number}` ? readonly [T[K]] : never;
[K in keyof T]: K extends `${number}` ? [T[K]] : never;
}

@@ -30,3 +32,3 @@ ];

...{
[K in keyof Head]: K extends `${number}` ? readonly [...{
[K in keyof Head]: K extends `${number}` ? [...{
[K2 in keyof A]: K extends keyof A[K2] ? A[K2][K] : never;

@@ -43,5 +45,5 @@ }] : never;

}]> : R extends RoArray ? [...{
[K in keyof R]: K extends `${number}` ? readonly [L, R[K]] : never;
[K in keyof R]: K extends `${number}` ? [L, R[K]] : never;
}] : [L, R];
export {};
//# sourceMappingURL=array.d.ts.map

@@ -34,18 +34,16 @@ import { isUintType, isBytesType, numberMaxSize, } from "./layout";

switch (item.binary) {
case "object": {
return internalDeserializeLayout(item.layout, encoded, offset);
}
case "array": {
let ret = [];
if (item.lengthSize !== undefined) {
const [length, newOffset] = deserializeUint(encoded, offset, item.lengthSize);
offset = newOffset;
for (let i = 0; i < length; ++i)
[ret[i], offset] = internalDeserializeLayout(item.layout, encoded, offset);
case "uint": {
const [value, newOffset] = deserializeUint(encoded, offset, item.size);
if (isUintType(item.custom)) {
checkUintEquals(item.custom, value);
return [item.custom, newOffset];
}
else {
while (offset < encoded.length)
[ret[ret.length], offset] = internalDeserializeLayout(item.layout, encoded, offset);
if (isUintType(item?.custom?.from)) {
checkUintEquals(item.custom.from, value);
return [item.custom.to, newOffset];
}
return [ret, offset];
return [
item.custom !== undefined ? item.custom.to(value) : value,
newOffset
];
}

@@ -88,15 +86,39 @@ case "bytes": {

}
case "uint": {
const [value, newOffset] = deserializeUint(encoded, offset, item.size);
if (isUintType(item.custom)) {
checkUintEquals(item.custom, value);
return [item.custom, newOffset];
case "array": {
let ret = [];
const { arrayItem } = item;
const deserializeArrayItem = (index) => {
const [deserializedItem, newOffset] = deserializeLayoutItem({ name: `${item.name}[${index}]`, ...arrayItem }, encoded, offset);
ret.push(deserializedItem);
offset = newOffset;
};
if (item.lengthSize !== undefined) {
const [length, newOffset] = deserializeUint(encoded, offset, item.lengthSize);
offset = newOffset;
for (let i = 0; i < length; ++i)
deserializeArrayItem(i);
}
if (isUintType(item?.custom?.from)) {
checkUintEquals(item.custom.from, value);
return [item.custom.to, newOffset];
}
else
while (offset < encoded.length)
deserializeArrayItem(ret.length);
return [ret, offset];
}
case "object": {
return internalDeserializeLayout(item.layout, encoded, offset);
}
case "switch": {
const [id, newOffset] = deserializeUint(encoded, offset, item.idSize);
const { idLayoutPairs } = item;
if (idLayoutPairs.length === 0)
throw new Error(`switch item '${item.name}' has no idLayoutPairs`);
const hasPlainIds = typeof idLayoutPairs[0][0] === "number";
const pair = idLayoutPairs.find(([idOrConversionId]) => hasPlainIds ? idOrConversionId === id : (idOrConversionId)[0] === id);
if (pair === undefined)
throw new Error(`unknown id value: ${id}`);
const [idOrConversionId, idLayout] = pair;
const [decoded, nextOffset] = internalDeserializeLayout(idLayout, encoded, newOffset);
return [
item.custom !== undefined ? item.custom.to(value) : value,
newOffset
{ [item.idTag ?? "id"]: hasPlainIds ? id : idOrConversionId[1],
...decoded },
nextOffset
];

@@ -103,0 +125,0 @@ }

@@ -26,8 +26,15 @@ import { isUintType, isBytesType, } from "./layout";

switch (item.binary) {
case "object": {
return createLayoutMeta(item.layout, offset, fixedBytes);
case "uint": {
const fixedVal = isUintType(item.custom)
? item.custom
: isUintType(item?.custom?.from)
? item.custom.from
: null;
if (fixedVal !== null) {
const serialized = new Uint8Array(item.size);
serializeUint(serialized, 0, fixedVal, item.size);
return knownFixed(item.size, serialized);
}
return [item.size, item.size];
}
case "array": {
return [item.lengthSize !== undefined ? item.lengthSize : 0, Infinity];
}
case "bytes": {

@@ -45,15 +52,66 @@ if ("size" in item && item.size !== undefined)

}
case "uint": {
const fixedVal = isUintType(item.custom)
? item.custom
: isUintType(item?.custom?.from)
? item.custom.from
: null;
if (fixedVal !== null) {
const serialized = new Uint8Array(item.size);
serializeUint(serialized, 0, fixedVal, item.size);
return knownFixed(item.size, serialized);
}
return [item.size, item.size];
case "array": {
return [item.lengthSize !== undefined ? item.lengthSize : 0, Infinity];
}
case "object": {
return createLayoutMeta(item.layout, offset, fixedBytes);
}
case "switch": {
const caseFixedBytes = item.idLayoutPairs.map(_ => []);
const { idSize } = item;
const caseBounds = item.idLayoutPairs.map(([idOrConversionId, layout], caseIndex) => {
const idVal = Array.isArray(idOrConversionId) ? idOrConversionId[0] : idOrConversionId;
if (offset !== null) {
const serializedId = new Uint8Array(idSize);
serializeUint(serializedId, 0, idVal, idSize);
caseFixedBytes[caseIndex].push([0, serializedId]);
}
const ret = createLayoutMeta(layout, offset ? idSize : null, caseFixedBytes[caseIndex]);
return [ret[0] + idSize, ret[1] + idSize];
});
if (offset !== null)
//find bytes that have the same value across all cases (turning this into a lambda to enable
// early return from inner loops)
(() => {
//constrain search to the minimum length of all cases
const minLen = Math.min(...caseFixedBytes.map(fbs => fbs.at(-1)[0] + fbs.at(-1)[1].length));
//keep track of the current index in each case's fixed bytes array
const itIndexes = caseFixedBytes.map(_ => 0);
for (let bytePos = 0; bytePos < minLen;) {
let byteVal = null;
let caseIndex = 0;
while (caseIndex < caseFixedBytes.length) {
let curItIndex = itIndexes[caseIndex];
const curFixedBytes = caseFixedBytes[caseIndex];
const [curOffset, curSerialized] = curFixedBytes[curItIndex];
if (curOffset + curSerialized.length <= bytePos) {
//no fixed byte at this position in this case
++curItIndex;
if (curItIndex === curFixedBytes.length)
return; //we have exhausted all fixed bytes in at least one case
itIndexes[caseIndex] = curItIndex;
//jump to the next possible bytePos given the fixed bytes of the current case index
bytePos = curFixedBytes[curItIndex][0];
break;
}
const curByteVal = curSerialized[bytePos - curOffset];
if (byteVal === null)
byteVal = curByteVal;
if (curByteVal !== byteVal)
break;
caseIndex++;
}
//only if we made it through all cases without breaking do we have a fixed byte
// and hence add it to the list of fixed bytes
if (caseIndex === caseFixedBytes.length) {
fixedBytes.push([offset + bytePos, new Uint8Array([byteVal])]);
++bytePos;
}
}
})();
return [
Math.min(...caseBounds.map(([lower]) => lower)),
Math.max(...caseBounds.map(([_, upper]) => upper))
];
}
}

@@ -60,0 +118,0 @@ }

@@ -1,18 +0,24 @@

import { Layout, LayoutItem, ObjectLayoutItem, ArrayLayoutItem, LayoutToType, PrimitiveType, FixedConversion } from "./layout";
type FilterFixedItem<I extends LayoutItem> = I extends {
import { Layout, LayoutItem, NamedLayoutItem, UintLayoutItem, BytesLayoutItem, ObjectLayoutItem, ArrayLayoutItem, SwitchLayoutItem, LayoutToType, PrimitiveType, FixedConversion } from "./layout";
type IsNever<T> = [T] extends [never] ? true : false;
type IsEmpty<T> = IsNever<T> extends false ? T extends readonly [unknown, ...unknown[]] ? false : true : true;
type IdLayoutPair = readonly [unknown, Layout];
type FilterItemsOfIdLayoutPairs<ILA extends readonly IdLayoutPair[], Fixed extends boolean> = ILA extends readonly [infer H extends IdLayoutPair, ...infer T extends readonly IdLayoutPair[]] ? FilterItemsOfLayout<H[1], Fixed> extends infer L ? IsEmpty<L> extends false ? [[H[0], L], ...FilterItemsOfIdLayoutPairs<T, Fixed>] : FilterItemsOfIdLayoutPairs<T, Fixed> : never : [];
type FilterItem<I extends LayoutItem, Fixed extends boolean> = [
I
] extends [UintLayoutItem | BytesLayoutItem] ? I extends {
custom: PrimitiveType | FixedConversion<PrimitiveType, any>;
} ? I : I extends ObjectLayoutItem | ArrayLayoutItem ? FixedItemsOfLayout<I["layout"]> extends readonly LayoutItem[] ? [FixedItemsOfLayout<I["layout"]>[number]] extends [never] ? never : {
readonly [K in keyof I]: K extends "layout" ? FixedItemsOfLayout<I["layout"]> : I[K];
} : never : never;
export type FixedItemsOfLayout<L extends Layout> = L extends readonly [infer H extends LayoutItem, ...infer T] ? [FilterFixedItem<H>] extends [never] ? T extends Layout ? FixedItemsOfLayout<T> : readonly [] : T extends Layout ? readonly [FilterFixedItem<H>, ...FixedItemsOfLayout<T>] : readonly [FilterFixedItem<H>] : readonly [];
export declare const fixedItemsOfLayout: <L extends Layout>(layout: L) => FixedItemsOfLayout<L>;
type FilterDynamicItem<I extends LayoutItem> = I extends {
custom: PrimitiveType | FixedConversion<PrimitiveType, any>;
} ? never : I extends ObjectLayoutItem | ArrayLayoutItem ? DynamicItemsOfLayout<I["layout"]> extends readonly LayoutItem[] ? [DynamicItemsOfLayout<I["layout"]>[number]] extends [never] ? never : {
readonly [K in keyof I]: K extends "layout" ? DynamicItemsOfLayout<I["layout"]> : I[K];
} : never : I;
export type DynamicItemsOfLayout<L extends Layout> = L extends readonly [infer H extends LayoutItem, ...infer T] ? [FilterDynamicItem<H>] extends [never] ? T extends Layout ? DynamicItemsOfLayout<T> : readonly [] : T extends Layout ? readonly [FilterDynamicItem<H>, ...DynamicItemsOfLayout<T>] : readonly [FilterDynamicItem<H>] : readonly [];
export declare const dynamicItemsOfLayout: <L extends Layout>(layout: L) => DynamicItemsOfLayout<L>;
export declare const addFixedValues: <L extends Layout>(layout: L, dynamicValues: LayoutToType<DynamicItemsOfLayout<L>>) => LayoutToType<L>;
} ? Fixed extends true ? I : never : Fixed extends true ? never : I : [I] extends [ArrayLayoutItem] ? FilterItem<I["arrayItem"], Fixed> extends infer LI ? {
readonly [K in keyof I]: K extends "arrayItem" ? LI : I[K];
} : never : [I] extends [ObjectLayoutItem] ? FilterItemsOfLayout<I["layout"], Fixed> extends infer L ? IsEmpty<L> extends false ? {
readonly [K in keyof I]: K extends "layout" ? L : I[K];
} : never : never : [I] extends [SwitchLayoutItem] ? {
readonly [K in keyof I]: K extends "idLayoutPairs" ? FilterItemsOfIdLayoutPairs<I["idLayoutPairs"], Fixed> : I[K];
} : never;
type FilterItemsOfLayout<L extends Layout, Fixed extends boolean> = L extends readonly [infer H extends NamedLayoutItem, ...infer T extends Layout] ? FilterItem<H, Fixed> extends infer I extends NamedLayoutItem ? IsNever<I> extends false ? [I, ...FilterItemsOfLayout<T, Fixed>] : FilterItemsOfLayout<T, Fixed> : never : [];
export type FixedItemsOfLayout<L extends Layout> = FilterItemsOfLayout<L, true>;
export type DynamicItemsOfLayout<L extends Layout> = FilterItemsOfLayout<L, false>;
export declare const fixedItemsOfLayout: <L extends Layout>(layout: L) => FilterItemsOfLayout<L, true>;
export declare const dynamicItemsOfLayout: <L extends Layout>(layout: L) => FilterItemsOfLayout<L, false>;
export declare function addFixedValues<L extends Layout>(layout: L, dynamicValues: LayoutToType<DynamicItemsOfLayout<L>>): LayoutToType<L>;
export {};
//# sourceMappingURL=fixedDynamic.d.ts.map
import { isPrimitiveType, } from "./layout";
export const fixedItemsOfLayout = (layout) => layout.reduce((acc, item) => {
if (item["custom"] !== undefined && (isPrimitiveType(item["custom"]) || isPrimitiveType(item["custom"].from)))
return [...acc, item];
if (item.binary === "array" || item.binary === "object") {
const fixedItems = fixedItemsOfLayout(item.layout);
if (fixedItems.length > 0)
return [...acc, { ...item, layout: fixedItems }];
function filterItem(item, fixed) {
switch (item.binary) {
case "uint":
case "bytes": {
const isFixedItem = item["custom"] !== undefined && (isPrimitiveType(item["custom"]) || isPrimitiveType(item["custom"].from));
return (fixed && isFixedItem || !fixed && !isFixedItem) ? item : null;
}
case "array": {
const filtered = filterItem(item.arrayItem, fixed);
return (filtered !== null) ? { ...item, arrayItem: filtered } : null;
}
case "object": {
const filteredItems = filterItemsOfLayout(item.layout, fixed);
return (filteredItems.length > 0) ? { ...item, layout: filteredItems } : null;
}
case "switch": {
const filteredIdLayoutPairs = item.idLayoutPairs.reduce((acc, [idOrConversionId, idLayout]) => {
const filteredItems = filterItemsOfLayout(idLayout, fixed);
return filteredItems.length > 0
? [...acc, [idOrConversionId, filteredItems]]
: acc;
}, []);
return { ...item, idLayoutPairs: filteredIdLayoutPairs };
}
}
return acc;
}, []);
export const dynamicItemsOfLayout = (layout) => layout.reduce((acc, item) => {
if (item["custom"] === undefined || !(isPrimitiveType(item["custom"]) || isPrimitiveType(item["custom"].from)))
return [...acc, item];
if (item.binary === "array" || item.binary === "object") {
const dynamicItems = dynamicItemsOfLayout(item.layout);
if (dynamicItems.length > 0)
return [...acc, { ...item, layout: dynamicItems }];
}
return acc;
}, []);
export const addFixedValues = (layout, dynamicValues) => {
}
function filterItemsOfLayout(layout, fixed) {
return layout.reduce((acc, item) => {
const filtered = filterItem(item, fixed);
return filtered !== null ? [...acc, filtered] : acc;
}, []);
}
export const fixedItemsOfLayout = (layout) => filterItemsOfLayout(layout, true);
export const dynamicItemsOfLayout = (layout) => filterItemsOfLayout(layout, false);
export function addFixedValues(layout, dynamicValues) {
const ret = {};
for (const item of layout) {
if (item.binary === "object") {
const subDynamicValues = ((item.name in dynamicValues)
? dynamicValues[item.name]
: {});
ret[item.name] = addFixedValues(item.layout, subDynamicValues);
const fromDynamic = () => dynamicValues[item.name];
switch (item.binary) {
case "uint":
case "bytes": {
if (!item?.omit)
ret[item.name] = (item.custom !== undefined &&
(isPrimitiveType(item.custom) || isPrimitiveType(item.custom.from))) ? (isPrimitiveType(item.custom) ? item.custom : item.custom.to)
: fromDynamic();
break;
}
case "array": {
if (item.name in dynamicValues) {
ret[item.name] = (item.arrayItem.binary !== "object")
? fromDynamic()
: fromDynamic().map(element => addFixedValues(item.arrayItem.layout, element));
}
break;
}
case "object": {
const subDynamicValues = ((item.name in dynamicValues) ? fromDynamic() : {});
ret[item.name] = addFixedValues(item.layout, subDynamicValues);
break;
}
case "switch": {
const id = fromDynamic()[item.idTag ?? "id"];
const [_, idLayout] = item.idLayoutPairs.find(([idOrConversionId]) => (Array.isArray(idOrConversionId) ? idOrConversionId[1] : idOrConversionId) == id);
ret[item.name] = {
[item.idTag ?? "id"]: id,
...addFixedValues(idLayout, fromDynamic())
};
break;
}
}
else if (item.binary === "array") {
const subDynamicValues = ((item.name in dynamicValues)
? dynamicValues[item.name]
: []);
ret[item.name] = subDynamicValues.map(element => addFixedValues(item.layout, element));
}
else if (item.custom !== undefined &&
(isPrimitiveType(item.custom) || isPrimitiveType(item.custom.from))) {
if (!item?.omit)
ret[item.name] = isPrimitiveType(item.custom) ? item.custom : item.custom.to;
}
else
ret[item.name] = dynamicValues[item.name];
}
return ret;
};
}
//# sourceMappingURL=fixedDynamic.js.map

@@ -1,2 +0,2 @@

export { Layout, LayoutItem, UintLayoutItem, BytesLayoutItem, FixedPrimitiveBytesLayoutItem, FixedValueBytesLayoutItem, FixedSizeBytesLayoutItem, LengthPrefixedBytesLayoutItem, ArrayLayoutItem, ObjectLayoutItem, LayoutToType, LayoutItemToType, FixedConversion, CustomConversion, } from "./layout";
export { Layout, LayoutItem, NamedLayoutItem, UintLayoutItem, BytesLayoutItem, FixedPrimitiveBytesLayoutItem, FixedValueBytesLayoutItem, FixedSizeBytesLayoutItem, LengthPrefixedBytesLayoutItem, ArrayLayoutItem, ObjectLayoutItem, LayoutToType, LayoutItemToType, FixedConversion, CustomConversion, } from "./layout";
export { serializeLayout } from "./serialize";

@@ -3,0 +3,0 @@ export { deserializeLayout } from "./deserialize";

@@ -7,3 +7,3 @@ export type UintType = number | bigint;

export declare const isPrimitiveType: (x: any) => x is PrimitiveType;
export type BinaryLiterals = "uint" | "bytes" | "array" | "object";
export type BinaryLiterals = "uint" | "bytes" | "array" | "object" | "switch";
export type NumberSize = 1 | 2 | 3 | 4 | 5 | 6;

@@ -21,3 +21,2 @@ export declare const numberMaxSize = 6;

interface LayoutItemBase<BL extends BinaryLiterals> {
readonly name: string;
readonly binary: BL;

@@ -54,3 +53,3 @@ }

readonly lengthSize?: NumberSize;
readonly layout: Layout;
readonly arrayItem: LayoutItem;
}

@@ -60,8 +59,19 @@ export interface ObjectLayoutItem extends LayoutItemBase<"object"> {

}
type PlainId = number;
type ConversionId = readonly [number, unknown];
type IdLayoutPair<Id extends PlainId | ConversionId, L extends Layout = Layout> = readonly [Id, L];
export interface SwitchLayoutItem extends LayoutItemBase<"switch"> {
readonly idTag?: string;
readonly idSize: NumberSize;
readonly idLayoutPairs: readonly IdLayoutPair<PlainId>[] | readonly IdLayoutPair<ConversionId>[];
}
export type UintLayoutItem = PrimitiveFixedUintLayoutItem<number> | OptionalToFromUintLayoutItem<number> | PrimitiveFixedUintLayoutItem<bigint> | OptionalToFromUintLayoutItem<bigint>;
export type BytesLayoutItem = FixedPrimitiveBytesLayoutItem | FixedValueBytesLayoutItem | FixedSizeBytesLayoutItem | LengthPrefixedBytesLayoutItem;
export type LayoutItem = UintLayoutItem | BytesLayoutItem | ArrayLayoutItem | ObjectLayoutItem;
export type Layout = readonly LayoutItem[];
export type LayoutItem = UintLayoutItem | BytesLayoutItem | ArrayLayoutItem | ObjectLayoutItem | SwitchLayoutItem;
export type NamedLayoutItem = LayoutItem & {
readonly name: string;
};
export type Layout = readonly NamedLayoutItem[];
type NameOrOmitted<T extends {
name: PropertyKey;
name: string;
}> = T extends {

@@ -73,6 +83,11 @@ omit: true;

};
type MaybeConvert<Id extends PlainId | ConversionId> = Id extends readonly [number, infer Converted] ? Converted : Id;
type IdLayoutPairArray = readonly IdLayoutPair<number>[] | readonly IdLayoutPair<ConversionId>[];
type IdLayoutPairsToTypeUnion<T extends IdLayoutPairArray, IdTag extends string> = T extends readonly [infer Head, ...infer Tail extends IdLayoutPairArray] ? Head extends IdLayoutPair<infer MaybeConversionId, infer L extends Layout> ? MaybeConvert<MaybeConversionId> extends infer Id ? LayoutToType<L> extends infer LT extends object ? {
readonly [K in IdTag | keyof LT]: K extends keyof LT ? LT[K] : Id;
} | IdLayoutPairsToTypeUnion<Tail, IdTag> : never : never : never : never;
export type LayoutItemToType<I extends LayoutItem> = [
I
] extends [ArrayLayoutItem] ? LayoutToType<I["layout"]>[] : [I] extends [ObjectLayoutItem] ? LayoutToType<I["layout"]> : [I] extends [UintLayoutItem] ? I["custom"] extends UintType ? I["custom"] : I["custom"] extends CustomConversion<any, infer ToType> ? ToType : I["custom"] extends FixedConversion<any, infer ToType> ? ToType : UintSizeToPrimitive<I["size"]> : [I] extends [BytesLayoutItem] ? I["custom"] extends CustomConversion<BytesType, infer ToType> ? ToType : I["custom"] extends FixedConversion<BytesType, infer ToType> ? ToType : BytesType : never;
] extends [UintLayoutItem] ? I["custom"] extends UintType ? I["custom"] : I["custom"] extends CustomConversion<infer FromType extends UintType, infer ToType> ? ToType : I["custom"] extends FixedConversion<infer FromType extends UintType, infer ToType> ? ToType : UintSizeToPrimitive<I["size"]> : [I] extends [BytesLayoutItem] ? I["custom"] extends CustomConversion<BytesType, infer ToType> ? ToType : I["custom"] extends FixedConversion<BytesType, infer ToType> ? ToType : BytesType : [I] extends [ArrayLayoutItem] ? readonly LayoutItemToType<I["arrayItem"]>[] : [I] extends [ObjectLayoutItem] ? LayoutToType<I["layout"]> : [I] extends [SwitchLayoutItem] ? IdLayoutPairsToTypeUnion<I["idLayoutPairs"], I["idTag"] extends string ? I["idTag"] : "id"> : never;
export {};
//# sourceMappingURL=layout.d.ts.map

@@ -1,3 +0,1 @@

//TODO:
// * implement a switch layout item that maps different values (versions) to different sublayouts
export const isUintType = (x) => typeof x === "number" || typeof x === "bigint";

@@ -4,0 +2,0 @@ export const isBytesType = (x) => x instanceof Uint8Array;

@@ -9,34 +9,45 @@ import { isUintType, isBytesType, numberMaxSize, } from "./layout";

}
const calcLayoutSize = (layout, data) => layout.reduce((acc, item) => {
const findIdLayoutPair = (item, data) => {
const id = data[item.idTag ?? "id"];
return item.idLayoutPairs.find(([idOrConversionId]) => (Array.isArray(idOrConversionId) ? idOrConversionId[1] : idOrConversionId) == id);
};
const withIgnoredName = (item) => ({ ...item, name: "ignored" });
const calcItemSize = (item, data) => {
switch (item.binary) {
case "object": {
return acc + calcLayoutSize(item.layout, data[item.name]);
case "uint": {
return item.size;
}
case "array": {
if (item.lengthSize !== undefined)
acc += item.lengthSize;
const narrowedData = data[item.name];
for (let i = 0; i < narrowedData.length; ++i)
acc += calcLayoutSize(item.layout, narrowedData[i]);
return acc;
}
case "bytes": {
if (isBytesType(item.custom))
return acc + item.custom.length;
return item.custom.length;
if (isBytesType(item?.custom?.from))
return acc + item.custom.from.length;
item = item;
return item.custom.from.length;
if ("size" in item && item.size !== undefined)
return acc + item.size;
return item.size;
let size = 0;
if (item?.lengthSize !== undefined)
size += item.lengthSize;
return size + ((item.custom !== undefined)
? item.custom.from(data)
: data).length;
}
case "array": {
let size = 0;
if (item.lengthSize !== undefined)
acc += item.lengthSize;
return acc + ((item.custom !== undefined)
? item.custom.from(data[item.name])
: data[item.name]).length;
size += item.lengthSize;
const narrowedData = data;
for (let i = 0; i < narrowedData.length; ++i)
size += calcItemSize(withIgnoredName(item.arrayItem), narrowedData[i]);
return size;
}
case "uint": {
return acc + item.size;
case "object": {
return calcLayoutSize(item.layout, data);
}
case "switch": {
const [_, layout] = findIdLayoutPair(item, data);
return item.idSize + calcLayoutSize(layout, data);
}
}
}, 0);
};
const calcLayoutSize = (layout, data) => layout.reduce((acc, item) => acc + calcItemSize(item, data[item.name]), 0);
//Wormhole uses big endian by default for all uints

@@ -59,5 +70,11 @@ //endianess can be easily added to UintLayout items if necessary

switch (item.binary) {
case "switch": {
const [idOrConversionId, layout] = findIdLayoutPair(item, data);
const idNum = (Array.isArray(idOrConversionId) ? idOrConversionId[0] : idOrConversionId);
offset = serializeUint(encoded, offset, idNum, item.idSize);
offset = serializeLayout(layout, data, encoded, offset);
break;
}
case "object": {
for (const i of item.layout)
offset = serializeLayoutItem(i, data[i.name], encoded, offset);
offset = serializeLayout(item.layout, data, encoded, offset);
break;

@@ -69,3 +86,3 @@ }

for (let i = 0; i < data.length; ++i)
offset = serializeLayout(item.layout, data[i], encoded, offset);
offset = serializeLayoutItem(withIgnoredName(item.arrayItem), data[i], encoded, offset);
break;

@@ -72,0 +89,0 @@ }

{
"name": "@wormhole-foundation/sdk-base",
"version": "0.1.8-beta.5",
"version": "0.1.8-beta.6",
"repository": {

@@ -5,0 +5,0 @@ "type": "git",

@@ -21,3 +21,3 @@ /* TODO:

* With all of this in mind: What should we name modules here?
* My preferred choice would be ["Wormholecore", "TokenBridge", "NftBridge", "Relayer"]
* My preferred choice would be ["CoreBridge", "TokenBridge", "NftBridge", "Relayer"]
* but ["Core", "TokenBridge", "NFTBridge", "WormholeRelayer"] seems to be more consistent given

@@ -28,10 +28,7 @@ * current naming "conventions"

export const protocols = [
"WormholeCore",
"CoreBridge",
"TokenBridge",
"AutomaticTokenBridge",
"CircleBridge",
"AutomaticCircleBridge",
"NftBridge",
"Relayer",
// not implemented
"NftBridge",
"CCTP",
] as const;

@@ -38,0 +35,0 @@

@@ -11,3 +11,3 @@ import { ParseNumber, RoArray, RoArray2D } from "./metaprogramming";

export type Entries<T extends RoArray> =
readonly [...{ [K in keyof T]: K extends `${number}` ? [T[K], ParseNumber<K>] : never }];
[...{ [K in keyof T]: K extends `${number}` ? [T[K], ParseNumber<K>] : never }];

@@ -38,3 +38,3 @@ export type Flatten<T extends RoArray> =

export type Unflatten<T extends RoArray> =
[...{ [K in keyof T]: K extends `${number}` ? readonly [T[K]] : never }];
[...{ [K in keyof T]: K extends `${number}` ? [T[K]] : never }];

@@ -67,3 +67,3 @@ export type AllSameLength<T extends RoArray2D, L extends number> =

K extends `${number}`
? readonly [...{ [K2 in keyof A]: K extends keyof A[K2] ? A[K2][K] : never }]
? [...{ [K2 in keyof A]: K extends keyof A[K2] ? A[K2][K] : never }]
: never

@@ -104,3 +104,3 @@ }]

: R extends RoArray
? [...{ [K in keyof R]: K extends `${number}` ? readonly [L, R[K]] : never }]
? [...{ [K in keyof R]: K extends `${number}` ? [L, R[K]] : never }]
: [L, R];
import {
Layout,
LayoutItem,
NamedLayoutItem,
LayoutToType,
LayoutItemToType,
FixedPrimitiveBytesLayoutItem,

@@ -87,3 +88,3 @@ FixedValueBytesLayoutItem,

function deserializeLayoutItem(
item: LayoutItem,
item: NamedLayoutItem,
encoded: Uint8Array,

@@ -94,18 +95,23 @@ offset: number,

switch (item.binary) {
case "object": {
return internalDeserializeLayout(item.layout, encoded, offset);
}
case "array": {
let ret = [] as LayoutToType<typeof item.layout>[];
if (item.lengthSize !== undefined) {
const [length, newOffset] = deserializeUint(encoded, offset, item.lengthSize);
offset = newOffset;
for (let i = 0; i < length; ++i)
[ret[i], offset] = internalDeserializeLayout(item.layout, encoded, offset);
case "uint": {
const [value, newOffset] = deserializeUint(encoded, offset, item.size);
if (isUintType(item.custom)) {
checkUintEquals(item.custom, value);
return [item.custom, newOffset];
}
else {
while (offset < encoded.length)
[ret[ret.length], offset] = internalDeserializeLayout(item.layout, encoded, offset);
if (isUintType(item?.custom?.from)) {
checkUintEquals(item!.custom!.from, value);
return [item!.custom!.to, newOffset];
}
return [ret, offset];
//narrowing to CustomConver<UintType, any> is a bit hacky here, since the true type
// would be CustomConver<number, any> | CustomConver<bigint, any>, but then we'd have to
// further tease that apart still for no real gain...
type narrowedCustom = CustomConversion<UintType, any>;
return [
item.custom !== undefined ? (item.custom as narrowedCustom).to(value) : value,
newOffset
];
}

@@ -153,22 +159,50 @@ case "bytes": {

}
case "uint": {
const [value, newOffset] = deserializeUint(encoded, offset, item.size);
if (isUintType(item.custom)) {
checkUintEquals(item.custom, value);
return [item.custom, newOffset];
case "array": {
let ret = [] as any[];
const { arrayItem } = item;
const deserializeArrayItem = (index: number) => {
const [deserializedItem, newOffset] = deserializeLayoutItem(
{ name: `${item.name}[${index}]`, ...arrayItem },
encoded,
offset
);
ret.push(deserializedItem);
offset = newOffset;
}
if (isUintType(item?.custom?.from)) {
checkUintEquals(item!.custom!.from, value);
return [item!.custom!.to, newOffset];
if (item.lengthSize !== undefined) {
const [length, newOffset] = deserializeUint(encoded, offset, item.lengthSize);
offset = newOffset;
for (let i = 0; i < length; ++i)
deserializeArrayItem(i);
}
else
while (offset < encoded.length)
deserializeArrayItem(ret.length);
//narrowing to CustomConver<UintType, any> is a bit hacky here, since the true type
// would be CustomConver<number, any> | CustomConver<bigint, any>, but then we'd have to
// further tease that apart still for no real gain...
type narrowedCustom = CustomConversion<UintType, any>;
return [ret, offset];
}
case "object": {
return internalDeserializeLayout(item.layout, encoded, offset);
}
case "switch": {
const [id, newOffset] = deserializeUint(encoded, offset, item.idSize);
const {idLayoutPairs} = item;
if (idLayoutPairs.length === 0)
throw new Error(`switch item '${item.name}' has no idLayoutPairs`);
const hasPlainIds = typeof idLayoutPairs[0][0] === "number";
const pair = (idLayoutPairs as any[]).find(([idOrConversionId]) =>
hasPlainIds ? idOrConversionId === id : (idOrConversionId)[0] === id);
if (pair === undefined)
throw new Error(`unknown id value: ${id}`);
const [idOrConversionId, idLayout] = pair;
const [decoded, nextOffset] = internalDeserializeLayout(idLayout, encoded, newOffset);
return [
item.custom !== undefined ? (item.custom as narrowedCustom).to(value) : value,
newOffset
{ [item.idTag ?? "id"]: hasPlainIds ? id : (idOrConversionId as any)[1],
...decoded
},
nextOffset
];

@@ -175,0 +209,0 @@ }

@@ -59,8 +59,18 @@ import {

switch (item.binary) {
case "object": {
return createLayoutMeta(item.layout, offset, fixedBytes);
case "uint": {
const fixedVal =
isUintType(item.custom)
? item.custom
: isUintType(item?.custom?.from)
? item!.custom!.from
: null;
if (fixedVal !== null) {
const serialized = new Uint8Array(item.size);
serializeUint(serialized, 0, fixedVal, item.size);
return knownFixed(item.size, serialized);
}
return [item.size, item.size];
}
case "array": {
return [item.lengthSize !== undefined ? item.lengthSize : 0, Infinity];
}
case "bytes": {

@@ -81,17 +91,76 @@ if ("size" in item && item.size !== undefined)

}
case "uint": {
const fixedVal =
isUintType(item.custom)
? item.custom
: isUintType(item?.custom?.from)
? item!.custom!.from
: null;
case "array": {
return [item.lengthSize !== undefined ? item.lengthSize : 0, Infinity];
}
case "object": {
return createLayoutMeta(item.layout, offset, fixedBytes);
}
case "switch": {
const caseFixedBytes = item.idLayoutPairs.map(_ => []) as FixedBytes[];
const {idSize} = item;
const caseBounds = item.idLayoutPairs.map(([idOrConversionId, layout], caseIndex) => {
const idVal = Array.isArray(idOrConversionId) ? idOrConversionId[0] : idOrConversionId;
if (offset !== null) {
const serializedId = new Uint8Array(idSize);
serializeUint(serializedId, 0, idVal, idSize);
caseFixedBytes[caseIndex].push([0, serializedId]);
}
const ret = createLayoutMeta(layout, offset ? idSize : null, caseFixedBytes[caseIndex]);
return [ret[0] + idSize, ret[1] + idSize] as Bounds;
});
if (fixedVal !== null) {
const serialized = new Uint8Array(item.size);
serializeUint(serialized, 0, fixedVal, item.size)
return knownFixed(item.size, serialized);
}
if (offset !== null)
//find bytes that have the same value across all cases (turning this into a lambda to enable
// early return from inner loops)
(() => {
//constrain search to the minimum length of all cases
const minLen = Math.min(
...caseFixedBytes.map(fbs => fbs.at(-1)![0] + fbs.at(-1)![1].length)
);
//keep track of the current index in each case's fixed bytes array
const itIndexes = caseFixedBytes.map(_ => 0);
return [item.size, item.size];
for (let bytePos = 0; bytePos < minLen;) {
let byteVal = null;
let caseIndex = 0;
while (caseIndex < caseFixedBytes.length) {
let curItIndex = itIndexes[caseIndex];
const curFixedBytes = caseFixedBytes[caseIndex];
const [curOffset, curSerialized] = curFixedBytes[curItIndex];
if (curOffset + curSerialized.length <= bytePos) {
//no fixed byte at this position in this case
++curItIndex;
if (curItIndex === curFixedBytes.length)
return; //we have exhausted all fixed bytes in at least one case
itIndexes[caseIndex] = curItIndex;
//jump to the next possible bytePos given the fixed bytes of the current case index
bytePos = curFixedBytes[curItIndex][0];
break;
}
const curByteVal = curSerialized[bytePos - curOffset];
if (byteVal === null)
byteVal = curByteVal;
if (curByteVal !== byteVal)
break;
caseIndex++;
}
//only if we made it through all cases without breaking do we have a fixed byte
// and hence add it to the list of fixed bytes
if (caseIndex === caseFixedBytes.length) {
fixedBytes.push([offset + bytePos, new Uint8Array([byteVal!])]);
++bytePos;
}
}
})();
return [
Math.min(...caseBounds.map(([lower]) => lower)),
Math.max(...caseBounds.map(([_, upper]) => upper))
] as Bounds;
}

@@ -98,0 +167,0 @@ }

import {
Layout,
LayoutItem,
NamedLayoutItem,
UintLayoutItem,
BytesLayoutItem,
ObjectLayoutItem,
ArrayLayoutItem,
SwitchLayoutItem,
LayoutToType,

@@ -12,112 +16,153 @@ PrimitiveType,

type FilterFixedItem<I extends LayoutItem> =
I extends { custom: PrimitiveType | FixedConversion<PrimitiveType, any> }
? I
: I extends ObjectLayoutItem | ArrayLayoutItem
? FixedItemsOfLayout<I["layout"]> extends readonly LayoutItem[]
? [FixedItemsOfLayout<I["layout"]>[number]] extends [never]
? never
: { readonly [K in keyof I]: K extends "layout" ? FixedItemsOfLayout<I["layout"]> : I[K] }
type IsNever<T> = [T] extends [never] ? true : false;
type IsEmpty<T> =
IsNever<T> extends false
? T extends readonly [unknown, ...unknown[]]
? false
: true
: true;
type IdLayoutPair = readonly [unknown, Layout];
type FilterItemsOfIdLayoutPairs<ILA extends readonly IdLayoutPair[], Fixed extends boolean> =
ILA extends readonly [infer H extends IdLayoutPair, ...infer T extends readonly IdLayoutPair[]]
? FilterItemsOfLayout<H[1], Fixed> extends infer L
? IsEmpty<L> extends false
? [[H[0], L], ...FilterItemsOfIdLayoutPairs<T, Fixed>]
: FilterItemsOfIdLayoutPairs<T, Fixed>
: never
: [];
type FilterItem<I extends LayoutItem, Fixed extends boolean> =
[I] extends [UintLayoutItem | BytesLayoutItem]
? I extends { custom: PrimitiveType | FixedConversion<PrimitiveType, any> }
? Fixed extends true ? I : never
: Fixed extends true ? never : I
: [I] extends [ArrayLayoutItem]
? FilterItem<I["arrayItem"], Fixed> extends infer LI
? { readonly [K in keyof I]: K extends "arrayItem" ? LI : I[K] }
: never
: [I] extends [ObjectLayoutItem]
? FilterItemsOfLayout<I["layout"], Fixed> extends infer L
? IsEmpty<L> extends false
? { readonly [K in keyof I]: K extends "layout" ? L : I[K] }
: never
: never
: [I] extends [SwitchLayoutItem]
? { readonly [K in keyof I]:
K extends "idLayoutPairs" ? FilterItemsOfIdLayoutPairs<I["idLayoutPairs"], Fixed> : I[K]
}
: never;
export type FixedItemsOfLayout<L extends Layout> =
L extends readonly [infer H extends LayoutItem, ...infer T]
? [FilterFixedItem<H>] extends [never]
? T extends Layout
? FixedItemsOfLayout<T>
: readonly []
: T extends Layout
? readonly [FilterFixedItem<H>, ...FixedItemsOfLayout<T>]
: readonly [FilterFixedItem<H>]
: readonly [];
type FilterItemsOfLayout<L extends Layout, Fixed extends boolean> =
L extends readonly [infer H extends NamedLayoutItem, ...infer T extends Layout]
? FilterItem<H, Fixed> extends infer I extends NamedLayoutItem
? IsNever<I> extends false
? [I, ...FilterItemsOfLayout<T, Fixed>]
: FilterItemsOfLayout<T, Fixed>
: never
: [];
export const fixedItemsOfLayout = <L extends Layout>(layout: L): FixedItemsOfLayout<L> =>
layout.reduce(
(acc: any, item: any) => {
if (item["custom"] !== undefined && (
isPrimitiveType(item["custom"]) || isPrimitiveType(item["custom"].from)
))
return [...acc, item ];
if (item.binary === "array" || item.binary === "object") {
const fixedItems = fixedItemsOfLayout(item.layout);
if (fixedItems.length > 0)
return [...acc, { ...item, layout: fixedItems }];
}
return acc;
function filterItem(item: LayoutItem, fixed: boolean): LayoutItem | null {
switch (item.binary) {
case "uint":
case "bytes": {
const isFixedItem = item["custom"] !== undefined && (
isPrimitiveType(item["custom"]) || isPrimitiveType(item["custom"].from)
);
return (fixed && isFixedItem || !fixed && !isFixedItem) ? item : null;
}
case "array": {
const filtered = filterItem(item.arrayItem, fixed);
return (filtered !== null) ? { ...item, arrayItem: filtered } : null;
}
case "object": {
const filteredItems = filterItemsOfLayout(item.layout, fixed);
return (filteredItems.length > 0) ? { ...item, layout: filteredItems } : null;
}
case "switch": {
const filteredIdLayoutPairs =
(item.idLayoutPairs as IdLayoutPair[]).reduce(
(acc: any, [idOrConversionId, idLayout]: any) => {
const filteredItems = filterItemsOfLayout(idLayout, fixed);
return filteredItems.length > 0
? [...acc, [idOrConversionId, filteredItems]]
: acc;
},
[] as any
);
return { ...item, idLayoutPairs: filteredIdLayoutPairs };
}
}
}
function filterItemsOfLayout<L extends Layout, Fixed extends boolean>(
layout: L,
fixed: Fixed
): FilterItemsOfLayout<L, Fixed> {
return layout.reduce(
(acc: Layout, item: NamedLayoutItem) => {
const filtered = filterItem(item, fixed) as NamedLayoutItem | null;
return filtered !== null ? [...acc, filtered] : acc;
},
[] as any
);
[] as Layout
) as FilterItemsOfLayout<L, Fixed>;
}
type FilterDynamicItem<I extends LayoutItem> =
I extends { custom: PrimitiveType | FixedConversion<PrimitiveType, any> }
? never
: I extends ObjectLayoutItem | ArrayLayoutItem
? DynamicItemsOfLayout<I["layout"]> extends readonly LayoutItem[]
? [DynamicItemsOfLayout<I["layout"]>[number]] extends [never]
? never
: { readonly [K in keyof I]: K extends "layout" ? DynamicItemsOfLayout<I["layout"]> : I[K] }
: never
: I;
export type FixedItemsOfLayout<L extends Layout> = FilterItemsOfLayout<L, true>;
export type DynamicItemsOfLayout<L extends Layout> = FilterItemsOfLayout<L, false>;
export type DynamicItemsOfLayout<L extends Layout> =
L extends readonly [infer H extends LayoutItem, ...infer T]
? [FilterDynamicItem<H>] extends [never]
? T extends Layout
? DynamicItemsOfLayout<T>
: readonly []
: T extends Layout
? readonly [FilterDynamicItem<H>, ...DynamicItemsOfLayout<T>]
: readonly [FilterDynamicItem<H>]
: readonly [];
export const fixedItemsOfLayout = <L extends Layout>(layout: L): FixedItemsOfLayout<L> =>
filterItemsOfLayout(layout, true);
export const dynamicItemsOfLayout = <L extends Layout>(layout: L): DynamicItemsOfLayout<L> =>
layout.reduce(
(acc: any, item: any) => {
if (item["custom"] === undefined || !(
isPrimitiveType(item["custom"]) || isPrimitiveType(item["custom"].from)
))
return [...acc, item ];
if (item.binary === "array" || item.binary === "object") {
const dynamicItems = dynamicItemsOfLayout(item.layout);
if (dynamicItems.length > 0)
return [...acc, { ...item, layout: dynamicItems }];
}
return acc;
},
[] as any
);
filterItemsOfLayout(layout, false);
export const addFixedValues = <L extends Layout>(
export function addFixedValues<L extends Layout>(
layout: L,
dynamicValues: LayoutToType<DynamicItemsOfLayout<L>>,
): LayoutToType<L> => {
): LayoutToType<L> {
const ret = {} as any;
for (const item of layout) {
if (item.binary === "object") {
const subDynamicValues = (
(item.name in dynamicValues)
? dynamicValues[item.name as keyof typeof dynamicValues]
: {}
) as LayoutToType<DynamicItemsOfLayout<typeof item.layout>>;
ret[item.name] = addFixedValues(item.layout, subDynamicValues);
}
else if (item.binary === "array") {
const subDynamicValues = (
(item.name in dynamicValues)
? dynamicValues[item.name as keyof typeof dynamicValues]
: []
) as readonly LayoutToType<DynamicItemsOfLayout<typeof item.layout>>[];
ret[item.name] = subDynamicValues.map(element => addFixedValues(item.layout, element));
}
else if (item.custom !== undefined &&
(isPrimitiveType(item.custom) || isPrimitiveType((item.custom as {from: any}).from))
) {
const fromDynamic = () => dynamicValues[item.name as keyof typeof dynamicValues];
switch (item.binary) {
case "uint":
case "bytes": {
if (!(item as {omit?: boolean})?.omit)
ret[item.name] = isPrimitiveType(item.custom) ? item.custom : item.custom.to;
ret[item.name] = (item.custom !== undefined &&
(isPrimitiveType(item.custom) || isPrimitiveType((item.custom as {from: any}).from))
) ? (isPrimitiveType(item.custom) ? item.custom : item.custom.to)
: fromDynamic();
break;
}
case "array": {
if (item.name in dynamicValues) {
ret[item.name] = (item.arrayItem.binary !== "object")
? fromDynamic()
: (fromDynamic() as Layout).map(element =>
addFixedValues((item.arrayItem as ObjectLayoutItem).layout, element)
);
}
break;
}
case "object": {
const subDynamicValues = (
(item.name in dynamicValues) ? fromDynamic() : {}
) as LayoutToType<DynamicItemsOfLayout<typeof item.layout>>;
ret[item.name] = addFixedValues(item.layout, subDynamicValues);
break;
}
case "switch": {
const id = (fromDynamic() as any)[item.idTag ?? "id"];
const [_, idLayout] = (item.idLayoutPairs as IdLayoutPair[]).find(([idOrConversionId]) =>
(Array.isArray(idOrConversionId) ? idOrConversionId[1] : idOrConversionId) == id
)!;
ret[item.name] = {
[item.idTag ?? "id"]: id,
...addFixedValues(idLayout, fromDynamic() as any)
};
break;
}
}
else
ret[item.name] = dynamicValues[item.name as keyof typeof dynamicValues];
}
return ret as LayoutToType<L>;
}
export {
Layout,
LayoutItem,
NamedLayoutItem,
UintLayoutItem,

@@ -5,0 +6,0 @@ BytesLayoutItem,

@@ -1,4 +0,1 @@

//TODO:
// * implement a switch layout item that maps different values (versions) to different sublayouts
export type UintType = number | bigint;

@@ -15,3 +12,3 @@ export const isUintType = (x: any): x is UintType =>

export type BinaryLiterals = "uint" | "bytes" | "array" | "object";
export type BinaryLiterals = "uint" | "bytes" | "array" | "object" | "switch";

@@ -43,3 +40,2 @@ //Why only a max value of 2**(6*8)?

interface LayoutItemBase<BL extends BinaryLiterals> {
readonly name: string,
readonly binary: BL,

@@ -90,3 +86,3 @@ };

readonly lengthSize?: NumberSize,
readonly layout: Layout,
readonly arrayItem: LayoutItem,
};

@@ -98,2 +94,11 @@

type PlainId = number;
type ConversionId = readonly [number, unknown];
type IdLayoutPair<Id extends PlainId | ConversionId, L extends Layout = Layout> = readonly [Id, L];
export interface SwitchLayoutItem extends LayoutItemBase<"switch"> {
readonly idTag?: string,
readonly idSize: NumberSize,
readonly idLayoutPairs: readonly IdLayoutPair<PlainId>[] | readonly IdLayoutPair<ConversionId>[],
}
export type UintLayoutItem = |

@@ -109,25 +114,35 @@ PrimitiveFixedUintLayoutItem<number> |

LengthPrefixedBytesLayoutItem;
export type LayoutItem = UintLayoutItem | BytesLayoutItem | ArrayLayoutItem | ObjectLayoutItem;
export type Layout = readonly LayoutItem[];
export type LayoutItem =
UintLayoutItem | BytesLayoutItem | ArrayLayoutItem | ObjectLayoutItem | SwitchLayoutItem;
export type NamedLayoutItem = LayoutItem & { readonly name: string };
export type Layout = readonly NamedLayoutItem[];
type NameOrOmitted<T extends { name: PropertyKey }> = T extends {omit: true} ? never : T["name"];
type NameOrOmitted<T extends { name: string }> = T extends {omit: true} ? never : T["name"];
//the order of the checks matters here!
// if FixedConversion was tested for first, its ToType would erroneously be inferred to be a
// the `to` function that actually belongs to a CustomConversion
// unclear why this happens, seeing how the `from` type wouldn't fit but it happened nonetheless
export type LayoutToType<L extends Layout> =
{ readonly [I in L[number] as NameOrOmitted<I>]: LayoutItemToType<I> };
type MaybeConvert<Id extends PlainId | ConversionId> =
Id extends readonly [number, infer Converted] ? Converted : Id;
type IdLayoutPairArray = readonly IdLayoutPair<number>[] | readonly IdLayoutPair<ConversionId>[];
type IdLayoutPairsToTypeUnion<T extends IdLayoutPairArray, IdTag extends string> =
T extends readonly [infer Head,...infer Tail extends IdLayoutPairArray]
? Head extends IdLayoutPair<infer MaybeConversionId, infer L extends Layout>
? MaybeConvert<MaybeConversionId> extends infer Id
? LayoutToType<L> extends infer LT extends object
? { readonly [K in IdTag | keyof LT]: K extends keyof LT ? LT[K] : Id }
| IdLayoutPairsToTypeUnion<Tail, IdTag>
: never
: never
: never
: never;
export type LayoutItemToType<I extends LayoutItem> =
[I] extends [ArrayLayoutItem]
? LayoutToType<I["layout"]>[]
: [I] extends [ObjectLayoutItem]
? LayoutToType<I["layout"]>
: [I] extends [UintLayoutItem]
[I] extends [UintLayoutItem]
? I["custom"] extends UintType
? I["custom"]
: I["custom"] extends CustomConversion<any, infer ToType>
: I["custom"] extends CustomConversion<infer FromType extends UintType, infer ToType>
? ToType
: I["custom"] extends FixedConversion<any, infer ToType>
: I["custom"] extends FixedConversion<infer FromType extends UintType, infer ToType>
? ToType

@@ -141,2 +156,8 @@ : UintSizeToPrimitive<I["size"]>

: BytesType //this also covers FixedValueBytesLayoutItem (Uint8Arrays don't support literals)
: [I] extends [ArrayLayoutItem]
? readonly LayoutItemToType<I["arrayItem"]>[]
: [I] extends [ObjectLayoutItem]
? LayoutToType<I["layout"]>
: [I] extends [SwitchLayoutItem]
? IdLayoutPairsToTypeUnion<I["idLayoutPairs"], I["idTag"] extends string ? I["idTag"] : "id">
: never;
import {
Layout,
LayoutItem,
NamedLayoutItem,
LayoutToType,
LayoutItemToType,
FixedSizeBytesLayoutItem,
LengthPrefixedBytesLayoutItem,
FixedPrimitiveBytesLayoutItem,
FixedValueBytesLayoutItem,
SwitchLayoutItem,
CustomConversion,

@@ -43,50 +43,64 @@ UintType,

const calcLayoutSize = (
layout: Layout,
data: LayoutToType<typeof layout>
): number =>
layout.reduce((acc: number, item: LayoutItem) => {
switch (item.binary) {
case "object": {
return acc + calcLayoutSize(item.layout, data[item.name] as LayoutItemToType<typeof item>)
}
case "array": {
if (item.lengthSize !== undefined)
acc += item.lengthSize;
const findIdLayoutPair = (item: SwitchLayoutItem, data: any) => {
const id = data[item.idTag ?? "id"];
return (item.idLayoutPairs as any[]).find(([idOrConversionId]) =>
(Array.isArray(idOrConversionId) ? idOrConversionId[1] : idOrConversionId) == id
)!;
}
const narrowedData = data[item.name] as LayoutItemToType<typeof item>;
for (let i = 0; i < narrowedData.length; ++i)
acc += calcLayoutSize(item.layout, narrowedData[i]);
const withIgnoredName = (item: LayoutItem) => ({ ...item, name: "ignored" });
return acc;
}
case "bytes": {
if (isBytesType(item.custom))
return acc + item.custom.length;
const calcItemSize = (item: NamedLayoutItem, data: any) => {
switch (item.binary) {
case "uint": {
return item.size;
}
case "bytes": {
if (isBytesType(item.custom))
return item.custom.length;
if (isBytesType(item?.custom?.from))
return acc + item!.custom!.from.length;
if (isBytesType(item?.custom?.from))
return item!.custom!.from.length;
item = item as FixedSizeBytesLayoutItem | LengthPrefixedBytesLayoutItem;
if ("size" in item && item.size !== undefined)
return item.size;
if ("size" in item && item.size !== undefined)
return acc + item.size;
let size = 0;
if ((item as { lengthSize?: number })?.lengthSize !== undefined)
size += (item as { lengthSize: number }).lengthSize;
if (item.lengthSize !== undefined)
acc += item.lengthSize;
return size + (
(item.custom !== undefined)
? item.custom.from(data)
: (data as LayoutItemToType<typeof item>)
).length;
}
case "array": {
let size = 0;
if (item.lengthSize !== undefined)
size += item.lengthSize;
return acc + (
(item.custom !== undefined)
? item.custom.from(data[item.name])
: (data[item.name] as LayoutItemToType<typeof item>)
).length;
}
case "uint": {
return acc + item.size;
}
const narrowedData = data as LayoutItemToType<typeof item>;
for (let i = 0; i < narrowedData.length; ++i)
size += calcItemSize(withIgnoredName(item.arrayItem), narrowedData[i]);
return size;
}
},
0
);
case "object": {
return calcLayoutSize(item.layout, data as LayoutItemToType<typeof item>)
}
case "switch": {
const [_, layout] = findIdLayoutPair(item, data);
return item.idSize + calcLayoutSize(layout, data);
}
}
}
const calcLayoutSize = (
layout: Layout,
data: LayoutToType<typeof layout>
): number =>
layout.reduce((acc: number, item: NamedLayoutItem) =>
acc + calcItemSize(item, data[item.name]), 0);
//Wormhole uses big endian by default for all uints

@@ -117,3 +131,3 @@ //endianess can be easily added to UintLayout items if necessary

function serializeLayoutItem(
item: LayoutItem,
item: NamedLayoutItem,
data: any,

@@ -125,6 +139,11 @@ encoded: Uint8Array,

switch (item.binary) {
case "switch": {
const [idOrConversionId, layout] = findIdLayoutPair(item, data);
const idNum = (Array.isArray(idOrConversionId) ? idOrConversionId[0] : idOrConversionId);
offset = serializeUint(encoded, offset, idNum, item.idSize);
offset = serializeLayout(layout, data, encoded, offset);
break;
}
case "object": {
for (const i of item.layout)
offset = serializeLayoutItem(i, data[i.name], encoded, offset);
offset = serializeLayout(item.layout, data, encoded, offset);
break;

@@ -137,3 +156,3 @@ }

for (let i = 0; i < data.length; ++i)
offset = serializeLayout(item.layout, data[i], encoded, offset);
offset = serializeLayoutItem(withIgnoredName(item.arrayItem), data[i], encoded, offset);

@@ -140,0 +159,0 @@ break;

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 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 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 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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc