|
| 1 | +import type { Chain as ViemChain } from "viem"; |
| 2 | +import type * as enums from "./enums"; |
| 3 | + |
| 4 | +/** |
| 5 | + * @see https://github.com/wevm/viem/discussions/3678 |
| 6 | + */ |
| 7 | +type ChainBlockExplorer = { |
| 8 | + name: string; |
| 9 | + url: string; |
| 10 | + apiUrl?: string | undefined; |
| 11 | +}; |
| 12 | + |
| 13 | +type Repository = { |
| 14 | + commit: string; |
| 15 | + url: `https://github.com/sablier-labs/${string}`; |
| 16 | +}; |
| 17 | + |
| 18 | +export namespace EVM { |
| 19 | + export type AliasMap = { [contractName: string]: string }; |
| 20 | + /** Ethereum address in the format 0x followed by 40 hex characters. */ |
| 21 | + export type Address = `0x${string}`; |
| 22 | + |
| 23 | + export type AbiMap = { [contractName: string]: readonly object[] }; |
| 24 | + export type Chain = ViemChain & { |
| 25 | + blockExplorers: { |
| 26 | + [key: string]: ChainBlockExplorer; |
| 27 | + default: ChainBlockExplorer; |
| 28 | + }; |
| 29 | + /** Whether this chain is supported by the Sablier Interface at https://app.sablier.com. */ |
| 30 | + isSupportedByUI: boolean; |
| 31 | + /** Whether this is a testnet network. */ |
| 32 | + isTestnet: boolean; |
| 33 | + /** Whether this is a zkEVM like zkSync. */ |
| 34 | + isZK: boolean; |
| 35 | + nativeCurrency: ViemChain["nativeCurrency"] & { |
| 36 | + coinGeckoId: string; |
| 37 | + }; |
| 38 | + rpc: { |
| 39 | + /** Alchemy RPC URL generator. */ |
| 40 | + alchemy?: (apiKey: string) => string; |
| 41 | + /** Default RPC URL. */ |
| 42 | + defaults: string[]; |
| 43 | + /** Infura RPC URL generator. */ |
| 44 | + infura?: (apiKey: string) => string; |
| 45 | + /** RouteMesh RPC URL generator. */ |
| 46 | + routemesh?: (apiKey: string) => string; |
| 47 | + }; |
| 48 | + /** Used in deployment files to identify the chain, e.g., arbitrum-sepolia. */ |
| 49 | + slug: string; |
| 50 | + }; |
| 51 | + |
| 52 | + /** |
| 53 | + * The base contract type. |
| 54 | + */ |
| 55 | + export type Contract = { |
| 56 | + /** The address of the contract. */ |
| 57 | + address: Address; |
| 58 | + /** Optional alias for the contract, used in the Sablier Interface and the indexers. */ |
| 59 | + alias?: string; |
| 60 | + /** The block number at which the contract was deployed. */ |
| 61 | + block?: number; |
| 62 | + /** The ID of the chain the contract is deployed on. */ |
| 63 | + chainId: number; |
| 64 | + /** URL to the explorer page for the contract. */ |
| 65 | + explorerURL?: string; |
| 66 | + /** The name of the contract. */ |
| 67 | + name: string; |
| 68 | + /** The protocol the contract is part of (optional). */ |
| 69 | + protocol: EVM.Protocol | undefined; |
| 70 | + /** The release version the contract is part of (optional). */ |
| 71 | + version: EVM.Version | undefined; |
| 72 | + }; |
| 73 | + |
| 74 | + /** |
| 75 | + * Reverse mapping of contracts so that we can look up contracts by address. |
| 76 | + */ |
| 77 | + export type ContractCatalog = { |
| 78 | + [protocol in Protocol]: { |
| 79 | + [chainId: number]: { |
| 80 | + [address: Address]: Contract; |
| 81 | + }; |
| 82 | + }; |
| 83 | + }; |
| 84 | + |
| 85 | + /** @internal */ |
| 86 | + export type ContractMap = { |
| 87 | + [contractName: string]: Address | [Address, number]; |
| 88 | + }; |
| 89 | + |
| 90 | + export type Protocol = `${enums.Protocol}` | enums.Protocol; |
| 91 | + |
| 92 | + export type CompilerSettings = { |
| 93 | + /** The EVM version such as shanghai, paris, etc. */ |
| 94 | + evmVersion: string; |
| 95 | + /** Whether the optimizer is enabled. */ |
| 96 | + optimizer: boolean; |
| 97 | + /** The number of optimizer runs. */ |
| 98 | + optimizerRuns: number; |
| 99 | + /** Optional salt used for CREATE2 deployment. None implies deployment using CREATE. */ |
| 100 | + salt?: string; |
| 101 | + /** The solc version used. */ |
| 102 | + solcVersion: `v${number}.${number}.${number}`; |
| 103 | + /** Whether the IR is used. */ |
| 104 | + viaIR: boolean; |
| 105 | + /** Optional zk version used, only valid for zkEVM chains. */ |
| 106 | + zkVersion?: `v${number}.${number}.${number}`; |
| 107 | + }; |
| 108 | + |
| 109 | + /* -------------------------------------------------------------------------- */ |
| 110 | + /* DEPLOYMENT */ |
| 111 | + /* -------------------------------------------------------------------------- */ |
| 112 | + |
| 113 | + export namespace Deployment { |
| 114 | + export type Standard = { |
| 115 | + chainId: number; |
| 116 | + contracts: Contract[]; |
| 117 | + /** TODO: Compiler settings for the contract. Not implemented yet. */ |
| 118 | + compilerSettings?: CompilerSettings; |
| 119 | + }; |
| 120 | + |
| 121 | + export type LockupV1 = Standard & { |
| 122 | + core: Contract[]; |
| 123 | + periphery: Contract[]; |
| 124 | + }; |
| 125 | + } |
| 126 | + |
| 127 | + export type Deployment = Deployment.Standard | Deployment.LockupV1; |
| 128 | + |
| 129 | + /* -------------------------------------------------------------------------- */ |
| 130 | + /* MANIFEST */ |
| 131 | + /* -------------------------------------------------------------------------- */ |
| 132 | + |
| 133 | + /** |
| 134 | + * Contract names for a given protocol and version. |
| 135 | + * Note that this may contain both deployed contracts and abstract contracts that are not deployed. |
| 136 | + */ |
| 137 | + export namespace Manifest { |
| 138 | + export type LockupV1 = { |
| 139 | + core: Standard; |
| 140 | + periphery: Standard; |
| 141 | + }; |
| 142 | + |
| 143 | + export type Standard = { |
| 144 | + [contractKey: string]: string; |
| 145 | + }; |
| 146 | + } |
| 147 | + |
| 148 | + export type Manifest = Manifest.LockupV1 | Manifest.Standard; |
| 149 | + |
| 150 | + /* -------------------------------------------------------------------------- */ |
| 151 | + /* RELEASE */ |
| 152 | + /* -------------------------------------------------------------------------- */ |
| 153 | + |
| 154 | + /** |
| 155 | + * A collection of deployments for a given protocol and version. |
| 156 | + */ |
| 157 | + export namespace Release { |
| 158 | + type Common = { |
| 159 | + abi: AbiMap; |
| 160 | + /** A map of contract names to their aliases, used in the Sablier Interface and the Graph. */ |
| 161 | + aliases?: AliasMap; |
| 162 | + /** An array of contract names. */ |
| 163 | + contractNames: string[]; |
| 164 | + /** Whether this is the latest release for this protocol. */ |
| 165 | + isLatest: boolean; |
| 166 | + /** The kind of release. */ |
| 167 | + kind: "standard" | "lockupV1"; |
| 168 | + /** The Sablier protocol released, e.g. `airdrops`. */ |
| 169 | + protocol: Protocol; |
| 170 | + /** Repository information for the release. */ |
| 171 | + repository?: Repository; |
| 172 | + /** The version of the release, e.g., `v1.3`. */ |
| 173 | + version: Version; |
| 174 | + }; |
| 175 | + |
| 176 | + /** |
| 177 | + * Lockup v1.x release used to separate Lockup contracts into core and periphery sub-categories. |
| 178 | + * @see https://github.com/sablier-labs/v2-periphery |
| 179 | + */ |
| 180 | + export type LockupV1 = Common & { |
| 181 | + deployments: Deployment.LockupV1[]; |
| 182 | + kind: "lockupV1"; |
| 183 | + manifest: Manifest.LockupV1; |
| 184 | + }; |
| 185 | + |
| 186 | + export type Standard = Common & { |
| 187 | + deployments: Deployment.Standard[]; |
| 188 | + kind: "standard"; |
| 189 | + manifest: Manifest.Standard; |
| 190 | + }; |
| 191 | + } |
| 192 | + |
| 193 | + export type Release = Release.Standard | Release.LockupV1; |
| 194 | + |
| 195 | + /* -------------------------------------------------------------------------- */ |
| 196 | + /* VERSION */ |
| 197 | + /* -------------------------------------------------------------------------- */ |
| 198 | + |
| 199 | + export namespace Version { |
| 200 | + export type Airdrops = `${enums.Version.Airdrops}` | enums.Version.Airdrops; |
| 201 | + |
| 202 | + export type Flow = `${enums.Version.Flow}` | enums.Version.Flow; |
| 203 | + |
| 204 | + export type Legacy = `${enums.Version.Legacy}` | enums.Version.Legacy; |
| 205 | + |
| 206 | + export type Lockup = `${enums.Version.Lockup}` | enums.Version.Lockup; |
| 207 | + } |
| 208 | + export type Version = Version.Airdrops | Version.Flow | Version.Legacy | Version.Lockup; |
| 209 | +} |
0 commit comments