Skip to content

Commit

Permalink
Update gh-pages
Browse files Browse the repository at this point in the history
Store path: /nix/store/myiv3b32cmbq17zkvq97z9y52n1w0py5-lambda-buffers-book
  • Loading branch information
hercules-ci[bot] committed Jan 27, 2024
1 parent 65b0b60 commit 4f6b0a9
Show file tree
Hide file tree
Showing 18 changed files with 867 additions and 0 deletions.
1 change: 1 addition & 0 deletions typescript-plutus/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
extra-dependencies/
13 changes: 13 additions & 0 deletions typescript-plutus/api/lbf/MySchema.lbf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module MySchema

import Plutus.V1
import Prelude (Eq, Json)

sum Branchy a
= Node PlutusData (Extended (Branchy a))
| Leaf a


derive Json (Branchy a)
derive Eq (Branchy a)
derive PlutusData (Branchy a)
17 changes: 17 additions & 0 deletions typescript-plutus/api/lbf/build.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
_:
{
perSystem = { config, ... }:
let
tsFlake =
config.lbf-nix.lbfPlutusTypescript {
name = "lbf-plutus-sample-project";
src = ./.;
files = [ "MySchema.lbf" ];
};
in
{
packages = {
inherit (tsFlake.packages) lbf-plutus-sample-project-typescript lbf-plutus-sample-project-typescript-tgz;
};
};
}
27 changes: 27 additions & 0 deletions typescript-plutus/build.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{ inputs, ... }:
{
imports = [ ./api/lbf/build.nix ];

perSystem = { config, system, ... }:
let
tsFlake =
inputs.flake-lang.lib.${system}.typescriptFlake {
name = "plutus-sample-project";
src = ./.;

npmExtraDependencies = [
config.packages.lbf-plutus-sample-project-typescript-tgz
];

devShellTools = config.settings.shell.tools;
devShellHook = config.settings.shell.hook;
};
in
{
packages = {
inherit (tsFlake.packages) plutus-sample-project-typescript plutus-sample-project-typescript-tgz;
};

inherit (tsFlake) devShells checks;
};
}
173 changes: 173 additions & 0 deletions typescript-plutus/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions typescript-plutus/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "lambda-buffers-prelude-sample-project",
"version": "1.0.0",
"description": "Sample project for LambdaBuffers",
"type": "module",
"exports": {
".": "./dist/index.mjs",
"./package.json": "./package.json"
},
"scripts": {
"build": "npx tsc -b src/",
"test": ":"
},
"author": "Jared Pon",
"license": "ISC",
"files": [
"./dist/**/*",
"./.extra-dependencies/**/*"
],
"devDependencies": {
"typescript": "^5.3.3"
},
"dependencies": {
"lbf-plutus": "file:.extra-dependencies/lbf-plutus-1.0.0.tgz",
"lbf-plutus-sample-project": "file:.extra-dependencies/lbf-plutus-sample-project-1.0.0.tgz",
"lbf-prelude": "file:.extra-dependencies/lbf-prelude-1.0.0.tgz",
"lbr-plutus": "file:.extra-dependencies/lbr-plutus-1.0.0.tgz",
"lbr-prelude": "file:.extra-dependencies/lbr-prelude-1.0.0.tgz",
"plutus-ledger-api": "file:.extra-dependencies/plutus-ledger-api-1.0.0.tgz",
"prelude": "file:.extra-dependencies/prelude-1.0.1.tgz"
}
}
126 changes: 126 additions & 0 deletions typescript-plutus/src/index.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
// Simple plutus sample project.
// To run, type
// ```
// npm run build && node ./dist/src/index.mjs
// ```
import * as LbrPlutusV1 from "lbr-plutus/V1.js";
import * as LbrPlutusPd from "lbr-plutus/PlutusData.js";
import * as LbrPrelude from "lbr-prelude";
import * as Prelude from "prelude";
import * as MySchema from "lbf-plutus-sample-project/LambdaBuffers/MySchema.mjs";

const pubKeyHash: LbrPlutusV1.PubKeyHash = new Uint8Array([
0,
0,
]) as LbrPlutusV1.PubKeyHash;

const cred: LbrPlutusV1.Credential = {
name: "PubKeyCredential",
fields: pubKeyHash,
};

console.log(`Some samples of PubKeyHash and Credential`);
console.log(pubKeyHash);
console.log(cred);

// Printing the leafy type
console.log(`The Leaf constructor`);
const leaf: MySchema.Branchy<LbrPlutusV1.Credential> = {
name: "Leaf",
fields: cred,
};
const leafpd: LbrPlutusV1.PlutusData = LbrPlutusPd.IsPlutusData
[MySchema.Branchy](
LbrPlutusPd.IsPlutusData[LbrPlutusV1.Credential],
).toData(leaf);

console.log(leafpd);
console.log(
`Prelude.Json: ${
Prelude.stringify(
LbrPrelude.Json[MySchema.Branchy](LbrPrelude.Json[LbrPlutusV1.Credential])
.toJson(leaf),
)
}`,
);
console.log(
`Prelude.Json: ${
Prelude.stringify(LbrPrelude.Json[LbrPlutusV1.PlutusData].toJson(leafpd))
}`,
);

console.log("fromData:");
console.log(
LbrPlutusPd.IsPlutusData[MySchema.Branchy](
LbrPlutusPd.IsPlutusData[LbrPlutusV1.Credential],
).fromData(leafpd),
);

// Printing the branchy
console.log(`The Node constructor`);
const branchy: MySchema.Branchy<LbrPlutusV1.Credential> = {
name: "Node",
fields: [leafpd, { name: "Finite", fields: leaf }],
};
const branchypd: LbrPlutusV1.PlutusData = LbrPlutusPd.IsPlutusData
[MySchema.Branchy](LbrPlutusPd.IsPlutusData[LbrPlutusV1.Credential]).toData(
branchy,
);

console.log("toData:");
console.log(branchypd);

console.log(
`Prelude.Json: ${
Prelude.stringify(
LbrPrelude.Json[MySchema.Branchy](LbrPrelude.Json[LbrPlutusV1.Credential])
.toJson(branchy),
)
}`,
);
console.log(
`Prelude.Json: ${
Prelude.stringify(LbrPrelude.Json[LbrPlutusV1.PlutusData].toJson(branchypd))
}`,
);

console.log("fromData:");
console.log(
LbrPlutusPd.IsPlutusData[MySchema.Branchy](
LbrPlutusPd.IsPlutusData[LbrPlutusV1.Credential],
).fromData(branchypd),
);

// Printing the Eq
console.log(
`branchy is branchy: ${
LbrPrelude.Eq[MySchema.Branchy](LbrPrelude.Eq[LbrPlutusV1.Credential]).eq(
branchy,
branchy,
)
}`,
);
console.log(
`branchy is not branchy: ${
LbrPrelude.Eq[MySchema.Branchy](LbrPrelude.Eq[LbrPlutusV1.Credential]).neq(
branchy,
branchy,
)
}`,
);
console.log(
`branchy is leaf: ${
LbrPrelude.Eq[MySchema.Branchy](LbrPrelude.Eq[LbrPlutusV1.Credential]).eq(
branchy,
leaf,
)
}`,
);
console.log(
`branchy is not leaf: ${
LbrPrelude.Eq[MySchema.Branchy](LbrPrelude.Eq[LbrPlutusV1.Credential]).neq(
branchy,
leaf,
)
}`,
);
Loading

0 comments on commit 4f6b0a9

Please sign in to comment.