-
Notifications
You must be signed in to change notification settings - Fork 173
/
config.ts
125 lines (114 loc) · 3.7 KB
/
config.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
import {
DeploymentFilter,
SingletonDeployment,
getCompatibilityFallbackHandlerDeployment,
getCreateCallDeployment,
getMultiSendCallOnlyDeployment,
getMultiSendDeployment,
getProxyFactoryDeployment,
getSafeL2SingletonDeployment,
getSafeSingletonDeployment,
getSignMessageLibDeployment,
getSimulateTxAccessorDeployment
} from '@safe-global/safe-deployments'
import { SafeVersion } from '@safe-global/safe-core-sdk-types'
export const DEFAULT_SAFE_VERSION: SafeVersion = '1.3.0'
export const SAFE_BASE_VERSION: SafeVersion = '1.0.0'
type contractNames = {
safeSingletonVersion: string
safeSingletonL2Version?: string
safeProxyFactoryVersion: string
compatibilityFallbackHandler: string
multiSendVersion: string
multiSendCallOnlyVersion?: string
signMessageLibVersion?: string
createCallVersion?: string
simulateTxAccessorVersion?: string
}
type SafeDeploymentsVersions = Record<SafeVersion, contractNames>
export type contractName = keyof contractNames
export const safeDeploymentsVersions: SafeDeploymentsVersions = {
'1.4.1': {
safeSingletonVersion: '1.4.1',
safeSingletonL2Version: '1.4.1',
safeProxyFactoryVersion: '1.4.1',
compatibilityFallbackHandler: '1.4.1',
multiSendVersion: '1.4.1',
multiSendCallOnlyVersion: '1.4.1',
signMessageLibVersion: '1.4.1',
createCallVersion: '1.4.1',
simulateTxAccessorVersion: '1.4.1'
},
'1.3.0': {
safeSingletonVersion: '1.3.0',
safeSingletonL2Version: '1.3.0',
safeProxyFactoryVersion: '1.3.0',
compatibilityFallbackHandler: '1.3.0',
multiSendVersion: '1.3.0',
multiSendCallOnlyVersion: '1.3.0',
signMessageLibVersion: '1.3.0',
createCallVersion: '1.3.0',
simulateTxAccessorVersion: '1.3.0'
},
'1.2.0': {
safeSingletonVersion: '1.2.0',
safeSingletonL2Version: undefined,
safeProxyFactoryVersion: '1.1.1',
compatibilityFallbackHandler: '1.3.0',
multiSendVersion: '1.1.1',
multiSendCallOnlyVersion: '1.3.0',
signMessageLibVersion: '1.3.0',
createCallVersion: '1.3.0'
},
'1.1.1': {
safeSingletonVersion: '1.1.1',
safeSingletonL2Version: undefined,
safeProxyFactoryVersion: '1.1.1',
compatibilityFallbackHandler: '1.3.0',
multiSendVersion: '1.1.1',
multiSendCallOnlyVersion: '1.3.0',
signMessageLibVersion: '1.3.0',
createCallVersion: '1.3.0'
},
'1.0.0': {
safeSingletonVersion: '1.0.0',
safeSingletonL2Version: undefined,
safeProxyFactoryVersion: '1.0.0',
compatibilityFallbackHandler: '1.3.0',
multiSendVersion: '1.1.1',
multiSendCallOnlyVersion: '1.3.0',
signMessageLibVersion: '1.3.0',
createCallVersion: '1.3.0'
}
}
export const safeDeploymentsL1ChainIds = [
1n // Ethereum Mainnet
]
const contractFunctions: Record<
contractName,
(filter?: DeploymentFilter) => SingletonDeployment | undefined
> = {
safeSingletonVersion: getSafeSingletonDeployment,
safeSingletonL2Version: getSafeL2SingletonDeployment,
safeProxyFactoryVersion: getProxyFactoryDeployment,
compatibilityFallbackHandler: getCompatibilityFallbackHandlerDeployment,
multiSendVersion: getMultiSendDeployment,
multiSendCallOnlyVersion: getMultiSendCallOnlyDeployment,
signMessageLibVersion: getSignMessageLibDeployment,
createCallVersion: getCreateCallDeployment,
simulateTxAccessorVersion: getSimulateTxAccessorDeployment
}
export function getContractDeployment(
safeVersion: SafeVersion,
chainId: bigint,
contractName: contractName
) {
const contractVersion = safeDeploymentsVersions[safeVersion][contractName]
const filters: DeploymentFilter = {
version: contractVersion,
network: chainId.toString(),
released: true
}
const deployment = contractFunctions[contractName](filters)
return deployment
}