@tcswap/wallet-hardware 4.2.16
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.
- package/dist/chunk-1w9rn6fj.js +5 -0
- package/dist/chunk-1w9rn6fj.js.map +10 -0
- package/dist/chunk-1z3vq8v6.js +4 -0
- package/dist/chunk-1z3vq8v6.js.map +10 -0
- package/dist/chunk-3jd7804n.js +4 -0
- package/dist/chunk-3jd7804n.js.map +10 -0
- package/dist/chunk-4pybhxzx.js +4 -0
- package/dist/chunk-4pybhxzx.js.map +10 -0
- package/dist/chunk-9kbkdt6e.js +4 -0
- package/dist/chunk-9kbkdt6e.js.map +10 -0
- package/dist/chunk-eng8tyvd.js +4 -0
- package/dist/chunk-eng8tyvd.js.map +10 -0
- package/dist/chunk-fazw0jvt.js +4 -0
- package/dist/chunk-fazw0jvt.js.map +9 -0
- package/dist/chunk-zzfbcc7e.js +5 -0
- package/dist/chunk-zzfbcc7e.js.map +9 -0
- package/dist/index.cjs +4 -0
- package/dist/index.cjs.map +9 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +9 -0
- package/dist/keepkey/index.cjs +4 -0
- package/dist/keepkey/index.cjs.map +15 -0
- package/dist/keepkey/index.js +4 -0
- package/dist/keepkey/index.js.map +15 -0
- package/dist/ledger/index.cjs +5 -0
- package/dist/ledger/index.cjs.map +25 -0
- package/dist/ledger/index.js +5 -0
- package/dist/ledger/index.js.map +25 -0
- package/dist/trezor/index.cjs +4 -0
- package/dist/trezor/index.cjs.map +10 -0
- package/dist/trezor/index.js +4 -0
- package/dist/trezor/index.js.map +10 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/keepkey/chains/cosmos.d.ts +7 -0
- package/dist/types/keepkey/chains/cosmos.d.ts.map +1 -0
- package/dist/types/keepkey/chains/evm.d.ts +29 -0
- package/dist/types/keepkey/chains/evm.d.ts.map +1 -0
- package/dist/types/keepkey/chains/mayachain.d.ts +10 -0
- package/dist/types/keepkey/chains/mayachain.d.ts.map +1 -0
- package/dist/types/keepkey/chains/ripple.d.ts +37 -0
- package/dist/types/keepkey/chains/ripple.d.ts.map +1 -0
- package/dist/types/keepkey/chains/thorchain.d.ts +10 -0
- package/dist/types/keepkey/chains/thorchain.d.ts.map +1 -0
- package/dist/types/keepkey/chains/utxo.d.ts +25 -0
- package/dist/types/keepkey/chains/utxo.d.ts.map +1 -0
- package/dist/types/keepkey/coins.d.ts +15 -0
- package/dist/types/keepkey/coins.d.ts.map +1 -0
- package/dist/types/keepkey/index.d.ts +15 -0
- package/dist/types/keepkey/index.d.ts.map +1 -0
- package/dist/types/ledger/clients/cosmos.d.ts +23 -0
- package/dist/types/ledger/clients/cosmos.d.ts.map +1 -0
- package/dist/types/ledger/clients/evm.d.ts +52 -0
- package/dist/types/ledger/clients/evm.d.ts.map +1 -0
- package/dist/types/ledger/clients/near.d.ts +7 -0
- package/dist/types/ledger/clients/near.d.ts.map +1 -0
- package/dist/types/ledger/clients/thorchain/common.d.ts +28 -0
- package/dist/types/ledger/clients/thorchain/common.d.ts.map +1 -0
- package/dist/types/ledger/clients/thorchain/helpers.d.ts +10 -0
- package/dist/types/ledger/clients/thorchain/helpers.d.ts.map +1 -0
- package/dist/types/ledger/clients/thorchain/index.d.ts +25 -0
- package/dist/types/ledger/clients/thorchain/index.d.ts.map +1 -0
- package/dist/types/ledger/clients/thorchain/lib.d.ts +25 -0
- package/dist/types/ledger/clients/thorchain/lib.d.ts.map +1 -0
- package/dist/types/ledger/clients/thorchain/utils.d.ts +5 -0
- package/dist/types/ledger/clients/thorchain/utils.d.ts.map +1 -0
- package/dist/types/ledger/clients/tron.d.ts +26 -0
- package/dist/types/ledger/clients/tron.d.ts.map +1 -0
- package/dist/types/ledger/clients/utxo.d.ts +43 -0
- package/dist/types/ledger/clients/utxo.d.ts.map +1 -0
- package/dist/types/ledger/clients/xrp.d.ts +11 -0
- package/dist/types/ledger/clients/xrp.d.ts.map +1 -0
- package/dist/types/ledger/cosmosTypes.d.ts +43 -0
- package/dist/types/ledger/cosmosTypes.d.ts.map +1 -0
- package/dist/types/ledger/helpers/getLedgerAddress.d.ts +10 -0
- package/dist/types/ledger/helpers/getLedgerAddress.d.ts.map +1 -0
- package/dist/types/ledger/helpers/getLedgerClient.d.ts +42 -0
- package/dist/types/ledger/helpers/getLedgerClient.d.ts.map +1 -0
- package/dist/types/ledger/helpers/getLedgerTransport.d.ts +6 -0
- package/dist/types/ledger/helpers/getLedgerTransport.d.ts.map +1 -0
- package/dist/types/ledger/helpers/index.d.ts +4 -0
- package/dist/types/ledger/helpers/index.d.ts.map +1 -0
- package/dist/types/ledger/index.d.ts +14 -0
- package/dist/types/ledger/index.d.ts.map +1 -0
- package/dist/types/ledger/interfaces/CosmosLedgerInterface.d.ts +14 -0
- package/dist/types/ledger/interfaces/CosmosLedgerInterface.d.ts.map +1 -0
- package/dist/types/ledger/types.d.ts +16 -0
- package/dist/types/ledger/types.d.ts.map +1 -0
- package/dist/types/trezor/evmSigner.d.ts +32 -0
- package/dist/types/trezor/evmSigner.d.ts.map +1 -0
- package/dist/types/trezor/index.d.ts +14 -0
- package/dist/types/trezor/index.d.ts.map +1 -0
- package/package.json +101 -0
- package/src/index.ts +1 -0
- package/src/keepkey/chains/cosmos.ts +69 -0
- package/src/keepkey/chains/evm.ts +117 -0
- package/src/keepkey/chains/mayachain.ts +102 -0
- package/src/keepkey/chains/ripple.ts +88 -0
- package/src/keepkey/chains/thorchain.ts +97 -0
- package/src/keepkey/chains/utxo.ts +141 -0
- package/src/keepkey/coins.ts +70 -0
- package/src/keepkey/index.ts +159 -0
- package/src/ledger/clients/cosmos.ts +83 -0
- package/src/ledger/clients/evm.ts +145 -0
- package/src/ledger/clients/near.ts +67 -0
- package/src/ledger/clients/thorchain/common.ts +93 -0
- package/src/ledger/clients/thorchain/helpers.ts +124 -0
- package/src/ledger/clients/thorchain/index.ts +91 -0
- package/src/ledger/clients/thorchain/lib.ts +282 -0
- package/src/ledger/clients/thorchain/utils.ts +71 -0
- package/src/ledger/clients/tron.ts +84 -0
- package/src/ledger/clients/utxo.ts +158 -0
- package/src/ledger/clients/xrp.ts +50 -0
- package/src/ledger/cosmosTypes.ts +102 -0
- package/src/ledger/helpers/getLedgerAddress.ts +73 -0
- package/src/ledger/helpers/getLedgerClient.ts +121 -0
- package/src/ledger/helpers/getLedgerTransport.ts +106 -0
- package/src/ledger/helpers/index.ts +3 -0
- package/src/ledger/index.ts +303 -0
- package/src/ledger/interfaces/CosmosLedgerInterface.ts +58 -0
- package/src/ledger/types.ts +40 -0
- package/src/trezor/evmSigner.ts +181 -0
- package/src/trezor/index.ts +350 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Modifications © 2025 Horizontal Systems.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type TronApp from "@ledgerhq/hw-app-trx";
|
|
6
|
+
import { type DerivationPathArray, derivationPathToString, NetworkDerivationPath, USwapError } from "@tcswap/helpers";
|
|
7
|
+
import type { TronSignedTransaction, TronSigner, TronTransaction } from "@tcswap/toolboxes/tron";
|
|
8
|
+
|
|
9
|
+
import { getLedgerTransport } from "../helpers/getLedgerTransport";
|
|
10
|
+
|
|
11
|
+
export class TronLedgerInterface implements TronSigner {
|
|
12
|
+
derivationPath: string;
|
|
13
|
+
ledgerApp: InstanceType<typeof TronApp> | null = null;
|
|
14
|
+
ledgerTimeout = 50000;
|
|
15
|
+
|
|
16
|
+
constructor(derivationPath?: DerivationPathArray | string) {
|
|
17
|
+
this.derivationPath =
|
|
18
|
+
typeof derivationPath === "string"
|
|
19
|
+
? derivationPath
|
|
20
|
+
: derivationPathToString(derivationPath || NetworkDerivationPath.TRON);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
checkOrCreateTransportAndLedger = async () => {
|
|
24
|
+
if (this.ledgerApp) return;
|
|
25
|
+
await this.createTransportAndLedger();
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
createTransportAndLedger = async () => {
|
|
29
|
+
const transport = await getLedgerTransport();
|
|
30
|
+
const TronApp = (await import("@ledgerhq/hw-app-trx")).default;
|
|
31
|
+
|
|
32
|
+
this.ledgerApp = new TronApp(transport);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
getAddress = async (): Promise<string> => {
|
|
36
|
+
const response = await this.getAddressAndPubKey();
|
|
37
|
+
if (!response) throw new USwapError("wallet_ledger_failed_to_get_address");
|
|
38
|
+
return response.address;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
getAddressAndPubKey = async () => {
|
|
42
|
+
await this.createTransportAndLedger();
|
|
43
|
+
const result = await this.ledgerApp?.getAddress(this.derivationPath);
|
|
44
|
+
|
|
45
|
+
if (!result) throw new USwapError("wallet_ledger_failed_to_get_address");
|
|
46
|
+
|
|
47
|
+
return { address: result.address, publicKey: result.publicKey };
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
showAddressAndPubKey = async () => {
|
|
51
|
+
await this.createTransportAndLedger();
|
|
52
|
+
return this.ledgerApp?.getAddress(this.derivationPath, true);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
signTransaction = async (transaction: TronTransaction): Promise<TronSignedTransaction> => {
|
|
56
|
+
await this.createTransportAndLedger();
|
|
57
|
+
|
|
58
|
+
if (!this.ledgerApp) {
|
|
59
|
+
throw new USwapError("wallet_ledger_transport_error");
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Tron transactions need to be serialized before signing
|
|
63
|
+
const serializedTx = JSON.stringify(transaction);
|
|
64
|
+
|
|
65
|
+
try {
|
|
66
|
+
const signature = await this.ledgerApp.signTransaction(
|
|
67
|
+
this.derivationPath,
|
|
68
|
+
serializedTx,
|
|
69
|
+
[], // Token signatures array - empty for native TRX transfers
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
if (!signature) {
|
|
73
|
+
throw new USwapError("wallet_ledger_signing_error");
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Return the signed transaction in Tron's expected format
|
|
77
|
+
return { ...transaction, signature: [signature] };
|
|
78
|
+
} catch (error) {
|
|
79
|
+
throw new USwapError("wallet_ledger_signing_error", { error });
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export const TronLedger = (derivationPath?: DerivationPathArray) => new TronLedgerInterface(derivationPath);
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Modifications © 2025 Horizontal Systems.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type BitcoinApp from "@ledgerhq/hw-app-btc";
|
|
6
|
+
import type { CreateTransactionArg } from "@ledgerhq/hw-app-btc/lib-es/createTransaction";
|
|
7
|
+
import { type DerivationPathArray, derivationPathToString, getWalletFormatFor, USwapError } from "@tcswap/helpers";
|
|
8
|
+
import type { UTXOType } from "@tcswap/toolboxes/utxo";
|
|
9
|
+
import type { Psbt } from "bitcoinjs-lib";
|
|
10
|
+
|
|
11
|
+
import { getLedgerTransport } from "../helpers/getLedgerTransport";
|
|
12
|
+
|
|
13
|
+
const nonSegwitLedgerChains = ["bitcoin-cash", "dash", "dogecoin", "zcash"];
|
|
14
|
+
|
|
15
|
+
type Params = {
|
|
16
|
+
psbt: Psbt;
|
|
17
|
+
inputUtxos: UTXOType[];
|
|
18
|
+
btcApp: BitcoinApp;
|
|
19
|
+
derivationPath: string;
|
|
20
|
+
chain: "bitcoin-cash" | "bitcoin" | "litecoin" | "dogecoin" | "dash" | "zcash";
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const signUTXOTransaction = (
|
|
24
|
+
{ psbt, inputUtxos, btcApp, derivationPath, chain }: Params,
|
|
25
|
+
options?: Partial<CreateTransactionArg>,
|
|
26
|
+
) => {
|
|
27
|
+
const inputs = inputUtxos.map((item) => {
|
|
28
|
+
const splitTx = btcApp.splitTransaction(
|
|
29
|
+
item.txHex || "",
|
|
30
|
+
!nonSegwitLedgerChains.includes(chain),
|
|
31
|
+
chain === "zcash",
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
return [splitTx, item.index, undefined as string | null | undefined, undefined as number | null | undefined] as any;
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const newTxHex = psbt.data.globalMap.unsignedTx.toBuffer().toString("hex");
|
|
38
|
+
|
|
39
|
+
const splitNewTx = btcApp.splitTransaction(newTxHex, true);
|
|
40
|
+
const outputScriptHex = btcApp.serializeTransactionOutputs(splitNewTx).toString("hex");
|
|
41
|
+
|
|
42
|
+
const params: CreateTransactionArg = {
|
|
43
|
+
additionals: ["bech32"],
|
|
44
|
+
associatedKeysets: inputs.map(() => derivationPath),
|
|
45
|
+
inputs,
|
|
46
|
+
outputScriptHex,
|
|
47
|
+
segwit: true,
|
|
48
|
+
useTrustedInputForSegwit: true,
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
return btcApp.createPaymentTransaction({ ...params, ...options });
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const BaseLedgerUTXO = ({
|
|
55
|
+
chain,
|
|
56
|
+
additionalSignParams,
|
|
57
|
+
}: {
|
|
58
|
+
chain: "bitcoin-cash" | "bitcoin" | "litecoin" | "dogecoin" | "dash" | "zcash";
|
|
59
|
+
additionalSignParams?: Partial<CreateTransactionArg>;
|
|
60
|
+
}) => {
|
|
61
|
+
let btcApp: InstanceType<typeof BitcoinApp>;
|
|
62
|
+
let transport: any = null;
|
|
63
|
+
|
|
64
|
+
async function checkBtcAppAndCreateTransportWebUSB(checkBtcApp = true) {
|
|
65
|
+
if (checkBtcApp && !btcApp) {
|
|
66
|
+
new USwapError("wallet_ledger_connection_error", {
|
|
67
|
+
message: `Ledger connection failed:\n${JSON.stringify({ btcApp, checkBtcApp })}`,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
transport ||= await getLedgerTransport();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
async function createTransportWebUSB() {
|
|
75
|
+
transport = await getLedgerTransport();
|
|
76
|
+
const BitcoinApp = (await import("@ledgerhq/hw-app-btc")).default;
|
|
77
|
+
|
|
78
|
+
btcApp = new BitcoinApp({ currency: chain, transport });
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return (derivationPathArray?: DerivationPathArray | string) => {
|
|
82
|
+
const derivationPath =
|
|
83
|
+
typeof derivationPathArray === "string"
|
|
84
|
+
? derivationPathArray
|
|
85
|
+
: derivationPathToString(derivationPathArray as DerivationPathArray);
|
|
86
|
+
|
|
87
|
+
const format = getWalletFormatFor(derivationPath);
|
|
88
|
+
|
|
89
|
+
return {
|
|
90
|
+
connect: async () => {
|
|
91
|
+
await checkBtcAppAndCreateTransportWebUSB(false);
|
|
92
|
+
const BitcoinApp = (await import("@ledgerhq/hw-app-btc")).default;
|
|
93
|
+
|
|
94
|
+
btcApp = new BitcoinApp({ currency: chain, transport });
|
|
95
|
+
},
|
|
96
|
+
getAddress: async () => {
|
|
97
|
+
const { toCashAddress } = await import("@tcswap/toolboxes/utxo");
|
|
98
|
+
|
|
99
|
+
await checkBtcAppAndCreateTransportWebUSB(false);
|
|
100
|
+
|
|
101
|
+
const { bitcoinAddress: address } = await btcApp.getWalletPublicKey(derivationPath, { format });
|
|
102
|
+
|
|
103
|
+
if (!address) {
|
|
104
|
+
throw new USwapError("wallet_ledger_get_address_error", {
|
|
105
|
+
message: `Cannot get ${chain} address from ledger derivation path: ${derivationPath}`,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return chain === "bitcoin-cash" && format === "legacy"
|
|
110
|
+
? toCashAddress(address).replace(/(bchtest:|bitcoincash:)/, "")
|
|
111
|
+
: address;
|
|
112
|
+
},
|
|
113
|
+
getExtendedPublicKey: async (path = "84'/0'/0'", xpubVersion = 76067358) => {
|
|
114
|
+
await checkBtcAppAndCreateTransportWebUSB(false);
|
|
115
|
+
|
|
116
|
+
return btcApp.getWalletXpub({ path, xpubVersion });
|
|
117
|
+
},
|
|
118
|
+
signTransaction: async (psbt: Psbt, inputUtxos: UTXOType[]) => {
|
|
119
|
+
await createTransportWebUSB();
|
|
120
|
+
|
|
121
|
+
return signUTXOTransaction({ btcApp, chain, derivationPath, inputUtxos, psbt }, additionalSignParams);
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
export const BitcoinLedger = BaseLedgerUTXO({ chain: "bitcoin" });
|
|
128
|
+
export const LitecoinLedger = BaseLedgerUTXO({ chain: "litecoin" });
|
|
129
|
+
|
|
130
|
+
export const BitcoinCashLedger = BaseLedgerUTXO({
|
|
131
|
+
additionalSignParams: { additionals: ["abc"], segwit: false, sigHashType: 0x41 },
|
|
132
|
+
chain: "bitcoin-cash",
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
export const DogecoinLedger = BaseLedgerUTXO({
|
|
136
|
+
additionalSignParams: { additionals: [], segwit: false, useTrustedInputForSegwit: false },
|
|
137
|
+
chain: "dogecoin",
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
export const DashLedger = BaseLedgerUTXO({
|
|
141
|
+
additionalSignParams: { additionals: [], segwit: false, useTrustedInputForSegwit: false },
|
|
142
|
+
chain: "dash",
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
export const ZcashLedger = BaseLedgerUTXO({
|
|
146
|
+
additionalSignParams: {
|
|
147
|
+
additionals: ["zcash", "sapling"],
|
|
148
|
+
expiryHeight: (() => {
|
|
149
|
+
const buf = Buffer.allocUnsafe(4);
|
|
150
|
+
buf.writeUInt32LE(0);
|
|
151
|
+
return buf;
|
|
152
|
+
})(),
|
|
153
|
+
lockTime: 0,
|
|
154
|
+
segwit: false,
|
|
155
|
+
useTrustedInputForSegwit: false,
|
|
156
|
+
},
|
|
157
|
+
chain: "zcash",
|
|
158
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import Xrp from "@ledgerhq/hw-app-xrp";
|
|
2
|
+
import type Transport from "@ledgerhq/hw-transport";
|
|
3
|
+
import { Chain, type DerivationPathArray, derivationPathToString, NetworkDerivationPath } from "@tcswap/helpers";
|
|
4
|
+
import type { Transaction } from "@tcswap/toolboxes/ripple";
|
|
5
|
+
import { encode } from "ripple-binary-codec";
|
|
6
|
+
import type { Payment } from "xrpl";
|
|
7
|
+
import { getLedgerTransport } from "../helpers/getLedgerTransport";
|
|
8
|
+
|
|
9
|
+
const TF_FULLY_CANONICAL_SIG = 2147483648;
|
|
10
|
+
|
|
11
|
+
function cleanTransactionObject(obj: Record<string, any>) {
|
|
12
|
+
const cleaned: Record<string, any> = {};
|
|
13
|
+
for (const key in obj) {
|
|
14
|
+
if (obj[key] !== null && obj[key] !== undefined) {
|
|
15
|
+
cleaned[key] = obj[key];
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return cleaned;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function establishConnection(transport: Transport) {
|
|
22
|
+
return new Xrp(transport);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const XRPLedger = async (derivationPath?: DerivationPathArray) => {
|
|
26
|
+
const path = derivationPathToString(derivationPath || NetworkDerivationPath[Chain.Ripple]);
|
|
27
|
+
const transport = await getLedgerTransport();
|
|
28
|
+
const xrpInstance = establishConnection(transport);
|
|
29
|
+
|
|
30
|
+
const { address, publicKey } = await xrpInstance.getAddress(path);
|
|
31
|
+
|
|
32
|
+
async function signTransaction(transaction: Payment | Transaction) {
|
|
33
|
+
const { hashes } = await import("@tcswap/toolboxes/ripple");
|
|
34
|
+
const cleanedTxWithPubKey = cleanTransactionObject(transaction);
|
|
35
|
+
const transactionJSON = {
|
|
36
|
+
...cleanedTxWithPubKey,
|
|
37
|
+
Flags: transaction.Flags || TF_FULLY_CANONICAL_SIG,
|
|
38
|
+
SigningPubKey: publicKey.toUpperCase(),
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const transactionToSignOnLedger = encode(transactionJSON);
|
|
42
|
+
const txnSignature = await xrpInstance.signTransaction(path, transactionToSignOnLedger);
|
|
43
|
+
const tx_blob = encode({ ...transactionJSON, TxnSignature: txnSignature });
|
|
44
|
+
const hash = hashes.hashSignedTx(tx_blob);
|
|
45
|
+
|
|
46
|
+
return { hash, tx_blob };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return { getAddress: () => address, signTransaction };
|
|
50
|
+
};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Modifications © 2025 Horizontal Systems.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { USwapError } from "@tcswap/helpers";
|
|
6
|
+
|
|
7
|
+
export interface Coin {
|
|
8
|
+
readonly denom: string;
|
|
9
|
+
readonly amount: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface EncodeObject {
|
|
13
|
+
readonly typeUrl: string;
|
|
14
|
+
readonly value: any;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface AminoMsg {
|
|
18
|
+
readonly type: string;
|
|
19
|
+
readonly value: any;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface AminoMsgSend extends AminoMsg {
|
|
23
|
+
readonly type: "cosmos-sdk/MsgSend";
|
|
24
|
+
readonly value: {
|
|
25
|
+
/** Bech32 account address */
|
|
26
|
+
readonly from_address: string;
|
|
27
|
+
/** Bech32 account address */
|
|
28
|
+
readonly to_address: string;
|
|
29
|
+
readonly amount: readonly Coin[];
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface AminoConverter {
|
|
34
|
+
readonly aminoType: string;
|
|
35
|
+
readonly toAmino: (value: any) => any;
|
|
36
|
+
readonly fromAmino: (value: any) => any;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** A map from protobuf type URL to the AminoConverter implementation if supported on chain */
|
|
40
|
+
export type AminoConverters = Record<string, AminoConverter | "not_supported_by_chain">;
|
|
41
|
+
|
|
42
|
+
function isAminoConverter(
|
|
43
|
+
converter: [string, AminoConverter | "not_supported_by_chain"],
|
|
44
|
+
): converter is [string, AminoConverter] {
|
|
45
|
+
return typeof converter[1] !== "string";
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* A map from Stargate message types as used in the messages's `Any` type
|
|
50
|
+
* to Amino types.
|
|
51
|
+
*/
|
|
52
|
+
export class AminoTypes {
|
|
53
|
+
// The map type here ensures uniqueness of the protobuf type URL in the key.
|
|
54
|
+
// There is no uniqueness guarantee of the Amino type identifier in the type
|
|
55
|
+
// system or constructor. Instead it's the user's responsibility to ensure
|
|
56
|
+
// there is no overlap when fromAmino is called.
|
|
57
|
+
private readonly register: Record<string, AminoConverter | "not_supported_by_chain">;
|
|
58
|
+
|
|
59
|
+
constructor(types: AminoConverters) {
|
|
60
|
+
this.register = types;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
toAmino({ typeUrl, value }: EncodeObject): AminoMsg {
|
|
64
|
+
const converter = this.register[typeUrl];
|
|
65
|
+
if (converter === "not_supported_by_chain") {
|
|
66
|
+
throw new USwapError("wallet_ledger_chain_not_supported", {
|
|
67
|
+
reason: `The message type '${typeUrl}' cannot be signed using the Amino JSON sign mode because this is not supported by chain.`,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
if (!converter) {
|
|
71
|
+
throw new USwapError("wallet_ledger_invalid_params", {
|
|
72
|
+
reason: `Type URL '${typeUrl}' does not exist in the Amino message type register.`,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
return { type: converter.aminoType, value: converter.toAmino(value) };
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
fromAmino({ type, value }: AminoMsg): EncodeObject {
|
|
79
|
+
const matches = Object.entries(this.register)
|
|
80
|
+
.filter(isAminoConverter)
|
|
81
|
+
.filter(([_typeUrl, { aminoType }]) => aminoType === type);
|
|
82
|
+
|
|
83
|
+
if (matches.length === 0) {
|
|
84
|
+
throw new USwapError("wallet_ledger_invalid_params", {
|
|
85
|
+
reason: `Amino type identifier '${type}' does not exist in the Amino message type register.`,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (matches.length > 1) {
|
|
90
|
+
throw new USwapError("wallet_ledger_invalid_params", {
|
|
91
|
+
reason: `Multiple types are registered with Amino type identifier '${type}': '${matches
|
|
92
|
+
.map(([key, _value]) => key)
|
|
93
|
+
.sort()
|
|
94
|
+
.join("', '")}'. Thus fromAmino cannot be performed.`,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const [typeUrl, converter] = matches[0] as [string, AminoConverter];
|
|
99
|
+
|
|
100
|
+
return { typeUrl, value: converter.fromAmino(value) };
|
|
101
|
+
}
|
|
102
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Modifications © 2025 Horizontal Systems.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { Chain, USwapError, WalletOption } from "@tcswap/helpers";
|
|
6
|
+
|
|
7
|
+
import type { getNearLedgerClient } from "../clients/near";
|
|
8
|
+
import type { TronLedger } from "../clients/tron";
|
|
9
|
+
import type { XRPLedger } from "../clients/xrp";
|
|
10
|
+
import type { LEDGER_SUPPORTED_CHAINS } from "../index";
|
|
11
|
+
import type { CosmosLedgerClients, EVMLedgerClients, UTXOLedgerClients } from "../types";
|
|
12
|
+
import type { getLedgerClient } from "./getLedgerClient";
|
|
13
|
+
|
|
14
|
+
export const getLedgerAddress = async <
|
|
15
|
+
T extends (typeof LEDGER_SUPPORTED_CHAINS)[number],
|
|
16
|
+
L extends Awaited<ReturnType<typeof getLedgerClient<T>>>,
|
|
17
|
+
>({
|
|
18
|
+
chain,
|
|
19
|
+
ledgerClient,
|
|
20
|
+
}: {
|
|
21
|
+
chain: T;
|
|
22
|
+
ledgerClient: L;
|
|
23
|
+
}) => {
|
|
24
|
+
if (!ledgerClient) return "";
|
|
25
|
+
|
|
26
|
+
switch (chain) {
|
|
27
|
+
case Chain.Cosmos:
|
|
28
|
+
case Chain.THORChain: {
|
|
29
|
+
return (ledgerClient as CosmosLedgerClients).connect();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
case Chain.Ethereum:
|
|
33
|
+
case Chain.BinanceSmartChain:
|
|
34
|
+
case Chain.Avalanche:
|
|
35
|
+
case Chain.Polygon:
|
|
36
|
+
case Chain.Arbitrum:
|
|
37
|
+
case Chain.Optimism:
|
|
38
|
+
case Chain.Base:
|
|
39
|
+
case Chain.Aurora:
|
|
40
|
+
case Chain.Gnosis:
|
|
41
|
+
case Chain.XLayer: {
|
|
42
|
+
return (ledgerClient as EVMLedgerClients).getAddress();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
case Chain.Bitcoin:
|
|
46
|
+
case Chain.BitcoinCash:
|
|
47
|
+
case Chain.Dash:
|
|
48
|
+
case Chain.Dogecoin:
|
|
49
|
+
case Chain.Litecoin:
|
|
50
|
+
case Chain.Zcash: {
|
|
51
|
+
const ledger = ledgerClient as UTXOLedgerClients;
|
|
52
|
+
await ledger.connect();
|
|
53
|
+
const address = await ledger.getAddress();
|
|
54
|
+
|
|
55
|
+
return chain === Chain.BitcoinCash ? address.replace("bitcoincash:", "") : address;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
case Chain.Near: {
|
|
59
|
+
return await (ledgerClient as Awaited<ReturnType<typeof getNearLedgerClient>>).getAddress();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
case Chain.Ripple: {
|
|
63
|
+
return (ledgerClient as Awaited<ReturnType<typeof XRPLedger>>).getAddress();
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
case Chain.Tron: {
|
|
67
|
+
return (ledgerClient as Awaited<ReturnType<typeof TronLedger>>).getAddress();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
default:
|
|
71
|
+
throw new USwapError("wallet_chain_not_supported", { chain, wallet: WalletOption.LEDGER });
|
|
72
|
+
}
|
|
73
|
+
};
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Modifications © 2025 Horizontal Systems.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { Chain, type DerivationPathArray, type EVMChain, USwapError, WalletOption } from "@tcswap/helpers";
|
|
6
|
+
|
|
7
|
+
import { CosmosLedger } from "../clients/cosmos";
|
|
8
|
+
import {
|
|
9
|
+
ArbitrumLedger,
|
|
10
|
+
AuroraLedger,
|
|
11
|
+
AvalancheLedger,
|
|
12
|
+
BaseLedger,
|
|
13
|
+
BinanceSmartChainLedger,
|
|
14
|
+
EthereumLedger,
|
|
15
|
+
GnosisLedger,
|
|
16
|
+
MonadLedger,
|
|
17
|
+
OptimismLedger,
|
|
18
|
+
PolygonLedger,
|
|
19
|
+
XLayerLedger,
|
|
20
|
+
} from "../clients/evm";
|
|
21
|
+
import { getNearLedgerClient } from "../clients/near";
|
|
22
|
+
import { THORChainLedger } from "../clients/thorchain";
|
|
23
|
+
import { TronLedger } from "../clients/tron";
|
|
24
|
+
import {
|
|
25
|
+
BitcoinCashLedger,
|
|
26
|
+
BitcoinLedger,
|
|
27
|
+
DashLedger,
|
|
28
|
+
DogecoinLedger,
|
|
29
|
+
LitecoinLedger,
|
|
30
|
+
ZcashLedger,
|
|
31
|
+
} from "../clients/utxo";
|
|
32
|
+
import { XRPLedger } from "../clients/xrp";
|
|
33
|
+
|
|
34
|
+
type LedgerSignerMap = {
|
|
35
|
+
[Chain.Arbitrum]: ReturnType<typeof ArbitrumLedger>;
|
|
36
|
+
[Chain.Aurora]: ReturnType<typeof AuroraLedger>;
|
|
37
|
+
[Chain.Avalanche]: ReturnType<typeof AvalancheLedger>;
|
|
38
|
+
[Chain.Base]: ReturnType<typeof BaseLedger>;
|
|
39
|
+
[Chain.BinanceSmartChain]: ReturnType<typeof BinanceSmartChainLedger>;
|
|
40
|
+
[Chain.BitcoinCash]: ReturnType<typeof BitcoinCashLedger>;
|
|
41
|
+
[Chain.Bitcoin]: ReturnType<typeof BitcoinLedger>;
|
|
42
|
+
[Chain.Cosmos]: CosmosLedger;
|
|
43
|
+
[Chain.Dash]: ReturnType<typeof DashLedger>;
|
|
44
|
+
[Chain.Dogecoin]: ReturnType<typeof DogecoinLedger>;
|
|
45
|
+
[Chain.Ethereum]: ReturnType<typeof EthereumLedger>;
|
|
46
|
+
[Chain.Gnosis]: ReturnType<typeof GnosisLedger>;
|
|
47
|
+
[Chain.Litecoin]: ReturnType<typeof LitecoinLedger>;
|
|
48
|
+
[Chain.Monad]: ReturnType<typeof MonadLedger>;
|
|
49
|
+
[Chain.Near]: ReturnType<typeof getNearLedgerClient>;
|
|
50
|
+
[Chain.Optimism]: ReturnType<typeof OptimismLedger>;
|
|
51
|
+
[Chain.Polygon]: ReturnType<typeof PolygonLedger>;
|
|
52
|
+
[Chain.Ripple]: ReturnType<typeof XRPLedger>;
|
|
53
|
+
[Chain.THORChain]: THORChainLedger;
|
|
54
|
+
[Chain.Tron]: ReturnType<typeof TronLedger>;
|
|
55
|
+
[Chain.XLayer]: ReturnType<typeof XLayerLedger>;
|
|
56
|
+
[Chain.Zcash]: ReturnType<typeof ZcashLedger>;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
type LedgerSupportedChain = keyof LedgerSignerMap;
|
|
60
|
+
|
|
61
|
+
export const getLedgerClient = async <T extends LedgerSupportedChain>({
|
|
62
|
+
chain,
|
|
63
|
+
derivationPath,
|
|
64
|
+
}: {
|
|
65
|
+
chain: T;
|
|
66
|
+
derivationPath?: DerivationPathArray;
|
|
67
|
+
}): Promise<LedgerSignerMap[T]> => {
|
|
68
|
+
const { match } = await import("ts-pattern");
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
match(chain as LedgerSupportedChain)
|
|
72
|
+
.returnType<Promise<LedgerSignerMap[T]>>()
|
|
73
|
+
.with(Chain.THORChain, () => Promise.resolve(new THORChainLedger(derivationPath) as LedgerSignerMap[T]))
|
|
74
|
+
.with(Chain.Cosmos, () => Promise.resolve(new CosmosLedger(derivationPath) as LedgerSignerMap[T]))
|
|
75
|
+
.with(Chain.Bitcoin, () => Promise.resolve(BitcoinLedger(derivationPath) as LedgerSignerMap[T]))
|
|
76
|
+
.with(Chain.BitcoinCash, () => Promise.resolve(BitcoinCashLedger(derivationPath) as LedgerSignerMap[T]))
|
|
77
|
+
.with(Chain.Dash, () => Promise.resolve(DashLedger(derivationPath) as LedgerSignerMap[T]))
|
|
78
|
+
.with(Chain.Dogecoin, () => Promise.resolve(DogecoinLedger(derivationPath) as LedgerSignerMap[T]))
|
|
79
|
+
.with(Chain.Litecoin, () => Promise.resolve(LitecoinLedger(derivationPath) as LedgerSignerMap[T]))
|
|
80
|
+
.with(Chain.Zcash, () => Promise.resolve(ZcashLedger(derivationPath) as LedgerSignerMap[T]))
|
|
81
|
+
.with(Chain.Ripple, () => Promise.resolve(XRPLedger(derivationPath) as LedgerSignerMap[T]))
|
|
82
|
+
.with(Chain.Tron, () => Promise.resolve(TronLedger(derivationPath) as LedgerSignerMap[T]))
|
|
83
|
+
// @ts-expect-error
|
|
84
|
+
.with(Chain.Near, () => {
|
|
85
|
+
return Promise.resolve(getNearLedgerClient(derivationPath));
|
|
86
|
+
})
|
|
87
|
+
.with(
|
|
88
|
+
Chain.Arbitrum,
|
|
89
|
+
Chain.Aurora,
|
|
90
|
+
Chain.Avalanche,
|
|
91
|
+
Chain.BinanceSmartChain,
|
|
92
|
+
Chain.Ethereum,
|
|
93
|
+
Chain.Gnosis,
|
|
94
|
+
Chain.Monad,
|
|
95
|
+
Chain.Optimism,
|
|
96
|
+
Chain.Polygon,
|
|
97
|
+
Chain.Base,
|
|
98
|
+
Chain.XLayer,
|
|
99
|
+
async () => {
|
|
100
|
+
const { getProvider } = await import("@tcswap/toolboxes/evm");
|
|
101
|
+
const params = { derivationPath, provider: await getProvider(chain as EVMChain) };
|
|
102
|
+
|
|
103
|
+
return match(chain as Chain)
|
|
104
|
+
.with(Chain.BinanceSmartChain, () => BinanceSmartChainLedger(params) as LedgerSignerMap[T])
|
|
105
|
+
.with(Chain.Avalanche, () => AvalancheLedger(params) as LedgerSignerMap[T])
|
|
106
|
+
.with(Chain.Arbitrum, () => ArbitrumLedger(params) as LedgerSignerMap[T])
|
|
107
|
+
.with(Chain.Optimism, () => OptimismLedger(params) as LedgerSignerMap[T])
|
|
108
|
+
.with(Chain.Polygon, () => PolygonLedger(params) as LedgerSignerMap[T])
|
|
109
|
+
.with(Chain.Base, () => BaseLedger(params) as LedgerSignerMap[T])
|
|
110
|
+
.with(Chain.Aurora, () => AuroraLedger(params) as LedgerSignerMap[T])
|
|
111
|
+
.with(Chain.Gnosis, () => GnosisLedger(params) as LedgerSignerMap[T])
|
|
112
|
+
.with(Chain.Monad, () => MonadLedger(params) as LedgerSignerMap[T])
|
|
113
|
+
.with(Chain.XLayer, () => XLayerLedger(params) as LedgerSignerMap[T])
|
|
114
|
+
.otherwise(() => EthereumLedger(params) as LedgerSignerMap[T]);
|
|
115
|
+
},
|
|
116
|
+
)
|
|
117
|
+
.otherwise(() => {
|
|
118
|
+
throw new USwapError("wallet_chain_not_supported", { chain, wallet: WalletOption.LEDGER });
|
|
119
|
+
})
|
|
120
|
+
);
|
|
121
|
+
};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Modifications © 2025 Horizontal Systems.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type Transport from "@ledgerhq/hw-transport";
|
|
6
|
+
import { USwapError } from "@tcswap/helpers";
|
|
7
|
+
|
|
8
|
+
const getNavigatorUsb = () =>
|
|
9
|
+
navigator?.usb as unknown as {
|
|
10
|
+
getDevices: () => Promise<any[]>;
|
|
11
|
+
requestDevice: (requestObject: any) => Promise<any>;
|
|
12
|
+
removeEventListener: (event: string, callback: (e: any) => void) => void;
|
|
13
|
+
addEventListener: (event: string, callback: (e: any) => void) => void;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const getLedgerDevices = async (): Promise<USBDevice> => {
|
|
17
|
+
const navigatorUsb = getNavigatorUsb();
|
|
18
|
+
|
|
19
|
+
if (typeof navigatorUsb?.getDevices !== "function") return {} as USBDevice;
|
|
20
|
+
const { ledgerUSBVendorId } = await import("@ledgerhq/devices");
|
|
21
|
+
|
|
22
|
+
const devices = await navigatorUsb?.getDevices();
|
|
23
|
+
const existingDevices = devices.filter((d) => d.vendorId === ledgerUSBVendorId);
|
|
24
|
+
if (existingDevices.length > 0) return existingDevices[0];
|
|
25
|
+
|
|
26
|
+
return navigatorUsb?.requestDevice({ filters: [{ vendorId: ledgerUSBVendorId }] });
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const getLedgerTransport = async (): Promise<Transport> => {
|
|
30
|
+
const device = await getLedgerDevices();
|
|
31
|
+
|
|
32
|
+
if (!device) {
|
|
33
|
+
throw new USwapError("wallet_ledger_device_not_found");
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
device.opened || (await device.open());
|
|
37
|
+
if (device.configuration === null) await device.selectConfiguration(1);
|
|
38
|
+
|
|
39
|
+
try {
|
|
40
|
+
await device.reset();
|
|
41
|
+
} catch {
|
|
42
|
+
// reset fails on devices that are already open
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const configuration = device.configuration ?? device.configurations?.[0];
|
|
46
|
+
|
|
47
|
+
const iface =
|
|
48
|
+
configuration?.interfaces.find(({ alternates }: { alternates: { interfaceClass: number }[] }) =>
|
|
49
|
+
alternates.some(({ interfaceClass }) => interfaceClass === 0xff),
|
|
50
|
+
) ||
|
|
51
|
+
configuration?.interfaces.find(({ alternates }: { alternates: { interfaceClass: number }[] }) =>
|
|
52
|
+
alternates.some(({ interfaceClass }) => interfaceClass === 0x03),
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
if (!iface) {
|
|
56
|
+
await device.close();
|
|
57
|
+
throw new USwapError("wallet_ledger_connection_error");
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const klass0x03 = (iface.alternates as any[])?.find(
|
|
61
|
+
({ interfaceClass }: { interfaceClass: number }) => interfaceClass === 0x03,
|
|
62
|
+
)?.interfaceClass as number;
|
|
63
|
+
|
|
64
|
+
const klass0xff = (iface.alternates as any[])?.find(
|
|
65
|
+
({ interfaceClass }: { interfaceClass: number }) => interfaceClass === 0xff,
|
|
66
|
+
)?.interfaceClass as number;
|
|
67
|
+
|
|
68
|
+
if (klass0x03 && !klass0xff) {
|
|
69
|
+
// -------- HID class (NEAR, ETH, SOL, etc.) -> WebHID transport --------
|
|
70
|
+
const TransportWebHID = (await import("@ledgerhq/hw-transport-webhid")).default;
|
|
71
|
+
const supported = await TransportWebHID.isSupported();
|
|
72
|
+
if (!supported) {
|
|
73
|
+
await device.close();
|
|
74
|
+
throw new USwapError("wallet_ledger_webhid_not_supported");
|
|
75
|
+
}
|
|
76
|
+
const transport = await TransportWebHID.create();
|
|
77
|
+
return transport;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
try {
|
|
81
|
+
await device.claimInterface(iface.interfaceNumber);
|
|
82
|
+
} catch (error: unknown) {
|
|
83
|
+
await device.close();
|
|
84
|
+
|
|
85
|
+
throw new USwapError("wallet_ledger_connection_claimed", error);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const Transport = (await import("@ledgerhq/hw-transport-webusb")).default;
|
|
89
|
+
const isSupported = await Transport.isSupported();
|
|
90
|
+
if (!isSupported) throw new USwapError("wallet_ledger_webusb_not_supported");
|
|
91
|
+
|
|
92
|
+
const { DisconnectedDevice } = await import("@ledgerhq/errors");
|
|
93
|
+
|
|
94
|
+
const transport = new Transport(device, iface.interfaceNumber);
|
|
95
|
+
|
|
96
|
+
const onDisconnect = (e: any) => {
|
|
97
|
+
if (device === e.device) {
|
|
98
|
+
getNavigatorUsb()?.removeEventListener("disconnect", onDisconnect);
|
|
99
|
+
|
|
100
|
+
transport._emitDisconnect(new DisconnectedDevice());
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
getNavigatorUsb()?.addEventListener("disconnect", onDisconnect);
|
|
104
|
+
|
|
105
|
+
return transport as Transport;
|
|
106
|
+
};
|