2019-11-23 17:57:05 +00:00
|
|
|
// TODO: These types should be defined using protobuf, but protoc can only emit []byte instead of types.HexBytes,
|
|
|
|
// 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.
|
2018-09-24 18:07:34 +00:00
|
|
|
|
2019-07-03 19:13:11 +00:00
|
|
|
package shhext
|
2018-09-24 18:07:34 +00:00
|
|
|
|
|
|
|
import (
|
2019-07-17 22:25:42 +00:00
|
|
|
"crypto/ecdsa"
|
2020-01-02 09:10:19 +00:00
|
|
|
|
2019-11-23 17:57:05 +00:00
|
|
|
"github.com/status-im/status-go/eth-node/crypto"
|
|
|
|
"github.com/status-im/status-go/eth-node/types"
|
2018-09-24 18:07:34 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// SendPublicMessageRPC represents the RPC payload for the SendPublicMessage RPC method
|
|
|
|
type SendPublicMessageRPC struct {
|
2019-07-17 22:25:42 +00:00
|
|
|
Sig string // TODO: remove
|
2018-09-24 18:07:34 +00:00
|
|
|
Chat string
|
2019-11-23 17:57:05 +00:00
|
|
|
Payload types.HexBytes
|
2018-09-24 18:07:34 +00:00
|
|
|
}
|
|
|
|
|
2019-11-21 16:19:22 +00:00
|
|
|
// TODO: implement with accordance to https://github.com/status-im/status-go/protocol/issues/28.
|
2019-07-17 22:25:42 +00:00
|
|
|
func (m SendPublicMessageRPC) ID() string { return m.Chat }
|
|
|
|
|
|
|
|
func (m SendPublicMessageRPC) PublicName() string { return m.Chat }
|
|
|
|
|
|
|
|
func (m SendPublicMessageRPC) PublicKey() *ecdsa.PublicKey { return nil }
|
|
|
|
|
2018-09-24 18:07:34 +00:00
|
|
|
// SendDirectMessageRPC represents the RPC payload for the SendDirectMessage RPC method
|
|
|
|
type SendDirectMessageRPC struct {
|
2019-07-17 22:25:42 +00:00
|
|
|
Sig string // TODO: remove
|
2018-12-18 15:27:12 +00:00
|
|
|
Chat string
|
2019-11-23 17:57:05 +00:00
|
|
|
Payload types.HexBytes
|
|
|
|
PubKey types.HexBytes
|
2019-07-17 22:25:42 +00:00
|
|
|
DH bool // TODO: make sure to remove safely
|
|
|
|
}
|
|
|
|
|
2019-11-21 16:19:22 +00:00
|
|
|
// TODO: implement with accordance to https://github.com/status-im/status-go/protocol/issues/28.
|
2019-07-17 22:25:42 +00:00
|
|
|
func (m SendDirectMessageRPC) ID() string { return "" }
|
|
|
|
|
|
|
|
func (m SendDirectMessageRPC) PublicName() string { return "" }
|
|
|
|
|
|
|
|
func (m SendDirectMessageRPC) PublicKey() *ecdsa.PublicKey {
|
|
|
|
publicKey, _ := crypto.UnmarshalPubkey(m.PubKey)
|
|
|
|
return publicKey
|
|
|
|
}
|
|
|
|
|
|
|
|
type JoinRPC struct {
|
|
|
|
Chat string
|
2019-11-23 17:57:05 +00:00
|
|
|
PubKey types.HexBytes
|
|
|
|
Payload types.HexBytes
|
2019-07-17 22:25:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (m JoinRPC) ID() string { return m.Chat }
|
|
|
|
|
|
|
|
func (m JoinRPC) PublicName() string {
|
|
|
|
if len(m.PubKey) > 0 {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
return m.Chat
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m JoinRPC) PublicKey() *ecdsa.PublicKey {
|
|
|
|
if len(m.PubKey) > 0 {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
publicKey, _ := crypto.UnmarshalPubkey(m.PubKey)
|
|
|
|
return publicKey
|
2018-09-24 18:07:34 +00:00
|
|
|
}
|