chore: rename example parents folder to gift card

This commit is contained in:
rvcas
2023-03-11 22:45:25 -05:00
committed by Lucas
parent a522cd1e7d
commit 0147af8330
21 changed files with 0 additions and 0 deletions

13
examples/gift_card/.gitignore vendored Normal file
View File

@@ -0,0 +1,13 @@
# Aiken compilation artifacts
artifacts/
# Aiken's project working directory
build/
# Aiken's default documentation export
docs/
# generated by deno fresh
.vscode/
vendor/
static/cardano_message_signing_bg.wasm
static/cardano_multiplatform_lib_bg.wasm

View File

@@ -0,0 +1,16 @@
# fresh project
### Usage
Start the project:
```
deno task start
```
This will watch the project directory and restart as necessary.
### Important
There is some very hacky things that need to be done to make lucid work correctly.
It involved vendoring lucid and making some adjustments to the `core/core.ts` file.

View File

@@ -0,0 +1,13 @@
# This file was generated by Aiken
# You typically do not need to edit this file
[[requirements]]
name = "aiken-lang/stdlib"
version = "main"
source = "github"
[[packages]]
name = "aiken-lang/stdlib"
version = "main"
requirements = []
source = "github"

View File

@@ -0,0 +1,14 @@
name = 'aiken-lang/gift_card'
version = '0.0.0'
license = 'Apache-2.0'
description = "Create a gift card that can be used to redeem locked assets"
[repository]
user = 'aiken-lang'
project = 'gift_card'
platform = 'github'
[[dependencies]]
name = 'aiken-lang/stdlib'
version = 'main'
source = 'github'

View File

@@ -0,0 +1,28 @@
export type Preamble = {
title: string;
description?: string;
version: string;
plutusVersion: string;
license?: string;
};
export type Argument = {
title?: string;
description?: string;
// schema: Record<string, unknown>;
};
export type Validator = {
title: string;
description?: string;
datum?: Argument;
redeemer: Argument;
parameters?: Argument[];
compiledCode: string;
hash: string;
};
export type Blueprint = {
preamble: Preamble;
validators: Validator[];
};

View File

@@ -0,0 +1,12 @@
import { JSX } from "preact";
import { IS_BROWSER } from "$fresh/runtime.ts";
export function Button(props: JSX.HTMLAttributes<HTMLButtonElement>) {
return (
<button
{...props}
disabled={!IS_BROWSER || props.disabled}
class={`group inline-flex items-center justify-center rounded-full py-2 px-4 text-sm font-semibold focus:outline-none bg-blue-600 text-white hover:bg-blue-500 active:bg-blue-800 active:text-blue-100 ${props.class}`}
/>
);
}

View File

@@ -0,0 +1,21 @@
import { ComponentChild, JSX } from "preact";
export function Input(
{ children, id, ...props }: JSX.HTMLAttributes<HTMLInputElement>,
) {
return (
<div>
<label
for={id}
class="block mb-3 text-sm font-medium text-gray-700"
>
{children}
</label>
<input
{...props}
id={id}
class="block w-full appearance-none rounded-md border border-gray-200 bg-gray-50 px-3 py-2 text-gray-900 placeholder-gray-400 focus:border-blue-500 focus:bg-white focus:outline-none focus:ring-blue-500 sm:text-sm"
/>
</div>
);
}

View File

@@ -0,0 +1,10 @@
{
"tasks": {
"start": "deno run -A --watch=static/,routes/ dev.ts"
},
"importMap": "./import_map.json",
"compilerOptions": {
"jsx": "react-jsx",
"jsxImportSource": "preact"
}
}

300
examples/gift_card/deno.lock generated Normal file
View File

