Page MenuHomePhabricator

[Cashtab] Show NFT offer on token page
ClosedPublic

Authored by bytesofman on Fri, Nov 15, 23:45.

Details

Reviewers
emack
Group Reviewers
Restricted Project
Commits
rABCcff88b5382e6: [Cashtab] Show NFT offer on token page
Summary

Show individual NFT offer on the token page.

This would allow users to share links to NFT offers.

Also show the listing on the page immediately when the user creates a listing, instead of auto-routing to the slow-to-load NFT page.

Test Plan

npm test

Diff Detail

Repository
rABC Bitcoin ABC
Branch
collections-on-collection-page
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 31159
Build 61818: Build Diffcashtab-tests
Build 61817: arc lint + arc unit

Event Timeline

Failed tests logs:

====== CashTab Unit Tests: <Token /> available actions rendered We can render an SLP1 NFT Parent token with a minted NFT in its collection ======
TestingLibraryElementError: Found multiple elements with the text: NFTs in this Collection

Here are the matching elements:

Ignored nodes: comments, script, style
<div
  class="sc-gtfDJT eDDrRa"
>
  NFTs in this Collection
</div>

Ignored nodes: comments, script, style
<div
  class="sc-gtfDJT eDDrRa"
>
  NFTs in this Collection
</div>

(If this is intentional, then use the `*AllBy*` variant of the query (like `queryAllByText`, `getAllByText`, or `findAllByText`)).

Ignored nodes: comments, script, style
<body>
  <div>
    <div
      class="sc-ivVeuv fHRvPq"
    >
      <div
        class="Toastify"
      />
      <div
        class="sc-cCbXAZ duJsQt"
      >
        <div
          class="sc-fHSTwm cxpJKj"
        >
          <div
            class="sc-cgHJcJ aiooe"
          >
            <img
              alt="cashtab"
              class="sc-hizQCF inqoGQ"
              src="test-file-stub"
            />
          </div>
          <div
            class="sc-kVrTmx ZRUlx"
          >
            <select
              class="sc-ekkqgF hmTBrl"
              data-testid="wallet-select"
              id="wallets"
              name="wallets"
            >
              <option
                class="sc-iBmynh bRQLyW"
                value="Token Test"
              >
                Token Test
              </option>
            </select>
            <div
              class="sc-jWojfa uPesV"
            >
              <button
                aria-label="Copy ecash:qqq9f9z3uhpzkxrgdjkd7dxuuey7tmpmugpmnw0kue"
                class="sc-kvZOFW liNaUH"
              >
                <svg
                  title="copy-paste"
                />
              </button>
              <div
                class="sc-fhYwyz fpwrfn"
              >
                <div
                  class="sc-jzgbtB cdJgRi"
                >
                  <input
                    checked=""
                    class="sc-CtfFt eXIHPX"
                    id="show-hide-balance"
                    name="show-hide-balance"
                    title="show-hide-balance"
                    type="checkbox"
                  />
                  <label
                    class="sc-gJWqzi cInajG"
                    for="show-hide-balance"
                  >
                    <span
                      class="sc-rBLzX kkNQQW"
                      data-off=""
                      data-on=""
                    />
                    <span
                      class="sc-bMvGRv kbAFcW"
                    />
                  </label>
                </div>
              </div>
            </div>
          </div>
          <div
            class="sc-ccLTTT SlYAe"
            title="Wallet Info"
          >
            <div
              class="sc-jvEmr fzPGnp"
              title="Balance in XEC"
            >
              9,970.81
               
              XEC
               
            </div>
            <div
              class="sc-hycgNl hvoCwn"
              title="Balance in Local Currency"
            >
              $
              0.30
               
              USD
            </div>
            <p
              class="sc-chAAoq cSPPxC"
              title="Price in Local Currency"
            >
              1 
              XEC
               = 
              0.00003000
               
              USD
            </p>
          </div>
          <div
            class="sc-dRCTWM oXRxq"
          >
            <div
              class="sc-iBEsjs ivzmun"
            >
              1
               
              The Four Half-Coins of Jin-qua
               (
              4HC
              )
            </div>
            <div
              class="sc-RcBXQ hYSJYt"
              title="Token Stats"
            >
              <div
                class="sc-fZwumE fFOESu"
              >
                <button
                  class="sc-cooIXK cZeeyU"
                >
                  <img
                    alt="icon for 12a049d0da64652b4e8db68b6052ad0cda43cf0269190fe81040bed65ca926a3"
                    height="128"
                    src="https://icons.etokens.cash/128/12a049d0da64652b4e8db68b6052ad0cda43cf0269190fe81040bed65ca926a3.png"
                    width="128"
                  />
                </button>
              </div>
              <div
                class="sc-fZwumE fFOESu"
              >
                <div
                  class="sc-clNaTc kbrFRK"
                >
                  <div
                    class="sc-etwtAo SIrdX"
                  >
                    Type:
                  </div>
                  <div
                    class="sc-fZwumE fFOESu"
                  >
                    <div
                      class="sc-kxynE ivrWtb"
                    >
                      NFT Collection
                       
                      <button
                        aria-label="Click for more info about this token type"
                        class="sc-kvZOFW liNaUH"
                      >
                        <svg
                          title="More Info"
                        />
                      </button>
                    </div>
                  ...
    at Object.getElementError (/work/cashtab/node_modules/@testing-library/dom/dist/config.js:37:19)
    at getElementError (/work/cashtab/node_modules/@testing-library/dom/dist/query-helpers.js:20:35)
    at getMultipleElementsFoundError (/work/cashtab/node_modules/@testing-library/dom/dist/query-helpers.js:23:10)
    at /work/cashtab/node_modules/@testing-library/dom/dist/query-helpers.js:55:13
    at /work/cashtab/node_modules/@testing-library/dom/dist/query-helpers.js:95:19
    at Object.getByText (/work/cashtab/src/components/Etokens/__tests__/TokenActions.test.js:815:23)
