HomePhabricator

[Cashtab][Alias] Sync pricing on new blocks

Description

[Cashtab][Alias] Sync pricing on new blocks

Summary:
This diff listens for 'BlockConnected' events, which then retrieves the latest alias registration fees from alias-server and checks whether prices have changed or not based on the length of the pricing array, before rendering as a localized price preview in Alias.js.

At this point in time the chronik-client module is still being upgraded to work with the in-node chronik indexer, therefore it is not efficient to be making a blockheight comparison between server and cashtab arrays. This is needed due to the potential for multiple pricing tiers in the pricing array returned from alias-server, where the latest entry could have a startHeight into the future.

As a temporary mitigation it is assumed initial go live pricing will always be a single entry array. Once chronik-client has been upgraded, this price parsing logic will be updated to use the new websocket for blockheight comparisons. The intention is to eventually reverse loop through aliasPrices.prices and parse for the latest array entry that has a startHeight within the chain's tipHeight.

Test Plan:

  • npm test
  • Enable alias flag in config
  • npm start
  • Navigate to Alias.js, enter a valid alias and verify the pricing preview being displayed per keystroke
  • Enter an invalid alias and ensure the "Please enter an alias (lowercase a-z, 0-9) between 1 and 21 bytes" error is displayed
  • Manually add an additional entry to the aliasPrices.prices array inside Alias.js (e.g. aliasPrices.prices.push({foo: 'asdfa'});) so that the length would be > 1, and verify the "Alias registration is temporarily unavailable, please check again later" error is displayed and both the Check Alias and Register Alias buttons are disabled
  • Manually empty the aliasPrices.prices array inside Alias.js (e.g. aliasPrices.prices = [];) so that the length would be 0, and verify the same "Alias registration is temporarily unavailable, please check again later" error is displayed and both the Check Alias and Register Alias buttons are disabled
  • Temporarily reintate previous debug log statements in processChronikWsMsg(), open dev console, wait for a new block to be found and observe the "New block found, refreshing alias prices" message in console with the latest prices displayed matching what's on the alias-server prices endpoint

image.png (128×344 px, 12 KB)

  • Regression test alias component features that calls upon the /address and /alias endpoints (e.g. check the registered downdown, register a new alias, attempt to re-register and observe pending dialog) to ensure the changes to queryAliasServer in this diff did not introduce new bugs.

Reviewers: bytesofman, #bitcoin_abc, Fabien

Reviewed By: bytesofman, #bitcoin_abc, Fabien

Subscribers: Fabien

Differential Revision: https://reviews.bitcoinabc.org/D14728

Details

Provenance
emackAuthored on Nov 2 2023, 14:29
emackPushed on Nov 21 2023, 22:13
Reviewer
Restricted Project
Differential Revision
D14728: [Cashtab][Alias] Sync pricing on new blocks
Parents
rABC6a9d2e9baa02: [avalanche] Fix a use after free bug in the peer manager unit tests
Branches
Unknown
Tags
Unknown