github.com/status-im/status-go@v1.1.0/services/ext/rpc.go (about) 1 // TODO: These types should be defined using protobuf, but protoc can only emit []byte instead of types.HexBytes, 2 // which causes issues when marshaling to JSON on the react side. Let's do that once the chat protocol is moved to the go repo. 3 4 package ext 5 6 import ( 7 "crypto/ecdsa" 8 9 "github.com/status-im/status-go/eth-node/crypto" 10 "github.com/status-im/status-go/eth-node/types" 11 ) 12 13 // SendPublicMessageRPC represents the RPC payload for the SendPublicMessage RPC method 14 type SendPublicMessageRPC struct { 15 Sig string // TODO: remove 16 Chat string 17 Payload types.HexBytes 18 } 19 20 // TODO: implement with accordance to https://github.com/status-im/status-go/protocol/issues/28. 21 func (m SendPublicMessageRPC) ID() string { return m.Chat } 22 23 func (m SendPublicMessageRPC) PublicName() string { return m.Chat } 24 25 func (m SendPublicMessageRPC) PublicKey() *ecdsa.PublicKey { return nil } 26 27 // SendDirectMessageRPC represents the RPC payload for the SendDirectMessage RPC method 28 type SendDirectMessageRPC struct { 29 Sig string // TODO: remove 30 Chat string 31 Payload types.HexBytes 32 PubKey types.HexBytes 33 DH bool // TODO: make sure to remove safely 34 } 35 36 // TODO: implement with accordance to https://github.com/status-im/status-go/protocol/issues/28. 37 func (m SendDirectMessageRPC) ID() string { return "" } 38 39 func (m SendDirectMessageRPC) PublicName() string { return "" } 40 41 func (m SendDirectMessageRPC) PublicKey() *ecdsa.PublicKey { 42 publicKey, _ := crypto.UnmarshalPubkey(m.PubKey) 43 return publicKey 44 } 45 46 type JoinRPC struct { 47 Chat string 48 PubKey types.HexBytes 49 Payload types.HexBytes 50 } 51 52 func (m JoinRPC) ID() string { return m.Chat } 53 54 func (m JoinRPC) PublicName() string { 55 if len(m.PubKey) > 0 { 56 return "" 57 } 58 return m.Chat 59 } 60 61 func (m JoinRPC) PublicKey() *ecdsa.PublicKey { 62 if len(m.PubKey) > 0 { 63 return nil 64 } 65 publicKey, _ := crypto.UnmarshalPubkey(m.PubKey) 66 return publicKey 67 }