Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@genesis-xyz/caips

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@genesis-xyz/caips

@genesis-xyz/caips is a powerful and user-friendly CAIPs (Chain Agnostic Improvement Proposals) library for JavaScript and TypeScript applications. This library provides a clean and intuitive API, with excellent support for applications utilizing zod for

  • 0.1.1
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
3
increased by200%
Maintainers
1
Weekly downloads
 
Created
Source

@genesis-xyz/caips

@genesis-xyz/caips is a powerful and user-friendly CAIPs (Chain Agnostic Improvement Proposals) library for JavaScript and TypeScript applications. This library provides a clean and intuitive API, with excellent support for applications utilizing zod for validation and parsing.

npm version

Features

  • Clean and intuitive API
  • Flexible constructors (from-string and from-object)
  • toString() method for seamless string interpolation
  • Exported zod schemas for seamless integration with zod-powered apps
  • RegExp support for advanced use cases

Installation

npm install @genesis-xyz/caips

Usage

Constructors

import { CAIP2, CAIP10, CAIP19 } from '@genesis-xyz/caips';

// ChainID examples
const chainIDFromString = new CAIP2.ChainID('eip155:1');
const chainIDFromObject = new CAIP2.ChainID({ namespace: 'eip155', reference: '1' });

// AccountID examples
const accountIDFromString = new CAIP10.AccountID('eip155:1:0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb');
const accountIDFromObject = new CAIP10.AccountID({
  chainId: 'eip155:1',
  address: '0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb',
});

// AssetID and AssetType examples
const assetIDFromString = new CAIP19.AssetID('eip155:1/erc721:0x123456789abcdef0123456789abcdef01234567/1');
const assetIDFromObject = new CAIP19.AssetID({
  chainId: 'eip155:1',
  assetName: 'erc721:0x123456789abcdef0123456789abcdef01234567',
  tokenId: '1',
});
const assetTypeFromString = new CAIP19.AssetType('eip155:1/erc721:0x123456789abcdef0123456789abcdef01234567');
const assetTypeFromObject = new CAIP19.AssetType({
  chainId: 'eip155:1',
  assetName: 'erc721:0x123456789abcdef0123456789abcdef01234567',
});

toString() method

const chainID = new CAIP2.ChainID('eip155:1');
console.log(`ChainID: ${chainID}`); // ChainID: eip155:1

Using exported zod schemas

import { CAIP2, CAIP10, CAIP19 } from '@genesis-xyz/caips';
import { z } from 'zod';

CAIP2.ChainIDStringSchema.parse('eip155:1');
CAIP2.ChainIDObjectSchema.parse({
  namespace: 'eip155',
  reference: '1',
});

FAQs

Package last updated on 01 May 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc