@onekeyfe/hwk-ledger-adapter 1.1.29-alpha.3 → 1.1.29
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/index.d.mts +17 -22
- package/dist/index.d.ts +17 -22
- package/dist/index.js +145 -129
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +157 -143
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _onekeyfe_hwk_adapter_core from '@onekeyfe/hwk-adapter-core';
|
|
2
|
-
import { IHardwareWallet, IConnector, TransportType, UiResponseEvent, SearchDevicesOptions, DeviceInfo, Response, ChainCapability,
|
|
2
|
+
import { IHardwareWallet, IConnector, TransportType, UiResponseEvent, SearchDevicesOptions, DeviceInfo, Response, ChainCapability, EvmGetAddressParams, ICommonCallParams, EvmAddress, EvmSignTxParams, EvmSignedTx, EvmSignMsgParams, EvmSignature, EvmSignTypedDataParams, BtcGetAddressParams, BtcAddress, BtcGetPublicKeyParams, BtcPublicKey, BtcSignTxParams, BtcSignedTx, BtcSignPsbtParams, BtcSignedPsbt, BtcSignMsgParams, BtcSignature, SolGetAddressParams, SolAddress, SolSignTxParams, SolSignedTx, SolSignMsgParams, SolSignature, TronGetAddressParams, TronAddress, TronSignTxParams, TronSignedTx, TronSignMsgParams, TronSignature, HardwareEventMap, DeviceEventListener, ChainForFingerprint, DeviceDescriptor, DeviceChangeEvent, ConnectionType, ConnectorDevice, ConnectorSession, ConnectorCallResult, ConnectorEventType, ConnectorEventMap, Failure, HardwareErrorCode } from '@onekeyfe/hwk-adapter-core';
|
|
3
3
|
import { DeviceActionState as DeviceActionState$1, DiscoveredDevice, ExecuteDeviceActionReturnType, DeviceManagementKit } from '@ledgerhq/device-management-kit';
|
|
4
4
|
import { Address, Signature, SignerEth as SignerEth$1, TypedData } from '@ledgerhq/device-signer-kit-ethereum';
|
|
5
5
|
import { ContextModule } from '@ledgerhq/context-module';
|
|
@@ -91,8 +91,6 @@ interface LedgerDeviceInfo extends FirmwareVersion {
|
|
|
91
91
|
seFlagsHex: string;
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
type LedgerCallParams<T> = NullableCallArg<IHardwareCallParams<T>>;
|
|
95
|
-
type LedgerCommonParams = NullableCallArg<IHardwareCommonCallParams>;
|
|
96
94
|
declare class LedgerAdapter implements IHardwareWallet {
|
|
97
95
|
readonly vendor: "ledger";
|
|
98
96
|
private readonly connector;
|
|
@@ -135,27 +133,24 @@ declare class LedgerAdapter implements IHardwareWallet {
|
|
|
135
133
|
getSupportedChains(): ChainCapability[];
|
|
136
134
|
allNetworkGetAddress: (connectId: string, _deviceId: string, params: _onekeyfe_hwk_adapter_core.AllNetworkGetAddressParams) => Promise<Response<_onekeyfe_hwk_adapter_core.AllNetworkAddressResponse[]>>;
|
|
137
135
|
private callChain;
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
btcSignPsbt(connectId?: string | null, deviceId?: string | null, params?: LedgerCallParams<BtcSignPsbtParams>): Promise<Response<BtcSignedPsbt>>;
|
|
149
|
-
btcSignMessage(connectId?: string | null, deviceId?: string | null, params?: LedgerCallParams<BtcSignMsgParams>): Promise<Response<BtcSignature>>;
|
|
150
|
-
btcGetMasterFingerprint(connectId?: string | null, deviceId?: string | null, params?: LedgerCommonParams): Promise<Response<{
|
|
136
|
+
evmGetAddress(connectId: string, deviceId: string, params: EvmGetAddressParams, commonParams?: ICommonCallParams): Promise<Response<EvmAddress>>;
|
|
137
|
+
evmSignTransaction(connectId: string, deviceId: string, params: EvmSignTxParams, commonParams?: ICommonCallParams): Promise<Response<EvmSignedTx>>;
|
|
138
|
+
evmSignMessage(connectId: string, deviceId: string, params: EvmSignMsgParams, commonParams?: ICommonCallParams): Promise<Response<EvmSignature>>;
|
|
139
|
+
evmSignTypedData(connectId: string, deviceId: string, params: EvmSignTypedDataParams, commonParams?: ICommonCallParams): Promise<Response<EvmSignature>>;
|
|
140
|
+
btcGetAddress(connectId: string, deviceId: string, params: BtcGetAddressParams, commonParams?: ICommonCallParams): Promise<Response<BtcAddress>>;
|
|
141
|
+
btcGetPublicKey(connectId: string, deviceId: string, params: BtcGetPublicKeyParams, commonParams?: ICommonCallParams): Promise<Response<BtcPublicKey>>;
|
|
142
|
+
btcSignTransaction(connectId: string, deviceId: string, params: BtcSignTxParams, commonParams?: ICommonCallParams): Promise<Response<BtcSignedTx>>;
|
|
143
|
+
btcSignPsbt(connectId: string, deviceId: string, params: BtcSignPsbtParams, commonParams?: ICommonCallParams): Promise<Response<BtcSignedPsbt>>;
|
|
144
|
+
btcSignMessage(connectId: string, deviceId: string, params: BtcSignMsgParams, commonParams?: ICommonCallParams): Promise<Response<BtcSignature>>;
|
|
145
|
+
btcGetMasterFingerprint(connectId: string, deviceId: string, commonParams?: ICommonCallParams): Promise<Response<{
|
|
151
146
|
masterFingerprint: string;
|
|
152
147
|
}>>;
|
|
153
|
-
solGetAddress(connectId
|
|
154
|
-
solSignTransaction(connectId
|
|
155
|
-
solSignMessage(connectId
|
|
156
|
-
tronGetAddress(connectId
|
|
157
|
-
tronSignTransaction(connectId
|
|
158
|
-
tronSignMessage(connectId
|
|
148
|
+
solGetAddress(connectId: string, deviceId: string, params: SolGetAddressParams, commonParams?: ICommonCallParams): Promise<Response<SolAddress>>;
|
|
149
|
+
solSignTransaction(connectId: string, deviceId: string, params: SolSignTxParams, commonParams?: ICommonCallParams): Promise<Response<SolSignedTx>>;
|
|
150
|
+
solSignMessage(connectId: string, deviceId: string, params: SolSignMsgParams, commonParams?: ICommonCallParams): Promise<Response<SolSignature>>;
|
|
151
|
+
tronGetAddress(connectId: string, deviceId: string, params: TronGetAddressParams, commonParams?: ICommonCallParams): Promise<Response<TronAddress>>;
|
|
152
|
+
tronSignTransaction(connectId: string, deviceId: string, params: TronSignTxParams, commonParams?: ICommonCallParams): Promise<Response<TronSignedTx>>;
|
|
153
|
+
tronSignMessage(connectId: string, deviceId: string, params: TronSignMsgParams, commonParams?: ICommonCallParams): Promise<Response<TronSignature>>;
|
|
159
154
|
installApp(connectId: string, appName: string): Promise<Response<void>>;
|
|
160
155
|
listInstalledApps(connectId: string): Promise<Response<AppMetadata[]>>;
|
|
161
156
|
listInstalledNames(connectId: string): Promise<Response<string[]>>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _onekeyfe_hwk_adapter_core from '@onekeyfe/hwk-adapter-core';
|
|
2
|
-
import { IHardwareWallet, IConnector, TransportType, UiResponseEvent, SearchDevicesOptions, DeviceInfo, Response, ChainCapability,
|
|
2
|
+
import { IHardwareWallet, IConnector, TransportType, UiResponseEvent, SearchDevicesOptions, DeviceInfo, Response, ChainCapability, EvmGetAddressParams, ICommonCallParams, EvmAddress, EvmSignTxParams, EvmSignedTx, EvmSignMsgParams, EvmSignature, EvmSignTypedDataParams, BtcGetAddressParams, BtcAddress, BtcGetPublicKeyParams, BtcPublicKey, BtcSignTxParams, BtcSignedTx, BtcSignPsbtParams, BtcSignedPsbt, BtcSignMsgParams, BtcSignature, SolGetAddressParams, SolAddress, SolSignTxParams, SolSignedTx, SolSignMsgParams, SolSignature, TronGetAddressParams, TronAddress, TronSignTxParams, TronSignedTx, TronSignMsgParams, TronSignature, HardwareEventMap, DeviceEventListener, ChainForFingerprint, DeviceDescriptor, DeviceChangeEvent, ConnectionType, ConnectorDevice, ConnectorSession, ConnectorCallResult, ConnectorEventType, ConnectorEventMap, Failure, HardwareErrorCode } from '@onekeyfe/hwk-adapter-core';
|
|
3
3
|
import { DeviceActionState as DeviceActionState$1, DiscoveredDevice, ExecuteDeviceActionReturnType, DeviceManagementKit } from '@ledgerhq/device-management-kit';
|
|
4
4
|
import { Address, Signature, SignerEth as SignerEth$1, TypedData } from '@ledgerhq/device-signer-kit-ethereum';
|
|
5
5
|
import { ContextModule } from '@ledgerhq/context-module';
|
|
@@ -91,8 +91,6 @@ interface LedgerDeviceInfo extends FirmwareVersion {
|
|
|
91
91
|
seFlagsHex: string;
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
type LedgerCallParams<T> = NullableCallArg<IHardwareCallParams<T>>;
|
|
95
|
-
type LedgerCommonParams = NullableCallArg<IHardwareCommonCallParams>;
|
|
96
94
|
declare class LedgerAdapter implements IHardwareWallet {
|
|
97
95
|
readonly vendor: "ledger";
|
|
98
96
|
private readonly connector;
|
|
@@ -135,27 +133,24 @@ declare class LedgerAdapter implements IHardwareWallet {
|
|
|
135
133
|
getSupportedChains(): ChainCapability[];
|
|
136
134
|
allNetworkGetAddress: (connectId: string, _deviceId: string, params: _onekeyfe_hwk_adapter_core.AllNetworkGetAddressParams) => Promise<Response<_onekeyfe_hwk_adapter_core.AllNetworkAddressResponse[]>>;
|
|
137
135
|
private callChain;
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
btcSignPsbt(connectId?: string | null, deviceId?: string | null, params?: LedgerCallParams<BtcSignPsbtParams>): Promise<Response<BtcSignedPsbt>>;
|
|
149
|
-
btcSignMessage(connectId?: string | null, deviceId?: string | null, params?: LedgerCallParams<BtcSignMsgParams>): Promise<Response<BtcSignature>>;
|
|
150
|
-
btcGetMasterFingerprint(connectId?: string | null, deviceId?: string | null, params?: LedgerCommonParams): Promise<Response<{
|
|
136
|
+
evmGetAddress(connectId: string, deviceId: string, params: EvmGetAddressParams, commonParams?: ICommonCallParams): Promise<Response<EvmAddress>>;
|
|
137
|
+
evmSignTransaction(connectId: string, deviceId: string, params: EvmSignTxParams, commonParams?: ICommonCallParams): Promise<Response<EvmSignedTx>>;
|
|
138
|
+
evmSignMessage(connectId: string, deviceId: string, params: EvmSignMsgParams, commonParams?: ICommonCallParams): Promise<Response<EvmSignature>>;
|
|
139
|
+
evmSignTypedData(connectId: string, deviceId: string, params: EvmSignTypedDataParams, commonParams?: ICommonCallParams): Promise<Response<EvmSignature>>;
|
|
140
|
+
btcGetAddress(connectId: string, deviceId: string, params: BtcGetAddressParams, commonParams?: ICommonCallParams): Promise<Response<BtcAddress>>;
|
|
141
|
+
btcGetPublicKey(connectId: string, deviceId: string, params: BtcGetPublicKeyParams, commonParams?: ICommonCallParams): Promise<Response<BtcPublicKey>>;
|
|
142
|
+
btcSignTransaction(connectId: string, deviceId: string, params: BtcSignTxParams, commonParams?: ICommonCallParams): Promise<Response<BtcSignedTx>>;
|
|
143
|
+
btcSignPsbt(connectId: string, deviceId: string, params: BtcSignPsbtParams, commonParams?: ICommonCallParams): Promise<Response<BtcSignedPsbt>>;
|
|
144
|
+
btcSignMessage(connectId: string, deviceId: string, params: BtcSignMsgParams, commonParams?: ICommonCallParams): Promise<Response<BtcSignature>>;
|
|
145
|
+
btcGetMasterFingerprint(connectId: string, deviceId: string, commonParams?: ICommonCallParams): Promise<Response<{
|
|
151
146
|
masterFingerprint: string;
|
|
152
147
|
}>>;
|
|
153
|
-
solGetAddress(connectId
|
|
154
|
-
solSignTransaction(connectId
|
|
155
|
-
solSignMessage(connectId
|
|
156
|
-
tronGetAddress(connectId
|
|
157
|
-
tronSignTransaction(connectId
|
|
158
|
-
tronSignMessage(connectId
|
|
148
|
+
solGetAddress(connectId: string, deviceId: string, params: SolGetAddressParams, commonParams?: ICommonCallParams): Promise<Response<SolAddress>>;
|
|
149
|
+
solSignTransaction(connectId: string, deviceId: string, params: SolSignTxParams, commonParams?: ICommonCallParams): Promise<Response<SolSignedTx>>;
|
|
150
|
+
solSignMessage(connectId: string, deviceId: string, params: SolSignMsgParams, commonParams?: ICommonCallParams): Promise<Response<SolSignature>>;
|
|
151
|
+
tronGetAddress(connectId: string, deviceId: string, params: TronGetAddressParams, commonParams?: ICommonCallParams): Promise<Response<TronAddress>>;
|
|
152
|
+
tronSignTransaction(connectId: string, deviceId: string, params: TronSignTxParams, commonParams?: ICommonCallParams): Promise<Response<TronSignedTx>>;
|
|
153
|
+
tronSignMessage(connectId: string, deviceId: string, params: TronSignMsgParams, commonParams?: ICommonCallParams): Promise<Response<TronSignature>>;
|
|
159
154
|
installApp(connectId: string, appName: string): Promise<Response<void>>;
|
|
160
155
|
listInstalledApps(connectId: string): Promise<Response<AppMetadata[]>>;
|
|
161
156
|
listInstalledNames(connectId: string): Promise<Response<string[]>>;
|
package/dist/index.js
CHANGED
|
@@ -541,10 +541,10 @@ function debugError(...args) {
|
|
|
541
541
|
var LEDGER_BTC_NETWORK_COIN_MAP = {
|
|
542
542
|
tbtc: "Testnet",
|
|
543
543
|
bch: "Bcash",
|
|
544
|
+
doge: "Dogecoin",
|
|
544
545
|
ltc: "Litecoin",
|
|
545
546
|
neurai: "Neurai"
|
|
546
547
|
};
|
|
547
|
-
var LEDGER_UNSUPPORTED_ALLNETWORK_NETWORKS = /* @__PURE__ */ new Set(["doge", "dogecoin"]);
|
|
548
548
|
function createAllNetworkGetAddress({
|
|
549
549
|
callChain,
|
|
550
550
|
getChainFingerprint
|
|
@@ -555,46 +555,49 @@ function createAllNetworkGetAddress({
|
|
|
555
555
|
const commonParams = {
|
|
556
556
|
autoInstallApp: params.autoInstallApp
|
|
557
557
|
};
|
|
558
|
+
const responses = [];
|
|
558
559
|
const chainFingerprints = /* @__PURE__ */ new Map();
|
|
559
|
-
const
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
callItem: async ({ method, chain, item }) => {
|
|
560
|
+
for (const item of params.bundle) {
|
|
561
|
+
const method = getAllNetworkMethod(item);
|
|
562
|
+
if (!method) {
|
|
563
|
+
responses.push(buildUnsupportedMethodResponse(item));
|
|
564
|
+
} else {
|
|
565
|
+
const chain = getFingerprintChain(method);
|
|
566
566
|
const itemDeviceId = getItemDeviceId(item) ?? chainFingerprints.get(chain) ?? "";
|
|
567
|
-
|
|
567
|
+
const normalizedItem = normalizeLedgerAllNetworkItem(method, item);
|
|
568
|
+
const response = await callAllNetworkItem(
|
|
568
569
|
callChain,
|
|
570
|
+
getChainFingerprint,
|
|
569
571
|
connectId,
|
|
570
572
|
itemDeviceId,
|
|
573
|
+
chain,
|
|
571
574
|
method,
|
|
572
|
-
|
|
575
|
+
normalizedItem,
|
|
573
576
|
commonParams,
|
|
574
|
-
installContext
|
|
575
|
-
|
|
576
|
-
},
|
|
577
|
-
attachIdentity: async ({ item, chain, payload }) => attachLedgerIdentity(
|
|
578
|
-
getChainFingerprint,
|
|
579
|
-
connectId,
|
|
580
|
-
item,
|
|
581
|
-
chain,
|
|
582
|
-
payload,
|
|
583
|
-
chainFingerprints
|
|
584
|
-
),
|
|
585
|
-
shouldAbortBundle: isTopLevelAllNetworkFailure,
|
|
586
|
-
buildTopLevelFailure: (response) => {
|
|
587
|
-
const code = response.payload?.code ?? import_hwk_adapter_core2.HardwareErrorCode.DeviceMismatch;
|
|
588
|
-
return (0, import_hwk_adapter_core2.failure)(
|
|
589
|
-
code,
|
|
590
|
-
response.payload?.error ?? "All-network get-address aborted",
|
|
591
|
-
response.payload?.params
|
|
577
|
+
installContext,
|
|
578
|
+
chainFingerprints
|
|
592
579
|
);
|
|
580
|
+
if (isTopLevelAllNetworkFailure(response)) {
|
|
581
|
+
const code = response.payload?.code ?? import_hwk_adapter_core2.HardwareErrorCode.DeviceMismatch;
|
|
582
|
+
const result2 = (0, import_hwk_adapter_core2.failure)(
|
|
583
|
+
code,
|
|
584
|
+
response.payload?.error ?? "All-network get-address aborted",
|
|
585
|
+
response.payload?.params
|
|
586
|
+
);
|
|
587
|
+
debugLog("[LedgerAdapter][RES]", {
|
|
588
|
+
method: "allNetworkGetAddress",
|
|
589
|
+
success: false,
|
|
590
|
+
payload: result2
|
|
591
|
+
});
|
|
592
|
+
return result2;
|
|
593
|
+
}
|
|
594
|
+
responses.push(response);
|
|
593
595
|
}
|
|
594
|
-
}
|
|
596
|
+
}
|
|
597
|
+
const result = (0, import_hwk_adapter_core2.success)(responses);
|
|
595
598
|
debugLog("[LedgerAdapter][RES]", {
|
|
596
599
|
method: "allNetworkGetAddress",
|
|
597
|
-
success:
|
|
600
|
+
success: true,
|
|
598
601
|
payload: result
|
|
599
602
|
});
|
|
600
603
|
return result;
|
|
@@ -611,16 +614,25 @@ function getItemDeviceId(item) {
|
|
|
611
614
|
const { deviceId } = item;
|
|
612
615
|
return typeof deviceId === "string" && deviceId.length > 0 ? deviceId : void 0;
|
|
613
616
|
}
|
|
614
|
-
function
|
|
615
|
-
|
|
617
|
+
function getAllNetworkMethod(item) {
|
|
618
|
+
switch (item.methodName) {
|
|
619
|
+
case "evmGetAddress":
|
|
620
|
+
case "btcGetAddress":
|
|
621
|
+
case "btcGetPublicKey":
|
|
622
|
+
case "solGetAddress":
|
|
623
|
+
case "tronGetAddress":
|
|
624
|
+
return item.methodName;
|
|
625
|
+
default:
|
|
626
|
+
return void 0;
|
|
627
|
+
}
|
|
616
628
|
}
|
|
617
|
-
function
|
|
629
|
+
function buildUnsupportedMethodResponse(item) {
|
|
618
630
|
return {
|
|
619
631
|
...item,
|
|
620
632
|
success: false,
|
|
621
633
|
payload: {
|
|
622
|
-
code: import_hwk_adapter_core2.HardwareErrorCode.
|
|
623
|
-
error: `
|
|
634
|
+
code: import_hwk_adapter_core2.HardwareErrorCode.InvalidParams,
|
|
635
|
+
error: `Unsupported allNetwork method: ${String(item.methodName)}`
|
|
624
636
|
}
|
|
625
637
|
};
|
|
626
638
|
}
|
|
@@ -635,8 +647,21 @@ function normalizeLedgerAllNetworkItem(method, item) {
|
|
|
635
647
|
const coin = LEDGER_BTC_NETWORK_COIN_MAP[item.network];
|
|
636
648
|
return coin ? { ...item, coin } : item;
|
|
637
649
|
}
|
|
638
|
-
async function
|
|
639
|
-
const
|
|
650
|
+
async function callAllNetworkItem(callChain, getChainFingerprint, connectId, deviceId, chain, method, item, commonParams, installContext, chainFingerprints) {
|
|
651
|
+
const response = await callAllNetworkMethod(
|
|
652
|
+
callChain,
|
|
653
|
+
connectId,
|
|
654
|
+
deviceId,
|
|
655
|
+
method,
|
|
656
|
+
item,
|
|
657
|
+
commonParams,
|
|
658
|
+
installContext
|
|
659
|
+
);
|
|
660
|
+
if (!response.success) {
|
|
661
|
+
return { ...item, success: false, payload: response.payload };
|
|
662
|
+
}
|
|
663
|
+
const payload = response.payload;
|
|
664
|
+
const fingerprint = deviceId || chainFingerprints.get(chain) || await bootstrapChainFingerprint(getChainFingerprint, connectId, chain);
|
|
640
665
|
if (!fingerprint) {
|
|
641
666
|
return buildFingerprintBootstrapFailure(item, chain);
|
|
642
667
|
}
|
|
@@ -646,12 +671,6 @@ async function attachLedgerIdentity(getChainFingerprint, connectId, item, chain,
|
|
|
646
671
|
success: true,
|
|
647
672
|
payload: {
|
|
648
673
|
...payload,
|
|
649
|
-
deviceIdentity: {
|
|
650
|
-
vendor: "ledger",
|
|
651
|
-
type: "chainFingerprint",
|
|
652
|
-
chain,
|
|
653
|
-
value: fingerprint
|
|
654
|
-
},
|
|
655
674
|
chainFingerprint: fingerprint,
|
|
656
675
|
chainFingerprintChain: chain
|
|
657
676
|
}
|
|
@@ -671,6 +690,23 @@ function buildFingerprintBootstrapFailure(item, chain) {
|
|
|
671
690
|
}
|
|
672
691
|
};
|
|
673
692
|
}
|
|
693
|
+
function getFingerprintChain(method) {
|
|
694
|
+
switch (method) {
|
|
695
|
+
case "evmGetAddress":
|
|
696
|
+
return "evm";
|
|
697
|
+
case "btcGetAddress":
|
|
698
|
+
case "btcGetPublicKey":
|
|
699
|
+
return "btc";
|
|
700
|
+
case "solGetAddress":
|
|
701
|
+
return "sol";
|
|
702
|
+
case "tronGetAddress":
|
|
703
|
+
return "tron";
|
|
704
|
+
default:
|
|
705
|
+
throw Object.assign(new Error(`Unsupported allNetwork method: ${method}`), {
|
|
706
|
+
code: import_hwk_adapter_core2.HardwareErrorCode.InvalidParams
|
|
707
|
+
});
|
|
708
|
+
}
|
|
709
|
+
}
|
|
674
710
|
async function callAllNetworkMethod(callChain, connectId, deviceId, method, item, commonParams, installContext) {
|
|
675
711
|
switch (method) {
|
|
676
712
|
case "evmGetAddress":
|
|
@@ -1076,196 +1112,176 @@ var _LedgerAdapter = class _LedgerAdapter {
|
|
|
1076
1112
|
return this.errorToFailure(err);
|
|
1077
1113
|
}
|
|
1078
1114
|
}
|
|
1079
|
-
static normalizeCallArgs(connectId, deviceId, params) {
|
|
1080
|
-
return {
|
|
1081
|
-
connectId: connectId ?? "",
|
|
1082
|
-
deviceId: deviceId ?? "",
|
|
1083
|
-
params: params ?? {}
|
|
1084
|
-
};
|
|
1085
|
-
}
|
|
1086
|
-
static splitCommonParams(params) {
|
|
1087
|
-
if (params && typeof params === "object") {
|
|
1088
|
-
const {
|
|
1089
|
-
autoInstallApp,
|
|
1090
|
-
passphraseState: _passphraseState,
|
|
1091
|
-
useEmptyPassphrase: _useEmptyPassphrase,
|
|
1092
|
-
...rest
|
|
1093
|
-
} = params;
|
|
1094
|
-
return {
|
|
1095
|
-
commonParams: {
|
|
1096
|
-
autoInstallApp: typeof autoInstallApp === "boolean" ? autoInstallApp : void 0
|
|
1097
|
-
},
|
|
1098
|
-
rest
|
|
1099
|
-
};
|
|
1100
|
-
}
|
|
1101
|
-
return { commonParams: {}, rest: params ?? {} };
|
|
1102
|
-
}
|
|
1103
|
-
callChainWithMergedParams(connectId, deviceId, chain, method, params) {
|
|
1104
|
-
const normalized = _LedgerAdapter.normalizeCallArgs(connectId, deviceId, params);
|
|
1105
|
-
const { commonParams, rest } = _LedgerAdapter.splitCommonParams(normalized.params);
|
|
1106
|
-
return this.callChain(
|
|
1107
|
-
normalized.connectId,
|
|
1108
|
-
normalized.deviceId,
|
|
1109
|
-
chain,
|
|
1110
|
-
method,
|
|
1111
|
-
rest,
|
|
1112
|
-
commonParams
|
|
1113
|
-
);
|
|
1114
|
-
}
|
|
1115
1115
|
// ---------------------------------------------------------------------------
|
|
1116
1116
|
// EVM chain methods
|
|
1117
1117
|
// ---------------------------------------------------------------------------
|
|
1118
|
-
evmGetAddress(connectId, deviceId, params) {
|
|
1119
|
-
return this.
|
|
1118
|
+
evmGetAddress(connectId, deviceId, params, commonParams) {
|
|
1119
|
+
return this.callChain(
|
|
1120
1120
|
connectId,
|
|
1121
1121
|
deviceId,
|
|
1122
1122
|
"evm",
|
|
1123
1123
|
"evmGetAddress",
|
|
1124
|
-
params
|
|
1124
|
+
params,
|
|
1125
|
+
commonParams
|
|
1125
1126
|
);
|
|
1126
1127
|
}
|
|
1127
|
-
evmSignTransaction(connectId, deviceId, params) {
|
|
1128
|
-
return this.
|
|
1128
|
+
evmSignTransaction(connectId, deviceId, params, commonParams) {
|
|
1129
|
+
return this.callChain(
|
|
1129
1130
|
connectId,
|
|
1130
1131
|
deviceId,
|
|
1131
1132
|
"evm",
|
|
1132
1133
|
"evmSignTransaction",
|
|
1133
|
-
params
|
|
1134
|
+
params,
|
|
1135
|
+
commonParams
|
|
1134
1136
|
);
|
|
1135
1137
|
}
|
|
1136
|
-
evmSignMessage(connectId, deviceId, params) {
|
|
1137
|
-
return this.
|
|
1138
|
+
evmSignMessage(connectId, deviceId, params, commonParams) {
|
|
1139
|
+
return this.callChain(
|
|
1138
1140
|
connectId,
|
|
1139
1141
|
deviceId,
|
|
1140
1142
|
"evm",
|
|
1141
1143
|
"evmSignMessage",
|
|
1142
|
-
params
|
|
1144
|
+
params,
|
|
1145
|
+
commonParams
|
|
1143
1146
|
);
|
|
1144
1147
|
}
|
|
1145
|
-
evmSignTypedData(connectId, deviceId, params) {
|
|
1146
|
-
return this.
|
|
1148
|
+
evmSignTypedData(connectId, deviceId, params, commonParams) {
|
|
1149
|
+
return this.callChain(
|
|
1147
1150
|
connectId,
|
|
1148
1151
|
deviceId,
|
|
1149
1152
|
"evm",
|
|
1150
1153
|
"evmSignTypedData",
|
|
1151
|
-
params
|
|
1154
|
+
params,
|
|
1155
|
+
commonParams
|
|
1152
1156
|
);
|
|
1153
1157
|
}
|
|
1154
1158
|
// ---------------------------------------------------------------------------
|
|
1155
1159
|
// BTC chain methods
|
|
1156
1160
|
// ---------------------------------------------------------------------------
|
|
1157
|
-
btcGetAddress(connectId, deviceId, params) {
|
|
1158
|
-
return this.
|
|
1161
|
+
btcGetAddress(connectId, deviceId, params, commonParams) {
|
|
1162
|
+
return this.callChain(
|
|
1159
1163
|
connectId,
|
|
1160
1164
|
deviceId,
|
|
1161
1165
|
"btc",
|
|
1162
1166
|
"btcGetAddress",
|
|
1163
|
-
params
|
|
1167
|
+
params,
|
|
1168
|
+
commonParams
|
|
1164
1169
|
);
|
|
1165
1170
|
}
|
|
1166
|
-
btcGetPublicKey(connectId, deviceId, params) {
|
|
1167
|
-
return this.
|
|
1171
|
+
btcGetPublicKey(connectId, deviceId, params, commonParams) {
|
|
1172
|
+
return this.callChain(
|
|
1168
1173
|
connectId,
|
|
1169
1174
|
deviceId,
|
|
1170
1175
|
"btc",
|
|
1171
1176
|
"btcGetPublicKey",
|
|
1172
|
-
params
|
|
1177
|
+
params,
|
|
1178
|
+
commonParams
|
|
1173
1179
|
);
|
|
1174
1180
|
}
|
|
1175
|
-
btcSignTransaction(connectId, deviceId, params) {
|
|
1176
|
-
return this.
|
|
1181
|
+
btcSignTransaction(connectId, deviceId, params, commonParams) {
|
|
1182
|
+
return this.callChain(
|
|
1177
1183
|
connectId,
|
|
1178
1184
|
deviceId,
|
|
1179
1185
|
"btc",
|
|
1180
1186
|
"btcSignTransaction",
|
|
1181
|
-
params
|
|
1187
|
+
params,
|
|
1188
|
+
commonParams
|
|
1182
1189
|
);
|
|
1183
1190
|
}
|
|
1184
|
-
btcSignPsbt(connectId, deviceId, params) {
|
|
1185
|
-
return this.
|
|
1191
|
+
btcSignPsbt(connectId, deviceId, params, commonParams) {
|
|
1192
|
+
return this.callChain(
|
|
1186
1193
|
connectId,
|
|
1187
1194
|
deviceId,
|
|
1188
1195
|
"btc",
|
|
1189
1196
|
"btcSignPsbt",
|
|
1190
|
-
params
|
|
1197
|
+
params,
|
|
1198
|
+
commonParams
|
|
1191
1199
|
);
|
|
1192
1200
|
}
|
|
1193
|
-
btcSignMessage(connectId, deviceId, params) {
|
|
1194
|
-
return this.
|
|
1201
|
+
btcSignMessage(connectId, deviceId, params, commonParams) {
|
|
1202
|
+
return this.callChain(
|
|
1195
1203
|
connectId,
|
|
1196
1204
|
deviceId,
|
|
1197
1205
|
"btc",
|
|
1198
1206
|
"btcSignMessage",
|
|
1199
|
-
params
|
|
1207
|
+
params,
|
|
1208
|
+
commonParams
|
|
1200
1209
|
);
|
|
1201
1210
|
}
|
|
1202
|
-
btcGetMasterFingerprint(connectId, deviceId,
|
|
1203
|
-
return this.
|
|
1211
|
+
btcGetMasterFingerprint(connectId, deviceId, commonParams) {
|
|
1212
|
+
return this.callChain(
|
|
1204
1213
|
connectId,
|
|
1205
1214
|
deviceId,
|
|
1206
1215
|
"btc",
|
|
1207
1216
|
"btcGetMasterFingerprint",
|
|
1208
|
-
|
|
1217
|
+
{},
|
|
1218
|
+
commonParams
|
|
1209
1219
|
);
|
|
1210
1220
|
}
|
|
1211
1221
|
// ---------------------------------------------------------------------------
|
|
1212
1222
|
// SOL chain methods
|
|
1213
1223
|
// ---------------------------------------------------------------------------
|
|
1214
|
-
solGetAddress(connectId, deviceId, params) {
|
|
1215
|
-
return this.
|
|
1224
|
+
solGetAddress(connectId, deviceId, params, commonParams) {
|
|
1225
|
+
return this.callChain(
|
|
1216
1226
|
connectId,
|
|
1217
1227
|
deviceId,
|
|
1218
1228
|
"sol",
|
|
1219
1229
|
"solGetAddress",
|
|
1220
|
-
params
|
|
1230
|
+
params,
|
|
1231
|
+
commonParams
|
|
1221
1232
|
);
|
|
1222
1233
|
}
|
|
1223
|
-
solSignTransaction(connectId, deviceId, params) {
|
|
1224
|
-
return this.
|
|
1234
|
+
solSignTransaction(connectId, deviceId, params, commonParams) {
|
|
1235
|
+
return this.callChain(
|
|
1225
1236
|
connectId,
|
|
1226
1237
|
deviceId,
|
|
1227
1238
|
"sol",
|
|
1228
1239
|
"solSignTransaction",
|
|
1229
|
-
params
|
|
1240
|
+
params,
|
|
1241
|
+
commonParams
|
|
1230
1242
|
);
|
|
1231
1243
|
}
|
|
1232
|
-
solSignMessage(connectId, deviceId, params) {
|
|
1233
|
-
return this.
|
|
1244
|
+
solSignMessage(connectId, deviceId, params, commonParams) {
|
|
1245
|
+
return this.callChain(
|
|
1234
1246
|
connectId,
|
|
1235
1247
|
deviceId,
|
|
1236
1248
|
"sol",
|
|
1237
1249
|
"solSignMessage",
|
|
1238
|
-
params
|
|
1250
|
+
params,
|
|
1251
|
+
commonParams
|
|
1239
1252
|
);
|
|
1240
1253
|
}
|
|
1241
1254
|
// ---------------------------------------------------------------------------
|
|
1242
1255
|
// TRON chain methods
|
|
1243
1256
|
// ---------------------------------------------------------------------------
|
|
1244
|
-
tronGetAddress(connectId, deviceId, params) {
|
|
1245
|
-
return this.
|
|
1257
|
+
tronGetAddress(connectId, deviceId, params, commonParams) {
|
|
1258
|
+
return this.callChain(
|
|
1246
1259
|
connectId,
|
|
1247
1260
|
deviceId,
|
|
1248
1261
|
"tron",
|
|
1249
1262
|
"tronGetAddress",
|
|
1250
|
-
params
|
|
1263
|
+
params,
|
|
1264
|
+
commonParams
|
|
1251
1265
|
);
|
|
1252
1266
|
}
|
|
1253
|
-
tronSignTransaction(connectId, deviceId, params) {
|
|
1254
|
-
return this.
|
|
1267
|
+
tronSignTransaction(connectId, deviceId, params, commonParams) {
|
|
1268
|
+
return this.callChain(
|
|
1255
1269
|
connectId,
|
|
1256
1270
|
deviceId,
|
|
1257
1271
|
"tron",
|
|
1258
1272
|
"tronSignTransaction",
|
|
1259
|
-
params
|
|
1273
|
+
params,
|
|
1274
|
+
commonParams
|
|
1260
1275
|
);
|
|
1261
1276
|
}
|
|
1262
|
-
tronSignMessage(connectId, deviceId, params) {
|
|
1263
|
-
return this.
|
|
1277
|
+
tronSignMessage(connectId, deviceId, params, commonParams) {
|
|
1278
|
+
return this.callChain(
|
|
1264
1279
|
connectId,
|
|
1265
1280
|
deviceId,
|
|
1266
1281
|
"tron",
|
|
1267
1282
|
"tronSignMessage",
|
|
1268
|
-
params
|
|
1283
|
+
params,
|
|
1284
|
+
commonParams
|
|
1269
1285
|
);
|
|
1270
1286
|
}
|
|
1271
1287
|
// ---------------------------------------------------------------------------
|
|
@@ -1612,7 +1628,7 @@ var _LedgerAdapter = class _LedgerAdapter {
|
|
|
1612
1628
|
if (devices.length === 0) {
|
|
1613
1629
|
for (let i = 0; i < 3 && !internalSignal.aborted; i += 1) {
|
|
1614
1630
|
await new Promise((resolve) => {
|
|
1615
|
-
setTimeout(resolve,
|
|
1631
|
+
setTimeout(resolve, 1e3);
|
|
1616
1632
|
});
|
|
1617
1633
|
devices = await this.searchDevices();
|
|
1618
1634
|
if (devices.length > 0) break;
|
|
@@ -4183,7 +4199,7 @@ var LedgerConnectorBase = class {
|
|
|
4183
4199
|
async searchDevices() {
|
|
4184
4200
|
const dm = await this._getDeviceManager();
|
|
4185
4201
|
const descriptors = await this._discoverDescriptors(dm);
|
|
4186
|
-
const resolvedDescriptors = descriptors.
|
|
4202
|
+
const resolvedDescriptors = descriptors.map((d) => ({
|
|
4187
4203
|
descriptor: d,
|
|
4188
4204
|
connectId: this._resolveConnectId(d)
|
|
4189
4205
|
}));
|