Skip to content

Commit

Permalink
Add SEP-45 implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
philipliu committed Jan 23, 2025
1 parent 964ac0d commit 4c2f3b2
Show file tree
Hide file tree
Showing 45 changed files with 996 additions and 67 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.stellar.anchor.api.sep.sep45;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Builder;
import lombok.Data;

@Builder
@Data
public class ChallengeRequest {
private String account;

@JsonProperty("home_domain")
private String homeDomain;

@JsonProperty("client_domain")
private String clientDomain;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.stellar.anchor.api.sep.sep45;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Builder;
import lombok.Data;

@Builder
@Data
public class ChallengeResponse {
@JsonProperty("authorization_entries")
private String authorizationEntries;

@JsonProperty("network_passphrase")
private String networkPassphrase;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.stellar.anchor.api.sep.sep45;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Builder;
import lombok.Data;

@Builder
@Data
public class ValidationRequest {
@JsonProperty("authorization_entries")
private String authorizationEntries;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.stellar.anchor.api.sep.sep45;

import lombok.Builder;
import lombok.Data;

@Builder
@Data
public class ValidationResponse {
private String token;
}
2 changes: 2 additions & 0 deletions core/src/main/java/org/stellar/anchor/config/AppConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@ public interface AppConfig {

String getHorizonUrl();

String getRpcUrl();

List<String> getLanguages();
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@ public interface SecretConfig {
@Deprecated // TODO: ANCHOR-667
String getSep10JwtSecretKey();

@Deprecated // TODO: ANCHOR-667
String getSep45JwtSecretKey();

String getSep10SigningSeed();

String getSep45SimulatingSigningSeed();

String getSep24InteractiveUrlJwtSecret();

String getSep24MoreInfoUrlJwtSecret();
Expand Down
14 changes: 14 additions & 0 deletions core/src/main/java/org/stellar/anchor/config/Sep45Config.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.stellar.anchor.config;

import java.util.List;

public interface Sep45Config {

Boolean getEnabled();

String getWebAuthDomain();

String getWebAuthContractId();

List<String> getHomeDomains();
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.stellar.anchor.horizon;
package org.stellar.anchor.network;

import static org.stellar.anchor.api.asset.AssetInfo.NATIVE_ASSET_CODE;

Expand Down
30 changes: 30 additions & 0 deletions core/src/main/java/org/stellar/anchor/network/Rpc.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.stellar.anchor.network;

import lombok.Getter;
import org.stellar.anchor.config.AppConfig;
import org.stellar.sdk.SorobanServer;
import org.stellar.sdk.Transaction;
import org.stellar.sdk.TransactionBuilderAccount;
import org.stellar.sdk.responses.sorobanrpc.GetLatestLedgerResponse;
import org.stellar.sdk.responses.sorobanrpc.SimulateTransactionResponse;

@Getter
public class Rpc {
private final SorobanServer rpc;

public Rpc(AppConfig appConfig) {
this.rpc = new SorobanServer(appConfig.getRpcUrl());
}

public TransactionBuilderAccount getAccount(String accountId) {
return rpc.getAccount(accountId);
}

public SimulateTransactionResponse simulateTransaction(Transaction transaction) {
return rpc.simulateTransaction(transaction);
}

public GetLatestLedgerResponse getLatestLedger() {
return rpc.getLatestLedger();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import org.stellar.anchor.config.AppConfig;
import org.stellar.anchor.config.SecretConfig;
import org.stellar.anchor.config.Sep10Config;
import org.stellar.anchor.horizon.Horizon;
import org.stellar.anchor.network.Horizon;
import org.stellar.anchor.util.Log;
import org.stellar.sdk.*;
import org.stellar.sdk.Sep10Challenge.ChallengeTransaction;
Expand Down
14 changes: 14 additions & 0 deletions core/src/main/java/org/stellar/anchor/sep45/ISep45Service.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.stellar.anchor.sep45;

import org.stellar.anchor.api.exception.AnchorException;
import org.stellar.anchor.api.sep.sep45.ChallengeRequest;
import org.stellar.anchor.api.sep.sep45.ChallengeResponse;
import org.stellar.anchor.api.sep.sep45.ValidationRequest;
import org.stellar.anchor.api.sep.sep45.ValidationResponse;

public interface ISep45Service {

ChallengeResponse getChallenge(ChallengeRequest request) throws AnchorException;

ValidationResponse validate(ValidationRequest request) throws AnchorException;
}
Loading

0 comments on commit 4c2f3b2

Please sign in to comment.