@novastera-oss/nitro-metamask 0.2.7 → 0.3.3

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 (58) hide show
  1. package/LICENSE +21 -201
  2. package/NitroMetamask.podspec +1 -1
  3. package/README.md +75 -228
  4. package/android/CMakeLists.txt +3 -0
  5. package/android/build.gradle +24 -18
  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/HybridNitroMetamask.kt +409 -0
  9. package/android/src/main/java/com/margelo/nitro/nitrometamask/MetamaskContextHolder.kt +4 -25
  10. package/android/src/main/java/com/margelo/nitro/nitrometamask/NitroMetamaskPackage.kt +36 -7
  11. package/ios/Bridge.h +2 -2
  12. package/ios/HybridNitroMetamask.swift +241 -0
  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/typescript/src/specs/nitro-metamask.nitro.d.ts +23 -0
  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} +31 -10
  30. package/nitrogen/generated/android/c++/{JHybridMetamaskConnectorSpec.hpp → JHybridNitroMetamaskSpec.hpp} +12 -10
  31. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrometamask/{HybridMetamaskConnectorSpec.kt → HybridNitroMetamaskSpec.kt} +14 -6
  32. package/nitrogen/generated/ios/NitroMetamask-Swift-Cxx-Bridge.cpp +9 -9
  33. package/nitrogen/generated/ios/NitroMetamask-Swift-Cxx-Bridge.hpp +38 -13
  34. package/nitrogen/generated/ios/NitroMetamask-Swift-Cxx-Umbrella.hpp +6 -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} +28 -13
  39. package/nitrogen/generated/ios/swift/HybridNitroMetamaskSpec.swift +59 -0
  40. package/nitrogen/generated/ios/swift/{HybridMetamaskConnectorSpec_cxx.swift → HybridNitroMetamaskSpec_cxx.swift} +55 -18
  41. package/nitrogen/generated/shared/c++/HybridNitroMetamaskSpec.cpp +24 -0
  42. package/nitrogen/generated/shared/c++/{HybridMetamaskConnectorSpec.hpp → HybridNitroMetamaskSpec.hpp} +13 -10
  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 +21 -0
  47. package/android/src/main/java/com/margelo/nitro/nitrometamask/HybridMetamaskConnector.kt +0 -126
  48. package/ios/HybridMetamaskConnector.swift +0 -97
  49. package/lib/MetamaskConnector.nitro.d.ts +0 -12
  50. package/lib/MetamaskConnector.nitro.js +0 -1
  51. package/lib/index.d.ts +0 -3
  52. package/lib/index.js +0 -2
  53. package/lib/specs/Example.nitro.d.ts +0 -0
  54. package/lib/specs/Example.nitro.js +0 -2
  55. package/nitrogen/generated/ios/swift/HybridMetamaskConnectorSpec.swift +0 -57
  56. package/nitrogen/generated/shared/c++/HybridMetamaskConnectorSpec.cpp +0 -22
  57. package/src/MetamaskConnector.nitro.ts +0 -13
  58. package/src/specs/Example.nitro.ts +0 -1
@@ -8,7 +8,7 @@
8
8
  #include "NitroMetamask-Swift-Cxx-Bridge.hpp"
9
9
 
10
10
  // Include C++ implementation defined types
11
- #include "HybridMetamaskConnectorSpecSwift.hpp"
11
+ #include "HybridNitroMetamaskSpecSwift.hpp"
12
12
  #include "NitroMetamask-Swift-Cxx-Umbrella.hpp"
13
13
  #include <NitroModules/NitroDefines.hpp>
14
14
 
@@ -38,19 +38,19 @@ namespace margelo::nitro::nitrometamask::bridge::swift {
38
38
  };
39
39
  }
40
40
 