@@ -0,0 +1,300 @@
{
"version": "2",
"remote": {
"https://deno.land/std@0.100.0/encoding/hex.ts": "f952e0727bddb3b2fd2e6889d104eacbd62e92091f540ebd6459317a61932d9b",
"https://deno.land/std@0.140.0/_util/assert.ts": "e94f2eb37cebd7f199952e242c77654e43333c1ac4c5c700e929ea3aa5489f74",
"https://deno.land/std@0.140.0/_util/os.ts": "3b4c6e27febd119d36a416d7a97bd3b0251b77c88942c8f16ee5953ea13e2e49",
"https://deno.land/std@0.140.0/fs/_util.ts": "0fb24eb4bfebc2c194fb1afdb42b9c3dda12e368f43e8f2321f84fc77d42cb0f",
"https://deno.land/std@0.140.0/fs/ensure_dir.ts": "9dc109c27df4098b9fc12d949612ae5c9c7169507660dcf9ad90631833209d9d",
"https://deno.land/std@0.140.0/fs/expand_glob.ts": "0c10130d67c9b02164b03df8e43c6d6defbf8e395cb69d09e84a8586e6d72ac3",
"https://deno.land/std@0.140.0/fs/walk.ts": "117403ccd21fd322febe56ba06053b1ad5064c802170f19b1ea43214088fe95f",
"https://deno.land/std@0.140.0/path/_constants.ts": "df1db3ffa6dd6d1252cc9617e5d72165cd2483df90e93833e13580687b6083c3",
"https://deno.land/std@0.140.0/path/_interface.ts": "ee3b431a336b80cf445441109d089b70d87d5e248f4f90ff906820889ecf8d09",
"https://deno.land/std@0.140.0/path/_util.ts": "c1e9686d0164e29f7d880b2158971d805b6e0efc3110d0b3e24e4b8af2190d2b",
"https://deno.land/std@0.140.0/path/common.ts": "bee563630abd2d97f99d83c96c2fa0cca7cee103e8cb4e7699ec4d5db7bd2633",
"https://deno.land/std@0.140.0/path/glob.ts": "cb5255638de1048973c3e69e420c77dc04f75755524cb3b2e160fe9277d939ee",
"https://deno.land/std@0.140.0/path/mod.ts": "d3e68d0abb393fb0bf94a6d07c46ec31dc755b544b13144dee931d8d5f06a52d",
"https://deno.land/std@0.140.0/path/posix.ts": "293cdaec3ecccec0a9cc2b534302dfe308adb6f10861fa183275d6695faace44",
"https://deno.land/std@0.140.0/path/separator.ts": "fe1816cb765a8068afb3e8f13ad272351c85cbc739af56dacfc7d93d710fe0f9",
"https://deno.land/std@0.140.0/path/win32.ts": "31811536855e19ba37a999cd8d1b62078235548d67902ece4aa6b814596dd757",
"https://deno.land/std@0.148.0/bytes/equals.ts": "3c3558c3ae85526f84510aa2b48ab2ad7bdd899e2e0f5b7a8ffc85acb3a6043a",
"https://deno.land/std@0.148.0/bytes/mod.ts": "763f97d33051cc3f28af1a688dfe2830841192a9fea0cbaa55f927b49d49d0bf",
"https://deno.land/std@0.150.0/_util/assert.ts": "e94f2eb37cebd7f199952e242c77654e43333c1ac4c5c700e929ea3aa5489f74",
"https://deno.land/std@0.150.0/_util/os.ts": "3b4c6e27febd119d36a416d7a97bd3b0251b77c88942c8f16ee5953ea13e2e49",
"https://deno.land/std@0.150.0/async/abortable.ts": "87aa7230be8360c24ad437212311c9e8d4328854baec27b4c7abb26e85515c06",
"https://deno.land/std@0.150.0/async/deadline.ts": "48ac998d7564969f3e6ec6b6f9bf0217ebd00239b1b2292feba61272d5dd58d0",
"https://deno.land/std@0.150.0/async/debounce.ts": "564273ef242bcfcda19a439132f940db8694173abffc159ea34f07d18fc42620",
"https://deno.land/std@0.150.0/async/deferred.ts": "bc18e28108252c9f67dfca2bbc4587c3cbf3aeb6e155f8c864ca8ecff992b98a",
"https://deno.land/std@0.150.0/async/delay.ts": "cbbdf1c87d1aed8edc7bae13592fb3e27e3106e0748f089c263390d4f49e5f6c",
"https://deno.land/std@0.150.0/async/mod.ts": "9852cd8ed897ab2d41a8fbee611d574e97898327db5c19d9d58e41126473f02c",
"https://deno.land/std@0.150.0/async/mux_async_iterator.ts": "5b4aca6781ad0f2e19ccdf1d1a1c092ccd3e00d52050d9c27c772658c8367256",
"https://deno.land/std@0.150.0/async/pool.ts": "ef9eb97b388543acbf0ac32647121e4dbe629236899586c4d4311a8770fbb239",
"https://deno.land/std@0.150.0/async/tee.ts": "bcfae0017ebb718cf4eef9e2420e8675d91cb1bcc0ed9b668681af6e6caad846",
"https://deno.land/std@0.150.0/flags/mod.ts": "594472736e24b2f2afd3451cf7ccd58a21706ce91006478a544fdfa056c69697",
"https://deno.land/std@0.150.0/fs/_util.ts": "2cf50bfb1081c2d5f2efec10ac19abbc2baf478e51cd1b057d0da2f30585b6ba",
"https://deno.land/std@0.150.0/fs/walk.ts": "6ce8d87fbaeda23383e979599ad27f3f94b3e5ff0c0cd976b5fc5c2aa0df7d92",
"https://deno.land/std@0.150.0/http/http_status.ts": "897575a7d6bc2b9123f6a38ecbc0f03d95a532c5d92029315dc9f508e12526b8",
"https://deno.land/std@0.150.0/http/server.ts": "0b0a9f3abfcfecead944b31ee9098a0c11a59b0495bf873ee200eb80e7441483",
"https://deno.land/std@0.150.0/media_types/_util.ts": "ce9b4fc4ba1c447dafab619055e20fd88236ca6bdd7834a21f98bd193c3fbfa1",
"https://deno.land/std@0.150.0/media_types/mod.ts": "2d4b6f32a087029272dc59e0a55ae3cc4d1b27b794ccf528e94b1925795b3118",
"https://deno.land/std@0.150.0/media_types/vendor/mime-db.v1.52.0.ts": "724cee25fa40f1a52d3937d6b4fbbfdd7791ff55e1b7ac08d9319d5632c7f5af",
"https://deno.land/std@0.150.0/path/_constants.ts": "df1db3ffa6dd6d1252cc9617e5d72165cd2483df90e93833e13580687b6083c3",
"https://deno.land/std@0.150.0/path/_interface.ts": "ee3b431a336b80cf445441109d089b70d87d5e248f4f90ff906820889ecf8d09",
"https://deno.land/std@0.150.0/path/_util.ts": "c1e9686d0164e29f7d880b2158971d805b6e0efc3110d0b3e24e4b8af2190d2b",
"https://deno.land/std@0.150.0/path/common.ts": "bee563630abd2d97f99d83c96c2fa0cca7cee103e8cb4e7699ec4d5db7bd2633",
"https://deno.land/std@0.150.0/path/glob.ts": "cb5255638de1048973c3e69e420c77dc04f75755524cb3b2e160fe9277d939ee",
"https://deno.land/std@0.150.0/path/mod.ts": "4945b430b759b0b3d98f2a278542cbcf95e0ad2bd8eaaed3c67322b306b2b346",
"https://deno.land/std@0.150.0/path/posix.ts": "c1f7afe274290ea0b51da07ee205653b2964bd74909a82deb07b69a6cc383aaa",
"https://deno.land/std@0.150.0/path/separator.ts": "fe1816cb765a8068afb3e8f13ad272351c85cbc739af56dacfc7d93d710fe0f9",
"https://deno.land/std@0.150.0/path/win32.ts": "bd7549042e37879c68ff2f8576a25950abbfca1d696d41d82c7bca0b7e6f452c",
"https://deno.land/std@0.150.0/semver/mod.ts": "4a5195fa81b4aede8875a386550a1119f01fb58d74aea899b2cfb136c05a7310",
"https://deno.land/std@0.152.0/async/abortable.ts": "87aa7230be8360c24ad437212311c9e8d4328854baec27b4c7abb26e85515c06",
"https://deno.land/std@0.152.0/async/deadline.ts": "48ac998d7564969f3e6ec6b6f9bf0217ebd00239b1b2292feba61272d5dd58d0",
"https://deno.land/std@0.152.0/async/debounce.ts": "564273ef242bcfcda19a439132f940db8694173abffc159ea34f07d18fc42620",
"https://deno.land/std@0.152.0/async/deferred.ts": "bc18e28108252c9f67dfca2bbc4587c3cbf3aeb6e155f8c864ca8ecff992b98a",
"https://deno.land/std@0.152.0/async/delay.ts": "cbbdf1c87d1aed8edc7bae13592fb3e27e3106e0748f089c263390d4f49e5f6c",
"https://deno.land/std@0.152.0/async/mod.ts": "dd0a8ed4f3984ffabe2fcca7c9f466b7932d57b1864ffee148a5d5388316db6b",
"https://deno.land/std@0.152.0/async/mux_async_iterator.ts": "5b4aca6781ad0f2e19ccdf1d1a1c092ccd3e00d52050d9c27c772658c8367256",
"https://deno.land/std@0.152.0/async/pool.ts": "ef9eb97b388543acbf0ac32647121e4dbe629236899586c4d4311a8770fbb239",
"https://deno.land/std@0.152.0/async/tee.ts": "bcfae0017ebb718cf4eef9e2420e8675d91cb1bcc0ed9b668681af6e6caad846",
"https://deno.land/std@0.152.0/http/server.ts": "0b0a9f3abfcfecead944b31ee9098a0c11a59b0495bf873ee200eb80e7441483",
"https://deno.land/std@0.153.0/hash/sha256.ts": "aa9479c260f41b72c639f36c3e4bc9319940b5d2e52fe793ebe3dc646d12832f",
"https://deno.land/x/code_block_writer@11.0.3/mod.ts": "2c3448060e47c9d08604c8f40dee34343f553f33edcdfebbf648442be33205e5",
"https://deno.land/x/code_block_writer@11.0.3/utils/string_utils.ts": "60cb4ec8bd335bf241ef785ccec51e809d576ff8e8d29da43d2273b69ce2a6ff",
"https://deno.land/x/denoflate@1.2.1/mod.ts": "f5628e44b80b3d80ed525afa2ba0f12408e3849db817d47a883b801f9ce69dd6",
"https://deno.land/x/denoflate@1.2.1/pkg/denoflate.js": "b9f9ad9457d3f12f28b1fb35c555f57443427f74decb403113d67364e4f2caf4",
"https://deno.land/x/denoflate@1.2.1/pkg/denoflate_bg.wasm.js": "d581956245407a2115a3d7e8d85a9641c032940a8e810acbd59ca86afd34d44d",
"https://deno.land/x/esbuild@v0.14.51/mod.d.ts": "c142324d0383c39de0d7660cd207a7f7f52c7198a13d7d3281c0d636a070f441",
"https://deno.land/x/esbuild@v0.14.51/mod.js": "7432566c71fac77637822dc230319c7392a2d2fef51204c9d12c956d7093c279",
"https://deno.land/x/esbuild@v0.14.51/wasm.d.ts": "c142324d0383c39de0d7660cd207a7f7f52c7198a13d7d3281c0d636a070f441",
"https://deno.land/x/esbuild@v0.14.51/wasm.js": "afc1b6927543b664af60ce452c4929e5dc2bb9a0f4ed47b446a6431847c7598e",
"https://deno.land/x/esbuild_deno_loader@0.5.2/deps.ts": "bf83c27b7787b2f245fa0bc0b99f5041aa949c000a81c016cfe828d06b476d37",
"https://deno.land/x/esbuild_deno_loader@0.5.2/mod.ts": "bc111a68f323dbdb6edec68dd558ab732b27866d2ef304708872d763387b65d7",
"https://deno.land/x/esbuild_deno_loader@0.5.2/src/deno.ts": "0e83ccabbe2b004389288e38df2031b79eb347df2d139fce9394d8e88a11f259",
"https://deno.land/x/esbuild_deno_loader@0.5.2/src/native_loader.ts": "343854a566cf510cf25144f7c09fc0c1097780a31830305142a075d12bb697ba",
"https://deno.land/x/esbuild_deno_loader@0.5.2/src/portable_loader.ts": "35b6c526eed8c2c781a3256b23c30aa7cce69c0ef1d583c15528663287ba18a3",
"https://deno.land/x/esbuild_deno_loader@0.5.2/src/shared.ts": "b64749cd8c0f6252a11498bd8758ef1220003e46b2c9b68e16da63fd7e92b13a",
"https://deno.land/x/fresh@1.1.4/dev.ts": "a66c7d64be35bcd6a8e12eec9c27ae335044c70363a241f2e36ee776db468622",
"https://deno.land/x/fresh@1.1.4/plugins/twind.ts": "c0570d6010e29ba24ee5f43b9d3f1fe735f7fac76d9a3e680c9896373d669876",
"https://deno.land/x/fresh@1.1.4/plugins/twind/shared.ts": "023e0ffcd66668753b5049edab0de46e6d66194fb6026c679034b9bbf04ad6f3",
"https://deno.land/x/fresh@1.1.4/runtime.ts": "b02ec1e2e32cf73a33d262b7c9dcab9468ce16cd89fd424196c71003698a4ab0",
"https://deno.land/x/fresh@1.1.4/server.ts": "f379c9aad24471a71e58fb887fa57e5cc27ad9df035987eb260541c78df38e84",
"https://deno.land/x/fresh@1.1.4/src/dev/deps.ts": "de5470828c17839c0b52c328e6709f3477740b9800deaf724d6569b64b1d3872",
"https://deno.land/x/fresh@1.1.4/src/dev/error.ts": "21a38d240c00279662e6adde41367f1da0ae7e2836d993f818ea94aabab53e7b",
"https://deno.land/x/fresh@1.1.4/src/dev/mod.ts": "f5836b2eccd0efd7c0a726a121f174a974daefc22058f759f07d4df56c46e978",
"https://deno.land/x/fresh@1.1.4/src/runtime/csp.ts": "9ee900e9b0b786057b1009da5976298c202d1b86d1f1e4d2510bde5f06530ac9",
"https://deno.land/x/fresh@1.1.4/src/runtime/head.ts": "0f9932874497ab6e57ed1ba01d549e843523df4a5d36ef97460e7a43e3132fdc",
"https://deno.land/x/fresh@1.1.4/src/runtime/utils.ts": "8320a874a44bdd5905c7d4b87a0e7a14a6c50a2ed133800e72ae57341e4d4faa",
"https://deno.land/x/fresh@1.1.4/src/server/bundle.ts": "7fb20c084948894b8eca90984ef92c3f6d12a194910ecb9adee21ace9f1607bb",
"https://deno.land/x/fresh@1.1.4/src/server/constants.ts": "ad10dda1bc20c25c2926f6a8cfd79ef4368d70b4b03a645f65c04b3fa7d93a8c",
"https://deno.land/x/fresh@1.1.4/src/server/context.ts": "2773bf0f9b170f888a3135df5646b2cd5492add072eeb8569e73eb3cfcad963e",
"https://deno.land/x/fresh@1.1.4/src/server/default_error_page.ts": "9a1a595a1a2b31c9b724b04db82b8af256285536db272658d831ac9ef1d3d448",
"https://deno.land/x/fresh@1.1.4/src/server/deps.ts": "1b467e4d00109356b06117a9f2e5a21a2b48353a0e573b25cdbbfe7e9cfccb34",
"https://deno.land/x/fresh@1.1.4/src/server/htmlescape.ts": "834ac7d0caa9fc38dffd9b8613fb47aeecd4f22d5d70c51d4b20a310c085835c",
"https://deno.land/x/fresh@1.1.4/src/server/mod.ts": "72d213444334dd2e94c757a0eee0fc486c0919399ea9184d07ad042f34edd00d",
"https://deno.land/x/fresh@1.1.4/src/server/render.ts": "6f50707bd1f6e33ed84bb71ae3b0996d202b953cefc4285f5356524c7b21f01f",
"https://deno.land/x/fresh@1.1.4/src/server/types.ts": "dde992ab4ee635df71a7fc96fe4cd85943c1a9286ea8eb586563d5f5ca154955",
"https://deno.land/x/importmap@0.2.1/_util.ts": "ada9a9618b537e6c0316c048a898352396c882b9f2de38aba18fd3f2950ede89",
"https://deno.land/x/importmap@0.2.1/mod.ts": "ae3d1cd7eabd18c01a4960d57db471126b020f23b37ef14e1359bbb949227ade",
"https://deno.land/x/lucid@0.9.3/mod.ts": "9473507398048cb24dbb37b3a220777106c69c28d573898648deb2bb84a7e131",
"https://deno.land/x/lucid@0.9.3/package.json": "c266e1f3b2e2ed4d43b1e5dfdb83707c248c1063a9460482528f1b928bdd5188",
"https://deno.land/x/lucid@0.9.3/src/core/core.ts": "3455a13022e89d54550c31f6177f45d218f0a1d10968171a9ac03b6b3e53a1e3",
"https://deno.land/x/lucid@0.9.3/src/core/mod.ts": "978b94101791fdad3113e5a9fa3813b1f48a8e505f68da14bcad72668b294926",
"https://deno.land/x/lucid@0.9.3/src/core/wasm_modules/cardano_message_signing_nodejs/cardano_message_signing.js": "747800f2a5aef81567ecedcbcd34ee1bcd44af22d99ec5701c3b971599aeb548",
"https://deno.land/x/lucid@0.9.3/src/core/wasm_modules/cardano_message_signing_web/cardano_message_signing.js": "fca45ded85b3db2e5951ddd5a09c304b126db8c9384c731922aacbce260f973b",
"https://deno.land/x/lucid@0.9.3/src/core/wasm_modules/cardano_multiplatform_lib_nodejs/cardano_multiplatform_lib.js": "14e966291b6f4908a9d4c54525847beb163bd60f241fde47400dfa00cf7df298",
"https://deno.land/x/lucid@0.9.3/src/core/wasm_modules/cardano_multiplatform_lib_web/cardano_multiplatform_lib.js": "62b5646630d2ca5820e5064b624697992f7f873314d3560a58b2cbfe59724ca0",
"https://deno.land/x/lucid@0.9.3/src/lucid/lucid.ts": "f718cd5c8fb16fb042e593f6309485ea559cb60b87f2a1ca01daf6f8e1eb196e",
"https://deno.land/x/lucid@0.9.3/src/lucid/message.ts": "b16bb7c06cbc81c777ac116d95db32959af42bc093ebe86b65f2dbc28b75f9b2",
"https://deno.land/x/lucid@0.9.3/src/lucid/mod.ts": "94bfe48ee683e932a67347786a1253a2e7277e53b1dc192d045d70bc5ce9bc10",
"https://deno.land/x/lucid@0.9.3/src/lucid/tx.ts": "1536bd191c72a3f72b07ba69aa82b8de219215d042313273e896e6c6919a5ad0",
"https://deno.land/x/lucid@0.9.3/src/lucid/tx_complete.ts": "7dad2313ee35a19152b9717025cc9e3f71c6db63518c59318f5f42cce6fd3787",
"https://deno.land/x/lucid@0.9.3/src/lucid/tx_signed.ts": "42f6f5f09844f8cf6dc2381935f9edfa54a019fa48530a64af281571ae84abb9",
"https://deno.land/x/lucid@0.9.3/src/misc/bip39.ts": "7dc0f49f96d43a254a048a956cac31ef8c8045f69f3b8dbc5350bc6c601441eb",
"https://deno.land/x/lucid@0.9.3/src/misc/crc8.ts": "c9abda52851d5c575f6a8714c3600d2e63bb8cfc942e035486b1ab03b780e2f9",
"https://deno.land/x/lucid@0.9.3/src/misc/sign_data.ts": "6f5066d19455ade77615b5cbbf5dd9947ea691a7b764f96c81ba911cc84183e5",
"https://deno.land/x/lucid@0.9.3/src/misc/wallet.ts": "b03ed0282141a4a7a76faad019337ab69be2e7b728c049b0bdc03c9d1f709b65",
"https://deno.land/x/lucid@0.9.3/src/mod.ts": "f4156883dc0dc394e9fd9e9e7222537a61ff8b2781a88761d7bcb65123a16bcf",
"https://deno.land/x/lucid@0.9.3/src/plutus/data.ts": "63da0823211a5980664a0fe147f9af69f18c34f60732e36ddf915b6d896b7325",
"https://deno.land/x/lucid@0.9.3/src/plutus/mod.ts": "3a7f784e950348d447cd6bcb27546b20902fae167e04fd42e67bfad57216e1a7",
"https://deno.land/x/lucid@0.9.3/src/plutus/time.ts": "f142f03f897a6e57625e8c0752bb73397818090871f3cff123ec64311590b6f9",
"https://deno.land/x/lucid@0.9.3/src/provider/blockfrost.ts": "0f86f28b5c44595dab6ffde02f62d5f79965c68e0269814ea8153f624fe2915c",
"https://deno.land/x/lucid@0.9.3/src/provider/emulator.ts": "ecd28f58dd834bc3d6e2d8a320127b94ce9f02240827e5d5f39512e7b0233b32",
"https://deno.land/x/lucid@0.9.3/src/provider/kupmios.ts": "840adfb1e0cc91a94f6a8c98889839385c75701285dd5e4f47bf2013ad71fa68",
"https://deno.land/x/lucid@0.9.3/src/provider/mod.ts": "cb3a5afd289694687aa9e021aadbeadfc47f20ee1075ddb518039bfe31c88afa",
"https://deno.land/x/lucid@0.9.3/src/types/global.ts": "3ea23ebcf9af819a01cbcf682856df2b178929ffec362113d24eb4a80a966ac3",
"https://deno.land/x/lucid@0.9.3/src/types/mod.ts": "2e6e4ffd7077025d1b45af726756455fc9c915666dd7f23a041be058039b49c6",
"https://deno.land/x/lucid@0.9.3/src/types/types.ts": "2aebe4b52215b2ca7f5ff7456c3924a079969beb8293dc8b16bbf78e6dc0ec71",
"https://deno.land/x/lucid@0.9.3/src/utils/cost_model.ts": "b49fdd767144b1cef74ff404dbd78d14cc5ff0906566fa1bb63ac813e8d6fdad",
"https://deno.land/x/lucid@0.9.3/src/utils/merkle_tree.ts": "af39a9167eb8b083a19a980916c95ab40332e959ef20bc43fdfef69eef08e594",
"https://deno.land/x/lucid@0.9.3/src/utils/mod.ts": "7e405bfa0db96d9e995e67fb77251e8465843addf141caf4ce64b3efa6077822",
"https://deno.land/x/lucid@0.9.3/src/utils/utils.ts": "176ef591fdb2403a51e82e29c2d1c530733edcb97dfa69027dddd1931cb0573c",
"https://deno.land/x/lucid@0.9.4/mod.ts": "9473507398048cb24dbb37b3a220777106c69c28d573898648deb2bb84a7e131",
"https://deno.land/x/lucid@0.9.4/package.json": "895bd79e7b5d00839bfcc25bca031a693d7c88c5dc2638f0e2ca6e9833ca2de1",
"https://deno.land/x/lucid@0.9.4/src/core/core.ts": "3455a13022e89d54550c31f6177f45d218f0a1d10968171a9ac03b6b3e53a1e3",
"https://deno.land/x/lucid@0.9.4/src/core/mod.ts": "978b94101791fdad3113e5a9fa3813b1f48a8e505f68da14bcad72668b294926",
"https://deno.land/x/lucid@0.9.4/src/core/wasm_modules/cardano_message_signing_nodejs/cardano_message_signing.js": "747800f2a5aef81567ecedcbcd34ee1bcd44af22d99ec5701c3b971599aeb548",
"https://deno.land/x/lucid@0.9.4/src/core/wasm_modules/cardano_message_signing_web/cardano_message_signing.js": "fca45ded85b3db2e5951ddd5a09c304b126db8c9384c731922aacbce260f973b",
"https://deno.land/x/lucid@0.9.4/src/core/wasm_modules/cardano_multiplatform_lib_nodejs/cardano_multiplatform_lib.js": "6edeecc382b729a11354f6c2d9bcec81d54266c81471d22c3097b76449f25057",
"https://deno.land/x/lucid@0.9.4/src/core/wasm_modules/cardano_multiplatform_lib_web/cardano_multiplatform_lib.js": "728839e5c2cbe4d5418422a571ca61c8a21a2822a8674f3bdaf791078f53c7f9",
"https://deno.land/x/lucid@0.9.4/src/lucid/lucid.ts": "f718cd5c8fb16fb042e593f6309485ea559cb60b87f2a1ca01daf6f8e1eb196e",
"https://deno.land/x/lucid@0.9.4/src/lucid/message.ts": "b16bb7c06cbc81c777ac116d95db32959af42bc093ebe86b65f2dbc28b75f9b2",
"https://deno.land/x/lucid@0.9.4/src/lucid/mod.ts": "94bfe48ee683e932a67347786a1253a2e7277e53b1dc192d045d70bc5ce9bc10",
"https://deno.land/x/lucid@0.9.4/src/lucid/tx.ts": "1536bd191c72a3f72b07ba69aa82b8de219215d042313273e896e6c6919a5ad0",
"https://deno.land/x/lucid@0.9.4/src/lucid/tx_complete.ts": "7dad2313ee35a19152b9717025cc9e3f71c6db63518c59318f5f42cce6fd3787",
"https://deno.land/x/lucid@0.9.4/src/lucid/tx_signed.ts": "42f6f5f09844f8cf6dc2381935f9edfa54a019fa48530a64af281571ae84abb9",
"https://deno.land/x/lucid@0.9.4/src/misc/bip39.ts": "7dc0f49f96d43a254a048a956cac31ef8c8045f69f3b8dbc5350bc6c601441eb",
"https://deno.land/x/lucid@0.9.4/src/misc/crc8.ts": "c9abda52851d5c575f6a8714c3600d2e63bb8cfc942e035486b1ab03b780e2f9",
"https://deno.land/x/lucid@0.9.4/src/misc/sign_data.ts": "6f5066d19455ade77615b5cbbf5dd9947ea691a7b764f96c81ba911cc84183e5",
"https://deno.land/x/lucid@0.9.4/src/misc/wallet.ts": "b03ed0282141a4a7a76faad019337ab69be2e7b728c049b0bdc03c9d1f709b65",
"https://deno.land/x/lucid@0.9.4/src/mod.ts": "f4156883dc0dc394e9fd9e9e7222537a61ff8b2781a88761d7bcb65123a16bcf",
"https://deno.land/x/lucid@0.9.4/src/plutus/data.ts": "63da0823211a5980664a0fe147f9af69f18c34f60732e36ddf915b6d896b7325",
"https://deno.land/x/lucid@0.9.4/src/plutus/mod.ts": "3a7f784e950348d447cd6bcb27546b20902fae167e04fd42e67bfad57216e1a7",
"https://deno.land/x/lucid@0.9.4/src/plutus/time.ts": "f142f03f897a6e57625e8c0752bb73397818090871f3cff123ec64311590b6f9",
"https://deno.land/x/lucid@0.9.4/src/provider/blockfrost.ts": "0f86f28b5c44595dab6ffde02f62d5f79965c68e0269814ea8153f624fe2915c",
"https://deno.land/x/lucid@0.9.4/src/provider/emulator.ts": "ecd28f58dd834bc3d6e2d8a320127b94ce9f02240827e5d5f39512e7b0233b32",
"https://deno.land/x/lucid@0.9.4/src/provider/kupmios.ts": "840adfb1e0cc91a94f6a8c98889839385c75701285dd5e4f47bf2013ad71fa68",
"https://deno.land/x/lucid@0.9.4/src/provider/mod.ts": "cb3a5afd289694687aa9e021aadbeadfc47f20ee1075ddb518039bfe31c88afa",
"https://deno.land/x/lucid@0.9.4/src/types/global.ts": "3ea23ebcf9af819a01cbcf682856df2b178929ffec362113d24eb4a80a966ac3",
"https://deno.land/x/lucid@0.9.4/src/types/mod.ts": "2e6e4ffd7077025d1b45af726756455fc9c915666dd7f23a041be058039b49c6",
"https://deno.land/x/lucid@0.9.4/src/types/types.ts": "2aebe4b52215b2ca7f5ff7456c3924a079969beb8293dc8b16bbf78e6dc0ec71",
"https://deno.land/x/lucid@0.9.4/src/utils/cost_model.ts": "b49fdd767144b1cef74ff404dbd78d14cc5ff0906566fa1bb63ac813e8d6fdad",
"https://deno.land/x/lucid@0.9.4/src/utils/merkle_tree.ts": "af39a9167eb8b083a19a980916c95ab40332e959ef20bc43fdfef69eef08e594",
"https://deno.land/x/lucid@0.9.4/src/utils/mod.ts": "7e405bfa0db96d9e995e67fb77251e8465843addf141caf4ce64b3efa6077822",
"https://deno.land/x/lucid@0.9.4/src/utils/utils.ts": "176ef591fdb2403a51e82e29c2d1c530733edcb97dfa69027dddd1931cb0573c",
"https://deno.land/x/rutt@0.0.14/mod.ts": "5027b8e8b12acca48b396a25aee74ad7ee94a25c24cda75571d7839cbd41113c",
"https://deno.land/x/ts_morph@16.0.0/common/DenoRuntime.ts": "537800e840d0994f9055164e11bf33eadf96419246af0d3c453793c3ae67bdb3",
"https://deno.land/x/ts_morph@16.0.0/common/mod.ts": "01985d2ee7da8d1caee318a9d07664774fbee4e31602bc2bb6bb62c3489555ed",
"https://deno.land/x/ts_morph@16.0.0/common/ts_morph_common.d.ts": "39f2ddefd4995e4344236c44c2bf296069149f45ef6f00440b56e7b32cb2b3bd",
"https://deno.land/x/ts_morph@16.0.0/common/ts_morph_common.js": "7d908bf4f416aa96de956dc11ecc83b585bed297e16418d496ca04a3481067e0",
"https://deno.land/x/ts_morph@16.0.0/common/typescript.d.ts": "df7dd83543f14081ca74918d5a80ff60f634f465746cf2aff8924b28bcc3b152",
"https://deno.land/x/ts_morph@16.0.0/common/typescript.js": "5c59651248a4c41b25fa7beee8e0d0d0fab5f439fa72d478e65abd8241aa533c",
"https://deno.land/x/ts_morph@16.0.0/mod.ts": "adba9b82f24865d15d2c78ef6074b9a7457011719056c9928c800f130a617c93",
"https://deno.land/x/ts_morph@16.0.0/ts_morph.d.ts": "38668b0e3780282a56a805425494490b0045d1928bd040c47a94095749dab8c3",
"https://deno.land/x/ts_morph@16.0.0/ts_morph.js": "9fc0f3d6a3997c2df023fabc4e529d2117d214ffd4fd04247ca2f56c4e9cd470",
"https://deno.land/x/typebox@0.25.13/src/typebox.ts": "9b20b62c0bf31f1a9128b6dc6dfd470a5d956a48f0b0ef0a1ccc4d794fb55dcc",
"https://esm.sh/*preact-render-to-string@5.2.4": "c7b78a1de01e18e40faf2588abd16be0319c309adaa55d4884e28daaf0263579",
"https://esm.sh/preact@10.11.0": "e888b244446037c56f1881173fb51d1f5fa7aae5599e6c5154619346a6a5094e",
"https://esm.sh/preact@10.11.0/hooks": "2b8ec155eb8b87501663f074acff1d55a9114fa7d88f0b39da06c940af1ff736",
"https://esm.sh/preact@10.11.0/jsx-runtime": "5c123264f19799ab243211132dded45f6d42d594b5c78dd585f947d07bf20eae",
"https://esm.sh/stable/preact@10.11.0/deno/hooks.js": "48b7674c1f0c2a0f8a0f758b786f5bc15ba0f7a4f3a356ecc783848f1e4a1c55",
"https://esm.sh/stable/preact@10.11.0/deno/jsx-runtime.js": "b5a8e96758c20b5dea05802c6f6962b8a95bfdbd476eb4ea51cf3234f6e09271",
"https://esm.sh/stable/preact@10.11.0/deno/preact.js": "071b515099e5dff2fe56768be62644e32fab702b194171357ccc4d7d1210144a",
"https://esm.sh/twind@0.16.17": "360ea3c611025dd14d33e4a8e939041a39eb3254c35ce6511476411a777cc637",
"https://esm.sh/twind@0.16.17/sheets": "52d9aae9684ce6657a9a6c3b5e308d24780f5e1608e937b4ff08168c98ac93bb",
"https://esm.sh/v107/csstype@3.1.1/index.d.ts": "1c29793071152b207c01ea1954e343be9a44d85234447b2b236acae9e709a383",
"https://esm.sh/v107/preact-render-to-string@5.2.4/X-ZS8q/deno/preact-render-to-string.js": "7651121e4bb5ef2a48f840dba3f0c13087293ca2eb825aa23ffea3a87bd463b3",
"https://esm.sh/v107/preact-render-to-string@5.2.4/X-ZS8q/src/index.d.ts": "b1d73703252c8570fdf2952475805f5808ba3511fefbd93a3e7bd8406de7dcd0",
"https://esm.sh/v107/preact@10.11.0/hooks/src/index.d.ts": "5c29febb624fc25d71cb0e125848c9b711e233337a08f7eacfade38fd4c14cc3",
"https://esm.sh/v107/preact@10.11.0/jsx-runtime/src/index.d.ts": "e153460ed2b3fe2ad8b93696ecd48fbf73cd628b0b0ea6692b71804a3af69dfd",
"https://esm.sh/v107/preact@10.11.0/src/index.d.ts": "1a5c331227be54be6515b0c92a469d352834fa413963ae84a39a05a3177111f6",
"https://esm.sh/v107/preact@10.11.0/src/jsx.d.ts": "c423715fd7992b2e1446fea11d2d04e8adbd66c1edca1ce5e85f90e0d26a2eb2",
"https://esm.sh/v107/style-vendorizer@2.2.3/deno/style-vendorizer.js": "4823723c1cd5b34a60b4a1dfdf272a821d367fc472c23aeed6c3bcd7af5b7a7b",
"https://esm.sh/v107/twind@0.16.17/deno/sheets.js": "c504a460f5df2954f7334a821ef3ac9bedfc94dcc3f0dbf60af8d22f000391db",
"https://esm.sh/v107/twind@0.16.17/deno/twind.js": "e42bab2b3622f13f826150079ddc44d68af6aa17052a03497cebea80aea930ad",
"https://esm.sh/v107/twind@0.16.17/sheets/sheets.d.ts": "8c5392e418e291ad37417a757520ef4945c857460eda15cb57be4aedbb0024f2",
"https://esm.sh/v107/twind@0.16.17/twind.d.ts": "54763379010e8184469f76a76bf936221097fb930a49534ae00e2c41a948a70a"
},
"npm": {
"specifiers": {
"@peculiar/webcrypto@1.4.0": "@peculiar/webcrypto@1.4.0",
"node-fetch@3.2.3": "node-fetch@3.2.3",
"ws@8.10.0": "ws@8.10.0"
},
"packages": {
"@peculiar/asn1-schema@2.3.3": {
"integrity": "sha512-6GptMYDMyWBHTUKndHaDsRZUO/XMSgIns2krxcm2L7SEExRHwawFvSwNBhqNPR9HJwv3MruAiF1bhN0we6j6GQ==",
"dependencies": {
"asn1js": "asn1js@3.0.5",
"pvtsutils": "pvtsutils@1.3.2",
"tslib": "tslib@2.5.0"
}
},
"@peculiar/json-schema@1.1.12": {
"integrity": "sha512-coUfuoMeIB7B8/NMekxaDzLhaYmp0HZNPEjYRm9goRou8UZIC3z21s0sL9AWoCw4EG876QyO3kYrc61WNF9B/w==",
"dependencies": {
"tslib": "tslib@2.5.0"
}
},
"@peculiar/webcrypto@1.4.0": {
"integrity": "sha512-U58N44b2m3OuTgpmKgf0LPDOmP3bhwNz01vAnj1mBwxBASRhptWYK+M3zG+HBkDqGQM+bFsoIihTW8MdmPXEqg==",
"dependencies": {
"@peculiar/asn1-schema": "@peculiar/asn1-schema@2.3.3",
"@peculiar/json-schema": "@peculiar/json-schema@1.1.12",
"pvtsutils": "pvtsutils@1.3.2",
"tslib": "tslib@2.5.0",
"webcrypto-core": "webcrypto-core@1.7.6"
}
},
"asn1js@3.0.5": {
"integrity": "sha512-FVnvrKJwpt9LP2lAMl8qZswRNm3T4q9CON+bxldk2iwk3FFpuwhx2FfinyitizWHsVYyaY+y5JzDR0rCMV5yTQ==",
"dependencies": {
"pvtsutils": "pvtsutils@1.3.2",
"pvutils": "pvutils@1.1.3",
"tslib": "tslib@2.5.0"
}
},
"data-uri-to-buffer@4.0.1": {
"integrity": "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==",
"dependencies": {}
},
"fetch-blob@3.2.0": {
"integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==",
"dependencies": {
"node-domexception": "node-domexception@1.0.0",
"web-streams-polyfill": "web-streams-polyfill@3.2.1"
}
},
"formdata-polyfill@4.0.10": {
"integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==",
"dependencies": {
"fetch-blob": "fetch-blob@3.2.0"
}
},
"node-domexception@1.0.0": {
"integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==",
"dependencies": {}
},
"node-fetch@3.2.3": {
"integrity": "sha512-AXP18u4pidSZ1xYXRDPY/8jdv3RAozIt/WLNR/MBGZAz+xjtlr90RvCnsvHQRiXyWliZF/CpytExp32UU67/SA==",
"dependencies": {
"data-uri-to-buffer": "data-uri-to-buffer@4.0.1",
"fetch-blob": "fetch-blob@3.2.0",
"formdata-polyfill": "formdata-polyfill@4.0.10"
}
},
"pvtsutils@1.3.2": {
"integrity": "sha512-+Ipe2iNUyrZz+8K/2IOo+kKikdtfhRKzNpQbruF2URmqPtoqAs8g3xS7TJvFF2GcPXjh7DkqMnpVveRFq4PgEQ==",
"dependencies": {
"tslib": "tslib@2.5.0"
}
},
"pvutils@1.1.3": {
"integrity": "sha512-pMpnA0qRdFp32b1sJl1wOJNxZLQ2cbQx+k6tjNtZ8CpvVhNqEPRgivZ2WOUev2YMajecdH7ctUPDvEe87nariQ==",
"dependencies": {}
},
"tslib@2.5.0": {
"integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==",
"dependencies": {}
},
"web-streams-polyfill@3.2.1": {
"integrity": "sha512-e0MO3wdXWKrLbL0DgGnUV7WHVuw9OUvL4hjgnPkIeEvESk74gAITi5G606JtZPp39cd8HA9VQzCIvA49LpPN5Q==",
"dependencies": {}
},
"webcrypto-core@1.7.6": {
"integrity": "sha512-TBPiewB4Buw+HI3EQW+Bexm19/W4cP/qZG/02QJCXN+iN+T5sl074vZ3rJcle/ZtDBQSgjkbsQO/1eFcxnSBUA==",
"dependencies": {
"@peculiar/asn1-schema": "@peculiar/asn1-schema@2.3.3",
"@peculiar/json-schema": "@peculiar/json-schema@1.1.12",
"asn1js": "asn1js@3.0.5",
"pvtsutils": "pvtsutils@1.3.2",
"tslib": "tslib@2.5.0"
}
},
"ws@8.10.0": {
"integrity": "sha512-+s49uSmZpvtAsd2h37vIPy1RBusaLawVe8of+GyEPsaJTCMpj/2v8NpeK1SHXjBlQ95lQTmQofOJnFiLoaN3yw==",
"dependencies": {}
}
}
}
}

