@lucid-evolution/utils 0.1.58 → 0.1.59
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 +30 -0
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +28 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -30,11 +30,13 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var src_exports = {};
|
|
32
32
|
__export(src_exports, {
|
|
33
|
+
CBOREncodingLevel: () => CBOREncodingLevel,
|
|
33
34
|
PROTOCOL_PARAMETERS_DEFAULT: () => PROTOCOL_PARAMETERS_DEFAULT,
|
|
34
35
|
addAssets: () => addAssets,
|
|
35
36
|
addressFromHexOrBech32: () => addressFromHexOrBech32,
|
|
36
37
|
applyDoubleCborEncoding: () => applyDoubleCborEncoding,
|
|
37
38
|
applyParamsToScript: () => applyParamsToScript,
|
|
39
|
+
applySingleCborEncoding: () => applySingleCborEncoding,
|
|
38
40
|
assetsToValue: () => assetsToValue,
|
|
39
41
|
calculateMinLovelaceFromUTxO: () => calculateMinLovelaceFromUTxO,
|
|
40
42
|
coreToOutRef: () => coreToOutRef,
|
|
@@ -206,6 +208,32 @@ var applyDoubleCborEncoding = (script) => {
|
|
|
206
208
|
}
|
|
207
209
|
}
|
|
208
210
|
};
|
|
211
|
+
var applySingleCborEncoding = (script) => {
|
|
212
|
+
try {
|
|
213
|
+
(0, import_cbor_x.decode)((0, import_cbor_x.decode)((0, import_core_utils.fromHex)(script)));
|
|
214
|
+
return (0, import_core_utils.toHex)((0, import_cbor_x.decode)((0, import_core_utils.fromHex)(script)));
|
|
215
|
+
} catch (error) {
|
|
216
|
+
try {
|
|
217
|
+
(0, import_cbor_x.decode)((0, import_core_utils.fromHex)(script));
|
|
218
|
+
return script;
|
|
219
|
+
} catch (error2) {
|
|
220
|
+
return (0, import_core_utils.toHex)(Uint8Array.from((0, import_cbor_x.encode)((0, import_core_utils.fromHex)(script).buffer)));
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
var CBOREncodingLevel = (script) => {
|
|
225
|
+
try {
|
|
226
|
+
(0, import_cbor_x.decode)((0, import_cbor_x.decode)((0, import_core_utils.fromHex)(script)));
|
|
227
|
+
return "double";
|
|
228
|
+
} catch (error) {
|
|
229
|
+
try {
|
|
230
|
+
(0, import_cbor_x.decode)((0, import_core_utils.fromHex)(script));
|
|
231
|
+
return "single";
|
|
232
|
+
} catch (error2) {
|
|
233
|
+
throw new Error("Script is not CBOR-encoded or invalid format.");
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
};
|
|
209
237
|
function datumJsonToCbor(json) {
|
|
210
238
|
const convert = (json2) => {
|
|
211
239
|
if (!isNaN(json2.int)) {
|
|
@@ -1656,11 +1684,13 @@ var fromCMLRedeemerTag = (tag) => {
|
|
|
1656
1684
|
};
|
|
1657
1685
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1658
1686
|
0 && (module.exports = {
|
|
1687
|
+
CBOREncodingLevel,
|
|
1659
1688
|
PROTOCOL_PARAMETERS_DEFAULT,
|
|
1660
1689
|
addAssets,
|
|
1661
1690
|
addressFromHexOrBech32,
|
|
1662
1691
|
applyDoubleCborEncoding,
|
|
1663
1692
|
applyParamsToScript,
|
|
1693
|
+
applySingleCborEncoding,
|
|
1664
1694
|
assetsToValue,
|
|
1665
1695
|
calculateMinLovelaceFromUTxO,
|
|
1666
1696
|
coreToOutRef,
|
package/dist/index.d.cts
CHANGED
|
@@ -66,6 +66,8 @@ declare function validatorToRewardAddress(network: Network, validator: Certifica
|
|
|
66
66
|
declare function getAddressDetails(address: string): AddressDetails;
|
|
67
67
|
|
|
68
68
|
declare const applyDoubleCborEncoding: (script: string) => string;
|
|
69
|
+
declare const applySingleCborEncoding: (script: string) => string;
|
|
70
|
+
declare const CBOREncodingLevel: (script: string) => "double" | "single";
|
|
69
71
|
declare function datumJsonToCbor(json: DatumJson): Datum;
|
|
70
72
|
|
|
71
73
|
declare function createCostModels(costModels: CostModels): CML.CostModels;
|
|
@@ -193,4 +195,4 @@ declare const stringify: (data: any) => string;
|
|
|
193
195
|
declare const toCMLRedeemerTag: (tag: string) => CML.RedeemerTag;
|
|
194
196
|
declare const fromCMLRedeemerTag: (tag: CML.RedeemerTag) => RedeemerTag;
|
|
195
197
|
|
|
196
|
-
export { type CMLNative, PROTOCOL_PARAMETERS_DEFAULT, type SortOrder, addAssets, addressFromHexOrBech32, applyDoubleCborEncoding, applyParamsToScript, assetsToValue, calculateMinLovelaceFromUTxO, coreToOutRef, coreToTxOutput, coreToUtxo, coresToOutRefs, coresToTxOutputs, coresToUtxos, createCostModels, credentialToAddress, credentialToRewardAddress, datumJsonToCbor, datumToHash, fromCMLRedeemerTag, fromLabel, fromScriptRef, fromUnit, generatePrivateKey, generateSeedPhrase, getAddressDetails, getInputIndices, getUniqueTokenName, isEqualUTxO, keyHashToCredential, mintingPolicyToId, networkToId, parseCMLNative, paymentCredentialOf, scriptFromCMLNative, scriptFromNative, scriptHashToCredential, selectUTxOs, slotToUnixTime, sortCanonical, sortUTxOs, stakeCredentialOf, stringify, toCMLNativeScript, toCMLRedeemerTag, toLabel, toPublicKey, toScriptRef, toUnit, unixTimeToSlot, utxoToCore, utxoToTransactionInput, utxoToTransactionOutput, utxosToCores, validatorToAddress, validatorToRewardAddress, validatorToScriptHash, valueToAssets };
|
|
198
|
+
export { CBOREncodingLevel, type CMLNative, PROTOCOL_PARAMETERS_DEFAULT, type SortOrder, addAssets, addressFromHexOrBech32, applyDoubleCborEncoding, applyParamsToScript, applySingleCborEncoding, assetsToValue, calculateMinLovelaceFromUTxO, coreToOutRef, coreToTxOutput, coreToUtxo, coresToOutRefs, coresToTxOutputs, coresToUtxos, createCostModels, credentialToAddress, credentialToRewardAddress, datumJsonToCbor, datumToHash, fromCMLRedeemerTag, fromLabel, fromScriptRef, fromUnit, generatePrivateKey, generateSeedPhrase, getAddressDetails, getInputIndices, getUniqueTokenName, isEqualUTxO, keyHashToCredential, mintingPolicyToId, networkToId, parseCMLNative, paymentCredentialOf, scriptFromCMLNative, scriptFromNative, scriptHashToCredential, selectUTxOs, slotToUnixTime, sortCanonical, sortUTxOs, stakeCredentialOf, stringify, toCMLNativeScript, toCMLRedeemerTag, toLabel, toPublicKey, toScriptRef, toUnit, unixTimeToSlot, utxoToCore, utxoToTransactionInput, utxoToTransactionOutput, utxosToCores, validatorToAddress, validatorToRewardAddress, validatorToScriptHash, valueToAssets };
|
package/dist/index.d.ts
CHANGED
|
@@ -66,6 +66,8 @@ declare function validatorToRewardAddress(network: Network, validator: Certifica
|
|
|
66
66
|
declare function getAddressDetails(address: string): AddressDetails;
|
|
67
67
|
|
|
68
68
|
declare const applyDoubleCborEncoding: (script: string) => string;
|
|
69
|
+
declare const applySingleCborEncoding: (script: string) => string;
|
|
70
|
+
declare const CBOREncodingLevel: (script: string) => "double" | "single";
|
|
69
71
|
declare function datumJsonToCbor(json: DatumJson): Datum;
|
|
70
72
|
|
|
71
73
|
declare function createCostModels(costModels: CostModels): CML.CostModels;
|
|
@@ -193,4 +195,4 @@ declare const stringify: (data: any) => string;
|
|
|
193
195
|
declare const toCMLRedeemerTag: (tag: string) => CML.RedeemerTag;
|
|
194
196
|
declare const fromCMLRedeemerTag: (tag: CML.RedeemerTag) => RedeemerTag;
|
|
195
197
|
|
|
196
|
-
export { type CMLNative, PROTOCOL_PARAMETERS_DEFAULT, type SortOrder, addAssets, addressFromHexOrBech32, applyDoubleCborEncoding, applyParamsToScript, assetsToValue, calculateMinLovelaceFromUTxO, coreToOutRef, coreToTxOutput, coreToUtxo, coresToOutRefs, coresToTxOutputs, coresToUtxos, createCostModels, credentialToAddress, credentialToRewardAddress, datumJsonToCbor, datumToHash, fromCMLRedeemerTag, fromLabel, fromScriptRef, fromUnit, generatePrivateKey, generateSeedPhrase, getAddressDetails, getInputIndices, getUniqueTokenName, isEqualUTxO, keyHashToCredential, mintingPolicyToId, networkToId, parseCMLNative, paymentCredentialOf, scriptFromCMLNative, scriptFromNative, scriptHashToCredential, selectUTxOs, slotToUnixTime, sortCanonical, sortUTxOs, stakeCredentialOf, stringify, toCMLNativeScript, toCMLRedeemerTag, toLabel, toPublicKey, toScriptRef, toUnit, unixTimeToSlot, utxoToCore, utxoToTransactionInput, utxoToTransactionOutput, utxosToCores, validatorToAddress, validatorToRewardAddress, validatorToScriptHash, valueToAssets };
|
|
198
|
+
export { CBOREncodingLevel, type CMLNative, PROTOCOL_PARAMETERS_DEFAULT, type SortOrder, addAssets, addressFromHexOrBech32, applyDoubleCborEncoding, applyParamsToScript, applySingleCborEncoding, assetsToValue, calculateMinLovelaceFromUTxO, coreToOutRef, coreToTxOutput, coreToUtxo, coresToOutRefs, coresToTxOutputs, coresToUtxos, createCostModels, credentialToAddress, credentialToRewardAddress, datumJsonToCbor, datumToHash, fromCMLRedeemerTag, fromLabel, fromScriptRef, fromUnit, generatePrivateKey, generateSeedPhrase, getAddressDetails, getInputIndices, getUniqueTokenName, isEqualUTxO, keyHashToCredential, mintingPolicyToId, networkToId, parseCMLNative, paymentCredentialOf, scriptFromCMLNative, scriptFromNative, scriptHashToCredential, selectUTxOs, slotToUnixTime, sortCanonical, sortUTxOs, stakeCredentialOf, stringify, toCMLNativeScript, toCMLRedeemerTag, toLabel, toPublicKey, toScriptRef, toUnit, unixTimeToSlot, utxoToCore, utxoToTransactionInput, utxoToTransactionOutput, utxosToCores, validatorToAddress, validatorToRewardAddress, validatorToScriptHash, valueToAssets };
|
package/dist/index.js
CHANGED
|
@@ -114,6 +114,32 @@ var applyDoubleCborEncoding = (script) => {
|
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
};
|
|
117
|
+
var applySingleCborEncoding = (script) => {
|
|
118
|
+
try {
|
|
119
|
+
decode(decode(fromHex(script)));
|
|
120
|
+
return toHex(decode(fromHex(script)));
|
|
121
|
+
} catch (error) {
|
|
122
|
+
try {
|
|
123
|
+
decode(fromHex(script));
|
|
124
|
+
return script;
|
|
125
|
+
} catch (error2) {
|
|
126
|
+
return toHex(Uint8Array.from(encode(fromHex(script).buffer)));
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
var CBOREncodingLevel = (script) => {
|
|
131
|
+
try {
|
|
132
|
+
decode(decode(fromHex(script)));
|
|
133
|
+
return "double";
|
|
134
|
+
} catch (error) {
|
|
135
|
+
try {
|
|
136
|
+
decode(fromHex(script));
|
|
137
|
+
return "single";
|
|
138
|
+
} catch (error2) {
|
|
139
|
+
throw new Error("Script is not CBOR-encoded or invalid format.");
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
};
|
|
117
143
|
function datumJsonToCbor(json) {
|
|
118
144
|
const convert = (json2) => {
|
|
119
145
|
if (!isNaN(json2.int)) {
|
|
@@ -1573,11 +1599,13 @@ var fromCMLRedeemerTag = (tag) => {
|
|
|
1573
1599
|
}
|
|
1574
1600
|
};
|
|
1575
1601
|
export {
|
|
1602
|
+
CBOREncodingLevel,
|
|
1576
1603
|
PROTOCOL_PARAMETERS_DEFAULT,
|
|
1577
1604
|
addAssets,
|
|
1578
1605
|
addressFromHexOrBech32,
|
|
1579
1606
|
applyDoubleCborEncoding,
|
|
1580
1607
|
applyParamsToScript,
|
|
1608
|
+
applySingleCborEncoding,
|
|
1581
1609
|
assetsToValue,
|
|
1582
1610
|
calculateMinLovelaceFromUTxO,
|
|
1583
1611
|
coreToOutRef,
|