41
- // pragma MARK: std::shared_ptr<HybridMetamaskConnectorSpec>
42
- std::shared_ptr<HybridMetamaskConnectorSpec> create_std__shared_ptr_HybridMetamaskConnectorSpec_(void* NON_NULL swiftUnsafePointer) noexcept {
43
- NitroMetamask::HybridMetamaskConnectorSpec_cxx swiftPart = NitroMetamask::HybridMetamaskConnectorSpec_cxx::fromUnsafe(swiftUnsafePointer);
44
- return std::make_shared<margelo::nitro::nitrometamask::HybridMetamaskConnectorSpecSwift>(swiftPart);
41
+ // pragma MARK: std::shared_ptr<HybridNitroMetamaskSpec>
42
+ std::shared_ptr<HybridNitroMetamaskSpec> create_std__shared_ptr_HybridNitroMetamaskSpec_(void* NON_NULL swiftUnsafePointer) noexcept {
43
+ NitroMetamask::HybridNitroMetamaskSpec_cxx swiftPart = NitroMetamask::HybridNitroMetamaskSpec_cxx::fromUnsafe(swiftUnsafePointer);
44
+ return std::make_shared<margelo::nitro::nitrometamask::HybridNitroMetamaskSpecSwift>(swiftPart);
45
45
  }
46
- void* NON_NULL get_std__shared_ptr_HybridMetamaskConnectorSpec_(std__shared_ptr_HybridMetamaskConnectorSpec_ cppType) {
47
- std::shared_ptr<margelo::nitro::nitrometamask::HybridMetamaskConnectorSpecSwift> swiftWrapper = std::dynamic_pointer_cast<margelo::nitro::nitrometamask::HybridMetamaskConnectorSpecSwift>(cppType);
46
+ void* NON_NULL get_std__shared_ptr_HybridNitroMetamaskSpec_(std__shared_ptr_HybridNitroMetamaskSpec_ cppType) {
47
+ std::shared_ptr<margelo::nitro::nitrometamask::HybridNitroMetamaskSpecSwift> swiftWrapper = std::dynamic_pointer_cast<margelo::nitro::nitrometamask::HybridNitroMetamaskSpecSwift>(cppType);
48
48
  #ifdef NITRO_DEBUG
49
49
  if (swiftWrapper == nullptr) [[unlikely]] {
50
- throw std::runtime_error("Class \"HybridMetamaskConnectorSpec\" is not implemented in Swift!");
50
+ throw std::runtime_error("Class \"HybridNitroMetamaskSpec\" is not implemented in Swift!");
51
51
  }
52
52
  #endif
53
- NitroMetamask::HybridMetamaskConnectorSpec_cxx& swiftPart = swiftWrapper->getSwiftPart();
53
+ NitroMetamask::HybridNitroMetamaskSpec_cxx& swiftPart = swiftWrapper->getSwiftPart();
54
54
  return swiftPart.toUnsafe();
55
55
  }
56
56
 
@@ -10,22 +10,23 @@
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
  // Forward declarations of Swift defined types
17
- // Forward declaration of `HybridMetamaskConnectorSpec_cxx` to properly resolve imports.
18
- namespace NitroMetamask { class HybridMetamaskConnectorSpec_cxx; }
17
+ // Forward declaration of `HybridNitroMetamaskSpec_cxx` to properly resolve imports.
18
+ namespace NitroMetamask { class HybridNitroMetamaskSpec_cxx; }
19
19
 
20
20
  // Include C++ defined types
21
21
  #include "ConnectResult.hpp"
22
- #include "HybridMetamaskConnectorSpec.hpp"
22
+ #include "HybridNitroMetamaskSpec.hpp"
23
23
  #include <NitroModules/Promise.hpp>
24
24
  #include <NitroModules/PromiseHolder.hpp>
25
25
  #include <NitroModules/Result.hpp>
26
26
  #include <exception>
27
27
  #include <functional>
28
28
  #include <memory>
29
+ #include <optional>
29
30
  #include <string>
30
31
 
31
32
  /**
@@ -34,6 +35,21 @@ namespace NitroMetamask { class HybridMetamaskConnectorSpec_cxx; }
34
35
  */
35
36
  namespace margelo::nitro::nitrometamask::bridge::swift {
36
37
 
38
+ // pragma MARK: std::optional<std::string>
39
+ /**
40
+ * Specialized version of `std::optional<std::string>`.
41
+ */
42
+ using std__optional_std__string_ = std::optional<std::string>;
43
+ inline std::optional<std::string> create_std__optional_std__string_(const std::string& value) noexcept {
44
+ return std::optional<std::string>(value);
45
+ }
46
+ inline bool has_value_std__optional_std__string_(const std::optional<std::string>& optional) noexcept {
47
+ return optional.has_value();
48
+ }
49
+ inline std::string get_std__optional_std__string_(const std::optional<std::string>& optional) noexcept {
50
+ return *optional;
51
+ }
52
+
37
53
  // pragma MARK: std::shared_ptr<Promise<ConnectResult>>
38
54
  /**
39
55
  * Specialized version of `std::shared_ptr<Promise<ConnectResult>>`.
@@ -124,17 +140,26 @@ namespace margelo::nitro::nitrometamask::bridge::swift {
124
140
  return Func_void_std__string_Wrapper(std::move(value));
125
141
  }
126
142
 
127
- // pragma MARK: std::shared_ptr<HybridMetamaskConnectorSpec>
143
+ // pragma MARK: std::shared_ptr<HybridNitroMetamaskSpec>
128
144
  /**
129
- * Specialized version of `std::shared_ptr<HybridMetamaskConnectorSpec>`.
145
+ * Specialized version of `std::shared_ptr<HybridNitroMetamaskSpec>`.
130
146
  */
131
- using std__shared_ptr_HybridMetamaskConnectorSpec_ = std::shared_ptr<HybridMetamaskConnectorSpec>;
132
- std::shared_ptr<HybridMetamaskConnectorSpec> create_std__shared_ptr_HybridMetamaskConnectorSpec_(void* NON_NULL swiftUnsafePointer) noexcept;
133
- void* NON_NULL get_std__shared_ptr_HybridMetamaskConnectorSpec_(std__shared_ptr_HybridMetamaskConnectorSpec_ cppType);
147
+ using std__shared_ptr_HybridNitroMetamaskSpec_ = std::shared_ptr<HybridNitroMetamaskSpec>;
148
+ std::shared_ptr<HybridNitroMetamaskSpec> create_std__shared_ptr_HybridNitroMetamaskSpec_(void* NON_NULL swiftUnsafePointer) noexcept;
149
+ void* NON_NULL get_std__shared_ptr_HybridNitroMetamaskSpec_(std__shared_ptr_HybridNitroMetamaskSpec_ cppType);
150
+
151
+ // pragma MARK: std::weak_ptr<HybridNitroMetamaskSpec>
152
+ using std__weak_ptr_HybridNitroMetamaskSpec_ = std::weak_ptr<HybridNitroMetamaskSpec>;
153
+ inline std__weak_ptr_HybridNitroMetamaskSpec_ weakify_std__shared_ptr_HybridNitroMetamaskSpec_(const std::shared_ptr<HybridNitroMetamaskSpec>& strong) noexcept { return strong; }
134
154
 
135
- // pragma MARK: std::weak_ptr<HybridMetamaskConnectorSpec>
136
- using std__weak_ptr_HybridMetamaskConnectorSpec_ = std::weak_ptr<HybridMetamaskConnectorSpec>;
137
- inline std__weak_ptr_HybridMetamaskConnectorSpec_ weakify_std__shared_ptr_HybridMetamaskConnectorSpec_(const std::shared_ptr<HybridMetamaskConnectorSpec>& strong) noexcept { return strong; }
155
+ // pragma MARK: Result<void>
156
+ using Result_void_ = Result<void>;
157
+ inline Result_void_ create_Result_void_() noexcept {
158
+ return Result<void>::withValue();
159
+ }
160
+ inline Result_void_ create_Result_void_(const std::exception_ptr& error) noexcept {
161
+ return Result<void>::withError(error);
162
+ }
138
163
 
139
164
  // pragma MARK: Result<std::shared_ptr<Promise<ConnectResult>>>
140
165
  using Result_std__shared_ptr_Promise_ConnectResult___ = Result<std::shared_ptr<Promise<ConnectResult>>>;
@@ -10,16 +10,17 @@
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>
22
22
  #include <memory>
23
+ #include <optional>
23
24
  #include <string>
24
25
 
25
26
  // C++ helpers for Swift
@@ -32,8 +33,8 @@ namespace margelo::nitro::nitrometamask { class HybridMetamaskConnectorSpec; }
32
33
  #include <NitroModules/DateToChronoDate.hpp>
33
34
 
34
35
  // Forward declarations of Swift defined types
35
- // Forward declaration of `HybridMetamaskConnectorSpec_cxx` to properly resolve imports.
36
- namespace NitroMetamask { class HybridMetamaskConnectorSpec_cxx; }
36
+ // Forward declaration of `HybridNitroMetamaskSpec_cxx` to properly resolve imports.
37
+ namespace NitroMetamask { class HybridNitroMetamaskSpec_cxx; }
37
38
 
38
39
  // Include Swift defined types
39
40
  #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,42 +7,43 @@
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; }
17
17
 
18
+ #include <string>
19
+ #include <optional>
18
20
  #include "ConnectResult.hpp"
19
21
  #include <NitroModules/Promise.hpp>
20
- #include <string>
21
22
 
22
23
  #include "NitroMetamask-Swift-Cxx-Umbrella.hpp"
23
24
 
24
25
  namespace margelo::nitro::nitrometamask {
25
26
 
26
27
  /**
27
- * The C++ part of HybridMetamaskConnectorSpec_cxx.swift.
28
+ * The C++ part of HybridNitroMetamaskSpec_cxx.swift.
28
29
  *
29
- * HybridMetamaskConnectorSpecSwift (C++) accesses HybridMetamaskConnectorSpec_cxx (Swift), and might
30
+ * HybridNitroMetamaskSpecSwift (C++) accesses HybridNitroMetamaskSpec_cxx (Swift), and might
30
31
  * contain some additional bridging code for C++ <> Swift interop.
31
32
  *
32
33
  * 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
34
+ * the future, HybridNitroMetamaskSpec_cxx can directly inherit from the C++ class HybridNitroMetamaskSpec
34
35
  * to simplify the whole structure and memory management.
35
36
  */
36
- class HybridMetamaskConnectorSpecSwift: public virtual HybridMetamaskConnectorSpec {
37
+ class HybridNitroMetamaskSpecSwift: public virtual HybridNitroMetamaskSpec {
37
38
  public:
38
39
  // Constructor from a Swift instance
39
- explicit HybridMetamaskConnectorSpecSwift(const NitroMetamask::HybridMetamaskConnectorSpec_cxx& swiftPart):
40
- HybridObject(HybridMetamaskConnectorSpec::TAG),
40
+ explicit HybridNitroMetamaskSpecSwift(const NitroMetamask::HybridNitroMetamaskSpec_cxx& swiftPart):
41
+ HybridObject(HybridNitroMetamaskSpec::TAG),
41
42
  _swiftPart(swiftPart) { }
42
43
 
43
44
  public:
44
45
  // Get the Swift part
45
- inline NitroMetamask::HybridMetamaskConnectorSpec_cxx& getSwiftPart() noexcept {
46
+ inline NitroMetamask::HybridNitroMetamaskSpec_cxx& getSwiftPart() noexcept {
46
47
  return _swiftPart;
47
48
  }
48
49
 
@@ -63,6 +64,12 @@ namespace margelo::nitro::nitrometamask {
63
64
 
64
65
  public:
65
66
  // Methods
67
+ inline void configure(const std::optional<std::string>& dappUrl) override {
68
+ auto __result = _swiftPart.configure(dappUrl);
69
+ if (__result.hasError()) [[unlikely]] {
70
+ std::rethrow_exception(__result.error());
71
+ }
72
+ }
66
73
  inline std::shared_ptr<Promise<ConnectResult>> connect() override {
67
74
  auto __result = _swiftPart.connect();
68
75
  if (__result.hasError()) [[unlikely]] {
@@ -79,9 +86,17 @@ namespace margelo::nitro::nitrometamask {
79
86
  auto __value = std::move(__result.value());
80
87
  return __value;
81
88
  }
89
+ inline std::shared_ptr<Promise<std::string>> connectSign(const std::string& nonce, int64_t exp) override {
90
+ auto __result = _swiftPart.connectSign(nonce, std::forward<decltype(exp)>(exp));
91
+ if (__result.hasError()) [[unlikely]] {
92
+ std::rethrow_exception(__result.error());
93
+ }
94
+ auto __value = std::move(__result.value());
95
+ return __value;
96
+ }
82
97
 
83
98
  private:
84
- NitroMetamask::HybridMetamaskConnectorSpec_cxx _swiftPart;
99
+ NitroMetamask::HybridNitroMetamaskSpec_cxx _swiftPart;
85
100
  };
86
101
 
87
102
  } // namespace margelo::nitro::nitrometamask
@@ -0,0 +1,59 @@
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 configure(dappUrl: String?) throws -> Void
18
+ func connect() throws -> Promise<ConnectResult>
19
+ func signMessage(message: String) throws -> Promise<String>
20
+ func connectSign(nonce: String, exp: Int64) throws -> Promise<String>
21
+ }
22
+
23
+ public extension HybridNitroMetamaskSpec_protocol {
24
+ /// Default implementation of ``HybridObject.toString``
25
+ func toString() -> String {
26
+ return "[HybridObject NitroMetamask]"
27
+ }
28
+ }
29
+
30
+ /// See ``HybridNitroMetamaskSpec``
31
+ open class HybridNitroMetamaskSpec_base {
32
+ private weak var cxxWrapper: HybridNitroMetamaskSpec_cxx? = nil
33
+ public init() { }
34
+ public func getCxxWrapper() -> HybridNitroMetamaskSpec_cxx {
35
+ #if DEBUG
36
+ guard self is HybridNitroMetamaskSpec else {
37
+ fatalError("`self` is not a `HybridNitroMetamaskSpec`! Did you accidentally inherit from `HybridNitroMetamaskSpec_base` instead of `HybridNitroMetamaskSpec`?")
38
+ }
39
+ #endif
40
+ if let cxxWrapper = self.cxxWrapper {
41
+ return cxxWrapper
42
+ } else {
43
+ let cxxWrapper = HybridNitroMetamaskSpec_cxx(self as! HybridNitroMetamaskSpec)
44
+ self.cxxWrapper = cxxWrapper
45
+ return cxxWrapper
46
+ }
47
+ }
48
+ }
49
+
50
+ /**
51
+ * A Swift base-protocol representing the NitroMetamask HybridObject.
52
+ * Implement this protocol to create Swift-based instances of NitroMetamask.
53
+ * ```swift
54
+ * class HybridNitroMetamask : HybridNitroMetamaskSpec {
55
+ * // ...
56
+ * }
57
+ * ```
58
+ */
59
+ 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
  }
@@ -117,6 +117,24 @@ open class HybridMetamaskConnectorSpec_cxx {
117
117
 
118
118
 
119
119
  // Methods
120
+ @inline(__always)
121
+ public final func configure(dappUrl: bridge.std__optional_std__string_) -> bridge.Result_void_ {
122
+ do {
123
+ try self.__implementation.configure(dappUrl: { () -> String? in
124
+ if bridge.has_value_std__optional_std__string_(dappUrl) {
125
+ let __unwrapped = bridge.get_std__optional_std__string_(dappUrl)
126
+ return String(__unwrapped)
127
+ } else {
128
+ return nil
129
+ }
130
+ }())
131
+ return bridge.create_Result_void_()
132
+ } catch (let __error) {
133
+ let __exceptionPtr = __error.toCpp()
134
+ return bridge.create_Result_void_(__exceptionPtr)
135
+ }
136
+ }
137
+
120
138
  @inline(__always)
121
139
  public final func connect() -> bridge.Result_std__shared_ptr_Promise_ConnectResult___ {
122
140
  do {
@@ -154,4 +172,23 @@ open class HybridMetamaskConnectorSpec_cxx {
154
172
  return bridge.create_Result_std__shared_ptr_Promise_std__string___(__exceptionPtr)
155
173
  }
156
174
  }
175
+
176
+ @inline(__always)
177
+ public final func connectSign(nonce: std.string, exp: Int64) -> bridge.Result_std__shared_ptr_Promise_std__string___ {
178
+ do {
179
+ let __result = try self.__implementation.connectSign(nonce: String(nonce), exp: exp)
180
+ let __resultCpp = { () -> bridge.std__shared_ptr_Promise_std__string__ in
181
+ let __promise = bridge.create_std__shared_ptr_Promise_std__string__()
182
+ let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_std__string__(__promise)
183
+ __result
184
+ .then({ __result in __promiseHolder.resolve(std.string(__result)) })
185
+ .catch({ __error in __promiseHolder.reject(__error.toCpp()) })
186
+ return __promise
187
+ }()
188
+ return bridge.create_Result_std__shared_ptr_Promise_std__string___(__resultCpp)
189
+ } catch (let __error) {
190
+ let __exceptionPtr = __error.toCpp()
191
+ return bridge.create_Result_std__shared_ptr_Promise_std__string___(__exceptionPtr)
192
+ }
193
+ }
157
194
  }
@@ -0,0 +1,24 @@
1
+ ///
2
+ /// HybridNitroMetamaskSpec.cpp
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
+ #include "HybridNitroMetamaskSpec.hpp"
9
+
10
+ namespace margelo::nitro::nitrometamask {
11
+
12
+ void HybridNitroMetamaskSpec::loadHybridMethods() {
13
+ // load base methods/properties
14
+ HybridObject::loadHybridMethods();
15
+ // load custom methods/properties
16
+ registerHybrids(this, [](Prototype& prototype) {
17
+ prototype.registerHybridMethod("configure", &HybridNitroMetamaskSpec::configure);
18
+ prototype.registerHybridMethod("connect", &HybridNitroMetamaskSpec::connect);
19
+ prototype.registerHybridMethod("signMessage", &HybridNitroMetamaskSpec::signMessage);
20
+ prototype.registerHybridMethod("connectSign", &HybridNitroMetamaskSpec::connectSign);
21
+ });
22
+ }
23
+
24
+ } // namespace margelo::nitro::nitrometamask
@@ -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
@@ -16,34 +16,35 @@
16
16
  // Forward declaration of `ConnectResult` to properly resolve imports.
17
17
  namespace margelo::nitro::nitrometamask { struct ConnectResult; }
18
18
 
19
+ #include <string>
20
+ #include <optional>
19
21
  #include "ConnectResult.hpp"
20
22
  #include <NitroModules/Promise.hpp>
21
- #include <string>
22
23
 
23
24
  namespace margelo::nitro::nitrometamask {
24
25
 
25
26
  using namespace margelo::nitro;
26
27
 
27
28
  /**
28
- * An abstract base class for `MetamaskConnector`
29
- * Inherit this class to create instances of `HybridMetamaskConnectorSpec` in C++.
29
+ * An abstract base class for `NitroMetamask`
30
+ * Inherit this class to create instances of `HybridNitroMetamaskSpec` in C++.
30
31
  * You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
31
32
  * @example
32
33
  * ```cpp
33
- * class HybridMetamaskConnector: public HybridMetamaskConnectorSpec {
34
+ * class HybridNitroMetamask: public HybridNitroMetamaskSpec {
34
35
  * public:
35
- * HybridMetamaskConnector(...): HybridObject(TAG) { ... }
36
+ * HybridNitroMetamask(...): HybridObject(TAG) { ... }
36
37
  * // ...
37
38
  * };
38
39
  * ```
39
40
  */
40
- class HybridMetamaskConnectorSpec: public virtual HybridObject {
41
+ class HybridNitroMetamaskSpec: public virtual HybridObject {
41
42
  public:
42
43
  // Constructor
43
- explicit HybridMetamaskConnectorSpec(): HybridObject(TAG) { }
44
+ explicit HybridNitroMetamaskSpec(): HybridObject(TAG) { }
44
45
 
45
46
  // Destructor
46
- ~HybridMetamaskConnectorSpec() override = default;
47
+ ~HybridNitroMetamaskSpec() override = default;
47
48
 
48
49
  public:
49
50
  // Properties
@@ -51,8 +52,10 @@ namespace margelo::nitro::nitrometamask {
51
52
 
52
53
  public:
53
54
  // Methods
55
+ virtual void configure(const std::optional<std::string>& dappUrl) = 0;
54
56
  virtual std::shared_ptr<Promise<ConnectResult>> connect() = 0;
55
57
  virtual std::shared_ptr<Promise<std::string>> signMessage(const std::string& message) = 0;
58
+ virtual std::shared_ptr<Promise<std::string>> connectSign(const std::string& nonce, int64_t exp) = 0;
56
59
 
57
60
  protected:
58
61
  // Hybrid Setup
@@ -60,7 +63,7 @@ namespace margelo::nitro::nitrometamask {
60
63
 
61
64
  protected:
62
65
  // Tag for logging
63
- static constexpr auto TAG = "MetamaskConnector";
66
+ static constexpr auto TAG = "NitroMetamask";
64
67
  };
65
68
 
66
69
  } // namespace margelo::nitro::nitrometamask