Skip to content

Commit

Permalink
Merge pull request #89 from Web3Auth/feat/wallet_services_updates
Browse files Browse the repository at this point in the history
feat: updated request() method and added platform paramater in url va…
  • Loading branch information
chaitanyapotti authored May 15, 2024
2 parents f1c719f + 2216d38 commit fb2e887
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
8 changes: 4 additions & 4 deletions app/src/main/java/com/web3auth/app/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,10 @@ class MainActivity : AppCompatActivity(), AdapterView.OnItemClickListener {
add("Android")
}
val signMsgCompletableFuture = web3Auth.request(
loginParams = LoginParams(
selectedLoginProvider,
extraLoginOptions = null,
mfaLevel = MFALevel.NONE,
chainConfig = ChainConfig(
chainId = "0x89",
rpcTarget = "https://polygon-rpc.com/",
chainNamespace = ChainNamespace.EIP155
), "personal_sign", requestParams = params
)
signMsgCompletableFuture.whenComplete { _, error ->
Expand Down
15 changes: 8 additions & 7 deletions core/src/main/java/com/web3auth/core/Web3Auth.kt
Original file line number Diff line number Diff line change
Expand Up @@ -390,14 +390,13 @@ class Web3Auth(web3AuthOptions: Web3AuthOptions) {
/**
* Launches the wallet services asynchronously.
*
* @param loginParams The login parameters required for authentication.
* @param chainConfig The configuration details of the blockchain network.
* @param path The path where the wallet services will be launched. Default value is "wallet".
* @return A CompletableFuture<Void> representing the asynchronous operation.
*/
fun launchWalletServices(
chainConfig: ChainConfig,
path: String? = "wallet"
path: String? = "wallet",
): CompletableFuture<Void> {
val launchWalletServiceCF: CompletableFuture<Void> = CompletableFuture()
val sessionId = sessionManager.getSessionId()
Expand All @@ -424,7 +423,7 @@ class Web3Auth(web3AuthOptions: Web3AuthOptions) {
"loginId", loginId
)
walletMap.addProperty("sessionId", sessionId)
walletMap.addProperty("isAndroid", true)
walletMap.addProperty("platform", "android")

val walletHash =
"b64Params=" + gson.toJson(walletMap).toByteArray(Charsets.UTF_8)
Expand All @@ -451,14 +450,14 @@ class Web3Auth(web3AuthOptions: Web3AuthOptions) {
/**
* Signs a message asynchronously.
*
* @param loginParams The login parameters required for authentication.
* @param chainConfig The configuration details of the blockchain network.
* @param method The method name of the request.
* @param requestParams The parameters of the request in JSON array format.
* @param path The path where the signing service is located. Default value is "wallet/request".
* @return A CompletableFuture<Void> representing the asynchronous operation.
*/
fun request(
loginParams: LoginParams,
chainConfig: ChainConfig,
method: String,
requestParams: JsonArray,
path: String? = "wallet/request"
Expand All @@ -469,12 +468,13 @@ class Web3Auth(web3AuthOptions: Web3AuthOptions) {
val sdkUrl = Uri.parse(web3AuthOption.walletSdkUrl)
val context = web3AuthOption.context
val initOptions = getInitOptions()
val initParams = getInitParams(loginParams)
initOptions.put(
"chainConfig", gson.toJson(chainConfig)
)
val paramMap = JSONObject()
paramMap.put(
"options", initOptions
)
paramMap.put("params", initParams)

val loginIdCf = getLoginId(paramMap)

Expand All @@ -483,6 +483,7 @@ class Web3Auth(web3AuthOptions: Web3AuthOptions) {
val signMessageMap = JsonObject()
signMessageMap.addProperty("loginId", loginId)
signMessageMap.addProperty("sessionId", sessionId)
signMessageMap.addProperty("platform", "android")

val requestData = JsonObject().apply {
addProperty("method", method)
Expand Down

0 comments on commit fb2e887

Please sign in to comment.