Skip to content

Commit

Permalink
add some stats
Browse files Browse the repository at this point in the history
  • Loading branch information
zapaz committed Apr 25, 2024
1 parent 003e38a commit de3c82e
Show file tree
Hide file tree
Showing 24 changed files with 649 additions and 289 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"avoid-sha3": "warn"
},
"window.zoomLevel": 0,
"workbench.colorTheme": "Night Owl Light",
"workbench.colorTheme": "Kiwi Light (rainglow)",
"workbench.layoutControl.enabled": true,
"workbench.statusBar.visible": true,
"favorites.sortOrder": "DESC",
Expand Down
9 changes: 7 additions & 2 deletions common/src/common/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ const addresses = JSON.parse(JSON.stringify(addressesRaw));
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-return
const getAddresses = (chainId: number | string): AddressesType | undefined => addresses[String(chainId)];

const getAddressOpenNFTsTemplate = (chainId: number): string => getAddresses(chainId)?.OpenNFTsV4 || "";
const getAddressOpenAutoMarket = (chainId: number): string => getAddresses(chainId)?.OpenAutoMarket || "";

// GET OpenMulti address
const getOpenBound = (chainId: number): string => getAddresses(chainId)?.OpenBound || "";
const hasOpenBound = (chainId: number): boolean => isAddress(getOpenBound(chainId));
Expand Down Expand Up @@ -113,11 +116,11 @@ const textShort = (str: string, n = 16, p = n): string => {
return str.substring(0, n) + (l < n ? "" : "..." + (p > 0 ? str.substring(l - p, l) : ""));
};

const getShortAddress = (address: string, n = 8): string =>
const getShortAddress = (address: string, n = 4): string =>
address
? address.endsWith(".eth")
? textShort(address, 2 * n, 0)
: textShort(getChecksumAddress(address), n, n)
: textShort(getChecksumAddress(address), n + 2, n)
: "?";

