@airgap/coinlib-core 0.13.16-beta.14 → 0.13.16-beta.15
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(
|
|
15
|
+
protected _synchronize(): Promise<void>;
|
|
16
16
|
protected reset(): void;
|
|
17
|
-
fetchCurrentMarketPrice(): Promise<BigNumber>;
|
|
17
|
+
fetchCurrentMarketPrice(baseSymbol?: string): Promise<BigNumber>;
|
|
18
18
|
balanceOf(): Promise<BigNumber>;
|
|
19
19
|
}
|
|
@@ -94,27 +94,19 @@ var AirGapCoinWallet = /** @class */ (function (_super) {
|
|
|
94
94
|
});
|
|
95
95
|
});
|
|
96
96
|
};
|
|
97
|
-
AirGapCoinWallet.prototype._synchronize = function (
|
|
98
|
-
if (onlyBalance === void 0) { onlyBalance = true; }
|
|
97
|
+
AirGapCoinWallet.prototype._synchronize = function () {
|
|
99
98
|
return __awaiter(this, void 0, void 0, function () {
|
|
100
|
-
var
|
|
101
|
-
return __generator(this, function (
|
|
102
|
-
switch (
|
|
103
|
-
case 0:
|
|
104
|
-
promises = [this.balanceOf()];
|
|
105
|
-
if (!onlyBalance) {
|
|
106
|
-
promises.push(this.fetchCurrentMarketPrice());
|
|
107
|
-
}
|
|
108
|
-
return [4 /*yield*/, Promise.all(promises)];
|
|
99
|
+
var _a, balance, marketPrice;
|
|
100
|
+
return __generator(this, function (_b) {
|
|
101
|
+
switch (_b.label) {
|
|
102
|
+
case 0: return [4 /*yield*/, Promise.all([this.balanceOf(), this.fetchCurrentMarketPrice()])];
|
|
109
103
|
case 1:
|
|
110
|
-
|
|
111
|
-
this.setCurrentBalance(
|
|
112
|
-
|
|
113
|
-
return [4 /*yield*/, this.setCurrentMarketPrice(results[1])];
|
|
104
|
+
_a = _b.sent(), balance = _a[0], marketPrice = _a[1];
|
|
105
|
+
this.setCurrentBalance(balance);
|
|
106
|
+
return [4 /*yield*/, this.setCurrentMarketPrice(marketPrice)];
|
|
114
107
|
case 2:
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
case 3: return [2 /*return*/];
|
|
108
|
+
_b.sent();
|
|
109
|
+
return [2 /*return*/];
|
|
118
110
|
}
|
|
119
111
|
});
|
|
120
112
|
});
|
|
@@ -123,12 +115,13 @@ var AirGapCoinWallet = /** @class */ (function (_super) {
|
|
|
123
115
|
this.currentBalance = undefined;
|
|
124
116
|
this.currentMarketPrice = undefined;
|
|
125
117
|
};
|
|
126
|
-
AirGapCoinWallet.prototype.fetchCurrentMarketPrice = function () {
|
|
118
|
+
AirGapCoinWallet.prototype.fetchCurrentMarketPrice = function (baseSymbol) {
|
|
119
|
+
if (baseSymbol === void 0) { baseSymbol = 'USD'; }
|
|
127
120
|
return __awaiter(this, void 0, void 0, function () {
|
|
128
121
|
var marketPrice;
|
|
129
122
|
return __generator(this, function (_a) {
|
|
130
123
|
switch (_a.label) {
|
|
131
|
-
case 0: return [4 /*yield*/, this.priceService.getCurrentMarketPrice(this.protocol)];
|
|
124
|
+
case 0: return [4 /*yield*/, this.priceService.getCurrentMarketPrice(this.protocol, baseSymbol)];
|
|
132
125
|
case 1:
|
|
133
126
|
marketPrice = _a.sent();
|
|
134
127
|
return [4 /*yield*/, this.setCurrentMarketPrice(marketPrice)];
|
|
@@ -157,7 +150,7 @@ var AirGapCoinWallet = /** @class */ (function (_super) {
|
|
|
157
150
|
// TODO: Remove and test
|
|
158
151
|
/*
|
|
159
152
|
We should remove this if BTC also uses blockbook. (And change the order of the if/else below)
|
|
160
|
-
|
|
153
|
+
|
|
161
154
|
The problem is that we have addresses cached for all protocols. But blockbook (grs) doesn't allow
|
|
162
155
|
multiple addresses to be checked at once, so we need to xPub key there (or we would do 100s of requests).
|
|
163
156
|
|
|
@@ -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;;IA2EA,CAAC;IAxEQ,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,QA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AAiB,CAAC,MAAM,CAAC,CAAA;wBAC9B,sBAAO,MAAM,EAAA;;;;KACd;IACH,uBAAC;AAAD,CAAC,AA3ED,CAAsC,uCAAkB,GA2EvD;AA3EY,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): Promise<BigNumber>;
|
|
6
|
+
getCurrentMarketPrice(protocol: ICoinProtocol, baseSymbol: string): 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
|
|