GraphQL API for checking and signing mStable Quests
-
Firebase login
firebase login
- Set project (optional)
firebase use ropsten
- Go to functions module
cd functions
- Get environment variables locally
firebase functions:config:get > .runtimeconfig.json
- Install, then build and run with emulators
yarn
yarn serve
# From the root of the projecet
firebase use production
firebase deploy
See the Firebase documentation for instructions on how to set the config.
query Quest($id: ID!, $account: ID!) {
quest(id: $id) {
id
metadata {
title
description
}
submission(account: $account) {
complete
progress
signature
}
}
}
mutation Submit($id: ID! $account: ID!) {
submitQuest(id: $id, account: $account) {
complete
progress
signature
}
}
Quests are defined programmatically; to add a new quest, copy an example and create a PR.
Quests need to have unique IDs; the numeric ID of the quest on-chain.
See src/quests/certifiedWhale.ts
for an example.
Quest checker functions have access to the data sources that the Apollo server uses. These can be used like so:
const certifiedWhale: QuestChecker = async (dataSources, account) => {
const balance = await dataSources.stakedToken.contract.balanceOf(account)
// ...do something with the balance
}
Data sources can be added as-needed; just extend Apollo's DataSource
class (or find an existing implentation) and add them to the Apollo server's dataSources
prop.