Skip to content

Commit

Permalink
fix: RA-84 fix amountDeposit and networkIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
shleger committed May 3, 2024
1 parent 49c59b6 commit 61e922e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ protected OperationMetadata mapToOperationMetaData(boolean spent, List<Amt> amou
.stream()
.flatMap(List::stream)
.forEach(amount -> {
operationMetadata.setDepositAmount(getDepositAmount());
if (!amount.getAssetName().equals(Constants.LOVELACE)) {
TokenBundleItem tokenBundleItem = new TokenBundleItem();
tokenBundleItem.setPolicyId(amount.getPolicyId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public Operation toDto(Utxo model, OperationStatus status, int index) {
.addMappings(mp -> {
mp.map(f -> Constants.OUTPUT, Operation::setType);
mp.<CoinAction>map(f -> CoinAction.CREATED, (d, v) -> d.getCoinChange().setCoinAction(v));
mp.<Long>map(f -> model.getOutputIndex(), (d, v) -> d.getOperationIdentifier()
.setNetworkIndex(v));
mp.map(f-> mapToOperationMetaData(false, model.getAmounts()), Operation::setMetadata);
mapOthers(model, status, index, mp, false);
})
Expand Down
3 changes: 2 additions & 1 deletion api/src/main/resources/config/application-staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ cardano:
GENESIS_SHELLEY_PATH: ${GENESIS_SHELLEY_PATH}
CARDANO_NODE_SUBMIT_HOST: ${CARDANO_NODE_SUBMIT_HOST}
NODE_SUBMIT_API_PORT: ${NODE_SUBMIT_API_PORT}
CARDANO_NODE_SOCKET: ${CARDANO_NODE_SOCKET}
CARDANO_NODE_VERSION: ${CARDANO_NODE_VERSION}
CARDANO_NODE_SOCKET: ${CARDANO_NODE_SOCKET}
# devkit variables
DEVKIT_ENABLED: ${DEVKIT_ENABLED:false}
DEVKIT_URL: ${DEVKIT_URL:yaci-cli}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ void toDto_Test_DelegationOperations() {
assertThat(stakeInto.getOperationIdentifier().getIndex()).isEqualTo(1); //index in array
assertThat(stakeInto.getAccount().getAddress()).isEqualTo(firstFrom.getAddress());
assertThat(stakeInto.getMetadata().getPoolKeyHash()).isEqualTo(firstFrom.getPoolId());
assertThat(stakeInto.getMetadata().getDepositAmount()).isNull();



}
Expand Down Expand Up @@ -235,6 +237,8 @@ void toDto_Test_getPoolRetirementOperations() {
assertThat(poolInto.getOperationIdentifier().getIndex()).isEqualTo(1); //index in array
assertThat(poolInto.getAccount().getAddress()).isEqualTo(firstFrom.getPoolId());
assertThat(poolInto.getMetadata().getEpoch()).isEqualTo(firstFrom.getEpoch());
assertThat(poolInto.getMetadata().getDepositAmount()).isNull();



}
Expand All @@ -261,7 +265,14 @@ void toDto_Test_getOutputsAsOperations() {
Utxo firstFrom = from.getOutputs().getFirst();
assertThat(opInto.getType()).isEqualTo(Constants.OUTPUT);
assertThat(opInto.getStatus()).isEqualTo("success");
assertThat(opInto.getOperationIdentifier().getIndex()).isEqualTo(1); //index in array
assertThat(opInto.getOperationIdentifier().getIndex())
.isEqualTo(1); //index in array for toDto_Test_getOutputsAsOperations test
assertThat(opInto.getOperationIdentifier().getNetworkIndex().intValue())
.isEqualTo(firstFrom.getOutputIndex());

assertThat(opInto.getMetadata()).isNotNull();
assertThat(opInto.getMetadata().getDepositAmount()).isNull();

assertThat(opInto.getAccount().getAddress()).isEqualTo(firstFrom.getOwnerAddr());
assertThat(opInto.getAmount()).isEqualTo(amountActual("10"));

Expand Down Expand Up @@ -311,6 +322,8 @@ void toDto_Test_getInputsAsOperations() {
assertThat(opInto.getOperationIdentifier().getIndex()).isEqualTo(0); //index in array
assertThat(opInto.getAccount().getAddress()).isEqualTo(firstFrom.getOwnerAddr());
assertThat(opInto.getAmount()).isEqualTo(amountActual("-10"));
assertThat(opInto.getMetadata().getDepositAmount()).isNull();


CoinChange coinChange = opInto.getCoinChange();
assertThat(coinChange.getCoinAction()).isEqualTo(CoinAction.SPENT);
Expand Down Expand Up @@ -358,6 +371,8 @@ void toDto_Test_getWithdrawlOperations() {
.isEqualTo(from.getWithdrawals().getFirst().getStakeAddress());
assertThat(opInto.getMetadata().getWithdrawalAmount().getValue())
.isEqualTo("-"+ from.getWithdrawals().getFirst().getAmount().toString());
assertThat(opInto.getMetadata().getDepositAmount()).isNull();

}


Expand Down

0 comments on commit 61e922e

Please sign in to comment.