@lucid-evolution/utils 0.1.22 → 0.1.24
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 +23 -17
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +22 -17
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -36,6 +36,7 @@ __export(src_exports, {
|
|
|
36
36
|
applyDoubleCborEncoding: () => applyDoubleCborEncoding,
|
|
37
37
|
applyParamsToScript: () => applyParamsToScript,
|
|
38
38
|
assetsToValue: () => assetsToValue,
|
|
39
|
+
calculateMinLovelaceFromUTxO: () => calculateMinLovelaceFromUTxO,
|
|
39
40
|
coreToOutRef: () => coreToOutRef,
|
|
40
41
|
coreToTxOutput: () => coreToTxOutput,
|
|
41
42
|
coreToUtxo: () => coreToUtxo,
|
|
@@ -1045,23 +1046,6 @@ async function getUniqueTokenName(utxo) {
|
|
|
1045
1046
|
|
|
1046
1047
|
// src/utxo.ts
|
|
1047
1048
|
var utxoToTransactionOutput = (utxo) => {
|
|
1048
|
-
const buildDatum = (utxo2, builder) => {
|
|
1049
|
-
if (utxo2.datumHash)
|
|
1050
|
-
return builder.with_data(
|
|
1051
|
-
CML.DatumOption.new_hash(CML.DatumHash.from_hex(utxo2.datumHash))
|
|
1052
|
-
);
|
|
1053
|
-
if (utxo2.datum)
|
|
1054
|
-
return builder.with_data(
|
|
1055
|
-
CML.DatumOption.new_datum(CML.PlutusData.from_cbor_hex(utxo2.datum))
|
|
1056
|
-
);
|
|
1057
|
-
return builder;
|
|
1058
|
-
};
|
|
1059
|
-
const buildOutput = (utxo2) => {
|
|
1060
|
-
const builder = CML.TransactionOutputBuilder.new().with_address(
|
|
1061
|
-
CML.Address.from_bech32(utxo2.address)
|
|
1062
|
-
);
|
|
1063
|
-
return utxo2.scriptRef ? buildDatum(utxo2, builder).with_reference_script(toScriptRef(utxo2.scriptRef)).next() : buildDatum(utxo2, builder).next();
|
|
1064
|
-
};
|
|
1065
1049
|
return buildOutput(utxo).with_value(assetsToValue(utxo.assets)).build().output();
|
|
1066
1050
|
};
|
|
1067
1051
|
var utxoToTransactionInput = (utxo) => {
|
|
@@ -1187,6 +1171,27 @@ var smallestFirst = (a, b) => {
|
|
|
1187
1171
|
return lovelaceA - lovelaceB;
|
|
1188
1172
|
};
|
|
1189
1173
|
var isEqualUTxO = (self, that) => self.txHash === that.txHash && self.outputIndex === that.outputIndex;
|
|
1174
|
+
var calculateMinLovelaceFromUTxO = (coinsPerUtxoByte, utxo) => buildOutput(utxo).with_asset_and_min_required_coin(
|
|
1175
|
+
assetsToValue(utxo.assets).multi_asset(),
|
|
1176
|
+
coinsPerUtxoByte
|
|
1177
|
+
).build().output().amount().coin();
|
|
1178
|
+
var buildOutput = (utxo) => {
|
|
1179
|
+
const builder = CML.TransactionOutputBuilder.new().with_address(
|
|
1180
|
+
CML.Address.from_bech32(utxo.address)
|
|
1181
|
+
);
|
|
1182
|
+
return utxo.scriptRef ? buildDatum(utxo, builder).with_reference_script(toScriptRef(utxo.scriptRef)).next() : buildDatum(utxo, builder).next();
|
|
1183
|
+
};
|
|
1184
|
+
var buildDatum = (utxo, builder) => {
|
|
1185
|
+
if (utxo.datumHash)
|
|
1186
|
+
return builder.with_data(
|
|
1187
|
+
CML.DatumOption.new_hash(CML.DatumHash.from_hex(utxo.datumHash))
|
|
1188
|
+
);
|
|
1189
|
+
if (utxo.datum)
|
|
1190
|
+
return builder.with_data(
|
|
1191
|
+
CML.DatumOption.new_datum(CML.PlutusData.from_cbor_hex(utxo.datum))
|
|
1192
|
+
);
|
|
1193
|
+
return builder;
|
|
1194
|
+
};
|
|
1190
1195
|
|
|
1191
1196
|
// src/objects.ts
|
|
1192
1197
|
var stringify = (data) => JSON.stringify(
|
|
@@ -1202,6 +1207,7 @@ var stringify = (data) => JSON.stringify(
|
|
|
1202
1207
|
applyDoubleCborEncoding,
|
|
1203
1208
|
applyParamsToScript,
|
|
1204
1209
|
assetsToValue,
|
|
1210
|
+
calculateMinLovelaceFromUTxO,
|
|
1205
1211
|
coreToOutRef,
|
|
1206
1212
|
coreToTxOutput,
|
|
1207
1213
|
coreToUtxo,
|
package/dist/index.d.cts
CHANGED
|
@@ -130,6 +130,7 @@ type SortOrder =
|
|
|
130
130
|
*/
|
|
131
131
|
declare const sortUTxOs: (utxos: UTxO[], order?: SortOrder) => UTxO[];
|
|
132
132
|
declare const isEqualUTxO: (self: UTxO, that: UTxO) => boolean;
|
|
133
|
+
declare const calculateMinLovelaceFromUTxO: (coinsPerUtxoByte: bigint, utxo: UTxO) => bigint;
|
|
133
134
|
|
|
134
135
|
declare function valueToAssets(value: CML.Value): Assets;
|
|
135
136
|
declare function assetsToValue(assets: Assets): CML.Value;
|
|
@@ -156,4 +157,4 @@ declare function getUniqueTokenName(utxo: UTxO): Promise<string>;
|
|
|
156
157
|
|
|
157
158
|
declare const stringify: (data: any) => string;
|
|
158
159
|
|
|
159
|
-
export { type CMLNative, PROTOCOL_PARAMETERS_DEFAULT, type SortOrder, addAssets, addressFromHexOrBech32, applyDoubleCborEncoding, applyParamsToScript, assetsToValue, coreToOutRef, coreToTxOutput, coreToUtxo, coresToOutRefs, coresToTxOutputs, coresToUtxos, createCostModels, credentialToAddress, credentialToRewardAddress, datumToHash, fromLabel, fromScriptRef, fromUnit, generatePrivateKey, generateSeedPhrase, getAddressDetails, getUniqueTokenName, isEqualUTxO, keyHashToCredential, mintingPolicyToId, networkToId, parseCMLNative, paymentCredentialOf, scriptFromCMLNative, scriptFromNative, scriptHashToCredential, selectUTxOs, slotToUnixTime, sortUTxOs, stakeCredentialOf, stringify, toCMLNativeScript, toLabel, toPublicKey, toScriptRef, toUnit, unixTimeToSlot, utxoToCore, utxoToTransactionInput, utxoToTransactionOutput, utxosToCores, validatorToAddress, validatorToRewardAddress, validatorToScriptHash, valueToAssets };
|
|
160
|
+
export { type CMLNative, PROTOCOL_PARAMETERS_DEFAULT, type SortOrder, addAssets, addressFromHexOrBech32, applyDoubleCborEncoding, applyParamsToScript, assetsToValue, calculateMinLovelaceFromUTxO, coreToOutRef, coreToTxOutput, coreToUtxo, coresToOutRefs, coresToTxOutputs, coresToUtxos, createCostModels, credentialToAddress, credentialToRewardAddress, datumToHash, fromLabel, fromScriptRef, fromUnit, generatePrivateKey, generateSeedPhrase, getAddressDetails, getUniqueTokenName, isEqualUTxO, keyHashToCredential, mintingPolicyToId, networkToId, parseCMLNative, paymentCredentialOf, scriptFromCMLNative, scriptFromNative, scriptHashToCredential, selectUTxOs, slotToUnixTime, sortUTxOs, stakeCredentialOf, stringify, toCMLNativeScript, toLabel, toPublicKey, toScriptRef, toUnit, unixTimeToSlot, utxoToCore, utxoToTransactionInput, utxoToTransactionOutput, utxosToCores, validatorToAddress, validatorToRewardAddress, validatorToScriptHash, valueToAssets };
|
package/dist/index.d.ts
CHANGED
|
@@ -130,6 +130,7 @@ type SortOrder =
|
|
|
130
130
|
*/
|
|
131
131
|
declare const sortUTxOs: (utxos: UTxO[], order?: SortOrder) => UTxO[];
|
|
132
132
|
declare const isEqualUTxO: (self: UTxO, that: UTxO) => boolean;
|
|
133
|
+
declare const calculateMinLovelaceFromUTxO: (coinsPerUtxoByte: bigint, utxo: UTxO) => bigint;
|
|
133
134
|
|
|
134
135
|
declare function valueToAssets(value: CML.Value): Assets;
|
|
135
136
|
declare function assetsToValue(assets: Assets): CML.Value;
|
|
@@ -156,4 +157,4 @@ declare function getUniqueTokenName(utxo: UTxO): Promise<string>;
|
|
|
156
157
|
|
|
157
158
|
declare const stringify: (data: any) => string;
|
|
158
159
|
|
|
159
|
-
export { type CMLNative, PROTOCOL_PARAMETERS_DEFAULT, type SortOrder, addAssets, addressFromHexOrBech32, applyDoubleCborEncoding, applyParamsToScript, assetsToValue, coreToOutRef, coreToTxOutput, coreToUtxo, coresToOutRefs, coresToTxOutputs, coresToUtxos, createCostModels, credentialToAddress, credentialToRewardAddress, datumToHash, fromLabel, fromScriptRef, fromUnit, generatePrivateKey, generateSeedPhrase, getAddressDetails, getUniqueTokenName, isEqualUTxO, keyHashToCredential, mintingPolicyToId, networkToId, parseCMLNative, paymentCredentialOf, scriptFromCMLNative, scriptFromNative, scriptHashToCredential, selectUTxOs, slotToUnixTime, sortUTxOs, stakeCredentialOf, stringify, toCMLNativeScript, toLabel, toPublicKey, toScriptRef, toUnit, unixTimeToSlot, utxoToCore, utxoToTransactionInput, utxoToTransactionOutput, utxosToCores, validatorToAddress, validatorToRewardAddress, validatorToScriptHash, valueToAssets };
|
|
160
|
+
export { type CMLNative, PROTOCOL_PARAMETERS_DEFAULT, type SortOrder, addAssets, addressFromHexOrBech32, applyDoubleCborEncoding, applyParamsToScript, assetsToValue, calculateMinLovelaceFromUTxO, coreToOutRef, coreToTxOutput, coreToUtxo, coresToOutRefs, coresToTxOutputs, coresToUtxos, createCostModels, credentialToAddress, credentialToRewardAddress, datumToHash, fromLabel, fromScriptRef, fromUnit, generatePrivateKey, generateSeedPhrase, getAddressDetails, getUniqueTokenName, isEqualUTxO, keyHashToCredential, mintingPolicyToId, networkToId, parseCMLNative, paymentCredentialOf, scriptFromCMLNative, scriptFromNative, scriptHashToCredential, selectUTxOs, slotToUnixTime, sortUTxOs, stakeCredentialOf, stringify, toCMLNativeScript, toLabel, toPublicKey, toScriptRef, toUnit, unixTimeToSlot, utxoToCore, utxoToTransactionInput, utxoToTransactionOutput, utxosToCores, validatorToAddress, validatorToRewardAddress, validatorToScriptHash, valueToAssets };
|
package/dist/index.js
CHANGED
|
@@ -963,23 +963,6 @@ async function getUniqueTokenName(utxo) {
|
|
|
963
963
|
|
|
964
964
|
// src/utxo.ts
|
|
965
965
|
var utxoToTransactionOutput = (utxo) => {
|
|
966
|
-
const buildDatum = (utxo2, builder) => {
|
|
967
|
-
if (utxo2.datumHash)
|
|
968
|
-
return builder.with_data(
|
|
969
|
-
CML.DatumOption.new_hash(CML.DatumHash.from_hex(utxo2.datumHash))
|
|
970
|
-
);
|
|
971
|
-
if (utxo2.datum)
|
|
972
|
-
return builder.with_data(
|
|
973
|
-
CML.DatumOption.new_datum(CML.PlutusData.from_cbor_hex(utxo2.datum))
|
|
974
|
-
);
|
|
975
|
-
return builder;
|
|
976
|
-
};
|
|
977
|
-
const buildOutput = (utxo2) => {
|
|
978
|
-
const builder = CML.TransactionOutputBuilder.new().with_address(
|
|
979
|
-
CML.Address.from_bech32(utxo2.address)
|
|
980
|
-
);
|
|
981
|
-
return utxo2.scriptRef ? buildDatum(utxo2, builder).with_reference_script(toScriptRef(utxo2.scriptRef)).next() : buildDatum(utxo2, builder).next();
|
|
982
|
-
};
|
|
983
966
|
return buildOutput(utxo).with_value(assetsToValue(utxo.assets)).build().output();
|
|
984
967
|
};
|
|
985
968
|
var utxoToTransactionInput = (utxo) => {
|
|
@@ -1105,6 +1088,27 @@ var smallestFirst = (a, b) => {
|
|
|
1105
1088
|
return lovelaceA - lovelaceB;
|
|
1106
1089
|
};
|
|
1107
1090
|
var isEqualUTxO = (self, that) => self.txHash === that.txHash && self.outputIndex === that.outputIndex;
|
|
1091
|
+
var calculateMinLovelaceFromUTxO = (coinsPerUtxoByte, utxo) => buildOutput(utxo).with_asset_and_min_required_coin(
|
|
1092
|
+
assetsToValue(utxo.assets).multi_asset(),
|
|
1093
|
+
coinsPerUtxoByte
|
|
1094
|
+
).build().output().amount().coin();
|
|
1095
|
+
var buildOutput = (utxo) => {
|
|
1096
|
+
const builder = CML.TransactionOutputBuilder.new().with_address(
|
|
1097
|
+
CML.Address.from_bech32(utxo.address)
|
|
1098
|
+
);
|
|
1099
|
+
return utxo.scriptRef ? buildDatum(utxo, builder).with_reference_script(toScriptRef(utxo.scriptRef)).next() : buildDatum(utxo, builder).next();
|
|
1100
|
+
};
|
|
1101
|
+
var buildDatum = (utxo, builder) => {
|
|
1102
|
+
if (utxo.datumHash)
|
|
1103
|
+
return builder.with_data(
|
|
1104
|
+
CML.DatumOption.new_hash(CML.DatumHash.from_hex(utxo.datumHash))
|
|
1105
|
+
);
|
|
1106
|
+
if (utxo.datum)
|
|
1107
|
+
return builder.with_data(
|
|
1108
|
+
CML.DatumOption.new_datum(CML.PlutusData.from_cbor_hex(utxo.datum))
|
|
1109
|
+
);
|
|
1110
|
+
return builder;
|
|
1111
|
+
};
|
|
1108
1112
|
|
|
1109
1113
|
// src/objects.ts
|
|
1110
1114
|
var stringify = (data) => JSON.stringify(
|
|
@@ -1119,6 +1123,7 @@ export {
|
|
|
1119
1123
|
applyDoubleCborEncoding,
|
|
1120
1124
|
applyParamsToScript,
|
|
1121
1125
|
assetsToValue,
|
|
1126
|
+
calculateMinLovelaceFromUTxO,
|
|
1122
1127
|
coreToOutRef,
|
|
1123
1128
|
coreToTxOutput,
|
|
1124
1129
|
coreToUtxo,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lucid-evolution/utils",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.24",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@lucid-evolution/core-utils": "0.1.7",
|
|
39
39
|
"@lucid-evolution/crc8": "0.1.7",
|
|
40
40
|
"@lucid-evolution/plutus": "0.1.12",
|
|
41
|
-
"@lucid-evolution/uplc": "0.2.
|
|
41
|
+
"@lucid-evolution/uplc": "0.2.8"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@types/node": "^20.12.8",
|