@ledgerhq/hw-app-exchange 0.12.0 → 0.13.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.
@@ -1,8 +1,8 @@
1
1
 
2
- > @ledgerhq/hw-app-exchange@0.12.0 prebuild /home/runner/work/ledger-live/ledger-live/libs/ledgerjs/packages/hw-app-exchange
2
+ > @ledgerhq/hw-app-exchange@0.13.0 prebuild /home/runner/work/ledger-live/ledger-live/libs/ledgerjs/packages/hw-app-exchange
3
3
  > pnpm pbjs -t json -r ledger_swap -o src/generate-protocol.json ./protocol.proto
4
4
 
5
5
 
6
- > @ledgerhq/hw-app-exchange@0.12.0 build /home/runner/work/ledger-live/ledger-live/libs/ledgerjs/packages/hw-app-exchange
6
+ > @ledgerhq/hw-app-exchange@0.13.0 build /home/runner/work/ledger-live/ledger-live/libs/ledgerjs/packages/hw-app-exchange
7
7
  > tsc && tsc -m esnext --moduleResolution bundler --outDir lib-es
8
8
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @ledgerhq/hw-app-exchange
2
2
 
3
+ ## 0.13.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#11346](https://github.com/LedgerHQ/ledger-live/pull/11346) [`fa8605b`](https://github.com/LedgerHQ/ledger-live/commit/fa8605befcc07e8446f8babfbe1bb99e5641c827) Thanks [@hhumphrey-ledger](https://github.com/hhumphrey-ledger)! - Added new payinExtraId to payload
8
+
9
+ ## 0.13.0-next.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [#11346](https://github.com/LedgerHQ/ledger-live/pull/11346) [`fa8605b`](https://github.com/LedgerHQ/ledger-live/commit/fa8605befcc07e8446f8babfbe1bb99e5641c827) Thanks [@hhumphrey-ledger](https://github.com/hhumphrey-ledger)! - Added new payinExtraId to payload
14
+
3
15
  ## 0.12.0
4
16
 
5
17
  ### Minor Changes
@@ -0,0 +1,11 @@
1
+ export type FundPayload = {
2
+ deviceTransactionId: object;
3
+ inAddress: string;
4
+ inAmount: object;
5
+ inCurrency: string;
6
+ accountName: string;
7
+ userId: string;
8
+ payinExtraId?: string;
9
+ };
10
+ export declare function decodeFundPayload(payload: string): Promise<FundPayload>;
11
+ //# sourceMappingURL=FundUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FundUtils.d.ts","sourceRoot":"","sources":["../src/FundUtils.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,WAAW,GAAG;IACxB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAmB7E"}
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.decodeFundPayload = void 0;
30
+ const protobufjs_1 = __importDefault(require("protobufjs"));
31
+ const protoJson = __importStar(require("./generate-protocol.json"));
32
+ const shared_utils_1 = require("./shared-utils");
33
+ async function decodeFundPayload(payload) {
34
+ const buffer = (0, shared_utils_1.isHexadecimal)(payload)
35
+ ? Buffer.from(payload, "hex")
36
+ : Buffer.from(payload, "base64");
37
+ const root = protobufjs_1.default.Root.fromJSON(protoJson) || {};
38
+ const TransactionResponse = root?.nested.ledger_swap?.NewFundResponse;
39
+ const err = TransactionResponse.verify(buffer);
40
+ if (err) {
41
+ throw Error(err);
42
+ }
43
+ const decodedPayload = TransactionResponse.decode(buffer);
44
+ return {
45
+ ...decodedPayload,
46
+ };
47
+ }
48
+ exports.decodeFundPayload = decodeFundPayload;
49
+ //# sourceMappingURL=FundUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FundUtils.js","sourceRoot":"","sources":["../src/FundUtils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4DAAkC;AAClC,oEAAsD;AACtD,iDAA+C;AAYxC,KAAK,UAAU,iBAAiB,CAAC,OAAe;IACrD,MAAM,MAAM,GAAG,IAAA,4BAAa,EAAC,OAAO,CAAC;QACnC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC;QAC7B,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAEnC,MAAM,IAAI,GAA2B,oBAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;IAE7E,MAAM,mBAAmB,GAAG,IAAI,EAAE,MAAM,CAAC,WAAW,EAAE,eAAe,CAAC;IACtE,MAAM,GAAG,GAAG,mBAAmB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAE/C,IAAI,GAAG,EAAE,CAAC;QACR,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;IACnB,CAAC;IAED,MAAM,cAAc,GAAG,mBAAmB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAE1D,OAAO;QACL,GAAG,cAAc;KAClB,CAAC;AACJ,CAAC;AAnBD,8CAmBC"}
@@ -6,6 +6,7 @@ export type SellPayload = {
6
6
  outAmount: object;
7
7
  outCurrency: string;
8
8
  traderEmail: string;
9
+ payinExtraId?: string;
9
10
  };
