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

@chorpiler/algorandvm

v0.2.1

Published

- Based on the [Chorpiler Core](https://github.com/fstiehle/chorpiler) package. - A compiler to transform BPMN 2.0 choreographies to application contracts in TEAL, based on petri-net reductions. - Current targets supported: TEAL

Downloads

13

Readme

Chorpiler/AlgorandVM

  • Based on the Chorpiler Core package.
  • A compiler to transform BPMN 2.0 choreographies to application contracts in TEAL, based on petri-net reductions.
  • Current targets supported: TEAL

Overview

| Element | Supported | |--------------------|------------| | Choreography tasks | ✔ | | Events | Start, End | | Gateways | XOR, AND | | Looping behaviour | ✔ |

Usage

Install and use through npm.

npm install chorpiler
npm install @chorpiler/algorandvm

See below example.

import chorpiler, { ProcessEncoding } from 'chorpiler';
import algchor from '@chorpiler/algorandvm';

const parser = new chorpiler.Parser();

// to generate a smart contract implementing the process
const contractGenerator = new algchor
  .generators.teal.DefaultContractGenerator();

Complete example usage to parse and generate.

import * as fs from 'fs';
import chorpiler, { ProcessEncoding } from 'chorpiler';
import algchor from '@chorpiler/algorandvm';
import path from 'path';

const parser = new chorpiler.Parser();

const contractGenerator = new algchor
  .generators.teal.DefaultContractGenerator();

const bpmnXML = fs.readFileSync(path.join(__dirname, "./../bpmn/incident-management.bpmn"));   
// parse BPMN file into petri net
parser.fromXML(bpmnXML).then((e) => {

// compile to smart contract
contractGenerator.compile(e)
.then((gen) => {
  fs.writeFileSync(
    "Process.teal", 
    gen.target, 
    { flag: 'w+' }
  );
  console.log("Process.teal generated.");
  // log encoding of participants and tasks, 
  // can also be written to a .json file
  console.log(ProcessEncoding.toJSON(gen.encoding));
})})
.catch(err => console.error(err));

For usage see also the tests defined in tests/output.

Replicate Results and Tests

Executing tests requires a local Algorand test environment. Chorpiler/AlgorandVM package is pre-configured for the algorand sandbox environment. The configuration can be adjusted in tests/config.ts. To fund additional accounts during testing, the mnemonic of a faucet account of the environment must be specified in .evn.test.ts.

To test that the environment is setup correctly, one can run npm run test/sdk. Then, execute npm run test to execute performance and conformance benchmarks. Results are formated and output to console and all tests must pass.

Theory

Petri net generation

Our approach is based on the optimised translation technique presented in Garćıa-Bañuelos et al. [1]: a process model is converted into a Petri net, and this net is reduced according to well-established equivalence rules. In the smart contract, the process state is then encoded as a bit array. Our approach is based on interaction Petri nets, which are a special kind of labelled Petri nets. Interaction Petri nets have been proposed as the formal basis for BPMN choreographies [2]. As labels, they store the initiator and respondent information, which are essential for the channel construction. After conversion, we apply the same reduction rules as in [1].

In contrast to [1], we must restrict enforcement to certain roles: only initiators are allowed to enforce tasks.3 Thus, in our approach, we can differentiate between manual and autonomous transitions. Manual transitions correspond to tasks that are initiated by a participant; these must be explicitly executed. Autonomous transitions are the remaining silent transitions. Converting a process model into a Petri net creates silent transitions. While most of them can be deleted through reduction, some can not be removed without creating infinite-loops [1]. These transitions must then be performed by the blockchain autonomously, given that the correct conditions are met. Consequently, these transitions are not bound to a role. The differentiation allows a more efficient execution: if the conditions for a manual task are met, it is fired and terminated; further autonomous transitions may be fired, without requiring further manual transitions.

Petri net generation

[1]: Garćıa-Bañuelos, L., Ponomarev, A., Dumas, M., Weber, I.: Optimized Execution of Business Processes on Blockchain. In: BPM. Springer, Cham (2017) 130–146

[2]: Decker, G., Weske, M.: Local enforceability in interaction Petri nets. In: BPM. Volume 4714 of LNCS., Springer, Cham (2007) 305–319