-
Notifications
You must be signed in to change notification settings - Fork 171
/
const.ts
131 lines (119 loc) · 3.35 KB
/
const.ts
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
import { Network as NetworkFromEthers } from '@ethersproject/networks';
import { Network } from '../types/types';
export const DEFAULT_ALCHEMY_API_KEY = 'demo';
export const DEFAULT_NETWORK = Network.ETH_MAINNET;
export const DEFAULT_MAX_RETRIES = 5;
export const DEFAULT_REQUEST_TIMEOUT = 0; // 0 = no timeout
/**
* Returns the base URL for making Alchemy API requests. The `alchemy.com`
* endpoints only work with non eth json-rpc requests.
*
* @internal
*/
export function getAlchemyHttpUrl(network: Network, apiKey: string): string {
return `https://${network}.g.alchemy.com/v2/${apiKey}`;
}
export function getAlchemyNftHttpUrl(network: Network, apiKey: string): string {
return `https://${network}.g.alchemy.com/nft/v3/${apiKey}`;
}
export function getAlchemyWsUrl(network: Network, apiKey: string): string {
return `wss://${network}.g.alchemy.com/v2/${apiKey}`;
}
export function getAlchemyWebhookHttpUrl(): string {
return 'https://dashboard.alchemy.com/api';
}
export enum AlchemyApiType {
BASE,
NFT,
WEBHOOK
}
/**
* Mapping of network names to their corresponding Network strings used to
* create an Ethers.js Provider instance.
*/
export const EthersNetwork = {
[Network.ETH_MAINNET]: 'mainnet',
[Network.ETH_GOERLI]: 'goerli',
[Network.ETH_SEPOLIA]: 'sepolia',
[Network.OPT_MAINNET]: 'optimism',
[Network.OPT_GOERLI]: 'optimism-goerli',
[Network.OPT_SEPOLIA]: 'optimism-sepolia',
[Network.ARB_MAINNET]: 'arbitrum',
[Network.ARB_GOERLI]: 'arbitrum-goerli',
[Network.ARB_SEPOLIA]: 'arbitrum-sepolia',
[Network.MATIC_MAINNET]: 'matic',
[Network.MATIC_MUMBAI]: 'maticmum',
[Network.MATIC_AMOY]: 'maticamoy',
[Network.ASTAR_MAINNET]: 'astar-mainnet',
[Network.POLYGONZKEVM_MAINNET]: 'polygonzkevm-mainnet',
[Network.POLYGONZKEVM_TESTNET]: 'polygonzkevm-testnet',
[Network.BASE_MAINNET]: 'base-mainnet',
[Network.BASE_GOERLI]: 'base-goerli',
[Network.BASE_SEPOLIA]: 'base-sepolia',
[Network.ZKSYNC_MAINNET]: 'zksync-mainnet',
[Network.ZKSYNC_SEPOLIA]: 'zksync-sepolia'
};
/**
* Mapping of network names to their corresponding Ethers Network objects. These
* networks are not yet supported by Ethers and are listed here to be overriden
* in the provider.
*/
export const CustomNetworks: { [key: string]: NetworkFromEthers } = {
'arbitrum-goerli': {
chainId: 421613,
name: 'arbitrum-goerli'
},
'arbitrum-sepolia': {
chainId: 421614,
name: 'arbitrum-sepolia'
},
'astar-mainnet': {
chainId: 592,
name: 'astar-mainnet'
},
sepolia: {
chainId: 11155111,
name: 'sepolia'
},
'optimism-sepolia': {
chainId: 11155420,
name: 'optimism-sepolia'
},
'polygonzkevm-mainnet': {
chainId: 1101,
name: 'polygonzkevm-mainnet'
},
'polygonzkevm-testnet': {
chainId: 1442,
name: 'polygonzkevm-testnet'
},
'base-mainnet': {
chainId: 8453,
name: 'base-mainnet'
},
'base-goerli': {
chainId: 84531,
name: 'base-goerli'
},
'base-sepolia': {
chainId: 84532,
name: 'base-sepolia'
},
maticamoy: {
chainId: 80002,
name: 'maticamoy'
},
'zksync-mainnet': {
chainId: 324,
name: 'zksync-mainnet'
},
'zksync-sepolia': {
chainId: 300,
name: 'zksync-sepolia'
}
};
export function noop(): void {
// It's a no-op
}
export const ETH_NULL_VALUE = '0x';
export const ETH_NULL_ADDRESS = '0x0000000000000000000000000000000000000000';