@bennyblader/ddk-rn 0.1.4
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/DdkRn.podspec +44 -0
- package/LICENSE +20 -0
- package/README.md +33 -0
- package/android/CMakeLists.txt +76 -0
- package/android/build.gradle +144 -0
- package/android/cpp-adapter.cpp +63 -0
- package/android/gradle.properties +5 -0
- package/android/proguard-rules.pro +4 -0
- package/android/src/main/AndroidManifest.xml +5 -0
- package/android/src/main/AndroidManifestNew.xml +2 -0
- package/android/src/main/java/com/ddkrn/DdkRnModule.kt +43 -0
- package/android/src/main/java/com/ddkrn/DdkRnPackage.kt +34 -0
- package/cpp/bennyblader-ddk-rn.cpp +16 -0
- package/cpp/bennyblader-ddk-rn.h +15 -0
- package/cpp/ddk_ffi.cpp +2557 -0
- package/cpp/ddk_ffi.hpp +78 -0
- package/ios/DdkRn.h +16 -0
- package/ios/DdkRn.mm +66 -0
- package/lib/commonjs/NativeDdkRn.js +10 -0
- package/lib/commonjs/NativeDdkRn.js.map +1 -0
- package/lib/commonjs/ddk_ffi-ffi.js +44 -0
- package/lib/commonjs/ddk_ffi-ffi.js.map +1 -0
- package/lib/commonjs/ddk_ffi.js +1072 -0
- package/lib/commonjs/ddk_ffi.js.map +1 -0
- package/lib/commonjs/index.js +63 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/module/NativeDdkRn.js +7 -0
- package/lib/module/NativeDdkRn.js.map +1 -0
- package/lib/module/ddk_ffi-ffi.js +43 -0
- package/lib/module/ddk_ffi-ffi.js.map +1 -0
- package/lib/module/ddk_ffi.js +1052 -0
- package/lib/module/ddk_ffi.js.map +1 -0
- package/lib/module/index.js +43 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/src/NativeDdkRn.d.ts +8 -0
- package/lib/typescript/commonjs/src/NativeDdkRn.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/ddk_ffi-ffi.d.ts +108 -0
- package/lib/typescript/commonjs/src/ddk_ffi-ffi.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/ddk_ffi.d.ts +773 -0
- package/lib/typescript/commonjs/src/ddk_ffi.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +8 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/src/NativeDdkRn.d.ts +8 -0
- package/lib/typescript/module/src/NativeDdkRn.d.ts.map +1 -0
- package/lib/typescript/module/src/ddk_ffi-ffi.d.ts +108 -0
- package/lib/typescript/module/src/ddk_ffi-ffi.d.ts.map +1 -0
- package/lib/typescript/module/src/ddk_ffi.d.ts +773 -0
- package/lib/typescript/module/src/ddk_ffi.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +8 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -0
- package/package.json +206 -0
- package/scripts/postinstall.js +130 -0
- package/src/NativeDdkRn.ts +10 -0
- package/src/ddk_ffi-ffi.ts +307 -0
- package/src/ddk_ffi.ts +1743 -0
- package/src/index.tsx +41 -0
package/cpp/ddk_ffi.hpp
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// This file was autogenerated by some hot garbage in the `uniffi-bindgen-react-native` crate.
|
|
2
|
+
// Trust me, you don't want to mess with it!
|
|
3
|
+
#pragma once
|
|
4
|
+
#include <jsi/jsi.h>
|
|
5
|
+
#include <iostream>
|
|
6
|
+
#include <map>
|
|
7
|
+
#include <memory>
|
|
8
|
+
#include <ReactCommon/CallInvoker.h>
|
|
9
|
+
#include "UniffiCallInvoker.h"
|
|
10
|
+
|
|
11
|
+
namespace react = facebook::react;
|
|
12
|
+
namespace jsi = facebook::jsi;
|
|
13
|
+
|
|
14
|
+
class NativeDdkFfi : public jsi::HostObject {
|
|
15
|
+
private:
|
|
16
|
+
// For calling back into JS from Rust.
|
|
17
|
+
std::shared_ptr<uniffi_runtime::UniffiCallInvoker> callInvoker;
|
|
18
|
+
|
|
19
|
+
protected:
|
|
20
|
+
std::map<std::string,jsi::Value> props;
|
|
21
|
+
jsi::Value cpp_uniffi_internal_fn_func_ffi__string_to_byte_length(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
|
22
|
+
jsi::Value cpp_uniffi_internal_fn_func_ffi__string_to_arraybuffer(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
|
23
|
+
jsi::Value cpp_uniffi_internal_fn_func_ffi__arraybuffer_to_string(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
|
24
|
+
jsi::Value cpp_uniffi_ddk_ffi_fn_func_create_cet(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
|
25
|
+
jsi::Value cpp_uniffi_ddk_ffi_fn_func_create_cet_adaptor_signature_from_oracle_info(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
|
26
|
+
jsi::Value cpp_uniffi_ddk_ffi_fn_func_create_cets(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
|
27
|
+
jsi::Value cpp_uniffi_ddk_ffi_fn_func_create_dlc_transactions(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
|
28
|
+
jsi::Value cpp_uniffi_ddk_ffi_fn_func_create_fund_tx_locking_script(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
|
29
|
+
jsi::Value cpp_uniffi_ddk_ffi_fn_func_create_refund_transaction(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
|
30
|
+
jsi::Value cpp_uniffi_ddk_ffi_fn_func_create_spliced_dlc_transactions(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
|
31
|
+
jsi::Value cpp_uniffi_ddk_ffi_fn_func_get_change_output_and_fees(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
|
32
|
+
jsi::Value cpp_uniffi_ddk_ffi_fn_func_get_raw_funding_transaction_input_signature(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
|
33
|
+
jsi::Value cpp_uniffi_ddk_ffi_fn_func_get_total_input_vsize(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
|
34
|
+
jsi::Value cpp_uniffi_ddk_ffi_fn_func_is_dust_output(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
|
35
|
+
jsi::Value cpp_uniffi_ddk_ffi_fn_func_sign_fund_transaction_input(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
|
36
|
+
jsi::Value cpp_uniffi_ddk_ffi_fn_func_verify_fund_tx_signature(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
|
37
|
+
jsi::Value cpp_uniffi_ddk_ffi_fn_func_version(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
|
38
|
+
jsi::Value cpp_uniffi_ddk_ffi_checksum_func_create_cet(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
|
39
|
+
jsi::Value cpp_uniffi_ddk_ffi_checksum_func_create_cet_adaptor_signature_from_oracle_info(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
|
40
|
+
jsi::Value cpp_uniffi_ddk_ffi_checksum_func_create_cets(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
|
41
|
+
jsi::Value cpp_uniffi_ddk_ffi_checksum_func_create_dlc_transactions(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
|
42
|
+
jsi::Value cpp_uniffi_ddk_ffi_checksum_func_create_fund_tx_locking_script(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
|
43
|
+
jsi::Value cpp_uniffi_ddk_ffi_checksum_func_create_refund_transaction(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
|
44
|
+
jsi::Value cpp_uniffi_ddk_ffi_checksum_func_create_spliced_dlc_transactions(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
|
45
|
+
jsi::Value cpp_uniffi_ddk_ffi_checksum_func_get_change_output_and_fees(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
|
46
|
+
jsi::Value cpp_uniffi_ddk_ffi_checksum_func_get_raw_funding_transaction_input_signature(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
|
47
|
+
jsi::Value cpp_uniffi_ddk_ffi_checksum_func_get_total_input_vsize(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
|
48
|
+
jsi::Value cpp_uniffi_ddk_ffi_checksum_func_is_dust_output(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
|
49
|
+
jsi::Value cpp_uniffi_ddk_ffi_checksum_func_sign_fund_transaction_input(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
|
50
|
+
jsi::Value cpp_uniffi_ddk_ffi_checksum_func_verify_fund_tx_signature(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
|
51
|
+
jsi::Value cpp_uniffi_ddk_ffi_checksum_func_version(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
|
52
|
+
jsi::Value cpp_ffi_ddk_ffi_uniffi_contract_version(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
|
53
|
+
|
|
54
|
+
public:
|
|
55
|
+
NativeDdkFfi(jsi::Runtime &rt, std::shared_ptr<uniffi_runtime::UniffiCallInvoker> callInvoker);
|
|
56
|
+
virtual ~NativeDdkFfi();
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The entry point into the crate.
|
|
60
|
+
*
|
|
61
|
+
* React Native must call `NativeDdkFfi.registerModule(rt, callInvoker)` before using
|
|
62
|
+
* the Javascript interface.
|
|
63
|
+
*/
|
|
64
|
+
static void registerModule(jsi::Runtime &rt, std::shared_ptr<react::CallInvoker> callInvoker);
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Some cleanup into the crate goes here.
|
|
68
|
+
*
|
|
69
|
+
* Current implementation is empty, however, this is not guaranteed to always be the case.
|
|
70
|
+
*
|
|
71
|
+
* Clients should call `NativeDdkFfi.unregisterModule(rt)` after final use where possible.
|
|
72
|
+
*/
|
|
73
|
+
static void unregisterModule(jsi::Runtime &rt);
|
|
74
|
+
|
|
75
|
+
virtual jsi::Value get(jsi::Runtime& rt, const jsi::PropNameID& name);
|
|
76
|
+
virtual void set(jsi::Runtime& rt,const jsi::PropNameID& name,const jsi::Value& value);
|
|
77
|
+
virtual std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime& rt);
|
|
78
|
+
};
|
package/ios/DdkRn.h
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Generated by uniffi-bindgen-react-native
|
|
2
|
+
#ifdef __cplusplus
|
|
3
|
+
#import "bennyblader-ddk-rn.h"
|
|
4
|
+
#endif
|
|
5
|
+
|
|
6
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
7
|
+
#import "RNDdkRnSpec.h"
|
|
8
|
+
|
|
9
|
+
@interface DdkRn : NSObject <NativeDdkRnSpec>
|
|
10
|
+
#else
|
|
11
|
+
#import <React/RCTBridgeModule.h>
|
|
12
|
+
|
|
13
|
+
@interface DdkRn : NSObject <RCTBridgeModule>
|
|
14
|
+
#endif
|
|
15
|
+
|
|
16
|
+
@end
|
package/ios/DdkRn.mm
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// Generated by uniffi-bindgen-react-native
|
|
2
|
+
#import "DdkRn.h"
|
|
3
|
+
|
|
4
|
+
namespace uniffi_generated {
|
|
5
|
+
using namespace facebook::react;
|
|
6
|
+
/**
|
|
7
|
+
* ObjC++ class for module 'NativeDdkRn'
|
|
8
|
+
*/
|
|
9
|
+
class JSI_EXPORT NativeDdkRnSpecJSI : public ObjCTurboModule {
|
|
10
|
+
public:
|
|
11
|
+
NativeDdkRnSpecJSI(const ObjCTurboModule::InitParams ¶ms);
|
|
12
|
+
std::shared_ptr<CallInvoker> callInvoker;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
static facebook::jsi::Value __hostFunction_DdkRn_installRustCrate(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
16
|
+
auto& tm = static_cast<NativeDdkRnSpecJSI&>(turboModule);
|
|
17
|
+
auto jsInvoker = tm.callInvoker;
|
|
18
|
+
uint8_t result = bennyblader_ddkrn::installRustCrate(rt, jsInvoker);
|
|
19
|
+
return facebook::jsi::Value(rt, result);
|
|
20
|
+
}
|
|
21
|
+
static facebook::jsi::Value __hostFunction_DdkRn_cleanupRustCrate(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
22
|
+
uint8_t result = bennyblader_ddkrn::cleanupRustCrate(rt);
|
|
23
|
+
return facebook::jsi::Value(rt, result);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
NativeDdkRnSpecJSI::NativeDdkRnSpecJSI(const ObjCTurboModule::InitParams ¶ms)
|
|
27
|
+
: ObjCTurboModule(params), callInvoker(params.jsInvoker) {
|
|
28
|
+
this->methodMap_["installRustCrate"] = MethodMetadata {1, __hostFunction_DdkRn_installRustCrate};
|
|
29
|
+
this->methodMap_["cleanupRustCrate"] = MethodMetadata {1, __hostFunction_DdkRn_cleanupRustCrate};
|
|
30
|
+
}
|
|
31
|
+
} // namespace uniffi_generated
|
|
32
|
+
|
|
33
|
+
@implementation DdkRn
|
|
34
|
+
RCT_EXPORT_MODULE()
|
|
35
|
+
|
|
36
|
+
// Don't compile this code when we build for the old architecture.
|
|
37
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
38
|
+
|
|
39
|
+
// Automated testing checks bennyblader_ddkrn
|
|
40
|
+
// by comparing the whole line here.
|
|
41
|
+
/*
|
|
42
|
+
- (NSNumber *)multiply:(double)a b:(double)b {
|
|
43
|
+
NSNumber *result = @(bennyblader_ddkrn::multiply(a, b));
|
|
44
|
+
}
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
- (NSNumber *)installRustCrate {
|
|
48
|
+
@throw [NSException exceptionWithName:@"UnreachableException"
|
|
49
|
+
reason:@"This method should never be called."
|
|
50
|
+
userInfo:nil];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
- (NSNumber *)cleanupRustCrate {
|
|
54
|
+
@throw [NSException exceptionWithName:@"UnreachableException"
|
|
55
|
+
reason:@"This method should never be called."
|
|
56
|
+
userInfo:nil];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
|
60
|
+
(const facebook::react::ObjCTurboModule::InitParams &)params
|
|
61
|
+
{
|
|
62
|
+
return std::make_shared<uniffi_generated::NativeDdkRnSpecJSI>(params);
|
|
63
|
+
}
|
|
64
|
+
#endif
|
|
65
|
+
|
|
66
|
+
@end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _reactNative = require("react-native");
|
|
8
|
+
// Generated by uniffi-bindgen-react-native
|
|
9
|
+
var _default = exports.default = _reactNative.TurboModuleRegistry.getEnforcing('DdkRn');
|
|
10
|
+
//# sourceMappingURL=NativeDdkRn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_default","exports","default","TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeDdkRn.ts"],"mappings":";;;;;;AAEA,IAAAA,YAAA,GAAAC,OAAA;AAFA;AAAA,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GASeC,gCAAmB,CAACC,YAAY,CAAO,OAAO,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
// This file was autogenerated by some hot garbage in the `uniffi-bindgen-react-native` crate.
|
|
8
|
+
// Trust me, you don't want to mess with it!
|
|
9
|
+
|
|
10
|
+
// Casting globalThis to any allows us to look for `NativeDdkFfi`
|
|
11
|
+
// if it was added via JSI.
|
|
12
|
+
//
|
|
13
|
+
// We use a getter here rather than simply `globalThis.NativeDdkFfi` so that
|
|
14
|
+
// if/when the startup sequence isn't just so, an empty value isn't inadvertantly cached.
|
|
15
|
+
const getter = () => globalThis.NativeDdkFfi;
|
|
16
|
+
var _default = exports.default = getter; // Structs and function types for calling back into Typescript from Rust.
|
|
17
|
+
// UniffiRustFutureContinuationCallback is generated as part of the component interface's
|
|
18
|
+
// ffi_definitions. However, we need it in the runtime.
|
|
19
|
+
// We could:
|
|
20
|
+
// (a) do some complicated template logic to ensure the declaration is not generated here (possible)
|
|
21
|
+
// (b) import the generated declaration into the runtime (m a y b e) or…
|
|
22
|
+
// (c) generate the declaration anyway, and use a different declaration in the runtime.
|
|
23
|
+
//
|
|
24
|
+
// We chose (c) here as the simplest. In addition, we perform a compile time check that
|
|
25
|
+
// the two versions of `UniffiRustFutureContinuationCallback` are structurally equivalent.
|
|
26
|
+
//
|
|
27
|
+
// If you see the error:
|
|
28
|
+
// ```
|
|
29
|
+
// Type 'true' is not assignable to type 'false'.(2322)
|
|
30
|
+
// ```
|
|
31
|
+
// Then a new version of uniffi has changed the signature of the callback. Most likely, code in
|
|
32
|
+
// `typescript/src/async-rust-call.ts` will need to be changed.
|
|
33
|
+
//
|
|
34
|
+
// If you see the error:
|
|
35
|
+
// ```
|
|
36
|
+
// Cannot find name 'UniffiRustFutureContinuationCallback'. Did you mean 'RuntimeUniffiRustFutureContinuationCallback'?(2552)
|
|
37
|
+
// ```
|
|
38
|
+
// then you may not be using callbacks or promises, and uniffi is now not generating Futures and callbacks.
|
|
39
|
+
// You should not generate this if that is the case.
|
|
40
|
+
//
|
|
41
|
+
// ('You' being the bindings generator maintainer).
|
|
42
|
+
const isRustFutureContinuationCallbackTypeCompatible = true;
|
|
43
|
+
const isUniffiForeignFutureTypeCompatible = true;
|
|
44
|
+
//# sourceMappingURL=ddk_ffi-ffi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getter","globalThis","NativeDdkFfi","_default","exports","default","isRustFutureContinuationCallbackTypeCompatible","isUniffiForeignFutureTypeCompatible"],"sourceRoot":"../../src","sources":["ddk_ffi-ffi.ts"],"mappings":";;;;;;AAAA;AACA;;AAqJA;AACA;AACA;AACA;AACA;AACA,MAAMA,MAAmC,GAAGA,CAAA,KACzCC,UAAU,CAASC,YAAY;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GACpBL,MAAM,EAErB;AAmHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMM,8CAGL,GAAG,IAAI;AACR,MAAMC,mCAGL,GAAG,IAAI","ignoreList":[]}
|