Skip to content

Commit

Permalink
removed PMaybe circulare deps
Browse files Browse the repository at this point in the history
  • Loading branch information
michele-nuzzi committed Jul 15, 2024
1 parent 7586868 commit 0fe4632
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 24 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@harmoniclabs/plu-ts",
"version": "0.8.0-dev2",
"version": "0.8.0-dev3",
"description": "An embedded DSL for Cardano smart contracts creation coupled with a library for Cardano transactions, all in Typescript",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand Down
8 changes: 1 addition & 7 deletions packages/offchain/src/__tests__/docs/docs.v3.hello.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ test("Hello plu-ts",() => {
fromHex("01010032323232323232322323259800800c5268b2ae686644b3001002800c5282ae693001329800991aba1357446ae8800400a003001800c0064601800300148888888c8cc966002600290004400e2b300130014800a20091598009800a400910058acc004c005200688034566002600290044401e2b300130014802a20111655cd1573455cd1573455cd15734370e6aae74004d55cf0009baa007134928ca6002e3e664664600e46ae80c0080040052f588eb8dd6191aba1357446ae88d5d11aba2357446ae88d5d11aba2001300435742005375c6ae84005222330093003001002244464664b300130014800220071598009800a400510048b2ae68ab9a1b8735573a0026aae78004dd500184cdc79bae300a0014890c48656c6c6f20706c752d7473003002001235573c6ea800488cc01484008888cc014008c00c0048cc00c852811119802980200109801800912cc00400a2946002ab9a18011111194c004c0100066006003002401866008006004444b3001001801c4cc008d5d08009aba2001555cf88c8c0088cc0080080048c0088cc0080080048d5d09aba200101")
);

console.log(
showUPLC(
parseUPLC( script.bytes ).body
)
);

const scriptAddr = Address.mainnet(
Credential.script( script.hash )
);
Expand Down Expand Up @@ -70,6 +64,6 @@ test("Hello plu-ts",() => {
changeAddress: myAddr
});

console.log( tx.body.fee );
expect( tx.body.fee ).toBeLessThan( 200_000 );

})
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ test("hello pluts", () => {
);
});

const compiled = compile( contract, [ 1, 0, 0 ] );
const compiled = compile( contract );

console.log( toHex( compiled ) );
// console.log( toHex( compiled ) );
});
26 changes: 12 additions & 14 deletions packages/onchain/src/pluts/lib/std/PMaybe/PMaybe.ts
Original file line number Diff line number Diff line change
@@ -1,38 +1,36 @@
import { pfn } from "../../pfn";
import { PDataRepresentable } from "../../../PType/PDataRepresentable";
import { PStruct, pstruct } from "../../../PTypes/PStruct/pstruct";
import { StructT, TermType, FromPType, ToPType } from "../../../type_system";
import { StructT, TermType, FromPType } from "../../../type_system";
import { _fromData } from "../data/conversion/fromData_minimal";
import { PFn, TermFn } from "../../../PTypes/PFn/PFn";
import { pmatch } from "../../pmatch/pmatch";

/*
TODO:
need to fix circular dependencies before implementing PMaybe methods
*/

export type MaybeT<T extends TermType> = StructT<{
Just: { val: T },
Nothing: {}
}, {
}/*, {
unwrap: TermFn<[ PMaybeRawT<ToPType<T>> ], ToPType<T>>,
default: TermFn<[ PMaybeRawT<ToPType<T>>, ToPType<T> ], ToPType<T>>,
}>
}*/>

type PMaybeRawT<PTy extends PDataRepresentable> = PStruct<{
Just: { val: FromPType<PTy> },
Nothing: {}
}, {}>

export type PMaybeT<PTy extends PDataRepresentable> = PStruct<{
Just: { val: FromPType<PTy> },
Nothing: {}
}, {
}, any/*{
unwrap: TermFn<[ PMaybeRawT<PTy> ], PTy>,
default: TermFn<[ PMaybeRawT<PTy>, PTy ], PTy>,
}>
}*/>

export function PMaybe<T extends TermType>(tyArg: T)
{
return pstruct({
Just: { val: tyArg },
Nothing: {}
}, self_t => {
}/*, self_t => {
return {
unwrap: pfn([ self_t ], tyArg)
Expand All @@ -44,5 +42,5 @@ export function PMaybe<T extends TermType>(tyArg: T)
.onNothing(_ => defaultValue )
)
};
});
}*/);
}

0 comments on commit 0fe4632

Please sign in to comment.