@wallfree-dev/wallet 0.13.42
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/LICENSE.md +7 -0
- package/index.d.ts +8 -0
- package/index.js +16 -0
- package/index.js.map +1 -0
- package/package.json +55 -0
- package/readme.md +121 -0
- package/utils/address.d.ts +2 -0
- package/utils/address.js +13 -0
- package/utils/address.js.map +1 -0
- package/utils/protocol.d.ts +2 -0
- package/utils/protocol.js +64 -0
- package/utils/protocol.js.map +1 -0
- package/wallet/AirGapWallet.d.ts +32 -0
- package/wallet/AirGapWallet.js +153 -0
- package/wallet/AirGapWallet.js.map +1 -0
- package/wallet/offline/AirGapOfflineWallet.d.ts +7 -0
- package/wallet/offline/AirGapOfflineWallet.js +31 -0
- package/wallet/offline/AirGapOfflineWallet.js.map +1 -0
- package/wallet/online/AirGapCoinWallet.d.ts +20 -0
- package/wallet/online/AirGapCoinWallet.js +204 -0
- package/wallet/online/AirGapCoinWallet.js.map +1 -0
- package/wallet/online/AirGapNFTWallet.d.ts +16 -0
- package/wallet/online/AirGapNFTWallet.js +182 -0
- package/wallet/online/AirGapNFTWallet.js.map +1 -0
- package/wallet/online/AirGapOnlineWallet.d.ts +36 -0
- package/wallet/online/AirGapOnlineWallet.js +259 -0
- package/wallet/online/AirGapOnlineWallet.js.map +1 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright 2019 Papers AG
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AirGapWallet, AirGapWalletStatus, SerializedAirGapWallet } from './wallet/AirGapWallet';
|
|
2
|
+
import { AirGapOfflineWallet } from './wallet/offline/AirGapOfflineWallet';
|
|
3
|
+
import { AirGapCoinWallet, TimeInterval } from './wallet/online/AirGapCoinWallet';
|
|
4
|
+
import { AirGapNFTWallet } from './wallet/online/AirGapNFTWallet';
|
|
5
|
+
import { AirGapOnlineWallet, AirGapWalletPriceService } from './wallet/online/AirGapOnlineWallet';
|
|
6
|
+
export { AirGapWallet, AirGapOfflineWallet, AirGapOnlineWallet, AirGapCoinWallet, AirGapWalletStatus, AirGapNFTWallet };
|
|
7
|
+
export { SerializedAirGapWallet };
|
|
8
|
+
export { TimeInterval, AirGapWalletPriceService };
|
package/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TimeInterval = exports.AirGapNFTWallet = exports.AirGapWalletStatus = exports.AirGapCoinWallet = exports.AirGapOnlineWallet = exports.AirGapOfflineWallet = exports.AirGapWallet = void 0;
|
|
4
|
+
var AirGapWallet_1 = require("./wallet/AirGapWallet");
|
|
5
|
+
Object.defineProperty(exports, "AirGapWallet", { enumerable: true, get: function () { return AirGapWallet_1.AirGapWallet; } });
|
|
6
|
+
Object.defineProperty(exports, "AirGapWalletStatus", { enumerable: true, get: function () { return AirGapWallet_1.AirGapWalletStatus; } });
|
|
7
|
+
var AirGapOfflineWallet_1 = require("./wallet/offline/AirGapOfflineWallet");
|
|
8
|
+
Object.defineProperty(exports, "AirGapOfflineWallet", { enumerable: true, get: function () { return AirGapOfflineWallet_1.AirGapOfflineWallet; } });
|
|
9
|
+
var AirGapCoinWallet_1 = require("./wallet/online/AirGapCoinWallet");
|
|
10
|
+
Object.defineProperty(exports, "AirGapCoinWallet", { enumerable: true, get: function () { return AirGapCoinWallet_1.AirGapCoinWallet; } });
|
|
11
|
+
Object.defineProperty(exports, "TimeInterval", { enumerable: true, get: function () { return AirGapCoinWallet_1.TimeInterval; } });
|
|
12
|
+
var AirGapNFTWallet_1 = require("./wallet/online/AirGapNFTWallet");
|
|
13
|
+
Object.defineProperty(exports, "AirGapNFTWallet", { enumerable: true, get: function () { return AirGapNFTWallet_1.AirGapNFTWallet; } });
|
|
14
|
+
var AirGapOnlineWallet_1 = require("./wallet/online/AirGapOnlineWallet");
|
|
15
|
+
Object.defineProperty(exports, "AirGapOnlineWallet", { enumerable: true, get: function () { return AirGapOnlineWallet_1.AirGapOnlineWallet; } });
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,sDAAgG;AAMvF,6FANA,2BAAY,OAMA;AAA6D,mGAN3D,iCAAkB,OAM2D;AALpG,4EAA0E;AAKnD,oGALd,yCAAmB,OAKc;AAJ1C,qEAAiF;AAIjB,iGAJvD,mCAAgB,OAIuD;AAMvE,6FAVkB,+BAAY,OAUlB;AATrB,mEAAiE;AAGqC,gGAH7F,iCAAe,OAG6F;AAFrH,yEAAiG;AAErD,mGAFnC,uCAAkB,OAEmC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@wallfree-dev/wallet",
|
|
3
|
+
"version": "0.13.42",
|
|
4
|
+
"description": "The @wallfree-dev/wallet package provides interfaces for offline/online wallet functionalities.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"airgap"
|
|
7
|
+
],
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"homepage": "https://www.airgap.it",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/airgap-it/airgap-coin-lib"
|
|
13
|
+
},
|
|
14
|
+
"publishConfig": {
|
|
15
|
+
"access": "public"
|
|
16
|
+
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "rm -rf ./dist && tsc && node scripts/copy-files-after-build.js && node scripts/make-ts-declaration-files-backwards-compatible.js",
|
|
19
|
+
"build-scripts": "tsc scripts/copy-files-after-build.ts scripts/make-ts-declaration-files-backwards-compatible.ts",
|
|
20
|
+
"lint": "tslint -c ./tslint.json --project ./tsconfig.json --format stylish --fix",
|
|
21
|
+
"lint:prettier": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
|
22
|
+
"lint-ci": "tslint -t json -o ../../lint-reports/core.json --project . || true",
|
|
23
|
+
"lint-ci:prettier": "prettier \"src/**/*.ts\" \"test/**/*.ts\" --list-different",
|
|
24
|
+
"test": "TS_NODE_PROJECT='./test/tsconfig.json' nyc mocha --bail --require ts-node/register --require tsconfig-paths/register --require source-map-support/register --full-trace --delay --timeout 40000 ./test/**/**.spec.ts",
|
|
25
|
+
"test-ci": "nyc --reporter=lcov pnpm test",
|
|
26
|
+
"browserify": "browserify ./dist/index.js -s airgapCoinLibWallet > ./dist/airgap-coinlib-wallet.min.js"
|
|
27
|
+
},
|
|
28
|
+
"author": "Papers AG <contact@papers.ch> (https://papers.ch)",
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@wallfree-dev/coinlib-core": "^0.13.42",
|
|
31
|
+
"@wallfree-dev/module-kit": "^0.13.42"
|
|
32
|
+
},
|
|
33
|
+
"nyc": {
|
|
34
|
+
"include": [
|
|
35
|
+
"src/**/*.ts"
|
|
36
|
+
],
|
|
37
|
+
"exclude": [
|
|
38
|
+
"test/**/*.spec.ts"
|
|
39
|
+
],
|
|
40
|
+
"extension": [
|
|
41
|
+
".ts"
|
|
42
|
+
],
|
|
43
|
+
"require": [
|
|
44
|
+
"ts-node/register"
|
|
45
|
+
],
|
|
46
|
+
"reporter": [
|
|
47
|
+
"text",
|
|
48
|
+
"text-summary"
|
|
49
|
+
],
|
|
50
|
+
"report-dir": "../../coverage/wallet",
|
|
51
|
+
"sourceMap": true,
|
|
52
|
+
"instrument": true
|
|
53
|
+
},
|
|
54
|
+
"gitHead": "8e8feb6788204501b7173aa825f5456c2a5f185b"
|
|
55
|
+
}
|
package/readme.md
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# AirGap Coin Library
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/airgap-coin-lib)
|
|
4
|
+
[](https://airgap-it.github.io/airgap-coin-lib/)
|
|
5
|
+
[](https://travis-ci.org/airgap-it/airgap-coin-lib/)
|
|
6
|
+
[](https://codecov.io/gh/airgap-it/airgap-coin-lib/)
|
|
7
|
+
|
|
8
|
+
The `airgap-coin-lib` is a protocol-agnostic library that allows easy handling of the most important tasks relating cryptocurrencies and blockchains.
|
|
9
|
+
|
|
10
|
+
It implements operations such as preparing, signing and broadcasting transactions for a range of protocols.
|
|
11
|
+
|
|
12
|
+
The library consists of a shared interface for all implemented protocols. This is especially useful in the context of AirGap because methods are designed to support offline key management and signing. The following core operations are specified:
|
|
13
|
+
|
|
14
|
+
- `prepareTransaction` - This is done on AirGap Wallet (online) side. Either a public key or extended public key is used and will fetch the required information from the network.
|
|
15
|
+
- `signTransaction` - This is done in AirGap Vault (offline) side. The output of "prepareTransaction" is the input for this method (hence the output of "prepareTransaction" is transferred via URL scheme (same-device) or QR code (2-device-setup)).
|
|
16
|
+
- `broadcastTransaction` - This is done in AirGap Wallet (online) side. The output of "signTransaction" is the input for this method (hence the output of "signTransaction" is transferred via URL scheme (same-device) or QR code (2-device-setup)).
|
|
17
|
+
|
|
18
|
+
## Supported Protocols
|
|
19
|
+
|
|
20
|
+
The modular design used in this library allows you to simply add new protocols with special logic. Adding a new Bitcoin-like protocol basically means:
|
|
21
|
+
|
|
22
|
+
1. select the correct network parameters (see `src/networks.ts`)
|
|
23
|
+
2. set the Insight API URL to communicate with the blockchain
|
|
24
|
+
|
|
25
|
+
Adding a new Ethereum-like protocol means:
|
|
26
|
+
|
|
27
|
+
1. set the correct chain id
|
|
28
|
+
2. set the JSON RPC URL
|
|
29
|
+
|
|
30
|
+
Currently supported are:
|
|
31
|
+
|
|
32
|
+
- Bitcoin
|
|
33
|
+
- Ethereum
|
|
34
|
+
- Generic ERC20 Tokens
|
|
35
|
+
- Aeternity
|
|
36
|
+
- Tezos
|
|
37
|
+
- FA1.2 tokens
|
|
38
|
+
- tzBTC
|
|
39
|
+
- USDtz
|
|
40
|
+
- FA2 tokens
|
|
41
|
+
- Groestlcoin
|
|
42
|
+
- Cosmos
|
|
43
|
+
- Polkadot
|
|
44
|
+
- Kusama
|
|
45
|
+
|
|
46
|
+
## Features
|
|
47
|
+
|
|
48
|
+
### Protocols
|
|
49
|
+
|
|
50
|
+
The way the interface was designed is to allow stateless calls. This means the class stores very little state itself.
|
|
51
|
+
All required input comes from the method params (public key, extended public key, etc...)
|
|
52
|
+
|
|
53
|
+
Currently we support for Bitcoin-like (UTXO) protocols:
|
|
54
|
+
|
|
55
|
+
- Single Address Wallets (deprecated)
|
|
56
|
+
- HD Wallets
|
|
57
|
+
|
|
58
|
+
Currently we support for Ethereum-like (Account-based) protocols:
|
|
59
|
+
|
|
60
|
+
- Single Address Wallets
|
|
61
|
+
|
|
62
|
+
### Delegation
|
|
63
|
+
|
|
64
|
+
There is a different interface that can be implemented if the protocol supports delegation. The delegation flow usually requires some changes in the user interface of the AirGap Wallet as well.
|
|
65
|
+
|
|
66
|
+
### Inter App Communication
|
|
67
|
+
|
|
68
|
+
A serializer is included that encodes JSON structures with RLP and base58check. Those strings can then be sent to the other app, either through QR codes or a URL. The serializer can only serialize messages in predefined formats, so new message types have to be added when new protocols are added.
|
|
69
|
+
|
|
70
|
+
### Tezos FA1.2 and FA2 tokens
|
|
71
|
+
|
|
72
|
+
It is possible to interact (fetch balances, create transfers, etc.) with an FA1.2 and FA2 smart contracts using the `TezosFA12Protocol` and `TezosFA2Protocol` classes. An example on how to use them can be found in `examples/custom/protocols/tezos/fa2-smart-contract.ts`.
|
|
73
|
+
|
|
74
|
+
## Synchronising information between wallet and vault
|
|
75
|
+
|
|
76
|
+
Such that the system works we need to be able to synchronise wallets. A wallet can be:
|
|
77
|
+
|
|
78
|
+
- Single Address Wallet
|
|
79
|
+
- HD Wallet
|
|
80
|
+
|
|
81
|
+
For the single address wallet we only need to share the public key. For HD Wallet we need to share the extended public key.
|
|
82
|
+
|
|
83
|
+
## Getting started
|
|
84
|
+
|
|
85
|
+
### Requirements
|
|
86
|
+
|
|
87
|
+
```
|
|
88
|
+
npm >= 6
|
|
89
|
+
NodeJS >= 12
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Build dependencies get installed using `npm install`.
|
|
93
|
+
|
|
94
|
+
### Clone and Run
|
|
95
|
+
|
|
96
|
+
```
|
|
97
|
+
$ git clone https://github.com/airgap-it/airgap-coin-lib.git
|
|
98
|
+
$ cd airgap-coin-lib
|
|
99
|
+
$ npm install
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
To run the tests, you will have to install the test dependencies
|
|
103
|
+
|
|
104
|
+
```
|
|
105
|
+
$ npm run install-test-dependencies
|
|
106
|
+
$ npm test
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
To remove the test dependencies and clean up the `package.json` and `package-lock.json`, execute this command
|
|
110
|
+
|
|
111
|
+
```
|
|
112
|
+
$ npm run install-build-dependencies
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Contributing
|
|
116
|
+
|
|
117
|
+
We welcome contributions from the community. Simple readme updates or bugfixes can be addressed with a PR directly.
|
|
118
|
+
|
|
119
|
+
For larger changes like new protocols, new features or larger refactorings, please contact us first by opening an issue. This project is under constant development and until version `1.x.x` has been reached, there will be frequent breaking changes. So make sure to take a look at the `develop` branch.
|
|
120
|
+
|
|
121
|
+
Regarding new protocols / currencies, we cannot guarantee that they will be merged, but we're more than happy to discuss the details of a specific integration in a github issue.
|
package/utils/address.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeAddress = void 0;
|
|
4
|
+
function normalizeAddress(address) {
|
|
5
|
+
return typeof address === 'string'
|
|
6
|
+
? {
|
|
7
|
+
address: address,
|
|
8
|
+
cursor: { hasNext: false }
|
|
9
|
+
}
|
|
10
|
+
: address;
|
|
11
|
+
}
|
|
12
|
+
exports.normalizeAddress = normalizeAddress;
|
|
13
|
+
//# sourceMappingURL=address.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"address.js","sourceRoot":"","sources":["../../src/utils/address.ts"],"names":[],"mappings":";;;AAEA,SAAgB,gBAAgB,CAAC,OAAmC;IAClE,OAAO,OAAO,OAAO,KAAK,QAAQ;QAChC,CAAC,CAAC;YACE,OAAO,SAAA;YACP,MAAM,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE;SAC3B;QACH,CAAC,CAAC,OAAO,CAAA;AACb,CAAC;AAPD,4CAOC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { AddressWithCursor, ExtendedPublicKey, OfflineBip32Protocol, OnlineBip32Protocol } from '@wallfree-dev/module-kit';
|
|
2
|
+
export declare function deriveAddresses(protocol: OfflineBip32Protocol | OnlineBip32Protocol, publicKey: ExtendedPublicKey, visibilityIndex: number, amount: number, offset: number): Promise<AddressWithCursor[]>;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
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;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.deriveAddresses = void 0;
|
|
40
|
+
var address_1 = require("./address");
|
|
41
|
+
function deriveAddresses(protocol, publicKey, visibilityIndex, amount, offset) {
|
|
42
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
43
|
+
var generatorArray;
|
|
44
|
+
var _this = this;
|
|
45
|
+
return __generator(this, function (_a) {
|
|
46
|
+
generatorArray = Array.from(new Array(amount), function (_, i) { return i + offset; });
|
|
47
|
+
return [2 /*return*/, Promise.all(generatorArray.map(function (x) { return __awaiter(_this, void 0, void 0, function () {
|
|
48
|
+
var derivedKey, _a;
|
|
49
|
+
return __generator(this, function (_b) {
|
|
50
|
+
switch (_b.label) {
|
|
51
|
+
case 0: return [4 /*yield*/, protocol.deriveFromExtendedPublicKey(publicKey, visibilityIndex, x)];
|
|
52
|
+
case 1:
|
|
53
|
+
derivedKey = _b.sent();
|
|
54
|
+
_a = address_1.normalizeAddress;
|
|
55
|
+
return [4 /*yield*/, protocol.getAddressFromPublicKey(derivedKey)];
|
|
56
|
+
case 2: return [2 /*return*/, _a.apply(void 0, [_b.sent()])];
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}); }))];
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
exports.deriveAddresses = deriveAddresses;
|
|
64
|
+
//# sourceMappingURL=protocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../src/utils/protocol.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,qCAA4C;AAE5C,SAAsB,eAAe,CACnC,QAAoD,EACpD,SAA4B,EAC5B,eAAuB,EACvB,MAAc,EACd,MAAc;;;;;YAER,cAAc,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,EAAE,UAAC,CAAC,EAAE,CAAC,IAAK,OAAA,CAAC,GAAG,MAAM,EAAV,CAAU,CAAC,CAAA;YAE1E,sBAAO,OAAO,CAAC,GAAG,CAChB,cAAc,CAAC,GAAG,CAAC,UAAO,CAAC;;;;oCACN,qBAAM,QAAQ,CAAC,2BAA2B,CAAC,SAAS,EAAE,eAAe,EAAE,CAAC,CAAC,EAAA;;gCAAtF,UAAU,GAAG,SAAyE;gCAErF,KAAA,0BAAgB,CAAA;gCAAC,qBAAM,QAAQ,CAAC,uBAAuB,CAAC,UAAU,CAAC,EAAA;oCAA1E,sBAAO,kBAAiB,SAAkD,EAAC,EAAA;;;qBAC5E,CAAC,CACH,EAAA;;;CACF;AAhBD,0CAgBC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ConditionViolationError } from '@wallfree-dev/coinlib-core/errors';
|
|
2
|
+
import { AirGapAnyProtocol, Bip32Extension, ExtendedPublicKey, PublicKey } from '@wallfree-dev/module-kit';
|
|
3
|
+
export declare enum AirGapWalletStatus {
|
|
4
|
+
ACTIVE = "active",
|
|
5
|
+
HIDDEN = "hidden",
|
|
6
|
+
DELETED = "deleted",
|
|
7
|
+
TRANSIENT = "transient"
|
|
8
|
+
}
|
|
9
|
+
export interface SerializedAirGapWallet {
|
|
10
|
+
protocolIdentifier: string;
|
|
11
|
+
publicKey: PublicKey | ExtendedPublicKey;
|
|
12
|
+
derivationPath: string;
|
|
13
|
+
addresses: string[];
|
|
14
|
+
masterFingerprint?: string;
|
|
15
|
+
status?: AirGapWalletStatus;
|
|
16
|
+
addressIndex?: number;
|
|
17
|
+
}
|
|
18
|
+
export declare abstract class AirGapWallet<Protocol extends AirGapAnyProtocol = AirGapAnyProtocol, T extends Protocol | Bip32Extension<Protocol> = Protocol | Bip32Extension<Protocol>> {
|
|
19
|
+
protocol: T;
|
|
20
|
+
readonly publicKey: T extends Bip32Extension<Protocol> ? PublicKey | ExtendedPublicKey : T extends Protocol ? PublicKey : never;
|
|
21
|
+
readonly derivationPath: string;
|
|
22
|
+
readonly masterFingerprint: string;
|
|
23
|
+
status: AirGapWalletStatus;
|
|
24
|
+
addressIndex?: number | undefined;
|
|
25
|
+
addresses: string[];
|
|
26
|
+
constructor(protocol: T, publicKey: T extends Bip32Extension<Protocol> ? PublicKey | ExtendedPublicKey : T extends Protocol ? PublicKey : never, derivationPath: string, masterFingerprint: string, status: AirGapWalletStatus, addressIndex?: number | undefined);
|
|
27
|
+
readonly receivingPublicAddress: string;
|
|
28
|
+
setProtocol(protocol: T): Promise<void>;
|
|
29
|
+
deriveAddresses(amount?: number): Promise<string[]>;
|
|
30
|
+
toJSON(): Promise<SerializedAirGapWallet>;
|
|
31
|
+
protected xpubRequiresExtendedProtocolError(): ConditionViolationError;
|
|
32
|
+
}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
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;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.AirGapWallet = exports.AirGapWalletStatus = void 0;
|
|
40
|
+
var errors_1 = require("@wallfree-dev/coinlib-core/errors");
|
|
41
|
+
var coinlib_error_1 = require("@wallfree-dev/coinlib-core/errors/coinlib-error");
|
|
42
|
+
var module_kit_1 = require("@wallfree-dev/module-kit");
|
|
43
|
+
var address_1 = require("../utils/address");
|
|
44
|
+
var protocol_1 = require("../utils/protocol");
|
|
45
|
+
var AirGapWalletStatus;
|
|
46
|
+
(function (AirGapWalletStatus) {
|
|
47
|
+
AirGapWalletStatus["ACTIVE"] = "active";
|
|
48
|
+
AirGapWalletStatus["HIDDEN"] = "hidden";
|
|
49
|
+
AirGapWalletStatus["DELETED"] = "deleted";
|
|
50
|
+
AirGapWalletStatus["TRANSIENT"] = "transient";
|
|
51
|
+
})(AirGapWalletStatus = exports.AirGapWalletStatus || (exports.AirGapWalletStatus = {}));
|
|
52
|
+
var AirGapWallet = /** @class */ (function () {
|
|
53
|
+
function AirGapWallet(protocol, publicKey, derivationPath, masterFingerprint, status, addressIndex) {
|
|
54
|
+
this.protocol = protocol;
|
|
55
|
+
this.publicKey = publicKey;
|
|
56
|
+
this.derivationPath = derivationPath;
|
|
57
|
+
this.masterFingerprint = masterFingerprint;
|
|
58
|
+
this.status = status;
|
|
59
|
+
this.addressIndex = addressIndex;
|
|
60
|
+
this.addresses = []; // used for cache
|
|
61
|
+
}
|
|
62
|
+
Object.defineProperty(AirGapWallet.prototype, "receivingPublicAddress", {
|
|
63
|
+
get: function () {
|
|
64
|
+
return this.addresses[this.addressIndex !== undefined ? this.addressIndex : 0];
|
|
65
|
+
},
|
|
66
|
+
enumerable: false,
|
|
67
|
+
configurable: true
|
|
68
|
+
});
|
|
69
|
+
AirGapWallet.prototype.setProtocol = function (protocol) {
|
|
70
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
71
|
+
var _a, currentProtocolIdentifier, nextProtocolIdentifier;
|
|
72
|
+
return __generator(this, function (_b) {
|
|
73
|
+
switch (_b.label) {
|
|
74
|
+
case 0: return [4 /*yield*/, Promise.all([
|
|
75
|
+
this.protocol.getMetadata().then(function (metadata) { return metadata.identifier; }),
|
|
76
|
+
protocol.getMetadata().then(function (metadata) { return metadata.identifier; })
|
|
77
|
+
])];
|
|
78
|
+
case 1:
|
|
79
|
+
_a = _b.sent(), currentProtocolIdentifier = _a[0], nextProtocolIdentifier = _a[1];
|
|
80
|
+
if (nextProtocolIdentifier !== currentProtocolIdentifier) {
|
|
81
|
+
throw new errors_1.ConditionViolationError(coinlib_error_1.Domain.WALLET, 'Can only set same protocol with a different network');
|
|
82
|
+
}
|
|
83
|
+
this.protocol = protocol;
|
|
84
|
+
return [2 /*return*/];
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
AirGapWallet.prototype.deriveAddresses = function (amount) {
|
|
90
|
+
if (amount === void 0) { amount = 50; }
|
|
91
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
92
|
+
var addresses, parts, offset, _a;
|
|
93
|
+
return __generator(this, function (_b) {
|
|
94
|
+
switch (_b.label) {
|
|
95
|
+
case 0:
|
|
96
|
+
if (!(this.publicKey.type === 'xpub')) return [3 /*break*/, 2];
|
|
97
|
+
if (!(0, module_kit_1.isBip32Protocol)(this.protocol)) {
|
|
98
|
+
// This *should* never happen because of how the constructor is typed, but the compiler doesn't know it.
|
|
99
|
+
// TODO: check if there's a way to tell the compiler here that `publicKey: ExtendedPublicKey => protocol: AirGapAnyExtendedProtocol`
|
|
100
|
+
throw this.xpubRequiresExtendedProtocolError();
|
|
101
|
+
}
|
|
102
|
+
parts = this.derivationPath.split('/');
|
|
103
|
+
offset = 0;
|
|
104
|
+
if (!parts[parts.length - 1].endsWith("'")) {
|
|
105
|
+
offset = Number.parseInt(parts[parts.length - 1], 10);
|
|
106
|
+
}
|
|
107
|
+
return [4 /*yield*/, Promise.all([
|
|
108
|
+
// TODO: this is not a desired behavior for ETH, maybe add UTXO protocol extension that BTC can implement and use it here?
|
|
109
|
+
(0, protocol_1.deriveAddresses)(this.protocol, this.publicKey, 0, amount, offset),
|
|
110
|
+
(0, protocol_1.deriveAddresses)(this.protocol, this.publicKey, 1, amount, offset)
|
|
111
|
+
])];
|
|
112
|
+
case 1:
|
|
113
|
+
addresses = (_b.sent()).reduce(function (flatten, next) { return flatten.concat(next); }, []);
|
|
114
|
+
return [3 /*break*/, 4];
|
|
115
|
+
case 2:
|
|
116
|
+
_a = address_1.normalizeAddress;
|
|
117
|
+
return [4 /*yield*/, this.protocol.getAddressFromPublicKey(this.publicKey)];
|
|
118
|
+
case 3:
|
|
119
|
+
addresses = [_a.apply(void 0, [_b.sent()])];
|
|
120
|
+
_b.label = 4;
|
|
121
|
+
case 4: return [2 /*return*/, addresses.map(function (address) { return address.address; })];
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
};
|
|
126
|
+
AirGapWallet.prototype.toJSON = function () {
|
|
127
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
128
|
+
var protocolIdentifier;
|
|
129
|
+
return __generator(this, function (_a) {
|
|
130
|
+
switch (_a.label) {
|
|
131
|
+
case 0: return [4 /*yield*/, this.protocol.getMetadata()];
|
|
132
|
+
case 1:
|
|
133
|
+
protocolIdentifier = (_a.sent()).identifier;
|
|
134
|
+
return [2 /*return*/, {
|
|
135
|
+
protocolIdentifier: protocolIdentifier,
|
|
136
|
+
publicKey: this.publicKey,
|
|
137
|
+
derivationPath: this.derivationPath,
|
|
138
|
+
addresses: this.addresses,
|
|
139
|
+
masterFingerprint: this.masterFingerprint,
|
|
140
|
+
status: this.status,
|
|
141
|
+
addressIndex: this.addressIndex
|
|
142
|
+
}];
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
};
|
|
147
|
+
AirGapWallet.prototype.xpubRequiresExtendedProtocolError = function () {
|
|
148
|
+
return new errors_1.ConditionViolationError(coinlib_error_1.Domain.WALLET, 'Extended public keys are supported only when paired with an extended protocol');
|
|
149
|
+
};
|
|
150
|
+
return AirGapWallet;
|
|
151
|
+
}());
|
|
152
|
+
exports.AirGapWallet = AirGapWallet;
|
|
153
|
+
//# sourceMappingURL=AirGapWallet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AirGapWallet.js","sourceRoot":"","sources":["../../src/wallet/AirGapWallet.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AirGapOfflineProtocol, Bip32Extension } from '@wallfree-dev/module-kit';
|
|
2
|
+
import { AirGapWallet, SerializedAirGapWallet } from '../AirGapWallet';
|
|
3
|
+
export interface SerializedAirGapOfflineWallet extends SerializedAirGapWallet {
|
|
4
|
+
}
|
|
5
|
+
export declare class AirGapOfflineWallet<T extends AirGapOfflineProtocol | Bip32Extension<AirGapOfflineProtocol> = AirGapOfflineProtocol | Bip32Extension<AirGapOfflineProtocol>> extends AirGapWallet<AirGapOfflineProtocol, T> {
|
|
6
|
+
toJSON(): Promise<SerializedAirGapOfflineWallet>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.AirGapOfflineWallet = void 0;
|
|
19
|
+
var AirGapWallet_1 = require("../AirGapWallet");
|
|
20
|
+
var AirGapOfflineWallet = /** @class */ (function (_super) {
|
|
21
|
+
__extends(AirGapOfflineWallet, _super);
|
|
22
|
+
function AirGapOfflineWallet() {
|
|
23
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
24
|
+
}
|
|
25
|
+
AirGapOfflineWallet.prototype.toJSON = function () {
|
|
26
|
+
return _super.prototype.toJSON.call(this);
|
|
27
|
+
};
|
|
28
|
+
return AirGapOfflineWallet;
|
|
29
|
+
}(AirGapWallet_1.AirGapWallet));
|
|
30
|
+
exports.AirGapOfflineWallet = AirGapOfflineWallet;
|
|
31
|
+
//# sourceMappingURL=AirGapOfflineWallet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AirGapOfflineWallet.js","sourceRoot":"","sources":["../../../src/wallet/offline/AirGapOfflineWallet.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAEA,gDAAsE;AAItE;IAEU,uCAAsC;IAFhD;;IAMA,CAAC;IAHQ,oCAAM,GAAb;QACE,OAAO,iBAAM,MAAM,WAAE,CAAA;IACvB,CAAC;IACH,0BAAC;AAAD,CAAC,AAND,CAEU,2BAAY,GAIrB;AANY,kDAAmB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import BigNumber from '@wallfree-dev/coinlib-core/dependencies/src/bignumber.js-9.0.0/bignumber';
|
|
2
|
+
import { AirGapOnlineProtocol, Bip32Extension } from '@wallfree-dev/module-kit';
|
|
3
|
+
import { AirGapOnlineWallet } from './AirGapOnlineWallet';
|
|
4
|
+
export declare enum TimeInterval {
|
|
5
|
+
HOURS = "24h",
|
|
6
|
+
DAYS = "7d",
|
|
7
|
+
MONTH = "30d"
|
|
8
|
+
}
|
|
9
|
+
export declare class AirGapCoinWallet<T extends AirGapOnlineProtocol | Bip32Extension<AirGapOnlineProtocol> = AirGapOnlineProtocol | Bip32Extension<AirGapOnlineProtocol>> extends AirGapOnlineWallet<T> {
|
|
10
|
+
private currentBalance;
|
|
11
|
+
getCurrentBalance(): BigNumber | undefined;
|
|
12
|
+
setCurrentBalance(balance: BigNumber | undefined): void;
|
|
13
|
+
currentMarketPrice: BigNumber | undefined;
|
|
14
|
+
getCurrentMarketPrice(): BigNumber | undefined;
|
|
15
|
+
setCurrentMarketPrice(marketPrice: BigNumber | undefined): Promise<void>;
|
|
16
|
+
protected _synchronize(): Promise<void>;
|
|
17
|
+
protected reset(): void;
|
|
18
|
+
fetchCurrentMarketPrice(baseSymbol?: string): Promise<BigNumber>;
|
|
19
|
+
balanceOf(): Promise<BigNumber>;
|
|
20
|
+
}
|