Page MenuHomePhabricator

[Cashtab] eCash Namespace Services prototype - part 1 base implementation
AbandonedPublic

Authored by emack on Oct 3 2022, 15:51.

Details

Reviewers
bytesofman
Group Reviewers
Restricted Project
Summary

As per T2551, this diff is the base implementation of how namespace aliases would work in Cashtab.

(I will send you the backend API keys on tg)

Workflow:

  1. User opens cashtab, navigates to the Receive page which will automatically check whether the active wallet's eCash address is attached to an existing alias

image.png (402×463 px, 17 KB)

  1. If this address is already attached to an alias then it will be displayed

image.png (148×367 px, 6 KB)

  1. If this address is unattached, then a registration input field will be rendered for the user to register an alias for their address.

image.png (373×477 px, 18 KB)

  1. If the chosen alias already exists, then an error will be displayed

image.png (120×312 px, 9 KB)

  1. If the chosen alias is unique, then it will be committed to the backend

image.png (124×599 px, 27 KB)

  1. Any cashtab user can simply input this alias into the address field and it will be converted to the equivalent ecash address in the backend prior to the tx being broadcasted via chronik.

image.png (209×492 px, 7 KB)

Implementation:

  • useWallet.s initializes the Backendless connection and makes the instance available to the rest of cashtab via ContextValue.
  • Receive.js checks for any alias attached to the active wallet's address upon loading, which then conditionally renders the alias registration input
  • Send.js' eCash address validation now detects whether an input ends in '.xec' and if so, bypasses existing eCash address validation logic and calls sendXec() with aliasFlag set to true
  • useBCH.js' sendXec() function now takes in an aliasFlag will lookup the .xec alias for a corresponding address and override the destinationAddress
  • the backend structure is as follows, with an eye on future expansion of identity management across the eCash ecosystem:

[

{
   "created":1664721736330,
   "alias":"ethan.xec",
   "ecashAddress":"ecash:qq9h6d0a5q65fv4ry64x04ep906mdku8f0gxfgx"
   "etokenAddress":null,
   "discordId":null,
   "redditId":null,
   "ownerId":null,
   "telegramId":null,
   "twitterId":null,
   "___class":"xns",       
   "updated":1664721760079,       
   "objectId":"588D2A9A-9F38-4F44-880E-CB4D01DC3F06",
}

]

Subsequent diffs will depend on ongoing discussions in T2551, including:

  • whether to adopt onchain issuances of tokens so namespaces are tradeable on DEXs
  • sybil resistance and mitigation for users hoarding valuable names
  • potential fees
  • whether aliases should expire and thus require renewal
Test Plan
  • npm i backendless
  • npm start
  • navigate to the Receive screen on a fresh wallet and observe no existing alias attached and the registration input field is rendered
  • register a desired alias and observe a success notification and the subsequent update of the alias field, which will then hide the registration input field
  • use the newly registered .xec alias in the send field and ensure it is sent to the correct address
  • navigate back to the Receive screen and ensure the registered alias is displayed and no rendering of the registration input field

Diff Detail

Repository
rABC Bitcoin ABC
Branch
xns
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 20333
Build 40339: Build Diffcashtab-tests
Build 40338: arc lint + arc unit

Event Timeline

emack requested review of this revision.Oct 3 2022, 15:51

Tail of the build log:

npm WARN EBADENGINE   package: 'postcss-overflow-shorthand@3.0.4',
npm WARN EBADENGINE   required: { node: '^12 || ^14 || >=16' },
npm WARN EBADENGINE   current: { node: 'v15.14.0', npm: '7.7.6' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: 'postcss-place@7.0.5',
npm WARN EBADENGINE   required: { node: '^12 || ^14 || >=16' },
npm WARN EBADENGINE   current: { node: 'v15.14.0', npm: '7.7.6' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: 'postcss-preset-env@7.8.2',
npm WARN EBADENGINE   required: { node: '^12 || ^14 || >=16' },
npm WARN EBADENGINE   current: { node: 'v15.14.0', npm: '7.7.6' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: 'postcss-pseudo-class-any-link@7.1.6',
npm WARN EBADENGINE   required: { node: '^12 || ^14 || >=16' },
npm WARN EBADENGINE   current: { node: 'v15.14.0', npm: '7.7.6' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: 'postcss-selector-not@6.0.1',
npm WARN EBADENGINE   required: { node: '^12 || ^14 || >=16' },
npm WARN EBADENGINE   current: { node: 'v15.14.0', npm: '7.7.6' }
npm WARN EBADENGINE }
npm WARN deprecated stable@0.1.8: Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the compatibility table on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#browser_compatibility
npm WARN deprecated text-encoding@0.6.4: no longer maintained
npm WARN deprecated ts-custom-error@2.2.2: npm package tarball contains useless codeclimate-reporter binary, please update to version 3.1.1. See https://github.com/adriengibrat/ts-custom-error/issues/32

> cashtab@1.0.0 prepare
> cd ../.. && husky install web/cashtab/.husky

husky - Git hooks installed

added 1807 packages, and audited 1808 packages in 27s

232 packages are looking for funding
  run `npm fund` for details

5 moderate severity vulnerabilities

To address all issues (including breaking changes), run:
  npm audit fix --force

Run `npm audit` for details.
npm notice 
npm notice New major version of npm available! 7.7.6 -> 8.19.2
npm notice Changelog: <https://github.com/npm/cli/releases/tag/v8.19.2>
npm notice Run `npm install -g npm@8.19.2` to update!
npm notice 

> cashtab@1.0.0 build
> node scripts/build.js

Creating an optimized production build...
Failed to compile.

Module not found: Error: Can't resolve 'backendless' in '/work/web/cashtab/src/hooks'


Build cashtab-tests failed with exit code 1
emack edited the summary of this revision. (Show Details)
emack edited the test plan for this revision. (Show Details)

Updated package.json to include backendless library

Removed --forceExit from test script args in package.json

The build failed due to an unexpected infrastructure outage. The administrators have been notified to investigate. Sorry for the inconvenience.
The build failed due to an unexpected infrastructure outage. The administrators have been notified to investigate. Sorry for the inconvenience.
bytesofman requested changes to this revision.Oct 4 2022, 16:36

We should get the ball rolling on this and not worry too much about optimization, since just having something that works and can be improved from is a big win.

IMO the one major thing we need to get right though is the supporting infra. Is there any critical reason we need to use backendless? Their npm module is almost 3 meg. The impact on the Cashtab bundle seems to be only about +12%, so at least it doesn't grab all of that, but this is still non-trivial for what is a basic API.

We already have a backend API with a database that handles the token icons -- I could create a new table there to handle these aliases? Is there any key feature of backendless we really want to run with here?

This revision now requires changes to proceed.Oct 4 2022, 16:36

further to tg discussion, I think this should be implemented as a three-part stacked diff:
part 1 - this base implementation for ecash addresses with the updated infra
part 2 - add the discussed race condition mitigations across infra and frontend
part 3 - add fee mechanism (will need its own dedicated hook to listen for fee payment confirmation via chornik websockets, before finalising registration)

To be pushed as a stacked diff - see T2551