@ledgerhq/coin-evm 0.6.1 → 0.7.0-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.
Files changed (228) hide show
  1. package/.eslintrc.js +8 -1
  2. package/.turbo/turbo-build.log +1 -1
  3. package/CHANGELOG.md +24 -0
  4. package/jest.config.js +1 -0
  5. package/lib/__tests__/fixtures/prepareTransaction.fixtures.js.map +1 -1
  6. package/lib/__tests__/fixtures/transaction.fixtures.d.ts.map +1 -1
  7. package/lib/__tests__/fixtures/transaction.fixtures.js +80 -0
  8. package/lib/__tests__/fixtures/transaction.fixtures.js.map +1 -1
  9. package/lib/__tests__/integration/bridge.integration.test.d.ts.map +1 -1
  10. package/lib/__tests__/integration/bridge.integration.test.js +4 -4
  11. package/lib/__tests__/integration/bridge.integration.test.js.map +1 -1
  12. package/lib/__tests__/unit/adapters/ethers.unit.test.js +15 -0
  13. package/lib/__tests__/unit/adapters/ethers.unit.test.js.map +1 -1
  14. package/lib/__tests__/unit/adapters/ledger.unit.test.js +63 -0
  15. package/lib/__tests__/unit/adapters/ledger.unit.test.js.map +1 -1
  16. package/lib/__tests__/unit/api/explorer/etherscan.unit.test.js +4 -0
  17. package/lib/__tests__/unit/api/explorer/etherscan.unit.test.js.map +1 -1
  18. package/lib/__tests__/unit/api/explorer/index.unit.test.js +10 -19
  19. package/lib/__tests__/unit/api/explorer/index.unit.test.js.map +1 -1
  20. package/lib/__tests__/unit/api/gasTracker/index.unit.test.js +8 -0
  21. package/lib/__tests__/unit/api/gasTracker/index.unit.test.js.map +1 -1
  22. package/lib/__tests__/unit/api/gasTracker/ledger.unit.test.js +182 -80
  23. package/lib/__tests__/unit/api/gasTracker/ledger.unit.test.js.map +1 -1
  24. package/lib/__tests__/unit/api/node/rpc.unit.test.js.map +1 -1
  25. package/lib/__tests__/unit/getTransactionStatus.unit.test.js +316 -143
  26. package/lib/__tests__/unit/getTransactionStatus.unit.test.js.map +1 -1
  27. package/lib/__tests__/unit/hw-getAddress.unit.test.js.map +1 -1
  28. package/lib/__tests__/unit/logic.unit.test.js +4 -4
  29. package/lib/__tests__/unit/logic.unit.test.js.map +1 -1
  30. package/lib/__tests__/unit/preload.unit.test.js.map +1 -1
  31. package/lib/__tests__/unit/signOperation.unit.test.js +1 -1
  32. package/lib/__tests__/unit/signOperation.unit.test.js.map +1 -1
  33. package/lib/__tests__/unit/synchronization.unit.test.js.map +1 -1
  34. package/lib/__tests__/unit/transaction.unit.test.js +95 -18
  35. package/lib/__tests__/unit/transaction.unit.test.js.map +1 -1
  36. package/lib/adapters/ethers.d.ts.map +1 -1
  37. package/lib/adapters/ethers.js +10 -5
  38. package/lib/adapters/ethers.js.map +1 -1
  39. package/lib/adapters/ledger.d.ts.map +1 -1
  40. package/lib/adapters/ledger.js +41 -8
  41. package/lib/adapters/ledger.js.map +1 -1
  42. package/lib/api/explorer/etherscan.d.ts +1 -1
  43. package/lib/api/explorer/etherscan.js +1 -1
  44. package/lib/api/explorer/ledger.d.ts +2 -2
  45. package/lib/api/explorer/ledger.d.ts.map +1 -1
  46. package/lib/api/explorer/ledger.js +2 -1
  47. package/lib/api/explorer/ledger.js.map +1 -1
  48. package/lib/api/gasTracker/ledger.d.ts.map +1 -1
  49. package/lib/api/gasTracker/ledger.js +18 -11
  50. package/lib/api/gasTracker/ledger.js.map +1 -1
  51. package/lib/api/node/ledger.d.ts.map +1 -1
  52. package/lib/api/node/ledger.js +7 -0
  53. package/lib/api/node/ledger.js.map +1 -1
  54. package/lib/api/node/rpc.common.d.ts.map +1 -1
  55. package/lib/api/node/rpc.common.js.map +1 -1
  56. package/lib/api/node/types.d.ts +2 -2
  57. package/lib/api/node/types.d.ts.map +1 -1
  58. package/lib/api/node/types.js.map +1 -1
  59. package/lib/cli-transaction.d.ts +3 -1
  60. package/lib/cli-transaction.d.ts.map +1 -1
  61. package/lib/cli-transaction.js.map +1 -1
  62. package/lib/datasets/ethereum1.js +2 -2
  63. package/lib/datasets/ethereum1.js.map +1 -1
  64. package/lib/errors.d.ts +0 -3
  65. package/lib/errors.d.ts.map +1 -1
  66. package/lib/errors.js +1 -2
  67. package/lib/errors.js.map +1 -1
  68. package/lib/getTransactionStatus.d.ts +2 -12
  69. package/lib/getTransactionStatus.d.ts.map +1 -1
  70. package/lib/getTransactionStatus.js +30 -10
  71. package/lib/getTransactionStatus.js.map +1 -1
  72. package/lib/hw-signMessage.js.map +1 -1
  73. package/lib/logic.d.ts +6 -2
  74. package/lib/logic.d.ts.map +1 -1
  75. package/lib/logic.js +19 -7
  76. package/lib/logic.js.map +1 -1
  77. package/lib/prepareTransaction.js.map +1 -1
  78. package/lib/signer.d.ts +1 -1
  79. package/lib/signer.d.ts.map +1 -1
  80. package/lib/specs.d.ts.map +1 -1
  81. package/lib/specs.js +117 -64
  82. package/lib/specs.js.map +1 -1
  83. package/lib/speculos-deviceActions.d.ts +3 -6
  84. package/lib/speculos-deviceActions.d.ts.map +1 -1
  85. package/lib/speculos-deviceActions.js +47 -7
  86. package/lib/speculos-deviceActions.js.map +1 -1
  87. package/lib/synchronization.d.ts.map +1 -1
  88. package/lib/synchronization.js.map +1 -1
  89. package/lib/transaction.d.ts.map +1 -1
  90. package/lib/transaction.js +33 -0
  91. package/lib/transaction.js.map +1 -1
  92. package/lib/types/ledger.d.ts +2 -2
  93. package/lib/types/ledger.d.ts.map +1 -1
  94. package/lib/types/transaction.d.ts +16 -6
  95. package/lib/types/transaction.d.ts.map +1 -1
  96. package/lib-es/__tests__/fixtures/prepareTransaction.fixtures.js.map +1 -1
  97. package/lib-es/__tests__/fixtures/transaction.fixtures.d.ts.map +1 -1
  98. package/lib-es/__tests__/fixtures/transaction.fixtures.js +80 -0
  99. package/lib-es/__tests__/fixtures/transaction.fixtures.js.map +1 -1
  100. package/lib-es/__tests__/integration/bridge.integration.test.d.ts.map +1 -1
  101. package/lib-es/__tests__/integration/bridge.integration.test.js +4 -4
  102. package/lib-es/__tests__/integration/bridge.integration.test.js.map +1 -1
  103. package/lib-es/__tests__/unit/adapters/ethers.unit.test.js +15 -0
  104. package/lib-es/__tests__/unit/adapters/ethers.unit.test.js.map +1 -1
  105. package/lib-es/__tests__/unit/adapters/ledger.unit.test.js +63 -0
  106. package/lib-es/__tests__/unit/adapters/ledger.unit.test.js.map +1 -1
  107. package/lib-es/__tests__/unit/api/explorer/etherscan.unit.test.js +4 -0
  108. package/lib-es/__tests__/unit/api/explorer/etherscan.unit.test.js.map +1 -1
  109. package/lib-es/__tests__/unit/api/explorer/index.unit.test.js +10 -19
  110. package/lib-es/__tests__/unit/api/explorer/index.unit.test.js.map +1 -1
  111. package/lib-es/__tests__/unit/api/gasTracker/index.unit.test.js +8 -0
  112. package/lib-es/__tests__/unit/api/gasTracker/index.unit.test.js.map +1 -1
  113. package/lib-es/__tests__/unit/api/gasTracker/ledger.unit.test.js +183 -81
  114. package/lib-es/__tests__/unit/api/gasTracker/ledger.unit.test.js.map +1 -1
  115. package/lib-es/__tests__/unit/api/node/rpc.unit.test.js.map +1 -1
  116. package/lib-es/__tests__/unit/getTransactionStatus.unit.test.js +317 -144
  117. package/lib-es/__tests__/unit/getTransactionStatus.unit.test.js.map +1 -1
  118. package/lib-es/__tests__/unit/hw-getAddress.unit.test.js.map +1 -1
  119. package/lib-es/__tests__/unit/logic.unit.test.js +4 -4
  120. package/lib-es/__tests__/unit/logic.unit.test.js.map +1 -1
  121. package/lib-es/__tests__/unit/preload.unit.test.js.map +1 -1
  122. package/lib-es/__tests__/unit/signOperation.unit.test.js +1 -1
  123. package/lib-es/__tests__/unit/signOperation.unit.test.js.map +1 -1
  124. package/lib-es/__tests__/unit/synchronization.unit.test.js.map +1 -1
  125. package/lib-es/__tests__/unit/transaction.unit.test.js +95 -18
  126. package/lib-es/__tests__/unit/transaction.unit.test.js.map +1 -1
  127. package/lib-es/adapters/ethers.d.ts.map +1 -1
  128. package/lib-es/adapters/ethers.js +10 -5
  129. package/lib-es/adapters/ethers.js.map +1 -1
  130. package/lib-es/adapters/ledger.d.ts.map +1 -1
  131. package/lib-es/adapters/ledger.js +41 -8
  132. package/lib-es/adapters/ledger.js.map +1 -1
  133. package/lib-es/api/explorer/etherscan.d.ts +1 -1
  134. package/lib-es/api/explorer/etherscan.js +1 -1
  135. package/lib-es/api/explorer/ledger.d.ts +2 -2
  136. package/lib-es/api/explorer/ledger.d.ts.map +1 -1
  137. package/lib-es/api/explorer/ledger.js +2 -1
  138. package/lib-es/api/explorer/ledger.js.map +1 -1
  139. package/lib-es/api/gasTracker/ledger.d.ts.map +1 -1
  140. package/lib-es/api/gasTracker/ledger.js +19 -12
  141. package/lib-es/api/gasTracker/ledger.js.map +1 -1
  142. package/lib-es/api/node/ledger.d.ts.map +1 -1
  143. package/lib-es/api/node/ledger.js +7 -0
  144. package/lib-es/api/node/ledger.js.map +1 -1
  145. package/lib-es/api/node/rpc.common.d.ts.map +1 -1
  146. package/lib-es/api/node/rpc.common.js.map +1 -1
  147. package/lib-es/api/node/types.d.ts +2 -2
  148. package/lib-es/api/node/types.d.ts.map +1 -1
  149. package/lib-es/api/node/types.js.map +1 -1
  150. package/lib-es/cli-transaction.d.ts +3 -1
  151. package/lib-es/cli-transaction.d.ts.map +1 -1
  152. package/lib-es/cli-transaction.js.map +1 -1
  153. package/lib-es/datasets/ethereum1.js +2 -2
  154. package/lib-es/datasets/ethereum1.js.map +1 -1
  155. package/lib-es/errors.d.ts +0 -3
  156. package/lib-es/errors.d.ts.map +1 -1
  157. package/lib-es/errors.js +0 -1
  158. package/lib-es/errors.js.map +1 -1
  159. package/lib-es/getTransactionStatus.d.ts +2 -12
  160. package/lib-es/getTransactionStatus.d.ts.map +1 -1
  161. package/lib-es/getTransactionStatus.js +30 -7
  162. package/lib-es/getTransactionStatus.js.map +1 -1
  163. package/lib-es/hw-signMessage.js.map +1 -1
  164. package/lib-es/logic.d.ts +6 -2
  165. package/lib-es/logic.d.ts.map +1 -1
  166. package/lib-es/logic.js +15 -4
  167. package/lib-es/logic.js.map +1 -1
  168. package/lib-es/prepareTransaction.js.map +1 -1
  169. package/lib-es/signer.d.ts +1 -1
  170. package/lib-es/signer.d.ts.map +1 -1
  171. package/lib-es/specs.d.ts.map +1 -1
  172. package/lib-es/specs.js +118 -65
  173. package/lib-es/specs.js.map +1 -1
  174. package/lib-es/speculos-deviceActions.d.ts +3 -6
  175. package/lib-es/speculos-deviceActions.d.ts.map +1 -1
  176. package/lib-es/speculos-deviceActions.js +46 -6
  177. package/lib-es/speculos-deviceActions.js.map +1 -1
  178. package/lib-es/synchronization.d.ts.map +1 -1
  179. package/lib-es/synchronization.js.map +1 -1
  180. package/lib-es/transaction.d.ts.map +1 -1
  181. package/lib-es/transaction.js +33 -0
  182. package/lib-es/transaction.js.map +1 -1
  183. package/lib-es/types/ledger.d.ts +2 -2
  184. package/lib-es/types/ledger.d.ts.map +1 -1
  185. package/lib-es/types/transaction.d.ts +16 -6
  186. package/lib-es/types/transaction.d.ts.map +1 -1
  187. package/package.json +14 -11
  188. package/src/__tests__/fixtures/prepareTransaction.fixtures.ts +2 -2
  189. package/src/__tests__/fixtures/transaction.fixtures.ts +80 -0
  190. package/src/__tests__/integration/bridge.integration.test.ts +6 -6
  191. package/src/__tests__/unit/adapters/ethers.unit.test.ts +21 -0
  192. package/src/__tests__/unit/adapters/ledger.unit.test.ts +67 -0
  193. package/src/__tests__/unit/api/explorer/etherscan.unit.test.ts +9 -5
  194. package/src/__tests__/unit/api/explorer/index.unit.test.ts +7 -7
  195. package/src/__tests__/unit/api/gasTracker/index.unit.test.ts +8 -0
  196. package/src/__tests__/unit/api/gasTracker/ledger.unit.test.ts +217 -83
  197. package/src/__tests__/unit/api/node/rpc.unit.test.ts +2 -2
  198. package/src/__tests__/unit/getTransactionStatus.unit.test.ts +535 -257
  199. package/src/__tests__/unit/hw-getAddress.unit.test.ts +5 -2
  200. package/src/__tests__/unit/logic.unit.test.ts +16 -4
  201. package/src/__tests__/unit/preload.unit.test.ts +3 -1
  202. package/src/__tests__/unit/signOperation.unit.test.ts +7 -2
  203. package/src/__tests__/unit/synchronization.unit.test.ts +1 -1
  204. package/src/__tests__/unit/transaction.unit.test.ts +179 -41
  205. package/src/adapters/ethers.ts +11 -5
  206. package/src/adapters/ledger.ts +42 -8
  207. package/src/api/explorer/etherscan.ts +1 -1
  208. package/src/api/explorer/ledger.ts +4 -2
  209. package/src/api/gasTracker/ledger.ts +20 -19
  210. package/src/api/node/ledger.ts +8 -1
  211. package/src/api/node/rpc.common.ts +16 -3
  212. package/src/api/node/types.ts +2 -2
  213. package/src/cli-transaction.ts +5 -1
  214. package/src/datasets/ethereum1.ts +2 -2
  215. package/src/errors.ts +0 -3
  216. package/src/getTransactionStatus.ts +44 -5
  217. package/src/hw-signMessage.ts +1 -1
  218. package/src/logic.ts +27 -6
  219. package/src/prepareTransaction.ts +2 -2
  220. package/src/signOperation.ts +1 -1
  221. package/src/signer.ts +1 -1
  222. package/src/specs.ts +142 -81
  223. package/src/speculos-deviceActions.ts +60 -10
  224. package/src/synchronization.ts +5 -1
  225. package/src/transaction.ts +47 -0
  226. package/src/types/ledger.ts +2 -2
  227. package/src/types/transaction.ts +19 -6
  228. package/tsconfig.json +1 -0
