diff --git a/cmd/ethkit/balance.go b/cmd/ethkit/balance.go index b38d0472..6ced50bb 100644 --- a/cmd/ethkit/balance.go +++ b/cmd/ethkit/balance.go @@ -16,8 +16,8 @@ import ( ) const ( - flagBalanceBlock = "block" - flagBalanceEther = "ether" + flagBalanceBlock = "block" + flagBalanceEther = "ether" flagBalanceRpcUrl = "rpc-url" ) @@ -28,11 +28,11 @@ func init() { func NewBalanceCmd() *cobra.Command { c := &balance{} cmd := &cobra.Command{ - Use: "balance [account]", - Short: "Get the balance of an account", + Use: "balance [account]", + Short: "Get the balance of an account", Aliases: []string{"b"}, - Args: cobra.ExactArgs(1), - RunE: c.Run, + Args: cobra.ExactArgs(1), + RunE: c.Run, } cmd.Flags().StringP(flagBalanceBlock, "B", "latest", "The block height to query at") diff --git a/cmd/ethkit/block.go b/cmd/ethkit/block.go index 98fe565a..ce36894d 100644 --- a/cmd/ethkit/block.go +++ b/cmd/ethkit/block.go @@ -16,10 +16,10 @@ import ( ) const ( - flagBlockField = "field" - flagBlockFull = "full" + flagBlockField = "field" + flagBlockFull = "full" flagBlockRpcUrl = "rpc-url" - flagBlockJson = "json" + flagBlockJson = "json" ) func init() { @@ -113,52 +113,52 @@ func (c *block) Run(cmd *cobra.Command, args []string) error { // Header is a customized block header for cli. type Header struct { - ParentHash common.Hash `json:"parentHash"` - UncleHash common.Hash `json:"sha3Uncles"` - Coinbase common.Address `json:"miner"` - Hash common.Hash `json:"hash"` - Root common.Hash `json:"stateRoot"` - TxHash common.Hash `json:"transactionsRoot"` - ReceiptHash common.Hash `json:"receiptsRoot"` - Bloom types.Bloom `json:"logsBloom"` - Difficulty *big.Int `json:"difficulty"` - Number *big.Int `json:"number"` - GasLimit uint64 `json:"gasLimit"` - GasUsed uint64 `json:"gasUsed"` - Time uint64 `json:"timestamp"` - Extra []byte `json:"extraData"` - MixDigest common.Hash `json:"mixHash"` - Nonce types.BlockNonce `json:"nonce"` - BaseFee *big.Int `json:"baseFeePerGas"` - WithdrawalsHash *common.Hash `json:"withdrawalsRoot"` - Size common.StorageSize `json:"size"` + ParentHash common.Hash `json:"parentHash"` + UncleHash common.Hash `json:"sha3Uncles"` + Coinbase common.Address `json:"miner"` + Hash common.Hash `json:"hash"` + Root common.Hash `json:"stateRoot"` + TxHash common.Hash `json:"transactionsRoot"` + ReceiptHash common.Hash `json:"receiptsRoot"` + Bloom types.Bloom `json:"logsBloom"` + Difficulty *big.Int `json:"difficulty"` + Number *big.Int `json:"number"` + GasLimit uint64 `json:"gasLimit"` + GasUsed uint64 `json:"gasUsed"` + Time uint64 `json:"timestamp"` + Extra []byte `json:"extraData"` + MixDigest common.Hash `json:"mixHash"` + Nonce types.BlockNonce `json:"nonce"` + BaseFee *big.Int `json:"baseFeePerGas"` + WithdrawalsHash *common.Hash `json:"withdrawalsRoot"` + Size common.StorageSize `json:"size"` // TODO: totalDifficulty to be implemented // TotalDifficulty *big.Int `json:"totalDifficulty"` - TransactionsHash []common.Hash `json:"transactions"` + TransactionsHash []common.Hash `json:"transactions"` } // NewHeader returns the custom-built Header object. func NewHeader(b *types.Block) *Header { return &Header{ - ParentHash: b.Header().ParentHash, - UncleHash: b.Header().UncleHash, - Coinbase: b.Header().Coinbase, - Hash: b.Hash(), - Root: b.Header().Root, - TxHash: b.Header().TxHash, - ReceiptHash: b.ReceiptHash(), - Bloom: b.Bloom(), - Difficulty: b.Header().Difficulty, - Number: b.Header().Number, - GasLimit: b.Header().GasLimit, - GasUsed: b.Header().GasUsed, - Time: b.Header().Time, - Extra: b.Header().Extra, - MixDigest: b.Header().MixDigest, - Nonce: b.Header().Nonce, - BaseFee: b.Header().BaseFee, - WithdrawalsHash: b.Header().WithdrawalsHash, - Size: b.Header().Size(), + ParentHash: b.Header().ParentHash, + UncleHash: b.Header().UncleHash, + Coinbase: b.Header().Coinbase, + Hash: b.Hash(), + Root: b.Header().Root, + TxHash: b.Header().TxHash, + ReceiptHash: b.ReceiptHash(), + Bloom: b.Bloom(), + Difficulty: b.Header().Difficulty, + Number: b.Header().Number, + GasLimit: b.Header().GasLimit, + GasUsed: b.Header().GasUsed, + Time: b.Header().Time, + Extra: b.Header().Extra, + MixDigest: b.Header().MixDigest, + Nonce: b.Header().Nonce, + BaseFee: b.Header().BaseFee, + WithdrawalsHash: b.Header().WithdrawalsHash, + Size: b.Header().Size(), // TotalDifficulty: b.Difficulty(), TransactionsHash: TransactionsHash(*b), } @@ -209,9 +209,9 @@ type Block struct { Size common.StorageSize `json:"size"` // TODO: totalDifficulty to be implemented // TotalDifficulty *big.Int `json:"totalDifficulty"` - Uncles []*types.Header `json:"uncles"` - Transactions types.Transactions `json:"transactions"` - Withdrawals types.Withdrawals `json:"withdrawals"` + Uncles []*types.Header `json:"uncles"` + Transactions types.Transactions `json:"transactions"` + Withdrawals types.Withdrawals `json:"withdrawals"` } // NewBlock returns the custom-built Block object. @@ -237,10 +237,10 @@ func NewBlock(b *types.Block) *Block { WithdrawalsHash: b.Header().WithdrawalsHash, Size: b.Header().Size(), // TotalDifficulty: b.Difficulty(), - Uncles: b.Uncles(), - Transactions: b.Transactions(), + Uncles: b.Uncles(), + Transactions: b.Transactions(), // TODO: Withdrawals is empty. To be fixed. - Withdrawals: b.Withdrawals(), + Withdrawals: b.Withdrawals(), } } diff --git a/cmd/ethkit/print.go b/cmd/ethkit/print.go index 9a00925b..ce183bbb 100644 --- a/cmd/ethkit/print.go +++ b/cmd/ethkit/print.go @@ -119,7 +119,8 @@ func formatFloat(f any) string { } func base64ToHex(str any) any { - _, ok := str.(string); if !ok { + _, ok := str.(string) + if !ok { return str } decoded, err := base64.StdEncoding.DecodeString(str.(string)) diff --git a/cmd/ethkit/print_test.go b/cmd/ethkit/print_test.go index 5591e5d5..6db83f59 100644 --- a/cmd/ethkit/print_test.go +++ b/cmd/ethkit/print_test.go @@ -37,7 +37,7 @@ var ( }, { "item3": 3e7, - "item4": 2E7, + "item4": 2e7, "item5": 2.123456e7, }, },