@ledgerhq/hw-app-exchange 0.1.0 → 0.1.1-next.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/CHANGELOG.md ADDED
@@ -0,0 +1,9 @@
1
+ # @ledgerhq/hw-app-exchange
2
+
3
+ ## 0.1.1-next.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`87d2349fd8`](https://github.com/LedgerHQ/ledger-live/commit/87d2349fd835e5deb39d1ee8dfcf3539f4195472)]:
8
+ - @ledgerhq/errors@6.12.5-next.0
9
+ - @ledgerhq/hw-transport@6.28.3-next.0
package/lib/Exchange.js CHANGED
@@ -8,57 +8,30 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
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 (g && (g = 0, op[0] && (_ = 0)), _) 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
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
39
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
40
13
  };
41
- exports.__esModule = true;
42
- var errors_1 = require("@ledgerhq/errors");
43
- var invariant_1 = __importDefault(require("invariant"));
44
- var START_NEW_TRANSACTION_COMMAND = 0x03;
45
- var SET_PARTNER_KEY_COMMAND = 0x04;
46
- var CHECK_PARTNER_COMMAND = 0x05;
47
- var PROCESS_TRANSACTION_RESPONSE = 0x06;
48
- var CHECK_TRANSACTION_SIGNATURE = 0x07;
49
- var CHECK_PAYOUT_ADDRESS = 0x08;
50
- var CHECK_ASSET_IN = 0x08;
51
- var CHECK_REFUND_ADDRESS = 0x09;
52
- var SIGN_COIN_TRANSACTION = 0x0a;
53
- var maybeThrowProtocolError = function (result) {
54
- (0, invariant_1["default"])(result.length >= 2, "ExchangeTransport: Unexpected result length");
55
- var resultCode = result.readUInt16BE(result.length - 2);
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const errors_1 = require("@ledgerhq/errors");
16
+ const invariant_1 = __importDefault(require("invariant"));
17
+ const START_NEW_TRANSACTION_COMMAND = 0x03;
18
+ const SET_PARTNER_KEY_COMMAND = 0x04;
19
+ const CHECK_PARTNER_COMMAND = 0x05;
20
+ const PROCESS_TRANSACTION_RESPONSE = 0x06;
21
+ const CHECK_TRANSACTION_SIGNATURE = 0x07;
22
+ const CHECK_PAYOUT_ADDRESS = 0x08;
23
+ const CHECK_ASSET_IN = 0x08;
24
+ const CHECK_REFUND_ADDRESS = 0x09;
25
+ const SIGN_COIN_TRANSACTION = 0x0a;
26
+ const maybeThrowProtocolError = (result) => {
27
+ (0, invariant_1.default)(result.length >= 2, "ExchangeTransport: Unexpected result length");
28
+ const resultCode = result.readUInt16BE(result.length - 2);
56
29
  if (resultCode !== 0x9000) {
57
30
  throw new errors_1.TransportStatusError(resultCode);
58
31
  }
59
32
  };
60
- var Exchange = /** @class */ (function () {
61
- function Exchange(transport, transactionType, transactionRate) {
33
+ class Exchange {
34
+ constructor(transport, transactionType, transactionRate) {
62
35
  this.allowedStatuses = [
63
36
  0x9000, 0x6a80, 0x6a81, 0x6a82, 0x6a83, 0x6a84, 0x6a85, 0x6e00, 0x6d00,
64
37
  0x9d1a,
@@ -67,159 +40,92 @@ var Exchange = /** @class */ (function () {
67
40
  this.transactionRate = transactionRate || 0 /* RateTypes.Fixed */;
68
41
  this.transport = transport;
69
42
  }
70
- Exchange.prototype.startNewTransaction = function () {
71
- return __awaiter(this, void 0, void 0, function () {
72
- var result;
73
- return __generator(this, function (_a) {
74
- switch (_a.label) {
75
- case 0: return [4 /*yield*/, this.transport.send(0xe0, START_NEW_TRANSACTION_COMMAND, this.transactionRate, this.transactionType, Buffer.alloc(0), this.allowedStatuses)];
76
- case 1:
77
- result = _a.sent();
78
- maybeThrowProtocolError(result);
79
- if (this.transactionType === 1 /* ExchangeTypes.Sell */ ||
80
- this.transactionType === 2 /* ExchangeTypes.Fund */) {
81
- return [2 /*return*/, result.slice(0, 32).toString("base64")];
82
- }
83
- return [2 /*return*/, result.toString("ascii", 0, 10)];
84
- }
85
- });
43
+ startNewTransaction() {
44
+ return __awaiter(this, void 0, void 0, function* () {
45
+ const result = yield this.transport.send(0xe0, START_NEW_TRANSACTION_COMMAND, this.transactionRate, this.transactionType, Buffer.alloc(0), this.allowedStatuses);
46
+ maybeThrowProtocolError(result);
47
+ if (this.transactionType === 1 /* ExchangeTypes.Sell */ ||
48
+ this.transactionType === 2 /* ExchangeTypes.Fund */) {
49
+ return result.slice(0, 32).toString("base64");
50
+ }
51
+ return result.toString("ascii", 0, 10);
86
52
  });
87
- };
88
- Exchange.prototype.setPartnerKey = function (partnerNameAndPublicKey) {
89
- return __awaiter(this, void 0, void 0, function () {
90
- var result;
91
- return __generator(this, function (_a) {
92
- switch (_a.label) {
93
- case 0: return [4 /*yield*/, this.transport.send(0xe0, SET_PARTNER_KEY_COMMAND, this.transactionRate, this.transactionType, partnerNameAndPublicKey, this.allowedStatuses)];
94
- case 1:
95
- result = _a.sent();
96
- maybeThrowProtocolError(result);
97
- return [2 /*return*/];
98
- }
99
- });
53
+ }
54
+ setPartnerKey(partnerNameAndPublicKey) {
55
+ return __awaiter(this, void 0, void 0, function* () {
56
+ const result = yield this.transport.send(0xe0, SET_PARTNER_KEY_COMMAND, this.transactionRate, this.transactionType, partnerNameAndPublicKey, this.allowedStatuses);
57
+ maybeThrowProtocolError(result);
100
58
  });
101
- };
102
- Exchange.prototype.checkPartner = function (signatureOfPartnerData) {
103
- return __awaiter(this, void 0, void 0, function () {
104
- var result;
105
- return __generator(this, function (_a) {
106
- switch (_a.label) {
107
- case 0: return [4 /*yield*/, this.transport.send(0xe0, CHECK_PARTNER_COMMAND, this.transactionRate, this.transactionType, signatureOfPartnerData, this.allowedStatuses)];
108
- case 1:
109
- result = _a.sent();
110
- maybeThrowProtocolError(result);
111
- return [2 /*return*/];
112
- }
113
- });
59
+ }
60
+ checkPartner(signatureOfPartnerData) {
61
+ return __awaiter(this, void 0, void 0, function* () {
62
+ const result = yield this.transport.send(0xe0, CHECK_PARTNER_COMMAND, this.transactionRate, this.transactionType, signatureOfPartnerData, this.allowedStatuses);
63
+ maybeThrowProtocolError(result);
114
64
  });
115
- };
116
- Exchange.prototype.processTransaction = function (transaction, fee) {
117
- return __awaiter(this, void 0, void 0, function () {
118
- var hex, feeHex, bufferToSend, result;
119
- return __generator(this, function (_a) {
120
- switch (_a.label) {
121
- case 0:
122
- hex = fee.toString(16);
123
- hex = hex.padStart(hex.length + (hex.length % 2), "0");
124
- feeHex = Buffer.from(hex, "hex");
125
- bufferToSend = Buffer.concat([
126
- Buffer.from([transaction.length]),
127
- transaction,
128
- Buffer.from([feeHex.length]),
129
- feeHex,
130
- ]);
131
- return [4 /*yield*/, this.transport.send(0xe0, PROCESS_TRANSACTION_RESPONSE, this.transactionRate, this.transactionType, bufferToSend, this.allowedStatuses)];
132
- case 1:
133
- result = _a.sent();
134
- maybeThrowProtocolError(result);
135
- return [2 /*return*/];
136
- }
137
- });
65
+ }
66
+ processTransaction(transaction, fee) {
67
+ return __awaiter(this, void 0, void 0, function* () {
68
+ let hex = fee.toString(16);
69
+ hex = hex.padStart(hex.length + (hex.length % 2), "0");
70
+ const feeHex = Buffer.from(hex, "hex");
71
+ const bufferToSend = Buffer.concat([
72
+ Buffer.from([transaction.length]),
73
+ transaction,
74
+ Buffer.from([feeHex.length]),
75
+ feeHex,
76
+ ]);
77
+ const result = yield this.transport.send(0xe0, PROCESS_TRANSACTION_RESPONSE, this.transactionRate, this.transactionType, bufferToSend, this.allowedStatuses);
78
+ maybeThrowProtocolError(result);
138
79
  });
139
- };
140
- Exchange.prototype.checkTransactionSignature = function (transactionSignature) {
141
- return __awaiter(this, void 0, void 0, function () {
142
- var result;
143
- return __generator(this, function (_a) {
144
- switch (_a.label) {
145
- case 0: return [4 /*yield*/, this.transport.send(0xe0, CHECK_TRANSACTION_SIGNATURE, this.transactionRate, this.transactionType, transactionSignature, this.allowedStatuses)];
146
- case 1:
147
- result = _a.sent();
148
- maybeThrowProtocolError(result);
149
- return [2 /*return*/];
150
- }
151
- });
80
+ }
81
+ checkTransactionSignature(transactionSignature) {
82
+ return __awaiter(this, void 0, void 0, function* () {
83
+ const result = yield this.transport.send(0xe0, CHECK_TRANSACTION_SIGNATURE, this.transactionRate, this.transactionType, transactionSignature, this.allowedStatuses);
84
+ maybeThrowProtocolError(result);
152
85
  });
153
- };
154
- Exchange.prototype.checkPayoutAddress = function (payoutCurrencyConfig, currencyConfigSignature, addressParameters) {
155
- return __awaiter(this, void 0, void 0, function () {
156
- var bufferToSend, result;
157
- return __generator(this, function (_a) {
158
- switch (_a.label) {
159
- case 0:
160
- (0, invariant_1["default"])(payoutCurrencyConfig.length <= 255, "Currency config is too big");
161
- (0, invariant_1["default"])(addressParameters.length <= 255, "Address parameter is too big.");
162
- (0, invariant_1["default"])(currencyConfigSignature.length >= 67 &&
163
- currencyConfigSignature.length <= 73, "Signature should be DER serialized and have length in [67, 73] bytes.");
164
- bufferToSend = Buffer.concat([
165
- Buffer.from([payoutCurrencyConfig.length]),
166
- payoutCurrencyConfig,
167
- currencyConfigSignature,
168
- Buffer.from([addressParameters.length]),
169
- addressParameters,
170
- ]);
171
- return [4 /*yield*/, this.transport.send(0xe0, this.transactionType === 0 /* ExchangeTypes.Swap */
172
- ? CHECK_PAYOUT_ADDRESS
173
- : CHECK_ASSET_IN, this.transactionRate, this.transactionType, bufferToSend, this.allowedStatuses)];
174
- case 1:
175
- result = _a.sent();
176
- maybeThrowProtocolError(result);
177
- return [2 /*return*/];
178
- }
179
- });
86
+ }
87
+ checkPayoutAddress(payoutCurrencyConfig, currencyConfigSignature, addressParameters) {
88
+ return __awaiter(this, void 0, void 0, function* () {
89
+ (0, invariant_1.default)(payoutCurrencyConfig.length <= 255, "Currency config is too big");
90
+ (0, invariant_1.default)(addressParameters.length <= 255, "Address parameter is too big.");
91
+ (0, invariant_1.default)(currencyConfigSignature.length >= 67 &&
92
+ currencyConfigSignature.length <= 73, "Signature should be DER serialized and have length in [67, 73] bytes.");
93
+ const bufferToSend = Buffer.concat([
94
+ Buffer.from([payoutCurrencyConfig.length]),
95
+ payoutCurrencyConfig,
96
+ currencyConfigSignature,
97
+ Buffer.from([addressParameters.length]),
98
+ addressParameters,
99
+ ]);
100
+ const result = yield this.transport.send(0xe0, this.transactionType === 0 /* ExchangeTypes.Swap */
101
+ ? CHECK_PAYOUT_ADDRESS
102
+ : CHECK_ASSET_IN, this.transactionRate, this.transactionType, bufferToSend, this.allowedStatuses);
103
+ maybeThrowProtocolError(result);
180
104
  });
181
- };
182
- Exchange.prototype.checkRefundAddress = function (refundCurrencyConfig, currencyConfigSignature, addressParameters) {
183
- return __awaiter(this, void 0, void 0, function () {
184
- var bufferToSend, result;
185
- return __generator(this, function (_a) {
186
- switch (_a.label) {
187
- case 0:
188
- (0, invariant_1["default"])(refundCurrencyConfig.length <= 255, "Currency config is too big");
189
- (0, invariant_1["default"])(addressParameters.length <= 255, "Address parameter is too big.");
190
- (0, invariant_1["default"])(currencyConfigSignature.length >= 67 &&
191
- currencyConfigSignature.length <= 73, "Signature should be DER serialized and have length in [67, 73] bytes.");
192
- bufferToSend = Buffer.concat([
193
- Buffer.from([refundCurrencyConfig.length]),
194
- refundCurrencyConfig,
195
- currencyConfigSignature,
196
- Buffer.from([addressParameters.length]),
197
- addressParameters,
198
- ]);
199
- return [4 /*yield*/, this.transport.send(0xe0, CHECK_REFUND_ADDRESS, this.transactionRate, this.transactionType, bufferToSend, this.allowedStatuses)];
200
- case 1:
201
- result = _a.sent();
202
- maybeThrowProtocolError(result);
203
- return [2 /*return*/];
204
- }
205
- });
105
+ }
106
+ checkRefundAddress(refundCurrencyConfig, currencyConfigSignature, addressParameters) {
107
+ return __awaiter(this, void 0, void 0, function* () {
108
+ (0, invariant_1.default)(refundCurrencyConfig.length <= 255, "Currency config is too big");
109
+ (0, invariant_1.default)(addressParameters.length <= 255, "Address parameter is too big.");
110
+ (0, invariant_1.default)(currencyConfigSignature.length >= 67 &&
111
+ currencyConfigSignature.length <= 73, "Signature should be DER serialized and have length in [67, 73] bytes.");
112
+ const bufferToSend = Buffer.concat([
113
+ Buffer.from([refundCurrencyConfig.length]),
114
+ refundCurrencyConfig,
115
+ currencyConfigSignature,
116
+ Buffer.from([addressParameters.length]),
117
+ addressParameters,
118
+ ]);
119
+ const result = yield this.transport.send(0xe0, CHECK_REFUND_ADDRESS, this.transactionRate, this.transactionType, bufferToSend, this.allowedStatuses);
120
+ maybeThrowProtocolError(result);
206
121
  });
207
- };
208
- Exchange.prototype.signCoinTransaction = function () {
209
- return __awaiter(this, void 0, void 0, function () {
210
- var result;
211
- return __generator(this, function (_a) {
212
- switch (_a.label) {
213
- case 0: return [4 /*yield*/, this.transport.send(0xe0, SIGN_COIN_TRANSACTION, this.transactionRate, this.transactionType, Buffer.alloc(0), this.allowedStatuses)];
214
- case 1:
215
- result = _a.sent();
216
- maybeThrowProtocolError(result);
217
- return [2 /*return*/];
218
- }
219
- });
122
+ }
123
+ signCoinTransaction() {
124
+ return __awaiter(this, void 0, void 0, function* () {
125
+ const result = yield this.transport.send(0xe0, SIGN_COIN_TRANSACTION, this.transactionRate, this.transactionType, Buffer.alloc(0), this.allowedStatuses);
126
+ maybeThrowProtocolError(result);
220
127
  });
221
- };
222
- return Exchange;
223
- }());
224
- exports["default"] = Exchange;
128
+ }
129
+ }
130
+ exports.default = Exchange;
225
131
  //# sourceMappingURL=Exchange.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Exchange.js","sourceRoot":"","sources":["../src/Exchange.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,2CAAwD;AACxD,wDAAkC;AAalC,IAAM,6BAA6B,GAAG,IAAI,CAAC;AAC3C,IAAM,uBAAuB,GAAG,IAAI,CAAC;AACrC,IAAM,qBAAqB,GAAG,IAAI,CAAC;AACnC,IAAM,4BAA4B,GAAG,IAAI,CAAC;AAC1C,IAAM,2BAA2B,GAAG,IAAI,CAAC;AACzC,IAAM,oBAAoB,GAAG,IAAI,CAAC;AAClC,IAAM,cAAc,GAAG,IAAI,CAAC;AAC5B,IAAM,oBAAoB,GAAG,IAAI,CAAC;AAClC,IAAM,qBAAqB,GAAG,IAAI,CAAC;AAEnC,IAAM,uBAAuB,GAAG,UAAC,MAAc;IAC7C,IAAA,sBAAS,EAAC,MAAM,CAAC,MAAM,IAAI,CAAC,EAAE,6CA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,CAC9C,IAAI,EACJ,oBAAoB,EACpB,IAAI,CAAC,eAAe,EACpB,IAAI,CAAC,eAAe,EACpB,YAAY,EACZ,IAAI,CAAC,eAAe,CACrB,CAAC;YACF,uBAAuB,CAAC,MAAM,CAAC,CAAC;QAClC,CAAC;KAAA;IAEK,mBAAmB;;YACvB,MAAM,MAAM,GAAW,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAC9C,IAAI,EACJ,qBAAqB,EACrB,IAAI,CAAC,eAAe,EACpB,IAAI,CAAC,eAAe,EACpB,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EACf,IAAI,CAAC,eAAe,CACrB,CAAC;YACF,uBAAuB,CAAC,MAAM,CAAC,CAAC;QAClC,CAAC;KAAA;CACF;AA1KD,2BA0KC"}
@@ -8,123 +8,66 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
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 (g && (g = 0, op[0] && (_ = 0)), _) 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
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
39
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
40
13
  };
41
- exports.__esModule = true;
42
- var hw_transport_mocker_1 = require("@ledgerhq/hw-transport-mocker");
43
- var Exchange_1 = __importDefault(require("./Exchange"));
44
- var util_1 = require("util");
45
- describe("Contrustructor", function () {
46
- [2 /* ExchangeTypes.Fund */, 1 /* ExchangeTypes.Sell */, 0 /* ExchangeTypes.Swap */].forEach(function (exchangeType) {
47
- it("Exchange (value of ".concat(exchangeType, ") init with default rate types of fixed"), function () { return __awaiter(void 0, void 0, void 0, function () {
48
- var transport, exchange;
49
- return __generator(this, function (_a) {
50
- switch (_a.label) {
51
- case 0: return [4 /*yield*/, (0, hw_transport_mocker_1.openTransportReplayer)(hw_transport_mocker_1.RecordStore.fromString(""))];
52
- case 1:
53
- transport = _a.sent();
54
- exchange = new Exchange_1["default"](transport, exchangeType);
55
- expect(exchange.transactionRate).toBe(0 /* RateTypes.Fixed */);
56
- return [2 /*return*/];
57
- }
58
- });
59
- }); });
60
- [0 /* RateTypes.Fixed */, 1 /* RateTypes.Floating */].forEach(function (rateType) {
61
- it("Exchange (value of ".concat(exchangeType, ") init with rate types of value ").concat(rateType), function () { return __awaiter(void 0, void 0, void 0, function () {
62
- var transport, exchange;
63
- return __generator(this, function (_a) {
64
- switch (_a.label) {
65
- case 0: return [4 /*yield*/, (0, hw_transport_mocker_1.openTransportReplayer)(hw_transport_mocker_1.RecordStore.fromString(""))];
66
- case 1:
67
- transport = _a.sent();
68
- exchange = new Exchange_1["default"](transport, exchangeType, rateType);
69
- expect(exchange.transactionRate).toBe(rateType);
70
- return [2 /*return*/];
71
- }
72
- });
73
- }); });
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const hw_transport_mocker_1 = require("@ledgerhq/hw-transport-mocker");
16
+ const Exchange_1 = __importDefault(require("./Exchange"));
17
+ const util_1 = require("util");
18
+ describe("Contrustructor", () => {
19
+ [2 /* ExchangeTypes.Fund */, 1 /* ExchangeTypes.Sell */, 0 /* ExchangeTypes.Swap */].forEach((exchangeType) => {
20
+ it(`Exchange (value of ${exchangeType}) init with default rate types of fixed`, () => __awaiter(void 0, void 0, void 0, function* () {
21
+ const transport = yield (0, hw_transport_mocker_1.openTransportReplayer)(hw_transport_mocker_1.RecordStore.fromString(""));
22
+ const exchange = new Exchange_1.default(transport, exchangeType);
23
+ expect(exchange.transactionRate).toBe(0 /* RateTypes.Fixed */);
24
+ }));
25
+ [0 /* RateTypes.Fixed */, 1 /* RateTypes.Floating */].forEach((rateType) => {
26
+ it(`Exchange (value of ${exchangeType}) init with rate types of value ${rateType}`, () => __awaiter(void 0, void 0, void 0, function* () {
27
+ const transport = yield (0, hw_transport_mocker_1.openTransportReplayer)(hw_transport_mocker_1.RecordStore.fromString(""));
28
+ const exchange = new Exchange_1.default(transport, exchangeType, rateType);
29
+ expect(exchange.transactionRate).toBe(rateType);
30
+ }));
74
31
  });
75
32
  });
76
33
  });
77
- describe("startNewTransaction", function () {
78
- var textEncoder = new util_1.TextEncoder();
79
- var mockResponse = "2ac38f187c"; // Response of length 10
80
- it("sends a correct sequence of APDU", function () { return __awaiter(void 0, void 0, void 0, function () {
81
- var recordStore, mockTransport, transport, exchange, result, expectCommand;
82
- return __generator(this, function (_a) {
83
- switch (_a.label) {
84
- case 0:
85
- recordStore = new hw_transport_mocker_1.RecordStore();
86
- mockTransport = new hw_transport_mocker_1.MockTransport(Buffer.concat([
87
- textEncoder.encode(mockResponse),
88
- Buffer.from([0x90, 0x00]), // StatusCodes.OK
89
- ]));
90
- transport = (0, hw_transport_mocker_1.createTransportRecorder)(mockTransport, recordStore);
91
- exchange = new Exchange_1["default"](new transport(mockTransport), 0 /* ExchangeTypes.Swap */);
92
- return [4 /*yield*/, exchange.startNewTransaction()];
93
- case 1:
94
- result = _a.sent();
95
- expectCommand = Buffer.from([
96
- 0xe0,
97
- 0x03,
98
- 0 /* ExchangeTypes.Swap */,
99
- 0 /* RateTypes.Fixed */,
100
- 0x00, // Data
101
- ]).toString("hex");
102
- expect(recordStore.queue[0][0]).toBe(expectCommand);
103
- expect(result).toEqual(mockResponse);
104
- return [2 /*return*/];
105
- }
106
- });
107
- }); });
34
+ describe("startNewTransaction", () => {
35
+ const textEncoder = new util_1.TextEncoder();
36
+ const mockResponse = "2ac38f187c"; // Response of length 10
37
+ it("sends a correct sequence of APDU", () => __awaiter(void 0, void 0, void 0, function* () {
38
+ // Given
39
+ const recordStore = new hw_transport_mocker_1.RecordStore();
40
+ const mockTransport = new hw_transport_mocker_1.MockTransport(Buffer.concat([
41
+ textEncoder.encode(mockResponse),
42
+ Buffer.from([0x90, 0x00]), // StatusCodes.OK
43
+ ]));
44
+ const transport = (0, hw_transport_mocker_1.createTransportRecorder)(mockTransport, recordStore);
45
+ const exchange = new Exchange_1.default(new transport(mockTransport), 0 /* ExchangeTypes.Swap */);
46
+ // When
47
+ const result = yield exchange.startNewTransaction();
48
+ // Then
49
+ const expectCommand = Buffer.from([
50
+ 0xe0,
51
+ 0x03,
52
+ 0 /* ExchangeTypes.Swap */,
53
+ 0 /* RateTypes.Fixed */,
54
+ 0x00, // Data
55
+ ]).toString("hex");
56
+ expect(recordStore.queue[0][0]).toBe(expectCommand);
57
+ expect(result).toEqual(mockResponse);
58
+ }));
108
59
  // TOFIX: TransportError is not recognize as an Error type
109
- xit("throws an error if status is not ok", function () { return __awaiter(void 0, void 0, void 0, function () {
110
- var recordStore, mockTransport, transport, exchange;
111
- return __generator(this, function (_a) {
112
- recordStore = new hw_transport_mocker_1.RecordStore();
113
- mockTransport = new hw_transport_mocker_1.MockTransport(Buffer.concat([
114
- textEncoder.encode(mockResponse),
115
- Buffer.from([0x6a, 0x80]),
116
- ]));
117
- transport = (0, hw_transport_mocker_1.createTransportRecorder)(mockTransport, recordStore);
118
- exchange = new Exchange_1["default"](new transport(mockTransport), 0 /* ExchangeTypes.Swap */);
119
- // When & Then
120
- expect(function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
121
- switch (_a.label) {
122
- case 0: return [4 /*yield*/, exchange.startNewTransaction()];
123
- case 1: return [2 /*return*/, _a.sent()];
124
- }
125
- }); }); }).toThrowError();
126
- return [2 /*return*/];
127
- });
128
- }); });
60
+ xit("throws an error if status is not ok", () => __awaiter(void 0, void 0, void 0, function* () {
61
+ // Given
62
+ const recordStore = new hw_transport_mocker_1.RecordStore();
63
+ const mockTransport = new hw_transport_mocker_1.MockTransport(Buffer.concat([
64
+ textEncoder.encode(mockResponse),
65
+ Buffer.from([0x6a, 0x80]),
66
+ ]));
67
+ const transport = (0, hw_transport_mocker_1.createTransportRecorder)(mockTransport, recordStore);
68
+ const exchange = new Exchange_1.default(new transport(mockTransport), 0 /* ExchangeTypes.Swap */);
69
+ // When & Then
70
+ expect(() => __awaiter(void 0, void 0, void 0, function* () { return yield exchange.startNewTransaction(); })).toThrowError();
71
+ }));
129
72
  });
130
73
  //# sourceMappingURL=Exchange.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Exchange.test.js","sourceRoot":"","sources":["../src/Exchange.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qEAKuC;AACvC,wDAAgE;AAChE,6BAAmC;AAEnC,QAAQ,CAAC,gBAAgB,EAAE;IACzB,oFAA4D,CAAC,O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AC;SAC1B,CAAC,CACH,CAAC;QACF,MAAM,SAAS,GAAG,IAAA,6CAAuB,EAAC,aAAa,EAAE,WAAW,CAAC,CAAC;QACtE,MAAM,QAAQ,GAAG,IAAI,kBAAQ,CAC3B,IAAI,SAAS,CAAC,aAAa,CAAC,6BAE7B,CAAC;QAEF,cAAc;QACd,MAAM,CAAC,GAAS,EAAE,kDAAC,OAAA,MAAM,QAAQ,CAAC,mBAAmB,EAAE,CAAA,GAAA,CAAC,CAAC,YAAY,EAAE,CAAC;IAC1E,CAAC,CAAA,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -7,53 +7,26 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- var __generator = (this && this.__generator) || function (thisArg, body) {
11
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
- function verb(n) { return function (v) { return step([n, v]); }; }
14
- function step(op) {
15
- if (f) throw new TypeError("Generator is already executing.");
16
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
- 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;
18
- if (y = 0, t) op = [op[0] & 2, t.value];
19
- switch (op[0]) {
20
- case 0: case 1: t = op; break;
21
- case 4: _.label++; return { value: op[1], done: false };
22
- case 5: _.label++; y = op[1]; op = [0]; continue;
23
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
- default:
25
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
- if (t[2]) _.ops.pop();
30
- _.trys.pop(); continue;
31
- }
32
- op = body.call(thisArg, _);
33
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
- }
36
- };
37
10
  import { TransportStatusError } from "@ledgerhq/errors";
38
11
  import invariant from "invariant";
39
- var START_NEW_TRANSACTION_COMMAND = 0x03;
40
- var SET_PARTNER_KEY_COMMAND = 0x04;
41
- var CHECK_PARTNER_COMMAND = 0x05;
42
- var PROCESS_TRANSACTION_RESPONSE = 0x06;
43
- var CHECK_TRANSACTION_SIGNATURE = 0x07;
44
- var CHECK_PAYOUT_ADDRESS = 0x08;
45
- var CHECK_ASSET_IN = 0x08;
46
- var CHECK_REFUND_ADDRESS = 0x09;
47
- var SIGN_COIN_TRANSACTION = 0x0a;
48
- var maybeThrowProtocolError = function (result) {
12
+ const START_NEW_TRANSACTION_COMMAND = 0x03;
13
+ const SET_PARTNER_KEY_COMMAND = 0x04;
14
+ const CHECK_PARTNER_COMMAND = 0x05;
15
+ const PROCESS_TRANSACTION_RESPONSE = 0x06;
16
+ const CHECK_TRANSACTION_SIGNATURE = 0x07;
17
+ const CHECK_PAYOUT_ADDRESS = 0x08;
18
+ const CHECK_ASSET_IN = 0x08;
19
+ const CHECK_REFUND_ADDRESS = 0x09;
20
+ const SIGN_COIN_TRANSACTION = 0x0a;
21
+ const maybeThrowProtocolError = (result) => {
49
22
  invariant(result.length >= 2, "ExchangeTransport: Unexpected result length");
50
- var resultCode = result.readUInt16BE(result.length - 2);
23
+ const resultCode = result.readUInt16BE(result.length - 2);
51
24
  if (resultCode !== 0x9000) {
52
25
  throw new TransportStatusError(resultCode);
53
26
  }
54
27
  };
55
- var Exchange = /** @class */ (function () {
56
- function Exchange(transport, transactionType, transactionRate) {
28
+ export default class Exchange {
29
+ constructor(transport, transactionType, transactionRate) {
57
30
  this.allowedStatuses = [
58
31
  0x9000, 0x6a80, 0x6a81, 0x6a82, 0x6a83, 0x6a84, 0x6a85, 0x6e00, 0x6d00,
59
32
  0x9d1a,
@@ -62,159 +35,91 @@ var Exchange = /** @class */ (function () {
62
35
  this.transactionRate = transactionRate || 0 /* RateTypes.Fixed */;
63
36
  this.transport = transport;
64
37
  }
65
- Exchange.prototype.startNewTransaction = function () {
66
- return __awaiter(this, void 0, void 0, function () {
67
- var result;
68
- return __generator(this, function (_a) {
69
- switch (_a.label) {
70
- case 0: return [4 /*yield*/, this.transport.send(0xe0, START_NEW_TRANSACTION_COMMAND, this.transactionRate, this.transactionType, Buffer.alloc(0), this.allowedStatuses)];
71
- case 1:
72
- result = _a.sent();
73
- maybeThrowProtocolError(result);
74
- if (this.transactionType === 1 /* ExchangeTypes.Sell */ ||
75
- this.transactionType === 2 /* ExchangeTypes.Fund */) {
76
- return [2 /*return*/, result.slice(0, 32).toString("base64")];
77
- }
78
- return [2 /*return*/, result.toString("ascii", 0, 10)];
79
- }
80
- });
38
+ startNewTransaction() {
39
+ return __awaiter(this, void 0, void 0, function* () {
40
+ const result = yield this.transport.send(0xe0, START_NEW_TRANSACTION_COMMAND, this.transactionRate, this.transactionType, Buffer.alloc(0), this.allowedStatuses);
41
+ maybeThrowProtocolError(result);
42
+ if (this.transactionType === 1 /* ExchangeTypes.Sell */ ||
43
+ this.transactionType === 2 /* ExchangeTypes.Fund */) {
44
+ return result.slice(0, 32).toString("base64");
45
+ }
46
+ return result.toString("ascii", 0, 10);
81
47
  });
82
- };
83
- Exchange.prototype.setPartnerKey = function (partnerNameAndPublicKey) {
84
- return __awaiter(this, void 0, void 0, function () {
85
- var result;
86
- return __generator(this, function (_a) {
87
- switch (_a.label) {
88
- case 0: return [4 /*yield*/, this.transport.send(0xe0, SET_PARTNER_KEY_COMMAND, this.transactionRate, this.transactionType, partnerNameAndPublicKey, this.allowedStatuses)];
89
- case 1:
90
- result = _a.sent();
91
- maybeThrowProtocolError(result);
92
- return [2 /*return*/];
93
- }
94
- });
48
+ }
49
+ setPartnerKey(partnerNameAndPublicKey) {
50
+ return __awaiter(this, void 0, void 0, function* () {
51
+ const result = yield this.transport.send(0xe0, SET_PARTNER_KEY_COMMAND, this.transactionRate, this.transactionType, partnerNameAndPublicKey, this.allowedStatuses);
52
+ maybeThrowProtocolError(result);
95
53
  });
96
- };
97
- Exchange.prototype.checkPartner = function (signatureOfPartnerData) {
98
- return __awaiter(this, void 0, void 0, function () {
99
- var result;
100
- return __generator(this, function (_a) {
101
- switch (_a.label) {
102
- case 0: return [4 /*yield*/, this.transport.send(0xe0, CHECK_PARTNER_COMMAND, this.transactionRate, this.transactionType, signatureOfPartnerData, this.allowedStatuses)];
103
- case 1:
104
- result = _a.sent();
105
- maybeThrowProtocolError(result);
106
- return [2 /*return*/];
107
- }
108
- });
54
+ }
55
+ checkPartner(signatureOfPartnerData) {
56
+ return __awaiter(this, void 0, void 0, function* () {
57
+ const result = yield this.transport.send(0xe0, CHECK_PARTNER_COMMAND, this.transactionRate, this.transactionType, signatureOfPartnerData, this.allowedStatuses);
58
+ maybeThrowProtocolError(result);
109
59
  });
110
- };
111
- Exchange.prototype.processTransaction = function (transaction, fee) {
112
- return __awaiter(this, void 0, void 0, function () {
113
- var hex, feeHex, bufferToSend, result;
114
- return __generator(this, function (_a) {
115
- switch (_a.label) {
116
- case 0:
117
- hex = fee.toString(16);
118
- hex = hex.padStart(hex.length + (hex.length % 2), "0");
119
- feeHex = Buffer.from(hex, "hex");
120
- bufferToSend = Buffer.concat([
121
- Buffer.from([transaction.length]),
122
- transaction,
123
- Buffer.from([feeHex.length]),
124
- feeHex,
125
- ]);
126
- return [4 /*yield*/, this.transport.send(0xe0, PROCESS_TRANSACTION_RESPONSE, this.transactionRate, this.transactionType, bufferToSend, this.allowedStatuses)];
127
- case 1:
128
- result = _a.sent();
129
- maybeThrowProtocolError(result);
130
- return [2 /*return*/];
131
- }
132
- });
60
+ }
61
+ processTransaction(transaction, fee) {
62
+ return __awaiter(this, void 0, void 0, function* () {
63
+ let hex = fee.toString(16);
64
+ hex = hex.padStart(hex.length + (hex.length % 2), "0");
65
+ const feeHex = Buffer.from(hex, "hex");
66
+ const bufferToSend = Buffer.concat([
67
+ Buffer.from([transaction.length]),
68
+ transaction,
69
+ Buffer.from([feeHex.length]),
70
+ feeHex,
71
+ ]);
72
+ const result = yield this.transport.send(0xe0, PROCESS_TRANSACTION_RESPONSE, this.transactionRate, this.transactionType, bufferToSend, this.allowedStatuses);
73
+ maybeThrowProtocolError(result);
133
74
  });
134
- };
135
- Exchange.prototype.checkTransactionSignature = function (transactionSignature) {
136
- return __awaiter(this, void 0, void 0, function () {
137
- var result;
138
- return __generator(this, function (_a) {
139
- switch (_a.label) {
140
- case 0: return [4 /*yield*/, this.transport.send(0xe0, CHECK_TRANSACTION_SIGNATURE, this.transactionRate, this.transactionType, transactionSignature, this.allowedStatuses)];
141
- case 1:
142
- result = _a.sent();
143
- maybeThrowProtocolError(result);
144
- return [2 /*return*/];
145
- }
146
- });
75
+ }
76
+ checkTransactionSignature(transactionSignature) {
77
+ return __awaiter(this, void 0, void 0, function* () {
78
+ const result = yield this.transport.send(0xe0, CHECK_TRANSACTION_SIGNATURE, this.transactionRate, this.transactionType, transactionSignature, this.allowedStatuses);
79
+ maybeThrowProtocolError(result);
147
80
  });
148
- };
149
- Exchange.prototype.checkPayoutAddress = function (payoutCurrencyConfig, currencyConfigSignature, addressParameters) {
150
- return __awaiter(this, void 0, void 0, function () {
151
- var bufferToSend, result;
152
- return __generator(this, function (_a) {
153
- switch (_a.label) {
154
- case 0:
155
- invariant(payoutCurrencyConfig.length <= 255, "Currency config is too big");
156
- invariant(addressParameters.length <= 255, "Address parameter is too big.");
157
- invariant(currencyConfigSignature.length >= 67 &&
158
- currencyConfigSignature.length <= 73, "Signature should be DER serialized and have length in [67, 73] bytes.");
159
- bufferToSend = Buffer.concat([
160
- Buffer.from([payoutCurrencyConfig.length]),
161
- payoutCurrencyConfig,
162
- currencyConfigSignature,
163
- Buffer.from([addressParameters.length]),
164
- addressParameters,
165
- ]);
166
- return [4 /*yield*/, this.transport.send(0xe0, this.transactionType === 0 /* ExchangeTypes.Swap */
167
- ? CHECK_PAYOUT_ADDRESS
168
- : CHECK_ASSET_IN, this.transactionRate, this.transactionType, bufferToSend, this.allowedStatuses)];
169
- case 1:
170
- result = _a.sent();
171
- maybeThrowProtocolError(result);
172
- return [2 /*return*/];
173
- }
174
- });
81
+ }
82
+ checkPayoutAddress(payoutCurrencyConfig, currencyConfigSignature, addressParameters) {
83
+ return __awaiter(this, void 0, void 0, function* () {
84
+ invariant(payoutCurrencyConfig.length <= 255, "Currency config is too big");
85
+ invariant(addressParameters.length <= 255, "Address parameter is too big.");
86
+ invariant(currencyConfigSignature.length >= 67 &&
87
+ currencyConfigSignature.length <= 73, "Signature should be DER serialized and have length in [67, 73] bytes.");
88
+ const bufferToSend = Buffer.concat([
89
+ Buffer.from([payoutCurrencyConfig.length]),
90
+ payoutCurrencyConfig,
91
+ currencyConfigSignature,
92
+ Buffer.from([addressParameters.length]),
93
+ addressParameters,
94
+ ]);
95
+ const result = yield this.transport.send(0xe0, this.transactionType === 0 /* ExchangeTypes.Swap */
96
+ ? CHECK_PAYOUT_ADDRESS
97
+ : CHECK_ASSET_IN, this.transactionRate, this.transactionType, bufferToSend, this.allowedStatuses);
98
+ maybeThrowProtocolError(result);
175
99
  });
176
- };
177
- Exchange.prototype.checkRefundAddress = function (refundCurrencyConfig, currencyConfigSignature, addressParameters) {
178
- return __awaiter(this, void 0, void 0, function () {
179
- var bufferToSend, result;
180
- return __generator(this, function (_a) {
181
- switch (_a.label) {
182
- case 0:
183
- invariant(refundCurrencyConfig.length <= 255, "Currency config is too big");
184
- invariant(addressParameters.length <= 255, "Address parameter is too big.");
185
- invariant(currencyConfigSignature.length >= 67 &&
186
- currencyConfigSignature.length <= 73, "Signature should be DER serialized and have length in [67, 73] bytes.");
187
- bufferToSend = Buffer.concat([
188
- Buffer.from([refundCurrencyConfig.length]),
189
- refundCurrencyConfig,
190
- currencyConfigSignature,
191
- Buffer.from([addressParameters.length]),
192
- addressParameters,
193
- ]);
194
- return [4 /*yield*/, this.transport.send(0xe0, CHECK_REFUND_ADDRESS, this.transactionRate, this.transactionType, bufferToSend, this.allowedStatuses)];
195
- case 1:
196
- result = _a.sent();
197
- maybeThrowProtocolError(result);
198
- return [2 /*return*/];
199
- }
200
- });
100
+ }
101
+ checkRefundAddress(refundCurrencyConfig, currencyConfigSignature, addressParameters) {
102
+ return __awaiter(this, void 0, void 0, function* () {
103
+ invariant(refundCurrencyConfig.length <= 255, "Currency config is too big");
104
+ invariant(addressParameters.length <= 255, "Address parameter is too big.");
105
+ invariant(currencyConfigSignature.length >= 67 &&
106
+ currencyConfigSignature.length <= 73, "Signature should be DER serialized and have length in [67, 73] bytes.");
107
+ const bufferToSend = Buffer.concat([
108
+ Buffer.from([refundCurrencyConfig.length]),
109
+ refundCurrencyConfig,
110
+ currencyConfigSignature,
111
+ Buffer.from([addressParameters.length]),
112
+ addressParameters,
113
+ ]);
114
+ const result = yield this.transport.send(0xe0, CHECK_REFUND_ADDRESS, this.transactionRate, this.transactionType, bufferToSend, this.allowedStatuses);
115
+ maybeThrowProtocolError(result);
201
116
  });
202
- };
203
- Exchange.prototype.signCoinTransaction = function () {
204
- return __awaiter(this, void 0, void 0, function () {
205
- var result;
206
- return __generator(this, function (_a) {
207
- switch (_a.label) {
208
- case 0: return [4 /*yield*/, this.transport.send(0xe0, SIGN_COIN_TRANSACTION, this.transactionRate, this.transactionType, Buffer.alloc(0), this.allowedStatuses)];
209
- case 1:
210
- result = _a.sent();
211
- maybeThrowProtocolError(result);
212
- return [2 /*return*/];
213
- }
214
- });
117
+ }
118
+ signCoinTransaction() {
119
+ return __awaiter(this, void 0, void 0, function* () {
120
+ const result = yield this.transport.send(0xe0, SIGN_COIN_TRANSACTION, this.transactionRate, this.transactionType, Buffer.alloc(0), this.allowedStatuses);
121
+ maybeThrowProtocolError(result);
215
122
  });
216
- };
217
- return Exchange;
218
- }());
219
- export default Exchange;
123
+ }
124
+ }
220
125
  //# sourceMappingURL=Exchange.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Exchange.js","sourceRoot":"","sources":["../src/Exchange.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,SAAS,MAAM,WAAW,CAAC;AAalC,IAAM,6BAA6B,GAAG,IAAI,CAAC;AAC3C,IAAM,uBAAuB,GAAG,IAAI,CAAC;AACrC,IAAM,qBAAqB,GAAG,IAAI,CAAC;AACnC,IAAM,4BAA4B,GAAG,IAAI,CAAC;AAC1C,IAAM,2BAA2B,GAAG,IAAI,CAAC;AACzC,IAAM,oBAAoB,GAAG,IAAI,CAAC;AAClC,IAAM,cAAc,GAAG,IAAI,CAAC;AAC5B,IAAM,oBAAoB,GAAG,IAAI,CAAC;AAClC,IAAM,qBAAqB,GAAG,IAAI,CAAC;AAEnC,IAAM,uBAAuB,GAAG,UAAC,MAAc;IAC7C,SAAS,CAAC,MAAM,CAAC,MAAM,IAAI,CAAC,EAAE,6CAA6C,CAAC,CAAC;IAC7E,IAAM,UAAU,GAAG,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAE1D,IAAI,UAAU,KAAK,MAAM,EAAE;QACzB,MAAM,IAAI,oBAAoB,CAAC,UAAU,CAAC,CAAC;KAC5C;AACH,CAAC,CAAC;AAEF;IASE,kBACE,SAAoB,EACpB,eAA8B,EAC9B,eAA2B;QAR7B,oBAAe,GAAkB;YAC/B,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;YAC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MAAM,CAAC,CAAC;QAClC,CAAC;KAAA;CACF"}
@@ -7,119 +7,62 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- var __generator = (this && this.__generator) || function (thisArg, body) {
11
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
- function verb(n) { return function (v) { return step([n, v]); }; }
14
- function step(op) {
15
- if (f) throw new TypeError("Generator is already executing.");
16
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
- 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;
18
- if (y = 0, t) op = [op[0] & 2, t.value];
19
- switch (op[0]) {
20
- case 0: case 1: t = op; break;
21
- case 4: _.label++; return { value: op[1], done: false };
22
- case 5: _.label++; y = op[1]; op = [0]; continue;
23
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
- default:
25
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
- if (t[2]) _.ops.pop();
30
- _.trys.pop(); continue;
31
- }
32
- op = body.call(thisArg, _);
33
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
- }
36
- };
37
10
  import { createTransportRecorder, MockTransport, openTransportReplayer, RecordStore, } from "@ledgerhq/hw-transport-mocker";
38
11
  import Exchange from "./Exchange";
39
12
  import { TextEncoder } from "util";
40
- describe("Contrustructor", function () {
41
- [2 /* ExchangeTypes.Fund */, 1 /* ExchangeTypes.Sell */, 0 /* ExchangeTypes.Swap */].forEach(function (exchangeType) {
42
- it("Exchange (value of ".concat(exchangeType, ") init with default rate types of fixed"), function () { return __awaiter(void 0, void 0, void 0, function () {
43
- var transport, exchange;
44
- return __generator(this, function (_a) {
45
- switch (_a.label) {
46
- case 0: return [4 /*yield*/, openTransportReplayer(RecordStore.fromString(""))];
47
- case 1:
48
- transport = _a.sent();
49
- exchange = new Exchange(transport, exchangeType);
50
- expect(exchange.transactionRate).toBe(0 /* RateTypes.Fixed */);
51
- return [2 /*return*/];
52
- }
53
- });
54
- }); });
55
- [0 /* RateTypes.Fixed */, 1 /* RateTypes.Floating */].forEach(function (rateType) {
56
- it("Exchange (value of ".concat(exchangeType, ") init with rate types of value ").concat(rateType), function () { return __awaiter(void 0, void 0, void 0, function () {
57
- var transport, exchange;
58
- return __generator(this, function (_a) {
59
- switch (_a.label) {
60
- case 0: return [4 /*yield*/, openTransportReplayer(RecordStore.fromString(""))];
61
- case 1:
62
- transport = _a.sent();
63
- exchange = new Exchange(transport, exchangeType, rateType);
64
- expect(exchange.transactionRate).toBe(rateType);
65
- return [2 /*return*/];
66
- }
67
- });
68
- }); });
13
+ describe("Contrustructor", () => {
14
+ [2 /* ExchangeTypes.Fund */, 1 /* ExchangeTypes.Sell */, 0 /* ExchangeTypes.Swap */].forEach((exchangeType) => {
15
+ it(`Exchange (value of ${exchangeType}) init with default rate types of fixed`, () => __awaiter(void 0, void 0, void 0, function* () {
16
+ const transport = yield openTransportReplayer(RecordStore.fromString(""));
17
+ const exchange = new Exchange(transport, exchangeType);
18
+ expect(exchange.transactionRate).toBe(0 /* RateTypes.Fixed */);
19
+ }));
20
+ [0 /* RateTypes.Fixed */, 1 /* RateTypes.Floating */].forEach((rateType) => {
21
+ it(`Exchange (value of ${exchangeType}) init with rate types of value ${rateType}`, () => __awaiter(void 0, void 0, void 0, function* () {
22
+ const transport = yield openTransportReplayer(RecordStore.fromString(""));
23
+ const exchange = new Exchange(transport, exchangeType, rateType);
24
+ expect(exchange.transactionRate).toBe(rateType);
25
+ }));
69
26
  });
70
27
  });
71
28
  });
72
- describe("startNewTransaction", function () {
73
- var textEncoder = new TextEncoder();
74
- var mockResponse = "2ac38f187c"; // Response of length 10
75
- it("sends a correct sequence of APDU", function () { return __awaiter(void 0, void 0, void 0, function () {
76
- var recordStore, mockTransport, transport, exchange, result, expectCommand;
77
- return __generator(this, function (_a) {
78
- switch (_a.label) {
79
- case 0:
80
- recordStore = new RecordStore();
81
- mockTransport = new MockTransport(Buffer.concat([
82
- textEncoder.encode(mockResponse),
83
- Buffer.from([0x90, 0x00]), // StatusCodes.OK
84
- ]));
85
- transport = createTransportRecorder(mockTransport, recordStore);
86
- exchange = new Exchange(new transport(mockTransport), 0 /* ExchangeTypes.Swap */);
87
- return [4 /*yield*/, exchange.startNewTransaction()];
88
- case 1:
89
- result = _a.sent();
90
- expectCommand = Buffer.from([
91
- 0xe0,
92
- 0x03,
93
- 0 /* ExchangeTypes.Swap */,
94
- 0 /* RateTypes.Fixed */,
95
- 0x00, // Data
96
- ]).toString("hex");
97
- expect(recordStore.queue[0][0]).toBe(expectCommand);
98
- expect(result).toEqual(mockResponse);
99
- return [2 /*return*/];
100
- }
101
- });
102
- }); });
29
+ describe("startNewTransaction", () => {
30
+ const textEncoder = new TextEncoder();
31
+ const mockResponse = "2ac38f187c"; // Response of length 10
32
+ it("sends a correct sequence of APDU", () => __awaiter(void 0, void 0, void 0, function* () {
33
+ // Given
34
+ const recordStore = new RecordStore();
35
+ const mockTransport = new MockTransport(Buffer.concat([
36
+ textEncoder.encode(mockResponse),
37
+ Buffer.from([0x90, 0x00]), // StatusCodes.OK
38
+ ]));
39
+ const transport = createTransportRecorder(mockTransport, recordStore);
40
+ const exchange = new Exchange(new transport(mockTransport), 0 /* ExchangeTypes.Swap */);
41
+ // When
42
+ const result = yield exchange.startNewTransaction();
43
+ // Then
44
+ const expectCommand = Buffer.from([
45
+ 0xe0,
46
+ 0x03,
47
+ 0 /* ExchangeTypes.Swap */,
48
+ 0 /* RateTypes.Fixed */,
49
+ 0x00, // Data
50
+ ]).toString("hex");
51
+ expect(recordStore.queue[0][0]).toBe(expectCommand);
52
+ expect(result).toEqual(mockResponse);
53
+ }));
103
54
  // TOFIX: TransportError is not recognize as an Error type
104
- xit("throws an error if status is not ok", function () { return __awaiter(void 0, void 0, void 0, function () {
105
- var recordStore, mockTransport, transport, exchange;
106
- return __generator(this, function (_a) {
107
- recordStore = new RecordStore();
108
- mockTransport = new MockTransport(Buffer.concat([
109
- textEncoder.encode(mockResponse),
110
- Buffer.from([0x6a, 0x80]),
111
- ]));
112
- transport = createTransportRecorder(mockTransport, recordStore);
113
- exchange = new Exchange(new transport(mockTransport), 0 /* ExchangeTypes.Swap */);
114
- // When & Then
115
- expect(function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
116
- switch (_a.label) {
117
- case 0: return [4 /*yield*/, exchange.startNewTransaction()];
118
- case 1: return [2 /*return*/, _a.sent()];
119
- }
120
- }); }); }).toThrowError();
121
- return [2 /*return*/];
122
- });
123
- }); });
55
+ xit("throws an error if status is not ok", () => __awaiter(void 0, void 0, void 0, function* () {
56
+ // Given
57
+ const recordStore = new RecordStore();
58
+ const mockTransport = new MockTransport(Buffer.concat([
59
+ textEncoder.encode(mockResponse),
60
+ Buffer.from([0x6a, 0x80]),
61
+ ]));
62
+ const transport = createTransportRecorder(mockTransport, recordStore);
63
+ const exchange = new Exchange(new transport(mockTransport), 0 /* ExchangeTypes.Swap */);
64
+ // When & Then
65
+ expect(() => __awaiter(void 0, void 0, void 0, function* () { return yield exchange.startNewTransaction(); })).toThrowError();
66
+ }));
124
67
  });
125
68
  //# sourceMappingURL=Exchange.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Exchange.test.js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M,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IACvC,CAAC,CAAA,CAAC,CAAC;IAEH,0DAA0D;IAC1D,GAAG,CAAC,qCAAqC,EAAE,GAAS,EAAE;QACpD,QAAQ;QACR,MAAM,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC;QACtC,MAAM,aAAa,GAAG,IAAI,aAAa,CACrC,MAAM,CAAC,MAAM,CAAC;YACZ,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC;YAChC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;SAC1B,CAAC,CACH,CAAC;QACF,MAAM,SAAS,GAAG,uBAAuB,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;QACtE,MAAM,QAAQ,GAAG,IAAI,QAAQ,CAC3B,IAAI,SAAS,CAAC,aAAa,CAAC,6BAE7B,CAAC;QAEF,cAAc;QACd,MAAM,CAAC,GAAS,EAAE,kDAAC,OAAA,MAAM,QAAQ,CAAC,mBAAmB,EAAE,CAAA,GAAA,CAAC,CAAC,YAAY,EAAE,CAAC;IAC1E,CAAC,CAAA,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ledgerhq/hw-app-exchange",
3
- "version": "0.1.0",
3
+ "version": "0.1.1-next.0",
4
4
  "description": "Ledger Hardware Wallet Cosmos Application API",
5
5
  "keywords": [
6
6
  "Ledger",
@@ -27,8 +27,8 @@
27
27
  "dependencies": {
28
28
  "bignumber.js": "^9.1.0",
29
29
  "invariant": "^2.2.2",
30
- "@ledgerhq/errors": "^6.12.4-nightly.2",
31
- "@ledgerhq/hw-transport": "^6.28.2-nightly.2"
30
+ "@ledgerhq/errors": "^6.12.5-next.0",
31
+ "@ledgerhq/hw-transport": "^6.28.3-next.0"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@types/jest": "^29.5.0",
@@ -37,8 +37,7 @@
37
37
  "jest": "^28.1.1",
38
38
  "ts-jest": "^28.0.5",
39
39
  "ts-node": "^10.4.0",
40
- "typescript": "^4",
41
- "@ledgerhq/hw-transport-mocker": "^6.27.13-nightly.2"
40
+ "@ledgerhq/hw-transport-mocker": "^6.27.14-next.0"
42
41
  },
43
42
  "scripts": {
44
43
  "clean": "rimraf lib lib-es",