10
11
  export declare function decodeSellPayload(payload: string): Promise<SellPayload>;
11
12
  //# sourceMappingURL=SellUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SellUtils.d.ts","sourceRoot":"","sources":["../src/SellUtils.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,WAAW,GAAG;IACxB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAmB7E"}
1
+ {"version":3,"file":"SellUtils.d.ts","sourceRoot":"","sources":["../src/SellUtils.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,WAAW,GAAG;IACxB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAmB7E"}
@@ -1 +1 @@
1
- {"version":3,"file":"SellUtils.js","sourceRoot":"","sources":["../src/SellUtils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4DAAkC;AAClC,oEAAsD;AACtD,iDAA+C;AAYxC,KAAK,UAAU,iBAAiB,CAAC,OAAe;IACrD,MAAM,MAAM,GAAG,IAAA,4BAAa,EAAC,OAAO,CAAC;QACnC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC;QAC7B,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAEnC,MAAM,IAAI,GAA2B,oBAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;IAE7E,MAAM,mBAAmB,GAAG,IAAI,EAAE,MAAM,CAAC,WAAW,EAAE,eAAe,CAAC;IACtE,MAAM,GAAG,GAAG,mBAAmB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAE/C,IAAI,GAAG,EAAE,CAAC;QACR,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;IACnB,CAAC;IAED,MAAM,cAAc,GAAG,mBAAmB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAE1D,OAAO;QACL,GAAG,cAAc;KAClB,CAAC;AACJ,CAAC;AAnBD,8CAmBC"}
1
+ {"version":3,"file":"SellUtils.js","sourceRoot":"","sources":["../src/SellUtils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4DAAkC;AAClC,oEAAsD;AACtD,iDAA+C;AAaxC,KAAK,UAAU,iBAAiB,CAAC,OAAe;IACrD,MAAM,MAAM,GAAG,IAAA,4BAAa,EAAC,OAAO,CAAC;QACnC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC;QAC7B,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAEnC,MAAM,IAAI,GAA2B,oBAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;IAE7E,MAAM,mBAAmB,GAAG,IAAI,EAAE,MAAM,CAAC,WAAW,EAAE,eAAe,CAAC;IACtE,MAAM,GAAG,GAAG,mBAAmB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAE/C,IAAI,GAAG,EAAE,CAAC;QACR,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;IACnB,CAAC;IAED,MAAM,cAAc,GAAG,mBAAmB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAE1D,OAAO;QACL,GAAG,cAAc;KAClB,CAAC;AACJ,CAAC;AAnBD,8CAmBC"}
package/lib/index.d.ts CHANGED
@@ -2,6 +2,7 @@ import { getExchangeErrorMessage } from "./ReturnCode";
2
2
  import Exchange, { createExchange, ExchangeTypes, RateTypes, PartnerKeyInfo, isExchangeTypeNg, PayloadSignatureComputedFormat } from "./Exchange";
3
3
  import { decodeSwapPayload, decodePayloadProtobuf } from "./SwapUtils";
4
4
  import { decodeSellPayload } from "./SellUtils";
5
- export { createExchange, decodePayloadProtobuf, decodeSwapPayload, getExchangeErrorMessage, ExchangeTypes, RateTypes, PartnerKeyInfo, isExchangeTypeNg, PayloadSignatureComputedFormat, decodeSellPayload, };
5
+ import { decodeFundPayload } from "./FundUtils";
6
+ export { createExchange, decodePayloadProtobuf, decodeSwapPayload, getExchangeErrorMessage, ExchangeTypes, RateTypes, PartnerKeyInfo, isExchangeTypeNg, PayloadSignatureComputedFormat, decodeSellPayload, decodeFundPayload, };
6
7
  export default Exchange;
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,QAAQ,EAAE,EACf,cAAc,EACd,aAAa,EACb,SAAS,EACT,cAAc,EACd,gBAAgB,EAChB,8BAA8B,EAC/B,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,EACL,cAAc,EACd,qBAAqB,EACrB,iBAAiB,EACjB,uBAAuB,EACvB,aAAa,EACb,SAAS,EACT,cAAc,EACd,gBAAgB,EAChB,8BAA8B,EAC9B,iBAAiB,GAClB,CAAC;AAEF,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,QAAQ,EAAE,EACf,cAAc,EACd,aAAa,EACb,SAAS,EACT,cAAc,EACd,gBAAgB,EAChB,8BAA8B,EAC/B,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,EACL,cAAc,EACd,qBAAqB,EACrB,iBAAiB,EACjB,uBAAuB,EACvB,aAAa,EACb,SAAS,EACT,cAAc,EACd,gBAAgB,EAChB,8BAA8B,EAC9B,iBAAiB,EACjB,iBAAiB,GAClB,CAAC;AAEF,eAAe,QAAQ,CAAC"}
package/lib/index.js CHANGED
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.decodeSellPayload = exports.isExchangeTypeNg = exports.getExchangeErrorMessage = exports.decodeSwapPayload = exports.decodePayloadProtobuf = exports.createExchange = void 0;
26
+ exports.decodeFundPayload = exports.decodeSellPayload = exports.isExchangeTypeNg = exports.getExchangeErrorMessage = exports.decodeSwapPayload = exports.decodePayloadProtobuf = exports.createExchange = void 0;
27
27
  const ReturnCode_1 = require("./ReturnCode");
28
28
  Object.defineProperty(exports, "getExchangeErrorMessage", { enumerable: true, get: function () { return ReturnCode_1.getExchangeErrorMessage; } });
29
29
  const Exchange_1 = __importStar(require("./Exchange"));
@@ -34,5 +34,7 @@ Object.defineProperty(exports, "decodeSwapPayload", { enumerable: true, get: fun
34
34
  Object.defineProperty(exports, "decodePayloadProtobuf", { enumerable: true, get: function () { return SwapUtils_1.decodePayloadProtobuf; } });
35
35
  const SellUtils_1 = require("./SellUtils");
36
36
  Object.defineProperty(exports, "decodeSellPayload", { enumerable: true, get: function () { return SellUtils_1.decodeSellPayload; } });
37
+ const FundUtils_1 = require("./FundUtils");
38
+ Object.defineProperty(exports, "decodeFundPayload", { enumerable: true, get: function () { return FundUtils_1.decodeFundPayload; } });
37
39
  exports.default = Exchange_1.default;
38
40
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAuD;AAgBrD,wGAhBO,oCAAuB,OAgBP;AAfzB,uDAOoB;AAKlB,+FAXA,yBAAc,OAWA;AAOd,iGAdA,2BAAgB,OAcA;AAXlB,2CAAuE;AAMrE,kGANO,6BAAiB,OAMP;AADjB,sGAL0B,iCAAqB,OAK1B;AAJvB,2CAAgD;AAY9C,kGAZO,6BAAiB,OAYP;AAGnB,kBAAe,kBAAQ,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAuD;AAiBrD,wGAjBO,oCAAuB,OAiBP;AAhBzB,uDAOoB;AAMlB,+FAZA,yBAAc,OAYA;AAOd,iGAfA,2BAAgB,OAeA;AAZlB,2CAAuE;AAOrE,kGAPO,6BAAiB,OAOP;AADjB,sGAN0B,iCAAqB,OAM1B;AALvB,2CAAgD;AAa9C,kGAbO,6BAAiB,OAaP;AAZnB,2CAAgD;AAa9C,kGAbO,6BAAiB,OAaP;AAGnB,kBAAe,kBAAQ,CAAC"}
@@ -0,0 +1,11 @@
1
+ export type FundPayload = {
2
+ deviceTransactionId: object;
3
+ inAddress: string;
4
+ inAmount: object;
5
+ inCurrency: string;
6
+ accountName: string;
7
+ userId: string;
8
+ payinExtraId?: string;
9
+ };
10
+ export declare function decodeFundPayload(payload: string): Promise<FundPayload>;
11
+ //# sourceMappingURL=FundUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FundUtils.d.ts","sourceRoot":"","sources":["../src/FundUtils.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,WAAW,GAAG;IACxB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAmB7E"}
@@ -0,0 +1,19 @@
1
+ import protobuf from "protobufjs";
2
+ import * as protoJson from "./generate-protocol.json";
3
+ import { isHexadecimal } from "./shared-utils";
4
+ export async function decodeFundPayload(payload) {
5
+ const buffer = isHexadecimal(payload)
6
+ ? Buffer.from(payload, "hex")
7
+ : Buffer.from(payload, "base64");
8
+ const root = protobuf.Root.fromJSON(protoJson) || {};
9
+ const TransactionResponse = root?.nested.ledger_swap?.NewFundResponse;
10
+ const err = TransactionResponse.verify(buffer);
11
+ if (err) {
12
+ throw Error(err);
13
+ }
14
+ const decodedPayload = TransactionResponse.decode(buffer);
15
+ return {
16
+ ...decodedPayload,
17
+ };
18
+ }
19
+ //# sourceMappingURL=FundUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FundUtils.js","sourceRoot":"","sources":["../src/FundUtils.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,KAAK,SAAS,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAY/C,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,OAAe;IACrD,MAAM,MAAM,GAAG,aAAa,CAAC,OAAO,CAAC;QACnC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC;QAC7B,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAEnC,MAAM,IAAI,GAA2B,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;IAE7E,MAAM,mBAAmB,GAAG,IAAI,EAAE,MAAM,CAAC,WAAW,EAAE,eAAe,CAAC;IACtE,MAAM,GAAG,GAAG,mBAAmB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAE/C,IAAI,GAAG,EAAE,CAAC;QACR,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;IACnB,CAAC;IAED,MAAM,cAAc,GAAG,mBAAmB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAE1D,OAAO;QACL,GAAG,cAAc;KAClB,CAAC;AACJ,CAAC"}
@@ -6,6 +6,7 @@ export type SellPayload = {
6
6
  outAmount: object;
7
7
  outCurrency: string;
8
8
  traderEmail: string;
9
+ payinExtraId?: string;
9
10
  };
10
11
  export declare function decodeSellPayload(payload: string): Promise<SellPayload>;
11
12
  //# sourceMappingURL=SellUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SellUtils.d.ts","sourceRoot":"","sources":["../src/SellUtils.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,WAAW,GAAG;IACxB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAmB7E"}
1
+ {"version":3,"file":"SellUtils.d.ts","sourceRoot":"","sources":["../src/SellUtils.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,WAAW,GAAG;IACxB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAmB7E"}
@@ -1 +1 @@
1
- {"version":3,"file":"SellUtils.js","sourceRoot":"","sources":["../src/SellUtils.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,KAAK,SAAS,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAY/C,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,OAAe;IACrD,MAAM,MAAM,GAAG,aAAa,CAAC,OAAO,CAAC;QACnC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC;QAC7B,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAEnC,MAAM,IAAI,GAA2B,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;IAE7E,MAAM,mBAAmB,GAAG,IAAI,EAAE,MAAM,CAAC,WAAW,EAAE,eAAe,CAAC;IACtE,MAAM,GAAG,GAAG,mBAAmB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAE/C,IAAI,GAAG,EAAE,CAAC;QACR,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;IACnB,CAAC;IAED,MAAM,cAAc,GAAG,mBAAmB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAE1D,OAAO;QACL,GAAG,cAAc;KAClB,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"SellUtils.js","sourceRoot":"","sources":["../src/SellUtils.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,KAAK,SAAS,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAa/C,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,OAAe;IACrD,MAAM,MAAM,GAAG,aAAa,CAAC,OAAO,CAAC;QACnC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC;QAC7B,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAEnC,MAAM,IAAI,GAA2B,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;IAE7E,MAAM,mBAAmB,GAAG,IAAI,EAAE,MAAM,CAAC,WAAW,EAAE,eAAe,CAAC;IACtE,MAAM,GAAG,GAAG,mBAAmB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAE/C,IAAI,GAAG,EAAE,CAAC;QACR,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;IACnB,CAAC;IAED,MAAM,cAAc,GAAG,mBAAmB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAE1D,OAAO;QACL,GAAG,cAAc;KAClB,CAAC;AACJ,CAAC"}
package/lib-es/index.d.ts CHANGED
@@ -2,6 +2,7 @@ import { getExchangeErrorMessage } from "./ReturnCode";
2
2
  import Exchange, { createExchange, ExchangeTypes, RateTypes, PartnerKeyInfo, isExchangeTypeNg, PayloadSignatureComputedFormat } from "./Exchange";
3
3
  import { decodeSwapPayload, decodePayloadProtobuf } from "./SwapUtils";
4
4
  import { decodeSellPayload } from "./SellUtils";
5
- export { createExchange, decodePayloadProtobuf, decodeSwapPayload, getExchangeErrorMessage, ExchangeTypes, RateTypes, PartnerKeyInfo, isExchangeTypeNg, PayloadSignatureComputedFormat, decodeSellPayload, };
5
+ import { decodeFundPayload } from "./FundUtils";
6
+ export { createExchange, decodePayloadProtobuf, decodeSwapPayload, getExchangeErrorMessage, ExchangeTypes, RateTypes, PartnerKeyInfo, isExchangeTypeNg, PayloadSignatureComputedFormat, decodeSellPayload, decodeFundPayload, };
6
7
  export default Exchange;
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,QAAQ,EAAE,EACf,cAAc,EACd,aAAa,EACb,SAAS,EACT,cAAc,EACd,gBAAgB,EAChB,8BAA8B,EAC/B,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,EACL,cAAc,EACd,qBAAqB,EACrB,iBAAiB,EACjB,uBAAuB,EACvB,aAAa,EACb,SAAS,EACT,cAAc,EACd,gBAAgB,EAChB,8BAA8B,EAC9B,iBAAiB,GAClB,CAAC;AAEF,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,QAAQ,EAAE,EACf,cAAc,EACd,aAAa,EACb,SAAS,EACT,cAAc,EACd,gBAAgB,EAChB,8BAA8B,EAC/B,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,EACL,cAAc,EACd,qBAAqB,EACrB,iBAAiB,EACjB,uBAAuB,EACvB,aAAa,EACb,SAAS,EACT,cAAc,EACd,gBAAgB,EAChB,8BAA8B,EAC9B,iBAAiB,EACjB,iBAAiB,GAClB,CAAC;AAEF,eAAe,QAAQ,CAAC"}
package/lib-es/index.js CHANGED
@@ -2,6 +2,7 @@ import { getExchangeErrorMessage } from "./ReturnCode";
2
2
  import Exchange, { createExchange, isExchangeTypeNg, } from "./Exchange";
3
3
  import { decodeSwapPayload, decodePayloadProtobuf } from "./SwapUtils";
4
4
  import { decodeSellPayload } from "./SellUtils";
5
- export { createExchange, decodePayloadProtobuf, decodeSwapPayload, getExchangeErrorMessage, isExchangeTypeNg, decodeSellPayload, };
5
+ import { decodeFundPayload } from "./FundUtils";
6
+ export { createExchange, decodePayloadProtobuf, decodeSwapPayload, getExchangeErrorMessage, isExchangeTypeNg, decodeSellPayload, decodeFundPayload, };
6
7
  export default Exchange;
7
8
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,QAAQ,EAAE,EACf,cAAc,EAId,gBAAgB,GAEjB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,EACL,cAAc,EACd,qBAAqB,EACrB,iBAAiB,EACjB,uBAAuB,EAIvB,gBAAgB,EAEhB,iBAAiB,GAClB,CAAC;AAEF,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,QAAQ,EAAE,EACf,cAAc,EAId,gBAAgB,GAEjB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,EACL,cAAc,EACd,qBAAqB,EACrB,iBAAiB,EACjB,uBAAuB,EAIvB,gBAAgB,EAEhB,iBAAiB,EACjB,iBAAiB,GAClB,CAAC;AAEF,eAAe,QAAQ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ledgerhq/hw-app-exchange",
3
- "version": "0.12.0",
3
+ "version": "0.13.0",
4
4
  "description": "Ledger Hardware Wallet Cosmos Application API",
5
5
  "keywords": [
6
6
  "Ledger",
@@ -0,0 +1,34 @@
1
+ import protobuf from "protobufjs";
2
+ import * as protoJson from "./generate-protocol.json";
3
+ import { isHexadecimal } from "./shared-utils";
4
+
5
+ export type FundPayload = {
6
+ deviceTransactionId: object;
7
+ inAddress: string;
8
+ inAmount: object;
9
+ inCurrency: string;
10
+ accountName: string;
11
+ userId: string;
12
+ payinExtraId?: string;
13
+ };
14
+
15
+ export async function decodeFundPayload(payload: string): Promise<FundPayload> {
16
+ const buffer = isHexadecimal(payload)
17
+ ? Buffer.from(payload, "hex")
18
+ : Buffer.from(payload, "base64");
19
+
20
+ const root: { [key: string]: any } = protobuf.Root.fromJSON(protoJson) || {};
21
+
22
+ const TransactionResponse = root?.nested.ledger_swap?.NewFundResponse;
23
+ const err = TransactionResponse.verify(buffer);
24
+
25
+ if (err) {
26
+ throw Error(err);
27
+ }
28
+
29
+ const decodedPayload = TransactionResponse.decode(buffer);
30
+
31
+ return {
32
+ ...decodedPayload,
33
+ };
34
+ }
package/src/SellUtils.ts CHANGED
@@ -10,6 +10,7 @@ export type SellPayload = {
10
10
  outAmount: object;
11
11
  outCurrency: string;
12
12
  traderEmail: string;
13
+ payinExtraId?: string;
13
14
  };
14
15
 
15
16
  export async function decodeSellPayload(payload: string): Promise<SellPayload> {
package/src/index.ts CHANGED
@@ -9,6 +9,7 @@ import Exchange, {
9
9
  } from "./Exchange";
10
10
  import { decodeSwapPayload, decodePayloadProtobuf } from "./SwapUtils";
11
11
  import { decodeSellPayload } from "./SellUtils";
12
+ import { decodeFundPayload } from "./FundUtils";
12
13
 
13
14
  export {
14
15
  createExchange,
@@ -21,6 +22,7 @@ export {
21
22
  isExchangeTypeNg,
22
23
  PayloadSignatureComputedFormat,
23
24
  decodeSellPayload,
25
+ decodeFundPayload,
24
26
  };
25
27
 
26
28
  export default Exchange;