Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
rosepuppy committed Apr 24, 2024
1 parent 77ff542 commit 88c11db
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 31 deletions.
34 changes: 11 additions & 23 deletions src/commonMain/kotlin/exchange.dydx.abacus/output/Compliance.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,21 @@ import kotlin.js.JsExport

@JsExport
@Serializable
enum class ComplianceStatus(val rawValue: String?) {
COMPLIANT("COMPLIANT"),
FIRST_STRIKE("FIRST_STRIKE"),
CLOSE_ONLY("CLOSE_ONLY"),
BLOCKED("BLOCKED"),
UNKNOWN("UNKNOWN"),
;

companion object {
operator fun invoke(rawValue: String?) =
ComplianceStatus.values().firstOrNull { it.rawValue == rawValue }
}
enum class ComplianceStatus {
COMPLIANT,
FIRST_STRIKE,
CLOSE_ONLY,
BLOCKED,
UNKNOWN;
}

@JsExport
@Serializable
enum class ComplianceAction(val rawValue: String?) {
ONBOARD("ONBOARD"),
CONNECT("CONNECT"),
VALID_SURVEY("VALID_SURVEY"),
INVALID_SURVEY("INVALID_SURVEY"),
;

companion object {
operator fun invoke(rawValue: String?) =
ComplianceStatus.values().firstOrNull { it.rawValue == rawValue }
}
enum class ComplianceAction {
ONBOARD,
CONNECT,
VALID_SURVEY,
INVALID_SURVEY;
}

@JsExport
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2422,7 +2422,7 @@ open class StateManagerAdaptor(
val res = parser.decodeJsonObject(response)?.toIMap()
if (res != null) {
val status = parser.asString(res["status"])
val complianceStatus = ComplianceStatus.invoke(status) ?: ComplianceStatus.UNKNOWN
val complianceStatus = if (status != null) ComplianceStatus.valueOf(status) else ComplianceStatus.UNKNOWN
callback?.invoke(complianceStatus)

Compliance(compliance?.geo, complianceStatus)
Expand All @@ -2444,8 +2444,8 @@ open class StateManagerAdaptor(
val payload = jsonEncoder.encode(
mapOf(
"message" to message,
"action" to action.rawValue,
"status" to status.rawValue,
"action" to action,
"status" to status,
),
)
transaction(
Expand All @@ -2462,15 +2462,14 @@ open class StateManagerAdaptor(
val timestamp = parser.asString(result["timestamp"])

val isUrlAndKeysPresent = url != null && signedMessage != null && publicKey != null && timestamp != null
val isActionAndStatusValid = action.rawValue != null && status.rawValue != null
val isStatusValid = status.rawValue != ComplianceStatus.UNKNOWN.rawValue
val isStatusValid = status != ComplianceStatus.UNKNOWN

if (isUrlAndKeysPresent && isActionAndStatusValid && isStatusValid) {
if (isUrlAndKeysPresent && isStatusValid) {
val body: IMap<String, String> = iMapOf(
"address" to address,
"message" to message,
"currentStatus" to status.rawValue!!,
"action" to action.rawValue!!,
"currentStatus" to status.toString(),
"action" to action.toString(),
"signedMessage" to signedMessage!!,
"pubkey" to publicKey!!,
"timestamp" to timestamp!!,
Expand Down

0 comments on commit 88c11db

Please sign in to comment.