@lucid-evolution/utils 0.1.18 → 0.1.19
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 +9 -1
- package/dist/index.d.cts +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +9 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -52,6 +52,7 @@ __export(src_exports, {
|
|
|
52
52
|
generatePrivateKey: () => generatePrivateKey,
|
|
53
53
|
generateSeedPhrase: () => generateSeedPhrase,
|
|
54
54
|
getAddressDetails: () => getAddressDetails,
|
|
55
|
+
getUniqueTokenName: () => getUniqueTokenName,
|
|
55
56
|
isEqualUTxO: () => isEqualUTxO,
|
|
56
57
|
keyHashToCredential: () => keyHashToCredential,
|
|
57
58
|
mintingPolicyToId: () => mintingPolicyToId,
|
|
@@ -940,7 +941,7 @@ function valueToAssets(value) {
|
|
|
940
941
|
for (let k = 0; k < assetNames.len(); k++) {
|
|
941
942
|
const policyAsset = assetNames.get(k);
|
|
942
943
|
const quantity = policyAssets.get(policyAsset);
|
|
943
|
-
const unit = policy.to_hex() +
|
|
944
|
+
const unit = policy.to_hex() + policyAsset.to_js_value();
|
|
944
945
|
assets[unit] = quantity;
|
|
945
946
|
}
|
|
946
947
|
}
|
|
@@ -1000,6 +1001,12 @@ function addAssets(...assets) {
|
|
|
1000
1001
|
return a;
|
|
1001
1002
|
}, {});
|
|
1002
1003
|
}
|
|
1004
|
+
async function getUniqueTokenName(utxo) {
|
|
1005
|
+
const id = (0, import_core_utils4.fromHex)(utxo.txHash);
|
|
1006
|
+
const data = new Uint8Array([utxo.outputIndex, ...id]);
|
|
1007
|
+
const hash = new Uint8Array(await crypto.subtle.digest("SHA3-256", data));
|
|
1008
|
+
return (0, import_core_utils4.toHex)(hash);
|
|
1009
|
+
}
|
|
1003
1010
|
|
|
1004
1011
|
// src/utxo.ts
|
|
1005
1012
|
var utxoToTransactionOutput = (utxo) => {
|
|
@@ -1171,6 +1178,7 @@ var stringify = (data) => JSON.stringify(
|
|
|
1171
1178
|
generatePrivateKey,
|
|
1172
1179
|
generateSeedPhrase,
|
|
1173
1180
|
getAddressDetails,
|
|
1181
|
+
getUniqueTokenName,
|
|
1174
1182
|
isEqualUTxO,
|
|
1175
1183
|
keyHashToCredential,
|
|
1176
1184
|
mintingPolicyToId,
|
package/dist/index.d.cts
CHANGED
|
@@ -100,7 +100,12 @@ declare function fromUnit(unit: Unit): {
|
|
|
100
100
|
*/
|
|
101
101
|
declare function toUnit(policyId: PolicyId, name?: string | null, label?: number | null): Unit;
|
|
102
102
|
declare function addAssets(...assets: Assets[]): Assets;
|
|
103
|
+
/**
|
|
104
|
+
* Returns a unique token name which is SHA3-256 hash of UTxO's txid and idx
|
|
105
|
+
* @param utxo UTxO whose OutRef will be used
|
|
106
|
+
*/
|
|
107
|
+
declare function getUniqueTokenName(utxo: UTxO): Promise<string>;
|
|
103
108
|
|
|
104
109
|
declare const stringify: (data: any) => string;
|
|
105
110
|
|
|
106
|
-
export { 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, isEqualUTxO, keyHashToCredential, mintingPolicyToId, nativeFromJson, nativeJSFromJson, nativeScriptFromJson, networkToId, paymentCredentialOf, scriptHashToCredential, selectUTxOs, slotToUnixTime, sortUTxOs, stakeCredentialOf, stringify, toLabel, toNativeScript, toPublicKey, toScriptRef, toUnit, unixTimeToSlot, utxoToCore, utxoToTransactionInput, utxoToTransactionOutput, utxosToCores, validatorToAddress, validatorToRewardAddress, validatorToScriptHash, valueToAssets };
|
|
111
|
+
export { 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, nativeFromJson, nativeJSFromJson, nativeScriptFromJson, networkToId, paymentCredentialOf, scriptHashToCredential, selectUTxOs, slotToUnixTime, sortUTxOs, stakeCredentialOf, stringify, toLabel, toNativeScript, toPublicKey, toScriptRef, toUnit, unixTimeToSlot, utxoToCore, utxoToTransactionInput, utxoToTransactionOutput, utxosToCores, validatorToAddress, validatorToRewardAddress, validatorToScriptHash, valueToAssets };
|
package/dist/index.d.ts
CHANGED
|
@@ -100,7 +100,12 @@ declare function fromUnit(unit: Unit): {
|
|
|
100
100
|
*/
|
|
101
101
|
declare function toUnit(policyId: PolicyId, name?: string | null, label?: number | null): Unit;
|
|
102
102
|
declare function addAssets(...assets: Assets[]): Assets;
|
|
103
|
+
/**
|
|
104
|
+
* Returns a unique token name which is SHA3-256 hash of UTxO's txid and idx
|
|
105
|
+
* @param utxo UTxO whose OutRef will be used
|
|
106
|
+
*/
|
|
107
|
+
declare function getUniqueTokenName(utxo: UTxO): Promise<string>;
|
|
103
108
|
|
|
104
109
|
declare const stringify: (data: any) => string;
|
|
105
110
|
|
|
106
|
-
export { 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, isEqualUTxO, keyHashToCredential, mintingPolicyToId, nativeFromJson, nativeJSFromJson, nativeScriptFromJson, networkToId, paymentCredentialOf, scriptHashToCredential, selectUTxOs, slotToUnixTime, sortUTxOs, stakeCredentialOf, stringify, toLabel, toNativeScript, toPublicKey, toScriptRef, toUnit, unixTimeToSlot, utxoToCore, utxoToTransactionInput, utxoToTransactionOutput, utxosToCores, validatorToAddress, validatorToRewardAddress, validatorToScriptHash, valueToAssets };
|
|
111
|
+
export { 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, nativeFromJson, nativeJSFromJson, nativeScriptFromJson, networkToId, paymentCredentialOf, scriptHashToCredential, selectUTxOs, slotToUnixTime, sortUTxOs, stakeCredentialOf, stringify, toLabel, toNativeScript, toPublicKey, toScriptRef, toUnit, unixTimeToSlot, utxoToCore, utxoToTransactionInput, utxoToTransactionOutput, utxosToCores, validatorToAddress, validatorToRewardAddress, validatorToScriptHash, valueToAssets };
|
package/dist/index.js
CHANGED
|
@@ -845,7 +845,7 @@ function slotToUnixTime(network, slot) {
|
|
|
845
845
|
}
|
|
846
846
|
|
|
847
847
|
// src/value.ts
|
|
848
|
-
import { fromHex as fromHex4,
|
|
848
|
+
import { fromHex as fromHex4, toHex as toHex3 } from "@lucid-evolution/core-utils";
|
|
849
849
|
function valueToAssets(value) {
|
|
850
850
|
const assets = {};
|
|
851
851
|
assets["lovelace"] = value.coin();
|
|
@@ -859,7 +859,7 @@ function valueToAssets(value) {
|
|
|
859
859
|
for (let k = 0; k < assetNames.len(); k++) {
|
|
860
860
|
const policyAsset = assetNames.get(k);
|
|
861
861
|
const quantity = policyAssets.get(policyAsset);
|
|
862
|
-
const unit = policy.to_hex() +
|
|
862
|
+
const unit = policy.to_hex() + policyAsset.to_js_value();
|
|
863
863
|
assets[unit] = quantity;
|
|
864
864
|
}
|
|
865
865
|
}
|
|
@@ -919,6 +919,12 @@ function addAssets(...assets) {
|
|
|
919
919
|
return a;
|
|
920
920
|
}, {});
|
|
921
921
|
}
|
|
922
|
+
async function getUniqueTokenName(utxo) {
|
|
923
|
+
const id = fromHex4(utxo.txHash);
|
|
924
|
+
const data = new Uint8Array([utxo.outputIndex, ...id]);
|
|
925
|
+
const hash = new Uint8Array(await crypto.subtle.digest("SHA3-256", data));
|
|
926
|
+
return toHex3(hash);
|
|
927
|
+
}
|
|
922
928
|
|
|
923
929
|
// src/utxo.ts
|
|
924
930
|
var utxoToTransactionOutput = (utxo) => {
|
|
@@ -1089,6 +1095,7 @@ export {
|
|
|
1089
1095
|
generatePrivateKey,
|
|
1090
1096
|
generateSeedPhrase,
|
|
1091
1097
|
getAddressDetails,
|
|
1098
|
+
getUniqueTokenName,
|
|
1092
1099
|
isEqualUTxO,
|
|
1093
1100
|
keyHashToCredential,
|
|
1094
1101
|
mintingPolicyToId,
|