@wormhole-foundation/sdk-base 0.1.8-beta.5 → 0.1.8-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/constants/chains.d.ts +3 -3
- package/dist/cjs/constants/chains.d.ts.map +1 -1
- package/dist/cjs/constants/circle.d.ts +4 -4
- package/dist/cjs/constants/circle.d.ts.map +1 -1
- package/dist/cjs/constants/platforms.d.ts +3 -3
- package/dist/cjs/constants/protocols.d.ts +2 -2
- package/dist/cjs/constants/protocols.d.ts.map +1 -1
- package/dist/cjs/constants/protocols.js +4 -7
- package/dist/cjs/constants/protocols.js.map +1 -1
- package/dist/cjs/utils/array.d.ts +8 -6
- package/dist/cjs/utils/array.d.ts.map +1 -1
- package/dist/cjs/utils/layout/deserialize.d.ts.map +1 -1
- package/dist/cjs/utils/layout/deserialize.js +47 -25
- package/dist/cjs/utils/layout/deserialize.js.map +1 -1
- package/dist/cjs/utils/layout/discriminate.d.ts.map +1 -1
- package/dist/cjs/utils/layout/discriminate.js +75 -17
- package/dist/cjs/utils/layout/discriminate.js.map +1 -1
- package/dist/cjs/utils/layout/fixedDynamic.d.ts +21 -15
- package/dist/cjs/utils/layout/fixedDynamic.d.ts.map +1 -1
- package/dist/cjs/utils/layout/fixedDynamic.js +67 -39
- package/dist/cjs/utils/layout/fixedDynamic.js.map +1 -1
- package/dist/cjs/utils/layout/index.d.ts +1 -1
- package/dist/cjs/utils/layout/index.d.ts.map +1 -1
- package/dist/cjs/utils/layout/index.js.map +1 -1
- package/dist/cjs/utils/layout/layout.d.ts +22 -7
- package/dist/cjs/utils/layout/layout.d.ts.map +1 -1
- package/dist/cjs/utils/layout/layout.js +0 -2
- package/dist/cjs/utils/layout/layout.js.map +1 -1
- package/dist/cjs/utils/layout/serialize.d.ts.map +1 -1
- package/dist/cjs/utils/layout/serialize.js +42 -25
- package/dist/cjs/utils/layout/serialize.js.map +1 -1
- package/dist/esm/constants/chains.d.ts +3 -3
- package/dist/esm/constants/chains.d.ts.map +1 -1
- package/dist/esm/constants/circle.d.ts +4 -4
- package/dist/esm/constants/circle.d.ts.map +1 -1
- package/dist/esm/constants/platforms.d.ts +3 -3
- package/dist/esm/constants/protocols.d.ts +2 -2
- package/dist/esm/constants/protocols.d.ts.map +1 -1
- package/dist/esm/constants/protocols.js +4 -7
- package/dist/esm/constants/protocols.js.map +1 -1
- package/dist/esm/utils/array.d.ts +8 -6
- package/dist/esm/utils/array.d.ts.map +1 -1
- package/dist/esm/utils/layout/deserialize.d.ts.map +1 -1
- package/dist/esm/utils/layout/deserialize.js +47 -25
- package/dist/esm/utils/layout/deserialize.js.map +1 -1
- package/dist/esm/utils/layout/discriminate.d.ts.map +1 -1
- package/dist/esm/utils/layout/discriminate.js +75 -17
- package/dist/esm/utils/layout/discriminate.js.map +1 -1
- package/dist/esm/utils/layout/fixedDynamic.d.ts +21 -15
- package/dist/esm/utils/layout/fixedDynamic.d.ts.map +1 -1
- package/dist/esm/utils/layout/fixedDynamic.js +67 -39
- package/dist/esm/utils/layout/fixedDynamic.js.map +1 -1
- package/dist/esm/utils/layout/index.d.ts +1 -1
- package/dist/esm/utils/layout/index.d.ts.map +1 -1
- package/dist/esm/utils/layout/index.js.map +1 -1
- package/dist/esm/utils/layout/layout.d.ts +22 -7
- package/dist/esm/utils/layout/layout.d.ts.map +1 -1
- package/dist/esm/utils/layout/layout.js +0 -2
- package/dist/esm/utils/layout/layout.js.map +1 -1
- package/dist/esm/utils/layout/serialize.d.ts.map +1 -1
- package/dist/esm/utils/layout/serialize.js +42 -25
- package/dist/esm/utils/layout/serialize.js.map +1 -1
- package/package.json +1 -1
- package/src/constants/protocols.ts +4 -7
- package/src/utils/array.ts +4 -4
- package/src/utils/layout/deserialize.ts +66 -32
- package/src/utils/layout/discriminate.ts +88 -19
- package/src/utils/layout/fixedDynamic.ts +137 -92
- package/src/utils/layout/index.ts +1 -0
- package/src/utils/layout/layout.ts +41 -20
- package/src/utils/layout/serialize.ts +65 -46
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const chains:
|
|
1
|
+
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];
|
|
2
2
|
export type ChainName = (typeof chains)[number];
|
|
3
3
|
export type ChainId = (typeof chainIds)[number];
|
|
4
4
|
export type Chain = ChainName | ChainId;
|
|
@@ -10,11 +10,11 @@ export declare const chainToChainId: (<K1 extends "Solana" | "Ethereum" | "Terra
|
|
|
10
10
|
get: (args_0: string) => 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 | undefined;
|
|
11
11
|
has: (args_0: string) => boolean;
|
|
12
12
|
};
|
|
13
|
-
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,
|
|
13
|
+
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 {
|
|
14
14
|
[key: string]: unknown;
|
|
15
15
|
[key: number]: unknown;
|
|
16
16
|
[key: symbol]: unknown;
|
|
17
|
-
} ? import("../utils/mapping").ObjectFromMappingEntries<[readonly [1,
|
|
17
|
+
} ? 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) & {
|
|
18
18
|
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;
|
|
19
19
|
has: (args_0: number) => boolean;
|
|
20
20
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chains.d.ts","sourceRoot":"","sources":["../../../src/constants/chains.ts"],"names":[],"mappings":"AAoDA,eAAO,MAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"chains.d.ts","sourceRoot":"","sources":["../../../src/constants/chains.ts"],"names":[],"mappings":"AAoDA,eAAO,MAAO,MAAM,8WAAE,QAAQ,oJAAgC,CAAC;AAC/D,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC;AAChD,MAAM,MAAM,OAAO,GAAG,CAAC,OAAO,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC;AAChD,MAAM,MAAM,KAAK,GAAG,SAAS,GAAG,OAAO,CAAC;AAExC,eAAO,MAAM,cAAc;;;;;;;CAAoC,CAAC;AAChE,eAAO,MAAM,cAAc;;;;;;;CAA4C,CAAC;AAExE,eAAO,MAAM,OAAO,UAAW,MAAM,yZACV,CAAC;AAC5B,eAAO,MAAM,SAAS,YAAa,MAAM,mMACZ,CAAC;AAE9B,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,IAAI,OAAO,CAEzE;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,IAAI,SAAS,CAErE;AAGD,eAAO,MAAM,SAAS,YAAa,MAAM,KAAG,OAG3C,CAAC;AAEF,eAAO,MAAM,SAAS,UAAW,MAAM,GAAG,MAAM,GAAG,KAAK,KAAG,OAU1D,CAAC;AAEF,eAAO,MAAM,WAAW,UACf,MAAM,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,KACtC,SAcF,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Network } from "./networks";
|
|
2
2
|
import { Chain, ChainName } from "./chains";
|
|
3
|
-
export declare const circleChains:
|
|
3
|
+
export declare const circleChains: ["Ethereum", "Avalanche", "Optimism", "Arbitrum", "Base"], circleChainIds: [0, 1, 2, 3, 6];
|
|
4
4
|
export type CircleChainName = (typeof circleChains)[number];
|
|
5
5
|
export type CircleChainId = (typeof circleChainIds)[number];
|
|
6
|
-
export declare const circleNetworks:
|
|
6
|
+
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"]]];
|
|
7
7
|
export type CircleNetwork = (typeof circleNetworks)[number];
|
|
8
8
|
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 {
|
|
9
9
|
[key: string]: unknown;
|
|
@@ -13,11 +13,11 @@ export declare const circleChainId: (<K1 extends "Ethereum" | "Avalanche" | "Arb
|
|
|
13
13
|
get: (args_0: string) => 0 | 3 | 1 | 2 | 6 | undefined;
|
|
14
14
|
has: (args_0: string) => boolean;
|
|
15
15
|
};
|
|
16
|
-
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,
|
|
16
|
+
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 {
|
|
17
17
|
[key: string]: unknown;
|
|
18
18
|
[key: number]: unknown;
|
|
19
19
|
[key: symbol]: unknown;
|
|
20
|
-
} ? import("../utils").ObjectFromMappingEntries<[readonly [0,
|
|
20
|
+
} ? 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) & {
|
|
21
21
|
get: (args_0: number) => "Ethereum" | "Avalanche" | "Arbitrum" | "Optimism" | "Base" | undefined;
|
|
22
22
|
has: (args_0: number) => boolean;
|
|
23
23
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"circle.d.ts","sourceRoot":"","sources":["../../../src/constants/circle.ts"],"names":[],"mappings":"AAAA,OAAO,E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,CAElC;AAGD,eAAO,MAAM,eAAe,YAAa,MAAM,KAAG,aAGjD,CAAC;AAEF,eAAO,MAAM,eAAe,UACnB,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,KACtC,aAcF,CAAC;AAEF,eAAO,MAAM,iBAAiB,UACrB,MAAM,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,KACtC,SAcF,CAAC"}
|
|
@@ -6,14 +6,14 @@ export declare const platformToChains: (<K1 extends "Solana" | "Algorand" | "Nea
|
|
|
6
6
|
[key: number]: unknown;
|
|
7
7
|
[key: symbol]: unknown;
|
|
8
8
|
} ? 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) & {
|
|
9
|
-
get: (args_0: string) => readonly ["
|
|
9
|
+
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;
|
|
10
10
|
has: (args_0: string) => boolean;
|
|
11
11
|
};
|
|
12
|
-
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",
|
|
12
|
+
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 {
|
|
13
13
|
[key: string]: unknown;
|
|
14
14
|
[key: number]: unknown;
|
|
15
15
|
[key: symbol]: unknown;
|
|
16
|
-
} ? import("../utils").ObjectFromMappingEntries<[readonly ["Acala",
|
|
16
|
+
} ? 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) & {
|
|
17
17
|
get: (args_0: string) => "Solana" | "Algorand" | "Near" | "Sui" | "Aptos" | "Btc" | "Evm" | "Cosmwasm" | undefined;
|
|
18
18
|
has: (args_0: string) => boolean;
|
|
19
19
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const protocols: readonly ["
|
|
1
|
+
export declare const protocols: readonly ["CoreBridge", "TokenBridge", "NftBridge", "Relayer", "CCTP"];
|
|
2
2
|
export type ProtocolName = (typeof protocols)[number];
|
|
3
|
-
export declare const isProtocolName: (protocol: string) => protocol is "
|
|
3
|
+
export declare const isProtocolName: (protocol: string) => protocol is "CoreBridge" | "TokenBridge" | "NftBridge" | "Relayer" | "CCTP";
|
|
4
4
|
//# sourceMappingURL=protocols.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocols.d.ts","sourceRoot":"","sources":["../../../src/constants/protocols.ts"],"names":[],"mappings":"AAyBA,eAAO,MAAM,SAAS,
|
|
1
|
+
{"version":3,"file":"protocols.d.ts","sourceRoot":"","sources":["../../../src/constants/protocols.ts"],"names":[],"mappings":"AAyBA,eAAO,MAAM,SAAS,wEAMZ,CAAC;AAEX,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC;AACtD,eAAO,MAAM,cAAc,aAAc,MAAM,gFACD,CAAC"}
|
|
@@ -19,21 +19,18 @@
|
|
|
19
19
|
* (notice the clash with EVM where bridge refers to the token bridge...).
|
|
20
20
|
*
|
|
21
21
|
* With all of this in mind: What should we name modules here?
|
|
22
|
-
* My preferred choice would be ["
|
|
22
|
+
* My preferred choice would be ["CoreBridge", "TokenBridge", "NftBridge", "Relayer"]
|
|
23
23
|
* but ["Core", "TokenBridge", "NFTBridge", "WormholeRelayer"] seems to be more consistent given
|
|
24
24
|
* current naming "conventions"
|
|
25
25
|
*/
|
|
26
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
27
|
exports.isProtocolName = exports.protocols = void 0;
|
|
28
28
|
exports.protocols = [
|
|
29
|
-
"
|
|
29
|
+
"CoreBridge",
|
|
30
30
|
"TokenBridge",
|
|
31
|
-
"AutomaticTokenBridge",
|
|
32
|
-
"CircleBridge",
|
|
33
|
-
"AutomaticCircleBridge",
|
|
34
|
-
"Relayer",
|
|
35
|
-
// not implemented
|
|
36
31
|
"NftBridge",
|
|
32
|
+
"Relayer",
|
|
33
|
+
"CCTP",
|
|
37
34
|
];
|
|
38
35
|
const isProtocolName = (protocol) => exports.protocols.includes(protocol);
|
|
39
36
|
exports.isProtocolName = isProtocolName;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocols.js","sourceRoot":"","sources":["../../../src/constants/protocols.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;AAEU,QAAA,SAAS,GAAG;IACvB,
|
|
1
|
+
{"version":3,"file":"protocols.js","sourceRoot":"","sources":["../../../src/constants/protocols.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;AAEU,QAAA,SAAS,GAAG;IACvB,YAAY;IACZ,aAAa;IACb,WAAW;IACX,SAAS;IACT,MAAM;CACE,CAAC;AAGJ,MAAM,cAAc,GAAG,CAAC,QAAgB,EAA4B,EAAE,CAC3E,iBAAS,CAAC,QAAQ,CAAC,QAAwB,CAAC,CAAC;AADlC,QAAA,cAAc,kBACoB"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { ParseNumber, RoArray, RoArray2D } from "./metaprogramming";
|
|
2
2
|
export type IndexEs = number | RoArray<number>;
|
|
3
3
|
export declare const range: (length: number) => number[];
|
|
4
|
-
export type Entries<T extends RoArray> =
|
|
5
|
-
|
|
6
|
-
}];
|
|
4
|
+
export type Entries<T extends RoArray> = [
|
|
5
|
+
...{
|
|
6
|
+
[K in keyof T]: K extends `${number}` ? [T[K], ParseNumber<K>] : never;
|
|
7
|
+
}
|
|
8
|
+
];
|
|
7
9
|
export type Flatten<T extends RoArray> = T extends readonly [infer Head, ...infer Tail] ? Head extends RoArray ? [...Head, ...Flatten<Tail>] : [Head, ...Flatten<Tail>] : [];
|
|
8
10
|
export type InnerFlatten<T extends RoArray> = [
|
|
9
11
|
...{
|
|
@@ -13,7 +15,7 @@ export type InnerFlatten<T extends RoArray> = [
|
|
|
13
15
|
export type IsFlat<T extends RoArray> = T extends readonly [infer Head, ...infer Tail] ? Head extends RoArray ? false : IsFlat<Tail> : true;
|
|
14
16
|
export type Unflatten<T extends RoArray> = [
|
|
15
17
|
...{
|
|
16
|
-
[K in keyof T]: K extends `${number}` ?
|
|
18
|
+
[K in keyof T]: K extends `${number}` ? [T[K]] : never;
|
|
17
19
|
}
|
|
18
20
|
];
|
|
19
21
|
export type AllSameLength<T extends RoArray2D, L extends number> = T extends readonly [infer Head extends RoArray, ...infer Tail extends RoArray2D] ? Head["length"] extends L ? AllSameLength<Tail, L> : false : true;
|
|
@@ -26,7 +28,7 @@ export type Column<A extends RoArray2D, I extends number> = [
|
|
|
26
28
|
export declare const column: <A extends RoArray2D, I extends number>(tupArr: A, index: I) => [...{ [K in keyof A]: K extends `${number}` ? A[K][I] : never; }];
|
|
27
29
|
export type Zip<A extends RoArray2D> = IsRectangular<A> extends true ? A[0] extends infer Head extends RoArray ? [
|
|
28
30
|
...{
|
|
29
|
-
[K in keyof Head]: K extends `${number}` ?
|
|
31
|
+
[K in keyof Head]: K extends `${number}` ? [...{
|
|
30
32
|
[K2 in keyof A]: K extends keyof A[K2] ? A[K2][K] : never;
|
|
31
33
|
}] : never;
|
|
32
34
|
}
|
|
@@ -38,7 +40,7 @@ export type ExcludeIndexes<T extends RoArray, C extends IndexEs> = ExcludeIndexe
|
|
|
38
40
|
export type Cartesian<L, R> = L extends RoArray ? Flatten<[...{
|
|
39
41
|
[K in keyof L]: K extends `${number}` ? Cartesian<L[K], R> : never;
|
|
40
42
|
}]> : R extends RoArray ? [...{
|
|
41
|
-
[K in keyof R]: K extends `${number}` ?
|
|
43
|
+
[K in keyof R]: K extends `${number}` ? [L, R[K]] : never;
|
|
42
44
|
}] : [L, R];
|
|
43
45
|
export {};
|
|
44
46
|
//# sourceMappingURL=array.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../../../src/utils/array.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAKpE,MAAM,MAAM,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AAE/C,eAAO,MAAM,KAAK,WAAY,MAAM,aAA8B,CAAC;AAEnE,MAAM,MAAM,OAAO,CAAC,CAAC,SAAS,OAAO,IACnC,
|
|
1
|
+
{"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../../../src/utils/array.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAKpE,MAAM,MAAM,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AAE/C,eAAO,MAAM,KAAK,WAAY,MAAM,aAA8B,CAAC;AAEnE,MAAM,MAAM,OAAO,CAAC,CAAC,SAAS,OAAO,IACnC;IAAC,GAAG;SAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,SAAS,GAAG,MAAM,EAAE,GAA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AC,CAAC,GAAG,KAAK;CAAE,CAAC,CAAC,GACpF,CAAC,SAAS,OAAO,GACjB,CAAC,GAAG;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,SAAS,GAAG,MAAM,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK;CAAE,CAAC,GAClE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deserialize.d.ts","sourceRoot":"","sources":["../../../../src/utils/layout/deserialize.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EAEN,YAAY,
|
|
1
|
+
{"version":3,"file":"deserialize.d.ts","sourceRoot":"","sources":["../../../../src/utils/layout/deserialize.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EAEN,YAAY,EAWb,MAAM,UAAU,CAAC;AAIlB,wBAAgB,iBAAiB,CAAC,KAAK,CAAC,CAAC,SAAS,MAAM,EACtD,MAAM,EAAE,CAAC,EACT,OAAO,EAAE,UAAU,EACnB,MAAM,CAAC,EAAE,MAAM,EACf,UAAU,CAAC,EAAE,IAAI,GAChB,YAAY,CAAC,CAAC,CAAC,CAAC;AAEnB,wBAAgB,iBAAiB,CAAC,KAAK,CAAC,CAAC,SAAS,MAAM,EACtD,MAAM,EAAE,CAAC,EACT,OAAO,EAAE,UAAU,EACnB,MAAM,CAAC,EAAE,MAAM,EACf,UAAU,CAAC,EAAE,KAAK,GACjB,SAAS,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC"}
|
|
@@ -35,22 +35,20 @@ function deserializeUint(encoded, offset, size) {
|
|
|
35
35
|
function deserializeLayoutItem(item, encoded, offset) {
|
|
36
36
|
try {
|
|
37
37
|
switch (item.binary) {
|
|
38
|
-
case "
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
if (item.lengthSize !== undefined) {
|
|
44
|
-
const [length, newOffset] = deserializeUint(encoded, offset, item.lengthSize);
|
|
45
|
-
offset = newOffset;
|
|
46
|
-
for (let i = 0; i < length; ++i)
|
|
47
|
-
[ret[i], offset] = internalDeserializeLayout(item.layout, encoded, offset);
|
|
38
|
+
case "uint": {
|
|
39
|
+
const [value, newOffset] = deserializeUint(encoded, offset, item.size);
|
|
40
|
+
if ((0, layout_1.isUintType)(item.custom)) {
|
|
41
|
+
(0, utils_1.checkUintEquals)(item.custom, value);
|
|
42
|
+
return [item.custom, newOffset];
|
|
48
43
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
44
|
+
if ((0, layout_1.isUintType)(item?.custom?.from)) {
|
|
45
|
+
(0, utils_1.checkUintEquals)(item.custom.from, value);
|
|
46
|
+
return [item.custom.to, newOffset];
|
|
52
47
|
}
|
|
53
|
-
return [
|
|
48
|
+
return [
|
|
49
|
+
item.custom !== undefined ? item.custom.to(value) : value,
|
|
50
|
+
newOffset
|
|
51
|
+
];
|
|
54
52
|
}
|
|
55
53
|
case "bytes": {
|
|
56
54
|
let newOffset;
|
|
@@ -88,19 +86,43 @@ function deserializeLayoutItem(item, encoded, offset) {
|
|
|
88
86
|
newOffset
|
|
89
87
|
];
|
|
90
88
|
}
|
|
91
|
-
case "
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
89
|
+
case "array": {
|
|
90
|
+
let ret = [];
|
|
91
|
+
const { arrayItem } = item;
|
|
92
|
+
const deserializeArrayItem = (index) => {
|
|
93
|
+
const [deserializedItem, newOffset] = deserializeLayoutItem({ name: `${item.name}[${index}]`, ...arrayItem }, encoded, offset);
|
|
94
|
+
ret.push(deserializedItem);
|
|
95
|
+
offset = newOffset;
|
|
96
|
+
};
|
|
97
|
+
if (item.lengthSize !== undefined) {
|
|
98
|
+
const [length, newOffset] = deserializeUint(encoded, offset, item.lengthSize);
|
|
99
|
+
offset = newOffset;
|
|
100
|
+
for (let i = 0; i < length; ++i)
|
|
101
|
+
deserializeArrayItem(i);
|
|
100
102
|
}
|
|
103
|
+
else
|
|
104
|
+
while (offset < encoded.length)
|
|
105
|
+
deserializeArrayItem(ret.length);
|
|
106
|
+
return [ret, offset];
|
|
107
|
+
}
|
|
108
|
+
case "object": {
|
|
109
|
+
return internalDeserializeLayout(item.layout, encoded, offset);
|
|
110
|
+
}
|
|
111
|
+
case "switch": {
|
|
112
|
+
const [id, newOffset] = deserializeUint(encoded, offset, item.idSize);
|
|
113
|
+
const { idLayoutPairs } = item;
|
|
114
|
+
if (idLayoutPairs.length === 0)
|
|
115
|
+
throw new Error(`switch item '${item.name}' has no idLayoutPairs`);
|
|
116
|
+
const hasPlainIds = typeof idLayoutPairs[0][0] === "number";
|
|
117
|
+
const pair = idLayoutPairs.find(([idOrConversionId]) => hasPlainIds ? idOrConversionId === id : (idOrConversionId)[0] === id);
|
|
118
|
+
if (pair === undefined)
|
|
119
|
+
throw new Error(`unknown id value: ${id}`);
|
|
120
|
+
const [idOrConversionId, idLayout] = pair;
|
|
121
|
+
const [decoded, nextOffset] = internalDeserializeLayout(idLayout, encoded, newOffset);
|
|
101
122
|
return [
|
|
102
|
-
item.
|
|
103
|
-
|
|
123
|
+
{ [item.idTag ?? "id"]: hasPlainIds ? id : idOrConversionId[1],
|
|
124
|
+
...decoded },
|
|
125
|
+
nextOffset
|
|
104
126
|
];
|
|
105
127
|
}
|
|
106
128
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deserialize.js","sourceRoot":"","sources":["../../../../src/utils/layout/deserialize.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"deserialize.js","sourceRoot":"","sources":["../../../../src/utils/layout/deserialize.ts"],"names":[],"mappings":";;;AAAA,qCAckB;AAElB,mCAAsE;AAgBtE,SAAgB,iBAAiB,CAC/B,MAAS,EACT,OAAmB,EACnB,MAAM,GAAG,C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GAAG,4BAA4B,IAAI,CAAC,IAAI,MAAO,CAAW,CAAC,OAAO,EAAE,CAAC;QACzF,MAAM,CAAC,CAAC;KACT;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discriminate.d.ts","sourceRoot":"","sources":["../../../../src/utils/layout/discriminate.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EAKP,MAAM,UAAU,CAAC;AAKlB,KAAK,IAAI,GAAG,MAAM,CAAC;AAKnB,KAAK,WAAW,GAAG,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"discriminate.d.ts","sourceRoot":"","sources":["../../../../src/utils/layout/discriminate.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EAKP,MAAM,UAAU,CAAC;AAKlB,KAAK,IAAI,GAAG,MAAM,CAAC;AAKnB,KAAK,WAAW,GAAG,IAAI,CAAC;AAkexB,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,OAAO,GAAG,KAAK,EAC3D,OAAO,EAAE,SAAS,MAAM,EAAE,EAC1B,cAAc,CAAC,EAAE,CAAC,aAaH,UAAU,KAAK,CAAC,SAAS,KAAK,GAAG,WAAW,GAAG,IAAI,GAAG,SAAS,WAAW,EAAE,CAC5F"}
|
|
@@ -26,11 +26,18 @@ function layoutItemMeta(item, offset, fixedBytes) {
|
|
|
26
26
|
return [size, size];
|
|
27
27
|
}
|
|
28
28
|
switch (item.binary) {
|
|
29
|
-
case "
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
case "uint": {
|
|
30
|
+
const fixedVal = (0, layout_1.isUintType)(item.custom)
|
|
31
|
+
? item.custom
|
|
32
|
+
: (0, layout_1.isUintType)(item?.custom?.from)
|
|
33
|
+
? item.custom.from
|
|
34
|
+
: null;
|
|
35
|
+
if (fixedVal !== null) {
|
|
36
|
+
const serialized = new Uint8Array(item.size);
|
|
37
|
+
(0, serialize_1.serializeUint)(serialized, 0, fixedVal, item.size);
|
|
38
|
+
return knownFixed(item.size, serialized);
|
|
39
|
+
}
|
|
40
|
+
return [item.size, item.size];
|
|
34
41
|
}
|
|
35
42
|
case "bytes": {
|
|
36
43
|
if ("size" in item && item.size !== undefined)
|
|
@@ -44,18 +51,69 @@ function layoutItemMeta(item, offset, fixedBytes) {
|
|
|
44
51
|
item = item;
|
|
45
52
|
return [item.lengthSize !== undefined ? item.lengthSize : 0, Infinity];
|
|
46
53
|
}
|
|
47
|
-
case "
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
54
|
+
case "array": {
|
|
55
|
+
return [item.lengthSize !== undefined ? item.lengthSize : 0, Infinity];
|
|
56
|
+
}
|
|
57
|
+
case "object": {
|
|
58
|
+
return createLayoutMeta(item.layout, offset, fixedBytes);
|
|
59
|
+
}
|
|
60
|
+
case "switch": {
|
|
61
|
+
const caseFixedBytes = item.idLayoutPairs.map(_ => []);
|
|
62
|
+
const { idSize } = item;
|
|
63
|
+
const caseBounds = item.idLayoutPairs.map(([idOrConversionId, layout], caseIndex) => {
|
|
64
|
+
const idVal = Array.isArray(idOrConversionId) ? idOrConversionId[0] : idOrConversionId;
|
|
65
|
+
if (offset !== null) {
|
|
66
|
+
const serializedId = new Uint8Array(idSize);
|
|
67
|
+
(0, serialize_1.serializeUint)(serializedId, 0, idVal, idSize);
|
|
68
|
+
caseFixedBytes[caseIndex].push([0, serializedId]);
|
|
69
|
+
}
|
|
70
|
+
const ret = createLayoutMeta(layout, offset ? idSize : null, caseFixedBytes[caseIndex]);
|
|
71
|
+
return [ret[0] + idSize, ret[1] + idSize];
|
|
72
|
+
});
|
|
73
|
+
if (offset !== null)
|
|
74
|
+
//find bytes that have the same value across all cases (turning this into a lambda to enable
|
|
75
|
+
// early return from inner loops)
|
|
76
|
+
(() => {
|
|
77
|
+
//constrain search to the minimum length of all cases
|
|
78
|
+
const minLen = Math.min(...caseFixedBytes.map(fbs => fbs.at(-1)[0] + fbs.at(-1)[1].length));
|
|
79
|
+
//keep track of the current index in each case's fixed bytes array
|
|
80
|
+
const itIndexes = caseFixedBytes.map(_ => 0);
|
|
81
|
+
for (let bytePos = 0; bytePos < minLen;) {
|
|
82
|
+
let byteVal = null;
|
|
83
|
+
let caseIndex = 0;
|
|
84
|
+
while (caseIndex < caseFixedBytes.length) {
|
|
85
|
+
let curItIndex = itIndexes[caseIndex];
|
|
86
|
+
const curFixedBytes = caseFixedBytes[caseIndex];
|
|
87
|
+
const [curOffset, curSerialized] = curFixedBytes[curItIndex];
|
|
88
|
+
if (curOffset + curSerialized.length <= bytePos) {
|
|
89
|
+
//no fixed byte at this position in this case
|
|
90
|
+
++curItIndex;
|
|
91
|
+
if (curItIndex === curFixedBytes.length)
|
|
92
|
+
return; //we have exhausted all fixed bytes in at least one case
|
|
93
|
+
itIndexes[caseIndex] = curItIndex;
|
|
94
|
+
//jump to the next possible bytePos given the fixed bytes of the current case index
|
|
95
|
+
bytePos = curFixedBytes[curItIndex][0];
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
const curByteVal = curSerialized[bytePos - curOffset];
|
|
99
|
+
if (byteVal === null)
|
|
100
|
+
byteVal = curByteVal;
|
|
101
|
+
if (curByteVal !== byteVal)
|
|
102
|
+
break;
|
|
103
|
+
caseIndex++;
|
|
104
|
+
}
|
|
105
|
+
//only if we made it through all cases without breaking do we have a fixed byte
|
|
106
|
+
// and hence add it to the list of fixed bytes
|
|
107
|
+
if (caseIndex === caseFixedBytes.length) {
|
|
108
|
+
fixedBytes.push([offset + bytePos, new Uint8Array([byteVal])]);
|
|
109
|
+
++bytePos;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
})();
|
|
113
|
+
return [
|
|
114
|
+
Math.min(...caseBounds.map(([lower]) => lower)),
|
|
115
|
+
Math.max(...caseBounds.map(([_, upper]) => upper))
|
|
116
|
+
];
|
|
59
117
|
}
|
|
60
118
|
}
|
|
61
119
|
}
|