@Test void extractNonFeeTransfersCryptoTransfer() { var transactionBody = getCryptoTransferTransactionBody(); var result = extractionStrategy.extractNonFeeTransfers(transactionBody, getSimpleTransactionRecord()); assertAll( () -> assertEquals(3, StreamSupport.stream(result.spliterator(), false).count()) , () -> assertResult(transactionBody.getCryptoTransfer().getTransfers().getAccountAmountsList(), result) ); }
@Override public Iterable<AccountAmount> extractNonFeeTransfers(TransactionBody body, TransactionRecord transactionRecord) { if (!body.hasCryptoCreateAccount() && !body.hasContractCreateInstance() && !body.hasCryptoTransfer() && !body.hasContractCall()) { return Collections.emptyList(); } AccountID payerAccountId = body.getTransactionID().getAccountID(); if (body.hasCryptoTransfer()) { return body.getCryptoTransfer().getTransfers().getAccountAmountsList(); } else if (body.hasCryptoCreateAccount()) { return extractForCreateEntity(body.getCryptoCreateAccount().getInitialBalance(), payerAccountId, transactionRecord.getReceipt().getAccountID(), transactionRecord); } else if (body.hasContractCreateInstance()) { return extractForCreateEntity(body.getContractCreateInstance().getInitialBalance(), payerAccountId, contractIdToAccountId(transactionRecord.getReceipt().getContractID()), transactionRecord); } else { LinkedList<AccountAmount> result = new LinkedList<>(); var amount = body.getContractCall().getAmount(); var contractAccountId = contractIdToAccountId(body.getContractCall().getContractID()); result.add(AccountAmount.newBuilder().setAccountID(contractAccountId).setAmount(amount).build()); result.add(AccountAmount.newBuilder().setAccountID(payerAccountId).setAmount(0 - amount).build()); return result; } }
NonFeeTransferExtractionStrategyImpl implements NonFeeTransferExtractionStrategy { @Override public Iterable<AccountAmount> extractNonFeeTransfers(TransactionBody body, TransactionRecord transactionRecord) { if (!body.hasCryptoCreateAccount() && !body.hasContractCreateInstance() && !body.hasCryptoTransfer() && !body.hasContractCall()) { return Collections.emptyList(); } AccountID payerAccountId = body.getTransactionID().getAccountID(); if (body.hasCryptoTransfer()) { return body.getCryptoTransfer().getTransfers().getAccountAmountsList(); } else if (body.hasCryptoCreateAccount()) { return extractForCreateEntity(body.getCryptoCreateAccount().getInitialBalance(), payerAccountId, transactionRecord.getReceipt().getAccountID(), transactionRecord); } else if (body.hasContractCreateInstance()) { return extractForCreateEntity(body.getContractCreateInstance().getInitialBalance(), payerAccountId, contractIdToAccountId(transactionRecord.getReceipt().getContractID()), transactionRecord); } else { LinkedList<AccountAmount> result = new LinkedList<>(); var amount = body.getContractCall().getAmount(); var contractAccountId = contractIdToAccountId(body.getContractCall().getContractID()); result.add(AccountAmount.newBuilder().setAccountID(contractAccountId).setAmount(amount).build()); result.add(AccountAmount.newBuilder().setAccountID(payerAccountId).setAmount(0 - amount).build()); return result; } } }
NonFeeTransferExtractionStrategyImpl implements NonFeeTransferExtractionStrategy { @Override public Iterable<AccountAmount> extractNonFeeTransfers(TransactionBody body, TransactionRecord transactionRecord) { if (!body.hasCryptoCreateAccount() && !body.hasContractCreateInstance() && !body.hasCryptoTransfer() && !body.hasContractCall()) { return Collections.emptyList(); } AccountID payerAccountId = body.getTransactionID().getAccountID(); if (body.hasCryptoTransfer()) { return body.getCryptoTransfer().getTransfers().getAccountAmountsList(); } else if (body.hasCryptoCreateAccount()) { return extractForCreateEntity(body.getCryptoCreateAccount().getInitialBalance(), payerAccountId, transactionRecord.getReceipt().getAccountID(), transactionRecord); } else if (body.hasContractCreateInstance()) { return extractForCreateEntity(body.getContractCreateInstance().getInitialBalance(), payerAccountId, contractIdToAccountId(transactionRecord.getReceipt().getContractID()), transactionRecord); } else { LinkedList<AccountAmount> result = new LinkedList<>(); var amount = body.getContractCall().getAmount(); var contractAccountId = contractIdToAccountId(body.getContractCall().getContractID()); result.add(AccountAmount.newBuilder().setAccountID(contractAccountId).setAmount(amount).build()); result.add(AccountAmount.newBuilder().setAccountID(payerAccountId).setAmount(0 - amount).build()); return result; } }  }
NonFeeTransferExtractionStrategyImpl implements NonFeeTransferExtractionStrategy { @Override public Iterable<AccountAmount> extractNonFeeTransfers(TransactionBody body, TransactionRecord transactionRecord) { if (!body.hasCryptoCreateAccount() && !body.hasContractCreateInstance() && !body.hasCryptoTransfer() && !body.hasContractCall()) { return Collections.emptyList(); } AccountID payerAccountId = body.getTransactionID().getAccountID(); if (body.hasCryptoTransfer()) { return body.getCryptoTransfer().getTransfers().getAccountAmountsList(); } else if (body.hasCryptoCreateAccount()) { return extractForCreateEntity(body.getCryptoCreateAccount().getInitialBalance(), payerAccountId, transactionRecord.getReceipt().getAccountID(), transactionRecord); } else if (body.hasContractCreateInstance()) { return extractForCreateEntity(body.getContractCreateInstance().getInitialBalance(), payerAccountId, contractIdToAccountId(transactionRecord.getReceipt().getContractID()), transactionRecord); } else { LinkedList<AccountAmount> result = new LinkedList<>(); var amount = body.getContractCall().getAmount(); var contractAccountId = contractIdToAccountId(body.getContractCall().getContractID()); result.add(AccountAmount.newBuilder().setAccountID(contractAccountId).setAmount(amount).build()); result.add(AccountAmount.newBuilder().setAccountID(payerAccountId).setAmount(0 - amount).build()); return result; } }  @Override Iterable<AccountAmount> extractNonFeeTransfers(TransactionBody body, TransactionRecord transactionRecord); }
NonFeeTransferExtractionStrategyImpl implements NonFeeTransferExtractionStrategy { @Override public Iterable<AccountAmount> extractNonFeeTransfers(TransactionBody body, TransactionRecord transactionRecord) { if (!body.hasCryptoCreateAccount() && !body.hasContractCreateInstance() && !body.hasCryptoTransfer() && !body.hasContractCall()) { return Collections.emptyList(); } AccountID payerAccountId = body.getTransactionID().getAccountID(); if (body.hasCryptoTransfer()) { return body.getCryptoTransfer().getTransfers().getAccountAmountsList(); } else if (body.hasCryptoCreateAccount()) { return extractForCreateEntity(body.getCryptoCreateAccount().getInitialBalance(), payerAccountId, transactionRecord.getReceipt().getAccountID(), transactionRecord); } else if (body.hasContractCreateInstance()) { return extractForCreateEntity(body.getContractCreateInstance().getInitialBalance(), payerAccountId, contractIdToAccountId(transactionRecord.getReceipt().getContractID()), transactionRecord); } else { LinkedList<AccountAmount> result = new LinkedList<>(); var amount = body.getContractCall().getAmount(); var contractAccountId = contractIdToAccountId(body.getContractCall().getContractID()); result.add(AccountAmount.newBuilder().setAccountID(contractAccountId).setAmount(amount).build()); result.add(AccountAmount.newBuilder().setAccountID(payerAccountId).setAmount(0 - amount).build()); return result; } }  @Override Iterable<AccountAmount> extractNonFeeTransfers(TransactionBody body, TransactionRecord transactionRecord);  }