From 6041cda0d5a80d0e2bb428d32e1ff1d34d452dc7 Mon Sep 17 00:00:00 2001 From: chaitanyapotti Date: Wed, 5 Oct 2022 15:11:26 -0700 Subject: [PATCH] Add support for networkUrl --- .../java/org/torusresearch/customauth/CustomAuth.java | 11 +++++++++-- .../customauth/types/CustomAuthArgs.java | 9 +++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/sdk/src/main/java/org/torusresearch/customauth/CustomAuth.java b/sdk/src/main/java/org/torusresearch/customauth/CustomAuth.java index c9798db..825dc31 100644 --- a/sdk/src/main/java/org/torusresearch/customauth/CustomAuth.java +++ b/sdk/src/main/java/org/torusresearch/customauth/CustomAuth.java @@ -25,6 +25,7 @@ import org.torusresearch.fetchnodedetails.FetchNodeDetails; import org.torusresearch.fetchnodedetails.types.NodeDetails; import org.torusresearch.torusutils.TorusUtils; +import org.torusresearch.torusutils.helpers.Utils; import org.torusresearch.torusutils.types.RetrieveSharesResponse; import org.torusresearch.torusutils.types.TorusCtorOptions; import org.torusresearch.torusutils.types.TorusPublicKey; @@ -36,7 +37,6 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; -import java.util.Objects; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ForkJoinPool; @@ -48,7 +48,14 @@ public class CustomAuth { public CustomAuth(CustomAuthArgs _customAuthArgs, Context context) { this.customAuthArgs = _customAuthArgs; - this.nodeDetailManager = new FetchNodeDetails(_customAuthArgs.getNetwork(), CustomAuthArgs.CONTRACT_MAP.get(_customAuthArgs.getNetwork())); + if (Utils.isEmpty(_customAuthArgs.getNetworkUrl())) { + this.nodeDetailManager = new FetchNodeDetails(_customAuthArgs.getNetwork(), + CustomAuthArgs.CONTRACT_MAP.get(_customAuthArgs.getNetwork())); + } else { + this.nodeDetailManager = new FetchNodeDetails(_customAuthArgs.getNetworkUrl(), + CustomAuthArgs.CONTRACT_MAP.get(_customAuthArgs.getNetwork())); + } + TorusCtorOptions opts = new TorusCtorOptions(context.getPackageName()); opts.setEnableOneKey(_customAuthArgs.isEnableOneKey()); opts.setNetwork(_customAuthArgs.getNetwork().toString()); diff --git a/sdk/src/main/java/org/torusresearch/customauth/types/CustomAuthArgs.java b/sdk/src/main/java/org/torusresearch/customauth/types/CustomAuthArgs.java index 450ae2d..7a46b80 100644 --- a/sdk/src/main/java/org/torusresearch/customauth/types/CustomAuthArgs.java +++ b/sdk/src/main/java/org/torusresearch/customauth/types/CustomAuthArgs.java @@ -27,6 +27,7 @@ public class CustomAuthArgs { private String redirectUri; private TorusNetwork network; private boolean enableOneKey; + private String networkUrl; public CustomAuthArgs(String browserRedirectUri, TorusNetwork network, String _redirectUri) { @@ -70,4 +71,12 @@ public boolean isEnableOneKey() { public void setEnableOneKey(boolean enableOneKey) { this.enableOneKey = enableOneKey; } + + public String getNetworkUrl() { + return networkUrl; + } + + public void setNetworkUrl(String networkUrl) { + this.networkUrl = networkUrl; + } }