@ledgerhq/coin-canton 0.5.1-nightly.4 → 0.6.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 (28) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/CHANGELOG.md +45 -38
  3. package/lib/bridge/prepareTransaction.d.ts.map +1 -1
  4. package/lib/bridge/prepareTransaction.js +3 -2
  5. package/lib/bridge/prepareTransaction.js.map +1 -1
  6. package/lib/common-logic/transaction/estimateFees.d.ts +1 -1
  7. package/lib/common-logic/transaction/estimateFees.d.ts.map +1 -1
  8. package/lib/common-logic/transaction/estimateFees.js +3 -35
  9. package/lib/common-logic/transaction/estimateFees.js.map +1 -1
  10. package/lib-es/bridge/prepareTransaction.d.ts.map +1 -1
  11. package/lib-es/bridge/prepareTransaction.js +3 -2
  12. package/lib-es/bridge/prepareTransaction.js.map +1 -1
  13. package/lib-es/common-logic/transaction/estimateFees.d.ts +1 -1
  14. package/lib-es/common-logic/transaction/estimateFees.d.ts.map +1 -1
  15. package/lib-es/common-logic/transaction/estimateFees.js +3 -35
  16. package/lib-es/common-logic/transaction/estimateFees.js.map +1 -1
  17. package/package.json +10 -10
  18. package/src/bridge/prepareTransaction.ts +3 -2
  19. package/src/common-logic/transaction/estimateFees.ts +4 -48
  20. package/lib/common-logic/transaction/estimateFees.test.d.ts +0 -2
  21. package/lib/common-logic/transaction/estimateFees.test.d.ts.map +0 -1
  22. package/lib/common-logic/transaction/estimateFees.test.js +0 -72
  23. package/lib/common-logic/transaction/estimateFees.test.js.map +0 -1
  24. package/lib-es/common-logic/transaction/estimateFees.test.d.ts +0 -2
  25. package/lib-es/common-logic/transaction/estimateFees.test.d.ts.map +0 -1
  26. package/lib-es/common-logic/transaction/estimateFees.test.js +0 -37
  27. package/lib-es/common-logic/transaction/estimateFees.test.js.map +0 -1
  28. package/src/common-logic/transaction/estimateFees.test.ts +0 -50
@@ -1,4 +1,4 @@
1
1
 
2
- > @ledgerhq/coin-canton@0.5.1-nightly.3 build /home/runner/work/ledger-live/ledger-live/libs/coin-modules/coin-canton
2
+ > @ledgerhq/coin-canton@0.6.0 build /home/runner/work/ledger-live/ledger-live/libs/coin-modules/coin-canton
3
3
  > tsc && tsc -m esnext --moduleResolution bundler --outDir lib-es
4
4
 
package/CHANGELOG.md CHANGED
@@ -1,61 +1,68 @@
1
1
  # @ledgerhq/coin-canton
2
2
 
3
- ## 0.5.1-nightly.4
3
+ ## 0.6.0
4
4
 
5
- ### Patch Changes
5
+ ### Minor Changes
6
6
 
