diff --git a/cmd_confirm.go b/cmd_confirm.go index 565dfac..43b6b18 100644 --- a/cmd_confirm.go +++ b/cmd_confirm.go @@ -29,6 +29,6 @@ func (cmd *cmdConfirm) Execute(ctx context.Context) error { } fmt.Fprintln(clingy.Stdout(ctx)) - printTransactionStatus(ctx, client, transactor.Caller, cmd.transactionID) + printTransactionStatus(ctx, client, cmd.transactor.client.nicknames, transactor.Caller, cmd.transactionID) return nil } diff --git a/cmd_execute.go b/cmd_execute.go index 8968402..1ddf775 100644 --- a/cmd_execute.go +++ b/cmd_execute.go @@ -29,5 +29,5 @@ func (cmd *cmdExecute) Execute(ctx context.Context) error { } fmt.Fprintln(clingy.Stdout(ctx)) - return printTransactionStatus(ctx, client, transactor.Caller, cmd.transactionID) + return printTransactionStatus(ctx, client, cmd.transactor.client.nicknames, transactor.Caller, cmd.transactionID) } diff --git a/cmd_query_multisig_transaction_list.go b/cmd_query_multisig_transaction_list.go index 35dbb08..40739c1 100644 --- a/cmd_query_multisig_transaction_list.go +++ b/cmd_query_multisig_transaction_list.go @@ -51,7 +51,7 @@ func (cmd *cmdQueryMultiSigTransactionList) Execute(ctx context.Context) error { if needsSeparator { fmt.Fprintln(clingy.Stdout(ctx)) } - if err := printTransactionStatus(ctx, client, caller, transactionID); err != nil { + if err := printTransactionStatus(ctx, client, cmd.caller.client.nicknames, caller, transactionID); err != nil { return err } needsSeparator = true diff --git a/cmd_query_multisig_transaction_status.go b/cmd_query_multisig_transaction_status.go index 9351488..e9fe03a 100644 --- a/cmd_query_multisig_transaction_status.go +++ b/cmd_query_multisig_transaction_status.go @@ -21,5 +21,5 @@ func (cmd *cmdQueryMultiSigTransactionStatus) Execute(ctx context.Context) error if err != nil { return err } - return printTransactionStatus(ctx, client, caller, cmd.transactionID) + return printTransactionStatus(ctx, client, cmd.caller.client.nicknames, caller, cmd.transactionID) } diff --git a/cmd_revoke.go b/cmd_revoke.go index 11280e1..782fefa 100644 --- a/cmd_revoke.go +++ b/cmd_revoke.go @@ -29,5 +29,5 @@ func (cmd *cmdRevoke) Execute(ctx context.Context) error { } fmt.Fprintln(clingy.Stdout(ctx)) - return printTransactionStatus(ctx, client, transactor.Caller, cmd.transactionID) + return printTransactionStatus(ctx, client, cmd.transactor.client.nicknames, transactor.Caller, cmd.transactionID) } diff --git a/cmd_submit_call.go b/cmd_submit_call.go index 8202adc..fe8b683 100644 --- a/cmd_submit_call.go +++ b/cmd_submit_call.go @@ -57,7 +57,7 @@ func (cmd *cmdSubmitContractCall) Execute(ctx context.Context) error { } fmt.Fprintln(clingy.Stdout(ctx)) - return printTransactionStatus(ctx, client, transactor.Caller, transactionID) + return printTransactionStatus(ctx, client, cmd.transactor.client.nicknames, transactor.Caller, transactionID) } func loadABI(path string) (*abi.ABI, error) { diff --git a/cmd_submit_eth_transfer.go b/cmd_submit_eth_transfer.go index 81b62c9..4e8596f 100644 --- a/cmd_submit_eth_transfer.go +++ b/cmd_submit_eth_transfer.go @@ -34,5 +34,5 @@ func (cmd *cmdSubmitETHTransfer) Execute(ctx context.Context) error { } fmt.Fprintln(clingy.Stdout(ctx)) - return printTransactionStatus(ctx, client, transactor.Caller, transactionID) + return printTransactionStatus(ctx, client, cmd.transactor.client.nicknames, transactor.Caller, transactionID) } diff --git a/cmd_submit_multisig_owner_add.go b/cmd_submit_multisig_owner_add.go index 28c2e26..18f9f01 100644 --- a/cmd_submit_multisig_owner_add.go +++ b/cmd_submit_multisig_owner_add.go @@ -31,5 +31,5 @@ func (cmd *cmdSubmitMultisigOwnerAdd) Execute(ctx context.Context) error { } fmt.Fprintln(clingy.Stdout(ctx)) - return printTransactionStatus(ctx, client, transactor.Caller, transactionID) + return printTransactionStatus(ctx, client, cmd.transactor.client.nicknames, transactor.Caller, transactionID) } diff --git a/cmd_submit_multisig_owner_remove.go b/cmd_submit_multisig_owner_remove.go index 5d3facc..84ebab9 100644 --- a/cmd_submit_multisig_owner_remove.go +++ b/cmd_submit_multisig_owner_remove.go @@ -31,5 +31,5 @@ func (cmd *cmdSubmitMultisigOwnerRemove) Execute(ctx context.Context) error { } fmt.Fprintln(clingy.Stdout(ctx)) - return printTransactionStatus(ctx, client, transactor.Caller, transactionID) + return printTransactionStatus(ctx, client, cmd.transactor.client.nicknames, transactor.Caller, transactionID) } diff --git a/cmd_submit_multisig_owner_replace.go b/cmd_submit_multisig_owner_replace.go index 6709b04..c629f53 100644 --- a/cmd_submit_multisig_owner_replace.go +++ b/cmd_submit_multisig_owner_replace.go @@ -33,5 +33,5 @@ func (cmd *cmdSubmitMultisigOwnerReplace) Execute(ctx context.Context) error { } fmt.Fprintln(clingy.Stdout(ctx)) - return printTransactionStatus(ctx, client, transactor.Caller, transactionID) + return printTransactionStatus(ctx, client, cmd.transactor.client.nicknames, transactor.Caller, transactionID) } diff --git a/cmd_submit_multisig_requirement_change.go b/cmd_submit_multisig_requirement_change.go index a3bee9a..9093d87 100644 --- a/cmd_submit_multisig_requirement_change.go +++ b/cmd_submit_multisig_requirement_change.go @@ -30,5 +30,5 @@ func (cmd *cmdSubmitMultisigRequirementChange) Execute(ctx context.Context) erro } fmt.Fprintln(clingy.Stdout(ctx)) - return printTransactionStatus(ctx, client, transactor.Caller, transactionID) + return printTransactionStatus(ctx, client, cmd.transactor.client.nicknames, transactor.Caller, transactionID) } diff --git a/cmd_submit_token_approve.go b/cmd_submit_token_approve.go index d8d5e79..dba47e1 100644 --- a/cmd_submit_token_approve.go +++ b/cmd_submit_token_approve.go @@ -36,5 +36,5 @@ func (cmd *cmdSubmitTokenApprove) Execute(ctx context.Context) error { } fmt.Fprintln(clingy.Stdout(ctx)) - return printTransactionStatus(ctx, client, transactor.Caller, transactionID) + return printTransactionStatus(ctx, client, cmd.transactor.client.nicknames, transactor.Caller, transactionID) } diff --git a/cmd_submit_token_set_upgrade_master.go b/cmd_submit_token_set_upgrade_master.go index 2cf704b..79bba85 100644 --- a/cmd_submit_token_set_upgrade_master.go +++ b/cmd_submit_token_set_upgrade_master.go @@ -33,5 +33,5 @@ func (cmd *cmdSubmitTokenSetUpgradeMaster) Execute(ctx context.Context) error { } fmt.Fprintln(clingy.Stdout(ctx)) - return printTransactionStatus(ctx, client, transactor.Caller, transactionID) + return printTransactionStatus(ctx, client, cmd.transactor.client.nicknames, transactor.Caller, transactionID) } diff --git a/cmd_submit_token_transfer.go b/cmd_submit_token_transfer.go index a104353..e0b66bd 100644 --- a/cmd_submit_token_transfer.go +++ b/cmd_submit_token_transfer.go @@ -36,5 +36,5 @@ func (cmd *cmdSubmitTokenTransfer) Execute(ctx context.Context) error { } fmt.Fprintln(clingy.Stdout(ctx)) - return printTransactionStatus(ctx, client, transactor.Caller, transactionID) + return printTransactionStatus(ctx, client, cmd.transactor.client.nicknames, transactor.Caller, transactionID) } diff --git a/cmd_submit_token_transfer_from.go b/cmd_submit_token_transfer_from.go index 7adc8ef..3587773 100644 --- a/cmd_submit_token_transfer_from.go +++ b/cmd_submit_token_transfer_from.go @@ -38,5 +38,5 @@ func (cmd *cmdSubmitTokenTransferFrom) Execute(ctx context.Context) error { } fmt.Fprintln(clingy.Stdout(ctx)) - return printTransactionStatus(ctx, client, transactor.Caller, transactionID) + return printTransactionStatus(ctx, client, cmd.transactor.client.nicknames, transactor.Caller, transactionID) } diff --git a/cmd_test_deploy_multisig.go b/cmd_test_deploy_multisig.go index 79f40ea..e7b2c79 100644 --- a/cmd_test_deploy_multisig.go +++ b/cmd_test_deploy_multisig.go @@ -39,7 +39,7 @@ func (cmd *cmdTestDeployMultiSig) Execute(ctx context.Context) error { if err != nil { return err } - opts, done, err := cmd.sender.transactOpts(ctx, client) + opts, done, err := cmd.sender.transactOpts(ctx, cmd.client.nicknames, client) if err != nil { return err } diff --git a/cmd_test_deploy_token.go b/cmd_test_deploy_token.go index 78980a5..a9b5bea 100644 --- a/cmd_test_deploy_token.go +++ b/cmd_test_deploy_token.go @@ -39,7 +39,7 @@ func (cmd *cmdTestDeployToken) Execute(ctx context.Context) error { if err != nil { return err } - opts, done, err := cmd.sender.transactOpts(ctx, client) + opts, done, err := cmd.sender.transactOpts(ctx, cmd.client.nicknames, client) if err != nil { return err } diff --git a/cmd_test_eth_transfer.go b/cmd_test_eth_transfer.go index db7dc83..d273c85 100644 --- a/cmd_test_eth_transfer.go +++ b/cmd_test_eth_transfer.go @@ -30,7 +30,7 @@ func (cmd *cmdTestETHTransfer) Execute(ctx context.Context) error { if err != nil { return err } - opts, done, err := cmd.sender.transactOpts(ctx, client) + opts, done, err := cmd.sender.transactOpts(ctx, cmd.client.nicknames, client) if err != nil { return err } diff --git a/dep_client.go b/dep_client.go index d6cc3a2..58a6e58 100644 --- a/dep_client.go +++ b/dep_client.go @@ -6,16 +6,19 @@ import ( "github.com/zeebo/clingy" "storj.io/briskitall/internal/eth" + "storj.io/briskitall/internal/multisig" ) type depClient struct { nodeURL string gasEstimateMultiplier float64 + nicknames multisig.Nicknames } func (dep *depClient) setup(params clingy.Parameters) { dep.nodeURL = requiredStringEnvFlag(params, "node-url", "Ethereum Node URL", envNodeURL) dep.gasEstimateMultiplier = float64Flag(params, "gas-estimate-multiplier", "Multiplier on the estimated gas price", 2.0) + dep.nicknames = optionalNicknameMap(params, "address-nicknames", "A comma separated list of wallet address nickname definitions, like name1:address,name2:address", nil, envAddressNicknames) } func (dep *depClient) open(ctx context.Context) (eth.Client, error) { diff --git a/dep_multisig_transactor.go b/dep_multisig_transactor.go index 3195d84..f9b6302 100644 --- a/dep_multisig_transactor.go +++ b/dep_multisig_transactor.go @@ -27,7 +27,7 @@ func (dep *depMultiSigTransactor) open(ctx context.Context) (eth.Client, *multis return nil, nil, nil, err } - opts, done, err := dep.sender.transactOpts(ctx, client) + opts, done, err := dep.sender.transactOpts(ctx, dep.client.nicknames, client) if err != nil { return nil, nil, nil, err } diff --git a/dep_sender.go b/dep_sender.go index c234463..3fef643 100644 --- a/dep_sender.go +++ b/dep_sender.go @@ -17,6 +17,7 @@ import ( "github.com/zeebo/errs" "storj.io/briskitall/internal/eth" + "storj.io/briskitall/internal/multisig" ) var ( @@ -39,7 +40,7 @@ func (dep *depSender) setup(params clingy.Parameters) { dep.gasLimit = uint64Flag(params, "gas-limit", "Sets the transaction gas limit (0 = estimate)", 0) } -func (dep *depSender) transactOpts(ctx context.Context, client bind.ContractTransactor) (opts *bind.TransactOpts, done func(), err error) { +func (dep *depSender) transactOpts(ctx context.Context, nicknames multisig.Nicknames, client bind.ContractTransactor) (opts *bind.TransactOpts, done func(), err error) { done = func() {} senderChoices := 0 @@ -97,23 +98,27 @@ func (dep *depSender) transactOpts(ctx context.Context, client bind.ContractTran } } - opts.Signer = confirmingSigner(ctx, opts.Signer, dep.skipConfirmation, isUSBWallet) + opts.Signer = confirmingSigner(ctx, nicknames, opts.Signer, dep.skipConfirmation, isUSBWallet) opts.GasLimit = dep.gasLimit opts.Context = ctx return opts, done, nil } -func confirmingSigner(ctx context.Context, signer bind.SignerFn, skip, isUSBWallet bool) bind.SignerFn { +func confirmingSigner(ctx context.Context, nicknames multisig.Nicknames, signer bind.SignerFn, skip, isUSBWallet bool) bind.SignerFn { return bind.SignerFn(func(sender common.Address, tx *types.Transaction) (*types.Transaction, error) { in := clingy.Stdin(ctx) out := clingy.Stdout(ctx) - call := tryDecodeCall(tx.Data()) + call := tryDecodeCall(nicknames, tx.Data()) fmt.Fprintf(out, "Preparing to send transaction:\n") fmt.Fprintf(out, " Type...........: %s\n", txType(tx.Type())) - fmt.Fprintf(out, " From...........: %s\n", sender) - fmt.Fprintf(out, " To.............: %s\n", tx.To()) + fmt.Fprintf(out, " From...........: %s\n", nicknames.Lookup(sender)) + to := "" + if txTo := tx.To(); txTo != nil { + to = nicknames.Lookup(*txTo) + } + fmt.Fprintf(out, " To.............: %s\n", to) switch { case len(tx.Data()) == 0: fmt.Fprintf(out, " Value..........: %s\n", eth.Pretty(tx.Value())) diff --git a/env.go b/env.go index 3c220f6..e8827c1 100644 --- a/env.go +++ b/env.go @@ -8,4 +8,5 @@ const ( envSenderKeyFile = "BRISKITALL_SENDER_KEY_FILE" envUSBWalletAccount = "BRISKITALL_USB_WALLET_ACCOUNT" envSkipConfirmation = "BRISKITALL_SKIP_CONFIRMATION" + envAddressNicknames = "BRISKITALL_ADDRESS_NICKNAMES" ) diff --git a/internal/multisig/events.go b/internal/multisig/events.go index 70e8996..a3ac93b 100644 --- a/internal/multisig/events.go +++ b/internal/multisig/events.go @@ -6,13 +6,28 @@ import ( "sort" "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" "github.com/zeebo/errs" "storj.io/briskitall/internal/contract" ) +type NicknameMap map[common.Address]string + +func (m NicknameMap) Lookup(wallet common.Address) string { + if entry, exists := m[wallet]; exists { + return entry + } + return wallet.String() +} + +type Nicknames interface { + Lookup(wallet common.Address) (name string) +} + type Event interface { String() string + StringWithNicknames(Nicknames) string BlockNumber() uint64 } @@ -20,7 +35,11 @@ type Event interface { type confirmationEvent contract.MultiSigWalletConfirmation func (e *confirmationEvent) String() string { - return fmt.Sprintf("ETH[%s]: Confirmation(%s)", e.Raw.TxHash, e.Sender) + return e.StringWithNicknames(NicknameMap(nil)) +} + +func (e *confirmationEvent) StringWithNicknames(n Nicknames) string { + return fmt.Sprintf("ETH[%s]: Confirmation(%s)", e.Raw.TxHash, n.Lookup(e.Sender)) } func (e *confirmationEvent) BlockNumber() uint64 { return e.Raw.BlockNumber } @@ -28,7 +47,11 @@ func (e *confirmationEvent) BlockNumber() uint64 { return e.Raw.BlockNumber } type revocationEvent contract.MultiSigWalletRevocation func (e *revocationEvent) String() string { - return fmt.Sprintf("ETH[%s]: Revocation(%s)", e.Raw.TxHash, e.Sender) + return e.StringWithNicknames(NicknameMap(nil)) +} + +func (e *revocationEvent) StringWithNicknames(n Nicknames) string { + return fmt.Sprintf("ETH[%s]: Revocation(%s)", e.Raw.TxHash, n.Lookup(e.Sender)) } func (e *revocationEvent) BlockNumber() uint64 { return e.Raw.BlockNumber } @@ -39,6 +62,10 @@ func (e *submissionEvent) String() string { return fmt.Sprintf("ETH[%s]: Submission()", e.Raw.TxHash) } +func (e *submissionEvent) StringWithNicknames(n Nicknames) string { + return e.String() +} + func (e *submissionEvent) BlockNumber() uint64 { return e.Raw.BlockNumber } type executionEvent contract.MultiSigWalletExecution @@ -47,6 +74,10 @@ func (e *executionEvent) String() string { return fmt.Sprintf("ETH[%s]: Execution()", e.Raw.TxHash) } +func (e *executionEvent) StringWithNicknames(n Nicknames) string { + return e.String() +} + func (e *executionEvent) BlockNumber() uint64 { return e.Raw.BlockNumber } type executionFailureEvent contract.MultiSigWalletExecutionFailure @@ -55,12 +86,20 @@ func (e *executionFailureEvent) String() string { return fmt.Sprintf("ETH[%s]: ExecutionFailure()", e.Raw.TxHash) } +func (e *executionFailureEvent) StringWithNicknames(n Nicknames) string { + return e.String() +} + func (e *executionFailureEvent) BlockNumber() uint64 { return e.Raw.BlockNumber } type depositEvent contract.MultiSigWalletDeposit func (e *depositEvent) String() string { - return fmt.Sprintf("ETH[%s]: Deposit(%s, %s)", e.Raw.TxHash, e.Sender, e.Value) + return e.StringWithNicknames(NicknameMap(nil)) +} + +func (e *depositEvent) StringWithNicknames(n Nicknames) string { + return fmt.Sprintf("ETH[%s]: Deposit(%s, %s)", e.Raw.TxHash, n.Lookup(e.Sender), e.Value) } func (e *depositEvent) BlockNumber() uint64 { return e.Raw.BlockNumber } @@ -68,7 +107,11 @@ func (e *depositEvent) BlockNumber() uint64 { return e.Raw.BlockNumber } type ownerAdditionEvent contract.MultiSigWalletOwnerAddition func (e *ownerAdditionEvent) String() string { - return fmt.Sprintf("ETH[%s]: OwnerAddition(%s)", e.Raw.TxHash, e.Owner) + return e.StringWithNicknames(NicknameMap(nil)) +} + +func (e *ownerAdditionEvent) StringWithNicknames(n Nicknames) string { + return fmt.Sprintf("ETH[%s]: OwnerAddition(%s)", e.Raw.TxHash, n.Lookup(e.Owner)) } func (e *ownerAdditionEvent) BlockNumber() uint64 { return e.Raw.BlockNumber } @@ -76,7 +119,11 @@ func (e *ownerAdditionEvent) BlockNumber() uint64 { return e.Raw.BlockNumber } type ownerRemovalEvent contract.MultiSigWalletOwnerRemoval func (e *ownerRemovalEvent) String() string { - return fmt.Sprintf("ETH[%s]: OwnerRemoval(%s)", e.Raw.TxHash, e.Owner) + return e.StringWithNicknames(NicknameMap(nil)) +} + +func (e *ownerRemovalEvent) StringWithNicknames(n Nicknames) string { + return fmt.Sprintf("ETH[%s]: OwnerRemoval(%s)", e.Raw.TxHash, n.Lookup(e.Owner)) } func (e *ownerRemovalEvent) BlockNumber() uint64 { return e.Raw.BlockNumber } @@ -87,6 +134,10 @@ func (e *requirementChangeEvent) String() string { return fmt.Sprintf("ETH[%s]: RequirementChanged(%s)", e.Raw.TxHash, e.Required) } +func (e *requirementChangeEvent) StringWithNicknames(n Nicknames) string { + return e.String() +} + func (e *requirementChangeEvent) BlockNumber() uint64 { return e.Raw.BlockNumber } func getAllEvents(opts *bind.FilterOpts, filterer *contract.MultiSigWalletWithDailyLimitFilterer) ([]Event, error) { diff --git a/params.go b/params.go index 4fefea7..d29f53c 100644 --- a/params.go +++ b/params.go @@ -4,12 +4,14 @@ import ( "fmt" "math/big" "strconv" + "strings" "github.com/ethereum/go-ethereum/accounts" "github.com/ethereum/go-ethereum/common" "github.com/zeebo/clingy" "storj.io/briskitall/internal/eth" + "storj.io/briskitall/internal/multisig" ) //lint:ignore U1000, utility func that is fine to be unused @@ -111,6 +113,10 @@ func optionalDerivationPathFlag(params clingy.Parameters, name, desc string, def return params.Flag(name, desc, def, clingy.Transform(accounts.ParseDerivationPath)).(accounts.DerivationPath) } +func optionalNicknameMap(params clingy.Parameters, name, desc string, def multisig.NicknameMap, env string) multisig.NicknameMap { + return params.Flag(name, desc, def, clingy.Getenv(env), clingy.Transform(transformNicknameMap)).(multisig.NicknameMap) +} + func transformInt64(s string) (int64, error) { return strconv.ParseInt(s, 10, 64) } @@ -144,3 +150,22 @@ func transformBigInt(s string) (*big.Int, error) { } return i, nil } + +func transformNicknameMap(s string) (multisig.NicknameMap, error) { + nicknames := multisig.NicknameMap{} + for _, definition := range strings.Split(s, ",") { + name, addrstring, found := strings.Cut(definition, ":") + if !found { + return nil, fmt.Errorf("invalid nickname map entry: %q", definition) + } + var address common.Address + if err := address.UnmarshalText([]byte(addrstring)); err != nil { + return nil, err + } + if _, exists := nicknames[address]; exists { + return nil, fmt.Errorf("nickname map entry defined twice: %s", address) + } + nicknames[address] = name + } + return nicknames, nil +} diff --git a/status.go b/status.go index 3b52eba..07cef3a 100644 --- a/status.go +++ b/status.go @@ -9,6 +9,7 @@ import ( "time" "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/common" "github.com/zeebo/clingy" "storj.io/briskitall/internal/contract" @@ -44,7 +45,7 @@ func initABIs() { }) } -func printTransactionStatus(ctx context.Context, client eth.Client, caller *multisig.Caller, transactionID uint64) error { +func printTransactionStatus(ctx context.Context, client eth.Client, nicknames multisig.Nicknames, caller *multisig.Caller, transactionID uint64) error { out := clingy.Stdout(ctx) tx, err := caller.FindTransaction(ctx, transactionID) @@ -82,10 +83,10 @@ func printTransactionStatus(ctx context.Context, client eth.Client, caller *mult return blockTimestamps[blockNo], nil } - call := tryDecodeCall(tx.Data) + call := tryDecodeCall(nicknames, tx.Data) fmt.Fprintf(out, "Transaction %d:\n", transactionID) - fmt.Fprintf(out, " Destination = %s\n", tx.Destination) + fmt.Fprintf(out, " Destination = %s\n", nicknames.Lookup(tx.Destination)) switch { case len(tx.Data) == 0: fmt.Fprintf(out, " Value = %s\n", tx.Value) @@ -98,7 +99,7 @@ func printTransactionStatus(ctx context.Context, client eth.Client, caller *mult fmt.Fprintf(out, " Confirmed = %t\n", confirmed) fmt.Fprintf(out, " Confirmations(%d):\n", len(confirmations)) for _, confirmation := range confirmations { - fmt.Fprintf(out, " - Owner(%s)\n", confirmation) + fmt.Fprintf(out, " - Owner(%s)\n", nicknames.Lookup(confirmation)) } fmt.Fprintf(out, " Events(%d):\n", len(events)) for _, event := range events { @@ -106,22 +107,22 @@ func printTransactionStatus(ctx context.Context, client eth.Client, caller *mult if err != nil { return err } - fmt.Fprintf(out, " - %s: %s\n", ts.Format("2006-01-02"), event) + fmt.Fprintf(out, " - %s: %s\n", ts.Format("2006-01-02"), event.StringWithNicknames(nicknames)) } return nil } -func tryDecodeCall(data []byte) string { +func tryDecodeCall(nicknames multisig.Nicknames, data []byte) string { initABIs() for _, a := range abis { - if decoded := tryDecodeABICall(a, data); decoded != "" { + if decoded := tryDecodeABICall(nicknames, a, data); decoded != "" { return decoded } } return "" } -func tryDecodeABICall(abi *abi.ABI, data []byte) string { +func tryDecodeABICall(nicknames multisig.Nicknames, abi *abi.ABI, data []byte) string { if len(data) < 4 { return "" } @@ -143,14 +144,18 @@ func tryDecodeABICall(abi *abi.ABI, data []byte) string { buf.WriteString(", ") } if argData, ok := arg.([]byte); ok { - if argCall := tryDecodeCall(argData); argCall != "" { + if argCall := tryDecodeCall(nicknames, argData); argCall != "" { fmt.Fprint(buf, argCall) } else { fmt.Fprintf(buf, "%x", arg) } continue } - fmt.Fprint(buf, arg) + if argAddr, ok := arg.(common.Address); ok { + fmt.Fprint(buf, nicknames.Lookup(argAddr)) + } else { + fmt.Fprint(buf, arg) + } } buf.WriteString(")") return buf.String()