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

multisig-wallet-sdk-common

v1.0.0

Published

dms-sdk-common provides general purpose components to use across the entire Aragon SDK:

Downloads

4

Readme

DMS SDK Common

dms-sdk-common provides general purpose components to use across the entire Aragon SDK:

  • Interfaces
  • Constants
  • Types
  • Enumerations
  • Helpers

Installation

Use npm or yarn to install dms-sdk-common.

npm install dms-sdk-common
yarn add dms-sdk-common

Usage

Constants

Encoding

Converting buffers and hex strings

import {hexToBytes, bytesToHex} from "dms-sdk-common";

const buff = hexToBytes("0xffffffff");
// [255, 255, 255, 255]

const str0x = bytesToHex(new Uint8Array([100, 100, 100, 100, 100, 100]));
// "0x646464646464"

const str = bytesToHex(new Uint8Array([100, 100, 100, 100, 100, 100]), true);
// "646464646464"

Converting between buffers and big integers

import {bigIntToBuffer, bigIntToLeBuffer} from "dms-sdk-common";

const bi = BigInt("111122223333444455556666777788889999000011112222333344445555666677778888999900")
const buff = bigIntToBuffer(bi);
// Uint8Array(32) [ 245, 172, 243,  22, 170, 44,  13,  78, ..., 220 ]

const buffLe = bigIntToLeBuffer(bi);
// Uint8Array(32) [ 220,  67, 63, 224,  21,  50, 154, 103, ..., 245 ]
import {bufferToBigInt, bufferLeToBigInt} from "dms-sdk-common";

const buff = new Uint8Array([
    245, 172, 243, 22, 170, 44, 13, 78,
    106, 70, 70, 147, 249, 71, 137, 190,
    155, 21, 186, 14, 206, 88, 97, 129,
    103, 154, 50, 21, 224, 63, 67, 220
]);
const hex = bufferToBigInt(buff);
// 111122223333444455556666777788889999000011112222333344445555666677778888999900n

const buffLe = new Uint8Array([
    220, 67, 63, 224, 21, 50, 154, 103,
    129, 97, 88, 206, 14, 186, 21, 155,
    190, 137, 71, 249, 147, 70, 70, 106,
    78, 13, 44, 170, 22, 243, 172, 245
]);
const hex = bufferLeToBigInt(buffLe);
// 111122223333444455556666777788889999000011112222333344445555666677778888999900n

Percent ratios stored on-chain

Encodes ratio values between 0 and 1 translated into an integer range with the given digit precision

import {encodeRatio, decodeRatio} from "dms-sdk-common";

let digits = 1
encodeRatio(0.5, digits) // 5
encodeRatio(0.53625, digits) // 5
encodeRatio(0.57625, digits) // 6

digits = 4
encodeRatio(0.5, digits) // 5000
encodeRatio(0.53625, digits) // 5362
encodeRatio(0.57625, digits) // 5762

Hex prefix guards

import {strip0x, ensure0x} from "dms-sdk-common";

strip0x("1234")
// "1234"
strip0x("0x1234")
// "1234"

ensure0x("1234")
// "0x1234"
ensure0x("0x1234")
// "0x1234"

Proposal ID's

For nonce based proposal ID's

import {encodeProposalId, decodeProposalId} from "dms-sdk-common";

encodeProposalId(pluginAddr, nonce)
// 0x1234567890123456789012345678901234567890_0x7

decodeProposalId("0x1234567890123456789012345678901234567890_0x7")
// { pluginAddress: "0x12345...", nonce: 7 }

Errors

Promises

Types