Merge pull request #3535 from filecoin-project/steb/robust-method-lookup
[cli/state] Robust actor lookup
This commit is contained in:
commit
e52232d85f
54
cli/state.go
54
cli/state.go
@ -26,11 +26,7 @@ import (
|
|||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin"
|
"github.com/filecoin-project/specs-actors/actors/builtin"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/market"
|
"github.com/filecoin-project/specs-actors/actors/builtin/exported"
|
||||||
miner2 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/multisig"
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/paych"
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/power"
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/runtime/exitcode"
|
"github.com/filecoin-project/specs-actors/actors/runtime/exitcode"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
@ -568,25 +564,7 @@ var stateGetActorCmd = &cli.Command{
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
var strtype string
|
strtype := builtin.ActorNameByCode(a.Code)
|
||||||
switch a.Code {
|
|
||||||
case builtin.AccountActorCodeID:
|
|
||||||
strtype = "account"
|
|
||||||
case builtin.MultisigActorCodeID:
|
|
||||||
strtype = "multisig"
|
|
||||||
case builtin.CronActorCodeID:
|
|
||||||
strtype = "cron"
|
|
||||||
case builtin.InitActorCodeID:
|
|
||||||
strtype = "init"
|
|
||||||
case builtin.StorageMinerActorCodeID:
|
|
||||||
strtype = "miner"
|
|
||||||
case builtin.StorageMarketActorCodeID:
|
|
||||||
strtype = "market"
|
|
||||||
case builtin.StoragePowerActorCodeID:
|
|
||||||
strtype = "power"
|
|
||||||
default:
|
|
||||||
strtype = "unknown"
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Printf("Address:\t%s\n", addr)
|
fmt.Printf("Address:\t%s\n", addr)
|
||||||
fmt.Printf("Balance:\t%s\n", types.FIL(a.Balance))
|
fmt.Printf("Balance:\t%s\n", types.FIL(a.Balance))
|
||||||
@ -1460,21 +1438,21 @@ func parseParamsForMethod(act cid.Cid, method uint64, args []string) ([]byte, er
|
|||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var f interface{}
|
var target abi.Invokee
|
||||||
switch act {
|
for _, actor := range exported.BuiltinActors() {
|
||||||
case builtin.StorageMarketActorCodeID:
|
if actor.Code() == act {
|
||||||
f = market.Actor{}.Exports()[method]
|
target = actor
|
||||||
case builtin.StorageMinerActorCodeID:
|
}
|
||||||
f = miner2.Actor{}.Exports()[method]
|
|
||||||
case builtin.StoragePowerActorCodeID:
|
|
||||||
f = power.Actor{}.Exports()[method]
|
|
||||||
case builtin.MultisigActorCodeID:
|
|
||||||
f = multisig.Actor{}.Exports()[method]
|
|
||||||
case builtin.PaymentChannelActorCodeID:
|
|
||||||
f = paych.Actor{}.Exports()[method]
|
|
||||||
default:
|
|
||||||
return nil, fmt.Errorf("the lazy devs didnt add support for that actor to this call yet")
|
|
||||||
}
|
}
|
||||||
|
if target == nil {
|
||||||
|
return nil, fmt.Errorf("unknown actor %s", act)
|
||||||
|
}
|
||||||
|
methods := target.Exports()
|
||||||
|
if uint64(len(methods)) <= method || methods[method] == nil {
|
||||||
|
return nil, fmt.Errorf("unknown method %d for actor %s", method, act)
|
||||||
|
}
|
||||||
|
|
||||||
|
f := methods[method]
|
||||||
|
|
||||||
rf := reflect.TypeOf(f)
|
rf := reflect.TypeOf(f)
|
||||||
if rf.NumIn() != 3 {
|
if rf.NumIn() != 3 {
|
||||||
|
Loading…
Reference in New Issue
Block a user