@bennyblader/ddk-rn 1.0.0-rc6 → 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.
Files changed (70) hide show
  1. package/README.md +39 -100
  2. package/android/build.gradle +0 -1
  3. package/android/src/main/jniLibs/arm64-v8a/libddk_ffi.so +0 -0
  4. package/android/src/main/jniLibs/armeabi-v7a/libddk_ffi.so +0 -0
  5. package/android/src/main/jniLibs/x86/libddk_ffi.so +0 -0
  6. package/android/src/main/jniLibs/x86_64/libddk_ffi.so +0 -0
  7. package/cpp/ddk_ffi.cpp +4583 -1245
  8. package/cpp/ddk_ffi.hpp +115 -10
  9. package/ios/DdkRn.xcframework/Info.plist +4 -4
  10. package/ios/DdkRn.xcframework/ios-arm64/libddk_ffi.a +0 -0
  11. package/ios/DdkRn.xcframework/ios-arm64-simulator/libddk_ffi.a +0 -0
  12. package/lib/commonjs/generated/NativeDdkRn.js.map +1 -0
  13. package/lib/commonjs/generated/ddk_ffi-ffi.js.map +1 -0
  14. package/lib/commonjs/{ddk_ffi.js → generated/ddk_ffi.js} +1458 -189
  15. package/lib/commonjs/generated/ddk_ffi.js.map +1 -0
  16. package/lib/commonjs/generated/index.js +63 -0
  17. package/lib/commonjs/generated/index.js.map +1 -0
  18. package/lib/commonjs/index.js +11 -48
  19. package/lib/commonjs/index.js.map +1 -1
  20. package/lib/module/generated/NativeDdkRn.js.map +1 -0
  21. package/lib/module/generated/ddk_ffi-ffi.js.map +1 -0
  22. package/lib/module/{ddk_ffi.js → generated/ddk_ffi.js} +1442 -184
  23. package/lib/module/generated/ddk_ffi.js.map +1 -0
  24. package/lib/module/generated/index.js +43 -0
  25. package/lib/module/generated/index.js.map +1 -0
  26. package/lib/module/index.js +2 -40
  27. package/lib/module/index.js.map +1 -1
  28. package/lib/typescript/commonjs/src/generated/NativeDdkRn.d.ts.map +1 -0
  29. package/lib/typescript/commonjs/src/{ddk_ffi-ffi.d.ts → generated/ddk_ffi-ffi.d.ts} +103 -15
  30. package/lib/typescript/commonjs/src/generated/ddk_ffi-ffi.d.ts.map +1 -0
  31. package/lib/typescript/{module/src → commonjs/src/generated}/ddk_ffi.d.ts +702 -125
  32. package/lib/typescript/commonjs/src/generated/ddk_ffi.d.ts.map +1 -0
  33. package/lib/typescript/commonjs/src/generated/index.d.ts +8 -0
  34. package/lib/typescript/commonjs/src/generated/index.d.ts.map +1 -0
  35. package/lib/typescript/commonjs/src/index.d.ts +2 -7
  36. package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
  37. package/lib/typescript/module/src/generated/NativeDdkRn.d.ts.map +1 -0
  38. package/lib/typescript/module/src/{ddk_ffi-ffi.d.ts → generated/ddk_ffi-ffi.d.ts} +103 -15
  39. package/lib/typescript/module/src/generated/ddk_ffi-ffi.d.ts.map +1 -0
  40. package/lib/typescript/{commonjs/src → module/src/generated}/ddk_ffi.d.ts +702 -125
  41. package/lib/typescript/module/src/generated/ddk_ffi.d.ts.map +1 -0
  42. package/lib/typescript/module/src/generated/index.d.ts +8 -0
  43. package/lib/typescript/module/src/generated/index.d.ts.map +1 -0
  44. package/lib/typescript/module/src/index.d.ts +2 -7
  45. package/lib/typescript/module/src/index.d.ts.map +1 -1
  46. package/package.json +18 -47
  47. package/src/{ddk_ffi-ffi.ts → generated/ddk_ffi-ffi.ts} +261 -37
  48. package/src/{ddk_ffi.ts → generated/ddk_ffi.ts} +2585 -430
  49. package/src/generated/index.tsx +41 -0
  50. package/src/index.tsx +2 -41
  51. package/ubrn.config.yaml +4 -3
  52. package/lib/commonjs/NativeDdkRn.js.map +0 -1
  53. package/lib/commonjs/ddk_ffi-ffi.js.map +0 -1
  54. package/lib/commonjs/ddk_ffi.js.map +0 -1
  55. package/lib/module/NativeDdkRn.js.map +0 -1
  56. package/lib/module/ddk_ffi-ffi.js.map +0 -1
  57. package/lib/module/ddk_ffi.js.map +0 -1
  58. package/lib/typescript/commonjs/src/NativeDdkRn.d.ts.map +0 -1
  59. package/lib/typescript/commonjs/src/ddk_ffi-ffi.d.ts.map +0 -1
  60. package/lib/typescript/commonjs/src/ddk_ffi.d.ts.map +0 -1
  61. package/lib/typescript/module/src/NativeDdkRn.d.ts.map +0 -1
  62. package/lib/typescript/module/src/ddk_ffi-ffi.d.ts.map +0 -1
  63. package/lib/typescript/module/src/ddk_ffi.d.ts.map +0 -1
  64. /package/lib/commonjs/{NativeDdkRn.js → generated/NativeDdkRn.js} +0 -0
  65. /package/lib/commonjs/{ddk_ffi-ffi.js → generated/ddk_ffi-ffi.js} +0 -0
  66. /package/lib/module/{NativeDdkRn.js → generated/NativeDdkRn.js} +0 -0
  67. /package/lib/module/{ddk_ffi-ffi.js → generated/ddk_ffi-ffi.js} +0 -0
  68. /package/lib/typescript/commonjs/src/{NativeDdkRn.d.ts → generated/NativeDdkRn.d.ts} +0 -0
  69. /package/lib/typescript/module/src/{NativeDdkRn.d.ts → generated/NativeDdkRn.d.ts} +0 -0
  70. /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
