@trezor/connect 9.0.6 → 9.0.8

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 (97) hide show
  1. package/CHANGELOG.md +22 -2
  2. package/README.md +1 -1
  3. package/lib/api/authorizeCoinjoin.d.ts +7 -0
  4. package/lib/api/{authorizeCoinJoin.js → authorizeCoinjoin.js} +3 -3
  5. package/lib/api/bitcoin/createPendingTx.d.ts +35 -0
  6. package/lib/api/bitcoin/createPendingTx.js +60 -0
  7. package/lib/api/bitcoin/index.d.ts +1 -0
  8. package/lib/api/bitcoin/index.js +1 -0
  9. package/lib/api/blockchainGetAccountBalanceHistory.d.ts +1 -1
  10. package/lib/api/blockchainGetCurrentFiatRates.d.ts +2 -1
  11. package/lib/api/blockchainGetCurrentFiatRates.js +6 -1
  12. package/lib/api/blockchainGetFiatRatesForTimestamps.d.ts +3 -1
  13. package/lib/api/blockchainGetFiatRatesForTimestamps.js +9 -1
  14. package/lib/api/blockchainGetTransactions.d.ts +1 -1
  15. package/lib/api/cardano/cardanoAuxiliaryData.js +43 -23
  16. package/lib/api/cardanoSignTransaction.d.ts +2 -1
  17. package/lib/api/cardanoSignTransaction.js +21 -11
  18. package/lib/api/composeTransaction.js +2 -2
  19. package/lib/api/ethereum/ethereumDefinitions.d.ts +7 -0
  20. package/lib/api/ethereum/ethereumDefinitions.js +43 -0
  21. package/lib/api/ethereum/ethereumSignTx.d.ts +3 -2
  22. package/lib/api/ethereum/ethereumSignTx.js +4 -2
  23. package/lib/api/ethereumGetAddress.d.ts +2 -1
  24. package/lib/api/ethereumGetAddress.js +19 -2
  25. package/lib/api/ethereumSignMessage.js +13 -0
  26. package/lib/api/ethereumSignTransaction.js +10 -3
  27. package/lib/api/ethereumSignTypedData.js +13 -0
  28. package/lib/api/firmware/getBinary.d.ts +3 -12
  29. package/lib/api/firmware/getBinary.js +5 -9
  30. package/lib/api/firmwareUpdate.d.ts +3 -2
  31. package/lib/api/firmwareUpdate.js +4 -5
  32. package/lib/api/getAccountInfo.d.ts +8 -8
  33. package/lib/api/getAccountInfo.js +1 -1
  34. package/lib/api/index.d.ts +1 -1
  35. package/lib/api/index.js +3 -3
  36. package/lib/api/setBusy.js +1 -4
  37. package/lib/api/setProxy.js +1 -1
  38. package/lib/api/signTransaction.d.ts +2 -1
  39. package/lib/api/signTransaction.js +12 -2
  40. package/lib/api/unlockPath.js +1 -4
  41. package/lib/backend/Blockchain.d.ts +3 -0
  42. package/lib/core/AbstractMethod.d.ts +1 -0
  43. package/lib/core/AbstractMethod.js +9 -0
  44. package/lib/core/index.d.ts +1 -1
  45. package/lib/core/index.js +24 -11
  46. package/lib/core/method.d.ts +1 -1
  47. package/lib/data/DataManager.d.ts +92 -15
  48. package/lib/data/DataManager.js +3 -53
  49. package/lib/data/config.js +9 -3
  50. package/lib/data/connectSettings.d.ts +0 -1
  51. package/lib/data/connectSettings.js +14 -58
  52. package/lib/data/firmwareInfo.js +48 -46
  53. package/lib/data/transportInfo.d.ts +1 -0
  54. package/lib/data/transportInfo.js +14 -1
  55. package/lib/data/udevInfo.d.ts +1 -0
  56. package/lib/data/udevInfo.js +14 -1
  57. package/lib/data/version.d.ts +1 -1
  58. package/lib/data/version.js +1 -1
  59. package/lib/device/DescriptorStream.js +1 -1
  60. package/lib/device/Device.js +1 -2
  61. package/lib/device/DeviceCommands.d.ts +1 -1
  62. package/lib/device/DeviceCommands.js +6 -7
  63. package/lib/device/DeviceList.d.ts +1 -2
  64. package/lib/device/DeviceList.js +27 -19
  65. package/lib/events/iframe.d.ts +2 -1
  66. package/lib/events/popup.d.ts +2 -1
  67. package/lib/events/transport.d.ts +2 -1
  68. package/lib/factory.js +1 -1
  69. package/lib/index.js +5 -4
  70. package/lib/types/api/{authorizeCoinJoin.d.ts → authorizeCoinjoin.d.ts} +3 -3
  71. package/lib/types/api/{authorizeCoinJoin.js → authorizeCoinjoin.js} +1 -1
  72. package/lib/types/api/bitcoin/index.d.ts +4 -0
  73. package/lib/types/api/cardano/index.d.ts +10 -9
  74. package/lib/types/api/firmwareUpdate.d.ts +2 -1
  75. package/lib/types/api/index.d.ts +2 -2
  76. package/lib/types/firmware.d.ts +2 -3
  77. package/lib/types/index.d.ts +1 -1
  78. package/lib/types/params.d.ts +1 -0
  79. package/lib/types/settings.d.ts +12 -1
  80. package/lib/utils/firmwareUtils.d.ts +0 -1
  81. package/lib/utils/firmwareUtils.js +1 -9
  82. package/lib/utils/pathUtils.d.ts +1 -0
  83. package/lib/utils/pathUtils.js +3 -1
  84. package/lib/utils/promiseUtils.d.ts +5 -1
  85. package/lib/utils/promiseUtils.js +7 -3
  86. package/lib/utils/urlUtils.d.ts +2 -1
  87. package/lib/utils/urlUtils.js +18 -3
  88. package/lib/utils/versionUtils.d.ts +3 -1
  89. package/lib/utils/versionUtils.js +5 -2
  90. package/package.json +16 -16
  91. package/lib/api/authorizeCoinJoin.d.ts +0 -7
  92. package/lib/device/AbortController.d.ts +0 -21
  93. package/lib/device/AbortController.js +0 -40
  94. package/lib/utils/browserUtils.d.ts +0 -21
  95. package/lib/utils/browserUtils.js +0 -100
  96. package/lib/utils/windowsUtils.d.ts +0 -2
  97. package/lib/utils/windowsUtils.js +0 -6
