-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Adds variant literal and simplifies constructions of artificial…
… types/values
- Loading branch information
Showing
9 changed files
with
936 additions
and
190 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 |
---|---|---|
|
@@ -40,4 +40,6 @@ export enum Prim { | |
None = 'None', | ||
Pair = 'Pair', | ||
Elt = 'Elt', | ||
Left = 'Left', | ||
Right = 'Right', | ||
} |
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,12 +1,28 @@ | ||
import { PairsOfKeys } from '../typings'; | ||
|
||
export const capitalizeBoolean = (bool: boolean): string => (bool ? 'True' : 'False'); | ||
|
||
export const compressHexString = (str: string) => { | ||
return (str.slice(0, 2) === '0x' ? str.slice(2) : str).toLowerCase(); | ||
}; | ||
|
||
/** | ||
* @description Build right aligned nested binary pairs | ||
* @see https://tezos.gitlab.io/active/michelson.html#operations-on-pairs-and-right-combs | ||
* @param fields A sequence of strings | ||
* @returns {PairsOfKeys<K>} | ||
*/ | ||
export const composeRightCombLayout = <K>(fields: K[]): PairsOfKeys<K> => { | ||
if (fields.length > 2) { | ||
return [fields[0], composeRightCombLayout<K>(fields.slice(1))]; | ||
} | ||
return fields; | ||
}; | ||
|
||
const Utils = { | ||
capitalizeBoolean, | ||
compressHexString, | ||
composeRightCombLayout, | ||
}; | ||
|
||
export default Utils; |
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,4 +1,5 @@ | ||
export type MichelsonJSON = Record<string, unknown> | MichelsonJSON[]; | ||
export type MichelsonMicheline = string; | ||
|
||
export type PairsOfKeys<K> = (K | PairsOfKeys<K>)[]; | ||
export * from './literal'; | ||
export * from './type'; |
Oops, something went wrong.