npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@magicblock-labs/soar-sdk

v0.1.23

Published

Sdk bindings for the SOAR smart contract.

Downloads

71

Readme

SOAR SDK

This Typescript sdk provides a convenient interface and methods for interacting with the on-chain soar program.

Contents

Getting started

import { SoarProgram, GameType, Genre } from "@magicblock-labs/soar-sdk";

const provider = anchor.AnchorProvider.env();
anchor.setProvider(provider);

const client = SoarProgram.get(provider);

let game = Keypair.generate();
let title = "Game1";
let description = "Description";
let genre = Genre.Action;
let gameType = GameType.Web; 
let nftMeta = Keypair.generate().publicKey;
let _auths = auths.map((keypair) => keypair.publicKey);

// Retrieve the bundled transaction.
let { newGame, transaction } = await client.initializeNewGame(game.publicKey, title, description, genre, gameType, nftMeta, _auths);
// Send and confirm the transaction with the game keypair as signer. 
await client.sendAndConfirmTransaction(transaction, [game]);

Classes

SoarProgram

The SoarProgram class gives client access to every instruction in the on-chain SOAR program.

It also gives utility functions for deriving PDAs:

const user = Keypair.generate().publicKey;
const playerAddress = client.utils.derivePlayerAddress(user)[0],

fetching an account:

const account = await client.fetchLeaderBoardAccount(address);

and fetching multiple accounts:

const accounts = await client.fetchAllLeaderboardAccounts([]);

GameClient

The GameClient provides a more specific set of functions tailored to a single Game account.

import { GameClient } from "@soar/sdk";

Get an instance representing an existing on-chain Game account:

const soar = SoarProgram.get(provider);
const gameClient = new GameClient(soar, address);

Register a new game:

const soar = SoarProgram.get(provider);
const game = new GameClient.register(soar, ...);
// Create a new leaderboard:
await game.addLeaderboard(....);

// Access the game's state.
await game.init();

// Refresh the game's state.
await game.refresh();

// Get the most recently-created achievement for a game
const achievement = game.recentAchievementAddress();

InstructionBuilder

import { InstructionBuilder } from "@magicblock-labs/soar-sdk"

Provides a set of methods for conveniently bundling transactions.

const transaction = await this.builder
      .andInitializePlayer({username, nftMeta}, user)
      .andRegisterPlayerEntry(/*...*/)
      .andSubmitScoreToLeaderboard(/*...*/)
      .and(/*some other transaction*/)
      .then((builder) => builder.build());

Contributing

The community is encouraged to contribute to the Soar SDK.

Fixes and features are always welcome! Please feel free to submit a PR for review.

Tests.

Test files are located in client/tests/*. To run the tests, enter anchor test from the root directory of the repository.