-
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.
Merge pull request #185 from input-output-hk/hrajchert/fix-branded-ou…
…tput Fix how the ContractId and TxId branded types are printed in the documentation
- Loading branch information
Showing
10 changed files
with
62 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
### @marlowe.io/runtime-core | ||
|
||
- Fix: Branding of ContractId and TxId ([PR-185](https://github.com/input-output-hk/marlowe-ts-sdk/pull/185)) | ||
|
||
|
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