Page MenuHomePhabricator

[Cashtab] Do not load ALL agora offers unless the user asks for it
ClosedPublic

Authored by bytesofman on Fri, Jan 10, 14:43.

Details

Summary

The Agora page is not really usable. Loading every single offer is no longer practical, with 700 offers.

It will take some time to get full searchable lazy loading for all offers, because I still need to

  • Improve ecash-agora to add better functions for analyzing offer history (getting volume)
  • Put some thought into the best ways to sort and search tokens
  • Handle loading info about all available tokens in the background somehow, bc we need this info available before a search is useful

Now that (1) the scope of the search problem is more clear and is large; and (2) the volume of agora orders is such that the page simply is not usable, we need some kind of interim solution.

For now, load a prelim whitelist. Whitelist is absolutely barebones. Only XECX and Star Crystals, the only 2 tokens that have done > $10k per day in volume.

Preserve the option to load all offers (existing behavior) so that all offers can be found somehow. But give a disclaimer that it WILL BE SLOW.

Test Plan

npm test

check it out at https://cashtab-local-dev.netlify.app/#/agora (lots of debug logging, so you can experiment loading all and watching lazy loading, seeing the sort by offer count become enabled, confirm this still works)

hard refresh, if you are on the latest it will look like this

image.png (673×1 px, 160 KB)

Diff Detail

Repository
rABC Bitcoin ABC
Branch
agora-init-whitelist
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 32033
Build 63558: Build Diffcashtab-tests
Build 63557: arc lint + arc unit

Event Timeline

Failed tests logs:

====== CashTab Unit Tests: <Agora /> We can see multiple offers, some we made, others we did not, and we can cancel an offer ======
Error: expect(received).toEqual(expected) // deep equality

- Expected  - 1
+ Received  + 0

  Array [
-   "01d63c4f4cb496829a6743f7b1805d086ea3877a1dd34b3f92ffba2c9c99f896",
    "aed861a31b96934b88c0252ede135cb9700d7649f69191235087a3030e553cb1",
  ]
    at Object.toEqual (/work/cashtab/src/components/Agora/__tests__/index.test.js:485:30)
====== CashTab Unit Tests: <Agora /> We get expected error if we try to buy an offer we cannot afford ======
Error: Unable to find an element with the text: Bull (BULL). This could be because the text is broken up by multiple elements. In this case, you can provide a function for your text matcher to make your matcher more flexible.

Ignored nodes: comments, script, style
<body>
  <div>
    <div
      class="sc-crNyjn ZdDAu"
    >
      <section
        aria-atomic="false"
        aria-label="Notifications Alt+T"
        aria-live="polite"
        aria-relevant="additions text"
        class="Toastify"
      />
      <div
        class="sc-cpHetk iAVmVp"
      >
        <div
          class="sc-nrwXf hfUHmV"
        >
          <div
            class="sc-iBmynh kaZLhZ"
          >
            <img
              alt="cashtab"
              class="sc-fKGOjr hMUwFD"
              src="test-file-stub"
            />
          </div>
          <div
            class="sc-chAAoq IEKNo"
          >
            <div
              class="sc-ekulBa txcVO"
            >
              <select
                class="sc-ciodno kiewTe"
                data-testid="wallet-select"
                id="wallets"
                name="wallets"
              >
                <option
                  class="sc-gGCbJM czBmUI"
                  value="Agora Partial Alpha"
                >
                  Agora Partial Alpha
                </option>
                <option
                  class="sc-gGCbJM czBmUI"
                  value="Agora Partial Beta"
                >
                  Agora Partial Beta
                </option>
              </select>
              <div
                class="sc-dznXNo goxNXI"
              >
                <button
                  aria-label="Copy ecash:qqpmsv8yh8wwx3lnf92rrc0e6yq97j6zqs8av8vx8h"
                  class="sc-cJSrbW kZNvLw"
                >
                  <svg
                    title="copy-paste"
                  />
                </button>
                <div
                  class="sc-eerKOB cvXwwv"
                >
                  <div
                    class="sc-emmjRN bSWkUh"
                  >
                    <input
                      checked=""
                      class="sc-gFaPwZ iPJMNd"
                      id="show-hide-balance"
                      name="show-hide-balance"
                      title="show-hide-balance"
                      type="checkbox"
                    />
                    <label
                      class="sc-cpmLhU iUeRKn"
                      for="show-hide-balance"
                    >
                      <span
                        class="sc-dymIpo isbbFI"
                        data-off=""
                        data-on=""
                      />
                      <span
                        class="sc-bnXvFD cpOMDW"
                      />
                    </label>
                  </div>
                </div>
              </div>
            </div>
            <div
              class="sc-dTLGrV fpLYfM"
              title="Wallet Info"
            >
              <div
                class="sc-lcpuFF gzavlp"
                title="Balance in XEC"
              >
                0.00
                 
                XEC
                 
              </div>
              <div
                class="sc-bqjOQT hkjSY"
                title="Balance in Local Currency"
              >
                $
                0.00
                 
                USD
              </div>
              <p
                class="sc-jkCMRl cVcqZz"
                title="Price in Local Currency"
              >
                1 
                XEC
                 = 
                0.00003000
                 
                USD
              </p>
            </div>
          </div>
          <div
            class="sc-ekkqgF dcpeyv"
          >
            <h2
              class="sc-hEsumM eLITmV"
            >
              Agora 
              <svg
                title="Meme Agora"
              />
            </h2>
            <div
              class="sc-jxGEyO ktqFXP"
              title="Active Offers"
            >
              <div
                class="sc-fQejPQ kELCPK"
              >
                <div
                  class="sc-eerKOB cvXwwv"
                >
                  <div
                    class="sc-emmjRN iogvmX"
                  >
                    <input
                      class="sc-gFaPwZ iPJMNd"
                      id="Toggle Active Offers"
                      name="Toggle Active Offers"
                      title="Toggle Active Offers"
                      type="checkbox"
                    />
                    <label
                      class="sc-cpmLhU iUeRKn"
                      for="Toggle Active Offers"
                    >
                      <span
                        class="sc-dymIpo kNGdId"
                        data-off=""
                        data-on=""
                   ...
    at waitForWrapper (/work/cashtab/node_modules/@testing-library/dom/dist/wait-for.js:163:27)
    at /work/cashtab/node_modules/@testing-library/dom/dist/query-helpers.js:86:33
    at Object.findByText (/work/cashtab/src/components/Agora/__tests__/index.test.js:779:29)
    at runNextTicks (node:internal/process/task_queues:60:5)
    at listOnTimeout (node:internal/timers:545:9)
    at processTimers (node:internal/timers:519:7)

Each failure log is accessible here:
CashTab Unit Tests: <Agora /> We can see multiple offers, some we made, others we did not, and we can cancel an offer
CashTab Unit Tests: <Agora /> We get expected error if we try to buy an offer we cannot afford

bare bones whitelist, update tests

bytesofman edited the test plan for this revision. (Show Details)
bytesofman edited the test plan for this revision. (Show Details)
bytesofman added inline comments.
cashtab/src/components/Agora/index.tsx
539 ↗(On Diff #52123)

hiding the switches is not really related to this diff, see D17510

this will be rebased on that

rebase, make styles fit in new design, update tests

johnkuney added a subscriber: johnkuney.

Cool, works for me and is good interim solution. The polite loading is nice
Only suggestion is move the button below the initial listings for subjective reasons

cashtab/src/components/Agora/index.tsx
580–597 ↗(On Diff #52126)

Could move this under the whitelisted listings

This revision is now accepted and ready to land.Sat, Jan 11, 07:01