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

@saturn-chain/dlt-tx-data-functions

v1.0.9

Published

Defines types to link `@saturn-chain/smart-contract` with different implementations accessing the chain. These functions takes the ethereum smart contract formatted data of the transactions and events filters and expect that the implementation of this l

Downloads

12

Readme

dlt-tx-data-functions: defines data types and interfaces

Defines types to link @saturn-chain/smart-contract with different implementations accessing the chain.
These functions takes the ethereum smart contract formatted data of the transactions and events filters and expect that the implementation of this library will send it properly to the network.

Two implementation exists as of now:

  • @saturn-chain/web3-function that communicates directly to a web3 provider. Transaction signatures are delegated to either the node or the provider
  • @saturn-chain/dlt-function that communicates to the dlt services via the @saturn-chain/dlt-rest-api library and expect transactions to be signed by the @saturn-chain/wallet-custody-rest-api.

Usage:

npm i --save @saturn-chain/dlt-tx-data-functions

Includes typescript types declaration

Documentation

export class YourImplementation implements EthProviderInterface {
  
  async account(index: number=0): Promise<string> {
    // returns the address available at index or the first available address if index invalid
  }

  call(options?: CallOptions): CallSendFunction {
    // function used to send a smart contract call (read only the smart contract state)
    const defaultOptions: CallOptions = { maxGas: 100000 };
    const opts = { ...defaultOptions, ...(options || {}) };
    return async (target, data): Promise<CallSendResult> => {
      // target is the address of the smart contract to be called
      // data is the encoded data to be sumitted
      // return the following structure with result as the result of the smart contract function called in raw format
      return { isTx: false, result: res };
    };
  }
  send(options?: SendOptions): CallSendFunction {
    // function used to submit a smart contract transaction that is expected to be mined
    const defaultOptions: SendOptions = { maxGas: 100000 };
    const opts = { ...defaultOptions, ...(options || {}) };
    return async (target, data): Promise<CallSendResult> => {
      // target is the address of the smart contract to be called
      // data is the encoded data to be sumitted
      // return the following structure with result as the transaction hash 
      return { isTx: true, result: txhash };
    };
  }
  newi(options?: SendOptions): DeployCallbackFunction {
    // function used to deploy a smart contract code to the chain
    const defaultOptions: SendOptions = { maxGas: 500000 };
    const opts = { ...defaultOptions, ...(options || {}) };
    return async (name, data): Promise<string | undefined> => {
      // name is the name of the smart contract as defined in solidity code
      // data is the compiled bytecode of the smart contract
      // should returned the contract address in the chain
      return contractCreated;
    };
  }


  sub(options?: LogsOptions): RequestEventsFunction {
    // function used to subscribe to Event Log from the chain
    const opts = {
      fromBlock: "latest",
      ...(options || {}),
    };
    return async (address, event, topics, receiver) => {
      // address is the optional smart contract address from which event should be captured
      // event is the name of the event, not always usefull since the first topic is the hash of the event signature
      // topics is an array of string or string[] interpreted by ethereum filters
      // receiver is an EventEmitter that should be used to pass the received log structure
      receiver.emit("log", {...}, 0 /* log index*/, 1 /* total logs to receive*/)
      // receiver will notify if the subscription should be called by raising the event removeListener
      receiver.on("removeListener", async (ev, listner)=>{
          if(ev === "log") {
            // remove subscription
          }
        })
      // receiver can be passed errors
      receiver.emit("error", error)
    }
  }

  get(options?: LogsOptions): RequestEventsFunction {
    // function used to query Event Log direclty
    const opts = {
      fromBlock: "earliest",
      toBlock: "latest",
      ...(options || {}),
    };
    return async (address, event, topics, receiver) => {
      // same behaviour than for the sub above 
      // except that there is no subscription so the 'removeListener' is never raised
    }
  }
}