The app caches data from on-chain sources and subgraphs to make it easier to query and display.
The sync jobs that support this app are somewhat complicated so we're documenting some important notes about how they work and how to test them.
Each sync job is run periodically on its own cron schedule. See vercel.json
for cron
configuration.
A sync job is invoked by calling its respective endpoint, e.g. /api/sync/cabin-token
.
Sync attempts target a specific block range. Block ranges are used when synchronizing directly from on-chain data sources (cabin token) and also from subgraphs (e.g. hats).
Sync attempts are locked via the Fauna database to prevent duplicate jobs from colliding with one another and to facilitate retries in the case of failures.
Synchronized data is expected to work at the Account
level, meaning a registered Profile
does
not need to exist in order for data to be imported. This allows synchronized data to be available to
end users immediately after their Profile
is created.
New Profile
for Account
with prior cabinTokenBalance
- Run the
/sync/cabin-token
job until an account is created that has acabinTokenBalance
greater than zero. - Create a new profile, either through onboarding or using the
createProfile
mutation. - Verify the
cabinTokenBalanceInt
on theProfile
is an accurate integer representation of the 18-decimal balance.
Existing Profile
with updated cabinTokenBalance
- Create a new
Profile
that is associated with anAccount
that does not yet have acabinTokenBalance
or has a balance that has recently changed on-chain. - Run
/sync/cabin-token
until theAccount
has acabinTokenBalance
. - Verify the
cabinTokenBalanceInt
on theProfile
is an accurate integer representation of the 18-decimal balance.