1
1
import { Signer , BigNumberish , BaseContract , ethers } from "ethers" ;
2
2
import { AddressZero } from "@ethersproject/constants" ;
3
3
import { Safe } from "../../typechain-types" ;
4
+ import { PayableOverrides } from "../../typechain-types/common" ;
4
5
5
6
export const EIP_DOMAIN = {
6
7
EIP712Domain : [
@@ -175,15 +176,27 @@ export const buildSignatureBytes = (signatures: SafeSignature[]): string => {
175
176
return signatureBytes + dynamicBytes ;
176
177
} ;
177
178
178
- export const logGas = async ( message : string , tx : Promise < any > , skip ?: boolean ) : Promise < any > => {
179
+ export const logGas = async (
180
+ message : string ,
181
+ tx : Promise < ethers . TransactionResponse > ,
182
+ skip ?: boolean ,
183
+ ) : Promise < ethers . TransactionResponse > => {
179
184
return tx . then ( async ( result ) => {
180
185
const receipt = await result . wait ( ) ;
186
+ if ( receipt === null ) {
187
+ throw new Error ( "transaction not mined" ) ;
188
+ }
181
189
if ( ! skip ) console . log ( " Used" , receipt . gasUsed , `gas for >${ message } <` ) ;
182
190
return result ;
183
191
} ) ;
184
192
} ;
185
193
186
- export const executeTx = async ( safe : Safe , safeTx : SafeTransaction , signatures : SafeSignature [ ] , overrides ?: any ) : Promise < any > => {
194
+ export const executeTx = async (
195
+ safe : Safe ,
196
+ safeTx : SafeTransaction ,
197
+ signatures : SafeSignature [ ] ,
198
+ overrides ?: PayableOverrides ,
199
+ ) : Promise < ethers . ContractTransactionResponse > => {
187
200
const signatureBytes = buildSignatureBytes ( signatures ) ;
188
201
return safe . execTransaction (
189
202
safeTx . to ,
@@ -203,7 +216,7 @@ export const executeTx = async (safe: Safe, safeTx: SafeTransaction, signatures:
203
216
export const buildContractCall = async (
204
217
contract : BaseContract ,
205
218
method : string ,
206
- params : any [ ] ,
219
+ params : unknown [ ] ,
207
220
nonce : BigNumberish ,
208
221
delegateCall ?: boolean ,
209
222
overrides ?: Partial < SafeTransaction > ,
@@ -224,7 +237,7 @@ export const buildContractCall = async (
224
237
) ;
225
238
} ;
226
239
227
- export const executeTxWithSigners = async ( safe : Safe , tx : SafeTransaction , signers : Signer [ ] , overrides ?: any ) => {
240
+ export const executeTxWithSigners = async ( safe : Safe , tx : SafeTransaction , signers : Signer [ ] , overrides ?: PayableOverrides ) => {
228
241
const safeAddress = await safe . getAddress ( ) ;
229
242
const sigs = await Promise . all ( signers . map ( ( signer ) => safeSignTypedData ( signer , safeAddress , tx ) ) ) ;
230
243
return executeTx ( safe , tx , sigs , overrides ) ;
@@ -234,7 +247,7 @@ export const executeContractCallWithSigners = async (
234
247
safe : Safe ,
235
248
contract : BaseContract ,
236
249
method : string ,
237
- params : any [ ] ,
250
+ params : unknown [ ] ,
238
251
signers : Signer [ ] ,
239
252
delegateCall ?: boolean ,
240
253
overrides ?: Partial < SafeTransaction > ,
0 commit comments