Coder Social home page Coder Social logo

tx_util's Introduction

tx_util

A utility library to help constructing ScriptContext, useful for testing.

โ„น๏ธ Package info aiken-extra/tx_util v1.170.202311 ๐Ÿชฒ
๐ŸŸข Depends on aiken-lang/stdlib v1.7.0 โœ”๏ธ
๐ŸŸข Tested with 7d319077e6 โœ”๏ธ

Usage Example

use tx_util/builder.{
    build_txn_context,
    mint_assets,
    add_tx_ref_input,
    add_tx_input,
    add_tx_output,
    add_signatory
}
test validate_something() {
  ...
  let ctx =
    after(now) // aiken/interval.{after}
      |> build_txn_context()
      |> mint_assets("PolicyID", minted_assets)
      |> add_tx_ref_input(tx_ref_in)
      |> add_tx_input(tx_in_1)
      |> add_tx_input(tx_in_2)
      |> add_tx_output(tx_out_1)
      |> add_tx_output(tx_out_2)
      |> add_signatory("Signer")
  ...
  validator(..., ..., ctx)
}

Where,

// aiken/transaction/value
minted_assets = to_minted_value(assets)

// tx_util/builder
tx_ref_in = new_tx_input(...)
      |> with_asset_of_tx_input(asset)

// tx_util/builder.{new_tx_input}
tx_in_1 = new_tx_input(...)

// tx_util/builder.{with_asset_of_tx_input}
tx_in_2 = new_tx_input(...)
      |> with_asset_of_tx_input(asset1)
      |> with_asset_of_tx_input(asset2)

// tx_util/builder.{new_tx_output}
tx_out_1 = new_tx_output(...)

// tx_util/builder.{add_asset_to_tx_output}
tx_out_2 = new_tx_output(...)
      |> add_asset_to_tx_output(asset1)
      |> add_asset_to_tx_output(asset2)

tx_util's People

Contributors

ariady-putra avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

ariady-putra

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.