5
examples/gift_card/dev.ts Executable file
View File

@@ -0,0 +1,5 @@
#!/usr/bin/env -S deno run -A --watch=static/,routes/
import dev from "$fresh/dev.ts";
await dev(import.meta.url, "./main.ts");

View File

@@ -0,0 +1,20 @@
// DO NOT EDIT. This file is generated by fresh.
// This file SHOULD be checked into source version control.
// This file is automatically updated during development when running `dev.ts`.
import config from "./deno.json" assert { type: "json" };
import * as $0 from "./routes/index.tsx";
import * as $$0 from "./islands/App.tsx";
const manifest = {
routes: {
"./routes/index.tsx": $0,
},
islands: {
"./islands/App.tsx": $$0,
},
baseUrl: import.meta.url,
config,
};
export default manifest;

View File

@@ -0,0 +1,13 @@
{
"imports": {
"$fresh/": "https://deno.land/x/fresh@1.1.4/",
"preact": "https://esm.sh/preact@10.11.0",
"preact/": "https://esm.sh/preact@10.11.0/",
"preact-render-to-string": "https://esm.sh/*preact-render-to-string@5.2.4",
"@preact/signals": "https://esm.sh/*@preact/signals@1.0.3",
"@preact/signals-core": "https://esm.sh/*@preact/signals-core@1.0.1",
"twind": "https://esm.sh/twind@0.16.17",
"twind/": "https://esm.sh/twind@0.16.17/",
"~/": "./"
}
}

