Page MenuHomePhabricator

[Cashtab] [Alias] pt 6.2 - Implement getAliasesFromLocalForage
ClosedPublic

Authored by emack on Jan 23 2023, 12:30.

Details

Summary

T2551

Depends on D13019

This diff implements the logic in Alias.js which determines whether the alias cache object needs to be refreshed based on the last cached total tx count vs the onchain total tx count of the alias payment address.

At this point in the stack, this will always result in the need for a refresh since the updating of local forage will be implemented in the next diff.

[Cashtab] [Alias] pt 1 - Create scaffold for new Identity component
[Cashtab] [Alias] pt 2 - Upgrade sendXec() to handle alias registration
[Cashtab] [Alias] pt 3 - Implement isAliasAvailable function
[Cashtab] [Alias] pt 4 - Implement isAddressRegistered function
[Cashtab] [Alias] pt 5 - Implement getAddressFromAlias function
[Cashtab] [Alias] pt 6.1 - Get latest alias tx count from payment address
[Cashtab] [Alias] pt 6.1.1 - Apply Promise.All approach for alias history retrieval
[Cashtab] [Alias] pt 6.2 - Implement getAliasesFromLocalForage
[Cashtab] [Alias] pt 6.3 - Implement updateAliases
[Cashtab] [Alias] pt 6.4 - Implement setAlisesToLocalForage
[Cashtab] [Alias] pt 6.5 - Deprecate caching related mocks and @TODOs
[Cashtab] [Alias] pt 7 - Enable alias lookup for Send XEC component
[Cashtab] [Alias] pt 8 - Enable alias lookup for Send Token component
[Cashtab] [Alias] pt 9 - Implement pricing mechanism
[Cashtab] [Alias] pt 10 - Server cron job
[Cashtab] [Alias] pt 11 - Upgrade tx history to recognize alias registration txs

Test Plan
  • npm test
  • npm start
  • navigate to the Alias page
  • note the passingloadstatus now that there are non-trivial logic being executed in useEffecT()
  • note the console log showing an alias refresh is required

Diff Detail

Event Timeline

emack requested review of this revision.Jan 23 2023, 12:30

What does this object look like in localForage?

Based on what we've learned so far, we should save both

  1. All valid aliases
  2. The tx count at the payment address up to which that list is valid

Probably something like

{
   aliasTxCount: 67,
   aliases: [ethan, joey, ..., chicken77]
}

This way the object could be taken as an input to getAllTxHistory, which would then know which page number to start from.

This revision now requires changes to proceed.Jan 23 2023, 18:14
emack requested review of this revision.EditedJan 23 2023, 22:49

What does this object look like in localForage?

Based on what we've learned so far, we should save both

  1. All valid aliases
  2. The tx count at the payment address up to which that list is valid

Probably something like

{
   aliasTxCount: 67,
   aliases: [ethan, joey, ..., chicken77]
}

This way the object could be taken as an input to getAllTxHistory, which would then know which page number to start from.

it will look as follows:

{
     totalPaymentTxCount: 67,
     aliases: [
          {alias: 'ethan',  address: 'ecash....'},
          {alias: 'joey',  address: 'ecash....'},
          {alias: 'chicken77',  address: 'ecash....'},
     ]
}
This revision is now accepted and ready to land.Jan 24 2023, 18:43