mirror of
https://github.com/status-im/status-go.git
synced 2025-01-20 19:52:42 +00:00
14dcd29eee
author shashankshampi <shashank.sanket1995@gmail.com> 1729780155 +0530 committer shashankshampi <shashank.sanket1995@gmail.com> 1730274350 +0530 test: Code Migration from status-cli-tests fix_: functional tests (#5979) * fix_: generate on test-functional * chore(test)_: fix functional test assertion --------- Co-authored-by: Siddarth Kumar <siddarthkay@gmail.com> feat(accounts)_: cherry-pick Persist acceptance of Terms of Use & Privacy policy (#5766) (#5977) * feat(accounts)_: Persist acceptance of Terms of Use & Privacy policy (#5766) The original GH issue https://github.com/status-im/status-mobile/issues/21113 came from a request from the Legal team. We must show to Status v1 users the new terms (Terms of Use & Privacy Policy) right after they upgrade to Status v2 from the stores. The solution we use is to create a flag in the accounts table, named hasAcceptedTerms. The flag will be set to true on the first account ever created in v2 and we provide a native call in mobile/status.go#AcceptTerms, which allows the client to persist the user's choice in case they are upgrading (from v1 -> v2, or from a v2 older than this PR). This solution is not the best because we should store the setting in a separate table, not in the accounts table. Related Mobile PR https://github.com/status-im/status-mobile/pull/21124 * fix(test)_: Compare addresses using uppercased strings --------- Co-authored-by: Icaro Motta <icaro.ldm@gmail.com> test_: restore account (#5960) feat_: `LogOnPanic` linter (#5969) * feat_: LogOnPanic linter * fix_: add missing defer LogOnPanic * chore_: make vendor * fix_: tests, address pr comments * fix_: address pr comments fix(ci)_: remove workspace and tmp dir This ensures we do not encounter weird errors like: ``` + ln -s /home/jenkins/workspace/go_prs_linux_x86_64_main_PR-5907 /home/jenkins/workspace/go_prs_linux_x86_64_main_PR-5907@tmp/go/src/github.com/status-im/status-go ln: failed to create symbolic link '/home/jenkins/workspace/go_prs_linux_x86_64_main_PR-5907@tmp/go/src/github.com/status-im/status-go': File exists script returned exit code 1 ``` Signed-off-by: Jakub Sokołowski <jakub@status.im> chore_: enable windows and macos CI build (#5840) - Added support for Windows and macOS in CI pipelines - Added missing dependencies for Windows and x86-64-darwin - Resolved macOS SDK version compatibility for darwin-x86_64 The `mkShell` override was necessary to ensure compatibility with the newer macOS SDK (version 11.0) for x86_64. The default SDK (10.12) was causing build failures because of the missing libs and frameworks. OverrideSDK creates a mapping from the default SDK in all package categories to the requested SDK (11.0). fix(contacts)_: fix trust status not being saved to cache when changed (#5965) Fixes https://github.com/status-im/status-desktop/issues/16392 cleanup added logger and cleanup review comments changes fix_: functional tests (#5979) * fix_: generate on test-functional * chore(test)_: fix functional test assertion --------- Co-authored-by: Siddarth Kumar <siddarthkay@gmail.com> feat(accounts)_: cherry-pick Persist acceptance of Terms of Use & Privacy policy (#5766) (#5977) * feat(accounts)_: Persist acceptance of Terms of Use & Privacy policy (#5766) The original GH issue https://github.com/status-im/status-mobile/issues/21113 came from a request from the Legal team. We must show to Status v1 users the new terms (Terms of Use & Privacy Policy) right after they upgrade to Status v2 from the stores. The solution we use is to create a flag in the accounts table, named hasAcceptedTerms. The flag will be set to true on the first account ever created in v2 and we provide a native call in mobile/status.go#AcceptTerms, which allows the client to persist the user's choice in case they are upgrading (from v1 -> v2, or from a v2 older than this PR). This solution is not the best because we should store the setting in a separate table, not in the accounts table. Related Mobile PR https://github.com/status-im/status-mobile/pull/21124 * fix(test)_: Compare addresses using uppercased strings --------- Co-authored-by: Icaro Motta <icaro.ldm@gmail.com> test_: restore account (#5960) feat_: `LogOnPanic` linter (#5969) * feat_: LogOnPanic linter * fix_: add missing defer LogOnPanic * chore_: make vendor * fix_: tests, address pr comments * fix_: address pr comments chore_: enable windows and macos CI build (#5840) - Added support for Windows and macOS in CI pipelines - Added missing dependencies for Windows and x86-64-darwin - Resolved macOS SDK version compatibility for darwin-x86_64 The `mkShell` override was necessary to ensure compatibility with the newer macOS SDK (version 11.0) for x86_64. The default SDK (10.12) was causing build failures because of the missing libs and frameworks. OverrideSDK creates a mapping from the default SDK in all package categories to the requested SDK (11.0). fix(contacts)_: fix trust status not being saved to cache when changed (#5965) Fixes https://github.com/status-im/status-desktop/issues/16392 test_: remove port bind chore(wallet)_: move route execution code to separate module chore_: replace geth logger with zap logger (#5962) closes: #6002 feat(telemetry)_: add metrics for message reliability (#5899) * feat(telemetry)_: track message reliability Add metrics for dial errors, missed messages, missed relevant messages, and confirmed delivery. * fix_: handle error from json marshal chore_: use zap logger as request logger iterates: status-im/status-desktop#16536 test_: unique project per run test_: use docker compose v2, more concrete project name fix(codecov)_: ignore folders without tests Otherwise Codecov reports incorrect numbers when making changes. https://docs.codecov.com/docs/ignoring-paths Signed-off-by: Jakub Sokołowski <jakub@status.im> test_: verify schema of signals during init; fix schema verification warnings (#5947) fix_: update defaultGorushURL (#6011) fix(tests)_: use non-standard port to avoid conflicts We have observed `nimbus-eth2` build failures reporting this port: ```json { "lvl": "NTC", "ts": "2024-10-28 13:51:32.308+00:00", "msg": "REST HTTP server could not be started", "topics": "beacnde", "address": "127.0.0.1:5432", "reason": "(98) Address already in use" } ``` https://ci.status.im/job/nimbus-eth2/job/platforms/job/linux/job/x86_64/job/main/job/PR-6683/3/ Signed-off-by: Jakub Sokołowski <jakub@status.im> fix_: create request logger ad-hoc in tests Fixes `TestCall` failing when run concurrently. chore_: configure codecov (#6005) * chore_: configure codecov * fix_: after_n_builds
239 lines
9.6 KiB
Go
239 lines
9.6 KiB
Go
//go:build nimbus
|
|
// +build nimbus
|
|
|
|
package shhext
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/status-im/status-go/protocol/common"
|
|
|
|
"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"
|
|
"github.com/status-im/status-go/protocol/encryption/multidevice"
|
|
"github.com/status-im/status-go/protocol/transport"
|
|
)
|
|
|
|
// -----
|
|
// PUBLIC API
|
|
// -----
|
|
|
|
// NimbusPublicAPI extends whisper public API.
|
|
type NimbusPublicAPI struct {
|
|
service *NimbusService
|
|
publicAPI types.PublicWhisperAPI
|
|
}
|
|
|
|
// NewPublicAPI returns instance of the public API.
|
|
func NewNimbusPublicAPI(s *NimbusService) *NimbusPublicAPI {
|
|
return &NimbusPublicAPI{
|
|
service: s,
|
|
publicAPI: s.w.PublicWhisperAPI(),
|
|
}
|
|
}
|
|
|
|
// ConfirmMessagesProcessedByID is a method to confirm that messages was consumed by
|
|
// the client side.
|
|
// TODO: this is broken now as it requires dedup ID while a message hash should be used.
|
|
func (api *NimbusPublicAPI) ConfirmMessagesProcessedByID(messageConfirmations []*Metadata) error {
|
|
confirmationCount := len(messageConfirmations)
|
|
dedupIDs := make([][]byte, confirmationCount)
|
|
encryptionIDs := make([][]byte, confirmationCount)
|
|
for i, confirmation := range messageConfirmations {
|
|
dedupIDs[i] = confirmation.DedupID
|
|
encryptionIDs[i] = confirmation.EncryptionID
|
|
}
|
|
return api.service.ConfirmMessagesProcessed(encryptionIDs)
|
|
}
|
|
|
|
// Post is used to send one-to-one for those who did not enabled device-to-device sync,
|
|
// in other words don't use PFS-enabled messages. Otherwise, SendDirectMessage is used.
|
|
// It's important to call NimbusPublicAPI.afterSend() so that the client receives a signal
|
|
// with confirmation that the message left the device.
|
|
func (api *NimbusPublicAPI) Post(ctx context.Context, newMessage types.NewMessage) (types.HexBytes, error) {
|
|
return api.publicAPI.Post(ctx, newMessage)
|
|
}
|
|
|
|
func (api *NimbusPublicAPI) Join(chat protocol.Chat) error {
|
|
return api.service.messenger.Join(chat)
|
|
}
|
|
|
|
func (api *NimbusPublicAPI) Leave(chat protocol.Chat) error {
|
|
return api.service.messenger.Leave(chat)
|
|
}
|
|
|
|
func (api *NimbusPublicAPI) LeaveGroupChat(ctx Context, chatID string) (*protocol.MessengerResponse, error) {
|
|
return api.service.messenger.LeaveGroupChat(ctx, chatID)
|
|
}
|
|
|
|
func (api *NimbusPublicAPI) CreateGroupChatWithMembers(ctx Context, name string, members []string) (*protocol.MessengerResponse, error) {
|
|
return api.service.messenger.CreateGroupChatWithMembers(ctx, name, members)
|
|
}
|
|
|
|
func (api *NimbusPublicAPI) AddMembersToGroupChat(ctx Context, chatID string, members []string) (*protocol.MessengerResponse, error) {
|
|
return api.service.messenger.AddMembersToGroupChat(ctx, chatID, members)
|
|
}
|
|
|
|
func (api *NimbusPublicAPI) RemoveMemberFromGroupChat(ctx Context, chatID string, member string) (*protocol.MessengerResponse, error) {
|
|
return api.service.messenger.RemoveMembersFromGroupChat(ctx, chatID, []string{member})
|
|
}
|
|
|
|
func (api *NimbusPublicAPI) AddAdminsToGroupChat(ctx Context, chatID string, members []string) (*protocol.MessengerResponse, error) {
|
|
return api.service.messenger.AddAdminsToGroupChat(ctx, chatID, members)
|
|
}
|
|
|
|
func (api *NimbusPublicAPI) ConfirmJoiningGroup(ctx context.Context, chatID string) (*protocol.MessengerResponse, error) {
|
|
return api.service.messenger.ConfirmJoiningGroup(ctx, chatID)
|
|
}
|
|
|
|
func (api *NimbusPublicAPI) LoadFilters(parent context.Context, chats []*transport.Filter) ([]*transport.Filter, error) {
|
|
return api.service.messenger.LoadFilters(chats)
|
|
}
|
|
|
|
func (api *NimbusPublicAPI) SaveChat(parent context.Context, chat *protocol.Chat) error {
|
|
return api.service.messenger.SaveChat(chat)
|
|
}
|
|
|
|
func (api *NimbusPublicAPI) Chats(parent context.Context) []*protocol.Chat {
|
|
return api.service.messenger.Chats()
|
|
}
|
|
|
|
func (api *NimbusPublicAPI) DeleteChat(parent context.Context, chatID string) error {
|
|
return api.service.messenger.DeleteChat(chatID)
|
|
}
|
|
|
|
func (api *NimbusPublicAPI) SaveContact(parent context.Context, contact *protocol.Contact) error {
|
|
return api.service.messenger.SaveContact(contact)
|
|
}
|
|
|
|
func (api *NimbusPublicAPI) BlockContact(parent context.Context, contact *protocol.Contact) (*protocol.MessengerResponse, error) {
|
|
return api.service.messenger.BlockContact(contact)
|
|
}
|
|
|
|
func (api *NimbusPublicAPI) Contacts(parent context.Context) []*protocol.Contact {
|
|
return api.service.messenger.Contacts()
|
|
}
|
|
|
|
func (api *NimbusPublicAPI) RemoveFilters(parent context.Context, chats []*transport.Filter) error {
|
|
return api.service.messenger.RemoveFilters(chats)
|
|
}
|
|
|
|
// EnableInstallation enables an installation for multi-device sync.
|
|
func (api *NimbusPublicAPI) EnableInstallation(installationID string) error {
|
|
return api.service.messenger.EnableInstallation(installationID)
|
|
}
|
|
|
|
// DisableInstallation disables an installation for multi-device sync.
|
|
func (api *NimbusPublicAPI) DisableInstallation(installationID string) error {
|
|
return api.service.messenger.DisableInstallation(installationID)
|
|
}
|
|
|
|
// GetOurInstallations returns all the installations available given an identity
|
|
func (api *NimbusPublicAPI) GetOurInstallations() []*multidevice.Installation {
|
|
return api.service.messenger.Installations()
|
|
}
|
|
|
|
// SetInstallationMetadata sets the metadata for our own installation
|
|
func (api *NimbusPublicAPI) SetInstallationMetadata(installationID string, data *multidevice.InstallationMetadata) error {
|
|
return api.service.messenger.SetInstallationMetadata(installationID, data)
|
|
}
|
|
|
|
// VerifyENSNames takes a list of ensdetails and returns whether they match the public key specified
|
|
func (api *NimbusPublicAPI) VerifyENSNames(details []enstypes.ENSDetails) (map[string]enstypes.ENSResponse, error) {
|
|
return api.service.messenger.VerifyENSNames(api.service.config.VerifyENSURL, ensContractAddress, details)
|
|
}
|
|
|
|
type ApplicationMessagesResponse struct {
|
|
Messages []*common.Message `json:"messages"`
|
|
Cursor string `json:"cursor"`
|
|
}
|
|
|
|
func (api *NimbusPublicAPI) ChatMessages(chatID, cursor string, limit int) (*ApplicationMessagesResponse, error) {
|
|
messages, cursor, err := api.service.messenger.MessageByChatID(chatID, cursor, limit)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &ApplicationMessagesResponse{
|
|
Messages: messages,
|
|
Cursor: cursor,
|
|
}, nil
|
|
}
|
|
|
|
func (api *NimbusPublicAPI) DeleteMessage(id string) error {
|
|
return api.service.messenger.DeleteMessage(id)
|
|
}
|
|
|
|
func (api *NimbusPublicAPI) DeleteMessagesByChatID(id string) error {
|
|
return api.service.messenger.DeleteMessagesByChatID(id)
|
|
}
|
|
|
|
func (api *NimbusPublicAPI) MarkMessagesSeen(chatID string, ids []string) error {
|
|
return api.service.messenger.MarkMessagesSeen(chatID, ids)
|
|
}
|
|
|
|
func (api *NimbusPublicAPI) UpdateMessageOutgoingStatus(id, newOutgoingStatus string) error {
|
|
return api.service.messenger.UpdateMessageOutgoingStatus(id, newOutgoingStatus)
|
|
}
|
|
|
|
func (api *PublicAPI) StartMessenger() error {
|
|
return api.service.StartMessenger()
|
|
}
|
|
|
|
func (api *NimbusPublicAPI) SendChatMessage(ctx context.Context, message *common.Message) (*protocol.MessengerResponse, error) {
|
|
return api.service.messenger.SendChatMessage(ctx, message)
|
|
}
|
|
|
|
func (api *NimbusPublicAPI) SendPinMessage(ctx context.Context, message *common.PinMessage) (*protocol.MessengerResponse, error) {
|
|
return api.service.messenger.SendPinMessage(ctx, message)
|
|
}
|
|
|
|
func (api *NimbusPublicAPI) ReSendChatMessage(ctx context.Context, messageID string) error {
|
|
return api.service.messenger.ReSendChatMessage(ctx, messageID)
|
|
}
|
|
|
|
func (api *NimbusPublicAPI) RequestTransaction(ctx context.Context, chatID, value, contract, address string) (*protocol.MessengerResponse, error) {
|
|
return api.service.messenger.RequestTransaction(ctx, chatID, value, contract, address)
|
|
}
|
|
|
|
func (api *NimbusPublicAPI) RequestAddressForTransaction(ctx context.Context, chatID, from, value, contract string) (*protocol.MessengerResponse, error) {
|
|
return api.service.messenger.RequestAddressForTransaction(ctx, chatID, from, value, contract)
|
|
}
|
|
|
|
func (api *NimbusPublicAPI) DeclineRequestAddressForTransaction(ctx context.Context, messageID string) (*protocol.MessengerResponse, error) {
|
|
return api.service.messenger.DeclineRequestAddressForTransaction(ctx, messageID)
|
|
}
|
|
|
|
func (api *NimbusPublicAPI) DeclineRequestTransaction(ctx context.Context, messageID string) (*protocol.MessengerResponse, error) {
|
|
return api.service.messenger.DeclineRequestTransaction(ctx, messageID)
|
|
}
|
|
|
|
func (api *NimbusPublicAPI) AcceptRequestAddressForTransaction(ctx context.Context, messageID, address string) (*protocol.MessengerResponse, error) {
|
|
return api.service.messenger.AcceptRequestAddressForTransaction(ctx, messageID, address)
|
|
}
|
|
|
|
func (api *NimbusPublicAPI) SendTransaction(ctx context.Context, chatID, value, contract, transactionHash string, signature types.HexBytes) (*protocol.MessengerResponse, error) {
|
|
return api.service.messenger.SendTransaction(ctx, chatID, value, contract, transactionHash, signature)
|
|
}
|
|
|
|
func (api *NimbusPublicAPI) AcceptRequestTransaction(ctx context.Context, transactionHash, messageID string, signature types.HexBytes) (*protocol.MessengerResponse, error) {
|
|
return api.service.messenger.AcceptRequestTransaction(ctx, transactionHash, messageID, signature)
|
|
}
|
|
|
|
func (api *NimbusPublicAPI) SendContactUpdates(ctx context.Context, name, picture string) error {
|
|
return api.service.messenger.SendContactUpdates(ctx, name, picture)
|
|
}
|
|
|
|
func (api *NimbusPublicAPI) SendContactUpdate(ctx context.Context, contactID, name, picture string) (*protocol.MessengerResponse, error) {
|
|
return api.service.messenger.SendContactUpdate(ctx, contactID, name, picture)
|
|
}
|
|
|
|
func (api *NimbusPublicAPI) SendPairInstallation(ctx context.Context) (*protocol.MessengerResponse, error) {
|
|
return api.service.messenger.SendPairInstallation(ctx)
|
|
}
|
|
|
|
func (api *NimbusPublicAPI) SyncDevices(ctx context.Context, name, picture string) error {
|
|
return api.service.messenger.SyncDevices(ctx, name, picture)
|
|
}
|