-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Add prefix to determine account's ecosystem (#147)
Determining which blockchain the address belongs to might be frustrating when dealing with multiple platforms. Defining a custom prefix for each blockchain might be a useful and easy to implement solution
- Loading branch information
Showing
2 changed files
with
15 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 14 additions & 7 deletions
21
src/main/kotlin/id/walt/webwallet/backend/auth/UserInfo.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,31 @@ | ||
package id.walt.webwallet.backend.auth | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
class UserInfo( | ||
val id: String | ||
) { | ||
class UserInfo(var id: String ) { | ||
var email: String? = null | ||
var password: String? = null | ||
var token: String? = null | ||
var ethAccount: String? = null | ||
var did: String? = null | ||
var tezosAccount: String? = null | ||
var polkadotAccount: String? = null | ||
var polkadotEvmAccount: String? = null | ||
var flowAccount: String? = null | ||
|
||
init { | ||
when { | ||
id.contains("@") -> email = id | ||
id.lowercase().contains("0x") -> ethAccount = id | ||
id.lowercase().startsWith("did:") -> did = id | ||
id.startsWith("did") -> { | ||
did = id | ||
} | ||
id.split("##")[0].lowercase().startsWith("eth") -> {ethAccount = id.split("##")[1] } | ||
id.split("##")[0].lowercase().startsWith("pol") -> {polkadotAccount = id.split("##")[1]} | ||
id.split("##")[0].lowercase().startsWith("polevm") -> {polkadotEvmAccount = id.split("##")[1]} | ||
id.split("##")[0].lowercase().startsWith("flow") -> {flowAccount = id.split("##")[1]} | ||
id.lowercase().startsWith("tz") -> tezosAccount = id | ||
|
||
} | ||
|
||
} | ||
} | ||
} |