- signContractCet,
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
- // signContractCet / signContractRefund
74
+ // contractCetTransaction / contractRefundTransaction
75
75
  ```
76
76
 
77
77
  Bytes cross the JSI boundary as `Uint8Array`, as they do in `@bennyblader/ddk`.
78
78
 
79
- `example/src/App.tsx` runs the complete flow on device — offline, deterministic,
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](../README.md#-the-contract-api).
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 globally at the version pinned in
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
- > The `uniffi` crate, this package's `uniffi-bindgen-react-native` dependency,
97
- > and the globally installed binary must all be the same release — the `just`
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 Source
98
+ ### Building from source
103
99
 
104
- ```bash
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 @bennyblader/ddk (N-API)
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
- # Build the Android JNI libraries (needs the NDK)
128
- just build-android
129
-
130
- # Setup example app
131
- just example
132
-
133
- # iOS example setup
134
- just example-ios
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
- > Adding a new `#[uniffi::export]` needs `just build-ios`, not just
147
- > `just uniffi-jsi`. `uniffi-jsi` regenerates the TypeScript and C++, but the C++
148
- > calls into the XCFramework, which only `build-ios` rebuilds — skip it and the
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
- Everything in `src/` except `src/__tests__/` is generated — don't hand-edit it,
179
- and don't "fix" lint errors inside it (those files are in `eslintIgnore` for
180
- exactly that reason).
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
 
@@ -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 example
180
+ cd ../../examples/react-native
242
181
  npx react-native run-ios
243
182
  ```
244
183
 
@@ -246,10 +185,10 @@ 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 example
191
+ cd ../../examples/react-native
253
192
  npx react-native run-android
254
193
  ```
255
194
 
@@ -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 `typescript/package.json`, `ddk-rn/package.json` and `ddk-ffi/Cargo.toml`
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
@@ -302,7 +241,7 @@ same bindgen, so it has the same names, the same argument lists and the same
302
241
  If you encounter build issues on iOS:
303
242
 
304
243
  ```bash
305
- cd example/ios
244
+ cd ../../examples/react-native/ios
306
245
  pod deintegrate
307
246
  pod install
308
247
  ```
@@ -312,7 +251,7 @@ pod install
312
251
  Clean and rebuild Android:
313
252
 
314
253
  ```bash
315
- cd example/android
254
+ cd ../../examples/react-native/android
316
255
  ./gradlew clean
317
256
  ./gradlew build
318
257
  ```
@@ -322,13 +261,13 @@ cd example/android
322
261
  If bindings are missing, regenerate them:
323
262
 
324
263
  ```bash
325
- just clean
326
- just build
264
+ pnpm --dir packages/react-native clean
265
+ just build react-native ios
327
266
  ```
328
267
 
329
268
  ### A modified `android/build.gradle` after building
330
269
 
331
- `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
332
271
  `jniLibs/` for the rest. Never commit that — a single-ABI `build.gradle` ships an
333
272
  app that only runs on one architecture:
334
273
 
@@ -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()) {