@onekeyfe/hwk-trezor-adapter 1.1.29-alpha.4 → 1.1.29-alpha.5
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 +72 -2
- package/dist/index.d.ts +72 -2
- package/dist/index.js +117 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +116 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IHardwareWallet, IConnector, TransportType, DeviceInfo, Response, ChainCapability, AllNetworkGetAddressParams, AllNetworkAddressResponse, TrezorDeviceSettingsParams, TrezorBrightnessParams, TrezorChangePinParams, UiResponseEvent, ChainForFingerprint, ICommonCallParams, EvmGetAddressParams, 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, ConnectorDevice } from '@onekeyfe/hwk-adapter-core';
|
|
1
|
+
import { IHardwareWallet, IConnector, TransportType, DeviceInfo, Response, ChainCapability, AllNetworkGetAddressParams, AllNetworkAddressResponse, TrezorDeviceSettingsParams, TrezorBrightnessParams, TrezorChangePinParams, UiResponseEvent, ChainForFingerprint, ICommonCallParams, EvmGetAddressParams, 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, EvmEthereumDefinitions, ConnectorDevice } from '@onekeyfe/hwk-adapter-core';
|
|
2
2
|
|
|
3
3
|
type TrezorPassphraseCallParams = {
|
|
4
4
|
passphraseState?: string;
|
|
@@ -190,6 +190,76 @@ declare class TrezorAdapter implements IHardwareWallet {
|
|
|
190
190
|
private _ensureDevicePermission;
|
|
191
191
|
}
|
|
192
192
|
|
|
193
|
+
/**
|
|
194
|
+
* Opt-in helpers for fetching Trezor Ethereum "definitions" — the SatoshiLabs-
|
|
195
|
+
* signed network/token metadata a Trezor device uses to render friendly names
|
|
196
|
+
* for chains and tokens that are NOT built into firmware.
|
|
197
|
+
*
|
|
198
|
+
* IMPORTANT — the SDK signing methods (evmSignTransaction / evmGetAddress / …)
|
|
199
|
+
* NEVER call these. A local hardware operation must not silently become a
|
|
200
|
+
* third-party network request (see PR #824 review). The caller decides whether,
|
|
201
|
+
* when, and where to fetch, then passes the result into the sign params as
|
|
202
|
+
* `ethereumDefinitions`. When omitted, the device falls back to a generic
|
|
203
|
+
* confirmation screen and signing still completes.
|
|
204
|
+
*
|
|
205
|
+
* Cross-process note: `fetchImpl` is a FUNCTION and cannot be serialized across
|
|
206
|
+
* an IPC / postMessage boundary. Call these helpers in a network-capable
|
|
207
|
+
* process and send only the resulting bytes (ArrayBuffer/hex) to the process
|
|
208
|
+
* that talks to the device. Use `baseUrl` (a string) to route through your own
|
|
209
|
+
* controlled proxy instead of hitting data.trezor.io directly.
|
|
210
|
+
*/
|
|
211
|
+
/** Default upstream (Trezor). Override with `baseUrl` to use your own proxy. */
|
|
212
|
+
declare const DEFAULT_ETHEREUM_DEFINITIONS_BASE_URL = "https://data.trezor.io/firmware/eth-definitions";
|
|
213
|
+
type FetchLike = (url: string) => Promise<{
|
|
214
|
+
status: number;
|
|
215
|
+
arrayBuffer(): Promise<ArrayBuffer>;
|
|
216
|
+
}>;
|
|
217
|
+
type FetchEthereumDefinitionsParams = {
|
|
218
|
+
chainId?: number;
|
|
219
|
+
slip44?: number;
|
|
220
|
+
contractAddress?: string;
|
|
221
|
+
baseUrl?: string;
|
|
222
|
+
fetchImpl?: FetchLike;
|
|
223
|
+
};
|
|
224
|
+
type BuildEthereumDefinitionsForPathParams = {
|
|
225
|
+
path: string;
|
|
226
|
+
baseUrl?: string;
|
|
227
|
+
fetchImpl?: FetchLike;
|
|
228
|
+
};
|
|
229
|
+
type BuildEthereumDefinitionsForSignTxParams = {
|
|
230
|
+
path: string;
|
|
231
|
+
chainId: number;
|
|
232
|
+
to?: string;
|
|
233
|
+
data?: string;
|
|
234
|
+
baseUrl?: string;
|
|
235
|
+
fetchImpl?: FetchLike;
|
|
236
|
+
};
|
|
237
|
+
/** Derive the SLIP-44 coin type (unhardened) from a BIP44-style path. */
|
|
238
|
+
declare function getSlip44FromPath(path: string): number;
|
|
239
|
+
declare function fetchEthereumDefinitions({ chainId, slip44, contractAddress, baseUrl, fetchImpl, }: FetchEthereumDefinitionsParams): Promise<EvmEthereumDefinitions>;
|
|
240
|
+
declare function buildEthereumDefinitionsForPath({ path, baseUrl, fetchImpl, }: BuildEthereumDefinitionsForPathParams): Promise<EvmEthereumDefinitions>;
|
|
241
|
+
declare function buildEthereumDefinitionsForSignTx({ path, chainId, to, data, baseUrl, fetchImpl, }: BuildEthereumDefinitionsForSignTxParams): Promise<EvmEthereumDefinitions | undefined>;
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Opt-in helper for fetching a Trezor Solana token definition. Same contract as
|
|
245
|
+
* the Ethereum helpers (see ./ethereumDefinitions): the SDK signing path NEVER
|
|
246
|
+
* calls this — the caller fetches (through its own `baseUrl` proxy if desired)
|
|
247
|
+
* and passes the bytes into `solSignTransaction` params as
|
|
248
|
+
* `additionalInfo.encodedToken`. When omitted the device shows a generic token
|
|
249
|
+
* confirmation screen and signing still completes.
|
|
250
|
+
*
|
|
251
|
+
* `fetchImpl` is a function and must not cross an IPC boundary — fetch in a
|
|
252
|
+
* network-capable process and pass only the resulting bytes.
|
|
253
|
+
*/
|
|
254
|
+
/** Default upstream (Trezor). Override with `baseUrl` to use your own proxy. */
|
|
255
|
+
declare const DEFAULT_SOLANA_TOKEN_DEFINITION_BASE_URL = "https://data.trezor.io/firmware/definitions/solana/token";
|
|
256
|
+
type FetchSolanaTokenDefinitionParams = {
|
|
257
|
+
tokenMint: string;
|
|
258
|
+
baseUrl?: string;
|
|
259
|
+
fetchImpl?: FetchLike;
|
|
260
|
+
};
|
|
261
|
+
declare function fetchSolanaTokenDefinition({ tokenMint, baseUrl, fetchImpl, }: FetchSolanaTokenDefinitionParams): Promise<ArrayBuffer | undefined>;
|
|
262
|
+
|
|
193
263
|
/**
|
|
194
264
|
* SDK-global event bus. Per-runtime singleton; hosts forward events over their
|
|
195
265
|
* own IPC when the adapter runs in an offscreen/background split.
|
|
@@ -254,4 +324,4 @@ declare function isTrezorBleServiceUuid(uuid: string): boolean;
|
|
|
254
324
|
declare function isTrezorBleDescriptor(descriptor: TrezorBleDescriptor): boolean;
|
|
255
325
|
declare function resolveTrezorBleConnectId(descriptor: TrezorBleDescriptor): string;
|
|
256
326
|
|
|
257
|
-
export { type SdkEvent, type SdkEventListener, type SdkLogEvent, TREZOR_BLE_PACKET_SIZE, TREZOR_BLE_SUPPORTED_MODELS, TREZOR_BLE_UUIDS, TREZOR_SAFE_7_MODEL, TrezorAdapter, type TrezorBleDescriptor, type TrezorBleTransport, type TrezorBleTransportFactory, type TrezorConnectedDevice, type TrezorConnectorDevice, isTrezorBleDescriptor, isTrezorBleServiceUuid, isTrezorBleSupportedModel, isTrezorSafe7BleDescriptor, isTrezorSafe7BleName, normalizeTrezorBleUuid, offSdkEvent, onSdkEvent, resolveTrezorBleConnectId };
|
|
327
|
+
export { type BuildEthereumDefinitionsForPathParams, type BuildEthereumDefinitionsForSignTxParams, DEFAULT_ETHEREUM_DEFINITIONS_BASE_URL, DEFAULT_SOLANA_TOKEN_DEFINITION_BASE_URL, type FetchEthereumDefinitionsParams, type FetchLike, type FetchSolanaTokenDefinitionParams, type SdkEvent, type SdkEventListener, type SdkLogEvent, TREZOR_BLE_PACKET_SIZE, TREZOR_BLE_SUPPORTED_MODELS, TREZOR_BLE_UUIDS, TREZOR_SAFE_7_MODEL, TrezorAdapter, type TrezorBleDescriptor, type TrezorBleTransport, type TrezorBleTransportFactory, type TrezorConnectedDevice, type TrezorConnectorDevice, buildEthereumDefinitionsForPath, buildEthereumDefinitionsForSignTx, fetchEthereumDefinitions, fetchSolanaTokenDefinition, getSlip44FromPath, isTrezorBleDescriptor, isTrezorBleServiceUuid, isTrezorBleSupportedModel, isTrezorSafe7BleDescriptor, isTrezorSafe7BleName, normalizeTrezorBleUuid, offSdkEvent, onSdkEvent, resolveTrezorBleConnectId };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IHardwareWallet, IConnector, TransportType, DeviceInfo, Response, ChainCapability, AllNetworkGetAddressParams, AllNetworkAddressResponse, TrezorDeviceSettingsParams, TrezorBrightnessParams, TrezorChangePinParams, UiResponseEvent, ChainForFingerprint, ICommonCallParams, EvmGetAddressParams, 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, ConnectorDevice } from '@onekeyfe/hwk-adapter-core';
|
|
1
|
+
import { IHardwareWallet, IConnector, TransportType, DeviceInfo, Response, ChainCapability, AllNetworkGetAddressParams, AllNetworkAddressResponse, TrezorDeviceSettingsParams, TrezorBrightnessParams, TrezorChangePinParams, UiResponseEvent, ChainForFingerprint, ICommonCallParams, EvmGetAddressParams, 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, EvmEthereumDefinitions, ConnectorDevice } from '@onekeyfe/hwk-adapter-core';
|
|
2
2
|
|
|
3
3
|
type TrezorPassphraseCallParams = {
|
|
4
4
|
passphraseState?: string;
|
|
@@ -190,6 +190,76 @@ declare class TrezorAdapter implements IHardwareWallet {
|
|
|
190
190
|
private _ensureDevicePermission;
|
|
191
191
|
}
|
|
192
192
|
|
|
193
|
+
/**
|
|
194
|
+
* Opt-in helpers for fetching Trezor Ethereum "definitions" — the SatoshiLabs-
|
|
195
|
+
* signed network/token metadata a Trezor device uses to render friendly names
|
|
196
|
+
* for chains and tokens that are NOT built into firmware.
|
|
197
|
+
*
|
|
198
|
+
* IMPORTANT — the SDK signing methods (evmSignTransaction / evmGetAddress / …)
|
|
199
|
+
* NEVER call these. A local hardware operation must not silently become a
|
|
200
|
+
* third-party network request (see PR #824 review). The caller decides whether,
|
|
201
|
+
* when, and where to fetch, then passes the result into the sign params as
|
|
202
|
+
* `ethereumDefinitions`. When omitted, the device falls back to a generic
|
|
203
|
+
* confirmation screen and signing still completes.
|
|
204
|
+
*
|
|
205
|
+
* Cross-process note: `fetchImpl` is a FUNCTION and cannot be serialized across
|
|
206
|
+
* an IPC / postMessage boundary. Call these helpers in a network-capable
|
|
207
|
+
* process and send only the resulting bytes (ArrayBuffer/hex) to the process
|
|
208
|
+
* that talks to the device. Use `baseUrl` (a string) to route through your own
|
|
209
|
+
* controlled proxy instead of hitting data.trezor.io directly.
|
|
210
|
+
*/
|
|
211
|
+
/** Default upstream (Trezor). Override with `baseUrl` to use your own proxy. */
|
|
212
|
+
declare const DEFAULT_ETHEREUM_DEFINITIONS_BASE_URL = "https://data.trezor.io/firmware/eth-definitions";
|
|
213
|
+
type FetchLike = (url: string) => Promise<{
|
|
214
|
+
status: number;
|
|
215
|
+
arrayBuffer(): Promise<ArrayBuffer>;
|
|
216
|
+
}>;
|
|
217
|
+
type FetchEthereumDefinitionsParams = {
|
|
218
|
+
chainId?: number;
|
|
219
|
+
slip44?: number;
|
|
220
|
+
contractAddress?: string;
|
|
221
|
+
baseUrl?: string;
|
|
222
|
+
fetchImpl?: FetchLike;
|
|
223
|
+
};
|
|
224
|
+
type BuildEthereumDefinitionsForPathParams = {
|
|
225
|
+
path: string;
|
|
226
|
+
baseUrl?: string;
|
|
227
|
+
fetchImpl?: FetchLike;
|
|
228
|
+
};
|
|
229
|
+
type BuildEthereumDefinitionsForSignTxParams = {
|
|
230
|
+
path: string;
|
|
231
|
+
chainId: number;
|
|
232
|
+
to?: string;
|
|
233
|
+
data?: string;
|
|
234
|
+
baseUrl?: string;
|
|
235
|
+
fetchImpl?: FetchLike;
|
|
236
|
+
};
|
|
237
|
+
/** Derive the SLIP-44 coin type (unhardened) from a BIP44-style path. */
|
|
238
|
+
declare function getSlip44FromPath(path: string): number;
|
|
239
|
+
declare function fetchEthereumDefinitions({ chainId, slip44, contractAddress, baseUrl, fetchImpl, }: FetchEthereumDefinitionsParams): Promise<EvmEthereumDefinitions>;
|
|
240
|
+
declare function buildEthereumDefinitionsForPath({ path, baseUrl, fetchImpl, }: BuildEthereumDefinitionsForPathParams): Promise<EvmEthereumDefinitions>;
|
|
241
|
+
declare function buildEthereumDefinitionsForSignTx({ path, chainId, to, data, baseUrl, fetchImpl, }: BuildEthereumDefinitionsForSignTxParams): Promise<EvmEthereumDefinitions | undefined>;
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Opt-in helper for fetching a Trezor Solana token definition. Same contract as
|
|
245
|
+
* the Ethereum helpers (see ./ethereumDefinitions): the SDK signing path NEVER
|
|
246
|
+
* calls this — the caller fetches (through its own `baseUrl` proxy if desired)
|
|
247
|
+
* and passes the bytes into `solSignTransaction` params as
|
|
248
|
+
* `additionalInfo.encodedToken`. When omitted the device shows a generic token
|
|
249
|
+
* confirmation screen and signing still completes.
|
|
250
|
+
*
|
|
251
|
+
* `fetchImpl` is a function and must not cross an IPC boundary — fetch in a
|
|
252
|
+
* network-capable process and pass only the resulting bytes.
|
|
253
|
+
*/
|
|
254
|
+
/** Default upstream (Trezor). Override with `baseUrl` to use your own proxy. */
|
|
255
|
+
declare const DEFAULT_SOLANA_TOKEN_DEFINITION_BASE_URL = "https://data.trezor.io/firmware/definitions/solana/token";
|
|
256
|
+
type FetchSolanaTokenDefinitionParams = {
|
|
257
|
+
tokenMint: string;
|
|
258
|
+
baseUrl?: string;
|
|
259
|
+
fetchImpl?: FetchLike;
|
|
260
|
+
};
|
|
261
|
+
declare function fetchSolanaTokenDefinition({ tokenMint, baseUrl, fetchImpl, }: FetchSolanaTokenDefinitionParams): Promise<ArrayBuffer | undefined>;
|
|
262
|
+
|
|
193
263
|
/**
|
|
194
264
|
* SDK-global event bus. Per-runtime singleton; hosts forward events over their
|
|
195
265
|
* own IPC when the adapter runs in an offscreen/background split.
|
|
@@ -254,4 +324,4 @@ declare function isTrezorBleServiceUuid(uuid: string): boolean;
|
|
|
254
324
|
declare function isTrezorBleDescriptor(descriptor: TrezorBleDescriptor): boolean;
|
|
255
325
|
declare function resolveTrezorBleConnectId(descriptor: TrezorBleDescriptor): string;
|
|
256
326
|
|
|
257
|
-
export { type SdkEvent, type SdkEventListener, type SdkLogEvent, TREZOR_BLE_PACKET_SIZE, TREZOR_BLE_SUPPORTED_MODELS, TREZOR_BLE_UUIDS, TREZOR_SAFE_7_MODEL, TrezorAdapter, type TrezorBleDescriptor, type TrezorBleTransport, type TrezorBleTransportFactory, type TrezorConnectedDevice, type TrezorConnectorDevice, isTrezorBleDescriptor, isTrezorBleServiceUuid, isTrezorBleSupportedModel, isTrezorSafe7BleDescriptor, isTrezorSafe7BleName, normalizeTrezorBleUuid, offSdkEvent, onSdkEvent, resolveTrezorBleConnectId };
|
|
327
|
+
export { type BuildEthereumDefinitionsForPathParams, type BuildEthereumDefinitionsForSignTxParams, DEFAULT_ETHEREUM_DEFINITIONS_BASE_URL, DEFAULT_SOLANA_TOKEN_DEFINITION_BASE_URL, type FetchEthereumDefinitionsParams, type FetchLike, type FetchSolanaTokenDefinitionParams, type SdkEvent, type SdkEventListener, type SdkLogEvent, TREZOR_BLE_PACKET_SIZE, TREZOR_BLE_SUPPORTED_MODELS, TREZOR_BLE_UUIDS, TREZOR_SAFE_7_MODEL, TrezorAdapter, type TrezorBleDescriptor, type TrezorBleTransport, type TrezorBleTransportFactory, type TrezorConnectedDevice, type TrezorConnectorDevice, buildEthereumDefinitionsForPath, buildEthereumDefinitionsForSignTx, fetchEthereumDefinitions, fetchSolanaTokenDefinition, getSlip44FromPath, isTrezorBleDescriptor, isTrezorBleServiceUuid, isTrezorBleSupportedModel, isTrezorSafe7BleDescriptor, isTrezorSafe7BleName, normalizeTrezorBleUuid, offSdkEvent, onSdkEvent, resolveTrezorBleConnectId };
|
package/dist/index.js
CHANGED
|
@@ -1082,6 +1082,115 @@ var TrezorAdapter = class _TrezorAdapter {
|
|
|
1082
1082
|
}
|
|
1083
1083
|
};
|
|
1084
1084
|
|
|
1085
|
+
// src/utils/ethereumDefinitions.ts
|
|
1086
|
+
var DEFAULT_ETHEREUM_DEFINITIONS_BASE_URL = "https://data.trezor.io/firmware/eth-definitions";
|
|
1087
|
+
function getSlip44FromPath(path) {
|
|
1088
|
+
const segments = path.trim().replace(/^m\//i, "").split("/");
|
|
1089
|
+
const coinType = segments[1];
|
|
1090
|
+
const parsed = coinType === void 0 ? NaN : Number(coinType.replace(/['hH]$/, ""));
|
|
1091
|
+
if (!Number.isFinite(parsed)) {
|
|
1092
|
+
throw new Error(`Cannot derive SLIP-44 coin type from path: ${path}`);
|
|
1093
|
+
}
|
|
1094
|
+
return parsed >= 2147483648 ? parsed - 2147483648 : parsed;
|
|
1095
|
+
}
|
|
1096
|
+
async function fetchEthereumDefinitions({
|
|
1097
|
+
chainId,
|
|
1098
|
+
slip44,
|
|
1099
|
+
contractAddress,
|
|
1100
|
+
baseUrl = DEFAULT_ETHEREUM_DEFINITIONS_BASE_URL,
|
|
1101
|
+
fetchImpl = globalThis.fetch
|
|
1102
|
+
}) {
|
|
1103
|
+
if (!chainId && !slip44) {
|
|
1104
|
+
throw new Error("fetchEthereumDefinitions requires chainId or slip44");
|
|
1105
|
+
}
|
|
1106
|
+
if (!fetchImpl) {
|
|
1107
|
+
return {};
|
|
1108
|
+
}
|
|
1109
|
+
const mode = chainId ? "chain-id" : "slip44";
|
|
1110
|
+
const id = _nullishCoalesce(chainId, () => ( slip44));
|
|
1111
|
+
const definitions = {};
|
|
1112
|
+
const network = await fetchDefinition(`${baseUrl}/${mode}/${id}/network.dat`, fetchImpl);
|
|
1113
|
+
if (network) {
|
|
1114
|
+
definitions.encodedNetwork = network;
|
|
1115
|
+
}
|
|
1116
|
+
if (contractAddress) {
|
|
1117
|
+
const token = await fetchDefinition(
|
|
1118
|
+
`${baseUrl}/${mode}/${id}/token-${stripHexPrefix(contractAddress).toLowerCase()}.dat`,
|
|
1119
|
+
fetchImpl
|
|
1120
|
+
);
|
|
1121
|
+
if (token) {
|
|
1122
|
+
definitions.encodedToken = token;
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
return definitions;
|
|
1126
|
+
}
|
|
1127
|
+
async function buildEthereumDefinitionsForPath({
|
|
1128
|
+
path,
|
|
1129
|
+
baseUrl,
|
|
1130
|
+
fetchImpl
|
|
1131
|
+
}) {
|
|
1132
|
+
return fetchEthereumDefinitions({
|
|
1133
|
+
slip44: getSlip44FromPath(path),
|
|
1134
|
+
baseUrl,
|
|
1135
|
+
fetchImpl
|
|
1136
|
+
});
|
|
1137
|
+
}
|
|
1138
|
+
async function buildEthereumDefinitionsForSignTx({
|
|
1139
|
+
path,
|
|
1140
|
+
chainId,
|
|
1141
|
+
to,
|
|
1142
|
+
data,
|
|
1143
|
+
baseUrl,
|
|
1144
|
+
fetchImpl
|
|
1145
|
+
}) {
|
|
1146
|
+
const dataHex = stripHexPrefix(_nullishCoalesce(data, () => ( "")));
|
|
1147
|
+
if (chainId === 1 && !dataHex) {
|
|
1148
|
+
return void 0;
|
|
1149
|
+
}
|
|
1150
|
+
return fetchEthereumDefinitions({
|
|
1151
|
+
chainId,
|
|
1152
|
+
slip44: getSlip44FromPath(path),
|
|
1153
|
+
contractAddress: dataHex && to ? to : void 0,
|
|
1154
|
+
baseUrl,
|
|
1155
|
+
fetchImpl
|
|
1156
|
+
});
|
|
1157
|
+
}
|
|
1158
|
+
async function fetchDefinition(url, fetchImpl) {
|
|
1159
|
+
try {
|
|
1160
|
+
const response = await fetchImpl(url);
|
|
1161
|
+
if (response.status !== 200) {
|
|
1162
|
+
return void 0;
|
|
1163
|
+
}
|
|
1164
|
+
return await response.arrayBuffer();
|
|
1165
|
+
} catch (e3) {
|
|
1166
|
+
return void 0;
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
function stripHexPrefix(value) {
|
|
1170
|
+
return value.startsWith("0x") || value.startsWith("0X") ? value.slice(2) : value;
|
|
1171
|
+
}
|
|
1172
|
+
|
|
1173
|
+
// src/utils/solanaTokenDefinition.ts
|
|
1174
|
+
var DEFAULT_SOLANA_TOKEN_DEFINITION_BASE_URL = "https://data.trezor.io/firmware/definitions/solana/token";
|
|
1175
|
+
async function fetchSolanaTokenDefinition({
|
|
1176
|
+
tokenMint,
|
|
1177
|
+
baseUrl = DEFAULT_SOLANA_TOKEN_DEFINITION_BASE_URL,
|
|
1178
|
+
fetchImpl = globalThis.fetch
|
|
1179
|
+
}) {
|
|
1180
|
+
if (!fetchImpl) {
|
|
1181
|
+
return void 0;
|
|
1182
|
+
}
|
|
1183
|
+
try {
|
|
1184
|
+
const response = await fetchImpl(`${baseUrl}/${tokenMint}.dat`);
|
|
1185
|
+
if (response.status !== 200) {
|
|
1186
|
+
return void 0;
|
|
1187
|
+
}
|
|
1188
|
+
return await response.arrayBuffer();
|
|
1189
|
+
} catch (e4) {
|
|
1190
|
+
return void 0;
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1085
1194
|
// src/constants.ts
|
|
1086
1195
|
var TREZOR_SAFE_7_MODEL = "T3W1";
|
|
1087
1196
|
var TREZOR_BLE_SUPPORTED_MODELS = [TREZOR_SAFE_7_MODEL];
|
|
@@ -1141,5 +1250,12 @@ function resolveTrezorBleConnectId(descriptor) {
|
|
|
1141
1250
|
|
|
1142
1251
|
|
|
1143
1252
|
|
|
1144
|
-
|
|
1253
|
+
|
|
1254
|
+
|
|
1255
|
+
|
|
1256
|
+
|
|
1257
|
+
|
|
1258
|
+
|
|
1259
|
+
|
|
1260
|
+
exports.DEFAULT_ETHEREUM_DEFINITIONS_BASE_URL = DEFAULT_ETHEREUM_DEFINITIONS_BASE_URL; exports.DEFAULT_SOLANA_TOKEN_DEFINITION_BASE_URL = DEFAULT_SOLANA_TOKEN_DEFINITION_BASE_URL; exports.TREZOR_BLE_PACKET_SIZE = TREZOR_BLE_PACKET_SIZE; exports.TREZOR_BLE_SUPPORTED_MODELS = TREZOR_BLE_SUPPORTED_MODELS; exports.TREZOR_BLE_UUIDS = TREZOR_BLE_UUIDS; exports.TREZOR_SAFE_7_MODEL = TREZOR_SAFE_7_MODEL; exports.TrezorAdapter = TrezorAdapter; exports.buildEthereumDefinitionsForPath = buildEthereumDefinitionsForPath; exports.buildEthereumDefinitionsForSignTx = buildEthereumDefinitionsForSignTx; exports.fetchEthereumDefinitions = fetchEthereumDefinitions; exports.fetchSolanaTokenDefinition = fetchSolanaTokenDefinition; exports.getSlip44FromPath = getSlip44FromPath; exports.isTrezorBleDescriptor = isTrezorBleDescriptor; exports.isTrezorBleServiceUuid = isTrezorBleServiceUuid; exports.isTrezorBleSupportedModel = isTrezorBleSupportedModel; exports.isTrezorSafe7BleDescriptor = isTrezorSafe7BleDescriptor; exports.isTrezorSafe7BleName = isTrezorSafe7BleName; exports.normalizeTrezorBleUuid = normalizeTrezorBleUuid; exports.offSdkEvent = offSdkEvent; exports.onSdkEvent = onSdkEvent; exports.resolveTrezorBleConnectId = resolveTrezorBleConnectId;
|
|
1145
1261
|
//# sourceMappingURL=index.js.map
|