// GENERIC helpers
Expand Down Expand Up @@ -362,6 +365,8 @@ export {
getShortAddress,
getChecksumAddress,
getAddresses,
getAddressOpenNFTsTemplate,
getAddressOpenAutoMarket,
getOpenBound,
hasOpenBound,
getDappUrl,
Expand Down
20 changes: 17 additions & 3 deletions common/src/common/networks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,17 @@ const networks = (() => {

// const _getMap = (): Map<number, NetworkType> | undefined => _networksMap;
const _getAll = (): NetworkType[] => [...(_networksMap?.values() || [])];
const _getAllActive = (): NetworkType[] => _getAll().filter((nw: NetworkType) => !(nw.active === false));
const getAllInactive = (): NetworkType[] => _getAll().filter((nw: NetworkType) => nw.active === false);
const getAllActive = (): NetworkType[] => _getAll().filter((nw: NetworkType) => !(nw.active === false));
const getAllSameType = (chainId: chainIdish): NetworkType[] =>
_getAllActive().filter((nw: NetworkType) => isMainnet(nw.chainId) === isMainnet(chainId));
getAllActive().filter((nw: NetworkType) => isMainnet(nw.chainId) === isMainnet(chainId));

const getAllMainnets = (): NetworkType[] => getAllActive().filter((nw: NetworkType) => isMainnet(nw.chainId));

const getAllTestnets = (): NetworkType[] => getAllActive().filter((nw: NetworkType) => isTestnet(nw.chainId));

const getAllOpMainnets = (): NetworkType[] =>
getAllActive().filter((nw: NetworkType) => isOpStack(nw.chainId) && isMainnet(nw.chainId));

const get = (chainId: chainIdish): NetworkType | undefined => _networksMap?.get(Number(chainId));

Expand All @@ -39,12 +47,13 @@ const networks = (() => {

const has = (chainId: chainIdish): boolean => _networksMap?.has(Number(chainId));

const isActive = (chainId: chainIdish): boolean => get(chainId)?.active || false;
const isActive = (chainId: chainIdish): boolean => get(chainId)?.active || true;
const isEip1559 = (chainId: chainIdish): boolean => Boolean(get(chainId)?.eip1559);
const isMainnet = (chainId: chainIdish): boolean => getLinkedMainnet(chainId) == 0;
const isTestnet = (chainId: chainIdish): boolean => !isMainnet(chainId);
const isLayer1 = (chainId: chainIdish): boolean => getLinkedLayer1(chainId) === undefined;
const isLayer2 = (chainId: chainIdish): boolean => !isLayer1(chainId);
const isOpStack = (chainId: chainIdish): boolean => get(chainId)?.opstack || false;

const getChainName = (chainId: chainIdish): string | undefined => get(chainId)?.chainName;
const getChainLabel = (chainId: chainIdish): string | undefined =>
Expand All @@ -60,7 +69,12 @@ const networks = (() => {
has,
get,

getAllActive,
getAllInactive,
getAllSameType,
getAllMainnets,
getAllTestnets,
getAllOpMainnets,

getBlur,
getBlurUrl,
Expand Down
1 change: 1 addition & 0 deletions common/src/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type NetworkType = {
covalent?: { active: boolean; url?: string; key?: string };
linkedLayer1?: number;
linkedMainnet?: number;
opstack?: boolean;
active?: boolean;
create?: boolean;
admin?: string;
Expand Down
12 changes: 12 additions & 0 deletions common/src/resolver/resolver-get-collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,19 @@ const resolverGetCollections = async (
return collections;
};

const countCollectionsCache = new Map<number, number>();
const resolverCountCollections = async (chainId: number): Promise<number | undefined> => {
if (!countCollectionsCache.has(chainId)) {
const nftsResolver = await resolverGetContract(chainId);
const countCollections = Number(await nftsResolver.countAddresses());
countCollectionsCache.set(chainId, countCollections);
}

return countCollectionsCache.get(chainId);
};

export {
resolverCountCollections,
resolverGetCollections,
resolverGetCollection,
resolverAreCollections,
Expand Down
11 changes: 9 additions & 2 deletions config/src/mainnets.handlebars.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
"url": "https://opt-mainnet.g.alchemy.com/nft/v2/{{ALCHEMY_API_KEY_OPTIMISM}}",
"active": true
},
"opstack": true,
"create": true,
"linkedLayer1": 1
},
Expand Down Expand Up @@ -137,6 +138,7 @@
"url": "https://base-mainnet.g.alchemy.com/nft/v2/{{ALCHEMY_API_KEY_BASE}}",
"active": false
},
"opstack": true,
"etherscanApiKey": "{{ETHERSCAN_API_KEY_BASE}}",
"create": true,
"linkedLayer1": 1
Expand All @@ -145,8 +147,8 @@
"chainId": 5000,
"chainName": "mantle",
"rpcUrls": [
"https://rpc.mantle.xyz",
"https://rpc.ankr.com/mantle",
"https://rpc.mantle.xyz",
"https://1rpc.io/mantle"
],
"nativeCurrency": {
Expand All @@ -157,6 +159,7 @@
"blockExplorerUrls": [
"https://explorer.mantle.xyz/"
],
"opstack": true,
"linkedLayer1": 1,
"create": true
},
Expand All @@ -176,6 +179,7 @@
"blockExplorerUrls": [
"https://explorer.mode.network/"
],
"opstack": true,
"linkedLayer1": 1,
"create": true
},
Expand All @@ -195,6 +199,7 @@
"blockExplorerUrls": [
"https://blastscan.io"
],
"opstack": true,
"create": true,
"active": true,
"linkedLayer1": 1
Expand Down Expand Up @@ -253,6 +258,7 @@
"blockExplorerUrls": [
"https://explorer.zora.energy"
],
"opstack": true,
"linkedLayer1": 1,
"active": true,
"create": true
Expand Down Expand Up @@ -372,7 +378,7 @@
"chainName": "bsc",
"chainLabel": "Binance Smart Chain",
"rpcUrls": [
"https://bsc-dataseed1.binance.org",
"https://bsc-rpc.publicnode.com",
"https://rpc.ankr.com/bsc",
"https://bsc-dataseed.binance.org",
"https://bsc-dataseed1.defibit.io",
Expand Down Expand Up @@ -439,6 +445,7 @@
"blockExplorerUrls": [
"https://pacific-explorer.manta.network"
],
"opstack": true,
"create": true,
"active": false,
"linkedLayer1": 0
Expand Down
78 changes: 72 additions & 6 deletions config/src/testnets.handlebars.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"https://base-sepolia.blockscout.com"
],
"etherscanApiKey": "{{ETHERSCAN_API_KEY_BASE}}",
"opstack": true,
"create": true,
"linkedMainnet": 8453,
"linkedLayer1": 11155111
Expand All @@ -77,6 +78,7 @@
"blockExplorerUrls": [
"https://sepolia.explorer.zora.energy/"
],
"opstack": true,
"linkedMainnet": 7777777,
"linkedLayer1": 11155111,
"create": true
Expand All @@ -95,6 +97,7 @@
"blockExplorerUrls": [
"https://testnet.blastscan.io"
],
"opstack": true,
"create": true,
"linkedMainnet": 81457,
"linkedLayer1": 11155111
Expand All @@ -113,6 +116,7 @@
"blockExplorerUrls": [
"https://giant-half-dual-testnet.explorer.testnet.skalenodes.com/"
],
"opstack": true,
"linkedMainnet": 34443,
"linkedLayer1": 11155111,
"create": true
Expand Down Expand Up @@ -160,6 +164,7 @@
"https://goerli.basescan.org",
"https://base-goerli.blockscout.com"
],
"opstack": true,
"etherscanApiKey": "{{ETHERSCAN_API_KEY_BASE}}",
"create": true,
"linkedMainnet": 8453,
Expand All @@ -168,7 +173,7 @@
},
{
"chainId": 59140,
"chainName": "linea-testnet",
"chainName": "linea-goerli",
"rpcUrls": [
"https://linea-goerli.infura.io/v3/{{INFURA_API_KEY}}",
"https://rpc.goerli.linea.build"
Expand All @@ -185,7 +190,47 @@
"linkedMainnet": 59144,
"linkedLayer1": 5,
"create": true,
"active": false
"active": true
},
{
"chainId": 59141,
"chainName": "linea-sepolia",
"rpcUrls": [
"https://linea-sepolia.infura.io/v3/{{INFURA_API_KEY}}",
"https://rpc.sepolia.linea.build"
],
"nativeCurrency": {
"name": "Linea Ether",
"symbol": "ETH",
"decimals": 18
},
"blockExplorerUrls": [
"https://sepolia.lineascan.build",
"https://explorer.sepolia.linea.build"
],
"linkedMainnet": 59144,
"linkedLayer1": 5,
"create": true,
"active": true
},
{
"chainId": 2442,
"chainName": "polygon-zkevm-cardona",
"rpcUrls": [
"https://rpc.cardona.zkevm-rpc.com"
],
"nativeCurrency": {
"name": "Ether",
"symbol": "zktETH",
"decimals": 18
},
"blockExplorerUrls": [
"https://testnet-zkevm.polygonscan.com"
],
"etherscanApiKey": "{{ETHERSCAN_API_KEY_POLYGON_ZKEVM}}",
"linkedMainnet": 1101,
"linkedLayer1": 11155111,
"create": true
},
{
"chainId": 1442,
Expand All @@ -203,6 +248,7 @@
"https://explorer.public.zkevm-test.net"
],
"etherscanApiKey": "{{ETHERSCAN_API_KEY_POLYGON_ZKEVM}}",
"active": false,
"linkedMainnet": 1101,
"linkedLayer1": 5,
"create": true
Expand Down Expand Up @@ -243,6 +289,25 @@
"linkedLayer1": 17000,
"create": true
},
{
"chainId": 80002,
"chainName": "amoy",
"rpcUrls": [
"https://polygon-amoy.infura.io/v3/{{INFURA_API_KEY}}",
"https://rpc-amoy.polygon.technology"
],
"nativeCurrency": {
"name": "Matic",
"symbol": "tMATIC",
"decimals": 18
},
"blockExplorerUrls": [
"https://amoy.polygonscan.com"
],
"etherscanApiKey": "{{ETHERSCAN_API_KEY_POLYGON}}",
"create": true,
"linkedMainnet": 137
},
{
"chainId": 80001,
"chainName": "mumbai",
Expand All @@ -266,6 +331,7 @@
"url": "https://api.thegraph.com/subgraphs/name/zapaz/eip721-mumbai",
"active": true
},
"active": false,
"etherscanApiKey": "{{ETHERSCAN_API_KEY_POLYGON}}",
"create": true,
"linkedMainnet": 137
Expand Down Expand Up @@ -352,10 +418,8 @@
"chainId": 97,
"chainName": "bsc-testnet",
"rpcUrls": [
"https://data-seed-prebsc-1-s1.binance.org:8545",
"https://rpc.ankr.com/bsc_testnet_chapel",
"https://data-seed-prebsc-2-s1.binance.org:8545",
"https://data-seed-prebsc-1-s2.binance.org:8545"
"https://bsc-testnet-rpc.publicnode.com",
"https://bsc-testnet.public.blastapi.io"
],
"nativeCurrency": {
"name": "BNB",
Expand Down Expand Up @@ -402,6 +466,7 @@
"blockExplorerUrls": [
"https://staging-fast-active-bellatrix.explorer.staging-v3.skalenodes.com"
],
"active": false,
"eip1559": false,
"create": true,
"linkedMainnet": 1564830818
Expand Down Expand Up @@ -439,6 +504,7 @@
"blockExplorerUrls": [
"https://pacific-explorer.testnet.manta.network"
],
"opstack": true,
"create": true,
"linkedMainnet": 169,
"linkedLayer1": 0
Expand Down
Loading

0 comments on commit de3c82e

Please sign in to comment.