edge-core-js 0.18.11 → 0.19.0
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/CHANGELOG.md +31 -0
- package/README.md +32 -15
- package/android/build.gradle +52 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/assets/edge-core-js/edge-core.js +2 -0
- package/{lib/react-native → android/src/main/assets/edge-core-js}/edge-core.js.LICENSE.txt +0 -0
- package/android/src/main/cpp/CMakeLists.txt +16 -0
- package/android/src/main/cpp/edge-core-jni.c +36 -0
- package/android/src/main/cpp/scrypt/crypto_scrypt.c +284 -0
- package/android/src/main/cpp/scrypt/crypto_scrypt.h +46 -0
- package/android/src/main/cpp/scrypt/readme.md +13 -0
- package/android/src/main/cpp/scrypt/sha256.c +412 -0
- package/android/src/main/cpp/scrypt/sha256.h +62 -0
- package/android/src/main/cpp/scrypt/sysendian.h +140 -0
- package/android/src/main/java/app/edge/reactnative/core/Disklet.java +98 -0
- package/android/src/main/java/app/edge/reactnative/core/EdgeCorePackage.java +23 -0
- package/android/src/main/java/app/edge/reactnative/core/EdgeCoreWebView.java +209 -0
- package/android/src/main/java/app/edge/reactnative/core/EdgeCoreWebViewManager.java +53 -0
- package/edge-core-js.podspec +36 -0
- package/ios/Disklet.swift +75 -0
- package/ios/EdgeCoreWebView.swift +236 -0
- package/ios/EdgeCoreWebViewManager.m +8 -0
- package/ios/EdgeCoreWebViewManager.swift +15 -0
- package/ios/edge-core-js-Bridging-Header.h +4 -0
- package/ios/edge-core-js.xcodeproj/project.pbxproj +0 -0
- package/lib/core/account/account-api.js +3 -3
- package/lib/core/account/account-files.js +8 -4
- package/lib/core/account/account-init.js +4 -0
- package/lib/core/context/context-api.js +1 -1
- package/lib/core/currency/currency-selectors.js +2 -3
- package/lib/core/currency/wallet/currency-wallet-api.js +25 -13
- package/lib/core/currency/wallet/currency-wallet-callbacks.js +1 -1
- package/lib/core/currency/wallet/currency-wallet-export.js +2 -5
- package/lib/core/currency/wallet/currency-wallet-files.js +1 -1
- package/lib/core/currency/wallet/currency-wallet-pixie.js +1 -0
- package/lib/core/exchange/exchange-selectors.js +1 -0
- package/lib/core/fake/fake-db.js +15 -1
- package/lib/core/fake/fake-responses.js +16 -10
- package/lib/core/fake/fake-server.js +408 -334
- package/lib/core/fake/fake-world.js +3 -6
- package/lib/core/login/create.js +1 -2
- package/lib/core/login/edge.js +3 -1
- package/lib/core/login/keys.js +11 -13
- package/lib/core/login/login.js +37 -14
- package/lib/core/login/password.js +1 -1
- package/lib/core/login/pin2.js +8 -12
- package/lib/core/login/recovery2.js +4 -4
- package/lib/core/login/vouchers.js +1 -2
- package/lib/core/root.js +14 -22
- package/lib/core/storage/repo.js +12 -13
- package/lib/core/storage/storage-actions.js +1 -1
- package/lib/core/storage/storage-reducer.js +1 -1
- package/lib/exports.d.ts +38 -33
- package/lib/fake-types.d.ts +24 -0
- package/lib/io/react-native/native-bridge.js +85 -0
- package/lib/io/react-native/polyfills.js +2 -2
- package/lib/io/react-native/react-native-types.js +16 -0
- package/lib/io/react-native/react-native-webview.js +81 -121
- package/lib/io/react-native/react-native-worker.js +134 -56
- package/lib/io/react-native/yaob-callbacks.js +106 -0
- package/lib/node/index.js +637 -504
- package/lib/react-native.js +22 -40
- package/lib/types/exports.js +59 -33
- package/lib/types/exports.ts +53 -27
- package/lib/types/fake-types.js +40 -2
- package/lib/types/fake-types.ts +39 -1
- package/lib/types/types.js +34 -0
- package/lib/types/types.ts +189 -134
- package/lib/types.d.ts +146 -132
- package/package.json +15 -7
- package/src/types/exports.js +66 -40
- package/src/types/fake-types.js +40 -2
- package/src/types/types.js +189 -155
- package/lib/io/react-native/react-native-io.js +0 -87
- package/lib/react-native/edge-core.js +0 -3
- package/lib/react-native/edge-core.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,36 @@
|
|
|
1
1
|
# edge-core-js
|
|
2
2
|
|
|
3
|
+
## v0.19.0 (2022-01-11)
|
|
4
|
+
|
|
5
|
+
This release completely changes the way React Native works, both to improve performance and to make integration and debugging much easier.
|
|
6
|
+
|
|
7
|
+
- changed: Simplify the React Native integration to "just work".
|
|
8
|
+
- Stop depending on external libraries such as react-native-fast-crypto, react-native-randombytes, or react-native-webview.
|
|
9
|
+
- Use React Native auto-linking to integrate all native code, HTML, and Javascript needed to run the core.
|
|
10
|
+
- Accept core plugins via a `pluginUris` prop to `MakeEdgeContext` or `MakeFakeEdgeWorld`.
|
|
11
|
+
- Allow core debugging by running `yarn start` in this repo to start a dev server, and then setting the `debug` prop to true.
|
|
12
|
+
- Accept an `allowDebugging` prop on Android to enable WebView debugging in general (useful for debugging plugins).
|
|
13
|
+
- changed: Require `EdgeCurrencyEngine` methods to return promises.
|
|
14
|
+
- changed: Mark methods as `readonly` in the TypeScript definitions, to match what Flow was already doing.
|
|
15
|
+
|
|
16
|
+
## v0.18.14 (2021-01-06)
|
|
17
|
+
|
|
18
|
+
- fixed: Allow logins with an appId to approve or reject vouchers.
|
|
19
|
+
- added: Allow maximum swaps by passing "max" to `EdgeSwapRequest.quoteFor`.
|
|
20
|
+
- added: Add an `EdgeCurrencyEngine.getMaxSpendable` method for native max-spend calculations.
|
|
21
|
+
|
|
22
|
+
## v0.18.13 (2021-12-17)
|
|
23
|
+
|
|
24
|
+
- added: `EdgeSpendTarget.memo`, which is a renamed version of `EdgeSpendTarget.uniqueIdentifier`.
|
|
25
|
+
- added: `EdgeCurrencyInfo.memoType`, `EdgeCurrencyInfo.memoMaxLength`, `EdgeCurrencyInfo.memoMaxValue`. Use these to learn which currencies support memos.
|
|
26
|
+
- added: `EdgeCurrencyTools.validateMemo` & `EdgeCurrencyWallet.validateMemo`. Use these to check memos for validity before sending.
|
|
27
|
+
- deprecated: `EdgeSpendTarget.uniqueIdentifier`. Use `EdgeSpendTarget.memo` instead.
|
|
28
|
+
|
|
29
|
+
## v0.18.12 (2021-12-10)
|
|
30
|
+
|
|
31
|
+
- fixed: Gracefully handle errors while reading the exchange-rate hint cache.
|
|
32
|
+
- fixed: Correctly match server-returned children with their on-disk stash entries. This produces more accurate errors if the server loses a child.
|
|
33
|
+
|
|
3
34
|
## v0.18.11 (2021-11-07)
|
|
4
35
|
|
|
5
36
|
- fixed: onWcNewContractCall callback type
|
package/README.md
CHANGED
|
@@ -16,7 +16,9 @@ To quickly get up and running with the UI for account creation, login, and manag
|
|
|
16
16
|
|
|
17
17
|
## Setup
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
Add this library to your project using `npm install --save edge-core-js`.
|
|
20
|
+
|
|
21
|
+
### Node.js & Browsers
|
|
20
22
|
|
|
21
23
|
To create an `EdgeContext` object, which provides various methods for logging in and creating account, do something like this:
|
|
22
24
|
|
|
@@ -45,32 +47,47 @@ addEdgeCorePlugins(currencyPlugins)
|
|
|
45
47
|
lockEdgeCorePlugins()
|
|
46
48
|
```
|
|
47
49
|
|
|
48
|
-
|
|
50
|
+
If the core seems to hang forever when logging in, you probably forgot to call `lockEdgeCorePlugins`.
|
|
51
|
+
|
|
52
|
+
Please note that edge-core-js uses modern JavaScript syntax features such as `async`, so you may need to run the library through [Babel](https://babeljs.io/) if you plan to run it in a browser. Node 10+ supports these features natively.
|
|
49
53
|
|
|
50
54
|
### React Native
|
|
51
55
|
|
|
52
|
-
|
|
56
|
+
Edge-core-js directly supports React Native v0.60+ with autolinking. Simply add edge-core-js to your application, and React Native will link the necessary native modules & assets.
|
|
53
57
|
|
|
54
|
-
|
|
58
|
+
To create an `EdgeContext` object, you need to mount a component:
|
|
55
59
|
|
|
56
|
-
|
|
60
|
+
```jsx
|
|
61
|
+
<MakeEdgeContext
|
|
62
|
+
// Get this from our support team:
|
|
63
|
+
apiKey="..."
|
|
64
|
+
appId="com.your-app"
|
|
57
65
|
|
|
58
|
-
|
|
66
|
+
// Configure currencies and swap providers you want to use:
|
|
67
|
+
plugins={{
|
|
68
|
+
'bitcoin': true
|
|
69
|
+
}}
|
|
70
|
+
pluginUris={[
|
|
71
|
+
"edge-currency-plugins.js",
|
|
72
|
+
"edge-exchange-plugins.js"
|
|
73
|
+
]}
|
|
74
|
+
|
|
75
|
+
// Called when the core is done loading:
|
|
76
|
+
onLoad={edgeContext => {}}
|
|
77
|
+
onError={error => {}}
|
|
78
|
+
/>
|
|
79
|
+
```
|
|
59
80
|
|
|
60
|
-
|
|
61
|
-
- `Promise`
|
|
62
|
-
- `Uint8Array`
|
|
81
|
+
The core itself runs inside a hidden WebView, which this `MakeEdgeContext` component mounts & manages.
|
|
63
82
|
|
|
64
|
-
|
|
83
|
+
The core creates a `<script>` tag for each source file in the `pluginUris` array. For this to work, you need to add these plugin files to your app's native asset bundle, which is located at `/android/app/src/main/assets/` on Android. For iOS, drag these files into the "Resources" section of your Xcode project.
|
|
65
84
|
|
|
66
|
-
- `
|
|
67
|
-
- `localStorage`
|
|
68
|
-
- `Window.crypto.getRandomNumbers`
|
|
85
|
+
To debug the core, run `yarn start` inside the edge-core-js project, and then pass a `debug={true}` property to the `MakeEdgeContext` component. This tells the WebView to load the core from a local development server.
|
|
69
86
|
|
|
70
87
|
## Contributing
|
|
71
88
|
|
|
72
|
-
Run `yarn` to download dependencies and
|
|
89
|
+
Run `yarn` to download dependencies, and then run `yarn prepare` to build the library.
|
|
73
90
|
|
|
74
|
-
All sources are in the [JavaScript Standard Style](http://standardjs.com/) + [Prettier](https://prettier.io/). We check files prior to each commit, so if you have formatting issues, you can run `yarn fix` to fix them automatically.
|
|
91
|
+
Use `yarn verify` to run all our code-quality tools. All sources are in the [JavaScript Standard Style](http://standardjs.com/) + [Prettier](https://prettier.io/). We check files prior to each commit, so if you have formatting issues, you can run `yarn fix` to fix them automatically.
|
|
75
92
|
|
|
76
93
|
If you use Visual Studio Code, consider installing the [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) extension. This will give you nice error highlighting as you work, along with quick fixes for formatting issues.
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
buildscript {
|
|
2
|
+
repositories {
|
|
3
|
+
google()
|
|
4
|
+
jcenter()
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
dependencies {
|
|
8
|
+
classpath 'com.android.tools.build:gradle:3.6.0'
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
apply plugin: 'com.android.library'
|
|
13
|
+
|
|
14
|
+
def safeExtGet(prop, fallback) {
|
|
15
|
+
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
def DEFAULT_COMPILE_SDK_VERSION = 28
|
|
19
|
+
def DEFAULT_BUILD_TOOLS_VERSION = '28.0.2'
|
|
20
|
+
def DEFAULT_MIN_SDK_VERSION = 19
|
|
21
|
+
def DEFAULT_TARGET_SDK_VERSION = 27
|
|
22
|
+
def DEFAULT_WEBKIT_VERSION = '1.4.0'
|
|
23
|
+
|
|
24
|
+
android {
|
|
25
|
+
compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
|
|
26
|
+
buildToolsVersion safeExtGet('buildToolsVersion', DEFAULT_BUILD_TOOLS_VERSION)
|
|
27
|
+
|
|
28
|
+
defaultConfig {
|
|
29
|
+
minSdkVersion safeExtGet('minSdkVersion', DEFAULT_MIN_SDK_VERSION)
|
|
30
|
+
targetSdkVersion safeExtGet('targetSdkVersion', DEFAULT_TARGET_SDK_VERSION)
|
|
31
|
+
versionCode 1
|
|
32
|
+
versionName '1.0'
|
|
33
|
+
}
|
|
34
|
+
lintOptions {
|
|
35
|
+
abortOnError false
|
|
36
|
+
}
|
|
37
|
+
externalNativeBuild {
|
|
38
|
+
cmake {
|
|
39
|
+
path "src/main/cpp/CMakeLists.txt"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
repositories {
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
def webkit_version = safeExtGet('webkitVersion', DEFAULT_WEBKIT_VERSION)
|
|
48
|
+
|
|
49
|
+
dependencies {
|
|
50
|
+
implementation "androidx.webkit:webkit:$webkit_version"
|
|
51
|
+
implementation 'com.facebook.react:react-native:+'
|
|
52
|
+
}
|