-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
methodgen.go
77 lines (64 loc) · 1.52 KB
/
methodgen.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package main
import (
"encoding/json"
"io/ioutil"
"os"
"github.com/multiformats/go-multihash"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/lotus/chain/stmgr"
)
func main() {
if _, err := os.Stat("code.json"); err != nil {
panic(err) // note: must run in lotuspond/front/src/chain
}
// TODO: ActorUpgrade: this is going to be a problem.
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)
}
}
out := map[string][]string{}
for c, methods := range stmgr.MethodsMap {
cmh, err := multihash.Decode(c.Hash())
if err != nil {
panic(err)
}
name := string(cmh.Digest)
remaining := len(methods)
// iterate over actor methods in order.
for i := abi.MethodNum(0); remaining > 0; i++ {
m, ok := methods[i]
if !ok {
continue
}
out[name] = append(out[name], m.Name)
remaining--
}
}
{
b, err := json.MarshalIndent(out, "", " ")
if err != nil {
panic(err)
}
if err := ioutil.WriteFile("methods.json", b, 0664); err != nil {
panic(err)
}
}
}