@novastera-oss/nitro-metamask 0.3.3 → 0.4.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.
- package/README.md +73 -12
- package/android/src/main/java/com/margelo/nitro/nitrometamask/HybridNitroMetamask.kt +349 -175
- package/app.plugin.js +121 -0
- package/ios/HybridNitroMetamask.swift +71 -110
- package/lib/typescript/src/specs/nitro-metamask.nitro.d.ts +31 -6
- package/lib/typescript/src/specs/nitro-metamask.nitro.d.ts.map +1 -1
- package/nitrogen/generated/android/NitroMetamask+autolinking.cmake +2 -0
- package/nitrogen/generated/android/c++/JConnectResult.hpp +3 -3
- package/nitrogen/generated/android/c++/JConnectSignResult.hpp +65 -0
- package/nitrogen/generated/android/c++/JHybridNitroMetamaskSpec.cpp +48 -7
- package/nitrogen/generated/android/c++/JHybridNitroMetamaskSpec.hpp +4 -2
- package/nitrogen/generated/android/c++/JVariant_NullType_Long.cpp +26 -0
- package/nitrogen/generated/android/c++/JVariant_NullType_Long.hpp +69 -0
- package/nitrogen/generated/android/c++/JVariant_NullType_String.cpp +26 -0
- package/nitrogen/generated/android/c++/JVariant_NullType_String.hpp +70 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrometamask/ConnectResult.kt +2 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrometamask/ConnectSignResult.kt +44 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrometamask/HybridNitroMetamaskSpec.kt +11 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrometamask/Variant_NullType_Long.kt +59 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrometamask/Variant_NullType_String.kt +59 -0
- package/nitrogen/generated/ios/NitroMetamask-Swift-Cxx-Bridge.cpp +24 -0
- package/nitrogen/generated/ios/NitroMetamask-Swift-Cxx-Bridge.hpp +192 -0
- package/nitrogen/generated/ios/NitroMetamask-Swift-Cxx-Umbrella.hpp +5 -0
- package/nitrogen/generated/ios/c++/HybridNitroMetamaskSpecSwift.hpp +24 -3
- package/nitrogen/generated/ios/swift/ConnectResult.swift +2 -2
- package/nitrogen/generated/ios/swift/ConnectSignResult.swift +40 -0
- package/nitrogen/generated/ios/swift/Func_void_ConnectSignResult.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_std__variant_nitro__NullType__int64_t_.swift +59 -0
- package/nitrogen/generated/ios/swift/Func_void_std__variant_nitro__NullType__std__string_.swift +59 -0
- package/nitrogen/generated/ios/swift/HybridNitroMetamaskSpec.swift +4 -2
- package/nitrogen/generated/ios/swift/HybridNitroMetamaskSpec_cxx.swift +67 -8
- package/nitrogen/generated/ios/swift/Variant_NullType_Int64.swift +18 -0
- package/nitrogen/generated/ios/swift/Variant_NullType_String.swift +18 -0
- package/nitrogen/generated/shared/c++/ConnectResult.hpp +5 -5
- package/nitrogen/generated/shared/c++/ConnectSignResult.hpp +91 -0
- package/nitrogen/generated/shared/c++/HybridNitroMetamaskSpec.cpp +2 -0
- package/nitrogen/generated/shared/c++/HybridNitroMetamaskSpec.hpp +9 -2
- package/package.json +18 -4
- package/src/specs/nitro-metamask.nitro.ts +32 -6
|
@@ -14,11 +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
|
|
|
18
20
|
#include <string>
|
|
19
21
|
#include <optional>
|
|
20
22
|
#include "ConnectResult.hpp"
|
|
21
23
|
#include <NitroModules/Promise.hpp>
|
|
24
|
+
#include "ConnectSignResult.hpp"
|
|
25
|
+
#include <NitroModules/Null.hpp>
|
|
26
|
+
#include <variant>
|
|
22
27
|
|
|
23
28
|
#include "NitroMetamask-Swift-Cxx-Umbrella.hpp"
|
|
24
29
|
|
|
@@ -64,8 +69,8 @@ namespace margelo::nitro::nitrometamask {
|
|
|
64
69
|
|
|
65
70
|
public:
|
|
66
71
|
// Methods
|
|
67
|
-
inline void configure(const std::optional<std::string>& dappUrl) override {
|
|
68
|
-
auto __result = _swiftPart.configure(dappUrl);
|
|
72
|
+
inline void configure(const std::optional<std::string>& dappUrl, const std::optional<std::string>& deepLinkScheme) override {
|
|
73
|
+
auto __result = _swiftPart.configure(dappUrl, deepLinkScheme);
|
|
69
74
|
if (__result.hasError()) [[unlikely]] {
|
|
70
75
|
std::rethrow_exception(__result.error());
|
|
71
76
|
}
|
|
@@ -86,7 +91,7 @@ namespace margelo::nitro::nitrometamask {
|
|
|
86
91
|
auto __value = std::move(__result.value());
|
|
87
92
|
return __value;
|
|
88
93
|
}
|
|
89
|
-
inline std::shared_ptr<Promise<
|
|
94
|
+
inline std::shared_ptr<Promise<ConnectSignResult>> connectSign(const std::string& nonce, int64_t exp) override {
|
|
90
95
|
auto __result = _swiftPart.connectSign(nonce, std::forward<decltype(exp)>(exp));
|
|
91
96
|
if (__result.hasError()) [[unlikely]] {
|
|
92
97
|
std::rethrow_exception(__result.error());
|
|
@@ -94,6 +99,22 @@ namespace margelo::nitro::nitrometamask {
|
|
|
94
99
|
auto __value = std::move(__result.value());
|
|
95
100
|
return __value;
|
|
96
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
|
+
}
|
|
97
118
|
|
|
98
119
|
private:
|
|
99
120
|
NitroMetamask::HybridNitroMetamaskSpec_cxx _swiftPart;
|
|
@@ -19,7 +19,7 @@ public extension ConnectResult {
|
|
|
19
19
|
/**
|
|
20
20
|
* Create a new instance of `ConnectResult`.
|
|
21
21
|
*/
|
|
22
|
-
init(address: String, chainId:
|
|
22
|
+
init(address: String, chainId: Int64) {
|
|
23
23
|
self.init(std.string(address), chainId)
|
|
24
24
|
}
|
|
25
25
|
|
|
@@ -29,7 +29,7 @@ public extension ConnectResult {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
@inline(__always)
|
|
32
|
-
var chainId:
|
|
32
|
+
var chainId: Int64 {
|
|
33
33
|
return self.__chainId
|
|
34
34
|
}
|
|
35
35
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// ConnectSignResult.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
|
+
/**
|
|
12
|
+
* Represents an instance of `ConnectSignResult`, backed by a C++ struct.
|
|
13
|
+
*/
|
|
14
|
+
public typealias ConnectSignResult = margelo.nitro.nitrometamask.ConnectSignResult
|
|
15
|
+
|
|
16
|
+
public extension ConnectSignResult {
|
|
17
|
+
private typealias bridge = margelo.nitro.nitrometamask.bridge.swift
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Create a new instance of `ConnectSignResult`.
|
|
21
|
+
*/
|
|
22
|
+
init(signature: String, address: String, chainId: Int64) {
|
|
23
|
+
self.init(std.string(signature), std.string(address), chainId)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@inline(__always)
|
|
27
|
+
var signature: String {
|
|
28
|
+
return String(self.__signature)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@inline(__always)
|
|
32
|
+
var address: String {
|
|
33
|
+
return String(self.__address)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@inline(__always)
|
|
37
|
+
var chainId: Int64 {
|
|
38
|
+
return self.__chainId
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void_ConnectSignResult.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
|
+
/**
|
|
12
|
+
* Wraps a Swift `(_ value: ConnectSignResult) -> Void` as a class.
|
|
13
|
+
* This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
|
|
14
|
+
*/
|
|
15
|
+
public final class Func_void_ConnectSignResult {
|
|
16
|
+
public typealias bridge = margelo.nitro.nitrometamask.bridge.swift
|
|
17
|
+
|
|
18
|
+
private let closure: (_ value: ConnectSignResult) -> Void
|
|
19
|
+
|
|
20
|
+
public init(_ closure: @escaping (_ value: ConnectSignResult) -> Void) {
|
|
21
|
+
self.closure = closure
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@inline(__always)
|
|
25
|
+
public func call(value: ConnectSignResult) -> Void {
|
|
26
|
+
self.closure(value)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
31
|
+
* This acquires one additional strong reference on the object!
|
|
32
|
+
*/
|
|
33
|
+
@inline(__always)
|
|
34
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
35
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Casts an unsafe pointer to a `Func_void_ConnectSignResult`.
|
|
40
|
+
* The pointer has to be a retained opaque `Unmanaged<Func_void_ConnectSignResult>`.
|
|
41
|
+
* This removes one strong reference from the object!
|
|
42
|
+
*/
|
|
43
|
+
@inline(__always)
|
|
44
|
+
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_ConnectSignResult {
|
|
45
|
+
return Unmanaged<Func_void_ConnectSignResult>.fromOpaque(pointer).takeRetainedValue()
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void_std__variant_nitro__NullType__int64_t_.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
|
+
/**
|
|
12
|
+
* Wraps a Swift `(_ value: Variant_NullType_Int64) -> Void` as a class.
|
|
13
|
+
* This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
|
|
14
|
+
*/
|
|
15
|
+
public final class Func_void_std__variant_nitro__NullType__int64_t_ {
|
|
16
|
+
public typealias bridge = margelo.nitro.nitrometamask.bridge.swift
|
|
17
|
+
|
|
18
|
+
private let closure: (_ value: Variant_NullType_Int64) -> Void
|
|
19
|
+
|
|
20
|
+
public init(_ closure: @escaping (_ value: Variant_NullType_Int64) -> Void) {
|
|
21
|
+
self.closure = closure
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@inline(__always)
|
|
25
|
+
public func call(value: bridge.std__variant_nitro__NullType__int64_t_) -> Void {
|
|
26
|
+
self.closure({ () -> Variant_NullType_Int64 in
|
|
27
|
+
let __variant = value
|
|
28
|
+
switch __variant.index() {
|
|
29
|
+
case 0:
|
|
30
|
+
let __actual = __variant.get_0()
|
|
31
|
+
return .first(NullType.null)
|
|
32
|
+
case 1:
|
|
33
|
+
let __actual = __variant.get_1()
|
|
34
|
+
return .second(__actual)
|
|
35
|
+
default:
|
|
36
|
+
fatalError("Variant can never have index \(__variant.index())!")
|
|
37
|
+
}
|
|
38
|
+
}())
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
43
|
+
* This acquires one additional strong reference on the object!
|
|
44
|
+
*/
|
|
45
|
+
@inline(__always)
|
|
46
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
47
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Casts an unsafe pointer to a `Func_void_std__variant_nitro__NullType__int64_t_`.
|
|
52
|
+
* The pointer has to be a retained opaque `Unmanaged<Func_void_std__variant_nitro__NullType__int64_t_>`.
|
|
53
|
+
* This removes one strong reference from the object!
|
|
54
|
+
*/
|
|
55
|
+
@inline(__always)
|
|
56
|
+
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__variant_nitro__NullType__int64_t_ {
|
|
57
|
+
return Unmanaged<Func_void_std__variant_nitro__NullType__int64_t_>.fromOpaque(pointer).takeRetainedValue()
|
|
58
|
+
}
|
|
59
|
+
}
|
package/nitrogen/generated/ios/swift/Func_void_std__variant_nitro__NullType__std__string_.swift
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void_std__variant_nitro__NullType__std__string_.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
|
+
/**
|
|
12
|
+
* Wraps a Swift `(_ value: Variant_NullType_String) -> Void` as a class.
|
|
13
|
+
* This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
|
|
14
|
+
*/
|
|
15
|
+
public final class Func_void_std__variant_nitro__NullType__std__string_ {
|
|
16
|
+
public typealias bridge = margelo.nitro.nitrometamask.bridge.swift
|
|
17
|
+
|
|
18
|
+
private let closure: (_ value: Variant_NullType_String) -> Void
|
|
19
|
+
|
|
20
|
+
public init(_ closure: @escaping (_ value: Variant_NullType_String) -> Void) {
|
|
21
|
+
self.closure = closure
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@inline(__always)
|
|
25
|
+
public func call(value: bridge.std__variant_nitro__NullType__std__string_) -> Void {
|
|
26
|
+
self.closure({ () -> Variant_NullType_String in
|
|
27
|
+
let __variant = value
|
|
28
|
+
switch __variant.index() {
|
|
29
|
+
case 0:
|
|
30
|
+
let __actual = __variant.get_0()
|
|
31
|
+
return .first(NullType.null)
|
|
32
|
+
case 1:
|
|
33
|
+
let __actual = __variant.get_1()
|
|
34
|
+
return .second(String(__actual))
|
|
35
|
+
default:
|
|
36
|
+
fatalError("Variant can never have index \(__variant.index())!")
|
|
37
|
+
}
|
|
38
|
+
}())
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
43
|
+
* This acquires one additional strong reference on the object!
|
|
44
|
+
*/
|
|
45
|
+
@inline(__always)
|
|
46
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
47
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Casts an unsafe pointer to a `Func_void_std__variant_nitro__NullType__std__string_`.
|
|
52
|
+
* The pointer has to be a retained opaque `Unmanaged<Func_void_std__variant_nitro__NullType__std__string_>`.
|
|
53
|
+
* This removes one strong reference from the object!
|
|
54
|
+
*/
|
|
55
|
+
@inline(__always)
|
|
56
|
+
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__variant_nitro__NullType__std__string_ {
|
|
57
|
+
return Unmanaged<Func_void_std__variant_nitro__NullType__std__string_>.fromOpaque(pointer).takeRetainedValue()
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -14,10 +14,12 @@ public protocol HybridNitroMetamaskSpec_protocol: HybridObject {
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
// Methods
|
|
17
|
-
func configure(dappUrl: String?) throws -> Void
|
|
17
|
+
func configure(dappUrl: String?, deepLinkScheme: String?) throws -> Void
|
|
18
18
|
func connect() throws -> Promise<ConnectResult>
|
|
19
19
|
func signMessage(message: String) throws -> Promise<String>
|
|
20
|
-
func connectSign(nonce: String, exp: Int64) throws -> Promise<
|
|
20
|
+
func connectSign(nonce: String, exp: Int64) throws -> Promise<ConnectSignResult>
|
|
21
|
+
func getAddress() throws -> Promise<Variant_NullType_String>
|
|
22
|
+
func getChainId() throws -> Promise<Variant_NullType_Int64>
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
public extension HybridNitroMetamaskSpec_protocol {
|
|
@@ -118,7 +118,7 @@ open class HybridNitroMetamaskSpec_cxx {
|
|
|
118
118
|
|
|
119
119
|
// Methods
|
|
120
120
|
@inline(__always)
|
|
121
|
-
public final func configure(dappUrl: bridge.std__optional_std__string_) -> bridge.Result_void_ {
|
|
121
|
+
public final func configure(dappUrl: bridge.std__optional_std__string_, deepLinkScheme: bridge.std__optional_std__string_) -> bridge.Result_void_ {
|
|
122
122
|
do {
|
|
123
123
|
try self.__implementation.configure(dappUrl: { () -> String? in
|
|
124
124
|
if bridge.has_value_std__optional_std__string_(dappUrl) {
|
|
@@ -127,6 +127,13 @@ open class HybridNitroMetamaskSpec_cxx {
|
|
|
127
127
|
} else {
|
|
128
128
|
return nil
|
|
129
129
|
}
|
|
130
|
+
}(), deepLinkScheme: { () -> String? in
|
|
131
|
+
if bridge.has_value_std__optional_std__string_(deepLinkScheme) {
|
|
132
|
+
let __unwrapped = bridge.get_std__optional_std__string_(deepLinkScheme)
|
|
133
|
+
return String(__unwrapped)
|
|
134
|
+
} else {
|
|
135
|
+
return nil
|
|
136
|
+
}
|
|
130
137
|
}())
|
|
131
138
|
return bridge.create_Result_void_()
|
|
132
139
|
} catch (let __error) {
|
|
@@ -174,21 +181,73 @@ open class HybridNitroMetamaskSpec_cxx {
|
|
|
174
181
|
}
|
|
175
182
|
|
|
176
183
|
@inline(__always)
|
|
177
|
-
public final func connectSign(nonce: std.string, exp: Int64) -> bridge.
|
|
184
|
+
public final func connectSign(nonce: std.string, exp: Int64) -> bridge.Result_std__shared_ptr_Promise_ConnectSignResult___ {
|
|
178
185
|
do {
|
|
179
186
|
let __result = try self.__implementation.connectSign(nonce: String(nonce), exp: exp)
|
|
180
|
-
let __resultCpp = { () -> bridge.
|
|
181
|
-
let __promise = bridge.
|
|
182
|
-
let __promiseHolder = bridge.
|
|
187
|
+
let __resultCpp = { () -> bridge.std__shared_ptr_Promise_ConnectSignResult__ in
|
|
188
|
+
let __promise = bridge.create_std__shared_ptr_Promise_ConnectSignResult__()
|
|
189
|
+
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_ConnectSignResult__(__promise)
|
|
183
190
|
__result
|
|
184
|
-
.then({ __result in __promiseHolder.resolve(
|
|
191
|
+
.then({ __result in __promiseHolder.resolve(__result) })
|
|
185
192
|
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
186
193
|
return __promise
|
|
187
194
|
}()
|
|
188
|
-
return bridge.
|
|
195
|
+
return bridge.create_Result_std__shared_ptr_Promise_ConnectSignResult___(__resultCpp)
|
|
189
196
|
} catch (let __error) {
|
|
190
197
|
let __exceptionPtr = __error.toCpp()
|
|
191
|
-
return bridge.
|
|
198
|
+
return bridge.create_Result_std__shared_ptr_Promise_ConnectSignResult___(__exceptionPtr)
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
@inline(__always)
|
|
203
|
+
public final func getAddress() -> bridge.Result_std__shared_ptr_Promise_std__variant_nitro__NullType__std__string____ {
|
|
204
|
+
do {
|
|
205
|
+
let __result = try self.__implementation.getAddress()
|
|
206
|
+
let __resultCpp = { () -> bridge.std__shared_ptr_Promise_std__variant_nitro__NullType__std__string___ in
|
|
207
|
+
let __promise = bridge.create_std__shared_ptr_Promise_std__variant_nitro__NullType__std__string___()
|
|
208
|
+
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_std__variant_nitro__NullType__std__string___(__promise)
|
|
209
|
+
__result
|
|
210
|
+
.then({ __result in __promiseHolder.resolve({ () -> bridge.std__variant_nitro__NullType__std__string_ in
|
|
211
|
+
switch __result {
|
|
212
|
+
case .first(let __value):
|
|
213
|
+
return bridge.create_std__variant_nitro__NullType__std__string_(margelo.nitro.NullType.null)
|
|
214
|
+
case .second(let __value):
|
|
215
|
+
return bridge.create_std__variant_nitro__NullType__std__string_(std.string(__value))
|
|
216
|
+
}
|
|
217
|
+
}().variant) })
|
|
218
|
+
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
219
|
+
return __promise
|
|
220
|
+
}()
|
|
221
|
+
return bridge.create_Result_std__shared_ptr_Promise_std__variant_nitro__NullType__std__string____(__resultCpp)
|
|
222
|
+
} catch (let __error) {
|
|
223
|
+
let __exceptionPtr = __error.toCpp()
|
|
224
|
+
return bridge.create_Result_std__shared_ptr_Promise_std__variant_nitro__NullType__std__string____(__exceptionPtr)
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
@inline(__always)
|
|
229
|
+
public final func getChainId() -> bridge.Result_std__shared_ptr_Promise_std__variant_nitro__NullType__int64_t____ {
|
|
230
|
+
do {
|
|
231
|
+
let __result = try self.__implementation.getChainId()
|
|
232
|
+
let __resultCpp = { () -> bridge.std__shared_ptr_Promise_std__variant_nitro__NullType__int64_t___ in
|
|
233
|
+
let __promise = bridge.create_std__shared_ptr_Promise_std__variant_nitro__NullType__int64_t___()
|
|
234
|
+
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_std__variant_nitro__NullType__int64_t___(__promise)
|
|
235
|
+
__result
|
|
236
|
+
.then({ __result in __promiseHolder.resolve({ () -> bridge.std__variant_nitro__NullType__int64_t_ in
|
|
237
|
+
switch __result {
|
|
238
|
+
case .first(let __value):
|
|
239
|
+
return bridge.create_std__variant_nitro__NullType__int64_t_(margelo.nitro.NullType.null)
|
|
240
|
+
case .second(let __value):
|
|
241
|
+
return bridge.create_std__variant_nitro__NullType__int64_t_(__value)
|
|
242
|
+
}
|
|
243
|
+
}().variant) })
|
|
244
|
+
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
245
|
+
return __promise
|
|
246
|
+
}()
|
|
247
|
+
return bridge.create_Result_std__shared_ptr_Promise_std__variant_nitro__NullType__int64_t____(__resultCpp)
|
|
248
|
+
} catch (let __error) {
|
|
249
|
+
let __exceptionPtr = __error.toCpp()
|
|
250
|
+
return bridge.create_Result_std__shared_ptr_Promise_std__variant_nitro__NullType__int64_t____(__exceptionPtr)
|
|
192
251
|
}
|
|
193
252
|
}
|
|
194
253
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Variant_NullType_Int64.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 NitroModules
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* An Swift enum with associated values representing a Variant/Union type.
|
|
12
|
+
* JS type: `null | bigint`
|
|
13
|
+
*/
|
|
14
|
+
@frozen
|
|
15
|
+
public enum Variant_NullType_Int64 {
|
|
16
|
+
case first(NullType)
|
|
17
|
+
case second(Int64)
|
|
18
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Variant_NullType_String.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 NitroModules
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* An Swift enum with associated values representing a Variant/Union type.
|
|
12
|
+
* JS type: `null | string`
|
|
13
|
+
*/
|
|
14
|
+
@frozen
|
|
15
|
+
public enum Variant_NullType_String {
|
|
16
|
+
case first(NullType)
|
|
17
|
+
case second(String)
|
|
18
|
+
}
|
|
@@ -40,11 +40,11 @@ namespace margelo::nitro::nitrometamask {
|
|
|
40
40
|
struct ConnectResult final {
|
|
41
41
|
public:
|
|
42
42
|
std::string address SWIFT_PRIVATE;
|
|
43
|
-
|
|
43
|
+
int64_t chainId SWIFT_PRIVATE;
|
|
44
44
|
|
|
45
45
|
public:
|
|
46
46
|
ConnectResult() = default;
|
|
47
|
-
explicit ConnectResult(std::string address,
|
|
47
|
+
explicit ConnectResult(std::string address, int64_t chainId): address(address), chainId(chainId) {}
|
|
48
48
|
|
|
49
49
|
public:
|
|
50
50
|
friend bool operator==(const ConnectResult& lhs, const ConnectResult& rhs) = default;
|
|
@@ -61,13 +61,13 @@ namespace margelo::nitro {
|
|
|
61
61
|
jsi::Object obj = arg.asObject(runtime);
|
|
62
62
|
return margelo::nitro::nitrometamask::ConnectResult(
|
|
63
63
|
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "address"))),
|
|
64
|
-
JSIConverter<
|
|
64
|
+
JSIConverter<int64_t>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "chainId")))
|
|
65
65
|
);
|
|
66
66
|
}
|
|
67
67
|
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::nitrometamask::ConnectResult& arg) {
|
|
68
68
|
jsi::Object obj(runtime);
|
|
69
69
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "address"), JSIConverter<std::string>::toJSI(runtime, arg.address));
|
|
70
|
-
obj.setProperty(runtime, PropNameIDCache::get(runtime, "chainId"), JSIConverter<
|
|
70
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "chainId"), JSIConverter<int64_t>::toJSI(runtime, arg.chainId));
|
|
71
71
|
return obj;
|
|
72
72
|
}
|
|
73
73
|
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
@@ -79,7 +79,7 @@ namespace margelo::nitro {
|
|
|
79
79
|
return false;
|
|
80
80
|
}
|
|
81
81
|
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "address")))) return false;
|
|
82
|
-
if (!JSIConverter<
|
|
82
|
+
if (!JSIConverter<int64_t>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "chainId")))) return false;
|
|
83
83
|
return true;
|
|
84
84
|
}
|
|
85
85
|
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// ConnectSignResult.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
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
11
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
16
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
#if __has_include(<NitroModules/JSIHelpers.hpp>)
|
|
21
|
+
#include <NitroModules/JSIHelpers.hpp>
|
|
22
|
+
#else
|
|
23
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
+
#endif
|
|
25
|
+
#if __has_include(<NitroModules/PropNameIDCache.hpp>)
|
|
26
|
+
#include <NitroModules/PropNameIDCache.hpp>
|
|
27
|
+
#else
|
|
28
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
29
|
+
#endif
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
#include <string>
|
|
34
|
+
|
|
35
|
+
namespace margelo::nitro::nitrometamask {
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* A struct which can be represented as a JavaScript object (ConnectSignResult).
|
|
39
|
+
*/
|
|
40
|
+
struct ConnectSignResult final {
|
|
41
|
+
public:
|
|
42
|
+
std::string signature SWIFT_PRIVATE;
|
|
43
|
+
std::string address SWIFT_PRIVATE;
|
|
44
|
+
int64_t chainId SWIFT_PRIVATE;
|
|
45
|
+
|
|
46
|
+
public:
|
|
47
|
+
ConnectSignResult() = default;
|
|
48
|
+
explicit ConnectSignResult(std::string signature, std::string address, int64_t chainId): signature(signature), address(address), chainId(chainId) {}
|
|
49
|
+
|
|
50
|
+
public:
|
|
51
|
+
friend bool operator==(const ConnectSignResult& lhs, const ConnectSignResult& rhs) = default;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
} // namespace margelo::nitro::nitrometamask
|
|
55
|
+
|
|
56
|
+
namespace margelo::nitro {
|
|
57
|
+
|
|
58
|
+
// C++ ConnectSignResult <> JS ConnectSignResult (object)
|
|
59
|
+
template <>
|
|
60
|
+
struct JSIConverter<margelo::nitro::nitrometamask::ConnectSignResult> final {
|
|
61
|
+
static inline margelo::nitro::nitrometamask::ConnectSignResult fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
62
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
63
|
+
return margelo::nitro::nitrometamask::ConnectSignResult(
|
|
64
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "signature"))),
|
|
65
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "address"))),
|
|
66
|
+
JSIConverter<int64_t>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "chainId")))
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::nitrometamask::ConnectSignResult& arg) {
|
|
70
|
+
jsi::Object obj(runtime);
|
|
71
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "signature"), JSIConverter<std::string>::toJSI(runtime, arg.signature));
|
|
72
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "address"), JSIConverter<std::string>::toJSI(runtime, arg.address));
|
|
73
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "chainId"), JSIConverter<int64_t>::toJSI(runtime, arg.chainId));
|
|
74
|
+
return obj;
|
|
75
|
+
}
|
|
76
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
77
|
+
if (!value.isObject()) {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
jsi::Object obj = value.getObject(runtime);
|
|
81
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "signature")))) return false;
|
|
85
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "address")))) return false;
|
|
86
|
+
if (!JSIConverter<int64_t>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "chainId")))) return false;
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
} // namespace margelo::nitro
|
|
@@ -18,6 +18,8 @@ namespace margelo::nitro::nitrometamask {
|
|
|
18
18
|
prototype.registerHybridMethod("connect", &HybridNitroMetamaskSpec::connect);
|
|
19
19
|
prototype.registerHybridMethod("signMessage", &HybridNitroMetamaskSpec::signMessage);
|
|
20
20
|
prototype.registerHybridMethod("connectSign", &HybridNitroMetamaskSpec::connectSign);
|
|
21
|
+
prototype.registerHybridMethod("getAddress", &HybridNitroMetamaskSpec::getAddress);
|
|
22
|
+
prototype.registerHybridMethod("getChainId", &HybridNitroMetamaskSpec::getChainId);
|
|
21
23
|
});
|
|
22
24
|
}
|
|
23
25
|
|
|
@@ -15,11 +15,16 @@
|
|
|
15
15
|
|
|
16
16
|
// Forward declaration of `ConnectResult` to properly resolve imports.
|
|
17
17
|
namespace margelo::nitro::nitrometamask { struct ConnectResult; }
|
|
18
|
+
// Forward declaration of `ConnectSignResult` to properly resolve imports.
|
|
19
|
+
namespace margelo::nitro::nitrometamask { struct ConnectSignResult; }
|
|
18
20
|
|
|
19
21
|
#include <string>
|
|
20
22
|
#include <optional>
|
|
21
23
|
#include "ConnectResult.hpp"
|
|
22
24
|
#include <NitroModules/Promise.hpp>
|
|
25
|
+
#include "ConnectSignResult.hpp"
|
|
26
|
+
#include <NitroModules/Null.hpp>
|
|
27
|
+
#include <variant>
|
|
23
28
|
|
|
24
29
|
namespace margelo::nitro::nitrometamask {
|
|
25
30
|
|
|
@@ -52,10 +57,12 @@ namespace margelo::nitro::nitrometamask {
|
|
|
52
57
|
|
|
53
58
|
public:
|
|
54
59
|
// Methods
|
|
55
|
-
virtual void configure(const std::optional<std::string>& dappUrl) = 0;
|
|
60
|
+
virtual void configure(const std::optional<std::string>& dappUrl, const std::optional<std::string>& deepLinkScheme) = 0;
|
|
56
61
|
virtual std::shared_ptr<Promise<ConnectResult>> connect() = 0;
|
|
57
62
|
virtual std::shared_ptr<Promise<std::string>> signMessage(const std::string& message) = 0;
|
|
58
|
-
virtual std::shared_ptr<Promise<
|
|
63
|
+
virtual std::shared_ptr<Promise<ConnectSignResult>> connectSign(const std::string& nonce, int64_t exp) = 0;
|
|
64
|
+
virtual std::shared_ptr<Promise<std::variant<nitro::NullType, std::string>>> getAddress() = 0;
|
|
65
|
+
virtual std::shared_ptr<Promise<std::variant<nitro::NullType, int64_t>>> getChainId() = 0;
|
|
59
66
|
|
|
60
67
|
protected:
|
|
61
68
|
// Hybrid Setup
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@novastera-oss/nitro-metamask",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Novastera
|
|
3
|
+
"version": "0.4.2",
|
|
4
|
+
"description": "Native mobile MetaMask wallet integration for React Native. Part of Novastera CRM/ERP platform ecosystem. Provides secure authentication and message signing for Web3 mobile applications.",
|
|
5
5
|
"main": "./lib/commonjs/index.js",
|
|
6
6
|
"module": "./lib/module/index.js",
|
|
7
7
|
"types": "./lib/typescript/src/index.d.ts",
|
|
@@ -18,7 +18,20 @@
|
|
|
18
18
|
"react-native",
|
|
19
19
|
"@novastera-oss/nitro-metamask",
|
|
20
20
|
"metamask",
|
|
21
|
-
"novastera"
|
|
21
|
+
"novastera",
|
|
22
|
+
"crm",
|
|
23
|
+
"erp",
|
|
24
|
+
"web3",
|
|
25
|
+
"blockchain",
|
|
26
|
+
"ethereum",
|
|
27
|
+
"wallet",
|
|
28
|
+
"mobile",
|
|
29
|
+
"ios",
|
|
30
|
+
"android",
|
|
31
|
+
"nitro-modules",
|
|
32
|
+
"authentication",
|
|
33
|
+
"crypto",
|
|
34
|
+
"defi"
|
|
22
35
|
],
|
|
23
36
|
"files": [
|
|
24
37
|
"src",
|
|
@@ -71,7 +84,8 @@
|
|
|
71
84
|
"peerDependencies": {
|
|
72
85
|
"react": "*",
|
|
73
86
|
"react-native": "*",
|
|
74
|
-
"react-native-nitro-modules": "*"
|
|
87
|
+
"react-native-nitro-modules": "*",
|
|
88
|
+
"@expo/config-plugins": "*"
|
|
75
89
|
},
|
|
76
90
|
"eslintConfig": {
|
|
77
91
|
"root": true,
|