Skip to content

Commit

Permalink
remove nonce field (#3714)
Browse files Browse the repository at this point in the history
Co-authored-by: dustinxie <dahuaxie@gmail.com>
  • Loading branch information
huof6829 and dustinxie authored Dec 16, 2022
1 parent db2969c commit 5d3910b
Show file tree
Hide file tree
Showing 9 changed files with 6 additions and 25 deletions.
2 changes: 0 additions & 2 deletions ioctl/cmd/account/accountinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ type infoMessage struct {
Address string `json:"address"`
EthAddress string `json:"ethAddress"`
Balance string `json:"balance"`
Nonce int `json:"nonce"`
PendingNonce int `json:"pendingNonce"`
NumActions int `json:"numActions"`
IsContract bool `json:"isContract"`
Expand Down Expand Up @@ -79,7 +78,6 @@ func info(arg string) error {
Address: addr,
EthAddress: ethAddr.Hex(),
Balance: util.RauToString(balance, util.IotxDecimalNum),
Nonce: int(accountMeta.Nonce),
PendingNonce: int(accountMeta.PendingNonce),
NumActions: int(accountMeta.NumActions),
IsContract: accountMeta.IsContract,
Expand Down
8 changes: 3 additions & 5 deletions ioctl/cmd/account/accountnonce.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,10 @@ var _accountNonceCmd = &cobra.Command{

type nonceMessage struct {
Address string `json:"address"`
Nonce int `json:"nonce"`
PendingNonce int `json:"pendingNonce"`
}

// nonce gets nonce and pending nonce of an IoTeX blockchain address
// nonce gets pending nonce of an IoTeX blockchain address
func nonce(arg string) error {
addr, err := util.GetAddress(arg)
if err != nil {
Expand All @@ -61,7 +60,6 @@ func nonce(arg string) error {
}
message := nonceMessage{
Address: addr,
Nonce: int(accountMeta.Nonce),
PendingNonce: int(accountMeta.PendingNonce),
}
fmt.Println(message.String())
Expand All @@ -70,8 +68,8 @@ func nonce(arg string) error {

func (m *nonceMessage) String() string {
if output.Format == "" {
return fmt.Sprintf("%s:\nNonce: %d, Pending Nonce: %d",
m.Address, m.Nonce, m.PendingNonce)
return fmt.Sprintf("%s:\nPending Nonce: %d",
m.Address, m.PendingNonce)
}
return output.FormatString(output.Result, m)
}
1 change: 0 additions & 1 deletion ioctl/newcmd/account/account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ func TestMeta(t *testing.T) {
accAddr := identityset.Address(28).String()
accountResponse := &iotexapi.GetAccountResponse{AccountMeta: &iotextypes.AccountMeta{
Address: accAddr,
Nonce: 1,
PendingNonce: 2,
}}
apiServiceClient.EXPECT().GetAccount(gomock.Any(), gomock.Any()).Return(accountResponse, nil)
Expand Down
4 changes: 1 addition & 3 deletions ioctl/newcmd/account/accountbalance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ import (
"testing"

"github.com/golang/mock/gomock"
"github.com/stretchr/testify/require"

"github.com/iotexproject/iotex-proto/golang/iotexapi"
"github.com/iotexproject/iotex-proto/golang/iotexapi/mock_iotexapi"
"github.com/iotexproject/iotex-proto/golang/iotextypes"
"github.com/stretchr/testify/require"

"github.com/iotexproject/iotex-core/ioctl/config"
"github.com/iotexproject/iotex-core/ioctl/util"
Expand All @@ -36,7 +35,6 @@ func TestNewAccountBalance(t *testing.T) {
accountResponse := &iotexapi.GetAccountResponse{AccountMeta: &iotextypes.AccountMeta{
Address: accAddr.String(),
Balance: "20000000132432000",
Nonce: uint64(0),
PendingNonce: uint64(1),
NumActions: uint64(2),
IsContract: true,
Expand Down
2 changes: 0 additions & 2 deletions ioctl/newcmd/account/accountinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ func NewAccountInfo(client ioctl.Client) *cobra.Command {
Address: addr,
EthAddress: ethAddr.Hex(),
Balance: util.RauToString(balance, util.IotxDecimalNum),
Nonce: int(accountMeta.Nonce),
PendingNonce: int(accountMeta.PendingNonce),
NumActions: int(accountMeta.NumActions),
IsContract: accountMeta.IsContract,
Expand All @@ -98,7 +97,6 @@ type infoMessage struct {
Address string `json:"address"`
EthAddress string `json:"ethAddress"`
Balance string `json:"balance"`
Nonce int `json:"nonce"`
PendingNonce int `json:"pendingNonce"`
NumActions int `json:"numActions"`
IsContract bool `json:"isContract"`
Expand Down
2 changes: 0 additions & 2 deletions ioctl/newcmd/account/accountinfo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ func TestNewAccountInfo(t *testing.T) {
accountResponse := &iotexapi.GetAccountResponse{AccountMeta: &iotextypes.AccountMeta{
Address: accAddr.String(),
Balance: "20000000132432000",
Nonce: uint64(0),
PendingNonce: uint64(1),
NumActions: uint64(2),
IsContract: true,
Expand All @@ -55,7 +54,6 @@ func TestNewAccountInfo(t *testing.T) {
var info infoMessage
require.NoError(json.Unmarshal([]byte(result), &info))
require.Equal(accAddr.String(), info.Address)
require.Equal(accountResponse.AccountMeta.Nonce, uint64(info.Nonce))
require.Equal(accountResponse.AccountMeta.PendingNonce, uint64(info.PendingNonce))
require.Equal(accountResponse.AccountMeta.NumActions, uint64(info.NumActions))
require.Equal(info.ContractByteCode, hex.EncodeToString(accountResponse.AccountMeta.ContractByteCode))
Expand Down
4 changes: 2 additions & 2 deletions ioctl/newcmd/account/accountnonce.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ func NewAccountNonce(client ioctl.Client) *cobra.Command {
return errors.Wrap(err, failToGetAccountMeta)
}

cmd.Println(fmt.Sprintf("%s:\nNonce: %d, Pending Nonce: %d",
addr, accountMeta.Nonce, accountMeta.PendingNonce))
cmd.Println(fmt.Sprintf("%s:\nPending Nonce: %d",
addr, accountMeta.PendingNonce))
return nil
},
}
Expand Down
6 changes: 0 additions & 6 deletions ioctl/newcmd/account/accountnonce_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,18 @@ func TestNewAccountNonce(t *testing.T) {
// input
inAddr string
// output
outNonce int
outPendingNonce int
}{
{
inAddr: "",
outNonce: 0,
outPendingNonce: 0,
},
{
inAddr: "io1cjh35tq9k8fu0gqcsat4px7yr8trh75c95hc5r",
outNonce: 0,
outPendingNonce: 1,
},
{
inAddr: "io187evpmjdankjh0g5dfz83w2z3p23ljhn4s9jw7",
outNonce: 2,
outPendingNonce: 3,
},
}
Expand All @@ -63,15 +59,13 @@ func TestNewAccountNonce(t *testing.T) {
client.EXPECT().AddressWithDefaultIfNotExist(gomock.Any()).Return(accAddr, nil)
accountResponse := &iotexapi.GetAccountResponse{AccountMeta: &iotextypes.AccountMeta{
Address: accAddr,
Nonce: uint64(accountNoneTests[i].outNonce),
PendingNonce: uint64(accountNoneTests[i].outPendingNonce),
}}
apiServiceClient.EXPECT().GetAccount(gomock.Any(), gomock.Any()).Return(accountResponse, nil)

cmd := NewAccountNonce(client)
result, err := util.ExecuteCmd(cmd, accountNoneTests[i].inAddr)
require.NoError(err)
require.Contains(result, fmt.Sprintf("Nonce: %d", accountNoneTests[i].outNonce))
require.Contains(result, fmt.Sprintf("Pending Nonce: %d", accountNoneTests[i].outPendingNonce))
}

Expand Down
2 changes: 0 additions & 2 deletions ioctl/newcmd/action/action_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ func TestSendAction(t *testing.T) {
require.NoError(err)
accountResponse := &iotexapi.GetAccountResponse{AccountMeta: &iotextypes.AccountMeta{
Address: accAddr.String(),
Nonce: 1,
PendingNonce: 1,
Balance: cost.String(),
}}
Expand Down Expand Up @@ -267,7 +266,6 @@ func TestExecute(t *testing.T) {
require.NoError(err)
accountResponse := &iotexapi.GetAccountResponse{AccountMeta: &iotextypes.AccountMeta{
Address: accAddr.String(),
Nonce: 1,
PendingNonce: 1,
Balance: cost.String(),
}}
Expand Down

0 comments on commit 5d3910b

Please sign in to comment.