@novastera-oss/nitro-metamask 0.2.5 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  package com.margelo.nitro.nitrometamask
2
2
 
3
3
  import com.margelo.nitro.core.Promise
4
- import com.margelo.nitro.core.NitroRuntime
4
+ import com.margelo.nitro.modules.NitroModulesContextHolder
5
5
  import io.metamask.androidsdk.Ethereum
6
6
  import io.metamask.androidsdk.Result
7
7
  import io.metamask.androidsdk.DappMetadata
@@ -14,10 +14,10 @@ import kotlin.coroutines.resume
14
14
  class HybridMetamaskConnector : HybridMetamaskConnectorSpec() {
15
15
  // Initialize Ethereum SDK with Context, DappMetadata, and SDKOptions
16
16
  // Based on: https://github.com/MetaMask/metamask-android-sdk
17
- // Using NitroRuntime for proper Nitro context access (survives reloads, no static leaks)
17
+ // Using NitroModulesContextHolder for proper Nitro context access (survives reloads, no static leaks)
18
18
  private val ethereum: Ethereum by lazy {
19
- val context = NitroRuntime.applicationContext
20
- ?: throw IllegalStateException("Nitro application context not available")
19
+ val context = NitroModulesContextHolder.getApplicationContext()
20
+ ?: throw IllegalStateException("Application context not available")
21
21
 
22
22
  val dappMetadata = DappMetadata(
23
23
  name = "Nitro MetaMask Connector",
@@ -56,12 +56,14 @@ class HybridMetamaskConnector : HybridMetamaskConnectorSpec() {
56
56
  ?: throw IllegalStateException("MetaMask SDK returned no chainId after connection")
57
57
 
58
58
  // Parse chainId from hex string (e.g., "0x1") or decimal string to number
59
+ // Nitro requires chainId to be Double (number in TS maps to Double in Kotlin)
59
60
  val chainId = try {
60
- if (chainIdString.startsWith("0x") || chainIdString.startsWith("0X")) {
61
+ val chainIdInt = if (chainIdString.startsWith("0x") || chainIdString.startsWith("0X")) {
61
62
  chainIdString.substring(2).toLong(16).toInt()
62
63
  } else {
63
64
  chainIdString.toLong().toInt()
64
65
  }
66
+ chainIdInt.toDouble()
65
67
  } catch (e: NumberFormatException) {
66
68
  throw IllegalStateException("Invalid chainId format: $chainIdString")
67
69
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@novastera-oss/nitro-metamask",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "description": "nitro-metamask",
5
5
  "main": "lib/index",
6
6
  "module": "lib/index",