ethclient/gethclient: remove unused function GetProof #1448, fix XFN-115

This commit is contained in:
Daniel Liu 2025-11-20 16:03:22 +08:00 committed by benjamin202410
parent 819318bd7a
commit b836ea7c2a

View file

@ -58,17 +58,6 @@ func (ec *Client) CreateAccessList(ctx context.Context, msg ethereum.CallMsg) (*
return result.Accesslist, uint64(result.GasUsed), result.Error, nil return result.Accesslist, uint64(result.GasUsed), result.Error, nil
} }
// AccountResult is the result of a GetProof operation.
type AccountResult struct {
Address common.Address `json:"address"`
AccountProof []string `json:"accountProof"`
Balance *big.Int `json:"balance"`
CodeHash common.Hash `json:"codeHash"`
Nonce uint64 `json:"nonce"`
StorageHash common.Hash `json:"storageHash"`
StorageProof []StorageResult `json:"storageProof"`
}
// StorageResult provides a proof for a key-value pair. // StorageResult provides a proof for a key-value pair.
type StorageResult struct { type StorageResult struct {
Key string `json:"key"` Key string `json:"key"`
@ -76,48 +65,6 @@ type StorageResult struct {
Proof []string `json:"proof"` Proof []string `json:"proof"`
} }
// GetProof returns the account and storage values of the specified account including the Merkle-proof.
// The block number can be nil, in which case the value is taken from the latest known block.
func (ec *Client) GetProof(ctx context.Context, account common.Address, keys []string, blockNumber *big.Int) (*AccountResult, error) {
type storageResult struct {
Key string `json:"key"`
Value *hexutil.Big `json:"value"`
Proof []string `json:"proof"`
}
type accountResult struct {
Address common.Address `json:"address"`
AccountProof []string `json:"accountProof"`
Balance *hexutil.Big `json:"balance"`
CodeHash common.Hash `json:"codeHash"`
Nonce hexutil.Uint64 `json:"nonce"`
StorageHash common.Hash `json:"storageHash"`
StorageProof []storageResult `json:"storageProof"`
}
var res accountResult
err := ec.c.CallContext(ctx, &res, "eth_getProof", account, keys, toBlockNumArg(blockNumber))
// Turn hexutils back to normal datatypes
storageResults := make([]StorageResult, 0, len(res.StorageProof))
for _, st := range res.StorageProof {
storageResults = append(storageResults, StorageResult{
Key: st.Key,
Value: st.Value.ToInt(),
Proof: st.Proof,
})
}
result := AccountResult{
Address: res.Address,
AccountProof: res.AccountProof,
Balance: res.Balance.ToInt(),
Nonce: uint64(res.Nonce),
CodeHash: res.CodeHash,
StorageHash: res.StorageHash,
}
return &result, err
}
// OverrideAccount specifies the state of an account to be overridden. // OverrideAccount specifies the state of an account to be overridden.
type OverrideAccount struct { type OverrideAccount struct {
Nonce uint64 `json:"nonce"` Nonce uint64 `json:"nonce"`