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

@range-security/range-sdk

v1.8.2

Published

SDK for easy custom alerts

Downloads

570

Readme

Range SDK

Range SDK is a powerful Typescript library that simplifies the development of security rules and anomaly detectors for Cosmos blockchains. With the Range SDK, developers can easily extend the security of their protocols, monitoring in real-time the validity of invariants, risk scenarios, phishing attacks, spam, and much more.

Table of Contents

Installation

yarn add @range-security/range-sdk

Usage

Here's a basic example to get you started:

// Range Implementation of `new-contract-code-stored` alert rule
import {
  RangeSDK,
  OnBlock,
  IRangeBlock,
  IRangeAlertRule,
  ISubEvent,
} from '@range-security/range-sdk';

// Define your OnBlock handler
const myOnBlock: OnBlock = {
  callback: async (
    block: IRangeBlock,
    rule: IRangeAlertRule,
  ): Promise<ISubEvent[]> => {
    const allMessages = block.transactions.flatMap((tx) => tx.messages);
    const targetMessages = allMessages.filter((m) => {
      return m.type === 'cosmwasm.wasm.v1.MsgStoreCode';
    });

    const results = targetMessages.map((m) => ({
      details: {
        message: `New CW contract code stored by ${m.value.sender}`,
      },
      txHash: m.hash,
      addressesInvolved: m.addresses,
    }));

    return results;
  },
};

(async () => {
  // Defining the RangeSDK instance
  const range = new RangeSDK({
    token: env.RANGE_TOKEN,
  });

  // Running the RangeSDK instance
  await range.init({
    onBlock: myOnBlock,
  });
})();
// Range Implementation of `rpc-status` alert rule
import {
  RangeSDK,
  OnTick,
  IRangeAlertRule,
  ISubEvent,
} from '@range-security/range-sdk';

// Define your OnTick handler
const myOnTick: OnTick = {
  callback: async (
    timestamp: string,
    rule: IRangeAlertRule,
  ): Promise<ISubEvent[]> => {
    const parameters = rule.parameters;

    // note: if p.ticker is set as 10, the rule will run on each 10 minutes
    if (dayjs(timestamp).get('minute') % p.ticker !== 0) {
      return [];
    }

    try {
      await axios.get(`https://rpc.osmosis.zone/status`);
      return [];
    } catch (error) {
      return [
        {
          details: {
            message: `Osmosis public RPC is down: ${JSON.stringify(error).slice(0, 100)}...`,
          },
          txHash: '',
          addressesInvolved: [],
          caption: 'Osmosis public RPC down',
        },
      ];
    }
  },
};

(async () => {
  // Defining the RangeSDK instance
  const range = new RangeSDK({
    token: env.RANGE_TOKEN,
  });

  // Running the RangeSDK instance
  await range.init({
    onTick: myOnTick,
  });
})();

For more examples and use-cases, see the open-source rule repositories of several Cosmos chains:

Features

  • Simple and intuitive API
  • Advanced security rule building in Typescript
  • Easy integration testing with real block data
  • Powerful anomaly detection examples
  • Integration with most Cosmos chains
  • Extensive documentation

Documentation

Complete documentation can be found at our official documentation site.

How To Contribute

We welcome contributions from the community! To get started:

  1. Fork the repository.
  2. Clone your forked repository and install dependencies:
git clone https://github.com/your-username/range-sdk.git
cd range-sdk
npm install
  1. Make your changes, add tests, and ensure tests pass.
  2. Commit your changes and push to your fork.
  3. Create a pull request with a detailed explanation of your changes.

Before contributing, please read our CONTRIBUTING.md.

Reporting bugs

If you encounter any bugs or issues, please open an issue on GitHub. When reporting a bug, please provide as much context as possible, including error messages, logs, and steps to reproduce the bug.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Credits

Thank you to all the contributors who have helped make Range SDK what it is today!