@cardano-sdk/input-selection 0.6.1-nightly.1 → 0.7.0-nightly.0
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/cjs/selectionConstraints.d.ts +3 -3
- package/dist/cjs/selectionConstraints.d.ts.map +1 -1
- package/dist/cjs/selectionConstraints.js +15 -15
- package/dist/cjs/selectionConstraints.js.map +1 -1
- package/dist/cjs/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/selectionConstraints.d.ts +3 -3
- package/dist/esm/selectionConstraints.d.ts.map +1 -1
- package/dist/esm/selectionConstraints.js +15 -15
- package/dist/esm/selectionConstraints.js.map +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CML } from '@cardano-sdk/core';
|
|
2
|
-
import { ComputeMinimumCoinQuantity, ComputeSelectionLimit, EstimateTxFee, ProtocolParametersForInputSelection, SelectionConstraints, SelectionSkeleton, TokenBundleSizeExceedsLimit } from './types';
|
|
3
|
-
import {
|
|
4
|
-
export declare type BuildTx = (selection: SelectionSkeleton) => Promise<CML.Transaction>;
|
|
2
|
+
import { ComputeMinimumCoinQuantity, ComputeSelectionLimit, EstimateTxFee, ProtocolParametersForInputSelection, ProtocolParametersRequiredByInputSelection, SelectionConstraints, SelectionSkeleton, TokenBundleSizeExceedsLimit } from './types';
|
|
3
|
+
import { ManagedFreeableScope } from '@cardano-sdk/util';
|
|
4
|
+
export declare type BuildTx = (selection: SelectionSkeleton, scope: ManagedFreeableScope) => Promise<CML.Transaction>;
|
|
5
5
|
export interface DefaultSelectionConstraintsProps {
|
|
6
6
|
protocolParameters: ProtocolParametersForInputSelection;
|
|
7
7
|
buildTx: BuildTx;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selectionConstraints.d.ts","sourceRoot":"","sources":["../../src/selectionConstraints.ts"],"names":[],"mappings":"AAAA,OAAO,EA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
|
import { CML, InvalidProtocolParametersError, cmlUtil, coreToCml } from '@cardano-sdk/core';
|
|
2
2
|
import { usingAutoFree } from '@cardano-sdk/util';
|
|
3
|
-
export const computeMinimumCost = ({ minFeeCoefficient, minFeeConstant }, buildTx) => async (
|
|
4
|
-
const tx = await buildTx(selection);
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
3
|
+
export const computeMinimumCost = ({ minFeeCoefficient, minFeeConstant }, buildTx) => (selection) => usingAutoFree(async (scope) => {
|
|
4
|
+
const tx = await buildTx(selection, scope);
|
|
5
|
+
const priceMem = scope.manage(CML.UnitInterval.new(scope.manage(CML.BigNum.from_str('577')), scope.manage(CML.BigNum.from_str('10000'))));
|
|
6
|
+
const priceStep = scope.manage(CML.UnitInterval.new(scope.manage(CML.BigNum.from_str('721')), scope.manage(CML.BigNum.from_str('100000000'))));
|
|
7
|
+
const exInitPrices = scope.manage(CML.ExUnitPrices.new(priceMem, priceStep));
|
|
8
|
+
const linearFee = scope.manage(CML.LinearFee.new(scope.manage(CML.BigNum.from_str(minFeeCoefficient.toString())), scope.manage(CML.BigNum.from_str(minFeeConstant.toString()))));
|
|
9
|
+
const minFee = scope.manage(CML.min_fee(tx, linearFee, exInitPrices));
|
|
10
|
+
return BigInt(minFee.to_str());
|
|
11
|
+
});
|
|
12
|
+
export const computeMinimumCoinQuantity = (coinsPerUtxoByte) => (output) => usingAutoFree((scope) => BigInt(scope
|
|
13
|
+
.manage(CML.min_ada_required(coreToCml.txOut(scope, output), scope.manage(CML.BigNum.from_str(coinsPerUtxoByte.toString()))))
|
|
14
|
+
.to_str()));
|
|
15
15
|
export const tokenBundleSizeExceedsLimit = (maxValueSize) => (tokenBundle) => {
|
|
16
16
|
if (!tokenBundle) {
|
|
17
17
|
return false;
|
|
@@ -23,14 +23,14 @@ export const tokenBundleSizeExceedsLimit = (maxValueSize) => (tokenBundle) => {
|
|
|
23
23
|
});
|
|
24
24
|
};
|
|
25
25
|
const getTxSize = (tx) => tx.to_bytes().length;
|
|
26
|
-
export const computeSelectionLimit = (maxTxSize, buildTx) => async (
|
|
27
|
-
const tx = await buildTx(selectionSkeleton);
|
|
26
|
+
export const computeSelectionLimit = (maxTxSize, buildTx) => (selectionSkeleton) => usingAutoFree(async (scope) => {
|
|
27
|
+
const tx = await buildTx(selectionSkeleton, scope);
|
|
28
28
|
const txSize = getTxSize(tx);
|
|
29
29
|
if (txSize <= maxTxSize) {
|
|
30
30
|
return selectionSkeleton.inputs.size;
|
|
31
31
|
}
|
|
32
32
|
return selectionSkeleton.inputs.size - 1;
|
|
33
|
-
};
|
|
33
|
+
});
|
|
34
34
|
export const defaultSelectionConstraints = ({ protocolParameters: { coinsPerUtxoByte, maxTxSize, maxValueSize, minFeeCoefficient, minFeeConstant }, buildTx }) => {
|
|
35
35
|
if (!coinsPerUtxoByte || !maxTxSize || !maxValueSize || !minFeeCoefficient || !minFeeConstant) {
|
|
36
36
|
throw new InvalidProtocolParametersError('Missing one of: coinsPerUtxoByte, maxTxSize, maxValueSize, minFeeCoefficient, minFeeConstant');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selectionConstraints.js","sourceRoot":"","sources":["../../src/selectionConstraints.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,8BAA8B,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAW5F,OAAO,
|
|
1
|
+
{"version":3,"file":"selectionConstraints.js","sourceRoot":"","sources":["../../src/selectionConstraints.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,8BAA8B,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAW5F,OAAO,EAAwB,aAAa,EAAE,MAAM,mBAAmB,CAAC;AASxE,MAAM,CAAC,MAAM,kBAAkB,GAC7B,CACE,EACE,iBAAi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