View File

@@ -0,0 +1,316 @@
import { useEffect, useState } from "preact/hooks";
import {
Blockfrost,
Constr,
Data,
fromText,
Lucid,
} from "~/vendor/lucid@0.9.4/mod.ts";
import { Input } from "~/components/Input.tsx";
import { Button } from "~/components/Button.tsx";
import {
AppliedValidators,
applyParams,
LocalCache,
Validators,
} from "~/utils.ts";
export interface AppProps {
validators: Validators;
}
export default function App({ validators }: AppProps) {
const [lucid, setLucid] = useState<Lucid | null>(null);
const [tokenName, setTokenName] = useState<string>("");
const [giftADA, setGiftADA] = useState<string | undefined>();
const [lockTxHash, setLockTxHash] = useState<string | undefined>(undefined);
const [waitingLockTx, setWaitingLockTx] = useState<boolean>(false);
const [unlockTxHash, setUnlockTxHash] = useState<string | undefined>(
undefined,
);
const [waitingUnlockTx, setWaitingUnlockTx] = useState<boolean>(false);
const [parameterizedContracts, setParameterizedContracts] = useState<
AppliedValidators | null
>(null);
const setupLucid = async (blockfrostApiKey: string) => {
const lucid = await Lucid.new(
new Blockfrost(
"https://cardano-mainnet.blockfrost.io/api/v0",
blockfrostApiKey,
),
"Mainnet",
);
const cache = localStorage.getItem("cache");
if (cache) {
const {
tokenName,
giftADA,
parameterizedValidators,
lockTxHash,
}: LocalCache = JSON.parse(cache);
setTokenName(tokenName);
setGiftADA(giftADA);
setParameterizedContracts(parameterizedValidators);
setLockTxHash(lockTxHash);
}
setLucid(lucid);
};
useEffect(() => {
if (lucid) {
window.cardano
.eternl
.enable()
.then((wallet) => {
lucid.selectWallet(wallet);
});
}
}, [lucid]);
const submitTokenName = async (e: Event) => {
e.preventDefault();
const utxos = await lucid?.wallet.getUtxos()!;
const utxo = utxos[0];
const outputReference = {
txHash: utxo.txHash,
outputIndex: utxo.outputIndex,
};
const contracts = applyParams(
tokenName,
outputReference,
validators,
lucid!,
);
setParameterizedContracts(contracts);
};
const createGiftCard = async (e: Event) => {
e.preventDefault();
setWaitingLockTx(true);
try {
const lovelace = Number(giftADA) * 1000000;
const assetName = `${parameterizedContracts!.policyId}${
fromText(tokenName)
}`;
// Action::Mint
const mintRedeemer = Data.to(new Constr(0, []));
const utxos = await lucid?.wallet.getUtxos()!;
const utxo = utxos[0];
const tx = await lucid!
.newTx()
.collectFrom([utxo])
.attachMintingPolicy(parameterizedContracts!.giftCard)
.mintAssets(
{ [assetName]: BigInt(1) },
mintRedeemer,
)
.payToContract(
parameterizedContracts!.lockAddress,
{ inline: Data.void() },
{ "lovelace": BigInt(lovelace) },
)
.complete();
const txSigned = await tx.sign().complete();
const txHash = await txSigned.submit();
const success = await lucid!.awaitTx(txHash);
// Wait a little bit longer so ExhuastedUTxOError doesn't happen
// in the next Tx
setTimeout(() => {
setWaitingLockTx(false);
if (success) {
localStorage.setItem(
"cache",
JSON.stringify({
tokenName,
giftADA,
parameterizedValidators: parameterizedContracts,
lockTxHash: txHash,
}),
);
setLockTxHash(txHash);
}
}, 3000);
} catch {
setWaitingLockTx(false);
}
};
const redeemGiftCard = async (e: Event) => {
e.preventDefault();
setWaitingUnlockTx(true);
try {
const utxos = await lucid!.utxosAt(parameterizedContracts!.lockAddress);
const assetName = `${parameterizedContracts!.policyId}${
fromText(tokenName)
}`;
// Action::Burn
const burnRedeemer = Data.to(new Constr(1, []));
const tx = await lucid!
.newTx()
.collectFrom(utxos, Data.void())
.attachMintingPolicy(parameterizedContracts!.giftCard)
.attachSpendingValidator(parameterizedContracts!.redeem)
.mintAssets(
{ [assetName]: BigInt(-1) },
burnRedeemer,
)
.complete();
const txSigned = await tx.sign().complete();
const txHash = await txSigned.submit();
const success = await lucid!.awaitTx(txHash);
setWaitingUnlockTx(false);
if (success) {
localStorage.removeItem("cache");
setUnlockTxHash(txHash);
}
} catch {
setWaitingUnlockTx(false);
}
};
return (
<div>
{!lucid
? (
<Input
type="password"
id="blockfrostApiKey"
onKeyDown={async (e) => {
if (e.key === "Enter") {
await setupLucid(e.currentTarget.value);
}
}}
>
Blockfrost API KEY (PRESS ENTER)
</Input>
)
: (
<form
class="mt-10 grid grid-cols-1 gap-y-8"
onSubmit={submitTokenName}
>
<Input
type="text"
name="tokenName"
id="tokenName"
value={tokenName}
onInput={(e) => setTokenName(e.currentTarget.value)}
>
Token Name
</Input>
{tokenName && (
<Button type="submit">
Make Contracts
</Button>
)}
</form>
)}
{lucid && parameterizedContracts && (
<>
<h3 class="mt-4 mb-2">Redeem</h3>
<pre class="bg-gray-200 p-2 rounded overflow-x-scroll">
{parameterizedContracts.redeem.script}
</pre>
<h3 class="mt-4 mb-2">Gift Card</h3>
<pre class="bg-gray-200 p-2 rounded overflow-x-scroll">
{parameterizedContracts.giftCard.script}
</pre>
<div class="mt-10 grid grid-cols-1 gap-y-8">
<Input
type="text"
name="giftADA"
id="giftADA"
value={giftADA}
onInput={(e) => setGiftADA(e.currentTarget.value)}
>
ADA Amount
</Input>
<Button
onClick={createGiftCard}
disabled={waitingLockTx || !!lockTxHash}
>
{waitingLockTx
? "Waiting for Tx..."
: "Create Gift Card (Locks ADA)"}
</Button>
{lockTxHash && (
<>
<h3 class="mt-4 mb-2">ADA Locked</h3>
<a
class="mb-2"
target="_blank"
href={`https://cardanoscan.io/transaction/${lockTxHash}`}
>
{lockTxHash}
</a>
<Button
onClick={redeemGiftCard}
disabled={waitingLockTx || !!unlockTxHash}
>
{waitingUnlockTx
? "Waiting for Tx..."
: "Redeem Gift Card (Unlocks ADA)"}
</Button>
</>
)}
{unlockTxHash && (
<>
<h3 class="mt-4 mb-2">ADA Unlocked</h3>
<a
class="mb-2"
target="_blank"
href={`https://cardanoscan.io/transaction/${unlockTxHash}`}
>
{unlockTxHash}
</a>
</>
)}
</div>
</>
)}
</div>
);
}

