Skip to content

Commit

Permalink
feat: disable import of private key for legacy networks
Browse files Browse the repository at this point in the history
  • Loading branch information
metalurgical committed Jan 21, 2025
1 parent 235a708 commit 26eaacb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Sources/TorusUtils/Helpers/Error.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public enum TorusUtilError: Error, Equatable {
case metadataNonceMissing
case pubNonceMissing
case gatingError(_ msg: String = "")
case legacyImportUnsupported(_ network: String)
case invalidInput
}

Expand Down Expand Up @@ -52,6 +53,8 @@ extension TorusUtilError: CustomDebugStringConvertible {
return "Unable to fetch metadata nonce"
case let .gatingError(msg):
return "could not process request" + msg
case let .legacyImportUnsupported(network):
return "importPrivateKey is not supported by legacy network: " + network
case .pubNonceMissing:
return "Public nonce is missing"
}
Expand Down Expand Up @@ -88,6 +91,8 @@ extension TorusUtilError: LocalizedError {
return "Could not encode data " + msg
case let .gatingError(msg):
return msg
case let .legacyImportUnsupported(network):
return "importPrivateKey is not supported by legacy network: " + network
default:
return "default Error msg"
}
Expand Down
4 changes: 4 additions & 0 deletions Sources/TorusUtils/TorusUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ public class TorusUtils {
newPrivateKey: String,
extraParams: TorusUtilsExtraParams = TorusUtilsExtraParams()
) async throws -> TorusKey {
if network.isLegacy {
throw TorusUtilError.legacyImportUnsupported(network.name)
}

let nodePubs = TorusNodePubModelToINodePub(nodes: nodePubKeys)
if endpoints.count != nodeIndexes.count {
throw TorusUtilError.runtime("Length of endpoints must be the same as length of nodeIndexes")
Expand Down
2 changes: 1 addition & 1 deletion Torus-utils.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |spec|
spec.name = "Torus-utils"
spec.version = "10.0.1"
spec.version = "10.0.2"
spec.ios.deployment_target = "13.0"
spec.summary = "Retrieve user shares"
spec.homepage = "https://github.com/torusresearch/torus-utils-swift"
Expand Down

0 comments on commit 26eaacb

Please sign in to comment.