SDK: fix chain id/name types (#3250)
This commit is contained in:
parent
5ce1a42c0b
commit
155d206322
|
@ -41,7 +41,7 @@ export type ChainId = typeof CHAINS[ChainName];
|
||||||
*
|
*
|
||||||
* All the EVM-based chain names that Wormhole supports
|
* All the EVM-based chain names that Wormhole supports
|
||||||
*/
|
*/
|
||||||
export const EVMChainNames: ReadonlyArray<ChainName> = [
|
export const EVMChainNames = [
|
||||||
"ethereum",
|
"ethereum",
|
||||||
"bsc",
|
"bsc",
|
||||||
"polygon",
|
"polygon",
|
||||||
|
@ -67,13 +67,10 @@ export type EVMChainName = typeof EVMChainNames[number];
|
||||||
*
|
*
|
||||||
* All the Solana-based chain names that Wormhole supports
|
* All the Solana-based chain names that Wormhole supports
|
||||||
*/
|
*/
|
||||||
export const SolanaChainNames: ReadonlyArray<ChainName> = [
|
export const SolanaChainNames = ["solana", "pythnet"] as const;
|
||||||
"solana",
|
|
||||||
"pythnet",
|
|
||||||
] as const;
|
|
||||||
export type SolanaChainName = typeof SolanaChainNames[number];
|
export type SolanaChainName = typeof SolanaChainNames[number];
|
||||||
|
|
||||||
export const CosmWasmChainNames: ReadonlyArray<ChainName> = [
|
export const CosmWasmChainNames = [
|
||||||
"terra",
|
"terra",
|
||||||
"terra2",
|
"terra2",
|
||||||
"injective",
|
"injective",
|
||||||
|
@ -83,10 +80,7 @@ export const CosmWasmChainNames: ReadonlyArray<ChainName> = [
|
||||||
export type CosmWasmChainName = typeof CosmWasmChainNames[number];
|
export type CosmWasmChainName = typeof CosmWasmChainNames[number];
|
||||||
|
|
||||||
// TODO: why? these are dupe of entries in CosmWasm
|
// TODO: why? these are dupe of entries in CosmWasm
|
||||||
export const TerraChainNames: ReadonlyArray<ChainName> = [
|
export const TerraChainNames = ["terra", "terra2"] as const;
|
||||||
"terra",
|
|
||||||
"terra2",
|
|
||||||
] as const;
|
|
||||||
export type TerraChainName = typeof TerraChainNames[number];
|
export type TerraChainName = typeof TerraChainNames[number];
|
||||||
|
|
||||||
export type Contracts = {
|
export type Contracts = {
|
||||||
|
@ -815,28 +809,28 @@ export function isEVMChain(
|
||||||
chain: ChainId | ChainName
|
chain: ChainId | ChainName
|
||||||
): chain is EVMChainId | EVMChainName {
|
): chain is EVMChainId | EVMChainName {
|
||||||
const chainName = coalesceChainName(chain);
|
const chainName = coalesceChainName(chain);
|
||||||
return EVMChainNames.includes(chainName);
|
return EVMChainNames.includes(chainName as unknown as EVMChainName);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isCosmWasmChain(
|
export function isCosmWasmChain(
|
||||||
chain: ChainId | ChainName
|
chain: ChainId | ChainName
|
||||||
): chain is CosmWasmChainId | CosmWasmChainName {
|
): chain is CosmWasmChainId | CosmWasmChainName {
|
||||||
const chainName = coalesceChainName(chain);
|
const chainName = coalesceChainName(chain);
|
||||||
return CosmWasmChainNames.includes(chainName);
|
return CosmWasmChainNames.includes(chainName as unknown as CosmWasmChainName);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isTerraChain(
|
export function isTerraChain(
|
||||||
chain: ChainId | ChainName
|
chain: ChainId | ChainName
|
||||||
): chain is TerraChainId | TerraChainName {
|
): chain is TerraChainId | TerraChainName {
|
||||||
const chainName = coalesceChainName(chain);
|
const chainName = coalesceChainName(chain);
|
||||||
return TerraChainNames.includes(chainName);
|
return TerraChainNames.includes(chainName as unknown as TerraChainName);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isSolanaChain(
|
export function isSolanaChain(
|
||||||
chain: ChainId | ChainName
|
chain: ChainId | ChainName
|
||||||
): chain is SolanaChainId | SolanaChainName {
|
): chain is SolanaChainId | SolanaChainName {
|
||||||
const chainName = coalesceChainName(chain);
|
const chainName = coalesceChainName(chain);
|
||||||
return SolanaChainNames.includes(chainName);
|
return SolanaChainNames.includes(chainName as unknown as SolanaChainName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue