-
Notifications
You must be signed in to change notification settings - Fork 261
/
types.ts
90 lines (72 loc) · 3.04 KB
/
types.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
export type AddressType = 'canonical' | 'eip155' | 'zksync';
export const enum DeploymentFormats {
// The old format that only allows a single address for each network.
SINGLETON = 'singleton',
// The new format that allows multiple addresses for each network.
MULTIPLE = 'multiple',
}
type AtLeastOne<T, U = { [K in keyof T]: Pick<T, K> }> = Partial<T> & U[keyof U];
export interface SingletonDeploymentJSON {
// Indicates if the deployment is released.
released: boolean;
// The name of the contract.
contractName: string;
// The version of the deployment.
version: string;
// The address & hash of the contract code, where the key is the deployment type.
// There could be multiple deployment types: canonical, eip155, zksync
// Possible addresses per version:
// 1.0.0: canonical
// 1.1.1: canonical
// 1.2.0: canonical
// 1.3.0: canonical, eip155, zksync
// 1.4.1: canonical, zksync
// Ex: deployments: { "canonical": { "codeHash": "0x1234", "address": "0x5678"}}
deployments: AtLeastOne<Record<AddressType, { address: string; codeHash: string }>>;
// A record of network addresses, where the key is the network identifier and the value is either a single address type or an array of address types.
networkAddresses: Record<string, AddressType | AddressType[]>;
// The ABI (Application Binary Interface) of the contract.
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
abi: any[];
}
// This is the old type that only allows a single address for each network.
// It is still used for backwards compatibility.
export interface SingletonDeployment {
// The default address of the deployment.
defaultAddress: string;
// Indicates if the deployment is released.
released: boolean;
// The name of the contract.
contractName: string;
// The version of the deployment.
version: string;
// The address & hash of the contract code, where the key is the deployment type.
// There could be multiple deployment types: canonical, eip155, zksync
// Possible addresses per version:
// 1.0.0: canonical
// 1.1.1: canonical
// 1.2.0: canonical
// 1.3.0: canonical, eip155, zksync
// 1.4.1: canonical, zksync
// Ex: deployments: { "canonical": { "codeHash": "0x1234", "address": "0x5678"}}
deployments: AtLeastOne<Record<AddressType, { address: string; codeHash: string }>>;
// A record of network addresses, where the key is the network identifier and the value is the address.
networkAddresses: Record<string, string>;
// The ABI (Application Binary Interface) of the contract.
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
abi: any[];
}
export interface SingletonDeploymentV2 {
released: boolean;
contractName: string;
version: string;
deployments: AtLeastOne<Record<AddressType, { address: string; codeHash: string }>>;
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
abi: any[];
networkAddresses: Record<string, string | string[]>;
}
export interface DeploymentFilter {
version?: string;
released?: boolean;
network?: string;
}