@ledgerhq/coin-ton 0.5.2 → 0.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/.turbo/turbo-build.log +2 -2
  2. package/CHANGELOG.md +14 -0
  3. package/lib/__tests__/fixtures/api.fixtures.d.ts +1 -1
  4. package/lib/__tests__/fixtures/api.fixtures.d.ts.map +1 -1
  5. package/lib/__tests__/fixtures/common.fixtures.js +4 -1
  6. package/lib/__tests__/fixtures/common.fixtures.js.map +1 -1
  7. package/lib/__tests__/integration/bridge.integration.test.js +2 -3
  8. package/lib/__tests__/integration/bridge.integration.test.js.map +1 -1
  9. package/lib/__tests__/unit/api.unit.test.js +18 -27
  10. package/lib/__tests__/unit/api.unit.test.js.map +1 -1
  11. package/lib/__tests__/unit/broadcast.unit.test.js +10 -13
  12. package/lib/__tests__/unit/broadcast.unit.test.js.map +1 -1
  13. package/lib/__tests__/unit/createTransaction.unit.test.js +2 -11
  14. package/lib/__tests__/unit/createTransaction.unit.test.js.map +1 -1
  15. package/lib/__tests__/unit/deviceTransactionConfig.unit.test.js +19 -22
  16. package/lib/__tests__/unit/deviceTransactionConfig.unit.test.js.map +1 -1
  17. package/lib/__tests__/unit/estimateMaxSpendable.unit.test.js +6 -15
  18. package/lib/__tests__/unit/estimateMaxSpendable.unit.test.js.map +1 -1
  19. package/lib/__tests__/unit/getTransactionStatus.unit.test.js +58 -48
  20. package/lib/__tests__/unit/getTransactionStatus.unit.test.js.map +1 -1
  21. package/lib/__tests__/unit/hw-getAddress.unit.test.js +12 -25
  22. package/lib/__tests__/unit/hw-getAddress.unit.test.js.map +1 -1
  23. package/lib/__tests__/unit/prepareTransaction.unit.test.js +46 -34
  24. package/lib/__tests__/unit/prepareTransaction.unit.test.js.map +1 -1
  25. package/lib/__tests__/unit/signOperation.unit.test.js +11 -22
  26. package/lib/__tests__/unit/signOperation.unit.test.js.map +1 -1
  27. package/lib/__tests__/unit/txn.unit.test.js +32 -39
  28. package/lib/__tests__/unit/txn.unit.test.js.map +1 -1
  29. package/lib/__tests__/unit/utils.unit.test.js +22 -8
  30. package/lib/__tests__/unit/utils.unit.test.js.map +1 -1
  31. package/lib/bridge/bridgeHelpers/api.js +65 -88
  32. package/lib/bridge/bridgeHelpers/api.js.map +1 -1
  33. package/lib/bridge/bridgeHelpers/txn.js +52 -66
  34. package/lib/bridge/bridgeHelpers/txn.js.map +1 -1
  35. package/lib/bridge/js.js +1 -10
  36. package/lib/bridge/js.js.map +1 -1
  37. package/lib/broadcast.js +3 -12
  38. package/lib/broadcast.js.map +1 -1
  39. package/lib/cli-transaction.js +6 -1
  40. package/lib/cli-transaction.js.map +1 -1
  41. package/lib/config.js +1 -1
  42. package/lib/config.js.map +1 -1
  43. package/lib/estimateMaxSpendable.js +7 -16
  44. package/lib/estimateMaxSpendable.js.map +1 -1
  45. package/lib/getTransactionStatus.js +14 -18
  46. package/lib/getTransactionStatus.js.map +1 -1
  47. package/lib/hw-getAddress.js +6 -15
  48. package/lib/hw-getAddress.js.map +1 -1
  49. package/lib/hw-signMessage.js +3 -12
  50. package/lib/hw-signMessage.js.map +1 -1
  51. package/lib/prepareTransaction.js +5 -15
  52. package/lib/prepareTransaction.js.map +1 -1
  53. package/lib/signOperation.js +23 -35
  54. package/lib/signOperation.js.map +1 -1
  55. package/lib/specs.js +12 -18
  56. package/lib/specs.js.map +1 -1
  57. package/lib/synchronisation.js +46 -55
  58. package/lib/synchronisation.js.map +1 -1
  59. package/lib/transaction.js +13 -2
  60. package/lib/transaction.js.map +1 -1
  61. package/lib/utils.js +11 -20
  62. package/lib/utils.js.map +1 -1
  63. package/lib-es/__tests__/fixtures/api.fixtures.d.ts +1 -1
  64. package/lib-es/__tests__/fixtures/api.fixtures.d.ts.map +1 -1
  65. package/lib-es/__tests__/fixtures/common.fixtures.js +4 -1
  66. package/lib-es/__tests__/fixtures/common.fixtures.js.map +1 -1
  67. package/lib-es/__tests__/integration/bridge.integration.test.js +2 -3
  68. package/lib-es/__tests__/integration/bridge.integration.test.js.map +1 -1
  69. package/lib-es/__tests__/unit/api.unit.test.js +18 -27
  70. package/lib-es/__tests__/unit/api.unit.test.js.map +1 -1
  71. package/lib-es/__tests__/unit/broadcast.unit.test.js +10 -13
  72. package/lib-es/__tests__/unit/broadcast.unit.test.js.map +1 -1
  73. package/lib-es/__tests__/unit/createTransaction.unit.test.js +2 -11
  74. package/lib-es/__tests__/unit/createTransaction.unit.test.js.map +1 -1
  75. package/lib-es/__tests__/unit/deviceTransactionConfig.unit.test.js +19 -22
  76. package/lib-es/__tests__/unit/deviceTransactionConfig.unit.test.js.map +1 -1
  77. package/lib-es/__tests__/unit/estimateMaxSpendable.unit.test.js +6 -15
  78. package/lib-es/__tests__/unit/estimateMaxSpendable.unit.test.js.map +1 -1
  79. package/lib-es/__tests__/unit/getTransactionStatus.unit.test.js +58 -48
  80. package/lib-es/__tests__/unit/getTransactionStatus.unit.test.js.map +1 -1
  81. package/lib-es/__tests__/unit/hw-getAddress.unit.test.js +12 -25
  82. package/lib-es/__tests__/unit/hw-getAddress.unit.test.js.map +1 -1
  83. package/lib-es/__tests__/unit/prepareTransaction.unit.test.js +46 -34
  84. package/lib-es/__tests__/unit/prepareTransaction.unit.test.js.map +1 -1
  85. package/lib-es/__tests__/unit/signOperation.unit.test.js +11 -22
  86. package/lib-es/__tests__/unit/signOperation.unit.test.js.map +1 -1
  87. package/lib-es/__tests__/unit/txn.unit.test.js +32 -39
  88. package/lib-es/__tests__/unit/txn.unit.test.js.map +1 -1
  89. package/lib-es/__tests__/unit/utils.unit.test.js +22 -8
  90. package/lib-es/__tests__/unit/utils.unit.test.js.map +1 -1
  91. package/lib-es/bridge/bridgeHelpers/api.js +65 -88
  92. package/lib-es/bridge/bridgeHelpers/api.js.map +1 -1
  93. package/lib-es/bridge/bridgeHelpers/txn.js +52 -66
  94. package/lib-es/bridge/bridgeHelpers/txn.js.map +1 -1
  95. package/lib-es/bridge/js.js +1 -10
  96. package/lib-es/bridge/js.js.map +1 -1
  97. package/lib-es/broadcast.js +3 -12
  98. package/lib-es/broadcast.js.map +1 -1
  99. package/lib-es/cli-transaction.js +6 -1
  100. package/lib-es/cli-transaction.js.map +1 -1
  101. package/lib-es/config.js +1 -1
  102. package/lib-es/config.js.map +1 -1
  103. package/lib-es/estimateMaxSpendable.js +7 -16
  104. package/lib-es/estimateMaxSpendable.js.map +1 -1
  105. package/lib-es/getTransactionStatus.js +14 -18
  106. package/lib-es/getTransactionStatus.js.map +1 -1
  107. package/lib-es/hw-getAddress.js +6 -15
  108. package/lib-es/hw-getAddress.js.map +1 -1
  109. package/lib-es/hw-signMessage.js +3 -12
  110. package/lib-es/hw-signMessage.js.map +1 -1
  111. package/lib-es/prepareTransaction.js +5 -15
  112. package/lib-es/prepareTransaction.js.map +1 -1
  113. package/lib-es/signOperation.js +23 -35
  114. package/lib-es/signOperation.js.map +1 -1
  115. package/lib-es/specs.js +12 -18
  116. package/lib-es/specs.js.map +1 -1
  117. package/lib-es/synchronisation.js +46 -55
  118. package/lib-es/synchronisation.js.map +1 -1
  119. package/lib-es/transaction.js +13 -2
  120. package/lib-es/transaction.js.map +1 -1
  121. package/lib-es/utils.js +11 -20
  122. package/lib-es/utils.js.map +1 -1
  123. package/package.json +4 -4
  124. package/tsconfig.json +0 -1
