48 lines
1.4 KiB
TypeScript
48 lines
1.4 KiB
TypeScript
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()
|