@novastera-oss/nitro-metamask 0.2.6 → 0.3.2

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.
Files changed (55) hide show
  1. package/LICENSE +21 -201
  2. package/NitroMetamask.podspec +1 -1
  3. package/README.md +16 -249
  4. package/android/CMakeLists.txt +3 -0
  5. package/android/build.gradle +25 -19
  6. package/android/fix-prefab.gradle +1 -1
  7. package/android/gradle.properties +2 -2
  8. package/android/src/main/java/com/{margelo/nitro/nitrometamask/HybridMetamaskConnector.kt → nitrometamask/HybridNitroMetamask.kt} +43 -24
  9. package/android/src/main/java/com/nitrometamask/MetamaskContextHolder.kt +15 -0
  10. package/android/src/main/java/com/nitrometamask/NitroMetamaskPackage.kt +53 -0
  11. package/ios/Bridge.h +2 -2
  12. package/ios/{HybridMetamaskConnector.swift → HybridNitroMetamask.swift} +1 -2
  13. package/lib/commonjs/index.js +20 -0
  14. package/lib/commonjs/index.js.map +1 -0
  15. package/lib/commonjs/package.json +1 -0
  16. package/lib/commonjs/specs/nitro-metamask.nitro.js +6 -0
  17. package/lib/commonjs/specs/nitro-metamask.nitro.js.map +1 -0
  18. package/lib/module/index.js +16 -0
  19. package/lib/module/index.js.map +1 -0
  20. package/lib/module/specs/nitro-metamask.nitro.js +4 -0
  21. package/lib/module/specs/nitro-metamask.nitro.js.map +1 -0
  22. package/lib/typescript/src/index.d.ts +15 -0
  23. package/lib/typescript/src/index.d.ts.map +1 -0
  24. package/lib/{MetamaskConnector.nitro.d.ts → typescript/src/specs/nitro-metamask.nitro.d.ts} +3 -2
  25. package/lib/typescript/src/specs/nitro-metamask.nitro.d.ts.map +1 -0
  26. package/nitro.json +4 -4
  27. package/nitrogen/generated/android/NitroMetamask+autolinking.cmake +2 -2
  28. package/nitrogen/generated/android/NitroMetamaskOnLoad.cpp +4 -4
  29. package/nitrogen/generated/android/c++/{JHybridMetamaskConnectorSpec.cpp → JHybridNitroMetamaskSpec.cpp} +10 -10
  30. package/nitrogen/generated/android/c++/{JHybridMetamaskConnectorSpec.hpp → JHybridNitroMetamaskSpec.hpp} +10 -10
  31. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrometamask/{HybridMetamaskConnectorSpec.kt → HybridNitroMetamaskSpec.kt} +6 -6
  32. package/nitrogen/generated/ios/NitroMetamask-Swift-Cxx-Bridge.cpp +9 -9
  33. package/nitrogen/generated/ios/NitroMetamask-Swift-Cxx-Bridge.hpp +13 -13
  34. package/nitrogen/generated/ios/NitroMetamask-Swift-Cxx-Umbrella.hpp +5 -5
  35. package/nitrogen/generated/ios/NitroMetamaskAutolinking.mm +3 -3
  36. package/nitrogen/generated/ios/NitroMetamaskAutolinking.swift +6 -6
  37. package/nitrogen/generated/ios/c++/{HybridMetamaskConnectorSpecSwift.cpp → HybridNitroMetamaskSpecSwift.cpp} +2 -2
  38. package/nitrogen/generated/ios/c++/{HybridMetamaskConnectorSpecSwift.hpp → HybridNitroMetamaskSpecSwift.hpp} +12 -12
  39. package/nitrogen/generated/ios/swift/HybridNitroMetamaskSpec.swift +57 -0
  40. package/nitrogen/generated/ios/swift/{HybridMetamaskConnectorSpec_cxx.swift → HybridNitroMetamaskSpec_cxx.swift} +18 -18
  41. package/nitrogen/generated/shared/c++/{HybridMetamaskConnectorSpec.cpp → HybridNitroMetamaskSpec.cpp} +5 -5
  42. package/nitrogen/generated/shared/c++/{HybridMetamaskConnectorSpec.hpp → HybridNitroMetamaskSpec.hpp} +9 -9
  43. package/package.json +55 -39
  44. package/react-native.config.js +4 -1
  45. package/src/index.ts +14 -5
  46. package/src/specs/nitro-metamask.nitro.ts +11 -0
  47. package/android/src/main/java/com/margelo/nitro/nitrometamask/NitroMetamaskPackage.kt +0 -21
  48. package/lib/MetamaskConnector.nitro.js +0 -1
  49. package/lib/index.d.ts +0 -3
  50. package/lib/index.js +0 -2
  51. package/lib/specs/Example.nitro.d.ts +0 -0
  52. package/lib/specs/Example.nitro.js +0 -2
  53. package/nitrogen/generated/ios/swift/HybridMetamaskConnectorSpec.swift +0 -57
  54. package/src/MetamaskConnector.nitro.ts +0 -13
  55. package/src/specs/Example.nitro.ts +0 -1