@@ -1,12 +1,3 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  import { AmountRequired, InvalidAddress, InvalidAddressBecauseDestinationIsAlsoSource, NotEnoughBalance, RecipientRequired, } from "@ledgerhq/errors";
11
2
  import BigNumber from "bignumber.js";
12
3
  import { TonCommentInvalid, TonExcessFee } from "../../errors";
@@ -14,81 +5,100 @@ import getTransactionStatus from "../../getTransactionStatus";
14
5
  import { account, transaction as baseTransaction, jettonTransaction, } from "../fixtures/common.fixtures";
15
6
  describe("getTransactionStatus", () => {
16
7
  describe("Recipient", () => {
17
- it("should detect the missing recipient and have an error", () => __awaiter(void 0, void 0, void 0, function* () {
18
- const transaction = Object.assign(Object.assign({}, baseTransaction), { recipient: "" });
19
- const res = yield getTransactionStatus(account, transaction);
8
+ it("should detect the missing recipient and have an error", async () => {
9
+ const transaction = { ...baseTransaction, recipient: "" };
10
+ const res = await getTransactionStatus(account, transaction);
20
11
  expect(res.errors).toEqual(expect.objectContaining({
21
12
  recipient: new RecipientRequired(),
22
13
  }));
23
- }));
24
- it("should detect the incorrect recipient and have an error", () => __awaiter(void 0, void 0, void 0, function* () {
25
- const transaction = Object.assign(Object.assign({}, baseTransaction), { recipient: "isInvalid" });
26
- const res = yield getTransactionStatus(account, transaction);
14
+ });
15
+ it("should detect the incorrect recipient and have an error", async () => {
16
+ const transaction = { ...baseTransaction, recipient: "isInvalid" };
17
+ const res = await getTransactionStatus(account, transaction);
27
18
  expect(res.errors).toEqual(expect.objectContaining({
28
19
  recipient: new InvalidAddress("", {
29
20
  currencyName: account.currency.name,
30
21
  }),
31
22
  }));
32
- }));
33
- it("should detect the recipient and the sender are the same and have an error", () => __awaiter(void 0, void 0, void 0, function* () {
34
- const transaction = Object.assign(Object.assign({}, baseTransaction), { recipient: "UQDzd8aeBOU-jqYw_ZSuZjceI5p-F4b7HMprAsUJAtRPbMol" });
35
- const res = yield getTransactionStatus(account, transaction);
23
+ });
24
+ it("should detect the recipient and the sender are the same and have an error", async () => {
25
+ const transaction = {
26
+ ...baseTransaction,
27
+ recipient: "UQDzd8aeBOU-jqYw_ZSuZjceI5p-F4b7HMprAsUJAtRPbMol",
28
+ };
29
+ const res = await getTransactionStatus(account, transaction);
36
30
  expect(res.errors).toEqual(expect.objectContaining({
37
31
  recipient: new InvalidAddressBecauseDestinationIsAlsoSource("", {
38
32
  currencyName: account.currency.name,
39
33
  }),
40
34
  }));
41
- }));
35
+ });
42
36
  });
43
37
  describe("Sender", () => {
44
- it("should detect the sender is not correct and have an error", () => __awaiter(void 0, void 0, void 0, function* () {
45
- const tempAccount = Object.assign(Object.assign({}, account), { freshAddress: "isInvalid" });
46
- const res = yield getTransactionStatus(tempAccount, baseTransaction);
38
+ it("should detect the sender is not correct and have an error", async () => {
39
+ const tempAccount = { ...account, freshAddress: "isInvalid" };
40
+ const res = await getTransactionStatus(tempAccount, baseTransaction);
47
41
  expect(res.errors).toEqual(expect.objectContaining({
48
42
  sender: new InvalidAddress(),
49
43
  }));
50
- }));
44
+ });
51
45
  });
52
46
  describe("Amount", () => {
53
- it("should detect the amount is missing and have an error", () => __awaiter(void 0, void 0, void 0, function* () {
54
- const transaction = Object.assign(Object.assign({}, baseTransaction), { amount: new BigNumber(0) });
55
- const res = yield getTransactionStatus(account, transaction);
47
+ it("should detect the amount is missing and have an error", async () => {
48
+ const transaction = { ...baseTransaction, amount: new BigNumber(0) };
49
+ const res = await getTransactionStatus(account, transaction);
56
50
  expect(res.errors).toEqual(expect.objectContaining({
57
51
  amount: new AmountRequired(),
58
52
  }));
59
- }));
60
- it("should detect the amount is greater than the spendable amount and have an error", () => __awaiter(void 0, void 0, void 0, function* () {
61
- const transaction = Object.assign(Object.assign({}, baseTransaction), { amount: BigNumber(1000000002), fees: new BigNumber("20") });
62
- const res = yield getTransactionStatus(account, transaction);
53
+ });
54
+ it("should detect the amount is greater than the spendable amount and have an error", async () => {
55
+ const transaction = {
56
+ ...baseTransaction,
57
+ amount: BigNumber(1000000002),
58
+ fees: new BigNumber("20"),
59
+ };
60
+ const res = await getTransactionStatus(account, transaction);
63
61
  expect(res.errors).toEqual(expect.objectContaining({
64
62
  amount: new NotEnoughBalance(),
65
63
  }));
66
- }));
67
- it("should detect the amount is greater than the spendable amount of the token account and have an error", () => __awaiter(void 0, void 0, void 0, function* () {
68
- const transaction = Object.assign(Object.assign({}, jettonTransaction), { amount: BigNumber(1000000002), fees: new BigNumber("20") });
69
- const res = yield getTransactionStatus(account, transaction);
64
+ });
65
+ it("should detect the amount is greater than the spendable amount of the token account and have an error", async () => {
66
+ const transaction = {
67
+ ...jettonTransaction,
68
+ amount: BigNumber(1000000002),
69
+ fees: new BigNumber("20"),
70
+ };
71
+ const res = await getTransactionStatus(account, transaction);
70
72
  expect(res.errors).toEqual(expect.objectContaining({
71
73
  amount: new NotEnoughBalance(),
72
74
  }));
73
- }));
74
- it("should detect the transaction is a jetton transfer and have a warning", () => __awaiter(void 0, void 0, void 0, function* () {
75
- const transaction = Object.assign(Object.assign({}, jettonTransaction), { amount: BigNumber(1000000002), fees: new BigNumber("20") });
76
- const res = yield getTransactionStatus(account, transaction);
75
+ });
76
+ it("should detect the transaction is a jetton transfer and have a warning", async () => {
77
+ const transaction = {
78
+ ...jettonTransaction,
79
+ amount: BigNumber(1000000002),
80
+ fees: new BigNumber("20"),
81
+ };
82
+ const res = await getTransactionStatus(account, transaction);
77
83
  expect(res.warnings).toEqual(expect.objectContaining({
78
84
  amount: new TonExcessFee(),
79
85
  }));
80
- }));
86
+ });
81
87
  describe("Comment", () => {
82
- it("should detect the comment is not valid and have an error", () => __awaiter(void 0, void 0, void 0, function* () {
83
- const transaction = Object.assign(Object.assign({}, baseTransaction), { amount: new BigNumber("1"), comment: { isEncrypted: false, text: "comment\nInvalid" } });
84
- const res = yield getTransactionStatus(account, transaction);
88
+ it("should detect the comment is not valid and have an error", async () => {
89
+ const transaction = {
90
+ ...baseTransaction,
91
+ amount: new BigNumber("1"),
92
+ comment: { isEncrypted: false, text: "comment\nInvalid" },
93
+ };
94
+ const res = await getTransactionStatus(account, transaction);
85
95
  expect(res.errors).toEqual(expect.objectContaining({
86
96
  transaction: new TonCommentInvalid(),
87
97
  }));
88
- }));
98
+ });
89
99
  });
90
100
  describe("Successful transaction", () => {
91
- it("should not have errors", () => __awaiter(void 0, void 0, void 0, function* () {
101
+ it("should not have errors", async () => {
92
102
  const successfulResult = {
93
103
  amount: baseTransaction.amount,
94
104
  errors: {},
@@ -96,9 +106,9 @@ describe("getTransactionStatus", () => {
96
106
  estimatedFees: baseTransaction.fees,
97
107
  totalSpent: baseTransaction.amount.plus(baseTransaction.fees),
98
108
  };
99
- const res = yield getTransactionStatus(account, baseTransaction);
109
+ const res = await getTransactionStatus(account, baseTransaction);
100
110
  expect(res).toEqual(successfulResult);
101
- }));
111
+ });
102
112
  });
103
113
  });
104
114
  });
@@ -1 +1 @@
1
- {"version":3,"file":"getTransactionStatus.unit.test.js","sourceRoot":"","sources":["../../../src/__tests__/unit/getTransactionStatus.unit.test.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EACL,cAAc,EACd,cAAc,EACd,4CAA4C,EAC5C,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,oBAAoB,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EACL,OAAO,EACP,WAAW,IAAI,eAAe,EAC9B,iBAAiB,GAClB,MAAM,6BAA6B,CAAC;AAErC,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;IACpC,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;QACzB,EAAE,CAAC,uDAAuD,EAAE,GAAS,EAAE;YACrE,MAAM,WAAW,mCAAQ,eAAe,KAAE,SAAS,EAAE,EAAE,GAAE,CAAC;YAC1D,MAAM,GAAG,GAAG,MAAM,oBAAoB,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;YAC7D,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,OAAO,CACxB,MAAM,CAAC,gBAAgB,CA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CAAC;QACL,CAAC,CAAC,CAAC;QAEH,QAAQ,CAAC,wBAAwB,EAAE,GAAG,EAAE;YACtC,EAAE,CAAC,wBAAwB,EAAE,GAAS,EAAE;gBACtC,MAAM,gBAAgB,GAAG;oBACvB,MAAM,EAAE,eAAe,CAAC,MAAM;oBAC9B,MAAM,EAAE,EAAE;oBACV,QAAQ,EAAE,EAAE;oBACZ,aAAa,EAAE,eAAe,CAAC,IAAI;oBACnC,UAAU,EAAE,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC;iBAC9D,CAAC;gBACF,MAAM,GAAG,GAAG,MAAM,oBAAoB,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;gBACjE,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;YACxC,CAAC,CAAA,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"getTransactionStatus.unit.test.js","sourceRoot":"","sources":["../../../src/__tests__/unit/getTransactionStatus.unit.test.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,cAAc,EACd,4CAA4C,EAC5C,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,oBAAoB,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EACL,OAAO,EACP,WAAW,IAAI,eAAe,EAC9B,iBAAiB,GAClB,MAAM,6BAA6B,CAAC;AAErC,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;IACpC,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;QACzB,EAAE,CAAC,uDAAuD,EAAE,KAAK,IAAI,EAAE;YACrE,MAAM,WAAW,GAAG,EAAE,GAAG,eAAe,E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AE,IAAI,EAAE,kBAAkB,EAAE;iBAC1D,CAAC;gBACF,MAAM,GAAG,GAAG,MAAM,oBAAoB,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;gBAC7D,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,OAAO,CACxB,MAAM,CAAC,gBAAgB,CAAC;oBACtB,WAAW,EAAE,IAAI,iBAAiB,EAAE;iBACrC,CAAC,CACH,CAAC;YACJ,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,QAAQ,CAAC,wBAAwB,EAAE,GAAG,EAAE;YACtC,EAAE,CAAC,wBAAwB,EAAE,KAAK,IAAI,EAAE;gBACtC,MAAM,gBAAgB,GAAG;oBACvB,MAAM,EAAE,eAAe,CAAC,MAAM;oBAC9B,MAAM,EAAE,EAAE;oBACV,QAAQ,EAAE,EAAE;oBACZ,aAAa,EAAE,eAAe,CAAC,IAAI;oBACnC,UAAU,EAAE,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC;iBAC9D,CAAC;gBACF,MAAM,GAAG,GAAG,MAAM,oBAAoB,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;gBACjE,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;YACxC,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,28 +1,15 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets";
11
2
  import resolver from "../../hw-getAddress";
12
3
  import { getLedgerTonPath } from "../../utils";
13
4
  const address = "0xc3f95102d5c8f2c83e49ce3acfb905edfb7f37de";
14
5
  const publicKey = "mockedPublicKey";
15
- const spyGetAddress = jest.fn().mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () {
16
- return Promise.resolve({
17
- publicKey,
18
- address: address.toLowerCase(),
19
- });
6
+ const spyGetAddress = jest.fn().mockImplementation(async () => Promise.resolve({
7
+ publicKey,
8
+ address: address.toLowerCase(),
20
9
  }));
21
- const spyValidateAddress = jest.fn().mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () {
22
- return Promise.resolve({
23
- publicKey,
24
- address: address.toLowerCase(),
25
- });
10
+ const spyValidateAddress = jest.fn().mockImplementation(async () => Promise.resolve({
11
+ publicKey,
12
+ address: address.toLowerCase(),
26
13
  }));
27
14
  const mockSignerFactory = (_, fn) => fn({
28
15
  getAddress: spyGetAddress,
@@ -30,9 +17,9 @@ const mockSignerFactory = (_, fn) => fn({
30
17
  signTransaction: jest.fn(),
31
18
  });
32
19
  describe("hw-getAddress", () => {
33
- it("should return an encoded address and a public key when verifiy is false", () => __awaiter(void 0, void 0, void 0, function* () {
20
+ it("should return an encoded address and a public key when verifiy is false", async () => {
34
21
  const getAddress = resolver(mockSignerFactory);
35
- const response = yield getAddress("deviceId", {
22
+ const response = await getAddress("deviceId", {
36
23
  path: "44'/607'/0'/0'/0'/0'",
37
24
  verify: false,
38
25
  currency: getCryptoCurrencyById("ton"),
@@ -43,10 +30,10 @@ describe("hw-getAddress", () => {
43
30
  expect(spyGetAddress).toHaveBeenCalledWith(getLedgerTonPath("44'/607'/0'/0'/0'/0'"), {
44
31
  bounceable: false,
45
32
  });
46
- }));
47
- it("should return an encoded address and a public key when verifiy is true", () => __awaiter(void 0, void 0, void 0, function* () {
33
+ });
34
+ it("should return an encoded address and a public key when verifiy is true", async () => {
48
35
  const getAddress = resolver(mockSignerFactory);
49
- const response = yield getAddress("deviceId", {
36
+ const response = await getAddress("deviceId", {
50
37
  path: "44'/607'/0'/0'/0'/0'",
51
38
  verify: true,
52
39
  currency: getCryptoCurrencyById("ton"),
@@ -57,6 +44,6 @@ describe("hw-getAddress", () => {
57
44
  expect(spyValidateAddress).toHaveBeenCalledWith(getLedgerTonPath("44'/607'/0'/0'/0'/0'"), {
58
45
  bounceable: false,
59
46
  });
60
- }));
47
+ });
61
48
  });
62
49
  //# sourceMappingURL=hw-getAddress.unit.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"hw-getAddress.unit.test.js","sourceRoot":"","sources":["../../../src/__tests__/unit/hw-getAddress.unit.test.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,QAAQ,MAAM,qBAAqB,CAAC;AAE3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,MAAM,OAAO,GAAG,4CAA4C,CAAC;AAC7D,MAAM,SAAS,GAAG,iBAAiB,CAAC;AACpC,MAAM,aAAa,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC,kBAAkB,CAAC,GAAS,EAAE;IAC5D,OAAA,OAAO,CAAC,OAAO,CAAC;QACd,SAAS;QACT,OAAO,EAAE,OAAO,CAAC,WAAW,EAAE;KAC/B,CAAC,CAAA;EAAA,CACH,CAAC;AACF,MAAM,kBAAkB,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC,kBAAkB,CAAC,GAAS,EAAE;IACjE,OAAA,OAAO,CAAC,OAAO,CAAC;QACd,SAAS;QACT,OAAO,EAAE,OAAO,CAAC,WAAW,EAAE;KAC/B,CAAC,CAAA;EAAA,CACH,CAAC;AAEF,MAAM,iBAAiB,GAAG,CAAI,CAAS,EAAE,EAAqC,EAAc,EAAE,CAC5F,EAAE,CAAC;IACD,UAAU,EAAE,aAAa;I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,GAAG,MAAM,UAAU,CAAC,UAAU,EAAE;YAC5C,IAAI,EAAE,sBAAsB;YAC5B,MAAM,EAAE,KAAK;YACb,QAAQ,EAAE,qBAAqB,CAAC,KAAK,CAAC;YACtC,cAAc,EAAE,KAAK;SACtB,CAAC,CAAC;QACH,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACvC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC3C,MAAM,CAAC,aAAa,CAAC,CAAC,oBAAoB,CAAC,gBAAgB,CAAC,sBAAsB,CAAC,EAAE;YACnF,UAAU,EAAE,KAAK;SAClB,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,wEAAwE,EAAE,KAAK,IAAI,EAAE;QACtF,MAAM,UAAU,GAAG,QAAQ,CAAC,iBAAiB,CAAC,CAAC;QAC/C,MAAM,QAAQ,GAAG,MAAM,UAAU,CAAC,UAAU,EAAE;YAC5C,IAAI,EAAE,sBAAsB;YAC5B,MAAM,EAAE,IAAI;YACZ,QAAQ,EAAE,qBAAqB,CAAC,KAAK,CAAC;YACtC,cAAc,EAAE,KAAK;SACtB,CAAC,CAAC;QACH,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACvC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC3C,MAAM,CAAC,kBAAkB,CAAC,CAAC,oBAAoB,CAAC,gBAAgB,CAAC,sBAAsB,CAAC,EAAE;YACxF,UAAU,EAAE,KAAK;SAClB,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,12 +1,3 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  import { estimateFee, fetchAccountInfo } from "../../bridge/bridgeHelpers/api";
11
2
  import prepareTransaction from "../../prepareTransaction";
12
3
  import { account, accountInfo, transaction as baseTransaction, fees, jettonTransaction, totalFees, } from "../fixtures/common.fixtures";
@@ -19,35 +10,56 @@ describe("prepareTransaction", () => {
19
10
  fetchEstimateFeeMock.mockReturnValue(Promise.resolve(fees));
20
11
  });
21
12
  describe("Ton Transaction", () => {
22
- it("should return the transaction with the updated amount and fees", () => __awaiter(void 0, void 0, void 0, function* () {
23
- const transaction = yield prepareTransaction(account, baseTransaction);
24
- expect(transaction).toEqual(Object.assign(Object.assign({}, baseTransaction), { fees: totalFees }));
25
- }));
26
- it("should preserve the reference when no change is detected on the transaction", () => __awaiter(void 0, void 0, void 0, function* () {
27
- const transaction = yield prepareTransaction(account, Object.assign({}, baseTransaction));
28
- const transaction2 = yield prepareTransaction(account, transaction);
13
+ it("should return the transaction with the updated amount and fees", async () => {
14
+ const transaction = await prepareTransaction(account, baseTransaction);
15
+ expect(transaction).toEqual({
16
+ ...baseTransaction,
17
+ fees: totalFees,
18
+ });
19
+ });
20
+ it("should preserve the reference when no change is detected on the transaction", async () => {
21
+ const transaction = await prepareTransaction(account, { ...baseTransaction });
22
+ const transaction2 = await prepareTransaction(account, transaction);
29
23
  expect(transaction).toBe(transaction2);
30
- }));
31
- it("should create a coin transaction using the spendableBalance in the account", () => __awaiter(void 0, void 0, void 0, function* () {
32
- const transaction = yield prepareTransaction(account, Object.assign(Object.assign({}, baseTransaction), { useAllAmount: true }));
33
- expect(transaction).toEqual(Object.assign(Object.assign({}, baseTransaction), { useAllAmount: true, fees: totalFees, amount: account.spendableBalance.minus(totalFees) }));
34
- }));
24
+ });
25
+ it("should create a coin transaction using the spendableBalance in the account", async () => {
26
+ const transaction = await prepareTransaction(account, {
27
+ ...baseTransaction,
28
+ useAllAmount: true,
29
+ });
30
+ expect(transaction).toEqual({
31
+ ...baseTransaction,
32
+ useAllAmount: true,
33
+ fees: totalFees,
34
+ amount: account.spendableBalance.minus(totalFees),
35
+ });
36
+ });
35
37
  });
36
38
  describe("Jetton Transaction", () => {
37
- it("should return the transaction with the updated amount and fees", () => __awaiter(void 0, void 0, void 0, function* () {
38
- const transaction = yield prepareTransaction(account, jettonTransaction);
39
- expect(transaction).toEqual(Object.assign(Object.assign({}, jettonTransaction), { fees: totalFees }));
40
- }));
41
- it("should preserve the reference when no change is detected on the transaction", () => __awaiter(void 0, void 0, void 0, function* () {
42
- const transaction = yield prepareTransaction(account, Object.assign({}, jettonTransaction));
43
- const transaction2 = yield prepareTransaction(account, transaction);
39
+ it("should return the transaction with the updated amount and fees", async () => {
40
+ const transaction = await prepareTransaction(account, jettonTransaction);
41
+ expect(transaction).toEqual({
42
+ ...jettonTransaction,
43
+ fees: totalFees,
44
+ });
45
+ });
46
+ it("should preserve the reference when no change is detected on the transaction", async () => {
47
+ const transaction = await prepareTransaction(account, { ...jettonTransaction });
48
+ const transaction2 = await prepareTransaction(account, transaction);
44
49
  expect(transaction).toBe(transaction2);
45
- }));
46
- it("should create a coin transaction using the spendableBalance in the account", () => __awaiter(void 0, void 0, void 0, function* () {
47
- var _a;
48
- const transaction = yield prepareTransaction(account, Object.assign(Object.assign({}, jettonTransaction), { useAllAmount: true }));
49
- expect(transaction).toEqual(Object.assign(Object.assign({}, jettonTransaction), { useAllAmount: true, fees: totalFees, amount: (_a = account.subAccounts) === null || _a === void 0 ? void 0 : _a[0].spendableBalance }));
50
- }));
50
+ });
51
+ it("should create a coin transaction using the spendableBalance in the account", async () => {
52
+ const transaction = await prepareTransaction(account, {
53
+ ...jettonTransaction,
54
+ useAllAmount: true,
55
+ });
56
+ expect(transaction).toEqual({
57
+ ...jettonTransaction,
58
+ useAllAmount: true,
59
+ fees: totalFees,
60
+ amount: account.subAccounts?.[0].spendableBalance,
61
+ });
62
+ });
51
63
  });
52
64
  });
53
65
  //# sourceMappingURL=prepareTransaction.unit.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"prepareTransaction.unit.test.js","sourceRoot":"","sources":["../../../src/__tests__/unit/prepareTransaction.unit.test.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAC/E,OAAO,kBAAkB,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EACL,OAAO,EACP,WAAW,EACX,WAAW,IAAI,eAAe,EAC9B,IAAI,EACJ,iBAAiB,EACjB,SAAS,GACV,MAAM,6BAA6B,CAAC;AAErC,IAAI,CAAC,IAAI,CAAC,gCAAgC,CAAC,CAAC;AAE5C,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;IAClC,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,oBAAoB,GAAG,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;QAC3D,oBAAoB,CAAC,eAAe,CAAC,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;QACnE,MAAM,oBAAoB,GAAG,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QACtD,oBAAoB,CAAC,eAAe,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;IAC9D,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;QAC/B,EAAE,CAAC,gEAAgE,EAAE,GAAS,EAAE;YAC9E,MAAM,WAAW,GAAG,MAAM,kBAAkB,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;YAEvE,MAAM,CAAC,WAAW,CAAC,CAAC,OAAO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CAAC,CAAC;YAEpE,MAAM,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACzC,CAAC,CAAA,CAAC,CAAC;QAEH,EAAE,CAAC,4EAA4E,EAAE,GAAS,EAAE;;YAC1F,MAAM,WAAW,GAAG,MAAM,kBAAkB,CAAC,OAAO,kCAC/C,iBAAiB,KACpB,YAAY,EAAE,IAAI,IAClB,CAAC;YAEH,MAAM,CAAC,WAAW,CAAC,CAAC,OAAO,iCACtB,iBAAiB,KACpB,YAAY,EAAE,IAAI,EAClB,IAAI,EAAE,SAAS,EACf,MAAM,EAAE,MAAA,OAAO,CAAC,WAAW,0CAAG,CAAC,EAAE,gBAAgB,IACjD,CAAC;QACL,CAAC,CAAA,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"prepareTransaction.unit.test.js","sourceRoot":"","sources":["../../../src/__tests__/unit/prepareTransaction.unit.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAC/E,OAAO,kBAAkB,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EACL,OAAO,EACP,WAAW,EACX,WAAW,IAAI,eAAe,EAC9B,IAAI,EACJ,iBAAiB,EACjB,SAAS,GACV,MAAM,6BAA6B,CAAC;AAErC,IAAI,CAAC,IAAI,CAAC,gCAAgC,CAAC,CAAC;AAE5C,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;IAClC,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,oBAAoB,GAAG,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;QAC3D,oBAAoB,CAAC,eAAe,CAAC,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;QACnE,MAAM,oBAAoB,GAAG,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QACtD,oBAAoB,CAAC,eAAe,CAAC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,GAAG,MAAM,kBAAkB,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC;YAEzE,MAAM,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC;gBAC1B,GAAG,iBAAiB;gBACpB,IAAI,EAAE,SAAS;aAChB,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,6EAA6E,EAAE,KAAK,IAAI,EAAE;YAC3F,MAAM,WAAW,GAAG,MAAM,kBAAkB,CAAC,OAAO,EAAE,EAAE,GAAG,iBAAiB,EAAE,CAAC,CAAC;YAChF,MAAM,YAAY,GAAG,MAAM,kBAAkB,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;YAEpE,MAAM,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACzC,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,4EAA4E,EAAE,KAAK,IAAI,EAAE;YAC1F,MAAM,WAAW,GAAG,MAAM,kBAAkB,CAAC,OAAO,EAAE;gBACpD,GAAG,iBAAiB;gBACpB,YAAY,EAAE,IAAI;aACnB,CAAC,CAAC;YAEH,MAAM,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC;gBAC1B,GAAG,iBAAiB;gBACpB,YAAY,EAAE,IAAI;gBAClB,IAAI,EAAE,SAAS;gBACf,MAAM,EAAE,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC,gBAAgB;aAClD,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,30 +1,19 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  import { Address, Cell, beginCell, storeMessage } from "@ton/core";
11
2
  import BigNumber from "bignumber.js";
12
3
  import { fetchAccountInfo } from "../../bridge/bridgeHelpers/api";
13
4
  import { buildSignOperation } from "../../signOperation";
14
5
  import { account, accountInfo, totalFees, transaction } from "../fixtures/common.fixtures";
15
6
  jest.mock("../../bridge/bridgeHelpers/api");
16
- const spySignTransaction = jest.fn().mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () {
17
- return Promise.resolve(beginCell()
18
- .store(storeMessage({
19
- info: {
20
- type: "external-in",
21
- dest: Address.parse("EQDzd8aeBOU-jqYw_ZSuZjceI5p-F4b7HMprAsUJAtRPbJfg"),
22
- importFee: BigInt(0),
23
- },
24
- body: new Cell(),
25
- }))
26
- .endCell());
27
- }));
7
+ const spySignTransaction = jest.fn().mockImplementation(async () => Promise.resolve(beginCell()
8
+ .store(storeMessage({
9
+ info: {
10
+ type: "external-in",
11
+ dest: Address.parse("EQDzd8aeBOU-jqYw_ZSuZjceI5p-F4b7HMprAsUJAtRPbJfg"),
12
+ importFee: BigInt(0),
13
+ },
14
+ body: new Cell(),
15
+ }))
16
+ .endCell()));
28
17
  const mockSignerContext = (_, fn) => {
29
18
  return fn({
30
19
  signTransaction: spySignTransaction,
@@ -41,7 +30,7 @@ describe("signOperation", () => {
41
30
  const signOperation = buildSignOperation(mockSignerContext);
42
31
  const signOpObservable = signOperation({
43
32
  account,
44
- transaction: Object.assign(Object.assign({}, transaction), { fees: totalFees }),
33
+ transaction: { ...transaction, fees: totalFees },
45
34
  deviceId: "",
46
35
  });
47
36
  signOpObservable.subscribe(obs => {
@@ -1 +1 @@
1
- {"version":3,"file":"signOperation.unit.test.js","sourceRoot":"","sources":["../../../src/__tests__/unit/signOperation.unit.test.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,OAAO,EAAE,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CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"signOperation.unit.test.js","sourceRoot":"","sources":["../../../src/__tests__/unit/signOperation.unit.test.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACnE,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEzD,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAE3F,IAAI,CAAC,IAAI,CAAC,gCAAgC,CAAC,CAAC;AAE5C,MAAM,kBAAkB,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC,kBAAkB,CAAC,KAAK,IAAI,EAAE,CACjE,OAAO,CAAC,OAAO,CACb,SAAS,EAAE;KACR,KAAK,CACJ,YAAY,CAAC;IACX,IAAI,EAAE;QACJ,IAAI,EAAE,aAAa;QACnB,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC,kDAAkD,CAAC;QACvE,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC;KACrB;IACD,IAAI,EAAE,IAAI,IAAI,EAAE;CACjB,CAAC,CACH;KACA,OAAO,EAAE,CACb,CACF,CAAC;AAEF,MAAM,iBAAiB,GAA6B,CAClD,CAAS,EACT,EAAqC,EACrC,EAAE;IACF,OAAO,EAAE,CAAC;QACR,eAAe,EAAE,kBAAkB;QACnC,UAAU,EAAE,IAAI,CAAC,EAAE,EAAE;QACrB,eAAe,EAAE,IAAI,CAAC,EAAE,EAAE;KAC3B,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAC7B,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,o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BACT;wBACD,YAAY,EAAE,EAAE;wBAChB,EAAE,EAAE,EAAE;qBACP;iBACF,CAAC,CAAC;gBACH,MAAM,CAAC,SAAS,CAAC,CAAC,IAAI,CACpB,sHAAsH,CACvH,CAAC;gBACF,IAAI,EAAE,CAAC;YACT,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,12 +1,3 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  import { encodeOperationId } from "@ledgerhq/coin-framework/lib/operation";
11
2
  import BigNumber from "bignumber.js";
12
3
  // eslint-disable-next-line no-restricted-imports
@@ -15,8 +6,7 @@ import { mapJettonTxToOps, mapTxToOps } from "../../bridge/bridgeHelpers/txn";
15
6
  import { jettonTransferResponse, mockAccountId, mockAddress, tonTransactionResponse, } from "../fixtures/common.fixtures";
16
7
  describe("Transaction functions", () => {
17
8
  describe("mapTxToOps", () => {
18
- it.skip("should map an IN ton transaction without total_fees to a ledger operation", () => __awaiter(void 0, void 0, void 0, function* () {
19
- var _a, _b;
9
+ it.skip("should map an IN ton transaction without total_fees to a ledger operation", async () => {
20
10
  const { now, lt, hash, in_msg, total_fees, mc_block_seqno } = tonTransactionResponse.transactions[0];
21
11
  const finalOperation = flatMap(tonTransactionResponse.transactions, mapTxToOps(mockAccountId, mockAddress, tonTransactionResponse.address_book));
22
12
  expect(finalOperation).toEqual([
@@ -28,24 +18,23 @@ describe("Transaction functions", () => {
28
18
  extra: { comment: { isEncrypted: false, text: "" }, explorerHash: hash, lt },
29
19
  fee: BigNumber(total_fees),
30
20
  hasFailed: false,
31
- hash: in_msg === null || in_msg === void 0 ? void 0 : in_msg.hash,
32
- id: encodeOperationId(mockAccountId, (_a = in_msg === null || in_msg === void 0 ? void 0 : in_msg.hash) !== null && _a !== void 0 ? _a : "", "IN"),
33
- recipients: [in_msg === null || in_msg === void 0 ? void 0 : in_msg.destination],
21
+ hash: in_msg?.hash,
22
+ id: encodeOperationId(mockAccountId, in_msg?.hash ?? "", "IN"),
23
+ recipients: [in_msg?.destination],
34
24
  senders: ["EQCVnqqL0OOiZi2BQnjVGm-ZeUYgfUhHgAi-vn9F8-94HwrH"],
35
25
  type: "IN",
36
- value: BigNumber((_b = in_msg === null || in_msg === void 0 ? void 0 : in_msg.value) !== null && _b !== void 0 ? _b : 0),
26
+ value: BigNumber(in_msg?.value ?? 0),
37
27
  },
38
28
  ]);
39
- }));
40
- it.skip("should map an IN ton transaction with total_fees to a ledger operation", () => __awaiter(void 0, void 0, void 0, function* () {
41
- var _c, _d, _e;
42
- const transactions = [Object.assign(Object.assign({}, tonTransactionResponse.transactions[0]), { total_fees: "15" })];
29
+ });
30
+ it.skip("should map an IN ton transaction with total_fees to a ledger operation", async () => {
31
+ const transactions = [{ ...tonTransactionResponse.transactions[0], total_fees: "15" }];
43
32
  const { now, lt, hash, in_msg, total_fees, mc_block_seqno, account } = transactions[0];
44
33
  const finalOperation = flatMap(transactions, mapTxToOps(mockAccountId, mockAddress, tonTransactionResponse.address_book));
45
34
  expect(finalOperation).toEqual([
46
35
  {
47
- id: encodeOperationId(mockAccountId, (_c = in_msg === null || in_msg === void 0 ? void 0 : in_msg.hash) !== null && _c !== void 0 ? _c : "", "NONE"),
48
- hash: in_msg === null || in_msg === void 0 ? void 0 : in_msg.hash,
36
+ id: encodeOperationId(mockAccountId, in_msg?.hash ?? "", "NONE"),
37
+ hash: in_msg?.hash,
49
38
  type: "NONE",
50
39
  value: BigNumber(total_fees),
51
40
  fee: BigNumber(0),
@@ -66,34 +55,36 @@ describe("Transaction functions", () => {
66
55
  extra: { comment: { isEncrypted: false, text: "" }, explorerHash: hash, lt },
67
56
  fee: BigNumber(total_fees),
68
57
  hasFailed: false,
69
- hash: in_msg === null || in_msg === void 0 ? void 0 : in_msg.hash,
70
- id: encodeOperationId(mockAccountId, (_d = in_msg === null || in_msg === void 0 ? void 0 : in_msg.hash) !== null && _d !== void 0 ? _d : "", "IN"),
71
- recipients: [in_msg === null || in_msg === void 0 ? void 0 : in_msg.destination],
58
+ hash: in_msg?.hash,
59
+ id: encodeOperationId(mockAccountId, in_msg?.hash ?? "", "IN"),
60
+ recipients: [in_msg?.destination],
72
61
  senders: ["EQCVnqqL0OOiZi2BQnjVGm-ZeUYgfUhHgAi-vn9F8-94HwrH"],
73
62
  type: "IN",
74
- value: BigNumber((_e = in_msg === null || in_msg === void 0 ? void 0 : in_msg.value) !== null && _e !== void 0 ? _e : 0),
63
+ value: BigNumber(in_msg?.value ?? 0),
75
64
  },
76
65
  ]);
77
- }));
78
- it.skip("should map an OUT ton transaction to a ledger operation", () => __awaiter(void 0, void 0, void 0, function* () {
79
- var _f;
66
+ });
67
+ it.skip("should map an OUT ton transaction to a ledger operation", async () => {
80
68
  // The IN transaction will be used as OUT transaction and it will be adjusted
81
69
  const transactions = [
82
- Object.assign(Object.assign({}, tonTransactionResponse.transactions[0]), { in_msg: null }),
70
+ {
71
+ ...tonTransactionResponse.transactions[0],
72
+ in_msg: null,
73
+ },
83
74
  ];
84
75
  if (tonTransactionResponse.transactions[0].in_msg) {
85
76
  transactions[0].out_msgs = [
86
- Object.assign(Object.assign({}, tonTransactionResponse.transactions[0].in_msg), { source: transactions[0].account }),
77
+ { ...tonTransactionResponse.transactions[0].in_msg, source: transactions[0].account },
87
78
  ];
88
79
  }
89
80
  const { now, lt, hash, out_msgs, total_fees, mc_block_seqno, account } = transactions[0];
90
81
  const finalOperation = flatMap(transactions, mapTxToOps(mockAccountId, mockAddress, tonTransactionResponse.address_book));
91
82
  expect(finalOperation).toEqual([
92
83
  {
93
- id: encodeOperationId(mockAccountId, hash !== null && hash !== void 0 ? hash : "", "OUT"),
94
- hash: out_msgs === null || out_msgs === void 0 ? void 0 : out_msgs[0].hash,
84
+ id: encodeOperationId(mockAccountId, hash ?? "", "OUT"),
85
+ hash: out_msgs?.[0].hash,
95
86
  type: "OUT",
96
- value: BigNumber((_f = out_msgs[0].value) !== null && _f !== void 0 ? _f : 0).plus(BigNumber(total_fees)),
87
+ value: BigNumber(out_msgs[0].value ?? 0).plus(BigNumber(total_fees)),
97
88
  fee: BigNumber(total_fees),
98
89
  blockHeight: mc_block_seqno,
99
90
  blockHash: null,
@@ -105,10 +96,10 @@ describe("Transaction functions", () => {
105
96
  extra: { comment: { isEncrypted: false, text: "" }, explorerHash: hash, lt },
106
97
  },
107
98
  ]);
108
- }));
99
+ });
109
100
  });
110
101
  describe("mapJettonToOps", () => {
111
- it("should map an IN ton transaction without total_fees to a ledger operation", () => __awaiter(void 0, void 0, void 0, function* () {
102
+ it("should map an IN ton transaction without total_fees to a ledger operation", async () => {
112
103
  const { transaction_hash, amount, transaction_now, transaction_lt } = jettonTransferResponse.jetton_transfers[0];
113
104
  const finalOperation = flatMap(jettonTransferResponse.jetton_transfers, mapJettonTxToOps(mockAccountId, mockAddress, tonTransactionResponse.address_book));
114
105
  const tokenByCurrencyAddress = `${mockAccountId}+ton%2Fjetton%2Feqavlwfdxgf2lxm67y4yzc17wykd9a0guwpkms1gosm~!underscore!~~!underscore!~not`;
@@ -133,11 +124,13 @@ describe("Transaction functions", () => {
133
124
  },
134
125
  },
135
126
  ]);
136
- }));
137
- it("should map an OUT jetton transaction to a ledger operation", () => __awaiter(void 0, void 0, void 0, function* () {
127
+ });
128
+ it("should map an OUT jetton transaction to a ledger operation", async () => {
138
129
  // The IN jetton transaction will be used as OUT transaction and it will be adjusted
139
130
  const jettonTransfers = [
140
- Object.assign({}, jettonTransferResponse.jetton_transfers[0]),
131
+ {
132
+ ...jettonTransferResponse.jetton_transfers[0],
133
+ },
141
134
  ];
142
135
  jettonTransfers[0].source = jettonTransfers[0].destination;
143
136
  jettonTransfers[0].destination = jettonTransferResponse.jetton_transfers[0].source;
@@ -165,7 +158,7 @@ describe("Transaction functions", () => {
165
158
  },
166
159
  },
167
160
  ]);
168
- }));
161
+ });
169
162
  });
170
163
  });
171
164
  //# sourceMappingURL=txn.unit.test.js.map