edge-currency-plugins 3.2.1 → 3.3.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/android/src/main/assets/edge-currency-plugins/edge-currency-plugins.js +41 -41
- package/lib/common/plugin/PluginState.js +4 -4
- package/lib/common/plugin/ServerScores.js +10 -0
- package/lib/common/plugin/types.js +1 -1
- package/lib/common/utxobased/db/{Processor.js → DataLayer.js} +15 -11
- package/lib/common/utxobased/db/Models/{ProcessorTransaction.js → TransactionData.js} +4 -6
- package/lib/common/utxobased/db/types.js +4 -4
- package/lib/common/utxobased/db/util/utxo.js +8 -8
- package/lib/common/utxobased/engine/ServerStates.js +137 -98
- package/lib/common/utxobased/engine/UtxoEngine.js +58 -55
- package/lib/common/utxobased/engine/{UtxoEngineState.js → UtxoEngineProcessor.js} +650 -714
- package/lib/common/utxobased/engine/types.js +4 -2
- package/lib/common/utxobased/engine/util/getOwnUtxosFromTx.js +4 -4
- package/lib/common/utxobased/info/bitcoin.js +2 -1
- package/lib/common/utxobased/info/bitcoincash.js +2 -1
- package/lib/common/utxobased/info/dash.js +2 -1
- package/lib/common/utxobased/info/digibyte.js +5 -1
- package/lib/common/utxobased/info/dogecoin.js +2 -1
- package/lib/common/utxobased/info/groestlcoin.js +4 -1
- package/lib/common/utxobased/info/litecoin.js +2 -1
- package/lib/common/utxobased/info/zcoin.js +4 -1
- package/lib/common/utxobased/network/Blockbook.js +33 -30
- package/lib/common/utxobased/network/BlockbookElectrum.js +79 -77
- package/lib/common/utxobased/network/Socket.js +70 -40
- package/lib/src/common/plugin/PluginState.d.ts +3 -3
- package/lib/src/common/plugin/types.d.ts +4 -4
- package/lib/src/common/utxobased/db/{Processor.d.ts → DataLayer.d.ts} +17 -11
- package/lib/src/common/utxobased/db/Models/{ProcessorTransaction.d.ts → TransactionData.d.ts} +5 -5
- package/lib/src/common/utxobased/db/Models/baselet.d.ts +4 -4
- package/lib/src/common/utxobased/db/types.d.ts +9 -9
- package/lib/src/common/utxobased/db/util/utxo.d.ts +3 -3
- package/lib/src/common/utxobased/engine/ServerStates.d.ts +7 -7
- package/lib/src/common/utxobased/engine/{UtxoEngineState.d.ts → UtxoEngineProcessor.d.ts} +44 -42
- package/lib/src/common/utxobased/engine/types.d.ts +4 -4
- package/lib/src/common/utxobased/engine/util/getOwnUtxosFromTx.d.ts +3 -3
- package/lib/src/common/utxobased/engine/utils.d.ts +2 -2
- package/lib/src/common/utxobased/keymanager/keymanager.d.ts +3 -3
- package/lib/src/common/utxobased/network/Blockbook.d.ts +8 -7
- package/lib/src/common/utxobased/network/BlockbookElectrum.d.ts +4 -2
- package/lib/src/common/utxobased/network/Socket.d.ts +10 -8
- package/lib/src/util/uriKeyParams.d.ts +4 -0
- package/lib/util/uriKeyParams.js +20 -0
- package/package.json +1 -1
- /package/lib/test/common/utxobased/db/{Processor.spec.d.ts → DataLayer.spec.d.ts} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Disklet } from 'disklet';
|
|
2
2
|
import { EdgeParsedUri } from 'edge-core-js/types';
|
|
3
3
|
import { ChangePath, CurrencyFormat, EngineInfo } from '../../plugin/types';
|
|
4
|
-
import {
|
|
4
|
+
import { UtxoData } from '../db/types';
|
|
5
5
|
import { ScriptTemplates } from '../info/scriptTemplates/types';
|
|
6
6
|
import { PrivateKey } from '../keymanager/cleaners';
|
|
7
7
|
import { AddressTypeEnum, BIP43PurposeTypeEnum, ScriptTypeEnum } from '../keymanager/keymanager';
|
|
@@ -55,4 +55,4 @@ export declare const parsePathname: (args: {
|
|
|
55
55
|
pathname: string;
|
|
56
56
|
coin: string;
|
|
57
57
|
}) => EdgeParsedUri;
|
|
58
|
-
export declare const sumUtxos: (utxos:
|
|
58
|
+
export declare const sumUtxos: (utxos: UtxoData[]) => string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EdgeLog, EdgeMemo } from 'edge-core-js/types';
|
|
2
2
|
import { ChangePath, FeeInfo } from '../../plugin/types';
|
|
3
|
-
import {
|
|
3
|
+
import { UtxoData } from '../db/types';
|
|
4
4
|
import { ScriptTemplate, ScriptTemplates } from '../info/scriptTemplates/types';
|
|
5
5
|
import * as utxopicker from './utxopicker';
|
|
6
6
|
export declare enum BIP43PurposeTypeEnum {
|
|
@@ -132,8 +132,8 @@ export interface TxOutput {
|
|
|
132
132
|
amount: number;
|
|
133
133
|
}
|
|
134
134
|
export interface MakeTxArgs {
|
|
135
|
-
forceUseUtxo:
|
|
136
|
-
utxos:
|
|
135
|
+
forceUseUtxo: UtxoData[];
|
|
136
|
+
utxos: UtxoData[];
|
|
137
137
|
targets: MakeTxTarget[];
|
|
138
138
|
memos: EdgeMemo[];
|
|
139
139
|
feeRate: number;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Cleaner } from 'cleaners';
|
|
2
2
|
import { EdgeLog, EdgeTransaction } from 'edge-core-js/types';
|
|
3
3
|
import { EngineEmitter } from '../../plugin/EngineEmitter';
|
|
4
|
+
import { UtxoInitOptions } from '../engine/types';
|
|
4
5
|
import { AddressResponse, AddresssMessageParams, AddressUtxosResponse, BlockbookTask, BlockbookTransaction, BroadcastTxResponse, InfoResponse, SubscribeAddressResponse, TransactionResponse } from './blockbookApi';
|
|
5
6
|
import Deferred from './Deferred';
|
|
6
|
-
import {
|
|
7
|
+
import { TaskGeneratorFn, WsResponse, WsTaskGenerator } from './Socket';
|
|
7
8
|
import { SocketEmitter } from './SocketEmitter';
|
|
8
9
|
export declare type WatchAddressesCB = (response: SubscribeAddressResponse) => void | Promise<void>;
|
|
9
10
|
export declare type WatchBlocksCB = () => void | Promise<void>;
|
|
@@ -18,26 +19,26 @@ export interface Blockbook {
|
|
|
18
19
|
fetchTransaction: (hash: string) => Promise<TransactionResponse>;
|
|
19
20
|
watchAddresses: (addresses: string[], deferredAddressSub: Deferred<unknown>) => void;
|
|
20
21
|
watchBlocks: (deferredBlockSub: Deferred<unknown>) => void;
|
|
21
|
-
onQueueSpace: (cb: OnQueueSpaceCB) => void;
|
|
22
22
|
promisifyWsMessage: <T>(message: BlockbookTask<T>) => Promise<T>;
|
|
23
23
|
addressQueryTask: (address: string, params: {
|
|
24
24
|
asBlockbookAddress?: Cleaner<string> | undefined;
|
|
25
25
|
lastQueriedBlockHeight: number;
|
|
26
26
|
page: number;
|
|
27
|
-
}
|
|
28
|
-
transactionQueryTask: (txId: string
|
|
29
|
-
transactionSpecialQueryTask: (txId: string
|
|
27
|
+
}) => WsTaskGenerator<AddressResponse>;
|
|
28
|
+
transactionQueryTask: (txId: string) => WsTaskGenerator<BlockbookTransaction>;
|
|
29
|
+
transactionSpecialQueryTask: (txId: string) => WsTaskGenerator<unknown>;
|
|
30
30
|
utxoListQueryTask: (address: string, params: {
|
|
31
31
|
asBlockbookAddress?: Cleaner<string> | undefined;
|
|
32
|
-
}
|
|
32
|
+
}) => WsTaskGenerator<AddressUtxosResponse>;
|
|
33
33
|
}
|
|
34
34
|
interface BlockbookConfig {
|
|
35
35
|
asAddress?: Cleaner<string>;
|
|
36
36
|
asResponse?: Cleaner<WsResponse>;
|
|
37
37
|
connectionUri: string;
|
|
38
38
|
engineEmitter: EngineEmitter;
|
|
39
|
+
initOptions: UtxoInitOptions;
|
|
39
40
|
log: EdgeLog;
|
|
40
|
-
|
|
41
|
+
taskGeneratorFn: TaskGeneratorFn;
|
|
41
42
|
ping?: () => Promise<void>;
|
|
42
43
|
socketEmitter: SocketEmitter;
|
|
43
44
|
walletId: string;
|
|
@@ -2,15 +2,17 @@ import { Cleaner } from 'cleaners';
|
|
|
2
2
|
import { EdgeLog } from 'edge-core-js/types';
|
|
3
3
|
import { EngineEmitter } from '../../plugin/EngineEmitter';
|
|
4
4
|
import { PluginInfo } from '../../plugin/types';
|
|
5
|
+
import { UtxoInitOptions } from '../engine/types';
|
|
5
6
|
import { Blockbook } from './Blockbook';
|
|
6
|
-
import {
|
|
7
|
+
import { TaskGeneratorFn } from './Socket';
|
|
7
8
|
import { SocketEmitter } from './SocketEmitter';
|
|
8
9
|
export interface BlockbookElectrumConfig {
|
|
9
10
|
asAddress?: Cleaner<string>;
|
|
10
11
|
connectionUri: string;
|
|
11
12
|
engineEmitter: EngineEmitter;
|
|
13
|
+
initOptions: UtxoInitOptions;
|
|
12
14
|
log: EdgeLog;
|
|
13
|
-
|
|
15
|
+
taskGeneratorFn: TaskGeneratorFn;
|
|
14
16
|
pluginInfo: PluginInfo;
|
|
15
17
|
socketEmitter: SocketEmitter;
|
|
16
18
|
walletId: string;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Cleaner } from 'cleaners';
|
|
2
2
|
import { EdgeLog } from 'edge-core-js/types';
|
|
3
|
+
import { UtxoInitOptions } from '../engine/types';
|
|
3
4
|
import Deferred from './Deferred';
|
|
4
5
|
import { SocketEmitter } from './SocketEmitter';
|
|
5
6
|
import { ReadyState } from './types';
|
|
@@ -7,9 +8,10 @@ export declare type OnFailHandler = (error: Error) => void;
|
|
|
7
8
|
export interface WsTask<T> {
|
|
8
9
|
method: string;
|
|
9
10
|
params: unknown;
|
|
10
|
-
deferred: Deferred<T>;
|
|
11
11
|
cleaner?: Cleaner<T>;
|
|
12
12
|
}
|
|
13
|
+
export declare type WsTaskGenerator<T> = Generator<WsTask<T>, T, T>;
|
|
14
|
+
export declare type WsTaskAsyncGenerator<T> = AsyncGenerator<WsTask<T> | boolean, boolean, T>;
|
|
13
15
|
export interface WsSubscription<T> {
|
|
14
16
|
method: string;
|
|
15
17
|
params: unknown;
|
|
@@ -22,21 +24,21 @@ export interface Socket {
|
|
|
22
24
|
readyState: ReadyState;
|
|
23
25
|
connect: () => Promise<void>;
|
|
24
26
|
disconnect: () => void;
|
|
25
|
-
submitTask: <T>(task: WsTask<T>) => void;
|
|
26
|
-
onQueueSpace: (cb: OnQueueSpaceCB) => void;
|
|
27
|
+
submitTask: <T>(task: WsTask<T>, generator: WsTaskAsyncGenerator<T>) => void;
|
|
27
28
|
subscribe: <T>(subscription: WsSubscription<T>) => void;
|
|
28
29
|
isConnected: () => boolean;
|
|
29
30
|
}
|
|
30
|
-
export declare type
|
|
31
|
+
export declare type TaskGeneratorFn = (uri: string) => WsTaskAsyncGenerator<unknown>;
|
|
31
32
|
interface SocketConfig {
|
|
32
33
|
asResponse?: Cleaner<WsResponse>;
|
|
34
|
+
emitter: SocketEmitter;
|
|
35
|
+
healthCheck: () => Promise<void>;
|
|
36
|
+
initOptions: UtxoInitOptions;
|
|
37
|
+
log: EdgeLog;
|
|
33
38
|
queueSize?: number;
|
|
39
|
+
taskGeneratorFn: TaskGeneratorFn;
|
|
34
40
|
timeout?: number;
|
|
35
41
|
walletId: string;
|
|
36
|
-
emitter: SocketEmitter;
|
|
37
|
-
log: EdgeLog;
|
|
38
|
-
healthCheck: () => Promise<void>;
|
|
39
|
-
onQueueSpaceCB: OnQueueSpaceCB;
|
|
40
42
|
}
|
|
41
43
|
export declare type WsResponse = WsResponseMessage[];
|
|
42
44
|
export interface WsResponseMessage {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function getUriKeyParams(uri) {
|
|
2
|
+
const params = uri.match(/%\{(\w|\d)+\}/g)
|
|
3
|
+
return _nullishCoalesce(params, () => ( []))
|
|
4
|
+
} exports.getUriKeyParams = getUriKeyParams;
|
|
5
|
+
|
|
6
|
+
function replaceKeyParams(
|
|
7
|
+
uri,
|
|
8
|
+
options
|
|
9
|
+
) {
|
|
10
|
+
const keyParams = getUriKeyParams(uri)
|
|
11
|
+
|
|
12
|
+
for (const keyParam of keyParams) {
|
|
13
|
+
const keyIndex = keyParam.replace(/%|{|}/g, '')
|
|
14
|
+
const key = options[keyIndex]
|
|
15
|
+
if (key == null) throw new Error(`Missing key for connection URI ${uri}`)
|
|
16
|
+
uri = uri.replace(keyParam, key)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return uri
|
|
20
|
+
} exports.replaceKeyParams = replaceKeyParams;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "edge-currency-plugins",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"description": "Edge currency plugins to fetch and process wallet accounts, balances and transactions.",
|
|
5
5
|
"homepage": "https://edge.app/",
|
|
6
6
|
"repository": "https://github.com/EdgeApp/edge-currency-plugins",
|
|
File without changes
|