Skip to content

Commit

Permalink
merkleization flow example
Browse files Browse the repository at this point in the history
  • Loading branch information
bjornkihlberg committed Dec 14, 2023
1 parent 6efc9d5 commit d29184f
Showing 1 changed file with 79 additions and 0 deletions.
79 changes: 79 additions & 0 deletions examples/merkleization-flow/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Merkleization Flow</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!-- This import map tells the browser what version of the SDK to use, the route is rewritten by the
local web server to point to the correct version -->
<script src="/importmap"></script>
</head>
<body>
<script type="module">
import { getRuntimeUrl } from "../js/poc-helpers.js";
import { mkRuntimeLifecycle } from "@marlowe.io/runtime-lifecycle/browser";
import { mkRestClient } from "@marlowe.io/runtime-rest-client";

const runtimeURL = getRuntimeUrl();
const walletName = "nami";

const restClient = mkRestClient(runtimeURL);
const runtimeLifeCycle = await mkRuntimeLifecycle({
runtimeURL,
walletName,
});

const contract_pt1_Label = "mycontractpart1";
const contract_pt2_Label = "mycontractpart2";
const contract_pt3_Label = "mycontractpart3";

const contract_pt1 = {
let: "x",
be: 5n,
then: { ref: contract_pt2_Label },
};
const contract_pt2 = {
let: "y",
be: { use_value: "x" },
then: { ref: contract_pt3_Label },
};

const contract_pt3 = { let: "z", be: { use_value: "y" }, then: "close" };

const runtimeGood = await restClient.healthcheck();
if (!runtimeGood) throw "Healthcheck failed!";

debugger;

const { contractSourceId, intermediateIds } =
await restClient.createContractSources(contract_pt1_Label, [
{ type: "contract", label: contract_pt1_Label, contract_pt1 },
{ type: "contract", label: contract_pt2_Label, contract_pt2 },
{ type: "contract", label: contract_pt3_Label, contract_pt3 },
]);

debugger;

const contract = await restClient.getContractSourceById({
contractSourceId,
});

debugger;

const { results: adjacencyResults } =
await restClient.getContractSourceAdjacency({
contractSourceId,
});

debugger;

const { results: closureResults } =
await restClient.getContractSourceClosure({
contractSourceId,
});

debugger;
</script>
</body>
</html>

0 comments on commit d29184f

Please sign in to comment.