@airgap/coinlib-core 0.13.16-beta.12 → 0.13.16-beta.14
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/package.json
CHANGED
|
@@ -12,8 +12,8 @@ export declare class AirGapCoinWallet extends AirGapMarketWallet {
|
|
|
12
12
|
currentMarketPrice: BigNumber | undefined;
|
|
13
13
|
getCurrentMarketPrice(): BigNumber | undefined;
|
|
14
14
|
setCurrentMarketPrice(marketPrice: BigNumber | undefined): Promise<void>;
|
|
15
|
-
protected _synchronize(): Promise<void>;
|
|
15
|
+
protected _synchronize(onlyBalance?: boolean): Promise<void>;
|
|
16
16
|
protected reset(): void;
|
|
17
|
-
fetchCurrentMarketPrice(
|
|
17
|
+
fetchCurrentMarketPrice(): Promise<BigNumber>;
|
|
18
18
|
balanceOf(): Promise<BigNumber>;
|
|
19
19
|
}
|
|
@@ -94,19 +94,27 @@ var AirGapCoinWallet = /** @class */ (function (_super) {
|
|
|
94
94
|
});
|
|
95
95
|
});
|
|
96
96
|
};
|
|
97
|
-
AirGapCoinWallet.prototype._synchronize = function () {
|
|
97
|
+
AirGapCoinWallet.prototype._synchronize = function (onlyBalance) {
|
|
98
|
+
if (onlyBalance === void 0) { onlyBalance = true; }
|
|
98
99
|
return __awaiter(this, void 0, void 0, function () {
|
|
99
|
-
var
|
|
100
|
-
return __generator(this, function (
|
|
101
|
-
switch (
|
|
102
|
-
case 0:
|
|
100
|
+
var promises, results;
|
|
101
|
+
return __generator(this, function (_a) {
|
|
102
|
+
switch (_a.label) {
|
|
103
|
+
case 0:
|
|
104
|
+
promises = [this.balanceOf()];
|
|
105
|
+
if (!onlyBalance) {
|
|
106
|
+
promises.push(this.fetchCurrentMarketPrice());
|
|
107
|
+
}
|
|
108
|
+
return [4 /*yield*/, Promise.all(promises)];
|
|
103
109
|
case 1:
|
|
104
|
-
|
|
105
|
-
this.setCurrentBalance(
|
|
106
|
-
return [
|
|
110
|
+
results = _a.sent();
|
|
111
|
+
this.setCurrentBalance(results[0]);
|
|
112
|
+
if (!!onlyBalance) return [3 /*break*/, 3];
|
|
113
|
+
return [4 /*yield*/, this.setCurrentMarketPrice(results[1])];
|
|
107
114
|
case 2:
|
|
108
|
-
|
|
109
|
-
|
|
115
|
+
_a.sent();
|
|
116
|
+
_a.label = 3;
|
|
117
|
+
case 3: return [2 /*return*/];
|
|
110
118
|
}
|
|
111
119
|
});
|
|
112
120
|
});
|
|
@@ -115,13 +123,12 @@ var AirGapCoinWallet = /** @class */ (function (_super) {
|
|
|
115
123
|
this.currentBalance = undefined;
|
|
116
124
|
this.currentMarketPrice = undefined;
|
|
117
125
|
};
|
|
118
|
-
AirGapCoinWallet.prototype.fetchCurrentMarketPrice = function (
|
|
119
|
-
if (baseSymbol === void 0) { baseSymbol = 'USD'; }
|
|
126
|
+
AirGapCoinWallet.prototype.fetchCurrentMarketPrice = function () {
|
|
120
127
|
return __awaiter(this, void 0, void 0, function () {
|
|
121
128
|
var marketPrice;
|
|
122
129
|
return __generator(this, function (_a) {
|
|
123
130
|
switch (_a.label) {
|
|
124
|
-
case 0: return [4 /*yield*/, this.priceService.getCurrentMarketPrice(this.protocol
|
|
131
|
+
case 0: return [4 /*yield*/, this.priceService.getCurrentMarketPrice(this.protocol)];
|
|
125
132
|
case 1:
|
|
126
133
|
marketPrice = _a.sent();
|
|
127
134
|
return [4 /*yield*/, this.setCurrentMarketPrice(marketPrice)];
|
|
@@ -150,7 +157,7 @@ var AirGapCoinWallet = /** @class */ (function (_super) {
|
|
|
150
157
|
// TODO: Remove and test
|
|
151
158
|
/*
|
|
152
159
|
We should remove this if BTC also uses blockbook. (And change the order of the if/else below)
|
|
153
|
-
|
|
160
|
+
|
|
154
161
|
The problem is that we have addresses cached for all protocols. But blockbook (grs) doesn't allow
|
|
155
162
|
multiple addresses to be checked at once, so we need to xPub key there (or we would do 100s of requests).
|
|
156
163
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AirGapCoinWallet.js","sourceRoot":"","sources":["../../src/wallet/AirGapCoinWallet.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+FAAwE;AACxE,4DAAsD;AACtD,4DAA8D;AAE9D,2DAAyD;AAEzD,IAAY,YAIX;AAJD,WAAY,YAAY;IACtB,6BAAa,CAAA;IACb,2BAAW,CAAA;IACX,6BAAa,CAAA;AACf,CAAC,EAJW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAIvB;AAED;IAAsC,oCAAkB;IAAxD;;
|
|
1
|
+
{"version":3,"file":"AirGapCoinWallet.js","sourceRoot":"","sources":["../../src/wallet/AirGapCoinWallet.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+FAAwE;AACxE,4DAAsD;AACtD,4DAA8D;AAE9D,2DAAyD;AAEzD,IAAY,YAIX;AAJD,WAAY,YAAY;IACtB,6BAAa,CAAA;IACb,2BAAW,CAAA;IACX,6BAAa,CAAA;AACf,CAAC,EAJW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAIvB;AAED;IAAsC,oCAAkB;IAAxD;;IAiFA,CAAC;IA9EQ,4CAAiB,GAAxB;QACE,OAAO,IAAI,CAAC,cAAc,CAAA;IAC5B,CAAC;IAEM,4CAAiB,GAAxB,UAAyB,OAA8B;QACrD,IAAI,CAAC,cAAc,GAAG,OAAO,CAAA;IAC/B,CAAC;IAIM,gDAAqB,GAA5B;QACE,OAAO,IAAI,CAAC,kBAAkB,CAAA;IAChC,CAAC;IAEY,gDAAqB,GAAlC,UAAmC,WAAkC;;;;;;wBACnE,KAAA,IAAI,CAAA;wBAAuB,qBAAM,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,EAAA;;wBAA3D,GAAK,kBAAkB,GAAG,CAAC,SAAgC,CAAC,CAAC,OAAO,CAAC,IAAI,KAA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AA;;;wBAEnF,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAA;wBAC9B,sBAAO,MAAM,EAAA;;;;KACd;IACH,uBAAC;AAAD,CAAC,AAjFD,CAAsC,uCAAkB,GAiFvD;AAjFY,4CAAgB"}
|
|
@@ -3,7 +3,7 @@ import { IAirGapTransaction, IAirGapTransactionResult, IProtocolTransactionCurso
|
|
|
3
3
|
import { FeeDefaults, ICoinProtocol } from '../protocols/ICoinProtocol';
|
|
4
4
|
import { AirGapWallet, AirGapWalletStatus } from './AirGapWallet';
|
|
5
5
|
export interface AirGapWalletPriceService {
|
|
6
|
-
getCurrentMarketPrice(protocol: ICoinProtocol
|
|
6
|
+
getCurrentMarketPrice(protocol: ICoinProtocol): Promise<BigNumber>;
|
|
7
7
|
}
|
|
8
8
|
export declare abstract class AirGapMarketWallet extends AirGapWallet {
|
|
9
9
|
protocol: ICoinProtocol;
|
|
@@ -128,7 +128,7 @@ var AirGapMarketWallet = /** @class */ (function (_super) {
|
|
|
128
128
|
// TODO: Remove and test
|
|
129
129
|
/*
|
|
130
130
|
We should remove this if BTC also uses blockbook. (And change the order of the if/else below)
|
|
131
|
-
|
|
131
|
+
|
|
132
132
|
The problem is that we have addresses cached for all protocols. But blockbook (grs) doesn't allow
|
|
133
133
|
multiple addresses to be checked at once, so we need to xPub key there (or we would do 100s of requests).
|
|
134
134
|
|