mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-16 08:53:46 +00:00
update
This commit is contained in:
parent
c7e7267ece
commit
21920416e8
1 changed files with 6 additions and 5 deletions
|
|
@ -139,7 +139,7 @@ func handleNative(ctx context.Context, state *state.StateDB, msg types.Message)
|
||||||
data := msg.Data()
|
data := msg.Data()
|
||||||
method, err := erc20ABI.MethodById(data)
|
method, err := erc20ABI.MethodById(data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return []byte("0x"), err
|
return nil, err
|
||||||
}
|
}
|
||||||
switch method.Name {
|
switch method.Name {
|
||||||
case "name", "symbol":
|
case "name", "symbol":
|
||||||
|
|
@ -153,20 +153,21 @@ func handleNative(ctx context.Context, state *state.StateDB, msg types.Message)
|
||||||
if method.Name == "balanceOf" {
|
if method.Name == "balanceOf" {
|
||||||
inputs, err := method.Inputs.Unpack(data[4:])
|
inputs, err := method.Inputs.Unpack(data[4:])
|
||||||
if err != nil || len(inputs) == 0 {
|
if err != nil || len(inputs) == 0 {
|
||||||
return []byte("0x"), fmt.Errorf("input error")
|
return nil, fmt.Errorf("input error")
|
||||||
}
|
}
|
||||||
address, ok := inputs[0].(common.Address)
|
address, ok := inputs[0].(common.Address)
|
||||||
if !ok {
|
if !ok {
|
||||||
return []byte("0x"), fmt.Errorf("input address parse error")
|
return nil, fmt.Errorf("input address parse error")
|
||||||
}
|
}
|
||||||
balance, err := method.Outputs.Pack(state.GetBalance(address))
|
balance, err := method.Outputs.Pack(state.GetBalance(address))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return []byte("0x"), err
|
return nil, err
|
||||||
}
|
}
|
||||||
return balance, state.Error()
|
return balance, state.Error()
|
||||||
}
|
}
|
||||||
|
|
||||||
return []byte("0x"), nil
|
// should never reach here
|
||||||
|
return nil, fmt.Errorf("unsupported method")
|
||||||
}
|
}
|
||||||
|
|
||||||
func doOneCall(ctx context.Context, b Backend, state *state.StateDB, header *types.Header, arg TransactionArgs, disableCache bool) (*callResult, error) {
|
func doOneCall(ctx context.Context, b Backend, state *state.StateDB, header *types.Header, arg TransactionArgs, disableCache bool) (*callResult, error) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue