@novastera-oss/nitro-metamask 0.3.2 → 0.4.1

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 (44) hide show
  1. package/README.md +124 -0
  2. package/android/build.gradle +2 -2
  3. package/android/src/main/java/com/margelo/nitro/nitrometamask/HybridNitroMetamask.kt +583 -0
  4. package/android/src/main/java/com/{nitrometamask → margelo/nitro/nitrometamask}/MetamaskContextHolder.kt +1 -1
  5. package/android/src/main/java/com/{nitrometamask → margelo/nitro/nitrometamask}/NitroMetamaskPackage.kt +1 -1
  6. package/app.plugin.js +121 -0
  7. package/ios/HybridNitroMetamask.swift +107 -1
  8. package/lib/typescript/src/specs/nitro-metamask.nitro.d.ts +36 -1
  9. package/lib/typescript/src/specs/nitro-metamask.nitro.d.ts.map +1 -1
  10. package/nitrogen/generated/android/NitroMetamask+autolinking.cmake +2 -0
  11. package/nitrogen/generated/android/c++/JConnectResult.hpp +3 -3
  12. package/nitrogen/generated/android/c++/JConnectSignResult.hpp +65 -0
  13. package/nitrogen/generated/android/c++/JHybridNitroMetamaskSpec.cpp +62 -0
  14. package/nitrogen/generated/android/c++/JHybridNitroMetamaskSpec.hpp +4 -0
  15. package/nitrogen/generated/android/c++/JVariant_NullType_Long.cpp +26 -0
  16. package/nitrogen/generated/android/c++/JVariant_NullType_Long.hpp +69 -0
  17. package/nitrogen/generated/android/c++/JVariant_NullType_String.cpp +26 -0
  18. package/nitrogen/generated/android/c++/JVariant_NullType_String.hpp +70 -0
  19. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrometamask/ConnectResult.kt +2 -2
  20. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrometamask/ConnectSignResult.kt +44 -0
  21. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrometamask/HybridNitroMetamaskSpec.kt +17 -0
  22. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrometamask/Variant_NullType_Long.kt +59 -0
  23. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrometamask/Variant_NullType_String.kt +59 -0
  24. package/nitrogen/generated/ios/NitroMetamask-Swift-Cxx-Bridge.cpp +24 -0
  25. package/nitrogen/generated/ios/NitroMetamask-Swift-Cxx-Bridge.hpp +217 -0
  26. package/nitrogen/generated/ios/NitroMetamask-Swift-Cxx-Umbrella.hpp +6 -0
  27. package/nitrogen/generated/ios/c++/HybridNitroMetamaskSpecSwift.hpp +37 -1
  28. package/nitrogen/generated/ios/swift/ConnectResult.swift +2 -2
  29. package/nitrogen/generated/ios/swift/ConnectSignResult.swift +40 -0
  30. package/nitrogen/generated/ios/swift/Func_void_ConnectSignResult.swift +47 -0
  31. package/nitrogen/generated/ios/swift/Func_void_std__variant_nitro__NullType__int64_t_.swift +59 -0
  32. package/nitrogen/generated/ios/swift/Func_void_std__variant_nitro__NullType__std__string_.swift +59 -0
  33. package/nitrogen/generated/ios/swift/HybridNitroMetamaskSpec.swift +4 -0
  34. package/nitrogen/generated/ios/swift/HybridNitroMetamaskSpec_cxx.swift +96 -0
  35. package/nitrogen/generated/ios/swift/Variant_NullType_Int64.swift +18 -0
  36. package/nitrogen/generated/ios/swift/Variant_NullType_String.swift +18 -0
  37. package/nitrogen/generated/shared/c++/ConnectResult.hpp +5 -5
  38. package/nitrogen/generated/shared/c++/ConnectSignResult.hpp +91 -0
  39. package/nitrogen/generated/shared/c++/HybridNitroMetamaskSpec.cpp +4 -0
  40. package/nitrogen/generated/shared/c++/HybridNitroMetamaskSpec.hpp +11 -1
  41. package/package.json +4 -3
  42. package/react-native.config.js +1 -1
  43. package/src/specs/nitro-metamask.nitro.ts +37 -1
  44. package/android/src/main/java/com/nitrometamask/HybridNitroMetamask.kt +0 -146
