@swapkit/wallet-hardware 6.0.0 → 6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/chunk-3h1f3hyp.js +4 -0
  2. package/dist/chunk-3h1f3hyp.js.map +10 -0
  3. package/dist/chunk-8m2sn76p.js +4 -0
  4. package/dist/chunk-8m2sn76p.js.map +10 -0
  5. package/dist/chunk-qjq7gvyx.js +4 -0
  6. package/dist/chunk-qjq7gvyx.js.map +10 -0
  7. package/dist/chunk-wfbg89d3.js +4 -0
  8. package/dist/chunk-wfbg89d3.js.map +10 -0
  9. package/dist/chunk-xn0fnag5.js +4 -0
  10. package/dist/chunk-xn0fnag5.js.map +10 -0
  11. package/dist/trezor/index.cjs +2 -2
  12. package/dist/trezor/index.cjs.map +9 -4
  13. package/dist/trezor/index.js +2 -2
  14. package/dist/trezor/index.js.map +3 -3
  15. package/dist/types/keepkey/index.d.ts +1 -1
  16. package/dist/types/ledger/index.d.ts +1 -1
  17. package/dist/types/trezor/cardanoSigner.d.ts +21 -0
  18. package/dist/types/trezor/cardanoSigner.d.ts.map +1 -0
  19. package/dist/types/trezor/index.d.ts +3 -3
  20. package/dist/types/trezor/index.d.ts.map +1 -1
  21. package/dist/types/trezor/rippleSigner.d.ts +23 -0
  22. package/dist/types/trezor/rippleSigner.d.ts.map +1 -0
  23. package/dist/types/trezor/solanaSigner.d.ts +17 -0
  24. package/dist/types/trezor/solanaSigner.d.ts.map +1 -0
  25. package/dist/types/trezor/stellarSigner.d.ts +99 -0
  26. package/dist/types/trezor/stellarSigner.d.ts.map +1 -0
  27. package/dist/types/trezor/tronSigner.d.ts +30 -0
  28. package/dist/types/trezor/tronSigner.d.ts.map +1 -0
  29. package/package.json +7 -3
  30. package/src/trezor/cardanoSigner.ts +226 -0
  31. package/src/trezor/index.ts +136 -43
  32. package/src/trezor/rippleSigner.ts +100 -0
  33. package/src/trezor/solanaSigner.ts +129 -0
  34. package/src/trezor/stellarSigner.ts +186 -0
  35. package/src/trezor/tronSigner.ts +148 -0