@@ -10,12 +10,12 @@
10
10
  // Forward declarations of C++ defined types
11
11
  // Forward declaration of `ConnectResult` to properly resolve imports.
12
12
  namespace margelo::nitro::nitrometamask { struct ConnectResult; }
13
- // Forward declaration of `HybridMetamaskConnectorSpec` to properly resolve imports.
14
- namespace margelo::nitro::nitrometamask { class HybridMetamaskConnectorSpec; }
13
+ // Forward declaration of `HybridNitroMetamaskSpec` to properly resolve imports.
14
+ namespace margelo::nitro::nitrometamask { class HybridNitroMetamaskSpec; }
15
15
 
16
16
  // Include C++ defined types
17
17
  #include "ConnectResult.hpp"
18
- #include "HybridMetamaskConnectorSpec.hpp"
18
+ #include "HybridNitroMetamaskSpec.hpp"
19
19
  #include <NitroModules/Promise.hpp>
20
20
  #include <NitroModules/Result.hpp>
21
21
  #include <exception>
@@ -32,8 +32,8 @@ namespace margelo::nitro::nitrometamask { class HybridMetamaskConnectorSpec; }
32
32
  #include <NitroModules/DateToChronoDate.hpp>
33
33
 
34
34
  // Forward declarations of Swift defined types
35
- // Forward declaration of `HybridMetamaskConnectorSpec_cxx` to properly resolve imports.
36
- namespace NitroMetamask { class HybridMetamaskConnectorSpec_cxx; }
35
+ // Forward declaration of `HybridNitroMetamaskSpec_cxx` to properly resolve imports.
36
+ namespace NitroMetamask { class HybridNitroMetamaskSpec_cxx; }
37
37
 
38
38
  // Include Swift defined types
39
39
  #if __has_include("NitroMetamask-Swift.h")
@@ -10,7 +10,7 @@
10
10
  #import "NitroMetamask-Swift-Cxx-Umbrella.hpp"
11
11
  #import <type_traits>
12
12
 
13
- #include "HybridMetamaskConnectorSpecSwift.hpp"
13
+ #include "HybridNitroMetamaskSpecSwift.hpp"
14
14
 
15
15
  @interface NitroMetamaskAutolinking : NSObject
16
16
  @end
@@ -22,9 +22,9 @@
22
22
  using namespace margelo::nitro::nitrometamask;
23
23
 
24
24
  HybridObjectRegistry::registerHybridObjectConstructor(
25
- "MetamaskConnector",
25
+ "NitroMetamask",
26
26
  []() -> std::shared_ptr<HybridObject> {
27
- std::shared_ptr<HybridMetamaskConnectorSpec> hybridObject = NitroMetamask::NitroMetamaskAutolinking::createMetamaskConnector();
27
+ std::shared_ptr<HybridNitroMetamaskSpec> hybridObject = NitroMetamask::NitroMetamaskAutolinking::createNitroMetamask();
28
28
  return hybridObject;
29
29
  }
30
30
  );
