Skip to content

Commit

Permalink
fix ledger
Browse files Browse the repository at this point in the history
  • Loading branch information
ljttl3q04t committed May 29, 2024
1 parent 266b76f commit 36cda41
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions packages/translucent/src/translucent/tx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,10 +330,16 @@ export class Tx {
parseInt(output.output().amount().coin().to_str()),
Number(assets.lovelace || 0),
);
valueBuilder = valueBuilder.with_coin_and_asset(
C.BigNum.from_str(coin.toString()),
masset,
);
if (masset.len() > 0) {
valueBuilder = valueBuilder.with_coin_and_asset(
C.BigNum.from_str(coin.toString()),
masset,
);
} else {
valueBuilder = valueBuilder.with_coin(
C.BigNum.from_str(coin.toString())
);
}
}
let output = valueBuilder.build();
that.txBuilder.add_output(output);
Expand Down Expand Up @@ -870,11 +876,19 @@ export class Tx {
let params = this.translucent.provider
? await this.translucent.provider.getProtocolParameters()
: PROTOCOL_PARAMETERS_DEFAULT;
let multiAsset = foundUtxo.output().amount().multiasset();
let multiAsset = foundUtxo.output().amount().multiasset()
multiAsset = multiAsset ?? C.MultiAsset.new();
amtBuilder = amtBuilder.with_asset_and_min_required_coin(
multiAsset || C.MultiAsset.new(),
multiAsset,
C.BigNum.from_str(params.coinsPerUtxoByte.toString()),
);
let amtBuilderResult = amtBuilder.build();
if (multiAsset.len() == 0) {
const collateralCoin = amtBuilderResult.output().amount().coin().to_str();
amtBuilder = amtBuilder.with_coin(
C.BigNum.from_str(collateralCoin)
);
}
const collateralReturn = amtBuilder.build().output();
this.txBuilder.add_collateral(collateralUTxO);
this.txBuilder.set_collateral_return(collateralReturn);
Expand Down

0 comments on commit 36cda41

Please sign in to comment.