@@ -0,0 +1,70 @@
1
+ ///
2
+ /// JVariant_NullType_String.hpp
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
+ #pragma once
9
+
10
+ #include <fbjni/fbjni.h>
11
+ #include <variant>
12
+
13
+ #include <NitroModules/Null.hpp>
14
+ #include <string>
15
+ #include <variant>
16
+ #include <NitroModules/JNull.hpp>
17
+
18
+ namespace margelo::nitro::nitrometamask {
19
+
20
+ using namespace facebook;
21
+
22
+ /**
23
+ * The C++ JNI bridge between the C++ std::variant and the Java class "Variant_NullType_String".
24
+ */
25
+ class JVariant_NullType_String: public jni::JavaClass<JVariant_NullType_String> {
26
+ public:
27
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/nitrometamask/Variant_NullType_String;";
28
+
29
+ static jni::local_ref<JVariant_NullType_String> create_0(jni::alias_ref<JNull> value) {
30
+ static const auto method = javaClassStatic()->getStaticMethod<JVariant_NullType_String(jni::alias_ref<JNull>)>("create");
31
+ return method(javaClassStatic(), value);
32
+ }
33
+ static jni::local_ref<JVariant_NullType_String> create_1(jni::alias_ref<jni::JString> value) {
34
+ static const auto method = javaClassStatic()->getStaticMethod<JVariant_NullType_String(jni::alias_ref<jni::JString>)>("create");
35
+ return method(javaClassStatic(), value);
36
+ }
37
+
38
+ static jni::local_ref<JVariant_NullType_String> fromCpp(const std::variant<nitro::NullType, std::string>& variant) {
39
+ switch (variant.index()) {
40
+ case 0: return create_0(JNull::null());
41
+ case 1: return create_1(jni::make_jstring(std::get<1>(variant)));
42
+ default: throw std::invalid_argument("Variant holds unknown index! (" + std::to_string(variant.index()) + ")");
43
+ }
44
+ }
45
+
46
+ [[nodiscard]] std::variant<nitro::NullType, std::string> toCpp() const;
47
+ };
48
+
49
+ namespace JVariant_NullType_String_impl {
50
+ class First final: public jni::JavaClass<First, JVariant_NullType_String> {
51
+ public:
52
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/nitrometamask/Variant_NullType_String$First;";
53
+
54
+ [[nodiscard]] jni::local_ref<JNull> getValue() const {
55
+ static const auto field = javaClassStatic()->getField<JNull>("value");
56
+ return getFieldValue(field);
57
+ }
58
+ };
59
+
60
+ class Second final: public jni::JavaClass<Second, JVariant_NullType_String> {
61
+ public:
62
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/nitrometamask/Variant_NullType_String$Second;";
63
+
64
+ [[nodiscard]] jni::local_ref<jni::JString> getValue() const {
65
+ static const auto field = javaClassStatic()->getField<jni::JString>("value");
66
+ return getFieldValue(field);
67
+ }
68
+ };
69
+ } // namespace JVariant_NullType_String_impl
70
+ } // namespace margelo::nitro::nitrometamask
@@ -22,7 +22,7 @@ data class ConnectResult(
22
22
  val address: String,
23
23
  @DoNotStrip
24
24
  @Keep
25
- val chainId: Double
25
+ val chainId: Long
26
26
  ) {
27
27
  /* primary constructor */
28
28
 
@@ -34,7 +34,7 @@ data class ConnectResult(
34
34
  @Keep
35
35
  @Suppress("unused")
36
36
  @JvmStatic
37
- private fun fromCpp(address: String, chainId: Double): ConnectResult {
37
+ private fun fromCpp(address: String, chainId: Long): ConnectResult {
38
38
  return ConnectResult(address, chainId)
39
39
  }
40
40
  }
@@ -0,0 +1,44 @@
1
+ ///
2
+ /// ConnectSignResult.kt
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
+ package com.margelo.nitro.nitrometamask
9
+
10
+ import androidx.annotation.Keep
11
+ import com.facebook.proguard.annotations.DoNotStrip
12
+
13
+
14
+ /**
15
+ * Represents the JavaScript object/struct "ConnectSignResult".
16
+ */
17
+ @DoNotStrip
18
+ @Keep
19
+ data class ConnectSignResult(
20
+ @DoNotStrip
21
+ @Keep
22
+ val signature: String,
23
+ @DoNotStrip
24
+ @Keep
25
+ val address: String,
26
+ @DoNotStrip
27
+ @Keep
28
+ val chainId: Long
29
+ ) {
30
+ /* primary constructor */
31
+
32
+ companion object {
33
+ /**
34
+ * Constructor called from C++
35
+ */
36
+ @DoNotStrip
37
+ @Keep
38
+ @Suppress("unused")
39
+ @JvmStatic
40
+ private fun fromCpp(signature: String, address: String, chainId: Long): ConnectSignResult {
41
+ return ConnectSignResult(signature, address, chainId)
42
+ }
43
+ }
44
+ }
@@ -11,6 +11,7 @@ import androidx.annotation.Keep
11
11
  import com.facebook.jni.HybridData
12
12
  import com.facebook.proguard.annotations.DoNotStrip
13
13
  import com.margelo.nitro.core.Promise
14
+ import com.margelo.nitro.core.NullType
14
15
  import com.margelo.nitro.core.HybridObject
15
16
 
16
17
  /**
@@ -46,6 +47,10 @@ abstract class HybridNitroMetamaskSpec: HybridObject() {
46
47
 
47
48
 
48
49
  // Methods
50
+ @DoNotStrip
51
+ @Keep
52
+ abstract fun configure(dappUrl: String?, deepLinkScheme: String?): Unit
53
+
49
54
  @DoNotStrip
50
55
  @Keep
51
56
  abstract fun connect(): Promise<ConnectResult>
@@ -53,6 +58,18 @@ abstract class HybridNitroMetamaskSpec: HybridObject() {
53
58
  @DoNotStrip
54
59
  @Keep
55
60
  abstract fun signMessage(message: String): Promise<String>
61
+
62
+ @DoNotStrip
63
+ @Keep
64
+ abstract fun connectSign(nonce: String, exp: Long): Promise<ConnectSignResult>
65
+
66
+ @DoNotStrip
67
+ @Keep
68
+ abstract fun getAddress(): Promise<Variant_NullType_String>
69
+
70
+ @DoNotStrip
71
+ @Keep
72
+ abstract fun getChainId(): Promise<Variant_NullType_Long>
56
73
 
57
74
  private external fun initHybrid(): HybridData
58
75
 
@@ -0,0 +1,59 @@
1
+ ///
2
+ /// Variant_NullType_Long.kt
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
+ package com.margelo.nitro.nitrometamask
9
+
10
+ import com.facebook.proguard.annotations.DoNotStrip
11
+ import com.margelo.nitro.core.NullType
12
+
13
+ /**
14
+ * Represents the TypeScript variant "NullType | Long".
15
+ */
16
+ @Suppress("ClassName")
17
+ @DoNotStrip
18
+ sealed class Variant_NullType_Long {
19
+ @DoNotStrip
20
+ data class First(@DoNotStrip val value: NullType): Variant_NullType_Long()
21
+ @DoNotStrip
22
+ data class Second(@DoNotStrip val value: Long): Variant_NullType_Long()
23
+
24
+ @Deprecated("getAs() is not type-safe. Use fold/asFirstOrNull/asSecondOrNull instead.", level = DeprecationLevel.ERROR)
25
+ inline fun <reified T> getAs(): T? = when (this) {
26
+ is First -> value as? T
27
+ is Second -> value as? T
28
+ }
29
+
30
+ val isFirst: Boolean
31
+ get() = this is First
32
+ val isSecond: Boolean
33
+ get() = this is Second
34
+
35
+ fun asFirstOrNull(): NullType? {
36
+ val value = (this as? First)?.value ?: return null
37
+ return value
38
+ }
39
+ fun asSecondOrNull(): Long? {
40
+ val value = (this as? Second)?.value ?: return null
41
+ return value
42
+ }
43
+
44
+ inline fun <R> match(first: (NullType) -> R, second: (Long) -> R): R {
45
+ return when (this) {
46
+ is First -> first(value)
47
+ is Second -> second(value)
48
+ }
49
+ }
50
+
51
+ companion object {
52
+ @JvmStatic
53
+ @DoNotStrip
54
+ fun create(value: NullType): Variant_NullType_Long = First(value)
55
+ @JvmStatic
56
+ @DoNotStrip
57
+ fun create(value: Long): Variant_NullType_Long = Second(value)
58
+ }
59
+ }
@@ -0,0 +1,59 @@
1
+ ///
2
+ /// Variant_NullType_String.kt
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
+ package com.margelo.nitro.nitrometamask
9
+
10
+ import com.facebook.proguard.annotations.DoNotStrip
11
+ import com.margelo.nitro.core.NullType
12
+
13
+ /**
14
+ * Represents the TypeScript variant "NullType | String".
15
+ */
16
+ @Suppress("ClassName")
17
+ @DoNotStrip
18
+ sealed class Variant_NullType_String {
19
+ @DoNotStrip
20
+ data class First(@DoNotStrip val value: NullType): Variant_NullType_String()
21
+ @DoNotStrip
22
+ data class Second(@DoNotStrip val value: String): Variant_NullType_String()
23
+
24
+ @Deprecated("getAs() is not type-safe. Use fold/asFirstOrNull/asSecondOrNull instead.", level = DeprecationLevel.ERROR)
25
+ inline fun <reified T> getAs(): T? = when (this) {
26
+ is First -> value as? T
27
+ is Second -> value as? T
28
+ }
29
+
30
+ val isFirst: Boolean
31
+ get() = this is First
32
+ val isSecond: Boolean
33
+ get() = this is Second
34
+
35
+ fun asFirstOrNull(): NullType? {
36
+ val value = (this as? First)?.value ?: return null
37
+ return value
38
+ }
39
+ fun asSecondOrNull(): String? {
40
+ val value = (this as? Second)?.value ?: return null
41
+ return value
42
+ }
43
+
44
+ inline fun <R> match(first: (NullType) -> R, second: (String) -> R): R {
45
+ return when (this) {
46
+ is First -> first(value)
47
+ is Second -> second(value)
48
+ }
49
+ }
50
+
51
+ companion object {
52
+ @JvmStatic
53
+ @DoNotStrip
54
+ fun create(value: NullType): Variant_NullType_String = First(value)
55
+ @JvmStatic
56
+ @DoNotStrip
57
+ fun create(value: String): Variant_NullType_String = Second(value)
58
+ }
59
+ }
@@ -38,6 +38,30 @@ namespace margelo::nitro::nitrometamask::bridge::swift {
38
38
  };
39
39
  }
40
40
 
41
+ // pragma MARK: std::function<void(const ConnectSignResult& /* result */)>
42
+ Func_void_ConnectSignResult create_Func_void_ConnectSignResult(void* NON_NULL swiftClosureWrapper) noexcept {
43
+ auto swiftClosure = NitroMetamask::Func_void_ConnectSignResult::fromUnsafe(swiftClosureWrapper);
44
+ return [swiftClosure = std::move(swiftClosure)](const ConnectSignResult& result) mutable -> void {
45
+ swiftClosure.call(result);
46
+ };
47
+ }
48
+
49
+ // pragma MARK: std::function<void(const std::variant<nitro::NullType, std::string>& /* result */)>
50
+ Func_void_std__variant_nitro__NullType__std__string_ create_Func_void_std__variant_nitro__NullType__std__string_(void* NON_NULL swiftClosureWrapper) noexcept {
51
+ auto swiftClosure = NitroMetamask::Func_void_std__variant_nitro__NullType__std__string_::fromUnsafe(swiftClosureWrapper);
52
+ return [swiftClosure = std::move(swiftClosure)](const std::variant<nitro::NullType, std::string>& result) mutable -> void {
53
+ swiftClosure.call(result);
54
+ };
55
+ }
56
+
57
+ // pragma MARK: std::function<void(const std::variant<nitro::NullType, int64_t>& /* result */)>
58
+ Func_void_std__variant_nitro__NullType__int64_t_ create_Func_void_std__variant_nitro__NullType__int64_t_(void* NON_NULL swiftClosureWrapper) noexcept {
59
+ auto swiftClosure = NitroMetamask::Func_void_std__variant_nitro__NullType__int64_t_::fromUnsafe(swiftClosureWrapper);
60
+ return [swiftClosure = std::move(swiftClosure)](const std::variant<nitro::NullType, int64_t>& result) mutable -> void {
61
+ swiftClosure.call(result);
62
+ };
63
+ }
64
+
41
65
  // pragma MARK: std::shared_ptr<HybridNitroMetamaskSpec>
42
66
  std::shared_ptr<HybridNitroMetamaskSpec> create_std__shared_ptr_HybridNitroMetamaskSpec_(void* NON_NULL swiftUnsafePointer) noexcept {
43
67
  NitroMetamask::HybridNitroMetamaskSpec_cxx swiftPart = NitroMetamask::HybridNitroMetamaskSpec_cxx::fromUnsafe(swiftUnsafePointer);
@@ -10,6 +10,8 @@
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 `ConnectSignResult` to properly resolve imports.
14
+ namespace margelo::nitro::nitrometamask { struct ConnectSignResult; }
13
15
  // Forward declaration of `HybridNitroMetamaskSpec` to properly resolve imports.
14
16
  namespace margelo::nitro::nitrometamask { class HybridNitroMetamaskSpec; }
15
17
 
@@ -19,14 +21,18 @@ namespace NitroMetamask { class HybridNitroMetamaskSpec_cxx; }
19
21
 
20
22
  // Include C++ defined types
21
23
  #include "ConnectResult.hpp"
24
+ #include "ConnectSignResult.hpp"
22
25
  #include "HybridNitroMetamaskSpec.hpp"
26
+ #include <NitroModules/Null.hpp>
23
27
  #include <NitroModules/Promise.hpp>
24
28
  #include <NitroModules/PromiseHolder.hpp>
25
29
  #include <NitroModules/Result.hpp>
26
30
  #include <exception>
27
31
  #include <functional>
28
32
  #include <memory>
33
+ #include <optional>
29
34
  #include <string>
35
+ #include <variant>
30
36
 
31
37
  /**
32
38
  * Contains specialized versions of C++ templated types so they can be accessed from Swift,
@@ -34,6 +40,21 @@ namespace NitroMetamask { class HybridNitroMetamaskSpec_cxx; }
34
40
  */
35
41
  namespace margelo::nitro::nitrometamask::bridge::swift {
36
42
 
43
+ // pragma MARK: std::optional<std::string>
44
+ /**
45
+ * Specialized version of `std::optional<std::string>`.
46
+ */
47
+ using std__optional_std__string_ = std::optional<std::string>;
48
+ inline std::optional<std::string> create_std__optional_std__string_(const std::string& value) noexcept {
49
+ return std::optional<std::string>(value);
50
+ }
51
+ inline bool has_value_std__optional_std__string_(const std::optional<std::string>& optional) noexcept {
52
+ return optional.has_value();
53
+ }
54
+ inline std::string get_std__optional_std__string_(const std::optional<std::string>& optional) noexcept {
55
+ return *optional;
56
+ }
57
+
37
58
  // pragma MARK: std::shared_ptr<Promise<ConnectResult>>
38
59
  /**
39
60
  * Specialized version of `std::shared_ptr<Promise<ConnectResult>>`.
@@ -124,6 +145,166 @@ namespace margelo::nitro::nitrometamask::bridge::swift {
124
145
  return Func_void_std__string_Wrapper(std::move(value));
125
146
  }
126
147
 
148
+ // pragma MARK: std::shared_ptr<Promise<ConnectSignResult>>
149
+ /**
150
+ * Specialized version of `std::shared_ptr<Promise<ConnectSignResult>>`.
151
+ */
152
+ using std__shared_ptr_Promise_ConnectSignResult__ = std::shared_ptr<Promise<ConnectSignResult>>;
153
+ inline std::shared_ptr<Promise<ConnectSignResult>> create_std__shared_ptr_Promise_ConnectSignResult__() noexcept {
154
+ return Promise<ConnectSignResult>::create();
155
+ }
156
+ inline PromiseHolder<ConnectSignResult> wrap_std__shared_ptr_Promise_ConnectSignResult__(std::shared_ptr<Promise<ConnectSignResult>> promise) noexcept {
157
+ return PromiseHolder<ConnectSignResult>(std::move(promise));
158
+ }
159
+
160
+ // pragma MARK: std::function<void(const ConnectSignResult& /* result */)>
161
+ /**
162
+ * Specialized version of `std::function<void(const ConnectSignResult&)>`.
163
+ */
164
+ using Func_void_ConnectSignResult = std::function<void(const ConnectSignResult& /* result */)>;
165
+ /**
166
+ * Wrapper class for a `std::function<void(const ConnectSignResult& / * result * /)>`, this can be used from Swift.
167
+ */
168
+ class Func_void_ConnectSignResult_Wrapper final {
169
+ public:
170
+ explicit Func_void_ConnectSignResult_Wrapper(std::function<void(const ConnectSignResult& /* result */)>&& func): _function(std::make_unique<std::function<void(const ConnectSignResult& /* result */)>>(std::move(func))) {}
171
+ inline void call(ConnectSignResult result) const noexcept {
172
+ _function->operator()(result);
173
+ }
174
+ private:
175
+ std::unique_ptr<std::function<void(const ConnectSignResult& /* result */)>> _function;
176
+ } SWIFT_NONCOPYABLE;
177
+ Func_void_ConnectSignResult create_Func_void_ConnectSignResult(void* NON_NULL swiftClosureWrapper) noexcept;
178
+ inline Func_void_ConnectSignResult_Wrapper wrap_Func_void_ConnectSignResult(Func_void_ConnectSignResult value) noexcept {
179
+ return Func_void_ConnectSignResult_Wrapper(std::move(value));
180
+ }
181
+
182
+ // pragma MARK: std::variant<nitro::NullType, std::string>
183
+ /**
184
+ * Wrapper struct for `std::variant<nitro::NullType, std::string>`.
185
+ * std::variant cannot be used in Swift because of a Swift bug.
186
+ * Not even specializing it works. So we create a wrapper struct.
187
+ */
188
+ struct std__variant_nitro__NullType__std__string_ final {
189
+ std::variant<nitro::NullType, std::string> variant;
190
+ std__variant_nitro__NullType__std__string_(std::variant<nitro::NullType, std::string> variant): variant(variant) { }
191
+ operator std::variant<nitro::NullType, std::string>() const noexcept {
192
+ return variant;
193
+ }
194
+ inline size_t index() const noexcept {
195
+ return variant.index();
196
+ }
197
+ inline nitro::NullType get_0() const noexcept {
198
+ return std::get<0>(variant);
199
+ }
200
+ inline std::string get_1() const noexcept {
201
+ return std::get<1>(variant);
202
+ }
203
+ };
204
+ inline std__variant_nitro__NullType__std__string_ create_std__variant_nitro__NullType__std__string_(nitro::NullType value) noexcept {
205
+ return std__variant_nitro__NullType__std__string_(value);
206
+ }
207
+ inline std__variant_nitro__NullType__std__string_ create_std__variant_nitro__NullType__std__string_(const std::string& value) noexcept {
208
+ return std__variant_nitro__NullType__std__string_(value);
209
+ }
210
+
211
+ // pragma MARK: std::shared_ptr<Promise<std::variant<nitro::NullType, std::string>>>
212
+ /**
213
+ * Specialized version of `std::shared_ptr<Promise<std::variant<nitro::NullType, std::string>>>`.
214
+ */
215
+ using std__shared_ptr_Promise_std__variant_nitro__NullType__std__string___ = std::shared_ptr<Promise<std::variant<nitro::NullType, std::string>>>;
216
+ inline std::shared_ptr<Promise<std::variant<nitro::NullType, std::string>>> create_std__shared_ptr_Promise_std__variant_nitro__NullType__std__string___() noexcept {
217
+ return Promise<std::variant<nitro::NullType, std::string>>::create();
218
+ }
219
+ inline PromiseHolder<std::variant<nitro::NullType, std::string>> wrap_std__shared_ptr_Promise_std__variant_nitro__NullType__std__string___(std::shared_ptr<Promise<std::variant<nitro::NullType, std::string>>> promise) noexcept {
220
+ return PromiseHolder<std::variant<nitro::NullType, std::string>>(std::move(promise));
221
+ }
222
+
223
+ // pragma MARK: std::function<void(const std::variant<nitro::NullType, std::string>& /* result */)>
224
+ /**
225
+ * Specialized version of `std::function<void(const std::variant<nitro::NullType, std::string>&)>`.
226
+ */
227
+ using Func_void_std__variant_nitro__NullType__std__string_ = std::function<void(const std::variant<nitro::NullType, std::string>& /* result */)>;
228
+ /**
229
+ * Wrapper class for a `std::function<void(const std::variant<nitro::NullType, std::string>& / * result * /)>`, this can be used from Swift.
230
+ */
231
+ class Func_void_std__variant_nitro__NullType__std__string__Wrapper final {
232
+ public:
233
+ explicit Func_void_std__variant_nitro__NullType__std__string__Wrapper(std::function<void(const std::variant<nitro::NullType, std::string>& /* result */)>&& func): _function(std::make_unique<std::function<void(const std::variant<nitro::NullType, std::string>& /* result */)>>(std::move(func))) {}
234
+ inline void call(std::variant<nitro::NullType, std::string> result) const noexcept {
235
+ _function->operator()(result);
236
+ }
237
+ private:
238
+ std::unique_ptr<std::function<void(const std::variant<nitro::NullType, std::string>& /* result */)>> _function;
239
+ } SWIFT_NONCOPYABLE;
240
+ Func_void_std__variant_nitro__NullType__std__string_ create_Func_void_std__variant_nitro__NullType__std__string_(void* NON_NULL swiftClosureWrapper) noexcept;
241
+ inline Func_void_std__variant_nitro__NullType__std__string__Wrapper wrap_Func_void_std__variant_nitro__NullType__std__string_(Func_void_std__variant_nitro__NullType__std__string_ value) noexcept {
242
+ return Func_void_std__variant_nitro__NullType__std__string__Wrapper(std::move(value));
243
+ }
244
+
245
+ // pragma MARK: std::variant<nitro::NullType, int64_t>
246
+ /**
247
+ * Wrapper struct for `std::variant<nitro::NullType, int64_t>`.
248
+ * std::variant cannot be used in Swift because of a Swift bug.
249
+ * Not even specializing it works. So we create a wrapper struct.
250
+ */
251
+ struct std__variant_nitro__NullType__int64_t_ final {
252
+ std::variant<nitro::NullType, int64_t> variant;
253
+ std__variant_nitro__NullType__int64_t_(std::variant<nitro::NullType, int64_t> variant): variant(variant) { }
254
+ operator std::variant<nitro::NullType, int64_t>() const noexcept {
255
+ return variant;
256
+ }
257
+ inline size_t index() const noexcept {
258
+ return variant.index();
259
+ }
260
+ inline nitro::NullType get_0() const noexcept {
261
+ return std::get<0>(variant);
262
+ }
263
+ inline int64_t get_1() const noexcept {
264
+ return std::get<1>(variant);
265
+ }
266
+ };
267
+ inline std__variant_nitro__NullType__int64_t_ create_std__variant_nitro__NullType__int64_t_(nitro::NullType value) noexcept {
268
+ return std__variant_nitro__NullType__int64_t_(value);
269
+ }
270
+ inline std__variant_nitro__NullType__int64_t_ create_std__variant_nitro__NullType__int64_t_(int64_t value) noexcept {
271
+ return std__variant_nitro__NullType__int64_t_(value);
272
+ }
273
+
274
+ // pragma MARK: std::shared_ptr<Promise<std::variant<nitro::NullType, int64_t>>>
275
+ /**
276
+ * Specialized version of `std::shared_ptr<Promise<std::variant<nitro::NullType, int64_t>>>`.
277
+ */
278
+ using std__shared_ptr_Promise_std__variant_nitro__NullType__int64_t___ = std::shared_ptr<Promise<std::variant<nitro::NullType, int64_t>>>;
279
+ inline std::shared_ptr<Promise<std::variant<nitro::NullType, int64_t>>> create_std__shared_ptr_Promise_std__variant_nitro__NullType__int64_t___() noexcept {
280
+ return Promise<std::variant<nitro::NullType, int64_t>>::create();
281
+ }
282
+ inline PromiseHolder<std::variant<nitro::NullType, int64_t>> wrap_std__shared_ptr_Promise_std__variant_nitro__NullType__int64_t___(std::shared_ptr<Promise<std::variant<nitro::NullType, int64_t>>> promise) noexcept {
283
+ return PromiseHolder<std::variant<nitro::NullType, int64_t>>(std::move(promise));
284
+ }
285
+
286
+ // pragma MARK: std::function<void(const std::variant<nitro::NullType, int64_t>& /* result */)>
287
+ /**
288
+ * Specialized version of `std::function<void(const std::variant<nitro::NullType, int64_t>&)>`.
289
+ */
290
+ using Func_void_std__variant_nitro__NullType__int64_t_ = std::function<void(const std::variant<nitro::NullType, int64_t>& /* result */)>;
291
+ /**
292
+ * Wrapper class for a `std::function<void(const std::variant<nitro::NullType, int64_t>& / * result * /)>`, this can be used from Swift.
293
+ */
294
+ class Func_void_std__variant_nitro__NullType__int64_t__Wrapper final {
295
+ public:
296
+ explicit Func_void_std__variant_nitro__NullType__int64_t__Wrapper(std::function<void(const std::variant<nitro::NullType, int64_t>& /* result */)>&& func): _function(std::make_unique<std::function<void(const std::variant<nitro::NullType, int64_t>& /* result */)>>(std::move(func))) {}
297
+ inline void call(std::variant<nitro::NullType, int64_t> result) const noexcept {
298
+ _function->operator()(result);
299
+ }
300
+ private:
301
+ std::unique_ptr<std::function<void(const std::variant<nitro::NullType, int64_t>& /* result */)>> _function;
302
+ } SWIFT_NONCOPYABLE;
303
+ Func_void_std__variant_nitro__NullType__int64_t_ create_Func_void_std__variant_nitro__NullType__int64_t_(void* NON_NULL swiftClosureWrapper) noexcept;
304
+ inline Func_void_std__variant_nitro__NullType__int64_t__Wrapper wrap_Func_void_std__variant_nitro__NullType__int64_t_(Func_void_std__variant_nitro__NullType__int64_t_ value) noexcept {
305
+ return Func_void_std__variant_nitro__NullType__int64_t__Wrapper(std::move(value));
306
+ }
307
+
127
308
  // pragma MARK: std::shared_ptr<HybridNitroMetamaskSpec>
128
309
  /**
129
310
  * Specialized version of `std::shared_ptr<HybridNitroMetamaskSpec>`.
@@ -136,6 +317,15 @@ namespace margelo::nitro::nitrometamask::bridge::swift {
136
317
  using std__weak_ptr_HybridNitroMetamaskSpec_ = std::weak_ptr<HybridNitroMetamaskSpec>;
137
318
  inline std__weak_ptr_HybridNitroMetamaskSpec_ weakify_std__shared_ptr_HybridNitroMetamaskSpec_(const std::shared_ptr<HybridNitroMetamaskSpec>& strong) noexcept { return strong; }
138
319
 
320
+ // pragma MARK: Result<void>
321
+ using Result_void_ = Result<void>;
322
+ inline Result_void_ create_Result_void_() noexcept {
323
+ return Result<void>::withValue();
324
+ }
325
+ inline Result_void_ create_Result_void_(const std::exception_ptr& error) noexcept {
326
+ return Result<void>::withError(error);
327
+ }
328
+
139
329
  // pragma MARK: Result<std::shared_ptr<Promise<ConnectResult>>>
140
330
  using Result_std__shared_ptr_Promise_ConnectResult___ = Result<std::shared_ptr<Promise<ConnectResult>>>;
141
331
  inline Result_std__shared_ptr_Promise_ConnectResult___ create_Result_std__shared_ptr_Promise_ConnectResult___(const std::shared_ptr<Promise<ConnectResult>>& value) noexcept {
@@ -153,5 +343,32 @@ namespace margelo::nitro::nitrometamask::bridge::swift {
153
343
  inline Result_std__shared_ptr_Promise_std__string___ create_Result_std__shared_ptr_Promise_std__string___(const std::exception_ptr& error) noexcept {
154
344
  return Result<std::shared_ptr<Promise<std::string>>>::withError(error);
155
345
  }
346
+
347
+ // pragma MARK: Result<std::shared_ptr<Promise<ConnectSignResult>>>
348
+ using Result_std__shared_ptr_Promise_ConnectSignResult___ = Result<std::shared_ptr<Promise<ConnectSignResult>>>;
349
+ inline Result_std__shared_ptr_Promise_ConnectSignResult___ create_Result_std__shared_ptr_Promise_ConnectSignResult___(const std::shared_ptr<Promise<ConnectSignResult>>& value) noexcept {
350
+ return Result<std::shared_ptr<Promise<ConnectSignResult>>>::withValue(value);
351
+ }
352
+ inline Result_std__shared_ptr_Promise_ConnectSignResult___ create_Result_std__shared_ptr_Promise_ConnectSignResult___(const std::exception_ptr& error) noexcept {
353
+ return Result<std::shared_ptr<Promise<ConnectSignResult>>>::withError(error);
354
+ }
355
+
356
+ // pragma MARK: Result<std::shared_ptr<Promise<std::variant<nitro::NullType, std::string>>>>
357
+ using Result_std__shared_ptr_Promise_std__variant_nitro__NullType__std__string____ = Result<std::shared_ptr<Promise<std::variant<nitro::NullType, std::string>>>>;
358
+ inline Result_std__shared_ptr_Promise_std__variant_nitro__NullType__std__string____ create_Result_std__shared_ptr_Promise_std__variant_nitro__NullType__std__string____(const std::shared_ptr<Promise<std::variant<nitro::NullType, std::string>>>& value) noexcept {
359
+ return Result<std::shared_ptr<Promise<std::variant<nitro::NullType, std::string>>>>::withValue(value);
360
+ }
361
+ inline Result_std__shared_ptr_Promise_std__variant_nitro__NullType__std__string____ create_Result_std__shared_ptr_Promise_std__variant_nitro__NullType__std__string____(const std::exception_ptr& error) noexcept {
362
+ return Result<std::shared_ptr<Promise<std::variant<nitro::NullType, std::string>>>>::withError(error);
363
+ }
364
+
365
+ // pragma MARK: Result<std::shared_ptr<Promise<std::variant<nitro::NullType, int64_t>>>>
366
+ using Result_std__shared_ptr_Promise_std__variant_nitro__NullType__int64_t____ = Result<std::shared_ptr<Promise<std::variant<nitro::NullType, int64_t>>>>;
367
+ inline Result_std__shared_ptr_Promise_std__variant_nitro__NullType__int64_t____ create_Result_std__shared_ptr_Promise_std__variant_nitro__NullType__int64_t____(const std::shared_ptr<Promise<std::variant<nitro::NullType, int64_t>>>& value) noexcept {
368
+ return Result<std::shared_ptr<Promise<std::variant<nitro::NullType, int64_t>>>>::withValue(value);
369
+ }
370
+ inline Result_std__shared_ptr_Promise_std__variant_nitro__NullType__int64_t____ create_Result_std__shared_ptr_Promise_std__variant_nitro__NullType__int64_t____(const std::exception_ptr& error) noexcept {
371
+ return Result<std::shared_ptr<Promise<std::variant<nitro::NullType, int64_t>>>>::withError(error);
372
+ }
156
373
 
157
374
  } // namespace margelo::nitro::nitrometamask::bridge::swift
@@ -10,17 +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 `ConnectSignResult` to properly resolve imports.
14
+ namespace margelo::nitro::nitrometamask { struct ConnectSignResult; }
13
15
  // Forward declaration of `HybridNitroMetamaskSpec` to properly resolve imports.
14
16
  namespace margelo::nitro::nitrometamask { class HybridNitroMetamaskSpec; }
15
17
 
16
18
  // Include C++ defined types
17
19
  #include "ConnectResult.hpp"
20
+ #include "ConnectSignResult.hpp"
18
21
  #include "HybridNitroMetamaskSpec.hpp"
22
+ #include <NitroModules/Null.hpp>
19
23
  #include <NitroModules/Promise.hpp>
20
24
  #include <NitroModules/Result.hpp>
21
25
  #include <exception>
22
26
  #include <memory>
27
+ #include <optional>
23
28
  #include <string>
29
+ #include <variant>
24
30
 
25
31
  // C++ helpers for Swift
26
32
  #include "NitroMetamask-Swift-Cxx-Bridge.hpp"
@@ -14,10 +14,16 @@ 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
+ // Forward declaration of `ConnectSignResult` to properly resolve imports.
18
+ namespace margelo::nitro::nitrometamask { struct ConnectSignResult; }
17
19
 
20
+ #include <string>
21
+ #include <optional>
18
22
  #include "ConnectResult.hpp"
19
23
  #include <NitroModules/Promise.hpp>
20
- #include <string>
24
+ #include "ConnectSignResult.hpp"
25
+ #include <NitroModules/Null.hpp>
26
+ #include <variant>
21
27
 
22
28
  #include "NitroMetamask-Swift-Cxx-Umbrella.hpp"
23
29
 
@@ -63,6 +69,12 @@ namespace margelo::nitro::nitrometamask {
63
69
 
64
70
  public:
65
71
  // Methods
72
+ inline void configure(const std::optional<std::string>& dappUrl, const std::optional<std::string>& deepLinkScheme) override {
73
+ auto __result = _swiftPart.configure(dappUrl, deepLinkScheme);
74
+ if (__result.hasError()) [[unlikely]] {
75
+ std::rethrow_exception(__result.error());
76
+ }
77
+ }
66
78
  inline std::shared_ptr<Promise<ConnectResult>> connect() override {
67
79
  auto __result = _swiftPart.connect();
68
80
  if (__result.hasError()) [[unlikely]] {
@@ -79,6 +91,30 @@ namespace margelo::nitro::nitrometamask {
79
91
  auto __value = std::move(__result.value());
80
92
  return __value;
81
93
  }
94
+ inline std::shared_ptr<Promise<ConnectSignResult>> connectSign(const std::string& nonce, int64_t exp) override {
95
+ auto __result = _swiftPart.connectSign(nonce, std::forward<decltype(exp)>(exp));
96
+ if (__result.hasError()) [[unlikely]] {
97
+ std::rethrow_exception(__result.error());
98
+ }
99
+ auto __value = std::move(__result.value());
100
+ return __value;
101
+ }
102
+ inline std::shared_ptr<Promise<std::variant<nitro::NullType, std::string>>> getAddress() override {
103
+ auto __result = _swiftPart.getAddress();
104
+ if (__result.hasError()) [[unlikely]] {
105
+ std::rethrow_exception(__result.error());
106
+ }
107
+ auto __value = std::move(__result.value());
108
+ return __value;
109
+ }
110
+ inline std::shared_ptr<Promise<std::variant<nitro::NullType, int64_t>>> getChainId() override {
111
+ auto __result = _swiftPart.getChainId();
112
+ if (__result.hasError()) [[unlikely]] {
113
+ std::rethrow_exception(__result.error());
114
+ }
115
+ auto __value = std::move(__result.value());
116
+ return __value;
117
+ }
82
118
 
83
119
  private:
84
120
  NitroMetamask::HybridNitroMetamaskSpec_cxx _swiftPart;