@therootnetwork/pact-web
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

@therootnetwork/pact-nodejs

Wasm pact js interface.

Create a Pact contract

const {OpLoad, OpComp, OpConj} = require(".@therootnetwork/pact-nodejs");
const Pact = require('@therootnetwork/pact-nodejs').Pact;
const OpCodeComparator = require('@therootnetwork/pact-nodejs').OpCodeComparator;
const OpCodeConjunction = require('@therootnetwork/pact-nodejs').OpCodeConjunction;


let data_table = ["10","20"];
let comp = new OpCodeComparator(OpLoad.InputVsUser, OpComp.EQ,0,0,false);
let conj = new OpCodeConjunction(OpConj.AND,false);
let bytecode = new Uint8Array([
    ...comp.encode(),
    conj.encode(),
]);

return new Pact(data_table, bytecode);

Encode and serialize a Pact contract

const {OpLoad, OpComp, OpConj} = require(".@therootnetwork/pact-nodejs");
const Pact = require('@therootnetwork/pact-nodejs').Pact;
const OpCodeComparator = require('@therootnetwork/pact-nodejs').OpCodeComparator;
const OpCodeConjunction = require('@therootnetwork/pact-nodejs').OpCodeConjunction;


let data_table = ["10","20"];
let comp = new OpCodeComparator(OpLoad.InputVsUser, OpComp.EQ,0,0,false);
let conj = new OpCodeConjunction(OpConj.AND,false);
let bytecode = new Uint8Array([
    ...comp.encode(),
    conj.encode(),
]);

let pactContract = new Pact(data_table, bytecode);
return pactContract.encode();

Readme

Keywords

none

Package Sidebar

Install

npm i @therootnetwork/pact-web

Weekly Downloads

0

Version

0.0.3

License

Apache-2.0

Unpacked Size

95.6 kB

Total Files

6

Last publish

Collaborators

  • zees-fv
  • karishma09
  • aidan-starke
  • kenvu-ai