-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Experimental feature: Add @marlowe.io/marlowe-template package #184
Merged
Merged
Changes from 15 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
86385ee
Fix metadata typing
hrajchert c70ef58
wip initial blueprint work
hrajchert 52c2067
wip: initial Blueprint class
hrajchert b959041
Added basic unit testing to blueprints
hrajchert f021508
Add first encode to Blueprint
hrajchert 24d8406
First version of blueprint decode
hrajchert f543af1
Improved blueprint typing, added name, description and tests
hrajchert c09a83e
Added AddressBech32 guard in Blueprint
hrajchert d22ed40
Modify marlowe-object-flow to use Blueprint
hrajchert 91fdb6b
Remove old experimenta-feature/metadata
hrajchert e49f93c
Fix build
hrajchert e4bc120
wip small refactor and documentation
hrajchert 5618a40
Small refactor and documentation regarding blueprints
hrajchert dcb4cf8
Add TokenParam to Blueprint
hrajchert a49629e
Add scriv entry
hrajchert c7bf939
Fix missing export
hrajchert 783f96d
Added preservedBrand io-ts helper
hrajchert 712adfc
Renamed package blueprint to marlowe-template
hrajchert bae26a5
Renamed TemplateParametersOf and mkMarloweTemplate
hrajchert 7725df3
Small codec refactor
hrajchert 32dfa41
Renamed some files from blueprint to template
hrajchert ca22762
Removed Blueprint all around
hrajchert ee4bd09
Renamed toMetadata and fromMetadata
hrajchert File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
|
||
### General | ||
|
||
- Feat: Created a new experimental package `@marlowe.io/blueprints` that helps to share the parameters used in the creation of a Marlowe contract. ([PR-184](https://github.com/input-output-hk/marlowe-ts-sdk/pull/184)) | ||
|
||
|
||
### @marlowe.io/runtime-core | ||
|
||
- Feat: Added AddressBech32 validation using the lucid library ([PR-184](https://github.com/input-output-hk/marlowe-ts-sdk/pull/184)) | ||
- Fix: Added proper type guards to Metadata ([PR-184](https://github.com/input-output-hk/marlowe-ts-sdk/pull/184)) | ||
|
This file was deleted.
Oops, something went wrong.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,30 @@ | ||
/** | ||
* Utility functions for bigint. | ||
*/ | ||
import * as t from "io-ts/lib/index.js"; | ||
|
||
export const min = (a: bigint, b: bigint): bigint => (a < b ? a : b); | ||
export const max = (a: bigint, b: bigint): bigint => (a > b ? a : b); | ||
|
||
// The following type and guard are used to represent a number that can be either a bigint or a number. | ||
// The guard always encode the number as a bigint (when outputting a value). | ||
// NOTE: I'm not sure if is better to have this or to have a guard that accepts both bigint and number | ||
// as input but has bigint as `A`ctual type and `O`utput type. | ||
// A good reason to have BigIntOrNumber as Actual type is that it is easier to construct values | ||
// (as you can omit the final `n`), but a drawback is that in usage you might need to cast | ||
// to `Number(actual)` or `BigInt(actual)` depending on context. | ||
export type BigIntOrNumber = bigint | number; | ||
export const BigIntOrNumberGuard = new t.Type<BigIntOrNumber, bigint, unknown>( | ||
"BigIntOrNumber", | ||
(u): u is BigIntOrNumber => typeof u === "bigint" || typeof u === "number", | ||
(u, c) => { | ||
if (typeof u === "bigint") { | ||
return t.success(u); | ||
} else if (typeof u === "number") { | ||
return t.success(u); | ||
} else { | ||
return t.failure(u, c); | ||
} | ||
}, | ||
(u) => BigInt(u) | ||
); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these functions that manually encoded and decoded the parameters as tags are now provided by the
toMetadata
andfromMetadata
functions of the template parameters.