@@ -0,0 +1,23 @@
1
+ import { type DerivationPathArray } from "@swapkit/helpers";
2
+ import type { RippleTransaction } from "@swapkit/toolboxes/ripple";
3
+ export declare function toTrezorRippleTransaction(transaction: RippleTransaction): {
4
+ fee: string;
5
+ flags: number | undefined;
6
+ maxLedgerVersion: number | undefined;
7
+ payment: {
8
+ amount: string;
9
+ destination: string;
10
+ destinationTag: number | undefined;
11
+ };
12
+ sequence: number;
13
+ };
14
+ export declare function getRippleSigner({ derivationPath }: {
15
+ derivationPath: DerivationPathArray;
16
+ }): {
17
+ getAddress: () => Promise<string>;
18
+ signTransaction: (transaction: RippleTransaction) => Promise<{
19
+ hash: string;
20
+ tx_blob: string;
21
+ }>;
22
+ };
23
+ //# sourceMappingURL=rippleSigner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rippleSigner.d.ts","sourceRoot":"","sources":["../../../src/trezor/rippleSigner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,mBAAmB,EAAwC,MAAM,kBAAkB,CAAC;AACzG,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAqBnE,wBAAgB,yBAAyB,CAAC,WAAW,EAAE,iBAAiB;;WA2BpD,MAAM,GAAG,SAAS;sBACM,MAAM,GAAG,SAAS;;;;wBAC6B,MAAM,GAAG,SAAS;;;EAG5G;AAED,wBAAgB,eAAe,CAAC,EAAE,cAAc,EAAE,EAAE;IAAE,cAAc,EAAE,mBAAmB,CAAA;CAAE;;mCAqB7C,iBAAiB;;;;EAsB9D"}
@@ -0,0 +1,17 @@
1
+ import { PublicKey, type Transaction, type VersionedTransaction } from "@solana/web3.js";
2
+ import { type DerivationPathArray } from "@swapkit/helpers";
3
+ type SolanaTransaction = Transaction | VersionedTransaction;
4
+ export declare function getSolanaSigner({ address, derivationPath, }: {
5
+ address?: string;
6
+ derivationPath: DerivationPathArray;
7
+ }): {
8
+ connect: () => Promise<{
9
+ publicKey: PublicKey;
10
+ }>;
11
+ disconnect: () => Promise<void>;
12
+ getAddress: () => Promise<string>;
13
+ readonly publicKey: PublicKey | null;
14
+ signTransaction: <T extends SolanaTransaction>(transaction: T) => Promise<T>;
15
+ };
16
+ export {};
17
+ //# sourceMappingURL=solanaSigner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"solanaSigner.d.ts","sourceRoot":"","sources":["../../../src/trezor/solanaSigner.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,KAAK,WAAW,EAAE,KAAK,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACzF,OAAO,EAAS,KAAK,mBAAmB,EAAwC,MAAM,kBAAkB,CAAC;AAEzG,KAAK,iBAAiB,GAAG,WAAW,GAAG,oBAAoB,CAAC;AAoD5D,wBAAgB,eAAe,CAAC,EAC9B,OAAO,EACP,cAAc,GACf,EAAE;IACD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,mBAAmB,CAAC;CACrC;;;;;;;sBAuCgC,CAAC,SAAS,iBAAiB,eAAe,CAAC;EA0B3E"}
@@ -0,0 +1,99 @@
1
+ import { type DerivationPathArray } from "@swapkit/helpers";
2
+ import type { StellarSigner, StellarTransaction } from "@swapkit/toolboxes/stellar";
3
+ export declare function toTrezorStellarTransaction(transaction: StellarTransaction): {
4
+ networkPassphrase: string;
5
+ transaction: {
6
+ fee: number;
7
+ memo: {
8
+ text: string;
9
+ type: 1;
10
+ id?: undefined;
11
+ hash?: undefined;
12
+ } | {
13
+ id: string;
14
+ type: 2;
15
+ text?: undefined;
16
+ hash?: undefined;
17
+ } | {
18
+ hash: string;
19
+ type: 4 | 3;
20
+ text?: undefined;
21
+ id?: undefined;
22
+ } | undefined;
23
+ operations: ({
24
+ amount: string;
25
+ asset: {
26
+ type: "NATIVE";
27
+ code?: undefined;
28
+ issuer?: undefined;
29
+ } | {
30
+ code: string;
31
+ issuer: string | undefined;
32
+ type: "ALPHANUM4" | "ALPHANUM12";
33
+ };
34
+ destination: string;
35
+ type: "payment";
36
+ source: string;
37
+ } | {
38
+ amount: string;
39
+ asset: {
40
+ type: "NATIVE";
41
+ code?: undefined;
42
+ issuer?: undefined;
43
+ } | {
44
+ code: string;
45
+ issuer: string | undefined;
46
+ type: "ALPHANUM4" | "ALPHANUM12";
47
+ };
48
+ destination: string;
49
+ type: "payment";
50
+ source?: undefined;
51
+ } | {
52
+ destination: string;
53
+ startingBalance: string;
54
+ type: "createAccount";
55
+ source: string;
56
+ } | {
57
+ destination: string;
58
+ startingBalance: string;
59
+ type: "createAccount";
60
+ source?: undefined;
61
+ } | {
62
+ limit: string;
63
+ line: {
64
+ type: "NATIVE";
65
+ code?: undefined;
66
+ issuer?: undefined;
67
+ } | {
68
+ code: string;
69
+ issuer: string | undefined;
70
+ type: "ALPHANUM4" | "ALPHANUM12";
71
+ };
72
+ type: "changeTrust";
73
+ source: string;
74
+ } | {
75
+ limit: string;
76
+ line: {
77
+ type: "NATIVE";
78
+ code?: undefined;
79
+ issuer?: undefined;
80
+ } | {
81
+ code: string;
82
+ issuer: string | undefined;
83
+ type: "ALPHANUM4" | "ALPHANUM12";
84
+ };
85
+ type: "changeTrust";
86
+ source?: undefined;
87
+ })[];
88
+ sequence: string;
89
+ source: string;
90
+ timebounds: {
91
+ maxTime: number;
92
+ minTime: number;
93
+ };
94
+ };
95
+ };
96
+ export declare function getStellarSigner({ derivationPath }: {
97
+ derivationPath: DerivationPathArray;
98
+ }): StellarSigner;
99
+ //# sourceMappingURL=stellarSigner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stellarSigner.d.ts","sourceRoot":"","sources":["../../../src/trezor/stellarSigner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,mBAAmB,EAAwC,MAAM,kBAAkB,CAAC;AACzG,OAAO,KAAK,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAkGpF,wBAAgB,0BAA0B,CAAC,WAAW,EAAE,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2BzE;AAED,wBAAgB,gBAAgB,CAAC,EAAE,cAAc,EAAE,EAAE;IAAE,cAAc,EAAE,mBAAmB,CAAA;CAAE,GAAG,aAAa,CAyD3G"}
@@ -0,0 +1,30 @@
1
+ import { type DerivationPathArray } from "@swapkit/helpers";
2
+ import { type TronSigner, type TronTransaction } from "@swapkit/toolboxes/tron";
3
+ export declare function toTrezorTronContract(transaction: TronTransaction): {
4
+ parameter: {
5
+ value: {
6
+ amount: string;
7
+ owner_address: string;
8
+ to_address: string;
9
+ contract_address?: undefined;
10
+ data?: undefined;
11
+ };
12
+ };
13
+ type: "TransferContract";
14
+ } | {
15
+ parameter: {
16
+ value: {
17
+ contract_address: string;
18
+ data: string;
19
+ owner_address: string;
20
+ amount?: undefined;
21
+ to_address?: undefined;
22
+ };
23
+ };
24
+ type: "TriggerSmartContract";
25
+ };
26
+ export declare function getTronSigner({ address: knownAddress, derivationPath, }: {
27
+ address?: string;
28
+ derivationPath: DerivationPathArray;
29
+ }): TronSigner;
30
+ //# sourceMappingURL=tronSigner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tronSigner.d.ts","sourceRoot":"","sources":["../../../src/trezor/tronSigner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,mBAAmB,EAAwC,MAAM,kBAAkB,CAAC;AACzG,OAAO,EAEL,KAAK,UAAU,EACf,KAAK,eAAe,EAErB,MAAM,yBAAyB,CAAC;AAiDjC,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,eAAe;;;;;;;;;;;;;;;;;;;;;;EAoChE;AAED,wBAAgB,aAAa,CAAC,EAC5B,OAAO,EAAE,YAAY,EACrB,cAAc,GACf,EAAE;IACD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,mBAAmB,CAAC;CACrC,GAAG,UAAU,CAgDb"}
package/package.json CHANGED
@@ -20,10 +20,12 @@
20
20
  "@ledgerhq/hw-transport": "~6.35.7",
