Skip to content

feat: 🎸 support the redesigned SubQuery schema - #3

Draft
prashantasdeveloper wants to merge 14 commits into
developfrom
feat/redesigned-subquery-schema
Draft

prashantasdeveloper wants to merge 14 commits into
developfrom
feat/redesigned-subquery-schema

Conversation

@prashantasdeveloper

Copy link
Copy Markdown
Collaborator

Description

Moves the explorer to the redesigned SubQuery schema. Rows now carry createdEvent / updatedEvent stamps, instruction, venue and block ids are zero-padded, several connections and reverse fields are gone, and nested connections stop at 100 rows without saying so.

Schema migration

  • Assets, venues, accounts: creation stamps come from createdEvent, holder counts from Asset.holderCount, and venue ids are padded for lookups and shown unpadded. An account reads primaryAccountId. A multisig is found through the multiSigs connection, because Account.multiSig is gone.
  • Identities: secondary keys are the current SecondaryKey memberships. Held NFT collections are heldAssets with nftCount > 0, and the monthly creation count filters on the creation block's time. When the creation stamp points to an event the index did not store, createdAt is left empty and the page still loads.
  • Asset transactions and portfolio movements: both come from assetTransactions, since portfolioMovements is gone. Accounts are the fromAccountId / toAccountId relations, and the block, event and extrinsic indexes come from createdEvent.
  • NFT holders and extrinsics: NFT holders are assetHolders with nftCount > 0. Fungible holders whose balance went back to zero are left out. Extrinsic parameters come from args (paramsTxt is gone), and block ids are shown unpadded.
  • Settlement instructions:
    • Legs name their parties by id.
    • Affirmations are one row per holder (a portfolio or an account) plus one per mediator. Each row stays Pending until its holder affirms.
    • An identity's instructions are the ones with a leg from or to its DID.
  • PortfolioMovementTypeEnum is typed locally, because the SDK's generated types no longer export it.
  • The introspection schema is regenerated from the final testnet schema, in the standard introspection format that buildClientSchema and codegen can read.

Performance

  • An NFT holder's token pages are fetched in one aliased request instead of many parallel ones. For a testnet holder of 2,724 tokens this went from 26 s to about 1 s.

Fixes found while testing

  • Multisig badge: it never showed, because the explorer compared against 'Multisig' while the SDK returns MultiSig. It now uses the SDK's AccountKeyType enum.
  • Identity asset lists past 100: the held assets, owned assets and held NFTs lists stopped at 100 rows. The rest are now fetched in batched pages of 100. Checked on mainnet against an identity that owns 403 assets, and on testnet against identities with 101 and 118.
  • Instructions with an off-chain leg did not open: the server failed while grouping legs by assetId, which is null on an off-chain leg. That grouping is removed, and the asset lookup skips legs without an asset id.
  • Off-chain and mixed legs were displayed wrongly:
    • Off-chain legs showed did/undefined as the party. They now show the DID alone.
    • Their amount was hidden. It is now shown.
    • The asset linked to a page that does not exist. It is now plain text: <ticker> (off-chain).
    • The off-chain direction never matched. It now compares against the indexer's OffChain.
    • An instruction that mixes fungible and NFT legs labels the quantity column Amount / Nft Id, and each row shows its own value.

Testing

Ran locally against the testnet and mainnet indexers and checked every page and tab against direct GraphQL queries:

  • Accounts: primary and secondary keys, multisig, subsidies, genesis.
  • Identities: the list, the monthly chart, identity details with more than 100 assets, and the genesis and system DIDs.
  • Assets: the list, CSV export and paging. Fungible holders and transactions. NFT holders (including the CSV with all token ids), transactions, documents, permissions and compliance. A single NFT page.
  • Venues: the list, venue details with signers, and the default venue.
  • Settlements: account legs, NFT legs, off-chain legs, and affirmations.
  • Search: full and partial DID, account, hex, uuid, ticker and number.
  • Network switch: testnet to mainnet.

Notes

The SDK's generated middleware types no longer export
PortfolioMovementTypeEnum, so the explorer names the two kinds itself.
- Creation stamps come from createdEvent and its block.
- Holder counts use Asset.holderCount, which counts identities with a
  balance or at least one NFT; the nftHolders connection is gone.
- Venue ids are zero-padded in the index: pad them for lookups and strip
  the padding for display.
- Account reads primaryAccountId, and a multisig is an account with a
  MultiSig row, not one that created a multisig.
- Secondary keys are the identity's current SecondaryKey memberships;
  the reverse relations are claims, venues, assetsOwned and
  custodiedPortfolios.
- Held NFT collections are heldAssets with nftCount above zero, and the
  assets tab shows that count.
- The monthly creation count filters on the creation event's block time.
- createdAt is left empty when the creation stamp names an event the
  index did not store, instead of failing the whole page.
…sactions

- Accounts are the fromAccountId/toAccountId relations, and the block,
  event and extrinsic indexes come from createdEvent.
- Instruction and venue ids are shown without the index's zero padding.
- Portfolio movements are internal transfers in assetTransactions,
  filtered by the did/number portfolio id; the portfolioMovements
  connection is gone.
- NFT holders are assetHolders with nftCount above zero. Their token ids
  are read from nfts in pages of 100, because a nested connection stops
  at 100 rows without saying so.
- Fungible holders exclude identities whose balance went back to zero.
- Extrinsic parameters are the args object; paramsTxt is gone.
- Extrinsic block ids are shown without the index's zero padding.
- Legs name their parties by id: fromId/toId, the account ids, and the
  did/number portfolio ids.
- Affirmations are one row per holder, a portfolio or an account, plus
  one per mediator, Pending until the holder affirms. The affirmations
  tab shows the holder and the time it affirmed, and an instruction is
  affirmed by the identities none of whose holdings are still Pending.
- An identity's instructions are those with a leg from or to its DID.
- Instruction and venue ids are padded for lookups and shown unpadded.
- Stamps and instruction events come from createdEvent and updatedEvent.
…leware

The snapshot is now the endpoint's standard introspection result, which
buildClientSchema and codegen can read, instead of a serialized
GraphQLSchema object.
The query service answers concurrent requests one at a time, so 27
parallel pages for a testnet holder of 2,724 tokens took 26 s. Sent as
aliases of one request, 25 pages at a time, they take about 1 s.
The schema no longer has the one-to-one reverse field Account.multiSig
(read as multiSigs), so the account query asks the multiSigs connection
for a row whose own account is this address.
…ication

Taken from the testnet endpoint, which serves the final schema without
StakingPosition, Validator, AssetPreApproval, EvmAccountMapping,
CorporateActionDefaultConfig and the one-to-one reverse fields.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant