1.0.65 β€’ Published 3 months ago

kinora-sdk v1.0.65

Weekly downloads
-
License
-
Repository
-
Last release
3 months ago

Kinora

An open source typescript SDK, with an easy interface to combine on-chain Livepeer videometric recording with decentralized social quests on Lens Protocol.

The Kinora SDK delineates three principle segments: Envoker, Dispatch and the Kinora Player Wrapper. Each segment can be used in isolation for greater flexibility in programming Quest deployment and player interaction.

Kinora

Check out the documentation for in depth implementation details.

To install the SDK run:

npm i kinora-sdk

Quick Start

Envoker

The Envoker class simplifies Quest setup.

It handles deployment and instantiation from the Kinora Contract Suite, publishing to Lens Protocol with integrated Kinora Open Actions and the configuration of milestones, escrowed rewards and token gated participation.

import { Envoker } from "kinora-sdk";

const apolloClient = new ApolloClient({
  link: new HttpLink({ uri: "https://api-v2.lens.dev/" }),
  headers: {
    "x-access-token": `Bearer ${authToken}`,
  },
  cache: new InMemoryCache(),
});

const polygonProvider = new ethers.providers.JsonRpcProvider(
  "https://polygonprovider.com",
  137,
);

const newEnvoker = new Envoker({
  authedApolloClient: apolloClient,
  signer: new ethers.Wallet(process.env.ENVOKER_PRIVATE_KEY, polygonProvider),
});

const { postId, factoryId, questId, transactionHash, factoryQuestData } =
  await newEnvoker.instantiateNewQuest({
    factoryId: 0,
    questDetails: {
      title: "Chromadin Chronicle",
      description:
        "Engage in a Chromadin video binge session for Season 1 and Season 2 of The Dial Pirate Radio . Interactions, mirrors and comments on episodes accrue bonus points.",
      cover: "ipfs://QmQk9TqFivUqc6ktosoZVVih9o1uiY3r5Z7F3GCC1FpaJS",
    },
    maxPlayerCount: 100,
    milestones,
    joinQuestTokenGatedLogic: tokenGatedLogic,
  });

Dispatch

The Dispatch class orchestrates player engagements with Quests, encompassing the joining of quests pursuant to entry conditions, and the accomplishment of milestones to obtain rewards upon satisfying milestone completion requisites.

import { Dispatch } from "kinora-sdk";

const apolloClient = new ApolloClient({
  link: new HttpLink({ uri: "https://api-v2.lens.dev/" }),
  headers: {
    "x-access-token": `Bearer ${authToken}`,
  },
  cache: new InMemoryCache(),
});

const polygonProvider = new ethers.providers.JsonRpcProvider(
  "https://polygonprovider.com",
  137,
);

const newDispatch = new Dispatch({
  playerAuthedApolloClient: apolloClient,
});

await newDispatch.playerJoinQuest(
  postId,
  new ethers.Wallet(process.env.PLAYER_PRIVATE_KEY, polygonProvider),
);

Kinora Player Wrapper

The Kinora Player Wrapper, a React Function Component, extends the functionality of the Livepeer Player Component to facilitate optionally encrypted videometric logging for a connected Lens Profile.

It empowers personalized on-chain video feeds, links to quest milestone criteria, and grants meticulous control over style properties, callback properties, and instance methods.

These improvements enable deeper media integration, more efficient state management, customized visual layout options, and a direct interface with corresponding Lens Protocol data.

import { Player } from "@livepeer/react";
import dynamic from "next/dynamic";
import { useWalletClient } from "wagmi";
import { KinoraProvider, KinoraPlayerWrapper } from "kinora-sdk";
import { apolloClient } from "../../lib/lens/client";
import {
  createReactClient,
  studioProvider,
  LivepeerConfig,
} from "@livepeer/react";

const livepeerClient = createReactClient({
  provider: studioProvider({
    apiKey: process.env.LIVEPEER_STUDIO_KEY!,
  }),
});

function App() {
  return (
    <LivepeerConfig client={livepeerClient}>
      <KinoraProvider playerAuthedApolloClient={apolloClient}>
        <Component {...pageProps} />
      </KinoraProvider>
    </LivepeerConfig>
  );
}

function Page() {
  return (
    <div id="parentId" className="w-20 h-20 flex">
      <KinoraPlayerWrapper
        parentId={"parentId"}
        postId={postId}
        customControls={true}
        fillWidthHeight={true}
      >
        {(setMediaElement: (node: HTMLVideoElement) => void) => (
          <Player
            mediaElementRef={setMediaElement}
            playbackId="f5eese9wwl88k4g8"
            objectFit="cover"
          />
        )}
      </KinoraPlayerWrapper>
    </div>
  );
}

Keen to venture on quests without the code entanglement?

Unlock the gateway to a no code implementation of the Quest Dispatch here.

Abstracted

Usage Terms

By using this project or its source code, for any purpose and in any shape or form, you grant your implicit agreement to all the following statements:

  • You condemn Russia and its military aggression against Ukraine
  • You recognize that Russia is an occupant that unlawfully invaded a sovereign state
  • You support Ukraine's territorial integrity, including its claims over temporarily occupied territories of Crimea and Donbas
  • You reject false narratives perpetuated by Russian state propaganda
  • To learn more about the war and how you can help, click here. Glory to Ukraine! πŸ‡ΊπŸ‡¦

og source

1.0.65

3 months ago

1.0.6

3 months ago

1.0.5

3 months ago

1.0.1

4 months ago

1.0.4

3 months ago

1.0.3

3 months ago

1.0.0

4 months ago

0.0.71

4 months ago

0.0.8

4 months ago

0.0.61

4 months ago

0.0.6

4 months ago

0.0.59

4 months ago

0.0.53

4 months ago

0.0.54

4 months ago

0.0.55

4 months ago

0.0.56

4 months ago

0.0.57

4 months ago

0.0.58

4 months ago

0.0.52

4 months ago

0.0.51

4 months ago

0.0.5

4 months ago

0.0.48

4 months ago

0.0.49

4 months ago

0.0.41

4 months ago

0.0.42

4 months ago

0.0.43

4 months ago

0.0.44

4 months ago

0.0.45

4 months ago

0.0.46

4 months ago

0.0.47

4 months ago

0.0.4

4 months ago

0.0.384

4 months ago

0.0.383

4 months ago

0.0.382

4 months ago

0.0.381

4 months ago

0.0.380

4 months ago

0.0.379

4 months ago

0.0.378

4 months ago

0.0.376

4 months ago

0.0.375

4 months ago

0.0.374

4 months ago

0.0.373

4 months ago

0.0.372

4 months ago

0.0.371

4 months ago

0.0.377

4 months ago

0.0.37

4 months ago

0.0.36

4 months ago

0.0.35

4 months ago

0.0.34

4 months ago

0.0.33

4 months ago

0.0.32

4 months ago

0.0.31

4 months ago

0.0.30

4 months ago

0.0.3

4 months ago

0.0.297

4 months ago

0.0.298

4 months ago

0.0.299

4 months ago

0.0.29

4 months ago

0.0.28

4 months ago

0.0.27

4 months ago

0.0.26

4 months ago

0.0.25

4 months ago

0.0.24

4 months ago

0.0.23

4 months ago

0.0.22

4 months ago

0.0.21

4 months ago

0.0.2

4 months ago