7
- - Updated dependencies [[`a37c06f`](https://github.com/LedgerHQ/ledger-live/commit/a37c06f97b061a5db0dad3632bb5c3e8f293677c)]:
8
- - @ledgerhq/types-live@6.85.0-nightly.4
9
- - @ledgerhq/coin-framework@6.4.1-nightly.4
7
+ - [#11717](https://github.com/LedgerHQ/ledger-live/pull/11717) [`aaa16b7`](https://github.com/LedgerHQ/ledger-live/commit/aaa16b718454dca51d59bb138ab1a638dc4b8243) Thanks [@ishaba](https://github.com/ishaba)! - add canton api key
10
8
 
11
- ## 0.5.1-nightly.3
9
+ - [#11756](https://github.com/LedgerHQ/ledger-live/pull/11756) [`2d747cf`](https://github.com/LedgerHQ/ledger-live/commit/2d747cf63f120a6634c2e2adbe60c4e94d37fc71) Thanks [@hedi-edelbloute](https://github.com/hedi-edelbloute)! - Canton send support
12
10
 
13
- ### Patch Changes
11
+ - [#11799](https://github.com/LedgerHQ/ledger-live/pull/11799) [`65c128a`](https://github.com/LedgerHQ/ledger-live/commit/65c128a93f07857b421bed3696bc9984f860ada9) Thanks [@hedi-edelbloute](https://github.com/hedi-edelbloute)! - Canton memo
12
+
13
+ - [#11831](https://github.com/LedgerHQ/ledger-live/pull/11831) [`a3bf70e`](https://github.com/LedgerHQ/ledger-live/commit/a3bf70ea59fc31277a170d4cb5530f2f58d0a2ab) Thanks [@hedi-edelbloute](https://github.com/hedi-edelbloute)! - Update fee canton
14
14
 
15
- - [#11956](https://github.com/LedgerHQ/ledger-live/pull/11956) [`2abaa52`](https://github.com/LedgerHQ/ledger-live/commit/2abaa522471e8247d274c4b22cb4e297969ebe9a) Thanks [@hedi-edelbloute](https://github.com/hedi-edelbloute)! - Update coin-canton coverage command
15
+ - [#11830](https://github.com/LedgerHQ/ledger-live/pull/11830) [`6c7ede3`](https://github.com/LedgerHQ/ledger-live/commit/6c7ede327fcfa0f87ffdb9684da4e3b95612643c) Thanks [@jonezque](https://github.com/jonezque)! - canton: removed comment label from send window, fixed account recreation
16
16
 
17
- - [#11923](https://github.com/LedgerHQ/ledger-live/pull/11923) [`49a8534`](https://github.com/LedgerHQ/ledger-live/commit/49a85340a9c4e5dd8dd07db87028fe48f307d1f6) Thanks [@hedi-edelbloute](https://github.com/hedi-edelbloute)! - Canton accurate fees
17
+ - [#11769](https://github.com/LedgerHQ/ledger-live/pull/11769) [`6941aac`](https://github.com/LedgerHQ/ledger-live/commit/6941aac638dcc8d4fb03aa92f42d2a71d4089202) Thanks [@ishaba](https://github.com/ishaba)! - fix canton receive flow
18
18
 
19
- - Updated dependencies [[`ab0e1bc`](https://github.com/LedgerHQ/ledger-live/commit/ab0e1bcc97b66b750b6c29e618eb03ce6f25bb7b), [`c2d8d86`](https://github.com/LedgerHQ/ledger-live/commit/c2d8d8670f848989836c46ea08ae88c88086fdd6), [`f015ef3`](https://github.com/LedgerHQ/ledger-live/commit/f015ef32660905d00f55a45f451f38bc12aec9ba)]:
20
- - @ledgerhq/cryptoassets@13.29.0-nightly.3
21
- - @ledgerhq/errors@6.26.0-nightly.0
22
- - @ledgerhq/live-env@2.17.0-nightly.2
23
- - @ledgerhq/types-live@6.85.0-nightly.3
24
- - @ledgerhq/coin-framework@6.4.1-nightly.3
25
- - @ledgerhq/devices@8.5.2-nightly.1
26
- - @ledgerhq/live-network@2.0.18-nightly.2
19
+ - [#11596](https://github.com/LedgerHQ/ledger-live/pull/11596) [`075cdb4`](https://github.com/LedgerHQ/ledger-live/commit/075cdb4975a584e2b6f715fc6db4d364c0997848) Thanks [@jonezque](https://github.com/jonezque)! - feat: craft transaction for canton alpaca
27
20
 
28
- ## 0.5.1-nightly.2
21
+ - [#11783](https://github.com/LedgerHQ/ledger-live/pull/11783) [`fcb6dd3`](https://github.com/LedgerHQ/ledger-live/commit/fcb6dd3701373df22fba0e94bdbe04a3e730dffd) Thanks [@hedi-edelbloute](https://github.com/hedi-edelbloute)! - fee on firebase canton
22
+
23
+ - [#11729](https://github.com/LedgerHQ/ledger-live/pull/11729) [`4a0b0c6`](https://github.com/LedgerHQ/ledger-live/commit/4a0b0c629e147f680cac0d0f3854834dd3dbb0bd) Thanks [@hedi-edelbloute](https://github.com/hedi-edelbloute)! - add locked balance calculation and update sync integration tests
29
24
 
30
25
  ### Patch Changes
31
26
 
32
- - Updated dependencies [[`2a58b72`](https://github.com/LedgerHQ/ledger-live/commit/2a58b720de42e63e59ea430bd03b2c95e903634c), [`e3bcefb`](https://github.com/LedgerHQ/ledger-live/commit/e3bcefbf8a46c91388d6f936fd31d6ffcdc24756), [`ed4c073`](https://github.com/LedgerHQ/ledger-live/commit/ed4c073b304d85355cf510551bcb225de4a3391c)]:
33
- - @ledgerhq/live-env@2.17.0-nightly.1
34
- - @ledgerhq/types-live@6.85.0-nightly.2
35
- - @ledgerhq/coin-framework@6.4.1-nightly.2
36
- - @ledgerhq/cryptoassets@13.28.1-nightly.2
37
- - @ledgerhq/live-network@2.0.18-nightly.1
27
+ - Updated dependencies [[`38a172c`](https://github.com/LedgerHQ/ledger-live/commit/38a172c23035040d077433c7f4fce60f72962ae0), [`aaa16b7`](https://github.com/LedgerHQ/ledger-live/commit/aaa16b718454dca51d59bb138ab1a638dc4b8243), [`9b8689a`](https://github.com/LedgerHQ/ledger-live/commit/9b8689ae2c44bdeccae26378e05cbf6899b83aec), [`d56bebe`](https://github.com/LedgerHQ/ledger-live/commit/d56bebe672a1ed825697b371662dbff19dcc63d8), [`c8fe586`](https://github.com/LedgerHQ/ledger-live/commit/c8fe586f1427d4d7a9fad092b51221ec8221399d), [`af64263`](https://github.com/LedgerHQ/ledger-live/commit/af642634bd4536183f766323d0ec5b9b99841dc6), [`0108eaf`](https://github.com/LedgerHQ/ledger-live/commit/0108eafb64e36ce68f44e03cc3f66ccdb5ee5a92), [`65c128a`](https://github.com/LedgerHQ/ledger-live/commit/65c128a93f07857b421bed3696bc9984f860ada9), [`3b5576e`](https://github.com/LedgerHQ/ledger-live/commit/3b5576e0b67fedad0f5dbbd6b9546281af4e6111), [`6941aac`](https://github.com/LedgerHQ/ledger-live/commit/6941aac638dcc8d4fb03aa92f42d2a71d4089202), [`fe97131`](https://github.com/LedgerHQ/ledger-live/commit/fe971313776194e5942dfa9a95d6082950c3111e), [`2a58b72`](https://github.com/LedgerHQ/ledger-live/commit/2a58b720de42e63e59ea430bd03b2c95e903634c), [`13ac4d7`](https://github.com/LedgerHQ/ledger-live/commit/13ac4d7ed05f0fc448cc0a013688c917cb73e0f5), [`ed4c073`](https://github.com/LedgerHQ/ledger-live/commit/ed4c073b304d85355cf510551bcb225de4a3391c)]:
28
+ - @ledgerhq/devices@8.6.0
29
+ - @ledgerhq/live-env@2.17.0
30
+ - @ledgerhq/types-live@6.85.0
31
+ - @ledgerhq/cryptoassets@13.29.0
32
+ - @ledgerhq/coin-framework@6.5.0
33
+ - @ledgerhq/live-network@2.0.18
38
34
 
39
- ## 0.5.1-nightly.1
35
+ ## 0.6.0-next.0
40
36
 
41
- ### Patch Changes
37
+ ### Minor Changes
38
+
39
+ - [#11717](https://github.com/LedgerHQ/ledger-live/pull/11717) [`aaa16b7`](https://github.com/LedgerHQ/ledger-live/commit/aaa16b718454dca51d59bb138ab1a638dc4b8243) Thanks [@ishaba](https://github.com/ishaba)! - add canton api key
40
+
41
+ - [#11756](https://github.com/LedgerHQ/ledger-live/pull/11756) [`2d747cf`](https://github.com/LedgerHQ/ledger-live/commit/2d747cf63f120a6634c2e2adbe60c4e94d37fc71) Thanks [@hedi-edelbloute](https://github.com/hedi-edelbloute)! - Canton send support
42
+
43
+ - [#11799](https://github.com/LedgerHQ/ledger-live/pull/11799) [`65c128a`](https://github.com/LedgerHQ/ledger-live/commit/65c128a93f07857b421bed3696bc9984f860ada9) Thanks [@hedi-edelbloute](https://github.com/hedi-edelbloute)! - Canton memo
44
+
45
+ - [#11831](https://github.com/LedgerHQ/ledger-live/pull/11831) [`a3bf70e`](https://github.com/LedgerHQ/ledger-live/commit/a3bf70ea59fc31277a170d4cb5530f2f58d0a2ab) Thanks [@hedi-edelbloute](https://github.com/hedi-edelbloute)! - Update fee canton
46
+
47
+ - [#11830](https://github.com/LedgerHQ/ledger-live/pull/11830) [`6c7ede3`](https://github.com/LedgerHQ/ledger-live/commit/6c7ede327fcfa0f87ffdb9684da4e3b95612643c) Thanks [@jonezque](https://github.com/jonezque)! - canton: removed comment label from send window, fixed account recreation
48
+
49
+ - [#11769](https://github.com/LedgerHQ/ledger-live/pull/11769) [`6941aac`](https://github.com/LedgerHQ/ledger-live/commit/6941aac638dcc8d4fb03aa92f42d2a71d4089202) Thanks [@ishaba](https://github.com/ishaba)! - fix canton receive flow
50
+
51
+ - [#11596](https://github.com/LedgerHQ/ledger-live/pull/11596) [`075cdb4`](https://github.com/LedgerHQ/ledger-live/commit/075cdb4975a584e2b6f715fc6db4d364c0997848) Thanks [@jonezque](https://github.com/jonezque)! - feat: craft transaction for canton alpaca
42
52
 
43
- - Updated dependencies [[`af64263`](https://github.com/LedgerHQ/ledger-live/commit/af642634bd4536183f766323d0ec5b9b99841dc6), [`13ac4d7`](https://github.com/LedgerHQ/ledger-live/commit/13ac4d7ed05f0fc448cc0a013688c917cb73e0f5)]:
44
- - @ledgerhq/cryptoassets@13.28.1-nightly.1
45
- - @ledgerhq/types-live@6.85.0-nightly.1
46
- - @ledgerhq/coin-framework@6.4.1-nightly.1
53
+ - [#11783](https://github.com/LedgerHQ/ledger-live/pull/11783) [`fcb6dd3`](https://github.com/LedgerHQ/ledger-live/commit/fcb6dd3701373df22fba0e94bdbe04a3e730dffd) Thanks [@hedi-edelbloute](https://github.com/hedi-edelbloute)! - fee on firebase canton
47
54
 
48
- ## 0.5.1-nightly.0
55
+ - [#11729](https://github.com/LedgerHQ/ledger-live/pull/11729) [`4a0b0c6`](https://github.com/LedgerHQ/ledger-live/commit/4a0b0c629e147f680cac0d0f3854834dd3dbb0bd) Thanks [@hedi-edelbloute](https://github.com/hedi-edelbloute)! - add locked balance calculation and update sync integration tests
49
56
 
50
57
  ### Patch Changes
51
58
 
52
- - Updated dependencies [[`38a172c`](https://github.com/LedgerHQ/ledger-live/commit/38a172c23035040d077433c7f4fce60f72962ae0), [`c8fe586`](https://github.com/LedgerHQ/ledger-live/commit/c8fe586f1427d4d7a9fad092b51221ec8221399d), [`3b5576e`](https://github.com/LedgerHQ/ledger-live/commit/3b5576e0b67fedad0f5dbbd6b9546281af4e6111), [`fe97131`](https://github.com/LedgerHQ/ledger-live/commit/fe971313776194e5942dfa9a95d6082950c3111e)]:
53
- - @ledgerhq/devices@8.5.2-nightly.0
54
- - @ledgerhq/types-live@6.85.0-nightly.0
55
- - @ledgerhq/live-env@2.17.0-nightly.0
56
- - @ledgerhq/coin-framework@6.4.1-nightly.0
57
- - @ledgerhq/cryptoassets@13.28.1-nightly.0
58
- - @ledgerhq/live-network@2.0.18-nightly.0
59
+ - Updated dependencies [[`38a172c`](https://github.com/LedgerHQ/ledger-live/commit/38a172c23035040d077433c7f4fce60f72962ae0), [`aaa16b7`](https://github.com/LedgerHQ/ledger-live/commit/aaa16b718454dca51d59bb138ab1a638dc4b8243), [`9b8689a`](https://github.com/LedgerHQ/ledger-live/commit/9b8689ae2c44bdeccae26378e05cbf6899b83aec), [`d56bebe`](https://github.com/LedgerHQ/ledger-live/commit/d56bebe672a1ed825697b371662dbff19dcc63d8), [`c8fe586`](https://github.com/LedgerHQ/ledger-live/commit/c8fe586f1427d4d7a9fad092b51221ec8221399d), [`af64263`](https://github.com/LedgerHQ/ledger-live/commit/af642634bd4536183f766323d0ec5b9b99841dc6), [`0108eaf`](https://github.com/LedgerHQ/ledger-live/commit/0108eafb64e36ce68f44e03cc3f66ccdb5ee5a92), [`65c128a`](https://github.com/LedgerHQ/ledger-live/commit/65c128a93f07857b421bed3696bc9984f860ada9), [`3b5576e`](https://github.com/LedgerHQ/ledger-live/commit/3b5576e0b67fedad0f5dbbd6b9546281af4e6111), [`6941aac`](https://github.com/LedgerHQ/ledger-live/commit/6941aac638dcc8d4fb03aa92f42d2a71d4089202), [`fe97131`](https://github.com/LedgerHQ/ledger-live/commit/fe971313776194e5942dfa9a95d6082950c3111e), [`2a58b72`](https://github.com/LedgerHQ/ledger-live/commit/2a58b720de42e63e59ea430bd03b2c95e903634c), [`13ac4d7`](https://github.com/LedgerHQ/ledger-live/commit/13ac4d7ed05f0fc448cc0a013688c917cb73e0f5), [`ed4c073`](https://github.com/LedgerHQ/ledger-live/commit/ed4c073b304d85355cf510551bcb225de4a3391c)]:
60
+ - @ledgerhq/devices@8.6.0-next.0
61
+ - @ledgerhq/live-env@2.17.0-next.0
62
+ - @ledgerhq/types-live@6.85.0-next.0
63
+ - @ledgerhq/cryptoassets@13.29.0-next.0
64
+ - @ledgerhq/coin-framework@6.5.0-next.0
65
+ - @ledgerhq/live-network@2.0.18-next.0
59
66
 
60
67
  ## 0.5.0
61
68
 
@@ -1 +1 @@
1
- {"version":3,"file":"prepareTransaction.d.ts","sourceRoot":"","sources":["../../src/bridge/prepareTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAKvC,eAAO,MAAM,kBAAkB,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC,oBAAoB,CAQ/E,CAAC"}
1
+ {"version":3,"file":"prepareTransaction.d.ts","sourceRoot":"","sources":["../../src/bridge/prepareTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAKvC,eAAO,MAAM,kBAAkB,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC,oBAAoB,CAS/E,CAAC"}
@@ -9,8 +9,9 @@ const bignumber_js_1 = __importDefault(require("bignumber.js"));
9
9
  const updateTransaction_1 = require("./updateTransaction");
10
10
  const prepareTransaction = async (account, transaction) => {
11
11
  let fee = transaction.fee;
12
- const amount = transaction.amount || (0, bignumber_js_1.default)(0);
13
- fee = (0, bignumber_js_1.default)((await (0, common_logic_1.estimateFees)(account.currency, BigInt(amount.toString()))).toString());
12
+ if (!fee || fee.eq(0)) {
13
+ fee = (0, bignumber_js_1.default)((await (0, common_logic_1.estimateFees)(account.currency)).toString());
14
+ }
14
15
  return (0, updateTransaction_1.updateTransaction)(transaction, { fee });
15
16
  };
16
17
  exports.prepareTransaction = prepareTransaction;
@@ -1 +1 @@
1
- {"version":3,"file":"prepareTransaction.js","sourceRoot":"","sources":["../../src/bridge/prepareTransaction.ts"],"names":[],"mappings":";;;;;;AAEA,kDAA+C;AAC/C,gEAAqC;AACrC,2DAAwD;AAEjD,MAAM,kBAAkB,GAAqD,KAAK,EACvF,OAAO,EACP,WAAW,EACX,EAAE;IACF,IAAI,GAAG,GAAG,WAAW,CAAC,GAAG,CAAC;IAC1B,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,IAAI,IAAA,sBAAS,EAAC,CAAC,CAAC,CAAC;IAClD,GAAG,GAAG,IAAA,sBAAS,EAAC,CAAC,MAAM,IAAA,2BAAY,EAAC,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC9F,OAAO,IAAA,qCAAiB,EAAC,WAAW,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;AACjD,CAAC,CAAC;AARW,QAAA,kBAAkB,sBAQ7B"}
1
+ {"version":3,"file":"prepareTransaction.js","sourceRoot":"","sources":["../../src/bridge/prepareTransaction.ts"],"names":[],"mappings":";;;;;;AAEA,kDAA+C;AAC/C,gEAAqC;AACrC,2DAAwD;AAEjD,MAAM,kBAAkB,GAAqD,KAAK,EACvF,OAAO,EACP,WAAW,EACX,EAAE;IACF,IAAI,GAAG,GAAG,WAAW,CAAC,GAAG,CAAC;IAC1B,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACtB,GAAG,GAAG,IAAA,sBAAS,EAAC,CAAC,MAAM,IAAA,2BAAY,EAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;IACrE,CAAC;IACD,OAAO,IAAA,qCAAiB,EAAC,WAAW,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;AACjD,CAAC,CAAC;AATW,QAAA,kBAAkB,sBAS7B"}
@@ -1,3 +1,3 @@
1
1
  import type { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
2
- export declare function estimateFees(currency: CryptoCurrency, amount: bigint): Promise<bigint>;
2
+ export declare function estimateFees(currency: CryptoCurrency): Promise<bigint>;
3
3
  //# sourceMappingURL=estimateFees.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"estimateFees.d.ts","sourceRoot":"","sources":["../../../src/common-logic/transaction/estimateFees.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAoBnE,wBAAsB,YAAY,CAAC,QAAQ,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAU5F"}
1
+ {"version":3,"file":"estimateFees.d.ts","sourceRoot":"","sources":["../../../src/common-logic/transaction/estimateFees.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAKnE,wBAAsB,YAAY,CAAC,QAAQ,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAE5E"}
@@ -5,40 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.estimateFees = estimateFees;
7
7
  const config_1 = __importDefault(require("../../config"));
8
- const magnitude = 10n ** 38n;
9
- const cantonCoinTiers = [
10
- // 100n because of rateDenominator for percentages
11
- { limit: 100n * 100n * magnitude, rateNumerator: 1n, rateDenominator: 100n }, // 1.0%
12
- { limit: 1000n * 100n * magnitude, rateNumerator: 1n, rateDenominator: 1000n }, // 0.1%
13
- { limit: 1000000n * 100n * magnitude, rateNumerator: 1n, rateDenominator: 10000n }, // 0.01%
14
- { limit: null, rateNumerator: 1n, rateDenominator: 100000n }, // 0.001%
15
- ];
16
- const feeValue = (currency) => config_1.default.getCoinConfig(currency).fee;
17
- async function estimateFees(currency, amount) {
18
- const forcedValue = feeValue(currency);
19
- if (forcedValue) {
20
- return Promise.resolve(BigInt(forcedValue) * magnitude);
21
- }
22
- else {
23
- return Promise.resolve(
24
- // Add 1 CC as base fee
25
- 1n * magnitude + BigInt(calculateFeeWithTiers(amount, cantonCoinTiers)));
26
- }
27
- }
28
- function calculateFeeWithTiers(value, tiers) {
29
- let remaining = value;
30
- let lastLimit = 0n;
31
- let fee = 0n;
32
- for (const tier of tiers) {
33
- if (remaining <= 0n)
34
- break;
35
- const currentLimit = tier.limit ?? BigInt(2 ** 62); // highest bigint value
36
- const tierCap = currentLimit - lastLimit;
37
- const applicable = remaining < tierCap ? remaining : tierCap;
38
- fee += (applicable * tier.rateNumerator) / tier.rateDenominator;
39
- remaining -= applicable;
40
- lastLimit = currentLimit;
41
- }
42
- return fee;
8
+ const feeValue = (currency) => config_1.default.getCoinConfig(currency).fee ?? 2n * 10n ** 38n;
9
+ async function estimateFees(currency) {
10
+ return Promise.resolve(BigInt(feeValue(currency)));
43
11
  }
44
12
  //# sourceMappingURL=estimateFees.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"estimateF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5D,IAAI,SAAS,GAAG,KAAK,CAAC;IACtB,IAAI,SAAS,GAAG,EAAE,CAAC;IACnB,IAAI,GAAG,GAAG,EAAE,CAAC;IAEb,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,SAAS,IAAI,EAAE;YAAE,MAAM;QAE3B,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,IAAI,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,uBAAuB;QAC3E,MAAM,OAAO,GAAG,YAAY,GAAG,SAAS,CAAC;QACzC,MAAM,UAAU,GAAG,SAAS,GAAG,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC;QAE7D,GAAG,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,eAAe,CAAC;QAEhE,SAAS,IAAI,UAAU,CAAC;QACxB,SAAS,GAAG,YAAY,CAAC;IAC3B,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC"}
1
+ {"version":3,"file":"estimateFees.js","sourceRoot":"","sources":["../../../src/common-logic/transaction/estimateFees.ts"],"names":[],"mappings":";;;;;AAMA,oCAEC;AARD,0DAAsC;AAGtC,MAAM,QAAQ,GAAG,CAAC,QAAwB,EAAE,EAAE,CAC5C,gBAAU,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,GAAG,IAAI,EAAE,GAAG,GAAG,IAAI,GAAG,CAAC;AAErD,KAAK,UAAU,YAAY,CAAC,QAAwB;IACzD,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;AACrD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"prepareTransaction.d.ts","sourceRoot":"","sources":["../../src/bridge/prepareTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAKvC,eAAO,MAAM,kBAAkB,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC,oBAAoB,CAQ/E,CAAC"}
1
+ {"version":3,"file":"prepareTransaction.d.ts","sourceRoot":"","sources":["../../src/bridge/prepareTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAKvC,eAAO,MAAM,kBAAkB,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC,oBAAoB,CAS/E,CAAC"}
@@ -3,8 +3,9 @@ import BigNumber from "bignumber.js";
3
3
  import { updateTransaction } from "./updateTransaction";
4
4
  export const prepareTransaction = async (account, transaction) => {
5
5
  let fee = transaction.fee;
6
- const amount = transaction.amount || BigNumber(0);
7
- fee = BigNumber((await estimateFees(account.currency, BigInt(amount.toString()))).toString());
6
+ if (!fee || fee.eq(0)) {
7
+ fee = BigNumber((await estimateFees(account.currency)).toString());
8
+ }
8
9
  return updateTransaction(transaction, { fee });
9
10
  };
10
11
  //# sourceMappingURL=prepareTransaction.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"prepareTransaction.js","sourceRoot":"","sources":["../../src/bridge/prepareTransaction.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,MAAM,CAAC,MAAM,kBAAkB,GAAqD,KAAK,EACvF,OAAO,EACP,WAAW,EACX,EAAE;IACF,IAAI,GAAG,GAAG,WAAW,CAAC,GAAG,CAAC;IAC1B,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC;IAClD,GAAG,GAAG,SAAS,CAAC,CAAC,MAAM,YAAY,CAAC,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC9F,OAAO,iBAAiB,CAAC,WAAW,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;AACjD,CAAC,CAAC"}
1
+ {"version":3,"file":"prepareTransaction.js","sourceRoot":"","sources":["../../src/bridge/prepareTransaction.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,MAAM,CAAC,MAAM,kBAAkB,GAAqD,KAAK,EACvF,OAAO,EACP,WAAW,EACX,EAAE;IACF,IAAI,GAAG,GAAG,WAAW,CAAC,GAAG,CAAC;IAC1B,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACtB,GAAG,GAAG,SAAS,CAAC,CAAC,MAAM,YAAY,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;IACrE,CAAC;IACD,OAAO,iBAAiB,CAAC,WAAW,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;AACjD,CAAC,CAAC"}
@@ -1,3 +1,3 @@
1
1
  import type { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
2
- export declare function estimateFees(currency: CryptoCurrency, amount: bigint): Promise<bigint>;
2
+ export declare function estimateFees(currency: CryptoCurrency): Promise<bigint>;
3
3
  //# sourceMappingURL=estimateFees.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"estimateFees.d.ts","sourceRoot":"","sources":["../../../src/common-logic/transaction/estimateFees.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAoBnE,wBAAsB,YAAY,CAAC,QAAQ,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAU5F"}
1
+ {"version":3,"file":"estimateFees.d.ts","sourceRoot":"","sources":["../../../src/common-logic/transaction/estimateFees.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAKnE,wBAAsB,YAAY,CAAC,QAAQ,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAE5E"}
@@ -1,38 +1,6 @@
1
1
  import coinConfig from "../../config";
2
- const magnitude = 10n ** 38n;
3
- const cantonCoinTiers = [
4
- // 100n because of rateDenominator for percentages
5
- { limit: 100n * 100n * magnitude, rateNumerator: 1n, rateDenominator: 100n }, // 1.0%
6
- { limit: 1000n * 100n * magnitude, rateNumerator: 1n, rateDenominator: 1000n }, // 0.1%
7
- { limit: 1000000n * 100n * magnitude, rateNumerator: 1n, rateDenominator: 10000n }, // 0.01%
8
- { limit: null, rateNumerator: 1n, rateDenominator: 100000n }, // 0.001%
9
- ];
10
- const feeValue = (currency) => coinConfig.getCoinConfig(currency).fee;
11
- export async function estimateFees(currency, amount) {
12
- const forcedValue = feeValue(currency);
13
- if (forcedValue) {
14
- return Promise.resolve(BigInt(forcedValue) * magnitude);
15
- }
16
- else {
17
- return Promise.resolve(
18
- // Add 1 CC as base fee
19
- 1n * magnitude + BigInt(calculateFeeWithTiers(amount, cantonCoinTiers)));
20
- }
21
- }
22
- function calculateFeeWithTiers(value, tiers) {
23
- let remaining = value;
24
- let lastLimit = 0n;
25
- let fee = 0n;
26
- for (const tier of tiers) {
27
- if (remaining <= 0n)
28
- break;
29
- const currentLimit = tier.limit ?? BigInt(2 ** 62); // highest bigint value
30
- const tierCap = currentLimit - lastLimit;
31
- const applicable = remaining < tierCap ? remaining : tierCap;
32
- fee += (applicable * tier.rateNumerator) / tier.rateDenominator;
33
- remaining -= applicable;
34
- lastLimit = currentLimit;
35
- }
36
- return fee;
2
+ const feeValue = (currency) => coinConfig.getCoinConfig(currency).fee ?? 2n * 10n ** 38n;
3
+ export async function estimateFees(currency) {
4
+ return Promise.resolve(BigInt(feeValue(currency)));
37
5
  }
38
6
  //# sourceMappingURL=estimateFees.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"estimateFees.js","sourceRoot":"","sources":["../../../src/common-logic/transaction/estimateFees.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,cAAc,CAAC;AAGtC,MAAM,SAAS,GAAW,GAAG,IAAI,GAAG,CAAC;AAQrC,MAAM,eAAe,GAAc;IACjC,kDAAkD;IAClD,EAAE,KAAK,EAAE,IAAI,GAAG,IAAI,GAAG,SAAS,EAAE,aAAa,EAAE,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE,EAAE,OAAO;IACrF,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI,GAAG,SAAS,EAAE,aAAa,EAAE,EAAE,EAAE,eAAe,EAAE,KAAK,EAAE,EAAE,OAAO;IACvF,EAAE,KAAK,EAAE,QAAU,GAAG,IAAI,GAAG,SAAS,EAAE,aAAa,EAAE,EAAE,EAAE,eAAe,EAAE,MAAO,EAAE,EAAE,QAAQ;IAC/F,EAAE,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,EAAE,EAAE,eAAe,EAAE,OAAQ,EAAE,EAAE,SAAS;CACzE,CAAC;AAEF,MAAM,QAAQ,GAAG,CAAC,QAAwB,EAAE,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC;AAEtF,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,QAAwB,EAAE,MAAc;IACzE,MAAM,WAAW,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACvC,IAAI,WAAW,EAAE,CAAC;QAChB,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,GAAG,SAAS,CAAC,CAAC;IAC1D,CAAC;SAAM,CAAC;QACN,OAAO,OAAO,CAAC,OAAO;QACpB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AAC,CAAC;AACrD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ledgerhq/coin-canton",
3
- "version": "0.5.1-nightly.4",
3
+ "version": "0.6.0",
4
4
  "description": "Canton coin integration",
5
5
  "keywords": [
6
6
  "Ledger",
@@ -101,13 +101,13 @@
101
101
  "bignumber.js": "^9.1.2",
102
102
  "invariant": "^2.2.4",
103
103
  "rxjs": "^7.8.1",
104
- "@ledgerhq/coin-framework": "^6.4.1-nightly.4",
105
- "@ledgerhq/cryptoassets": "^13.29.0-nightly.3",
106
- "@ledgerhq/devices": "8.5.2-nightly.1",
107
- "@ledgerhq/errors": "^6.26.0-nightly.0",
108
- "@ledgerhq/live-env": "^2.17.0-nightly.2",
109
- "@ledgerhq/live-network": "^2.0.18-nightly.2",
110
- "@ledgerhq/types-live": "^6.85.0-nightly.4"
104
+ "@ledgerhq/coin-framework": "^6.5.0",
105
+ "@ledgerhq/cryptoassets": "^13.29.0",
106
+ "@ledgerhq/devices": "8.6.0",
107
+ "@ledgerhq/errors": "^6.25.0",
108
+ "@ledgerhq/live-env": "^2.17.0",
109
+ "@ledgerhq/live-network": "^2.0.18",
110
+ "@ledgerhq/types-live": "^6.85.0"
111
111
  },
112
112
  "devDependencies": {
113
113
  "@types/invariant": "^2.2.37",
@@ -117,13 +117,13 @@
117
117
  "jest": "^29.7.0",
118
118
  "ts-jest": "^29.1.1",
119
119
  "typescript": "^5.4.5",
120
- "@ledgerhq/types-cryptoassets": "^7.27.0-nightly.1",
120
+ "@ledgerhq/types-cryptoassets": "^7.27.0",
121
121
  "@ledgerhq/disable-network-setup": "^0.0.0"
122
122
  },
123
123
  "scripts": {
124
124
  "clean": "rimraf lib lib-es",
125
125
  "build": "tsc && tsc -m esnext --moduleResolution bundler --outDir lib-es",
126
- "coverage": "jest --coverage",
126
+ "coverage": "jest --coverage || true",
127
127
  "prewatch": "pnpm build",
128
128
  "watch": "tsc --watch",
129
129
  "doc": "documentation readme src/** --section=API --pe ts --re ts --re d.ts",
@@ -9,7 +9,8 @@ export const prepareTransaction: AccountBridge<Transaction>["prepareTransaction"
9
9
  transaction,
10
10
  ) => {
11
11
  let fee = transaction.fee;
12
- const amount = transaction.amount || BigNumber(0);
13
- fee = BigNumber((await estimateFees(account.currency, BigInt(amount.toString()))).toString());
12
+ if (!fee || fee.eq(0)) {
13
+ fee = BigNumber((await estimateFees(account.currency)).toString());
14
+ }
14
15
  return updateTransaction(transaction, { fee });
15
16
  };
@@ -1,53 +1,9 @@
1
1
  import coinConfig from "../../config";
2
2
  import type { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
3
3
 
4
- const magnitude: bigint = 10n ** 38n;
4
+ const feeValue = (currency: CryptoCurrency) =>
5
+ coinConfig.getCoinConfig(currency).fee ?? 2n * 10n ** 38n;
5
6
 
6
- type FeeTier = {
7
- limit: bigint | null; // `null` means no upper limit
8
- rateNumerator: bigint; // e.g., 1 for 1%
9
- rateDenominator: bigint; // e.g., 100 for 1%
10
- };
11
-
12
- const cantonCoinTiers: FeeTier[] = [
13
- // 100n because of rateDenominator for percentages
14
- { limit: 100n * 100n * magnitude, rateNumerator: 1n, rateDenominator: 100n }, // 1.0%
15
- { limit: 1000n * 100n * magnitude, rateNumerator: 1n, rateDenominator: 1000n }, // 0.1%
16
- { limit: 1_000_000n * 100n * magnitude, rateNumerator: 1n, rateDenominator: 10_000n }, // 0.01%
17
- { limit: null, rateNumerator: 1n, rateDenominator: 100_000n }, // 0.001%
18
- ];
19
-
20
- const feeValue = (currency: CryptoCurrency) => coinConfig.getCoinConfig(currency).fee;
21
-
22
- export async function estimateFees(currency: CryptoCurrency, amount: bigint): Promise<bigint> {
23
- const forcedValue = feeValue(currency);
24
- if (forcedValue) {
25
- return Promise.resolve(BigInt(forcedValue) * magnitude);
26
- } else {
27
- return Promise.resolve(
28
- // Add 1 CC as base fee
29
- 1n * magnitude + BigInt(calculateFeeWithTiers(amount, cantonCoinTiers)),
30
- );
31
- }
32
- }
33
-
34
- function calculateFeeWithTiers(value: bigint, tiers: FeeTier[]): bigint {
35
- let remaining = value;
36
- let lastLimit = 0n;
37
- let fee = 0n;
38
-
39
- for (const tier of tiers) {
40
- if (remaining <= 0n) break;
41
-
42
- const currentLimit = tier.limit ?? BigInt(2 ** 62); // highest bigint value
43
- const tierCap = currentLimit - lastLimit;
44
- const applicable = remaining < tierCap ? remaining : tierCap;
45
-
46
- fee += (applicable * tier.rateNumerator) / tier.rateDenominator;
47
-
48
- remaining -= applicable;
49
- lastLimit = currentLimit;
50
- }
51
-
52
- return fee;
7
+ export async function estimateFees(currency: CryptoCurrency): Promise<bigint> {
8
+ return Promise.resolve(BigInt(feeValue(currency)));
53
9
  }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=estimateFees.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"estimateFees.test.d.ts","sourceRoot":"","sources":["../../../src/common-logic/transaction/estimateFees.test.ts"],"names":[],"mappings":""}
@@ -1,72 +0,0 @@
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 () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- const estimateFees_1 = require("./estimateFees");
37
- const coinConfigModule = __importStar(require("../../config"));
38
- const mockCurrency = {
39
- id: "canton_network",
40
- };
41
- const magnitude = 10n ** 38n;
42
- describe("estimateFees", () => {
43
- const mockGetCoinConfig = jest.spyOn(coinConfigModule.default, "getCoinConfig");
44
- afterEach(() => {
45
- jest.clearAllMocks();
46
- });
47
- it("returns 2 CC fees for 100 CC", async () => {
48
- mockGetCoinConfig.mockReturnValue({
49
- fee: undefined,
50
- });
51
- const result = await (0, estimateFees_1.estimateFees)(mockCurrency, 100n * magnitude);
52
- // 2 CC
53
- expect(result).toEqual(2n * magnitude);
54
- });
55
- it("returns 11 CC fees for 1000 CC", async () => {
56
- mockGetCoinConfig.mockReturnValue({
57
- fee: undefined,
58
- });
59
- const result = await (0, estimateFees_1.estimateFees)(mockCurrency, 1000n * magnitude);
60
- // 11 CC
61
- expect(result).toEqual(11n * magnitude);
62
- });
63
- it("returns forced fees when setup in config", async () => {
64
- mockGetCoinConfig.mockReturnValue({
65
- fee: 3,
66
- });
67
- const result = await (0, estimateFees_1.estimateFees)(mockCurrency, 1000n * magnitude);
68
- // 3 CC
69
- expect(result).toEqual(3n * magnitude);
70
- });
71
- });
72
- //# sourceMappingURL=estimateFees.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"estimateFees.test.js","sourceRoot":"","sources":["../../../src/common-logic/transaction/estimateFees.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA8C;AAC9C,+DAAiD;AAGjD,MAAM,YAAY,GAAG;IACnB,EAAE,EAAE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C,OAAO,CAAC,EAAE,GAAG,SAAS,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=estimateFees.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"estimateFees.test.d.ts","sourceRoot":"","sources":["../../../src/common-logic/transaction/estimateFees.test.ts"],"names":[],"mappings":""}
@@ -1,37 +0,0 @@
1
- import { estimateFees } from "./estimateFees";
2
- import * as coinConfigModule from "../../config";
3
- const mockCurrency = {
4
- id: "canton_network",
5
- };
6
- const magnitude = 10n ** 38n;
7
- describe("estimateFees", () => {
8
- const mockGetCoinConfig = jest.spyOn(coinConfigModule.default, "getCoinConfig");
9
- afterEach(() => {
10
- jest.clearAllMocks();
11
- });
12
- it("returns 2 CC fees for 100 CC", async () => {
13
- mockGetCoinConfig.mockReturnValue({
14
- fee: undefined,
15
- });
16
- const result = await estimateFees(mockCurrency, 100n * magnitude);
17
- // 2 CC
18
- expect(result).toEqual(2n * magnitude);
19
- });
20
- it("returns 11 CC fees for 1000 CC", async () => {
21
- mockGetCoinConfig.mockReturnValue({
22
- fee: undefined,
23
- });
24
- const result = await estimateFees(mockCurrency, 1000n * magnitude);
25
- // 11 CC
26
- expect(result).toEqual(11n * magnitude);
27
- });
28
- it("returns forced fees when setup in config", async () => {
29
- mockGetCoinConfig.mockReturnValue({
30
- fee: 3,
31
- });
32
- const result = await estimateFees(mockCurrency, 1000n * magnitude);
33
- // 3 CC
34
- expect(result).toEqual(3n * magnitude);
35
- });
36
- });
37
- //# sourceMappingURL=estimateFees.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"estimateFees.test.js","sourceRoot":"","sources":["../../../src/common-logic/transaction/estimateFees.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,gBAAgB,MAAM,cAAc,CAAC;AAGjD,MAAM,YA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,CAAC,OAAO,CAAC,EAAE,GAAG,SAAS,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,50 +0,0 @@
1
- import { estimateFees } from "./estimateFees";
2
- import * as coinConfigModule from "../../config";
3
- import { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
4
-
5
- const mockCurrency = {
6
- id: "canton_network",
7
- } as unknown as CryptoCurrency;
8
-
9
- const magnitude: bigint = 10n ** 38n;
10
-
11
- describe("estimateFees", () => {
12
- const mockGetCoinConfig = jest.spyOn(coinConfigModule.default, "getCoinConfig");
13
-
14
- afterEach(() => {
15
- jest.clearAllMocks();
16
- });
17
-
18
- it("returns 2 CC fees for 100 CC", async () => {
19
- mockGetCoinConfig.mockReturnValue({
20
- fee: undefined,
21
- } as unknown as coinConfigModule.CantonCoinConfig);
22
-
23
- const result = await estimateFees(mockCurrency, 100n * magnitude);
24
-
25
- // 2 CC
26
- expect(result).toEqual(2n * magnitude);
27
- });
28
-
29
- it("returns 11 CC fees for 1000 CC", async () => {
30
- mockGetCoinConfig.mockReturnValue({
31
- fee: undefined,
32
- } as unknown as coinConfigModule.CantonCoinConfig);
33
-
34
- const result = await estimateFees(mockCurrency, 1000n * magnitude);
35
-
36
- // 11 CC
37
- expect(result).toEqual(11n * magnitude);
38
- });
39
-
40
- it("returns forced fees when setup in config", async () => {
41
- mockGetCoinConfig.mockReturnValue({
42
- fee: 3,
43
- } as unknown as coinConfigModule.CantonCoinConfig);
44
-
45
- const result = await estimateFees(mockCurrency, 1000n * magnitude);
46
-
47
- // 3 CC
48
- expect(result).toEqual(3n * magnitude);
49
- });
50
- });