Page MenuHomePhabricator

[token-server] Add XEC faucet to Cashtab
ClosedPublic

Authored by bytesofman on Aug 9 2024, 22:41.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABCe2ccad1170dc: [token-server] Add XEC faucet to Cashtab
Summary

Add XEC airdrops for new Cashtab wallets.

Only newly-created wallets are eligible for airdrops.

Test Plan

npm test

Event Timeline

Failed tests logs:

====== CashTab Unit Tests: Correctly prepares Cashtab mocked chronik client and localforage environment for Cashtab pre 1.7.* for unit tests initializeCashtabStateAtLegacyWalletKeysForTests: Wallet with xec and tokens ======
Error: expect(received).toEqual(expected) // deep equality

- Expected  - 0
+ Received  + 1

@@ -1,7 +1,8 @@
  Object {
    "numPages": 1,
+   "numTxs": 10,
    "txs": Array [
      Object {
        "inputs": Array [
          Object {
            "inputScript": "483045022100b8699595913167f3abd5c6dde588fe9dd89e56e811436d0cc02e81a6623a93c1022043954f663eb37a4e0a7cb28bd8ff857d0913cc771832b0e7ccf2b2fbaa9f3ae0412103318d0e1109f32debc66952d0e3ec21b1cf96575ea4c2a97a6535628f7f8b10e6",
    at Object.toEqual (/work/cashtab/src/components/App/fixtures/__tests__/index.test.js:94:15)

Each failure log is accessible here:
CashTab Unit Tests: Correctly prepares Cashtab mocked chronik client and localforage environment for Cashtab pre 1.7.* for unit tests initializeCashtabStateAtLegacyWalletKeysForTests: Wallet with xec and tokens

Fabien retitled this revision from [token-server] Add new helper function to determine if address in unused to [token-server] Add new helper function to determine if address is unused.Aug 13 2024, 06:59
Fabien requested changes to this revision.Aug 13 2024, 07:02
Fabien added a subscriber: Fabien.

I think such a small change should just be inlined, it doesn't bring any value on its own.

apps/token-server/src/chronik/clientHandler.ts
103 ↗(On Diff #49166)

This is a wrapped and exported single line call, imo this doesn't really add any value except it makes the code flow more complicated. Do you plan to call this in several places ? Also you added unit tests for what, for chronik ? This is mostly testing your mock at this point.

This revision now requires changes to proceed.Aug 13 2024, 07:02

expand function to be more like isAddressEligible ... no need for just a chronik wrapper

apps/token-server/src/chronik/clientHandler.ts
103 ↗(On Diff #49166)

good point

Implement XEC airdrops in token-server and Cashtab

better comments, update test mock tx for new airdrop amount

bytesofman retitled this revision from [token-server] Add new helper function to determine if address is unused to [token-server] Add XEC faucet to Cashtab.Aug 14 2024, 23:47
bytesofman edited the summary of this revision. (Show Details)

Tail of the build log:

To address all issues, run:
  npm audit fix

Run `npm audit` for details.
Test depends on ecash-lib. Building TypeScript...
/work/modules/ecash-lib /work/modules/chronik-client /work/modules/ecash-lib-wasm /work/modules/mock-chronik-client /work/modules/ecashaddrjs /work/abc-ci-builds/token-server-tests

added 363 packages, and audited 366 packages in 2s

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

found 0 vulnerabilities

> ecash-lib@0.2.0 build
> tsc && tsc -p ./tsconfig.build.json && cp -r ./src/ffi ./dist

Test does not depend on ecash-script, skipping ecash-script dependencies...
Test does not depend on ecash-coinselect, skipping ecash-coinselect dependencies...
/work/apps/token-server /work/modules/ecash-lib /work/modules/chronik-client /work/modules/ecash-lib-wasm /work/modules/mock-chronik-client /work/modules/ecashaddrjs /work/abc-ci-builds/token-server-tests
npm warn deprecated har-validator@5.1.5: this library is no longer supported
npm warn deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm warn deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.

added 591 packages, and audited 596 packages in 3s

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

7 vulnerabilities (6 moderate, 1 high)

To address issues that do not require attention, run:
  npm audit fix

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

Run `npm audit` for details.
CI configured to test build. Building...

> token-server@0.0.0 prebuild
> ts-node scripts/prepSecrets.ts

secrets.ts does not exist, copying secrets.sample.ts...

> token-server@0.0.0 build
> tsc


> token-server@0.0.0 pretest
> ts-node scripts/prepSecrets.ts

secrets.ts exists, proceeding to build...

> token-server@0.0.0 test
> mocha --reporter mocha-junit-reporter --reporter-options mochaFile=test_results/token-server-junit.xml --reporter-options testsuitesTitle=Token Server Unit Tests --reporter-options rootSuiteTitle=Token Server

Serving static assets from /token-server/token-icons
/claimxec/ecash:qrfkcnzdm0dvkrc20dhcf7qv23vt736ynuujzxnzs6 from IP: ::ffff:127.0.0.1, host 127.0.0.1:5000
Build token-server-tests timed out after 3600.0s

note the above teamcity failure was corrected by this step

better comments, update test mock tx for new airdrop amount

Fabien added inline comments.
cashtab/src/components/Home/Home.js
164 ↗(On Diff #49222)
197 ↗(On Diff #49222)
This revision is now accepted and ready to land.Aug 15 2024, 08:21

Abuse can me mitigated by asking for an email address or having them take some other kind of higher friction action. It probably won't take long before it's necessary to deal with automated scripts.

bytesofman added inline comments.
cashtab/src/components/Home/Home.js
164 ↗(On Diff #49222)

it's confusing but the comment is correct

when this function is first called, we setAirdropPending(true); -- this disables the button while the airdrop is processed

we do not call setAirdropPending(false) on a success response -- this would enable the button -- because, once the airdrop succeeds, the button will no longer be rendered.

The button can only ever be used once, so we never re-enable it.

166 ↗(On Diff #49222)

we do call setAirdropPending(false) if the server returns an error response though. This indicates that no tx was sent -- instead there is some issue with the server, and the user could still try to claim later.

197 ↗(On Diff #49222)

same comment as above

This revision was automatically updated to reflect the committed changes.
bytesofman marked 2 inline comments as done.