pond: Method mapping generator
This commit is contained in:
parent
9b55f4b471
commit
fbd346a36b
5
Makefile
5
Makefile
@ -189,5 +189,10 @@ dist-clean:
|
|||||||
type-gen:
|
type-gen:
|
||||||
go run ./gen/main.go
|
go run ./gen/main.go
|
||||||
|
|
||||||
|
method-gen:
|
||||||
|
(cd ./lotuspond/front/src/chain && go run ./methodgen.go)
|
||||||
|
|
||||||
|
gen: type-gen method-gen
|
||||||
|
|
||||||
print-%:
|
print-%:
|
||||||
@echo $*=$($*)
|
@echo $*=$($*)
|
||||||
|
@ -3,7 +3,7 @@ import CID from 'cids'
|
|||||||
import ReactTooltip from 'react-tooltip'
|
import ReactTooltip from 'react-tooltip'
|
||||||
import * as multihash from "multihashes"
|
import * as multihash from "multihashes"
|
||||||
import State from "./State"
|
import State from "./State"
|
||||||
import methods from "./chain/methods"
|
import methods from "./chain/methods.json"
|
||||||
import Fil from "./Fil";
|
import Fil from "./Fil";
|
||||||
|
|
||||||
function truncAddr(addr, len) {
|
function truncAddr(addr, len) {
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
export default {
|
|
||||||
system: "fil/1/system",
|
|
||||||
init: "fil/1/init",
|
|
||||||
cron: "fil/1/cron",
|
|
||||||
account: "fil/1/account",
|
|
||||||
power: "fil/1/storagepower",
|
|
||||||
miner: "fil/1/storageminer",
|
|
||||||
market: "fil/1/storagemarket",
|
|
||||||
paych: "fil/1/paymentchannel",
|
|
||||||
multisig: "fil/1/multisig",
|
|
||||||
reward: "fil/1/reward",
|
|
||||||
}
|
|
13
lotuspond/front/src/chain/code.json
Normal file
13
lotuspond/front/src/chain/code.json
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"account": "fil/1/account",
|
||||||
|
"cron": "fil/1/cron",
|
||||||
|
"init": "fil/1/init",
|
||||||
|
"market": "fil/1/storagemarket",
|
||||||
|
"miner": "fil/1/storageminer",
|
||||||
|
"multisig": "fil/1/multisig",
|
||||||
|
"paych": "fil/1/paymentchannel",
|
||||||
|
"power": "fil/1/storagepower",
|
||||||
|
"reward": "fil/1/reward",
|
||||||
|
"system": "fil/1/system",
|
||||||
|
"verifreg": "fil/1/verifiedregistry"
|
||||||
|
}
|
85
lotuspond/front/src/chain/methodgen.go
Normal file
85
lotuspond/front/src/chain/methodgen.go
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
|
"reflect"
|
||||||
|
|
||||||
|
"github.com/ipfs/go-cid"
|
||||||
|
"github.com/multiformats/go-multihash"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/builtin"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
if _, err := os.Stat("code.json"); err != nil {
|
||||||
|
panic(err) // note: must run in lotuspond/front/src/chain
|
||||||
|
}
|
||||||
|
|
||||||
|
names := map[string]string{
|
||||||
|
"system": "fil/1/system",
|
||||||
|
"init": "fil/1/init",
|
||||||
|
"cron": "fil/1/cron",
|
||||||
|
"account": "fil/1/account",
|
||||||
|
"power": "fil/1/storagepower",
|
||||||
|
"miner": "fil/1/storageminer",
|
||||||
|
"market": "fil/1/storagemarket",
|
||||||
|
"paych": "fil/1/paymentchannel",
|
||||||
|
"multisig": "fil/1/multisig",
|
||||||
|
"reward": "fil/1/reward",
|
||||||
|
"verifreg": "fil/1/verifiedregistry",
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
b, err := json.MarshalIndent(names, "", " ")
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := ioutil.WriteFile("code.json", b, 0664); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
methods := map[cid.Cid]interface{}{
|
||||||
|
// builtin.SystemActorCodeID: builtin.MethodsSystem - apparently it doesn't have methods
|
||||||
|
builtin.InitActorCodeID: builtin.MethodsInit,
|
||||||
|
builtin.CronActorCodeID: builtin.MethodsCron,
|
||||||
|
builtin.AccountActorCodeID: builtin.MethodsAccount,
|
||||||
|
builtin.StoragePowerActorCodeID: builtin.MethodsPower,
|
||||||
|
builtin.StorageMinerActorCodeID: builtin.MethodsMiner,
|
||||||
|
builtin.StorageMarketActorCodeID: builtin.MethodsMarket,
|
||||||
|
builtin.PaymentChannelActorCodeID: builtin.MethodsPaych,
|
||||||
|
builtin.MultisigActorCodeID: builtin.MethodsMultisig,
|
||||||
|
builtin.RewardActorCodeID: builtin.MethodsReward,
|
||||||
|
builtin.VerifiedRegistryActorCodeID: builtin.MethodsVerifiedRegistry,
|
||||||
|
}
|
||||||
|
|
||||||
|
out := map[string][]string{}
|
||||||
|
for c, methods := range methods {
|
||||||
|
cmh, err := multihash.Decode(c.Hash())
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
rt := reflect.TypeOf(methods)
|
||||||
|
nf := rt.NumField()
|
||||||
|
|
||||||
|
out[string(cmh.Digest)] = append(out[string(cmh.Digest)], "Send")
|
||||||
|
for i := 0; i < nf; i++ {
|
||||||
|
out[string(cmh.Digest)] = append(out[string(cmh.Digest)], rt.Field(i).Name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
b, err := json.MarshalIndent(out, "", " ")
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := ioutil.WriteFile("methods.json", b, 0664); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,47 +1,45 @@
|
|||||||
import code from "./code";
|
{
|
||||||
|
"fil/1/account": [
|
||||||
export default {
|
|
||||||
[code.account]: [
|
|
||||||
"Send",
|
"Send",
|
||||||
"Constructor",
|
"Constructor",
|
||||||
"PubkeyAddress",
|
"PubkeyAddress"
|
||||||
],
|
],
|
||||||
[code.init]: [
|
"fil/1/cron": [
|
||||||
"Send",
|
"Send",
|
||||||
"Constructor",
|
"Constructor",
|
||||||
"Exec",
|
"EpochTick"
|
||||||
],
|
],
|
||||||
[code.cron]: [
|
"fil/1/init": [
|
||||||
"Send",
|
"Send",
|
||||||
"Constructor",
|
"Constructor",
|
||||||
"EpochTick",
|
"Exec"
|
||||||
],
|
],
|
||||||
[code.reward]: [
|
"fil/1/multisig": [
|
||||||
"Send",
|
|
||||||
"Constructor",
|
|
||||||
"AwardBlockReward",
|
|
||||||
"WithdrawReward",
|
|
||||||
],
|
|
||||||
[code.multisig]: [
|
|
||||||
"Send",
|
"Send",
|
||||||
"Constructor",
|
"Constructor",
|
||||||
"Propose",
|
"Propose",
|
||||||
"Approve",
|
"Approve",
|
||||||
"Cancel",
|
"Cancel",
|
||||||
"ClearCompleted",
|
|
||||||
"AddSigner",
|
"AddSigner",
|
||||||
"RemoveSigner",
|
"RemoveSigner",
|
||||||
"SwapSigner",
|
"SwapSigner",
|
||||||
"ChangeNumApprovalsThreshold",
|
"ChangeNumApprovalsThreshold"
|
||||||
],
|
],
|
||||||
[code.paych]: [
|
"fil/1/paymentchannel": [
|
||||||
"Send",
|
"Send",
|
||||||
"Constructor",
|
"Constructor",
|
||||||
"UpdateChannelState",
|
"UpdateChannelState",
|
||||||
"Settle",
|
"Settle",
|
||||||
"Collect",
|
"Collect"
|
||||||
],
|
],
|
||||||
[code.market]: [
|
"fil/1/reward": [
|
||||||
|
"Send",
|
||||||
|
"Constructor",
|
||||||
|
"AwardBlockReward",
|
||||||
|
"LastPerEpochReward",
|
||||||
|
"UpdateNetworkKPI"
|
||||||
|
],
|
||||||
|
"fil/1/storagemarket": [
|
||||||
"Send",
|
"Send",
|
||||||
"Constructor",
|
"Constructor",
|
||||||
"AddBalance",
|
"AddBalance",
|
||||||
@ -51,39 +49,49 @@ export default {
|
|||||||
"VerifyDealsOnSectorProveCommit",
|
"VerifyDealsOnSectorProveCommit",
|
||||||
"OnMinerSectorsTerminate",
|
"OnMinerSectorsTerminate",
|
||||||
"ComputeDataCommitment",
|
"ComputeDataCommitment",
|
||||||
"GetWeightForDealSet",
|
"HandleInitTimeoutDeals"
|
||||||
],
|
],
|
||||||
[code.power]: [
|
"fil/1/storageminer": [
|
||||||
"Send",
|
|
||||||
"Constructor",
|
|
||||||
"AddBalance",
|
|
||||||
"WithdrawBalance",
|
|
||||||
"CreateMiner",
|
|
||||||
"DeleteMiner",
|
|
||||||
"OnSectorProveCommit",
|
|
||||||
"OnSectorTerminate",
|
|
||||||
"OnSectorTemporaryFaultEffectiveBegin",
|
|
||||||
"OnSectorTemporaryFaultEffectiveEnd",
|
|
||||||
"OnSectorModifyWeightDesc",
|
|
||||||
"OnMinerWindowedPoStSuccess",
|
|
||||||
"OnMinerWindowedPoStFailure",
|
|
||||||
"EnrollCronEvent",
|
|
||||||
"ReportConsensusFault",
|
|
||||||
"OnEpochTickEnd",
|
|
||||||
],
|
|
||||||
[code.miner]: [
|
|
||||||
"Send",
|
"Send",
|
||||||
"Constructor",
|
"Constructor",
|
||||||
"ControlAddresses",
|
"ControlAddresses",
|
||||||
"ChangeWorkerAddress",
|
"ChangeWorkerAddress",
|
||||||
"ChangePeerID",
|
"ChangePeerID",
|
||||||
"SubmitWindowedPoSt",
|
"SubmitWindowedPoSt",
|
||||||
"OnDeleteMiner",
|
|
||||||
"PreCommitSector",
|
"PreCommitSector",
|
||||||
"ProveCommitSector",
|
"ProveCommitSector",
|
||||||
"ExtendSectorExpiration",
|
"ExtendSectorExpiration",
|
||||||
"TerminateSectors",
|
"TerminateSectors",
|
||||||
"DeclareTemporaryFaults",
|
"DeclareFaults",
|
||||||
|
"DeclareFaultsRecovered",
|
||||||
"OnDeferredCronEvent",
|
"OnDeferredCronEvent",
|
||||||
|
"CheckSectorProven",
|
||||||
|
"AddLockedFund",
|
||||||
|
"ReportConsensusFault",
|
||||||
|
"WithdrawBalance"
|
||||||
],
|
],
|
||||||
|
"fil/1/storagepower": [
|
||||||
|
"Send",
|
||||||
|
"Constructor",
|
||||||
|
"CreateMiner",
|
||||||
|
"DeleteMiner",
|
||||||
|
"OnSectorProveCommit",
|
||||||
|
"OnSectorTerminate",
|
||||||
|
"OnFaultBegin",
|
||||||
|
"OnFaultEnd",
|
||||||
|
"OnSectorModifyWeightDesc",
|
||||||
|
"EnrollCronEvent",
|
||||||
|
"OnEpochTickEnd",
|
||||||
|
"UpdatePledgeTotal",
|
||||||
|
"OnConsensusFault"
|
||||||
|
],
|
||||||
|
"fil/1/verifiedregistry": [
|
||||||
|
"Send",
|
||||||
|
"Constructor",
|
||||||
|
"AddVerifier",
|
||||||
|
"RemoveVerifier",
|
||||||
|
"AddVerifiedClient",
|
||||||
|
"UseBytes",
|
||||||
|
"RestoreBytes"
|
||||||
|
]
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user