@@ -12,12 +12,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
+ const cryptoassets_1 = require("@ledgerhq/cryptoassets");
15
16
  const errors_1 = require("@ledgerhq/errors");
16
17
  const bignumber_js_1 = __importDefault(require("bignumber.js"));
17
- const cryptoassets_1 = require("@ledgerhq/cryptoassets");
18
- const common_fixtures_1 = require("../fixtures/common.fixtures");
19
- const getTransactionStatus_1 = __importDefault(require("../../getTransactionStatus"));
18
+ const fast_check_1 = __importDefault(require("fast-check"));
20
19
  const errors_2 = require("../../errors");
20
+ const getTransactionStatus_1 = __importDefault(require("../../getTransactionStatus"));
21
+ const common_fixtures_1 = require("../fixtures/common.fixtures");
21
22
  const recipient = "0xe2ca7390e76c5A992749bB622087310d2e63ca29"; // rambo.eth
22
23
  const testData = Buffer.from("testBufferString").toString("hex");
23
24
  const tokenAccount = (0, common_fixtures_1.makeTokenAccount)("0xkvn", (0, cryptoassets_1.getTokenById)("ethereum/erc20/usd__coin"));
@@ -53,6 +54,22 @@ const eip1559Tx = {
53
54
  maxPriorityFeePerGas: new bignumber_js_1.default(100),
54
55
  type: 2,
55
56
  };