View File

@@ -0,0 +1,13 @@
/// <reference no-default-lib="true" />
/// <reference lib="dom" />
/// <reference lib="dom.iterable" />
/// <reference lib="dom.asynciterable" />
/// <reference lib="deno.ns" />
import { start } from "$fresh/server.ts";
import manifest from "~/fresh.gen.ts";
import twindPlugin from "$fresh/plugins/twind.ts";
import twindConfig from "~/twind.config.ts";
await start(manifest, { plugins: [twindPlugin(twindConfig)] });

View File

@@ -0,0 +1,124 @@
{
"preamble": {
"title": "aiken-lang/gift_card",
"description": "Create a gift card that can be used to redeem locked assets",
"version": "0.0.0",
"plutusVersion": "v2",
"license": "Apache-2.0"
},
"validators": [
{
"title": "main.gift_card",
"redeemer": {
"title": "Action",
"schema": {
"anyOf": [
{
"title": "Mint",
"dataType": "constructor",
"index": 0,
"fields": []
},
{
"title": "Burn",
"dataType": "constructor",
"index": 1,
"fields": []
}
]
}
},
"parameters": [
{
"title": "token_name",
"schema": {
"dataType": "bytes"
}
},
{
"title": "OutputReference",
"description": "An `OutputReference` is a unique reference to an output on-chain. The `output_index`\n corresponds to the position in the output list of the transaction (identified by its id)\n that produced that output",
"schema": {
"anyOf": [
{
"title": "OutputReference",
"dataType": "constructor",
"index": 0,
"fields": [
{
"title": "transaction_id",
"description": "A unique transaction identifier, as the hash of a transaction body. Note that the transaction id\n isn't a direct hash of the `Transaction` as visible on-chain. Rather, they correspond to hash\n digests of transaction body as they are serialized on the network.",
"anyOf": [
{
"title": "TransactionId",
"dataType": "constructor",
"index": 0,
"fields": [
{
"title": "hash",
"dataType": "bytes"
}
]
}
]
},
{
"title": "output_index",
"dataType": "integer"
}
]
}
]
}
}
],
"compiledCode": "59029b0100003232323232323232323232232222533300832323232323232323232323232323232533301d30200021323232533301b3370e0029000099299980e19b87003480084cdc780200c0a50301332533301c3370e9000180f9baa0011001153301e4912a4578706563746564206f6e20696e636f727265637420636f6e7374727563746f722076617269616e742e001632323300100d23375e6644646660020029000001911199981199b8700400202a23330040043370000690011816000800980b000a40000326002002444a666046004266e9520024bd700991929998101801801099ba548000cc0980092f5c0266600a00a002006604e006604a0042a66603666e1c008cdc0a40009001099b8f00301714a0603a6ea8050dd6980e8011bae301b001153301a491364c6973742f5475706c652f436f6e73747220636f6e7461696e73206d6f7265206974656d73207468616e2069742065787065637465640016301e00132320010013232332232332232533301e3370e00290010801099190009bab302600130160033020375400400297adef6c6033223300500200100200100300a3001001222533301e00213374a900125eb804c8c8c8c94ccc074cdc7802800899ba548000cc08cdd300125eb804ccc01c01c00c014dd7180f8019bab301f002302200330200023756603800260380026036002603400260320046eb0c05c004c01c014dd7180a8009802a99980699b8748000c040dd500088008a99807a492a4578706563746564206f6e20696e636f727265637420636f6e7374727563746f722076617269616e742e001630130013013002301100130010022300d37540022930b1bae0013001001222533300900214984cc014c004c02c008ccc00c00cc0300080055cd2b9b5738aae7555cf2ab9f5740ae855d101",
"hash": "9185bf20c9bbdd7062d9b2dc11a03290bfb256938395d56855baee81"
},
{
"title": "main.redeem",
"datum": {
"title": "Unit",
"description": "The nullary constructor.",
"schema": {
"anyOf": [
{
"dataType": "constructor",
"index": 0,
"fields": []
}
]
}
},
"redeemer": {
"title": "Unit",
"description": "The nullary constructor.",
"schema": {
"anyOf": [
{
"dataType": "constructor",
"index": 0,
"fields": []
}
]
}
},
"parameters": [
{
"title": "token_name",
"schema": {
"dataType": "bytes"
}
},
{
"title": "policy_id",
"schema": {
"dataType": "bytes"
}
}
],
"compiledCode": "5901980100003232323232323232323232232232222533300a323232323232323232323232533301b301e0021323253330183370e00266e052000480084cdc780100a0a50375a60360046eb8c06400454cc0612401364c6973742f5475706c652f436f6e73747220636f6e7461696e73206d6f7265206974656d73207468616e2069742065787065637465640016301c00132320010013232332232332232533301c3370e00290010801099190009bab30240013012003301e375400400297adef6c603322330050020010020010030103001001222533301c00213374a900125eb804c8c8c8c94ccc06ccdc7802800899ba548000cc084dd300125eb804ccc01c01c00c014dd7180e8019bab301d0023020003301e00237566034002603400260320026030002602e00260080026028002600400644646660020029000001911199980819b870040020172333004004337000069001180c800800918079baa001149858dd70009bae0013001001222533300900214984cc014c004c02c008ccc00c00cc0300080055cd2b9b5738aae7555cf2ab9f5740ae855d11",
"hash": "e1c247d17b275dc889a0437d23f7791a2ea60a6d1b84612572668ec2"
}
]
}

