@bennyblader/ddk-ts 0.1.5
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/LICENSE +21 -0
- package/README.md +150 -0
- package/index.js +524 -0
- package/package.json +95 -0
- package/src/conversions.rs +268 -0
- package/src/lib.rs +285 -0
- package/src/types.rs +111 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 N-API for Rust
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
# @bennyblader/ddk-ts
|
|
2
|
+
|
|
3
|
+
TypeScript/Node.js bindings for the DLC Dev Kit (DDK) - NAPI-RS based native bindings for Node.js applications.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @bennyblader/ddk-ts
|
|
9
|
+
# or
|
|
10
|
+
yarn add @bennyblader/ddk-ts
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
The package includes prebuilt binaries for:
|
|
14
|
+
- macOS ARM64 (Apple Silicon)
|
|
15
|
+
- Linux x64 (glibc)
|
|
16
|
+
|
|
17
|
+
## Quick Start
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import { version, createFundTxLockingScript } from '@bennyblader/ddk-ts';
|
|
21
|
+
|
|
22
|
+
console.log(`DDK Version: ${version()}`);
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
For complete API documentation, see the [main README](../README.md#api-reference).
|
|
26
|
+
|
|
27
|
+
## Development
|
|
28
|
+
|
|
29
|
+
### Prerequisites
|
|
30
|
+
|
|
31
|
+
- Node.js >= 14
|
|
32
|
+
- Rust >= 1.70
|
|
33
|
+
- Yarn
|
|
34
|
+
- NAPI-RS CLI: `npm install -g @napi-rs/cli`
|
|
35
|
+
|
|
36
|
+
### Building from Source
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
# Install dependencies
|
|
40
|
+
yarn install
|
|
41
|
+
|
|
42
|
+
# Build for current platform
|
|
43
|
+
yarn build
|
|
44
|
+
|
|
45
|
+
# Build for all supported platforms (Darwin ARM64 and Linux x64)
|
|
46
|
+
yarn build:all
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Just Commands
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
# Build TypeScript bindings for current platform
|
|
53
|
+
just ts-build
|
|
54
|
+
|
|
55
|
+
# Build for all supported platforms
|
|
56
|
+
just ts-build-all
|
|
57
|
+
|
|
58
|
+
# Run example
|
|
59
|
+
just ts-example
|
|
60
|
+
|
|
61
|
+
# Run tests
|
|
62
|
+
just ts-test
|
|
63
|
+
|
|
64
|
+
# Development setup (build + example setup)
|
|
65
|
+
just ts-dev
|
|
66
|
+
|
|
67
|
+
# Release new version to npm
|
|
68
|
+
just ts-release <version>
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Project Structure
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
ddk-ts/
|
|
75
|
+
├── src-napi/ # Rust NAPI-RS source code
|
|
76
|
+
│ ├── lib.rs # Main library wrapper functions
|
|
77
|
+
│ ├── types.rs # Type definitions matching UDL
|
|
78
|
+
│ └── conversions.rs # Type conversions between Rust and JS
|
|
79
|
+
├── src/ # Generated TypeScript/JavaScript files
|
|
80
|
+
│ ├── index.js # Main entry point (generated)
|
|
81
|
+
│ └── index.d.ts # TypeScript definitions (generated)
|
|
82
|
+
├── npm/ # Platform-specific packages
|
|
83
|
+
│ ├── darwin-arm64/ # macOS ARM64 package
|
|
84
|
+
│ └── linux-x64-gnu/ # Linux x64 package
|
|
85
|
+
├── example/ # Example TypeScript application
|
|
86
|
+
├── __test__/ # Test files
|
|
87
|
+
└── scripts/ # Build and verification scripts
|
|
88
|
+
└── verify-parity.js # Ensures API compatibility with UDL
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Testing
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
# Run all tests
|
|
95
|
+
yarn test
|
|
96
|
+
|
|
97
|
+
# Run verification scripts
|
|
98
|
+
yarn verify # Run all verification checks
|
|
99
|
+
yarn verify:parity # Check API parity with UDL definitions
|
|
100
|
+
yarn verify:types # Verify TypeScript types
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Platform Support
|
|
104
|
+
|
|
105
|
+
| Platform | Architecture | Status |
|
|
106
|
+
|----------|-------------|---------|
|
|
107
|
+
| macOS | ARM64 (Apple Silicon) | ✅ Supported |
|
|
108
|
+
| Linux | x64 (glibc) | ✅ Supported |
|
|
109
|
+
| macOS | x64 (Intel) | ❌ Not included |
|
|
110
|
+
| Windows | x64 | ❌ Not included |
|
|
111
|
+
| Linux | ARM64 | ❌ Not included |
|
|
112
|
+
|
|
113
|
+
### Release Process
|
|
114
|
+
|
|
115
|
+
To release a new version:
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
just ts-release 0.2.0
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
This will:
|
|
122
|
+
1. Check working directory is clean
|
|
123
|
+
2. Update version in package.json
|
|
124
|
+
3. Build for all supported platforms
|
|
125
|
+
4. Run tests
|
|
126
|
+
5. Commit and tag as `ddk-ts-v0.2.0`
|
|
127
|
+
6. Push to GitHub
|
|
128
|
+
7. Publish to npm
|
|
129
|
+
|
|
130
|
+
### API Compatibility
|
|
131
|
+
|
|
132
|
+
The TypeScript bindings maintain 100% API compatibility with the UniFFI definitions. The [verify-parity.js](scripts/verify-parity.js) script ensures that all functions defined in the UDL file are properly exposed in the TypeScript bindings.
|
|
133
|
+
|
|
134
|
+
## Troubleshooting
|
|
135
|
+
|
|
136
|
+
### Missing Binary
|
|
137
|
+
|
|
138
|
+
If you get an error about missing binaries, ensure your platform is supported or build from source:
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
yarn build
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### BigInt Support
|
|
145
|
+
|
|
146
|
+
All 64-bit integers are represented as JavaScript `BigInt`. Make sure your Node.js version supports BigInt (Node.js 10.4.0+).
|
|
147
|
+
|
|
148
|
+
## License
|
|
149
|
+
|
|
150
|
+
MIT
|
package/index.js
ADDED
|
@@ -0,0 +1,524 @@
|
|
|
1
|
+
// prettier-ignore
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
// @ts-nocheck
|
|
4
|
+
/* auto-generated by NAPI-RS */
|
|
5
|
+
|
|
6
|
+
const { createRequire } = require('node:module')
|
|
7
|
+
require = createRequire(__filename)
|
|
8
|
+
|
|
9
|
+
const { readFileSync } = require('node:fs')
|
|
10
|
+
let nativeBinding = null
|
|
11
|
+
const loadErrors = []
|
|
12
|
+
|
|
13
|
+
const isMusl = () => {
|
|
14
|
+
let musl = false
|
|
15
|
+
if (process.platform === 'linux') {
|
|
16
|
+
musl = isMuslFromFilesystem()
|
|
17
|
+
if (musl === null) {
|
|
18
|
+
musl = isMuslFromReport()
|
|
19
|
+
}
|
|
20
|
+
if (musl === null) {
|
|
21
|
+
musl = isMuslFromChildProcess()
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return musl
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const isFileMusl = (f) => f.includes('libc.musl-') || f.includes('ld-musl-')
|
|
28
|
+
|
|
29
|
+
const isMuslFromFilesystem = () => {
|
|
30
|
+
try {
|
|
31
|
+
return readFileSync('/usr/bin/ldd', 'utf-8').includes('musl')
|
|
32
|
+
} catch {
|
|
33
|
+
return null
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const isMuslFromReport = () => {
|
|
38
|
+
let report = null
|
|
39
|
+
if (typeof process.report?.getReport === 'function') {
|
|
40
|
+
process.report.excludeNetwork = true
|
|
41
|
+
report = process.report.getReport()
|
|
42
|
+
}
|
|
43
|
+
if (!report) {
|
|
44
|
+
return null
|
|
45
|
+
}
|
|
46
|
+
if (report.header && report.header.glibcVersionRuntime) {
|
|
47
|
+
return false
|
|
48
|
+
}
|
|
49
|
+
if (Array.isArray(report.sharedObjects)) {
|
|
50
|
+
if (report.sharedObjects.some(isFileMusl)) {
|
|
51
|
+
return true
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return false
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const isMuslFromChildProcess = () => {
|
|
58
|
+
try {
|
|
59
|
+
return require('child_process').execSync('ldd --version', { encoding: 'utf8' }).includes('musl')
|
|
60
|
+
} catch (e) {
|
|
61
|
+
// If we reach this case, we don't know if the system is musl or not, so is better to just fallback to false
|
|
62
|
+
return false
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function requireNative() {
|
|
67
|
+
if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) {
|
|
68
|
+
try {
|
|
69
|
+
nativeBinding = require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);
|
|
70
|
+
} catch (err) {
|
|
71
|
+
loadErrors.push(err)
|
|
72
|
+
}
|
|
73
|
+
} else if (process.platform === 'android') {
|
|
74
|
+
if (process.arch === 'arm64') {
|
|
75
|
+
try {
|
|
76
|
+
return require('./ddk-ts.android-arm64.node')
|
|
77
|
+
} catch (e) {
|
|
78
|
+
loadErrors.push(e)
|
|
79
|
+
}
|
|
80
|
+
try {
|
|
81
|
+
const binding = require('@bennyblader/ddk-ts-android-arm64')
|
|
82
|
+
const bindingPackageVersion = require('@bennyblader/ddk-ts-android-arm64/package.json').version
|
|
83
|
+
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
84
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
85
|
+
}
|
|
86
|
+
return binding
|
|
87
|
+
} catch (e) {
|
|
88
|
+
loadErrors.push(e)
|
|
89
|
+
}
|
|
90
|
+
} else if (process.arch === 'arm') {
|
|
91
|
+
try {
|
|
92
|
+
return require('./ddk-ts.android-arm-eabi.node')
|
|
93
|
+
} catch (e) {
|
|
94
|
+
loadErrors.push(e)
|
|
95
|
+
}
|
|
96
|
+
try {
|
|
97
|
+
const binding = require('@bennyblader/ddk-ts-android-arm-eabi')
|
|
98
|
+
const bindingPackageVersion = require('@bennyblader/ddk-ts-android-arm-eabi/package.json').version
|
|
99
|
+
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
100
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
101
|
+
}
|
|
102
|
+
return binding
|
|
103
|
+
} catch (e) {
|
|
104
|
+
loadErrors.push(e)
|
|
105
|
+
}
|
|
106
|
+
} else {
|
|
107
|
+
loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`))
|
|
108
|
+
}
|
|
109
|
+
} else if (process.platform === 'win32') {
|
|
110
|
+
if (process.arch === 'x64') {
|
|
111
|
+
try {
|
|
112
|
+
return require('./ddk-ts.win32-x64-msvc.node')
|
|
113
|
+
} catch (e) {
|
|
114
|
+
loadErrors.push(e)
|
|
115
|
+
}
|
|
116
|
+
try {
|
|
117
|
+
const binding = require('@bennyblader/ddk-ts-win32-x64-msvc')
|
|
118
|
+
const bindingPackageVersion = require('@bennyblader/ddk-ts-win32-x64-msvc/package.json').version
|
|
119
|
+
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
120
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
121
|
+
}
|
|
122
|
+
return binding
|
|
123
|
+
} catch (e) {
|
|
124
|
+
loadErrors.push(e)
|
|
125
|
+
}
|
|
126
|
+
} else if (process.arch === 'ia32') {
|
|
127
|
+
try {
|
|
128
|
+
return require('./ddk-ts.win32-ia32-msvc.node')
|
|
129
|
+
} catch (e) {
|
|
130
|
+
loadErrors.push(e)
|
|
131
|
+
}
|
|
132
|
+
try {
|
|
133
|
+
const binding = require('@bennyblader/ddk-ts-win32-ia32-msvc')
|
|
134
|
+
const bindingPackageVersion = require('@bennyblader/ddk-ts-win32-ia32-msvc/package.json').version
|
|
135
|
+
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
136
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
137
|
+
}
|
|
138
|
+
return binding
|
|
139
|
+
} catch (e) {
|
|
140
|
+
loadErrors.push(e)
|
|
141
|
+
}
|
|
142
|
+
} else if (process.arch === 'arm64') {
|
|
143
|
+
try {
|
|
144
|
+
return require('./ddk-ts.win32-arm64-msvc.node')
|
|
145
|
+
} catch (e) {
|
|
146
|
+
loadErrors.push(e)
|
|
147
|
+
}
|
|
148
|
+
try {
|
|
149
|
+
const binding = require('@bennyblader/ddk-ts-win32-arm64-msvc')
|
|
150
|
+
const bindingPackageVersion = require('@bennyblader/ddk-ts-win32-arm64-msvc/package.json').version
|
|
151
|
+
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
152
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
153
|
+
}
|
|
154
|
+
return binding
|
|
155
|
+
} catch (e) {
|
|
156
|
+
loadErrors.push(e)
|
|
157
|
+
}
|
|
158
|
+
} else {
|
|
159
|
+
loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`))
|
|
160
|
+
}
|
|
161
|
+
} else if (process.platform === 'darwin') {
|
|
162
|
+
try {
|
|
163
|
+
return require('./ddk-ts.darwin-universal.node')
|
|
164
|
+
} catch (e) {
|
|
165
|
+
loadErrors.push(e)
|
|
166
|
+
}
|
|
167
|
+
try {
|
|
168
|
+
const binding = require('@bennyblader/ddk-ts-darwin-universal')
|
|
169
|
+
const bindingPackageVersion = require('@bennyblader/ddk-ts-darwin-universal/package.json').version
|
|
170
|
+
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
171
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
172
|
+
}
|
|
173
|
+
return binding
|
|
174
|
+
} catch (e) {
|
|
175
|
+
loadErrors.push(e)
|
|
176
|
+
}
|
|
177
|
+
if (process.arch === 'x64') {
|
|
178
|
+
try {
|
|
179
|
+
return require('./ddk-ts.darwin-x64.node')
|
|
180
|
+
} catch (e) {
|
|
181
|
+
loadErrors.push(e)
|
|
182
|
+
}
|
|
183
|
+
try {
|
|
184
|
+
const binding = require('@bennyblader/ddk-ts-darwin-x64')
|
|
185
|
+
const bindingPackageVersion = require('@bennyblader/ddk-ts-darwin-x64/package.json').version
|
|
186
|
+
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
187
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
188
|
+
}
|
|
189
|
+
return binding
|
|
190
|
+
} catch (e) {
|
|
191
|
+
loadErrors.push(e)
|
|
192
|
+
}
|
|
193
|
+
} else if (process.arch === 'arm64') {
|
|
194
|
+
try {
|
|
195
|
+
return require('./ddk-ts.darwin-arm64.node')
|
|
196
|
+
} catch (e) {
|
|
197
|
+
loadErrors.push(e)
|
|
198
|
+
}
|
|
199
|
+
try {
|
|
200
|
+
const binding = require('@bennyblader/ddk-ts-darwin-arm64')
|
|
201
|
+
const bindingPackageVersion = require('@bennyblader/ddk-ts-darwin-arm64/package.json').version
|
|
202
|
+
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
203
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
204
|
+
}
|
|
205
|
+
return binding
|
|
206
|
+
} catch (e) {
|
|
207
|
+
loadErrors.push(e)
|
|
208
|
+
}
|
|
209
|
+
} else {
|
|
210
|
+
loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`))
|
|
211
|
+
}
|
|
212
|
+
} else if (process.platform === 'freebsd') {
|
|
213
|
+
if (process.arch === 'x64') {
|
|
214
|
+
try {
|
|
215
|
+
return require('./ddk-ts.freebsd-x64.node')
|
|
216
|
+
} catch (e) {
|
|
217
|
+
loadErrors.push(e)
|
|
218
|
+
}
|
|
219
|
+
try {
|
|
220
|
+
const binding = require('@bennyblader/ddk-ts-freebsd-x64')
|
|
221
|
+
const bindingPackageVersion = require('@bennyblader/ddk-ts-freebsd-x64/package.json').version
|
|
222
|
+
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
223
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
224
|
+
}
|
|
225
|
+
return binding
|
|
226
|
+
} catch (e) {
|
|
227
|
+
loadErrors.push(e)
|
|
228
|
+
}
|
|
229
|
+
} else if (process.arch === 'arm64') {
|
|
230
|
+
try {
|
|
231
|
+
return require('./ddk-ts.freebsd-arm64.node')
|
|
232
|
+
} catch (e) {
|
|
233
|
+
loadErrors.push(e)
|
|
234
|
+
}
|
|
235
|
+
try {
|
|
236
|
+
const binding = require('@bennyblader/ddk-ts-freebsd-arm64')
|
|
237
|
+
const bindingPackageVersion = require('@bennyblader/ddk-ts-freebsd-arm64/package.json').version
|
|
238
|
+
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
239
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
240
|
+
}
|
|
241
|
+
return binding
|
|
242
|
+
} catch (e) {
|
|
243
|
+
loadErrors.push(e)
|
|
244
|
+
}
|
|
245
|
+
} else {
|
|
246
|
+
loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`))
|
|
247
|
+
}
|
|
248
|
+
} else if (process.platform === 'linux') {
|
|
249
|
+
if (process.arch === 'x64') {
|
|
250
|
+
if (isMusl()) {
|
|
251
|
+
try {
|
|
252
|
+
return require('./ddk-ts.linux-x64-musl.node')
|
|
253
|
+
} catch (e) {
|
|
254
|
+
loadErrors.push(e)
|
|
255
|
+
}
|
|
256
|
+
try {
|
|
257
|
+
const binding = require('@bennyblader/ddk-ts-linux-x64-musl')
|
|
258
|
+
const bindingPackageVersion = require('@bennyblader/ddk-ts-linux-x64-musl/package.json').version
|
|
259
|
+
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
260
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
261
|
+
}
|
|
262
|
+
return binding
|
|
263
|
+
} catch (e) {
|
|
264
|
+
loadErrors.push(e)
|
|
265
|
+
}
|
|
266
|
+
} else {
|
|
267
|
+
try {
|
|
268
|
+
return require('./ddk-ts.linux-x64-gnu.node')
|
|
269
|
+
} catch (e) {
|
|
270
|
+
loadErrors.push(e)
|
|
271
|
+
}
|
|
272
|
+
try {
|
|
273
|
+
const binding = require('@bennyblader/ddk-ts-linux-x64-gnu')
|
|
274
|
+
const bindingPackageVersion = require('@bennyblader/ddk-ts-linux-x64-gnu/package.json').version
|
|
275
|
+
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
276
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
277
|
+
}
|
|
278
|
+
return binding
|
|
279
|
+
} catch (e) {
|
|
280
|
+
loadErrors.push(e)
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
} else if (process.arch === 'arm64') {
|
|
284
|
+
if (isMusl()) {
|
|
285
|
+
try {
|
|
286
|
+
return require('./ddk-ts.linux-arm64-musl.node')
|
|
287
|
+
} catch (e) {
|
|
288
|
+
loadErrors.push(e)
|
|
289
|
+
}
|
|
290
|
+
try {
|
|
291
|
+
const binding = require('@bennyblader/ddk-ts-linux-arm64-musl')
|
|
292
|
+
const bindingPackageVersion = require('@bennyblader/ddk-ts-linux-arm64-musl/package.json').version
|
|
293
|
+
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
294
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
295
|
+
}
|
|
296
|
+
return binding
|
|
297
|
+
} catch (e) {
|
|
298
|
+
loadErrors.push(e)
|
|
299
|
+
}
|
|
300
|
+
} else {
|
|
301
|
+
try {
|
|
302
|
+
return require('./ddk-ts.linux-arm64-gnu.node')
|
|
303
|
+
} catch (e) {
|
|
304
|
+
loadErrors.push(e)
|
|
305
|
+
}
|
|
306
|
+
try {
|
|
307
|
+
const binding = require('@bennyblader/ddk-ts-linux-arm64-gnu')
|
|
308
|
+
const bindingPackageVersion = require('@bennyblader/ddk-ts-linux-arm64-gnu/package.json').version
|
|
309
|
+
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
310
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
311
|
+
}
|
|
312
|
+
return binding
|
|
313
|
+
} catch (e) {
|
|
314
|
+
loadErrors.push(e)
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
} else if (process.arch === 'arm') {
|
|
318
|
+
if (isMusl()) {
|
|
319
|
+
try {
|
|
320
|
+
return require('./ddk-ts.linux-arm-musleabihf.node')
|
|
321
|
+
} catch (e) {
|
|
322
|
+
loadErrors.push(e)
|
|
323
|
+
}
|
|
324
|
+
try {
|
|
325
|
+
const binding = require('@bennyblader/ddk-ts-linux-arm-musleabihf')
|
|
326
|
+
const bindingPackageVersion = require('@bennyblader/ddk-ts-linux-arm-musleabihf/package.json').version
|
|
327
|
+
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
328
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
329
|
+
}
|
|
330
|
+
return binding
|
|
331
|
+
} catch (e) {
|
|
332
|
+
loadErrors.push(e)
|
|
333
|
+
}
|
|
334
|
+
} else {
|
|
335
|
+
try {
|
|
336
|
+
return require('./ddk-ts.linux-arm-gnueabihf.node')
|
|
337
|
+
} catch (e) {
|
|
338
|
+
loadErrors.push(e)
|
|
339
|
+
}
|
|
340
|
+
try {
|
|
341
|
+
const binding = require('@bennyblader/ddk-ts-linux-arm-gnueabihf')
|
|
342
|
+
const bindingPackageVersion = require('@bennyblader/ddk-ts-linux-arm-gnueabihf/package.json').version
|
|
343
|
+
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
344
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
345
|
+
}
|
|
346
|
+
return binding
|
|
347
|
+
} catch (e) {
|
|
348
|
+
loadErrors.push(e)
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
} else if (process.arch === 'riscv64') {
|
|
352
|
+
if (isMusl()) {
|
|
353
|
+
try {
|
|
354
|
+
return require('./ddk-ts.linux-riscv64-musl.node')
|
|
355
|
+
} catch (e) {
|
|
356
|
+
loadErrors.push(e)
|
|
357
|
+
}
|
|
358
|
+
try {
|
|
359
|
+
const binding = require('@bennyblader/ddk-ts-linux-riscv64-musl')
|
|
360
|
+
const bindingPackageVersion = require('@bennyblader/ddk-ts-linux-riscv64-musl/package.json').version
|
|
361
|
+
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
362
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
363
|
+
}
|
|
364
|
+
return binding
|
|
365
|
+
} catch (e) {
|
|
366
|
+
loadErrors.push(e)
|
|
367
|
+
}
|
|
368
|
+
} else {
|
|
369
|
+
try {
|
|
370
|
+
return require('./ddk-ts.linux-riscv64-gnu.node')
|
|
371
|
+
} catch (e) {
|
|
372
|
+
loadErrors.push(e)
|
|
373
|
+
}
|
|
374
|
+
try {
|
|
375
|
+
const binding = require('@bennyblader/ddk-ts-linux-riscv64-gnu')
|
|
376
|
+
const bindingPackageVersion = require('@bennyblader/ddk-ts-linux-riscv64-gnu/package.json').version
|
|
377
|
+
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
378
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
379
|
+
}
|
|
380
|
+
return binding
|
|
381
|
+
} catch (e) {
|
|
382
|
+
loadErrors.push(e)
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
} else if (process.arch === 'ppc64') {
|
|
386
|
+
try {
|
|
387
|
+
return require('./ddk-ts.linux-ppc64-gnu.node')
|
|
388
|
+
} catch (e) {
|
|
389
|
+
loadErrors.push(e)
|
|
390
|
+
}
|
|
391
|
+
try {
|
|
392
|
+
const binding = require('@bennyblader/ddk-ts-linux-ppc64-gnu')
|
|
393
|
+
const bindingPackageVersion = require('@bennyblader/ddk-ts-linux-ppc64-gnu/package.json').version
|
|
394
|
+
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
395
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
396
|
+
}
|
|
397
|
+
return binding
|
|
398
|
+
} catch (e) {
|
|
399
|
+
loadErrors.push(e)
|
|
400
|
+
}
|
|
401
|
+
} else if (process.arch === 's390x') {
|
|
402
|
+
try {
|
|
403
|
+
return require('./ddk-ts.linux-s390x-gnu.node')
|
|
404
|
+
} catch (e) {
|
|
405
|
+
loadErrors.push(e)
|
|
406
|
+
}
|
|
407
|
+
try {
|
|
408
|
+
const binding = require('@bennyblader/ddk-ts-linux-s390x-gnu')
|
|
409
|
+
const bindingPackageVersion = require('@bennyblader/ddk-ts-linux-s390x-gnu/package.json').version
|
|
410
|
+
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
411
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
412
|
+
}
|
|
413
|
+
return binding
|
|
414
|
+
} catch (e) {
|
|
415
|
+
loadErrors.push(e)
|
|
416
|
+
}
|
|
417
|
+
} else {
|
|
418
|
+
loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`))
|
|
419
|
+
}
|
|
420
|
+
} else if (process.platform === 'openharmony') {
|
|
421
|
+
if (process.arch === 'arm64') {
|
|
422
|
+
try {
|
|
423
|
+
return require('./ddk-ts.openharmony-arm64.node')
|
|
424
|
+
} catch (e) {
|
|
425
|
+
loadErrors.push(e)
|
|
426
|
+
}
|
|
427
|
+
try {
|
|
428
|
+
const binding = require('@bennyblader/ddk-ts-openharmony-arm64')
|
|
429
|
+
const bindingPackageVersion = require('@bennyblader/ddk-ts-openharmony-arm64/package.json').version
|
|
430
|
+
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
431
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
432
|
+
}
|
|
433
|
+
return binding
|
|
434
|
+
} catch (e) {
|
|
435
|
+
loadErrors.push(e)
|
|
436
|
+
}
|
|
437
|
+
} else if (process.arch === 'x64') {
|
|
438
|
+
try {
|
|
439
|
+
return require('./ddk-ts.openharmony-x64.node')
|
|
440
|
+
} catch (e) {
|
|
441
|
+
loadErrors.push(e)
|
|
442
|
+
}
|
|
443
|
+
try {
|
|
444
|
+
const binding = require('@bennyblader/ddk-ts-openharmony-x64')
|
|
445
|
+
const bindingPackageVersion = require('@bennyblader/ddk-ts-openharmony-x64/package.json').version
|
|
446
|
+
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
447
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
448
|
+
}
|
|
449
|
+
return binding
|
|
450
|
+
} catch (e) {
|
|
451
|
+
loadErrors.push(e)
|
|
452
|
+
}
|
|
453
|
+
} else if (process.arch === 'arm') {
|
|
454
|
+
try {
|
|
455
|
+
return require('./ddk-ts.openharmony-arm.node')
|
|
456
|
+
} catch (e) {
|
|
457
|
+
loadErrors.push(e)
|
|
458
|
+
}
|
|
459
|
+
try {
|
|
460
|
+
const binding = require('@bennyblader/ddk-ts-openharmony-arm')
|
|
461
|
+
const bindingPackageVersion = require('@bennyblader/ddk-ts-openharmony-arm/package.json').version
|
|
462
|
+
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
463
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
464
|
+
}
|
|
465
|
+
return binding
|
|
466
|
+
} catch (e) {
|
|
467
|
+
loadErrors.push(e)
|
|
468
|
+
}
|
|
469
|
+
} else {
|
|
470
|
+
loadErrors.push(new Error(`Unsupported architecture on OpenHarmony: ${process.arch}`))
|
|
471
|
+
}
|
|
472
|
+
} else {
|
|
473
|
+
loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`))
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
nativeBinding = requireNative()
|
|
478
|
+
|
|
479
|
+
if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
480
|
+
try {
|
|
481
|
+
nativeBinding = require('./ddk-ts.wasi.cjs')
|
|
482
|
+
} catch (err) {
|
|
483
|
+
if (process.env.NAPI_RS_FORCE_WASI) {
|
|
484
|
+
loadErrors.push(err)
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
if (!nativeBinding) {
|
|
488
|
+
try {
|
|
489
|
+
nativeBinding = require('@bennyblader/ddk-ts-wasm32-wasi')
|
|
490
|
+
} catch (err) {
|
|
491
|
+
if (process.env.NAPI_RS_FORCE_WASI) {
|
|
492
|
+
loadErrors.push(err)
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
if (!nativeBinding) {
|
|
499
|
+
if (loadErrors.length > 0) {
|
|
500
|
+
throw new Error(
|
|
501
|
+
`Cannot find native binding. ` +
|
|
502
|
+
`npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` +
|
|
503
|
+
'Please try `npm i` again after removing both package-lock.json and node_modules directory.',
|
|
504
|
+
{ cause: loadErrors }
|
|
505
|
+
)
|
|
506
|
+
}
|
|
507
|
+
throw new Error(`Failed to load native binding`)
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
module.exports = nativeBinding
|
|
511
|
+
module.exports.createCet = nativeBinding.createCet
|
|
512
|
+
module.exports.createCetAdaptorSignatureFromOracleInfo = nativeBinding.createCetAdaptorSignatureFromOracleInfo
|
|
513
|
+
module.exports.createCets = nativeBinding.createCets
|
|
514
|
+
module.exports.createDlcTransactions = nativeBinding.createDlcTransactions
|
|
515
|
+
module.exports.createFundTxLockingScript = nativeBinding.createFundTxLockingScript
|
|
516
|
+
module.exports.createRefundTransaction = nativeBinding.createRefundTransaction
|
|
517
|
+
module.exports.createSplicedDlcTransactions = nativeBinding.createSplicedDlcTransactions
|
|
518
|
+
module.exports.getChangeOutputAndFees = nativeBinding.getChangeOutputAndFees
|
|
519
|
+
module.exports.getRawFundingTransactionInputSignature = nativeBinding.getRawFundingTransactionInputSignature
|
|
520
|
+
module.exports.getTotalInputVsize = nativeBinding.getTotalInputVsize
|
|
521
|
+
module.exports.isDustOutput = nativeBinding.isDustOutput
|
|
522
|
+
module.exports.signFundTransactionInput = nativeBinding.signFundTransactionInput
|
|
523
|
+
module.exports.verifyFundTxSignature = nativeBinding.verifyFundTxSignature
|
|
524
|
+
module.exports.version = nativeBinding.version
|