====== CashTab Unit Tests: <Token /> available actions rendered We can list an SLP1 NFT ======
TestingLibraryElementError: Unable to find an element with the text: eCash NFT. NFT supply is always 1. This NFT may belong to an NFT collection.. 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 />
</body>
    at Object.getElementError (/work/cashtab/node_modules/@testing-library/dom/dist/config.js:37:19)
    at /work/cashtab/node_modules/@testing-library/dom/dist/query-helpers.js:76:38
    at /work/cashtab/node_modules/@testing-library/dom/dist/query-helpers.js:52:17
    at /work/cashtab/node_modules/@testing-library/dom/dist/query-helpers.js:95:19
    at Object.getByText (/work/cashtab/src/components/Etokens/__tests__/TokenActions.test.js:901:20)

Each failure log is accessible here:
CashTab Unit Tests: <Token /> available actions rendered We can render an SLP1 NFT Parent token with a minted NFT in its collection
CashTab Unit Tests: <Token /> available actions rendered We can list an SLP1 NFT

remove debug log, back out unrelated test change

emack requested changes to this revision.Sat, Nov 16, 11:41
emack added a subscriber: emack.
emack added inline comments.
cashtab/src/components/Etokens/Token/index.js
541–542 ↗(On Diff #50883)

isn't this redundant if the if loop right after is for a NFT child?
And if the tokenType matches SLP_TOKEN_TYPE_FUNGIBLE then it's not a parent anyway.

This revision now requires changes to proceed.Sat, Nov 16, 11:41
bytesofman marked an inline comment as done.
bytesofman added inline comments.
cashtab/src/components/Etokens/Token/index.js
541–542 ↗(On Diff #50883)

You are right that the logic should be improved. Can tell the screen (originally designed only for sending SLP1 fungible tokens) has grown, and has not been thoughtfully designed for handling all token types.

However I don't think it should be fixed in this diff. In this case, we are using the existing (effective, if ugly) logic for "is this an NFT" -- and applying this new feature there.

Going forward with this screen, should

  1. Convert to ts
  2. Improve onload filtering to directly use ChronikClient types, now that they are stable
  3. Better organize test files so we are testing all tokens by type

This will also make it easier to add support for ALP and SLP2.

I don't think we should hold up this diff for that refactor, since this is completing the last of the "token landing page" functionality for supported tokens.

This revision is now accepted and ready to land.Sat, Nov 16, 13:58
This revision was automatically updated to reflect the committed changes.
bytesofman marked an inline comment as done.