Skip to content

Commit 35ad4c5

Browse files
committed
feat: Update code for wallet-services and request function. Example also updated
Signed-off-by: Gaurav Goel <[email protected]>
1 parent 83cda5a commit 35ad4c5

File tree

2 files changed

+23
-15
lines changed

2 files changed

+23
-15
lines changed

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

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -224,11 +224,13 @@ class MainActivity : AppCompatActivity(), AdapterView.OnItemClickListener {
224224
val launchWalletButton = findViewById<Button>(R.id.launchWalletButton)
225225
launchWalletButton.setOnClickListener {
226226
val launchWalletCompletableFuture = web3Auth.launchWalletServices(
227-
chainConfig = ChainConfig(
228-
chainId = "0x89",
229-
rpcTarget = "https://1rpc.io/matic",
230-
chainNamespace = ChainNamespace.EIP155
231-
)
227+
chainConfig = listOf(
228+
ChainConfig(
229+
chainId = "0x89",
230+
rpcTarget = "https://1rpc.io/matic",
231+
chainNamespace = ChainNamespace.EIP155
232+
)
233+
), chainId = "0x89"
232234
)
233235
launchWalletCompletableFuture.whenComplete { _, error ->
234236
if (error == null) {
@@ -248,11 +250,13 @@ class MainActivity : AppCompatActivity(), AdapterView.OnItemClickListener {
248250
add("Android")
249251
}
250252
val signMsgCompletableFuture = web3Auth.request(
251-
chainConfig = ChainConfig(
252-
chainId = "0x89",
253-
rpcTarget = "https://polygon-rpc.com/",
254-
chainNamespace = ChainNamespace.EIP155
255-
), "personal_sign", requestParams = params, appState = "web3Auth"
253+
chainConfig = listOf(
254+
ChainConfig(
255+
chainId = "0x89",
256+
rpcTarget = "https://polygon-rpc.com/",
257+
chainNamespace = ChainNamespace.EIP155
258+
)
259+
), chainId = "0x89", "personal_sign", requestParams = params, appState = "web3Auth"
256260
)
257261
signMsgCompletableFuture.whenComplete { signResult, error ->
258262
if (error == null) {

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -520,8 +520,9 @@ class Web3Auth(web3AuthOptions: Web3AuthOptions, context: Context) : WebViewResu
520520
* @return A CompletableFuture<Void> representing the asynchronous operation.
521521
*/
522522
fun launchWalletServices(
523-
chainConfig: ChainConfig,
524-
path: String? = "wallet"
523+
chainConfig: List<ChainConfig>,
524+
chainId: String,
525+
path: String? = "wallet",
525526
): CompletableFuture<Void> {
526527
val launchWalletServiceCF: CompletableFuture<Void> = CompletableFuture()
527528
val savedSessionId = SessionManager.getSessionIdFromStorage()
@@ -530,8 +531,9 @@ class Web3Auth(web3AuthOptions: Web3AuthOptions, context: Context) : WebViewResu
530531

531532
val initOptions = JSONObject(gson.toJson(getInitOptions()))
532533
initOptions.put(
533-
"chainConfig", gson.toJson(chainConfig)
534+
"chains", gson.toJson(chainConfig)
534535
)
536+
initOptions.put("chainId", chainId)
535537

536538
val paramMap = JSONObject()
537539
paramMap.put(
@@ -581,7 +583,8 @@ class Web3Auth(web3AuthOptions: Web3AuthOptions, context: Context) : WebViewResu
581583
* @return A CompletableFuture<Void> representing the asynchronous operation.
582584
*/
583585
fun request(
584-
chainConfig: ChainConfig,
586+
chainConfig: List<ChainConfig>,
587+
chainId: String,
585588
method: String,
586589
requestParams: JsonArray,
587590
path: String? = "wallet/request",
@@ -595,8 +598,9 @@ class Web3Auth(web3AuthOptions: Web3AuthOptions, context: Context) : WebViewResu
595598
val sdkUrl = Uri.parse(web3AuthOption.walletSdkUrl)
596599
val initOptions = JSONObject(gson.toJson(getInitOptions()))
597600
initOptions.put(
598-
"chainConfig", gson.toJson(chainConfig)
601+
"chains", gson.toJson(chainConfig)
599602
)
603+
initOptions.put("chainId", chainId)
600604
val paramMap = JSONObject()
601605
paramMap.put(
602606
"options", initOptions

0 commit comments

Comments
 (0)