@meshsdk/transaction 1.9.0-beta.102 → 1.9.0-beta.103
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 +58 -4
- package/dist/index.d.cts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +62 -5
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -1423,7 +1423,7 @@ var BuilderCallbacksSdkBridge = class {
|
|
|
1423
1423
|
change: selectionSkeleton.change.map(
|
|
1424
1424
|
(output) => CSDKOutputToMeshOutput(output)
|
|
1425
1425
|
),
|
|
1426
|
-
fee:
|
|
1426
|
+
fee: BigInt(1e9)
|
|
1427
1427
|
});
|
|
1428
1428
|
return {
|
|
1429
1429
|
fee: costs.fee,
|
|
@@ -1765,7 +1765,6 @@ var CSDKRedeemerTagToMeshRedeemerTag = (tag) => {
|
|
|
1765
1765
|
};
|
|
1766
1766
|
|
|
1767
1767
|
// src/mesh-tx-builder/coin-selection/largest-first-selector.ts
|
|
1768
|
-
var MAX_U64 = 18446744073709551615n;
|
|
1769
1768
|
var mergeValue = (a, b) => {
|
|
1770
1769
|
const merged = new Map(a);
|
|
1771
1770
|
b.forEach((quantity, unit) => {
|
|
@@ -2012,7 +2011,7 @@ var LargestFirstInputSelector = class {
|
|
|
2012
2011
|
newInputs: selectedUtxos,
|
|
2013
2012
|
newOutputs: /* @__PURE__ */ new Set(),
|
|
2014
2013
|
change: changeOutputs,
|
|
2015
|
-
fee:
|
|
2014
|
+
fee: BigInt(1e9)
|
|
2016
2015
|
})).fee;
|
|
2017
2016
|
}
|
|
2018
2017
|
}
|
|
@@ -3536,6 +3535,15 @@ var MeshTxBuilderCore = class {
|
|
|
3536
3535
|
this.meshTxBuilderBody.network = network;
|
|
3537
3536
|
return this;
|
|
3538
3537
|
};
|
|
3538
|
+
/**
|
|
3539
|
+
* Alias for setNetwork for custom cost models
|
|
3540
|
+
* @param costModels
|
|
3541
|
+
* @returns The MeshTxBuilder instance
|
|
3542
|
+
*/
|
|
3543
|
+
setCostModels = (costModels) => {
|
|
3544
|
+
this.setNetwork(costModels);
|
|
3545
|
+
return this;
|
|
3546
|
+
};
|
|
3539
3547
|
/**
|
|
3540
3548
|
* Add a transaction that is used as input, but not yet reflected on the global blockchain
|
|
3541
3549
|
* @param txHex The transaction hex of chained transaction
|
|
@@ -4028,6 +4036,37 @@ var MeshTxBuilder = class _MeshTxBuilder extends MeshTxBuilderCore {
|
|
|
4028
4036
|
this._protocolParams
|
|
4029
4037
|
);
|
|
4030
4038
|
};
|
|
4039
|
+
completeCostModels = async () => {
|
|
4040
|
+
console.log("completing cost models...");
|
|
4041
|
+
if (Array.isArray(this.meshTxBuilderBody.network)) {
|
|
4042
|
+
return;
|
|
4043
|
+
}
|
|
4044
|
+
const defaults = [
|
|
4045
|
+
import_common3.DEFAULT_V1_COST_MODEL_LIST,
|
|
4046
|
+
import_common3.DEFAULT_V2_COST_MODEL_LIST,
|
|
4047
|
+
import_common3.DEFAULT_V3_COST_MODEL_LIST
|
|
4048
|
+
];
|
|
4049
|
+
if (this.fetcher) {
|
|
4050
|
+
try {
|
|
4051
|
+
console.log("fetching cost models from fetcher...");
|
|
4052
|
+
const costModels = await this.fetcher.fetchCostModels();
|
|
4053
|
+
if (Array.isArray(costModels) && costModels.length > 0) {
|
|
4054
|
+
this.meshTxBuilderBody.network = costModels;
|
|
4055
|
+
return;
|
|
4056
|
+
}
|
|
4057
|
+
console.warn(
|
|
4058
|
+
"fetchCostModels returned an invalid value, using default cost models:",
|
|
4059
|
+
costModels
|
|
4060
|
+
);
|
|
4061
|
+
} catch (error) {
|
|
4062
|
+
console.warn(
|
|
4063
|
+
"Failed to fetch cost models, using default cost models. Error: ",
|
|
4064
|
+
error
|
|
4065
|
+
);
|
|
4066
|
+
}
|
|
4067
|
+
}
|
|
4068
|
+
this.meshTxBuilderBody.network = defaults;
|
|
4069
|
+
};
|
|
4031
4070
|
/**
|
|
4032
4071
|
* It builds the transaction query the blockchain for missing information
|
|
4033
4072
|
* @param customizedTx The optional customized transaction body
|
|
@@ -4071,6 +4110,7 @@ var MeshTxBuilder = class _MeshTxBuilder extends MeshTxBuilderCore {
|
|
|
4071
4110
|
this.setFee(customizedTx.fee);
|
|
4072
4111
|
}
|
|
4073
4112
|
}
|
|
4113
|
+
await this.completeCostModels();
|
|
4074
4114
|
this.queueAllLastItem();
|
|
4075
4115
|
if (this.verbose) {
|
|
4076
4116
|
console.log(
|
|
@@ -4128,7 +4168,15 @@ var MeshTxBuilder = class _MeshTxBuilder extends MeshTxBuilderCore {
|
|
|
4128
4168
|
const selectionCallbacks = {
|
|
4129
4169
|
computeMinimumCost: async (selectionSkeleton) => {
|
|
4130
4170
|
const clonedBuilder = this.clone();
|
|
4131
|
-
|
|
4171
|
+
if (this.manualFee) {
|
|
4172
|
+
const newSelectionSkeleton = {
|
|
4173
|
+
...selectionSkeleton,
|
|
4174
|
+
fee: BigInt(this.manualFee)
|
|
4175
|
+
};
|
|
4176
|
+
await clonedBuilder.updateByTxPrototype(newSelectionSkeleton);
|
|
4177
|
+
} else {
|
|
4178
|
+
await clonedBuilder.updateByTxPrototype(selectionSkeleton);
|
|
4179
|
+
}
|
|
4132
4180
|
try {
|
|
4133
4181
|
await clonedBuilder.evaluateRedeemers();
|
|
4134
4182
|
} catch (error) {
|
|
@@ -6209,6 +6257,8 @@ var TxParser = class {
|
|
|
6209
6257
|
this.serializer = serializer;
|
|
6210
6258
|
this.fetcher = fetcher;
|
|
6211
6259
|
}
|
|
6260
|
+
serializer;
|
|
6261
|
+
fetcher;
|
|
6212
6262
|
parse = async (txHex, providedUtxos = []) => {
|
|
6213
6263
|
const resolvedUtxos = [...providedUtxos];
|
|
6214
6264
|
const resolvedUtxosSet = new Set(
|
|
@@ -6258,6 +6308,7 @@ var SpendBuilderImpl = class {
|
|
|
6258
6308
|
constructor(builder) {
|
|
6259
6309
|
this.builder = builder;
|
|
6260
6310
|
}
|
|
6311
|
+
builder;
|
|
6261
6312
|
script(scriptCbor) {
|
|
6262
6313
|
this.builder.txInScript(scriptCbor);
|
|
6263
6314
|
return this;
|
|
@@ -6309,6 +6360,7 @@ var MintBuilderImpl = class {
|
|
|
6309
6360
|
constructor(builder) {
|
|
6310
6361
|
this.builder = builder;
|
|
6311
6362
|
}
|
|
6363
|
+
builder;
|
|
6312
6364
|
script(scriptCbor) {
|
|
6313
6365
|
this.builder.mintingScript(scriptCbor);
|
|
6314
6366
|
return this;
|
|
@@ -6342,6 +6394,7 @@ var WithdrawBuilderImpl = class {
|
|
|
6342
6394
|
constructor(builder) {
|
|
6343
6395
|
this.builder = builder;
|
|
6344
6396
|
}
|
|
6397
|
+
builder;
|
|
6345
6398
|
script(scriptCbor) {
|
|
6346
6399
|
this.builder.withdrawalScript(scriptCbor);
|
|
6347
6400
|
return this;
|
|
@@ -6371,6 +6424,7 @@ var VoteBuilderImpl = class {
|
|
|
6371
6424
|
constructor(builder) {
|
|
6372
6425
|
this.builder = builder;
|
|
6373
6426
|
}
|
|
6427
|
+
builder;
|
|
6374
6428
|
script(scriptCbor) {
|
|
6375
6429
|
this.builder.voteScript(scriptCbor);
|
|
6376
6430
|
return this;
|
package/dist/index.d.cts
CHANGED
|
@@ -582,6 +582,12 @@ declare class MeshTxBuilderCore {
|
|
|
582
582
|
* @returns The MeshTxBuilder instance
|
|
583
583
|
*/
|
|
584
584
|
setNetwork: (network: Network | number[][]) => this;
|
|
585
|
+
/**
|
|
586
|
+
* Alias for setNetwork for custom cost models
|
|
587
|
+
* @param costModels
|
|
588
|
+
* @returns The MeshTxBuilder instance
|
|
589
|
+
*/
|
|
590
|
+
setCostModels: (costModels: number[][]) => this;
|
|
585
591
|
/**
|
|
586
592
|
* Add a transaction that is used as input, but not yet reflected on the global blockchain
|
|
587
593
|
* @param txHex The transaction hex of chained transaction
|
|
@@ -652,6 +658,7 @@ declare class MeshTxBuilder extends MeshTxBuilderCore {
|
|
|
652
658
|
protected utxosWithRefScripts: UTxO[];
|
|
653
659
|
constructor({ serializer, selector, fetcher, submitter, evaluator, params, isHydra, verbose, }?: MeshTxBuilderOptions);
|
|
654
660
|
serializeMockTx: () => string;
|
|
661
|
+
completeCostModels: () => Promise<void>;
|
|
655
662
|
/**
|
|
656
663
|
* It builds the transaction query the blockchain for missing information
|
|
657
664
|
* @param customizedTx The optional customized transaction body
|
package/dist/index.d.ts
CHANGED
|
@@ -582,6 +582,12 @@ declare class MeshTxBuilderCore {
|
|
|
582
582
|
* @returns The MeshTxBuilder instance
|
|
583
583
|
*/
|
|
584
584
|
setNetwork: (network: Network | number[][]) => this;
|
|
585
|
+
/**
|
|
586
|
+
* Alias for setNetwork for custom cost models
|
|
587
|
+
* @param costModels
|
|
588
|
+
* @returns The MeshTxBuilder instance
|
|
589
|
+
*/
|
|
590
|
+
setCostModels: (costModels: number[][]) => this;
|
|
585
591
|
/**
|
|
586
592
|
* Add a transaction that is used as input, but not yet reflected on the global blockchain
|
|
587
593
|
* @param txHex The transaction hex of chained transaction
|
|
@@ -652,6 +658,7 @@ declare class MeshTxBuilder extends MeshTxBuilderCore {
|
|
|
652
658
|
protected utxosWithRefScripts: UTxO[];
|
|
653
659
|
constructor({ serializer, selector, fetcher, submitter, evaluator, params, isHydra, verbose, }?: MeshTxBuilderOptions);
|
|
654
660
|
serializeMockTx: () => string;
|
|
661
|
+
completeCostModels: () => Promise<void>;
|
|
655
662
|
/**
|
|
656
663
|
* It builds the transaction query the blockchain for missing information
|
|
657
664
|
* @param customizedTx The optional customized transaction body
|
package/dist/index.js
CHANGED
|
@@ -1345,7 +1345,10 @@ var bignumber_default = BigNumber;
|
|
|
1345
1345
|
// src/mesh-tx-builder/index.ts
|
|
1346
1346
|
import JSONBig3 from "json-bigint";
|
|
1347
1347
|
import {
|
|
1348
|
-
DEFAULT_PROTOCOL_PARAMETERS as DEFAULT_PROTOCOL_PARAMETERS3
|
|
1348
|
+
DEFAULT_PROTOCOL_PARAMETERS as DEFAULT_PROTOCOL_PARAMETERS3,
|
|
1349
|
+
DEFAULT_V1_COST_MODEL_LIST,
|
|
1350
|
+
DEFAULT_V2_COST_MODEL_LIST,
|
|
1351
|
+
DEFAULT_V3_COST_MODEL_LIST
|
|
1349
1352
|
} from "@meshsdk/common";
|
|
1350
1353
|
import {
|
|
1351
1354
|
CardanoSDKSerializer,
|
|
@@ -1390,7 +1393,7 @@ var BuilderCallbacksSdkBridge = class {
|
|
|
1390
1393
|
change: selectionSkeleton.change.map(
|
|
1391
1394
|
(output) => CSDKOutputToMeshOutput(output)
|
|
1392
1395
|
),
|
|
1393
|
-
fee:
|
|
1396
|
+
fee: BigInt(1e9)
|
|
1394
1397
|
});
|
|
1395
1398
|
return {
|
|
1396
1399
|
fee: costs.fee,
|
|
@@ -1732,7 +1735,6 @@ var CSDKRedeemerTagToMeshRedeemerTag = (tag) => {
|
|
|
1732
1735
|
};
|
|
1733
1736
|
|
|
1734
1737
|
// src/mesh-tx-builder/coin-selection/largest-first-selector.ts
|
|
1735
|
-
var MAX_U64 = 18446744073709551615n;
|
|
1736
1738
|
var mergeValue = (a, b) => {
|
|
1737
1739
|
const merged = new Map(a);
|
|
1738
1740
|
b.forEach((quantity, unit) => {
|
|
@@ -1979,7 +1981,7 @@ var LargestFirstInputSelector = class {
|
|
|
1979
1981
|
newInputs: selectedUtxos,
|
|
1980
1982
|
newOutputs: /* @__PURE__ */ new Set(),
|
|
1981
1983
|
change: changeOutputs,
|
|
1982
|
-
fee:
|
|
1984
|
+
fee: BigInt(1e9)
|
|
1983
1985
|
})).fee;
|
|
1984
1986
|
}
|
|
1985
1987
|
}
|
|
@@ -3510,6 +3512,15 @@ var MeshTxBuilderCore = class {
|
|
|
3510
3512
|
this.meshTxBuilderBody.network = network;
|
|
3511
3513
|
return this;
|
|
3512
3514
|
};
|
|
3515
|
+
/**
|
|
3516
|
+
* Alias for setNetwork for custom cost models
|
|
3517
|
+
* @param costModels
|
|
3518
|
+
* @returns The MeshTxBuilder instance
|
|
3519
|
+
*/
|
|
3520
|
+
setCostModels = (costModels) => {
|
|
3521
|
+
this.setNetwork(costModels);
|
|
3522
|
+
return this;
|
|
3523
|
+
};
|
|
3513
3524
|
/**
|
|
3514
3525
|
* Add a transaction that is used as input, but not yet reflected on the global blockchain
|
|
3515
3526
|
* @param txHex The transaction hex of chained transaction
|
|
@@ -4004,6 +4015,37 @@ var MeshTxBuilder = class _MeshTxBuilder extends MeshTxBuilderCore {
|
|
|
4004
4015
|
this._protocolParams
|
|
4005
4016
|
);
|
|
4006
4017
|
};
|
|
4018
|
+
completeCostModels = async () => {
|
|
4019
|
+
console.log("completing cost models...");
|
|
4020
|
+
if (Array.isArray(this.meshTxBuilderBody.network)) {
|
|
4021
|
+
return;
|
|
4022
|
+
}
|
|
4023
|
+
const defaults = [
|
|
4024
|
+
DEFAULT_V1_COST_MODEL_LIST,
|
|
4025
|
+
DEFAULT_V2_COST_MODEL_LIST,
|
|
4026
|
+
DEFAULT_V3_COST_MODEL_LIST
|
|
4027
|
+
];
|
|
4028
|
+
if (this.fetcher) {
|
|
4029
|
+
try {
|
|
4030
|
+
console.log("fetching cost models from fetcher...");
|
|
4031
|
+
const costModels = await this.fetcher.fetchCostModels();
|
|
4032
|
+
if (Array.isArray(costModels) && costModels.length > 0) {
|
|
4033
|
+
this.meshTxBuilderBody.network = costModels;
|
|
4034
|
+
return;
|
|
4035
|
+
}
|
|
4036
|
+
console.warn(
|
|
4037
|
+
"fetchCostModels returned an invalid value, using default cost models:",
|
|
4038
|
+
costModels
|
|
4039
|
+
);
|
|
4040
|
+
} catch (error) {
|
|
4041
|
+
console.warn(
|
|
4042
|
+
"Failed to fetch cost models, using default cost models. Error: ",
|
|
4043
|
+
error
|
|
4044
|
+
);
|
|
4045
|
+
}
|
|
4046
|
+
}
|
|
4047
|
+
this.meshTxBuilderBody.network = defaults;
|
|
4048
|
+
};
|
|
4007
4049
|
/**
|
|
4008
4050
|
* It builds the transaction query the blockchain for missing information
|
|
4009
4051
|
* @param customizedTx The optional customized transaction body
|
|
@@ -4047,6 +4089,7 @@ var MeshTxBuilder = class _MeshTxBuilder extends MeshTxBuilderCore {
|
|
|
4047
4089
|
this.setFee(customizedTx.fee);
|
|
4048
4090
|
}
|
|
4049
4091
|
}
|
|
4092
|
+
await this.completeCostModels();
|
|
4050
4093
|
this.queueAllLastItem();
|
|
4051
4094
|
if (this.verbose) {
|
|
4052
4095
|
console.log(
|
|
@@ -4104,7 +4147,15 @@ var MeshTxBuilder = class _MeshTxBuilder extends MeshTxBuilderCore {
|
|
|
4104
4147
|
const selectionCallbacks = {
|
|
4105
4148
|
computeMinimumCost: async (selectionSkeleton) => {
|
|
4106
4149
|
const clonedBuilder = this.clone();
|
|
4107
|
-
|
|
4150
|
+
if (this.manualFee) {
|
|
4151
|
+
const newSelectionSkeleton = {
|
|
4152
|
+
...selectionSkeleton,
|
|
4153
|
+
fee: BigInt(this.manualFee)
|
|
4154
|
+
};
|
|
4155
|
+
await clonedBuilder.updateByTxPrototype(newSelectionSkeleton);
|
|
4156
|
+
} else {
|
|
4157
|
+
await clonedBuilder.updateByTxPrototype(selectionSkeleton);
|
|
4158
|
+
}
|
|
4108
4159
|
try {
|
|
4109
4160
|
await clonedBuilder.evaluateRedeemers();
|
|
4110
4161
|
} catch (error) {
|
|
@@ -6208,6 +6259,8 @@ var TxParser = class {
|
|
|
6208
6259
|
this.serializer = serializer;
|
|
6209
6260
|
this.fetcher = fetcher;
|
|
6210
6261
|
}
|
|
6262
|
+
serializer;
|
|
6263
|
+
fetcher;
|
|
6211
6264
|
parse = async (txHex, providedUtxos = []) => {
|
|
6212
6265
|
const resolvedUtxos = [...providedUtxos];
|
|
6213
6266
|
const resolvedUtxosSet = new Set(
|
|
@@ -6259,6 +6312,7 @@ var SpendBuilderImpl = class {
|
|
|
6259
6312
|
constructor(builder) {
|
|
6260
6313
|
this.builder = builder;
|
|
6261
6314
|
}
|
|
6315
|
+
builder;
|
|
6262
6316
|
script(scriptCbor) {
|
|
6263
6317
|
this.builder.txInScript(scriptCbor);
|
|
6264
6318
|
return this;
|
|
@@ -6310,6 +6364,7 @@ var MintBuilderImpl = class {
|
|
|
6310
6364
|
constructor(builder) {
|
|
6311
6365
|
this.builder = builder;
|
|
6312
6366
|
}
|
|
6367
|
+
builder;
|
|
6313
6368
|
script(scriptCbor) {
|
|
6314
6369
|
this.builder.mintingScript(scriptCbor);
|
|
6315
6370
|
return this;
|
|
@@ -6343,6 +6398,7 @@ var WithdrawBuilderImpl = class {
|
|
|
6343
6398
|
constructor(builder) {
|
|
6344
6399
|
this.builder = builder;
|
|
6345
6400
|
}
|
|
6401
|
+
builder;
|
|
6346
6402
|
script(scriptCbor) {
|
|
6347
6403
|
this.builder.withdrawalScript(scriptCbor);
|
|
6348
6404
|
return this;
|
|
@@ -6372,6 +6428,7 @@ var VoteBuilderImpl = class {
|
|
|
6372
6428
|
constructor(builder) {
|
|
6373
6429
|
this.builder = builder;
|
|
6374
6430
|
}
|
|
6431
|
+
builder;
|
|
6375
6432
|
script(scriptCbor) {
|
|
6376
6433
|
this.builder.voteScript(scriptCbor);
|
|
6377
6434
|
return this;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meshsdk/transaction",
|
|
3
|
-
"version": "1.9.0-beta.
|
|
3
|
+
"version": "1.9.0-beta.103",
|
|
4
4
|
"description": "Transactions - https://meshjs.dev/apis/transaction",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"browser": "./dist/index.js",
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"typescript": "^5.3.3"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@meshsdk/common": "1.9.0-beta.
|
|
39
|
-
"@meshsdk/core-cst": "1.9.0-beta.
|
|
38
|
+
"@meshsdk/common": "1.9.0-beta.103",
|
|
39
|
+
"@meshsdk/core-cst": "1.9.0-beta.103",
|
|
40
40
|
"@cardano-sdk/core": "0.46.12",
|
|
41
41
|
"@cardano-sdk/util": "0.17.1",
|
|
42
42
|
"@cardano-sdk/input-selection": "0.14.28",
|