@opeslabs/sdk
v1.33.0-development129
Published
The OPES JavaScript SDK
Downloads
104
Keywords
Readme
OPES SDK
https://www.npmjs.com/package/@opeslabs/sdk
Getting started
- As this is intended to be an open-source project, we will want to first fork the original project that can be found here. Make sure you are added to the Github organization.
- Fork the project and clone it on your machine
- Set the remote upstream of the fork to point to the opeslabs repository
- Install the dependencies by running
yarn install
Building
- In order to build the project, we have to run
yarn build
in order to generate all the transpiled files
Branching & Pull Requests
Current workflow is as follows:
- Make sure your
main
branch is up to date with the upstream - Create a new feature-branch. This is where you will do most of the work regarding a feature. A common naming convention would be
feat-#23/framer
, where#23
is the issue in the organization's project. - Commits will be linted and checked with commitizen, so it's easier when you want to commit some changes to run
npx cz
- When you consider the branch to be done, create a pull request into the
upstream/main
branch from opeslabs and ask for reviewers - After the PR is approved by 1 or more peers, you can merge it into the main
- After, you will want to sync your local main with the upstream main branch from the original opeslabs repository
Local development
Since this is an SDK, it does not do much on its own unless it's imported in another project.
If you want to take the latest version that's available on npm, you can simply run yarn add @opeslabs/sdk
and then import whatever methods you need
If you want to test locally functionality that you've written inside the local SDK, we first need to:
- create a feature-branch
- implement your changes
- run
yarn build
in order to compile all files that will be used (a/lib
folder will be generated) - run
npm i . -g
in order to install this local version globally on your machine - Then, in the project you want to test out the functionality, run
npm link @opeslabs/sdk
in order to link it to the globally installed package - After you're done testing the integration, run
npm unlink @opeslabs/sdk
in order to remove the reference and then go back to using the NPM version by installing it with:yarn add @opeslabs/sdk
Using the SDK
Fetching the monsters list
- Login to you Metamask
- Filter for the NFTs in the Monster collection and map over the
tokenId
attribute (use Alchemy SDK or something similar) - The above array of numbers will be passed as payload along with the
env
in the following API call from the SDK
import { getWaitingListGatekeepersByIds } from '@opeslabs/sdk/lib/services/waitinglist';
...
const response = await getWaitingListGatekeepersByIds({
ids: nftIds,
env: 'dev',
});
Fetching the monster's details
nftId
is equivalent totokenId
from the metamask account collection
import { getGatekeeperDetails } from '@opeslabs/sdk/lib/services/waitinglist';
...
const apiMonsterNFT = await getGatekeeperDetails({
gatekeeperId: nftId,
env: 'dev',
});
Deployment
When the feature is ready and you've tested locally that it's working (check above), we want to deploy it to npm
- First we make sure we're on the feature branch
- Bump the package version
- Stage & commit the files & push it to the branch
- Open a PR into the upstream main
- Ask for reviews and once they're approved merge the PR
- Publish the package by running
npm --access public publish
- Sync your forked main with the upstream main
- Create a release tag in Github with the version from the
package.json
Deploying
- Log in to npm
- Perform necessary changes
- Run
yarn build
- Increase version in
package.json
- Stage & commit & push into your fork's main and then merge it
- Open PR into upstream and ask for reviews
- Merge PR
- Run
npm --access public publish
- Create a release tag in Github with the version from the
package.json