Skip to content

Commit a860462

Browse files
authored
Merge pull request #231 from meshplus/fix-release-1.11
fix(cmd):update appchain register and rule
2 parents 6c4523e + fad506a commit a860462

File tree

5 files changed

+36
-333
lines changed

5 files changed

+36
-333
lines changed

cmd/pier/did.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ var methodCommand = cli.Command{
4545
appchainVersionFlag,
4646
appchainValidatorFlag,
4747
appchainConsensusFlag,
48+
appchainRuleFlag,
49+
appchainRuleUrlFlag,
4850
governanceReasonFlag,
4951
},
5052
Action: registerMethod,
@@ -89,6 +91,8 @@ func registerMethod(ctx *cli.Context) error {
8991
version := ctx.String("version")
9092
validatorsPath := ctx.String("validators")
9193
consensus := ctx.String("consensus")
94+
rule := ctx.String("rule")
95+
rule_url := ctx.String("rule-url")
9296
reason := ctx.String("reason")
9397
validatorData, err := ioutil.ReadFile(validatorsPath)
9498
if err != nil {
@@ -107,13 +111,13 @@ func registerMethod(ctx *cli.Context) error {
107111
// init method registry with this admin key
108112
receipt, err := client.InvokeBVMContract(
109113
constant.AppchainMgrContractAddr.Address(),
110-
"Register", nil,
114+
"RegisterV2", nil,
111115
rpcx.String(method),
112116
rpcx.String(didDocAddr), rpcx.String(didDocHash),
113117
rpcx.String(string(validatorData)), rpcx.String(consensus), rpcx.String(typ),
114118
rpcx.String(name), rpcx.String(desc), rpcx.String(version),
115119
rpcx.String(pubKey),
116-
rpcx.String(reason),
120+
rpcx.String(reason), rpcx.String(rule), rpcx.String(rule_url),
117121
)
118122
if err != nil {
119123
return fmt.Errorf("invoke bvm contract: %w", err)

cmd/pier/flags.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,16 @@ var (
7272
Usage: "Specific appchain consensus type",
7373
Required: true,
7474
}
75+
appchainRuleFlag = cli.StringFlag{
76+
Name: "rule",
77+
Usage: "Specific appchain rule",
78+
Required: true,
79+
}
80+
appchainRuleUrlFlag = cli.StringFlag{
81+
Name: "rule-url",
82+
Usage: "Specific appchain rule url",
83+
Required: true,
84+
}
7585
governanceReasonFlag = cli.StringFlag{
7686
Name: "reason",
7787
Usage: "Specify governance reason",

cmd/pier/rule.go

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ var ruleCMD = cli.Command{
2626
},
2727
methodFlag,
2828
adminKeyPathFlag,
29-
governanceReasonFlag,
29+
appchainRuleUrlFlag,
3030
},
3131
Action: deployRule,
3232
},
@@ -66,7 +66,7 @@ func deployRule(ctx *cli.Context) error {
6666
rulePath := ctx.String("path")
6767
method := ctx.String("method")
6868
chainAdminKeyPath := ctx.String("admin-key")
69-
reason := ctx.String("reason")
69+
rule_url := ctx.String("rule-url")
7070

7171
client, _, err := initClientWithKeyPath(ctx, chainAdminKeyPath)
7272
if err != nil {
@@ -91,22 +91,16 @@ func deployRule(ctx *cli.Context) error {
9191
appchainMethod := fmt.Sprintf("%s:%s:.", bitxhubRootPrefix, method)
9292
receipt, err := client.InvokeBVMContract(
9393
constant.RuleManagerContractAddr.Address(),
94-
"RegisterRule", nil,
95-
rpcx.String(appchainMethod), rpcx.String(contractAddr.String()), rpcx.String(reason))
94+
"RegisterRuleV2", nil,
95+
rpcx.String(appchainMethod), rpcx.String(contractAddr.String()), rpcx.String(rule_url))
9696
if err != nil {
9797
return fmt.Errorf("Register rule: %w", err)
9898
}
9999

100100
if !receipt.IsSuccess() {
101101
color.Red(fmt.Sprintf("Register rule to bitxhub for appchain %s error: %s", appchainMethod, string(receipt.Ret)))
102102
} else {
103-
proposalId := gjson.Get(string(receipt.Ret), "proposal_id").String()
104-
if proposalId != "" {
105-
color.Green(fmt.Sprintf("Register rule to bitxhub for appchain %s successfully, the bind request was submitted successfully, wait for proposal %s to finish.", appchainMethod, proposalId))
106-
} else {
107-
color.Green(fmt.Sprintf("Register rule to bitxhub for appchain %s successfully.", appchainMethod))
108-
}
109-
103+
color.Green(fmt.Sprintf("Register rule to bitxhub for appchain %s successfully.", appchainMethod))
110104
}
111105

112106
return nil

go.mod

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,19 @@ require (
66
github.com/Rican7/retry v0.1.0
77
github.com/btcsuite/btcd v0.21.0-beta
88
github.com/cbergoon/merkletree v0.2.0
9-
github.com/ethereum/go-ethereum v1.10.7 // indirect
109
github.com/fatih/color v1.9.0
1110
github.com/fsnotify/fsnotify v1.4.9
1211
github.com/gin-gonic/gin v1.6.3
1312
github.com/gobuffalo/packd v1.0.0
1413
github.com/gobuffalo/packr v1.30.1
1514
github.com/gogo/protobuf v1.3.2
1615
github.com/golang/mock v1.5.0
16+
github.com/golang/snappy v0.0.3 // indirect
17+
github.com/google/uuid v1.1.5 // indirect
1718
github.com/hashicorp/go-hclog v0.0.0-20180709165350-ff2cf002a8dd
1819
github.com/hashicorp/go-plugin v1.3.0
20+
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect
21+
github.com/huin/goupnp v1.0.2 // indirect
1922
github.com/ipfs/go-cid v0.0.7
2023
github.com/lestrrat-go/strftime v1.0.3 // indirect
2124
github.com/libp2p/go-libp2p-core v0.6.1
@@ -34,7 +37,14 @@ require (
3437
github.com/urfave/cli v1.22.1
3538
github.com/wonderivan/logger v1.0.0
3639
go.uber.org/atomic v1.6.0
40+
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2 // indirect
41+
golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f // indirect
42+
golang.org/x/mod v0.4.2 // indirect
43+
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
44+
golang.org/x/sys v0.0.0-20210420205809-ac73e9fd8988 // indirect
45+
golang.org/x/text v0.3.6 // indirect
3746
google.golang.org/grpc v1.33.1
47+
honnef.co/go/tools v0.1.3 // indirect
3848
)
3949

4050
replace github.com/libp2p/go-libp2p-core => github.com/libp2p/go-libp2p-core v0.5.6

0 commit comments

Comments
 (0)