From e4433b1835a2e9eadbccf7642dfcb1ba64fb744c Mon Sep 17 00:00:00 2001 From: taratorio <94537774+taratorio@users.noreply.github.com> Date: Sat, 27 Apr 2024 10:41:39 +0300 Subject: [PATCH] make: fix make devtools --- accounts/abi/bind/template.go | 17 +++++++-- consensus/aura/auraabi/gen_block_reward.go | 42 ++++++++++++++++++++++ 2 files changed, 57 insertions(+), 2 deletions(-) diff --git a/accounts/abi/bind/template.go b/accounts/abi/bind/template.go index 344b1974bf0..d80dacf1a0e 100644 --- a/accounts/abi/bind/template.go +++ b/accounts/abi/bind/template.go @@ -90,8 +90,21 @@ package {{.Package}} import ( "math/big" "strings" - "fmt" - "reflect" + +{{range .Contracts}} + {{$stop := false}} + {{range .Transacts}} + {{if ne (len .Normalized.Inputs) 0}} + "fmt" + "reflect" + {{$stop = true}} + {{break}} + {{end}} + {{end}} + {{if $stop}} + {{break}} + {{end}} +{{end}} ethereum "github.com/ledgerwatch/erigon" "github.com/ledgerwatch/erigon/accounts/abi" diff --git a/consensus/aura/auraabi/gen_block_reward.go b/consensus/aura/auraabi/gen_block_reward.go index 27d4fce7bec..4137b58f952 100644 --- a/consensus/aura/auraabi/gen_block_reward.go +++ b/consensus/aura/auraabi/gen_block_reward.go @@ -7,6 +7,9 @@ import ( "math/big" "strings" + "fmt" + "reflect" + ethereum "github.com/ledgerwatch/erigon" libcommon "github.com/ledgerwatch/erigon-lib/common" "github.com/ledgerwatch/erigon/accounts/abi" @@ -191,3 +194,42 @@ func (_BlockReward *BlockRewardSession) Reward(benefactors []libcommon.Address, func (_BlockReward *BlockRewardTransactorSession) Reward(benefactors []libcommon.Address, kind []uint16) (types.Transaction, error) { return _BlockReward.Contract.Reward(&_BlockReward.TransactOpts, benefactors, kind) } + +// RewardParams is an auto generated read-only Go binding of transcaction calldata params +type RewardParams struct { + Param_benefactors []libcommon.Address + Param_kind []uint16 +} + +// Parse Reward method from calldata of a transaction +// +// Solidity: function reward(address[] benefactors, uint16[] kind) returns(address[], uint256[]) +func ParseReward(calldata []byte) (*RewardParams, error) { + if len(calldata) <= 4 { + return nil, fmt.Errorf("invalid calldata input") + } + + _abi, err := abi.JSON(strings.NewReader(BlockRewardABI)) + if err != nil { + return nil, fmt.Errorf("failed to get abi of registry metadata: %w", err) + } + + out, err := _abi.Methods["reward"].Inputs.Unpack(calldata[4:]) + if err != nil { + return nil, fmt.Errorf("failed to unpack reward params data: %w", err) + } + + var paramsResult = new(RewardParams) + value := reflect.ValueOf(paramsResult).Elem() + + if value.NumField() != len(out) { + return nil, fmt.Errorf("failed to match calldata with param field number") + } + + out0 := *abi.ConvertType(out[0], new([]libcommon.Address)).(*[]libcommon.Address) + out1 := *abi.ConvertType(out[1], new([]uint16)).(*[]uint16) + + return &RewardParams{ + Param_benefactors: out0, Param_kind: out1, + }, nil +}