View File

@@ -0,0 +1,50 @@
import { Head } from "$fresh/runtime.ts";
import { Handlers, PageProps } from "$fresh/server.ts";
import App from "~/islands/App.tsx";
import { readValidators, Validators } from "~/utils.ts";
interface Data {
validators: Validators;
}
export const handler: Handlers<Data> = {
GET(_req, ctx) {
const validators = readValidators();
return ctx.render({ validators });
},
};
export default function Home({ data }: PageProps<Data>) {
const { validators } = data;
return (
<>
<Head>
<title>One Shot</title>
</Head>
<div class="max-w-2xl mx-auto mt-20 mb-10">
<div class="mb-10">
<h2 class="text-lg font-semibold text-gray-900">
Make a one shot minting and lock contract
</h2>
<h3 class="mt-4 mb-2">Redeem</h3>
<pre class="bg-gray-200 p-2 rounded overflow-x-scroll">
{validators.redeem.script}
</pre>
<h3 class="mt-4 mb-2">Gift Card</h3>
<pre class="bg-gray-200 p-2 rounded overflow-x-scroll">
{validators.giftCard.script}
</pre>
</div>
<App validators={validators} />
</div>
</>
);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View File

@@ -0,0 +1,6 @@
<svg width="40" height="40" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M34.092 8.845C38.929 20.652 34.092 27 30 30.5c1 3.5-2.986 4.222-4.5 2.5-4.457 1.537-13.512 1.487-20-5C2 24.5 4.73 16.714 14 11.5c8-4.5 16-7 20.092-2.655Z" fill="#FFDB1E"/>
<path d="M14 11.5c6.848-4.497 15.025-6.38 18.368-3.47C37.5 12.5 21.5 22.612 15.5 25c-6.5 2.587-3 8.5-6.5 8.5-3 0-2.5-4-5.183-7.75C2.232 23.535 6.16 16.648 14 11.5Z" fill="#fff" stroke="#FFDB1E"/>
<path d="M28.535 8.772c4.645 1.25-.365 5.695-4.303 8.536-3.732 2.692-6.606 4.21-7.923 4.83-.366.173-1.617-2.252-1.617-1 0 .417-.7 2.238-.934 2.326-1.365.512-4.223 1.29-5.835 1.29-3.491 0-1.923-4.754 3.014-9.122.892-.789 1.478-.645 2.283-.645-.537-.773-.534-.917.403-1.546C17.79 10.64 23 8.77 25.212 8.42c.366.014.82.35.82.629.41-.14 2.095-.388 2.503-.278Z" fill="#FFE600"/>
<path d="M14.297 16.49c.985-.747 1.644-1.01 2.099-2.526.566.121.841-.08 1.29-.701.324.466 1.657.608 2.453.701-.715.451-1.057.852-1.452 2.106-1.464-.611-3.167-.302-4.39.42Z" fill="#fff"/>
</svg>

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@@ -0,0 +1,5 @@
import { Options } from "$fresh/plugins/twind.ts";
export default {
selfURL: import.meta.url,
} as Options;

100
examples/gift_card/utils.ts Normal file
View File

@@ -0,0 +1,100 @@
import {
applyDoubleCborEncoding,
applyParamsToScript,
Constr,
fromText,
Lucid,
MintingPolicy,
OutRef,
SpendingValidator,
} from "~/vendor/lucid@0.9.4/mod.ts";
import { Blueprint } from "~/blueprint.ts";
import blueprint from "~/plutus.json" assert { type: "json" };
export type Validators = {
redeem: SpendingValidator;
giftCard: MintingPolicy;
};
export type LocalCache = {
tokenName: string;
giftADA: string;
lockTxHash: string;
parameterizedValidators: AppliedValidators;
};
export function readValidators(): Validators {
const redeem = (blueprint as Blueprint).validators.find((v) =>
v.title === "main.redeem"
);
if (!redeem) {
throw new Error("Redeem validator not found");
}
const giftCard = (blueprint as Blueprint).validators.find((v) =>
v.title === "main.gift_card"
);
if (!giftCard) {
throw new Error("Gift Card validator not found");
}
return {
redeem: {
type: "PlutusV2",
script: redeem.compiledCode,
},
giftCard: {
type: "PlutusV2",
script: giftCard.compiledCode,
},
};
}
export type AppliedValidators = {
redeem: SpendingValidator;
giftCard: MintingPolicy;
policyId: string;
lockAddress: string;
};
export function applyParams(
tokenName: string,
outputReference: OutRef,
validators: Validators,
lucid: Lucid,
): AppliedValidators {
const outRef = new Constr(0, [
new Constr(0, [outputReference.txHash]),
BigInt(outputReference.outputIndex),
]);
const giftCard = applyParamsToScript(validators.giftCard.script, [
fromText(tokenName),
outRef,
]);
const policyId = lucid.utils.validatorToScriptHash({
type: "PlutusV2",
script: giftCard,
});
const redeem = applyParamsToScript(validators.redeem.script, [
fromText(tokenName),
policyId,
]);
const lockAddress = lucid.utils.validatorToAddress({
type: "PlutusV2",
script: redeem,
});
return {
redeem: { type: "PlutusV2", script: applyDoubleCborEncoding(redeem) },
giftCard: { type: "PlutusV2", script: applyDoubleCborEncoding(giftCard) },
policyId,
lockAddress,
};
}

View File

@@ -0,0 +1,48 @@
use aiken/dict
use aiken/list
use aiken/transaction.{OutputReference, ScriptContext, Transaction} as tx
use aiken/transaction/value
type Action {
Mint
Burn
}
validator gift_card(token_name: ByteArray, utxo_ref: OutputReference) {
fn(rdmr: Action, ctx: ScriptContext) -> Bool {
let ScriptContext { transaction, purpose } = ctx
expect tx.Mint(policy_id) = purpose
let Transaction { inputs, mint, .. } = transaction
expect [(asset_name, amount)] =
mint
|> value.tokens(policy_id)
|> dict.to_list()
when rdmr is {
Mint -> {
expect Some(_input) =
list.find(inputs, fn(input) { input.output_reference == utxo_ref })
amount == 1 && asset_name == token_name
}
Burn -> amount == -1 && asset_name == token_name
}
}
}
validator redeem(token_name: ByteArray, policy_id: ByteArray) {
fn(_d: Void, _r: Void, ctx: ScriptContext) -> Bool {
let ScriptContext { transaction, .. } = ctx
let Transaction { mint, .. } = transaction
expect [(asset_name, amount)] =
mint
|> value.tokens(policy_id)
|> dict.to_list()
amount == -1 && asset_name == token_name
}
}