@lucid-evolution/utils 0.1.33 → 0.1.34

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
@@ -1114,11 +1114,12 @@ function coresToTxOutputs(outputs) {
1114
1114
  }
1115
1115
  return result;
1116
1116
  }
1117
- var selectUTxOs = (utxos, totalAssets) => {
1117
+ var selectUTxOs = (utxos, totalAssets, includeUTxOsWithScriptRef = false) => {
1118
1118
  const selectedUtxos = [];
1119
1119
  let isSelected = false;
1120
1120
  const assetsRequired = new Map(Object.entries(totalAssets));
1121
1121
  for (const utxo of utxos) {
1122
+ if (!includeUTxOsWithScriptRef && utxo.scriptRef) continue;
1122
1123
  isSelected = false;
1123
1124
  for (const [unit, amount] of assetsRequired) {
1124
1125
  if (Object.hasOwn(utxo.assets, unit)) {
package/dist/index.d.cts CHANGED
@@ -107,7 +107,13 @@ declare function coreToOutRef(input: CML.TransactionInput): OutRef;
107
107
  declare function coresToOutRefs(inputs: CML.TransactionInput[]): OutRef[];
108
108
  declare function coreToTxOutput(output: CML.TransactionOutput): TxOutput;
109
109
  declare function coresToTxOutputs(outputs: CML.TransactionOutput[]): TxOutput[];
110
- declare const selectUTxOs: (utxos: UTxO[], totalAssets: Assets) => UTxO[];
110
+ /**
111
+ * Returns a list of UTxOs whose total assets are equal to or greater than the asset value provided
112
+ * @param utxos list of available utxos
113
+ * @param totalAssets minimum total assets required
114
+ * @param includeUTxOsWithScriptRef Whether to include UTxOs with scriptRef or not. default = false
115
+ */
116
+ declare const selectUTxOs: (utxos: UTxO[], totalAssets: Assets, includeUTxOsWithScriptRef?: boolean) => UTxO[];
111
117
  /**
112
118
  * Union type for specifying sorting order in function "sortUTxOs"
113
119
  */
package/dist/index.d.ts CHANGED
@@ -107,7 +107,13 @@ declare function coreToOutRef(input: CML.TransactionInput): OutRef;
107
107
  declare function coresToOutRefs(inputs: CML.TransactionInput[]): OutRef[];
108
108
  declare function coreToTxOutput(output: CML.TransactionOutput): TxOutput;
109
109
  declare function coresToTxOutputs(outputs: CML.TransactionOutput[]): TxOutput[];
110
- declare const selectUTxOs: (utxos: UTxO[], totalAssets: Assets) => UTxO[];
110
+ /**
111
+ * Returns a list of UTxOs whose total assets are equal to or greater than the asset value provided
112
+ * @param utxos list of available utxos
113
+ * @param totalAssets minimum total assets required
114
+ * @param includeUTxOsWithScriptRef Whether to include UTxOs with scriptRef or not. default = false
115
+ */
116
+ declare const selectUTxOs: (utxos: UTxO[], totalAssets: Assets, includeUTxOsWithScriptRef?: boolean) => UTxO[];
111
117
  /**
112
118
  * Union type for specifying sorting order in function "sortUTxOs"
113
119
  */
package/dist/index.js CHANGED
@@ -1030,11 +1030,12 @@ function coresToTxOutputs(outputs) {
1030
1030
  }
1031
1031
  return result;
1032
1032
  }
1033
- var selectUTxOs = (utxos, totalAssets) => {
1033
+ var selectUTxOs = (utxos, totalAssets, includeUTxOsWithScriptRef = false) => {
1034
1034
  const selectedUtxos = [];
1035
1035
  let isSelected = false;
1036
1036
  const assetsRequired = new Map(Object.entries(totalAssets));
1037
1037
  for (const utxo of utxos) {
1038
+ if (!includeUTxOsWithScriptRef && utxo.scriptRef) continue;
1038
1039
  isSelected = false;
1039
1040
  for (const [unit, amount] of assetsRequired) {
1040
1041
  if (Object.hasOwn(utxo.assets, unit)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lucid-evolution/utils",
3
- "version": "0.1.33",
3
+ "version": "0.1.34",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",