Skip to content

Commit fb2e887

Browse files
Merge pull request #89 from Web3Auth/feat/wallet_services_updates
feat: updated request() method and added platform paramater in url va…
2 parents f1c719f + 2216d38 commit fb2e887

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

app/src/main/java/com/web3auth/app/MainActivity.kt

+4-4
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,10 @@ class MainActivity : AppCompatActivity(), AdapterView.OnItemClickListener {
212212
add("Android")
213213
}
214214
val signMsgCompletableFuture = web3Auth.request(
215-
loginParams = LoginParams(
216-
selectedLoginProvider,
217-
extraLoginOptions = null,
218-
mfaLevel = MFALevel.NONE,
215+
chainConfig = ChainConfig(
216+
chainId = "0x89",
217+
rpcTarget = "https://polygon-rpc.com/",
218+
chainNamespace = ChainNamespace.EIP155
219219
), "personal_sign", requestParams = params
220220
)
221221
signMsgCompletableFuture.whenComplete { _, error ->

core/src/main/java/com/web3auth/core/Web3Auth.kt

+8-7
Original file line numberDiff line numberDiff line change
@@ -390,14 +390,13 @@ class Web3Auth(web3AuthOptions: Web3AuthOptions) {
390390
/**
391391
* Launches the wallet services asynchronously.
392392
*
393-
* @param loginParams The login parameters required for authentication.
394393
* @param chainConfig The configuration details of the blockchain network.
395394
* @param path The path where the wallet services will be launched. Default value is "wallet".
396395
* @return A CompletableFuture<Void> representing the asynchronous operation.
397396
*/
398397
fun launchWalletServices(
399398
chainConfig: ChainConfig,
400-
path: String? = "wallet"
399+
path: String? = "wallet",
401400
): CompletableFuture<Void> {
402401
val launchWalletServiceCF: CompletableFuture<Void> = CompletableFuture()
403402
val sessionId = sessionManager.getSessionId()
@@ -424,7 +423,7 @@ class Web3Auth(web3AuthOptions: Web3AuthOptions) {
424423
"loginId", loginId
425424
)
426425
walletMap.addProperty("sessionId", sessionId)
427-
walletMap.addProperty("isAndroid", true)
426+
walletMap.addProperty("platform", "android")
428427

429428
val walletHash =
430429
"b64Params=" + gson.toJson(walletMap).toByteArray(Charsets.UTF_8)
@@ -451,14 +450,14 @@ class Web3Auth(web3AuthOptions: Web3AuthOptions) {
451450
/**
452451
* Signs a message asynchronously.
453452
*
454-
* @param loginParams The login parameters required for authentication.
453+
* @param chainConfig The configuration details of the blockchain network.
455454
* @param method The method name of the request.
456455
* @param requestParams The parameters of the request in JSON array format.
457456
* @param path The path where the signing service is located. Default value is "wallet/request".
458457
* @return A CompletableFuture<Void> representing the asynchronous operation.
459458
*/
460459
fun request(
461-
loginParams: LoginParams,
460+
chainConfig: ChainConfig,
462461
method: String,
463462
requestParams: JsonArray,
464463
path: String? = "wallet/request"
@@ -469,12 +468,13 @@ class Web3Auth(web3AuthOptions: Web3AuthOptions) {
469468
val sdkUrl = Uri.parse(web3AuthOption.walletSdkUrl)
470469
val context = web3AuthOption.context
471470
val initOptions = getInitOptions()
472-
val initParams = getInitParams(loginParams)
471+
initOptions.put(
472+
"chainConfig", gson.toJson(chainConfig)
473+
)
473474
val paramMap = JSONObject()
474475
paramMap.put(
475476
"options", initOptions
476477
)
477-
paramMap.put("params", initParams)
478478

479479
val loginIdCf = getLoginId(paramMap)
480480

@@ -483,6 +483,7 @@ class Web3Auth(web3AuthOptions: Web3AuthOptions) {
483483
val signMessageMap = JsonObject()
484484
signMessageMap.addProperty("loginId", loginId)
485485
signMessageMap.addProperty("sessionId", sessionId)
486+
signMessageMap.addProperty("platform", "android")
486487

487488
val requestData = JsonObject().apply {
488489
addProperty("method", method)

0 commit comments

Comments
 (0)