21
21
  "@near-js/crypto": "~2.5.0",
22
22
  "@near-js/transactions": "~2.5.0",
23
+ "@noble/curves": "2.2.0",
23
24
  "@scure/base": "2.2.0",
24
25
  "@scure/bip32": "2.2.0",
25
- "@swapkit/helpers": "^6.1.1",
26
- "@swapkit/toolboxes": "^6.2.0",
26
+ "@solana/web3.js": "~1.98.4",
27
+ "@swapkit/helpers": "^6.1.2",
28
+ "@swapkit/toolboxes": "^6.3.0",
27
29
  "@swapkit/utxo-signer": "^3.1.1",
28
30
  "@swapkit/wallet-core": "^5.0.10",
29
31
  "@trezor/connect-web": "~9.7.3",
@@ -57,6 +59,8 @@
57
59
  "@near-js/transactions": "2.5.0",
58
60
  "@scure/base": "2.2.0",
59
61
  "@scure/bip32": "2.2.0",
62
+ "@solana/web3.js": "1.98.4",
63
+ "@stricahq/cbors": "1.0.4",
60
64
  "@trezor/connect-web": "9.7.3",
61
65
  "bitcoinjs-lib": "6.1.7",
62
66
  "ethers": "6.16.0",
@@ -109,5 +113,5 @@
109
113
  "type-check:go": "tsgo"
