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

aftr-js

v0.1.28

Published

Library for interacting with the AFTR Protocol on Arweave.

Downloads

4

Readme

AFTR-JS

AFTR JS is an SDK that gives dApps the ability to work with AFTR Repos. The current functionality allows developers to quickly create AFTR Repos and deposit assets into AFTR Repos. Users will then be able to manage their AFTR Repos on the AFTR.Market (Mainnet or Testnet) site.

Installation

npm i aftr-js

Requirements

Disclaimer: The AFTR protocol, libraries, and websites are beta versions. They are all provided "as is." While Arceum Inc. will do its best to resolve any issue encountered in these platforms, Arceum Inc. will not be liable for any loss as a result from usage of any of these platforms.

Supported Assets

AFTR is a multi-sig for Arweave assets. As such, an asset must support internal writes to be deposited into an AFTR Repo. This means that an asset must include the following parameters and functions to be deposited into an AFTR Repo:

Parameters

  1. claimable[]
  2. claims[]

Functions

  1. allow
  2. claim

To read more about cross contract communication, please see the following:

Usage

All calls to AFTR JS asynchronously return an SDKReturn object (Don't forget await!):

{ status: "success", data: string | object  } | { status: "error", message: string }

Create Repo

To create an AFTR Repo, you'll need to define the following parameters:

  1. repo (object) The repo is an object requiring 2 parameters, name and ticker.
{
    name: "NAME",
    ticker: "TICKER"
}

A repo will be created with the following default state:

{
    name: "<NAME set in the required parameters>",
    ticker: "<TICKER set in the required parameters>",
    balances: { "<OWNER WALLET ADDR>" : 1 },
    tokens: [],
    vault: {},
    votes: [],
    status: "started",
    owner: "<OWNER WALLET ADDR>",
    ownership: "single",
    votingSystem: "weighted",
    claims: [],
    claimable: [],
    evolve: "",
    functions: ["transfer", "deposit", "allow", "claim", "multiInteraction"],
    settings: [
        ["quorum", 0.5],
        ["support", 0.51],
        ["voteLength", 2160],
        ["communityLogo", ""]
    ]
}

You can set any of the parameters above to meet your needs.

There are several optional functions that may be turned off in a repo contract. By default, these will be turned on, so if you have a use case where you want to restrict these capabilities, you can define functions parameter in your initial state. For example, if you setup a repo to act as a multi-sig where you and several others have rights to sign transactions, you may not want signers of this repo to be able to transfer their membership. In this case, you would add the functions array to your repo state leaving out the "transfer" value. Just remember, if you add the functions array to your state, you'll need to supply all the optional functions that you want to include in the repo contract. You can also edit these settings later on AFTR.Market.

Valid values for the functions array include the following:

["transfer", "deposit", "allow", "claim", "multiInteraction"] | []
  • Transfer - Gives the repo the ability to transfer membership balances.
  • Deposit - Allows anyone to deposit supported Arweave assets into this repo.
  • Allow - Required for tradability protocols such as Verto Flex and for depositing this repo into another AFTR Repo.
  • Claim - Required for tradability protocols such as Verto Flex and for depositing this repo into another AFTR Repo.
  • Multi-Interactions - Gives the repo the ability to perform more than one change at a time.
  1. wallet (JWK) The wallet is Arweave wallet that will be the owner of the newly created repo. If you use a wallet like ArConnect, you can simply pass in "use_wallet".
  2. tags (optional) Tags allow you add additional tags to the newly created repo. This can be a good idea if you'd like to be able to query for these in your dApp. Tags is an array of name/value objects:
[
    { name: "TAG_NAME1", value: "TAG_VALUE1" },
    { name: "TAG_NAME2", value: "TAG_VALUE2" }
]

Please note that if you'd like to have your asset implement ANS-110, you'll need to add those tags. AFTR-JS does not implement ANS-110 by default.

  1. env (optional, defaults to mainnet) - "PROD" | "TEST" The env parameter allows you to create repos on the Arweave Mainnet (default) or the Arweave Testnet. Mainnet repos can be found on aftr.market and Testnet repos can be found on test.aftr.market.

Response

{ status: "success", data: <NEW-REPO-CONTRACT-ID>  } | { status: "error", message: string }
import { createRepo } from "aftr-js";

// Method Definition
async function createRepo(repo: RepoInterface, wallet: ExtensionOrJWK, tags?: any, env: "PROD" | "TEST" = "PROD") : Promise<SDKResult>

// Example Call with a quorum setting that's different from the default
const repo = {
    name: "My Repo",
    ticker: "MR",
    settings: [
        ["quorum", 0.3]
    ]
};

const tags = [
    { name: "My dApp", value: "CustomerID"}
];

const env = "TEST";  // "PROD" for Mainnet

let response = await createRepo(repo, "use_wallet", tags, env);
if (response.status === "success") {
    console.log("NEW REPO ID: " + response.data);
} else {
    console.log("ERROR: " + response.message);
}

Deposit

A desposit call for a repo performs 2 operations. First, it makes a call to the contract of the asset being deposited. Then, it makes a call to the repo being deposited into. It requires the following parameters:

  1. repoId (string) The repoId is the contract ID of the repo being deposited into.
  2. depTokenId (string) The depTokenId is the contract ID of the asset being deposited into the repo.
  3. qty (number) The qty is the amount of tokens being deposited into the repo.
  4. wallet (JWK) The wallet is Arweave wallet that is depositing tokens into the repo. If you use a wallet like ArConnect, you can simply pass in "use_wallet". The deposit validates this wallet (the caller) to make sure they have the appropriate balance on the depositing token.
  5. env (optional, defaults to mainnet) - "PROD" | "TEST"

Response

{ status: "success", data: { repoTxId: <TX-ID-REPO-INTERACTION>, depTokenTxId: <TX-ID-TOKEN-INTERACTION>} } | { status: "error", message: string }
import { deposit } from "aftr-js";

// Method Definition
async function deposit(repoId: string, depTokenId: string, qty: number, wallet: ExtensionOrJWK, env: "PROD" | "TEST" = "PROD") : Promise<SDKResult>

// Example Call
const response = await deposit(repoId, depTokenId, qty, "use_wallet", "TEST");
if (response.status === "success") {
    console.log("Deposit Successful: " + response.data.repoTxId + " & " + response.data.depTokenTxId);
} else {
    console.log("Deposit Failed: " + response.message);
}