feat(wallet) return offset in the activity result

Updates status-desktop #10994
This commit is contained in:
Stefan 2023-06-11 16:22:25 +02:00 committed by Stefan Dunca
parent 37653638bc
commit 4c8fd538ba
3 changed files with 15 additions and 10 deletions

View File

@ -4,9 +4,9 @@
| | Buy | Swap | Bridge | Send/Receive |
| ------------- | -------------- | -------------- | ------------- | ------------- |
| Activity data | ~~API~~ ~~DB~~ | ~~API~~ ~~DB~~ | _API_ _DB_ | _API_ _DB_ |
| Raw data | ~~API~~ ~~DB~~ | ~~API~~ ~~DB~~ | _API_ _DB_ | _API_ _DB_ |
| Pending data | ~~API~~ ~~DB~~ | ~~API~~ ~~DB~~ | _API_ _DB_ | _API_ _DB_ |
| Activity data | ~~API~~ ~~DB~~ | ~~API~~ DB | _API_ DB | _API_ DB |
| Raw data | ~~API~~ ~~DB~~ | ~~API~~ DB | _API_ DB | _API_ DB |
| Pending data | ~~API~~ ~~DB~~ | ~~API~~ DB | _API_ DB | _API_ DB |
Legend:
@ -37,8 +37,8 @@ Filter requirements
- [x] `finalized`: similar to `complete` for `Send`, `Receive`
- all sub-transactions are `complete` for `Buy`, `Swap`, `Bridge`
- [x] `failed`: extract from `status` for all sub-transactions
- [ ] `chainID`: aggregate data for activity entries `Bridge`, `Buy`, `Swap`
- [ ] `tokenCode` for activity entries `Send`, `Receive`
- [x] `chainID`: aggregate data for activity entries `Bridge`, `Buy`, `Swap`
- [x] `tokenCode` for activity entries `Send`, `Receive`
- For `Bridge` its already there and `Buy`, `Swap` is coming soon
- [ ] `collectibles`: require adding collectible attributes to activity data (probably `token_address` and `tokenId`)

View File

@ -429,7 +429,7 @@ const (
//
// Adding a no-limit option was never considered or required.
func getActivityEntries(ctx context.Context, db *sql.DB, addresses []eth.Address, chainIDs []common.ChainID, filter Filter, offset int, limit int) ([]Entry, error) {
// TODO: filter collectibles after they are added to multi_transactions table
// TODO: filter collectibles after they are added to multi_transactions table
if len(filter.Tokens.EnabledTypes) > 0 && !sliceContains(filter.Tokens.EnabledTypes, AssetTT) {
// For now we deal only with assets so return empty result
return []Entry{}, nil

View File

@ -47,9 +47,12 @@ const (
)
type FilterResponse struct {
Activities []Entry `json:"activities"`
ThereMightBeMore bool `json:"thereMightBeMore"`
ErrorCode ErrorCode `json:"errorCode"`
Activities []Entry `json:"activities"`
Offset int `json:"offset"`
// Used to indicate that there might be more entries that were not returned
// based on a simple heuristic
HasMore bool `json:"hasMore"`
ErrorCode ErrorCode `json:"errorCode"`
}
// FilterActivityAsync allows only one filter task to run at a time
@ -72,6 +75,7 @@ func (s *Service) FilterActivityAsync(ctx context.Context, addresses []common.Ad
s.context, s.cancelFn = context.WithCancel(context.Background())
s.wg.Add(1)
go func() {
defer s.wg.Done()
defer func() {
@ -88,7 +92,8 @@ func (s *Service) FilterActivityAsync(ctx context.Context, addresses []common.Ad
res.ErrorCode = ErrorCodeFilterCanceled
} else if err == nil {
res.Activities = activities
res.ThereMightBeMore = len(activities) == limit
res.Offset = offset
res.HasMore = len(activities) == limit
res.ErrorCode = ErrorCodeSuccess
}