Skip to content

Commit

Permalink
go fmt ./...
Browse files Browse the repository at this point in the history
  • Loading branch information
attente committed Sep 6, 2024
1 parent d41fe41 commit 5679a31
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 56 deletions.
12 changes: 6 additions & 6 deletions cmd/ethkit/balance.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import (
)

const (
flagBalanceBlock = "block"
flagBalanceEther = "ether"
flagBalanceBlock = "block"
flagBalanceEther = "ether"
flagBalanceRpcUrl = "rpc-url"
)

Expand All @@ -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")
Expand Down
96 changes: 48 additions & 48 deletions cmd/ethkit/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import (
)

const (
flagBlockField = "field"
flagBlockFull = "full"
flagBlockField = "field"
flagBlockFull = "full"
flagBlockRpcUrl = "rpc-url"
flagBlockJson = "json"
flagBlockJson = "json"
)

func init() {
Expand Down Expand Up @@ -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),
}
Expand Down Expand Up @@ -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.
Expand All @@ -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(),
}
}

Expand Down
3 changes: 2 additions & 1 deletion cmd/ethkit/print.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion cmd/ethkit/print_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ var (
},
{
"item3": 3e7,
"item4": 2E7,
"item4": 2e7,
"item5": 2.123456e7,
},
},
Expand Down

0 comments on commit 5679a31

Please sign in to comment.