Skip to content

Commit

Permalink
Show event dates in transaction status output (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
jtolio authored Feb 21, 2024
1 parent b67cb82 commit 03f764e
Show file tree
Hide file tree
Showing 24 changed files with 110 additions and 69 deletions.
4 changes: 2 additions & 2 deletions cmd_confirm.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func (cmd *cmdConfirm) Setup(params clingy.Parameters) {
}

func (cmd *cmdConfirm) Execute(ctx context.Context) error {
transactor, done, err := cmd.transactor.open(ctx)
client, transactor, done, err := cmd.transactor.open(ctx)
if err != nil {
return err
}
Expand All @@ -29,6 +29,6 @@ func (cmd *cmdConfirm) Execute(ctx context.Context) error {
}

fmt.Fprintln(clingy.Stdout(ctx))
printTransactionStatus(ctx, transactor.Caller, cmd.transactionID)
printTransactionStatus(ctx, client, transactor.Caller, cmd.transactionID)
return nil
}
4 changes: 2 additions & 2 deletions cmd_execute.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func (cmd *cmdExecute) Setup(params clingy.Parameters) {
}

func (cmd *cmdExecute) Execute(ctx context.Context) error {
transactor, done, err := cmd.transactor.open(ctx)
client, transactor, done, err := cmd.transactor.open(ctx)
if err != nil {
return err
}
Expand All @@ -29,5 +29,5 @@ func (cmd *cmdExecute) Execute(ctx context.Context) error {
}

fmt.Fprintln(clingy.Stdout(ctx))
return printTransactionStatus(ctx, transactor.Caller, cmd.transactionID)
return printTransactionStatus(ctx, client, transactor.Caller, cmd.transactionID)
}
2 changes: 1 addition & 1 deletion cmd_query_multisig_owner_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func (cmd *cmdQueryMultiSigOwnerList) Setup(params clingy.Parameters) {
}

func (cmd *cmdQueryMultiSigOwnerList) Execute(ctx context.Context) error {
caller, err := cmd.caller.open(ctx)
_, caller, err := cmd.caller.open(ctx)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd_query_multisig_requirement.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func (cmd *cmdQueryMultiSigRequirement) Setup(params clingy.Parameters) {
}

func (cmd *cmdQueryMultiSigRequirement) Execute(ctx context.Context) error {
caller, err := cmd.caller.open(ctx)
_, caller, err := cmd.caller.open(ctx)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions cmd_query_multisig_transaction_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func (cmd *cmdQueryMultiSigTransactionList) Setup(params clingy.Parameters) {
}

func (cmd *cmdQueryMultiSigTransactionList) Execute(ctx context.Context) error {
caller, err := cmd.caller.open(ctx)
client, caller, err := cmd.caller.open(ctx)
if err != nil {
return err
}
Expand Down Expand Up @@ -51,7 +51,7 @@ func (cmd *cmdQueryMultiSigTransactionList) Execute(ctx context.Context) error {
if needsSeparator {
fmt.Fprintln(clingy.Stdout(ctx))
}
if err := printTransactionStatus(ctx, caller, transactionID); err != nil {
if err := printTransactionStatus(ctx, client, caller, transactionID); err != nil {
return err
}
needsSeparator = true
Expand Down
25 changes: 15 additions & 10 deletions cmd_query_multisig_transaction_list_test.go
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
package main

import (
"fmt"
"testing"
"time"

"github.com/stretchr/testify/assert"

"storj.io/briskitall/test"
)

func TestQueryMultiSigTransactionListCmd(t *testing.T) {
const expectedPending = `Transaction 0:
today := time.Now().Format("2006-01-02")

expectedPending := fmt.Sprintf(`Transaction 0:
Destination = 0x7A35a1584FDD8c88B0Fe60f21199CF6eEeCAA0fe
Call = addOwner(0xD370Bbc286487CD41E18c3561c0Fc9C1a986516B)
Executed = false
Confirmed = false
Confirmations(1):
- Owner(0x46f40B6B0dFDa35A8b6247489669a83c69804F3a)
Events(2):
- ETH[0]: Confirmation(0x46f40B6B0dFDa35A8b6247489669a83c69804F3a)
- ETH[0]: Submission()
`
const expectedExecuted = `Transaction 0:
- %s: ETH[0]: Confirmation(0x46f40B6B0dFDa35A8b6247489669a83c69804F3a)
- %s: ETH[0]: Submission()
`, today, today)

expectedExecuted := fmt.Sprintf(`Transaction 0:
Destination = 0x7A35a1584FDD8c88B0Fe60f21199CF6eEeCAA0fe
Call = addOwner(0xD370Bbc286487CD41E18c3561c0Fc9C1a986516B)
Executed = true
Expand All @@ -29,11 +34,11 @@ func TestQueryMultiSigTransactionListCmd(t *testing.T) {
- Owner(0x46f40B6B0dFDa35A8b6247489669a83c69804F3a)
- Owner(0xBA4e70c2dc335aa86c6BF55F80d631Cf846435F0)
Events(4):
- ETH[0]: Confirmation(0x46f40B6B0dFDa35A8b6247489669a83c69804F3a)
- ETH[0]: Submission()
- ETH[1]: Confirmation(0xBA4e70c2dc335aa86c6BF55F80d631Cf846435F0)
- ETH[1]: Execution()
`
- %s: ETH[0]: Confirmation(0x46f40B6B0dFDa35A8b6247489669a83c69804F3a)
- %s: ETH[0]: Submission()
- %s: ETH[1]: Confirmation(0xBA4e70c2dc335aa86c6BF55F80d631Cf846435F0)
- %s: ETH[1]: Execution()
`, today, today, today, today)

harness := test.Run(t)

Expand Down
4 changes: 2 additions & 2 deletions cmd_query_multisig_transaction_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ func (cmd *cmdQueryMultiSigTransactionStatus) Setup(params clingy.Parameters) {
}

func (cmd *cmdQueryMultiSigTransactionStatus) Execute(ctx context.Context) error {
caller, err := cmd.caller.open(ctx)
client, caller, err := cmd.caller.open(ctx)
if err != nil {
return err
}
return printTransactionStatus(ctx, caller, cmd.transactionID)
return printTransactionStatus(ctx, client, caller, cmd.transactionID)
}
20 changes: 14 additions & 6 deletions cmd_query_multisig_transaction_status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"fmt"
"testing"
"time"

"github.com/stretchr/testify/assert"

Expand All @@ -11,6 +12,7 @@ import (

func TestQueryMultiSigTransactionStatusCmd(t *testing.T) {
harness := test.Run(t)
today := time.Now().Format("2006-01-02")

transactionID := harness.MultiSig.SubmitAddOwner(t, test.AccountKey[0], test.AccountAddress[2])

Expand All @@ -23,13 +25,15 @@ func TestQueryMultiSigTransactionStatusCmd(t *testing.T) {
Confirmations(1):
- Owner(%s)
Events(2):
- ETH[0]: Confirmation(%s)
- ETH[0]: Submission()
- %s: ETH[0]: Confirmation(%s)
- %s: ETH[0]: Submission()
`, transactionID,
harness.MultiSig.ContractAddress,
test.AccountAddress[2],
test.AccountAddress[0],
today,
test.AccountAddress[0],
today,
), stdout)

harness.MultiSig.ConfirmTransaction(t, test.AccountKey[1], transactionID)
Expand All @@ -44,16 +48,20 @@ func TestQueryMultiSigTransactionStatusCmd(t *testing.T) {
- Owner(%s)
- Owner(%s)
Events(4):
- ETH[0]: Confirmation(%s)
- ETH[0]: Submission()
- ETH[1]: Confirmation(%s)
- ETH[1]: Execution()
- %s: ETH[0]: Confirmation(%s)
- %s: ETH[0]: Submission()
- %s: ETH[1]: Confirmation(%s)
- %s: ETH[1]: Execution()
`, transactionID,
harness.MultiSig.ContractAddress,
test.AccountAddress[2],
test.AccountAddress[0],
test.AccountAddress[1],
today,
test.AccountAddress[0],
today,
today,
test.AccountAddress[1],
today,
), stdout)
}
4 changes: 2 additions & 2 deletions cmd_revoke.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func (cmd *cmdRevoke) Setup(params clingy.Parameters) {
}

func (cmd *cmdRevoke) Execute(ctx context.Context) error {
transactor, done, err := cmd.transactor.open(ctx)
client, transactor, done, err := cmd.transactor.open(ctx)
if err != nil {
return err
}
Expand All @@ -29,5 +29,5 @@ func (cmd *cmdRevoke) Execute(ctx context.Context) error {
}

fmt.Fprintln(clingy.Stdout(ctx))
return printTransactionStatus(ctx, transactor.Caller, cmd.transactionID)
return printTransactionStatus(ctx, client, transactor.Caller, cmd.transactionID)
}
4 changes: 2 additions & 2 deletions cmd_submit_call.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (cmd *cmdSubmitContractCall) Execute(ctx context.Context) error {
return err
}

transactor, done, err := cmd.transactor.open(ctx)
client, transactor, done, err := cmd.transactor.open(ctx)
if err != nil {
return err
}
Expand All @@ -57,7 +57,7 @@ func (cmd *cmdSubmitContractCall) Execute(ctx context.Context) error {
}

fmt.Fprintln(clingy.Stdout(ctx))
return printTransactionStatus(ctx, transactor.Caller, transactionID)
return printTransactionStatus(ctx, client, transactor.Caller, transactionID)
}

func loadABI(path string) (*abi.ABI, error) {
Expand Down
4 changes: 2 additions & 2 deletions cmd_submit_eth_transfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func (cmd *cmdSubmitETHTransfer) Setup(params clingy.Parameters) {
}

func (cmd *cmdSubmitETHTransfer) Execute(ctx context.Context) error {
transactor, done, err := cmd.transactor.open(ctx)
client, transactor, done, err := cmd.transactor.open(ctx)
if err != nil {
return err
}
Expand All @@ -34,5 +34,5 @@ func (cmd *cmdSubmitETHTransfer) Execute(ctx context.Context) error {
}

fmt.Fprintln(clingy.Stdout(ctx))
return printTransactionStatus(ctx, transactor.Caller, transactionID)
return printTransactionStatus(ctx, client, transactor.Caller, transactionID)
}
4 changes: 2 additions & 2 deletions cmd_submit_multisig_owner_add.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func (cmd *cmdSubmitMultisigOwnerAdd) Setup(params clingy.Parameters) {
}

func (cmd *cmdSubmitMultisigOwnerAdd) Execute(ctx context.Context) error {
transactor, done, err := cmd.transactor.open(ctx)
client, transactor, done, err := cmd.transactor.open(ctx)
if err != nil {
return err
}
Expand All @@ -31,5 +31,5 @@ func (cmd *cmdSubmitMultisigOwnerAdd) Execute(ctx context.Context) error {
}

fmt.Fprintln(clingy.Stdout(ctx))
return printTransactionStatus(ctx, transactor.Caller, transactionID)
return printTransactionStatus(ctx, client, transactor.Caller, transactionID)
}
4 changes: 2 additions & 2 deletions cmd_submit_multisig_owner_remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func (cmd *cmdSubmitMultisigOwnerRemove) Setup(params clingy.Parameters) {
}

func (cmd *cmdSubmitMultisigOwnerRemove) Execute(ctx context.Context) error {
transactor, done, err := cmd.transactor.open(ctx)
client, transactor, done, err := cmd.transactor.open(ctx)
if err != nil {
return err
}
Expand All @@ -31,5 +31,5 @@ func (cmd *cmdSubmitMultisigOwnerRemove) Execute(ctx context.Context) error {
}

fmt.Fprintln(clingy.Stdout(ctx))
return printTransactionStatus(ctx, transactor.Caller, transactionID)
return printTransactionStatus(ctx, client, transactor.Caller, transactionID)
}
4 changes: 2 additions & 2 deletions cmd_submit_multisig_owner_replace.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func (cmd *cmdSubmitMultisigOwnerReplace) Setup(params clingy.Parameters) {
}

func (cmd *cmdSubmitMultisigOwnerReplace) Execute(ctx context.Context) error {
transactor, done, err := cmd.transactor.open(ctx)
client, transactor, done, err := cmd.transactor.open(ctx)
if err != nil {
return err
}
Expand All @@ -33,5 +33,5 @@ func (cmd *cmdSubmitMultisigOwnerReplace) Execute(ctx context.Context) error {
}

fmt.Fprintln(clingy.Stdout(ctx))
return printTransactionStatus(ctx, transactor.Caller, transactionID)
return printTransactionStatus(ctx, client, transactor.Caller, transactionID)
}
4 changes: 2 additions & 2 deletions cmd_submit_multisig_requirement_change.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func (cmd *cmdSubmitMultisigRequirementChange) Setup(params clingy.Parameters) {
}

func (cmd *cmdSubmitMultisigRequirementChange) Execute(ctx context.Context) error {
transactor, done, err := cmd.transactor.open(ctx)
client, transactor, done, err := cmd.transactor.open(ctx)
if err != nil {
return err
}
Expand All @@ -30,5 +30,5 @@ func (cmd *cmdSubmitMultisigRequirementChange) Execute(ctx context.Context) erro
}

fmt.Fprintln(clingy.Stdout(ctx))
return printTransactionStatus(ctx, transactor.Caller, transactionID)
return printTransactionStatus(ctx, client, transactor.Caller, transactionID)
}
4 changes: 2 additions & 2 deletions cmd_submit_token_approve.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func (cmd *cmdSubmitTokenApprove) Setup(params clingy.Parameters) {
}

func (cmd *cmdSubmitTokenApprove) Execute(ctx context.Context) error {
transactor, done, err := cmd.transactor.open(ctx)
client, transactor, done, err := cmd.transactor.open(ctx)
if err != nil {
return err
}
Expand All @@ -36,5 +36,5 @@ func (cmd *cmdSubmitTokenApprove) Execute(ctx context.Context) error {
}

fmt.Fprintln(clingy.Stdout(ctx))
return printTransactionStatus(ctx, transactor.Caller, transactionID)
return printTransactionStatus(ctx, client, transactor.Caller, transactionID)
}
4 changes: 2 additions & 2 deletions cmd_submit_token_set_upgrade_master.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func (cmd *cmdSubmitTokenSetUpgradeMaster) Setup(params clingy.Parameters) {
}

func (cmd *cmdSubmitTokenSetUpgradeMaster) Execute(ctx context.Context) error {
transactor, done, err := cmd.transactor.open(ctx)
client, transactor, done, err := cmd.transactor.open(ctx)
if err != nil {
return err
}
Expand All @@ -33,5 +33,5 @@ func (cmd *cmdSubmitTokenSetUpgradeMaster) Execute(ctx context.Context) error {
}

fmt.Fprintln(clingy.Stdout(ctx))
return printTransactionStatus(ctx, transactor.Caller, transactionID)
return printTransactionStatus(ctx, client, transactor.Caller, transactionID)
}
4 changes: 2 additions & 2 deletions cmd_submit_token_transfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func (cmd *cmdSubmitTokenTransfer) Setup(params clingy.Parameters) {
}

func (cmd *cmdSubmitTokenTransfer) Execute(ctx context.Context) error {
transactor, done, err := cmd.transactor.open(ctx)
client, transactor, done, err := cmd.transactor.open(ctx)
if err != nil {
return err
}
Expand All @@ -36,5 +36,5 @@ func (cmd *cmdSubmitTokenTransfer) Execute(ctx context.Context) error {
}

fmt.Fprintln(clingy.Stdout(ctx))
return printTransactionStatus(ctx, transactor.Caller, transactionID)
return printTransactionStatus(ctx, client, transactor.Caller, transactionID)
}
4 changes: 2 additions & 2 deletions cmd_submit_token_transfer_from.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (cmd *cmdSubmitTokenTransferFrom) Setup(params clingy.Parameters) {
}

func (cmd *cmdSubmitTokenTransferFrom) Execute(ctx context.Context) error {
transactor, done, err := cmd.transactor.open(ctx)
client, transactor, done, err := cmd.transactor.open(ctx)
if err != nil {
return err
}
Expand All @@ -38,5 +38,5 @@ func (cmd *cmdSubmitTokenTransferFrom) Execute(ctx context.Context) error {
}

fmt.Fprintln(clingy.Stdout(ctx))
return printTransactionStatus(ctx, transactor.Caller, transactionID)
return printTransactionStatus(ctx, client, transactor.Caller, transactionID)
}
11 changes: 8 additions & 3 deletions dep_multisig_caller.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/zeebo/clingy"

"storj.io/briskitall/internal/eth"
"storj.io/briskitall/internal/multisig"
)

Expand All @@ -18,10 +19,14 @@ func (dep *depMultiSigCaller) setup(params clingy.Parameters) {
dep.multiSig.setup(params)
}

func (dep *depMultiSigCaller) open(ctx context.Context) (*multisig.Caller, error) {
func (dep *depMultiSigCaller) open(ctx context.Context) (eth.Client, *multisig.Caller, error) {
client, err := dep.client.open(ctx)
if err != nil {
return nil, err
return nil, nil, err
}
return multisig.NewCaller(client, dep.multiSig.contractAddress)
caller, err := multisig.NewCaller(client, dep.multiSig.contractAddress)
if err != nil {
return nil, nil, err
}
return client, caller, nil
}
Loading

0 comments on commit 03f764e

Please sign in to comment.