110
114
  },
111
115
  "type": "module",
112
- "version": "6.0.0"
116
+ "version": "6.1.0"
113
117
  }
@@ -0,0 +1,226 @@
1
+ import { hex } from "@scure/base";
2
+ import { Chain, type DerivationPathArray, derivationPathToString, SwapKitError } from "@swapkit/helpers";
3
+ import {
4
+ addCardanoVkeyWitnesses,
5
+ decodeCardanoTransaction,
6
+ getCardanoAddressFromBytes,
7
+ getCardanoPublicKeyHash,
8
+ } from "@swapkit/toolboxes/cardano";
9
+ import type {
10
+ CardanoAssetGroup,
11
+ CardanoInput,
12
+ CardanoOutput,
13
+ CardanoSignedTxData,
14
+ CardanoSignTransaction,
15
+ PROTO,
16
+ } from "@trezor/connect-web";
17
+
18
+ type CardanoAddressParams = { address: string; path: string; stakingPath: string };
19
+ export type TrezorConnectModule = typeof import("@trezor/connect-web");
20
+
21
+ function getConnectParams({ CARDANO, PROTO }: TrezorConnectModule) {
22
+ return {
23
+ // Trezor Suite default, same as the SwapKit keystore
24
+ derivationType: PROTO.CardanoDerivationType.ICARUS,
25
+ mainnet: { networkId: CARDANO.NETWORK_IDS.mainnet, protocolMagic: CARDANO.PROTOCOL_MAGICS.mainnet },
26
+ };
27
+ }
28
+
29
+ const BODY = { AUXILIARY_DATA_HASH: 7, FEE: 2, INPUTS: 0, OUTPUTS: 1, TTL: 3, VALIDITY_INTERVAL_START: 8 } as const;
30
+ const SET_TAG = 258;
31
+
32
+ function notSupported(reason: string) {
33
+ return new SwapKitError({ errorKey: "wallet_trezor_method_not_supported", info: { chain: Chain.Cardano, reason } });
34
+ }
35
+
36
+ function signFailed(error: string) {
37
+ return new SwapKitError({
38
+ errorKey: "wallet_trezor_failed_to_sign_transaction",
39
+ info: { chain: Chain.Cardano, error },
40
+ });
41
+ }
42
+
43
+ function toUint(value: unknown, field: string) {
44
+ const isBigNumber = typeof value === "object" && value !== null && "toFixed" in value;
45
+ const text = isBigNumber || Number.isSafeInteger(value) ? String((value as number).toFixed()) : "";
46
+ if (!/^\d+$/.test(text)) throw notSupported(`Invalid ${field} in Cardano transaction`);
47
+ return text;
48
+ }
49
+
50
+ function toTokenBundle(multiAsset: Map<Uint8Array, Map<Uint8Array, unknown>>): CardanoAssetGroup[] {
51
+ return [...multiAsset].map(([policyId, assets]) => ({
52
+ policyId: hex.encode(policyId),
53
+ tokenAmounts: [...assets].map(([assetName, amount]) => ({
54
+ amount: toUint(amount, "token amount"),
55
+ assetNameBytes: hex.encode(assetName),
56
+ })),
57
+ }));
58
+ }
59
+
60
+ async function toTrezorOutput(
61
+ output: unknown,
62
+ own: CardanoAddressParams,
63
+ proto: TrezorConnectModule["PROTO"],
64
+ ): Promise<CardanoOutput> {
65
+ let address: unknown;
66
+ let value: unknown;
67
+ let format: PROTO.CardanoTxOutputSerializationFormat;
68
+
69
+ if (Array.isArray(output)) {
70
+ if (output.length !== 2) throw notSupported("Trezor cannot sign Cardano outputs with a datum");
71
+ [address, value] = output;
72
+ format = proto.CardanoTxOutputSerializationFormat.ARRAY_LEGACY;
73
+ } else if (output instanceof Map) {
74
+ if (output.has(2)) throw notSupported("Trezor cannot sign Cardano outputs with a datum");
75
+ if (output.has(3)) throw notSupported("Trezor cannot sign Cardano outputs with a reference script");
76
+ if (output.size !== 2) throw notSupported("Unsupported field in Cardano output");
77
+ address = output.get(0);
78
+ value = output.get(1);
79
+ format = proto.CardanoTxOutputSerializationFormat.MAP_BABBAGE;
80
+ } else {
81
+ throw notSupported("Invalid Cardano output");
82
+ }
83
+
84
+ if (Array.isArray(value) && value.length !== 2) throw notSupported("Invalid Cardano output value");
85
+ const [coin, multiAsset] = Array.isArray(value) ? value : [value];
86
+ const outputAddress = await getCardanoAddressFromBytes(address as Uint8Array);
87
+ const destination =
88
+ outputAddress === own.address
89
+ ? {
90
+ addressParameters: {
91
+ addressType: proto.CardanoAddressType.BASE,
92
+ path: own.path,
93
+ stakingPath: own.stakingPath,
94
+ },
95
+ }
96
+ : { address: outputAddress };
97
+
98
+ return {
99
+ ...destination,
100
+ amount: toUint(coin, "output amount"),
101
+ format,
102
+ ...(multiAsset === undefined ? {} : { tokenBundle: toTokenBundle(multiAsset) }),
103
+ };
104
+ }
105
+
106
+ function toTrezorInputs(inputs: unknown, path: string) {
107
+ const isTagged =
108
+ typeof inputs === "object" && inputs !== null && "tag" in inputs && inputs.tag === SET_TAG && "value" in inputs;
109
+ const list = (isTagged ? inputs.value : inputs) as unknown[][];
110
+
111
+ const trezorInputs: CardanoInput[] = list.map((input) => {
112
+ if (input.length !== 2) throw notSupported("Invalid Cardano input");
113
+ const [txHash, index] = input as [Uint8Array, unknown];
114
+ return { path, prev_hash: hex.encode(txHash), prev_index: Number(toUint(index, "input index")) };
115
+ });
116
+
117
+ return { inputs: trezorInputs, tagCborSets: isTagged };
118
+ }
119
+
120
+ export async function toTrezorCardanoTransaction(
121
+ txHex: string,
122
+ own: CardanoAddressParams,
123
+ connect: TrezorConnectModule,
124
+ ): Promise<CardanoSignTransaction> {
125
+ const { body } = await decodeCardanoTransaction(txHex);
126
+ const { derivationType, mainnet } = getConnectParams(connect);
127
+ const { PROTO: proto } = connect;
128
+
129
+ const supportedFields: unknown[] = Object.values(BODY);
130
+ const unsupported = [...body.keys()].filter((field) => !supportedFields.includes(field));
131
+ if (unsupported.length > 0) {
132
+ throw notSupported(`Trezor cannot sign Cardano transactions with body fields ${unsupported.join(", ")}`);
133
+ }
134
+
135
+ const outputs = body.get(BODY.OUTPUTS) as unknown[];
136
+ const auxiliaryDataHash = body.get(BODY.AUXILIARY_DATA_HASH) as Uint8Array | undefined;
137
+
138
+ const ttl = body.get(BODY.TTL);
139
+ const validityIntervalStart = body.get(BODY.VALIDITY_INTERVAL_START);
140
+
141
+ return {
142
+ ...toTrezorInputs(body.get(BODY.INPUTS), own.path),
143
+ ...mainnet,
144
+ derivationType,
145
+ fee: toUint(body.get(BODY.FEE), "fee"),
146
+ outputs: await Promise.all(outputs.map((output) => toTrezorOutput(output, own, proto))),
147
+ signingMode: proto.CardanoTxSigningMode.ORDINARY_TRANSACTION,
148
+ ...(auxiliaryDataHash ? { auxiliaryData: { hash: hex.encode(auxiliaryDataHash) } } : {}),
149
+ ...(ttl === undefined ? {} : { ttl: toUint(ttl, "ttl") }),
150
+ ...(validityIntervalStart === undefined
151
+ ? {}
152
+ : { validityIntervalStart: toUint(validityIntervalStart, "validity interval start") }),
153
+ };
154
+ }
155
+
156
+ export async function addTrezorWitnesses(
157
+ txHex: string,
158
+ { hash, witnesses }: Pick<CardanoSignedTxData, "hash" | "witnesses">,
159
+ publicKey: string,
160
+ { PROTO: proto }: TrezorConnectModule,
161
+ ) {
162
+ const { bodyHash } = await decodeCardanoTransaction(txHex);
163
+
164
+ if (hash.toLowerCase() !== bodyHash) throw signFailed("Trezor signed a different transaction body");
165
+
166
+ const vkeyWitnesses = witnesses.map(({ pubKey, signature, type }) => {
167
+ if (type !== proto.CardanoTxWitnessType.SHELLEY_WITNESS || pubKey.toLowerCase() !== publicKey) {
168
+ throw signFailed("Trezor returned a witness for an unexpected key");
169
+ }
170
+ return { publicKey: hex.decode(pubKey), signature: hex.decode(signature) };
171
+ });
172
+
173
+ return addCardanoVkeyWitnesses(txHex, vkeyWitnesses);
174
+ }
175
+
176
+ export async function getCardanoSigner({
177
+ connect,
178
+ derivationPath,
179
+ }: {
180
+ connect: TrezorConnectModule;
181
+ derivationPath: DerivationPathArray;
182
+ }) {
183
+ const [purpose, coinType, account, role, index] = derivationPath;
184
+ if (derivationPath.length !== 5 || role !== 0 || index === undefined) {
185
+ throw new SwapKitError({
186
+ errorKey: "wallet_trezor_derivation_path_not_supported",
187
+ info: { chain: Chain.Cardano, derivationPath },
188
+ });
189
+ }
190
+
191
+ const path = derivationPathToString(derivationPath);
192
+ const stakingPath = derivationPathToString([purpose, coinType, account, 2, 0] as DerivationPathArray);
193
+ const { derivationType, mainnet } = getConnectParams(connect);
194
+ const TrezorConnect = connect.default;
195
+
196
+ // One device call: a second one right after would need a new Connect popup
197
+ const keysResult = await TrezorConnect.cardanoGetPublicKey({
198
+ bundle: [path, stakingPath].map((keyPath) => ({ derivationType, path: keyPath })),
199
+ });
200
+ if (!keysResult.success) {
201
+ throw new SwapKitError({
202
+ errorKey: "wallet_trezor_failed_to_get_address",
203
+ info: { chain: Chain.Cardano, derivationPath, error: keysResult.payload.error },
204
+ });
205
+ }
206
+
207
+ const [publicKey, stakingKey] = keysResult.payload.map(({ node }) => Buffer.from(node.public_key, "hex")) as [
208
+ Buffer,
209
+ Buffer,
210
+ ];
211
+ const publicKeyHash = await getCardanoPublicKeyHash(publicKey);
212
+ const address = await getCardanoAddressFromBytes(
213
+ Buffer.concat([Buffer.from([mainnet.networkId]), publicKeyHash, await getCardanoPublicKeyHash(stakingKey)]),
214
+ );
215
+
216
+ async function signTransaction(txHex: string) {
217
+ const params = await toTrezorCardanoTransaction(txHex, { address, path, stakingPath }, connect);
218
+ const result = await TrezorConnect.cardanoSignTransaction(params);
219
+
220
+ if (!result.success) throw signFailed(result.payload.error);
221
+
222
+ return addTrezorWitnesses(txHex, result.payload, publicKey.toString("hex"), connect);
223
+ }
224
+
225
+ return { getAddress: () => address, publicKey, publicKeyHash, signTransaction };
226
+ }