@trezor/connect 9.1.1 → 9.1.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 (135) hide show
  1. package/CHANGELOG.md +17 -3
  2. package/README.md +2 -2
  3. package/lib/api/backupDevice.d.ts +1 -1
  4. package/lib/api/binanceGetAddress.d.ts +1 -0
  5. package/lib/api/binanceGetAddress.js +4 -4
  6. package/lib/api/binanceGetPublicKey.d.ts +1 -0
  7. package/lib/api/binanceGetPublicKey.js +3 -1
  8. package/lib/api/binanceSignTransaction.d.ts +2 -1
  9. package/lib/api/binanceSignTransaction.js +3 -1
  10. package/lib/api/bitcoin/Fees.d.ts +2 -2
  11. package/lib/api/bitcoin/Fees.js +32 -90
  12. package/lib/api/bitcoin/TransactionComposer.d.ts +1 -2
  13. package/lib/api/bitcoin/TransactionComposer.js +3 -2
  14. package/lib/api/bitcoin/refTx.d.ts +10 -2
  15. package/lib/api/bitcoin/refTx.js +46 -19
  16. package/lib/api/blockchainDisconnect.d.ts +1 -0
  17. package/lib/api/blockchainDisconnect.js +3 -1
  18. package/lib/api/blockchainEstimateFee.js +1 -1
  19. package/lib/api/blockchainSetCustomBackend.d.ts +1 -0
  20. package/lib/api/blockchainSetCustomBackend.js +3 -1
  21. package/lib/api/cancelCoinjoinAuthorization.d.ts +1 -0
  22. package/lib/api/cancelCoinjoinAuthorization.js +3 -1
  23. package/lib/api/cardanoGetAddress.d.ts +1 -0
  24. package/lib/api/cardanoGetAddress.js +4 -4
  25. package/lib/api/cardanoGetNativeScriptHash.d.ts +1 -0
  26. package/lib/api/cardanoGetNativeScriptHash.js +3 -1
  27. package/lib/api/cardanoGetPublicKey.d.ts +1 -0
  28. package/lib/api/cardanoGetPublicKey.js +4 -2
  29. package/lib/api/cardanoSignTransaction.d.ts +1 -0
  30. package/lib/api/cardanoSignTransaction.js +3 -1
  31. package/lib/api/checkFirmwareAuthenticity.js +2 -1
  32. package/lib/api/cipherKeyValue.d.ts +1 -0
  33. package/lib/api/cipherKeyValue.js +3 -1
  34. package/lib/api/composeTransaction.d.ts +3 -0
  35. package/lib/api/composeTransaction.js +9 -7
  36. package/lib/api/eosGetPublicKey.d.ts +1 -0
  37. package/lib/api/eosGetPublicKey.js +3 -1
  38. package/lib/api/eosSignTransaction.d.ts +1 -0
  39. package/lib/api/eosSignTransaction.js +3 -1
  40. package/lib/api/ethereum/ethereumDefinitions.d.ts +28 -6
  41. package/lib/api/ethereum/ethereumDefinitions.js +60 -1
  42. package/lib/api/ethereum/ethereumSignTx.d.ts +1 -1
  43. package/lib/api/ethereumGetAddress.d.ts +2 -0
  44. package/lib/api/ethereumGetAddress.js +28 -26
  45. package/lib/api/ethereumGetPublicKey.d.ts +1 -0
  46. package/lib/api/ethereumGetPublicKey.js +8 -10
  47. package/lib/api/ethereumSignMessage.d.ts +10 -1
  48. package/lib/api/ethereumSignMessage.js +14 -13
  49. package/lib/api/ethereumSignTransaction.d.ts +6 -0
  50. package/lib/api/ethereumSignTransaction.js +18 -5
  51. package/lib/api/ethereumSignTypedData.d.ts +6 -0
  52. package/lib/api/ethereumSignTypedData.js +15 -13
  53. package/lib/api/ethereumVerifyMessage.d.ts +1 -0
  54. package/lib/api/ethereumVerifyMessage.js +3 -1
  55. package/lib/api/getAccountInfo.d.ts +1 -0
  56. package/lib/api/getAccountInfo.js +3 -1
  57. package/lib/api/getAddress.d.ts +1 -0
  58. package/lib/api/getAddress.js +8 -10
  59. package/lib/api/getFeatures.d.ts +1 -1
  60. package/lib/api/getOwnershipId.d.ts +1 -0
  61. package/lib/api/getOwnershipId.js +3 -1
  62. package/lib/api/getOwnershipProof.d.ts +1 -0
  63. package/lib/api/getOwnershipProof.js +3 -1
  64. package/lib/api/getPublicKey.d.ts +1 -0
  65. package/lib/api/getPublicKey.js +4 -2
  66. package/lib/api/nemGetAddress.d.ts +1 -0
  67. package/lib/api/nemGetAddress.js +4 -4
  68. package/lib/api/nemSignTransaction.d.ts +1 -0
  69. package/lib/api/nemSignTransaction.js +3 -1
  70. package/lib/api/rebootToBootloader.d.ts +2 -1
  71. package/lib/api/rebootToBootloader.js +3 -1
  72. package/lib/api/requestLogin.d.ts +1 -0
  73. package/lib/api/requestLogin.js +3 -1
  74. package/lib/api/resetDevice.d.ts +1 -0
  75. package/lib/api/resetDevice.js +3 -1
  76. package/lib/api/rippleGetAddress.d.ts +1 -0
  77. package/lib/api/rippleGetAddress.js +4 -4
  78. package/lib/api/rippleSignTransaction.d.ts +1 -0
  79. package/lib/api/rippleSignTransaction.js +3 -1
  80. package/lib/api/showDeviceTutorial.d.ts +1 -0
  81. package/lib/api/showDeviceTutorial.js +3 -1
  82. package/lib/api/signMessage.d.ts +1 -0
  83. package/lib/api/signMessage.js +5 -1
  84. package/lib/api/signTransaction.d.ts +1 -0
  85. package/lib/api/signTransaction.js +16 -4
  86. package/lib/api/stellarGetAddress.d.ts +1 -0
  87. package/lib/api/stellarGetAddress.js +4 -4
  88. package/lib/api/stellarSignTransaction.d.ts +1 -0
  89. package/lib/api/stellarSignTransaction.js +3 -1
  90. package/lib/api/tezosGetAddress.d.ts +1 -0
  91. package/lib/api/tezosGetAddress.js +4 -4
  92. package/lib/api/tezosGetPublicKey.d.ts +1 -0
  93. package/lib/api/tezosGetPublicKey.js +3 -1
  94. package/lib/api/tezosSignTransaction.d.ts +1 -0
  95. package/lib/api/tezosSignTransaction.js +3 -1
  96. package/lib/api/verifyMessage.d.ts +1 -0
  97. package/lib/api/verifyMessage.js +7 -2
  98. package/lib/api/wipeDevice.d.ts +2 -1
  99. package/lib/api/wipeDevice.js +3 -1
  100. package/lib/backend/Blockchain.d.ts +1 -3
  101. package/lib/backend/Blockchain.js +10 -6
  102. package/lib/constants/index.d.ts +1 -1
  103. package/lib/constants/index.js +1 -1
  104. package/lib/core/AbstractMethod.d.ts +3 -1
  105. package/lib/core/AbstractMethod.js +3 -1
  106. package/lib/core/index.js +9 -1
  107. package/lib/data/DataManager.js +4 -1
  108. package/lib/data/analyticsInfo.js +1 -1
  109. package/lib/data/coinInfo.d.ts +9 -0
  110. package/lib/data/coinInfo.js +10 -41
  111. package/lib/data/config.js +5 -1
  112. package/lib/data/defaultFeeLevels.d.ts +17 -0
  113. package/lib/data/defaultFeeLevels.js +84 -0
  114. package/lib/data/version.d.ts +1 -1
  115. package/lib/data/version.js +1 -1
  116. package/lib/device/Device.d.ts +2 -2
  117. package/lib/device/Device.js +9 -7
  118. package/lib/device/DeviceCommands.js +6 -1
  119. package/lib/events/popup.d.ts +8 -1
  120. package/lib/events/popup.js +1 -0
  121. package/lib/events/ui-request.d.ts +2 -2
  122. package/lib/types/account.d.ts +1 -20
  123. package/lib/types/api/bitcoin/index.d.ts +2 -0
  124. package/lib/types/api/blockchainEstimateFee.d.ts +2 -5
  125. package/lib/types/coinInfo.d.ts +5 -17
  126. package/lib/types/device.d.ts +5 -2
  127. package/lib/types/device.js +7 -2
  128. package/lib/types/fees.d.ts +26 -0
  129. package/lib/types/fees.js +3 -0
  130. package/lib/types/index.d.ts +2 -1
  131. package/lib/types/index.js +1 -0
  132. package/lib/utils/assetUtils.js +3 -1
  133. package/lib/utils/urlUtils.d.ts +10 -3
  134. package/lib/utils/urlUtils.js +5 -9
  135. package/package.json +10 -8