57
+ const erc721Nft = {
58
+ contract: "0xNftContract",
59
+ tokenId: "1",
60
+ amount: new bignumber_js_1.default(1),
61
+ currencyId: account.currency.id,
62
+ id: "doesn't matter",
63
+ standard: "ERC721",
64
+ };
65
+ const erc1155Nft = {
66
+ contract: "0xAnotherNftContract",
67
+ tokenId: "2",
68
+ amount: new bignumber_js_1.default(2),
69
+ currencyId: account.currency.id,
70
+ id: "still doesn't matter",
71
+ standard: "ERC1155",
72
+ };
56
73
  const gasOptions = {
57
74
  slow: {
58
75
  maxFeePerGas: new bignumber_js_1.default(1),
@@ -88,7 +105,7 @@ describe("EVM Family", () => {
88
105
  const res = yield (0, getTransactionStatus_1.default)(account, tx);
89
106
  expect(res.errors).toEqual(expect.objectContaining({
90
107
  recipient: new errors_1.InvalidAddress("", {
91
- currency: account.currency,
108
+ currencyName: account.currency.name,
92
109
  }),
93
110
  }));
94
111
  }));
@@ -97,11 +114,11 @@ describe("EVM Family", () => {
97
114
  const res = yield (0, getTransactionStatus_1.default)(account, tx);
98
115
  expect(res.errors).toEqual(expect.objectContaining({
99
116
  recipient: new errors_1.InvalidAddress("", {
100
- currency: account.currency,
117
+ currencyName: account.currency.name,
101
118
  }),
102
119
  }));
103
120
  }));
