@l.x/hashcash-native 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/NitroHashcashNative.podspec +56 -0
  2. package/README.md +24 -0
  3. package/android/CMakeLists.txt +29 -0
  4. package/android/build.gradle +141 -0
  5. package/android/fix-prefab.gradle +51 -0
  6. package/android/gradle.properties +5 -0
  7. package/android/src/main/AndroidManifest.xml +2 -0
  8. package/android/src/main/cpp/cpp-adapter.cpp +6 -0
  9. package/android/src/main/java/com/margelo/nitro/hashcashnative/HybridHashcash.kt +113 -0
  10. package/android/src/main/java/com/margelo/nitro/hashcashnative/NitroHashcashNativePackage.kt +18 -0
  11. package/ios/Bridge.h +8 -0
  12. package/ios/HybridHashcash.swift +133 -0
  13. package/lib/benchmark.d.ts +74 -0
  14. package/lib/benchmark.d.ts.map +1 -0
  15. package/lib/benchmark.js +92 -0
  16. package/lib/benchmark.js.map +1 -0
  17. package/lib/index.d.ts +11 -0
  18. package/lib/index.d.ts.map +1 -0
  19. package/lib/index.js +10 -0
  20. package/lib/index.js.map +1 -0
  21. package/lib/specs/Hashcash.nitro.d.ts +59 -0
  22. package/lib/specs/Hashcash.nitro.d.ts.map +1 -0
  23. package/lib/specs/Hashcash.nitro.js +2 -0
  24. package/lib/specs/Hashcash.nitro.js.map +1 -0
  25. package/nitro.json +18 -0
  26. package/nitrogen/generated/.gitattributes +1 -0
  27. package/nitrogen/generated/android/NitroHashcashNative+autolinking.cmake +81 -0
  28. package/nitrogen/generated/android/NitroHashcashNative+autolinking.gradle +27 -0
  29. package/nitrogen/generated/android/NitroHashcashNativeOnLoad.cpp +44 -0
  30. package/nitrogen/generated/android/NitroHashcashNativeOnLoad.hpp +25 -0
  31. package/nitrogen/generated/android/c++/JFindProofParams.hpp +68 -0
  32. package/nitrogen/generated/android/c++/JHashcashChallenge.hpp +69 -0
  33. package/nitrogen/generated/android/c++/JHashcashProofResult.hpp +69 -0
  34. package/nitrogen/generated/android/c++/JHybridHashcashSpec.cpp +81 -0
  35. package/nitrogen/generated/android/c++/JHybridHashcashSpec.hpp +66 -0
  36. package/nitrogen/generated/android/kotlin/com/margelo/nitro/hashcashnative/FindProofParams.kt +44 -0
  37. package/nitrogen/generated/android/kotlin/com/margelo/nitro/hashcashnative/HashcashChallenge.kt +47 -0
  38. package/nitrogen/generated/android/kotlin/com/margelo/nitro/hashcashnative/HashcashProofResult.kt +47 -0
  39. package/nitrogen/generated/android/kotlin/com/margelo/nitro/hashcashnative/HybridHashcashSpec.kt +62 -0
  40. package/nitrogen/generated/android/kotlin/com/margelo/nitro/hashcashnative/NitroHashcashNativeOnLoad.kt +35 -0
  41. package/nitrogen/generated/ios/NitroHashcashNative+autolinking.rb +60 -0
  42. package/nitrogen/generated/ios/NitroHashcashNative-Swift-Cxx-Bridge.cpp +49 -0
  43. package/nitrogen/generated/ios/NitroHashcashNative-Swift-Cxx-Bridge.hpp +154 -0
  44. package/nitrogen/generated/ios/NitroHashcashNative-Swift-Cxx-Umbrella.hpp +55 -0
  45. package/nitrogen/generated/ios/NitroHashcashNativeAutolinking.mm +33 -0
  46. package/nitrogen/generated/ios/NitroHashcashNativeAutolinking.swift +25 -0
  47. package/nitrogen/generated/ios/c++/HybridHashcashSpecSwift.cpp +11 -0
  48. package/nitrogen/generated/ios/c++/HybridHashcashSpecSwift.hpp +92 -0
  49. package/nitrogen/generated/ios/swift/FindProofParams.swift +82 -0
  50. package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +47 -0
  51. package/nitrogen/generated/ios/swift/Func_void_std__optional_HashcashProofResult_.swift +47 -0
  52. package/nitrogen/generated/ios/swift/HashcashChallenge.swift +69 -0
  53. package/nitrogen/generated/ios/swift/HashcashProofResult.swift +69 -0
  54. package/nitrogen/generated/ios/swift/HybridHashcashSpec.swift +57 -0
  55. package/nitrogen/generated/ios/swift/HybridHashcashSpec_cxx.swift +155 -0
  56. package/nitrogen/generated/shared/c++/FindProofParams.hpp +85 -0
  57. package/nitrogen/generated/shared/c++/HashcashChallenge.hpp +87 -0
  58. package/nitrogen/generated/shared/c++/HashcashProofResult.hpp +87 -0
  59. package/nitrogen/generated/shared/c++/HybridHashcashSpec.cpp +22 -0
  60. package/nitrogen/generated/shared/c++/HybridHashcashSpec.hpp +69 -0
  61. package/package.json +73 -1
  62. package/react-native.config.js +16 -0
  63. package/src/benchmark.ts +152 -0
  64. package/src/index.ts +23 -0
  65. package/src/specs/Hashcash.nitro.ts +64 -0
  66. package/index.d.ts +0 -1
  67. package/index.js +0 -1