package/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ # 9.1.3
2
+
3
+ - fix(connect): correct import of internal connect dependency (https://github.com/trezor/trezor-suite/issues/9389)
4
+
5
+ # 9.1.2
6
+
7
+ - feat(connect): analytics method name and method param names (23df6d8)
8
+ - feat(connect): improve calculation of fees and dust limit. (d726aab, 9d1ef05, 60f1e26, 2187c34, d84e3ca)
9
+ - fix(connect): device.firmwareType can't be safely determined in bootloader mode so we set it to undefined (c3d33a0)
10
+ - feat(connect): signTransaction with refTxs passed as AccountTransaction interface (d7ec435)
11
+ - feat(connect): decoding ethereum definitions which allows richer UI in connect-popup (0e9356f)
12
+ - feat(connect-explorer): updated examples ethereum (b025834, e58c416), applySettings (1a28816)
13
+ - feat(connect-explorer): render docs from docs folder on index page (93fddc4)
14
+
1
15
  # 9.1.1
2
16
 
3
17
  - feat(connect-popup): added device model_internal in features
@@ -24,12 +38,12 @@
24
38
 
25
39
  # 9.0.8
26
40
 
27
- - feat: support multiple intermediary FWs for T1 and devkit binaries
41
+ - feat: support multiple intermediary FWs for T1B1 and devkit binaries
28
42
  - `FirmwareUpdate` now accepts `intermediaryVersion` param instead of `intermediary`
29
- - `getInfo` returns `intermediaryVersion` needed for T1 and removed `latest` param. 'release' always return latest version for T1 so it means abandoning the concept of incremental updates for T1.
43
+ - `getInfo` returns `intermediaryVersion` needed for T1B1 and removed `latest` param. 'release' always return latest version for T1B1 so it means abandoning the concept of incremental updates for T1B1.
30
44
  - feat: signTransaction now returns `signedTransaction` which can be used for visualization purposes before notification about pending transaction from blockchain is received.
31
45
  - feat(blockchain): `blockchainGetCurrentFiatRates` and `blockchainGetFiatRatesForTimestamps` now accept additional `token` parameter
32
- - feat: support coinjoin for T1
46
+ - feat: support coinjoin for T1B1
33
47
  - feat(transport): eth definitions
34
48
  - feat(webextension): Ignore port events if it is not port created by current popup
35
49
  - feat(cardano): allow external reward addresses in governance registrations
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @trezor/connect
2
2
 
3
- API version 9.1.1
3
+ API version 9.1.3
4
4
 
5
5
  [![Build Status](https://github.com/trezor/trezor-suite/actions/workflows/connect-test.yml/badge.svg)](https://github.com/trezor/trezor-suite/actions/workflows/connect-test.yml)
6
6
  [![NPM](https://img.shields.io/npm/v/@trezor/connect.svg)](https://www.npmjs.org/package/@trezor/connect)
@@ -86,4 +86,4 @@ A collection of examples on how to implement @trezor/connect in various environm
86
86
 
87
87
  ## Tests
88
88
 
89
- For integration testing against trezord and emulator refer to [this document](https://github.com/trezor/trezor-suite/blob/develop/packages/integration-tests/projects/connect/README.md).
89
+ For integration testing against trezord and emulator refer to [this document](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/e2e/README.md).
@@ -2,6 +2,6 @@ import { AbstractMethod } from '../core/AbstractMethod';
2
2
  export default class BackupDevice extends AbstractMethod<'backupDevice'> {
3
3
  init(): void;
4
4
  confirmation(): Promise<boolean>;
5
- run(): Promise<import("packages/transport/lib/types/messages").Success>;
5
+ run(): Promise<import("packages/protobuf/lib/messages").Success>;
6
6
  }
7
7
  //# sourceMappingURL=backupDevice.d.ts.map
@@ -8,6 +8,7 @@ export default class BinanceGetAddress extends AbstractMethod<'binanceGetAddress
8
8
  progress: number;
9
9
  confirmed?: boolean;
10
10
  init(): void;
11
+ get info(): string;
11
12
  getButtonRequestData(code: string): {
12
13
  type: "address";
13
14
  serializedPath: string;
@@ -41,12 +41,12 @@ class BinanceGetAddress extends AbstractMethod_1.AbstractMethod {
41
41
  this.params[0].show_display;
42
42
  this.confirmed = useEventListener;
43
43
  this.useUi = !useEventListener;
44
+ }
45
+ get info() {
44
46
  if (this.params.length === 1) {
45
- this.info = `Export Binance address for account #${(0, pathUtils_1.fromHardened)(this.params[0].address_n[2]) + 1}`;
46
- }
47
- else {
48
- this.info = 'Export multiple Binance addresses';
47
+ return `Export Binance address for account #${(0, pathUtils_1.fromHardened)(this.params[0].address_n[2]) + 1}`;
49
48
  }
49
+ return 'Export multiple Binance addresses';
50
50
  }
51
51
  getButtonRequestData(code) {
52
52
  if (code === 'ButtonRequest_Address') {
@@ -4,6 +4,7 @@ export default class BinanceGetPublicKey extends AbstractMethod<'binanceGetPubli
4
4
  hasBundle?: boolean;
5
5
  confirmed?: boolean;
6
6
  init(): void;
7
+ get info(): string;
7
8
  confirmation(): Promise<boolean>;
8
9
  run(): Promise<import("..").PublicKey | import("..").PublicKey[]>;
9
10
  }
@@ -9,7 +9,6 @@ class BinanceGetPublicKey extends AbstractMethod_1.AbstractMethod {
9
9
  init() {
10
10
  this.requiredPermissions = ['read'];
11
11
  this.firmwareRange = (0, paramsValidator_1.getFirmwareRange)(this.name, (0, coinInfo_1.getMiscNetwork)('BNB'), this.firmwareRange);
12
- this.info = 'Export Binance public key';
13
12
  this.hasBundle = !!this.payload.bundle;
14
13
  const payload = !this.payload.bundle
15
14
  ? { ...this.payload, bundle: [this.payload] }
@@ -27,6 +26,9 @@ class BinanceGetPublicKey extends AbstractMethod_1.AbstractMethod {
27
26
  };
28
27
  });
29
28
  }
29
+ get info() {
30
+ return 'Export Binance public key';
31
+ }
30
32
  async confirmation() {
31
33
  if (this.confirmed)
32
34
  return true;
@@ -6,7 +6,8 @@ type Params = {
6
6
  };
7
7
  export default class BinanceSignTransaction extends AbstractMethod<'binanceSignTransaction', Params> {
8
8
  init(): void;
9
- run(): Promise<import("packages/transport/lib/types/messages").BinanceSignedTx>;
9
+ get info(): string;
10
+ run(): Promise<import("packages/protobuf/lib/messages").BinanceSignedTx>;
10
11
  }
11
12
  export {};
12
13
  //# sourceMappingURL=binanceSignTransaction.d.ts.map
@@ -10,7 +10,6 @@ class BinanceSignTransaction extends AbstractMethod_1.AbstractMethod {
10
10
  init() {
11
11
  this.requiredPermissions = ['read', 'write'];
12
12
  this.firmwareRange = (0, paramsValidator_1.getFirmwareRange)(this.name, (0, coinInfo_1.getMiscNetwork)('BNB'), this.firmwareRange);
13
- this.info = 'Sign Binance transaction';
14
13
  const { payload } = this;
15
14
  (0, paramsValidator_1.validateParams)(payload, [
16
15
  { name: 'path', type: 'string', required: true },
@@ -23,6 +22,9 @@ class BinanceSignTransaction extends AbstractMethod_1.AbstractMethod {
23
22
  transaction,
24
23
  };
25
24
  }
25
+ get info() {
26
+ return 'Sign Binance transaction';
27
+ }
26
28
  run() {
27
29
  return helper.signTx(this.device.getCommands().typedCall.bind(this.device.getCommands()), this.params.path, this.params.transaction);
28
30
  }
@@ -1,10 +1,10 @@
1
1
  import { Blockchain } from '../../backend/BlockchainLink';
2
- import type { CoinInfo } from '../../types';
3
- import type { FeeLevel } from '../../types/account';
2
+ import type { CoinInfo, FeeLevel } from '../../types';
4
3
  type Blocks = Array<string | undefined>;
5
4
  export declare class FeeLevels {
6
5
  coinInfo: CoinInfo;
7
6
  levels: FeeLevel[];
7
+ longTermFeeRate?: string;
8
8
  blocks: Blocks;
9
9
  constructor(coinInfo: CoinInfo);
10
10
  loadMisc(blockchain: Blockchain): Promise<FeeLevel[]>;
@@ -3,38 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FeeLevels = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const bignumber_js_1 = tslib_1.__importDefault(require("bignumber.js"));
6
- const BLOCKS = {
7
- btc: {
8
- high: 1,
9
- normal: 6,
10
- economy: 36,
11
- low: 144,
12
- },
13
- bch: {
14
- high: 1,
15
- normal: 5,
16
- economy: 10,
17
- low: 10,
18
- },
19
- btg: {
20
- high: 1,
21
- normal: 5,
22
- economy: 10,
23
- low: 10,
24
- },
25
- dgb: {
26
- high: 1,
27
- normal: 15,
28
- economy: 30,
29
- low: 60,
30
- },
31
- };
32
- const getDefaultBlocks = (shortcut, label) => BLOCKS[shortcut] && BLOCKS[shortcut][label] ? BLOCKS[shortcut][label] : -1;
33
- const feePerKB = (fee) => {
34
- const bn = new bignumber_js_1.default(fee);
35
- if (bn.isNaN() || bn.lte('0'))
6
+ const convertFeeRate = (fee, minFee) => {
7
+ const feePerKB = new bignumber_js_1.default(fee);
8
+ if (feePerKB.isNaN() || feePerKB.lte('0'))
36
9
  return;
37
- return bn.div(1000).integerValue(bignumber_js_1.default.ROUND_HALF_CEIL).toString();
10
+ const feePerB = feePerKB.div(1000);
11
+ if (feePerB.lt(minFee))
12
+ return minFee.toString();
13
+ return feePerB.isInteger() ? feePerB.toString() : feePerB.toFixed(2);
38
14
  };
39
15
  const fillGap = (from, step, size) => {
40
16
  const fill = [];
@@ -43,36 +19,27 @@ const fillGap = (from, step, size) => {
43
19
  }
44
20
  return fill;
45
21
  };
46
- const findLowest = (blocks) => {
47
- const unique = [];
48
- blocks.forEach(item => {
49
- if (typeof item === 'string' && unique.indexOf(item) < 0) {
50
- unique.push(item);
51
- }
52
- });
53
- return unique[unique.length - 1];
54
- };
55
22
  const findNearest = (requested, blocks) => {
23
+ if (typeof blocks[requested] === 'string')
24
+ return blocks[requested];
56
25
  const len = blocks.length;
57
- const knownValue = blocks[requested];
58
- if (typeof knownValue === 'string')
59
- return knownValue;
60
- const lastKnownValue = blocks
61
- .slice()
62
- .reverse()
63
- .find(item => typeof item === 'string');
64
- if (!lastKnownValue)
65
- return;
66
- const lastKnownIndex = blocks.indexOf(lastKnownValue);
67
- if (requested >= lastKnownIndex) {
68
- return lastKnownValue;
69
- }
70
26
  let index = requested;
71
27
  while (typeof blocks[index] !== 'string' && index < len) {
72
28
  index++;
73
29
  }
30
+ if (typeof blocks[index] === 'string') {
31
+ return blocks[index];
32
+ }
33
+ index = requested;
34
+ while (typeof blocks[index] !== 'string' && index > 0) {
35
+ index--;
36
+ }
74
37
  return blocks[index];
75
38
  };
39
+ const findLowest = (blocks) => blocks
40
+ .slice(0)
41
+ .reverse()
42
+ .find(item => typeof item === 'string');
76
43
  const findBlocksForFee = (feePerUnit, blocks) => {
77
44
  const bn = new bignumber_js_1.default(feePerUnit);
78
45
  const lower = blocks.find(b => typeof b === 'string' && bn.gte(b));
@@ -84,26 +51,7 @@ class FeeLevels {
84
51
  constructor(coinInfo) {
85
52
  this.blocks = [];
86
53
  this.coinInfo = coinInfo;
87
- const shortcut = coinInfo.shortcut.toLowerCase();
88
- if (coinInfo.type === 'ethereum') {
89
- this.levels = coinInfo.defaultFees.map(level => ({
90
- ...level,
91
- blocks: -1,
92
- }));
93
- return;
94
- }
95
- const keys = Object.keys(coinInfo.defaultFees);
96
- this.levels = keys
97
- .sort((levelA, levelB) => coinInfo.defaultFees[levelB] - coinInfo.defaultFees[levelA])
98
- .map(level => {
99
- const label = level.toLowerCase();
100
- const blocks = getDefaultBlocks(shortcut, label);
101
- return {
102
- label,
103
- feePerUnit: coinInfo.defaultFees[level].toString(),
104
- blocks,
105
- };
106
- });
54
+ this.levels = coinInfo.defaultFees;
107
55
  }
108
56
  async loadMisc(blockchain) {
109
57
  try {
@@ -135,27 +83,21 @@ class FeeLevels {
135
83
  return result.concat(fill);
136
84
  }, []);
137
85
  }
86
+ const oneDayBlocks = 6 * 24;
87
+ blocks.push(...fillGap(oneDayBlocks, oneDayBlocks / 2, oneDayBlocks * 6));
138
88
  try {
139
89
  const response = await blockchain.estimateFee({ blocks });
140
- response.forEach((r, i) => {
141
- this.blocks[blocks[i]] = feePerKB(r.feePerUnit);
90
+ response.forEach(({ feePerUnit }, index) => {
91
+ this.blocks[blocks[index]] = convertFeeRate(feePerUnit, this.coinInfo.minFee);
142
92
  });
143
- if (this.levels.length === 1) {
144
- const lowest = findLowest(this.blocks);
145
- if (typeof lowest === 'string') {
146
- this.levels[0].blocks = this.blocks.indexOf(lowest);
147
- this.levels[0].feePerUnit = lowest;
93
+ this.levels.forEach(level => {
94
+ const updatedValue = findNearest(level.blocks, this.blocks);
95
+ if (typeof updatedValue === 'string') {
96
+ level.blocks = this.blocks.indexOf(updatedValue);
97
+ level.feePerUnit = updatedValue;
148
98
  }
149
- }
150
- else {
151
- this.levels.forEach(l => {
152
- const updatedValue = findNearest(l.blocks, this.blocks);
153
- if (typeof updatedValue === 'string') {
154
- l.blocks = this.blocks.indexOf(updatedValue);
155
- l.feePerUnit = updatedValue;
156
- }
157
- });
158
- }
99
+ });
100
+ this.longTermFeeRate = findLowest(this.blocks);
159
101
  }
160
102
  catch (error) {
161
103
  }
@@ -1,8 +1,7 @@
1
1
  import { ComposeInput, ComposeOutput, ComposeResult } from '@trezor/utxo-lib';
2
2
  import { FeeLevels } from './Fees';
3
3
  import { Blockchain } from '../../backend/BlockchainLink';
4
- import type { BitcoinNetworkInfo } from '../../types';
5
- import type { DiscoveryAccount, SelectFeeLevel } from '../../types/account';
4
+ import type { BitcoinNetworkInfo, DiscoveryAccount, SelectFeeLevel } from '../../types';
6
5
  import type { PrecomposeParams } from '../../types/api/composeTransaction';
7
6
  type Options = {
8
7
  account: DiscoveryAccount;
@@ -25,7 +25,7 @@ class TransactionComposer {
25
25
  .concat(addresses.change)
26
26
  .map(a => a.address);
27
27
  this.utxos = options.utxo.flatMap(u => {
28
- if (!u.required && new bignumber_js_1.default(u.amount).lte(this.coinInfo.dustLimit))
28
+ if (!u.required && new bignumber_js_1.default(u.amount).lt(this.coinInfo.dustLimit))
29
29
  return [];
30
30
  const addressPath = (0, pathUtils_1.getHDPath)(u.path);
31
31
  const [chain, index] = addressPath.slice(addressPath.length - 2);
@@ -99,7 +99,7 @@ class TransactionComposer {
99
99
  name: level.label,
100
100
  fee: tx.fee,
101
101
  feePerByte: level.feePerUnit,
102
- minutes: level.blocks * this.coinInfo.blocktime,
102
+ minutes: level.blocks * this.coinInfo.blockTime,
103
103
  total: tx.totalSpent,
104
104
  });
105
105
  }
@@ -135,6 +135,7 @@ class TransactionComposer {
135
135
  outputs: this.outputs,
136
136
  height: this.blockHeight,
137
137
  feeRate,
138
+ longTermFeeRate: this.feeLevels.longTermFeeRate,
138
139
  skipPermutation: this.skipPermutation,
139
140
  basePath: account.address_n,
140
141
  network: coinInfo.network,
@@ -1,11 +1,19 @@
1
+ import { Transaction as BitcoinJsTransaction } from '@trezor/utxo-lib';
1
2
  import type { TypedRawTransaction } from '@trezor/blockchain-link';
2
- import type { CoinInfo, AccountAddresses } from '../../types';
3
+ import type { CoinInfo, AccountAddresses, AccountTransaction } from '../../types';
3
4
  import type { RefTransaction, TransactionOptions } from '../../types/api/bitcoin';
4
5
  import type { PROTO } from '../../constants';
5
6
  export declare const requireReferencedTransactions: (inputs: PROTO.TxInputType[], options?: TransactionOptions, coinInfo?: CoinInfo) => boolean;
6
7
  export declare const getReferencedTransactions: (inputs: PROTO.TxInputType[]) => string[];
7
8
  export declare const getOrigTransactions: (inputs: PROTO.TxInputType[], outputs: PROTO.TxOutputType[]) => string[];
8
9
  export declare const transformOrigTransactions: (txs: TypedRawTransaction[], coinInfo: CoinInfo, addresses?: AccountAddresses) => RefTransaction[];
10
+ export declare const transformReferencedTransaction: (tx: BitcoinJsTransaction) => RefTransaction;
9
11
  export declare const transformReferencedTransactions: (txs: TypedRawTransaction[], coinInfo: CoinInfo) => RefTransaction[];
10
- export declare const validateReferencedTransactions: (txs: RefTransaction[] | typeof undefined, inputs: PROTO.TxInputType[], outputs: PROTO.TxOutputType[]) => RefTransaction[] | undefined;
12
+ export declare const validateReferencedTransactions: ({ transactions, inputs, outputs, addresses, coinInfo, }: {
13
+ transactions?: (RefTransaction | AccountTransaction)[] | undefined;
14
+ inputs: PROTO.TxInputType[];
15
+ outputs: PROTO.TxOutputType[];
16
+ addresses?: AccountAddresses | undefined;
17
+ coinInfo: CoinInfo;
18
+ }) => RefTransaction[] | undefined;
11
19
  //# sourceMappingURL=refTx.d.ts.map
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validateReferencedTransactions = exports.transformReferencedTransactions = exports.transformOrigTransactions = exports.getOrigTransactions = exports.getReferencedTransactions = exports.requireReferencedTransactions = void 0;
3
+ exports.validateReferencedTransactions = exports.transformReferencedTransactions = exports.transformReferencedTransaction = exports.transformOrigTransactions = exports.getOrigTransactions = exports.getReferencedTransactions = exports.requireReferencedTransactions = void 0;
4
4
  const utxo_lib_1 = require("@trezor/utxo-lib");
5
5
  const utils_1 = require("@trezor/utils");
6
6
  const pathUtils_1 = require("../../utils/pathUtils");
@@ -55,17 +55,14 @@ const enhanceTransaction = (refTx, srcTx) => {
55
55
  }
56
56
  return refTx;
57
57
  };
58
- const transformOrigTransactions = (txs, coinInfo, addresses) => txs.flatMap(raw => {
59
- if (coinInfo.type !== 'bitcoin' || raw.type !== 'blockbook' || !addresses)
60
- return [];
61
- const { hex, vin, vout } = raw.tx;
62
- const tx = utxo_lib_1.Transaction.fromHex(hex, { network: coinInfo.network });
58
+ const transformOrigTransaction = (origTx, tx, addresses) => {
59
+ const { vin, vout, txid } = origTx;
63
60
  const inputAddresses = addresses.used.concat(addresses.change).concat(addresses.unused);
64
61
  const inputsMap = (input, i) => {
65
62
  var _a;
66
63
  const rawInput = vin[i];
67
64
  if (!(rawInput === null || rawInput === void 0 ? void 0 : rawInput.value) || !(rawInput === null || rawInput === void 0 ? void 0 : rawInput.addresses) || rawInput.addresses.length !== 1) {
68
- throw (0, errors_1.TypedError)('Method_InvalidParameter', `transformOrigTransactions: invalid input at ${raw.tx.txid} [${i}]`);
65
+ throw (0, errors_1.TypedError)('Method_InvalidParameter', `transformOrigTransactions: invalid input at ${txid} [${i}]`);
69
66
  }
70
67
  const [address] = rawInput.addresses;
71
68
  const inputAddress = inputAddresses.find(addr => addr.address === address);
@@ -92,7 +89,7 @@ const transformOrigTransactions = (txs, coinInfo, addresses) => txs.flatMap(raw
92
89
  const { data } = utxo_lib_1.payments.embed({ output: output.script });
93
90
  const op_return_data = (_a = data === null || data === void 0 ? void 0 : data.shift()) === null || _a === void 0 ? void 0 : _a.toString('hex');
94
91
  if (typeof op_return_data !== 'string') {
95
- throw (0, errors_1.TypedError)('Method_InvalidParameter', `transformOrigTransactions: invalid op_return_data at ${raw.tx.txid} [${i}]`);
92
+ throw (0, errors_1.TypedError)('Method_InvalidParameter', `transformOrigTransactions: invalid op_return_data at ${txid} [${i}]`);
96
93
  }
97
94
  return {
98
95
  script_type: 'PAYTOOPRETURN',
@@ -101,7 +98,7 @@ const transformOrigTransactions = (txs, coinInfo, addresses) => txs.flatMap(raw
101
98
  };
102
99
  }
103
100
  if (!rawOutput.addresses || rawOutput.addresses.length !== 1) {
104
- throw (0, errors_1.TypedError)('Method_InvalidParameter', `transformOrigTransactions: invalid output at ${raw.tx.txid} [${i}]`);
101
+ throw (0, errors_1.TypedError)('Method_InvalidParameter', `transformOrigTransactions: invalid output at ${txid} [${i}]`);
105
102
  }
106
103
  const [address] = rawOutput.addresses;
107
104
  const changeAddress = addresses.change.find(addr => addr.address === address);
@@ -129,13 +126,16 @@ const transformOrigTransactions = (txs, coinInfo, addresses) => txs.flatMap(raw
129
126
  expiry: tx.expiry,
130
127
  };
131
128
  return enhanceTransaction(refTx, tx);
132
- });
129
+ };
130
+ const isTransactionWithHex = (tx) => tx.type === 'blockbook' && !!tx.tx.hex;
131
+ const transformOrigTransactions = (txs, coinInfo, addresses) => coinInfo.type !== 'bitcoin' || !addresses
132
+ ? []
133
+ : txs.filter(isTransactionWithHex).map(raw => {
134
+ const tx = utxo_lib_1.Transaction.fromHex(raw.tx.hex, { network: coinInfo.network });
135
+ return transformOrigTransaction(raw.tx, tx, addresses);
136
+ });
133
137
  exports.transformOrigTransactions = transformOrigTransactions;
134
- const transformReferencedTransactions = (txs, coinInfo) => txs.flatMap(raw => {
135
- if (coinInfo.type !== 'bitcoin' || raw.type !== 'blockbook')
136
- return [];
137
- const { hex } = raw.tx;
138
- const tx = utxo_lib_1.Transaction.fromHex(hex, { network: coinInfo.network });
138
+ const transformReferencedTransaction = (tx) => {
139
139
  const inputsMap = (input) => ({
140
140
  prev_index: input.index,
141
141
  sequence: input.sequence,
@@ -156,14 +156,41 @@ const transformReferencedTransactions = (txs, coinInfo) => txs.flatMap(raw => {
156
156
  expiry: tx.expiry,
157
157
  };
158
158
  return enhanceTransaction(refTx, tx);
159
- });
159
+ };
160
+ exports.transformReferencedTransaction = transformReferencedTransaction;
161
+ const transformReferencedTransactions = (txs, coinInfo) => coinInfo.type !== 'bitcoin'
162
+ ? []
163
+ : txs.filter(isTransactionWithHex).map(raw => {
164
+ const tx = utxo_lib_1.Transaction.fromHex(raw.tx.hex, { network: coinInfo.network });
165
+ return (0, exports.transformReferencedTransaction)(tx);
166
+ });
160
167
  exports.transformReferencedTransactions = transformReferencedTransactions;
161
- const validateReferencedTransactions = (txs, inputs, outputs) => {
162
- if (!Array.isArray(txs) || txs.length === 0)
168
+ const transformAccountToOrigTransaction = ({ tx, addresses, coinInfo, }) => {
169
+ if (!tx.hex)
170
+ throw (0, errors_1.TypedError)('Method_InvalidParameter', `refTx: hex for ${tx.txid} not provided`);
171
+ if (!addresses)
172
+ throw (0, errors_1.TypedError)('Method_InvalidParameter', `refTx: addresses for ${tx.txid} not provided`);
173
+ const srcTx = utxo_lib_1.Transaction.fromHex(tx.hex, { network: coinInfo.network });
174
+ return transformOrigTransaction({ ...tx.details, txid: tx.txid }, srcTx, addresses);
175
+ };
176
+ const transformAccountToReferencedTransaction = ({ tx, coinInfo, }) => {
177
+ if (!tx.hex)
178
+ throw (0, errors_1.TypedError)('Method_InvalidParameter', `refTx: hex for ${tx.txid} not provided`);
179
+ const srcTx = utxo_lib_1.Transaction.fromHex(tx.hex, { network: coinInfo.network });
180
+ return (0, exports.transformReferencedTransaction)(srcTx);
181
+ };
182
+ const validateReferencedTransactions = ({ transactions, inputs, outputs, addresses, coinInfo, }) => {
183
+ if (!Array.isArray(transactions) || transactions.length === 0)
163
184
  return;
164
185
  const refTxs = (0, exports.requireReferencedTransactions)(inputs) ? (0, exports.getReferencedTransactions)(inputs) : [];
165
186
  const origTxs = (0, exports.getOrigTransactions)(inputs, outputs);
166
- const transformedTxs = txs.map(tx => {
187
+ const transformedTxs = transactions.map(tx => {
188
+ if ('details' in tx) {
189
+ if (origTxs.includes(tx.txid)) {
190
+ return transformAccountToOrigTransaction({ tx, addresses, coinInfo });
191
+ }
192
+ return transformAccountToReferencedTransaction({ tx, coinInfo });
193
+ }
167
194
  (0, paramsValidator_1.validateParams)(tx, [
168
195
  { name: 'hash', type: 'string', required: true },
169
196
  { name: 'inputs', type: 'array', required: true },
@@ -5,6 +5,7 @@ type Params = {
5
5
  };
6
6
  export default class BlockchainDisconnect extends AbstractMethod<'blockchainDisconnect', Params> {
7
7
  init(): void;
8
+ get info(): string;
8
9
  run(): Promise<{
9
10
  disconnected: boolean;
10
11
  }>;
@@ -8,7 +8,6 @@ const coinInfo_1 = require("../data/coinInfo");
8
8
  class BlockchainDisconnect extends AbstractMethod_1.AbstractMethod {
9
9
  init() {
10
10
  this.requiredPermissions = [];
11
- this.info = '';
12
11
  this.useDevice = false;
13
12
  this.useUi = false;
14
13
  const { payload } = this;
@@ -22,6 +21,9 @@ class BlockchainDisconnect extends AbstractMethod_1.AbstractMethod {
22
21
  coinInfo,
23
22
  };
24
23
  }
24
+ get info() {
25
+ return '';
26
+ }
25
27
  run() {
26
28
  const backend = (0, BlockchainLink_1.findBackend)(this.params.coinInfo.shortcut);
27
29
  if (backend) {
@@ -45,7 +45,7 @@ class BlockchainEstimateFee extends AbstractMethod_1.AbstractMethod {
45
45
  async run() {
46
46
  const { coinInfo, request } = this.params;
47
47
  const feeInfo = {
48
- blockTime: coinInfo.blocktime,
48
+ blockTime: coinInfo.blockTime,
49
49
  minFee: coinInfo.minFee,
50
50
  maxFee: coinInfo.maxFee,
51
51
  dustLimit: coinInfo.type === 'bitcoin' ? coinInfo.dustLimit : undefined,
@@ -5,6 +5,7 @@ type Params = {
5
5
  };
6
6
  export default class BlockchainSetCustomBackend extends AbstractMethod<'blockchainSetCustomBackend', Params> {
7
7
  init(): void;
8
+ get info(): string;
8
9
  run(): Promise<boolean>;
9
10
  }
10
11
  export {};
@@ -8,7 +8,6 @@ const coinInfo_1 = require("../data/coinInfo");
8
8
  class BlockchainSetCustomBackend extends AbstractMethod_1.AbstractMethod {
9
9
  init() {
10
10
  this.requiredPermissions = [];
11
- this.info = '';
12
11
  this.useDevice = false;
13
12
  this.useUi = false;
14
13
  const { payload } = this;
@@ -25,6 +24,9 @@ class BlockchainSetCustomBackend extends AbstractMethod_1.AbstractMethod {
25
24
  coinInfo,
26
25
  };
27
26
  }
27
+ get info() {
28
+ return '';
29
+ }
28
30
  async run() {
29
31
  const current = (0, BlockchainLink_1.findBackend)(this.params.coinInfo.shortcut);
30
32
  if (current) {
@@ -2,6 +2,7 @@ import { AbstractMethod } from '../core/AbstractMethod';
2
2
  import { PROTO } from '../constants';
3
3
  export default class CancelCoinjoinAuthorization extends AbstractMethod<'cancelCoinjoinAuthorization', PROTO.CancelAuthorization> {
4
4
  init(): void;
5
+ get info(): string;
5
6
  run(): Promise<PROTO.Success>;
6
7
  }
7
8
  //# sourceMappingURL=cancelCoinjoinAuthorization.d.ts.map
@@ -8,7 +8,9 @@ class CancelCoinjoinAuthorization extends AbstractMethod_1.AbstractMethod {
8
8
  this.firmwareRange = (0, paramsValidator_1.getFirmwareRange)(this.name, null, this.firmwareRange);
9
9
  this.preauthorized =
10
10
  typeof payload.preauthorized === 'boolean' ? payload.preauthorized : true;
11
- this.info = 'Cancel Coinjoin Authorization';
11
+ }
12
+ get info() {
13
+ return 'Cancel Coinjoin Authorization';
12
14
  }
13
15
  async run() {
14
16
  const cmd = this.device.getCommands();
@@ -8,6 +8,7 @@ export default class CardanoGetAddress extends AbstractMethod<'cardanoGetAddress
8
8
  progress: number;
9
9
  confirmed?: boolean;
10
10
  init(): void;
11
+ get info(): string;
11
12
  getButtonRequestData(code: string): {
12
13
  type: "address";
13
14
  serializedPath: string;
@@ -50,12 +50,12 @@ class CardanoGetAddress extends AbstractMethod_1.AbstractMethod {
50
50
  this.params[0].show_display;
51
51
  this.confirmed = useEventListener;
52
52
  this.useUi = !useEventListener;
53
+ }
54
+ get info() {
53
55
  if (this.params.length === 1) {
54
- this.info = `Export Cardano address for account #${(0, pathUtils_1.fromHardened)(this.params[0].address_parameters.address_n[2]) + 1}`;
55
- }
56
- else {
57
- this.info = 'Export multiple Cardano addresses';
56
+ return `Export Cardano address for account #${(0, pathUtils_1.fromHardened)(this.params[0].address_parameters.address_n[2]) + 1}`;
58
57
  }
58
+ return 'Export multiple Cardano addresses';
59
59
  }
60
60
  getButtonRequestData(code) {
61
61
  if (code === 'ButtonRequest_Address') {
@@ -3,6 +3,7 @@ import { AbstractMethod } from '../core/AbstractMethod';
3
3
  import type { CardanoNativeScript } from '../types/api/cardano';
4
4
  export default class CardanoGetNativeScriptHash extends AbstractMethod<'cardanoGetNativeScriptHash', PROTO.CardanoGetNativeScriptHash> {
5
5
  init(): void;
6
+ get info(): string;
6
7
  validateScript(script: CardanoNativeScript): void;
7
8
  scriptToProto(script: CardanoNativeScript): PROTO.CardanoNativeScript;
8
9
  run(): Promise<{
@@ -9,7 +9,6 @@ class CardanoGetNativeScriptHash extends AbstractMethod_1.AbstractMethod {
9
9
  init() {
10
10
  this.requiredPermissions = ['read'];
11
11
  this.firmwareRange = (0, paramsValidator_1.getFirmwareRange)(this.name, (0, coinInfo_1.getMiscNetwork)('Cardano'), this.firmwareRange);
12
- this.info = 'Get Cardano native script hash';
13
12
  const { payload } = this;
14
13
  (0, paramsValidator_1.validateParams)(payload, [
15
14
  { name: 'script', type: 'object', required: true },
@@ -25,6 +24,9 @@ class CardanoGetNativeScriptHash extends AbstractMethod_1.AbstractMethod {
25
24
  : constants_1.PROTO.CardanoDerivationType.ICARUS_TREZOR,
26
25
  };
27
26
  }
27
+ get info() {
28
+ return 'Get Cardano native script hash';
29
+ }
28
30
  validateScript(script) {
29
31
  (0, paramsValidator_1.validateParams)(script, [
30
32
  { name: 'type', type: 'number', required: true },
@@ -4,6 +4,7 @@ export default class CardanoGetPublicKey extends AbstractMethod<'cardanoGetPubli
4
4
  hasBundle?: boolean;
5
5
  confirmed?: boolean;
6
6
  init(): void;
7
+ get info(): string;
7
8
  confirmation(): Promise<boolean>;
8
9
  noBackupConfirmation(): Promise<boolean>;
9
10
  run(): Promise<import("..").CardanoPublicKey | import("..").CardanoPublicKey[]>;