1
1
import { DeployFunction } from "hardhat-deploy/types" ;
2
2
import { Address , encodeAbiParameters , encodeFunctionData , Hash , parseAbiParameters , zeroAddress } from "viem" ;
3
3
4
- import { logTransaction } from "../chainDeploy/helpers/logging" ;
4
+ import { prepareAndLogTransaction } from "../chainDeploy/helpers/logging" ;
5
5
6
6
const func : DeployFunction = async ( { viem, getNamedAccounts, deployments } ) => {
7
7
const { deployer, multisig } = await getNamedAccounts ( ) ;
8
8
const publicClient = await viem . getPublicClient ( ) ;
9
+ const walletClient = await viem . getWalletClient ( deployer as Address ) ;
9
10
10
11
const fuseFeeDistributor = await viem . getContractAt (
11
12
"FeeDistributor" ,
@@ -64,14 +65,17 @@ const func: DeployFunction = async ({ viem, getNamedAccounts, deployments }) =>
64
65
const erc20DelExtensions = await fuseFeeDistributor . read . getCErc20DelegateExtensions ( [ erc20Del . address as Address ] ) ;
65
66
if ( erc20DelExtensions . length == 0 || erc20DelExtensions [ 0 ] != erc20Del . address ) {
66
67
if ( ( await fuseFeeDistributor . read . owner ( ) ) . toLowerCase ( ) !== deployer . toLowerCase ( ) ) {
67
- logTransaction (
68
- "Set CErc20Delegate Extensions" ,
69
- encodeFunctionData ( {
70
- abi : fuseFeeDistributor . abi ,
71
- functionName : "_setCErc20DelegateExtensions" ,
72
- args : [ erc20Del . address as Address , [ erc20Del . address as Address , cTokenFirstExtension . address as Address ] ]
73
- } )
74
- ) ;
68
+ await prepareAndLogTransaction ( {
69
+ contractInstance : fuseFeeDistributor ,
70
+ functionName : "_setCErc20DelegateExtensions" ,
71
+ args : [ erc20Del . address as Address , [ erc20Del . address as Address , cTokenFirstExtension . address as Address ] ] ,
72
+ description : "Set CErc20Delegate Extensions" ,
73
+ walletClient,
74
+ inputs : [
75
+ { internalType : "address" , name : "cErc20Delegate" , type : "address" } ,
76
+ { internalType : "address[]" , name : "extensions" , type : "address[]" }
77
+ ]
78
+ } ) ;
75
79
} else {
76
80
tx = await fuseFeeDistributor . write . _setCErc20DelegateExtensions ( [
77
81
erc20Del . address as Address ,
@@ -86,14 +90,18 @@ const func: DeployFunction = async ({ viem, getNamedAccounts, deployments }) =>
86
90
const [ latestCErc20Delegate ] = await fuseFeeDistributor . read . latestCErc20Delegate ( [ 1 ] ) ;
87
91
if ( latestCErc20Delegate === zeroAddress || latestCErc20Delegate !== erc20Del . address ) {
88
92
if ( multisig && ( await fuseFeeDistributor . read . owner ( ) ) . toLowerCase ( ) !== deployer . toLowerCase ( ) ) {
89
- logTransaction (
90
- "Set Latest CErc20Delegate" ,
91
- encodeFunctionData ( {
92
- abi : fuseFeeDistributor . abi ,
93
- functionName : "_setLatestCErc20Delegate" ,
94
- args : [ 1 , erc20Del . address as Address , becomeImplementationData ]
95
- } )
96
- ) ;
93
+ await prepareAndLogTransaction ( {
94
+ contractInstance : fuseFeeDistributor ,
95
+ functionName : "_setLatestCErc20Delegate" ,
96
+ args : [ 1 , erc20Del . address as Address , becomeImplementationData ] ,
97
+ description : "Set Latest CErc20Delegate" ,
98
+ walletClient,
99
+ inputs : [
100
+ { internalType : "uint8" , name : "delegateType" , type : "uint8" } ,
101
+ { internalType : "address" , name : "newImplementation" , type : "address" } ,
102
+ { internalType : "bytes" , name : "becomeImplementationData" , type : "bytes" }
103
+ ]
104
+ } ) ;
97
105
} else {
98
106
tx = await fuseFeeDistributor . write . _setLatestCErc20Delegate ( [
99
107
1 ,
@@ -115,17 +123,20 @@ const func: DeployFunction = async ({ viem, getNamedAccounts, deployments }) =>
115
123
] ) ;
116
124
if ( erc20PluginDelExtensions . length == 0 || erc20PluginDelExtensions [ 0 ] != erc20PluginDel . address ) {
117
125
if ( multisig && ( await fuseFeeDistributor . read . owner ( ) ) . toLowerCase ( ) !== deployer . toLowerCase ( ) ) {
118
- logTransaction (
119
- "Set CErc20PluginDelegate Extensions" ,
120
- encodeFunctionData ( {
121
- abi : fuseFeeDistributor . abi ,
122
- functionName : "_setCErc20DelegateExtensions" ,
123
- args : [
124
- erc20PluginDel . address as Address ,
125
- [ erc20PluginDel . address as Address , cTokenFirstExtension . address as Address ]
126
- ]
127
- } )
128
- ) ;
126
+ await prepareAndLogTransaction ( {
127
+ contractInstance : fuseFeeDistributor ,
128
+ functionName : "_setCErc20DelegateExtensions" ,
129
+ args : [
130
+ erc20PluginDel . address as Address ,
131
+ [ erc20PluginDel . address as Address , cTokenFirstExtension . address as Address ]
132
+ ] ,
133
+ description : "Set CErc20PluginDelegate Extensions" ,
134
+ walletClient,
135
+ inputs : [
136
+ { internalType : "address" , name : "cErc20Delegate" , type : "address" } ,
137
+ { internalType : "address[]" , name : "extensions" , type : "address[]" }
138
+ ]
139
+ } ) ;
129
140
} else {
130
141
tx = await fuseFeeDistributor . write . _setCErc20DelegateExtensions ( [
131
142
erc20PluginDel . address as Address ,
@@ -141,14 +152,18 @@ const func: DeployFunction = async ({ viem, getNamedAccounts, deployments }) =>
141
152
const [ latestCErc20PluginDelegate ] = await fuseFeeDistributor . read . latestCErc20Delegate ( [ 2 ] ) ;
142
153
if ( latestCErc20PluginDelegate === zeroAddress || latestCErc20PluginDelegate !== erc20PluginDel . address ) {
143
154
if ( multisig && ( await fuseFeeDistributor . read . owner ( ) ) . toLowerCase ( ) !== deployer . toLowerCase ( ) ) {
144
- logTransaction (
145
- "Set Latest CErc20PluginDelegate" ,
146
- encodeFunctionData ( {
147
- abi : fuseFeeDistributor . abi ,
148
- functionName : "_setLatestCErc20Delegate" ,
149
- args : [ 2 , erc20PluginDel . address as Address , becomeImplementationData ]
150
- } )
151
- ) ;
155
+ await prepareAndLogTransaction ( {
156
+ contractInstance : fuseFeeDistributor ,
157
+ functionName : "_setLatestCErc20Delegate" ,
158
+ args : [ 2 , erc20PluginDel . address as Address , becomeImplementationData ] ,
159
+ description : "Set Latest CErc20PluginDelegate" ,
160
+ walletClient,
161
+ inputs : [
162
+ { internalType : "uint8" , name : "delegateType" , type : "uint8" } ,
163
+ { internalType : "address" , name : "newImplementation" , type : "address" } ,
164
+ { internalType : "bytes" , name : "becomeImplementationData" , type : "bytes" }
165
+ ]
166
+ } ) ;
152
167
} else {
153
168
tx = await fuseFeeDistributor . write . _setLatestCErc20Delegate ( [
154
169
2 ,
@@ -172,17 +187,20 @@ const func: DeployFunction = async ({ viem, getNamedAccounts, deployments }) =>
172
187
] ) ;
173
188
if ( erc20RewardsDelExtensions . length == 0 || erc20RewardsDelExtensions [ 0 ] != erc20RewardsDel . address ) {
174
189
if ( ( await fuseFeeDistributor . read . owner ( ) ) . toLowerCase ( ) !== deployer . toLowerCase ( ) ) {
175
- logTransaction (
176
- "Set CErc20RewardsDelegate Extensions" ,
177
- encodeFunctionData ( {
178
- abi : fuseFeeDistributor . abi ,
179
- functionName : "_setCErc20DelegateExtensions" ,
180
- args : [
181
- erc20RewardsDel . address as Address ,
182
- [ erc20RewardsDel . address as Address , cTokenFirstExtension . address as Address ]
183
- ]
184
- } )
185
- ) ;
190
+ await prepareAndLogTransaction ( {
191
+ contractInstance : fuseFeeDistributor ,
192
+ functionName : "_setCErc20DelegateExtensions" ,
193
+ args : [
194
+ erc20RewardsDel . address as Address ,
195
+ [ erc20RewardsDel . address as Address , cTokenFirstExtension . address as Address ]
196
+ ] ,
197
+ description : "Set CErc20RewardsDelegate Extensions" ,
198
+ walletClient,
199
+ inputs : [
200
+ { internalType : "address" , name : "cErc20Delegate" , type : "address" } ,
201
+ { internalType : "address[]" , name : "extensions" , type : "address[]" }
202
+ ]
203
+ } ) ;
186
204
} else {
187
205
tx = await fuseFeeDistributor . write . _setCErc20DelegateExtensions ( [
188
206
erc20RewardsDel . address as Address ,
@@ -197,14 +215,18 @@ const func: DeployFunction = async ({ viem, getNamedAccounts, deployments }) =>
197
215
const [ latestCErc20RewardsDelegate ] = await fuseFeeDistributor . read . latestCErc20Delegate ( [ 3 ] ) ;
198
216
if ( latestCErc20RewardsDelegate === zeroAddress || latestCErc20RewardsDelegate !== erc20RewardsDel . address ) {
199
217
if ( ( await fuseFeeDistributor . read . owner ( ) ) . toLowerCase ( ) !== deployer . toLowerCase ( ) ) {
200
- logTransaction (
201
- "Set Latest CErc20RewardsDelegate" ,
202
- encodeFunctionData ( {
203
- abi : fuseFeeDistributor . abi ,
204
- functionName : "_setLatestCErc20Delegate" ,
205
- args : [ 3 , erc20RewardsDel . address as Address , becomeImplementationData ]
206
- } )
207
- ) ;
218
+ await prepareAndLogTransaction ( {
219
+ contractInstance : fuseFeeDistributor ,
220
+ functionName : "_setLatestCErc20Delegate" ,
221
+ args : [ 3 , erc20RewardsDel . address as Address , becomeImplementationData ] ,
222
+ description : "Set Latest CErc20RewardsDelegate" ,
223
+ walletClient,
224
+ inputs : [
225
+ { internalType : "uint8" , name : "delegateType" , type : "uint8" } ,
226
+ { internalType : "address" , name : "newImplementation" , type : "address" } ,
227
+ { internalType : "bytes" , name : "becomeImplementationData" , type : "bytes" }
228
+ ]
229
+ } ) ;
208
230
} else {
209
231
tx = await fuseFeeDistributor . write . _setLatestCErc20Delegate ( [
210
232
3 ,
@@ -231,17 +253,20 @@ const func: DeployFunction = async ({ viem, getNamedAccounts, deployments }) =>
231
253
erc20PluginRewardsDelExtensions [ 0 ] != erc20PluginRewardsDel . address
232
254
) {
233
255
if ( ( await fuseFeeDistributor . read . owner ( ) ) . toLowerCase ( ) !== deployer . toLowerCase ( ) ) {
234
- logTransaction (
235
- "Set CErc20PluginRewardsDelegate Extensions" ,
236
- encodeFunctionData ( {
237
- abi : fuseFeeDistributor . abi ,
238
- functionName : "_setCErc20DelegateExtensions" ,
239
- args : [
240
- erc20PluginRewardsDel . address as Address ,
241
- [ erc20PluginRewardsDel . address as Address , cTokenFirstExtension . address as Address ]
242
- ]
243
- } )
244
- ) ;
256
+ await prepareAndLogTransaction ( {
257
+ contractInstance : fuseFeeDistributor ,
258
+ functionName : "_setCErc20DelegateExtensions" ,
259
+ args : [
260
+ erc20PluginRewardsDel . address as Address ,
261
+ [ erc20PluginRewardsDel . address as Address , cTokenFirstExtension . address as Address ]
262
+ ] ,
263
+ description : "Set CErc20PluginRewardsDelegate Extensions" ,
264
+ walletClient,
265
+ inputs : [
266
+ { internalType : "address" , name : "cErc20Delegate" , type : "address" } ,
267
+ { internalType : "address[]" , name : "extensions" , type : "address[]" }
268
+ ]
269
+ } ) ;
245
270
} else {
246
271
tx = await fuseFeeDistributor . write . _setCErc20DelegateExtensions ( [
247
272
erc20PluginRewardsDel . address as Address ,
@@ -259,14 +284,18 @@ const func: DeployFunction = async ({ viem, getNamedAccounts, deployments }) =>
259
284
latestCErc20PluginRewardsDelegate !== erc20PluginRewardsDel . address
260
285
) {
261
286
if ( ( await fuseFeeDistributor . read . owner ( ) ) . toLowerCase ( ) !== deployer . toLowerCase ( ) ) {
262
- logTransaction (
263
- "Set Latest CErc20PluginRewardsDelegate" ,
264
- encodeFunctionData ( {
265
- abi : fuseFeeDistributor . abi ,
266
- functionName : "_setLatestCErc20Delegate" ,
267
- args : [ 4 , erc20PluginRewardsDel . address as Address , becomeImplementationData ]
268
- } )
269
- ) ;
287
+ await prepareAndLogTransaction ( {
288
+ contractInstance : fuseFeeDistributor ,
289
+ functionName : "_setLatestCErc20Delegate" ,
290
+ args : [ 4 , erc20PluginRewardsDel . address as Address , becomeImplementationData ] ,
291
+ description : "Set Latest CErc20PluginRewardsDelegate" ,
292
+ walletClient,
293
+ inputs : [
294
+ { internalType : "uint8" , name : "delegateType" , type : "uint8" } ,
295
+ { internalType : "address" , name : "newImplementation" , type : "address" } ,
296
+ { internalType : "bytes" , name : "becomeImplementationData" , type : "bytes" }
297
+ ]
298
+ } ) ;
270
299
} else {
271
300
tx = await fuseFeeDistributor . write . _setLatestCErc20Delegate ( [
272
301
4 ,
0 commit comments