|
9 | 9 | "github.com/ethereum/go-ethereum/core/types"
|
10 | 10 | "github.com/ethereum/go-ethereum/crypto"
|
11 | 11 | "github.com/spf13/cobra"
|
| 12 | + "github.com/tranvictor/walletarmy" |
12 | 13 |
|
13 | 14 | "github.com/tranvictor/jarvis/accounts"
|
14 | 15 | jtypes "github.com/tranvictor/jarvis/accounts/types"
|
@@ -266,7 +267,7 @@ var batchApproveMsigCmd = &cobra.Command{
|
266 | 267 | Short: "Approve multiple gnosis transactions",
|
267 | 268 | Long: `This command only works with list of init transactions as the first param`,
|
268 | 269 | Run: func(cmd *cobra.Command, args []string) {
|
269 |
| - cm := cmdutil.NewContextManager() |
| 270 | + cm := walletarmy.NewWalletManager() |
270 | 271 | a := util.GetGnosisMsigABI()
|
271 | 272 | // get networks and txs from params
|
272 | 273 | networks, txs := cmdutil.ScanForTxs(args[0])
|
@@ -357,46 +358,54 @@ var batchApproveMsigCmd = &cobra.Command{
|
357 | 358 | fmt.Printf("We are doing legacy tx hence we ignore tip gas parameter.\n")
|
358 | 359 | }
|
359 | 360 |
|
360 |
| - tx, err := cm.BuildTx( |
| 361 | + minedTx, err := cm.EnsureTxWithHooks( |
361 | 362 | txType,
|
362 |
| - jarviscommon.HexToAddress(from), jarviscommon.HexToAddress(msigHex), |
363 |
| - nil, |
364 |
| - big.NewInt(0), |
365 |
| - 0, |
366 |
| - 0, |
367 |
| - 0, |
| 363 | + jarviscommon.HexToAddress(from), jarviscommon.HexToAddress(msigHex), // from, to |
| 364 | + nil, // value |
| 365 | + 0, // gasLimit |
| 366 | + 0, // gasPrice |
| 367 | + 0, // tipCap |
368 | 368 | data,
|
369 | 369 | network,
|
| 370 | + func(tx *types.Transaction, buildError error) error { // before signing and broadcasting hook |
| 371 | + if buildError != nil { |
| 372 | + fmt.Printf("Couldn't build tx: %s\n", buildError) |
| 373 | + return buildError |
| 374 | + } |
| 375 | + |
| 376 | + // prompt user to confirm the tx |
| 377 | + err = cmdutil.PromptTxConfirmation( |
| 378 | + cm.Analyzer(network), |
| 379 | + util.GetJarvisAddress(from, network), |
| 380 | + tx, |
| 381 | + nil, |
| 382 | + network, |
| 383 | + ) |
| 384 | + if err != nil { |
| 385 | + fmt.Printf("Skip this tx. Continue with next tx.\n") |
| 386 | + return fmt.Errorf("user aborted: %w", err) |
| 387 | + } |
| 388 | + return nil |
| 389 | + }, |
| 390 | + func(broadcastedTx *types.Transaction, signError error) error { // after signing hook |
| 391 | + if signError != nil { |
| 392 | + return signError |
| 393 | + } |
| 394 | + |
| 395 | + if config.DontWaitToBeMined { |
| 396 | + util.DisplayBroadcastedTx( |
| 397 | + broadcastedTx, true, signError, network, |
| 398 | + ) |
| 399 | + return fmt.Errorf("user aborted: %w", signError) |
| 400 | + } |
| 401 | + return nil |
| 402 | + }, |
370 | 403 | )
|
371 |
| - if err != nil { |
372 |
| - fmt.Printf("Couldn't build tx: %s\n", err) |
373 |
| - continue |
374 |
| - } |
375 | 404 |
|
376 |
| - err = cmdutil.PromptTxConfirmation( |
377 |
| - cm.Analyzer(network), |
378 |
| - util.GetJarvisAddress(from, network), |
379 |
| - tx, |
380 |
| - nil, |
381 |
| - network, |
| 405 | + util.DisplayWaitAnalyze( |
| 406 | + cm.Reader(network), cm.Analyzer(network), minedTx, true, nil, network, |
| 407 | + a, nil, config.DegenMode, |
382 | 408 | )
|
383 |
| - if err != nil { |
384 |
| - fmt.Printf("Skip this tx. Continue with next tx.\n") |
385 |
| - continue |
386 |
| - } |
387 |
| - |
388 |
| - signedTx, broadcasted, err := cm.SignTxAndBroadcast(jarviscommon.HexToAddress(from), tx, network) |
389 |
| - |
390 |
| - if config.DontWaitToBeMined { |
391 |
| - util.DisplayBroadcastedTx( |
392 |
| - signedTx, broadcasted, err, network, |
393 |
| - ) |
394 |
| - } else { |
395 |
| - util.DisplayWaitAnalyze( |
396 |
| - cm.Reader(network), cm.Analyzer(network), signedTx, broadcasted, err, network, |
397 |
| - a, nil, config.DegenMode, |
398 |
| - ) |
399 |
| - } |
400 | 409 | }
|
401 | 410 | },
|
402 | 411 | }
|
|
0 commit comments