@bennyblader/ddk-rn 1.0.0-rc5 → 1.0.0-rc7
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 +47 -109
- package/android/build.gradle +0 -1
- package/android/src/main/jniLibs/arm64-v8a/libddk_ffi.so +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/libddk_ffi.so +0 -0
- package/android/src/main/jniLibs/x86/libddk_ffi.so +0 -0
- package/android/src/main/jniLibs/x86_64/libddk_ffi.so +0 -0
- package/cpp/ddk_ffi.cpp +4666 -1189
- package/cpp/ddk_ffi.hpp +121 -10
- package/ios/DdkRn.xcframework/Info.plist +4 -4
- package/ios/DdkRn.xcframework/ios-arm64/libddk_ffi.a +0 -0
- package/ios/DdkRn.xcframework/ios-arm64-simulator/libddk_ffi.a +0 -0
- package/lib/commonjs/generated/NativeDdkRn.js.map +1 -0
- package/lib/commonjs/generated/ddk_ffi-ffi.js.map +1 -0
- package/lib/commonjs/{ddk_ffi.js → generated/ddk_ffi.js} +1593 -207
- package/lib/commonjs/generated/ddk_ffi.js.map +1 -0
- package/lib/commonjs/generated/index.js +63 -0
- package/lib/commonjs/generated/index.js.map +1 -0
- package/lib/commonjs/index.js +11 -48
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/generated/NativeDdkRn.js.map +1 -0
- package/lib/module/generated/ddk_ffi-ffi.js.map +1 -0
- package/lib/module/{ddk_ffi.js → generated/ddk_ffi.js} +1574 -202
- package/lib/module/generated/ddk_ffi.js.map +1 -0
- package/lib/module/generated/index.js +43 -0
- package/lib/module/generated/index.js.map +1 -0
- package/lib/module/index.js +2 -40
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/commonjs/src/generated/NativeDdkRn.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/{ddk_ffi-ffi.d.ts → generated/ddk_ffi-ffi.d.ts} +110 -16
- package/lib/typescript/commonjs/src/generated/ddk_ffi-ffi.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/{ddk_ffi.d.ts → generated/ddk_ffi.d.ts} +764 -129
- package/lib/typescript/commonjs/src/generated/ddk_ffi.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/generated/index.d.ts +8 -0
- package/lib/typescript/commonjs/src/generated/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +2 -7
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/generated/NativeDdkRn.d.ts.map +1 -0
- package/lib/typescript/module/src/{ddk_ffi-ffi.d.ts → generated/ddk_ffi-ffi.d.ts} +110 -16
- package/lib/typescript/module/src/generated/ddk_ffi-ffi.d.ts.map +1 -0
- package/lib/typescript/module/src/{ddk_ffi.d.ts → generated/ddk_ffi.d.ts} +764 -129
- package/lib/typescript/module/src/generated/ddk_ffi.d.ts.map +1 -0
- package/lib/typescript/module/src/generated/index.d.ts +8 -0
- package/lib/typescript/module/src/generated/index.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +2 -7
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/package.json +18 -47
- package/src/{ddk_ffi-ffi.ts → generated/ddk_ffi-ffi.ts} +298 -37
- package/src/{ddk_ffi.ts → generated/ddk_ffi.ts} +2870 -474
- package/src/generated/index.tsx +41 -0
- package/src/index.tsx +2 -41
- package/ubrn.config.yaml +4 -3
- package/lib/commonjs/NativeDdkRn.js.map +0 -1
- package/lib/commonjs/ddk_ffi-ffi.js.map +0 -1
- package/lib/commonjs/ddk_ffi.js.map +0 -1
- package/lib/module/NativeDdkRn.js.map +0 -1
- package/lib/module/ddk_ffi-ffi.js.map +0 -1
- package/lib/module/ddk_ffi.js.map +0 -1
- package/lib/typescript/commonjs/src/NativeDdkRn.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/ddk_ffi-ffi.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/ddk_ffi.d.ts.map +0 -1
- package/lib/typescript/module/src/NativeDdkRn.d.ts.map +0 -1
- package/lib/typescript/module/src/ddk_ffi-ffi.d.ts.map +0 -1
- package/lib/typescript/module/src/ddk_ffi.d.ts.map +0 -1
- /package/lib/commonjs/{NativeDdkRn.js → generated/NativeDdkRn.js} +0 -0
- /package/lib/commonjs/{ddk_ffi-ffi.js → generated/ddk_ffi-ffi.js} +0 -0
- /package/lib/module/{NativeDdkRn.js → generated/NativeDdkRn.js} +0 -0
- /package/lib/module/{ddk_ffi-ffi.js → generated/ddk_ffi-ffi.js} +0 -0
- /package/lib/typescript/commonjs/src/{NativeDdkRn.d.ts → generated/NativeDdkRn.d.ts} +0 -0
- /package/lib/typescript/module/src/{NativeDdkRn.d.ts → generated/NativeDdkRn.d.ts} +0 -0
- /package/src/{NativeDdkRn.ts → generated/NativeDdkRn.ts} +0 -0
package/README.md
CHANGED
|
@@ -48,7 +48,7 @@ import {
|
|
|
48
48
|
acceptOffer,
|
|
49
49
|
signAccept,
|
|
50
50
|
finalizeSign,
|
|
51
|
-
|
|
51
|
+
contractCetTransaction,
|
|
52
52
|
} from '@bennyblader/ddk-rn';
|
|
53
53
|
|
|
54
54
|
const keys = ContractKeyProvider.fromMnemonic(MNEMONIC, undefined, 'regtest');
|
|
@@ -71,15 +71,15 @@ const offer = createOffer({
|
|
|
71
71
|
contractFlags: 0,
|
|
72
72
|
});
|
|
73
73
|
// …acceptOffer → sign the funding PSBT → signAccept → finalizeSign →
|
|
74
|
-
//
|
|
74
|
+
// contractCetTransaction / contractRefundTransaction
|
|
75
75
|
```
|
|
76
76
|
|
|
77
|
-
Bytes cross the JSI boundary as `
|
|
77
|
+
Bytes cross the JSI boundary as `Uint8Array`, as they do in `@bennyblader/ddk`.
|
|
78
78
|
|
|
79
|
-
|
|
79
|
+
`../../examples/react-native/src/App.tsx` runs the complete flow on device — offline, deterministic,
|
|
80
80
|
and asserted by the Maestro E2E.
|
|
81
81
|
|
|
82
|
-
For complete API documentation, see the [main README](
|
|
82
|
+
For complete API documentation, see the [main README](../../README.md#-the-contract-api).
|
|
83
83
|
|
|
84
84
|
## Development
|
|
85
85
|
|
|
@@ -88,96 +88,35 @@ For complete API documentation, see the [main README](../README.md#-the-contract
|
|
|
88
88
|
- Node.js >= 20
|
|
89
89
|
- Rust >= 1.70
|
|
90
90
|
- pnpm
|
|
91
|
-
- UniFFI React Native, installed
|
|
92
|
-
`package.json`: `pnpm add -g uniffi-bindgen-react-native@<version>`
|
|
91
|
+
- UniFFI React Native, installed by the root `pnpm install`.
|
|
93
92
|
- iOS: Xcode 14+, CocoaPods
|
|
94
93
|
- Android: Android Studio, NDK 27.1.12297006
|
|
95
94
|
|
|
96
|
-
>
|
|
97
|
-
>
|
|
98
|
-
> recipes call the binary on `$PATH`, not the one in `node_modules`. A skew shows
|
|
99
|
-
> up as TypeScript errors like "Expected 2 arguments, but got 1" on every
|
|
100
|
-
> generated `.lower()` call.
|
|
95
|
+
> Keep the Rust UniFFI version and both npm generator pins compatible.
|
|
96
|
+
> Root commands use the workspace-local generator.
|
|
101
97
|
|
|
102
|
-
### Building from
|
|
98
|
+
### Building from source
|
|
103
99
|
|
|
104
|
-
|
|
105
|
-
# Install dependencies
|
|
106
|
-
pnpm install
|
|
107
|
-
|
|
108
|
-
# Generate all bindings and build the native libraries
|
|
109
|
-
just build
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
### Just Commands
|
|
113
|
-
|
|
114
|
-
```bash
|
|
115
|
-
# JSI + TurboModule bindings, the iOS XCFramework, and ddk-ts
|
|
116
|
-
just build
|
|
117
|
-
|
|
118
|
-
# Generate JSI bindings only (TypeScript + C++)
|
|
119
|
-
just uniffi-jsi
|
|
120
|
-
|
|
121
|
-
# Generate TurboModule specifications
|
|
122
|
-
just uniffi-turbo
|
|
123
|
-
|
|
124
|
-
# Build the iOS XCFramework (release, stripped)
|
|
125
|
-
just build-ios
|
|
100
|
+
Run from the repository root:
|
|
126
101
|
|
|
127
|
-
|
|
128
|
-
just
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
just
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
just example-
|
|
135
|
-
|
|
136
|
-
# Android example build
|
|
137
|
-
just example-android
|
|
138
|
-
|
|
139
|
-
# Report the size of every binary destined for the npm package
|
|
140
|
-
just binary-sizes
|
|
141
|
-
|
|
142
|
-
# Clean all generated files
|
|
143
|
-
just clean
|
|
102
|
+
```sh
|
|
103
|
+
just install
|
|
104
|
+
just generate-react-native
|
|
105
|
+
just build react-native ios
|
|
106
|
+
just build react-native android
|
|
107
|
+
just native example-ios
|
|
108
|
+
just example react-native ios
|
|
109
|
+
just example react-native android
|
|
144
110
|
```
|
|
145
111
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
> app fails at link with `Undefined symbols … _uniffi_ddk_ffi_fn_func_<name>`.
|
|
150
|
-
> Nothing earlier in the chain catches this.
|
|
151
|
-
|
|
152
|
-
### Project Structure
|
|
153
|
-
|
|
154
|
-
```
|
|
155
|
-
ddk-rn/
|
|
156
|
-
├── src/ # Generated TypeScript bindings
|
|
157
|
-
│ ├── index.tsx # Main entry point (generated)
|
|
158
|
-
│ ├── ddk_ffi.ts # The API consumers import (generated)
|
|
159
|
-
│ ├── ddk_ffi-ffi.ts # Native JSI symbol declarations (generated)
|
|
160
|
-
│ └── __tests__/ # Hand-written — the only non-generated code in src/
|
|
161
|
-
├── cpp/ # Generated C++ JSI bindings
|
|
162
|
-
│ ├── ddk_ffi.hpp # C++ header (generated)
|
|
163
|
-
│ ├── ddk_ffi.cpp # C++ implementation (generated)
|
|
164
|
-
│ └── *.cpp/.h # TurboModule files (generated)
|
|
165
|
-
├── ios/ # iOS native module
|
|
166
|
-
│ ├── DdkRn.xcframework/ # Prebuilt iOS framework (generated, shipped)
|
|
167
|
-
│ └── *.h/.mm # iOS bridge code
|
|
168
|
-
├── android/ # Android native module
|
|
169
|
-
│ └── src/main/
|
|
170
|
-
│ ├── java/ # Kotlin/Java bridge code
|
|
171
|
-
│ └── jniLibs/ # Prebuilt native libraries (generated, shipped)
|
|
172
|
-
├── example/ # Example React Native app + Maestro flows
|
|
173
|
-
├── patches/ # pnpm patch for an unreleased ubrn fix
|
|
174
|
-
├── scripts/ # Package verification
|
|
175
|
-
└── ubrn.config.yaml # UniFFI React Native configuration
|
|
176
|
-
```
|
|
112
|
+
The package's `src/index.tsx` re-exports `src/generated/`. UniFFI owns everything
|
|
113
|
+
under `src/generated/` and the native adapters in `cpp/`, `ios/` and `android/`.
|
|
114
|
+
The example and Maestro flows live in `../../examples/react-native/`.
|
|
177
115
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
116
|
+
Native build and device-test recipes live in this package's `justfile`.
|
|
117
|
+
`just native --list` from the repository root lists the individual steps.
|
|
118
|
+
Rebuild native libraries after changing Rust exports, as generating TypeScript
|
|
119
|
+
alone does not update the linked native symbols.
|
|
181
120
|
|
|
182
121
|
### Testing
|
|
183
122
|
|
|
@@ -192,8 +131,8 @@ bindings can't execute under Node, so it asserts instead that generation was
|
|
|
192
131
|
complete — every function, record, and constructor present in both the
|
|
193
132
|
TypeScript surface and the native symbol layer. It catches the classic
|
|
194
133
|
regression where `ddk-ffi` changed but `ddk-rn` wasn't regenerated. Runtime
|
|
195
|
-
behavior is covered by the shared Rust (`ddk-ffi` unit tests and the `ddk
|
|
196
|
-
|
|
134
|
+
behavior is covered by the shared Rust (`ddk-ffi` unit tests and the `ddk`
|
|
135
|
+
suites exercise the same functions).
|
|
197
136
|
|
|
198
137
|
### End-to-end, on a device
|
|
199
138
|
|
|
@@ -204,12 +143,12 @@ launching.
|
|
|
204
143
|
|
|
205
144
|
| command | needs | time |
|
|
206
145
|
|---|---|---|
|
|
207
|
-
| `just e2e-flows` | nothing — no device, no app | ~15s |
|
|
208
|
-
| `just e2e-ios-test` | the app already installed | ~10s |
|
|
209
|
-
| `just e2e-ios` | full: build + install + run | ~5-10m |
|
|
146
|
+
| `just native e2e-flows` | nothing — no device, no app | ~15s |
|
|
147
|
+
| `just native e2e-ios-test` | the app already installed | ~10s |
|
|
148
|
+
| `just native e2e-ios` | full: build + install + run | ~5-10m |
|
|
210
149
|
|
|
211
|
-
Android needs a one-time `just e2e-android-setup` (~1.5GB) to create the
|
|
212
|
-
emulator and AVD, then `just e2e-android`.
|
|
150
|
+
Android needs a one-time `just native e2e-android-setup` (~1.5GB) to create the
|
|
151
|
+
emulator and AVD, then `just native e2e-android`.
|
|
213
152
|
|
|
214
153
|
While editing a flow, stay in `e2e-ios-test`; only rebuild when the app itself
|
|
215
154
|
changes (JS, Rust, or the generated bindings).
|
|
@@ -235,10 +174,10 @@ apps actually build with.
|
|
|
235
174
|
|
|
236
175
|
```bash
|
|
237
176
|
# Install iOS dependencies with new architecture
|
|
238
|
-
just example-ios
|
|
177
|
+
just example react-native ios
|
|
239
178
|
|
|
240
179
|
# Run the app
|
|
241
|
-
cd
|
|
180
|
+
cd ../../examples/react-native
|
|
242
181
|
npx react-native run-ios
|
|
243
182
|
```
|
|
244
183
|
|
|
@@ -246,16 +185,16 @@ npx react-native run-ios
|
|
|
246
185
|
|
|
247
186
|
```bash
|
|
248
187
|
# Build Android app
|
|
249
|
-
just example-android
|
|
188
|
+
just example react-native android
|
|
250
189
|
|
|
251
190
|
# Run the app
|
|
252
|
-
cd
|
|
191
|
+
cd ../../examples/react-native
|
|
253
192
|
npx react-native run-android
|
|
254
193
|
```
|
|
255
194
|
|
|
256
195
|
### Release Process
|
|
257
196
|
|
|
258
|
-
`ddk
|
|
197
|
+
`ddk` and `ddk-rn` are versioned and released together, from the repo root:
|
|
259
198
|
|
|
260
199
|
```bash
|
|
261
200
|
just release 0.5.0
|
|
@@ -264,7 +203,7 @@ just release 0.5.0
|
|
|
264
203
|
This will:
|
|
265
204
|
|
|
266
205
|
1. Check the working directory is clean
|
|
267
|
-
2. Set the version in `
|
|
206
|
+
2. Set the version in `packages/node-browser/package.json`, `packages/react-native/package.json` and `ffi/Cargo.toml`
|
|
268
207
|
3. Commit, tag as `v0.5.0` and push
|
|
269
208
|
|
|
270
209
|
Publishing happens in CI — pushing the tag is what publishes. The iOS
|
|
@@ -284,11 +223,10 @@ All bindings are generated from the compiled `ddk-ffi` library, whose Rust
|
|
|
284
223
|
source — annotated with UniFFI proc-macros, with no `.udl` file — is the single
|
|
285
224
|
source of truth for the interface.
|
|
286
225
|
|
|
287
|
-
`@bennyblader/ddk
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
[comparison table](../README.md#where-the-two-packages-differ).
|
|
226
|
+
`@bennyblader/ddk` (Node and browsers) is generated from the same library by the
|
|
227
|
+
same bindgen, so it has the same names, the same argument lists and the same
|
|
228
|
+
`Uint8Array` byte type. The one difference: its browser build needs
|
|
229
|
+
`await init()` before the first call.
|
|
292
230
|
|
|
293
231
|
### Known Issues
|
|
294
232
|
|
|
@@ -303,7 +241,7 @@ there, and a dozen transaction operations are methods on a record here
|
|
|
303
241
|
If you encounter build issues on iOS:
|
|
304
242
|
|
|
305
243
|
```bash
|
|
306
|
-
cd
|
|
244
|
+
cd ../../examples/react-native/ios
|
|
307
245
|
pod deintegrate
|
|
308
246
|
pod install
|
|
309
247
|
```
|
|
@@ -313,7 +251,7 @@ pod install
|
|
|
313
251
|
Clean and rebuild Android:
|
|
314
252
|
|
|
315
253
|
```bash
|
|
316
|
-
cd
|
|
254
|
+
cd ../../examples/react-native/android
|
|
317
255
|
./gradlew clean
|
|
318
256
|
./gradlew build
|
|
319
257
|
```
|
|
@@ -323,13 +261,13 @@ cd example/android
|
|
|
323
261
|
If bindings are missing, regenerate them:
|
|
324
262
|
|
|
325
263
|
```bash
|
|
326
|
-
|
|
327
|
-
just build
|
|
264
|
+
pnpm --dir packages/react-native clean
|
|
265
|
+
just build react-native ios
|
|
328
266
|
```
|
|
329
267
|
|
|
330
268
|
### A modified `android/build.gradle` after building
|
|
331
269
|
|
|
332
|
-
`just build-android <abi>` narrows `abiFilters` to the ABIs you passed and wipes
|
|
270
|
+
`just native build-android <abi>` narrows `abiFilters` to the ABIs you passed and wipes
|
|
333
271
|
`jniLibs/` for the rest. Never commit that — a single-ABI `build.gradle` ships an
|
|
334
272
|
app that only runs on one architecture:
|
|
335
273
|
|
package/android/build.gradle
CHANGED
|
@@ -133,7 +133,6 @@ dependencies {
|
|
|
133
133
|
//noinspection GradleDynamicVersion
|
|
134
134
|
implementation "com.facebook.react:react-native:+"
|
|
135
135
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
136
|
-
implementation "net.java.dev.jna:jna:5.17.0@aar"
|
|
137
136
|
}
|
|
138
137
|
|
|
139
138
|
if (isNewArchitectureEnabled()) {
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|