@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.
- package/.turbo/turbo-build.log +2 -2
- package/CHANGELOG.md +12 -0
- package/lib/FundUtils.d.ts +11 -0
- package/lib/FundUtils.d.ts.map +1 -0
- package/lib/FundUtils.js +49 -0
- package/lib/FundUtils.js.map +1 -0
- package/lib/SellUtils.d.ts +1 -0
- package/lib/SellUtils.d.ts.map +1 -1
- package/lib/SellUtils.js.map +1 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -1
- package/lib/index.js.map +1 -1
- package/lib-es/FundUtils.d.ts +11 -0
- package/lib-es/FundUtils.d.ts.map +1 -0
- package/lib-es/FundUtils.js +19 -0
- package/lib-es/FundUtils.js.map +1 -0
- package/lib-es/SellUtils.d.ts +1 -0
- package/lib-es/SellUtils.d.ts.map +1 -1
- package/lib-es/SellUtils.js.map +1 -1
- package/lib-es/index.d.ts +2 -1
- package/lib-es/index.d.ts.map +1 -1
- package/lib-es/index.js +2 -1
- package/lib-es/index.js.map +1 -1
- package/package.json +1 -1
- package/src/FundUtils.ts +34 -0
- package/src/SellUtils.ts +1 -0
- package/src/index.ts +2 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
|
-
> @ledgerhq/hw-app-exchange@0.
|
|
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.
|
|
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"}
|
package/lib/FundUtils.js
ADDED
|
@@ -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"}
|
package/lib/SellUtils.d.ts
CHANGED
package/lib/SellUtils.d.ts.map
CHANGED
|
@@ -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;
|
|
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"}
|
package/lib/SellUtils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SellUtils.js","sourceRoot":"","sources":["../src/SellUtils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4DAAkC;AAClC,oEAAsD;AACtD,iDAA+C;
|
|
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
|
-
|
|
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
|
package/lib/index.d.ts.map
CHANGED
|
@@ -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;
|
|
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"}
|
package/lib-es/SellUtils.d.ts
CHANGED
|
@@ -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;
|
|
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"}
|
package/lib-es/SellUtils.js.map
CHANGED
|
@@ -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;
|
|
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
|
-
|
|
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
|
package/lib-es/index.d.ts.map
CHANGED
|
@@ -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
|
-
|
|
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
|
package/lib-es/index.js.map
CHANGED
|
@@ -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
package/src/FundUtils.ts
ADDED
|
@@ -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
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;
|