104
- it("should detect the recipient not being an EIP55 address and have an warning", () => __awaiter(void 0, void 0, void 0, function* () {
121
+ it("should detect the recipient not being an EIP55 address and have a warning", () => __awaiter(void 0, void 0, void 0, function* () {
105
122
  const tx = Object.assign(Object.assign({}, eip1559Tx), { recipient: recipient.toLowerCase() });
106
123
  const res = yield (0, getTransactionStatus_1.default)(account, tx);
107
124
  expect(res.warnings).toEqual(expect.objectContaining({
@@ -137,133 +154,102 @@ describe("EVM Family", () => {
137
154
  }));
138
155
  });
139
156
  describe("Gas", () => {
140
- it("should detect missing fees in a 1559 tx and have an error", () => __awaiter(void 0, void 0, void 0, function* () {
141
- const tx = Object.assign(Object.assign({}, eip1559Tx), { maxFeePerGas: undefined });
142
- const res = yield (0, getTransactionStatus_1.default)(account, tx);
143
- expect(res.errors).toEqual(expect.objectContaining({
144
- gasPrice: new errors_1.FeeNotLoaded(),
145
- }));
146
- }));
147
- it("should detect missing fees in a legacy tx and have an error", () => __awaiter(void 0, void 0, void 0, function* () {
148
- const tx = Object.assign(Object.assign({}, legacyTx), { gasPrice: undefined });
149
- const res = yield (0, getTransactionStatus_1.default)(account, tx);
150
- expect(res.errors).toEqual(expect.objectContaining({
151
- gasPrice: new errors_1.FeeNotLoaded(),
152
- }));
153
- }));
154
- it("should detect a gasLimit = 0 in a 1559 tx and have an error", () => __awaiter(void 0, void 0, void 0, function* () {
155
- const tx = Object.assign(Object.assign({}, eip1559Tx), { gasLimit: new bignumber_js_1.default(0) });
156
- const res = yield (0, getTransactionStatus_1.default)(account, tx);
157
- expect(res.errors).toEqual(expect.objectContaining({
158
- gasLimit: new errors_1.FeeNotLoaded(),
159
- }));
160
- }));
161
- it("should detect a gasLimit = 0 in a legacy tx and have an error", () => __awaiter(void 0, void 0, void 0, function* () {
162
- const tx = Object.assign(Object.assign({}, legacyTx), { gasLimit: new bignumber_js_1.default(0) });
163
- const res = yield (0, getTransactionStatus_1.default)(account, tx);
164
- expect(res.errors).toEqual(expect.objectContaining({
165
- gasLimit: new errors_1.FeeNotLoaded(),
166
- }));
167
- }));
168
- it("should detect gas limit being too low in a tx and have an error", () => __awaiter(void 0, void 0, void 0, function* () {
169
- const tx = Object.assign(Object.assign({}, eip1559Tx), { gasLimit: new bignumber_js_1.default(20000) }); // min should be 21000
170
- const res = yield (0, getTransactionStatus_1.default)(account, tx);
171
- expect(res.errors).toEqual(expect.objectContaining({
172
- gasLimit: new errors_1.GasLessThanEstimate(),
173
- }));
174
- }));
175
- it("should detect gas being too high in a 1559 tx for the account balance and have an error", () => __awaiter(void 0, void 0, void 0, function* () {
176
- const notEnoughBalanceResponse = yield (0, getTransactionStatus_1.default)(Object.assign(Object.assign({}, account), { balance: new bignumber_js_1.default(2099999) }), eip1559Tx);
177
- const enoughhBalanceResponse = yield (0, getTransactionStatus_1.default)(Object.assign(Object.assign({}, account), { balance: new bignumber_js_1.default(2100000) }), eip1559Tx);
178
- expect(notEnoughBalanceResponse.errors).toEqual(expect.objectContaining({
179
- gasPrice: new errors_1.NotEnoughGas(),
180
- }));
181
- expect(enoughhBalanceResponse.errors).not.toEqual(expect.objectContaining({
182
- gasPrice: new errors_1.NotEnoughGas(),
183
- }));
184
- }));
185
- it("should detect a maxPriorityFee = 0 in a 1559 tx and have an error", () => __awaiter(void 0, void 0, void 0, function* () {
186
- const res = yield (0, getTransactionStatus_1.default)(Object.assign(Object.assign({}, account), { balance: new bignumber_js_1.default(2100000) }), Object.assign(Object.assign({}, eip1559Tx), { maxPriorityFeePerGas: new bignumber_js_1.default(0) }));
187
- expect(res.errors).toEqual(expect.objectContaining({
188
- maxPriorityFee: new errors_1.PriorityFeeTooLow(),
189
- }));
190
- }));
191
- it("should detect gas being too high in a legacy tx for the account balance and have an error", () => __awaiter(void 0, void 0, void 0, function* () {
192
- const notEnoughBalanceResponse = yield (0, getTransactionStatus_1.default)(Object.assign(Object.assign({}, account), { balance: new bignumber_js_1.default(2099999) }), legacyTx);
193
- const enoughhBalanceResponse = yield (0, getTransactionStatus_1.default)(Object.assign(Object.assign({}, account), { balance: new bignumber_js_1.default(2100001) }), legacyTx);
194
- expect(notEnoughBalanceResponse.errors).toEqual(expect.objectContaining({
195
- gasPrice: new errors_1.NotEnoughGas(),
196
- }));
197
- expect(enoughhBalanceResponse.errors).not.toEqual(expect.objectContaining({
198
- gasPrice: new errors_1.NotEnoughGas(),
199
- }));
200
- }));
201
- it("should not detect gas being too high in a 1559 tx when there is no recipient and have an error", () => __awaiter(void 0, void 0, void 0, function* () {
202
- const notEnoughBalanceResponse = yield (0, getTransactionStatus_1.default)(Object.assign(Object.assign({}, account), { balance: new bignumber_js_1.default(2099999) }), Object.assign(Object.assign({}, eip1559Tx), { recipient: "" }));
203
- const enoughhBalanceResponse = yield (0, getTransactionStatus_1.default)(Object.assign(Object.assign({}, account), { balance: new bignumber_js_1.default(2100000) }), Object.assign(Object.assign({}, eip1559Tx), { recipient: "" }));
204
- expect(notEnoughBalanceResponse.errors).not.toEqual(expect.objectContaining({
205
- gasPrice: new errors_1.NotEnoughGas(),
206
- }));
207
- expect(enoughhBalanceResponse.errors).not.toEqual(expect.objectContaining({
208
- gasPrice: new errors_1.NotEnoughGas(),
209
- }));
210
- }));
211
- it("should not detect gas being too high in a legacy tx when there is no recipient and have an error", () => __awaiter(void 0, void 0, void 0, function* () {
212
- const notEnoughBalanceResponse = yield (0, getTransactionStatus_1.default)(Object.assign(Object.assign({}, account), { balance: new bignumber_js_1.default(2099999) }), Object.assign(Object.assign({}, legacyTx), { recipient: "" }));
213
- const enoughhBalanceResponse = yield (0, getTransactionStatus_1.default)(Object.assign(Object.assign({}, account), { balance: new bignumber_js_1.default(2100001) }), Object.assign(Object.assign({}, legacyTx), { recipient: "" }));
214
- expect(notEnoughBalanceResponse.errors).not.toEqual(expect.objectContaining({
215
- gasPrice: new errors_1.NotEnoughGas(),
216
- }));
217
- expect(enoughhBalanceResponse.errors).not.toEqual(expect.objectContaining({
218
- gasPrice: new errors_1.NotEnoughGas(),
219
- }));
220
- }));
221
- it("should detect maxFeePerGas being greater than max gasOptions maxFeePerGas and error", () => __awaiter(void 0, void 0, void 0, function* () {
222
- const response = yield (0, getTransactionStatus_1.default)(account, Object.assign(Object.assign({}, eip1559Tx), { gasOptions, maxFeePerGas: new bignumber_js_1.default(5) }));
223
- expect(response.errors).toEqual(expect.objectContaining({
224
- maxPriorityFee: new errors_1.PriorityFeeHigherThanMaxFee(),
225
- }));
226
- }));
227
- it("should detect customGasLimit being lower than gasLimit and warn", () => __awaiter(void 0, void 0, void 0, function* () {
228
- const response = yield (0, getTransactionStatus_1.default)(account, Object.assign(Object.assign({}, eip1559Tx), { customGasLimit: eip1559Tx.gasLimit.minus(1) }));
229
- expect(response.warnings).toEqual(expect.objectContaining({
230
- gasLimit: new errors_1.GasLessThanEstimate(),
231
- }));
232
- }));
233
- it("should detect maxPriorityFeePerGas being greater than max gasOptions maxPriorityFeePerGas and warn", () => __awaiter(void 0, void 0, void 0, function* () {
234
- const response = yield (0, getTransactionStatus_1.default)(account, Object.assign(Object.assign({}, eip1559Tx), { gasOptions, maxPriorityFeePerGas: new bignumber_js_1.default(4) }));
235
- expect(response.warnings).toEqual(expect.objectContaining({
236
- maxPriorityFee: new errors_1.PriorityFeeTooHigh(),
237
- }));
238
- }));
239
- it("should detect maxPriorityFeePerGas being lower than min gasOptions maxPriorityFeePerGas and warn", () => __awaiter(void 0, void 0, void 0, function* () {
240
- const response = yield (0, getTransactionStatus_1.default)(account, Object.assign(Object.assign({}, eip1559Tx), { gasOptions, maxPriorityFeePerGas: new bignumber_js_1.default(0.5) }));
241
- expect(response.warnings).toEqual(expect.objectContaining({
242
- maxPriorityFee: new errors_1.PriorityFeeTooLow(),
243
- }));
244
- }));
245
- it("should detect maxFeePerGas being lower than recommanded next base fee and warn", () => __awaiter(void 0, void 0, void 0, function* () {
246
- const response = yield (0, getTransactionStatus_1.default)(account, Object.assign(Object.assign({}, eip1559Tx), { gasOptions, maxFeePerGas: new bignumber_js_1.default(1) }));
247
- expect(response.warnings).toEqual(expect.objectContaining({
248
- maxFee: new errors_1.MaxFeeTooLow(),
249
- }));
250
- }));
157
+ describe("Common", () => {
158
+ describe.each([
159
+ { type: "Legacy", defaultTx: legacyTx },
160
+ { type: "EIP1559", defaultTx: eip1559Tx },
161
+ ])("Transaction Type: $type", ({ defaultTx }) => {
162
+ it("should detect missing fees and have an error", () => __awaiter(void 0, void 0, void 0, function* () {
163
+ const tx = Object.assign(Object.assign({}, defaultTx), { gasPrice: undefined, maxFeePerGas: undefined });
164
+ const res = yield (0, getTransactionStatus_1.default)(account, tx);
165
+ expect(res.errors).toEqual(expect.objectContaining({
166
+ gasPrice: new errors_1.FeeNotLoaded(),
167
+ }));
168
+ }));
169
+ it("should detect a gasLimit = 0 and have an error", () => __awaiter(void 0, void 0, void 0, function* () {
170
+ const tx = Object.assign(Object.assign({}, defaultTx), { gasLimit: new bignumber_js_1.default(0) });
171
+ const res = yield (0, getTransactionStatus_1.default)(account, tx);
172
+ expect(res.errors).toEqual(expect.objectContaining({
173
+ gasLimit: new errors_1.FeeNotLoaded(),
174
+ }));
175
+ }));
176
+ it("should detect gas being too high for the account balance and have an error", () => __awaiter(void 0, void 0, void 0, function* () {
177
+ const notEnoughBalanceResponse = yield (0, getTransactionStatus_1.default)(Object.assign(Object.assign({}, account), { balance: new bignumber_js_1.default(2099999) }), defaultTx);
178
+ const enoughBalanceResponse = yield (0, getTransactionStatus_1.default)(Object.assign(Object.assign({}, account), { balance: new bignumber_js_1.default(2100001) }), defaultTx);
179
+ expect(notEnoughBalanceResponse.errors).toEqual(expect.objectContaining({
180
+ gasPrice: new errors_1.NotEnoughGas(),
181
+ }));
182
+ expect(enoughBalanceResponse.errors).not.toEqual(expect.objectContaining({
183
+ gasPrice: new errors_1.NotEnoughGas(),
184
+ }));
185
+ }));
186
+ it("should not detect gas being too high when there is no recipient and have an error", () => __awaiter(void 0, void 0, void 0, function* () {
187
+ const notEnoughBalanceResponse = yield (0, getTransactionStatus_1.default)(Object.assign(Object.assign({}, account), { balance: new bignumber_js_1.default(2099999) }), Object.assign(Object.assign({}, defaultTx), { recipient: "" }));
188
+ const enoughhBalanceResponse = yield (0, getTransactionStatus_1.default)(Object.assign(Object.assign({}, account), { balance: new bignumber_js_1.default(2100001) }), Object.assign(Object.assign({}, defaultTx), { recipient: "" }));
189
+ expect(notEnoughBalanceResponse.errors).not.toEqual(expect.objectContaining({
190
+ gasPrice: new errors_1.NotEnoughGas(),
191
+ }));
192
+ expect(enoughhBalanceResponse.errors).not.toEqual(expect.objectContaining({
193
+ gasPrice: new errors_1.NotEnoughGas(),
194
+ }));
195
+ }));
196
+ it("should detect gas limit being too low in a tx and have an error", () => __awaiter(void 0, void 0, void 0, function* () {
197
+ const tx = Object.assign(Object.assign({}, defaultTx), { gasLimit: new bignumber_js_1.default(20000) }); // min should be 21000
198
+ const res = yield (0, getTransactionStatus_1.default)(account, tx);
199
+ expect(res.errors).toEqual(expect.objectContaining({
200
+ gasLimit: new errors_1.GasLessThanEstimate(),
201
+ }));
202
+ }));
203
+ });
204
+ });
205
+ describe("Specific", () => {
206
+ describe("Transaction Type: EIP1559", () => {
207
+ it("should detect a maxPriorityFee = 0 and have an error", () => __awaiter(void 0, void 0, void 0, function* () {
208
+ const res = yield (0, getTransactionStatus_1.default)(Object.assign(Object.assign({}, account), { balance: new bignumber_js_1.default(2100000) }), Object.assign(Object.assign({}, eip1559Tx), { maxPriorityFeePerGas: new bignumber_js_1.default(0) }));
209
+ expect(res.errors).toEqual(expect.objectContaining({
210
+ maxPriorityFee: new errors_1.PriorityFeeTooLow(),
211
+ }));
212
+ }));
213
+ it("should detect maxFeePerGas being greater than max gasOptions maxFeePerGas and error", () => __awaiter(void 0, void 0, void 0, function* () {
214
+ const response = yield (0, getTransactionStatus_1.default)(account, Object.assign(Object.assign({}, eip1559Tx), { gasOptions, maxFeePerGas: new bignumber_js_1.default(5) }));
215
+ expect(response.errors).toEqual(expect.objectContaining({
216
+ maxPriorityFee: new errors_1.PriorityFeeHigherThanMaxFee(),
217
+ }));
218
+ }));
219
+ it("should detect customGasLimit being lower than gasLimit and warn", () => __awaiter(void 0, void 0, void 0, function* () {
220
+ const response = yield (0, getTransactionStatus_1.default)(account, Object.assign(Object.assign({}, eip1559Tx), { customGasLimit: eip1559Tx.gasLimit.minus(1) }));
221
+ expect(response.warnings).toEqual(expect.objectContaining({
222
+ gasLimit: new errors_1.GasLessThanEstimate(),
223
+ }));
224
+ }));
225
+ it("should detect maxPriorityFeePerGas being greater than max gasOptions maxPriorityFeePerGas and warn", () => __awaiter(void 0, void 0, void 0, function* () {
226
+ const response = yield (0, getTransactionStatus_1.default)(account, Object.assign(Object.assign({}, eip1559Tx), { gasOptions, maxPriorityFeePerGas: new bignumber_js_1.default(4) }));
227
+ expect(response.warnings).toEqual(expect.objectContaining({
228
+ maxPriorityFee: new errors_1.PriorityFeeTooHigh(),
229
+ }));
230
+ }));
231
+ it("should detect maxPriorityFeePerGas being lower than min gasOptions maxPriorityFeePerGas and warn", () => __awaiter(void 0, void 0, void 0, function* () {
232
+ const response = yield (0, getTransactionStatus_1.default)(account, Object.assign(Object.assign({}, eip1559Tx), { gasOptions, maxPriorityFeePerGas: new bignumber_js_1.default(0.5) }));
233
+ expect(response.warnings).toEqual(expect.objectContaining({
234
+ maxPriorityFee: new errors_1.PriorityFeeTooLow(),
235
+ }));
236
+ }));
237
+ it("should detect maxFeePerGas being lower than recommanded next base fee and warn", () => __awaiter(void 0, void 0, void 0, function* () {
238
+ const response = yield (0, getTransactionStatus_1.default)(account, Object.assign(Object.assign({}, eip1559Tx), { gasOptions, maxFeePerGas: new bignumber_js_1.default(1) }));
239
+ expect(response.warnings).toEqual(expect.objectContaining({
240
+ maxFee: new errors_1.MaxFeeTooLow(),
241
+ }));
242
+ }));
243
+ });
244
+ });
251
245
  });
252
246
  describe("Nft", () => {
253
247
  describe("ERC721", () => {
254
- const nft = {
255
- contract: "0xNftContract",
256
- tokenId: "1",
257
- amount: new bignumber_js_1.default(1),
258
- currencyId: account.currency.id,
259
- id: "doesn't matter",
260
- standard: "ERC721",
261
- };
262
248
  it("should detect a transaction for an ERC721 nft not owned by the account and have an error", () => __awaiter(void 0, void 0, void 0, function* () {
263
249
  const tx = Object.assign(Object.assign({}, eip1559Tx), { mode: "erc721", nft: {
264
250
  collectionName: "",
265
- contract: nft.contract,
266
- tokenId: nft.tokenId,
251
+ contract: erc721Nft.contract,
252
+ tokenId: erc721Nft.tokenId,
267
253
  quantity: new bignumber_js_1.default(1),
268
254
  } });
269
255
  const res = yield (0, getTransactionStatus_1.default)(account, tx);
@@ -271,21 +257,26 @@ describe("EVM Family", () => {
271
257
  amount: new errors_2.NotOwnedNft(),
272
258
  }));
273
259
  }));
260
+ it("should detect a transaction for an ERC721 nft owned by the account but it does not have enough balance to pay for gas and have an error", () => __awaiter(void 0, void 0, void 0, function* () {
261
+ const tx = Object.assign(Object.assign({}, eip1559Tx), { mode: "erc721", nft: {
262
+ collectionName: "",
263
+ contract: erc721Nft.contract,
264
+ tokenId: erc721Nft.tokenId,
265
+ quantity: new bignumber_js_1.default(1),
266
+ } });
267
+ const res = yield (0, getTransactionStatus_1.default)(Object.assign(Object.assign({}, account), { nfts: [erc721Nft] }), tx);
268
+ expect(res.errors).toEqual(expect.objectContaining({
269
+ amount: new errors_1.NotEnoughBalanceInParentAccount(),
270
+ gasPrice: new errors_1.NotEnoughGas(),
271
+ }));
272
+ }));
274
273
  });
275
274
  describe("ERC1155", () => {
276
- const nft = {
277
- contract: "0xAnotherNftContract",
278
- tokenId: "2",
279
- amount: new bignumber_js_1.default(2),
280
- currencyId: account.currency.id,
281
- id: "still doesn't matter",
282
- standard: "ERC1155",
283
- };
284
275
  it("should detect a transaction for an ERC1155 nft not owned by the account and have an error", () => __awaiter(void 0, void 0, void 0, function* () {
285
276
  const tx = Object.assign(Object.assign({}, eip1559Tx), { mode: "erc1155", nft: {
286
277
  collectionName: "",
287
- contract: nft.contract,
288
- tokenId: nft.tokenId,
278
+ contract: erc1155Nft.contract,
279
+ tokenId: erc1155Nft.tokenId,
289
280
  quantity: new bignumber_js_1.default(1),
290
281
  } });
291
282
  const res = yield (0, getTransactionStatus_1.default)(account, tx);
@@ -296,11 +287,11 @@ describe("EVM Family", () => {
296
287
  it("should detect a transaction for an ERC1155 where the quantity is 0 or below and have an error", () => __awaiter(void 0, void 0, void 0, function* () {
297
288
  const tx = Object.assign(Object.assign({}, eip1559Tx), { mode: "erc1155", nft: {
298
289
  collectionName: "",
299
- contract: nft.contract,
300
- tokenId: nft.tokenId,
290
+ contract: erc1155Nft.contract,
291
+ tokenId: erc1155Nft.tokenId,
301
292
  quantity: new bignumber_js_1.default(0),
302
293
  } });
303
- const res = yield (0, getTransactionStatus_1.default)(Object.assign(Object.assign({}, account), { nfts: [nft] }), tx);
294
+ const res = yield (0, getTransactionStatus_1.default)(Object.assign(Object.assign({}, account), { nfts: [erc1155Nft] }), tx);
304
295
  expect(res.errors).toEqual(expect.objectContaining({
305
296
  amount: new errors_2.QuantityNeedsToBePositive(),
306
297
  }));
@@ -308,15 +299,197 @@ describe("EVM Family", () => {
308
299
  it("should detect a transaction for an ERC1155 nft but the account doesn't own enough of it and have an error", () => __awaiter(void 0, void 0, void 0, function* () {
309
300
  const tx = Object.assign(Object.assign({}, eip1559Tx), { mode: "erc1155", nft: {
310
301
  collectionName: "",
311
- contract: nft.contract,
312
- tokenId: nft.tokenId,
302
+ contract: erc1155Nft.contract,
303
+ tokenId: erc1155Nft.tokenId,
313
304
  quantity: new bignumber_js_1.default(3),
314
305
  } });
315
- const res = yield (0, getTransactionStatus_1.default)(Object.assign(Object.assign({}, account), { nfts: [nft] }), tx);
306
+ const res = yield (0, getTransactionStatus_1.default)(Object.assign(Object.assign({}, account), { nfts: [erc1155Nft] }), tx);
316
307
  expect(res.errors).toEqual(expect.objectContaining({
317
308
  amount: new errors_2.NotEnoughNftOwned(),
318
309
  }));
319
310
  }));
311
+ it("should detect a transaction for an ERC1155 nft owned by the account but it does not have enough balance to pay for gas and have an error", () => __awaiter(void 0, void 0, void 0, function* () {
312
+ const tx = Object.assign(Object.assign({}, eip1559Tx), { mode: "erc1155", nft: {
313
+ collectionName: "",
314
+ contract: erc1155Nft.contract,
315
+ tokenId: erc1155Nft.tokenId,
316
+ quantity: new bignumber_js_1.default(1),
317
+ } });
318
+ const res = yield (0, getTransactionStatus_1.default)(Object.assign(Object.assign({}, account), { nfts: [erc1155Nft] }), tx);
319
+ expect(res.errors).toEqual(expect.objectContaining({
320
+ amount: new errors_1.NotEnoughBalanceInParentAccount(),
321
+ gasPrice: new errors_1.NotEnoughGas(),
322
+ }));
323
+ }));
324
+ });
325
+ });
326
+ describe("Fee Ratio", () => {
327
+ /**
328
+ * Helper function to narrow down the type of transaction and set the
329
+ * specific field depending on the type of transaction
330
+ */
331
+ const specifyTx = ({ tx, specificField, }) => {
332
+ if (tx.type === 2) {
333
+ return Object.assign(Object.assign({}, tx), { maxFeePerGas: new bignumber_js_1.default(specificField) });
334
+ }
335
+ else {
336
+ return Object.assign(Object.assign({}, tx), { gasPrice: new bignumber_js_1.default(specificField) });
337
+ }
338
+ };
339
+ describe.each([
340
+ { type: "Legacy", defaultTx: legacyTx },
341
+ { type: "EIP1559", defaultTx: eip1559Tx },
342
+ ])("Transaction Type: $type", ({ defaultTx }) => {
343
+ describe("when fees are too high compared to the amount (fees are more than 10% of the amount)", () => {
344
+ it("should have a warning", () => __awaiter(void 0, void 0, void 0, function* () {
345
+ yield fast_check_1.default.assert(fast_check_1.default.asyncProperty(fast_check_1.default
346
+ .record({
347
+ amount: fast_check_1.default.integer({ min: 1 }),
348
+ gasLimit: fast_check_1.default.integer({ min: 1 }),
349
+ specificField: fast_check_1.default.integer({ min: 1 }),
350
+ })
351
+ .filter(({ amount, gasLimit, specificField }) => (0, bignumber_js_1.default)(gasLimit)
352
+ .multipliedBy((0, bignumber_js_1.default)(specificField))
353
+ .times(10)
354
+ .gt((0, bignumber_js_1.default)(amount))), ({ amount, gasLimit, specificField }) => __awaiter(void 0, void 0, void 0, function* () {
355
+ const tx = specifyTx({
356
+ tx: Object.assign(Object.assign({}, defaultTx), { amount: new bignumber_js_1.default(amount), gasLimit: new bignumber_js_1.default(gasLimit), data: undefined }),
357
+ specificField,
358
+ });
359
+ const res = yield (0, getTransactionStatus_1.default)(account, tx);
360
+ expect(res.warnings).toEqual(expect.objectContaining({
361
+ feeTooHigh: new errors_1.FeeTooHigh(),
362
+ }));
363
+ })));
364
+ }));
365
+ /**
366
+ * Note: This is to test the lower bound of the x*y*r=a equation
367
+ * with x = gasPrice, y = gasLimit, a = amount, r = ratio
368
+ * This test would pass for r = 10 but would fail for r = 9
369
+ */
370
+ it("should have a warning for lower bound", () => __awaiter(void 0, void 0, void 0, function* () {
371
+ const amount = 990;
372
+ const gasLimit = 11;
373
+ const specificField = 10;
374
+ const tx = specifyTx({
375
+ tx: Object.assign(Object.assign({}, defaultTx), { amount: new bignumber_js_1.default(amount), gasLimit: new bignumber_js_1.default(gasLimit), data: undefined }),
376
+ specificField,
377
+ });
378
+ const res = yield (0, getTransactionStatus_1.default)(account, tx);
379
+ expect(res.warnings).toEqual(expect.objectContaining({
380
+ feeTooHigh: new errors_1.FeeTooHigh(),
381
+ }));
382
+ }));
383
+ });
384
+ describe("when fees are not too high compared to the amount (fees are less than or equal to 10% of the amount)", () => {
385
+ it("should not have a warning", () => __awaiter(void 0, void 0, void 0, function* () {
386
+ yield fast_check_1.default.assert(fast_check_1.default.asyncProperty(fast_check_1.default
387
+ .record({
388
+ amount: fast_check_1.default.integer({ min: 1 }),
389
+ gasLimit: fast_check_1.default.integer({ min: 1 }),
390
+ specificField: fast_check_1.default.integer({ min: 1 }),
391
+ })
392
+ .filter(({ amount, specificField, gasLimit }) => (0, bignumber_js_1.default)(specificField)
393
+ .multipliedBy((0, bignumber_js_1.default)(gasLimit))
394
+ .times(10)
395
+ .lt((0, bignumber_js_1.default)(amount))), ({ amount, specificField, gasLimit }) => __awaiter(void 0, void 0, void 0, function* () {
396
+ const tx = specifyTx({
397
+ tx: Object.assign(Object.assign({}, defaultTx), { amount: new bignumber_js_1.default(amount), gasLimit: new bignumber_js_1.default(gasLimit), data: undefined }),
398
+ specificField,
399
+ });
400
+ const res = yield (0, getTransactionStatus_1.default)(account, tx);
401
+ expect(res.warnings).toEqual(expect.not.objectContaining({
402
+ feeTooHigh: new errors_1.FeeTooHigh(),
403
+ }));
404
+ })));
405
+ }));
406
+ /**
407
+ * Note: This is to test the upper bound of the x*y*r=a equation
408
+ * with x = gasPrice, y = gasLimit, a = amount, r = ratio
409
+ * This test would pass for r = 10 but would fail for r = 11
410
+ */
411
+ it("should not have a warning for upper bound", () => __awaiter(void 0, void 0, void 0, function* () {
412
+ const amount = 100;
413
+ const gasLimit = 1;
414
+ const specificField = 10;
415
+ const tx = specifyTx({
416
+ tx: Object.assign(Object.assign({}, defaultTx), { amount: new bignumber_js_1.default(amount), gasLimit: new bignumber_js_1.default(gasLimit), data: undefined }),
417
+ specificField,
418
+ });
419
+ const res = yield (0, getTransactionStatus_1.default)(account, tx);
420
+ expect(res.warnings).toEqual(expect.not.objectContaining({
421
+ feeTooHigh: new errors_1.FeeTooHigh(),
422
+ }));
423
+ }));
424
+ });
425
+ describe("when tx has data", () => {
426
+ it("should not have a warning", () => __awaiter(void 0, void 0, void 0, function* () {
427
+ const amount = 1;
428
+ const gasLimit = 1;
429
+ const specificField = 1;
430
+ const tx = specifyTx({
431
+ tx: Object.assign(Object.assign({}, defaultTx), { amount: new bignumber_js_1.default(amount), gasLimit: new bignumber_js_1.default(gasLimit) }),
432
+ specificField,
433
+ });
434
+ const res = yield (0, getTransactionStatus_1.default)(account, tx);
435
+ expect(res.warnings).toEqual(expect.not.objectContaining({
436
+ feeTooHigh: new errors_1.FeeTooHigh(),
437
+ }));
438
+ }));
439
+ });
440
+ describe("when tx is nft tx", () => {
441
+ it("should not have a warning for ERC721 NFT", () => __awaiter(void 0, void 0, void 0, function* () {
442
+ const amount = 1;
443
+ const gasLimit = 1;
444
+ const specificField = 1;
445
+ const tx = specifyTx({
446
+ tx: Object.assign(Object.assign({}, defaultTx), { amount: new bignumber_js_1.default(amount), gasLimit: new bignumber_js_1.default(gasLimit), mode: "erc721", nft: {
447
+ collectionName: "",
448
+ contract: erc721Nft.contract,
449
+ tokenId: erc721Nft.tokenId,
450
+ quantity: new bignumber_js_1.default(1),
451
+ } }),
452
+ specificField,
453
+ });
454
+ const res = yield (0, getTransactionStatus_1.default)(account, tx);
455
+ expect(res.warnings).toEqual(expect.not.objectContaining({
456
+ feeTooHigh: new errors_1.FeeTooHigh(),
457
+ }));
458
+ }));
459
+ it("should not have a warning for ERC1155 NFT", () => __awaiter(void 0, void 0, void 0, function* () {
460
+ const amount = 1;
461
+ const gasLimit = 1;
462
+ const specificField = 1;
463
+ const tx = specifyTx({
464
+ tx: Object.assign(Object.assign({}, defaultTx), { amount: new bignumber_js_1.default(amount), gasLimit: new bignumber_js_1.default(gasLimit), mode: "erc1155", nft: {
465
+ collectionName: "",
466
+ contract: erc1155Nft.contract,
467
+ tokenId: erc1155Nft.tokenId,
468
+ quantity: new bignumber_js_1.default(1),
469
+ } }),
470
+ specificField,
471
+ });
472
+ const res = yield (0, getTransactionStatus_1.default)(account, tx);
473
+ expect(res.warnings).toEqual(expect.not.objectContaining({
474
+ feeTooHigh: new errors_1.FeeTooHigh(),
475
+ }));
476
+ }));
477
+ });
478
+ describe("when tx is token tx", () => {
479
+ it("should not have a warning", () => __awaiter(void 0, void 0, void 0, function* () {
480
+ const amount = 1;
481
+ const gasLimit = 1;
482
+ const specificField = 1;
483
+ const tx = specifyTx({
484
+ tx: Object.assign(Object.assign({}, defaultTx), { amount: new bignumber_js_1.default(amount), gasLimit: new bignumber_js_1.default(gasLimit), subAccountId: tokenAccount.id }),
485
+ specificField,
486
+ });
487
+ const res = yield (0, getTransactionStatus_1.default)(account, tx);
488
+ expect(res.warnings).toEqual(expect.not.objectContaining({
489
+ feeTooHigh: new errors_1.FeeTooHigh(),
490
+ }));
491
+ }));
492
+ });
320
493
  });
321
494
  });
322
495
  describe("Global return", () => {