@airgap/coinlib-core 0.13.45-beta.1 → 0.13.45-beta.3
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/actions/Action.js +30 -83
- package/actions/Action.js.map +1 -1
- package/actions/LinkedAction.js +18 -82
- package/actions/LinkedAction.js.map +1 -1
- package/actions/RepeatableAction.js +20 -83
- package/actions/RepeatableAction.js.map +1 -1
- package/actions/SimpleAction.js +12 -74
- package/actions/SimpleAction.js.map +1 -1
- package/actions/StateMachine.js +16 -17
- package/actions/StateMachine.js.map +1 -1
- package/data/KeyPair.d.ts +0 -1
- package/data/Lazy.js +15 -64
- package/data/Lazy.js.map +1 -1
- package/data/RPCBody.js +3 -6
- package/data/RPCBody.js.map +1 -1
- package/dependencies/src/@stablelib/binary-1.0.1/packages/binary/binary.d.ts +12 -12
- package/dependencies/src/@stablelib/binary-1.0.1/packages/binary/binary.js +88 -130
- package/dependencies/src/@stablelib/binary-1.0.1/packages/binary/binary.js.map +1 -1
- package/dependencies/src/@stablelib/blake2b-1.0.1/packages/blake2b/blake2b.d.ts +3 -3
- package/dependencies/src/@stablelib/blake2b-1.0.1/packages/blake2b/blake2b.js +57 -61
- package/dependencies/src/@stablelib/blake2b-1.0.1/packages/blake2b/blake2b.js.map +1 -1
- package/dependencies/src/@stablelib/ed25519-1.0.3/packages/ed25519/ed25519.js +96 -96
- package/dependencies/src/@stablelib/ed25519-1.0.3/packages/ed25519/ed25519.js.map +1 -1
- package/dependencies/src/@stablelib/hash-1.0.1/packages/hash/hash.js +1 -2
- package/dependencies/src/@stablelib/hash-1.0.1/packages/hash/hash.js.map +1 -1
- package/dependencies/src/@stablelib/int-1.0.1/packages/int/int.js +8 -10
- package/dependencies/src/@stablelib/int-1.0.1/packages/int/int.js.map +1 -1
- package/dependencies/src/@stablelib/random-1.0.2/packages/random/random.js +22 -28
- package/dependencies/src/@stablelib/random-1.0.2/packages/random/random.js.map +1 -1
- package/dependencies/src/@stablelib/random-1.0.2/packages/random/source/browser.js +9 -10
- package/dependencies/src/@stablelib/random-1.0.2/packages/random/source/browser.js.map +1 -1
- package/dependencies/src/@stablelib/random-1.0.2/packages/random/source/node.js +10 -11
- package/dependencies/src/@stablelib/random-1.0.2/packages/random/source/node.js.map +1 -1
- package/dependencies/src/@stablelib/random-1.0.2/packages/random/source/system.js +7 -8
- package/dependencies/src/@stablelib/random-1.0.2/packages/random/source/system.js.map +1 -1
- package/dependencies/src/@stablelib/sha512/packages/sha512/sha512.d.ts +3 -3
- package/dependencies/src/@stablelib/sha512/packages/sha512/sha512.js +61 -63
- package/dependencies/src/@stablelib/sha512/packages/sha512/sha512.js.map +1 -1
- package/dependencies/src/@stablelib/sha512-1.0.1/packages/sha512/sha512.d.ts +4 -4
- package/dependencies/src/@stablelib/sha512-1.0.1/packages/sha512/sha512.js +61 -63
- package/dependencies/src/@stablelib/sha512-1.0.1/packages/sha512/sha512.js.map +1 -1
- package/dependencies/src/@stablelib/wipe-1.0.1/packages/wipe/wipe.d.ts +1 -1
- package/dependencies/src/@stablelib/wipe-1.0.1/packages/wipe/wipe.js +2 -3
- package/dependencies/src/@stablelib/wipe-1.0.1/packages/wipe/wipe.js.map +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/codec.js +111 -111
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/codec.js.map +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/constants.js +15 -15
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/constants.js.map +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/decoder.d.ts +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/decoder.js +47 -76
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/decoder.js.map +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/encoder.d.ts +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/encoder.js +46 -61
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/encoder.js.map +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/error.js +61 -106
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/error.js.map +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/interface.d.ts +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/michelson/codec.d.ts +6 -6
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/michelson/codec.js +95 -100
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/michelson/codec.js.map +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/codec-proto14.js +33 -33
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/codec-proto14.js.map +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/constants-proto14.js +9 -9
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/constants-proto14.js.map +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/decoder-proto14.d.ts +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/decoder-proto14.js +46 -75
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/decoder-proto14.js.map +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/encoder-proto14.d.ts +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/encoder-proto14.js +45 -70
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/encoder-proto14.js.map +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/michelson/codec-proto14.js +41 -41
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/proto14-kathmandu/michelson/codec-proto14.js.map +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/protocols.js +4 -4
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/protocols.js.map +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/schema/operation.d.ts +2 -2
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/schema/operation.js +58 -63
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/schema/operation.js.map +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/taquito-local-forging.js +30 -33
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/taquito-local-forging.js.map +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/uint8array-consumer.js +18 -20
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/uint8array-consumer.js.map +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/utils.d.ts +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/utils.js +5 -12
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/utils.js.map +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/validator.js +13 -13
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-local-forging/src/validator.js.map +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-rpc/src/opkind.js +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-rpc/src/opkind.js.map +1 -1
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-rpc/src/types.d.ts +78 -78
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-rpc/src/types.js +2 -2
- package/dependencies/src/@taquito/local-forging-15.0.1/packages/taquito-rpc/src/types.js.map +1 -1
- package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/constants.d.ts +45 -45
- package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/constants.js +75 -76
- package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/constants.js.map +1 -1
- package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/errors.js +115 -178
- package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/errors.js.map +1 -1
- package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/format.d.ts +1 -1
- package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/format.js +6 -9
- package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/format.js.map +1 -1
- package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/taquito-utils.js +78 -83
- package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/taquito-utils.js.map +1 -1
- package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/validators.js +27 -36
- package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/validators.js.map +1 -1
- package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/verify-signature.d.ts +1 -1
- package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/verify-signature.js +25 -26
- package/dependencies/src/@taquito/utils-15.0.1/packages/taquito-utils/src/verify-signature.js.map +1 -1
- package/dependencies/src/cosmjs/index.d.ts +14 -230
- package/dependencies/src/cosmjs/index.js +373 -480
- package/dependencies/src/cosmjs/index.js.map +1 -1
- package/dependencies/src/eciesjs-0.3.9/src/index.d.ts +0 -1
- package/dependencies/src/eciesjs-0.3.9/src/index.js +15 -19
- package/dependencies/src/eciesjs-0.3.9/src/index.js.map +1 -1
- package/dependencies/src/eciesjs-0.3.9/src/keys/PrivateKey.d.ts +0 -1
- package/dependencies/src/eciesjs-0.3.9/src/keys/PrivateKey.js +37 -28
- package/dependencies/src/eciesjs-0.3.9/src/keys/PrivateKey.js.map +1 -1
- package/dependencies/src/eciesjs-0.3.9/src/keys/PublicKey.d.ts +0 -1
- package/dependencies/src/eciesjs-0.3.9/src/keys/PublicKey.js +38 -30
- package/dependencies/src/eciesjs-0.3.9/src/keys/PublicKey.js.map +1 -1
- package/dependencies/src/eciesjs-0.3.9/src/utils.d.ts +0 -1
- package/dependencies/src/eciesjs-0.3.9/src/utils.js +33 -24
- package/dependencies/src/eciesjs-0.3.9/src/utils.js.map +1 -1
- package/dependencies/src/hd-wallet-js-b216450e56954a6e82ace0aade9474673de5d9d5/src/hd-key.js +42 -34
- package/dependencies/src/hd-wallet-js-b216450e56954a6e82ace0aade9474673de5d9d5/src/hd-key.js.map +1 -1
- package/dependencies/src/hd-wallet-js-b216450e56954a6e82ace0aade9474673de5d9d5/src/hd-wallet.js +6 -10
- package/dependencies/src/hd-wallet-js-b216450e56954a6e82ace0aade9474673de5d9d5/src/hd-wallet.js.map +1 -1
- package/errors/coinlib-error.js +16 -37
- package/errors/coinlib-error.js.map +1 -1
- package/errors/index.d.ts +2 -2
- package/errors/index.js +89 -148
- package/errors/index.js.map +1 -1
- package/index.js +19 -19
- package/index.js.map +1 -1
- package/interfaces/IAirGapSignedTransaction.d.ts +1 -1
- package/interfaces/IAirGapTransaction.js +3 -3
- package/interfaces/IAirGapTransaction.js.map +1 -1
- package/networks.js +9 -9
- package/networks.js.map +1 -1
- package/package.json +1 -1
- package/protocols/BlockExplorerProtocol.js +7 -54
- package/protocols/BlockExplorerProtocol.js.map +1 -1
- package/protocols/CryptoClient.js +19 -78
- package/protocols/CryptoClient.js.map +1 -1
- package/protocols/Ed25519CryptoClient.js +30 -98
- package/protocols/Ed25519CryptoClient.js.map +1 -1
- package/protocols/ICoinSubProtocol.js +1 -1
- package/protocols/ICoinSubProtocol.js.map +1 -1
- package/protocols/NonExtendedProtocol.js +26 -29
- package/protocols/NonExtendedProtocol.js.map +1 -1
- package/protocols/Secp256k1CryptoClient.js +9 -73
- package/protocols/Secp256k1CryptoClient.js.map +1 -1
- package/protocols/Sr25519CryptoClient.js +12 -76
- package/protocols/Sr25519CryptoClient.js.map +1 -1
- package/utils/AES.js +81 -132
- package/utils/AES.js.map +1 -1
- package/utils/ErrorWithData.js +5 -23
- package/utils/ErrorWithData.js.map +1 -1
- package/utils/Network.js +1 -1
- package/utils/Network.js.map +1 -1
- package/utils/ProtocolBlockExplorer.js +3 -4
- package/utils/ProtocolBlockExplorer.js.map +1 -1
- package/utils/ProtocolNetwork.js +11 -16
- package/utils/ProtocolNetwork.js.map +1 -1
- package/utils/ProtocolSymbols.d.ts +1 -1
- package/utils/ProtocolSymbols.js +6 -6
- package/utils/ProtocolSymbols.js.map +1 -1
- package/utils/array.js +14 -15
- package/utils/array.js.map +1 -1
- package/utils/assert.js +8 -12
- package/utils/assert.js.map +1 -1
- package/utils/base64Check.d.ts +0 -1
- package/utils/base64Check.js +15 -15
- package/utils/base64Check.js.map +1 -1
- package/utils/blake2b.js +11 -14
- package/utils/blake2b.js.map +1 -1
- package/utils/buffer.d.ts +0 -1
- package/utils/buffer.js +1 -1
- package/utils/buffer.js.map +1 -1
- package/utils/cache.js +38 -87
- package/utils/cache.js.map +1 -1
- package/utils/error.js +2 -3
- package/utils/error.js.map +1 -1
- package/utils/hex.d.ts +1 -2
- package/utils/hex.js +31 -38
- package/utils/hex.js.map +1 -1
- package/utils/interfaces.js +3 -4
- package/utils/interfaces.js.map +1 -1
- package/utils/object.js +5 -7
- package/utils/object.js.map +1 -1
- package/utils/padStart.js +1 -2
- package/utils/padStart.js.map +1 -1
- package/utils/remote-data/HttpRemoteData.js +24 -107
- package/utils/remote-data/HttpRemoteData.js.map +1 -1
- package/utils/remote-data/IpfsRemoteData.js +32 -116
- package/utils/remote-data/IpfsRemoteData.js.map +1 -1
- package/utils/remote-data/RemoteData.d.ts +0 -1
- package/utils/remote-data/RemoteData.js +3 -4
- package/utils/remote-data/RemoteData.js.map +1 -1
- package/utils/remote-data/RemoteDataFactory.d.ts +2 -2
- package/utils/remote-data/RemoteDataFactory.js +13 -20
- package/utils/remote-data/RemoteDataFactory.js.map +1 -1
- package/utils/remote-data/Sha256RemoteData.d.ts +0 -1
- package/utils/remote-data/Sha256RemoteData.js +44 -117
- package/utils/remote-data/Sha256RemoteData.js.map +1 -1
- package/utils/string.js +8 -9
- package/utils/string.js.map +1 -1
- package/utils/type.js +3 -4
- package/utils/type.js.map +1 -1
- package/utils/xxhash.d.ts +0 -1
- package/utils/xxhash.js +9 -11
- package/utils/xxhash.js.map +1 -1
- package/wallet/AirGapCoinWallet.js +64 -183
- package/wallet/AirGapCoinWallet.js.map +1 -1
- package/wallet/AirGapMarketWallet.js +88 -201
- package/wallet/AirGapMarketWallet.js.map +1 -1
- package/wallet/AirGapNFTWallet.js +48 -165
- package/wallet/AirGapNFTWallet.js.map +1 -1
- package/wallet/AirGapWallet.js +58 -145
- package/wallet/AirGapWallet.js.map +1 -1
|
@@ -1,172 +1,77 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
28
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
-
function step(op) {
|
|
31
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
-
while (_) try {
|
|
33
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
34
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
-
switch (op[0]) {
|
|
36
|
-
case 0: case 1: t = op; break;
|
|
37
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
-
default:
|
|
41
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
-
if (t[2]) _.ops.pop();
|
|
46
|
-
_.trys.pop(); continue;
|
|
47
|
-
}
|
|
48
|
-
op = body.call(thisArg, _);
|
|
49
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
54
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
55
4
|
};
|
|
56
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
57
6
|
exports.AirGapMarketWallet = void 0;
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
_this.addressIndex = addressIndex;
|
|
73
|
-
return _this;
|
|
7
|
+
const bignumber_1 = __importDefault(require("../dependencies/src/bignumber.js-9.0.0/bignumber"));
|
|
8
|
+
const ProtocolSymbols_1 = require("../utils/ProtocolSymbols");
|
|
9
|
+
const AirGapWallet_1 = require("./AirGapWallet");
|
|
10
|
+
class AirGapMarketWallet extends AirGapWallet_1.AirGapWallet {
|
|
11
|
+
constructor(protocol, publicKey, isExtendedPublicKey, derivationPath, masterFingerprint, status, priceService, addressIndex) {
|
|
12
|
+
super(protocol, publicKey, isExtendedPublicKey, derivationPath, masterFingerprint, status, addressIndex);
|
|
13
|
+
this.protocol = protocol;
|
|
14
|
+
this.publicKey = publicKey;
|
|
15
|
+
this.isExtendedPublicKey = isExtendedPublicKey;
|
|
16
|
+
this.derivationPath = derivationPath;
|
|
17
|
+
this.masterFingerprint = masterFingerprint;
|
|
18
|
+
this.status = status;
|
|
19
|
+
this.priceService = priceService;
|
|
20
|
+
this.addressIndex = addressIndex;
|
|
74
21
|
}
|
|
75
|
-
|
|
76
|
-
|
|
22
|
+
addressesToCheck() {
|
|
23
|
+
const addressesToReceive = this.addressIndex !== undefined ? [this.addresses[this.addressIndex]] : this.addresses;
|
|
77
24
|
return addressesToReceive;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
case 2:
|
|
89
|
-
_a.sent();
|
|
90
|
-
return [2 /*return*/];
|
|
91
|
-
}
|
|
25
|
+
}
|
|
26
|
+
async setProtocol(protocol) {
|
|
27
|
+
await super.setProtocol(protocol);
|
|
28
|
+
this.reset();
|
|
29
|
+
await this.synchronize();
|
|
30
|
+
}
|
|
31
|
+
async synchronize(...args) {
|
|
32
|
+
if (this.synchronizePromise === undefined) {
|
|
33
|
+
this.synchronizePromise = this._synchronize(...args).finally(() => {
|
|
34
|
+
this.synchronizePromise = undefined;
|
|
92
35
|
});
|
|
93
|
-
});
|
|
94
|
-
};
|
|
95
|
-
AirGapMarketWallet.prototype.synchronize = function () {
|
|
96
|
-
var args = [];
|
|
97
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
98
|
-
args[_i] = arguments[_i];
|
|
99
36
|
}
|
|
100
|
-
return
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
*/
|
|
139
|
-
transactionResult = _a.sent();
|
|
140
|
-
return [3 /*break*/, 11];
|
|
141
|
-
case 3:
|
|
142
|
-
if (!(protocolIdentifier === ProtocolSymbols_1.MainProtocolSymbols.XTZ_SHIELDED) /* TODO: cover ALL sapling protocols */) return [3 /*break*/, 5]; /* TODO: cover ALL sapling protocols */
|
|
143
|
-
return [4 /*yield*/, this.protocol.getTransactionsFromPublicKey(this.publicKey, limit, cursor)];
|
|
144
|
-
case 4:
|
|
145
|
-
transactionResult = _a.sent();
|
|
146
|
-
return [3 /*break*/, 11];
|
|
147
|
-
case 5:
|
|
148
|
-
if (!(this.addresses.length > 0)) return [3 /*break*/, 7];
|
|
149
|
-
return [4 /*yield*/, this.protocol.getTransactionsFromAddresses(this.addressesToCheck(), limit, cursor)];
|
|
150
|
-
case 6:
|
|
151
|
-
transactionResult = _a.sent();
|
|
152
|
-
return [3 /*break*/, 11];
|
|
153
|
-
case 7:
|
|
154
|
-
if (!this.isExtendedPublicKey) return [3 /*break*/, 9];
|
|
155
|
-
return [4 /*yield*/, this.protocol.getTransactionsFromExtendedPublicKey(this.publicKey, limit, cursor)];
|
|
156
|
-
case 8:
|
|
157
|
-
transactionResult = _a.sent();
|
|
158
|
-
return [3 /*break*/, 11];
|
|
159
|
-
case 9: return [4 /*yield*/, this.protocol.getTransactionsFromPublicKey(this.publicKey, limit, cursor)];
|
|
160
|
-
case 10:
|
|
161
|
-
transactionResult = _a.sent();
|
|
162
|
-
_a.label = 11;
|
|
163
|
-
case 11: return [2 /*return*/, transactionResult];
|
|
164
|
-
}
|
|
165
|
-
});
|
|
166
|
-
});
|
|
167
|
-
};
|
|
168
|
-
AirGapMarketWallet.prototype.prepareTransaction = function (recipients, values, fee, data) {
|
|
169
|
-
if (data === void 0) { data = {}; }
|
|
37
|
+
return this.synchronizePromise;
|
|
38
|
+
}
|
|
39
|
+
async fetchTransactions(limit, cursor) {
|
|
40
|
+
const protocolIdentifier = await this.protocol.getIdentifier();
|
|
41
|
+
// let transactions: IAirGapTransaction[] = []
|
|
42
|
+
let transactionResult;
|
|
43
|
+
if ((protocolIdentifier === ProtocolSymbols_1.MainProtocolSymbols.BTC ||
|
|
44
|
+
protocolIdentifier === ProtocolSymbols_1.MainProtocolSymbols.BTC_SEGWIT ||
|
|
45
|
+
protocolIdentifier === ProtocolSymbols_1.MainProtocolSymbols.BTC_TAPROOT ||
|
|
46
|
+
protocolIdentifier === ProtocolSymbols_1.MainProtocolSymbols.GRS) &&
|
|
47
|
+
this.isExtendedPublicKey) {
|
|
48
|
+
// TODO: Remove and test
|
|
49
|
+
/*
|
|
50
|
+
We should remove this if BTC also uses blockbook. (And change the order of the if/else below)
|
|
51
|
+
|
|
52
|
+
The problem is that we have addresses cached for all protocols. But blockbook (grs) doesn't allow
|
|
53
|
+
multiple addresses to be checked at once, so we need to xPub key there (or we would do 100s of requests).
|
|
54
|
+
|
|
55
|
+
We can also not simply change the order of the following if/else, because then it would use the xPub method for
|
|
56
|
+
BTC as well, which results in the addresses being derived again, which causes massive lags in the apps.
|
|
57
|
+
*/
|
|
58
|
+
transactionResult = await this.protocol.getTransactionsFromExtendedPublicKey(this.publicKey, limit, cursor);
|
|
59
|
+
}
|
|
60
|
+
else if (protocolIdentifier === ProtocolSymbols_1.MainProtocolSymbols.XTZ_SHIELDED /* TODO: cover ALL sapling protocols */) {
|
|
61
|
+
transactionResult = await this.protocol.getTransactionsFromPublicKey(this.publicKey, limit, cursor);
|
|
62
|
+
}
|
|
63
|
+
else if (this.addresses.length > 0) {
|
|
64
|
+
transactionResult = await this.protocol.getTransactionsFromAddresses(this.addressesToCheck(), limit, cursor);
|
|
65
|
+
}
|
|
66
|
+
else if (this.isExtendedPublicKey) {
|
|
67
|
+
transactionResult = await this.protocol.getTransactionsFromExtendedPublicKey(this.publicKey, limit, cursor);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
transactionResult = await this.protocol.getTransactionsFromPublicKey(this.publicKey, limit, cursor);
|
|
71
|
+
}
|
|
72
|
+
return transactionResult;
|
|
73
|
+
}
|
|
74
|
+
prepareTransaction(recipients, values, fee, data = {}) {
|
|
170
75
|
if (this.isExtendedPublicKey) {
|
|
171
76
|
return this.protocol.prepareTransactionFromExtendedPublicKey(this.publicKey, 0, recipients, values, fee, data);
|
|
172
77
|
}
|
|
@@ -176,47 +81,29 @@ var AirGapMarketWallet = /** @class */ (function (_super) {
|
|
|
176
81
|
}
|
|
177
82
|
return this.protocol.prepareTransactionFromPublicKey(this.publicKey, recipients, values, fee, data);
|
|
178
83
|
}
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
if (
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
if (data === void 0) { data = {}; }
|
|
204
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
205
|
-
return __generator(this, function (_a) {
|
|
206
|
-
if (this.isExtendedPublicKey) {
|
|
207
|
-
return [2 /*return*/, this.protocol.estimateFeeDefaultsFromExtendedPublicKey(this.publicKey, recipients, values, data)];
|
|
208
|
-
}
|
|
209
|
-
else {
|
|
210
|
-
if (this.addressIndex) {
|
|
211
|
-
data = Object.assign(data, { addressIndex: this.addressIndex });
|
|
212
|
-
}
|
|
213
|
-
return [2 /*return*/, this.protocol.estimateFeeDefaultsFromPublicKey(this.publicKey, recipients, values, data)];
|
|
214
|
-
}
|
|
215
|
-
return [2 /*return*/];
|
|
216
|
-
});
|
|
217
|
-
});
|
|
218
|
-
};
|
|
219
|
-
return AirGapMarketWallet;
|
|
220
|
-
}(AirGapWallet_1.AirGapWallet));
|
|
84
|
+
}
|
|
85
|
+
async getMaxTransferValue(recipients, fee, data = {}) {
|
|
86
|
+
if (this.isExtendedPublicKey) {
|
|
87
|
+
return new bignumber_1.default(await this.protocol.estimateMaxTransactionValueFromExtendedPublicKey(this.publicKey, recipients, fee, data));
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
if (this.addressIndex) {
|
|
91
|
+
data = Object.assign(data, { addressIndex: this.addressIndex });
|
|
92
|
+
}
|
|
93
|
+
return new bignumber_1.default(await this.protocol.estimateMaxTransactionValueFromPublicKey(this.publicKey, recipients, fee, data));
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
async estimateFees(recipients, values, data = {}) {
|
|
97
|
+
if (this.isExtendedPublicKey) {
|
|
98
|
+
return this.protocol.estimateFeeDefaultsFromExtendedPublicKey(this.publicKey, recipients, values, data);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
if (this.addressIndex) {
|
|
102
|
+
data = Object.assign(data, { addressIndex: this.addressIndex });
|
|
103
|
+
}
|
|
104
|
+
return this.protocol.estimateFeeDefaultsFromPublicKey(this.publicKey, recipients, values, data);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
221
108
|
exports.AirGapMarketWallet = AirGapMarketWallet;
|
|
222
109
|
//# sourceMappingURL=AirGapMarketWallet.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AirGapMarketWallet.js","sourceRoot":"","sources":["../../src/wallet/AirGapMarketWallet.ts"],"names":[],"mappings":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AC,YAAY,EAAE,CAAC;gBACtB,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,YAAY,EAAE,IAAI,CAAC,YAAY,EAAE,CAAC,CAAA;YACjE,CAAC;YAED,OAAO,IAAI,mBAAS,CAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,wCAAwC,CAAC,IAAI,CAAC,SAAS,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC,CAAA;QAC3H,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,YAAY,CAAC,UAAoB,EAAE,MAAgB,EAAE,OAAmC,EAAE;QACrG,IAAI,IAAI,CAAC,mBAAmB,EAAE,CAAC;YAC7B,OAAO,IAAI,CAAC,QAAQ,CAAC,wCAAwC,CAAC,IAAI,CAAC,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,CAAC,CAAA;QACzG,CAAC;aAAM,CAAC;YACN,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;gBACtB,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,YAAY,EAAE,IAAI,CAAC,YAAY,EAAE,CAAC,CAAA;YACjE,CAAC;YAED,OAAO,IAAI,CAAC,QAAQ,CAAC,gCAAgC,CAAC,IAAI,CAAC,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,CAAC,CAAA;QACjG,CAAC;IACH,CAAC;CACF;AA9HD,gDA8HC"}
|
|
@@ -1,179 +1,62 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
28
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
-
function step(op) {
|
|
31
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
-
while (_) try {
|
|
33
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
34
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
-
switch (op[0]) {
|
|
36
|
-
case 0: case 1: t = op; break;
|
|
37
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
-
default:
|
|
41
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
-
if (t[2]) _.ops.pop();
|
|
46
|
-
_.trys.pop(); continue;
|
|
47
|
-
}
|
|
48
|
-
op = body.call(thisArg, _);
|
|
49
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
54
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
55
4
|
};
|
|
56
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
57
6
|
exports.AirGapNFTWallet = void 0;
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
_this.currentMarketPrice = {};
|
|
67
|
-
return _this;
|
|
7
|
+
const bignumber_1 = __importDefault(require("../dependencies/src/bignumber.js-9.0.0/bignumber"));
|
|
8
|
+
const ProtocolNetwork_1 = require("../utils/ProtocolNetwork");
|
|
9
|
+
const AirGapMarketWallet_1 = require("./AirGapMarketWallet");
|
|
10
|
+
class AirGapNFTWallet extends AirGapMarketWallet_1.AirGapMarketWallet {
|
|
11
|
+
constructor() {
|
|
12
|
+
super(...arguments);
|
|
13
|
+
this.currentBalance = {};
|
|
14
|
+
this.currentMarketPrice = {};
|
|
68
15
|
}
|
|
69
|
-
|
|
16
|
+
getCurrentBalance(assetID) {
|
|
70
17
|
return this.currentBalance[assetID];
|
|
71
|
-
}
|
|
72
|
-
|
|
18
|
+
}
|
|
19
|
+
setCurrentBalance(balance, assetID) {
|
|
73
20
|
this.currentBalance[assetID] = balance;
|
|
74
|
-
}
|
|
75
|
-
|
|
21
|
+
}
|
|
22
|
+
getCurrentMarketPrice(assetID) {
|
|
76
23
|
return this.currentMarketPrice[assetID];
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
});
|
|
94
|
-
};
|
|
95
|
-
AirGapNFTWallet.prototype.synchronize = function (assetsID) {
|
|
96
|
-
if (assetsID === void 0) { assetsID = []; }
|
|
97
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
98
|
-
return __generator(this, function (_a) {
|
|
99
|
-
return [2 /*return*/, _super.prototype.synchronize.call(this, assetsID)];
|
|
100
|
-
});
|
|
101
|
-
});
|
|
102
|
-
};
|
|
103
|
-
AirGapNFTWallet.prototype._synchronize = function (assetIDs) {
|
|
104
|
-
if (assetIDs === void 0) { assetIDs = []; }
|
|
105
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
106
|
-
var _this = this;
|
|
107
|
-
return __generator(this, function (_a) {
|
|
108
|
-
switch (_a.label) {
|
|
109
|
-
case 0: return [4 /*yield*/, Promise.all(assetIDs.map(function (assetID) { return __awaiter(_this, void 0, void 0, function () {
|
|
110
|
-
var _a, balance, marketPrice;
|
|
111
|
-
return __generator(this, function (_b) {
|
|
112
|
-
switch (_b.label) {
|
|
113
|
-
case 0: return [4 /*yield*/, Promise.all([this.balanceOf(assetID), this.fetchCurrentMarketPrice(assetID)])];
|
|
114
|
-
case 1:
|
|
115
|
-
_a = _b.sent(), balance = _a[0], marketPrice = _a[1];
|
|
116
|
-
this.setCurrentBalance(balance, assetID);
|
|
117
|
-
return [4 /*yield*/, this.setCurrentMarketPrice(marketPrice, assetID)];
|
|
118
|
-
case 2:
|
|
119
|
-
_b.sent();
|
|
120
|
-
return [2 /*return*/];
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
}); }))];
|
|
124
|
-
case 1:
|
|
125
|
-
_a.sent();
|
|
126
|
-
return [2 /*return*/];
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
});
|
|
130
|
-
};
|
|
131
|
-
AirGapNFTWallet.prototype.reset = function () {
|
|
24
|
+
}
|
|
25
|
+
async setCurrentMarketPrice(marketPrice, assetID) {
|
|
26
|
+
this.getCurrentMarketPrice[assetID] =
|
|
27
|
+
(await this.protocol.getOptions()).network.type === ProtocolNetwork_1.NetworkType.MAINNET ? marketPrice : new bignumber_1.default(0);
|
|
28
|
+
}
|
|
29
|
+
async synchronize(assetsID = []) {
|
|
30
|
+
return super.synchronize(assetsID);
|
|
31
|
+
}
|
|
32
|
+
async _synchronize(assetIDs = []) {
|
|
33
|
+
await Promise.all(assetIDs.map(async (assetID) => {
|
|
34
|
+
const [balance, marketPrice] = await Promise.all([this.balanceOf(assetID), this.fetchCurrentMarketPrice(assetID)]);
|
|
35
|
+
this.setCurrentBalance(balance, assetID);
|
|
36
|
+
await this.setCurrentMarketPrice(marketPrice, assetID);
|
|
37
|
+
}));
|
|
38
|
+
}
|
|
39
|
+
reset() {
|
|
132
40
|
this.currentBalance = {};
|
|
133
41
|
this.currentMarketPrice = {};
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
var result, _a, _b;
|
|
154
|
-
return __generator(this, function (_c) {
|
|
155
|
-
switch (_c.label) {
|
|
156
|
-
case 0:
|
|
157
|
-
if (!this.isExtendedPublicKey) return [3 /*break*/, 2];
|
|
158
|
-
_a = bignumber_1.default.bind;
|
|
159
|
-
return [4 /*yield*/, this.protocol.getBalanceOfExtendedPublicKey(this.publicKey, 0, { assetID: assetID })];
|
|
160
|
-
case 1:
|
|
161
|
-
result = new (_a.apply(bignumber_1.default, [void 0, _c.sent()]))();
|
|
162
|
-
return [3 /*break*/, 4];
|
|
163
|
-
case 2:
|
|
164
|
-
_b = bignumber_1.default.bind;
|
|
165
|
-
return [4 /*yield*/, this.protocol.getBalanceOfPublicKey(this.publicKey, { addressIndex: this.addressIndex, assetID: assetID })];
|
|
166
|
-
case 3:
|
|
167
|
-
result = new (_b.apply(bignumber_1.default, [void 0, _c.sent()]))();
|
|
168
|
-
_c.label = 4;
|
|
169
|
-
case 4:
|
|
170
|
-
this.setCurrentBalance(result, assetID);
|
|
171
|
-
return [2 /*return*/, result];
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
});
|
|
175
|
-
};
|
|
176
|
-
return AirGapNFTWallet;
|
|
177
|
-
}(AirGapMarketWallet_1.AirGapMarketWallet));
|
|
42
|
+
}
|
|
43
|
+
async fetchCurrentMarketPrice(assetID, _baseSymbol = 'USD') {
|
|
44
|
+
// TODO
|
|
45
|
+
const result = new bignumber_1.default(0);
|
|
46
|
+
await this.setCurrentMarketPrice(result, assetID);
|
|
47
|
+
return result;
|
|
48
|
+
}
|
|
49
|
+
async balanceOf(assetID) {
|
|
50
|
+
let result;
|
|
51
|
+
if (this.isExtendedPublicKey) {
|
|
52
|
+
result = new bignumber_1.default(await this.protocol.getBalanceOfExtendedPublicKey(this.publicKey, 0, { assetID }));
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
result = new bignumber_1.default(await this.protocol.getBalanceOfPublicKey(this.publicKey, { addressIndex: this.addressIndex, assetID }));
|
|
56
|
+
}
|
|
57
|
+
this.setCurrentBalance(result, assetID);
|
|
58
|
+
return result;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
178
61
|
exports.AirGapNFTWallet = AirGapNFTWallet;
|
|
179
62
|
//# sourceMappingURL=AirGapNFTWallet.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AirGapNFTWallet.js","sourceRoot":"","sources":["../../src/wallet/AirGapNFTWallet.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AirGapNFTWallet.js","sourceRoot":"","sources":["../../src/wallet/AirGapNFTWallet.ts"],"names":[],"mappings":";;;;;;AAAA,iGAAwE;AACxE,8DAAsD;AAEtD,6DAAyD;AAEzD,MAAa,eAAgB,SAAQ,uCAAkB;IAAvD;;QACU,mBAAc,GAA0C,EAAE,CAAA;QAU1D,uBAAkB,GAA0C,EAAE,CAAA;IAgDxE,CAAC;IAxDQ,iBAAiB,CAAC,OAAe;QACtC,OAAO,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAA;IACrC,CAAC;IAEM,iBAAiB,CAAC,OAA8B,EAAE,OAAe;QACtE,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,GAAG,OAAO,CAAA;IACxC,CAAC;IAIM,qBAAqB,CAAC,OAAe;QAC1C,OAAO,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAA;IACzC,CAAC;IAEM,KAAK,CAAC,qBAAqB,CAAC,WAAkC,EAAE,OAAe;QACpF,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC;YACjC,CAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,KAAK,6BAAW,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,mBAAS,CAAC,CAAC,CAAC,CAAA;IAC5G,CAAC;IAEM,KA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