init
This commit is contained in:
commit
76ac2964c7
|
@ -0,0 +1,14 @@
|
|||
# Serde
|
||||
|
||||
FIXME :: this subdir needs updating. There has been divergence.
|
||||
|
||||
This is a deno repo using lucid.
|
||||
|
||||
## Run
|
||||
|
||||
To run some examples, `deno run -A src/main.ts`.
|
||||
Inspect the file for details.
|
||||
|
||||
## TODO
|
||||
|
||||
- [ ] expose methods via ergonomic api
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"tasks": {
|
||||
},
|
||||
"lint": {
|
||||
"rules": {
|
||||
"tags": [
|
||||
"recommended"
|
||||
],
|
||||
"exclude": [
|
||||
"import-map-remap"
|
||||
]
|
||||
}
|
||||
},
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
{
|
||||
"version": "3",
|
||||
"remote": {
|
||||
"https://deno.land/std@0.100.0/encoding/hex.ts": "f952e0727bddb3b2fd2e6889d104eacbd62e92091f540ebd6459317a61932d9b",
|
||||
"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.153.0/hash/sha256.ts": "aa9479c260f41b72c639f36c3e4bc9319940b5d2e52fe793ebe3dc646d12832f",
|
||||
"https://deno.land/x/lucid@0.10.7/mod.ts": "9473507398048cb24dbb37b3a220777106c69c28d573898648deb2bb84a7e131",
|
||||
"https://deno.land/x/lucid@0.10.7/package.json": "402ef25f1bcbf29c57b24f4737637db8470dc9197e80478455ec132a7a08a0cc",
|
||||
"https://deno.land/x/lucid@0.10.7/src/core/core.ts": "5b2f6d4746933a425bfcb134a55b84c946bc2ddd98b795aa9189f345778b113c",
|
||||
"https://deno.land/x/lucid@0.10.7/src/core/libs/cardano_message_signing/cardano_message_signing.generated.js": "b3cae6f286d855a1cf9c84987026bfa46f577e9edd6b269127e88c0f41d68bfa",
|
||||
"https://deno.land/x/lucid@0.10.7/src/core/libs/cardano_multiplatform_lib/cardano_multiplatform_lib.generated.js": "286312109897e46032173ab3a0a233212ea0741051bcba936914ac7af8f22227",
|
||||
"https://deno.land/x/lucid@0.10.7/src/core/mod.ts": "978b94101791fdad3113e5a9fa3813b1f48a8e505f68da14bcad72668b294926",
|
||||
"https://deno.land/x/lucid@0.10.7/src/lucid/lucid.ts": "80f06b1965074a6c3504d509df676f2508d49cc0a8050dee1b1f8ea804fb565a",
|
||||
"https://deno.land/x/lucid@0.10.7/src/lucid/message.ts": "b16bb7c06cbc81c777ac116d95db32959af42bc093ebe86b65f2dbc28b75f9b2",
|
||||
"https://deno.land/x/lucid@0.10.7/src/lucid/mod.ts": "94bfe48ee683e932a67347786a1253a2e7277e53b1dc192d045d70bc5ce9bc10",
|
||||
"https://deno.land/x/lucid@0.10.7/src/lucid/tx.ts": "5833f0cb10bcd83439e7caff03c20296b8e646ce1d3797e9db56f3fdcfe33e19",
|
||||
"https://deno.land/x/lucid@0.10.7/src/lucid/tx_complete.ts": "a687e19df52072fe239af33081cfddf2fba40011324ff86f3352042940a65362",
|
||||
"https://deno.land/x/lucid@0.10.7/src/lucid/tx_signed.ts": "58edce3295e5fa14977120d887b43796ebd40893caaf012d441a8b56909c8ae1",
|
||||
"https://deno.land/x/lucid@0.10.7/src/misc/bip39.ts": "7dc0f49f96d43a254a048a956cac31ef8c8045f69f3b8dbc5350bc6c601441eb",
|
||||
"https://deno.land/x/lucid@0.10.7/src/misc/crc8.ts": "c9abda52851d5c575f6a8714c3600d2e63bb8cfc942e035486b1ab03b780e2f9",
|
||||
"https://deno.land/x/lucid@0.10.7/src/misc/sign_data.ts": "6f5066d19455ade77615b5cbbf5dd9947ea691a7b764f96c81ba911cc84183e5",
|
||||
"https://deno.land/x/lucid@0.10.7/src/misc/wallet.ts": "7a8d63c234f0741dc49d3134554b7c455e24f4692ba42a3843aad7e37bcc7d2b",
|
||||
"https://deno.land/x/lucid@0.10.7/src/mod.ts": "f4156883dc0dc394e9fd9e9e7222537a61ff8b2781a88761d7bcb65123a16bcf",
|
||||
"https://deno.land/x/lucid@0.10.7/src/plutus/data.ts": "b6eb205124e6f340f47dd789d94d91146b2bf038c6a76b57ede12874b60d5920",
|
||||
"https://deno.land/x/lucid@0.10.7/src/plutus/mod.ts": "3a7f784e950348d447cd6bcb27546b20902fae167e04fd42e67bfad57216e1a7",
|
||||
"https://deno.land/x/lucid@0.10.7/src/plutus/time.ts": "f142f03f897a6e57625e8c0752bb73397818090871f3cff123ec64311590b6f9",
|
||||
"https://deno.land/x/lucid@0.10.7/src/provider/blockfrost.ts": "7cd49ed72464f3faf3c4bc93b54a1c30dbe0f34035b3c5e844adfdeb3ca74e32",
|
||||
"https://deno.land/x/lucid@0.10.7/src/provider/emulator.ts": "066892a5dfbe27bde86d449650913da18da8025bd618c7cfed0a6fc16e07bb29",
|
||||
"https://deno.land/x/lucid@0.10.7/src/provider/kupmios.ts": "e15178e252d5a87b6c6123e51c3dc426ec7ebe02bac920dea26213f62eabcbd0",
|
||||
"https://deno.land/x/lucid@0.10.7/src/provider/maestro.ts": "76c379f946bdc2198ccf6898ce1b09ed5a6ddb1d858f0abe2b39e5300aa7a6c1",
|
||||
"https://deno.land/x/lucid@0.10.7/src/provider/mod.ts": "76b36094551556045e851fe0ba6012626e1a08c03dec62a21b69d22311266379",
|
||||
"https://deno.land/x/lucid@0.10.7/src/types/global.ts": "3ea23ebcf9af819a01cbcf682856df2b178929ffec362113d24eb4a80a966ac3",
|
||||
"https://deno.land/x/lucid@0.10.7/src/types/mod.ts": "2e6e4ffd7077025d1b45af726756455fc9c915666dd7f23a041be058039b49c6",
|
||||
"https://deno.land/x/lucid@0.10.7/src/types/types.ts": "b637a944c04576c42c2bb5df98aa8128cd4677e04fa0ec911e042ce96e764fa2",
|
||||
"https://deno.land/x/lucid@0.10.7/src/utils/cost_model.ts": "f04e4d393062b0057f703e37ddcb1aa9fe378b589134c679688f9786235a25ee",
|
||||
"https://deno.land/x/lucid@0.10.7/src/utils/merkle_tree.ts": "af39a9167eb8b083a19a980916c95ab40332e959ef20bc43fdfef69eef08e594",
|
||||
"https://deno.land/x/lucid@0.10.7/src/utils/mod.ts": "7e405bfa0db96d9e995e67fb77251e8465843addf141caf4ce64b3efa6077822",
|
||||
"https://deno.land/x/lucid@0.10.7/src/utils/utils.ts": "177ec0578b788f947f6afb6cc911c4eae776aaf98b5249412a750b8f366b4d11",
|
||||
"https://deno.land/x/typebox@0.25.13/src/typebox.ts": "9b20b62c0bf31f1a9128b6dc6dfd470a5d956a48f0b0ef0a1ccc4d794fb55dcc"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
export * as lucid from "https://deno.land/x/lucid@0.10.7/mod.ts";
|
||||
export * as cml from "https://deno.land/x/lucid@0.10.7/src/core/libs/cardano_multiplatform_lib/cardano_multiplatform_lib.generated.js";
|
|
@ -0,0 +1,259 @@
|
|||
import { lucid } from "../deps.ts";
|
||||
const { applyParamsToScript } = lucid;
|
||||
type Data = lucid.Data;
|
||||
type Validator = lucid.Validator;
|
||||
|
||||
export interface XContext {
|
||||
new (): Validator;
|
||||
_: { feedId: string; collectAfter: bigint; collector: string };
|
||||
}
|
||||
|
||||
export const XContext = Object.assign(
|
||||
function () {
|
||||
return {
|
||||
type: "PlutusV2",
|
||||
script:
|
||||
"585d010000323232323232232253330044a229309b2b299980119b8748000c00cdd50008991919191919299980598068010a4c2c6eb8c02c004c02c008dd6980480098048011bae3007001300437540022cae6955ceaab9e5573eae855d101",
|
||||
};
|
||||
},
|
||||
{
|
||||
_: {
|
||||
"title": "Context",
|
||||
"description": "Used by orcfax validator",
|
||||
"anyOf": [{
|
||||
"title": "Context",
|
||||
"dataType": "constructor",
|
||||
"index": 0,
|
||||
"fields": [{ "dataType": "bytes", "title": "feedId" }, {
|
||||
"dataType": "integer",
|
||||
"title": "collectAfter",
|
||||
}, { "dataType": "bytes", "title": "collector" }],
|
||||
}],
|
||||
},
|
||||
},
|
||||
) as unknown as XContext;
|
||||
|
||||
export interface XDatumData {
|
||||
new (): Validator;
|
||||
_: {
|
||||
statement: { feedId: string; createdAt: bigint; body: Data };
|
||||
context: { feedId: string; collectAfter: bigint; collector: string };
|
||||
};
|
||||
}
|
||||
|
||||
export const XDatumData = Object.assign(
|
||||
function () {
|
||||
return {
|
||||
type: "PlutusV2",
|
||||
script:
|
||||
"58c2010000323232323232232253330044a229309b2b299919801980098021baa002132323232533300a300c002132324994ccc020c018c024dd50010991919191919299980898098010a4c2c6eb8c044004c044008dd6980780098078011bae300d001300a37540042ca66600e600a60106ea800c4c8c8c8c8c8c94ccc040c0480085261630100013010002375a601c002601c0046eb8c030004c024dd50018b0b18050009805001180400098029baa002370e90000b2b9a5573aaae7955cfaba157441",
|
||||
};
|
||||
},
|
||||
{
|
||||
_: {
|
||||
"title": "Datum",
|
||||
"anyOf": [{
|
||||
"title": "Datum",
|
||||
"dataType": "constructor",
|
||||
"index": 0,
|
||||
"fields": [{
|
||||
"title": "statement",
|
||||
"description": "Used by consumers",
|
||||
"anyOf": [{
|
||||
"title": "Statement",
|
||||
"dataType": "constructor",
|
||||
"index": 0,
|
||||
"fields": [{ "dataType": "bytes", "title": "feedId" }, {
|
||||
"dataType": "integer",
|
||||
"title": "createdAt",
|
||||
}, { "title": "body", "description": "Any Plutus data." }],
|
||||
}],
|
||||
}, {
|
||||
"title": "context",
|
||||
"description": "Used by orcfax validator",
|
||||
"anyOf": [{
|
||||
"title": "Context",
|
||||
"dataType": "constructor",
|
||||
"index": 0,
|
||||
"fields": [{ "dataType": "bytes", "title": "feedId" }, {
|
||||
"dataType": "integer",
|
||||
"title": "collectAfter",
|
||||
}, { "dataType": "bytes", "title": "collector" }],
|
||||
}],
|
||||
}],
|
||||
}],
|
||||
},
|
||||
},
|
||||
) as unknown as XDatumData;
|
||||
|
||||
export interface XDatumPrice {
|
||||
new (): Validator;
|
||||
_: {
|
||||
statement: {
|
||||
feedId: string;
|
||||
createdAt: bigint;
|
||||
body: { num: bigint; denom: bigint };
|
||||
};
|
||||
context: { feedId: string; collectAfter: bigint; collector: string };
|
||||
};
|
||||
}
|
||||
|
||||
export const XDatumPrice = Object.assign(
|
||||
function () {
|
||||
return {
|
||||
type: "PlutusV2",
|
||||
script:
|
||||
"58f1010000323232323232232253330044a229309b2b299919801980098021baa002132323232533300a300c002132324994ccc020c018c024dd50010991919191919299980898098010a4c2c6eb8c044004c044008dd6980780098078011bae300d001300a37540042ca66600e600a60106ea800c4c8c8c8c8c8c94ccc040c0480084c926533300d300b300e3754002264646464a666028602c0042930b1bad30140013014002375a6024002601e6ea80045858c040004c040008dd6980700098070011bae300c001300937540062c2c601400260140046010002600a6ea8008dc3a40002cae6955ceaab9e5573eae855d101",
|
||||
};
|
||||
},
|
||||
{
|
||||
_: {
|
||||
"title": "Datum",
|
||||
"anyOf": [{
|
||||
"title": "Datum",
|
||||
"dataType": "constructor",
|
||||
"index": 0,
|
||||
"fields": [{
|
||||
"title": "statement",
|
||||
"description": "Used by consumers",
|
||||
"anyOf": [{
|
||||
"title": "Statement",
|
||||
"dataType": "constructor",
|
||||
"index": 0,
|
||||
"fields": [{ "dataType": "bytes", "title": "feedId" }, {
|
||||
"dataType": "integer",
|
||||
"title": "createdAt",
|
||||
}, {
|
||||
"title": "body",
|
||||
"anyOf": [{
|
||||
"title": "Price",
|
||||
"dataType": "constructor",
|
||||
"index": 0,
|
||||
"fields": [{ "dataType": "integer", "title": "num" }, {
|
||||
"dataType": "integer",
|
||||
"title": "denom",
|
||||
}],
|
||||
}],
|
||||
}],
|
||||
}],
|
||||
}, {
|
||||
"title": "context",
|
||||
"description": "Used by orcfax validator",
|
||||
"anyOf": [{
|
||||
"title": "Context",
|
||||
"dataType": "constructor",
|
||||
"index": 0,
|
||||
"fields": [{ "dataType": "bytes", "title": "feedId" }, {
|
||||
"dataType": "integer",
|
||||
"title": "collectAfter",
|
||||
}, { "dataType": "bytes", "title": "collector" }],
|
||||
}],
|
||||
}],
|
||||
}],
|
||||
},
|
||||
},
|
||||
) as unknown as XDatumPrice;
|
||||
|
||||
export interface XPrice {
|
||||
new (): Validator;
|
||||
_: { num: bigint; denom: bigint };
|
||||
}
|
||||
|
||||
export const XPrice = Object.assign(
|
||||
function () {
|
||||
return {
|
||||
type: "PlutusV2",
|
||||
script:
|
||||
"5852010000323232323232232253330044a229309b2b299980119b8748000c00cdd5000899191919299980498058010a4c2c6eb4c024004c024008dd6980380098021baa001165734aae7555cf2ab9f5742ae881",
|
||||
};
|
||||
},
|
||||
{
|
||||
_: {
|
||||
"title": "Price",
|
||||
"anyOf": [{
|
||||
"title": "Price",
|
||||
"dataType": "constructor",
|
||||
"index": 0,
|
||||
"fields": [{ "dataType": "integer", "title": "num" }, {
|
||||
"dataType": "integer",
|
||||
"title": "denom",
|
||||
}],
|
||||
}],
|
||||
},
|
||||
},
|
||||
) as unknown as XPrice;
|
||||
|
||||
export interface XStatementData {
|
||||
new (): Validator;
|
||||
_: { feedId: string; createdAt: bigint; body: Data };
|
||||
}
|
||||
|
||||
export const XStatementData = Object.assign(
|
||||
function () {
|
||||
return {
|
||||
type: "PlutusV2",
|
||||
script:
|
||||
"585b010000323232323232232253330044a229309b2b299980119b8748000c00cdd50008991919191919299980598068010a4c2c601600260160046eb4c024004c024008dd7180380098021baa001165734aae7555cf2ab9f5742ae881",
|
||||
};
|
||||
},
|
||||
{
|
||||
_: {
|
||||
"title": "Statement",
|
||||
"description": "Used by consumers",
|
||||
"anyOf": [{
|
||||
"title": "Statement",
|
||||
"dataType": "constructor",
|
||||
"index": 0,
|
||||
"fields": [{ "dataType": "bytes", "title": "feedId" }, {
|
||||
"dataType": "integer",
|
||||
"title": "createdAt",
|
||||
}, { "title": "body", "description": "Any Plutus data." }],
|
||||
}],
|
||||
},
|
||||
},
|
||||
) as unknown as XStatementData;
|
||||
|
||||
export interface XStatementPrice {
|
||||
new (): Validator;
|
||||
_: {
|
||||
feedId: string;
|
||||
createdAt: bigint;
|
||||
body: { num: bigint; denom: bigint };
|
||||
};
|
||||
}
|
||||
|
||||
export const XStatementPrice = Object.assign(
|
||||
function () {
|
||||
return {
|
||||
type: "PlutusV2",
|
||||
script:
|
||||
"588c010000323232323232232253330044a229309b2b299980119b8748000c00cdd500089919191919192999805980680109924ca66601066e1d200030093754002264646464a66601e60220042930b1bad300f001300f002375a601a00260146ea80045858c02c004c02c008dd6980480098048011bae3007001300437540022cae6955ceaab9e5573eae855d11",
|
||||
};
|
||||
},
|
||||
{
|
||||
_: {
|
||||
"title": "Statement",
|
||||
"description": "Used by consumers",
|
||||
"anyOf": [{
|
||||
"title": "Statement",
|
||||
"dataType": "constructor",
|
||||
"index": 0,
|
||||
"fields": [{ "dataType": "bytes", "title": "feedId" }, {
|
||||
"dataType": "integer",
|
||||
"title": "createdAt",
|
||||
}, {
|
||||
"title": "body",
|
||||
"anyOf": [{
|
||||
"title": "Price",
|
||||
"dataType": "constructor",
|
||||
"index": 0,
|
||||
"fields": [{ "dataType": "integer", "title": "num" }, {
|
||||
"dataType": "integer",
|
||||
"title": "denom",
|
||||
}],
|
||||
}],
|
||||
}],
|
||||
}],
|
||||
},
|
||||
},
|
||||
) as unknown as XStatementPrice;
|
|
@ -0,0 +1,47 @@
|
|||
import { lucid } from "../deps.ts";
|
||||
import * as serde from "./serde.ts"
|
||||
|
||||
BigInt.prototype.toJSON = function () {
|
||||
return this.toString();
|
||||
};
|
||||
|
||||
function main() {
|
||||
const x : serde.DatumPrice = {
|
||||
statement: {
|
||||
feedId: "70663a667433312d3e416461",
|
||||
createdAt: 1714074620000n,
|
||||
body: {
|
||||
num: 19n,
|
||||
denom: 20n,
|
||||
}
|
||||
},
|
||||
context: {
|
||||
feedId: "70663a667433312d3e416461",
|
||||
collectAfter: 1715774620000n,
|
||||
collector: "f5f75d2d010de90a8075285139542d99de12f51af319891d75d995b5"
|
||||
}
|
||||
}
|
||||
console.log(JSON.stringify(x, null, 2))
|
||||
console.log(serde.datumPriceToData(x))
|
||||
|
||||
const y : serde.DatumPrice = {
|
||||
statement : {
|
||||
feedId: lucid.fromText("feedID"),
|
||||
createdAt: 1713377742844n,
|
||||
body: { num: 122345n, denom: 6n },
|
||||
},
|
||||
context : {
|
||||
feedId: lucid.fromText("feedID"),
|
||||
collectAfter: 1713381462844n,
|
||||
collector: "61dcf39e073ddc8dd79c0428bf83939378717c34abc91c806a6908ad7c",
|
||||
}
|
||||
}
|
||||
console.log(JSON.stringify(y, null, 2))
|
||||
console.log(serde.datumPriceToData(y))
|
||||
|
||||
const z = "D87982D879834C70663A667433392D3E4164611B0000018F30CEB420D8798219A941C25102F050FE938943ACC45F65568000000000D879834C70663A667433392D3E4164611B0000018F529ECD11581CF5F75D2D010DE90A8075285139542D99DE12F51AF319891D75D995B5"
|
||||
console.log(JSON.stringify(serde.datumPricefromData(z), null , 2))
|
||||
|
||||
}
|
||||
|
||||
if (import.meta.main) main()
|
|
@ -0,0 +1,68 @@
|
|||
import { lucid } from "../deps.ts";
|
||||
import * as bp from "./blueprint.ts";
|
||||
|
||||
export type Context = bp.XContext["_"]
|
||||
export const Context = bp.XContext["_"]
|
||||
|
||||
export function contextToData(x: Context): string {
|
||||
return lucid.Data.to<Context>(x, Context);
|
||||
}
|
||||
|
||||
export function contextfromData(x: string): Context {
|
||||
return lucid.Data.from<Context>(x, Context);
|
||||
}
|
||||
|
||||
export type StatementData = bp.XStatementData["_"]
|
||||
export const StatementData = bp.XStatementData["_"]
|
||||
|
||||
export function statementDataToData(x: StatementData): string {
|
||||
return lucid.Data.to<StatementData>(x, StatementData);
|
||||
}
|
||||
|
||||
export function statementDatafromData(x: string): StatementData {
|
||||
return lucid.Data.from<StatementData>(x, StatementData);
|
||||
}
|
||||
|
||||
export type DatumData = bp.XDatumData["_"]
|
||||
export const DatumData = bp.XDatumData["_"]
|
||||
|
||||
export function datumDataToData(x: DatumData): string {
|
||||
return lucid.Data.to<DatumData>(x, DatumData);
|
||||
}
|
||||
|
||||
export function datumDatafromData(x: string): DatumData {
|
||||
return lucid.Data.from<DatumData>(x, DatumData);
|
||||
}
|
||||
|
||||
export type Price = bp.XPrice["_"]
|
||||
export const Price = bp.XPrice["_"]
|
||||
|
||||
export function priceToData(x: Price): string {
|
||||
return lucid.Data.to<Price>(x, Price);
|
||||
}
|
||||
|
||||
export function pricefromData(x: string): Price {
|
||||
return lucid.Data.from<Price>(x, Price);
|
||||
}
|
||||
|
||||
export type StatementPrice = bp.XStatementPrice["_"]
|
||||
export const StatementPrice = bp.XStatementPrice["_"]
|
||||
|
||||
export function statementPriceToData(x: StatementPrice): string {
|
||||
return lucid.Data.to<StatementPrice>(x, StatementPrice);
|
||||
}
|
||||
|
||||
export function statementPricefromData(x: string): StatementPrice {
|
||||
return lucid.Data.from<StatementPrice>(x, StatementPrice);
|
||||
}
|
||||
|
||||
export type DatumPrice = bp.XDatumPrice["_"]
|
||||
export const DatumPrice = bp.XDatumPrice["_"]
|
||||
|
||||
export function datumPriceToData(x: DatumPrice): string {
|
||||
return lucid.Data.to<DatumPrice>(x, DatumPrice);
|
||||
}
|
||||
|
||||
export function datumPricefromData(x: string): DatumPrice {
|
||||
return lucid.Data.from<DatumPrice>(x, DatumPrice);
|
||||
}
|
Loading…
Reference in New Issue