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

@eversurf/surfkeeper-provider

v0.3.0

Published

Provider interface for Surf Keeper extension of the Everscale blockchain

Downloads

212

Readme

How to install

yarn add @eversurf/surfkeeper-provider

Methods

Surf Extension methods

  • connect Requests new permissions for current origin. Shows an approval window to the user.
    input: {};
    output: {
        isConnected: boolean; // Flag shows connection status for the current origin
        address?: string; // Address of extension wallet
        publicKey?: string; // Hex encoded public key
    };
    Example:
    const result = await rpc.connect();
  • connectStatus Returns the current connection status.
    input: {};
    output: {
        isConnected: boolean; // Flag shows connection status for the current origin
        address?: string; // Address of extension wallet
        publicKey?: string; // Hex encoded public key
    };
    Example:
    const result = await rpc.connectStatus();
  • disconnect Removes all permissions for current origin.
    input: {
    }
    output: {
        isConnected: boolean; // Flag shows connection status for the current origin; should return `false` as disconnect method execution result.
    }
    Example:
    const result = await rpc.disconnect();
  • sendMessage Sends an internal message from the user account. Shows an approval window to the user.
    input: {
        abi: string; // Contract abi.
        action?: string; // Name of action to be performed by message send.
        address: string; // Address string.
        amount: string; // Amount of nano tokens to send.
        bounce: boolean; // Whether to bounce message back on error.
        callSet: {
            functionName: string; // Name of contract function to be sent to the contract.
            input: Record<string, any>; // Input for the contract function.
            header?: FunctionHeader; // Options header for function.
        };
    };
    output: {
        // Result of message send.
        result?: {
            // Result of send message.
            sendMessageResult: {
                shard_block_id: string; // The last generated shard block of the message destination account before the message was sent.
                sending_endpoints: string[]; // The list of endpoints to which the message was sent.
            };
            messageID: string; // Message id.
        };
        error?: string; // String with error details.
    };
    Example:
    const response = await rpc.sendMessage({
        abi: '{"ABI version":2,"version":"2.3","header":["pubkey","time","expire"]...',
        action: 'Create comment',
        address: '0:8959ea111cc0c85d996df0d16e530d584d5366618cfed9ab6a1754828bb78479',
        amount: '2000000000', // in nano-tokens, i.e. 2 tokens
        bounce: true,
        callSet: {
            functionName: 'addComment',
            input: {
                comment: 'Test comment',
            },
        },
    });
  • sendTransaction Sends transaction with provided params. Shows an approval window to the user.
    input: {
        amount: string; // Amount of nano tokens to send.
        bounce: boolean; // Whether to bounce message back on error.
        comment: string; // Comment for the transaction to send it in payload.
        to: string; // Address to send transaction to.
    }
    output: {
      // Result of transaction message send.
      result?: {
          // Result of send message.
          sendMessageResult: {
              shard_block_id: string; // The last generated shard block of the message destination account before the message was sent.
              sending_endpoints: string[]; // The list of endpoints to which the message was sent.
          };
          messageID: string; // Message id.
      };
      error?: string; // String with error details.
    };
    Example:
    const response = await rpc.sendTransaction({
        amount: '10000000000', // in nano-tokens, i.e. 10 tokens
        bounce: true,
        comment: 'check it out!',
        to: '0:b76b532fbe72307bff243b401d6792d5d01332ea294a0310c0ffdf874026f2b9',
    });
  • signData Signs arbitrary data. Shows an approval window to the user.
    input: {
        data: string; // Unsigned user data; must be encoded with base64.
    }
    output: {
        signature?: string; // Data signature; encoded with hex.
        error?: string; // String with error details.
    };
    Example:
    const response = await rpc.signData({
        data: 'te6ccgEBAQEAKAAASw4E0p6AD5fz9JsGWfbBhP0Bwq9+jk0X3za9rhuI7A1H3DxC0QBw',
    });
  • subscribe Subscribes to data updates.
    input: {
        type: string; // Subscription type, for now "balance" and "isConnected" subscription types are available.
        address: string; // Target address (for balance subscription).
        listener: (value: string) => void; // Subscription data update handler.
    };
    output: {
        remove: () => void; // A disposer to unsubscribe from the subscription.
    };
    Example:
    const response = rpc.subscribe({
        type: 'balance',
        address: '0x000000..000',
        listener: val => console.log('Balance updated:', val),
    });

Example

import { ProviderNetwork, ProviderRpcClient } from '@eversurf/surfkeeper-provider';

// By default new client will be created for ProviderNetwork.everscale network;
// to work with other networks pass ProviderNetwork enum value
// as a first parameter of ProviderRpcClient constructor
const rpc = new ProviderRpcClient(ProviderNetwork.everscale);

async function myApp() {
    if (!(await rpc.hasProvider())) {
        throw new Error('Extension is not installed');
    }

    const connectionInfo = await rpc.connect();
    if (connectionInfo == undefined) {
        throw new Error('Insufficient permissions');
    }

    const selectedAddress = connectionInfo.address;
    const isConnected = connectionInfo.isConnected;
    const publicKey = connectionInfo.publicKey;

    const sendTransactionResult = await rpc
        .sendTransaction({
            amount: '10000000000',
            bounce: true,
            comment: 'check it out!',
            to: '0:b76b532fbe72307bff243b401d6792d5d01332ea294a0310c0ffdf874026f2b9'
        });
    console.log(sendTransactionResult);

    const sendMessageResult = await rpc
        .sendMessage({
            abi,
            action: 'Create comment',
            address: '0:8959ea111cc0c85d996df0d16e530d584d5366618cfed9ab6a1754828bb78479',
            amount: '2000000000', // in nano-tokens, i.e. 2 tokens
            bounce: true,
            callSet: {
                functionName: 'functionName',
                input: {
                    comment: 'Test comment',
                },
            },
        });
    console.log(sendMessageResult);
}

const abi = {
    'ABI version': 2,
    'header': ['time', 'expire'],
    'functions': [{
        ...
    }],
    'data': [],
    'events': [],
} as const; // NOTE: `as const` is very important here

myApp().catch(console.error);