@trezor/connect 9.0.0-beta.4 → 9.0.0-beta.7

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 (157) hide show
  1. package/README.md +37 -14
  2. package/lib/api/binance/binanceSignTx.d.ts +1 -1
  3. package/lib/api/binanceSignTransaction.d.ts +1 -1
  4. package/lib/api/binanceSignTransaction.js +1 -1
  5. package/lib/api/bitcoin/Fees.js +1 -1
  6. package/lib/api/bitcoin/TransactionComposer.js +1 -1
  7. package/lib/api/bitcoin/enhanceSignTx.d.ts +1 -1
  8. package/lib/api/bitcoin/index.js +9 -9
  9. package/lib/api/bitcoin/refTx.d.ts +3 -3
  10. package/lib/api/bitcoin/signtx.d.ts +1 -1
  11. package/lib/api/bitcoin/signtxLegacy.d.ts +1 -1
  12. package/lib/api/cardano/cardanoAddressParameters.d.ts +1 -1
  13. package/lib/api/cardano/cardanoAuxiliaryData.d.ts +1 -1
  14. package/lib/api/cardano/cardanoCertificate.d.ts +1 -1
  15. package/lib/api/cardano/cardanoInputs.d.ts +1 -0
  16. package/lib/api/cardano/cardanoInputs.js +12 -1
  17. package/lib/api/cardano/cardanoOutputs.d.ts +6 -3
  18. package/lib/api/cardano/cardanoOutputs.js +37 -1
  19. package/lib/api/cardano/cardanoTokenBundle.d.ts +1 -1
  20. package/lib/api/cardano/cardanoUtils.d.ts +3 -0
  21. package/lib/api/cardano/cardanoUtils.js +17 -0
  22. package/lib/api/cardano/cardanoWitnesses.js +4 -4
  23. package/lib/api/cardanoGetAddress.d.ts +1 -1
  24. package/lib/api/cardanoGetNativeScriptHash.d.ts +1 -1
  25. package/lib/api/cardanoGetPublicKey.d.ts +1 -1
  26. package/lib/api/cardanoSignTransaction.d.ts +8 -4
  27. package/lib/api/cardanoSignTransaction.js +40 -17
  28. package/lib/api/common/Discovery.js +1 -1
  29. package/lib/api/common/paramsValidator.d.ts +1 -1
  30. package/lib/api/composeTransaction.d.ts +1 -1
  31. package/lib/api/composeTransaction.js +2 -2
  32. package/lib/api/eos/eosSignTx.d.ts +1 -1
  33. package/lib/api/eos/eosSignTx.js +1 -1
  34. package/lib/api/eosGetPublicKey.d.ts +1 -1
  35. package/lib/api/eosSignTransaction.js +1 -1
  36. package/lib/api/ethereum/__fixtures__/ethereumSignTypedData.js +1 -1
  37. package/lib/api/ethereum/ethereumSignTx.d.ts +3 -3
  38. package/lib/api/ethereum/ethereumSignTypedData.d.ts +1 -1
  39. package/lib/api/ethereum/ethereumSignTypedData.js +1 -1
  40. package/lib/api/ethereumSignTransaction.d.ts +1 -1
  41. package/lib/api/ethereumSignTransaction.js +1 -1
  42. package/lib/api/ethereumSignTypedData.d.ts +1 -1
  43. package/lib/api/firmware/calculateFirmwareHash.d.ts +6 -0
  44. package/lib/api/firmware/calculateFirmwareHash.js +26 -0
  45. package/lib/api/firmware/getBinary.d.ts +2 -2
  46. package/lib/api/firmware/getBinary.js +2 -3
  47. package/lib/api/firmware/index.d.ts +5 -0
  48. package/lib/api/firmware/index.js +13 -0
  49. package/lib/api/firmware/modifyFirmware.d.ts +3 -5
  50. package/lib/api/firmware/modifyFirmware.js +12 -10
  51. package/lib/api/{management → firmware}/uploadFirmware.d.ts +0 -0
  52. package/lib/api/{management → firmware}/uploadFirmware.js +0 -0
  53. package/lib/api/firmwareUpdate.d.ts +4 -1
  54. package/lib/api/firmwareUpdate.js +8 -13
  55. package/lib/api/getFirmwareHash.d.ts +7 -0
  56. package/lib/api/getFirmwareHash.js +29 -0
  57. package/lib/api/index.d.ts +1 -0
  58. package/lib/api/index.js +4 -2
  59. package/lib/api/nem/nemSignTx.d.ts +1 -1
  60. package/lib/api/nemSignTransaction.js +1 -1
  61. package/lib/api/signTransaction.d.ts +2 -2
  62. package/lib/api/signTransaction.js +1 -1
  63. package/lib/api/stellar/stellarSignTx.d.ts +1 -1
  64. package/lib/api/stellarSignTransaction.d.ts +1 -1
  65. package/lib/api/stellarSignTransaction.js +1 -1
  66. package/lib/api/tezos/tezosSignTx.d.ts +1 -1
  67. package/lib/api/tezos/tezosSignTx.js +1 -1
  68. package/lib/api/tezosSignTransaction.js +1 -1
  69. package/lib/backend/BlockchainLink.js +1 -1
  70. package/lib/constants/errors.d.ts +1 -1
  71. package/lib/constants/errors.js +1 -1
  72. package/lib/constants/index.js +5 -5
  73. package/lib/core/AbstractMethod.js +1 -1
  74. package/lib/core/index.d.ts +1 -1
  75. package/lib/core/index.js +1 -1
  76. package/lib/core/method.d.ts +1 -1
  77. package/lib/core/method.js +1 -1
  78. package/lib/data/DataManager.js +1 -1
  79. package/lib/data/connectSettings.d.ts +1 -1
  80. package/lib/data/firmwareInfo.js +0 -9
  81. package/lib/data/version.d.ts +1 -1
  82. package/lib/data/version.js +1 -1
  83. package/lib/device/AbortController.js +1 -1
  84. package/lib/device/DescriptorStream.js +1 -1
  85. package/lib/device/Device.js +1 -1
  86. package/lib/device/DeviceCommands.js +2 -2
  87. package/lib/device/DeviceList.js +6 -4
  88. package/lib/events/index.js +10 -10
  89. package/lib/exports.js +3 -3
  90. package/lib/factory.js +1 -0
  91. package/lib/index-browser.js +1 -1
  92. package/lib/index.js +2 -2
  93. package/lib/types/api/binance/index.d.ts +29 -0
  94. package/lib/types/api/binance/index.js +3 -0
  95. package/lib/types/api/binanceSignTransaction.d.ts +1 -27
  96. package/lib/types/api/bitcoin/index.d.ts +82 -0
  97. package/lib/types/api/bitcoin/index.js +3 -0
  98. package/lib/types/api/cardano/index.d.ts +193 -0
  99. package/lib/types/api/cardano/index.js +3 -0
  100. package/lib/types/api/cardanoGetAddress.d.ts +1 -31
  101. package/lib/types/api/cardanoGetNativeScriptHash.d.ts +1 -18
  102. package/lib/types/api/cardanoGetPublicKey.d.ts +1 -12
  103. package/lib/types/api/cardanoSignTransaction.d.ts +1 -127
  104. package/lib/types/api/eos/index.d.ts +119 -0
  105. package/lib/types/api/eos/index.js +3 -0
  106. package/lib/types/api/eosGetPublicKey.d.ts +1 -10
  107. package/lib/types/api/eosSignTransaction.d.ts +1 -107
  108. package/lib/types/api/ethereum/index.d.ts +86 -0
  109. package/lib/types/api/ethereum/index.js +3 -0
  110. package/lib/types/api/ethereumSignMessage.d.ts +1 -5
  111. package/lib/types/api/ethereumSignTransaction.d.ts +1 -37
  112. package/lib/types/api/ethereumSignTypedData.d.ts +1 -37
  113. package/lib/types/api/ethereumVerifyMessage.d.ts +1 -6
  114. package/lib/types/api/firmwareUpdate.d.ts +6 -3
  115. package/lib/types/api/getFirmwareHash.d.ts +4 -0
  116. package/lib/types/api/getFirmwareHash.js +3 -0
  117. package/lib/types/api/index.d.ts +2 -0
  118. package/lib/types/api/nem/index.d.ts +90 -0
  119. package/lib/types/api/nem/index.js +3 -0
  120. package/lib/types/api/nemSignTransaction.d.ts +2 -89
  121. package/lib/types/api/ripple/index.d.ts +21 -0
  122. package/lib/types/api/ripple/index.js +3 -0
  123. package/lib/types/api/rippleSignTransaction.d.ts +1 -20
  124. package/lib/types/api/signMessage.d.ts +1 -7
  125. package/lib/types/api/signTransaction.d.ts +1 -67
  126. package/lib/types/api/stellar/index.d.ts +180 -0
  127. package/lib/types/api/stellar/index.js +3 -0
  128. package/lib/types/api/stellarSignTransaction.d.ts +1 -179
  129. package/lib/types/api/tezos/index.d.ts +58 -0
  130. package/lib/types/api/tezos/index.js +3 -0
  131. package/lib/types/api/tezosSignTransaction.d.ts +1 -57
  132. package/lib/types/api/verifyMessage.d.ts +1 -7
  133. package/lib/types/index.d.ts +8 -4
  134. package/lib/types/index.js +15 -7
  135. package/lib/utils/__fixtures__/accountUtils.js +1 -1
  136. package/lib/utils/__fixtures__/ethereumUtils.js +1 -1
  137. package/lib/utils/__fixtures__/formatUtils.js +1 -1
  138. package/lib/utils/accountUtils.d.ts +2 -2
  139. package/lib/utils/assetUtils.d.ts +2 -0
  140. package/lib/utils/assetUtils.js +22 -0
  141. package/lib/utils/assets-browser.js +1 -1
  142. package/lib/utils/assets-native.d.ts +2 -0
  143. package/lib/utils/assets-native.js +7 -0
  144. package/lib/utils/assets.js +6 -14
  145. package/lib/utils/browserUtils.js +1 -1
  146. package/lib/utils/debug.d.ts +2 -2
  147. package/lib/utils/deviceFeaturesUtils.d.ts +1 -1
  148. package/lib/utils/deviceFeaturesUtils.js +1 -1
  149. package/lib/utils/ethereumUtils.d.ts +1 -1
  150. package/lib/utils/formatUtils.js +1 -1
  151. package/lib/utils/hdnodeUtils.d.ts +1 -1
  152. package/lib/utils/pathUtils.d.ts +2 -2
  153. package/lib/workers/workers-browser.js +5 -5
  154. package/lib/workers/workers-react-native.js +4 -4
  155. package/lib/workers/workers.js +4 -4
  156. package/package.json +12 -9
  157. package/CHANGELOG.md +0 -26
