-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix ContractId and TxId branded doc generation
- Loading branch information
Showing
9 changed files
with
57 additions
and
24 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
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
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
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
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,6 +1,22 @@ | ||
import { unsafeEither } from "@marlowe.io/adapter/fp-ts"; | ||
import * as t from "io-ts/lib/index.js"; | ||
|
||
// TODO: Try to make newtype as this gets replaced to string | ||
// in the docs. | ||
export type TxId = t.TypeOf<typeof TxId>; | ||
export const TxId = t.string; // to refine | ||
export interface TxIdBrand { | ||
readonly TxId: unique symbol; | ||
} | ||
|
||
/** | ||
* Cardano transaction identifier. | ||
* | ||
* @remarks The underlying data structure is a normal string, but in the type | ||
* level it is **Branded** with a unique symbol so that it is not confused with other strings | ||
*/ | ||
export type TxId = t.Branded<string, TxIdBrand>; | ||
|
||
export const TxIdGuard = t.brand( | ||
t.string, | ||
(s): s is t.Branded<string, TxIdBrand> => true, | ||
"TxId" | ||
); | ||
|
||
export const txId = (s: string) => unsafeEither(TxIdGuard.decode(s)); |
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