@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.
- package/README.md +124 -0
- package/android/build.gradle +2 -2
- package/android/src/main/java/com/margelo/nitro/nitrometamask/HybridNitroMetamask.kt +583 -0
- package/android/src/main/java/com/{nitrometamask → margelo/nitro/nitrometamask}/MetamaskContextHolder.kt +1 -1
- package/android/src/main/java/com/{nitrometamask → margelo/nitro/nitrometamask}/NitroMetamaskPackage.kt +1 -1
- package/app.plugin.js +121 -0
- package/ios/HybridNitroMetamask.swift +107 -1
- package/lib/typescript/src/specs/nitro-metamask.nitro.d.ts +36 -1
- 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 +62 -0
- package/nitrogen/generated/android/c++/JHybridNitroMetamaskSpec.hpp +4 -0
- 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 +17 -0
- 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 +217 -0
- package/nitrogen/generated/ios/NitroMetamask-Swift-Cxx-Umbrella.hpp +6 -0
- package/nitrogen/generated/ios/c++/HybridNitroMetamaskSpecSwift.hpp +37 -1
- 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 -0
- package/nitrogen/generated/ios/swift/HybridNitroMetamaskSpec_cxx.swift +96 -0
- 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 +4 -0
- package/nitrogen/generated/shared/c++/HybridNitroMetamaskSpec.hpp +11 -1
- package/package.json +4 -3
- package/react-native.config.js +1 -1
- package/src/specs/nitro-metamask.nitro.ts +37 -1
- package/android/src/main/java/com/nitrometamask/HybridNitroMetamask.kt +0 -146
|
@@ -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,8 +14,12 @@ public protocol HybridNitroMetamaskSpec_protocol: HybridObject {
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
// Methods
|
|
17
|
+
func configure(dappUrl: String?, deepLinkScheme: String?) throws -> Void
|
|
17
18
|
func connect() throws -> Promise<ConnectResult>
|
|
18
19
|
func signMessage(message: String) throws -> Promise<String>
|
|
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>
|
|
19
23
|
}
|
|
20
24
|
|
|
21
25
|
public extension HybridNitroMetamaskSpec_protocol {
|
|
@@ -117,6 +117,31 @@ open class HybridNitroMetamaskSpec_cxx {
|
|
|
117
117
|
|
|
118
118
|
|
|
119
119
|
// Methods
|
|
120
|
+
@inline(__always)
|
|
121
|
+
public final func configure(dappUrl: bridge.std__optional_std__string_, deepLinkScheme: 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
|
+
}(), 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
|
+
}
|
|
137
|
+
}())
|
|
138
|
+
return bridge.create_Result_void_()
|
|
139
|
+
} catch (let __error) {
|
|
140
|
+
let __exceptionPtr = __error.toCpp()
|
|
141
|
+
return bridge.create_Result_void_(__exceptionPtr)
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
120
145
|
@inline(__always)
|
|
121
146
|
public final func connect() -> bridge.Result_std__shared_ptr_Promise_ConnectResult___ {
|
|
122
147
|
do {
|
|
@@ -154,4 +179,75 @@ open class HybridNitroMetamaskSpec_cxx {
|
|
|
154
179
|
return bridge.create_Result_std__shared_ptr_Promise_std__string___(__exceptionPtr)
|
|
155
180
|
}
|
|
156
181
|
}
|
|
182
|
+
|
|
183
|
+
@inline(__always)
|
|
184
|
+
public final func connectSign(nonce: std.string, exp: Int64) -> bridge.Result_std__shared_ptr_Promise_ConnectSignResult___ {
|
|
185
|
+
do {
|
|
186
|
+
let __result = try self.__implementation.connectSign(nonce: String(nonce), exp: exp)
|
|
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)
|
|
190
|
+
__result
|
|
191
|
+
.then({ __result in __promiseHolder.resolve(__result) })
|
|
192
|
+
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
193
|
+
return __promise
|
|
194
|
+
}()
|
|
195
|
+
return bridge.create_Result_std__shared_ptr_Promise_ConnectSignResult___(__resultCpp)
|
|
196
|
+
} catch (let __error) {
|
|
197
|
+
let __exceptionPtr = __error.toCpp()
|
|
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)
|
|
251
|
+
}
|
|
252
|
+
}
|
|
157
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
|
|
@@ -14,8 +14,12 @@ namespace margelo::nitro::nitrometamask {
|
|
|
14
14
|
HybridObject::loadHybridMethods();
|
|
15
15
|
// load custom methods/properties
|
|
16
16
|
registerHybrids(this, [](Prototype& prototype) {
|
|
17
|
+
prototype.registerHybridMethod("configure", &HybridNitroMetamaskSpec::configure);
|
|
17
18
|
prototype.registerHybridMethod("connect", &HybridNitroMetamaskSpec::connect);
|
|
18
19
|
prototype.registerHybridMethod("signMessage", &HybridNitroMetamaskSpec::signMessage);
|
|
20
|
+
prototype.registerHybridMethod("connectSign", &HybridNitroMetamaskSpec::connectSign);
|
|
21
|
+
prototype.registerHybridMethod("getAddress", &HybridNitroMetamaskSpec::getAddress);
|
|
22
|
+
prototype.registerHybridMethod("getChainId", &HybridNitroMetamaskSpec::getChainId);
|
|
19
23
|
});
|
|
20
24
|
}
|
|
21
25
|
|
|
@@ -15,10 +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
|
|
|
21
|
+
#include <string>
|
|
22
|
+
#include <optional>
|
|
19
23
|
#include "ConnectResult.hpp"
|
|
20
24
|
#include <NitroModules/Promise.hpp>
|
|
21
|
-
#include
|
|
25
|
+
#include "ConnectSignResult.hpp"
|
|
26
|
+
#include <NitroModules/Null.hpp>
|
|
27
|
+
#include <variant>
|
|
22
28
|
|
|
23
29
|
namespace margelo::nitro::nitrometamask {
|
|
24
30
|
|
|
@@ -51,8 +57,12 @@ namespace margelo::nitro::nitrometamask {
|
|
|
51
57
|
|
|
52
58
|
public:
|
|
53
59
|
// Methods
|
|
60
|
+
virtual void configure(const std::optional<std::string>& dappUrl, const std::optional<std::string>& deepLinkScheme) = 0;
|
|
54
61
|
virtual std::shared_ptr<Promise<ConnectResult>> connect() = 0;
|
|
55
62
|
virtual std::shared_ptr<Promise<std::string>> signMessage(const std::string& message) = 0;
|
|
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;
|
|
56
66
|
|
|
57
67
|
protected:
|
|
58
68
|
// Hybrid Setup
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@novastera-oss/nitro-metamask",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Novastera metamask authentication with native mobile libraries",
|
|
5
5
|
"main": "./lib/commonjs/index.js",
|
|
6
6
|
"module": "./lib/module/index.js",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"clean": "git clean -dfX",
|
|
13
13
|
"release": "semantic-release",
|
|
14
14
|
"build": "npm run typecheck && bob build",
|
|
15
|
-
"codegen": "nitrogen --logLevel=\"debug\" && npm run build
|
|
15
|
+
"codegen": "nitrogen --logLevel=\"debug\" && npm run build"
|
|
16
16
|
},
|
|
17
17
|
"keywords": [
|
|
18
18
|
"react-native",
|
|
@@ -71,7 +71,8 @@
|
|
|
71
71
|
"peerDependencies": {
|
|
72
72
|
"react": "*",
|
|
73
73
|
"react-native": "*",
|
|
74
|
-
"react-native-nitro-modules": "*"
|
|
74
|
+
"react-native-nitro-modules": "*",
|
|
75
|
+
"@expo/config-plugins": "*"
|
|
75
76
|
},
|
|
76
77
|
"eslintConfig": {
|
|
77
78
|
"root": true,
|
package/react-native.config.js
CHANGED
|
@@ -11,7 +11,7 @@ module.exports = {
|
|
|
11
11
|
* @type {import('@react-native-community/cli-types').AndroidDependencyParams}
|
|
12
12
|
*/
|
|
13
13
|
android: {
|
|
14
|
-
packageImportPath: 'import com.nitrometamask.NitroMetamaskPackage;',
|
|
14
|
+
packageImportPath: 'import com.margelo.nitro.nitrometamask.NitroMetamaskPackage;',
|
|
15
15
|
packageInstance: 'new NitroMetamaskPackage()',
|
|
16
16
|
},
|
|
17
17
|
},
|
|
@@ -2,10 +2,46 @@ import { type HybridObject } from 'react-native-nitro-modules'
|
|
|
2
2
|
|
|
3
3
|
export interface ConnectResult {
|
|
4
4
|
address: string
|
|
5
|
-
chainId:
|
|
5
|
+
chainId: bigint
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface ConnectSignResult {
|
|
9
|
+
signature: string
|
|
10
|
+
address: string
|
|
11
|
+
chainId: bigint
|
|
6
12
|
}
|
|
7
13
|
|
|
8
14
|
export interface NitroMetamask extends HybridObject<{ ios: 'swift', android: 'kotlin' }> {
|
|
15
|
+
/**
|
|
16
|
+
* Configure the dapp URL and deep link scheme for MetaMask SDK.
|
|
17
|
+
*
|
|
18
|
+
* @param dappUrl - A valid HTTP/HTTPS URL (e.g., "https://yourdomain.com").
|
|
19
|
+
* If not provided, defaults to "https://novastera.com".
|
|
20
|
+
* This is used for SDK validation.
|
|
21
|
+
* @param deepLinkScheme - The deep link scheme from your AndroidManifest.xml (e.g., "nitrometamask").
|
|
22
|
+
* If not provided, the library will attempt to auto-detect it.
|
|
23
|
+
* This is used to return to your app after MetaMask operations.
|
|
24
|
+
*/
|
|
25
|
+
configure(dappUrl?: string, deepLinkScheme?: string): void
|
|
9
26
|
connect(): Promise<ConnectResult>
|
|
10
27
|
signMessage(message: string): Promise<string>
|
|
28
|
+
/**
|
|
29
|
+
* Connect to MetaMask (if not already connected) and sign a message containing nonce and expiration.
|
|
30
|
+
* Returns the signature along with the address and chainId that were used to sign.
|
|
31
|
+
*
|
|
32
|
+
* @param nonce - A unique nonce for this signing request
|
|
33
|
+
* @param exp - Expiration timestamp (as bigint)
|
|
34
|
+
* @returns Promise resolving to ConnectSignResult containing signature, address, and chainId
|
|
35
|
+
*/
|
|
36
|
+
connectSign(nonce: string, exp: bigint): Promise<ConnectSignResult>
|
|
37
|
+
/**
|
|
38
|
+
* Get the currently connected wallet address.
|
|
39
|
+
* Returns null if not connected.
|
|
40
|
+
*/
|
|
41
|
+
getAddress(): Promise<string | null>
|
|
42
|
+
/**
|
|
43
|
+
* Get the current chain ID.
|
|
44
|
+
* Returns null if not connected.
|
|
45
|
+
*/
|
|
46
|
+
getChainId(): Promise<bigint | null>
|
|
11
47
|
}
|