@@ -0,0 +1,55 @@
1
+ ///
2
+ /// NitroHashcashNative-Swift-Cxx-Umbrella.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ // Forward declarations of C++ defined types
11
+ // Forward declaration of `FindProofParams` to properly resolve imports.
12
+ namespace margelo::nitro::hashcashnative { struct FindProofParams; }
13
+ // Forward declaration of `HashcashChallenge` to properly resolve imports.
14
+ namespace margelo::nitro::hashcashnative { struct HashcashChallenge; }
15
+ // Forward declaration of `HashcashProofResult` to properly resolve imports.
16
+ namespace margelo::nitro::hashcashnative { struct HashcashProofResult; }
17
+ // Forward declaration of `HybridHashcashSpec` to properly resolve imports.
18
+ namespace margelo::nitro::hashcashnative { class HybridHashcashSpec; }
19
+
20
+ // Include C++ defined types
21
+ #include "FindProofParams.hpp"
22
+ #include "HashcashChallenge.hpp"
23
+ #include "HashcashProofResult.hpp"
24
+ #include "HybridHashcashSpec.hpp"
25
+ #include <NitroModules/Promise.hpp>
26
+ #include <NitroModules/Result.hpp>
27
+ #include <exception>
28
+ #include <memory>
29
+ #include <optional>
30
+ #include <string>
31
+
32
+ // C++ helpers for Swift
33
+ #include "NitroHashcashNative-Swift-Cxx-Bridge.hpp"
34
+
35
+ // Common C++ types used in Swift
36
+ #include <NitroModules/ArrayBufferHolder.hpp>
37
+ #include <NitroModules/AnyMapUtils.hpp>
38
+ #include <NitroModules/RuntimeError.hpp>
39
+ #include <NitroModules/DateToChronoDate.hpp>
40
+
41
+ // Forward declarations of Swift defined types
42
+ // Forward declaration of `HybridHashcashSpec_cxx` to properly resolve imports.
43
+ namespace NitroHashcashNative { class HybridHashcashSpec_cxx; }
44
+
45
+ // Include Swift defined types
46
+ #if __has_include("NitroHashcashNative-Swift.h")
47
+ // This header is generated by Xcode/Swift on every app build.
48
+ // If it cannot be found, make sure the Swift module's name (= podspec name) is actually "NitroHashcashNative".
49
+ #include "NitroHashcashNative-Swift.h"
50
+ // Same as above, but used when building with frameworks (`use_frameworks`)
51
+ #elif __has_include(<NitroHashcashNative/NitroHashcashNative-Swift.h>)
52
+ #include <NitroHashcashNative/NitroHashcashNative-Swift.h>
53
+ #else
54
+ #error NitroHashcashNative's autogenerated Swift header cannot be found! Make sure the Swift module's name (= podspec name) is actually "NitroHashcashNative", and try building the app first.
55
+ #endif
@@ -0,0 +1,33 @@
1
+ ///
2
+ /// NitroHashcashNativeAutolinking.mm
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #import <Foundation/Foundation.h>
9
+ #import <NitroModules/HybridObjectRegistry.hpp>
10
+ #import "NitroHashcashNative-Swift-Cxx-Umbrella.hpp"
11
+ #import <type_traits>
12
+
13
+ #include "HybridHashcashSpecSwift.hpp"
14
+
15
+ @interface NitroHashcashNativeAutolinking : NSObject
16
+ @end
17
+
18
+ @implementation NitroHashcashNativeAutolinking
19
+
20
+ + (void) load {
21
+ using namespace margelo::nitro;
22
+ using namespace margelo::nitro::hashcashnative;
23
+
24
+ HybridObjectRegistry::registerHybridObjectConstructor(
25
+ "Hashcash",
26
+ []() -> std::shared_ptr<HybridObject> {
27
+ std::shared_ptr<HybridHashcashSpec> hybridObject = NitroHashcashNative::NitroHashcashNativeAutolinking::createHashcash();
28
+ return hybridObject;
29
+ }
30
+ );
31
+ }
32
+
33
+ @end
@@ -0,0 +1,25 @@
1
+ ///
2
+ /// NitroHashcashNativeAutolinking.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ public final class NitroHashcashNativeAutolinking {
9
+ public typealias bridge = margelo.nitro.hashcashnative.bridge.swift
10
+
11
+ /**
12
+ * Creates an instance of a Swift class that implements `HybridHashcashSpec`,
13
+ * and wraps it in a Swift class that can directly interop with C++ (`HybridHashcashSpec_cxx`)
14
+ *
15
+ * This is generated by Nitrogen and will initialize the class specified
16
+ * in the `"autolinking"` property of `nitro.json` (in this case, `HybridHashcash`).
17
+ */
18
+ public static func createHashcash() -> bridge.std__shared_ptr_HybridHashcashSpec_ {
19
+ let hybridObject = HybridHashcash()
20
+ return { () -> bridge.std__shared_ptr_HybridHashcashSpec_ in
21
+ let __cxxWrapped = hybridObject.getCxxWrapper()
22
+ return __cxxWrapped.getCxxPart()
23
+ }()
24
+ }
25
+ }
@@ -0,0 +1,11 @@
1
+ ///
2
+ /// HybridHashcashSpecSwift.cpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #include "HybridHashcashSpecSwift.hpp"
9
+
10
+ namespace margelo::nitro::hashcashnative {
11
+ } // namespace margelo::nitro::hashcashnative
@@ -0,0 +1,92 @@
1
+ ///
2
+ /// HybridHashcashSpecSwift.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #include "HybridHashcashSpec.hpp"
11
+
12
+ // Forward declaration of `HybridHashcashSpec_cxx` to properly resolve imports.
13
+ namespace NitroHashcashNative { class HybridHashcashSpec_cxx; }
14
+
15
+ // Forward declaration of `HashcashProofResult` to properly resolve imports.
16
+ namespace margelo::nitro::hashcashnative { struct HashcashProofResult; }
17
+ // Forward declaration of `FindProofParams` to properly resolve imports.
18
+ namespace margelo::nitro::hashcashnative { struct FindProofParams; }
19
+ // Forward declaration of `HashcashChallenge` to properly resolve imports.
20
+ namespace margelo::nitro::hashcashnative { struct HashcashChallenge; }
21
+
22
+ #include "HashcashProofResult.hpp"
23
+ #include <optional>
24
+ #include <NitroModules/Promise.hpp>
25
+ #include <string>
26
+ #include "FindProofParams.hpp"
27
+ #include "HashcashChallenge.hpp"
28
+
29
+ #include "NitroHashcashNative-Swift-Cxx-Umbrella.hpp"
30
+
31
+ namespace margelo::nitro::hashcashnative {
32
+
33
+ /**
34
+ * The C++ part of HybridHashcashSpec_cxx.swift.
35
+ *
36
+ * HybridHashcashSpecSwift (C++) accesses HybridHashcashSpec_cxx (Swift), and might
37
+ * contain some additional bridging code for C++ <> Swift interop.
38
+ *
39
+ * Since this obviously introduces an overhead, I hope at some point in
40
+ * the future, HybridHashcashSpec_cxx can directly inherit from the C++ class HybridHashcashSpec
41
+ * to simplify the whole structure and memory management.
42
+ */
43
+ class HybridHashcashSpecSwift: public virtual HybridHashcashSpec {
44
+ public:
45
+ // Constructor from a Swift instance
46
+ explicit HybridHashcashSpecSwift(const NitroHashcashNative::HybridHashcashSpec_cxx& swiftPart):
47
+ HybridObject(HybridHashcashSpec::TAG),
48
+ _swiftPart(swiftPart) { }
49
+
50
+ public:
51
+ // Get the Swift part
52
+ inline NitroHashcashNative::HybridHashcashSpec_cxx& getSwiftPart() noexcept {
53
+ return _swiftPart;
54
+ }
55
+
56
+ public:
57
+ inline size_t getExternalMemorySize() noexcept override {
58
+ return _swiftPart.getMemorySize();
59
+ }
60
+ void dispose() noexcept override {
61
+ _swiftPart.dispose();
62
+ }
63
+ std::string toString() override {
64
+ return _swiftPart.toString();
65
+ }
66
+
67
+ public:
68
+ // Properties
69
+
70
+
71
+ public:
72
+ // Methods
73
+ inline std::shared_ptr<Promise<std::optional<HashcashProofResult>>> findProof(const FindProofParams& params) override {
74
+ auto __result = _swiftPart.findProof(std::forward<decltype(params)>(params));
75
+ if (__result.hasError()) [[unlikely]] {
76
+ std::rethrow_exception(__result.error());
77
+ }
78
+ auto __value = std::move(__result.value());
79
+ return __value;
80
+ }
81
+ inline void cancel() override {
82
+ auto __result = _swiftPart.cancel();
83
+ if (__result.hasError()) [[unlikely]] {
84
+ std::rethrow_exception(__result.error());
85
+ }
86
+ }
87
+
88
+ private:
89
+ NitroHashcashNative::HybridHashcashSpec_cxx _swiftPart;
90
+ };
91
+
92
+ } // namespace margelo::nitro::hashcashnative
@@ -0,0 +1,82 @@
1
+ ///
2
+ /// FindProofParams.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ import Foundation
9
+ import NitroModules
10
+
11
+ /**
12
+ * Represents an instance of `FindProofParams`, backed by a C++ struct.
13
+ */
14
+ public typealias FindProofParams = margelo.nitro.hashcashnative.FindProofParams
15
+
16
+ public extension FindProofParams {
17
+ private typealias bridge = margelo.nitro.hashcashnative.bridge.swift
18
+
19
+ /**
20
+ * Create a new instance of `FindProofParams`.
21
+ */
22
+ init(challenge: HashcashChallenge, rangeStart: Double?, rangeSize: Double?) {
23
+ self.init(challenge, { () -> bridge.std__optional_double_ in
24
+ if let __unwrappedValue = rangeStart {
25
+ return bridge.create_std__optional_double_(__unwrappedValue)
26
+ } else {
27
+ return .init()
28
+ }
29
+ }(), { () -> bridge.std__optional_double_ in
30
+ if let __unwrappedValue = rangeSize {
31
+ return bridge.create_std__optional_double_(__unwrappedValue)
32
+ } else {
33
+ return .init()
34
+ }
35
+ }())
36
+ }
37
+
38
+ var challenge: HashcashChallenge {
39
+ @inline(__always)
40
+ get {
41
+ return self.__challenge
42
+ }
43
+ @inline(__always)
44
+ set {
45
+ self.__challenge = newValue
46
+ }
47
+ }
48
+
49
+ var rangeStart: Double? {
50
+ @inline(__always)
51
+ get {
52
+ return self.__rangeStart.value
53
+ }
54
+ @inline(__always)
55
+ set {
56
+ self.__rangeStart = { () -> bridge.std__optional_double_ in
57
+ if let __unwrappedValue = newValue {
58
+ return bridge.create_std__optional_double_(__unwrappedValue)
59
+ } else {
60
+ return .init()
61
+ }
62
+ }()
63
+ }
64
+ }
65
+
66
+ var rangeSize: Double? {
67
+ @inline(__always)
68
+ get {
69
+ return self.__rangeSize.value
70
+ }
71
+ @inline(__always)
72
+ set {
73
+ self.__rangeSize = { () -> bridge.std__optional_double_ in
74
+ if let __unwrappedValue = newValue {
75
+ return bridge.create_std__optional_double_(__unwrappedValue)
76
+ } else {
77
+ return .init()
78
+ }
79
+ }()
80
+ }
81
+ }
82
+ }
@@ -0,0 +1,47 @@
1
+ ///
2
+ /// Func_void_std__exception_ptr.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ import Foundation
9
+ import NitroModules
10
+
11
+ /**
12
+ * Wraps a Swift `(_ error: Error) -> 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__exception_ptr {
16
+ public typealias bridge = margelo.nitro.hashcashnative.bridge.swift
17
+
18
+ private let closure: (_ error: Error) -> Void
19
+
20
+ public init(_ closure: @escaping (_ error: Error) -> Void) {
21
+ self.closure = closure
22
+ }
23
+
24
+ @inline(__always)
25
+ public func call(error: std.exception_ptr) -> Void {
26
+ self.closure(RuntimeError.from(cppError: error))
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_std__exception_ptr`.
40
+ * The pointer has to be a retained opaque `Unmanaged<Func_void_std__exception_ptr>`.
41
+ * This removes one strong reference from the object!
42
+ */
43
+ @inline(__always)
44
+ public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__exception_ptr {
45
+ return Unmanaged<Func_void_std__exception_ptr>.fromOpaque(pointer).takeRetainedValue()
46
+ }
47
+ }
@@ -0,0 +1,47 @@
1
+ ///
2
+ /// Func_void_std__optional_HashcashProofResult_.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ import Foundation
9
+ import NitroModules
10
+
11
+ /**
12
+ * Wraps a Swift `(_ value: HashcashProofResult?) -> 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__optional_HashcashProofResult_ {
16
+ public typealias bridge = margelo.nitro.hashcashnative.bridge.swift
17
+
18
+ private let closure: (_ value: HashcashProofResult?) -> Void
19
+
20
+ public init(_ closure: @escaping (_ value: HashcashProofResult?) -> Void) {
21
+ self.closure = closure
22
+ }
23
+
24
+ @inline(__always)
25
+ public func call(value: bridge.std__optional_HashcashProofResult_) -> Void {
26
+ self.closure(value.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_std__optional_HashcashProofResult_`.
40
+ * The pointer has to be a retained opaque `Unmanaged<Func_void_std__optional_HashcashProofResult_>`.
41
+ * This removes one strong reference from the object!
42
+ */
43
+ @inline(__always)
44
+ public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__optional_HashcashProofResult_ {
45
+ return Unmanaged<Func_void_std__optional_HashcashProofResult_>.fromOpaque(pointer).takeRetainedValue()
46
+ }
47
+ }
@@ -0,0 +1,69 @@
1
+ ///
2
+ /// HashcashChallenge.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ import Foundation
9
+ import NitroModules
10
+
11
+ /**
12
+ * Represents an instance of `HashcashChallenge`, backed by a C++ struct.
13
+ */
14
+ public typealias HashcashChallenge = margelo.nitro.hashcashnative.HashcashChallenge
15
+
16
+ public extension HashcashChallenge {
17
+ private typealias bridge = margelo.nitro.hashcashnative.bridge.swift
18
+
19
+ /**
20
+ * Create a new instance of `HashcashChallenge`.
21
+ */
22
+ init(difficulty: Double, subject: String, nonce: String, maxProofLength: Double) {
23
+ self.init(difficulty, std.string(subject), std.string(nonce), maxProofLength)
24
+ }
25
+
26
+ var difficulty: Double {
27
+ @inline(__always)
28
+ get {
29
+ return self.__difficulty
30
+ }
31
+ @inline(__always)
32
+ set {
33
+ self.__difficulty = newValue
34
+ }
35
+ }
36
+
37
+ var subject: String {
38
+ @inline(__always)
39
+ get {
40
+ return String(self.__subject)
41
+ }
42
+ @inline(__always)
43
+ set {
44
+ self.__subject = std.string(newValue)
45
+ }
46
+ }
47
+
48
+ var nonce: String {
49
+ @inline(__always)
50
+ get {
51
+ return String(self.__nonce)
52
+ }
53
+ @inline(__always)
54
+ set {
55
+ self.__nonce = std.string(newValue)
56
+ }
57
+ }
58
+
59
+ var maxProofLength: Double {
60
+ @inline(__always)
61
+ get {
62
+ return self.__maxProofLength
63
+ }
64
+ @inline(__always)
65
+ set {
66
+ self.__maxProofLength = newValue
67
+ }
68
+ }
69
+ }
@@ -0,0 +1,69 @@
1
+ ///
2
+ /// HashcashProofResult.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ import Foundation
9
+ import NitroModules
10
+
11
+ /**
12
+ * Represents an instance of `HashcashProofResult`, backed by a C++ struct.
13
+ */
14
+ public typealias HashcashProofResult = margelo.nitro.hashcashnative.HashcashProofResult
15
+
16
+ public extension HashcashProofResult {
17
+ private typealias bridge = margelo.nitro.hashcashnative.bridge.swift
18
+
19
+ /**
20
+ * Create a new instance of `HashcashProofResult`.
21
+ */
22
+ init(counter: String, hashBase64: String, attempts: Double, timeMs: Double) {
23
+ self.init(std.string(counter), std.string(hashBase64), attempts, timeMs)
24
+ }
25
+
26
+ var counter: String {
27
+ @inline(__always)
28
+ get {
29
+ return String(self.__counter)
30
+ }
31
+ @inline(__always)
32
+ set {
33
+ self.__counter = std.string(newValue)
34
+ }
35
+ }
36
+
37
+ var hashBase64: String {
38
+ @inline(__always)
39
+ get {
40
+ return String(self.__hashBase64)
41
+ }
42
+ @inline(__always)
43
+ set {
44
+ self.__hashBase64 = std.string(newValue)
45
+ }
46
+ }
47
+
48
+ var attempts: Double {
49
+ @inline(__always)
50
+ get {
51
+ return self.__attempts
52
+ }
53
+ @inline(__always)
54
+ set {
55
+ self.__attempts = newValue
56
+ }
57
+ }
58
+
59
+ var timeMs: Double {
60
+ @inline(__always)
61
+ get {
62
+ return self.__timeMs
63
+ }
64
+ @inline(__always)
65
+ set {
66
+ self.__timeMs = newValue
67
+ }
68
+ }
69
+ }
@@ -0,0 +1,57 @@
1
+ ///
2
+ /// HybridHashcashSpec.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ import Foundation
9
+ import NitroModules
10
+
11
+ /// See ``HybridHashcashSpec``
12
+ public protocol HybridHashcashSpec_protocol: HybridObject {
13
+ // Properties
14
+
15
+
16
+ // Methods
17
+ func findProof(params: FindProofParams) throws -> Promise<HashcashProofResult?>
18
+ func cancel() throws -> Void
19
+ }
20
+
21
+ public extension HybridHashcashSpec_protocol {
22
+ /// Default implementation of ``HybridObject.toString``
23
+ func toString() -> String {
24
+ return "[HybridObject Hashcash]"
25
+ }
26
+ }
27
+
28
+ /// See ``HybridHashcashSpec``
29
+ open class HybridHashcashSpec_base {
30
+ private weak var cxxWrapper: HybridHashcashSpec_cxx? = nil
31
+ public init() { }
32
+ public func getCxxWrapper() -> HybridHashcashSpec_cxx {
33
+ #if DEBUG
34
+ guard self is HybridHashcashSpec else {
35
+ fatalError("`self` is not a `HybridHashcashSpec`! Did you accidentally inherit from `HybridHashcashSpec_base` instead of `HybridHashcashSpec`?")
36
+ }
37
+ #endif
38
+ if let cxxWrapper = self.cxxWrapper {
39
+ return cxxWrapper
40
+ } else {
41
+ let cxxWrapper = HybridHashcashSpec_cxx(self as! HybridHashcashSpec)
42
+ self.cxxWrapper = cxxWrapper
43
+ return cxxWrapper
44
+ }
45
+ }
46
+ }
47
+
48
+ /**
49
+ * A Swift base-protocol representing the Hashcash HybridObject.
50
+ * Implement this protocol to create Swift-based instances of Hashcash.
51
+ * ```swift
52
+ * class HybridHashcash : HybridHashcashSpec {
53
+ * // ...
54
+ * }
55
+ * ```
56
+ */
57
+ public typealias HybridHashcashSpec = HybridHashcashSpec_protocol & HybridHashcashSpec_base