package/CHANGELOG.md CHANGED
@@ -1,3 +1,23 @@
1
+ # 9.0.8
2
+
3
+ - feat: support multiple intermediary FWs for model 1 and devkit binaries
4
+ - `FirmwareUpdate` now accepts `intermediaryVersion` param instead of `intermediary`
5
+ - `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.
6
+ - feat: signTransaction now returns `signedTransaction` which can be used for visualization purposes before notification about pending transaction from blockchain is received.
7
+ - feat(blockchain): `blockchainGetCurrentFiatRates` and `blockchainGetFiatRatesForTimestamps` now accept additional `token` parameter
8
+ - feat: support coinjoin for model 1
9
+ - feat(transport): eth definitions
10
+ - feat(webextension): Ignore port events if it is not port created by current popup
11
+ - feat(cardano): allow external reward addresses in governance registrations
12
+ - refactor(connect): removing browser related code from @trezor/connect
13
+
14
+ # 9.0.7
15
+
16
+ - feat(connect-ui): connect UI will now display a warning in case it was opened by an application listed in https://github.com/MetaMask/eth-phishing-detect (#7488)
17
+ - fix(connect-ui): set max pin input length to 50 instead of 9 (#7668)
18
+ - fix(connect): ltc spending problem (#7666)
19
+ - change(connect): TrezorConnect.init `webusb` option is now deprecated. It was replaced with `transports` param `('BridgeTransport' | 'WebUsbTransport')[]`. (#7411)
20
+
1
21
  # 9.0.6
2
22
 
3
23
  - fix: list tslib as direct dependency
@@ -22,7 +42,7 @@
22
42
  - added `setBusy` method
23
43
  - added `goerli` (TGOR) coin support
24
44
  - added `serialize` and `coinjoinRequest` option to `signTransaction` method
25
- - added `preauthorized` option to `authorizeCoinJoin` method
45
+ - added `preauthorized` option to `authorizeCoinjoin` method
26
46
  - Cardano: added support for [CIP36 Catalyst registration format](https://cips.cardano.org/cips/cip36/) in `cardanoSignTransaction` method
27
47
  - `auxiliaryData.catalystRegistrationParameters` is deprecated, use `auxiliaryData.governanceRegistrationParameters` instead
28
48
 
@@ -69,6 +89,6 @@
69
89
 
70
90
  - `getOwnershipId` method
71
91
  - `getOwnershipProof` method
72
- - `authorizeCoinJoin` method
92
+ - `authorizeCoinjoin` method
73
93
  - `getFirmwareHash` method
74
94
  - [support for babbage features in cardano](https://github.com/trezor/trezor-suite/commit/efe9c78a2f74a1b7653b3fddf6cca35ba38d3ae9)
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @trezor/connect
2
2
 
3
- API version 9.0.6
3
+ API version 9.0.8
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)
@@ -0,0 +1,7 @@
1
+ import { AbstractMethod } from '../core/AbstractMethod';
2
+ import { PROTO } from '../constants';
3
+ export default class AuthorizeCoinjoin extends AbstractMethod<'authorizeCoinjoin', PROTO.AuthorizeCoinJoin> {
4
+ init(): void;
5
+ run(): Promise<PROTO.Success>;
6
+ }
7
+ //# sourceMappingURL=authorizeCoinjoin.d.ts.map
@@ -4,7 +4,7 @@ const AbstractMethod_1 = require("../core/AbstractMethod");
4
4
  const paramsValidator_1 = require("./common/paramsValidator");
5
5
  const pathUtils_1 = require("../utils/pathUtils");
6
6
  const coinInfo_1 = require("../data/coinInfo");
7
- class AuthorizeCoinJoin extends AbstractMethod_1.AbstractMethod {
7
+ class AuthorizeCoinjoin extends AbstractMethod_1.AbstractMethod {
8
8
  init() {
9
9
  const { payload } = this;
10
10
  (0, paramsValidator_1.validateParams)(payload, [
@@ -45,5 +45,5 @@ class AuthorizeCoinJoin extends AbstractMethod_1.AbstractMethod {
45
45
  return response.message;
46
46
  }
47
47
  }
48
- exports.default = AuthorizeCoinJoin;
49
- //# sourceMappingURL=authorizeCoinJoin.js.map
48
+ exports.default = AuthorizeCoinjoin;
49
+ //# sourceMappingURL=authorizeCoinjoin.js.map
@@ -0,0 +1,35 @@
1
+ import { Transaction as BitcoinJsTransaction } from '@trezor/utxo-lib';
2
+ import { PROTO } from '../../constants';
3
+ import type { AccountAddresses, AccountUtxo } from '../../types';
4
+ export declare const createPendingTransaction: (tx: BitcoinJsTransaction, { utxo, addresses, inputs, outputs, }: {
5
+ utxo: AccountUtxo[];
6
+ addresses: AccountAddresses;
7
+ inputs: PROTO.TxInputType[];
8
+ outputs: PROTO.TxOutputType[];
9
+ }) => {
10
+ txid: string;
11
+ hex: string;
12
+ blockHeight: number;
13
+ blockTime: number;
14
+ confirmations: number;
15
+ vsize: number;
16
+ size: number;
17
+ value: string;
18
+ valueIn: string;
19
+ fees: string;
20
+ vin: {
21
+ n: number;
22
+ txid: string;
23
+ vout: number;
24
+ isAddress: boolean;
25
+ addresses: string[];
26
+ value: string;
27
+ }[];
28
+ vout: {
29
+ n: number;
30
+ isAddress: boolean;
31
+ addresses: string[];
32
+ value: string;
33
+ }[];
34
+ };
35
+ //# sourceMappingURL=createPendingTx.d.ts.map
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createPendingTransaction = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const bignumber_js_1 = tslib_1.__importDefault(require("bignumber.js"));
6
+ const pathUtils_1 = require("../../utils/pathUtils");
7
+ const createPendingTransaction = (tx, { utxo, addresses, inputs, outputs, }) => {
8
+ const valueOut = outputs.reduce((sum, out) => (0, bignumber_js_1.default)(sum).plus(out.amount), new bignumber_js_1.default('0'));
9
+ const valueIn = inputs.reduce((sum, ins) => (0, bignumber_js_1.default)(sum).plus(ins.amount), new bignumber_js_1.default('0'));
10
+ return {
11
+ txid: tx.getId(),
12
+ hex: tx.toHex(),
13
+ blockHeight: 0,
14
+ blockTime: Math.floor(Date.now() / 1000),
15
+ confirmations: 0,
16
+ vsize: tx.virtualSize(),
17
+ size: tx.weight(),
18
+ value: valueOut.toString(),
19
+ valueIn: valueIn.toString(),
20
+ fees: valueIn.minus(valueOut).toString(),
21
+ vin: inputs.map((ins, n) => ({
22
+ n,
23
+ txid: ins.prev_hash,
24
+ vout: ins.prev_index,
25
+ isAddress: true,
26
+ addresses: utxo
27
+ .filter(utxo => utxo.txid === ins.prev_hash && utxo.vout === ins.prev_index)
28
+ .map(utxo => utxo.address),
29
+ value: ins.amount.toString(),
30
+ })),
31
+ vout: outputs.map((out, n) => {
32
+ let transformedAddresses = [];
33
+ if (out.address) {
34
+ transformedAddresses = [out.address];
35
+ }
36
+ else if ('op_return_data' in out) {
37
+ transformedAddresses = [
38
+ `OP_RETURN (${Buffer.from(out.op_return_data, 'hex').toString('ascii')})`,
39
+ ];
40
+ }
41
+ else {
42
+ transformedAddresses = [
43
+ ...addresses.change,
44
+ ...addresses.unused,
45
+ ...addresses.used,
46
+ ]
47
+ .filter(address => out.address_n && address.path === (0, pathUtils_1.getSerializedPath)(out.address_n))
48
+ .map(address => address.address);
49
+ }
50
+ return {
51
+ n,
52
+ isAddress: out.script_type !== 'PAYTOOPRETURN',
53
+ addresses: transformedAddresses,
54
+ value: out.amount.toString(),
55
+ };
56
+ }),
57
+ };
58
+ };
59
+ exports.createPendingTransaction = createPendingTransaction;
60
+ //# sourceMappingURL=createPendingTx.js.map
@@ -1,3 +1,4 @@
1
+ export * from './createPendingTx';
1
2
  export * from './enhanceSignTx';
2
3
  export * from './Fees';
3
4
  export * from './inputs';
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./createPendingTx"), exports);
4
5
  tslib_1.__exportStar(require("./enhanceSignTx"), exports);
5
6
  tslib_1.__exportStar(require("./Fees"), exports);
6
7
  tslib_1.__exportStar(require("./inputs"), exports);
@@ -6,7 +6,7 @@ type Params = {
6
6
  };
7
7
  export default class BlockchainGetAccountBalanceHistory extends AbstractMethod<'blockchainGetAccountBalanceHistory', Params> {
8
8
  init(): void;
9
- run(): Promise<import("packages/blockchain-link/lib/types/common").AccountBalanceHistory[]>;
9
+ run(): Promise<import("packages/blockchain-link-types/lib/common").AccountBalanceHistory[]>;
10
10
  }
11
11
  export {};
12
12
  //# sourceMappingURL=blockchainGetAccountBalanceHistory.d.ts.map
@@ -3,12 +3,13 @@ import type { CoinInfo } from '../types';
3
3
  type Params = {
4
4
  coinInfo: CoinInfo;
5
5
  currencies: Payload<'blockchainGetCurrentFiatRates'>['currencies'];
6
+ token: Payload<'blockchainGetCurrentFiatRates'>['token'];
6
7
  };
7
8
  export default class BlockchainGetCurrentFiatRates extends AbstractMethod<'blockchainGetCurrentFiatRates', Params> {
8
9
  init(): void;
9
10
  run(): Promise<{
10
11
  ts: number;
11
- rates: import("packages/blockchain-link/lib").FiatRates;
12
+ rates: import("packages/blockchain-link-types/lib/common").FiatRates;
12
13
  }>;
13
14
  }
14
15
  export {};
@@ -12,6 +12,7 @@ class BlockchainGetCurrentFiatRates extends AbstractMethod_1.AbstractMethod {
12
12
  const { payload } = this;
13
13
  (0, paramsValidator_1.validateParams)(payload, [
14
14
  { name: 'currencies', type: 'array', required: false },
15
+ { name: 'token', type: 'string' },
15
16
  { name: 'coin', type: 'string', required: true },
16
17
  ]);
17
18
  const coinInfo = (0, coinInfo_1.getCoinInfo)(payload.coin);
@@ -21,12 +22,16 @@ class BlockchainGetCurrentFiatRates extends AbstractMethod_1.AbstractMethod {
21
22
  (0, BlockchainLink_1.isBackendSupported)(coinInfo);
22
23
  this.params = {
23
24
  currencies: payload.currencies,
25
+ token: payload.token,
24
26
  coinInfo,
25
27
  };
26
28
  }
27
29
  async run() {
28
30
  const backend = await (0, BlockchainLink_1.initBlockchain)(this.params.coinInfo, this.postMessage);
29
- return backend.getCurrentFiatRates({ currencies: this.params.currencies });
31
+ return backend.getCurrentFiatRates({
32
+ currencies: this.params.currencies,
33
+ token: this.params.token,
34
+ });
30
35
  }
31
36
  }
32
37
  exports.default = BlockchainGetCurrentFiatRates;
@@ -2,14 +2,16 @@ import { Payload, AbstractMethod } from '../core/AbstractMethod';
2
2
  import type { CoinInfo } from '../types';
3
3
  type Params = {
4
4
  coinInfo: CoinInfo;
5
+ currencies: Payload<'blockchainGetFiatRatesForTimestamps'>['currencies'];
5
6
  timestamps: Payload<'blockchainGetFiatRatesForTimestamps'>['timestamps'];
7
+ token: Payload<'blockchainGetFiatRatesForTimestamps'>['token'];
6
8
  };
7
9
  export default class BlockchainGetFiatRatesForTimestamps extends AbstractMethod<'blockchainGetFiatRatesForTimestamps', Params> {
8
10
  init(): void;
9
11
  run(): Promise<{
10
12
  tickers: {
11
13
  ts: number;
12
- rates: import("packages/blockchain-link/lib").FiatRates;
14
+ rates: import("packages/blockchain-link-types/lib/common").FiatRates;
13
15
  }[];
14
16
  }>;
15
17
  }
@@ -11,7 +11,9 @@ class BlockchainGetFiatRatesForTimestamps extends AbstractMethod_1.AbstractMetho
11
11
  this.useUi = false;
12
12
  const { payload } = this;
13
13
  (0, paramsValidator_1.validateParams)(payload, [
14
+ { name: 'currencies', type: 'array', required: false },
14
15
  { name: 'timestamps', type: 'array', required: true },
16
+ { name: 'token', type: 'string' },
15
17
  { name: 'coin', type: 'string', required: true },
16
18
  ]);
17
19
  const coinInfo = (0, coinInfo_1.getCoinInfo)(payload.coin);
@@ -20,13 +22,19 @@ class BlockchainGetFiatRatesForTimestamps extends AbstractMethod_1.AbstractMetho
20
22
  }
21
23
  (0, BlockchainLink_1.isBackendSupported)(coinInfo);
22
24
  this.params = {
25
+ currencies: payload.currencies,
23
26
  timestamps: payload.timestamps,
27
+ token: payload.token,
24
28
  coinInfo,
25
29
  };
26
30
  }
27
31
  async run() {
28
32
  const backend = await (0, BlockchainLink_1.initBlockchain)(this.params.coinInfo, this.postMessage);
29
- return backend.getFiatRatesForTimestamps({ timestamps: this.params.timestamps });
33
+ return backend.getFiatRatesForTimestamps({
34
+ currencies: this.params.currencies,
35
+ timestamps: this.params.timestamps,
36
+ token: this.params.token,
37
+ });
30
38
  }
31
39
  }
32
40
  exports.default = BlockchainGetFiatRatesForTimestamps;
@@ -6,7 +6,7 @@ type Params = {
6
6
  };
7
7
  export default class BlockchainGetTransactions extends AbstractMethod<'blockchainGetTransactions', Params> {
8
8
  init(): void;
9
- run(): Promise<import("packages/blockchain-link/lib").TypedRawTransaction[]>;
9
+ run(): Promise<import("packages/blockchain-link-types/lib").TypedRawTransaction[]>;
10
10
  }
11
11
  export {};
12
12
  //# sourceMappingURL=blockchainGetTransactions.d.ts.map
@@ -7,37 +7,57 @@ const pathUtils_1 = require("../../utils/pathUtils");
7
7
  const constants_1 = require("../../constants");
8
8
  const MAX_DELEGATION_COUNT = 32;
9
9
  const transformDelegation = (delegation) => {
10
+ if (delegation.votingPublicKey) {
11
+ console.warn('Please use votePublicKey instead of votingPublicKey.');
12
+ delegation.votePublicKey = delegation.votingPublicKey;
13
+ }
10
14
  (0, paramsValidator_1.validateParams)(delegation, [
11
- { name: 'votingPublicKey', type: 'string', required: true },
15
+ { name: 'votePublicKey', type: 'string', required: true },
12
16
  { name: 'weight', type: 'uint', required: true },
13
17
  ]);
14
18
  return {
15
- voting_public_key: delegation.votingPublicKey,
19
+ vote_public_key: delegation.votePublicKey,
16
20
  weight: delegation.weight,
17
21
  };
18
22
  };
19
- const transformGovernanceRegistrationParameters = (governanceRegistrationParameters) => {
20
- (0, paramsValidator_1.validateParams)(governanceRegistrationParameters, [
21
- { name: 'votingPublicKey', type: 'string' },
23
+ const transformCvoteRegistrationParameters = (cVoteRegistrationParameters) => {
24
+ if (cVoteRegistrationParameters.votingPublicKey) {
25
+ console.warn('Please use votePublicKey instead of votingPublicKey.');
26
+ cVoteRegistrationParameters.votePublicKey = cVoteRegistrationParameters.votingPublicKey;
27
+ }
28
+ if (cVoteRegistrationParameters.rewardAddressParameters) {
29
+ console.warn('Please use paymentAddressParameters instead of rewardAddressParameters.');
30
+ cVoteRegistrationParameters.paymentAddressParameters =
31
+ cVoteRegistrationParameters.rewardAddressParameters;
32
+ }
33
+ (0, paramsValidator_1.validateParams)(cVoteRegistrationParameters, [
34
+ { name: 'votePublicKey', type: 'string' },
22
35
  { name: 'stakingPath', required: true },
23
36
  { name: 'nonce', type: 'uint', required: true },
24
37
  { name: 'format', type: 'number' },
25
38
  { name: 'delegations', type: 'array', allowEmpty: true },
26
39
  { name: 'votingPurpose', type: 'uint' },
40
+ { name: 'address', type: 'string' },
27
41
  ]);
28
- (0, cardanoAddressParameters_1.validateAddressParameters)(governanceRegistrationParameters.rewardAddressParameters);
29
- const { delegations } = governanceRegistrationParameters;
42
+ const { paymentAddressParameters } = cVoteRegistrationParameters;
43
+ if (paymentAddressParameters) {
44
+ (0, cardanoAddressParameters_1.validateAddressParameters)(paymentAddressParameters);
45
+ }
46
+ const { delegations } = cVoteRegistrationParameters;
30
47
  if (delegations && delegations.length > MAX_DELEGATION_COUNT) {
31
- throw constants_1.ERRORS.TypedError('Method_InvalidParameter', `At most ${MAX_DELEGATION_COUNT} delegations are allowed in a governance registration`);
48
+ throw constants_1.ERRORS.TypedError('Method_InvalidParameter', `At most ${MAX_DELEGATION_COUNT} delegations are allowed in a CIP-36 registration`);
32
49
  }
33
50
  return {
34
- voting_public_key: governanceRegistrationParameters.votingPublicKey,
35
- staking_path: (0, pathUtils_1.validatePath)(governanceRegistrationParameters.stakingPath, 3),
36
- reward_address_parameters: (0, cardanoAddressParameters_1.addressParametersToProto)(governanceRegistrationParameters.rewardAddressParameters),
37
- nonce: governanceRegistrationParameters.nonce,
38
- format: governanceRegistrationParameters.format,
51
+ vote_public_key: cVoteRegistrationParameters.votePublicKey,
52
+ staking_path: (0, pathUtils_1.validatePath)(cVoteRegistrationParameters.stakingPath, 3),
53
+ payment_address_parameters: paymentAddressParameters
54
+ ? (0, cardanoAddressParameters_1.addressParametersToProto)(paymentAddressParameters)
55
+ : undefined,
56
+ nonce: cVoteRegistrationParameters.nonce,
57
+ format: cVoteRegistrationParameters.format,
39
58
  delegations: delegations === null || delegations === void 0 ? void 0 : delegations.map(transformDelegation),
40
- voting_purpose: governanceRegistrationParameters.votingPurpose,
59
+ voting_purpose: cVoteRegistrationParameters.votingPurpose,
60
+ payment_address: cVoteRegistrationParameters.paymentAddress,
41
61
  };
42
62
  };
43
63
  const transformAuxiliaryData = (auxiliaryData) => {
@@ -47,24 +67,24 @@ const transformAuxiliaryData = (auxiliaryData) => {
47
67
  type: 'string',
48
68
  },
49
69
  ]);
50
- let governanceRegistrationParameters;
51
- if (auxiliaryData.governanceRegistrationParameters) {
52
- governanceRegistrationParameters = transformGovernanceRegistrationParameters(auxiliaryData.governanceRegistrationParameters);
70
+ let cVoteRegistrationParameters;
71
+ if (auxiliaryData.cVoteRegistrationParameters) {
72
+ cVoteRegistrationParameters = transformCvoteRegistrationParameters(auxiliaryData.cVoteRegistrationParameters);
53
73
  }
54
74
  return {
55
75
  hash: auxiliaryData.hash,
56
- governance_registration_parameters: governanceRegistrationParameters,
76
+ cvote_registration_parameters: cVoteRegistrationParameters,
57
77
  };
58
78
  };
59
79
  exports.transformAuxiliaryData = transformAuxiliaryData;
60
80
  const modifyAuxiliaryDataForBackwardsCompatibility = (device, auxiliary_data) => {
61
- const { governance_registration_parameters } = auxiliary_data;
62
- if (governance_registration_parameters) {
63
- governance_registration_parameters.reward_address_parameters =
64
- (0, cardanoAddressParameters_1.modifyAddressParametersForBackwardsCompatibility)(device, governance_registration_parameters.reward_address_parameters);
81
+ const { cvote_registration_parameters } = auxiliary_data;
82
+ if (cvote_registration_parameters === null || cvote_registration_parameters === void 0 ? void 0 : cvote_registration_parameters.payment_address_parameters) {
83
+ cvote_registration_parameters.payment_address_parameters =
84
+ (0, cardanoAddressParameters_1.modifyAddressParametersForBackwardsCompatibility)(device, cvote_registration_parameters.payment_address_parameters);
65
85
  return {
66
86
  ...auxiliary_data,
67
- governance_registration_parameters,
87
+ cvote_registration_parameters,
68
88
  };
69
89
  }
70
90
  return auxiliary_data;
@@ -15,7 +15,8 @@ declare const CardanoSignTransactionFeatures: Readonly<{
15
15
  Plutus: string[];
16
16
  KeyHashStakeCredential: string[];
17
17
  Babbage: string[];
18
- GovernanceRegistrationCIP36: string[];
18
+ CIP36Registration: string[];
19
+ CIP36RegistrationExternalPaymentAddress: string[];
19
20
  }>;
20
21
  export type CardanoSignTransactionParams = {
21
22
  signingMode: PROTO.CardanoTxSigningMode;
@@ -21,7 +21,8 @@ const CardanoSignTransactionFeatures = Object.freeze({
21
21
  Plutus: ['0', '2.4.4'],
22
22
  KeyHashStakeCredential: ['0', '2.4.4'],
23
23
  Babbage: ['0', '2.5.2'],
24
- GovernanceRegistrationCIP36: ['0', '2.5.3'],
24
+ CIP36Registration: ['0', '2.5.3'],
25
+ CIP36RegistrationExternalPaymentAddress: ['0', '2.5.4'],
25
26
  });
26
27
  class CardanoSignTransaction extends AbstractMethod_1.AbstractMethod {
27
28
  init() {
@@ -36,10 +37,15 @@ class CardanoSignTransaction extends AbstractMethod_1.AbstractMethod {
36
37
  throw constants_1.ERRORS.TypedError('Method_InvalidParameter', 'Auxiliary data can now only be sent as a hash.');
37
38
  }
38
39
  if (payload.auxiliaryData && payload.auxiliaryData.catalystRegistrationParameters) {
39
- console.warn('Please use governanceRegistrationParameters instead of catalystRegistrationParameters.');
40
- payload.auxiliaryData.governanceRegistrationParameters =
40
+ console.warn('Please use cVoteRegistrationParameters instead of catalystRegistrationParameters.');
41
+ payload.auxiliaryData.cVoteRegistrationParameters =
41
42
  payload.auxiliaryData.catalystRegistrationParameters;
42
43
  }
44
+ if (payload.auxiliaryData && payload.auxiliaryData.governanceRegistrationParameters) {
45
+ console.warn('Please use cVoteRegistrationParameters instead of governanceRegistrationParameters.');
46
+ payload.auxiliaryData.cVoteRegistrationParameters =
47
+ payload.auxiliaryData.governanceRegistrationParameters;
48
+ }
43
49
  (0, paramsValidator_1.validateParams)(payload, [
44
50
  { name: 'signingMode', type: 'number', required: true },
45
51
  { name: 'inputs', type: 'array', required: true },
@@ -204,12 +210,15 @@ class CardanoSignTransaction extends AbstractMethod_1.AbstractMethod {
204
210
  params.signingMode !== constants_1.PROTO.CardanoTxSigningMode.PLUTUS_TRANSACTION) {
205
211
  this._ensureFeatureIsSupported('Babbage');
206
212
  }
207
- if ((_a = params.auxiliaryData) === null || _a === void 0 ? void 0 : _a.governance_registration_parameters) {
208
- const { format, delegations, voting_purpose } = params.auxiliaryData.governance_registration_parameters;
209
- if (format === constants_1.PROTO.CardanoGovernanceRegistrationFormat.CIP36 ||
213
+ if ((_a = params.auxiliaryData) === null || _a === void 0 ? void 0 : _a.cvote_registration_parameters) {
214
+ const { format, delegations, voting_purpose, payment_address } = params.auxiliaryData.cvote_registration_parameters;
215
+ if (format === constants_1.PROTO.CardanoCVoteRegistrationFormat.CIP36 ||
210
216
  (delegations === null || delegations === void 0 ? void 0 : delegations.length) ||
211
217
  voting_purpose != null) {
212
- this._ensureFeatureIsSupported('GovernanceRegistrationCIP36');
218
+ this._ensureFeatureIsSupported('CIP36Registration');
219
+ }
220
+ if (payment_address) {
221
+ this._ensureFeatureIsSupported('CIP36RegistrationExternalPaymentAddress');
213
222
  }
214
223
  }
215
224
  }
@@ -261,8 +270,8 @@ class CardanoSignTransaction extends AbstractMethod_1.AbstractMethod {
261
270
  }
262
271
  let auxiliaryDataSupplement;
263
272
  if (this.params.auxiliaryData) {
264
- const { governance_registration_parameters } = this.params.auxiliaryData;
265
- if (governance_registration_parameters) {
273
+ const { cvote_registration_parameters } = this.params.auxiliaryData;
274
+ if (cvote_registration_parameters) {
266
275
  this.params.auxiliaryData = (0, cardanoAuxiliaryData_1.modifyAuxiliaryDataForBackwardsCompatibility)(this.device, this.params.auxiliaryData);
267
276
  }
268
277
  const { message } = await typedCall('CardanoTxAuxiliaryData', 'CardanoTxAuxiliaryDataSupplement', this.params.auxiliaryData);
@@ -271,8 +280,9 @@ class CardanoSignTransaction extends AbstractMethod_1.AbstractMethod {
271
280
  auxiliaryDataSupplement = {
272
281
  type: auxiliaryDataType,
273
282
  auxiliaryDataHash: message.auxiliary_data_hash,
274
- governanceSignature: message.governance_signature,
275
- catalystSignature: message.governance_signature,
283
+ cVoteRegistrationSignature: message.cvote_registration_signature,
284
+ catalystSignature: message.cvote_registration_signature,
285
+ governanceSignature: message.cvote_registration_signature,
276
286
  };
277
287
  }
278
288
  await typedCall('CardanoTxHostAck', 'CardanoTxItemAck');
@@ -172,7 +172,7 @@ class ComposeTransaction extends AbstractMethod_1.AbstractMethod {
172
172
  discovery.removeAllListeners();
173
173
  discovery.stop();
174
174
  if (!discovery.completed) {
175
- await (0, promiseUtils_1.resolveAfter)(501);
175
+ await (0, promiseUtils_1.resolveAfter)(501).promise;
176
176
  }
177
177
  const account = discovery.accounts[uiResp.payload];
178
178
  this.params.coinInfo = (0, coinInfo_1.fixCoinInfoNetwork)(this.params.coinInfo, account.address_n);
@@ -195,7 +195,7 @@ class ComposeTransaction extends AbstractMethod_1.AbstractMethod {
195
195
  const hasFunds = composer.composeAllFeeLevels();
196
196
  if (!hasFunds) {
197
197
  this.postMessage((0, events_1.createUiMessage)(events_1.UI.INSUFFICIENT_FUNDS));
198
- await (0, promiseUtils_1.resolveAfter)(2000, null);
198
+ await (0, promiseUtils_1.resolveAfter)(2000, null).promise;
199
199
  return 'change-account';
200
200
  }
201
201
  this.postMessage((0, events_1.createUiMessage)(events_1.UI.SELECT_FEE, {
@@ -0,0 +1,7 @@
1
+ import { EthereumDefinitions } from '@trezor/transport/lib/types/messages';
2
+ export declare const getEthereumDefinitions: ({ chainId, slip44, contractAddress, }: {
3
+ chainId: number | undefined;
4
+ slip44?: number | undefined;
5
+ contractAddress?: string | undefined;
6
+ }) => Promise<EthereumDefinitions>;
7
+ //# sourceMappingURL=ethereumDefinitions.d.ts.map
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getEthereumDefinitions = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const cross_fetch_1 = tslib_1.__importDefault(require("cross-fetch"));
6
+ const getEthereumDefinitions = async ({ chainId, slip44, contractAddress, }) => {
7
+ const definitions = {};
8
+ if (!chainId && !slip44) {
9
+ throw new Error('argument chainId or slip44 is required');
10
+ }
11
+ try {
12
+ const networkDefinitionUrl = `https://data.trezor.io/firmware/eth-definitions/${chainId ? 'chain-id' : 'slip44'}/${chainId !== null && chainId !== void 0 ? chainId : slip44}/network.dat`;
13
+ const networkDefinition = await (0, cross_fetch_1.default)(networkDefinitionUrl);
14
+ if (networkDefinition.status === 200) {
15
+ definitions.encoded_network = await networkDefinition.arrayBuffer();
16
+ }
17
+ else if (networkDefinition.status !== 404) {
18
+ throw new Error(`unexpected status: $${networkDefinition.status}`);
19
+ }
20
+ }
21
+ catch (err) {
22
+ console.warn(`unable to download or parse ${chainId} definition. detail: ${err.message}`);
23
+ }
24
+ try {
25
+ if (contractAddress) {
26
+ const lowerCaseContractAddress = contractAddress.toLowerCase();
27
+ const tokenDefinitionUrl = `https://data.trezor.io/firmware/eth-definitions/${chainId ? 'chain-id' : 'slip44'}/${chainId !== null && chainId !== void 0 ? chainId : slip44}/token-${lowerCaseContractAddress}.dat`;
28
+ const tokenDefinition = await (0, cross_fetch_1.default)(tokenDefinitionUrl);
29
+ if (tokenDefinition.status === 200) {
30
+ definitions.encoded_token = await tokenDefinition.arrayBuffer();
31
+ }
32
+ else if (tokenDefinition.status !== 404) {
33
+ throw new Error(`unexpected status: $${tokenDefinition.status}`);
34
+ }
35
+ }
36
+ }
37
+ catch (err) {
38
+ console.warn(`unable to download or parse ${chainId}/${contractAddress} definition. detail: ${err.message}`);
39
+ }
40
+ return definitions;
41
+ };
42
+ exports.getEthereumDefinitions = getEthereumDefinitions;
43
+ //# sourceMappingURL=ethereumDefinitions.js.map
@@ -1,11 +1,12 @@
1
+ import { EthereumDefinitions } from '@trezor/transport/lib/types/messages';
1
2
  import type { TypedCall } from '../../device/DeviceCommands';
