2.10.0 • Published 3 years ago

dcl-quests-client v2.10.0

Weekly downloads
85
License
MIT
Repository
-
Last release
3 years ago

Decentraland Quests Client

This library is intended to be used with the Decentraland Quests Server, which is responsible of keeping track of active quests and the progress made by each player.

Usage

First, you need to create a client. If you have access to the signature provider, you can use this:

import { QuestsClient } from 'dcl-quests-client'
import { Authenticator, IdentityType } from 'dcl-crypto'

let identity: IdentityType

const questsClient = new QuestsClient({
  baseUrl: 'https://quests-api.decentraland.io',
  authChainProvider: (payload) => Authenticator.signPayload(identity, payload)
})

You can use dcl-crypto (not included with this library) for signing the payload. But any valid auth chain for an ethereum address should be ok.

If not, you can provide a custom fetch function that injects the headers. The next example uses SignedFetch from the Decentraland SDK:

import { QuestsClient } from "dcl-quests-client/quests-client-amd";
import { signedFetch } from "@decentraland/SignedFetch";

const client = new QuestsClient({
  baseUrl: "https://quests-api.decentraland.io",
  fetchFn: signedFetch,
});

Then you can make requests:

  const { status: httpStatus, body: quests } = await questsClient.getQuests()

  console.log(quests) // A list of quests available for the player (started or not)

  const { status: httpStatus, body: details } = await questsClient.getQuestDetails(questUuid)

  console.log(details) // Details of a particular quest (same as above, but for only one quest)

  const { status: httpStatus, body: detailsStartedQuest } = await questsClient.startQuest(questUuid)

  console.log(detailsStartedQuest) // Same as above. The quest is now started for this player

  import { ProgressData } from 'dcl-quests-client'

  let progressData: ProgressData

  const { status: httpStatus, body: details } = await questsClient.makeProgress(questUuid, taskUuid, progressData)

  console.log(details) // Same as above. The quest has now made some progress for this player
2.10.0

3 years ago

2.9.2

3 years ago

2.9.1

3 years ago

2.7.0

3 years ago

2.9.0

3 years ago

2.8.1

3 years ago

2.8.0

3 years ago

2.6.1

3 years ago

2.5.2

3 years ago

2.6.0

3 years ago

2.5.3

3 years ago

2.5.0

3 years ago

2.4.1

3 years ago

2.4.0

3 years ago

2.5.1

3 years ago

2.3.2

3 years ago

2.3.3

3 years ago

2.3.1

3 years ago

2.3.0

3 years ago

2.2.1

3 years ago

2.2.0

3 years ago

2.2.2

3 years ago

2.1.1

3 years ago

2.1.0

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.11.0

3 years ago

1.9.0

3 years ago

1.8.0

3 years ago

1.10.0

3 years ago

1.7.0

3 years ago

1.6.1

3 years ago

1.6.0

3 years ago

1.5.0

3 years ago

1.4.0

3 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.2.1

3 years ago

1.2.0

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago