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

@wingriders/apply-params-to-script

v0.1.2

Published

Simple WASM wrapper around uplc's `apply_params_to_script` function

Downloads

357

Readme

@wingriders/apply-params-to-script

Simple isomorphic WASM wrapper around apply_params_to_script function from uplc. It enables you to take a parametrized script and apply the parameters to it.

Same functionality is also part of lucid, which integrates it further with the cardano-multiplatform-lib. So if you are already using CML that might be a better fit for you.

The goal of this library is to be a very thin WASM wrapper that communicates using buffers, and leaves the CBOR serialization of params and working with the script to you, so you can plug it into whatever toolchain you might be using.

Get started

npm

npm install @wingriders/apply-params-to-script

pnpm

pnpm add @wingriders/apply-params-to-script

yarn

yarn add @wingriders/apply-params-to-script

Usage

import {applyParamsToScript} from '@wingriders/apply-params-to-script'

// In this example our script is parametrized by one integer parameter
// so we'll apply the parameter 42 to this script

// This package works directly with the script CBOR, it doesn't accept double CBOR encoded scripts
const script = Buffer.from('your script cbor', 'hex')

// Our parameter needs to be wrapped in a PlutusData array
// so 42 becomes [42] which CBOR encoded is 81182A
const params = Buffer.from('81182A', 'hex')

// This returns Uint8Array type by default
const scriptWithAppliedParams = await applyParamsToScript(params, script)

// so we can cast it to a Buffer, so it's easier to work with
const scriptWithAppliedParamsBuffer = Buffer.from(scriptWithAppliedParams)

// No you can continue working with the script as you want to

You can also refer to the tests to see example usage. In case the application of the paramter is not successful, the function will throw an error.

Development

Building

To build this project you need to:

  1. Install rust - refer to the their guide
  2. Install wasm-pack - refer to the their guide
  3. After that run wasm-pack build --target nodejs to build the library

Testing

First you need to build the project, after that you need to install the development dependencies using pnpm

pnpm

Then you can run the included tests with:

pnpm test

Contributing

This is a very simple and single focused library, but if you see any room for improvement, for example reducing the size of the outputted WASM bundle, or improving the isomorphic building and bundling, feel free to open a PR.