package/README.md CHANGED
@@ -1,4 +1,6 @@
1
- # @trezor/connect API version 9.0.0-beta.4
1
+ # @trezor/connect
2
+
3
+ API version 9.0.0-beta.7
2
4
 
3
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)
4
6
  [![NPM](https://img.shields.io/npm/v/@trezor/connect.svg)](https://www.npmjs.org/package/@trezor/connect)
@@ -6,9 +8,31 @@
6
8
 
7
9
  Trezor Connect is a platform for easy integration of Trezor into 3rd party services, as well as into Trezor Suite. It provides an API with functionality to access public keys, sign transactions and authenticate users.
8
10
 
9
- User interface is presented in a secure popup window served from `connect.trezor.io/<version>/popup.html`. To try it out, use [@trezor/connect-explorer](../connect-explorer) hosted [here](https://trezor.github.io/trezor-suite/connect-explorer).
11
+ This package is intended to be used in node.js environment. If you wan't to build a web application please refer to [@trezor/connect-web package](../connect-web/README.md).
12
+
13
+ ## Installation
14
+
15
+ Install library as npm module:
16
+
17
+ ```javascript
18
+ npm install @trezor/connect
19
+ ```
20
+
21
+ or
22
+
23
+ ```javascript
24
+ yarn add @trezor/connect
25
+ ```
26
+
27
+ ## Initialization
28
+
29
+ ES6
10
30
 
11
- - [Integration](https://github.com/trezor/trezor-suite/blob/develop/docs/packages/connect/index.md)
31
+ ```javascript
32
+ import TrezorConnect from '@trezor/connect';
33
+ ```
34
+
35
+ For more instructions [refer to this document](../../docs/packages/connect/index.md)
12
36
 
13
37
  ## Version 9+ (experimental)
14
38
 
@@ -19,17 +43,6 @@ Since version 9 we are adopting a new versioning strategy. With every release, w
19
43
 
20
44
  Version 9+ will be available as `@trezor/connect` and `@trezor/connect-web` npm packages.
21
45
 
22
- ## Step by step release process
23
-
24
- - Make sure you have released all [npm dependencies](../../releases/npm-packages.md).
25
- - Optional: if unsure run `node ./ci/scripts/check-npm-dependencies.js connect`. Please note that this script will report unreleased dependencies even for changes that do not affect runtime (READMEs etc.)
26
- - bump version in all @trezor/connect\* packages (except plugin packages). `yarn workspace @trezor/connect version:<beta|patch|minor|major>`
27
- - make sure CHANGELOG files have been updated
28
- - merge into develop branch
29
- - from develop branch create a pull requests into branch `release/connect-v9`
30
- - gitlab: click manual release `@trezor/connect-web` and `@trezor/connect` into npm
31
- - gitlab: click manual deploy job to connect.trezor.io/9
32
-
33
46
  ## Version 8 (stable)
34
47
 
35
48
  Currently, we are at version 8, which has an url https://connect.trezor.io/8/trezor-connect.js.
@@ -44,6 +57,16 @@ With regards to this repo - All updates should go to current version branch, the
44
57
 
45
58
  For deployment process of trezor-connect v8 refer to [trezor/connect repository](https://github.com/trezor/connect/blob/develop/docs/deployment/index.md)
46
59
 
60
+ ## Docs
61
+
62
+ Interactive API explorer is available on https://connect.trezor.io/9/#/
63
+
64
+ Documentation is available [docs/packages/connect](../../docs/packages/connect/index.md)
65
+
66
+ ## Examples
67
+
68
+ A collection of examples on how to implement @trezor/connect in various environments is available in [packages/connect-examples](../connect-examples/README.md)
69
+
47
70
  ## Tests
48
71
 
49
72
  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).
@@ -1,5 +1,5 @@
1
1
  import { PROTO } from '../../constants';
2
- import type { BinanceSDKTransaction, BinancePreparedTransaction } from '../../types/api/binanceSignTransaction';
2
+ import type { BinanceSDKTransaction, BinancePreparedTransaction } from '../../types/api/binance';
3
3
  import type { TypedCall } from '../../device/DeviceCommands';
4
4
  export declare const validate: (tx: BinanceSDKTransaction) => BinancePreparedTransaction;
5
5
  export declare const signTx: (typedCall: TypedCall, address_n: number[], tx: BinancePreparedTransaction) => Promise<PROTO.BinanceSignedTx>;
@@ -1,5 +1,5 @@
1
1
  import { AbstractMethod } from '../core/AbstractMethod';
2
- import type { BinancePreparedTransaction } from '../types/api/binanceSignTransaction';
2
+ import type { BinancePreparedTransaction } from '../types/api/binance';
3
3
  declare type Params = {
4
4
  path: number[];
5
5
  transaction: BinancePreparedTransaction;
@@ -5,7 +5,7 @@ const AbstractMethod_1 = require("../core/AbstractMethod");
5
5
  const paramsValidator_1 = require("./common/paramsValidator");
6
6
  const coinInfo_1 = require("../data/coinInfo");
7
7
  const pathUtils_1 = require("../utils/pathUtils");
8
- const helper = (0, tslib_1.__importStar)(require("./binance/binanceSignTx"));
8
+ const helper = tslib_1.__importStar(require("./binance/binanceSignTx"));
9
9
  class BinanceSignTransaction extends AbstractMethod_1.AbstractMethod {
10
10
  init() {
11
11
  this.requiredPermissions = ['read', 'write'];
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FeeLevels = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const bignumber_js_1 = (0, tslib_1.__importDefault)(require("bignumber.js"));
5
+ const bignumber_js_1 = tslib_1.__importDefault(require("bignumber.js"));
6
6
  const BLOCKS = {
7
7
  btc: {
8
8
  high: 1,
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TransactionComposer = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const bignumber_js_1 = (0, tslib_1.__importDefault)(require("bignumber.js"));
5
+ const bignumber_js_1 = tslib_1.__importDefault(require("bignumber.js"));
6
6
  const utxo_lib_1 = require("@trezor/utxo-lib");
7
7
  const Fees_1 = require("./Fees");
8
8
  const pathUtils_1 = require("../../utils/pathUtils");
@@ -1,4 +1,4 @@
1
1
  import type { BitcoinNetworkInfo } from '../../types';
2
- import type { TransactionOptions } from '../../types/api/signTransaction';
2
+ import type { TransactionOptions } from '../../types/api/bitcoin';
3
3
  export declare const enhanceSignTx: (options: TransactionOptions, coinInfo: BitcoinNetworkInfo) => TransactionOptions;
4
4
  //# sourceMappingURL=enhanceSignTx.d.ts.map
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- (0, tslib_1.__exportStar)(require("./enhanceSignTx"), exports);
5
- (0, tslib_1.__exportStar)(require("./Fees"), exports);
6
- (0, tslib_1.__exportStar)(require("./inputs"), exports);
7
- (0, tslib_1.__exportStar)(require("./outputs"), exports);
8
- (0, tslib_1.__exportStar)(require("./refTx"), exports);
9
- (0, tslib_1.__exportStar)(require("./signtx"), exports);
10
- (0, tslib_1.__exportStar)(require("./signtxLegacy"), exports);
11
- (0, tslib_1.__exportStar)(require("./signtxVerify"), exports);
12
- (0, tslib_1.__exportStar)(require("./TransactionComposer"), exports);
4
+ tslib_1.__exportStar(require("./enhanceSignTx"), exports);
5
+ tslib_1.__exportStar(require("./Fees"), exports);
6
+ tslib_1.__exportStar(require("./inputs"), exports);
7
+ tslib_1.__exportStar(require("./outputs"), exports);
8
+ tslib_1.__exportStar(require("./refTx"), exports);
9
+ tslib_1.__exportStar(require("./signtx"), exports);
10
+ tslib_1.__exportStar(require("./signtxLegacy"), exports);
11
+ tslib_1.__exportStar(require("./signtxVerify"), exports);
12
+ tslib_1.__exportStar(require("./TransactionComposer"), exports);
13
13
  //# sourceMappingURL=index.js.map
@@ -1,11 +1,11 @@
1
1
  import type { TypedRawTransaction } from '@trezor/blockchain-link';
2
2
  import type { CoinInfo, AccountAddresses } from '../../types';
3
- import type { RefTransaction, TransactionOptions } from '../../types/api/signTransaction';
3
+ import type { RefTransaction, TransactionOptions } from '../../types/api/bitcoin';
4
4
  import type { PROTO } from '../../constants';
5
- export declare const requireReferencedTransactions: (inputs: PROTO.TxInputType[], options?: TransactionOptions, coinInfo?: CoinInfo | undefined) => boolean;
5
+ export declare const requireReferencedTransactions: (inputs: PROTO.TxInputType[], options?: TransactionOptions, coinInfo?: CoinInfo) => boolean;
6
6
  export declare const getReferencedTransactions: (inputs: PROTO.TxInputType[]) => string[];
7
7
  export declare const getOrigTransactions: (inputs: PROTO.TxInputType[], outputs: PROTO.TxOutputType[]) => string[];
8
- export declare const transformOrigTransactions: (txs: TypedRawTransaction[], coinInfo: CoinInfo, addresses?: AccountAddresses | undefined) => RefTransaction[];
8
+ export declare const transformOrigTransactions: (txs: TypedRawTransaction[], coinInfo: CoinInfo, addresses?: AccountAddresses) => RefTransaction[];
9
9
  export declare const transformReferencedTransactions: (txs: TypedRawTransaction[], coinInfo: CoinInfo) => RefTransaction[];
10
10
  export declare const validateReferencedTransactions: (txs: RefTransaction[] | typeof undefined, inputs: PROTO.TxInputType[], outputs: PROTO.TxOutputType[]) => RefTransaction[] | undefined;
11
11
  //# sourceMappingURL=refTx.d.ts.map
@@ -1,7 +1,7 @@
1
1
  import { PROTO } from '../../constants';
2
2
  import type { BitcoinNetworkInfo } from '../../types';
3
3
  import type { TypedCall } from '../../device/DeviceCommands';
4
- import type { RefTransaction, TransactionOptions, SignedTransaction } from '../../types/api/signTransaction';
4
+ import type { RefTransaction, TransactionOptions, SignedTransaction } from '../../types/api/bitcoin';
5
5
  export interface SignTxHelperProps {
6
6
  typedCall: TypedCall;
7
7
  txRequest: PROTO.TxRequest;
@@ -1,4 +1,4 @@
1
- import type { SignedTransaction } from '../../types/api/signTransaction';
1
+ import type { SignedTransaction } from '../../types/api/bitcoin';
2
2
  import type { SignTxHelperParams } from './signtx';
3
3
  export declare const signTxLegacy: ({ typedCall, inputs, outputs, refTxs, options, coinInfo, }: SignTxHelperParams) => Promise<SignedTransaction>;
4
4
  //# sourceMappingURL=signtxLegacy.d.ts.map
@@ -1,6 +1,6 @@
1
1
  import { PROTO } from '../../constants';
2
2
  import type { Device } from '../../device/Device';
3
- import type { CardanoAddressParameters } from '../../types/api/cardanoGetAddress';
3
+ import type { CardanoAddressParameters } from '../../types/api/cardano';
4
4
  export declare const validateAddressParameters: (addressParameters: CardanoAddressParameters) => void;
5
5
  export declare const modifyAddressParametersForBackwardsCompatibility: (device: Device, address_parameters: PROTO.CardanoAddressParametersType) => PROTO.CardanoAddressParametersType;
6
6
  export declare const addressParametersToProto: (addressParameters: CardanoAddressParameters) => PROTO.CardanoAddressParametersType;
@@ -1,6 +1,6 @@
1
1
  import type { Device } from '../../device/Device';
2
2
  import type { PROTO } from '../../constants';
3
- import type { CardanoAuxiliaryData } from '../../types/api/cardanoSignTransaction';
3
+ import type { CardanoAuxiliaryData } from '../../types/api/cardano';
4
4
  export declare const transformAuxiliaryData: (auxiliaryData: CardanoAuxiliaryData) => PROTO.CardanoTxAuxiliaryData;
5
5
  export declare const modifyAuxiliaryDataForBackwardsCompatibility: (device: Device, auxiliary_data: PROTO.CardanoTxAuxiliaryData) => PROTO.CardanoTxAuxiliaryData;
6
6
  //# sourceMappingURL=cardanoAuxiliaryData.d.ts.map
@@ -1,5 +1,5 @@
1
1
  import { PROTO } from '../../constants';
2
- import type { CardanoCertificate } from '../../types/api/cardanoSignTransaction';
2
+ import type { CardanoCertificate } from '../../types/api/cardano';
3
3
  export declare type CertificateWithPoolOwnersAndRelays = {
4
4
  certificate: PROTO.CardanoTxCertificate;
5
5
  poolOwners: PROTO.CardanoPoolOwner[];
@@ -10,4 +10,5 @@ export declare type CollateralInputWithPath = {
10
10
  };
11
11
  export declare const transformInput: (input: any) => InputWithPath;
12
12
  export declare const transformCollateralInput: (collateralInput: any) => CollateralInputWithPath;
13
+ export declare const transformReferenceInput: (referenceInput: any) => PROTO.CardanoTxReferenceInput;
13
14
  //# sourceMappingURL=cardanoInputs.d.ts.map
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.transformCollateralInput = exports.transformInput = void 0;
3
+ exports.transformReferenceInput = exports.transformCollateralInput = exports.transformInput = void 0;
4
4
  const paramsValidator_1 = require("../common/paramsValidator");
5
5
  const pathUtils_1 = require("../../utils/pathUtils");
6
6
  const transformInput = (input) => {
@@ -31,4 +31,15 @@ const transformCollateralInput = (collateralInput) => {
31
31
  };
32
32
  };
33
33
  exports.transformCollateralInput = transformCollateralInput;
34
+ const transformReferenceInput = (referenceInput) => {
35
+ (0, paramsValidator_1.validateParams)(referenceInput, [
36
+ { name: 'prev_hash', type: 'string', required: true },
37
+ { name: 'prev_index', type: 'number', required: true },
38
+ ]);
39
+ return {
40
+ prev_hash: referenceInput.prev_hash,
41
+ prev_index: referenceInput.prev_index,
42
+ };
43
+ };
44
+ exports.transformReferenceInput = transformReferenceInput;
34
45
  //# sourceMappingURL=cardanoInputs.js.map
@@ -1,8 +1,11 @@
1
1
  import type { AssetGroupWithTokens } from './cardanoTokenBundle';
2
- import type { PROTO } from '../../constants';
3
- export declare type OutputWithTokens = {
2
+ import { PROTO } from '../../constants';
3
+ export declare type OutputWithData = {
4
4
  output: PROTO.CardanoTxOutput;
5
5
  tokenBundle?: AssetGroupWithTokens[];
6
+ inlineDatum?: string;
7
+ referenceScript?: string;
6
8
  };
7
- export declare const transformOutput: (output: any) => OutputWithTokens;
9
+ export declare const transformOutput: (output: any) => OutputWithData;
10
+ export declare const sendOutput: (typedCall: any, outputWithData: OutputWithData) => Promise<void>;
8
11
  //# sourceMappingURL=cardanoOutputs.d.ts.map
@@ -1,22 +1,35 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.transformOutput = void 0;
3
+ exports.sendOutput = exports.transformOutput = void 0;
4
4
  const paramsValidator_1 = require("../common/paramsValidator");
5
5
  const cardanoAddressParameters_1 = require("./cardanoAddressParameters");
6
6
  const cardanoTokenBundle_1 = require("./cardanoTokenBundle");
7
+ const cardanoUtils_1 = require("./cardanoUtils");
7
8
  const transformOutput = (output) => {
8
9
  (0, paramsValidator_1.validateParams)(output, [
9
10
  { name: 'address', type: 'string' },
10
11
  { name: 'amount', type: 'uint', required: true },
11
12
  { name: 'tokenBundle', type: 'array', allowEmpty: true },
12
13
  { name: 'datumHash', type: 'string' },
14
+ { name: 'format', type: 'number' },
15
+ { name: 'inlineDatum', type: 'string' },
16
+ { name: 'referenceScript', type: 'string' },
13
17
  ]);
14
18
  const result = {
15
19
  output: {
16
20
  amount: output.amount,
17
21
  asset_groups_count: 0,
18
22
  datum_hash: output.datumHash,
23
+ format: output.format,
24
+ inline_datum_size: output.inlineDatum
25
+ ? (0, cardanoUtils_1.hexStringByteLength)(output.inlineDatum)
26
+ : undefined,
27
+ reference_script_size: output.referenceScript
28
+ ? (0, cardanoUtils_1.hexStringByteLength)(output.referenceScript)
29
+ : undefined,
19
30
  },
31
+ inlineDatum: output.inlineDatum,
32
+ referenceScript: output.referenceScript,
20
33
  };
21
34
  if (output.addressParameters) {
22
35
  (0, cardanoAddressParameters_1.validateAddressParameters)(output.addressParameters);
@@ -35,4 +48,27 @@ const transformOutput = (output) => {
35
48
  return result;
36
49
  };
37
50
  exports.transformOutput = transformOutput;
51
+ const sendOutput = async (typedCall, outputWithData) => {
52
+ const MAX_CHUNK_SIZE = 1024 * 2;
53
+ const { output, tokenBundle, inlineDatum, referenceScript } = outputWithData;
54
+ await typedCall('CardanoTxOutput', 'CardanoTxItemAck', output);
55
+ if (tokenBundle) {
56
+ for (const assetGroup of tokenBundle) {
57
+ await typedCall('CardanoAssetGroup', 'CardanoTxItemAck', {
58
+ policy_id: assetGroup.policyId,
59
+ tokens_count: assetGroup.tokens.length,
60
+ });
61
+ for (const token of assetGroup.tokens) {
62
+ await typedCall('CardanoToken', 'CardanoTxItemAck', token);
63
+ }
64
+ }
65
+ }
66
+ if (inlineDatum) {
67
+ await (0, cardanoUtils_1.sendChunkedHexString)(typedCall, inlineDatum, MAX_CHUNK_SIZE, 'CardanoTxInlineDatumChunk');
68
+ }
69
+ if (referenceScript) {
70
+ await (0, cardanoUtils_1.sendChunkedHexString)(typedCall, referenceScript, MAX_CHUNK_SIZE, 'CardanoTxReferenceScriptChunk');
71
+ }
72
+ };
73
+ exports.sendOutput = sendOutput;
38
74
  //# sourceMappingURL=cardanoOutputs.js.map
@@ -1,5 +1,5 @@
1
1
  import type { PROTO } from '../../constants';
2
- import type { CardanoAssetGroup } from '../../types/api/cardanoSignTransaction';
2
+ import type { CardanoAssetGroup } from '../../types/api/cardano';
3
3
  export declare type AssetGroupWithTokens = {
4
4
  policyId: string;
5
5
  tokens: PROTO.CardanoToken[];
@@ -0,0 +1,3 @@
1
+ export declare const hexStringByteLength: (s: string) => number;
2
+ export declare const sendChunkedHexString: (typedCall: any, data: string, chunkSize: number, messageType: string) => Promise<void>;
3
+ //# sourceMappingURL=cardanoUtils.d.ts.map
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sendChunkedHexString = exports.hexStringByteLength = void 0;
4
+ const hexStringByteLength = (s) => s.length / 2;
5
+ exports.hexStringByteLength = hexStringByteLength;
6
+ const sendChunkedHexString = async (typedCall, data, chunkSize, messageType) => {
7
+ let processedSize = 0;
8
+ while (processedSize < data.length) {
9
+ const chunk = data.slice(processedSize, processedSize + chunkSize);
10
+ await typedCall(messageType, 'CardanoTxItemAck', {
11
+ data: chunk,
12
+ });
13
+ processedSize += chunkSize;
14
+ }
15
+ };
16
+ exports.sendChunkedHexString = sendChunkedHexString;
17
+ //# sourceMappingURL=cardanoUtils.js.map
@@ -34,11 +34,11 @@ const gatherWitnessPaths = (inputsWithPath, certificatesWithPoolOwnersAndRelays,
34
34
  if (path)
35
35
  _insert(path);
36
36
  });
37
- requiredSigners.forEach(({ key_path }) => {
38
- if (key_path)
39
- _insert(key_path);
40
- });
41
37
  }
38
+ requiredSigners.forEach(({ key_path }) => {
39
+ if (key_path)
40
+ _insert(key_path);
41
+ });
42
42
  additionalWitnessRequests.forEach(path => {
43
43
  _insert(path);
44
44
  });
@@ -17,7 +17,7 @@ export default class CardanoGetAddress extends AbstractMethod<'cardanoGetAddress
17
17
  noBackupConfirmation(): Promise<boolean>;
18
18
  _call({ address_parameters, protocol_magic, network_id, derivation_type, show_display, }: Params): Promise<PROTO.CardanoAddress>;
19
19
  _ensureFirmwareSupportsBatch(batch: Params): void;
20
- run(): Promise<import("../types/api/cardanoGetAddress").CardanoAddress | import("../types/api/cardanoGetAddress").CardanoAddress[]>;
20
+ run(): Promise<import("..").CardanoAddress | import("..").CardanoAddress[]>;
21
21
  }
22
22
  export {};
23
23
  //# sourceMappingURL=cardanoGetAddress.d.ts.map
@@ -1,6 +1,6 @@
1
1
  import { PROTO } from '../constants';
2
2
  import { AbstractMethod } from '../core/AbstractMethod';
3
- import type { CardanoNativeScript } from '../types/api/cardanoGetNativeScriptHash';
3
+ import type { CardanoNativeScript } from '../types/api/cardano';
4
4
  export default class CardanoGetNativeScriptHash extends AbstractMethod<'cardanoGetNativeScriptHash', PROTO.CardanoGetNativeScriptHash> {
5
5
  init(): void;
6
6
  validateScript(script: CardanoNativeScript): void;
@@ -5,6 +5,6 @@ export default class CardanoGetPublicKey extends AbstractMethod<'cardanoGetPubli
5
5
  confirmed?: boolean;
6
6
  init(): void;
7
7
  confirmation(): Promise<boolean>;
8
- run(): Promise<import("../types/api/cardanoGetPublicKey").CardanoPublicKey | import("../types/api/cardanoGetPublicKey").CardanoPublicKey[]>;
8
+ run(): Promise<import("..").CardanoPublicKey | import("..").CardanoPublicKey[]>;
9
9
  }
10
10
  //# sourceMappingURL=cardanoGetPublicKey.d.ts.map
@@ -1,9 +1,9 @@
1
1
  import { AbstractMethod } from '../core/AbstractMethod';
2
2
  import type { CertificateWithPoolOwnersAndRelays } from './cardano/cardanoCertificate';
3
- import type { Path, InputWithPath, CollateralInputWithPath } from './cardano/cardanoInputs';
4
- import type { OutputWithTokens } from './cardano/cardanoOutputs';
3
+ import { Path, InputWithPath, CollateralInputWithPath } from './cardano/cardanoInputs';
4
+ import type { OutputWithData } from './cardano/cardanoOutputs';
5
5
  import { PROTO } from '../constants';
6
- import type { CardanoSignedTxData } from '../types/api/cardanoSignTransaction';
6
+ import type { CardanoSignedTxData } from '../types/api/cardano';
7
7
  import type { AssetGroupWithTokens } from './cardano/cardanoTokenBundle';
8
8
  declare const CardanoSignTransactionFeatures: Readonly<{
9
9
  TransactionStreaming: string[];
@@ -14,11 +14,12 @@ declare const CardanoSignTransactionFeatures: Readonly<{
14
14
  ScriptDataHash: string[];
15
15
  Plutus: string[];
16
16
  KeyHashStakeCredential: string[];
17
+ Babbage: string[];
17
18
  }>;
18
19
  export declare type CardanoSignTransactionParams = {
19
20
  signingMode: PROTO.CardanoTxSigningMode;
20
21
  inputsWithPath: InputWithPath[];
21
- outputsWithTokens: OutputWithTokens[];
22
+ outputsWithData: OutputWithData[];
22
23
  fee: PROTO.UintType;
23
24
  ttl?: PROTO.UintType;
24
25
  certificatesWithPoolOwnersAndRelays: CertificateWithPoolOwnersAndRelays[];
@@ -29,6 +30,9 @@ export declare type CardanoSignTransactionParams = {
29
30
  scriptDataHash?: string;
30
31
  collateralInputsWithPath: CollateralInputWithPath[];
31
32
  requiredSigners: PROTO.CardanoTxRequiredSigner[];
33
+ collateralReturnWithData?: OutputWithData;
34
+ totalCollateral?: PROTO.UintType;
35
+ referenceInputs: PROTO.CardanoTxReferenceInput[];
32
36
  protocolMagic: number;
33
37
  networkId: number;
34
38
  witnessPaths: Path[];
@@ -20,6 +20,7 @@ const CardanoSignTransactionFeatures = Object.freeze({
20
20
  ScriptDataHash: ['0', '2.4.4'],
21
21
  Plutus: ['0', '2.4.4'],
22
22
  KeyHashStakeCredential: ['0', '2.4.4'],
23
+ Babbage: ['0', '2.5.2'],
23
24
  });
24
25
  class CardanoSignTransaction extends AbstractMethod_1.AbstractMethod {
25
26
  init() {
@@ -46,6 +47,8 @@ class CardanoSignTransaction extends AbstractMethod_1.AbstractMethod {
46
47
  { name: 'scriptDataHash', type: 'string' },
47
48
  { name: 'collateralInputs', type: 'array', allowEmpty: true },
48
49
  { name: 'requiredSigners', type: 'array', allowEmpty: true },
50
+ { name: 'totalCollateral', type: 'uint' },
51
+ { name: 'referenceInputs', type: 'array', allowEmpty: true },
49
52
  { name: 'protocolMagic', type: 'number', required: true },
50
53
  { name: 'networkId', type: 'number', required: true },
51
54
  { name: 'additionalWitnessRequests', type: 'array', allowEmpty: true },
@@ -53,7 +56,7 @@ class CardanoSignTransaction extends AbstractMethod_1.AbstractMethod {
53
56
  { name: 'includeNetworkId', type: 'boolean' },
54
57
  ]);
55
58
  const inputsWithPath = payload.inputs.map(cardanoInputs_1.transformInput);
56
- const outputsWithTokens = payload.outputs.map(cardanoOutputs_1.transformOutput);
59
+ const outputsWithData = payload.outputs.map(cardanoOutputs_1.transformOutput);
57
60
  let certificatesWithPoolOwnersAndRelays = [];
58
61
  if (payload.certificates) {
59
62
  certificatesWithPoolOwnersAndRelays = payload.certificates.map(cardanoCertificate_1.transformCertificate);
@@ -102,10 +105,17 @@ class CardanoSignTransaction extends AbstractMethod_1.AbstractMethod {
102
105
  };
103
106
  });
104
107
  }
108
+ const collateralReturnWithData = payload.collateralReturn
109
+ ? (0, cardanoOutputs_1.transformOutput)(payload.collateralReturn)
110
+ : undefined;
111
+ let referenceInputs = [];
112
+ if (payload.referenceInputs) {
113
+ referenceInputs = payload.referenceInputs.map(cardanoInputs_1.transformReferenceInput);
114
+ }
105
115
  this.params = {
106
116
  signingMode: payload.signingMode,
107
117
  inputsWithPath,
108
- outputsWithTokens,
118
+ outputsWithData,
109
119
  fee: payload.fee,
110
120
  ttl: payload.ttl,
111
121
  certificatesWithPoolOwnersAndRelays,
@@ -116,6 +126,9 @@ class CardanoSignTransaction extends AbstractMethod_1.AbstractMethod {
116
126
  scriptDataHash: payload.scriptDataHash,
117
127
  collateralInputsWithPath,
118
128
  requiredSigners,
129
+ collateralReturnWithData,
130
+ totalCollateral: payload.totalCollateral,
131
+ referenceInputs,
119
132
  protocolMagic: payload.protocolMagic,
120
133
  networkId: payload.networkId,
121
134
  witnessPaths: (0, cardanoWitnesses_1.gatherWitnessPaths)(inputsWithPath, certificatesWithPoolOwnersAndRelays, withdrawals, collateralInputsWithPath, requiredSigners, additionalWitnessRequests, payload.signingMode),
@@ -142,7 +155,7 @@ class CardanoSignTransaction extends AbstractMethod_1.AbstractMethod {
142
155
  this._ensureFeatureIsSupported('KeyHashStakeCredential');
143
156
  }
144
157
  });
145
- params.outputsWithTokens.forEach(({ output }) => {
158
+ params.outputsWithData.forEach(({ output }) => {
146
159
  if (output.datum_hash) {
147
160
  this._ensureFeatureIsSupported('OutputDatumHash');
148
161
  }
@@ -168,6 +181,18 @@ class CardanoSignTransaction extends AbstractMethod_1.AbstractMethod {
168
181
  if (params.signingMode === constants_1.PROTO.CardanoTxSigningMode.PLUTUS_TRANSACTION) {
169
182
  this._ensureFeatureIsSupported('Plutus');
170
183
  }
184
+ params.outputsWithData.forEach(({ output, inlineDatum, referenceScript }) => {
185
+ if (output.format === constants_1.PROTO.CardanoTxOutputSerializationFormat.MAP_BABBAGE ||
186
+ inlineDatum ||
187
+ referenceScript) {
188
+ this._ensureFeatureIsSupported('Babbage');
189
+ }
190
+ });
191
+ if (params.collateralReturnWithData ||
192
+ params.totalCollateral != null ||
193
+ params.referenceInputs.length > 0) {
194
+ this._ensureFeatureIsSupported('Babbage');
195
+ }
171
196
  }
172
197
  async _sign_tx() {
173
198
  const typedCall = this.device.getCommands().typedCall.bind(this.device.getCommands());
@@ -177,7 +202,7 @@ class CardanoSignTransaction extends AbstractMethod_1.AbstractMethod {
177
202
  protocol_magic: this.params.protocolMagic,
178
203
  network_id: this.params.networkId,
179
204
  inputs_count: this.params.inputsWithPath.length,
180
- outputs_count: this.params.outputsWithTokens.length,
205
+ outputs_count: this.params.outputsWithData.length,
181
206
  fee: this.params.fee,
182
207
  ttl: this.params.ttl,
183
208
  certificates_count: this.params.certificatesWithPoolOwnersAndRelays.length,
@@ -189,6 +214,9 @@ class CardanoSignTransaction extends AbstractMethod_1.AbstractMethod {
189
214
  script_data_hash: this.params.scriptDataHash,
190
215
  collateral_inputs_count: this.params.collateralInputsWithPath.length,
191
216
  required_signers_count: this.params.requiredSigners.length,
217
+ has_collateral_return: this.params.collateralReturnWithData != null,
218
+ total_collateral: this.params.totalCollateral,
219
+ reference_inputs_count: this.params.referenceInputs.length,
192
220
  derivation_type: this.params.derivationType,
193
221
  include_network_id: this.params.includeNetworkId,
194
222
  };
@@ -196,19 +224,8 @@ class CardanoSignTransaction extends AbstractMethod_1.AbstractMethod {
196
224
  for (const { input } of this.params.inputsWithPath) {
197
225
  await typedCall('CardanoTxInput', 'CardanoTxItemAck', input);
198
226
  }
199
- for (const { output, tokenBundle } of this.params.outputsWithTokens) {
200
- await typedCall('CardanoTxOutput', 'CardanoTxItemAck', output);
201
- if (tokenBundle) {
202
- for (const assetGroup of tokenBundle) {
203
- await typedCall('CardanoAssetGroup', 'CardanoTxItemAck', {
204
- policy_id: assetGroup.policyId,
205
- tokens_count: assetGroup.tokens.length,
206
- });
207
- for (const token of assetGroup.tokens) {
208
- await typedCall('CardanoToken', 'CardanoTxItemAck', token);
209
- }
210
- }
211
- }
227
+ for (const outputWithData of this.params.outputsWithData) {
228
+ await (0, cardanoOutputs_1.sendOutput)(typedCall, outputWithData);
212
229
  }
213
230
  for (const { certificate, poolOwners, poolRelays } of this.params
214
231
  .certificatesWithPoolOwnersAndRelays) {
@@ -260,6 +277,12 @@ class CardanoSignTransaction extends AbstractMethod_1.AbstractMethod {
260
277
  for (const requiredSigner of this.params.requiredSigners) {
261
278
  await typedCall('CardanoTxRequiredSigner', 'CardanoTxItemAck', requiredSigner);
262
279
  }
280
+ if (this.params.collateralReturnWithData) {
281
+ await (0, cardanoOutputs_1.sendOutput)(typedCall, this.params.collateralReturnWithData);
282
+ }
283
+ for (const referenceInput of this.params.referenceInputs) {
284
+ await typedCall('CardanoTxReferenceInput', 'CardanoTxItemAck', referenceInput);
285
+ }
263
286
  const witnesses = [];
264
287
  for (const path of this.params.witnessPaths) {
265
288
  const { message } = await typedCall('CardanoTxWitnessRequest', 'CardanoTxWitnessResponse', { path });
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Discovery = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const events_1 = (0, tslib_1.__importDefault)(require("events"));
5
+ const events_1 = tslib_1.__importDefault(require("events"));
6
6
  const constants_1 = require("../../constants");
7
7
  const accountUtils_1 = require("../../utils/accountUtils");
8
8
  const formatUtils_1 = require("../../utils/formatUtils");
@@ -8,7 +8,7 @@ declare type Param = {
8
8
  allowNegative?: boolean;
9
9
  };
10
10
  export declare function validateParams<P extends Record<string, any>>(params: P, schema: Param[]): P;
11
- export declare const validateCoinPath: (path: number[], coinInfo?: CoinInfo | undefined) => void;
11
+ export declare const validateCoinPath: (path: number[], coinInfo?: CoinInfo) => void;
12
12
  export declare const getFirmwareRange: (method: string, coinInfo: CoinInfo | null | undefined, currentRange: FirmwareRange) => FirmwareRange;
13
13
  export {};
14
14
  //# sourceMappingURL=paramsValidator.d.ts.map
@@ -26,7 +26,7 @@ export default class ComposeTransaction extends AbstractMethod<'composeTransacti
26
26
  }>;
27
27
  selectFee(account: DiscoveryAccount, utxo: AccountUtxo[]): Promise<SignedTransaction | "change-account">;
28
28
  _selectFeeUiResponse(composer: TransactionComposer): Promise<SignedTransaction | 'change-account'>;
29
- _sign(tx: ComposeResult): Promise<import("../types/api/signTransaction").SignedTransaction>;
29
+ _sign(tx: ComposeResult): Promise<import("../types").SignedTransaction>;
30
30
  dispose(): void;
31
31
  }
32
32
  export {};
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- const bignumber_js_1 = (0, tslib_1.__importDefault)(require("bignumber.js"));
4
+ const bignumber_js_1 = tslib_1.__importDefault(require("bignumber.js"));
5
5
  const AbstractMethod_1 = require("../core/AbstractMethod");
6
6
  const constants_1 = require("../constants");
7
7
  const events_1 = require("../events");
8
8
  const Discovery_1 = require("./common/Discovery");
9
9
  const paramsValidator_1 = require("./common/paramsValidator");
10
- const pathUtils = (0, tslib_1.__importStar)(require("../utils/pathUtils"));
10
+ const pathUtils = tslib_1.__importStar(require("../utils/pathUtils"));
11
11
  const promiseUtils_1 = require("../utils/promiseUtils");
12
12
  const formatUtils_1 = require("../utils/formatUtils");
13
13
  const coinInfo_1 = require("../data/coinInfo");
@@ -1,5 +1,5 @@
1
1
  import { PROTO } from '../../constants';
2
- import type { EosSDKTransaction } from '../../types/api/eosSignTransaction';
2
+ import type { EosSDKTransaction } from '../../types/api/eos';
3
3
  import type { TypedCall } from '../../device/DeviceCommands';
4
4
  export declare const validate: (tx: EosSDKTransaction) => {
5
5
  chain_id: string;