edge-core-js 2.41.2 → 2.42.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 +14 -0
- package/android/src/main/assets/edge-core-js/edge-core.js +1 -1
- package/ios/EdgeCoreModule.swift +16 -1
- package/lib/core/account/account-api.js +39 -11
- package/lib/core/account/memory-wallet.js +48 -40
- package/lib/core/actions.js +1 -0
- package/lib/core/currency/wallet/currency-wallet-api.js +20 -1
- package/lib/core/currency/wallet/currency-wallet-callbacks.js +17 -3
- package/lib/core/currency/wallet/currency-wallet-reducer.js +9 -4
- package/lib/core/login/splitting.js +114 -55
- package/lib/flow/types.js +47 -7
- package/lib/flow/webby.js +35 -0
- package/lib/node/index.js +1177 -1080
- package/lib/types/types.js +40 -0
- package/lib/util/edgeResult.js +11 -0
- package/package.json +1 -1
- package/src/types/types.ts +47 -7
- package/src/types/webby.js +33 -0
package/lib/types/types.js
CHANGED
|
@@ -2175,6 +2175,46 @@ export * from './server-types'
|
|
|
2175
2175
|
|
|
2176
2176
|
|
|
2177
2177
|
|
|
2178
|
+
|
|
2179
|
+
|
|
2180
|
+
|
|
2181
|
+
|
|
2182
|
+
|
|
2183
|
+
|
|
2184
|
+
|
|
2185
|
+
|
|
2186
|
+
|
|
2187
|
+
|
|
2188
|
+
|
|
2189
|
+
|
|
2190
|
+
|
|
2191
|
+
|
|
2192
|
+
|
|
2193
|
+
|
|
2194
|
+
|
|
2195
|
+
|
|
2196
|
+
|
|
2197
|
+
|
|
2198
|
+
|
|
2199
|
+
|
|
2200
|
+
|
|
2201
|
+
|
|
2202
|
+
|
|
2203
|
+
|
|
2204
|
+
|
|
2205
|
+
|
|
2206
|
+
|
|
2207
|
+
|
|
2208
|
+
|
|
2209
|
+
|
|
2210
|
+
|
|
2211
|
+
|
|
2212
|
+
|
|
2213
|
+
|
|
2214
|
+
|
|
2215
|
+
|
|
2216
|
+
|
|
2217
|
+
|
|
2178
2218
|
|
|
2179
2219
|
|
|
2180
2220
|
|
package/package.json
CHANGED
package/src/types/types.ts
CHANGED
|
@@ -542,6 +542,9 @@ export interface EdgeCurrencyInfo {
|
|
|
542
542
|
unsafeSyncNetwork?: boolean
|
|
543
543
|
usesChangeServer?: boolean
|
|
544
544
|
|
|
545
|
+
/** Show the total sync percentage with this many decimal digits */
|
|
546
|
+
syncDisplayPrecision?: number
|
|
547
|
+
|
|
545
548
|
/** @deprecated The default user settings are always `{}` */
|
|
546
549
|
defaultSettings?: JsonObject
|
|
547
550
|
|
|
@@ -809,6 +812,23 @@ export interface EdgeStakingStatus {
|
|
|
809
812
|
}>
|
|
810
813
|
}
|
|
811
814
|
|
|
815
|
+
/**
|
|
816
|
+
* Reports a currency wallet's blockchain syncing progress.
|
|
817
|
+
*/
|
|
818
|
+
export interface EdgeSyncStatus {
|
|
819
|
+
/** A single "overview" value of the sync state from 0 to 1. */
|
|
820
|
+
totalRatio: number
|
|
821
|
+
|
|
822
|
+
/** How far along the chain we are, for chains that scan by blocks. */
|
|
823
|
+
blockRatio?: [number, number] // [ourHeight: number, chainHeight: number]
|
|
824
|
+
|
|
825
|
+
/**
|
|
826
|
+
* Free-form values to show the user, for engines with unusual info.
|
|
827
|
+
* For example: `{ "donwload speed": "1 KB/s" }`
|
|
828
|
+
*/
|
|
829
|
+
otherParams?: { [name: string]: string } // Record<string, string>
|
|
830
|
+
}
|
|
831
|
+
|
|
812
832
|
export interface EdgeTxidMap {
|
|
813
833
|
[txid: string]: number
|
|
814
834
|
}
|
|
@@ -967,7 +987,6 @@ export interface EdgeSignMessageOptions {
|
|
|
967
987
|
|
|
968
988
|
export interface EdgeCurrencyEngineCallbacks {
|
|
969
989
|
readonly onAddressChanged: () => void
|
|
970
|
-
readonly onAddressesChecked: (progressRatio: number) => void
|
|
971
990
|
readonly onNewTokens: (tokenIds: string[]) => void
|
|
972
991
|
readonly onSeenTxCheckpoint: (checkpoint: string) => void
|
|
973
992
|
readonly onStakingStatusChanged: (status: EdgeStakingStatus) => void
|
|
@@ -977,6 +996,7 @@ export interface EdgeCurrencyEngineCallbacks {
|
|
|
977
996
|
/** @deprecated Use the array of EdgeSubscribedAddress objects instead. */
|
|
978
997
|
| string[]
|
|
979
998
|
) => void
|
|
999
|
+
readonly onSyncStatusChanged: (syncStatus: EdgeSyncStatus) => void
|
|
980
1000
|
readonly onTokenBalanceChanged: (
|
|
981
1001
|
tokenId: EdgeTokenId,
|
|
982
1002
|
balance: string
|
|
@@ -986,6 +1006,9 @@ export interface EdgeCurrencyEngineCallbacks {
|
|
|
986
1006
|
readonly onUnactivatedTokenIdsChanged: (unactivatedTokenIds: string[]) => void
|
|
987
1007
|
readonly onWcNewContractCall: (payload: JsonObject) => void
|
|
988
1008
|
|
|
1009
|
+
/** @deprecated Use onSyncStatusChanged */
|
|
1010
|
+
readonly onAddressesChecked: (progressRatio: number) => void
|
|
1011
|
+
|
|
989
1012
|
/** @deprecated onTransactionsChanged handles confirmation changes */
|
|
990
1013
|
readonly onBlockHeightChanged: (blockHeight: number) => void
|
|
991
1014
|
|
|
@@ -1325,7 +1348,7 @@ export interface EdgeCurrencyWallet {
|
|
|
1325
1348
|
readonly balanceMap: EdgeBalanceMap
|
|
1326
1349
|
readonly balances: EdgeBalances
|
|
1327
1350
|
readonly blockHeight: number
|
|
1328
|
-
readonly
|
|
1351
|
+
readonly syncStatus: EdgeSyncStatus
|
|
1329
1352
|
readonly unactivatedTokenIds: string[]
|
|
1330
1353
|
|
|
1331
1354
|
// Running state:
|
|
@@ -1385,6 +1408,9 @@ export interface EdgeCurrencyWallet {
|
|
|
1385
1408
|
// Wallet management:
|
|
1386
1409
|
readonly dumpData: () => Promise<EdgeDataDump>
|
|
1387
1410
|
readonly resyncBlockchain: () => Promise<void>
|
|
1411
|
+
readonly split: (
|
|
1412
|
+
splitWallets: EdgeSplitCurrencyWallet[]
|
|
1413
|
+
) => Promise<Array<EdgeResult<EdgeCurrencyWallet>>>
|
|
1388
1414
|
|
|
1389
1415
|
// URI handling:
|
|
1390
1416
|
readonly encodeUri: (obj: EdgeEncodeUri) => Promise<string>
|
|
@@ -1428,13 +1454,16 @@ export interface EdgeCurrencyWallet {
|
|
|
1428
1454
|
message: string,
|
|
1429
1455
|
opts?: EdgeSignMessageOptions
|
|
1430
1456
|
) => Promise<string>
|
|
1457
|
+
|
|
1458
|
+
/** @deprecated Use `syncStatus` instead */
|
|
1459
|
+
readonly syncRatio: number
|
|
1431
1460
|
}
|
|
1432
1461
|
|
|
1433
1462
|
export interface EdgeMemoryWallet {
|
|
1434
1463
|
readonly watch: Subscriber<EdgeMemoryWallet>
|
|
1435
1464
|
readonly balanceMap: EdgeBalanceMap
|
|
1436
1465
|
readonly detectedTokenIds: string[]
|
|
1437
|
-
readonly
|
|
1466
|
+
readonly syncStatus: EdgeSyncStatus
|
|
1438
1467
|
readonly changeEnabledTokenIds: (tokenIds: string[]) => Promise<void>
|
|
1439
1468
|
readonly startEngine: () => Promise<void>
|
|
1440
1469
|
readonly getMaxSpendable: (spendInfo: EdgeSpendInfo) => Promise<string>
|
|
@@ -1443,6 +1472,9 @@ export interface EdgeMemoryWallet {
|
|
|
1443
1472
|
readonly broadcastTx: (tx: EdgeTransaction) => Promise<EdgeTransaction>
|
|
1444
1473
|
readonly saveTx: (tx: EdgeTransaction) => Promise<void>
|
|
1445
1474
|
readonly close: () => Promise<void>
|
|
1475
|
+
|
|
1476
|
+
/** @deprecated Use syncStatus */
|
|
1477
|
+
readonly syncRatio: number
|
|
1446
1478
|
}
|
|
1447
1479
|
|
|
1448
1480
|
// ---------------------------------------------------------------------
|
|
@@ -1635,6 +1667,12 @@ export type EdgeCreateCurrencyWallet = EdgeCreateCurrencyWalletOptions & {
|
|
|
1635
1667
|
walletType: string
|
|
1636
1668
|
}
|
|
1637
1669
|
|
|
1670
|
+
export interface EdgeSplitCurrencyWallet {
|
|
1671
|
+
fiatCurrencyCode?: string
|
|
1672
|
+
name?: string
|
|
1673
|
+
walletType: string
|
|
1674
|
+
}
|
|
1675
|
+
|
|
1638
1676
|
export interface EdgeCurrencyConfig {
|
|
1639
1677
|
readonly watch: Subscriber<EdgeCurrencyConfig>
|
|
1640
1678
|
|
|
@@ -1838,10 +1876,6 @@ export interface EdgeAccount {
|
|
|
1838
1876
|
readonly getWalletInfo: (id: string) => EdgeWalletInfoFull | undefined
|
|
1839
1877
|
readonly listWalletIds: () => string[]
|
|
1840
1878
|
readonly listSplittableWalletTypes: (walletId: string) => Promise<string[]>
|
|
1841
|
-
readonly splitWalletInfo: (
|
|
1842
|
-
walletId: string,
|
|
1843
|
-
newWalletType: string
|
|
1844
|
-
) => Promise<string>
|
|
1845
1879
|
|
|
1846
1880
|
// Key access:
|
|
1847
1881
|
readonly getDisplayPrivateKey: (walletId: string) => Promise<string>
|
|
@@ -1888,6 +1922,12 @@ export interface EdgeAccount {
|
|
|
1888
1922
|
request: EdgeSwapRequest,
|
|
1889
1923
|
opts?: EdgeSwapRequestOptions
|
|
1890
1924
|
) => Promise<EdgeSwapQuote[]>
|
|
1925
|
+
|
|
1926
|
+
/** @deprecated Use `EdgeCurrencyWallet.split` instead */
|
|
1927
|
+
readonly splitWalletInfo: (
|
|
1928
|
+
walletId: string,
|
|
1929
|
+
newWalletType: string
|
|
1930
|
+
) => Promise<string>
|
|
1891
1931
|
}
|
|
1892
1932
|
|
|
1893
1933
|
// ---------------------------------------------------------------------
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Buffer } from 'buffer'
|
|
2
|
+
import http from 'http'
|
|
3
|
+
import { createProxyServer } from 'http-proxy'
|
|
4
|
+
|
|
5
|
+
const proxy = createProxyServer({})
|
|
6
|
+
|
|
7
|
+
// Rust WebDAV server running on port 3000
|
|
8
|
+
const WEBDAV_TARGET = 'http://localhost:3000'
|
|
9
|
+
const OTHER_TARGET = 'http://localhost:4000'
|
|
10
|
+
|
|
11
|
+
const AUTH_USER = 'william'
|
|
12
|
+
const AUTH_PASS = 'hunter2'
|
|
13
|
+
|
|
14
|
+
const mainServer = http.createServer((req, res) => {
|
|
15
|
+
if (isAuthorized(req)) {
|
|
16
|
+
proxy.web(req, res, { target: WEBDAV_TARGET })
|
|
17
|
+
} else {
|
|
18
|
+
proxy.web(req, res, { target: OTHER_TARGET })
|
|
19
|
+
}
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
mainServer.listen(8080, () => {
|
|
23
|
+
console.log('Node proxy running on port 8080')
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
function isAuthorized(req) {
|
|
27
|
+
const authHeader = req.headers.authorization
|
|
28
|
+
if (!authHeader || !authHeader.startsWith('Basic ')) return false
|
|
29
|
+
|
|
30
|
+
const encoded = authHeader.slice(6)
|
|
31
|
+
const decoded = Buffer.from(encoded, 'base64').toString('utf8')
|
|
32
|
+
return decoded === `${AUTH_USER}:${AUTH_PASS}`
|
|
33
|
+
}
|