diff --git a/packages/mesh-common/src/data/mesh/aliases.ts b/packages/mesh-common/src/data/mesh/aliases.ts index f062de328..8205291bb 100644 --- a/packages/mesh-common/src/data/mesh/aliases.ts +++ b/packages/mesh-common/src/data/mesh/aliases.ts @@ -3,52 +3,128 @@ import { Data } from "../../types"; import { mConStr0, MConStr0, mConStr1, MConStr1 } from "./constructors"; /** - * PlutusTx alias - * The Mesh Data asset class + * @typealias MAssetClass + * @description + * PlutusTx alias, represents a Cardano asset class in Mesh Data type as a constructor object with currency symbol and token name. + * + * @purpose + * TODO + * + * @property {MConStr0<[string, string]>} + * Constructor object with two string fields: currency symbol (hex) and token name (hex). + * - Example: `mConStr0(["5ac3d4bdca238105a040a565e5d7e734b7c9e1630aec7650e809e34a", "7075707079"])` */ export type MAssetClass = MConStr0<[string, string]>; /** - * Aiken alias - * The Mesh Data output reference + * @typealias MOutputReference + * @description + * Represents a Cardano output reference in Mesh Data type as a constructor object with transaction hash and output index. + * + * @purpose + * TODO + * + * @property {MConStr0<[string, number]>} + * Constructor object with transaction hash (hex string) and output index (number). + * - Example: `mConStr0(["766a7f683444256f0b17cb5fb125f7cb3e2210f2784347848ea2f6917d080a1c", 1])` */ export type MOutputReference = MConStr0<[string, number]>; /** - * PlutusTx alias - * The Mesh Data TxOutRef + * @typealias MTxOutRef + * @description + * PlutusTx alias, represents a Cardano transaction output reference in Mesh Data type as a nested constructor object. + * + * @purpose + * TODO + * + * @property {MConStr0<[MConStr0<[string]>, number]>} + * Constructor object with nested transaction hash constructor and output index. + * - Example: `mConStr0([mConStr0(["766a7f683444256f0b17cb5fb125f7cb3e2210f2784347848ea2f6917d080a1c"]), 1])` */ export type MTxOutRef = MConStr0<[MConStr0<[string]>, number]>; /** - * Aiken alias - * The Mesh Data tuple + * @typealias MTuple + * @description + * Represents a Mesh Data tuple as an array of values. + * Aiken alias for encoding tuple structures in Cardano smart contracts. + * + * @purpose + * TODO + * + * @property {T[]} + * Array of tuple elements. + * - Example: `["mesh", "coin"]` */ export type MTuple = T[]; /** - * Aiken alias - * The Mesh Data Option type + * @typealias MOption + * @description + * Represents a Mesh Data Option type as either Some or None. + * Aiken alias for encoding optional values in Cardano smart contracts. + * + * @purpose + * TODO + * + * @property {MSome | MNone} value + * Option value, either Some (with value) or None. + * - Example: `mSome("mesh")` or `mNone()` */ export type MOption = MSome | MNone; /** - * Aiken alias - * The Mesh Data Option - Some type + * @typealias MSome + * @description + * Represents a Mesh Data Some type as a constructor object with a value. + * Aiken alias for encoding present optional values in Cardano smart contracts. + * + * @purpose + * TODO + * + * @property {MConStr0<[T]>} + * Constructor object with a single value field. + * - Example: `mConStr0(["mesh"])` */ export type MSome = MConStr0<[T]>; /** - * Aiken alias - * The Mesh Data Option - None type + * @typealias MNone + * @description + * Represents a Mesh Data None type as a constructor object with no fields. + * Aiken alias for encoding absent optional values in Cardano smart contracts. + * + * @purpose + * TODO + * + * @property {MConStr1<[]>} + * Constructor object with no fields. + * - Example: `mConStr1([])` */ export type MNone = MConStr1<[]>; /** - * The utility function to create a Mesh Data asset class - * @param currencySymbolHex The currency symbol in hex - * @param tokenNameHex The token name in hex - * @returns The Mesh Data asset class object + * @function mAssetClass + * @description + * Creates a Mesh Data asset class object with a currency symbol and token name in hex format. + * + * @purpose + * TODO + * + * @param {string} currencySymbolHex + * The currency symbol in hex. + * - Must be a 56-character hex string or empty string for lovelace. + * - Example value: `"5ac3d4bdca238105a040a565e5d7e734b7c9e1630aec7650e809e34a"` + * + * @param {string} tokenNameHex + * The token name in hex. + * - Must be a hex string up to 64 characters. + * - Example value: `"7075707079"` (for "puppy") + * + * @returns {MAssetClass} + * Mesh Data asset class object. + * - Example: `mConStr0(["5ac3d4bdca238105a040a565e5d7e734b7c9e1630aec7650e809e34a", "7075707079"])` */ export const mAssetClass = ( currencySymbolHex: string, @@ -70,10 +146,26 @@ export const mAssetClass = ( }; /** - * The utility function to create a Mesh Data output reference in Mesh Data type - * @param txHash The transaction hash - * @param index The index of the output - * @returns The Mesh Data output reference object + * @function mOutputReference + * @description + * Creates a Mesh Data output reference object with a transaction hash and output index. + * + * @purpose + * TODO + * + * @param {string} txHash + * The transaction hash in hex. + * - Must be a 64-character hex string. + * - Example value: `"766a7f683444256f0b17cb5fb125f7cb3e2210f2784347848ea2f6917d080a1c"` + * + * @param {number} index + * The index of the output. + * - Must be a non-negative integer. + * - Example value: `1` + * + * @returns {MOutputReference} + * Mesh Data output reference object. + * - Example: `mConStr0(["766a7f683444256f0b17cb5fb125f7cb3e2210f2784347848ea2f6917d080a1c", 1])` */ export const mOutputReference = ( txHash: string, @@ -86,10 +178,26 @@ export const mOutputReference = ( }; /** - * The utility function to create a Mesh Data TxOutRef in Mesh Data type - * @param txHash The transaction hash - * @param index The index of the output - * @returns The Mesh Data TxOutRef object + * @function mTxOutRef + * @description + * Creates a Mesh Data TxOutRef object with a transaction hash and output index. + * + * @purpose + * TODO + * + * @param {string} txHash + * The transaction hash in hex. + * - Must be a 64-character hex string. + * - Example value: `"766a7f683444256f0b17cb5fb125f7cb3e2210f2784347848ea2f6917d080a1c"` + * + * @param {number} index + * The index of the output. + * - Must be a non-negative integer. + * - Example value: `1` + * + * @returns {MTxOutRef} + * Mesh Data TxOutRef object. + * - Example: `mConStr0([mConStr0(["766a7f683444256f0b17cb5fb125f7cb3e2210f2784347848ea2f6917d080a1c"]), 1])` */ export const mTxOutRef = (txHash: string, index: number): MTxOutRef => { if (txHash.length !== 64) { @@ -99,16 +207,40 @@ export const mTxOutRef = (txHash: string, index: number): MTxOutRef => { }; /** - * The utility function to create a Mesh Data tuple in Mesh Data type - * @param args The arguments of the tuple - * @returns The Mesh Data tuple object + * @function mTuple + * @description + * Creates a Mesh Data tuple object with an array of arguments. + * + * @purpose + * TODO + * + * @param {any[]} args + * The arguments of the tuple. + * - Must be a list of values. + * - Example value: `["mesh", "coin"]` + * + * @returns {MTuple} + * Mesh Data tuple object. + * - Example: `["mesh", "coin"]` */ export const mTuple = (...args: T): MTuple => args; /** - * The utility function to create a Mesh Data Option type in Mesh Data type - * @param value The value of the option - * @returns The Mesh Data Option object + * @function mOption + * @description + * Creates a Mesh Data Option object as either MSome or MNone. + * + * @purpose + * TODO + * + * @param {Data} value + * The value of the option. + * - Optional; if provided, creates Some, otherwise None. + * - Example value: `"mesh"` + * + * @returns {MOption} + * Mesh Data Option object. + * - Example: `mSome("mesh")` or `mNone()` */ export const mOption = (value?: T): MOption => { if (value) { @@ -118,15 +250,35 @@ export const mOption = (value?: T): MOption => { }; /** - * The utility function to create a Mesh Data Option type in Mesh Data type - * @param value The value of the option - * @returns The Mesh Data Option object + * @function mSome + * @description + * Creates a Mesh Data Some object with a value. + * + * @purpose + * TODO + * + * @param {Data} value + * The value to wrap in MSome. + * - Must be a valid Data value. + * - Example value: `"mesh"` + * + * @returns {MSome} + * Mesh Data Option - Some object. + * - Example: `mConStr0(["mesh"])` */ export const mSome = (value: T): MSome => mConStr0([value]) as MSome; /** - * The utility function to create a Mesh Data Option - None type in Mesh Data type - * @returns The Mesh Data Option - None object + * @function mNone + * @description + * Creates a Mesh Data Option - None object with no value. + * + * @purpose + * TODO + * + * @returns {MNone} + * Mesh Data Option - None object. + * - Example: `mConStr1([])` */ export const mNone = (): MNone => mConStr1([]); diff --git a/packages/mesh-common/src/data/mesh/constructors.ts b/packages/mesh-common/src/data/mesh/constructors.ts index 29de66af2..51e65a366 100644 --- a/packages/mesh-common/src/data/mesh/constructors.ts +++ b/packages/mesh-common/src/data/mesh/constructors.ts @@ -1,35 +1,107 @@ import { Data } from "../../types"; /** - * The Mesh Data constructor object, representing custom data type + * @typealias MConStr + * @description + * Represents a Mesh Data constructor object for custom data types. + * + * @purpose + * Used to encode Cardano Plutus data constructors with an index and associated fields. + * + * @property {N} alternative + * The constructor index number (e.g., 0, 1, 2, 3). + * @property {T} fields + * The fields or data associated with the constructor. + * - Example: `{ alternative: 0, fields: [data1, data2] }` */ export type MConStr = { alternative: N; fields: T }; /** - * The Mesh Data index 0 constructor object, representing custom data type + * @typealias MConStr0 + * @description + * Represents a Mesh Data index 0 constructor object for custom data types. + * + * @purpose + * Used for Cardano Plutus data encoding with constructor index 0. + * + * @property {0} alternative + * The constructor index number (always 0). + * @property {T} fields + * The fields or data associated with the constructor. + * - Example: `{ alternative: 0, fields: [data1, data2] }` */ export type MConStr0 = MConStr<0, T>; /** - * The Mesh Data index 1 constructor object, representing custom data type + * @typealias MConStr1 + * @description + * Represents a Mesh Data index 1 constructor object for custom data types. + * + * @purpose + * Used for Cardano Plutus data encoding with constructor index 1. + * + * @property {1} alternative + * The constructor index number (always 1). + * @property {T} fields + * The fields or data associated with the constructor. + * - Example: `{ alternative: 1, fields: [data1, data2] }` */ export type MConStr1 = MConStr<1, T>; /** - * The Mesh Data index 2 constructor object, representing custom data type + * @typealias MConStr2 + * @description + * Represents a Mesh Data index 2 constructor object for custom data types. + * + * @purpose + * Used for Cardano Plutus data encoding with constructor index 2. + * + * @property {2} alternative + * The constructor index number (always 2). + * @property {T} fields + * The fields or data associated with the constructor. + * - Example: `{ alternative: 2, fields: [data1, data2] }` */ export type MConStr2 = MConStr<2, T>; /** - * The Mesh Data index 3 constructor object, representing custom data type + * @typealias MConStr3 + * @description + * Represents a Mesh Data index 3 constructor object for custom data types. + * Used for Cardano Plutus data encoding with constructor index 3. + * + * @purpose + * Enables developers to define index 3 constructor objects for Cardano smart contract data serialization. + * + * @property {3} alternative + * The constructor index number (always 3). + * @property {T} fields + * The fields or data associated with the constructor. + * - Example: `{ alternative: 3, fields: [data1, data2] }` */ export type MConStr3 = MConStr<3, T>; /** - * The utility function to create a Mesh Data constructor object, representing custom data type - * @param alternative The constructor index number - * @param fields The items in array - * @returns The Mesh Data constructor object + * @function mConStr + * @description + * Creates a Mesh Data constructor object for custom data types with a specified constructor index and fields. + * + * @purpose + * TODO + * + * @param {number} alternative + * The constructor index number. + * - Must be a non-negative integer. + * - Example value: `2` + * + * @param {Data[]} fields + * The items in the array to be included as fields. + * - Must be an array of Data objects. + * - Example value: `[data1, data2]` + * + * @returns {MConStr} + * Mesh Data constructor object with the specified index and provided fields. + * - Example: `{ alternative: 2, fields: [data1, data2] }` */ export const mConStr = ( alternative: N, @@ -40,9 +112,21 @@ export const mConStr = ( }); /** - * The utility function to create a Mesh Data index 0 constructor object, representing custom data type - * @param fields The items in array - * @returns The Mesh Data constructor object + * @function mConStr0 + * @description + * Creates a Mesh Data index 0 constructor object for custom data types. + * + * @purpose + * TODO + * + * @param {Data[]} fields + * The items in the array to be included as fields. + * - Must be an array of Data objects. + * - Example value: `[data1, data2]` + * + * @returns {MConStr0} + * Mesh Data constructor object with index 0 and provided fields. + * - Example: `{ alternative: 0, fields: [data1, data2] }` */ export const mConStr0 = (fields: T): MConStr0 => ({ alternative: 0, @@ -50,9 +134,21 @@ export const mConStr0 = (fields: T): MConStr0 => ({ }); /** - * The utility function to create a Mesh Data index 1 constructor object, representing custom data type - * @param fields The items in array - * @returns The Mesh Data constructor object + * @function mConStr1 + * @description + * Creates a Mesh Data index 1 constructor object for custom data types. + * + * @purpose + * TODO + * + * @param {Data[]} fields + * The items in the array to be included as fields. + * - Must be an array of Data objects. + * - Example value: `[data1, data2]` + * + * @returns {MConStr1} + * Mesh Data constructor object with index 1 and provided fields. + * - Example: `{ alternative: 1, fields: [data1, data2] }` */ export const mConStr1 = (fields: T): MConStr1 => ({ alternative: 1, @@ -60,9 +156,21 @@ export const mConStr1 = (fields: T): MConStr1 => ({ }); /** - * The utility function to create a Mesh Data index 2 constructor object, representing custom data type - * @param fields The items in array - * @returns The Mesh Data constructor object + * @function mConStr2 + * @description + * Creates a Mesh Data index 2 constructor object for custom data types. + * + * @purpose + * TODO + * + * @param {Data[]} fields + * The items in the array to be included as fields. + * - Must be an array of Data objects. + * - Example value: `[data1, data2]` + * + * @returns {MConStr2} + * Mesh Data constructor object with index 2 and provided fields. + * - Example: `{ alternative: 2, fields: [data1, data2] }` */ export const mConStr2 = (fields: T): MConStr2 => ({ alternative: 2, @@ -70,9 +178,21 @@ export const mConStr2 = (fields: T): MConStr2 => ({ }); /** - * The utility function to create a Mesh Data index 3 constructor object, representing custom data type - * @param fields The items in array - * @returns The Mesh Data constructor object + * @function mConStr3 + * @description + * Creates a Mesh Data index 3 constructor object for custom data types. + * + * @purpose + * TODO + * + * @param {Data[]} fields + * The items in the array to be included as fields. + * - Must be an array of Data objects. + * - Example value: `[data1, data2]` + * + * @returns {MConStr3} + * Mesh Data constructor object with index 3 and provided fields. + * - Example: `{ alternative: 3, fields: [data1, data2] }` */ export const mConStr3 = (fields: T): MConStr3 => ({ alternative: 3, diff --git a/packages/mesh-common/src/data/mesh/credentials.ts b/packages/mesh-common/src/data/mesh/credentials.ts index 53ebb59af..a1d8f0509 100644 --- a/packages/mesh-common/src/data/mesh/credentials.ts +++ b/packages/mesh-common/src/data/mesh/credentials.ts @@ -1,17 +1,46 @@ import { mConStr0, MConStr0, mConStr1, MConStr1 } from "./constructors"; /** - * The Mesh Data verification key + * @typealias MVerificationKey + * @description + * Represents a Mesh Data verification key as a constructor object with a public key hash in hex. + * + * @purpose + * TODO + * + * @property {MConStr0<[string]>} + * Constructor object with a single string field for the public key hash (hex). + * - Example: `mConStr0(["f275cb75d82f..."])` */ export type MVerificationKey = MConStr0<[string]>; /** - * The Mesh Data script key + * @typealias MScript + * @description + * Represents a Mesh Data script key as a constructor object with a script hash in hex. + * + * @purpose + * TODO + * + * @property {MConStr1<[string]>} + * Constructor object with a single string field for the script hash (hex). + * - Example: `mConStr1(["1c84c63dcea3..."])` */ export type MScript = MConStr1<[string]>; /** - * The Mesh Data staking credential + * @typealias MMaybeStakingHash + * @description + * Represents a Mesh Data staking credential as a constructor object for optional staking hashes. + * + * @purpose + * TODO + * + * @property {MConStr1<[]> | MConStr0<[MConStr0<[MVerificationKey]>]> | MConStr0<[MConStr0<[MScript]>]>} + * - `MConStr1<[]>`: No staking credential. + * - `MConStr0<[MConStr0<[MVerificationKey]>]>`: Staking credential as verification key. + * - `MConStr0<[MConStr0<[MScript]>]>`: Staking credential as script. + * - Example: `mConStr1([])` or `mConStr0([mConStr0([mVerificationKey("f275cb75d82f...")])])` */ export type MMaybeStakingHash = | MConStr1<[]> @@ -19,40 +48,106 @@ export type MMaybeStakingHash = | MConStr0<[MConStr0<[MScript]>]>; /** - * The Mesh Data public key address + * @typealias MPubKeyAddress + * @description + * Represents a Mesh Data public key address as a constructor object with verification key and optional staking hash. + * + * @purpose + * TODO + * + * @property {MConStr0<[MVerificationKey, MMaybeStakingHash]>} + * Constructor object with verification key and optional staking hash. + * - Example: `mConStr0([mVerificationKey("f275cb75d82f..."), mConStr1([])])` */ export type MPubKeyAddress = MConStr0<[MVerificationKey, MMaybeStakingHash]>; /** - * The Mesh Data script address + * @typealias MScriptAddress + * @description + * Represents a Mesh Data script address as a constructor object with script key and optional staking hash. + * + * @purpose + * TODO + * + * @property {MConStr0<[MScript, MMaybeStakingHash]>} + * Constructor object with script key and optional staking hash. + * - Example: `mConStr0([mScript("1c84c63dcea3..."), mConStr1([])])` */ export type MScriptAddress = MConStr0<[MScript, MMaybeStakingHash]>; /** - * The Mesh Data credential + * @typealias MCredential + * @description + * Represents a Mesh Data credential as either a verification key or script key. + * + * @purpose + * TODO + * + * @property {MVerificationKey | MScript} + * Credential object, either verification key or script key. + * - Example: `mVerificationKey("f275cb75d82f...")` or `mScript("1c84c63dcea3...")` */ export type MCredential = MVerificationKey | MScript; /** - * The utility function to create a Mesh Data verification key - * @param bytes The public key hash in hex - * @returns The Mesh Data verification key object + * @function mVerificationKey + * @description + * Creates a Mesh Data verification key object from a public key hash in hex format. + * + * @purpose + * TODO + * + * @param {string} bytes + * The public key hash in hex. + * - Must be a valid hex string. + * - Example value: `"f275cb75d82f..."` + * + * @returns {MVerificationKey} + * Mesh Data verification key object. + * - Example: `mConStr0(["f275cb75d82f..."])` */ export const mVerificationKey = (bytes: string): MVerificationKey => mConStr0([bytes]); /** - * The utility function to create a Mesh Data script key - * @param bytes The script hash in hex - * @returns The Mesh Data script key object + * @function mScript + * @description + * Creates a Mesh Data script key object from a script hash in hex format. + * + * @purpose + * TODO + * + * @param {string} bytes + * The script hash in hex. + * - Must be a valid hex string. + * - Example value: `"1c84c63dcea3..."` + * + * @returns {MScript} + * Mesh Data script key object. + * - Example: `mConStr1(["1c84c63dcea3..."])` */ export const mScript = (bytes: string): MScript => mConStr1([bytes]); /** - * The utility function to create a Mesh Data staking hash - * @param stakeCredential The staking credential in hex - * @param isStakeScriptCredential The flag to indicate if the credential is a script credential - * @returns The Mesh Data staking hash object + * @function mMaybeStakingHash + * @description + * Creates a Mesh Data staking hash object from a staking credential in hex format. + * + * @purpose + * TODO + * + * @param {string} stakeCredential + * The staking credential in hex. + * - Must be a valid hex string or empty string for no staking credential. + * - Example value: `"f275cb75d82f..."` + * + * @param {boolean} isStakeScriptCredential + * The flag to indicate if the credential is a script credential. + * - Optional; defaults to `false`. + * + * @returns {MMaybeStakingHash} + * Mesh Data staking hash object. + * - Example: `mConStr1([])` or `mConStr0([mConStr0([mVerificationKey("f275cb75d82f...")])])` */ export const mMaybeStakingHash = ( stakeCredential: string, @@ -72,11 +167,30 @@ export const mMaybeStakingHash = ( }; /** - * The utility function to create a Mesh Data public key address - * @param bytes The public key hash in hex - * @param stakeCredential The staking credential in hex - * @param isStakeScriptCredential The flag to indicate if the credential is a script credential - * @returns The Mesh Data public key address object + * @function mPubKeyAddress + * @description + * Creates a Mesh Data public key address object from a public key hash and optional staking credential. + * + * @purpose + * TODO + * + * @param {string} bytes + * The public key hash in hex. + * - Must be a valid hex string. + * - Example value: `"f275cb75d82f..."` + * + * @param {string} [stakeCredential] + * The staking credential in hex. + * - Optional; must be a valid hex string or empty string. + * - Example value: `"f275cb75d82f..."` + * + * @param {boolean} isStakeScriptCredential + * The flag to indicate if the credential is a script credential. + * - Optional; defaults to `false`. + * + * @returns {MPubKeyAddress} + * Mesh Data public key address object. + * - Example: `mConStr0([mVerificationKey("f275cb75d82f..."), mConStr1([])])` */ export const mPubKeyAddress = ( bytes: string, @@ -89,11 +203,30 @@ export const mPubKeyAddress = ( ]); /** - * The utility function to create a Mesh Data script address - * @param bytes The validator hash in hex - * @param stakeCredential The staking credential in hex - * @param isStakeScriptCredential The flag to indicate if the credential is a script credential - * @returns The Mesh Data script address object + * @function mScriptAddress + * @description + * Creates a Mesh Data script address object from a validator hash and optional staking credential. + * + * @purpose + * TODO + * + * @param {string} bytes + * The validator hash in hex. + * - Must be a valid hex string. + * - Example value: `"1c84c63dcea3..."` + * + * @param {string} [stakeCredential] + * The staking credential in hex. + * - Optional; must be a valid hex string or empty string. + * - Example value: `"f275cb75d82f..."` + * + * @param {boolean} isStakeScriptCredential + * The flag to indicate if the credential is a script credential. + * - Optional; defaults to `false`. + * + * @returns {MScriptAddress} + * Mesh Data script address object. + * - Example: `mConStr0([mScript("1c84c63dcea3..."), mConStr1([])])` */ export const mScriptAddress = ( bytes: string, @@ -106,10 +239,25 @@ export const mScriptAddress = ( ]); /** - * The utility function to create a Mesh Data credential - * @param hash The pub key hash or script hash - * @param isScriptCredential Indicate if the credential is script hash (false for pub key hash) - * @returns Mesh Data credential object + * @function mCredential + * @description + * Creates a Mesh Data credential object from a pub key hash or script hash. + * + * @purpose + * TODO + * + * @param {string} hash + * The pub key hash or script hash. + * - Must be a valid hex string. + * - Example value: `"f275cb75d82f..."` + * + * @param {boolean} isScriptCredential + * Indicate if the credential is script hash (false for pub key hash). + * - Optional; defaults to `false`. + * + * @returns {MCredential} + * Mesh Data credential object. + * - Example: `mVerificationKey("f275cb75d82f...")` or `mScript("1c84c63dcea3...")` */ export const mCredential = ( hash: string, diff --git a/packages/mesh-common/src/data/mesh/primitives.ts b/packages/mesh-common/src/data/mesh/primitives.ts index f4bd18c30..4f8ec8600 100644 --- a/packages/mesh-common/src/data/mesh/primitives.ts +++ b/packages/mesh-common/src/data/mesh/primitives.ts @@ -1,22 +1,54 @@ import { MConStr0, mConStr0, MConStr1, mConStr1 } from "./constructors"; /** - * The Mesh Data boolean + * @typealias MBool + * @description + * Represents the Mesh Data boolean type as a constructor object. + * + * @purpose + * TODO + * + * @property {MConStr0<[]> | MConStr1<[]>} + * - `MConStr0<[]>`: Represents `false`. + * - `MConStr1<[]>`: Represents `true`. + * - Example: `const b: MBool = mConStr1([]); // true` */ export type MBool = MConStr0<[]> | MConStr1<[]>; /** - * The utility function to create a Mesh Data boolean - * @param b boolean value - * @returns The Mesh Data boolean object + * @function mBool + * @description + * Creates a Mesh Data boolean object for Cardano Plutus data encoding. + * + * @purpose + * TODO + * + * @param {boolean} b + * The boolean value to encode. + * + * @returns {MBool} + * Mesh Data boolean object representing the input value. + * - Example: `mConStr1([])` for `true`, `mConStr0([])` for `false` */ export const mBool = (b: boolean): MBool => b ? mConStr1<[]>([]) : mConStr0<[]>([]); /** - * Converting a hex string into a BuiltinByteString Array, with max 32 bytes on each items - * @param hexString The hex string to be converted into BuiltinByteString Array - * @returns The BuiltinByteString Array representation of the hex string + * @function mStringToPlutusBSArray + * @description + * Converts a hex string into a BuiltinByteString Array, with a maximum of 32 bytes per item. + * + * @purpose + * TODO + * + * @param {string} hexString + * The hex string to be converted. + * - Must be a valid hex string. + * - Example value: `"6d657368636f696e4d657368636f696e4d657368636f696e4d657368636f696e4d657368636f696e"` + * + * @returns {string[]} + * BuiltinByteString Array representation of the hex string, each item up to 32 bytes. + * - Example: `["6d657368636f696e4d657368636f696e4d657368636f696e4d657368636f696e", "4d657368636f696e"]` */ export const mStringToPlutusBSArray = (hexString: string): string[] => { const chunks = []; @@ -28,9 +60,21 @@ export const mStringToPlutusBSArray = (hexString: string): string[] => { }; /** - * Converting BuiltinByteString Array into a single string - * @param bsArray The BuiltinByteString Array to be converted into a single string - * @returns The string representation of the BuiltinByteString Array + * @function mPlutusBSArrayToString + * @description + * Converts a BuiltinByteString Array into a single string. + * + * @purpose + * TODO + * + * @param {string[]} bsArray + * The BuiltinByteString Array to be converted. + * - Must be an array of hex string segments. + * - Example value: `["6d657368636f696e4d657368636f696e4d657368636f696e4d657368636f696e", "4d657368636f696e"]` + * + * @returns {string} + * String representation of the concatenated BuiltinByteString Array. + * - Example: `"6d657368636f696e4d657368636f696e4d657368636f696e4d657368636f696e4d657368636f696e"` */ export const mPlutusBSArrayToString = (bsArray: string[]): string => { return bsArray.join("");