diff --git a/node/exts/erc20reward/meta_extension.go b/node/exts/erc20reward/meta_extension.go index 396e81d65..15195b6b3 100644 --- a/node/exts/erc20reward/meta_extension.go +++ b/node/exts/erc20reward/meta_extension.go @@ -939,8 +939,9 @@ func init() { {Name: "reward_root", Type: types.ByteaType, Nullable: true}, {Name: "end_block_hash", Type: types.ByteaType, Nullable: true}, {Name: "voters", Type: types.TextArrayType, Nullable: true}, - {Name: "voter_signatures", Type: types.ByteaArrayType, Nullable: true}, + {Name: "vote_amounts", Type: types.TextArrayType, Nullable: true}, {Name: "vote_nonces", Type: types.IntArrayType, Nullable: true}, + {Name: "voter_signatures", Type: types.ByteaArrayType, Nullable: true}, }, }, AccessModifiers: []precompiles.Modifier{precompiles.PUBLIC, precompiles.VIEW}, @@ -955,8 +956,16 @@ func init() { } } + var voteAmts []string + if len(e.VoteAmounts) > 0 { + for _, item := range e.VoteAmounts { + voteAmts = append(voteAmts, item.String()) + } + } + return resultFn([]any{e.ID, e.StartHeight, e.StartTime, *e.EndHeight, e.Root, e.BlockHash, voters, + voteAmts, e.VoteSigs, e.VoteNonces, }) @@ -983,8 +992,9 @@ func init() { {Name: "reward_root", Type: types.ByteaType, Nullable: true}, {Name: "end_block_hash", Type: types.ByteaType, Nullable: true}, {Name: "voters", Type: types.TextArrayType, Nullable: true}, - {Name: "voter_signatures", Type: types.ByteaArrayType, Nullable: true}, + {Name: "vote_amounts", Type: types.TextArrayType, Nullable: true}, {Name: "vote_nonces", Type: types.IntArrayType, Nullable: true}, + {Name: "voter_signatures", Type: types.ByteaArrayType, Nullable: true}, }, }, AccessModifiers: []precompiles.Modifier{precompiles.PUBLIC, precompiles.VIEW}, @@ -1002,8 +1012,16 @@ func init() { } } + var voteAmts []string + if len(e.VoteAmounts) > 0 { + for _, item := range e.VoteAmounts { + voteAmts = append(voteAmts, item.String()) + } + } + return resultFn([]any{e.ID, e.StartHeight, e.StartTime, *e.EndHeight, e.Root, e.BlockHash, voters, + voteAmts, e.VoteSigs, e.VoteNonces, }) @@ -1458,9 +1476,10 @@ func (p *PendingEpoch) copy() *PendingEpoch { } type EpochVoteInfo struct { - Voters []ethcommon.Address - VoteSigs [][]byte - VoteNonces []int64 + Voters []ethcommon.Address + VoteAmounts []*types.Decimal + VoteSigs [][]byte + VoteNonces []int64 } // Epoch is a period in which rewards are distributed. diff --git a/node/exts/erc20reward/meta_sql.go b/node/exts/erc20reward/meta_sql.go index e66329322..13cd1c9a5 100644 --- a/node/exts/erc20reward/meta_sql.go +++ b/node/exts/erc20reward/meta_sql.go @@ -408,6 +408,7 @@ func rowToEpoch(r *common.Row) (*Epoch, error) { blockHash = r.Values[5].([]byte) } + fmt.Printf("yaiba ===== %+v, %v, %T", r.Values[6], r.Values[6], r.Values[6]) var voters []ethcommon.Address if r.Values[6] != nil { rawVoters := r.Values[6].([][]byte) @@ -426,13 +427,7 @@ func rowToEpoch(r *common.Row) (*Epoch, error) { var amounts []*types.Decimal if r.Values[7] != nil { - rawAmounts := r.Values[7].([][]*types.Decimal) - for _, rawAmount := range rawAmounts { - if rawAmount == nil { - continue - } - amounts = append(amounts, rawAmount...) - } + amounts = r.Values[7].([]*types.Decimal) } var voteNonces []int64 @@ -448,7 +443,7 @@ func rowToEpoch(r *common.Row) (*Epoch, error) { var signatures [][]byte if r.Values[9] != nil { - signatures = r.Values[7].([][]byte) + signatures = r.Values[9].([][]byte) } return &Epoch{ @@ -461,9 +456,10 @@ func rowToEpoch(r *common.Row) (*Epoch, error) { BlockHash: blockHash, Root: rewardRoot, EpochVoteInfo: EpochVoteInfo{ - Voters: voters, - VoteSigs: signatures, - VoteNonces: voteNonces, + Voters: voters, + VoteAmounts: amounts, + VoteSigs: signatures, + VoteNonces: voteNonces, }, }, nil } diff --git a/node/exts/erc20reward/named_extension.go b/node/exts/erc20reward/named_extension.go index 66b0ca80f..601775a5c 100644 --- a/node/exts/erc20reward/named_extension.go +++ b/node/exts/erc20reward/named_extension.go @@ -221,8 +221,9 @@ func init() { {Name: "reward_root", Type: types.ByteaType, Nullable: true}, {Name: "end_block_hash", Type: types.ByteaType, Nullable: true}, {Name: "voters", Type: types.TextArrayType, Nullable: true}, - {Name: "voter_signatures", Type: types.ByteaArrayType, Nullable: true}, + {Name: "vote_amounts", Type: types.TextArrayType, Nullable: true}, {Name: "vote_nonces", Type: types.IntArrayType, Nullable: true}, + {Name: "voter_signatures", Type: types.ByteaArrayType, Nullable: true}, }, }, AccessModifiers: []precompiles.Modifier{precompiles.PUBLIC, precompiles.VIEW}, @@ -245,8 +246,9 @@ func init() { {Name: "reward_root", Type: types.ByteaType, Nullable: true}, {Name: "end_block_hash", Type: types.ByteaType, Nullable: true}, {Name: "voters", Type: types.TextArrayType, Nullable: true}, - {Name: "voter_signatures", Type: types.ByteaArrayType, Nullable: true}, + {Name: "vote_amounts", Type: types.TextArrayType, Nullable: true}, {Name: "vote_nonces", Type: types.IntArrayType, Nullable: true}, + {Name: "voter_signatures", Type: types.ByteaArrayType, Nullable: true}, }, }, AccessModifiers: []precompiles.Modifier{precompiles.PUBLIC, precompiles.VIEW},