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

@yoroi/claim

v1.0.0

Published

The Claim (proof-of-onboarding) package of Yoroi SDK

Downloads

17

Readme

@yoroi/claim

Overview

The @yoroi/claim is a utility package designed to handle token claims on the Cardano blockchain, following the CIP-99 (Cardano Improvement Proposal 99) standard for Proof of Ownership (POO) in decentralized token claiming. It provides an API for managing claim requests and responses, including error handling, token synchronization, and status management for claims.

The package works seamlessly with the Yoroi ecosystem and interacts with the Cardano blockchain to allow users to claim various tokens (both native and NFT) and manage their status in real-time.

Features

Claim Token Handling: Process token claims for native assets, NFTs, and Lovelace based on claim responses. Status Management: Handles multiple claim statuses such as accepted, queued, and claimed. Error Handling: Provides detailed error messages and error handling based on claim API responses. Token Synchronization: Synchronizes tokens with external sources to ensure the correct token information is used while displaying claims. Support for CIP-99: Follows the Cardano Improvement Proposal 99 standard for Proof of Ownership (POO), enabling secure and decentralized token claims.

Installation

To install the package, you can use npm or yarn:

npm install @yoroi/claim

or

yarn add @yoroi/claim

Peer Dependencies

This package works alongside other @yoroi modules, such as @yoroi/portfolio and @yoroi/types. Ensure these dependencies are installed in your project:

npm install @yoroi/{portfolio,types}

Usage

Creating a Claim Manager

The main utility of this package is the claimManagerMaker function. This function sets up a claim manager that can be used to request tokens to be claimed and sent to a specified Cardano address.

The claimManagerMaker requires the following inputs:

  • address: The Cardano address where the claimed tokens should be sent.
  • primaryTokenInfo: Information about the primary token (e.g., Lovelace) being claimed.
  • tokenManager: A token manager responsible for handling the synchronization and management of token data, please check on @yoroi/portfolio
  • deps: Optional dependency injection, providing a request function for interacting with the API.
import {claimManagerMaker} from '@yoroi/claim'
import {tokenMocks} from '@yoroi/portfolio'
import {Portfolio} from '@yoroi/types'
import {fetchData} from '@yoroi/common'

import {tokenManager, primaryTokenInfo} from '../your-code'

const claimManagerOptions = {
  address: 'addr1q...xyz', // Address where the tokens should be sent
  primaryTokenInfo,
  tokenManager,
}

// Create a claim manager
const claimManager = claimManagerMaker(claimManagerOptions)

// Now you can use `claimManager.claimTokens()` to process a claim based on a Scan.ActionClain
const claimAction: Scan.ActionClaim = {
  action: 'claim',
  code: 'claim_code',
  params: {someParam: 'value'},
  url: 'https://api.example.com/claim',
}

claimManager.claimTokens(claimAction)

Warning

This package will be interacting with an external API during the token claim process. Specifically, a scan action will trigger it and by providing the URL that will be hit during claim process. Be cautious when using this feature in production environments. Ensure that you are aware of the API's reliability, security, and any associated rate limits or costs.