@@ -9,15 +9,15 @@ public final class NitroMetamaskAutolinking {
9
9
  public typealias bridge = margelo.nitro.nitrometamask.bridge.swift
10
10
 
11
11
  /**
12
- * Creates an instance of a Swift class that implements `HybridMetamaskConnectorSpec`,
13
- * and wraps it in a Swift class that can directly interop with C++ (`HybridMetamaskConnectorSpec_cxx`)
12
+ * Creates an instance of a Swift class that implements `HybridNitroMetamaskSpec`,
13
+ * and wraps it in a Swift class that can directly interop with C++ (`HybridNitroMetamaskSpec_cxx`)
14
14
  *
15
15
  * This is generated by Nitrogen and will initialize the class specified
16
- * in the `"autolinking"` property of `nitro.json` (in this case, `HybridMetamaskConnector`).
16
+ * in the `"autolinking"` property of `nitro.json` (in this case, `HybridNitroMetamask`).
17
17
  */
18
- public static func createMetamaskConnector() -> bridge.std__shared_ptr_HybridMetamaskConnectorSpec_ {
19
- let hybridObject = HybridMetamaskConnector()
20
- return { () -> bridge.std__shared_ptr_HybridMetamaskConnectorSpec_ in
18
+ public static func createNitroMetamask() -> bridge.std__shared_ptr_HybridNitroMetamaskSpec_ {
19
+ let hybridObject = HybridNitroMetamask()
20
+ return { () -> bridge.std__shared_ptr_HybridNitroMetamaskSpec_ in
21
21
  let __cxxWrapped = hybridObject.getCxxWrapper()
22
22
  return __cxxWrapped.getCxxPart()
23
23
  }()
@@ -1,11 +1,11 @@
1
1
  ///
2
- /// HybridMetamaskConnectorSpecSwift.cpp
2
+ /// HybridNitroMetamaskSpecSwift.cpp
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
4
  /// https://github.com/mrousavy/nitro
5
5
  /// Copyright © 2026 Marc Rousavy @ Margelo
6
6
  ///
7
7
 
8
- #include "HybridMetamaskConnectorSpecSwift.hpp"
8
+ #include "HybridNitroMetamaskSpecSwift.hpp"
9
9
 
10
10
  namespace margelo::nitro::nitrometamask {
11
11
  } // namespace margelo::nitro::nitrometamask
@@ -1,5 +1,5 @@
1
1
  ///
2
- /// HybridMetamaskConnectorSpecSwift.hpp
2
+ /// HybridNitroMetamaskSpecSwift.hpp
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
4
  /// https://github.com/mrousavy/nitro
5
5
  /// Copyright © 2026 Marc Rousavy @ Margelo
@@ -7,10 +7,10 @@
7
7
 
8
8
  #pragma once
9
9
 
10
- #include "HybridMetamaskConnectorSpec.hpp"
10
+ #include "HybridNitroMetamaskSpec.hpp"
11
11
 
12
- // Forward declaration of `HybridMetamaskConnectorSpec_cxx` to properly resolve imports.
13
- namespace NitroMetamask { class HybridMetamaskConnectorSpec_cxx; }
12
+ // Forward declaration of `HybridNitroMetamaskSpec_cxx` to properly resolve imports.
13
+ namespace NitroMetamask { class HybridNitroMetamaskSpec_cxx; }
14
14
 
15
15
  // Forward declaration of `ConnectResult` to properly resolve imports.
16
16
  namespace margelo::nitro::nitrometamask { struct ConnectResult; }
@@ -24,25 +24,25 @@ namespace margelo::nitro::nitrometamask { struct ConnectResult; }
24
24
  namespace margelo::nitro::nitrometamask {
25
25
 
26
26
  /**
27
- * The C++ part of HybridMetamaskConnectorSpec_cxx.swift.
27
+ * The C++ part of HybridNitroMetamaskSpec_cxx.swift.
28
28
  *
29
- * HybridMetamaskConnectorSpecSwift (C++) accesses HybridMetamaskConnectorSpec_cxx (Swift), and might
29
+ * HybridNitroMetamaskSpecSwift (C++) accesses HybridNitroMetamaskSpec_cxx (Swift), and might
30
30
  * contain some additional bridging code for C++ <> Swift interop.
31
31
  *
32
32
  * Since this obviously introduces an overhead, I hope at some point in
33
- * the future, HybridMetamaskConnectorSpec_cxx can directly inherit from the C++ class HybridMetamaskConnectorSpec
33
+ * the future, HybridNitroMetamaskSpec_cxx can directly inherit from the C++ class HybridNitroMetamaskSpec
34
34
  * to simplify the whole structure and memory management.
35
35
  */
36
- class HybridMetamaskConnectorSpecSwift: public virtual HybridMetamaskConnectorSpec {
36
+ class HybridNitroMetamaskSpecSwift: public virtual HybridNitroMetamaskSpec {
37
37
  public:
38
38
  // Constructor from a Swift instance
39
- explicit HybridMetamaskConnectorSpecSwift(const NitroMetamask::HybridMetamaskConnectorSpec_cxx& swiftPart):
40
- HybridObject(HybridMetamaskConnectorSpec::TAG),
39
+ explicit HybridNitroMetamaskSpecSwift(const NitroMetamask::HybridNitroMetamaskSpec_cxx& swiftPart):
40
+ HybridObject(HybridNitroMetamaskSpec::TAG),
41
41
  _swiftPart(swiftPart) { }
42
42
 
43
43
  public:
44
44
  // Get the Swift part
45
- inline NitroMetamask::HybridMetamaskConnectorSpec_cxx& getSwiftPart() noexcept {
45
+ inline NitroMetamask::HybridNitroMetamaskSpec_cxx& getSwiftPart() noexcept {
46
46
  return _swiftPart;
47
47
  }
48
48
 
@@ -81,7 +81,7 @@ namespace margelo::nitro::nitrometamask {
81
81
  }
82
82
 
83
83
  private:
84
- NitroMetamask::HybridMetamaskConnectorSpec_cxx _swiftPart;
84
+ NitroMetamask::HybridNitroMetamaskSpec_cxx _swiftPart;
85
85
  };
86
86
 
87
87
  } // namespace margelo::nitro::nitrometamask
@@ -0,0 +1,57 @@
1
+ ///
2
+ /// HybridNitroMetamaskSpec.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2026 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ import Foundation
9
+ import NitroModules
10
+
11
+ /// See ``HybridNitroMetamaskSpec``
12
+ public protocol HybridNitroMetamaskSpec_protocol: HybridObject {
13
+ // Properties
14
+
15
+
16
+ // Methods
17
+ func connect() throws -> Promise<ConnectResult>
18
+ func signMessage(message: String) throws -> Promise<String>
19
+ }
20
+
21
+ public extension HybridNitroMetamaskSpec_protocol {
22
+ /// Default implementation of ``HybridObject.toString``
23
+ func toString() -> String {
24
+ return "[HybridObject NitroMetamask]"
25
+ }
26
+ }
27
+
28
+ /// See ``HybridNitroMetamaskSpec``
29
+ open class HybridNitroMetamaskSpec_base {
30
+ private weak var cxxWrapper: HybridNitroMetamaskSpec_cxx? = nil
31
+ public init() { }
32
+ public func getCxxWrapper() -> HybridNitroMetamaskSpec_cxx {
33
+ #if DEBUG
34
+ guard self is HybridNitroMetamaskSpec else {
35
+ fatalError("`self` is not a `HybridNitroMetamaskSpec`! Did you accidentally inherit from `HybridNitroMetamaskSpec_base` instead of `HybridNitroMetamaskSpec`?")
36
+ }
37
+ #endif
38
+ if let cxxWrapper = self.cxxWrapper {
39
+ return cxxWrapper
40
+ } else {
41
+ let cxxWrapper = HybridNitroMetamaskSpec_cxx(self as! HybridNitroMetamaskSpec)
42
+ self.cxxWrapper = cxxWrapper
43
+ return cxxWrapper
44
+ }
45
+ }
46
+ }
47
+
48
+ /**
49
+ * A Swift base-protocol representing the NitroMetamask HybridObject.
50
+ * Implement this protocol to create Swift-based instances of NitroMetamask.
51
+ * ```swift
52
+ * class HybridNitroMetamask : HybridNitroMetamaskSpec {
53
+ * // ...
54
+ * }
55
+ * ```
56
+ */
57
+ public typealias HybridNitroMetamaskSpec = HybridNitroMetamaskSpec_protocol & HybridNitroMetamaskSpec_base
@@ -1,5 +1,5 @@
1
1
  ///
2
- /// HybridMetamaskConnectorSpec_cxx.swift
2
+ /// HybridNitroMetamaskSpec_cxx.swift
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
4
  /// https://github.com/mrousavy/nitro
5
5
  /// Copyright © 2026 Marc Rousavy @ Margelo
@@ -9,7 +9,7 @@ import Foundation
9
9
  import NitroModules
10
10
 
11
11
  /**
12
- * A class implementation that bridges HybridMetamaskConnectorSpec over to C++.
12
+ * A class implementation that bridges HybridNitroMetamaskSpec over to C++.
13
13
  * In C++, we cannot use Swift protocols - so we need to wrap it in a class to make it strongly defined.
14
14
  *
15
15
  * Also, some Swift types need to be bridged with special handling:
@@ -17,7 +17,7 @@ import NitroModules
17
17
  * - Other HybridObjects need to be wrapped/unwrapped from the Swift TCxx wrapper
18
18
  * - Throwing methods need to be wrapped with a Result<T, Error> type, as exceptions cannot be propagated to C++
19
19
  */
20
- open class HybridMetamaskConnectorSpec_cxx {
20
+ open class HybridNitroMetamaskSpec_cxx {
21
21
  /**
22
22
  * The Swift <> C++ bridge's namespace (`margelo::nitro::nitrometamask::bridge::swift`)
23
23
  * from `NitroMetamask-Swift-Cxx-Bridge.hpp`.
@@ -26,30 +26,30 @@ open class HybridMetamaskConnectorSpec_cxx {
26
26
  public typealias bridge = margelo.nitro.nitrometamask.bridge.swift
27
27
 
28
28
  /**
29
- * Holds an instance of the `HybridMetamaskConnectorSpec` Swift protocol.
29
+ * Holds an instance of the `HybridNitroMetamaskSpec` Swift protocol.
30
30
  */
31
- private var __implementation: any HybridMetamaskConnectorSpec
31
+ private var __implementation: any HybridNitroMetamaskSpec
32
32
 
33
33
  /**
34
34
  * Holds a weak pointer to the C++ class that wraps the Swift class.
35
35
  */
36
- private var __cxxPart: bridge.std__weak_ptr_HybridMetamaskConnectorSpec_
36
+ private var __cxxPart: bridge.std__weak_ptr_HybridNitroMetamaskSpec_
37
37
 
38
38
  /**
39
- * Create a new `HybridMetamaskConnectorSpec_cxx` that wraps the given `HybridMetamaskConnectorSpec`.
39
+ * Create a new `HybridNitroMetamaskSpec_cxx` that wraps the given `HybridNitroMetamaskSpec`.
40
40
  * All properties and methods bridge to C++ types.
41
41
  */
42
- public init(_ implementation: any HybridMetamaskConnectorSpec) {
42
+ public init(_ implementation: any HybridNitroMetamaskSpec) {
43
43
  self.__implementation = implementation
44
44
  self.__cxxPart = .init()
45
45
  /* no base class */
46
46
  }
47
47
 
48
48
  /**
49
- * Get the actual `HybridMetamaskConnectorSpec` instance this class wraps.
49
+ * Get the actual `HybridNitroMetamaskSpec` instance this class wraps.
50
50
  */
51
51
  @inline(__always)
52
- public func getHybridMetamaskConnectorSpec() -> any HybridMetamaskConnectorSpec {
52
+ public func getHybridNitroMetamaskSpec() -> any HybridNitroMetamaskSpec {
53
53
  return __implementation
54
54
  }
55
55
 
@@ -62,25 +62,25 @@ open class HybridMetamaskConnectorSpec_cxx {
62
62
  }
63
63
 
64
64
  /**
65
- * Casts an unsafe pointer to a `HybridMetamaskConnectorSpec_cxx`.
66
- * The pointer has to be a retained opaque `Unmanaged<HybridMetamaskConnectorSpec_cxx>`.
65
+ * Casts an unsafe pointer to a `HybridNitroMetamaskSpec_cxx`.
66
+ * The pointer has to be a retained opaque `Unmanaged<HybridNitroMetamaskSpec_cxx>`.
67
67
  * This removes one strong reference from the object!
68
68
  */
69
- public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridMetamaskConnectorSpec_cxx {
70
- return Unmanaged<HybridMetamaskConnectorSpec_cxx>.fromOpaque(pointer).takeRetainedValue()
69
+ public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridNitroMetamaskSpec_cxx {
70
+ return Unmanaged<HybridNitroMetamaskSpec_cxx>.fromOpaque(pointer).takeRetainedValue()
71
71
  }
72
72
 
73
73
  /**
74
74
  * Gets (or creates) the C++ part of this Hybrid Object.
75
- * The C++ part is a `std::shared_ptr<HybridMetamaskConnectorSpec>`.
75
+ * The C++ part is a `std::shared_ptr<HybridNitroMetamaskSpec>`.
76
76
  */
77
- public func getCxxPart() -> bridge.std__shared_ptr_HybridMetamaskConnectorSpec_ {
77
+ public func getCxxPart() -> bridge.std__shared_ptr_HybridNitroMetamaskSpec_ {
78
78
  let cachedCxxPart = self.__cxxPart.lock()
79
79
  if Bool(fromCxx: cachedCxxPart) {
80
80
  return cachedCxxPart
81
81
  } else {
82
- let newCxxPart = bridge.create_std__shared_ptr_HybridMetamaskConnectorSpec_(self.toUnsafe())
83
- __cxxPart = bridge.weakify_std__shared_ptr_HybridMetamaskConnectorSpec_(newCxxPart)
82
+ let newCxxPart = bridge.create_std__shared_ptr_HybridNitroMetamaskSpec_(self.toUnsafe())
83
+ __cxxPart = bridge.weakify_std__shared_ptr_HybridNitroMetamaskSpec_(newCxxPart)
84
84
  return newCxxPart
85
85
  }
86
86
  }
@@ -1,21 +1,21 @@
1
1
  ///
2
- /// HybridMetamaskConnectorSpec.cpp
2
+ /// HybridNitroMetamaskSpec.cpp
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
4
  /// https://github.com/mrousavy/nitro
5
5
  /// Copyright © 2026 Marc Rousavy @ Margelo
6
6
  ///
7
7
 
8
- #include "HybridMetamaskConnectorSpec.hpp"
8
+ #include "HybridNitroMetamaskSpec.hpp"
9
9
 
10
10
  namespace margelo::nitro::nitrometamask {
11
11
 
12
- void HybridMetamaskConnectorSpec::loadHybridMethods() {
12
+ void HybridNitroMetamaskSpec::loadHybridMethods() {
13
13
  // load base methods/properties
14
14
  HybridObject::loadHybridMethods();
15
15
  // load custom methods/properties
16
16
  registerHybrids(this, [](Prototype& prototype) {
17
- prototype.registerHybridMethod("connect", &HybridMetamaskConnectorSpec::connect);
18
- prototype.registerHybridMethod("signMessage", &HybridMetamaskConnectorSpec::signMessage);
17
+ prototype.registerHybridMethod("connect", &HybridNitroMetamaskSpec::connect);
18
+ prototype.registerHybridMethod("signMessage", &HybridNitroMetamaskSpec::signMessage);
19
19
  });
20
20
  }
21
21
 
@@ -1,5 +1,5 @@
1
1
  ///
2
- /// HybridMetamaskConnectorSpec.hpp
2
+ /// HybridNitroMetamaskSpec.hpp
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
4
  /// https://github.com/mrousavy/nitro
5
5
  /// Copyright © 2026 Marc Rousavy @ Margelo
@@ -25,25 +25,25 @@ namespace margelo::nitro::nitrometamask {
25
25
  using namespace margelo::nitro;
26
26
 
27
27
  /**
28
- * An abstract base class for `MetamaskConnector`
29
- * Inherit this class to create instances of `HybridMetamaskConnectorSpec` in C++.
28
+ * An abstract base class for `NitroMetamask`
29
+ * Inherit this class to create instances of `HybridNitroMetamaskSpec` in C++.
30
30
  * You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
31
31
  * @example
32
32
  * ```cpp
33
- * class HybridMetamaskConnector: public HybridMetamaskConnectorSpec {
33
+ * class HybridNitroMetamask: public HybridNitroMetamaskSpec {
34
34
  * public:
35
- * HybridMetamaskConnector(...): HybridObject(TAG) { ... }
35
+ * HybridNitroMetamask(...): HybridObject(TAG) { ... }
36
36
  * // ...
37
37
  * };
38
38
  * ```
39
39
  */
40
- class HybridMetamaskConnectorSpec: public virtual HybridObject {
40
+ class HybridNitroMetamaskSpec: public virtual HybridObject {
41
41
  public:
42
42
  // Constructor
43
- explicit HybridMetamaskConnectorSpec(): HybridObject(TAG) { }
43
+ explicit HybridNitroMetamaskSpec(): HybridObject(TAG) { }
44
44
 
45
45
  // Destructor
46
- ~HybridMetamaskConnectorSpec() override = default;
46
+ ~HybridNitroMetamaskSpec() override = default;
47
47
 
48
48
  public:
49
49
  // Properties
@@ -60,7 +60,7 @@ namespace margelo::nitro::nitrometamask {
60
60
 
61
61
  protected:
62
62
  // Tag for logging
63
- static constexpr auto TAG = "MetamaskConnector";
63
+ static constexpr auto TAG = "NitroMetamask";
64
64
  };
65
65
 
66
66
  } // namespace margelo::nitro::nitrometamask
package/package.json CHANGED
@@ -1,20 +1,35 @@
1
1
  {
2
2
  "name": "@novastera-oss/nitro-metamask",
3
- "version": "0.2.6",
4
- "description": "nitro-metamask",
5
- "main": "lib/index",
6
- "module": "lib/index",
7
- "types": "lib/index.d.ts",
3
+ "version": "0.3.2",
4
+ "description": "Novastera metamask authentication with native mobile libraries",
5
+ "main": "./lib/commonjs/index.js",
6
+ "module": "./lib/module/index.js",
7
+ "types": "./lib/typescript/src/index.d.ts",
8
8
  "react-native": "src/index",
9
9
  "source": "src/index",
10
+ "scripts": {
11
+ "typecheck": "tsc --noEmit",
12
+ "clean": "git clean -dfX",
13
+ "release": "semantic-release",
14
+ "build": "npm run typecheck && bob build",
15
+ "codegen": "nitrogen --logLevel=\"debug\" && npm run build && node post-script.js"
16
+ },
17
+ "keywords": [
18
+ "react-native",
19
+ "@novastera-oss/nitro-metamask",
20
+ "metamask",
21
+ "novastera"
22
+ ],
10
23
  "files": [
11
24
  "src",
12
25
  "react-native.config.js",
13
26
  "lib",
14
27
  "nitrogen",
28
+ "cpp",
29
+ "nitro.json",
15
30
  "android/build.gradle",
16
- "android/gradle.properties",
17
31
  "android/fix-prefab.gradle",
32
+ "android/gradle.properties",
18
33
  "android/CMakeLists.txt",
19
34
  "android/src",
20
35
  "ios/**/*.h",
@@ -23,53 +38,40 @@
23
38
  "ios/**/*.cpp",
24
39
  "ios/**/*.swift",
25
40
  "app.plugin.js",
26
- "nitro.json",
27
41
  "*.podspec",
28
42
  "README.md"
29
43
  ],
30
- "scripts": {
31
- "postinstall": "tsc || exit 0;",
32
- "typecheck": "tsc --noEmit",
33
- "clean": "rm -rf android/build node_modules/**/android/build lib",
34
- "lint": "eslint \"**/*.{js,ts,tsx}\" --fix",
35
- "lint-ci": "eslint \"**/*.{js,ts,tsx}\" -f @jamesacarr/github-actions",
36
- "typescript": "tsc",
37
- "specs": "tsc --noEmit false && nitrogen --logLevel=\"debug\""
38
- },
39
- "keywords": [
40
- "react-native",
41
- "nitro"
44
+ "workspaces": [
45
+ "example"
42
46
  ],
43
- "repository": {
44
- "type": "git",
45
- "url": "https://github.com/novastera/nitro-metamask"
46
- },
47
- "author": "Novastera <hassan@novastera.com>",
47
+ "repository": "https://github.com/darksorrow/@novastera-oss/nitro-metamask.git",
48
+ "author": "DarkSorrow",
48
49
  "license": "MIT",
49
- "bugs": {
50
- "url": "https://github.com/novastera/nitro-metamask/issues"
51
- },
52
- "homepage": "https://novastera.com",
50
+ "bugs": "https://github.com/darksorrow/@novastera-oss/nitro-metamask/issues",
51
+ "homepage": "https://github.com/darksorrow/@novastera-oss/nitro-metamask#readme",
53
52
  "publishConfig": {
53
+ "access": "public",
54
54
  "registry": "https://registry.npmjs.org/"
55
55
  },
56
56
  "devDependencies": {
57
- "@react-native/eslint-config": "0.82.0",
58
- "@types/react": "^19.1.03",
59
- "eslint": "^9.39.0",
60
- "eslint-config-prettier": "^10.1.0",
61
- "eslint-plugin-prettier": "^5.2.1",
62
- "nitrogen": "^0.32.0",
63
- "prettier": "^3.3.3",
64
- "react": "19.1.1",
65
- "react-native": "0.82.0",
66
- "react-native-nitro-modules": "^0.32.0",
57
+ "@jamesacarr/eslint-formatter-github-actions": "^0.2.0",
58
+ "@semantic-release/changelog": "^6.0.3",
59
+ "@semantic-release/git": "^10.0.1",
60
+ "@types/jest": "^29.5.12",
61
+ "@types/react": "19.2.0",
62
+ "nitrogen": "0.32.0",
63
+ "react": "19.2.0",
64
+ "react-native": "0.83",
65
+ "react-native-builder-bob": "^0.40.17",
66
+ "react-native-nitro-modules": "0.32.0",
67
+ "conventional-changelog-conventionalcommits": "^9.1.0",
68
+ "semantic-release": "^25.0.2",
67
69
  "typescript": "^5.8.3"
68
70
  },
69
71
  "peerDependencies": {
70
72
  "react": "*",
71
73
  "react-native": "*",
72
- "react-native-nitro-modules": "^0.32.0"
74
+ "react-native-nitro-modules": "*"
73
75
  },
74
76
  "eslintConfig": {
75
77
  "root": true,
@@ -104,5 +106,19 @@
104
106
  "trailingComma": "es5",
105
107
  "useTabs": false,
106
108
  "semi": false
109
+ },
110
+ "react-native-builder-bob": {
111
+ "source": "src",
112
+ "output": "lib",
113
+ "targets": [
114
+ "commonjs",
115
+ "module",
116
+ [
117
+ "typescript",
118
+ {
119
+ "project": "tsconfig.json"
120
+ }
121
+ ]
122
+ ]
107
123
  }
108
124
  }
@@ -10,7 +10,10 @@ module.exports = {
10
10
  /**
11
11
  * @type {import('@react-native-community/cli-types').AndroidDependencyParams}
12
12
  */
13
- android: {},
13
+ android: {
14
+ packageImportPath: 'import com.nitrometamask.NitroMetamaskPackage;',
15
+ packageInstance: 'new NitroMetamaskPackage()',
16
+ },
14
17
  },
15
18
  },
16
19
  }
package/src/index.ts CHANGED
@@ -1,8 +1,17 @@
1
1
  import { NitroModules } from 'react-native-nitro-modules'
2
+ import type { NitroMetamask as NitroMetamaskSpec, ConnectResult } from './specs/nitro-metamask.nitro'
2
3
 
3
- import type { ConnectResult, MetamaskConnector } from './MetamaskConnector.nitro'
4
+ /**
5
+ * NitroMetamask - MetaMask connector for React Native
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * import { NitroMetamask } from '@novastera-oss/nitro-metamask'
10
+ *
11
+ * const result = await NitroMetamask.connect()
12
+ * const signature = await NitroMetamask.signMessage('Hello')
13
+ * ```
14
+ */
15
+ export const NitroMetamask = NitroModules.createHybridObject<NitroMetamaskSpec>('NitroMetamask')
4
16
 
5
- export const metamaskConnector =
6
- NitroModules.createHybridObject<MetamaskConnector>('MetamaskConnector')
7
-
8
- export type { ConnectResult, MetamaskConnector }
17
+ export type { ConnectResult, NitroMetamaskSpec }
@@ -0,0 +1,11 @@
1
+ import { type HybridObject } from 'react-native-nitro-modules'
2
+
3
+ export interface ConnectResult {
4
+ address: string
5
+ chainId: number
6
+ }
7
+
8
+ export interface NitroMetamask extends HybridObject<{ ios: 'swift', android: 'kotlin' }> {
9
+ connect(): Promise<ConnectResult>
10
+ signMessage(message: string): Promise<string>
11
+ }
@@ -1,21 +0,0 @@
1
- package com.margelo.nitro.nitrometamask
2
-
3
- import com.facebook.react.bridge.NativeModule
4
- import com.facebook.react.bridge.ReactApplicationContext
5
- import com.facebook.react.module.model.ReactModuleInfoProvider
6
- import com.facebook.react.BaseReactPackage
7
-
8
- class NitroMetamaskPackage : BaseReactPackage() {
9
- override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
10
- // No need to store ReactApplicationContext - HybridMetamaskConnector uses NitroRuntime
11
- return null
12
- }
13
-
14
- override fun getReactModuleInfoProvider(): ReactModuleInfoProvider = ReactModuleInfoProvider { HashMap() }
15
-
16
- companion object {
17
- init {
18
- NitroMetamaskOnLoad.initializeNative()
19
- }
20
- }
21
- }
@@ -1 +0,0 @@
1
- export {};
package/lib/index.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import type { ConnectResult, MetamaskConnector } from './MetamaskConnector.nitro';
2
- export declare const metamaskConnector: MetamaskConnector;
3
- export type { ConnectResult, MetamaskConnector };
package/lib/index.js DELETED
@@ -1,2 +0,0 @@
1
- import { NitroModules } from 'react-native-nitro-modules';
2
- export const metamaskConnector = NitroModules.createHybridObject('MetamaskConnector');
File without changes
@@ -1,2 +0,0 @@
1
- "use strict";
2
- // TODO: Export specs that extend HybridObject<...> here