Skip to content

๐Ÿ‰ GraphQL API for checking and signing mStable Quests

Notifications You must be signed in to change notification settings

mstable/mStable-QuestBook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

32 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

mStable QuestBook

GraphQL API for checking and signing mStable Quests

Quickstart

  1. Install Firebase tools

  2. Firebase login

firebase login
  1. Set project (optional)
firebase use ropsten
  1. Go to functions module
cd functions
  1. Get environment variables locally
firebase functions:config:get > .runtimeconfig.json
  1. Install, then build and run with emulators
yarn
yarn serve

Deployment

# From the root of the projecet
firebase use production
firebase deploy

Environment variables

See the Firebase documentation for instructions on how to set the config.

API

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
    }
}

Defining quests

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.

Data sources

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.

About

๐Ÿ‰ GraphQL API for checking and signing mStable Quests

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published