From b441b1b4f2f2a03d3e0e57600920dcf544a74a1b Mon Sep 17 00:00:00 2001 From: Gaurav Goel Date: Mon, 16 Sep 2024 12:48:22 +0530 Subject: [PATCH 1/5] feat: add sentry for error logging and information. Signed-off-by: Gaurav Goel --- build.gradle | 12 +++++ .../torusresearch/torusutils/TorusUtils.java | 8 ++++ .../torusutils/analytics/SentryUtils.java | 42 ++++++++++++++++++ .../torusutils/helpers/KeyUtils.java | 7 ++- .../torusutils/helpers/NodeUtils.java | 3 ++ .../torusutils/helpers/TorusUtilError.java | 44 ++++++++++--------- .../torusresearch/torusutils/types/Share.java | 5 ++- 7 files changed, 96 insertions(+), 25 deletions(-) create mode 100644 src/main/java/org/torusresearch/torusutils/analytics/SentryUtils.java diff --git a/build.gradle b/build.gradle index 48861fc..ae0ddf9 100644 --- a/build.gradle +++ b/build.gradle @@ -2,6 +2,7 @@ plugins { id 'java-library' id 'maven-publish' id "org.gradle.test-retry" version "1.5.10" + id "io.sentry.jvm.gradle" version "4.11.0" } group 'org.torusresearch' @@ -15,6 +16,17 @@ repositories { maven { url 'https://jitpack.io' } } +sentry { + // Generates a JVM (Java, Kotlin, etc.) source bundle and uploads your source code to Sentry. + // This enables source context, allowing you to see your source + // code as part of your stack traces in Sentry. + includeSourceContext = true + + org = "torus" + projectName = "torus-utils-java" + authToken = System.getenv("SENTRY_AUTH_TOKEN") +} + dependencies { implementation 'org.torusresearch:fetch-node-details-java:5.0.0' implementation 'org.web3j:core:4.8.8-android' diff --git a/src/main/java/org/torusresearch/torusutils/TorusUtils.java b/src/main/java/org/torusresearch/torusutils/TorusUtils.java index a5d4931..67a127e 100644 --- a/src/main/java/org/torusresearch/torusutils/TorusUtils.java +++ b/src/main/java/org/torusresearch/torusutils/TorusUtils.java @@ -6,6 +6,7 @@ import org.jetbrains.annotations.NotNull; import org.torusresearch.fetchnodedetails.types.TorusNodePub; import org.torusresearch.fetchnodedetails.types.Web3AuthNetwork; +import org.torusresearch.torusutils.analytics.SentryUtils; import org.torusresearch.torusutils.apis.APIUtils; import org.torusresearch.torusutils.apis.JsonRPCErrorInfo; import org.torusresearch.torusutils.apis.requests.GetMetadataParams; @@ -50,14 +51,17 @@ public class TorusUtils { private int sessionTime = 86400; private final TorusKeyType keyType; private String apiKey = "torus-default"; + public static String clientId; { setupBouncyCastle(); + SentryUtils.init(); } public TorusUtils(TorusOptions options) throws TorusUtilError { this.options = options; this.keyType = options.keyType; + this.clientId = options.clientId; if (options.legacyMetadataHost == null) { if (isLegacyNetorkRouteMap(options.network)) { this.defaultHost = METADATA_MAP.get(options.network); @@ -92,6 +96,10 @@ public void removeApiKey() { APIUtils.setApiKey("torus-default"); } + public static String getClientId() { + return clientId; + } + public void setSessionTime(int sessionTime) { this.sessionTime = sessionTime; } diff --git a/src/main/java/org/torusresearch/torusutils/analytics/SentryUtils.java b/src/main/java/org/torusresearch/torusutils/analytics/SentryUtils.java new file mode 100644 index 0000000..3ead36d --- /dev/null +++ b/src/main/java/org/torusresearch/torusutils/analytics/SentryUtils.java @@ -0,0 +1,42 @@ +package org.torusresearch.torusutils.analytics; + +import io.sentry.Sentry; + +public class SentryUtils { + + public static void init() { + Sentry.init(options -> { + options.setDsn("https://bff95fa0489909b1f269f3bd099e3c6d@o503538.ingest.us.sentry.io/4507960706990080"); + options.setDebug(true); + }); + } + + // Capture an exception + public static void captureException(String msg) { + Sentry.captureException(new Exception(msg)); + } + + public static void addBreadcrumb(String message) { + Sentry.addBreadcrumb(message); + } + + public static void logInformation(String clientId, String finalEvmAddress, String finalPrivKey, String platform) { + Sentry.configureScope(scope -> { + scope.setTag("clientId", clientId); + scope.setTag("finalEvmAddress", finalEvmAddress); + scope.setTag("finalPrivKey", finalPrivKey); + scope.setTag("platform", platform); + }); + } + + public static void setContext(String key, String value) { + Sentry.configureScope(scope -> { + scope.setExtra(key, value); + }); + } + + public static void close() { + Sentry.close(); + } +} + diff --git a/src/main/java/org/torusresearch/torusutils/helpers/KeyUtils.java b/src/main/java/org/torusresearch/torusutils/helpers/KeyUtils.java index e80de63..597d0a0 100644 --- a/src/main/java/org/torusresearch/torusutils/helpers/KeyUtils.java +++ b/src/main/java/org/torusresearch/torusutils/helpers/KeyUtils.java @@ -1,5 +1,7 @@ package org.torusresearch.torusutils.helpers; + import com.google.gson.Gson; + import org.bouncycastle.crypto.ec.CustomNamedCurves; import org.bouncycastle.crypto.params.ECDomainParameters; import org.bouncycastle.crypto.params.ECPrivateKeyParameters; @@ -17,6 +19,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.torusresearch.fetchnodedetails.types.TorusNodePub; +import org.torusresearch.torusutils.TorusUtils; import org.torusresearch.torusutils.apis.requests.NonceMetadataParams; import org.torusresearch.torusutils.apis.requests.SetNonceData; import org.torusresearch.torusutils.helpers.encryption.Encryption; @@ -122,7 +125,7 @@ public static String[] getPublicKeyCoords(@NotNull String pubKey) throws TorusUt if (publicKeyUnprefixed.length() <= 128) { Common.padLeft(publicKeyUnprefixed, '0', 128); } else { - throw new TorusUtilError("Invalid public key size"); + throw new TorusUtilError("Invalid public key size", TorusUtils.getClientId()); } String xCoord = publicKeyUnprefixed.substring(0, 64); @@ -151,7 +154,7 @@ public static String combinePublicKeysFromStrings(@NotNull List keys, bo public static String combinePublicKeys(@NotNull List keys, boolean compressed) throws TorusUtilError { if (keys.isEmpty()) { - throw new TorusUtilError("The keys list cannot be empty"); + throw new TorusUtilError("The keys list cannot be empty", TorusUtils.getClientId()); } ECPoint combinedPoint = keys.get(0); diff --git a/src/main/java/org/torusresearch/torusutils/helpers/NodeUtils.java b/src/main/java/org/torusresearch/torusutils/helpers/NodeUtils.java index 9310030..f802c45 100644 --- a/src/main/java/org/torusresearch/torusutils/helpers/NodeUtils.java +++ b/src/main/java/org/torusresearch/torusutils/helpers/NodeUtils.java @@ -12,6 +12,7 @@ import org.jetbrains.annotations.Nullable; import org.torusresearch.fetchnodedetails.types.Web3AuthNetwork; import org.torusresearch.torusutils.TorusUtils; +import org.torusresearch.torusutils.analytics.SentryUtils; import org.torusresearch.torusutils.apis.APIUtils; import org.torusresearch.torusutils.apis.JsonRPCErrorInfo; import org.torusresearch.torusutils.apis.JsonRPCResponse; @@ -536,6 +537,8 @@ public static TorusKey retrieveOrImportShare(@NotNull String legacyMetadataHost, isUpgraded = metadataNonce.equals(BigInteger.ZERO); } + SentryUtils.logInformation(clientId, finalEvmAddress, finalPrivKey, "torus-utils-java"); + return new TorusKey( new FinalKeyData(finalEvmAddress, finalPubKeyCoords[0], finalPubKeyCoords[1], finalPrivKey), new OAuthKeyData(oAuthKeyAddress, oAuthPublicKeyCoords[0], oAuthPublicKeyCoords[1], oAuthKey), diff --git a/src/main/java/org/torusresearch/torusutils/helpers/TorusUtilError.java b/src/main/java/org/torusresearch/torusutils/helpers/TorusUtilError.java index 50befb6..f5200b0 100644 --- a/src/main/java/org/torusresearch/torusutils/helpers/TorusUtilError.java +++ b/src/main/java/org/torusresearch/torusutils/helpers/TorusUtilError.java @@ -1,35 +1,37 @@ package org.torusresearch.torusutils.helpers; import org.jetbrains.annotations.NotNull; +import org.torusresearch.torusutils.TorusUtils; +import org.torusresearch.torusutils.analytics.SentryUtils; public class TorusUtilError extends Exception { // Define error cases - public static final TorusUtilError CONFIGURATION_ERROR = new TorusUtilError("SDK Configuration incorrect. Network is probably incorrect"); - public static final TorusUtilError COMMITMENT_REQUEST_FAILED = new TorusUtilError("commitment request failed"); - public static final TorusUtilError DECRYPTION_FAILED = new TorusUtilError("Decryption Failed"); - public static final TorusUtilError ENCODING_FAILED = new TorusUtilError("Could not encode data"); - public static final TorusUtilError DECODING_FAILED = new TorusUtilError("JSON Decoding error"); - public static final TorusUtilError IMPORT_SHARE_FAILED = new TorusUtilError("import share failed"); - public static final TorusUtilError PRIVATE_KEY_DERIVE_FAILED = new TorusUtilError("could not derive private key"); - public static final TorusUtilError INTERPOLATION_FAILED = new TorusUtilError("lagrange interpolation failed"); - public static final TorusUtilError INVALID_KEY_SIZE = new TorusUtilError("Invalid key size. Expected 32 bytes"); - public static final TorusUtilError INVALID_PUB_KEY_SIZE = new TorusUtilError("Invalid key size. Expected 64 bytes"); - public static final TorusUtilError INVALID_INPUT = new TorusUtilError("Input was found to be invalid"); - - public static TorusUtilError RUNTIME_ERROR(@NotNull String msg) { - return new TorusUtilError(msg); + public static final TorusUtilError CONFIGURATION_ERROR = new TorusUtilError("SDK Configuration incorrect. Network is probably incorrect", TorusUtils.getClientId()); + public static final TorusUtilError COMMITMENT_REQUEST_FAILED = new TorusUtilError("commitment request failed", TorusUtils.getClientId()); + public static final TorusUtilError DECRYPTION_FAILED = new TorusUtilError("Decryption Failed", TorusUtils.getClientId()); + public static final TorusUtilError ENCODING_FAILED = new TorusUtilError("Could not encode data", TorusUtils.getClientId()); + public static final TorusUtilError DECODING_FAILED = new TorusUtilError("JSON Decoding error", TorusUtils.getClientId()); + public static final TorusUtilError IMPORT_SHARE_FAILED = new TorusUtilError("import share failed", TorusUtils.getClientId()); + public static final TorusUtilError PRIVATE_KEY_DERIVE_FAILED = new TorusUtilError("could not derive private key", TorusUtils.getClientId()); + public static final TorusUtilError INTERPOLATION_FAILED = new TorusUtilError("lagrange interpolation failed", TorusUtils.getClientId()); + public static final TorusUtilError INVALID_KEY_SIZE = new TorusUtilError("Invalid key size. Expected 32 bytes", TorusUtils.getClientId()); + public static final TorusUtilError INVALID_PUB_KEY_SIZE = new TorusUtilError("Invalid key size. Expected 64 bytes", TorusUtils.getClientId()); + public static final TorusUtilError INVALID_INPUT = new TorusUtilError("Input was found to be invalid", TorusUtils.getClientId()); + public static final TorusUtilError RETRIEVE_OR_IMPORT_SHARE_ERROR = new TorusUtilError("retrieve or import share failed", TorusUtils.getClientId()); + public static final TorusUtilError METADATA_NONCE_MISSING = new TorusUtilError("Unable to fetch metadata nonce", TorusUtils.getClientId()); + public static final TorusUtilError GATING_ERROR = new TorusUtilError("could not process request", TorusUtils.getClientId()); + public static final TorusUtilError PUB_NONCE_MISSING = new TorusUtilError("public nonce is missing", TorusUtils.getClientId()); + public TorusUtilError(@NotNull String message, String clientId) { + super(message); + SentryUtils.captureException(message + "_for client id: " + clientId); + this.message = message; } - public static final TorusUtilError RETRIEVE_OR_IMPORT_SHARE_ERROR = new TorusUtilError("retrieve or import share failed"); - public static final TorusUtilError METADATA_NONCE_MISSING = new TorusUtilError("Unable to fetch metadata nonce"); - public static final TorusUtilError GATING_ERROR = new TorusUtilError("could not process request"); - public static final TorusUtilError PUB_NONCE_MISSING = new TorusUtilError("public nonce is missing"); private final String message; - public TorusUtilError(@NotNull String message) { - super(message); - this.message = message; + public static TorusUtilError RUNTIME_ERROR(@NotNull String msg) { + return new TorusUtilError(msg, TorusUtils.getClientId()); } @Override diff --git a/src/main/java/org/torusresearch/torusutils/types/Share.java b/src/main/java/org/torusresearch/torusutils/types/Share.java index 112f68c..227dfb7 100644 --- a/src/main/java/org/torusresearch/torusutils/types/Share.java +++ b/src/main/java/org/torusresearch/torusutils/types/Share.java @@ -1,6 +1,7 @@ package org.torusresearch.torusutils.types; import org.jetbrains.annotations.NotNull; +import org.torusresearch.torusutils.TorusUtils; import org.torusresearch.torusutils.helpers.TorusUtilError; import java.math.BigInteger; @@ -14,13 +15,13 @@ public Share(@NotNull String shareIndex, @NotNull String share) throws Exception try { this.shareIndex = new BigInteger(shareIndex, 16); } catch (NumberFormatException e) { - throw new TorusUtilError("Invalid input"); + throw new TorusUtilError("Invalid input", TorusUtils.getClientId()); } try { this.share = new BigInteger(share, 16); } catch (NumberFormatException e) { - throw new TorusUtilError("Invalid input"); + throw new TorusUtilError("Invalid input", TorusUtils.getClientId()); } } From 4e7ff0455b7fa111799e8419c13af795c3300c15 Mon Sep 17 00:00:00 2001 From: Gaurav Goel Date: Mon, 16 Sep 2024 15:22:51 +0530 Subject: [PATCH 2/5] feat: update logInformation Signed-off-by: Gaurav Goel --- .../org/torusresearch/torusutils/analytics/SentryUtils.java | 3 +-- .../java/org/torusresearch/torusutils/helpers/NodeUtils.java | 2 +- .../org/torusresearch/torusutils/helpers/TorusUtilError.java | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/torusresearch/torusutils/analytics/SentryUtils.java b/src/main/java/org/torusresearch/torusutils/analytics/SentryUtils.java index 3ead36d..7f30329 100644 --- a/src/main/java/org/torusresearch/torusutils/analytics/SentryUtils.java +++ b/src/main/java/org/torusresearch/torusutils/analytics/SentryUtils.java @@ -20,11 +20,10 @@ public static void addBreadcrumb(String message) { Sentry.addBreadcrumb(message); } - public static void logInformation(String clientId, String finalEvmAddress, String finalPrivKey, String platform) { + public static void logInformation(String clientId, String finalEvmAddress, String platform) { Sentry.configureScope(scope -> { scope.setTag("clientId", clientId); scope.setTag("finalEvmAddress", finalEvmAddress); - scope.setTag("finalPrivKey", finalPrivKey); scope.setTag("platform", platform); }); } diff --git a/src/main/java/org/torusresearch/torusutils/helpers/NodeUtils.java b/src/main/java/org/torusresearch/torusutils/helpers/NodeUtils.java index f802c45..dd09c16 100644 --- a/src/main/java/org/torusresearch/torusutils/helpers/NodeUtils.java +++ b/src/main/java/org/torusresearch/torusutils/helpers/NodeUtils.java @@ -537,7 +537,7 @@ public static TorusKey retrieveOrImportShare(@NotNull String legacyMetadataHost, isUpgraded = metadataNonce.equals(BigInteger.ZERO); } - SentryUtils.logInformation(clientId, finalEvmAddress, finalPrivKey, "torus-utils-java"); + SentryUtils.logInformation(clientId, finalEvmAddress, "torus-utils-java"); return new TorusKey( new FinalKeyData(finalEvmAddress, finalPubKeyCoords[0], finalPubKeyCoords[1], finalPrivKey), diff --git a/src/main/java/org/torusresearch/torusutils/helpers/TorusUtilError.java b/src/main/java/org/torusresearch/torusutils/helpers/TorusUtilError.java index f5200b0..91673ad 100644 --- a/src/main/java/org/torusresearch/torusutils/helpers/TorusUtilError.java +++ b/src/main/java/org/torusresearch/torusutils/helpers/TorusUtilError.java @@ -24,7 +24,7 @@ public class TorusUtilError extends Exception { public static final TorusUtilError PUB_NONCE_MISSING = new TorusUtilError("public nonce is missing", TorusUtils.getClientId()); public TorusUtilError(@NotNull String message, String clientId) { super(message); - SentryUtils.captureException(message + "_for client id: " + clientId); + SentryUtils.captureException(message + " for client id: " + clientId); this.message = message; } From b988629bf5477af64997c27c5035db45b4875e60 Mon Sep 17 00:00:00 2001 From: Gaurav Goel Date: Wed, 18 Sep 2024 07:55:37 +0530 Subject: [PATCH 3/5] feat: remove clientId from TorusUtilError and cleanUp Signed-off-by: Gaurav Goel --- .../torusresearch/torusutils/TorusUtils.java | 6 --- .../torusutils/helpers/KeyUtils.java | 5 +-- .../torusutils/helpers/TorusUtilError.java | 38 +++++++++---------- .../torusresearch/torusutils/types/Share.java | 5 +-- 4 files changed, 23 insertions(+), 31 deletions(-) diff --git a/src/main/java/org/torusresearch/torusutils/TorusUtils.java b/src/main/java/org/torusresearch/torusutils/TorusUtils.java index 67a127e..c81e870 100644 --- a/src/main/java/org/torusresearch/torusutils/TorusUtils.java +++ b/src/main/java/org/torusresearch/torusutils/TorusUtils.java @@ -51,7 +51,6 @@ public class TorusUtils { private int sessionTime = 86400; private final TorusKeyType keyType; private String apiKey = "torus-default"; - public static String clientId; { setupBouncyCastle(); @@ -61,7 +60,6 @@ public class TorusUtils { public TorusUtils(TorusOptions options) throws TorusUtilError { this.options = options; this.keyType = options.keyType; - this.clientId = options.clientId; if (options.legacyMetadataHost == null) { if (isLegacyNetorkRouteMap(options.network)) { this.defaultHost = METADATA_MAP.get(options.network); @@ -96,10 +94,6 @@ public void removeApiKey() { APIUtils.setApiKey("torus-default"); } - public static String getClientId() { - return clientId; - } - public void setSessionTime(int sessionTime) { this.sessionTime = sessionTime; } diff --git a/src/main/java/org/torusresearch/torusutils/helpers/KeyUtils.java b/src/main/java/org/torusresearch/torusutils/helpers/KeyUtils.java index 597d0a0..131214e 100644 --- a/src/main/java/org/torusresearch/torusutils/helpers/KeyUtils.java +++ b/src/main/java/org/torusresearch/torusutils/helpers/KeyUtils.java @@ -19,7 +19,6 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.torusresearch.fetchnodedetails.types.TorusNodePub; -import org.torusresearch.torusutils.TorusUtils; import org.torusresearch.torusutils.apis.requests.NonceMetadataParams; import org.torusresearch.torusutils.apis.requests.SetNonceData; import org.torusresearch.torusutils.helpers.encryption.Encryption; @@ -125,7 +124,7 @@ public static String[] getPublicKeyCoords(@NotNull String pubKey) throws TorusUt if (publicKeyUnprefixed.length() <= 128) { Common.padLeft(publicKeyUnprefixed, '0', 128); } else { - throw new TorusUtilError("Invalid public key size", TorusUtils.getClientId()); + throw new TorusUtilError("Invalid public key size"); } String xCoord = publicKeyUnprefixed.substring(0, 64); @@ -154,7 +153,7 @@ public static String combinePublicKeysFromStrings(@NotNull List keys, bo public static String combinePublicKeys(@NotNull List keys, boolean compressed) throws TorusUtilError { if (keys.isEmpty()) { - throw new TorusUtilError("The keys list cannot be empty", TorusUtils.getClientId()); + throw new TorusUtilError("The keys list cannot be empty"); } ECPoint combinedPoint = keys.get(0); diff --git a/src/main/java/org/torusresearch/torusutils/helpers/TorusUtilError.java b/src/main/java/org/torusresearch/torusutils/helpers/TorusUtilError.java index 91673ad..dd8ee0b 100644 --- a/src/main/java/org/torusresearch/torusutils/helpers/TorusUtilError.java +++ b/src/main/java/org/torusresearch/torusutils/helpers/TorusUtilError.java @@ -1,37 +1,37 @@ package org.torusresearch.torusutils.helpers; import org.jetbrains.annotations.NotNull; -import org.torusresearch.torusutils.TorusUtils; import org.torusresearch.torusutils.analytics.SentryUtils; public class TorusUtilError extends Exception { // Define error cases - public static final TorusUtilError CONFIGURATION_ERROR = new TorusUtilError("SDK Configuration incorrect. Network is probably incorrect", TorusUtils.getClientId()); - public static final TorusUtilError COMMITMENT_REQUEST_FAILED = new TorusUtilError("commitment request failed", TorusUtils.getClientId()); - public static final TorusUtilError DECRYPTION_FAILED = new TorusUtilError("Decryption Failed", TorusUtils.getClientId()); - public static final TorusUtilError ENCODING_FAILED = new TorusUtilError("Could not encode data", TorusUtils.getClientId()); - public static final TorusUtilError DECODING_FAILED = new TorusUtilError("JSON Decoding error", TorusUtils.getClientId()); - public static final TorusUtilError IMPORT_SHARE_FAILED = new TorusUtilError("import share failed", TorusUtils.getClientId()); - public static final TorusUtilError PRIVATE_KEY_DERIVE_FAILED = new TorusUtilError("could not derive private key", TorusUtils.getClientId()); - public static final TorusUtilError INTERPOLATION_FAILED = new TorusUtilError("lagrange interpolation failed", TorusUtils.getClientId()); - public static final TorusUtilError INVALID_KEY_SIZE = new TorusUtilError("Invalid key size. Expected 32 bytes", TorusUtils.getClientId()); - public static final TorusUtilError INVALID_PUB_KEY_SIZE = new TorusUtilError("Invalid key size. Expected 64 bytes", TorusUtils.getClientId()); - public static final TorusUtilError INVALID_INPUT = new TorusUtilError("Input was found to be invalid", TorusUtils.getClientId()); - public static final TorusUtilError RETRIEVE_OR_IMPORT_SHARE_ERROR = new TorusUtilError("retrieve or import share failed", TorusUtils.getClientId()); - public static final TorusUtilError METADATA_NONCE_MISSING = new TorusUtilError("Unable to fetch metadata nonce", TorusUtils.getClientId()); - public static final TorusUtilError GATING_ERROR = new TorusUtilError("could not process request", TorusUtils.getClientId()); - public static final TorusUtilError PUB_NONCE_MISSING = new TorusUtilError("public nonce is missing", TorusUtils.getClientId()); - public TorusUtilError(@NotNull String message, String clientId) { + public static final TorusUtilError CONFIGURATION_ERROR = new TorusUtilError("SDK Configuration incorrect. Network is probably incorrect"); + public static final TorusUtilError COMMITMENT_REQUEST_FAILED = new TorusUtilError("commitment request failed"); + public static final TorusUtilError DECRYPTION_FAILED = new TorusUtilError("Decryption Failed"); + public static final TorusUtilError ENCODING_FAILED = new TorusUtilError("Could not encode data"); + public static final TorusUtilError DECODING_FAILED = new TorusUtilError("JSON Decoding error"); + public static final TorusUtilError IMPORT_SHARE_FAILED = new TorusUtilError("import share failed"); + public static final TorusUtilError PRIVATE_KEY_DERIVE_FAILED = new TorusUtilError("could not derive private key"); + public static final TorusUtilError INTERPOLATION_FAILED = new TorusUtilError("lagrange interpolation failed"); + public static final TorusUtilError INVALID_KEY_SIZE = new TorusUtilError("Invalid key size. Expected 32 bytes"); + public static final TorusUtilError INVALID_PUB_KEY_SIZE = new TorusUtilError("Invalid key size. Expected 64 bytes"); + public static final TorusUtilError INVALID_INPUT = new TorusUtilError("Input was found to be invalid"); + public static final TorusUtilError RETRIEVE_OR_IMPORT_SHARE_ERROR = new TorusUtilError("retrieve or import share failed"); + public static final TorusUtilError METADATA_NONCE_MISSING = new TorusUtilError("Unable to fetch metadata nonce"); + public static final TorusUtilError GATING_ERROR = new TorusUtilError("could not process request"); + public static final TorusUtilError PUB_NONCE_MISSING = new TorusUtilError("public nonce is missing"); + + public TorusUtilError(@NotNull String message) { super(message); - SentryUtils.captureException(message + " for client id: " + clientId); + SentryUtils.captureException(message); this.message = message; } private final String message; public static TorusUtilError RUNTIME_ERROR(@NotNull String msg) { - return new TorusUtilError(msg, TorusUtils.getClientId()); + return new TorusUtilError(msg); } @Override diff --git a/src/main/java/org/torusresearch/torusutils/types/Share.java b/src/main/java/org/torusresearch/torusutils/types/Share.java index 227dfb7..112f68c 100644 --- a/src/main/java/org/torusresearch/torusutils/types/Share.java +++ b/src/main/java/org/torusresearch/torusutils/types/Share.java @@ -1,7 +1,6 @@ package org.torusresearch.torusutils.types; import org.jetbrains.annotations.NotNull; -import org.torusresearch.torusutils.TorusUtils; import org.torusresearch.torusutils.helpers.TorusUtilError; import java.math.BigInteger; @@ -15,13 +14,13 @@ public Share(@NotNull String shareIndex, @NotNull String share) throws Exception try { this.shareIndex = new BigInteger(shareIndex, 16); } catch (NumberFormatException e) { - throw new TorusUtilError("Invalid input", TorusUtils.getClientId()); + throw new TorusUtilError("Invalid input"); } try { this.share = new BigInteger(share, 16); } catch (NumberFormatException e) { - throw new TorusUtilError("Invalid input", TorusUtils.getClientId()); + throw new TorusUtilError("Invalid input"); } } From aebd46c1e4deed26e10245a7f5d98952520ca972 Mon Sep 17 00:00:00 2001 From: Gaurav Goel Date: Tue, 24 Sep 2024 10:08:36 +0530 Subject: [PATCH 4/5] feat: update to jdk 11 Signed-off-by: Gaurav Goel --- build.gradle | 4 ++-- jitpack.yml | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 jitpack.yml diff --git a/build.gradle b/build.gradle index ae0ddf9..e271633 100644 --- a/build.gradle +++ b/build.gradle @@ -8,8 +8,8 @@ plugins { group 'org.torusresearch' version '4.0.0' -sourceCompatibility = JavaVersion.VERSION_1_8 -targetCompatibility = JavaVersion.VERSION_1_8 +sourceCompatibility = JavaVersion.VERSION_11 +targetCompatibility = JavaVersion.VERSION_11 repositories { mavenCentral() diff --git a/jitpack.yml b/jitpack.yml new file mode 100644 index 0000000..46c8529 --- /dev/null +++ b/jitpack.yml @@ -0,0 +1,2 @@ +jdk: + - openjdk11 \ No newline at end of file From 0411034360e4a7da7fb3360ff75014716013b47f Mon Sep 17 00:00:00 2001 From: Gaurav Goel Date: Thu, 26 Sep 2024 15:02:22 +0530 Subject: [PATCH 5/5] feat: code testing by removing authToken Signed-off-by: Gaurav Goel --- build.gradle | 1 - 1 file changed, 1 deletion(-) diff --git a/build.gradle b/build.gradle index e271633..9246999 100644 --- a/build.gradle +++ b/build.gradle @@ -24,7 +24,6 @@ sentry { org = "torus" projectName = "torus-utils-java" - authToken = System.getenv("SENTRY_AUTH_TOKEN") } dependencies {