2
3
  import type { EthereumAccessList } from '../../types/api/ethereum';
3
- export declare const ethereumSignTx: (typedCall: TypedCall, address_n: number[], to: string, value: string, gas_limit: string, gas_price: string, nonce: string, chain_id: number, data?: string, tx_type?: number) => Promise<{
4
+ export declare const ethereumSignTx: (typedCall: TypedCall, address_n: number[], to: string, value: string, gas_limit: string, gas_price: string, nonce: string, chain_id: number, data?: string, tx_type?: number, definitions?: EthereumDefinitions) => Promise<{
4
5
  v: string;
5
6
  r: string;
6
7
  s: string;
7
8
  }>;
8
- export declare const ethereumSignTxEIP1559: (typedCall: TypedCall, address_n: number[], to: string, value: string, gas_limit: string, max_gas_fee: string, max_priority_fee: string, nonce: string, chain_id: number, data?: string, access_list?: EthereumAccessList[]) => Promise<{
9
+ export declare const ethereumSignTxEIP1559: (typedCall: TypedCall, address_n: number[], to: string, value: string, gas_limit: string, max_gas_fee: string, max_priority_fee: string, nonce: string, chain_id: number, data?: string, access_list?: EthereumAccessList[], definitions?: EthereumDefinitions) => Promise<{
9
10
  v: string;
10
11
  r: string;
11
12
  s: string;
@@ -37,7 +37,7 @@ const stripLeadingZeroes = (str) => {
37
37
  }
38
38
  return str;
39
39
  };
40
- const ethereumSignTx = async (typedCall, address_n, to, value, gas_limit, gas_price, nonce, chain_id, data, tx_type) => {
40
+ const ethereumSignTx = async (typedCall, address_n, to, value, gas_limit, gas_price, nonce, chain_id, data, tx_type, definitions) => {
41
41
  const length = data == null ? 0 : data.length / 2;
42
42
  const [first, rest] = splitString(data, 1024 * 2);
43
43
  let message = {
@@ -48,6 +48,7 @@ const ethereumSignTx = async (typedCall, address_n, to, value, gas_limit, gas_pr
48
48
  gas_limit: stripLeadingZeroes(gas_limit),
49
49
  to,
50
50
  value: stripLeadingZeroes(value),
51
+ definitions,
51
52
  };
52
53
  if (length !== 0) {
53
54
  message = {
@@ -66,7 +67,7 @@ const ethereumSignTx = async (typedCall, address_n, to, value, gas_limit, gas_pr
66
67
  return processTxRequest(typedCall, response.message, rest, chain_id);
67
68
  };
68
69
  exports.ethereumSignTx = ethereumSignTx;
69
- const ethereumSignTxEIP1559 = async (typedCall, address_n, to, value, gas_limit, max_gas_fee, max_priority_fee, nonce, chain_id, data, access_list) => {
70
+ const ethereumSignTxEIP1559 = async (typedCall, address_n, to, value, gas_limit, max_gas_fee, max_priority_fee, nonce, chain_id, data, access_list, definitions) => {
70
71
  const length = data == null ? 0 : data.length / 2;
71
72
  const [first, rest] = splitString(data, 1024 * 2);
72
73
  const message = {
@@ -84,6 +85,7 @@ const ethereumSignTxEIP1559 = async (typedCall, address_n, to, value, gas_limit,
84
85
  address: a.address,
85
86
  storage_keys: a.storageKeys,
86
87
  })),
88
+ definitions,
87
89
  };
88
90
  const response = await typedCall('EthereumSignTxEIP1559', 'EthereumTxRequest', message);
89
91
  return processTxRequest(typedCall, response.message, rest);
@@ -4,6 +4,7 @@ import type { EthereumNetworkInfo } from '../types';
4
4
  type Params = PROTO.EthereumGetAddress & {
5
5
  address?: string;
6
6
  network?: EthereumNetworkInfo;
7
+ encoded_network?: ArrayBuffer;
7
8
  };
8
9
  export default class EthereumGetAddress extends AbstractMethod<'ethereumGetAddress', Params[]> {
9
10
  hasBundle?: boolean;
@@ -17,7 +18,7 @@ export default class EthereumGetAddress extends AbstractMethod<'ethereumGetAddre
17
18
  } | undefined;
18
19
  confirmation(): Promise<boolean>;
19
20
  noBackupConfirmation(): Promise<boolean>;
20
- _call({ address_n, show_display }: Params): Promise<{
21
+ _call({ address_n, show_display, encoded_network }: Params): Promise<{
21
22
  path: number[];
22
23
  serializedPath: string;
23
24
  address: string;