Skip to content

Commit

Permalink
[Feature] Merge sep-6 into develop (#1151)
Browse files Browse the repository at this point in the history
### Description

This merges the `sep-6` development branch into `develop`.

### Context

Anchor Platform is releasing SEP-6 support in 2.4.0.

### Documentation

API docs have been updated in
stellar/stellar-docs#253. This will merged be
merged alongside this PR.

### Testing

- `./gradlew test`

### Known limitations

N/A
  • Loading branch information
philipliu authored Nov 3, 2023
2 parents f948a9d + 7e2f8f9 commit fd7b651
Show file tree
Hide file tree
Showing 195 changed files with 13,387 additions and 1,971 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/sub_gradle_test_and_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:

# Prepare Stellar Validation Tests
- name: Pull Stellar Validation Tests Docker Image
run: docker pull stellar/anchor-tests:v0.6.5 &
run: docker pull stellar/anchor-tests:v0.6.9 &

# Set up JDK 11
- name: Set up JDK 11
Expand Down Expand Up @@ -109,7 +109,7 @@ jobs:

- name: Run Stellar validation tool
run: |
docker run --network host -v ${GITHUB_WORKSPACE}/platform/src/test/resources://config stellar/anchor-tests:v0.6.5 --home-domain http://host.docker.internal:8080 --seps 1 10 12 24 31 38 --sep-config //config/stellar-anchor-tests-sep-config.json --verbose
docker run --network host -v ${GITHUB_WORKSPACE}/platform/src/test/resources://config stellar/anchor-tests:v0.6.9 --home-domain http://host.docker.internal:8080 --seps 1 6 10 12 24 31 38 --sep-config //config/stellar-anchor-tests-sep-config.json --verbose
- name: Upload Artifacts
if: always()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import lombok.Data;
import lombok.NoArgsConstructor;
import org.stellar.anchor.api.event.AnchorEvent;
import org.stellar.anchor.api.platform.CustomerUpdatedResponse;
import org.stellar.anchor.api.platform.GetQuoteResponse;
import org.stellar.anchor.api.platform.GetTransactionResponse;

Expand All @@ -13,6 +14,7 @@
public class SendEventRequestPayload {
GetTransactionResponse transaction;
GetQuoteResponse quote;
CustomerUpdatedResponse customer;

/**
* Creates a SendEventRequestPayload from an AnchorEvent.
Expand All @@ -23,6 +25,8 @@ public class SendEventRequestPayload {
public static SendEventRequestPayload from(AnchorEvent event) {
SendEventRequestPayload payload = new SendEventRequestPayload();
switch (event.getType()) {
case CUSTOMER_UPDATED:
payload.setCustomer(event.getCustomer());
case QUOTE_CREATED:
payload.setQuote(event.getQuote());
case TRANSACTION_CREATED:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.google.gson.annotations.SerializedName;
import lombok.*;
import org.stellar.anchor.api.platform.CustomerUpdatedResponse;
import org.stellar.anchor.api.platform.GetQuoteResponse;
import org.stellar.anchor.api.platform.GetTransactionResponse;

Expand All @@ -13,8 +14,7 @@
* Schema</a>
*/
@Builder
@Getter
@Setter
@Data
@NoArgsConstructor
@AllArgsConstructor
public class AnchorEvent {
Expand All @@ -23,6 +23,7 @@ public class AnchorEvent {
String sep;
GetTransactionResponse transaction;
GetQuoteResponse quote;
CustomerUpdatedResponse customer;

public enum Type {
@SerializedName("transaction_created")
Expand All @@ -32,7 +33,9 @@ public enum Type {
@SerializedName("transaction_error")
TRANSACTION_ERROR("transaction_error"),
@SerializedName("quote_created")
QUOTE_CREATED("quote_created");
QUOTE_CREATED("quote_created"),
@SerializedName("customer_updated")
CUSTOMER_UPDATED("customer_updated");

public final String type;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.stellar.anchor.api.exception;

import java.util.List;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

/** Thrown when a customer's info is needed to complete a request. */
@RequiredArgsConstructor
@Getter
public class SepCustomerInfoNeededException extends AnchorException {
private final List<String> fields;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.stellar.anchor.api.platform;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class CustomerUpdatedResponse {
String id;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package org.stellar.anchor.api.platform;

import com.google.gson.annotations.SerializedName;
import java.util.List;
import lombok.Builder;
import lombok.Data;
import lombok.NonNull;
import org.stellar.anchor.api.sep.SepTransactionStatus;

/**
* The request body of the GET /transactions endpoint of the Platform API.
*
* @see <a
* href="https://github.com/stellar/stellar-docs/blob/main/openapi/anchor-platform/Platform%20API.yml">Platform
* API</a>
*/
@Data
@Builder
public class GetTransactionsRequest {
@NonNull private TransactionsSeps sep;

@SerializedName("order_by")
private TransactionsOrderBy orderBy;

private TransactionsOrder order;

private List<SepTransactionStatus> statuses;

@SerializedName("page_size")
private Integer pageSize;

@SerializedName("page_number")
private Integer pageNumber;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.google.gson.annotations.SerializedName;
import java.time.Instant;
import java.util.List;
import java.util.Map;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
Expand All @@ -29,6 +30,8 @@ public class PlatformTransactionData {
Kind kind;
SepTransactionStatus status;

String type;

@SerializedName("amount_expected")
Amount amountExpected;

Expand Down Expand Up @@ -89,7 +92,23 @@ public class PlatformTransactionData {
Customers customers;
StellarId creator;

@SerializedName("required_info_message")
String requiredInfoMessage;

@SerializedName("required_info_updates")
List<String> requiredInfoUpdates;

@SerializedName("required_customer_info_message")
String requiredCustomerInfoMessage;

@SerializedName("required_customer_info_updates")
List<String> requiredCustomerInfoUpdates;

Map<String, InstructionField> instructions;

public enum Sep {
@SerializedName("6")
SEP_6(6),
@SuppressWarnings("unused")
@SerializedName("24")
SEP_24(24),
Expand Down Expand Up @@ -127,8 +146,13 @@ public enum Kind {
RECEIVE("receive"),
@SerializedName("deposit")
DEPOSIT("deposit"),
@SerializedName("deposit-exchange")
DEPOSIT_EXCHANGE("deposit-exchange"),
@SerializedName("withdrawal")
WITHDRAWAL("withdrawal");
WITHDRAWAL("withdrawal"),

@SerializedName("withdrawal-exchange")
WITHDRAWAL_EXCHANGE("withdrawal-exchange");

public final String kind;

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

import com.google.gson.annotations.SerializedName;

public enum TransactionsOrder {
@SerializedName("asc")
ASC,
@SerializedName("desc")
DESC
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.stellar.anchor.apiclient;
package org.stellar.anchor.api.platform;

public enum TransactionsOrderBy {
CREATED_AT("started_at"),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.stellar.anchor.apiclient;
package org.stellar.anchor.api.platform;

import com.google.gson.annotations.SerializedName;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.stellar.anchor.api.rpc.method;

import com.google.gson.annotations.SerializedName;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
Expand All @@ -9,4 +11,11 @@
@SuperBuilder
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
public class RequestCustomerInfoUpdateRequest extends RpcMethodParamsRequest {}
public class RequestCustomerInfoUpdateRequest extends RpcMethodParamsRequest {

@SerializedName("required_customer_info_message")
private String requiredCustomerInfoMessage;

@SerializedName("required_customer_info_updates")
private List<String> requiredCustomerInfoUpdates;
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package org.stellar.anchor.api.rpc.method;

import com.google.gson.annotations.SerializedName;
import java.util.Map;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.SuperBuilder;
import org.stellar.anchor.api.shared.InstructionField;

@Data
@SuperBuilder
Expand All @@ -23,4 +25,7 @@ public class RequestOffchainFundsRequest extends RpcMethodParamsRequest {

@SerializedName("amount_expected")
private AmountRequest amountExpected;

@SerializedName("instructions")
Map<String, InstructionField> instructions;
}
27 changes: 23 additions & 4 deletions api-schema/src/main/java/org/stellar/anchor/api/sep/AssetInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,30 @@ public class AssetInfo {
String code;
String issuer;

public String getAssetName() {
if (issuer != null) {
return schema + ":" + code + ":" + issuer;
/**
* Returns the SEP-38 asset name, which is the SEP-11 asset name prefixed with the schema.
*
* @return The SEP-38 asset name.
*/
public String getSep38AssetName() {
return schema + ":" + makeSep11AssetName(code, issuer);
}

/**
* Returns the SEP-11 asset name for the given asset code and issuer.
*
* @param assetCode The asset code.
* @param assetIssuer The asset issuer.
* @return The SEP-11 asset name.
*/
public static String makeSep11AssetName(String assetCode, String assetIssuer) {
if (AssetInfo.NATIVE_ASSET_CODE.equals(assetCode)) {
return AssetInfo.NATIVE_ASSET_CODE;
} else if (assetIssuer != null) {
return assetCode + ":" + assetIssuer;
} else {
return assetCode;
}
return schema + ":" + code;
}

@SerializedName("distribution_account")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.stellar.anchor.api.sep;

import java.util.List;
import lombok.Data;
import lombok.RequiredArgsConstructor;

@RequiredArgsConstructor
@Data
public class CustomerInfoNeededResponse {
private final String type = "non_interactive_customer_info_needed";
private final List<String> fields;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.stellar.anchor.api.sep.sep12;

import com.google.gson.annotations.SerializedName;
import java.time.Instant;
import lombok.Builder;
import lombok.Data;

Expand Down Expand Up @@ -108,10 +109,10 @@ public class Sep12PutCustomerRequest implements Sep12CustomerRequestBase {
String idCountryCode;

@SerializedName("id_issue_date")
String idIssueDate;
Instant idIssueDate;

@SerializedName("id_expiration_date")
String idExpirationDate;
Instant idExpirationDate;

@SerializedName("id_number")
String idNumber;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ public enum Sep12Status {
PROCESSING("PROCESSING"),

@SerializedName("REJECTED")
REJECTED("REJECTED"),

@SerializedName("VERIFICATION_REQUIRED")
VERIFICATION_REQUIRED("VERIFICATION_REQUIRED");
REJECTED("REJECTED");

private final String name;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
@Data
@AllArgsConstructor
public class GetTransactionResponse {
Sep6Transaction transaction;
Sep6TransactionResponse transaction;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
@Data
@AllArgsConstructor
public class GetTransactionsResponse {
List<Sep6Transaction> transactions;
List<Sep6TransactionResponse> transactions;
}
Loading

0 comments on commit fd7b651

Please sign in to comment.