Skip to content

Commit fcf906f

Browse files
authored
Merge pull request #55 from meshplus/fix/fix-invoke-interchain
Fix/fix invoke interchain
2 parents 5581035 + f6a4d7b commit fcf906f

File tree

21 files changed

+3104
-1013
lines changed

21 files changed

+3104
-1013
lines changed

a_main-packr.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client.go

Lines changed: 220 additions & 188 deletions
Large diffs are not rendered by default.

config.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ type Fabric struct {
2121
CCID string `toml:"ccid" json:"ccid"`
2222
ChannelId string `mapstructure:"channel_id" toml:"channel_id" json:"channel_id"`
2323
Org string `toml:"org" json:"org"`
24+
ServerPort string `toml:"server_port" json:"server_port"`
2425
TimeoutHeight int64 `mapstructure:"timeout_height" json:"timeout_height"`
2526
}
2627

@@ -35,7 +36,7 @@ func DefaultConfig() *Config {
3536
Fabric: Fabric{
3637
Name: "fabric",
3738
Username: "Admin",
38-
CCID: "Broker-001",
39+
CCID: "broker",
3940
ChannelId: "mychannel",
4041
Org: "org2",
4142
TimeoutHeight: 30,

event.go

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
package main
22

33
import (
4-
"fmt"
54
"strings"
65

76
"github.com/cloudflare/cfssl/log"
7+
"github.com/ethereum/go-ethereum/crypto"
88
"github.com/meshplus/bitxhub-model/pb"
99
)
1010

1111
type Event struct {
12-
Index uint64 `json:"index"`
13-
DstFullID string `json:"dst_full_id"`
14-
SrcFullID string `json:"src_full_id"`
15-
Func string `json:"func"`
16-
Args string `json:"args"`
17-
Argscb string `json:"argscb"`
18-
Argsrb string `json:"argsrb"`
12+
Index uint64 `json:"index"`
13+
DstFullID string `json:"dst_full_id"`
14+
SrcFullID string `json:"src_full_id"`
15+
Encrypt bool `json:"encrypt"`
16+
CallFunc CallFunc `json:"call_func"`
17+
CallBack CallFunc `json:"callback"`
18+
RollBack CallFunc `json:"rollback"`
1919
}
2020

2121
func (ev *Event) Convert2IBTP(timeoutHeight int64, ibtpType pb.IBTP_Type) *pb.IBTP {
@@ -44,25 +44,26 @@ func handleArgs(args string) [][]byte {
4444
}
4545

4646
func (ev *Event) encryptPayload() ([]byte, error) {
47-
funcSplit := strings.Split(ev.Func, ",")
48-
if len(funcSplit) != 3 {
49-
return nil, fmt.Errorf("ibtp func not is (func, callback,rollback)")
50-
}
5147
content := &pb.Content{
52-
Func: funcSplit[0],
53-
Args: handleArgs(ev.Args),
54-
Callback: funcSplit[1],
55-
ArgsCb: handleArgs(ev.Argscb),
56-
Rollback: funcSplit[2],
57-
ArgsRb: handleArgs(ev.Argsrb),
48+
Func: ev.CallFunc.Func,
49+
Args: ev.CallFunc.Args,
5850
}
5951
data, err := content.Marshal()
6052
if err != nil {
6153
return nil, err
6254
}
6355

56+
var packed []byte
57+
packed = append(packed, []byte(ev.CallFunc.Func)...)
58+
for _, arg := range ev.CallFunc.Args {
59+
packed = append(packed, arg...)
60+
}
61+
hash := crypto.Keccak256(packed)
62+
6463
ibtppd := &pb.Payload{
65-
Content: data,
64+
Encrypted: ev.Encrypt,
65+
Content: data,
66+
Hash: hash,
6667
}
6768
return ibtppd.Marshal()
6869
}

example/contracts.zip

13.4 MB
Binary file not shown.

0 commit comments

Comments
 (0)