Move message to common namespace

This commit is contained in:
Andrea Maria Piana 2020-09-01 15:27:01 +02:00
parent 7d5d413222
commit 00c5b60d7f
No known key found for this signature in database
GPG Key ID: AA6CCA6DE0E06424
19 changed files with 311 additions and 274 deletions

View File

@ -8,6 +8,7 @@ import (
"github.com/status-im/status-go/eth-node/crypto"
"github.com/status-im/status-go/eth-node/types"
"github.com/status-im/status-go/protocol/common"
"github.com/status-im/status-go/protocol/protobuf"
v1protocol "github.com/status-im/status-go/protocol/v1"
)
@ -51,7 +52,7 @@ type Chat struct {
// Denormalized fields
UnviewedMessagesCount uint `json:"unviewedMessagesCount"`
LastMessage *Message `json:"lastMessage"`
LastMessage *common.Message `json:"lastMessage"`
// Group chat fields
// Members are the members who have been invited to the group chat
@ -172,7 +173,7 @@ func (c *Chat) NextClockAndTimestamp(timesource TimeSource) (uint64, uint64) {
return clock, timestamp
}
func (c *Chat) UpdateFromMessage(message *Message, timesource TimeSource) error {
func (c *Chat) UpdateFromMessage(message *common.Message, timesource TimeSource) error {
c.Timestamp = int64(timesource.GetCurrentTime())
// If the clock of the last message is lower, we set the message

View File

@ -5,6 +5,8 @@ import (
"testing"
"github.com/stretchr/testify/suite"
"github.com/status-im/status-go/protocol/common"
)
type ChatTestSuite struct {
@ -75,7 +77,7 @@ func (s *ChatTestSuite) TestValidateChat() {
func (s *ChatTestSuite) TestUpdateFromMessage() {
// Base case, clock is higher
message := &Message{}
message := &common.Message{}
chat := &Chat{}
message.Clock = 1
@ -84,7 +86,7 @@ func (s *ChatTestSuite) TestUpdateFromMessage() {
s.Require().Equal(uint64(1), chat.LastClockValue)
// Clock is lower and lastMessage is not nil
message = &Message{}
message = &common.Message{}
lastMessage := message
chat = &Chat{LastClockValue: 2, LastMessage: lastMessage}
@ -94,7 +96,7 @@ func (s *ChatTestSuite) TestUpdateFromMessage() {
s.Require().Equal(uint64(2), chat.LastClockValue)
// Clock is lower and lastMessage is nil
message = &Message{}
message = &common.Message{}
chat = &Chat{LastClockValue: 2}
message.Clock = 1
@ -103,7 +105,7 @@ func (s *ChatTestSuite) TestUpdateFromMessage() {
s.Require().Equal(uint64(2), chat.LastClockValue)
// Clock is higher but lastMessage has lower clock message then the receiving one
message = &Message{}
message = &common.Message{}
chat = &Chat{LastClockValue: 2}
message.Clock = 1
@ -112,7 +114,7 @@ func (s *ChatTestSuite) TestUpdateFromMessage() {
s.Require().Equal(uint64(2), chat.LastClockValue)
chat.LastClockValue = 4
message = &Message{}
message = &common.Message{}
message.Clock = 3
s.Require().NoError(chat.UpdateFromMessage(message, &testTimeSource{}))
s.Require().Equal(chat.LastMessage, message)
@ -122,7 +124,7 @@ func (s *ChatTestSuite) TestUpdateFromMessage() {
func (s *ChatTestSuite) TestSerializeJSON() {
message := &Message{}
message := &common.Message{}
chat := &Chat{}
message.Clock = 1

View File

@ -1,4 +1,4 @@
package protocol
package common
import (
"crypto/ecdsa"
@ -11,6 +11,7 @@ import (
"unicode/utf8"
"github.com/golang/protobuf/proto"
"github.com/status-im/markdown"
"github.com/status-im/markdown/ast"

View File

@ -1,4 +1,4 @@
package protocol
package common
import (
"io/ioutil"
@ -16,7 +16,7 @@ const expectedJPEG = "data:image/jpeg;base64,/9j/2wBDAAMCAgICAgMCAgIDAwMDBAYEBAQ
const expectedAAC = "data:audio/aac;base64,//FQgBw//NoATGF2YzUyLjcwLjAAQniptokphEFCg5qs1v9fn48+qz1rfWNhwvz+CqB5dipmq3T2PlT1Ld6sPj+19fUt1C3NKV0KowiqohZVCrdf19WMatvV3YbIvAuy/q2RafA8UiZPmZY7DdmHZtP9ri25kedWSiMKQRt79ttlod55LkuX7/f7/f7/f7/YGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYHNqo8g5qs1v9fn48+qz1rfWNhwvz+CqAAAAAAAAAAAAAAAAAAAAAAABw//FQgCNf/CFXbUZfDKFRgsYlKDegtXJH9eLkT54uRM1ckDYDcXRzZGF6Kz5Yps5fTeLY6w7gclwly+0PJL3udY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JKosqMJhgdHtj9yflthd65rxxxxXnid+f0/Ia195vi6oAAAAAAAAAAAAAAAAAAAAAAAAAAAABw"
func TestPrepareContentImage(t *testing.T) {
file, err := os.Open("../_assets/tests/test.jpg")
file, err := os.Open("../../_assets/tests/test.jpg")
require.NoError(t, err)
defer file.Close()
@ -62,7 +62,7 @@ func TestGetImageMessageMIME(t *testing.T) {
}
func TestPrepareContentAudio(t *testing.T) {
file, err := os.Open("../_assets/tests/test.aac")
file, err := os.Open("../../_assets/tests/test.aac")
require.NoError(t, err)
defer file.Close()

View File

@ -6,6 +6,7 @@ import (
"github.com/status-im/status-go/eth-node/crypto"
"github.com/status-im/status-go/eth-node/types"
"github.com/status-im/status-go/protocol/common"
"github.com/status-im/status-go/protocol/protobuf"
v1protocol "github.com/status-im/status-go/protocol/v1"
)
@ -27,7 +28,7 @@ func tsprintf(format string, params map[string]string) string {
return format
}
func eventToSystemMessage(e v1protocol.MembershipUpdateEvent, translations map[protobuf.MembershipUpdateEvent_EventType]string) *Message {
func eventToSystemMessage(e v1protocol.MembershipUpdateEvent, translations map[protobuf.MembershipUpdateEvent_EventType]string) *common.Message {
var text string
switch e.Type {
case protobuf.MembershipUpdateEvent_CHAT_CREATED:
@ -56,7 +57,7 @@ func eventToSystemMessage(e v1protocol.MembershipUpdateEvent, translations map[p
}
timestamp := v1protocol.TimestampInMsFromTime(time.Now())
message := &Message{
message := &common.Message{
ChatMessage: protobuf.ChatMessage{
ChatId: e.ChatID,
Text: text,
@ -75,8 +76,8 @@ func eventToSystemMessage(e v1protocol.MembershipUpdateEvent, translations map[p
return message
}
func buildSystemMessages(events []v1protocol.MembershipUpdateEvent, translations map[protobuf.MembershipUpdateEvent_EventType]string) []*Message {
var messages []*Message
func buildSystemMessages(events []v1protocol.MembershipUpdateEvent, translations map[protobuf.MembershipUpdateEvent_EventType]string) []*common.Message {
var messages []*common.Message
for _, e := range events {
messages = append(messages, eventToSystemMessage(e, translations))

View File

@ -5,11 +5,12 @@ import (
"github.com/status-im/status-go/eth-node/crypto"
"github.com/status-im/status-go/eth-node/types"
"github.com/status-im/status-go/protocol/common"
"github.com/status-im/status-go/protocol/identity/alias"
"github.com/status-im/status-go/protocol/identity/identicon"
)
func extendMessageFromChat(message *Message, chat *Chat, key *ecdsa.PublicKey, timesource TimeSource) error {
func extendMessageFromChat(message *common.Message, chat *Chat, key *ecdsa.PublicKey, timesource TimeSource) error {
clock, timestamp := chat.NextClockAndTimestamp(timesource)
message.LocalChatID = chat.ID
@ -19,7 +20,7 @@ func extendMessageFromChat(message *Message, chat *Chat, key *ecdsa.PublicKey, t
message.SigPubKey = key
message.WhisperTimestamp = timestamp
message.Seen = true
message.OutgoingStatus = OutgoingStatusSending
message.OutgoingStatus = common.OutgoingStatusSending
identicon, err := identicon.GenerateBase64(message.From)
if err != nil {

View File

@ -145,7 +145,7 @@ func (m *MessageHandler) HandleMembershipUpdate(messageState *ReceivedMessageSta
return nil
}
func (m *MessageHandler) handleCommandMessage(state *ReceivedMessageState, message *Message) error {
func (m *MessageHandler) handleCommandMessage(state *ReceivedMessageState, message *common.Message) error {
message.ID = state.CurrentMessageState.MessageID
message.From = state.CurrentMessageState.Contact.ID
message.Alias = state.CurrentMessageState.Contact.Alias
@ -182,7 +182,7 @@ func (m *MessageHandler) handleCommandMessage(state *ReceivedMessageState, messa
message.OutgoingStatus = ""
} else {
// Our own message, mark as sent
message.OutgoingStatus = OutgoingStatusSent
message.OutgoingStatus = common.OutgoingStatusSent
}
err = chat.UpdateFromMessage(message, state.Timesource)
@ -330,7 +330,7 @@ func (m *MessageHandler) HandleChatMessage(state *ReceivedMessageState) error {
logger.Warn("failed to validate message", zap.Error(err))
return err
}
receivedMessage := &Message{
receivedMessage := &common.Message{
ID: state.CurrentMessageState.MessageID,
ChatMessage: state.CurrentMessageState.Message,
From: state.CurrentMessageState.Contact.ID,
@ -369,7 +369,7 @@ func (m *MessageHandler) HandleChatMessage(state *ReceivedMessageState) error {
chat.UnviewedMessagesCount++
} else {
// Our own message, mark as sent
receivedMessage.OutgoingStatus = OutgoingStatusSent
receivedMessage.OutgoingStatus = common.OutgoingStatusSent
}
err = chat.UpdateFromMessage(receivedMessage, state.Timesource)
@ -401,7 +401,7 @@ func (m *MessageHandler) HandleRequestAddressForTransaction(messageState *Receiv
if err != nil {
return err
}
message := &Message{
message := &common.Message{
ChatMessage: protobuf.ChatMessage{
Clock: command.Clock,
Timestamp: messageState.CurrentMessageState.WhisperTimestamp,
@ -410,11 +410,11 @@ func (m *MessageHandler) HandleRequestAddressForTransaction(messageState *Receiv
MessageType: protobuf.MessageType_ONE_TO_ONE,
ContentType: protobuf.ChatMessage_TRANSACTION_COMMAND,
},
CommandParameters: &CommandParameters{
CommandParameters: &common.CommandParameters{
ID: messageState.CurrentMessageState.MessageID,
Value: command.Value,
Contract: command.Contract,
CommandState: CommandStateRequestAddressForTransaction,
CommandState: common.CommandStateRequestAddressForTransaction,
},
}
return m.handleCommandMessage(messageState, message)
@ -425,7 +425,7 @@ func (m *MessageHandler) HandleRequestTransaction(messageState *ReceivedMessageS
if err != nil {
return err
}
message := &Message{
message := &common.Message{
ChatMessage: protobuf.ChatMessage{
Clock: command.Clock,
Timestamp: messageState.CurrentMessageState.WhisperTimestamp,
@ -434,11 +434,11 @@ func (m *MessageHandler) HandleRequestTransaction(messageState *ReceivedMessageS
MessageType: protobuf.MessageType_ONE_TO_ONE,
ContentType: protobuf.ChatMessage_TRANSACTION_COMMAND,
},
CommandParameters: &CommandParameters{
CommandParameters: &common.CommandParameters{
ID: messageState.CurrentMessageState.MessageID,
Value: command.Value,
Contract: command.Contract,
CommandState: CommandStateRequestTransaction,
CommandState: common.CommandStateRequestTransaction,
Address: command.Address,
},
}
@ -466,7 +466,7 @@ func (m *MessageHandler) HandleAcceptRequestAddressForTransaction(messageState *
return errors.New("Initial message must originate from us")
}
if initialMessage.CommandParameters.CommandState != CommandStateRequestAddressForTransaction {
if initialMessage.CommandParameters.CommandState != common.CommandStateRequestAddressForTransaction {
return errors.New("Wrong state for command")
}
@ -475,7 +475,7 @@ func (m *MessageHandler) HandleAcceptRequestAddressForTransaction(messageState *
initialMessage.Text = requestAddressForTransactionAcceptedMessage
initialMessage.CommandParameters.Address = command.Address
initialMessage.Seen = false
initialMessage.CommandParameters.CommandState = CommandStateRequestAddressForTransactionAccepted
initialMessage.CommandParameters.CommandState = common.CommandStateRequestAddressForTransactionAccepted
// Hide previous message
previousMessage, err := m.persistence.MessageByCommandID(messageState.CurrentMessageState.Contact.ID, command.Id)
@ -536,7 +536,7 @@ func (m *MessageHandler) HandleDeclineRequestAddressForTransaction(messageState
return errors.New("Initial message must originate from us")
}
if oldMessage.CommandParameters.CommandState != CommandStateRequestAddressForTransaction {
if oldMessage.CommandParameters.CommandState != common.CommandStateRequestAddressForTransaction {
return errors.New("Wrong state for command")
}
@ -544,7 +544,7 @@ func (m *MessageHandler) HandleDeclineRequestAddressForTransaction(messageState
oldMessage.Timestamp = messageState.CurrentMessageState.WhisperTimestamp
oldMessage.Text = requestAddressForTransactionDeclinedMessage
oldMessage.Seen = false
oldMessage.CommandParameters.CommandState = CommandStateRequestAddressForTransactionDeclined
oldMessage.CommandParameters.CommandState = common.CommandStateRequestAddressForTransactionDeclined
// Hide previous message
err = m.persistence.HideMessage(command.Id)
@ -577,7 +577,7 @@ func (m *MessageHandler) HandleDeclineRequestTransaction(messageState *ReceivedM
return errors.New("Initial message must originate from us")
}
if oldMessage.CommandParameters.CommandState != CommandStateRequestTransaction {
if oldMessage.CommandParameters.CommandState != common.CommandStateRequestTransaction {
return errors.New("Wrong state for command")
}
@ -585,7 +585,7 @@ func (m *MessageHandler) HandleDeclineRequestTransaction(messageState *ReceivedM
oldMessage.Timestamp = messageState.CurrentMessageState.WhisperTimestamp
oldMessage.Text = transactionRequestDeclinedMessage
oldMessage.Seen = false
oldMessage.CommandParameters.CommandState = CommandStateRequestTransactionDeclined
oldMessage.CommandParameters.CommandState = common.CommandStateRequestTransactionDeclined
// Hide previous message
err = m.persistence.HideMessage(command.Id)

View File

@ -7,6 +7,7 @@ import (
"fmt"
"strings"
"github.com/status-im/status-go/protocol/common"
"github.com/status-im/status-go/protocol/protobuf"
"github.com/pkg/errors"
@ -106,7 +107,7 @@ type scanner interface {
Scan(dest ...interface{}) error
}
func (db sqlitePersistence) tableUserMessagesScanAllFields(row scanner, message *Message, others ...interface{}) error {
func (db sqlitePersistence) tableUserMessagesScanAllFields(row scanner, message *common.Message, others ...interface{}) error {
var quotedText sql.NullString
var quotedParsedText []byte
var quotedFrom sql.NullString
@ -118,7 +119,7 @@ func (db sqlitePersistence) tableUserMessagesScanAllFields(row scanner, message
var identicon sql.NullString
sticker := &protobuf.StickerMessage{}
command := &CommandParameters{}
command := &common.CommandParameters{}
audio := &protobuf.AudioMessage{}
args := []interface{}{
@ -169,7 +170,7 @@ func (db sqlitePersistence) tableUserMessagesScanAllFields(row scanner, message
}
if quotedText.Valid {
message.QuotedMessage = &QuotedMessage{
message.QuotedMessage = &common.QuotedMessage{
From: quotedFrom.String,
Text: quotedText.String,
ParsedText: quotedParsedText,
@ -202,7 +203,7 @@ func (db sqlitePersistence) tableUserMessagesScanAllFields(row scanner, message
return nil
}
func (db sqlitePersistence) tableUserMessagesAllValues(message *Message) ([]interface{}, error) {
func (db sqlitePersistence) tableUserMessagesAllValues(message *common.Message) ([]interface{}, error) {
sticker := message.GetSticker()
if sticker == nil {
sticker = &protobuf.StickerMessage{}
@ -220,7 +221,7 @@ func (db sqlitePersistence) tableUserMessagesAllValues(message *Message) ([]inte
command := message.CommandParameters
if command == nil {
command = &CommandParameters{}
command = &common.CommandParameters{}
}
var serializedMentions []byte
@ -271,7 +272,7 @@ func (db sqlitePersistence) tableUserMessagesAllValues(message *Message) ([]inte
}, nil
}
func (db sqlitePersistence) messageByID(tx *sql.Tx, id string) (*Message, error) {
func (db sqlitePersistence) messageByID(tx *sql.Tx, id string) (*common.Message, error) {
var err error
if tx == nil {
tx, err = db.db.BeginTx(context.Background(), &sql.TxOptions{})
@ -288,7 +289,7 @@ func (db sqlitePersistence) messageByID(tx *sql.Tx, id string) (*Message, error)
}()
}
var message Message
var message common.Message
allFields := db.tableUserMessagesAllFieldsJoin()
row := tx.QueryRow(
@ -322,9 +323,9 @@ func (db sqlitePersistence) messageByID(tx *sql.Tx, id string) (*Message, error)
}
}
func (db sqlitePersistence) MessageByCommandID(chatID, id string) (*Message, error) {
func (db sqlitePersistence) MessageByCommandID(chatID, id string) (*common.Message, error) {
var message Message
var message common.Message
allFields := db.tableUserMessagesAllFieldsJoin()
row := db.db.QueryRow(
@ -363,7 +364,7 @@ func (db sqlitePersistence) MessageByCommandID(chatID, id string) (*Message, err
}
}
func (db sqlitePersistence) MessageByID(id string) (*Message, error) {
func (db sqlitePersistence) MessageByID(id string) (*common.Message, error) {
return db.messageByID(nil, id)
}
@ -398,7 +399,7 @@ func (db sqlitePersistence) MessagesExist(ids []string) (map[string]bool, error)
return result, nil
}
func (db sqlitePersistence) MessagesByIDs(ids []string) ([]*Message, error) {
func (db sqlitePersistence) MessagesByIDs(ids []string) ([]*common.Message, error) {
if len(ids) == 0 {
return nil, nil
}
@ -433,9 +434,9 @@ func (db sqlitePersistence) MessagesByIDs(ids []string) ([]*Message, error) {
}
defer rows.Close()
var result []*Message
var result []*common.Message
for rows.Next() {
var message Message
var message common.Message
if err := db.tableUserMessagesScanAllFields(rows, &message); err != nil {
return nil, err
}
@ -448,7 +449,7 @@ func (db sqlitePersistence) MessagesByIDs(ids []string) ([]*Message, error) {
// MessageByChatID returns all messages for a given chatID in descending order.
// Ordering is accomplished using two concatenated values: ClockValue and ID.
// These two values are also used to compose a cursor which is returned to the result.
func (db sqlitePersistence) MessageByChatID(chatID string, currCursor string, limit int) ([]*Message, string, error) {
func (db sqlitePersistence) MessageByChatID(chatID string, currCursor string, limit int) ([]*common.Message, string, error) {
cursorWhere := ""
if currCursor != "" {
cursorWhere = "AND cursor <= ?"
@ -491,12 +492,12 @@ func (db sqlitePersistence) MessageByChatID(chatID string, currCursor string, li
defer rows.Close()
var (
result []*Message
result []*common.Message
cursors []string
)
for rows.Next() {
var (
message Message
message common.Message
cursor string
)
if err := db.tableUserMessagesScanAllFields(rows, &message, &cursor); err != nil {
@ -587,7 +588,7 @@ func (db sqlitePersistence) EmojiReactionsByChatID(chatID string, currCursor str
return result, nil
}
func (db sqlitePersistence) SaveMessages(messages []*Message) (err error) {
func (db sqlitePersistence) SaveMessages(messages []*common.Message) (err error) {
tx, err := db.db.BeginTx(context.Background(), &sql.TxOptions{})
if err != nil {
return

View File

@ -91,7 +91,7 @@ type RawResponse struct {
type MessengerResponse struct {
Chats []*Chat `json:"chats,omitempty"`
Messages []*Message `json:"messages,omitempty"`
Messages []*common.Message `json:"messages,omitempty"`
Contacts []*Contact `json:"contacts,omitempty"`
Installations []*multidevice.Installation `json:"installations,omitempty"`
EmojiReactions []*EmojiReaction `json:"emojiReactions,omitempty"`
@ -1689,7 +1689,7 @@ func (m *Messenger) dispatchMessage(ctx context.Context, spec common.RawMessage)
}
// SendChatMessage takes a minimal message and sends it based on the corresponding chat
func (m *Messenger) SendChatMessage(ctx context.Context, message *Message) (*MessengerResponse, error) {
func (m *Messenger) SendChatMessage(ctx context.Context, message *common.Message) (*MessengerResponse, error) {
m.mutex.Lock()
defer m.mutex.Unlock()
@ -1778,12 +1778,12 @@ func (m *Messenger) SendChatMessage(ctx context.Context, message *Message) (*Mes
return nil, err
}
err = m.persistence.SaveMessages([]*Message{message})
err = m.persistence.SaveMessages([]*common.Message{message})
if err != nil {
return nil, err
}
response.Messages, err = m.pullMessagesAndResponsesFromDB([]*Message{message})
response.Messages, err = m.pullMessagesAndResponsesFromDB([]*common.Message{message})
if err != nil {
return nil, err
}
@ -2540,7 +2540,7 @@ func (m *Messenger) ConfirmMessagesProcessed(messageIDs [][]byte) error {
return nil
}
func (m *Messenger) MessageByID(id string) (*Message, error) {
func (m *Messenger) MessageByID(id string) (*common.Message, error) {
return m.persistence.MessageByID(id)
}
@ -2548,11 +2548,11 @@ func (m *Messenger) MessagesExist(ids []string) (map[string]bool, error) {
return m.persistence.MessagesExist(ids)
}
func (m *Messenger) MessageByChatID(chatID, cursor string, limit int) ([]*Message, string, error) {
func (m *Messenger) MessageByChatID(chatID, cursor string, limit int) ([]*common.Message, string, error) {
return m.persistence.MessageByChatID(chatID, cursor, limit)
}
func (m *Messenger) SaveMessages(messages []*Message) error {
func (m *Messenger) SaveMessages(messages []*common.Message) error {
return m.persistence.SaveMessages(messages)
}
@ -2733,7 +2733,7 @@ func (m *Messenger) RequestTransaction(ctx context.Context, chatID, value, contr
return nil, errors.New("Need to be a one-to-one chat")
}
message := &Message{}
message := &common.Message{}
err := extendMessageFromChat(message, chat, &m.identity.PublicKey, m.transport)
if err != nil {
return nil, err
@ -2760,12 +2760,12 @@ func (m *Messenger) RequestTransaction(ctx context.Context, chatID, value, contr
ResendAutomatically: true,
})
message.CommandParameters = &CommandParameters{
message.CommandParameters = &common.CommandParameters{
ID: types.EncodeHex(id),
Value: value,
Address: address,
Contract: contract,
CommandState: CommandStateRequestTransaction,
CommandState: common.CommandStateRequestTransaction,
}
if err != nil {
@ -2785,13 +2785,13 @@ func (m *Messenger) RequestTransaction(ctx context.Context, chatID, value, contr
return nil, err
}
err = m.persistence.SaveMessages([]*Message{message})
err = m.persistence.SaveMessages([]*common.Message{message})
if err != nil {
return nil, err
}
response.Chats = []*Chat{chat}
response.Messages = []*Message{message}
response.Messages = []*common.Message{message}
return &response, m.saveChat(chat)
}
@ -2810,7 +2810,7 @@ func (m *Messenger) RequestAddressForTransaction(ctx context.Context, chatID, fr
return nil, errors.New("Need to be a one-to-one chat")
}
message := &Message{}
message := &common.Message{}
err := extendMessageFromChat(message, chat, &m.identity.PublicKey, m.transport)
if err != nil {
return nil, err
@ -2836,12 +2836,12 @@ func (m *Messenger) RequestAddressForTransaction(ctx context.Context, chatID, fr
ResendAutomatically: true,
})
message.CommandParameters = &CommandParameters{
message.CommandParameters = &common.CommandParameters{
ID: types.EncodeHex(id),
From: from,
Value: value,
Contract: contract,
CommandState: CommandStateRequestAddressForTransaction,
CommandState: common.CommandStateRequestAddressForTransaction,
}
if err != nil {
@ -2861,13 +2861,13 @@ func (m *Messenger) RequestAddressForTransaction(ctx context.Context, chatID, fr
return nil, err
}
err = m.persistence.SaveMessages([]*Message{message})
err = m.persistence.SaveMessages([]*common.Message{message})
if err != nil {
return nil, err
}
response.Chats = []*Chat{chat}
response.Messages = []*Message{message}
response.Messages = []*common.Message{message}
return &response, m.saveChat(chat)
}
@ -2902,7 +2902,7 @@ func (m *Messenger) AcceptRequestAddressForTransaction(ctx context.Context, mess
message.WhisperTimestamp = timestamp
message.Timestamp = timestamp
message.Text = "Request address for transaction accepted"
message.OutgoingStatus = OutgoingStatusSending
message.OutgoingStatus = common.OutgoingStatusSending
// Hide previous message
previousMessage, err := m.persistence.MessageByCommandID(chatID, messageID)
@ -2944,7 +2944,7 @@ func (m *Messenger) AcceptRequestAddressForTransaction(ctx context.Context, mess
message.ID = types.EncodeHex(newMessageID)
message.CommandParameters.Address = address
message.CommandParameters.CommandState = CommandStateRequestAddressForTransactionAccepted
message.CommandParameters.CommandState = common.CommandStateRequestAddressForTransactionAccepted
err = message.PrepareContent()
if err != nil {
@ -2956,13 +2956,13 @@ func (m *Messenger) AcceptRequestAddressForTransaction(ctx context.Context, mess
return nil, err
}
err = m.persistence.SaveMessages([]*Message{message})
err = m.persistence.SaveMessages([]*common.Message{message})
if err != nil {
return nil, err
}
response.Chats = []*Chat{chat}
response.Messages = []*Message{message}
response.Messages = []*common.Message{message}
return &response, m.saveChat(chat)
}
@ -2997,7 +2997,7 @@ func (m *Messenger) DeclineRequestTransaction(ctx context.Context, messageID str
message.WhisperTimestamp = timestamp
message.Timestamp = timestamp
message.Text = "Transaction request declined"
message.OutgoingStatus = OutgoingStatusSending
message.OutgoingStatus = common.OutgoingStatusSending
message.Replace = messageID
err = m.persistence.HideMessage(messageID)
@ -3026,7 +3026,7 @@ func (m *Messenger) DeclineRequestTransaction(ctx context.Context, messageID str
}
message.ID = types.EncodeHex(newMessageID)
message.CommandParameters.CommandState = CommandStateRequestTransactionDeclined
message.CommandParameters.CommandState = common.CommandStateRequestTransactionDeclined
err = message.PrepareContent()
if err != nil {
@ -3038,13 +3038,13 @@ func (m *Messenger) DeclineRequestTransaction(ctx context.Context, messageID str
return nil, err
}
err = m.persistence.SaveMessages([]*Message{message})
err = m.persistence.SaveMessages([]*common.Message{message})
if err != nil {
return nil, err
}
response.Chats = []*Chat{chat}
response.Messages = []*Message{message}
response.Messages = []*common.Message{message}
return &response, m.saveChat(chat)
}
@ -3079,7 +3079,7 @@ func (m *Messenger) DeclineRequestAddressForTransaction(ctx context.Context, mes
message.WhisperTimestamp = timestamp
message.Timestamp = timestamp
message.Text = "Request address for transaction declined"
message.OutgoingStatus = OutgoingStatusSending
message.OutgoingStatus = common.OutgoingStatusSending
message.Replace = messageID
err = m.persistence.HideMessage(messageID)
@ -3108,7 +3108,7 @@ func (m *Messenger) DeclineRequestAddressForTransaction(ctx context.Context, mes
}
message.ID = types.EncodeHex(newMessageID)
message.CommandParameters.CommandState = CommandStateRequestAddressForTransactionDeclined
message.CommandParameters.CommandState = common.CommandStateRequestAddressForTransactionDeclined
err = message.PrepareContent()
if err != nil {
@ -3120,13 +3120,13 @@ func (m *Messenger) DeclineRequestAddressForTransaction(ctx context.Context, mes
return nil, err
}
err = m.persistence.SaveMessages([]*Message{message})
err = m.persistence.SaveMessages([]*common.Message{message})
if err != nil {
return nil, err
}
response.Chats = []*Chat{chat}
response.Messages = []*Message{message}
response.Messages = []*common.Message{message}
return &response, m.saveChat(chat)
}
@ -3161,7 +3161,7 @@ func (m *Messenger) AcceptRequestTransaction(ctx context.Context, transactionHas
message.WhisperTimestamp = timestamp
message.Timestamp = timestamp
message.Text = transactionSentTxt
message.OutgoingStatus = OutgoingStatusSending
message.OutgoingStatus = common.OutgoingStatusSending
// Hide previous message
previousMessage, err := m.persistence.MessageByCommandID(chatID, messageID)
@ -3207,7 +3207,7 @@ func (m *Messenger) AcceptRequestTransaction(ctx context.Context, transactionHas
message.ID = types.EncodeHex(newMessageID)
message.CommandParameters.TransactionHash = transactionHash
message.CommandParameters.Signature = signature
message.CommandParameters.CommandState = CommandStateTransactionSent
message.CommandParameters.CommandState = common.CommandStateTransactionSent
err = message.PrepareContent()
if err != nil {
@ -3219,13 +3219,13 @@ func (m *Messenger) AcceptRequestTransaction(ctx context.Context, transactionHas
return nil, err
}
err = m.persistence.SaveMessages([]*Message{message})
err = m.persistence.SaveMessages([]*common.Message{message})
if err != nil {
return nil, err
}
response.Chats = []*Chat{chat}
response.Messages = []*Message{message}
response.Messages = []*common.Message{message}
return &response, m.saveChat(chat)
}
@ -3244,7 +3244,7 @@ func (m *Messenger) SendTransaction(ctx context.Context, chatID, value, contract
return nil, errors.New("Need to be a one-to-one chat")
}
message := &Message{}
message := &common.Message{}
err := extendMessageFromChat(message, chat, &m.identity.PublicKey, m.transport)
if err != nil {
return nil, err
@ -3282,12 +3282,12 @@ func (m *Messenger) SendTransaction(ctx context.Context, chatID, value, contract
}
message.ID = types.EncodeHex(newMessageID)
message.CommandParameters = &CommandParameters{
message.CommandParameters = &common.CommandParameters{
TransactionHash: transactionHash,
Value: value,
Contract: contract,
Signature: signature,
CommandState: CommandStateTransactionSent,
CommandState: common.CommandStateTransactionSent,
}
err = message.PrepareContent()
@ -3300,13 +3300,13 @@ func (m *Messenger) SendTransaction(ctx context.Context, chatID, value, contract
return nil, err
}
err = m.persistence.SaveMessages([]*Message{message})
err = m.persistence.SaveMessages([]*common.Message{message})
if err != nil {
return nil, err
}
response.Chats = []*Chat{chat}
response.Messages = []*Message{message}
response.Messages = []*common.Message{message}
return &response, m.saveChat(chat)
}
@ -3335,7 +3335,7 @@ func (m *Messenger) ValidateTransactions(ctx context.Context, addresses []types.
return nil, err
}
for _, validationResult := range responses {
var message *Message
var message *common.Message
chatID := contactIDFromPublicKey(validationResult.Transaction.From)
chat, ok := m.allChats[chatID]
if !ok {
@ -3344,7 +3344,7 @@ func (m *Messenger) ValidateTransactions(ctx context.Context, addresses []types.
if validationResult.Message != nil {
message = validationResult.Message
} else {
message = &Message{}
message = &common.Message{}
err := extendMessageFromChat(message, chat, &m.identity.PublicKey, m.transport)
if err != nil {
return nil, err
@ -3365,7 +3365,7 @@ func (m *Messenger) ValidateTransactions(ctx context.Context, addresses []types.
message.ID = validationResult.Transaction.MessageID
if message.CommandParameters == nil {
message.CommandParameters = &CommandParameters{}
message.CommandParameters = &common.CommandParameters{}
} else {
message.CommandParameters = validationResult.Message.CommandParameters
}
@ -3373,7 +3373,7 @@ func (m *Messenger) ValidateTransactions(ctx context.Context, addresses []types.
message.CommandParameters.Value = validationResult.Value
message.CommandParameters.Contract = validationResult.Contract
message.CommandParameters.Address = validationResult.Address
message.CommandParameters.CommandState = CommandStateTransactionSent
message.CommandParameters.CommandState = common.CommandStateTransactionSent
message.CommandParameters.TransactionHash = validationResult.Transaction.TransactionHash
err = message.PrepareContent()
@ -3422,7 +3422,7 @@ func (m *Messenger) ValidateTransactions(ctx context.Context, addresses []types.
// pullMessagesAndResponsesFromDB pulls all the messages and the one that have
// been replied to from the database
func (m *Messenger) pullMessagesAndResponsesFromDB(messages []*Message) ([]*Message, error) {
func (m *Messenger) pullMessagesAndResponsesFromDB(messages []*common.Message) ([]*common.Message, error) {
var messageIDs []string
for _, message := range messages {
messageIDs = append(messageIDs, message.ID)

View File

@ -24,6 +24,7 @@ import (
"github.com/status-im/status-go/eth-node/crypto"
"github.com/status-im/status-go/eth-node/types"
enstypes "github.com/status-im/status-go/eth-node/types/ens"
"github.com/status-im/status-go/protocol/common"
"github.com/status-im/status-go/protocol/protobuf"
"github.com/status-im/status-go/protocol/tt"
v1protocol "github.com/status-im/status-go/protocol/v1"
@ -288,9 +289,9 @@ func (s *MessengerSuite) TestInit() {
}
}
func buildTestMessage(chat Chat) *Message {
func buildTestMessage(chat Chat) *common.Message {
clock, timestamp := chat.NextClockAndTimestamp(&testTimeSource{})
message := &Message{}
message := &common.Message{}
message.Text = "text-input-message"
message.ChatId = chat.ID
message.Clock = clock
@ -322,7 +323,7 @@ func (s *MessengerSuite) TestMarkMessagesSeen() {
inputMessage2.ID = "2"
inputMessage2.Seen = false
err = s.m.SaveMessages([]*Message{inputMessage1, inputMessage2})
err = s.m.SaveMessages([]*common.Message{inputMessage1, inputMessage2})
s.Require().NoError(err)
count, err := s.m.MarkMessagesSeen(chat.ID, []string{inputMessage1.ID})
@ -346,7 +347,7 @@ func (s *MessengerSuite) TestMarkAllRead() {
inputMessage2.ID = "2"
inputMessage2.Seen = false
err = s.m.SaveMessages([]*Message{inputMessage1, inputMessage2})
err = s.m.SaveMessages([]*common.Message{inputMessage1, inputMessage2})
s.Require().NoError(err)
err = s.m.MarkAllRead(chat.ID)
@ -374,7 +375,7 @@ func (s *MessengerSuite) TestSendPublic() {
s.Require().NotEqual(uint64(0), chat.Timestamp, "it sets the timestamp")
s.Require().Equal("0x"+hex.EncodeToString(crypto.FromECDSAPub(&s.privateKey.PublicKey)), outputMessage.From, "it sets the From field")
s.Require().True(outputMessage.Seen, "it marks the message as seen")
s.Require().Equal(outputMessage.OutgoingStatus, OutgoingStatusSending, "it marks the message as sending")
s.Require().Equal(outputMessage.OutgoingStatus, common.OutgoingStatusSending, "it marks the message as sending")
s.Require().NotEmpty(outputMessage.ID, "it sets the ID field")
s.Require().Equal(protobuf.MessageType_PUBLIC_GROUP, outputMessage.MessageType)
@ -389,7 +390,7 @@ func (s *MessengerSuite) TestSendPrivateOneToOne() {
pkString := hex.EncodeToString(crypto.FromECDSAPub(&recipientKey.PublicKey))
chat := CreateOneToOneChat(pkString, &recipientKey.PublicKey, s.m.transport)
inputMessage := &Message{}
inputMessage := &common.Message{}
inputMessage.ChatId = chat.ID
chat.LastClockValue = uint64(100000000000000)
err = s.m.SaveChat(&chat)
@ -405,7 +406,7 @@ func (s *MessengerSuite) TestSendPrivateOneToOne() {
s.Require().NotEqual(uint64(0), chat.Timestamp, "it sets the timestamp")
s.Require().Equal("0x"+hex.EncodeToString(crypto.FromECDSAPub(&s.privateKey.PublicKey)), outputMessage.From, "it sets the From field")
s.Require().True(outputMessage.Seen, "it marks the message as seen")
s.Require().Equal(outputMessage.OutgoingStatus, OutgoingStatusSending, "it marks the message as sending")
s.Require().Equal(outputMessage.OutgoingStatus, common.OutgoingStatusSending, "it marks the message as sending")
s.Require().NotEmpty(outputMessage.ID, "it sets the ID field")
s.Require().Equal(protobuf.MessageType_ONE_TO_ONE, outputMessage.MessageType)
}
@ -422,13 +423,13 @@ func (s *MessengerSuite) TestSendPrivateGroup() {
_, err = s.m.AddMembersToGroupChat(context.Background(), chat.ID, members)
s.NoError(err)
inputMessage := &Message{}
inputMessage := &common.Message{}
inputMessage.ChatId = chat.ID
chat.LastClockValue = uint64(100000000000000)
err = s.m.SaveChat(chat)
s.NoError(err)
response, err = s.m.SendChatMessage(context.Background(), inputMessage)
s.NoError(err)
s.Require().NoError(err)
s.Require().Equal(1, len(response.Messages), "it returns the message")
outputMessage := response.Messages[0]
@ -438,7 +439,7 @@ func (s *MessengerSuite) TestSendPrivateGroup() {
s.Require().NotEqual(uint64(0), chat.Timestamp, "it sets the timestamp")
s.Require().Equal("0x"+hex.EncodeToString(crypto.FromECDSAPub(&s.privateKey.PublicKey)), outputMessage.From, "it sets the From field")
s.Require().True(outputMessage.Seen, "it marks the message as seen")
s.Require().Equal(outputMessage.OutgoingStatus, OutgoingStatusSending, "it marks the message as sending")
s.Require().Equal(outputMessage.OutgoingStatus, common.OutgoingStatusSending, "it marks the message as sending")
s.Require().NotEmpty(outputMessage.ID, "it sets the ID field")
s.Require().Equal(protobuf.MessageType_PRIVATE_GROUP, outputMessage.MessageType)
}
@ -450,7 +451,7 @@ func (s *MessengerSuite) TestSendPrivateEmptyGroup() {
chat := response.Chats[0]
inputMessage := &Message{}
inputMessage := &common.Message{}
inputMessage.ChatId = chat.ID
chat.LastClockValue = uint64(100000000000000)
err = s.m.SaveChat(chat)
@ -466,7 +467,7 @@ func (s *MessengerSuite) TestSendPrivateEmptyGroup() {
s.Require().NotEqual(uint64(0), chat.Timestamp, "it sets the timestamp")
s.Require().Equal("0x"+hex.EncodeToString(crypto.FromECDSAPub(&s.privateKey.PublicKey)), outputMessage.From, "it sets the From field")
s.Require().True(outputMessage.Seen, "it marks the message as seen")
s.Require().Equal(outputMessage.OutgoingStatus, OutgoingStatusSending, "it marks the message as sending")
s.Require().Equal(outputMessage.OutgoingStatus, common.OutgoingStatusSending, "it marks the message as sending")
s.Require().NotEmpty(outputMessage.ID, "it sets the ID field")
s.Require().Equal(protobuf.MessageType_PRIVATE_GROUP, outputMessage.MessageType)
}
@ -962,7 +963,7 @@ func (s *MessengerSuite) TestChatPersistencePublic() {
LastClockValue: 20,
DeletedAtClockValue: 30,
UnviewedMessagesCount: 40,
LastMessage: &Message{},
LastMessage: &common.Message{},
}
s.Require().NoError(s.m.SaveChat(&chat))
@ -987,7 +988,7 @@ func (s *MessengerSuite) TestDeleteChat() {
LastClockValue: 20,
DeletedAtClockValue: 30,
UnviewedMessagesCount: 40,
LastMessage: &Message{},
LastMessage: &common.Message{},
}
s.Require().NoError(s.m.SaveChat(&chat))
@ -1010,7 +1011,7 @@ func (s *MessengerSuite) TestChatPersistenceUpdate() {
LastClockValue: 20,
DeletedAtClockValue: 30,
UnviewedMessagesCount: 40,
LastMessage: &Message{},
LastMessage: &common.Message{},
}
s.Require().NoError(s.m.SaveChat(&chat))
@ -1044,7 +1045,7 @@ func (s *MessengerSuite) TestChatPersistenceOneToOne() {
LastClockValue: 20,
DeletedAtClockValue: 30,
UnviewedMessagesCount: 40,
LastMessage: &Message{},
LastMessage: &common.Message{},
}
contact := Contact{
ID: testPK,
@ -1133,7 +1134,7 @@ func (s *MessengerSuite) TestChatPersistencePrivateGroupChat() {
LastClockValue: 20,
DeletedAtClockValue: 30,
UnviewedMessagesCount: 40,
LastMessage: &Message{},
LastMessage: &common.Message{},
}
s.Require().NoError(s.m.SaveChat(&chat))
savedChats := s.m.Chats()
@ -1211,7 +1212,7 @@ func (s *MessengerSuite) TestBlockContact() {
contact.Name = "blocked"
messages := []*Message{
messages := []*common.Message{
{
ID: "test-1",
LocalChatID: chat2.ID,
@ -1479,7 +1480,7 @@ func (s *MessengerSuite) TestDeclineRequestAddressForTransaction() {
s.Require().Equal(value, senderMessage.CommandParameters.Value)
s.Require().Equal(contract, senderMessage.CommandParameters.Contract)
s.Require().Equal(initialCommandID, senderMessage.CommandParameters.ID)
s.Require().Equal(CommandStateRequestAddressForTransaction, senderMessage.CommandParameters.CommandState)
s.Require().Equal(common.CommandStateRequestAddressForTransaction, senderMessage.CommandParameters.CommandState)
// Wait for the message to reach its destination
response, err = WaitOnMessengerResponse(
@ -1500,7 +1501,7 @@ func (s *MessengerSuite) TestDeclineRequestAddressForTransaction() {
s.Require().Equal(value, receiverMessage.CommandParameters.Value)
s.Require().Equal(contract, receiverMessage.CommandParameters.Contract)
s.Require().Equal(initialCommandID, receiverMessage.CommandParameters.ID)
s.Require().Equal(CommandStateRequestAddressForTransaction, receiverMessage.CommandParameters.CommandState)
s.Require().Equal(common.CommandStateRequestAddressForTransaction, receiverMessage.CommandParameters.CommandState)
// We decline the request
response, err = theirMessenger.DeclineRequestAddressForTransaction(context.Background(), receiverMessage.ID)
@ -1514,7 +1515,7 @@ func (s *MessengerSuite) TestDeclineRequestAddressForTransaction() {
s.Require().NotNil(senderMessage.CommandParameters)
s.Require().Equal(value, senderMessage.CommandParameters.Value)
s.Require().Equal(contract, senderMessage.CommandParameters.Contract)
s.Require().Equal(CommandStateRequestAddressForTransactionDeclined, senderMessage.CommandParameters.CommandState)
s.Require().Equal(common.CommandStateRequestAddressForTransactionDeclined, senderMessage.CommandParameters.CommandState)
s.Require().Equal(initialCommandID, senderMessage.CommandParameters.ID)
s.Require().Equal(receiverMessage.ID, senderMessage.Replace)
@ -1535,7 +1536,7 @@ func (s *MessengerSuite) TestDeclineRequestAddressForTransaction() {
s.Require().NotNil(receiverMessage.CommandParameters)
s.Require().Equal(value, receiverMessage.CommandParameters.Value)
s.Require().Equal(contract, receiverMessage.CommandParameters.Contract)
s.Require().Equal(CommandStateRequestAddressForTransactionDeclined, receiverMessage.CommandParameters.CommandState)
s.Require().Equal(common.CommandStateRequestAddressForTransactionDeclined, receiverMessage.CommandParameters.CommandState)
s.Require().Equal(initialCommandID, receiverMessage.CommandParameters.ID)
s.Require().Equal(initialCommandID, receiverMessage.Replace)
s.Require().NoError(theirMessenger.Shutdown())
@ -1574,7 +1575,7 @@ func (s *MessengerSuite) TestSendEthTransaction() {
s.Require().Equal(contract, senderMessage.CommandParameters.Contract)
s.Require().Equal(value, senderMessage.CommandParameters.Value)
s.Require().Equal(signature, senderMessage.CommandParameters.Signature)
s.Require().Equal(CommandStateTransactionSent, senderMessage.CommandParameters.CommandState)
s.Require().Equal(common.CommandStateTransactionSent, senderMessage.CommandParameters.CommandState)
s.Require().NotEmpty(senderMessage.ID)
s.Require().Equal("", senderMessage.Replace)
@ -1638,7 +1639,7 @@ func (s *MessengerSuite) TestSendEthTransaction() {
s.Require().Equal(transactionHash, receiverMessage.CommandParameters.TransactionHash)
s.Require().Equal(receiverAddressString, receiverMessage.CommandParameters.Address)
s.Require().Equal("", receiverMessage.CommandParameters.ID)
s.Require().Equal(CommandStateTransactionSent, receiverMessage.CommandParameters.CommandState)
s.Require().Equal(common.CommandStateTransactionSent, receiverMessage.CommandParameters.CommandState)
s.Require().Equal(senderMessage.ID, receiverMessage.ID)
s.Require().Equal("", receiverMessage.Replace)
s.Require().NoError(theirMessenger.Shutdown())
@ -1677,7 +1678,7 @@ func (s *MessengerSuite) TestSendTokenTransaction() {
s.Require().Equal(value, senderMessage.CommandParameters.Value)
s.Require().Equal(contract, senderMessage.CommandParameters.Contract)
s.Require().Equal(signature, senderMessage.CommandParameters.Signature)
s.Require().Equal(CommandStateTransactionSent, senderMessage.CommandParameters.CommandState)
s.Require().Equal(common.CommandStateTransactionSent, senderMessage.CommandParameters.CommandState)
s.Require().NotEmpty(senderMessage.ID)
var transactions []*TransactionToValidate
@ -1741,7 +1742,7 @@ func (s *MessengerSuite) TestSendTokenTransaction() {
s.Require().Equal(transactionHash, receiverMessage.CommandParameters.TransactionHash)
s.Require().Equal(receiverAddressString, receiverMessage.CommandParameters.Address)
s.Require().Equal("", receiverMessage.CommandParameters.ID)
s.Require().Equal(CommandStateTransactionSent, receiverMessage.CommandParameters.CommandState)
s.Require().Equal(common.CommandStateTransactionSent, receiverMessage.CommandParameters.CommandState)
s.Require().Equal(senderMessage.ID, receiverMessage.ID)
s.Require().Equal(senderMessage.Replace, senderMessage.Replace)
s.Require().NoError(theirMessenger.Shutdown())
@ -1775,7 +1776,7 @@ func (s *MessengerSuite) TestAcceptRequestAddressForTransaction() {
s.Require().Equal(value, senderMessage.CommandParameters.Value)
s.Require().Equal(contract, senderMessage.CommandParameters.Contract)
s.Require().Equal(initialCommandID, senderMessage.CommandParameters.ID)
s.Require().Equal(CommandStateRequestAddressForTransaction, senderMessage.CommandParameters.CommandState)
s.Require().Equal(common.CommandStateRequestAddressForTransaction, senderMessage.CommandParameters.CommandState)
// Wait for the message to reach its destination
response, err = WaitOnMessengerResponse(
@ -1796,7 +1797,7 @@ func (s *MessengerSuite) TestAcceptRequestAddressForTransaction() {
s.Require().Equal(value, receiverMessage.CommandParameters.Value)
s.Require().Equal(contract, receiverMessage.CommandParameters.Contract)
s.Require().Equal(initialCommandID, receiverMessage.CommandParameters.ID)
s.Require().Equal(CommandStateRequestAddressForTransaction, receiverMessage.CommandParameters.CommandState)
s.Require().Equal(common.CommandStateRequestAddressForTransaction, receiverMessage.CommandParameters.CommandState)
// We accept the request
response, err = theirMessenger.AcceptRequestAddressForTransaction(context.Background(), receiverMessage.ID, "some-address")
@ -1810,7 +1811,7 @@ func (s *MessengerSuite) TestAcceptRequestAddressForTransaction() {
s.Require().NotNil(senderMessage.CommandParameters)
s.Require().Equal(value, senderMessage.CommandParameters.Value)
s.Require().Equal(contract, senderMessage.CommandParameters.Contract)
s.Require().Equal(CommandStateRequestAddressForTransactionAccepted, senderMessage.CommandParameters.CommandState)
s.Require().Equal(common.CommandStateRequestAddressForTransactionAccepted, senderMessage.CommandParameters.CommandState)
s.Require().Equal(initialCommandID, senderMessage.CommandParameters.ID)
s.Require().Equal("some-address", senderMessage.CommandParameters.Address)
s.Require().Equal(receiverMessage.ID, senderMessage.Replace)
@ -1832,7 +1833,7 @@ func (s *MessengerSuite) TestAcceptRequestAddressForTransaction() {
s.Require().NotNil(receiverMessage.CommandParameters)
s.Require().Equal(value, receiverMessage.CommandParameters.Value)
s.Require().Equal(contract, receiverMessage.CommandParameters.Contract)
s.Require().Equal(CommandStateRequestAddressForTransactionAccepted, receiverMessage.CommandParameters.CommandState)
s.Require().Equal(common.CommandStateRequestAddressForTransactionAccepted, receiverMessage.CommandParameters.CommandState)
s.Require().Equal(initialCommandID, receiverMessage.CommandParameters.ID)
s.Require().Equal("some-address", receiverMessage.CommandParameters.Address)
s.Require().Equal(initialCommandID, receiverMessage.Replace)
@ -1868,7 +1869,7 @@ func (s *MessengerSuite) TestDeclineRequestTransaction() {
s.Require().Equal(contract, senderMessage.CommandParameters.Contract)
s.Require().Equal(receiverAddressString, senderMessage.CommandParameters.Address)
s.Require().Equal(initialCommandID, senderMessage.CommandParameters.ID)
s.Require().Equal(CommandStateRequestTransaction, senderMessage.CommandParameters.CommandState)
s.Require().Equal(common.CommandStateRequestTransaction, senderMessage.CommandParameters.CommandState)
// Wait for the message to reach its destination
response, err = WaitOnMessengerResponse(
@ -1890,7 +1891,7 @@ func (s *MessengerSuite) TestDeclineRequestTransaction() {
s.Require().Equal(contract, receiverMessage.CommandParameters.Contract)
s.Require().Equal(receiverAddressString, receiverMessage.CommandParameters.Address)
s.Require().Equal(initialCommandID, receiverMessage.CommandParameters.ID)
s.Require().Equal(CommandStateRequestTransaction, receiverMessage.CommandParameters.CommandState)
s.Require().Equal(common.CommandStateRequestTransaction, receiverMessage.CommandParameters.CommandState)
response, err = theirMessenger.DeclineRequestTransaction(context.Background(), initialCommandID)
s.Require().NoError(err)
@ -1904,7 +1905,7 @@ func (s *MessengerSuite) TestDeclineRequestTransaction() {
s.Require().Equal("Transaction request declined", senderMessage.Text)
s.Require().Equal(initialCommandID, senderMessage.CommandParameters.ID)
s.Require().Equal(receiverMessage.ID, senderMessage.Replace)
s.Require().Equal(CommandStateRequestTransactionDeclined, senderMessage.CommandParameters.CommandState)
s.Require().Equal(common.CommandStateRequestTransactionDeclined, senderMessage.CommandParameters.CommandState)
// Wait for the message to reach its destination
response, err = WaitOnMessengerResponse(
@ -1924,7 +1925,7 @@ func (s *MessengerSuite) TestDeclineRequestTransaction() {
s.Require().Equal("Transaction request declined", receiverMessage.Text)
s.Require().Equal(initialCommandID, receiverMessage.CommandParameters.ID)
s.Require().Equal(initialCommandID, receiverMessage.Replace)
s.Require().Equal(CommandStateRequestTransactionDeclined, receiverMessage.CommandParameters.CommandState)
s.Require().Equal(common.CommandStateRequestTransactionDeclined, receiverMessage.CommandParameters.CommandState)
s.Require().NoError(theirMessenger.Shutdown())
}
@ -1957,7 +1958,7 @@ func (s *MessengerSuite) TestRequestTransaction() {
s.Require().Equal(contract, senderMessage.CommandParameters.Contract)
s.Require().Equal(receiverAddressString, senderMessage.CommandParameters.Address)
s.Require().Equal(initialCommandID, senderMessage.CommandParameters.ID)
s.Require().Equal(CommandStateRequestTransaction, senderMessage.CommandParameters.CommandState)
s.Require().Equal(common.CommandStateRequestTransaction, senderMessage.CommandParameters.CommandState)
// Wait for the message to reach its destination
response, err = WaitOnMessengerResponse(
@ -1979,7 +1980,7 @@ func (s *MessengerSuite) TestRequestTransaction() {
s.Require().Equal(contract, receiverMessage.CommandParameters.Contract)
s.Require().Equal(receiverAddressString, receiverMessage.CommandParameters.Address)
s.Require().Equal(initialCommandID, receiverMessage.CommandParameters.ID)
s.Require().Equal(CommandStateRequestTransaction, receiverMessage.CommandParameters.CommandState)
s.Require().Equal(common.CommandStateRequestTransaction, receiverMessage.CommandParameters.CommandState)
transactionHash := "0x412a851ac2ae51cad34a56c8a9cfee55d577ac5e1ac71cf488a2f2093a373799"
signature, err := buildSignature(theirMessenger.identity, &theirMessenger.identity.PublicKey, transactionHash)
@ -2003,7 +2004,7 @@ func (s *MessengerSuite) TestRequestTransaction() {
s.Require().Equal(signature, senderMessage.CommandParameters.Signature)
s.Require().NotEmpty(senderMessage.ID)
s.Require().Equal(receiverMessage.ID, senderMessage.Replace)
s.Require().Equal(CommandStateTransactionSent, senderMessage.CommandParameters.CommandState)
s.Require().Equal(common.CommandStateTransactionSent, senderMessage.CommandParameters.CommandState)
var transactions []*TransactionToValidate
// Wait for the message to reach its destination
@ -2068,7 +2069,7 @@ func (s *MessengerSuite) TestRequestTransaction() {
s.Require().Equal(receiverAddressString, receiverMessage.CommandParameters.Address)
s.Require().Equal(initialCommandID, receiverMessage.CommandParameters.ID)
s.Require().Equal(signature, receiverMessage.CommandParameters.Signature)
s.Require().Equal(CommandStateTransactionSent, receiverMessage.CommandParameters.CommandState)
s.Require().Equal(common.CommandStateTransactionSent, receiverMessage.CommandParameters.CommandState)
s.Require().Equal(senderMessage.ID, receiverMessage.ID)
s.Require().Equal(senderMessage.Replace, senderMessage.Replace)
s.Require().NoError(theirMessenger.Shutdown())
@ -2102,7 +2103,7 @@ func (m *mockSendMessagesRequest) SendMessagesRequest(peerID []byte, request typ
}
func (s *MessengerSuite) TestMessageJSON() {
message := &Message{
message := &common.Message{
ID: "test-1",
LocalChatID: "local-chat-id",
Alias: "alias",
@ -2121,7 +2122,7 @@ func (s *MessengerSuite) TestMessageJSON() {
s.Require().NoError(err)
s.Require().Equal(expectedJSON, string(messageJSON))
decodedMessage := &Message{}
decodedMessage := &common.Message{}
err = json.Unmarshal([]byte(expectedJSON), decodedMessage)
s.Require().NoError(err)
s.Require().Equal(message, decodedMessage)
@ -2186,14 +2187,14 @@ func (s *MessageHandlerSuite) TestRun() {
Name string
Error bool
Chat Chat // Chat to create
Message Message
Message common.Message
SigPubKey *ecdsa.PublicKey
ExpectedChatID string
}{
{
Name: "Public chat",
Chat: CreatePublicChat("test-chat", &testTimeSource{}),
Message: Message{
Message: common.Message{
ChatMessage: protobuf.ChatMessage{
ChatId: "test-chat",
MessageType: protobuf.MessageType_PUBLIC_GROUP,
@ -2205,7 +2206,7 @@ func (s *MessageHandlerSuite) TestRun() {
{
Name: "Private message from myself with existing chat",
Chat: CreateOneToOneChat("test-private-chat", &key1.PublicKey, &testTimeSource{}),
Message: Message{
Message: common.Message{
ChatMessage: protobuf.ChatMessage{
ChatId: "test-chat",
MessageType: protobuf.MessageType_ONE_TO_ONE,
@ -2217,7 +2218,7 @@ func (s *MessageHandlerSuite) TestRun() {
{
Name: "Private message from other with existing chat",
Chat: CreateOneToOneChat("test-private-chat", &key2.PublicKey, &testTimeSource{}),
Message: Message{
Message: common.Message{
ChatMessage: protobuf.ChatMessage{
ChatId: "test-chat",
MessageType: protobuf.MessageType_ONE_TO_ONE,
@ -2229,7 +2230,7 @@ func (s *MessageHandlerSuite) TestRun() {
},
{
Name: "Private message from myself without chat",
Message: Message{
Message: common.Message{
ChatMessage: protobuf.ChatMessage{
ChatId: "test-chat",
MessageType: protobuf.MessageType_ONE_TO_ONE,
@ -2241,7 +2242,7 @@ func (s *MessageHandlerSuite) TestRun() {
},
{
Name: "Private message from other without chat",
Message: Message{
Message: common.Message{
ChatMessage: protobuf.ChatMessage{
ChatId: "test-chat",
MessageType: protobuf.MessageType_ONE_TO_ONE,
@ -2258,7 +2259,7 @@ func (s *MessageHandlerSuite) TestRun() {
},
{
Name: "Private group message",
Message: Message{
Message: common.Message{
ChatMessage: protobuf.ChatMessage{
ChatId: "non-existing-chat",
MessageType: protobuf.MessageType_PRIVATE_GROUP,

View File

@ -266,7 +266,7 @@ func (db sqlitePersistence) chats(tx *sql.Tx) (chats []*Chat, err error) {
// Restore last message
if lastMessageBytes != nil {
message := &Message{}
message := &common.Message{}
if err = json.Unmarshal(lastMessageBytes, message); err != nil {
return
}
@ -346,7 +346,7 @@ func (db sqlitePersistence) Chat(chatID string) (*Chat, error) {
// Restore last message
if lastMessageBytes != nil {
message := &Message{}
message := &common.Message{}
if err = json.Unmarshal(lastMessageBytes, message); err != nil {
return nil, err
}

View File

@ -13,6 +13,7 @@ import (
"github.com/status-im/status-go/eth-node/crypto"
"github.com/status-im/status-go/eth-node/types"
"github.com/status-im/status-go/protocol/common"
"github.com/status-im/status-go/protocol/protobuf"
"github.com/status-im/status-go/protocol/sqlite"
)
@ -103,9 +104,9 @@ func TestMessageByChatID(t *testing.T) {
count := 1000
pageSize := 50
var messages []*Message
var messages []*common.Message
for i := 0; i < count; i++ {
messages = append(messages, &Message{
messages = append(messages, &common.Message{
ID: strconv.Itoa(i),
LocalChatID: chatID,
ChatMessage: protobuf.ChatMessage{
@ -116,7 +117,7 @@ func TestMessageByChatID(t *testing.T) {
// Add some other chats.
if count%5 == 0 {
messages = append(messages, &Message{
messages = append(messages, &common.Message{
ID: strconv.Itoa(count + i),
LocalChatID: "other-chat",
ChatMessage: protobuf.ChatMessage{
@ -132,7 +133,7 @@ func TestMessageByChatID(t *testing.T) {
outOfOrderCount := pageSize + 1
allCount := count + outOfOrderCount
for i := 0; i < pageSize+1; i++ {
messages = append(messages, &Message{
messages = append(messages, &common.Message{
ID: strconv.Itoa(count*2 + i),
LocalChatID: chatID,
ChatMessage: protobuf.ChatMessage{
@ -147,13 +148,13 @@ func TestMessageByChatID(t *testing.T) {
require.NoError(t, err)
var (
result []*Message
result []*common.Message
cursor string
iter int
)
for {
var (
items []*Message
items []*common.Message
err error
)
@ -183,7 +184,7 @@ func TestMessageReplies(t *testing.T) {
require.NoError(t, err)
p := sqlitePersistence{db: db}
chatID := testPublicChatID
message1 := &Message{
message1 := &common.Message{
ID: "id-1",
LocalChatID: chatID,
ChatMessage: protobuf.ChatMessage{
@ -192,7 +193,7 @@ func TestMessageReplies(t *testing.T) {
},
From: "1",
}
message2 := &Message{
message2 := &common.Message{
ID: "id-2",
LocalChatID: chatID,
ChatMessage: protobuf.ChatMessage{
@ -204,7 +205,7 @@ func TestMessageReplies(t *testing.T) {
From: "2",
}
message3 := &Message{
message3 := &common.Message{
ID: "id-3",
LocalChatID: chatID,
ChatMessage: protobuf.ChatMessage{
@ -215,7 +216,7 @@ func TestMessageReplies(t *testing.T) {
From: "3",
}
messages := []*Message{message1, message2, message3}
messages := []*common.Message{message1, message2, message3}
err = p.SaveMessages(messages)
require.NoError(t, err)
@ -227,7 +228,7 @@ func TestMessageReplies(t *testing.T) {
require.Nil(t, retrievedMessages[0].QuotedMessage)
require.Equal(t, "id-1", retrievedMessages[1].ResponseTo)
require.Equal(t, &QuotedMessage{From: "1", Text: "content-1"}, retrievedMessages[1].QuotedMessage)
require.Equal(t, &common.QuotedMessage{From: "1", Text: "content-1"}, retrievedMessages[1].QuotedMessage)
require.Equal(t, "", retrievedMessages[2].ResponseTo)
require.Nil(t, retrievedMessages[2].QuotedMessage)
@ -242,10 +243,10 @@ func TestMessageByChatIDWithTheSameClocks(t *testing.T) {
count := len(clockValues)
pageSize := 2
var messages []*Message
var messages []*common.Message
for i, clock := range clockValues {
messages = append(messages, &Message{
messages = append(messages, &common.Message{
ID: strconv.Itoa(i),
LocalChatID: chatID,
ChatMessage: protobuf.ChatMessage{
@ -259,13 +260,13 @@ func TestMessageByChatIDWithTheSameClocks(t *testing.T) {
require.NoError(t, err)
var (
result []*Message
result []*common.Message
cursor string
iter int
)
for {
var (
items []*Message
items []*common.Message
err error
)
@ -324,14 +325,14 @@ func TestDeleteMessagesByChatID(t *testing.T) {
err = insertMinimalMessage(p, "2")
require.NoError(t, err)
m, _, err := p.MessageByChatID("chat-id", "", 10)
m, _, err := p.MessageByChatID(testPublicChatID, "", 10)
require.NoError(t, err)
require.Equal(t, 2, len(m))
err = p.DeleteMessagesByChatID("chat-id")
err = p.DeleteMessagesByChatID(testPublicChatID)
require.NoError(t, err)
m, _, err = p.MessageByChatID("chat-id", "", 10)
m, _, err = p.MessageByChatID(testPublicChatID, "", 10)
require.NoError(t, err)
require.Equal(t, 0, len(m))
@ -390,7 +391,7 @@ func TestPersistenceEmojiReactions(t *testing.T) {
from2 := "from-2"
from3 := "from-3"
chatID := "chat-id"
chatID := testPublicChatID
err = insertMinimalMessage(p, id1)
require.NoError(t, err)
@ -487,9 +488,9 @@ func openTestDB() (*sql.DB, error) {
}
func insertMinimalMessage(p sqlitePersistence, id string) error {
return p.SaveMessages([]*Message{{
return p.SaveMessages([]*common.Message{{
ID: id,
LocalChatID: "chat-id",
LocalChatID: testPublicChatID,
ChatMessage: protobuf.ChatMessage{Text: "some-text"},
From: "me",
}})
@ -512,7 +513,7 @@ func TestMessagesAudioDurationMsNull(t *testing.T) {
require.NoError(t, err)
require.Len(t, m, 1)
m, _, err = p.MessageByChatID("chat-id", "", 10)
m, _, err = p.MessageByChatID(testPublicChatID, "", 10)
require.NoError(t, err)
require.Len(t, m, 1)
}
@ -523,7 +524,7 @@ func TestSaveChat(t *testing.T) {
p := sqlitePersistence{db: db}
chat := CreatePublicChat("test-chat", &testTimeSource{})
chat.LastMessage = &Message{}
chat.LastMessage = &common.Message{}
err = p.SaveChat(chat)
require.NoError(t, err)
@ -533,7 +534,7 @@ func TestSaveChat(t *testing.T) {
}
func TestSaveMentions(t *testing.T) {
chatID := "chat-id"
chatID := testPublicChatID
db, err := openTestDB()
require.NoError(t, err)
p := sqlitePersistence{db: db}
@ -543,7 +544,7 @@ func TestSaveMentions(t *testing.T) {
pkString := types.EncodeHex(crypto.FromECDSAPub(&key.PublicKey))
message := Message{
message := common.Message{
ID: "1",
LocalChatID: chatID,
ChatMessage: protobuf.ChatMessage{Text: "some-text"},
@ -551,7 +552,7 @@ func TestSaveMentions(t *testing.T) {
Mentions: []string{pkString},
}
err = p.SaveMessages([]*Message{&message})
err = p.SaveMessages([]*common.Message{&message})
require.NoError(t, err)
retrievedMessages, _, err := p.MessageByChatID(chatID, "", 10)

View File

@ -154,6 +154,8 @@ type PushNotificationRegistration struct {
Grant []byte `protobuf:"bytes,10,opt,name=grant,proto3" json:"grant,omitempty"`
AllowFromContactsOnly bool `protobuf:"varint,11,opt,name=allow_from_contacts_only,json=allowFromContactsOnly,proto3" json:"allow_from_contacts_only,omitempty"`
ApnTopic string `protobuf:"bytes,12,opt,name=apn_topic,json=apnTopic,proto3" json:"apn_topic,omitempty"`
BlockMentions bool `protobuf:"varint,13,opt,name=block_mentions,json=blockMentions,proto3" json:"block_mentions,omitempty"`
AllowedMentionsChatList [][]byte `protobuf:"bytes,14,rep,name=allowed_mentions_chat_list,json=allowedMentionsChatList,proto3" json:"allowed_mentions_chat_list,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
@ -268,6 +270,20 @@ func (m *PushNotificationRegistration) GetApnTopic() string {
return ""
}
func (m *PushNotificationRegistration) GetBlockMentions() bool {
if m != nil {
return m.BlockMentions
}
return false
}
func (m *PushNotificationRegistration) GetAllowedMentionsChatList() [][]byte {
if m != nil {
return m.AllowedMentionsChatList
}
return nil
}
type PushNotificationRegistrationResponse struct {
Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"`
Error PushNotificationRegistrationResponse_ErrorType `protobuf:"varint,2,opt,name=error,proto3,enum=protobuf.PushNotificationRegistrationResponse_ErrorType" json:"error,omitempty"`
@ -799,65 +815,67 @@ func init() {
func init() { proto.RegisterFile("push_notifications.proto", fileDescriptor_200acd86044eaa5d) }
var fileDescriptor_200acd86044eaa5d = []byte{
// 952 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0x51, 0x6f, 0xe3, 0x44,
0x10, 0xc6, 0x4e, 0xda, 0x24, 0x93, 0x90, 0xba, 0xab, 0xb6, 0x67, 0x0e, 0x7a, 0x04, 0x83, 0x44,
0xd4, 0x87, 0x80, 0x8a, 0xc4, 0x9d, 0x78, 0x22, 0xa4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3, 0x4d, 0x5a, 0x03, 0x84, 0xdc,
0x45, 0xb0, 0x66, 0xc3, 0x5e, 0x99, 0x17, 0x69, 0xf0, 0xaa, 0x10, 0xf6, 0xf8, 0x62, 0xf2, 0xd6,
0x31, 0x2d, 0xdb, 0x18, 0x1a, 0x83, 0xbe, 0x9d, 0x6a, 0x37, 0x17, 0x79, 0x13, 0x6a, 0x77, 0xd2,
0x16, 0x86, 0x99, 0xba, 0x15, 0x59, 0x8b, 0xe1, 0xc5, 0xfa, 0xf2, 0x11, 0x1b, 0x04, 0x7d, 0x0b,
0xf5, 0x7c, 0x99, 0xb0, 0x9c, 0xde, 0x97, 0x1b, 0x36, 0xd6, 0xf2, 0xec, 0x13, 0xcc, 0x6a, 0x7f,
0xca, 0x70, 0xb0, 0x5e, 0x32, 0xa6, 0x09, 0xdf, 0xb0, 0x3a, 0xbf, 0xbf, 0xbf, 0x3a, 0x8f, 0x36,
0xad, 0xce, 0x34, 0x55, 0xe9, 0xb2, 0xfc, 0x3f, 0x58, 0xd6, 0x7e, 0x7e, 0xce, 0x52, 0xdd, 0x81,
0xe6, 0x3b, 0x6c, 0x99, 0xa7, 0xab, 0x5f, 0x94, 0x07, 0xcb, 0x51, 0x4e, 0x31, 0xd3, 0xb2, 0x1d,
0xac, 0x9f, 0x1a, 0x13, 0x5b, 0xc7, 0xfa, 0x89, 0x52, 0x49, 0x17, 0xe6, 0xfa, 0x83, 0x72, 0xa9,
0xdd, 0xef, 0xab, 0xf4, 0x50, 0x31, 0xdf, 0x41, 0x2d, 0x11, 0x6f, 0x67, 0xaa, 0x2c, 0xd8, 0xea,
0x3c, 0xd5, 0x24, 0x5c, 0x04, 0x4c, 0xb7, 0xc5, 0xc9, 0x6f, 0xfe, 0x0d, 0x00, 0x00, 0xff, 0xff,
0xff, 0x42, 0x7f, 0xee, 0x48, 0x09, 0x00, 0x00,
// 990 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x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2,
0x28, 0x26, 0x98, 0x6e, 0x98, 0x04, 0xab, 0x67, 0xda, 0xc4, 0x54, 0xb1, 0x7a, 0x2a, 0x55, 0x12,
0xc1, 0x5c, 0x2d, 0x28, 0xa3, 0xda, 0xfd, 0xbe, 0x0a, 0x0f, 0x19, 0xf3, 0x1d, 0xd4, 0x22, 0x5e,
0x3b, 0x93, 0x45, 0x3e, 0xad, 0xce, 0x53, 0x4d, 0xc2, 0x79, 0xc0, 0x74, 0x93, 0x7b, 0x7e, 0xf3,
0x5f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x65, 0x07, 0x55, 0xdb, 0xac, 0x09, 0x00, 0x00,
}

View File

@ -20,6 +20,8 @@ message PushNotificationRegistration {
bytes grant = 10;
bool allow_from_contacts_only = 11;
string apn_topic = 12;
bool block_mentions = 13;
repeated bytes allowed_mentions_chat_list = 14;
}
message PushNotificationRegistrationResponse {

View File

@ -176,6 +176,10 @@ type Client struct {
registrationSubscriptions []chan struct{}
}
type MessagePersistence interface {
MessageByID(string) (*common.Message, error)
}
func New(persistence *Persistence, config *Config, processor *common.MessageProcessor) *Client {
return &Client{
quit: make(chan struct{}),

View File

@ -16,6 +16,7 @@ import (
coretypes "github.com/status-im/status-go/eth-node/core/types"
"github.com/status-im/status-go/eth-node/crypto"
"github.com/status-im/status-go/eth-node/types"
"github.com/status-im/status-go/protocol/common"
)
const (
@ -92,7 +93,7 @@ func (t *TransactionValidator) verifyTransactionSignature(ctx context.Context, f
return nil
}
func (t *TransactionValidator) validateTokenTransfer(parameters *CommandParameters, transaction coretypes.Message) (*VerifyTransactionResponse, error) {
func (t *TransactionValidator) validateTokenTransfer(parameters *common.CommandParameters, transaction coretypes.Message) (*VerifyTransactionResponse, error) {
data := transaction.Data()
if len(data) != tokenTransferDataLength {
@ -153,7 +154,7 @@ func (t *TransactionValidator) validateToAddress(specifiedTo, actualTo string) b
return t.addresses[actualTo]
}
func (t *TransactionValidator) validateEthereumTransfer(parameters *CommandParameters, transaction coretypes.Message) (*VerifyTransactionResponse, error) {
func (t *TransactionValidator) validateEthereumTransfer(parameters *common.CommandParameters, transaction coretypes.Message) (*VerifyTransactionResponse, error) {
toAddress := strings.ToLower(transaction.To().Hex())
if !t.validateToAddress(parameters.Address, toAddress) {
@ -197,7 +198,7 @@ type VerifyTransactionResponse struct {
// The address the transaction was actually sent
Address string
Message *Message
Message *common.Message
Transaction *TransactionToValidate
}
@ -205,7 +206,7 @@ type VerifyTransactionResponse struct {
// If a negative response is returned, i.e `Valid` is false, it should
// not be retried.
// If an error is returned, validation can be retried.
func (t *TransactionValidator) validateTransaction(ctx context.Context, message coretypes.Message, parameters *CommandParameters, from *ecdsa.PublicKey) (*VerifyTransactionResponse, error) {
func (t *TransactionValidator) validateTransaction(ctx context.Context, message coretypes.Message, parameters *common.CommandParameters, from *ecdsa.PublicKey) (*VerifyTransactionResponse, error) {
fromAddress := types.BytesToAddress(message.From().Bytes())
err := t.verifyTransactionSignature(ctx, from, fromAddress, parameters.TransactionHash, parameters.Signature)
@ -268,7 +269,7 @@ func (t *TransactionValidator) ValidateTransactions(ctx context.Context) ([]*Ver
}
validationResult.Message = message
} else {
commandParameters := &CommandParameters{}
commandParameters := &common.CommandParameters{}
commandParameters.TransactionHash = transaction.TransactionHash
commandParameters.Signature = transaction.Signature
@ -304,7 +305,7 @@ func (t *TransactionValidator) ValidateTransactions(ctx context.Context) ([]*Ver
return response, nil
}
func (t *TransactionValidator) ValidateTransaction(ctx context.Context, parameters *CommandParameters, from *ecdsa.PublicKey) (*VerifyTransactionResponse, error) {
func (t *TransactionValidator) ValidateTransaction(ctx context.Context, parameters *common.CommandParameters, from *ecdsa.PublicKey) (*VerifyTransactionResponse, error) {
t.logger.Debug("validating transaction", zap.Any("transaction", parameters), zap.Any("from", from))
hash := parameters.TransactionHash
c, cancel := context.WithTimeout(ctx, 10*time.Second)

View File

@ -14,6 +14,7 @@ import (
coretypes "github.com/status-im/status-go/eth-node/core/types"
"github.com/status-im/status-go/eth-node/crypto"
"github.com/status-im/status-go/eth-node/types"
"github.com/status-im/status-go/protocol/common"
"github.com/status-im/status-go/protocol/tt"
)
@ -105,7 +106,7 @@ func (s *TransactionValidatorSuite) TestValidateTransactions() {
Transaction coretypes.Message
OverrideSignatureChatKey *ecdsa.PublicKey
OverrideTransactionHash string
Parameters *CommandParameters
Parameters *common.CommandParameters
WalletKey *ecdsa.PrivateKey
From *ecdsa.PublicKey
}{
@ -123,7 +124,7 @@ func (s *TransactionValidatorSuite) TestValidateTransactions() {
nil,
false,
),
Parameters: &CommandParameters{
Parameters: &common.CommandParameters{
Value: "23",
},
WalletKey: senderWalletKey,
@ -143,7 +144,7 @@ func (s *TransactionValidatorSuite) TestValidateTransactions() {
nil,
false,
),
Parameters: &CommandParameters{
Parameters: &common.CommandParameters{
Value: "23",
Address: strings.ToLower(myAddress1.Hex()),
},
@ -162,7 +163,7 @@ func (s *TransactionValidatorSuite) TestValidateTransactions() {
nil,
false,
),
Parameters: &CommandParameters{
Parameters: &common.CommandParameters{
Value: "23",
Address: strings.ToLower(myAddress1.Hex()),
},
@ -182,7 +183,7 @@ func (s *TransactionValidatorSuite) TestValidateTransactions() {
nil,
false,
),
Parameters: &CommandParameters{
Parameters: &common.CommandParameters{
Value: "23",
Address: strings.ToLower(myAddress1.Hex()),
},
@ -202,7 +203,7 @@ func (s *TransactionValidatorSuite) TestValidateTransactions() {
false,
),
OverrideTransactionHash: "0xdd9202df5e2f3611b5b6b716aef2a3543cc0bdd7506f50926e0869b83c8383b9",
Parameters: &CommandParameters{
Parameters: &common.CommandParameters{
Value: "23",
},
WalletKey: senderWalletKey,
@ -221,7 +222,7 @@ func (s *TransactionValidatorSuite) TestValidateTransactions() {
nil,
false,
),
Parameters: &CommandParameters{
Parameters: &common.CommandParameters{
Value: "23",
Address: strings.ToLower(myAddress2.Hex()),
},
@ -240,7 +241,7 @@ func (s *TransactionValidatorSuite) TestValidateTransactions() {
nil,
false,
),
Parameters: &CommandParameters{
Parameters: &common.CommandParameters{
Value: "23",
},
WalletKey: senderWalletKey,
@ -259,7 +260,7 @@ func (s *TransactionValidatorSuite) TestValidateTransactions() {
nil,
false,
),
Parameters: &CommandParameters{
Parameters: &common.CommandParameters{
Value: "23",
},
WalletKey: senderWalletKey,
@ -279,7 +280,7 @@ func (s *TransactionValidatorSuite) TestValidateTransactions() {
buildData(transferFunction, myAddress1, big.NewInt(int64(23))),
false,
),
Parameters: &CommandParameters{
Parameters: &common.CommandParameters{
Contract: contractString,
Value: "23",
},
@ -300,7 +301,7 @@ func (s *TransactionValidatorSuite) TestValidateTransactions() {
buildData(transferFunction, myAddress1, big.NewInt(int64(23))),
false,
),
Parameters: &CommandParameters{
Parameters: &common.CommandParameters{
Contract: contractString,
Address: strings.ToLower(myAddress1.Hex()),
Value: "23",
@ -322,7 +323,7 @@ func (s *TransactionValidatorSuite) TestValidateTransactions() {
buildData(transferFunction, myAddress1, big.NewInt(int64(13))),
false,
),
Parameters: &CommandParameters{
Parameters: &common.CommandParameters{
Contract: contractString,
Value: "23",
},
@ -341,7 +342,7 @@ func (s *TransactionValidatorSuite) TestValidateTransactions() {
buildData(transferFunction, myAddress1, big.NewInt(int64(23))),
false,
),
Parameters: &CommandParameters{
Parameters: &common.CommandParameters{
Contract: contractString,
Address: strings.ToLower(myAddress1.Hex()),
Value: "23",
@ -362,7 +363,7 @@ func (s *TransactionValidatorSuite) TestValidateTransactions() {
buildData(transferFunction, myAddress1, big.NewInt(int64(23))),
false,
),
Parameters: &CommandParameters{
Parameters: &common.CommandParameters{
Contract: contractString,
Address: strings.ToLower(senderAddress.Hex()),
Value: "23",
@ -383,7 +384,7 @@ func (s *TransactionValidatorSuite) TestValidateTransactions() {
buildData(transferFunction, myAddress2, big.NewInt(int64(23))),
false,
),
Parameters: &CommandParameters{
Parameters: &common.CommandParameters{
Contract: contractString,
Address: strings.ToLower(myAddress1.Hex()),
Value: "23",
@ -403,7 +404,7 @@ func (s *TransactionValidatorSuite) TestValidateTransactions() {
buildData(notTransferFunction, myAddress1, big.NewInt(int64(23))),
false,
),
Parameters: &CommandParameters{
Parameters: &common.CommandParameters{
Contract: contractString,
Value: "23",
},

View File

@ -16,6 +16,7 @@ import (
"github.com/status-im/status-go/eth-node/types"
"github.com/status-im/status-go/mailserver"
"github.com/status-im/status-go/protocol"
"github.com/status-im/status-go/protocol/common"
"github.com/status-im/status-go/protocol/encryption/multidevice"
"github.com/status-im/status-go/protocol/protobuf"
"github.com/status-im/status-go/protocol/pushnotificationclient"
@ -315,7 +316,7 @@ func (api *PublicAPI) SetInstallationMetadata(installationID string, data *multi
}
type ApplicationMessagesResponse struct {
Messages []*protocol.Message `json:"messages"`
Messages []*common.Message `json:"messages"`
Cursor string `json:"cursor"`
}
@ -355,7 +356,7 @@ func (api *PublicAPI) UpdateMessageOutgoingStatus(id, newOutgoingStatus string)
return api.service.messenger.UpdateMessageOutgoingStatus(id, newOutgoingStatus)
}
func (api *PublicAPI) SendChatMessage(ctx context.Context, message *protocol.Message) (*protocol.MessengerResponse, error) {
func (api *PublicAPI) SendChatMessage(ctx context.Context, message *common.Message) (*protocol.MessengerResponse, error) {
return api.service.messenger.SendChatMessage(ctx, message)
}

View File

@ -4,6 +4,7 @@ package shhext
import (
"context"
"github.com/status-im/status-go/protocol/common"
"github.com/ethereum/go-ethereum/log"
@ -465,7 +466,7 @@ func (api *NimbusPublicAPI) VerifyENSNames(details []enstypes.ENSDetails) (map[s
}
type ApplicationMessagesResponse struct {
Messages []*protocol.Message `json:"messages"`
Messages []*common.Message `json:"messages"`
Cursor string `json:"cursor"`
}
@ -501,7 +502,7 @@ func (api *PublicAPI) StartMessenger() error {
return api.service.StartMessenger()
}
func (api *NimbusPublicAPI) SendChatMessage(ctx context.Context, message *protocol.Message) (*protocol.MessengerResponse, error) {
func (api *NimbusPublicAPI) SendChatMessage(ctx context.Context, message *common.Message) (*protocol.MessengerResponse, error) {
return api.service.messenger.SendChatMessage(ctx, message)
}