Skip to content

Commit

Permalink
add stellar transfer transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
AnthonyBuisset committed Sep 2, 2024
1 parent a43f29f commit 4eec012
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
package onlydust.com.marketplace.kernel.model.blockchain.stellar;

import lombok.EqualsAndHashCode;
import lombok.NonNull;
import lombok.*;
import lombok.experimental.Accessors;
import lombok.experimental.FieldDefaults;
import onlydust.com.marketplace.kernel.model.blockchain.Blockchain;
import onlydust.com.marketplace.kernel.model.blockchain.Blockchain.Transaction;
import onlydust.com.marketplace.kernel.model.blockchain.HexHash;

import java.time.ZonedDateTime;

public record StellarTransaction(Hash hash, ZonedDateTime timestamp, Status status) implements Transaction {
@AllArgsConstructor
@EqualsAndHashCode
@FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE)
@Getter
@Accessors(fluent = true)
public class StellarTransaction implements Transaction {
Hash hash;
ZonedDateTime timestamp;
Status status;

@Override
public Blockchain blockchain() {
return Blockchain.STELLAR;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package onlydust.com.marketplace.kernel.model.blockchain.stellar;

import lombok.*;
import lombok.experimental.Accessors;
import lombok.experimental.FieldDefaults;
import onlydust.com.marketplace.kernel.model.blockchain.Blockchain.TransferTransaction;

import java.math.BigDecimal;
import java.time.ZonedDateTime;
import java.util.Optional;

@EqualsAndHashCode(callSuper = true)
@FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE)
@Getter
@Accessors(fluent = true)
@ToString
public class StellarTransferTransaction extends StellarTransaction implements TransferTransaction {
@NonNull
StellarAccountId sender;
@NonNull
StellarAccountId recipient;
@NonNull
BigDecimal amount;
StellarContractAddress contractAddress;

public StellarTransferTransaction(final @NonNull Hash hash, final @NonNull ZonedDateTime timestamp, final @NonNull Status status, final @NonNull StellarAccountId sender, final @NonNull StellarAccountId recipient, final @NonNull BigDecimal amount, final StellarContractAddress contractAddress) {
super(hash, timestamp, status);

this.sender = sender;
this.recipient = recipient;
this.amount = amount;
this.contractAddress = contractAddress;
}

@Override
public String senderAddress() {
return sender.toString();
}

@Override
public String recipientAddress() {
return recipient.toString();
}

@Override
public Optional<String> contractAddress() {
return Optional.ofNullable(contractAddress).map(StellarContractAddress::toString);
}
}

0 comments on commit 4eec012

Please sign in to comment.