-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add some examples cases and move helper the utils from cardano-crafting
- Loading branch information
1 parent
ff09704
commit 791a0bf
Showing
41 changed files
with
5,564 additions
and
81,117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
/target | ||
.vscode | ||
**/*/node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const m = await import('npm:marlowe_lang@0.1.22-experimental1'); | ||
|
||
let redeemer = m.decode_marlowe_input_cbor_hex("9fd8799fd87a9fd8799f4763686f69636531d8799fd87980d8799fd8799f581c22584b09e116a2b98819723bbe6eb65d01e1edc225fc2a3e46884d58ffd8799fd8799fd8799f581cb1131cc98fc9ff8936a281874115fce0b73f99b40542172c8eb223b9ffffffffffff02ffffff") | ||
let datum = m.decode_cborhex_marlowe_plutus_datum ("d8799fd8799f40ffd8799fa1d8799fd8799fd87980d8799fd8799f581c22584b09e116a2b98819723bbe6eb65d01e1edc225fc2a3e46884d58ffd8799fd8799fd8799f581cb1131cc98fc9ff8936a281874115fce0b73f99b40542172c8eb223b9ffffffffffd8799f4040ffff1a002dc6c0a1d8799f4763686f69636531d8799fd87980d8799fd8799f581c22584b09e116a2b98819723bbe6eb65d01e1edc225fc2a3e46884d58ffd8799fd8799fd8799f581cb1131cc98fc9ff8936a281874115fce0b73f99b40542172c8eb223b9ffffffffffff02a01b0000018709761f88ffd87c9f9fd8799fd87a9fd8799f4763686f69636532d8799fd87980d8799fd8799f581c22584b09e116a2b98819723bbe6eb65d01e1edc225fc2a3e46884d58ffd8799fd8799fd8799f581cb1131cc98fc9ff8936a281874115fce0b73f99b40542172c8eb223b9ffffffffffff9fd8799f0304ffffffd87980ffff1b0000019ce9379560d87980ffff") | ||
|
||
let simpleMarloweDslContract = "Close" | ||
let json = m.marlowe_to_json(simpleMarloweDslContract) | ||
|
||
console.log("dsl_to_json_encoded_contract",json) | ||
console.log("Decoded redeemer",redeemer) | ||
console.log("Decoded datum",datum) | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"name": "deno", | ||
"version": "1.0.0", | ||
"description": "```bash\r deno run --allow-net --allow-read --allow-sys --allow-env .\\index.js\r ```", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"marlowe_lang": "^0.1.22-experimental1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
Basic example of how to use marlowe_lang in Deno. | ||
|
||
```bash | ||
deno run --allow-net --allow-read --allow-sys --allow-env .\index.js | ||
``` | ||
|
||
``` | ||
marlowe_lang utils initialized. | ||
dsl_to_json_encoded_contract "close" | ||
Decoded redeemer { | ||
"Ok": [ | ||
{ | ||
"for_choice_id": { | ||
"choice_owner": { | ||
"address": "addr_test1qq39sjcfuyt29wvgr9erh0nwkewsrc0dcgjlc237g6yy6k93zvwvnr7fl7yndg5psaq3tl8qkulendq9ggtjer4jywusugp3gf" | ||
}, | ||
"choice_name": "choice1" | ||
}, | ||
"input_that_chooses_num": 2 | ||
} | ||
] | ||
} | ||
Decoded datum { | ||
"marlowe_params": "", | ||
"state": { | ||
"accounts": [ | ||
[ | ||
[ | ||
{ | ||
"address": "addr_test1qq39sjcfuyt29wvgr9erh0nwkewsrc0dcgjlc237g6yy6k93zvwvnr7fl7yndg5psaq3tl8qkulendq9ggtjer4jywusugp3gf" | ||
}, | ||
{ | ||
"token_name": "", | ||
"currency_symbol": "" | ||
} | ||
], | ||
3000000 | ||
] | ||
], | ||
"choices": [ | ||
[ | ||
{ | ||
"choice_owner": { | ||
"address": "addr_test1qq39sjcfuyt29wvgr9erh0nwkewsrc0dcgjlc237g6yy6k93zvwvnr7fl7yndg5psaq3tl8qkulendq9ggtjer4jywusugp3gf" | ||
}, | ||
"choice_name": "choice1" | ||
}, | ||
2 | ||
] | ||
], | ||
"boundValues": [], | ||
"minTime": 1679490949000 | ||
}, | ||
"contract": { | ||
"when": [ | ||
{ | ||
"then": "close", | ||
"case": { | ||
"for_choice": { | ||
"choice_owner": { | ||
"address": "addr_test1qq39sjcfuyt29wvgr9erh0nwkewsrc0dcgjlc237g6yy6k93zvwvnr7fl7yndg5psaq3tl8qkulendq9ggtjer4jywusugp3gf" | ||
}, | ||
"choice_name": "choice2" | ||
}, | ||
"choose_between": [ | ||
{ | ||
"to": 4, | ||
"from": 3 | ||
} | ||
] | ||
} | ||
} | ||
], | ||
"timeout_continuation": "close", | ||
"timeout": 1773439260000 | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<html> | ||
<head> | ||
<meta content="text/html;charset=utf-8" http-equiv="Content-Type"/> | ||
</head> | ||
<body> | ||
<script type="module"> | ||
import init, { | ||
marlowe_to_json | ||
} from './path/to/marlowe_lang.js'; | ||
async function run() { | ||
await init(); | ||
let example = marlowe_to_json("Close") | ||
console.log("result",example) | ||
} | ||
run(); | ||
</script> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Basic example how how to load marlowe_lang in browsers. | ||
|
||
1. Use the build script for wasm_web | ||
2. Host the resulting pkg_web together with the index.html (update as needed) | ||
3. Profit? |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
const m = require('marlowe_lang'); | ||
|
||
let redeemer = m.decode_marlowe_input_cbor_hex("9fd8799fd87a9fd8799f4763686f69636531d8799fd87980d8799fd8799f581c22584b09e116a2b98819723bbe6eb65d01e1edc225fc2a3e46884d58ffd8799fd8799fd8799f581cb1131cc98fc9ff8936a281874115fce0b73f99b40542172c8eb223b9ffffffffffff02ffffff") | ||
let datum = m.decode_cborhex_marlowe_plutus_datum ("d8799fd8799f40ffd8799fa1d8799fd8799fd87980d8799fd8799f581c22584b09e116a2b98819723bbe6eb65d01e1edc225fc2a3e46884d58ffd8799fd8799fd8799f581cb1131cc98fc9ff8936a281874115fce0b73f99b40542172c8eb223b9ffffffffffd8799f4040ffff1a002dc6c0a1d8799f4763686f69636531d8799fd87980d8799fd8799f581c22584b09e116a2b98819723bbe6eb65d01e1edc225fc2a3e46884d58ffd8799fd8799fd8799f581cb1131cc98fc9ff8936a281874115fce0b73f99b40542172c8eb223b9ffffffffffff02a01b0000018709761f88ffd87c9f9fd8799fd87a9fd8799f4763686f69636532d8799fd87980d8799fd8799f581c22584b09e116a2b98819723bbe6eb65d01e1edc225fc2a3e46884d58ffd8799fd8799fd8799f581cb1131cc98fc9ff8936a281874115fce0b73f99b40542172c8eb223b9ffffffffffff9fd8799f0304ffffffd87980ffff1b0000019ce9379560d87980ffff") | ||
|
||
let simpleMarloweDslContract = "Close" | ||
let json = m.marlowe_to_json(simpleMarloweDslContract) | ||
|
||
console.log("dsl_to_json_encoded_contract",json) | ||
console.log("Decoded redeemer",redeemer) | ||
console.log("Decoded datum",datum) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
Basic example for using marlowe_lang in a basic nodejs application | ||
|
||
```bash | ||
npm install | ||
node .\index.js | ||
``` | ||
|
||
|
||
``` | ||
marlowe_lang utils initialized. | ||
dsl_to_json_encoded_contract "close" | ||
Decoded redeemer { | ||
"Ok": [ | ||
{ | ||
"for_choice_id": { | ||
"choice_owner": { | ||
"address": "addr_test1qq39sjcfuyt29wvgr9erh0nwkewsrc0dcgjlc237g6yy6k93zvwvnr7fl7yndg5psaq3tl8qkulendq9ggtjer4jywusugp3gf" | ||
}, | ||
"choice_name": "choice1" | ||
}, | ||
"input_that_chooses_num": 2 | ||
} | ||
] | ||
} | ||
Decoded datum { | ||
"marlowe_params": "", | ||
"state": { | ||
"accounts": [ | ||
[ | ||
[ | ||
{ | ||
"address": "addr_test1qq39sjcfuyt29wvgr9erh0nwkewsrc0dcgjlc237g6yy6k93zvwvnr7fl7yndg5psaq3tl8qkulendq9ggtjer4jywusugp3gf" | ||
}, | ||
{ | ||
"token_name": "", | ||
"currency_symbol": "" | ||
} | ||
], | ||
3000000 | ||
] | ||
], | ||
"choices": [ | ||
[ | ||
{ | ||
"choice_owner": { | ||
"address": "addr_test1qq39sjcfuyt29wvgr9erh0nwkewsrc0dcgjlc237g6yy6k93zvwvnr7fl7yndg5psaq3tl8qkulendq9ggtjer4jywusugp3gf" | ||
}, | ||
"choice_name": "choice1" | ||
}, | ||
2 | ||
] | ||
], | ||
"boundValues": [], | ||
"minTime": 1679490949000 | ||
}, | ||
"contract": { | ||
"when": [ | ||
{ | ||
"then": "close", | ||
"case": { | ||
"for_choice": { | ||
"choice_owner": { | ||
"address": "addr_test1qq39sjcfuyt29wvgr9erh0nwkewsrc0dcgjlc237g6yy6k93zvwvnr7fl7yndg5psaq3tl8qkulendq9ggtjer4jywusugp3gf" | ||
}, | ||
"choice_name": "choice2" | ||
}, | ||
"choose_between": [ | ||
{ | ||
"to": 4, | ||
"from": 3 | ||
} | ||
] | ||
} | ||
} | ||
], | ||
"timeout_continuation": "close", | ||
"timeout": 1773439260000 | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "next/core-web-vitals" | ||
} |
Oops, something went wrong.