@edgeandnode/common
Advanced tools
Comparing version 5.1.2 to 5.2.0
@@ -0,1 +1,2 @@ | ||
import { BlockchainNetwork, Chain, NetworkId } from '../models'; | ||
export declare const NETWORKS: { | ||
@@ -18,1 +19,9 @@ 1: string; | ||
export declare function getNetworkId(name: string): number; | ||
export declare const DefChain: Chain; | ||
export declare const SupportedNetworkMap: Map<NetworkId, BlockchainNetwork>; | ||
/** Returns an array of all Chains across all Networks, sorted by: network.order, chain.chainId */ | ||
export declare const ChainsByChainId: Chain[]; | ||
/** Returns an array of all Chains across all Networks, sorted by: network.order, chain.chainLikessOrder */ | ||
export declare const ChainsByLikeness: Chain[]; | ||
/** Build a map of chains by the chain uid. Useful for finding chains by their uid */ | ||
export declare const SupportedChainMap: Map<"evm-1" | "evm-3" | "evm-4" | "evm-5" | "evm-10" | "evm-42" | "evm-56" | "evm-69" | "evm-77" | "evm-97" | "evm-99" | "evm-100" | "evm-122" | "evm-137" | "evm-250" | "evm-288" | "evm-1023" | "evm-1285" | "evm-1287" | "evm-42161" | "evm-42220" | "evm-43113" | "evm-43114" | "evm-44787" | "evm-80001" | "evm-421611" | "evm-1313161554" | "evm-1313161555" | "evm-1666600000" | "near-1" | "near-2" | "cosmos-1" | "cosmos-2" | "ar-1", Chain>; |
@@ -465,2 +465,78 @@ import { gql } from 'graphql-tag'; | ||
/// These models are internal representations of blockchain networks and their associated chains | ||
/** | ||
* As support for different chains moves from the hosted-service -> the decentralized network/Studio, | ||
* the status of the chain will change to where we allow users to deploy the subgraph to. | ||
*/ | ||
var ChainProductStatus; | ||
(function (ChainProductStatus) { | ||
/** Deploying a Subgraph indexing the chain is BLOCKED in the given app */ | ||
ChainProductStatus["BLOCKED"] = "BLOCKED"; | ||
/** Deploying a Subgraph indexing the chain is ALLOWED in the given app */ | ||
ChainProductStatus["ALLOWED"] = "ALLOWED"; | ||
})(ChainProductStatus || (ChainProductStatus = {})); | ||
var EventType; | ||
(function (EventType) { | ||
EventType["CURATE"] = "Curate"; | ||
EventType["DELEGATE"] = "Delegate"; | ||
EventType["PUBLISH"] = "Publish"; | ||
EventType["INDEX"] = "Index"; | ||
EventType["SETTINGS"] = "Settings"; | ||
})(EventType || (EventType = {})); | ||
var AllocationStatus; | ||
(function (AllocationStatus) { | ||
AllocationStatus["Null"] = "Null"; | ||
AllocationStatus["Active"] = "Active"; | ||
AllocationStatus["Closed"] = "Closed"; | ||
AllocationStatus["Finalized"] = "Finalized"; | ||
AllocationStatus["Claimed"] = "Claimed"; | ||
})(AllocationStatus || (AllocationStatus = {})); | ||
var DisputeStatus; | ||
(function (DisputeStatus) { | ||
DisputeStatus["Undecided"] = "Undecided"; | ||
DisputeStatus["Accepted"] = "Accepted"; | ||
DisputeStatus["Rejected"] = "Rejected"; | ||
DisputeStatus["Draw"] = "Draw"; | ||
})(DisputeStatus || (DisputeStatus = {})); | ||
var DisputeType; | ||
(function (DisputeType) { | ||
DisputeType["Indexing"] = "Indexing"; | ||
DisputeType["SingleQuery"] = "SingleQuery"; | ||
DisputeType["Conflicting"] = "Conflicting"; | ||
})(DisputeType || (DisputeType = {})); | ||
var TransactionType; | ||
(function (TransactionType) { | ||
TransactionType["Stake"] = "Stake"; | ||
TransactionType["Unstake"] = "Unstake"; | ||
TransactionType["MintSignal"] = "MintSignal"; | ||
TransactionType["BurnSignal"] = "BurnSignal"; | ||
TransactionType["MintNSignal"] = "MintNSignal"; | ||
TransactionType["BurnNSignal"] = "BurnNSignal"; | ||
})(TransactionType || (TransactionType = {})); | ||
var Revocability; | ||
(function (Revocability) { | ||
Revocability["NotSet"] = "NotSet"; | ||
Revocability["Enabled"] = "Enabled"; | ||
Revocability["Disabled"] = "Disabled"; | ||
})(Revocability || (Revocability = {})); | ||
var SubgraphIndexHealth; | ||
(function (SubgraphIndexHealth) { | ||
SubgraphIndexHealth["HEALTHY"] = "healthy"; | ||
SubgraphIndexHealth["UNHEALTHY"] = "unhealthy"; | ||
SubgraphIndexHealth["FAILED"] = "failed"; | ||
})(SubgraphIndexHealth || (SubgraphIndexHealth = {})); | ||
var BillingTransactionType; | ||
(function (BillingTransactionType) { | ||
BillingTransactionType["TokensAdded"] = "TokensAdded"; | ||
BillingTransactionType["TokensRemoved"] = "TokensRemoved"; | ||
BillingTransactionType["TokensPulled"] = "TokensPulled"; | ||
})(BillingTransactionType || (BillingTransactionType = {})); | ||
const NETWORKS = { | ||
@@ -503,2 +579,422 @@ 1: 'Mainnet', | ||
} | ||
const studioAllowedStatus = { | ||
hostedService: ChainProductStatus.BLOCKED, | ||
studio: ChainProductStatus.ALLOWED | ||
}; | ||
const hostedServiceAllowedStatus = { | ||
hostedService: ChainProductStatus.ALLOWED, | ||
studio: ChainProductStatus.BLOCKED | ||
}; | ||
const DefChain = { | ||
uid: 'evm-1', | ||
network: 'evm', | ||
chainId: 1, | ||
chainLikenessOrder: 1, | ||
name: 'Mainnet', | ||
graphCliName: 'mainnet', | ||
aliases: ['homestead'], | ||
testnet: false, | ||
productDeployStatus: studioAllowedStatus | ||
}; | ||
const SupportedNetworkMap = new Map([ | ||
[ | ||
'evm', | ||
{ | ||
id: 'evm', | ||
name: 'Ethereum', | ||
order: 1, | ||
chains: new Set([ | ||
DefChain, | ||
{ | ||
uid: 'evm-3', | ||
network: 'evm', | ||
chainId: 3, | ||
chainLikenessOrder: 2, | ||
name: 'Ropsten', | ||
graphCliName: 'ropsten', | ||
testnet: true, | ||
notes: 'deprecated Q4 2022', | ||
productDeployStatus: hostedServiceAllowedStatus | ||
}, | ||
{ | ||
uid: 'evm-4', | ||
network: 'evm', | ||
chainId: 4, | ||
chainLikenessOrder: 3, | ||
name: 'Rinkeby', | ||
graphCliName: 'rinkeby', | ||
testnet: true, | ||
notes: 'deprecated Q2/Q3 2022', | ||
productDeployStatus: studioAllowedStatus | ||
}, | ||
{ | ||
uid: 'evm-5', | ||
network: 'evm', | ||
chainId: 5, | ||
chainLikenessOrder: 4, | ||
name: 'Görli', | ||
graphCliName: 'goerli', | ||
aliases: ['goerli'], | ||
testnet: true, | ||
notes: 'deprecated Q2/Q3 2022', | ||
productDeployStatus: hostedServiceAllowedStatus | ||
}, | ||
{ | ||
uid: 'evm-10', | ||
network: 'evm', | ||
chainId: 10, | ||
chainLikenessOrder: 6, | ||
name: 'Optimism', | ||
graphCliName: 'optimism', | ||
testnet: false, | ||
productDeployStatus: hostedServiceAllowedStatus | ||
}, | ||
{ | ||
uid: 'evm-42', | ||
network: 'evm', | ||
chainId: 42, | ||
chainLikenessOrder: 5, | ||
name: 'Kovan', | ||
graphCliName: 'kovan', | ||
testnet: true, | ||
productDeployStatus: hostedServiceAllowedStatus | ||
}, | ||
{ | ||
uid: 'evm-56', | ||
network: 'evm', | ||
chainId: 56, | ||
chainLikenessOrder: 8, | ||
name: 'BNB', | ||
graphCliName: 'bsc', | ||
aliases: ['bsc'], | ||
testnet: false, | ||
notes: 'formerly Binance Smart Chain (bsc)', | ||
productDeployStatus: hostedServiceAllowedStatus | ||
}, | ||
{ | ||
uid: 'evm-69', | ||
network: 'evm', | ||
chainId: 69, | ||
chainLikenessOrder: 7, | ||
name: 'Optimism Kovan', | ||
graphCliName: 'optimism-kovan', | ||
testnet: true, | ||
productDeployStatus: hostedServiceAllowedStatus | ||
}, | ||
{ | ||
uid: 'evm-77', | ||
network: 'evm', | ||
chainId: 77, | ||
chainLikenessOrder: 11, | ||
name: 'POA-Sokol', | ||
graphCliName: 'poa-sokol', | ||
testnet: false, | ||
productDeployStatus: hostedServiceAllowedStatus | ||
}, | ||
{ | ||
uid: 'evm-97', | ||
network: 'evm', | ||
chainId: 97, | ||
chainLikenessOrder: 9, | ||
name: 'BNB Bruno Testnet', | ||
graphCliName: 'chapel', | ||
testnet: true, | ||
notes: 'formerly Binance Smart Chain Testnet (tbsc)', | ||
productDeployStatus: hostedServiceAllowedStatus | ||
}, | ||
{ | ||
uid: 'evm-99', | ||
network: 'evm', | ||
chainId: 99, | ||
chainLikenessOrder: 10, | ||
name: 'POA-Core', | ||
graphCliName: 'poa-core', | ||
testnet: false, | ||
productDeployStatus: hostedServiceAllowedStatus | ||
}, | ||
{ | ||
uid: 'evm-100', | ||
network: 'evm', | ||
chainId: 100, | ||
chainLikenessOrder: 12, | ||
name: 'Gnosis Chain', | ||
graphCliName: 'xdai', | ||
testnet: false, | ||
productDeployStatus: hostedServiceAllowedStatus | ||
}, | ||
{ | ||
uid: 'evm-122', | ||
network: 'evm', | ||
chainId: 122, | ||
chainLikenessOrder: 13, | ||
name: 'Fuse', | ||
graphCliName: 'fuse', | ||
testnet: false, | ||
productDeployStatus: hostedServiceAllowedStatus | ||
}, | ||
{ | ||
uid: 'evm-137', | ||
network: 'evm', | ||
chainId: 137, | ||
chainLikenessOrder: 14, | ||
name: 'Polygon Mainnet', | ||
graphCliName: 'matic', | ||
testnet: false, | ||
notes: 'formerly matic', | ||
productDeployStatus: hostedServiceAllowedStatus | ||
}, | ||
{ | ||
uid: 'evm-250', | ||
network: 'evm', | ||
chainId: 250, | ||
chainLikenessOrder: 16, | ||
name: 'Fantom Opera', | ||
graphCliName: 'fantom', | ||
testnet: false, | ||
productDeployStatus: hostedServiceAllowedStatus | ||
}, | ||
{ | ||
uid: 'evm-288', | ||
network: 'evm', | ||
chainId: 288, | ||
chainLikenessOrder: 17, | ||
name: 'Boba', | ||
graphCliName: 'boba', | ||
testnet: false, | ||
productDeployStatus: hostedServiceAllowedStatus | ||
}, | ||
{ | ||
uid: 'evm-1023', | ||
network: 'evm', | ||
chainId: 1023, | ||
chainLikenessOrder: 18, | ||
name: 'Clover Testnet', | ||
graphCliName: 'clover', | ||
testnet: true, | ||
productDeployStatus: hostedServiceAllowedStatus | ||
}, | ||
{ | ||
uid: 'evm-1285', | ||
network: 'evm', | ||
chainId: 1285, | ||
chainLikenessOrder: 19, | ||
name: 'Moonriver', | ||
graphCliName: 'moonriver', | ||
testnet: false, | ||
productDeployStatus: hostedServiceAllowedStatus | ||
}, | ||
{ | ||
uid: 'evm-1287', | ||
network: 'evm', | ||
chainId: 1287, | ||
chainLikenessOrder: 20, | ||
name: 'Moonbase Alpha', | ||
graphCliName: 'mbase', | ||
aliases: ['moonbase'], | ||
testnet: false, | ||
productDeployStatus: hostedServiceAllowedStatus | ||
}, | ||
{ | ||
uid: 'evm-42161', | ||
network: 'evm', | ||
chainId: 42161, | ||
chainLikenessOrder: 21, | ||
name: 'Arbitrum One', | ||
graphCliName: 'arbitrum-one', | ||
aliases: ['arbitrum'], | ||
testnet: false, | ||
productDeployStatus: hostedServiceAllowedStatus | ||
}, | ||
{ | ||
uid: 'evm-42220', | ||
network: 'evm', | ||
chainId: 42220, | ||
chainLikenessOrder: 23, | ||
name: 'Celo', | ||
graphCliName: 'celo', | ||
testnet: false, | ||
productDeployStatus: hostedServiceAllowedStatus | ||
}, | ||
{ | ||
uid: 'evm-43113', | ||
network: 'evm', | ||
chainId: 43113, | ||
chainLikenessOrder: 26, | ||
name: 'Avalanche Fuji Testnet', | ||
graphCliName: 'fuji', | ||
testnet: true, | ||
productDeployStatus: hostedServiceAllowedStatus | ||
}, | ||
{ | ||
uid: 'evm-43114', | ||
network: 'evm', | ||
chainId: 43114, | ||
chainLikenessOrder: 25, | ||
name: 'Avalanche', | ||
graphCliName: 'avalanche', | ||
testnet: false, | ||
productDeployStatus: hostedServiceAllowedStatus | ||
}, | ||
{ | ||
uid: 'evm-44787', | ||
network: 'evm', | ||
chainId: 44787, | ||
chainLikenessOrder: 24, | ||
name: 'Celo Alfajores Testnet', | ||
graphCliName: 'celo-alfajores', | ||
testnet: true, | ||
productDeployStatus: hostedServiceAllowedStatus | ||
}, | ||
{ | ||
uid: 'evm-80001', | ||
network: 'evm', | ||
chainId: 80001, | ||
chainLikenessOrder: 15, | ||
name: 'Polygon Testnet', | ||
graphCliName: 'mumbai', | ||
testnet: true, | ||
notes: 'mumbai - formerly matic testnet', | ||
productDeployStatus: hostedServiceAllowedStatus | ||
}, | ||
{ | ||
uid: 'evm-421611', | ||
network: 'evm', | ||
chainId: 421611, | ||
chainLikenessOrder: 22, | ||
name: 'Arbitrum Rinkeby', | ||
graphCliName: 'arbitrum-rinkeby', | ||
testnet: true, | ||
notes: 'deprecated Q2/Q3 2022', | ||
productDeployStatus: hostedServiceAllowedStatus | ||
}, | ||
{ | ||
uid: 'evm-1313161554', | ||
network: 'evm', | ||
chainId: 1313161554, | ||
chainLikenessOrder: 27, | ||
name: 'Aurora Mainnet', | ||
graphCliName: 'aurora', | ||
testnet: false, | ||
productDeployStatus: hostedServiceAllowedStatus | ||
}, | ||
{ | ||
uid: 'evm-1313161555', | ||
network: 'evm', | ||
chainId: 1313161555, | ||
chainLikenessOrder: 28, | ||
name: 'Aurora Testnet', | ||
graphCliName: 'aurora-testnet', | ||
testnet: true, | ||
productDeployStatus: hostedServiceAllowedStatus | ||
}, | ||
{ | ||
uid: 'evm-1666600000', | ||
network: 'evm', | ||
chainId: 1666600000, | ||
chainLikenessOrder: 29, | ||
name: 'Harmony', | ||
graphCliName: 'harmony', | ||
testnet: false, | ||
notes: 'shard 0', | ||
productDeployStatus: hostedServiceAllowedStatus | ||
} | ||
]) | ||
} | ||
], | ||
[ | ||
'near', | ||
{ | ||
id: 'near', | ||
name: 'NEAR', | ||
order: 2, | ||
chains: new Set([ | ||
{ | ||
uid: 'near-1', | ||
network: 'near', | ||
chainId: 1, | ||
chainLikenessOrder: 31, | ||
name: 'NEAR Mainnet', | ||
graphCliName: 'near-mainnet', | ||
testnet: false, | ||
productDeployStatus: hostedServiceAllowedStatus | ||
}, | ||
{ | ||
uid: 'near-2', | ||
network: 'near', | ||
chainId: 2, | ||
chainLikenessOrder: 32, | ||
name: 'NEAR Testnet', | ||
graphCliName: 'near-testnet', | ||
testnet: true, | ||
productDeployStatus: hostedServiceAllowedStatus | ||
} | ||
]) | ||
} | ||
], | ||
[ | ||
'cosmos', | ||
{ | ||
id: 'cosmos', | ||
name: 'Cosmos', | ||
order: 3, | ||
chains: new Set([ | ||
{ | ||
uid: 'cosmos-1', | ||
network: 'cosmos', | ||
chainId: 1, | ||
chainLikenessOrder: 33, | ||
name: 'Cosmos', | ||
graphCliName: 'cosmoshub-4', | ||
testnet: false, | ||
productDeployStatus: hostedServiceAllowedStatus | ||
}, | ||
{ | ||
uid: 'cosmos-2', | ||
network: 'cosmos', | ||
chainId: 2, | ||
chainLikenessOrder: 34, | ||
name: 'Cosmos Hub Testnet', | ||
graphCliName: 'theta-testnet-001', | ||
testnet: true, | ||
productDeployStatus: hostedServiceAllowedStatus | ||
} | ||
]) | ||
} | ||
], | ||
[ | ||
'ar', | ||
{ | ||
id: 'ar', | ||
name: 'Arweave', | ||
order: 4, | ||
chains: new Set([ | ||
{ | ||
uid: 'ar-1', | ||
network: 'ar', | ||
chainId: 1, | ||
chainLikenessOrder: 30, | ||
name: 'Arweave Mainnet', | ||
graphCliName: 'arweave-mainnet', | ||
testnet: false, | ||
productDeployStatus: hostedServiceAllowedStatus | ||
} | ||
]) | ||
} | ||
] | ||
]); | ||
const SortedNetworks = Array.from(SupportedNetworkMap.values()).sort((a, b) => a.order - b.order); | ||
/** Returns an array of all Chains across all Networks, sorted by: network.order, chain.chainId */ | ||
const ChainsByChainId = SortedNetworks.reduce((chains, curr) => { | ||
const networkChains = Array.from(curr.chains).sort((a, b) => a.chainId - b.chainId); | ||
return [...chains, ...networkChains]; | ||
}, []); | ||
/** Returns an array of all Chains across all Networks, sorted by: network.order, chain.chainLikessOrder */ | ||
const ChainsByLikeness = SortedNetworks.reduce((chains, curr) => { | ||
const networkChains = Array.from(curr.chains).sort((a, b) => a.chainLikenessOrder - b.chainLikenessOrder); | ||
return [...chains, ...networkChains]; | ||
}, []); | ||
/** Build a map of chains by the chain uid. Useful for finding chains by their uid */ | ||
const SupportedChainMap = new Map(ChainsByChainId.reduce((map, curr) => { | ||
return map.set(curr.uid, curr); | ||
}, new Map())); | ||
@@ -927,65 +1423,2 @@ const TenTrillion = utils.parseEther('10000000000000'); | ||
var EventType; | ||
(function (EventType) { | ||
EventType["CURATE"] = "Curate"; | ||
EventType["DELEGATE"] = "Delegate"; | ||
EventType["PUBLISH"] = "Publish"; | ||
EventType["INDEX"] = "Index"; | ||
EventType["SETTINGS"] = "Settings"; | ||
})(EventType || (EventType = {})); | ||
var AllocationStatus; | ||
(function (AllocationStatus) { | ||
AllocationStatus["Null"] = "Null"; | ||
AllocationStatus["Active"] = "Active"; | ||
AllocationStatus["Closed"] = "Closed"; | ||
AllocationStatus["Finalized"] = "Finalized"; | ||
AllocationStatus["Claimed"] = "Claimed"; | ||
})(AllocationStatus || (AllocationStatus = {})); | ||
var DisputeStatus; | ||
(function (DisputeStatus) { | ||
DisputeStatus["Undecided"] = "Undecided"; | ||
DisputeStatus["Accepted"] = "Accepted"; | ||
DisputeStatus["Rejected"] = "Rejected"; | ||
DisputeStatus["Draw"] = "Draw"; | ||
})(DisputeStatus || (DisputeStatus = {})); | ||
var DisputeType; | ||
(function (DisputeType) { | ||
DisputeType["Indexing"] = "Indexing"; | ||
DisputeType["SingleQuery"] = "SingleQuery"; | ||
DisputeType["Conflicting"] = "Conflicting"; | ||
})(DisputeType || (DisputeType = {})); | ||
var TransactionType; | ||
(function (TransactionType) { | ||
TransactionType["Stake"] = "Stake"; | ||
TransactionType["Unstake"] = "Unstake"; | ||
TransactionType["MintSignal"] = "MintSignal"; | ||
TransactionType["BurnSignal"] = "BurnSignal"; | ||
TransactionType["MintNSignal"] = "MintNSignal"; | ||
TransactionType["BurnNSignal"] = "BurnNSignal"; | ||
})(TransactionType || (TransactionType = {})); | ||
var Revocability; | ||
(function (Revocability) { | ||
Revocability["NotSet"] = "NotSet"; | ||
Revocability["Enabled"] = "Enabled"; | ||
Revocability["Disabled"] = "Disabled"; | ||
})(Revocability || (Revocability = {})); | ||
var SubgraphIndexHealth; | ||
(function (SubgraphIndexHealth) { | ||
SubgraphIndexHealth["HEALTHY"] = "healthy"; | ||
SubgraphIndexHealth["UNHEALTHY"] = "unhealthy"; | ||
SubgraphIndexHealth["FAILED"] = "failed"; | ||
})(SubgraphIndexHealth || (SubgraphIndexHealth = {})); | ||
var BillingTransactionType; | ||
(function (BillingTransactionType) { | ||
BillingTransactionType["TokensAdded"] = "TokensAdded"; | ||
BillingTransactionType["TokensRemoved"] = "TokensRemoved"; | ||
BillingTransactionType["TokensPulled"] = "TokensPulled"; | ||
})(BillingTransactionType || (BillingTransactionType = {})); | ||
const getEventTypeFromTypename = (__typename) => { | ||
@@ -1148,3 +1581,53 @@ switch (true) { | ||
export { AllocationStatus, BillingTransactionType, DisputeStatus, DisputeType, ETHEREUM_BLOCK_TIME, EventType, GRTBufferedMaxUint256, GrtUsdcUniswapPair, MAX_WEIGHT, NETWORKS, NetworkEnum, PPM, Revocability, SECONDS_IN_DAY, SIGNAL_PER_MINIMUM_DEPOSIT, SubgraphIndexHealth, TenTrillion, TransactionType, ZERO, addrShortener, appendEth, appendQueryParam, bigNumberify, blocksToDays, buildEnsDataLoader, buildEventInterfaceList, buildGasLimit, buildSubgraphId, checkAllowance, connectProvider, convertSubgraphId, convertSubgraphIdtoBase58, dateFromNow, dateStringFromNow, dateUntilNow, decToBigNumber, delegatorCooldownToDays, ensLookup, ensLookups, ensNameBuilder, formatDayHourMin, formatDays, formatDuration, formatDurationWithSeconds, formatHourMin, formatNameHash, formatUnits, formatUnitsToNumber, formatWithNumeral, generateExampleQuery, generateExampleQueryForField, generateExampleQueryForFieldWithNamedType, generateExampleQueryForFieldWithType, generateExampleQueryForType, getContract, getDate, getERC20Balance, getEventInterface, getEventTypeFromTypename, getGnosisTxLink, getGrtPriceUsd, getNetworkId, getNetworkName, getProvider, getTxLink, isV1SubgraphId, nSignalToTokens, nSignalToVSignal, overrides, pickExampleFields, pickExampleTypes, purchaseTargetAmount, saleTargetAmount, signalToTokens, toCamelCase, toGRT, toPlural, toWei, tokensToNSignal, tokensToSignal, unixDateFromNow, vSignalToNSignal }; | ||
function buildChainSlug(chain) { | ||
var _a; | ||
return `${chain.name}${chain.graphCliName || ''}${((_a = chain.aliases) !== null && _a !== void 0 ? _a : []).join('')}`.toLowerCase(); | ||
} | ||
/** | ||
* Search the list of supported chains to find the chain by the chain name and return its NetworkChainUID | ||
* @param nameOrGraphCliName the chain name, or graph-cli reference name to resolve to a NetworkChainUID | ||
* @returns the resolved NetworkChainUID from the list of supported chains. If no chain found with the name, return null | ||
*/ | ||
function resolveNetworkChainUID(nameOrGraphCliName) { | ||
var _a; | ||
const search = nameOrGraphCliName.toLowerCase(); | ||
const found = ChainsByChainId.find((c) => { | ||
const slug = buildChainSlug(c); | ||
return slug.includes(search); | ||
}); | ||
return (_a = found === null || found === void 0 ? void 0 : found.uid) !== null && _a !== void 0 ? _a : null; | ||
} | ||
/** | ||
* Attempt to find the supported chain by the given params. | ||
* - if uid, find from the SupportedChainMap by the uid key | ||
* - if name, find by the chain name or the graph-cli name reference for the chain | ||
* - if network, find by the network id, and the chain id | ||
* If none of the params are passed in, and the `returnDefault` param is true, return the default chain of ethereum mainnet, evm-1; | ||
* otherwise, return null | ||
*/ | ||
function resolveChain({ uid, nameOrGraphCliName, network, returnDefault = true }) { | ||
var _a, _b; | ||
const defaultChain = returnDefault ? DefChain : null; | ||
switch (true) { | ||
case uid != null: { | ||
return (_a = SupportedChainMap.get(uid)) !== null && _a !== void 0 ? _a : defaultChain; | ||
} | ||
case nameOrGraphCliName != null: { | ||
const search = nameOrGraphCliName.toLowerCase(); | ||
const found = ChainsByChainId.find((c) => { | ||
const slug = buildChainSlug(c); | ||
return slug.includes(search); | ||
}); | ||
return found !== null && found !== void 0 ? found : defaultChain; | ||
} | ||
case network != null: { | ||
return ((_b = ChainsByChainId.find((c) => c.network === network.network && c.chainId === network.chainId)) !== null && _b !== void 0 ? _b : defaultChain); | ||
} | ||
default: { | ||
return defaultChain; | ||
} | ||
} | ||
} | ||
export { AllocationStatus, BillingTransactionType, ChainProductStatus, ChainsByChainId, ChainsByLikeness, DefChain, DisputeStatus, DisputeType, ETHEREUM_BLOCK_TIME, EventType, GRTBufferedMaxUint256, GrtUsdcUniswapPair, MAX_WEIGHT, NETWORKS, NetworkEnum, PPM, Revocability, SECONDS_IN_DAY, SIGNAL_PER_MINIMUM_DEPOSIT, SubgraphIndexHealth, SupportedChainMap, SupportedNetworkMap, TenTrillion, TransactionType, ZERO, addrShortener, appendEth, appendQueryParam, bigNumberify, blocksToDays, buildEnsDataLoader, buildEventInterfaceList, buildGasLimit, buildSubgraphId, checkAllowance, connectProvider, convertSubgraphId, convertSubgraphIdtoBase58, dateFromNow, dateStringFromNow, dateUntilNow, decToBigNumber, delegatorCooldownToDays, ensLookup, ensLookups, ensNameBuilder, formatDayHourMin, formatDays, formatDuration, formatDurationWithSeconds, formatHourMin, formatNameHash, formatUnits, formatUnitsToNumber, formatWithNumeral, generateExampleQuery, generateExampleQueryForField, generateExampleQueryForFieldWithNamedType, generateExampleQueryForFieldWithType, generateExampleQueryForType, getContract, getDate, getERC20Balance, getEventInterface, getEventTypeFromTypename, getGnosisTxLink, getGrtPriceUsd, getNetworkId, getNetworkName, getProvider, getTxLink, isV1SubgraphId, nSignalToTokens, nSignalToVSignal, overrides, pickExampleFields, pickExampleTypes, purchaseTargetAmount, resolveChain, resolveNetworkChainUID, saleTargetAmount, signalToTokens, toCamelCase, toGRT, toPlural, toWei, tokensToNSignal, tokensToSignal, unixDateFromNow, vSignalToNSignal }; | ||
//# sourceMappingURL=index.esm.js.map |
export * from './big-number.model'; | ||
export * from './block.model'; | ||
export * from './network-chain.model'; | ||
export * from './analytics'; | ||
@@ -4,0 +5,0 @@ export * from './explorer'; |
@@ -13,1 +13,3 @@ export * from './graphql.utils'; | ||
export * from './grt.utils'; | ||
export * from './network-chain.utils'; | ||
export * from './typelevel'; |
{ | ||
"name": "@edgeandnode/common", | ||
"version": "5.1.2", | ||
"version": "5.2.0", | ||
"description": "Common Edge & Node utils and types", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
278764
62
4918