Skip to content

Commit 8c02942

Browse files
committed
using wallet army instead of context manager
1 parent 4b1c25a commit 8c02942

9 files changed

+201
-700
lines changed

Diff for: cmd/info.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ var txCmd = &cobra.Command{
5858
config.DegenMode,
5959
)
6060
results[t] = r
61-
fmt.Printf("----------------------------------------------------------\n")
61+
fmt.Printf("\n----------------------------------------------------------\n")
6262
}
6363
}
6464
},

Diff for: cmd/msig.go

+44-35
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/ethereum/go-ethereum/core/types"
1010
"github.com/ethereum/go-ethereum/crypto"
1111
"github.com/spf13/cobra"
12+
"github.com/tranvictor/walletarmy"
1213

1314
"github.com/tranvictor/jarvis/accounts"
1415
jtypes "github.com/tranvictor/jarvis/accounts/types"
@@ -266,7 +267,7 @@ var batchApproveMsigCmd = &cobra.Command{
266267
Short: "Approve multiple gnosis transactions",
267268
Long: `This command only works with list of init transactions as the first param`,
268269
Run: func(cmd *cobra.Command, args []string) {
269-
cm := cmdutil.NewContextManager()
270+
cm := walletarmy.NewWalletManager()
270271
a := util.GetGnosisMsigABI()
271272
// get networks and txs from params
272273
networks, txs := cmdutil.ScanForTxs(args[0])
@@ -357,46 +358,54 @@ var batchApproveMsigCmd = &cobra.Command{
357358
fmt.Printf("We are doing legacy tx hence we ignore tip gas parameter.\n")
358359
}
359360

360-
tx, err := cm.BuildTx(
361+
minedTx, err := cm.EnsureTxWithHooks(
361362
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
368368
data,
369369
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+
},
370403
)
371-
if err != nil {
372-
fmt.Printf("Couldn't build tx: %s\n", err)
373-
continue
374-
}
375404

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,
382408
)
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-
}
400409
}
401410
},
402411
}

0 commit comments

Comments
 (0)