Commit Graph

244 Commits

Author SHA1 Message Date
Dario Gabriel Lipicar e6711c8cc8 feat(wallet): detect ETH L1 to L2 bridge transactions 2023-07-10 09:59:05 -03:00
Andrea Maria Piana e08aad7d73 Send account/settings on login 2023-07-06 17:35:32 +01:00
frank bbb17c6ce8 fix: unable to perform backup 2023-06-29 13:04:49 +01:00
frank 09c5223d77
fix: ROW_NUMBER() not work on ios for some reason (#3687) 2023-06-29 18:45:57 +08:00
Roman Volosovskyi 18a0bc3130
Set installation name on account creation and pairing 2023-06-29 10:14:12 +02:00
Khushboo-dev-cpp bada9fee11
fix: Revert wrongly checked-in prev file (#3688) 2023-06-28 17:25:13 +02:00
Khushboo-dev-cpp e1004b4aec
feat: Add new settings for include watch-only accounts (#3676) 2023-06-28 12:05:06 +02:00
Pascal Precht b8b402da8d feat: store check channel permission responses
This commit adds new tables to the database and APIs in `Messenger` and
communities `Manager` to store `CheckChannelPermissionsResponse`s.

The responses are stored whenever channel permissions have been checked.

The reason we're doing this is so that clients can retrieve the last
known channel permission state before waiting for onchain checks to
finish.
2023-06-27 12:13:59 +02:00
Anthony Laibe da2f155f2d feat: add account position 2023-06-26 16:15:48 +02:00
Boris Melnik 3e7d1a5f34
fix(migration): Fixes mute_till migration (#3653) 2023-06-22 18:49:58 +03:00
Ibrahem Khalil d3e650d5e5
Make chat muting only works on one chat and not to completely block PNs from a user (#3647) 2023-06-22 08:06:32 +03:00
Dario Gabriel Lipicar bf54a57780 fix: correct transfer type detection 2023-06-21 12:10:25 -03:00
Stefan 8e63f44735 feat(wallet) filter activity by erc20
Main changes:

- Refactor activity API to propagate token identities.
- Extend service to convert token identities to symbols for filtering
  multi-transaction
- Filter transfers, pending_transactions and multi-transactions based
  on the provided token identities
- Return involved token identities in activity API
- Test token filtering

Also:

- Fixed calling cancel on a filer activity completed task to release
  resources

Notes:

- Found limitations with the token identity which complicates things
  by not allowing to filter by token groups (like token-code does)

Updates status-desktop #11025
2023-06-20 14:06:49 +02:00
Boris Melnik 1eb92a19a2
feat(communities): Adds muting interval to community (#3549) 2023-06-17 11:19:05 +03:00
Mykhailo Prakhov e058b50a2e
feat: community admin permission functionality (#3569)
* feat: community admin implementation

* fix: code review fixes

* chore: request admin permissions in CheckPermissionToJoin, unit test fix
2023-06-14 10:15:46 -04:00
Alex Jbanca 3978048afa
feat: Make DB re-encryption fault proof (#3607)
Improve the error management in order to avoid DB corruption in case the process is killed while encrypting the DB.

Changes:
Use sqlcipher_export instead of rekey to change the DB password. The advantage is that sqlcipher_export will operate on a new DB file and we don't need to modify the current account unless the export is successful.
Keeping the rekey requires to create a DB copy before trying to re-encrypt the DB, but the DB copy is risky in case the DB file changes wile the copy is in progress. It could also lead to DB corruption.
2023-06-14 13:12:23 +03:00
Alex Jbanca 43b2c3b7ce
perf(sqlCipher): Increase cipher page size to 8192 (#3591)
* perf(sqlCipher): Increase cipher page size to 8192

Increasing the cipher page size to 8192 requires DB re-encryption. The process is as follows:
//Login to v3 DB
PRAGMA key = 'key';
PRAGMA cipher_page_size = 1024"; // old Page size
PRAGMA cipher_hmac_algorithm = HMAC_SHA1";
PRAGMA cipher_kdf_algorithm = PBKDF2_HMAC_SHA1";
PRAGMA kdf_iter = kdfIterationsNumber";

//Create V4 DB with increased page size
ATTACH DATABASE 'newdb.db' AS newdb KEY 'key';
PRAGMA newdb.cipher_page_size = 8192; // new Page size
PRAGMA newdb.cipher_hmac_algorithm = HMAC_SHA1"; // same as in v3
PRAGMA newdb.cipher_kdf_algorithm = PBKDF2_HMAC_SHA1"; // same as in v3
PRAGMA newdb.kdf_iter = kdfIterationsNumber"; // same as in v3
SELECT sqlcipher_export('newdb');
DETACH DATABASE newdb;

//Login to V4 DB
...

Worth noting:
The DB migration will happen on the first successful login.
The new DB version will have a different name to be able to distinguish between different DB versions.Versions naming mirrors sqlcipher major version (naming conventions used by sqlcipher), meaning that we're migrating from V3 to V4 DB (even if we're not fully aligned with V4 standards). The DB is not migrated to the v4 standard `SHA512` due to performance reasons. Our custom `SHA1` implementation is fully optimised for perfomance.

* perf(sqlCipher): Fixing failing tests

Update the new DB file format in Delete account, Change password and Decrypt database flows

* perf(SQLCipher): Increase page size - send events to notify when the DB re-encryption starts/ends
2023-06-13 18:20:21 +03:00
mprakhov 6bc8765d39 chore: new CommunityTokenPermission types 2023-06-13 13:42:48 +02:00
Stefan 5b6f7226bb feat(wallet) extract json blobs and add custom migration support
Extended the migration process with a generic way of applying custom
migration code on top of the SQL files. The implementation provides
a safer way to run GO code along with the SQL migrations and possibility
of rolling back the changes in case of failure to keep the database
consistent.
This custom GO migration is needed to extract the status from
the JSON blob receipt and store it in transfers table.

Other changes:
- Add NULL DB value tracking to JSONBlob helper
- Index status column on transfers table
- Remove unnecessary panic calls
- Move log_parser to wallet's common package and use to extract token
  identity from the logs

Notes:
- there is already an index on transfers table, sqlite creates one for
  each unique constraint therefore add only status to a new index
- the planned refactoring and improvements to the database have been
  postponed due to time constraints. Got the time to migrate the data
  though, extracting it can be done later for a more efficient
  implementation

Update status-desktop #10746
2023-06-08 13:54:40 +02:00
Stefan bf29188b2d fix(wallet) add index on transfers(blk_number, loaded)
Improve performance of queries for
- transfer.GetTransfersInRange
- transfer.GetTransfersByAddress
- transfer.GetTransfersByAddressAndBlock
- transfer.GetTransfers
- transfer.GetPreloadedTransactions

For 16952 entries worst case scenario tested with `sqlcipher`:
- Before: Run Time: real 0.897 user 0.728139 sys 0.166714
- After:  Run Time: real 0.001 user 0.000437 sys 0.000189

A single composite index (with the default one) might work better though
2023-06-06 12:09:38 +02:00
Sale Djenic a11cbb2f30 fix: profile social links, `position` column addded 2023-06-06 09:59:12 +02:00
Sale Djenic cff7d2f693 fix: profile social links updated 2023-06-06 09:59:12 +02:00
Dario Gabriel Lipicar 2fc79fb9b5 feat(Wallet) detect uniswapV2 swap events
Part of #10251
2023-06-05 12:08:18 -03:00
Sale Djenic c6192bd26c fix: issues caused by wrong `pairing.proto` fixed 2023-06-05 09:29:34 +02:00
Khushboo-dev-cpp 8b91e3aaaf
chore: Add ColorId for Wallet accounts that can be shared with mobile (#3521) 2023-06-02 17:06:51 +02:00
Roman Volosovskyi ee4003279a
Changes necessary to restore wallet on mobile app 2023-05-25 21:08:34 +02:00
Sale Djenic eeaaf0ce3f feat: accounts improvements applied
- old `accounts` table is moved/mapped to `keypairs` and `keypairs_accounts`
- `keycards` table has foreign key which refers to `keypairs.key_uid`
- `Keypair` introduced as a new type
- api endpoints updated according to this change
2023-05-25 19:46:47 +02:00
Andrea Maria Piana 959e370389 config: add new Push notifications fleet
Also drop no longer existing `eth.test` fleet.

Signed-off-by: Jakub Sokołowski <jakub@status.im>
2023-05-19 17:29:18 +01:00
Andrea Maria Piana 6acb34bab7 Allow setting up wallet with new config
This commit does a few things:

1) Extend create/import account endpoint to get wallet config, some of
   which has been moved to the backend
2) Set up a loop for retrieving balances every 10 minutes, caching the
   balances
3) Return information about which checks are not passing when trying to
   join a token gated community
4) Add tests to the token gated communities
5) Fixes an issue with addresses not matching when checking for
   permissions

The move to the wallet as a background task is not yet complete, I need
to publish a signal, and most likely I will disable it before merging
for now, as it's currently not used by desktop/mobile, but the PR was
  getting to big
2023-05-19 13:23:21 +01:00
IvanBelyakoff 94c7cd32af
feat(wallet): Implemented SequentialFetchStrategy for transfers. (#3480)
By default OnDemandFetchStategy is still used.

Updates #10246
2023-05-19 11:19:48 +03:00
Icaro Motta 6fa8c11382
URL unfurling (initial implementation) (#3471)
This is the initial implementation for the new URL unfurling requirements. The
most important one is that only the message sender will pay the privacy cost for
unfurling and extracting metadata from websites. Once the message is sent, the
unfurled data will be stored at the protocol level and receivers will just
profit and happily decode the metadata to render it.

Further development of this URL unfurling capability will be mostly guided by
issues created on clients. For the moment in status-mobile:
https://github.com/status-im/status-mobile/labels/url-preview

- https://github.com/status-im/status-mobile/issues/15918
- https://github.com/status-im/status-mobile/issues/15917
- https://github.com/status-im/status-mobile/issues/15910
- https://github.com/status-im/status-mobile/issues/15909
- https://github.com/status-im/status-mobile/issues/15908
- https://github.com/status-im/status-mobile/issues/15906
- https://github.com/status-im/status-mobile/issues/15905

### Terminology

In the code, I've tried to stick to the word "unfurl URL" to really mean the
process of extracting metadata from a website, sort of lower level. I use "link
preview" to mean a higher level structure which is enriched by unfurled data.
"link preview" is also how designers refer to it.

### User flows

1. Carol needs to see link previews while typing in the chat input field. Notice
   from the diagram nothing is persisted and that status-go endpoints are
   essentially stateless.

```
#+begin_src plantuml :results verbatim
  Client->>Server: Call wakuext_getTextURLs
  Server-->>Client: Normalized URLs
  Client->>Client: Render cached unfurled URLs
  Client->>Server: Unfurl non-cached URLs.\nCall wakuext_unfurlURLs
  Server->>Website: Fetch metadata
  Website-->>Server: Metadata (thumbnail URL, title, etc)
  Server->>Website: Fetch thumbnail
  Server->>Website: Fetch favicon
  Website-->>Server: Favicon bytes
  Website-->>Server: Thumbnail bytes
  Server->>Server: Decode & process images
  Server-->>Client: Unfurled data (thumbnail data URI, etc)
#+end_src
```

```
     ,------.                                 ,------.                             ,-------.
     |Client|                                 |Server|                             |Website|
     `--+---'                                 `--+---'                             `---+---'
        |        Call wakuext_getTextURLs        |                                     |
        | --------------------------------------->                                     |
        |                                        |                                     |
        |             Normalized URLs            |                                     |
        | <- - - - - - - - - - - - - - - - - - - -                                     |
        |                                        |                                     |
        |----.                                   |                                     |
        |    | Render cached unfurled URLs       |                                     |
        |<---'                                   |                                     |
        |                                        |                                     |
        |         Unfurl non-cached URLs.        |                                     |
        |         Call wakuext_unfurlURLs        |                                     |
        | --------------------------------------->                                     |
        |                                        |                                     |
        |                                        |            Fetch metadata           |
        |                                        | ------------------------------------>
        |                                        |                                     |
        |                                        | Metadata (thumbnail URL, title, etc)|
        |                                        | <- - - - - - - - - - - - - - - - - -
        |                                        |                                     |
        |                                        |           Fetch thumbnail           |
        |                                        | ------------------------------------>
        |                                        |                                     |
        |                                        |            Fetch favicon            |
        |                                        | ------------------------------------>
        |                                        |                                     |
        |                                        |            Favicon bytes            |
        |                                        | <- - - - - - - - - - - - - - - - - -
        |                                        |                                     |
        |                                        |           Thumbnail bytes           |
        |                                        | <- - - - - - - - - - - - - - - - - -
        |                                        |                                     |
        |                                        |----.                                |
        |                                        |    | Decode & process images        |
        |                                        |<---'                                |
        |                                        |                                     |
        | Unfurled data (thumbnail data URI, etc)|                                     |
        | <- - - - - - - - - - - - - - - - - - - -                                     |
     ,--+---.                                 ,--+---.                             ,---+---.
     |Client|                                 |Server|                             |Website|
     `------'                                 `------'                             `-------'
```

2. Carol sends the text message with link previews in the RPC request
   wakuext_sendChatMessages. status-go assumes the link previews are good
   because it can't and shouldn't attempt to re-unfurl them.

```
#+begin_src plantuml :results verbatim
  Client->>Server: Call wakuext_sendChatMessages
  Server->>Server: Transform link previews to\nbe proto-marshalled
  Server->DB: Write link previews serialized as JSON
  Server-->>Client: Updated message response
#+end_src
```

```
     ,------.                       ,------.                                  ,--.
     |Client|                       |Server|                                  |DB|
     `--+---'                       `--+---'                                  `+-'
        | Call wakuext_sendChatMessages|                                       |
        | ----------------------------->                                       |
        |                              |                                       |
        |                              |----.                                  |
        |                              |    | Transform link previews to       |
        |                              |<---' be proto-marshalled              |
        |                              |                                       |
        |                              |                                       |
        |                              | Write link previews serialized as JSON|
        |                              | -------------------------------------->
        |                              |                                       |
        |   Updated message response   |                                       |
        | <- - - - - - - - - - - - - - -                                       |
     ,--+---.                       ,--+---.                                  ,+-.
     |Client|                       |Server|                                  |DB|
     `------'                       `------'                                  `--'
```

3. The message was sent over waku and persisted locally in Carol's device. She
   should now see the link previews in the chat history. There can be many link
   previews shared by other chat members, therefore it is important to serve the
   assets via the media server to avoid overloading the ReactNative bridge with
   lots of big JSON payloads containing base64 encoded data URIs (maybe this
   concern is meaningless for desktop). When a client is rendering messages with
   link previews, they will have the field linkPreviews, and the thumbnail URL
   will point to the local media server.

```
 #+begin_src plantuml :results verbatim
   Client->>Server: GET /link-preview/thumbnail (media server)
   Server->>DB: Read from user_messages.unfurled_links
   Server->Server: Unmarshal JSON
   Server-->>Client: HTTP Content-Type: image/jpeg/etc
 #+end_src
```

```
     ,------.                                    ,------.                                  ,--.
     |Client|                                    |Server|                                  |DB|
     `--+---'                                    `--+---'                                  `+-'
        | GET /link-preview/thumbnail (media server)|                                       |
        | ------------------------------------------>                                       |
        |                                           |                                       |
        |                                           | Read from user_messages.unfurled_links|
        |                                           | -------------------------------------->
        |                                           |                                       |
        |                                           |----.                                  |
        |                                           |    | Unmarshal JSON                   |
        |                                           |<---'                                  |
        |                                           |                                       |
        |     HTTP Content-Type: image/jpeg/etc     |                                       |
        | <- - - - - - - - - - - - - - - - - - - - -                                        |
     ,--+---.                                    ,--+---.                                  ,+-.
     |Client|                                    |Server|                                  |DB|
     `------'                                    `------'                                  `--'
```

### Some limitations of the current implementation

The following points will become separate issues in status-go that I'll work on
over the next couple weeks. In no order of importance:

- Improve how multiple links are fetched; retries on failure and testing how
  unfurling behaves around the timeout limits (deterministically, not by making
  real HTTP calls as I did). https://github.com/status-im/status-go/issues/3498
- Unfurl favicons and store them in the protobuf too.
- For this PR, I added unfurling support only for websites with OpenGraph
  https://ogp.me/ meta tags. Other unfurlers will be implemented on demand. The
  next one will probably be for oEmbed https://oembed.com/, the protocol
  supported by YouTube, for example.
- Resize and/or compress thumbnails (and favicons). Often times, thumbnails are
  huge for the purposes of link previews. There is already support for
  compressing JPEGs in status-go, but I prefer to work with compression in a
  separate PR because I'd like to also solve the problem for PNGs (probably
  convert them to JPEGs, plus compress them). This would be a safe choice for
  thumbnails, favicons not so much because transparency is desirable.
- Editing messages is not yet supported.
- I haven't coded any artificial limit on the number of previews or on the size
  of the thumbnail payload. This will be done in a separate issue. I have heard
  the ideal solution may be to split messages into smaller chunks of ~125 KiB
  because of libp2p, but that might be too complicated at this stage of the
  product (?).
- Link preview deletion.
- For the moment, OpenGraph metadata is extracted by requesting data for the
  English language (and fallback to whatever is available). In the future, we'll
  want to unfurl by respecting the user's local device language. Some websites,
  like GoDaddy, are already localized based on the device's IP, but many aren't.
- The website's description text should be limited by a certain number of
  characters, especially because it's outside our control. Exactly how much has
  not been decided yet, so it'll be done separately.
- URL normalization can be tricky, so I implemented only the basics to help with
  caching. For example, the url https://status.im and HTTPS://status.im are
  considered identical. Also, a URL is considered valid for unfurling if its TLD
  exists according to publicsuffix.EffectiveTLDPlusOne. This was essential,
  otherwise the default Go url.Parse approach would consider many invalid URLs
  valid, and thus the server would waste resources trying to unfurl the
  unfurleable.

### Other requirements

- If the message is edited, the link previews should reflect the edited text,
  not the original one. This has been aligned with the design team as well.
- If the website's thumbnail or the favicon can't be fetched, just ignore them.
  The only mandatory piece of metadata is the website's title and URL.
- Link previews in clients should be generated in near real-time, that is, as
  the user types, previews are updated. In mobile this performs very well, and
  it's what other clients like WhatsApp, Telegram, and Facebook do.

### Decisions

- While the user typing in the input field, the client is constantly (debounced)
  asking status-go to parse the text and extract normalized URLs and then the
  client checks if they're already in its in-memory cache. If they are, no RPC
  call is made. I chose this approach to achieve the best possible performance
  in mobile and avoid the whole RPC overhead, since the chat experience is
  already not smooth enough. The mobile client uses URLs as cache keys in a
  hashmap, i.e. if the key is present, it means the preview is readily available
  (naive, but good enough for now). This decision also gave me more flexibility
  to find the best UX at this stage of the feature.
- Due to the requirement that users should be able to see independent loading
  indicators for each link preview, when status-go can't unfurl a URL, it
  doesn't return it in the response.
- As an initial implementation, I added the BLOB column unfurled_links to the
  user_messages table. The preview data is then serialized as JSON before being
  stored in this column. I felt that creating a separate table and the related
  code for this initial PR would be inconvenient. Is that reasonable to you?
  Once things stabilize I can create a proper table if we want to avoid this
  kind of solution with serialized columns.
2023-05-18 15:43:06 -03:00
frank 98d3b4198b
sync message for `delete for me` should not be sent to someone else (#3462)
* sync message for `delete for me` should not be sent to someone else

* addressed feedback from review

* remove LocalChatID

* bump version
2023-05-09 20:54:56 +08:00
frank a2ed1b78dd
feat:support backup/sync ens name (#3415) 2023-04-26 23:37:18 +08:00
Andrea Maria Piana 7650f3003e Fix some issues with pinned messages
There were a couple of issues on how we handle pinned messages:

1) Clock of the message was only checked when saving, meaning that the
   client would receive potentially updates that were not to be
   processed.
2) We relied on the client to generate a notification for a pinned
   message by sending a normal message through the wire. This PR changes
   the behavior so that the notification is generated locally, either on
   response to a network event or client event.
3) When deleting a message, we pull all the replies/pinned notifications
   and send them over to the client so they know that those messages
   needs updating.
2023-04-25 16:02:48 +01:00
Anthony Laibe dd7c59423f feat: add saved address created at 2023-04-22 10:22:43 +02:00
Sale Djenic a0b062b503 chore: unused `latest_derived_path` removed from `settings` table 2023-04-21 16:35:24 +02:00
frank 272173c939
feat:support backup/sync social settings (#3407)
* feat:support backup/sync social settings

* update binddata.go

* fix lint issue

* addressed feedback from @saledjenic @osmaczko

* addressed feedback from @saledjenic @osmaczko

* add corresponding test for local pairing

* addressed feedback from @saledjenic
2023-04-20 06:59:09 +08:00
Richard Ramos 2ebe5b97e7 fix: set default value in sync period column to 9d 2023-04-18 09:41:42 -04:00
Samuel Hawksby-Robinson b47bc730a0 reset superfluous go mod tidy changes 2023-04-17 12:01:38 +01:00
Samuel Hawksby-Robinson 17bc1e9f5d Rough initial proof of concept for udp network checking 2023-04-17 12:01:38 +01:00
Ibrahem Khalil 719af90fcc
Add muted_till param for chats (#3258) 2023-04-16 17:06:00 +02:00
Richard Ramos 06749717ea chore: set default sync period to 9 days 2023-04-13 14:20:15 -04:00
frank 5fd9e93e9c
backup/sync if seed phrase removed (#3385) (#3384)
backup/sync bio
2023-04-13 08:45:25 +08:00
Ibrahem Khalil d0766e3023
Update album_images_count column on receiver side (#3375) 2023-04-05 15:24:55 +02:00
Boris Melnik 696e061861
fix(unread_count): Skip extra count of new messages for album of images (#3345)
* fix(unread_count): Skip extra count of new messages for album of images

* fix(unread_count): Update migration files
2023-03-31 12:15:06 +03:00
Ibrahem Khalil bd593373b2
Add album count key to messages (#3347) 2023-03-30 12:02:20 +02:00
Sale Djenic f10bd00ceb feat: `keypair_name` and `last_used_derivation_index` columns added to `accounts` table
- `keypair_name` added to `accounts` table, all accounts derived from the
same master key have the same keypair name and also no two keypairs share
the same keypair name (keypair name is unique per keypair)
- `last_used_derivation_index` added to `accounts` table, cause we need
to maintain the highest index been used for the derivations made within
the same keypair
2023-03-28 16:19:27 +02:00
Andrea Maria Piana b20dc0a87c Add index to raw messages 2023-03-16 13:40:20 +00:00
Andrea Maria Piana 44a0f5b74d
Add collapsed community categories 2023-03-14 17:13:21 +00:00
Sale Djenic b660672a60 chore(accounts): `type` column from `accounts` table updated
`type` column is set for all rows to appropriate value. Before this change
accounts which were generated from the keypair created importing seed phrase
had `generated` value for the `type`.

According to above, a function for generating an account sets the `type`
based on the passed derive from address.
2023-03-07 11:28:06 +01:00