Skip to content

Commit

Permalink
Add migration file
Browse files Browse the repository at this point in the history
  • Loading branch information
philipliu committed Jul 10, 2023
1 parent b121747 commit 9f6091c
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,6 @@ public interface Sep24Transaction {

void setRefundMemoType(String refundMemoType);

// TODO: do something about these types
enum Kind {
DEPOSIT("deposit"),
WITHDRAWAL("withdrawal"),
Expand Down
11 changes: 9 additions & 2 deletions core/src/main/java/org/stellar/anchor/sep6/Sep6Transaction.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.stellar.anchor.sep6;

import java.time.Instant;
import java.util.Map;

public interface Sep6Transaction {

Expand Down Expand Up @@ -60,7 +61,6 @@ public interface Sep6Transaction {

void setWithdrawAnchorAccount(String withdrawAnchorAccount);

// TODO: are these even needed?
String getFromAccount();

void setFromAccount(String fromAccount);
Expand Down Expand Up @@ -105,6 +105,14 @@ public interface Sep6Transaction {

void setAmountFeeAsset(String amountFeeAsset);

Map<String, String> getFields();

void setFields(Map<String, String> fields);

String getQuoteId();

void setQuoteId(String quoteId);

Boolean getRefunded();

void setRefunded(Boolean refunded);
Expand All @@ -125,7 +133,6 @@ enum Kind {
DEPOSIT("deposit"),
WITHDRAWAL("withdrawal"),

// TODO: This is how it is represented in Polaris
DEPOSIT_EXCHANGE("deposit-exchange"),
WITHDRAWAL_EXCHANGE("withdrawal-exchange");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ public String getRequestAssetName() {

/** The SEP10 account memo used for authentication. */
@SerializedName("sep10_account_memo")
// TODO: why
@Column(name = "sep10account_memo")
String sep10AccountMemo;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package org.stellar.anchor.platform.data;

import com.google.gson.annotations.SerializedName;
import com.google.gson.reflect.TypeToken;
import com.vladmihalcea.hibernate.type.json.JsonType;
import javax.persistence.Access;
import javax.persistence.AccessType;
import javax.persistence.Column;
import javax.persistence.Entity;
import java.util.Map;
import javax.persistence.*;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
Expand Down Expand Up @@ -77,6 +76,26 @@ public String getProtocol() {
@Column(name = "claimable_balance_supported")
Boolean claimableBalanceSupported;

@SerializedName("fields")
@Transient
Map<String, String> fields;

@Access(AccessType.PROPERTY)
@Column(name = "fields")
public String getFieldsJson() {
return gson.toJson(this.fields);
}

public void setFieldsJson(String fieldsJson) {
if (fieldsJson != null) {
this.fields = gson.fromJson(fieldsJson, new TypeToken<Map<String, String>>() {}.getType());
}
}

@SerializedName("quote_id")
@Column(name = "quote_id")
String quoteId;

@SerializedName("refunded")
@Column(name = "refunded")
Boolean refunded;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,24 @@ public Sep6RefundPayment newRefundPayment() {
}

@Override
public Sep6Transaction findByTransactionId(String transactionId) throws SepException {
public Sep6Transaction findByTransactionId(String transactionId) {
return transactionRepo.findOneByTransactionId(transactionId);
}

@Override
public Sep6Transaction findByStellarTransactionId(String stellarTransactionId)
throws SepException {
public Sep6Transaction findByStellarTransactionId(String stellarTransactionId) {
return transactionRepo.findOneByStellarTransactionId(stellarTransactionId);
}

@Override
public Sep6Transaction findByExternalTransactionId(String externalTransactionId)
throws SepException {
public Sep6Transaction findByExternalTransactionId(String externalTransactionId) {
return transactionRepo.findOneByExternalTransactionId(externalTransactionId);
}

@Override
public List<Sep6Transaction> findTransactions(
String accountId, String accountMemo, GetTransactionsRequest request) throws SepException {
// TODO: implement
String accountId, String accountMemo, GetTransactionsRequest request) {
// TODO: implement with GET /transactions endpoint
return null;
}

Expand Down
37 changes: 37 additions & 0 deletions platform/src/main/resources/db/migration/V7__sep6_transactions.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
CREATE TABLE sep6_transaction (
id VARCHAR(255) NOT NULL,
transaction_id VARCHAR(255),
stellar_transaction_id VARCHAR(255),
external_transaction_id VARCHAR(255),
stellar_transactions JSON,
status VARCHAR(255),
kind VARCHAR(255),
updated_at TIMESTAMP WITHOUT TIME ZONE,
started_at TIMESTAMP WITHOUT TIME ZONE,
completed_at TIMESTAMP WITHOUT TIME ZONE,
transfer_received_at TIMESTAMP WITHOUT TIME ZONE,
request_asset_code VARCHAR(255),
request_asset_issuer VARCHAR(255),
amount_in VARCHAR(255),
amount_in_asset VARCHAR(255),
amount_out VARCHAR(255),
amount_out_asset VARCHAR(255),
amount_fee VARCHAR(255),
amount_fee_asset VARCHAR(255),
amount_expected VARCHAR(255),
sep10_account VARCHAR(255),
sep10_account_memo VARCHAR(255),
withdraw_anchor_account VARCHAR(255),
from_account VARCHAR(255),
to_account VARCHAR(255),
memo VARCHAR(255),
memo_type VARCHAR(255),
claimable_balance_supported BOOLEAN,
quote_id VARCHAR(255),
fields VARCHAR(255),
refunded BOOLEAN,
refunds JSON,
refund_memo VARCHAR(255),
refund_memo_type VARCHAR(255),
CONSTRAINT pk_sep6_transaction PRIMARY KEY (id)
)

0 comments on commit 9f6091c

Please sign in to comment.