@fivebinaries/coin-selection
Advanced tools
Comparing version 2.0.0-beta.2 to 2.0.0-beta.3
@@ -14,2 +14,6 @@ import * as CardanoWasm from '@emurgo/cardano-serialization-lib-browser'; | ||
}; | ||
readonly UTXO_VALUE_TOO_SMALL: { | ||
readonly code: "UTXO_VALUE_TOO_SMALL"; | ||
readonly message: "UTxO value too small"; | ||
}; | ||
readonly UNSUPPORTED_CERTIFICATE_TYPE: { | ||
@@ -16,0 +20,0 @@ readonly code: "UNSUPPORTED_CERTIFICATE_TYPE"; |
@@ -15,2 +15,6 @@ import * as CardanoWasm from '@emurgo/cardano-serialization-lib-browser'; | ||
}, | ||
UTXO_VALUE_TOO_SMALL: { | ||
code: 'UTXO_VALUE_TOO_SMALL', | ||
message: 'UTxO value too small', | ||
}, | ||
UNSUPPORTED_CERTIFICATE_TYPE: { | ||
@@ -17,0 +21,0 @@ code: 'UNSUPPORTED_CERTIFICATE_TYPE', |
@@ -169,2 +169,3 @@ import * as CardanoWasm from '@emurgo/cardano-serialization-lib-browser'; | ||
if (output.assets.length > 0 && outputAmount.compare(minOutputAmount) < 0) { | ||
// output with an asset(s) adjust minimum ADA to met network requirements | ||
amount = minOutputAmount.to_str(); | ||
@@ -175,2 +176,12 @@ } | ||
} | ||
if (!output.setMax && | ||
output.assets.length === 0 && | ||
output.amount && | ||
outputAmount.compare(minOutputAmount) < 0) { | ||
// Case of an output without any asset, and without setMax = true | ||
// If the user entered less than min utxo val then throw an error (won't throw if there is no amount yet) | ||
// (On outputs with setMax flag we set '0' on purpose) | ||
// (On outputs with an asset we automatically adjust ADA amount if it is below required minimum) | ||
throw new CoinSelectionError(ERROR.UTXO_VALUE_TOO_SMALL); | ||
} | ||
if (output.setMax) { | ||
@@ -186,3 +197,3 @@ // if setMax is active set initial value to 0 | ||
return Object.assign(Object.assign({}, output), { | ||
// if output contains assets make sure that minUtxoValue is at least minOutputAmount (even for output where we want to setMax) | ||
// if output contains assets make sure that minUtxoValue is at least minOutputAmount (even for output where we want to setMax) | ||
amount }); | ||
@@ -189,0 +200,0 @@ }); |
{ | ||
"name": "@fivebinaries/coin-selection", | ||
"version": "2.0.0-beta.2", | ||
"version": "2.0.0-beta.3", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
64019
1315