Page MenuHomePhabricator

[Cashtab] [Alias] pt 13 - real time alias char length and registration fee display
ClosedPublic

Authored by emack on Feb 25 2023, 11:41.

Details

Summary

T2551
T2948

This is a standalone diff that displays the char count and registration fee for the alias input in real time.

Also removed a bug where an alias that's already been taken is temporarily rendered as (pending) on the Registered Alias section in Alias.js upon the dupicate alias error notification.

[Cashtab] [Alias] pt 1 - Create scaffold for new Alias 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 - Update getAliases() to extract both alias and address
[Cashtab] [Alias] pt 6.5 - Optimize getAllTxHistory to only make API calls for uncached tx history pages
[Cashtab] [Alias] pt 6.6 - Render list of Aliases owned by active wallet in Alias.js
[Cashtab] [Alias] pt 7 - Mitigate edge cases for registration records
[Cashtab] [Alias] pt 8 - Activation flag in prod
[Cashtab] [Alias] pt 9 - Retain tokenInfoById upon alias validation
--stacked diff cutoff--
[Cashtab] [Alias] pt 10 - Enable alias inputs for one to one Send XEC txs
[Cashtab] [Alias] pt 11 - Enable alias inputs for Send Token txs
[Cashtab] [Alias] pt 12 - Upgrade tx history to recognize alias registration txs
[Cashtab] [Alias] pt 13 -real time alias char length and registration fee display
[Cashtab] [Alias] pt 14 - Frontend bytesize validation
--closed beta--
[Cashtab] [Alias] pt 15 - Pre-prod update (add p2sh parsing, set final registration fees, remove residual dev logs, test in extension mode and enable prod flag)
[Cashtab] [Alias] pt 16 - Port Alias feature to Cashtab extension
--post mvp---
[Cashtab] [Alias] - Enable alias parsing without the .xec extension
[Cashtab] [Alias] - Optimize isAliasAvailable to take cached tx history as input
[Cashtab] [Alias] - Add active wallet's aliases to caching mechanism
[Cashtab] [Alias] - Resolve special characters processing in node app

Test Plan
  • npm test
  • set aliasEnabled to true
  • npm start
  • test with registering an alias under 8 chars and verify character length and registration fee displayed under the input field
  • test with an alias 8 chars and above and verify character length and registration fee displayed under the input field
  • test with something similar to 🙈🙉🙊 and verify 6 character length costing 5.53
  • set aliasEnabled to false and ensure no regression to app

Diff Detail

Repository
rABC Bitcoin ABC
Branch
realTimeFeeDisplay
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 22099
Build 43833: Build Diffcashtab-tests
Build 43832: arc lint + arc unit

Event Timeline

emack requested review of this revision.Feb 25 2023, 11:41

test with something similar to 🙈🙉🙊 and verify 6 character length costing 5.53

The issue is that this is actually a 12-char length alias on the backend.

A bit of a philosophical question here since, well, it means that some "short" aliases are cheaper. i.e. this alias looks like it's 3 characters long, involves typing only 3 characters, but takes 12 characters to encode in utf8. So it's a 12-character alias.

Imo I think that's acceptable. The alternative is to add custom emoji parsing in the spec, which I think is too complicated. It's reasonable that an emoji alias would be "cheaper."

I think the best way to handle is to consistently define "character length" based on how many characters are taken in the OP_RETURN of the registration transaction.

This revision now requires changes to proceed.Feb 27 2023, 00:26

Calculating alias length as bytes

Please add a handful of unit tests for the getAliasRegistrationFee function including

  • single emoji aliases
  • aliases with characters and emojis
  • special character aliases
  • korean alias
  • arabic alias
This revision now requires changes to proceed.Feb 27 2023, 13:10

added additional unit tests for getAliasRegistrationFee

bytesofman requested changes to this revision.Mar 1 2023, 17:40

Please refactor these unit tests so that they

  1. define aliasInput (as is)
  2. calculate byteLength of alias input
  3. create the OP_RETURN hex string for the alias input
  4. calculate the alias length based on parsing the OP_RETURN hex string
  5. confirm the lengths are the same

no need to run these through the fee check functions. more concerned here on making sure that we are getting the same alias length in the front end and the OP_RETURN.

This revision now requires changes to proceed.Mar 1 2023, 17:40

refactored unit tests to compare frontend and backend bytecounts of the alias

Please address in another diff -- the front end validation should be cutting off at 21 based on byte length, not front end char, to avoid this kind of situation:

image.png (318×580 px, 32 KB)

This revision is now accepted and ready to land.Mar 2 2023, 17:51