@meshsdk/common 1.9.0-beta.24 → 1.9.0-beta.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -100,12 +100,14 @@ __export(index_exports, {
100
100
  mOutputReference: () => mOutputReference,
101
101
  mPlutusBSArrayToString: () => mPlutusBSArrayToString,
102
102
  mPubKeyAddress: () => mPubKeyAddress,
103
+ mScript: () => mScript,
103
104
  mScriptAddress: () => mScriptAddress,
104
105
  mSome: () => mSome,
105
106
  mStringToPlutusBSArray: () => mStringToPlutusBSArray,
106
107
  mTuple: () => mTuple,
107
108
  mTxOutRef: () => mTxOutRef,
108
109
  mValue: () => mValue,
110
+ mVerificationKey: () => mVerificationKey,
109
111
  maybeStakingHash: () => maybeStakingHash,
110
112
  mergeAssets: () => mergeAssets,
111
113
  metadataStandardKeys: () => metadataStandardKeys,
@@ -127,6 +129,7 @@ __export(index_exports, {
127
129
  resolveSlotNo: () => resolveSlotNo,
128
130
  resolveTxFees: () => resolveTxFees,
129
131
  royaltiesStandardKeys: () => royaltiesStandardKeys,
132
+ script: () => script,
130
133
  scriptAddress: () => scriptAddress,
131
134
  scriptHash: () => scriptHash,
132
135
  slotToBeginUnixTime: () => slotToBeginUnixTime,
@@ -141,7 +144,8 @@ __export(index_exports, {
141
144
  txOutRef: () => txOutRef,
142
145
  unixTimeToEnclosingSlot: () => unixTimeToEnclosingSlot,
143
146
  validityRangeToObj: () => validityRangeToObj,
144
- value: () => value
147
+ value: () => value,
148
+ verificationKey: () => verificationKey
145
149
  });
146
150
  module.exports = __toCommonJS(index_exports);
147
151
 
@@ -1094,14 +1098,16 @@ var mSome = (value2) => mConStr0([value2]);
1094
1098
  var mNone = () => mConStr1([]);
1095
1099
 
1096
1100
  // src/data/mesh/credentials.ts
1101
+ var mVerificationKey = (bytes) => mConStr0([bytes]);
1102
+ var mScript = (bytes) => mConStr1([bytes]);
1097
1103
  var mMaybeStakingHash = (stakeCredential, isStakeScriptCredential = false) => {
1098
1104
  if (stakeCredential === "") {
1099
1105
  return mConStr1([]);
1100
1106
  }
1101
1107
  if (isStakeScriptCredential) {
1102
- return mConStr0([mConStr0([mConStr1([stakeCredential])])]);
1108
+ return mConStr0([mConStr0([mScript(stakeCredential)])]);
1103
1109
  }
1104
- return mConStr0([mConStr0([mConStr0([stakeCredential])])]);
1110
+ return mConStr0([mConStr0([mVerificationKey(stakeCredential)])]);
1105
1111
  };
1106
1112
  var mPubKeyAddress = (bytes, stakeCredential, isStakeScriptCredential = false) => mConStr0([
1107
1113
  { alternative: 0, fields: [bytes] },
@@ -1111,7 +1117,7 @@ var mScriptAddress = (bytes, stakeCredential, isStakeScriptCredential = false) =
1111
1117
  { alternative: 1, fields: [bytes] },
1112
1118
  mMaybeStakingHash(stakeCredential || "", isStakeScriptCredential)
1113
1119
  ]);
1114
- var mCredential = (hash, isScriptCredential = false) => isScriptCredential ? mConStr1([hash]) : mConStr0([hash]);
1120
+ var mCredential = (hash, isScriptCredential = false) => isScriptCredential ? mScript(hash) : mVerificationKey(hash);
1115
1121
 
1116
1122
  // src/data/mesh/primitives.ts
1117
1123
  var mBool = (b) => b ? mConStr1([]) : mConStr0([]);
@@ -1215,7 +1221,9 @@ var pairs = (mapItems, validation = true) => ({
1215
1221
  // src/data/json/aliases.ts
1216
1222
  var hashByteString = (bytes) => {
1217
1223
  if (bytes.length !== 56) {
1218
- throw new Error(`Invalid hash for [${bytes}] - should be 56 bytes long`);
1224
+ throw new Error(
1225
+ `Invalid hash for [${bytes}] - should be 28 bytes (56 hex length) long`
1226
+ );
1219
1227
  }
1220
1228
  return byteString(bytes);
1221
1229
  };
@@ -1224,7 +1232,7 @@ var pubKeyHash = (bytes) => hashByteString(bytes);
1224
1232
  var policyId = (bytes) => {
1225
1233
  if (bytes.length !== POLICY_ID_LENGTH && bytes !== "") {
1226
1234
  throw new Error(
1227
- `Invalid policy id for [${bytes}] - should be ${POLICY_ID_LENGTH} bytes long or empty string for lovelace`
1235
+ `Invalid policy id for [${bytes}] - should be ${POLICY_ID_LENGTH / 2} bytes (${POLICY_ID_LENGTH} hex length) long or empty string for lovelace`
1228
1236
  );
1229
1237
  }
1230
1238
  return byteString(bytes);
@@ -1267,28 +1275,26 @@ var some = (value2) => conStr0([value2]);
1267
1275
  var none = () => conStr1([]);
1268
1276
 
1269
1277
  // src/data/json/credentials.ts
1278
+ var verificationKey = (bytes) => conStr0([pubKeyHash(bytes)]);
1279
+ var script = (bytes) => conStr1([scriptHash(bytes)]);
1270
1280
  var maybeStakingHash = (stakeCredential, isStakeScriptCredential = false) => {
1271
1281
  if (stakeCredential === "") {
1272
1282
  return conStr1([]);
1273
1283
  }
1274
1284
  if (isStakeScriptCredential) {
1275
- return conStr0([
1276
- conStr0([conStr1([scriptHash(stakeCredential)])])
1277
- ]);
1285
+ return conStr0([conStr0([script(stakeCredential)])]);
1278
1286
  }
1279
- return conStr0([
1280
- conStr0([conStr0([pubKeyHash(stakeCredential)])])
1281
- ]);
1287
+ return conStr0([conStr0([verificationKey(stakeCredential)])]);
1282
1288
  };
1283
1289
  var pubKeyAddress = (bytes, stakeCredential, isStakeScriptCredential = false) => conStr0([
1284
1290
  conStr0([pubKeyHash(bytes)]),
1285
1291
  maybeStakingHash(stakeCredential || "", isStakeScriptCredential)
1286
1292
  ]);
1287
1293
  var scriptAddress = (bytes, stakeCredential, isStakeScriptCredential = false) => conStr0([
1288
- conStr1([scriptHash(bytes)]),
1294
+ script(bytes),
1289
1295
  maybeStakingHash(stakeCredential || "", isStakeScriptCredential)
1290
1296
  ]);
1291
- var credential = (hash, isScriptCredential = false) => isScriptCredential ? conStr1([scriptHash(hash)]) : conStr0([pubKeyHash(hash)]);
1297
+ var credential = (hash, isScriptCredential = false) => isScriptCredential ? script(hash) : verificationKey(hash);
1292
1298
 
1293
1299
  // src/data/json/mpf.ts
1294
1300
  var jsonProofToPlutusData = (proof) => {
@@ -2092,12 +2098,14 @@ var import_bip39 = require("bip39");
2092
2098
  mOutputReference,
2093
2099
  mPlutusBSArrayToString,
2094
2100
  mPubKeyAddress,
2101
+ mScript,
2095
2102
  mScriptAddress,
2096
2103
  mSome,
2097
2104
  mStringToPlutusBSArray,
2098
2105
  mTuple,
2099
2106
  mTxOutRef,
2100
2107
  mValue,
2108
+ mVerificationKey,
2101
2109
  maybeStakingHash,
2102
2110
  mergeAssets,
2103
2111
  metadataStandardKeys,
@@ -2119,6 +2127,7 @@ var import_bip39 = require("bip39");
2119
2127
  resolveSlotNo,
2120
2128
  resolveTxFees,
2121
2129
  royaltiesStandardKeys,
2130
+ script,
2122
2131
  scriptAddress,
2123
2132
  scriptHash,
2124
2133
  slotToBeginUnixTime,
@@ -2133,5 +2142,6 @@ var import_bip39 = require("bip39");
2133
2142
  txOutRef,
2134
2143
  unixTimeToEnclosingSlot,
2135
2144
  validityRangeToObj,
2136
- value
2145
+ value,
2146
+ verificationKey
2137
2147
  });
package/dist/index.d.cts CHANGED
@@ -731,22 +731,42 @@ declare const mSome: <T extends Data>(value: T) => MSome<T>;
731
731
  */
732
732
  declare const mNone: () => MNone;
733
733
 
734
+ /**
735
+ * The Mesh Data verification key
736
+ */
737
+ type MVerificationKey = MConStr0<[string]>;
738
+ /**
739
+ * The Mesh Data script key
740
+ */
741
+ type MScript = MConStr1<[string]>;
734
742
  /**
735
743
  * The Mesh Data staking credential
736
744
  */
737
- type MMaybeStakingHash = MConStr1<[]> | MConStr0<[MConStr0<[MConStr0<[string]>]>]> | MConStr0<[MConStr0<[MConStr1<[string]>]>]>;
745
+ type MMaybeStakingHash = MConStr1<[]> | MConStr0<[MConStr0<[MVerificationKey]>]> | MConStr0<[MConStr0<[MScript]>]>;
738
746
  /**
739
747
  * The Mesh Data public key address
740
748
  */
741
- type MPubKeyAddress = MConStr0<[MConStr0<[string]>, MMaybeStakingHash]>;
749
+ type MPubKeyAddress = MConStr0<[MVerificationKey, MMaybeStakingHash]>;
742
750
  /**
743
751
  * The Mesh Data script address
744
752
  */
745
- type MScriptAddress = MConStr0<[MConStr1<[string]>, MMaybeStakingHash]>;
753
+ type MScriptAddress = MConStr0<[MScript, MMaybeStakingHash]>;
746
754
  /**
747
755
  * The Mesh Data credential
748
756
  */
749
- type MCredential = MConStr0<[string]> | MConStr1<[string]>;
757
+ type MCredential = MVerificationKey | MScript;
758
+ /**
759
+ * The utility function to create a Mesh Data verification key
760
+ * @param bytes The public key hash in hex
761
+ * @returns The Mesh Data verification key object
762
+ */
763
+ declare const mVerificationKey: (bytes: string) => MVerificationKey;
764
+ /**
765
+ * The utility function to create a Mesh Data script key
766
+ * @param bytes The script hash in hex
767
+ * @returns The Mesh Data script key object
768
+ */
769
+ declare const mScript: (bytes: string) => MScript;
750
770
  /**
751
771
  * The utility function to create a Mesh Data staking hash
752
772
  * @param stakeCredential The staking credential in hex
@@ -1079,7 +1099,7 @@ declare const scriptHash: (bytes: string) => ScriptHash;
1079
1099
  * @param bytes The script hash in hex
1080
1100
  * @returns The Plutus Data script hash object
1081
1101
  */
1082
- declare const pubKeyHash: (bytes: string) => ScriptHash;
1102
+ declare const pubKeyHash: (bytes: string) => PubKeyHash;
1083
1103
  /**
1084
1104
  * The utility function to create a Plutus Data policy id in JSON
1085
1105
  * @param bytes The policy id in hex
@@ -1164,22 +1184,42 @@ declare const some: <T>(value: T) => Some<T>;
1164
1184
  */
1165
1185
  declare const none: () => None;
1166
1186
 
1187
+ /**
1188
+ * The Plutus Data verification key in JSON
1189
+ */
1190
+ type VerificationKey = ConStr0<[PubKeyHash]>;
1191
+ /**
1192
+ * The Plutus Data Script key in JSON
1193
+ */
1194
+ type Script = ConStr1<[ScriptHash]>;
1167
1195
  /**
1168
1196
  * The Plutus Data staking credential in JSON
1169
1197
  */
1170
- type MaybeStakingHash = ConStr1<[]> | ConStr0<[ConStr0<[ConStr0<[PubKeyHash]>]>]> | ConStr0<[ConStr0<[ConStr1<[ScriptHash]>]>]>;
1198
+ type MaybeStakingHash = ConStr1<[]> | ConStr0<[ConStr0<[VerificationKey]>]> | ConStr0<[ConStr0<[Script]>]>;
1171
1199
  /**
1172
1200
  * The Plutus Data public key address in JSON
1173
1201
  */
1174
- type PubKeyAddress = ConStr0<[ConStr0<[PubKeyHash]>, MaybeStakingHash]>;
1202
+ type PubKeyAddress = ConStr0<[VerificationKey, MaybeStakingHash]>;
1175
1203
  /**
1176
1204
  * The Plutus Data script address in JSON
1177
1205
  */
1178
- type ScriptAddress = ConStr0<[ConStr1<[ScriptHash]>, MaybeStakingHash]>;
1206
+ type ScriptAddress = ConStr0<[Script, MaybeStakingHash]>;
1179
1207
  /**
1180
1208
  * The Plutus Data credential in JSON
1181
1209
  */
1182
- type Credential = ConStr0<[PubKeyHash]> | ConStr1<[ScriptHash]>;
1210
+ type Credential = VerificationKey | Script;
1211
+ /**
1212
+ * The utility function to create a Plutus Data verification key in JSON
1213
+ * @param bytes The public key hash in hex
1214
+ * @returns The Plutus Data verification key object
1215
+ */
1216
+ declare const verificationKey: (bytes: string) => VerificationKey;
1217
+ /**
1218
+ * The utility function to create a Plutus Data script key in JSON
1219
+ * @param bytes The script hash in hex
1220
+ * @returns The Plutus Data script key object
1221
+ * */
1222
+ declare const script: (bytes: string) => Script;
1183
1223
  /**
1184
1224
  * The utility function to create a Plutus Data staking hash in JSON
1185
1225
  * @param stakeCredential The staking credential in hex
@@ -1730,4 +1770,4 @@ declare const hashDrepAnchor: (jsonLD: object) => string;
1730
1770
 
1731
1771
  declare function getFile(url: string): string;
1732
1772
 
1733
- export { type AccountInfo, type Action, type Anchor, type Asset, type AssetClass, type AssetExtended, AssetFingerprint, type AssetMetadata, type AssetName, type AssocMap, type AssocMapItem, type BasicVote, BigNum, type BlockInfo, type Bool, type Budget, type BuilderData, type BuiltinByteString, type ByteString, CIP68_100, CIP68_222, type Certificate, type CertificateType, type ConStr, type ConStr0, type ConStr1, type ConStr2, type ConStr3, type Credential, type CurrencySymbol, DEFAULT_FETCHER_OPTIONS, DEFAULT_PROTOCOL_PARAMETERS, DEFAULT_REDEEMER_BUDGET, DEFAULT_V1_COST_MODEL_LIST, DEFAULT_V2_COST_MODEL_LIST, DEFAULT_V3_COST_MODEL_LIST, DREP_DEPOSIT, type DRep, type Data, type DataSignature, type DatumSource, type DeserializedAddress, type DeserializedScript, type Dict, type DictItem, type Era, type Files, type ForkNeighbor, type FungibleAssetMetadata, type GovernanceProposalInfo, HARDENED_KEY_START, type IDeserializer, type IEvaluator, type IFetcher, type IFetcherOptions, type IInitiator, type IListener, type IMeshTxSerializer, type IMintingBlueprint, type IResolver, type ISigner, type ISpendingBlueprint, type ISubmitter, type IWallet, type IWithdrawalBlueprint, type ImageAssetMetadata, type Integer, LANGUAGE_VERSIONS, type LanguageVersion, type List, type MAssetClass, type MBool, type MConStr, type MConStr0, type MConStr1, type MConStr2, type MConStr3, type MCredential, type MMaybeStakingHash, type MNone, type MOption, type MOutputReference, type MPubKeyAddress, type MScriptAddress, type MSome, type MTuple, type MTxOutRef, type MValue, type MaybeStakingHash, type MeshTxBuilderBody, MeshValue, type Message, type Metadata, type Metadatum, type MetadatumMap, type Mint, type MintItem, type NativeScript, type Network, type NonFungibleAssetMetadata, type None, type Option, type Output, type OutputReference, POLICY_ID_LENGTH, type POSIXTime, type Pair, type Pairs, type PlutusData, type PlutusDataType, type PlutusScript, type PolicyId, type PoolMetadata, type PoolParams, type ProofStep, type ProofStepBranch, type ProofStepFork, type ProofStepLeaf, type Protocol, type PubKeyAddress, type PubKeyHash, type PubKeyTxIn, type PubKeyWithdrawal, type Quantity, type Recipient, type Redeemer, type RedeemerTagType, type RefTxIn, type Relay, type RequiredWith, type RoyaltiesStandard, SLOT_CONFIG_NETWORK, SUPPORTED_CLOCKS, SUPPORTED_HANDLES, SUPPORTED_LANGUAGE_VIEWS, SUPPORTED_OGMIOS_LINKS, SUPPORTED_TOKENS, SUPPORTED_WALLETS, type ScriptAddress, type ScriptHash, type ScriptSource, type ScriptTxIn, type ScriptTxInParameter, type ScriptVote, type ScriptWithdrawal, type SimpleScriptSourceInfo, type SimpleScriptTxIn, type SimpleScriptTxInParameter, type SimpleScriptVote, type SimpleScriptWithdrawal, type SlotConfig, type Some, type Token, type TokenName, type TransactionInfo, type Tuple, type TxIn, type TxInParameter, type TxMetadata, type TxOutRef, type UTxO, type Unit, UtxoSelection, type UtxoSelectionStrategy, type ValidityRange, type Value, type Vote, type VoteKind, type VoteType, type Voter, type VotingProcedure, type Wallet, type Withdrawal, assetClass, assetName, assocMap, bool, builtinByteString, byteString, bytesToHex, castProtocol, conStr, conStr0, conStr1, conStr2, conStr3, credential, currencySymbol, dict, emptyTxBuilderBody, experimentalSelectUtxos, fromUTF8, fungibleAssetKeys, getFile, hashByteString, hashDrepAnchor, hexToBytes, hexToString, integer, isNetwork, jsonProofToPlutusData, keepRelevant, largestFirst, largestFirstMultiAsset, list, mAssetClass, mBool, mConStr, mConStr0, mConStr1, mConStr2, mConStr3, mCredential, mMaybeStakingHash, mNone, mOption, mOutputReference, mPlutusBSArrayToString, mPubKeyAddress, mScriptAddress, mSome, mStringToPlutusBSArray, mTuple, mTxOutRef, mValue, maybeStakingHash, mergeAssets, metadataStandardKeys, metadataToCip68, none, option, outputReference, pairs, parseAssetUnit, plutusBSArrayToString, policyId, posixTime, pubKeyAddress, pubKeyHash, resolveEpochNo, resolveFingerprint, resolveLanguageView, resolveSlotNo, resolveTxFees, royaltiesStandardKeys, scriptAddress, scriptHash, slotToBeginUnixTime, some, stringToBSArray, stringToHex, toBytes, toUTF8, tokenName, tuple, txInToUtxo, txOutRef, unixTimeToEnclosingSlot, validityRangeToObj, value };
1773
+ export { type AccountInfo, type Action, type Anchor, type Asset, type AssetClass, type AssetExtended, AssetFingerprint, type AssetMetadata, type AssetName, type AssocMap, type AssocMapItem, type BasicVote, BigNum, type BlockInfo, type Bool, type Budget, type BuilderData, type BuiltinByteString, type ByteString, CIP68_100, CIP68_222, type Certificate, type CertificateType, type ConStr, type ConStr0, type ConStr1, type ConStr2, type ConStr3, type Credential, type CurrencySymbol, DEFAULT_FETCHER_OPTIONS, DEFAULT_PROTOCOL_PARAMETERS, DEFAULT_REDEEMER_BUDGET, DEFAULT_V1_COST_MODEL_LIST, DEFAULT_V2_COST_MODEL_LIST, DEFAULT_V3_COST_MODEL_LIST, DREP_DEPOSIT, type DRep, type Data, type DataSignature, type DatumSource, type DeserializedAddress, type DeserializedScript, type Dict, type DictItem, type Era, type Files, type ForkNeighbor, type FungibleAssetMetadata, type GovernanceProposalInfo, HARDENED_KEY_START, type IDeserializer, type IEvaluator, type IFetcher, type IFetcherOptions, type IInitiator, type IListener, type IMeshTxSerializer, type IMintingBlueprint, type IResolver, type ISigner, type ISpendingBlueprint, type ISubmitter, type IWallet, type IWithdrawalBlueprint, type ImageAssetMetadata, type Integer, LANGUAGE_VERSIONS, type LanguageVersion, type List, type MAssetClass, type MBool, type MConStr, type MConStr0, type MConStr1, type MConStr2, type MConStr3, type MCredential, type MMaybeStakingHash, type MNone, type MOption, type MOutputReference, type MPubKeyAddress, type MScript, type MScriptAddress, type MSome, type MTuple, type MTxOutRef, type MValue, type MVerificationKey, type MaybeStakingHash, type MeshTxBuilderBody, MeshValue, type Message, type Metadata, type Metadatum, type MetadatumMap, type Mint, type MintItem, type NativeScript, type Network, type NonFungibleAssetMetadata, type None, type Option, type Output, type OutputReference, POLICY_ID_LENGTH, type POSIXTime, type Pair, type Pairs, type PlutusData, type PlutusDataType, type PlutusScript, type PolicyId, type PoolMetadata, type PoolParams, type ProofStep, type ProofStepBranch, type ProofStepFork, type ProofStepLeaf, type Protocol, type PubKeyAddress, type PubKeyHash, type PubKeyTxIn, type PubKeyWithdrawal, type Quantity, type Recipient, type Redeemer, type RedeemerTagType, type RefTxIn, type Relay, type RequiredWith, type RoyaltiesStandard, SLOT_CONFIG_NETWORK, SUPPORTED_CLOCKS, SUPPORTED_HANDLES, SUPPORTED_LANGUAGE_VIEWS, SUPPORTED_OGMIOS_LINKS, SUPPORTED_TOKENS, SUPPORTED_WALLETS, type Script, type ScriptAddress, type ScriptHash, type ScriptSource, type ScriptTxIn, type ScriptTxInParameter, type ScriptVote, type ScriptWithdrawal, type SimpleScriptSourceInfo, type SimpleScriptTxIn, type SimpleScriptTxInParameter, type SimpleScriptVote, type SimpleScriptWithdrawal, type SlotConfig, type Some, type Token, type TokenName, type TransactionInfo, type Tuple, type TxIn, type TxInParameter, type TxMetadata, type TxOutRef, type UTxO, type Unit, UtxoSelection, type UtxoSelectionStrategy, type ValidityRange, type Value, type VerificationKey, type Vote, type VoteKind, type VoteType, type Voter, type VotingProcedure, type Wallet, type Withdrawal, assetClass, assetName, assocMap, bool, builtinByteString, byteString, bytesToHex, castProtocol, conStr, conStr0, conStr1, conStr2, conStr3, credential, currencySymbol, dict, emptyTxBuilderBody, experimentalSelectUtxos, fromUTF8, fungibleAssetKeys, getFile, hashByteString, hashDrepAnchor, hexToBytes, hexToString, integer, isNetwork, jsonProofToPlutusData, keepRelevant, largestFirst, largestFirstMultiAsset, list, mAssetClass, mBool, mConStr, mConStr0, mConStr1, mConStr2, mConStr3, mCredential, mMaybeStakingHash, mNone, mOption, mOutputReference, mPlutusBSArrayToString, mPubKeyAddress, mScript, mScriptAddress, mSome, mStringToPlutusBSArray, mTuple, mTxOutRef, mValue, mVerificationKey, maybeStakingHash, mergeAssets, metadataStandardKeys, metadataToCip68, none, option, outputReference, pairs, parseAssetUnit, plutusBSArrayToString, policyId, posixTime, pubKeyAddress, pubKeyHash, resolveEpochNo, resolveFingerprint, resolveLanguageView, resolveSlotNo, resolveTxFees, royaltiesStandardKeys, script, scriptAddress, scriptHash, slotToBeginUnixTime, some, stringToBSArray, stringToHex, toBytes, toUTF8, tokenName, tuple, txInToUtxo, txOutRef, unixTimeToEnclosingSlot, validityRangeToObj, value, verificationKey };
package/dist/index.d.ts CHANGED
@@ -731,22 +731,42 @@ declare const mSome: <T extends Data>(value: T) => MSome<T>;
731
731
  */
732
732
  declare const mNone: () => MNone;
733
733
 
734
+ /**
735
+ * The Mesh Data verification key
736
+ */
737
+ type MVerificationKey = MConStr0<[string]>;
738
+ /**
739
+ * The Mesh Data script key
740
+ */
741
+ type MScript = MConStr1<[string]>;
734
742
  /**
735
743
  * The Mesh Data staking credential
736
744
  */
737
- type MMaybeStakingHash = MConStr1<[]> | MConStr0<[MConStr0<[MConStr0<[string]>]>]> | MConStr0<[MConStr0<[MConStr1<[string]>]>]>;
745
+ type MMaybeStakingHash = MConStr1<[]> | MConStr0<[MConStr0<[MVerificationKey]>]> | MConStr0<[MConStr0<[MScript]>]>;
738
746
  /**
739
747
  * The Mesh Data public key address
740
748
  */
741
- type MPubKeyAddress = MConStr0<[MConStr0<[string]>, MMaybeStakingHash]>;
749
+ type MPubKeyAddress = MConStr0<[MVerificationKey, MMaybeStakingHash]>;
742
750
  /**
743
751
  * The Mesh Data script address
744
752
  */
745
- type MScriptAddress = MConStr0<[MConStr1<[string]>, MMaybeStakingHash]>;
753
+ type MScriptAddress = MConStr0<[MScript, MMaybeStakingHash]>;
746
754
  /**
747
755
  * The Mesh Data credential
748
756
  */
749
- type MCredential = MConStr0<[string]> | MConStr1<[string]>;
757
+ type MCredential = MVerificationKey | MScript;
758
+ /**
759
+ * The utility function to create a Mesh Data verification key
760
+ * @param bytes The public key hash in hex
761
+ * @returns The Mesh Data verification key object
762
+ */
763
+ declare const mVerificationKey: (bytes: string) => MVerificationKey;
764
+ /**
765
+ * The utility function to create a Mesh Data script key
766
+ * @param bytes The script hash in hex
767
+ * @returns The Mesh Data script key object
768
+ */
769
+ declare const mScript: (bytes: string) => MScript;
750
770
  /**
751
771
  * The utility function to create a Mesh Data staking hash
752
772
  * @param stakeCredential The staking credential in hex
@@ -1079,7 +1099,7 @@ declare const scriptHash: (bytes: string) => ScriptHash;
1079
1099
  * @param bytes The script hash in hex
1080
1100
  * @returns The Plutus Data script hash object
1081
1101
  */
1082
- declare const pubKeyHash: (bytes: string) => ScriptHash;
1102
+ declare const pubKeyHash: (bytes: string) => PubKeyHash;
1083
1103
  /**
1084
1104
  * The utility function to create a Plutus Data policy id in JSON
1085
1105
  * @param bytes The policy id in hex
@@ -1164,22 +1184,42 @@ declare const some: <T>(value: T) => Some<T>;
1164
1184
  */
1165
1185
  declare const none: () => None;
1166
1186
 
1187
+ /**
1188
+ * The Plutus Data verification key in JSON
1189
+ */
1190
+ type VerificationKey = ConStr0<[PubKeyHash]>;
1191
+ /**
1192
+ * The Plutus Data Script key in JSON
1193
+ */
1194
+ type Script = ConStr1<[ScriptHash]>;
1167
1195
  /**
1168
1196
  * The Plutus Data staking credential in JSON
1169
1197
  */
1170
- type MaybeStakingHash = ConStr1<[]> | ConStr0<[ConStr0<[ConStr0<[PubKeyHash]>]>]> | ConStr0<[ConStr0<[ConStr1<[ScriptHash]>]>]>;
1198
+ type MaybeStakingHash = ConStr1<[]> | ConStr0<[ConStr0<[VerificationKey]>]> | ConStr0<[ConStr0<[Script]>]>;
1171
1199
  /**
1172
1200
  * The Plutus Data public key address in JSON
1173
1201
  */
1174
- type PubKeyAddress = ConStr0<[ConStr0<[PubKeyHash]>, MaybeStakingHash]>;
1202
+ type PubKeyAddress = ConStr0<[VerificationKey, MaybeStakingHash]>;
1175
1203
  /**
1176
1204
  * The Plutus Data script address in JSON
1177
1205
  */
1178
- type ScriptAddress = ConStr0<[ConStr1<[ScriptHash]>, MaybeStakingHash]>;
1206
+ type ScriptAddress = ConStr0<[Script, MaybeStakingHash]>;
1179
1207
  /**
1180
1208
  * The Plutus Data credential in JSON
1181
1209
  */
1182
- type Credential = ConStr0<[PubKeyHash]> | ConStr1<[ScriptHash]>;
1210
+ type Credential = VerificationKey | Script;
1211
+ /**
1212
+ * The utility function to create a Plutus Data verification key in JSON
1213
+ * @param bytes The public key hash in hex
1214
+ * @returns The Plutus Data verification key object
1215
+ */
1216
+ declare const verificationKey: (bytes: string) => VerificationKey;
1217
+ /**
1218
+ * The utility function to create a Plutus Data script key in JSON
1219
+ * @param bytes The script hash in hex
1220
+ * @returns The Plutus Data script key object
1221
+ * */
1222
+ declare const script: (bytes: string) => Script;
1183
1223
  /**
1184
1224
  * The utility function to create a Plutus Data staking hash in JSON
1185
1225
  * @param stakeCredential The staking credential in hex
@@ -1730,4 +1770,4 @@ declare const hashDrepAnchor: (jsonLD: object) => string;
1730
1770
 
1731
1771
  declare function getFile(url: string): string;
1732
1772
 
1733
- export { type AccountInfo, type Action, type Anchor, type Asset, type AssetClass, type AssetExtended, AssetFingerprint, type AssetMetadata, type AssetName, type AssocMap, type AssocMapItem, type BasicVote, BigNum, type BlockInfo, type Bool, type Budget, type BuilderData, type BuiltinByteString, type ByteString, CIP68_100, CIP68_222, type Certificate, type CertificateType, type ConStr, type ConStr0, type ConStr1, type ConStr2, type ConStr3, type Credential, type CurrencySymbol, DEFAULT_FETCHER_OPTIONS, DEFAULT_PROTOCOL_PARAMETERS, DEFAULT_REDEEMER_BUDGET, DEFAULT_V1_COST_MODEL_LIST, DEFAULT_V2_COST_MODEL_LIST, DEFAULT_V3_COST_MODEL_LIST, DREP_DEPOSIT, type DRep, type Data, type DataSignature, type DatumSource, type DeserializedAddress, type DeserializedScript, type Dict, type DictItem, type Era, type Files, type ForkNeighbor, type FungibleAssetMetadata, type GovernanceProposalInfo, HARDENED_KEY_START, type IDeserializer, type IEvaluator, type IFetcher, type IFetcherOptions, type IInitiator, type IListener, type IMeshTxSerializer, type IMintingBlueprint, type IResolver, type ISigner, type ISpendingBlueprint, type ISubmitter, type IWallet, type IWithdrawalBlueprint, type ImageAssetMetadata, type Integer, LANGUAGE_VERSIONS, type LanguageVersion, type List, type MAssetClass, type MBool, type MConStr, type MConStr0, type MConStr1, type MConStr2, type MConStr3, type MCredential, type MMaybeStakingHash, type MNone, type MOption, type MOutputReference, type MPubKeyAddress, type MScriptAddress, type MSome, type MTuple, type MTxOutRef, type MValue, type MaybeStakingHash, type MeshTxBuilderBody, MeshValue, type Message, type Metadata, type Metadatum, type MetadatumMap, type Mint, type MintItem, type NativeScript, type Network, type NonFungibleAssetMetadata, type None, type Option, type Output, type OutputReference, POLICY_ID_LENGTH, type POSIXTime, type Pair, type Pairs, type PlutusData, type PlutusDataType, type PlutusScript, type PolicyId, type PoolMetadata, type PoolParams, type ProofStep, type ProofStepBranch, type ProofStepFork, type ProofStepLeaf, type Protocol, type PubKeyAddress, type PubKeyHash, type PubKeyTxIn, type PubKeyWithdrawal, type Quantity, type Recipient, type Redeemer, type RedeemerTagType, type RefTxIn, type Relay, type RequiredWith, type RoyaltiesStandard, SLOT_CONFIG_NETWORK, SUPPORTED_CLOCKS, SUPPORTED_HANDLES, SUPPORTED_LANGUAGE_VIEWS, SUPPORTED_OGMIOS_LINKS, SUPPORTED_TOKENS, SUPPORTED_WALLETS, type ScriptAddress, type ScriptHash, type ScriptSource, type ScriptTxIn, type ScriptTxInParameter, type ScriptVote, type ScriptWithdrawal, type SimpleScriptSourceInfo, type SimpleScriptTxIn, type SimpleScriptTxInParameter, type SimpleScriptVote, type SimpleScriptWithdrawal, type SlotConfig, type Some, type Token, type TokenName, type TransactionInfo, type Tuple, type TxIn, type TxInParameter, type TxMetadata, type TxOutRef, type UTxO, type Unit, UtxoSelection, type UtxoSelectionStrategy, type ValidityRange, type Value, type Vote, type VoteKind, type VoteType, type Voter, type VotingProcedure, type Wallet, type Withdrawal, assetClass, assetName, assocMap, bool, builtinByteString, byteString, bytesToHex, castProtocol, conStr, conStr0, conStr1, conStr2, conStr3, credential, currencySymbol, dict, emptyTxBuilderBody, experimentalSelectUtxos, fromUTF8, fungibleAssetKeys, getFile, hashByteString, hashDrepAnchor, hexToBytes, hexToString, integer, isNetwork, jsonProofToPlutusData, keepRelevant, largestFirst, largestFirstMultiAsset, list, mAssetClass, mBool, mConStr, mConStr0, mConStr1, mConStr2, mConStr3, mCredential, mMaybeStakingHash, mNone, mOption, mOutputReference, mPlutusBSArrayToString, mPubKeyAddress, mScriptAddress, mSome, mStringToPlutusBSArray, mTuple, mTxOutRef, mValue, maybeStakingHash, mergeAssets, metadataStandardKeys, metadataToCip68, none, option, outputReference, pairs, parseAssetUnit, plutusBSArrayToString, policyId, posixTime, pubKeyAddress, pubKeyHash, resolveEpochNo, resolveFingerprint, resolveLanguageView, resolveSlotNo, resolveTxFees, royaltiesStandardKeys, scriptAddress, scriptHash, slotToBeginUnixTime, some, stringToBSArray, stringToHex, toBytes, toUTF8, tokenName, tuple, txInToUtxo, txOutRef, unixTimeToEnclosingSlot, validityRangeToObj, value };
1773
+ export { type AccountInfo, type Action, type Anchor, type Asset, type AssetClass, type AssetExtended, AssetFingerprint, type AssetMetadata, type AssetName, type AssocMap, type AssocMapItem, type BasicVote, BigNum, type BlockInfo, type Bool, type Budget, type BuilderData, type BuiltinByteString, type ByteString, CIP68_100, CIP68_222, type Certificate, type CertificateType, type ConStr, type ConStr0, type ConStr1, type ConStr2, type ConStr3, type Credential, type CurrencySymbol, DEFAULT_FETCHER_OPTIONS, DEFAULT_PROTOCOL_PARAMETERS, DEFAULT_REDEEMER_BUDGET, DEFAULT_V1_COST_MODEL_LIST, DEFAULT_V2_COST_MODEL_LIST, DEFAULT_V3_COST_MODEL_LIST, DREP_DEPOSIT, type DRep, type Data, type DataSignature, type DatumSource, type DeserializedAddress, type DeserializedScript, type Dict, type DictItem, type Era, type Files, type ForkNeighbor, type FungibleAssetMetadata, type GovernanceProposalInfo, HARDENED_KEY_START, type IDeserializer, type IEvaluator, type IFetcher, type IFetcherOptions, type IInitiator, type IListener, type IMeshTxSerializer, type IMintingBlueprint, type IResolver, type ISigner, type ISpendingBlueprint, type ISubmitter, type IWallet, type IWithdrawalBlueprint, type ImageAssetMetadata, type Integer, LANGUAGE_VERSIONS, type LanguageVersion, type List, type MAssetClass, type MBool, type MConStr, type MConStr0, type MConStr1, type MConStr2, type MConStr3, type MCredential, type MMaybeStakingHash, type MNone, type MOption, type MOutputReference, type MPubKeyAddress, type MScript, type MScriptAddress, type MSome, type MTuple, type MTxOutRef, type MValue, type MVerificationKey, type MaybeStakingHash, type MeshTxBuilderBody, MeshValue, type Message, type Metadata, type Metadatum, type MetadatumMap, type Mint, type MintItem, type NativeScript, type Network, type NonFungibleAssetMetadata, type None, type Option, type Output, type OutputReference, POLICY_ID_LENGTH, type POSIXTime, type Pair, type Pairs, type PlutusData, type PlutusDataType, type PlutusScript, type PolicyId, type PoolMetadata, type PoolParams, type ProofStep, type ProofStepBranch, type ProofStepFork, type ProofStepLeaf, type Protocol, type PubKeyAddress, type PubKeyHash, type PubKeyTxIn, type PubKeyWithdrawal, type Quantity, type Recipient, type Redeemer, type RedeemerTagType, type RefTxIn, type Relay, type RequiredWith, type RoyaltiesStandard, SLOT_CONFIG_NETWORK, SUPPORTED_CLOCKS, SUPPORTED_HANDLES, SUPPORTED_LANGUAGE_VIEWS, SUPPORTED_OGMIOS_LINKS, SUPPORTED_TOKENS, SUPPORTED_WALLETS, type Script, type ScriptAddress, type ScriptHash, type ScriptSource, type ScriptTxIn, type ScriptTxInParameter, type ScriptVote, type ScriptWithdrawal, type SimpleScriptSourceInfo, type SimpleScriptTxIn, type SimpleScriptTxInParameter, type SimpleScriptVote, type SimpleScriptWithdrawal, type SlotConfig, type Some, type Token, type TokenName, type TransactionInfo, type Tuple, type TxIn, type TxInParameter, type TxMetadata, type TxOutRef, type UTxO, type Unit, UtxoSelection, type UtxoSelectionStrategy, type ValidityRange, type Value, type VerificationKey, type Vote, type VoteKind, type VoteType, type Voter, type VotingProcedure, type Wallet, type Withdrawal, assetClass, assetName, assocMap, bool, builtinByteString, byteString, bytesToHex, castProtocol, conStr, conStr0, conStr1, conStr2, conStr3, credential, currencySymbol, dict, emptyTxBuilderBody, experimentalSelectUtxos, fromUTF8, fungibleAssetKeys, getFile, hashByteString, hashDrepAnchor, hexToBytes, hexToString, integer, isNetwork, jsonProofToPlutusData, keepRelevant, largestFirst, largestFirstMultiAsset, list, mAssetClass, mBool, mConStr, mConStr0, mConStr1, mConStr2, mConStr3, mCredential, mMaybeStakingHash, mNone, mOption, mOutputReference, mPlutusBSArrayToString, mPubKeyAddress, mScript, mScriptAddress, mSome, mStringToPlutusBSArray, mTuple, mTxOutRef, mValue, mVerificationKey, maybeStakingHash, mergeAssets, metadataStandardKeys, metadataToCip68, none, option, outputReference, pairs, parseAssetUnit, plutusBSArrayToString, policyId, posixTime, pubKeyAddress, pubKeyHash, resolveEpochNo, resolveFingerprint, resolveLanguageView, resolveSlotNo, resolveTxFees, royaltiesStandardKeys, script, scriptAddress, scriptHash, slotToBeginUnixTime, some, stringToBSArray, stringToHex, toBytes, toUTF8, tokenName, tuple, txInToUtxo, txOutRef, unixTimeToEnclosingSlot, validityRangeToObj, value, verificationKey };
package/dist/index.js CHANGED
@@ -947,14 +947,16 @@ var mSome = (value2) => mConStr0([value2]);
947
947
  var mNone = () => mConStr1([]);
948
948
 
949
949
  // src/data/mesh/credentials.ts
950
+ var mVerificationKey = (bytes) => mConStr0([bytes]);
951
+ var mScript = (bytes) => mConStr1([bytes]);
950
952
  var mMaybeStakingHash = (stakeCredential, isStakeScriptCredential = false) => {
951
953
  if (stakeCredential === "") {
952
954
  return mConStr1([]);
953
955
  }
954
956
  if (isStakeScriptCredential) {
955
- return mConStr0([mConStr0([mConStr1([stakeCredential])])]);
957
+ return mConStr0([mConStr0([mScript(stakeCredential)])]);
956
958
  }
957
- return mConStr0([mConStr0([mConStr0([stakeCredential])])]);
959
+ return mConStr0([mConStr0([mVerificationKey(stakeCredential)])]);
958
960
  };
959
961
  var mPubKeyAddress = (bytes, stakeCredential, isStakeScriptCredential = false) => mConStr0([
960
962
  { alternative: 0, fields: [bytes] },
@@ -964,7 +966,7 @@ var mScriptAddress = (bytes, stakeCredential, isStakeScriptCredential = false) =
964
966
  { alternative: 1, fields: [bytes] },
965
967
  mMaybeStakingHash(stakeCredential || "", isStakeScriptCredential)
966
968
  ]);
967
- var mCredential = (hash, isScriptCredential = false) => isScriptCredential ? mConStr1([hash]) : mConStr0([hash]);
969
+ var mCredential = (hash, isScriptCredential = false) => isScriptCredential ? mScript(hash) : mVerificationKey(hash);
968
970
 
969
971
  // src/data/mesh/primitives.ts
970
972
  var mBool = (b) => b ? mConStr1([]) : mConStr0([]);
@@ -1068,7 +1070,9 @@ var pairs = (mapItems, validation = true) => ({
1068
1070
  // src/data/json/aliases.ts
1069
1071
  var hashByteString = (bytes) => {
1070
1072
  if (bytes.length !== 56) {
1071
- throw new Error(`Invalid hash for [${bytes}] - should be 56 bytes long`);
1073
+ throw new Error(
1074
+ `Invalid hash for [${bytes}] - should be 28 bytes (56 hex length) long`
1075
+ );
1072
1076
  }
1073
1077
  return byteString(bytes);
1074
1078
  };
@@ -1077,7 +1081,7 @@ var pubKeyHash = (bytes) => hashByteString(bytes);
1077
1081
  var policyId = (bytes) => {
1078
1082
  if (bytes.length !== POLICY_ID_LENGTH && bytes !== "") {
1079
1083
  throw new Error(
1080
- `Invalid policy id for [${bytes}] - should be ${POLICY_ID_LENGTH} bytes long or empty string for lovelace`
1084
+ `Invalid policy id for [${bytes}] - should be ${POLICY_ID_LENGTH / 2} bytes (${POLICY_ID_LENGTH} hex length) long or empty string for lovelace`
1081
1085
  );
1082
1086
  }
1083
1087
  return byteString(bytes);
@@ -1120,28 +1124,26 @@ var some = (value2) => conStr0([value2]);
1120
1124
  var none = () => conStr1([]);
1121
1125
 
1122
1126
  // src/data/json/credentials.ts
1127
+ var verificationKey = (bytes) => conStr0([pubKeyHash(bytes)]);
1128
+ var script = (bytes) => conStr1([scriptHash(bytes)]);
1123
1129
  var maybeStakingHash = (stakeCredential, isStakeScriptCredential = false) => {
1124
1130
  if (stakeCredential === "") {
1125
1131
  return conStr1([]);
1126
1132
  }
1127
1133
  if (isStakeScriptCredential) {
1128
- return conStr0([
1129
- conStr0([conStr1([scriptHash(stakeCredential)])])
1130
- ]);
1134
+ return conStr0([conStr0([script(stakeCredential)])]);
1131
1135
  }
1132
- return conStr0([
1133
- conStr0([conStr0([pubKeyHash(stakeCredential)])])
1134
- ]);
1136
+ return conStr0([conStr0([verificationKey(stakeCredential)])]);
1135
1137
  };
1136
1138
  var pubKeyAddress = (bytes, stakeCredential, isStakeScriptCredential = false) => conStr0([
1137
1139
  conStr0([pubKeyHash(bytes)]),
1138
1140
  maybeStakingHash(stakeCredential || "", isStakeScriptCredential)
1139
1141
  ]);
1140
1142
  var scriptAddress = (bytes, stakeCredential, isStakeScriptCredential = false) => conStr0([
1141
- conStr1([scriptHash(bytes)]),
1143
+ script(bytes),
1142
1144
  maybeStakingHash(stakeCredential || "", isStakeScriptCredential)
1143
1145
  ]);
1144
- var credential = (hash, isScriptCredential = false) => isScriptCredential ? conStr1([scriptHash(hash)]) : conStr0([pubKeyHash(hash)]);
1146
+ var credential = (hash, isScriptCredential = false) => isScriptCredential ? script(hash) : verificationKey(hash);
1145
1147
 
1146
1148
  // src/data/json/mpf.ts
1147
1149
  var jsonProofToPlutusData = (proof) => {
@@ -1944,12 +1946,14 @@ export {
1944
1946
  mOutputReference,
1945
1947
  mPlutusBSArrayToString,
1946
1948
  mPubKeyAddress,
1949
+ mScript,
1947
1950
  mScriptAddress,
1948
1951
  mSome,
1949
1952
  mStringToPlutusBSArray,
1950
1953
  mTuple,
1951
1954
  mTxOutRef,
1952
1955
  mValue,
1956
+ mVerificationKey,
1953
1957
  maybeStakingHash,
1954
1958
  mergeAssets,
1955
1959
  metadataStandardKeys,
@@ -1971,6 +1975,7 @@ export {
1971
1975
  resolveSlotNo,
1972
1976
  resolveTxFees,
1973
1977
  royaltiesStandardKeys,
1978
+ script,
1974
1979
  scriptAddress,
1975
1980
  scriptHash,
1976
1981
  slotToBeginUnixTime,
@@ -1985,5 +1990,6 @@ export {
1985
1990
  txOutRef,
1986
1991
  unixTimeToEnclosingSlot,
1987
1992
  validityRangeToObj,
1988
- value
1993
+ value,
1994
+ verificationKey
1989
1995
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meshsdk/common",
3
- "version": "1.9.0-beta.24",
3
+ "version": "1.9.0-beta.25",
4
4
  "description": "Contains constants, types and interfaces used across the SDK and different serialization libraries",
5
5
  "main": "./dist/index.cjs",
6
6
  "browser": "./dist/index.js",