chore(repo): mostly buildless monorepo (#11464)

* chore: buildless blockchain link

* chore: buildless connect

* chore: buildless connect-webextension

* chore: buildless transport

* chore: replace few imports from lib

* fix: icons linter error

* chore: adjust tooling to buildless setup

* fix: connect overrides

* chore: replace all imports from @trezor/*/src

* chore(lint): ban imports from @trezor/*/lib

* fix: replace imports on Linux

* chore: add safety check to replace imports script

* chore: reorder entries
This commit is contained in:
Daniel Suchý
2024-03-07 08:31:02 +01:00
committed by GitHub
parent bb7e6c766f
commit 637ad88dcf
113 changed files with 299 additions and 267 deletions

View File

@@ -223,13 +223,7 @@ module.exports = {
'error',
{
paths: [{ name: '.' }, { name: '..' }, { name: '../..' }],
patterns: [
'**/libDev/src',
'@trezor/utils/lib',
'@trezor/utils/lib/*',
'@trezor/protobuf/lib',
'@trezor/protobuf/lib/*',
],
patterns: ['@trezor/*/lib', '@trezor/*/lib/**'],
},
],
'no-restricted-syntax': [

View File

@@ -42,4 +42,5 @@ module.exports = {
// An array of regexp pattern strings that are matched against all module paths before those paths are
// to be considered 'visible' to the module loader
modulePathIgnorePatterns: ['libDev'],
moduleNameMapper: { '^uuid$': require.resolve('uuid') },
};

View File

@@ -40,4 +40,5 @@ module.exports = {
'<rootDir>/../../suite-native/test-utils/src/setupReactReanimatedMock.js',
'<rootDir>/../../suite-native/test-utils/src/atomsMock.js',
],
moduleNameMapper: { '^uuid$': require.resolve('uuid') },
};

View File

@@ -22,7 +22,7 @@
"cache": true
},
"type-check": {
"dependsOn": ["^build:lib", "^type-check", "build:lib"],
"dependsOn": ["^type-check"],
"inputs": [
"^prod",
"{workspaceRoot}/tsconfig.base.json",
@@ -32,7 +32,7 @@
"cache": true
},
"test:unit": {
"dependsOn": ["^build:lib", "build:lib"],
"dependsOn": [],
"inputs": [
"^prod",
"{workspaceRoot}/jest.config.base.js",

View File

@@ -15,7 +15,7 @@
"lint:js": "yarn g:eslint '**/*.{ts,tsx,js}'",
"test:unit": "yarn g:jest -c ../../jest.config.base.js",
"type-check": "yarn g:tsc --build",
"build:lib": "yarn g:rimraf lib && yarn g:tsc --build ./tsconfig.lib.json"
"build:lib": "yarn g:rimraf lib && yarn g:tsc --build tsconfig.lib.json && ../../scripts/replace-imports.sh ./lib"
},
"dependencies": {
"@trezor/env-utils": "workspace:*",

View File

@@ -9,7 +9,7 @@
"lint:js": "yarn g:eslint '**/*.{ts,tsx,js}'",
"type-check": "yarn g:tsc --build",
"dev": "yarn g:tsx watch ./src/index.ts",
"build": "rimraf ./lib && yarn g:tsc --build tsconfig.lib.json",
"build": "rimraf ./lib && yarn g:tsc --build tsconfig.lib.json && ../../scripts/replace-imports.sh ./lib",
"start": "node ./lib/index.js"
},
"dependencies": {

View File

@@ -3,7 +3,10 @@
"version": "1.0.14",
"license": "See LICENSE.md in repo root",
"sideEffects": false,
"main": "lib/index",
"main": "src/index.ts",
"publishConfig": {
"main": "lib/index.js"
},
"files": [
"lib/",
"!**/*.map"
@@ -11,7 +14,7 @@
"scripts": {
"lint:js": "yarn g:eslint '**/*.{ts,tsx,js}'",
"type-check": "yarn g:tsc --build",
"build:lib": "yarn g:rimraf ./lib && yarn g:tsc --build tsconfig.lib.json",
"build:lib": "yarn g:rimraf ./lib && yarn g:tsc --build tsconfig.lib.json && ../../scripts/replace-imports.sh ./lib",
"prepublishOnly": "yarn tsx ../../scripts/prepublishNPM.js",
"prepublish": "yarn tsx ../../scripts/prepublish.js"
},

View File

@@ -3,7 +3,10 @@
"version": "1.0.15",
"license": "See LICENSE.md in repo root",
"sideEffects": false,
"main": "lib/index",
"main": "src/index.ts",
"publishConfig": {
"main": "lib/index.js"
},
"files": [
"lib/",
"!**/*.map"
@@ -12,7 +15,7 @@
"lint:js": "yarn g:eslint '**/*.{ts,tsx,js}'",
"test:unit": "yarn g:jest -c ../../jest.config.base.js",
"type-check": "yarn g:tsc --build",
"build:lib": "yarn g:rimraf ./lib && yarn g:tsc --build tsconfig.lib.json",
"build:lib": "yarn g:rimraf ./lib && yarn g:tsc --build tsconfig.lib.json && ../../scripts/replace-imports.sh ./lib",
"prepublishOnly": "yarn tsx ../../scripts/prepublishNPM.js",
"prepublish": "yarn tsx ../../scripts/prepublish.js"
},

View File

@@ -16,7 +16,7 @@ import type {
AccountUtxo as BlockbookAccountUtxo,
Transaction as BlockbookTransaction,
VinVout,
} from '@trezor/blockchain-link-types/lib/blockbook';
} from '@trezor/blockchain-link-types/src/blockbook';
import { Addresses, filterTargets, enhanceVinVout, sumVinVout, transformTarget } from './utils';

View File

@@ -5,8 +5,8 @@ import type {
BlockfrostTransaction,
BlockfrostAccountInfo,
ParseAssetResult,
} from '@trezor/blockchain-link-types/lib/blockfrost';
import type { VinVout } from '@trezor/blockchain-link-types/lib/blockbook';
} from '@trezor/blockchain-link-types/src/blockfrost';
import type { VinVout } from '@trezor/blockchain-link-types/src/blockbook';
import type {
Utxo,
Transaction,
@@ -15,7 +15,7 @@ import type {
TokenInfo,
TokenTransfer,
TransferType,
} from '@trezor/blockchain-link-types/lib/common';
} from '@trezor/blockchain-link-types/src/common';
import { enhanceVinVout, filterTargets, sumVinVout, transformTarget } from './utils';

View File

@@ -1,7 +1,7 @@
import { A, D, F, pipe } from '@mobily/ts-belt';
import BigNumber from 'bignumber.js';
import { Target, TokenTransfer, Transaction } from '@trezor/blockchain-link-types/lib';
import { Target, TokenTransfer, Transaction } from '@trezor/blockchain-link-types/src';
import { arrayPartition } from '@trezor/utils';
import type {
AccountInfo,
@@ -13,8 +13,8 @@ import type {
PartiallyDecodedInstruction,
TokenDetailByMint,
PublicKey,
} from '@trezor/blockchain-link-types/lib/solana';
import type { TokenInfo } from '@trezor/blockchain-link-types/lib';
} from '@trezor/blockchain-link-types/src/solana';
import type { TokenInfo } from '@trezor/blockchain-link-types/src';
export type ApiTokenAccount = { account: AccountInfo<ParsedAccountData>; pubkey: PublicKey };

View File

@@ -1,7 +1,7 @@
import { ParsedTransactionWithMeta } from '@solana/web3.js';
import { TokenTransfer, Transaction } from '@trezor/blockchain-link-types/lib';
import { SolanaValidParsedTxWithMeta } from '@trezor/blockchain-link-types/lib/solana';
import { TokenTransfer, Transaction } from '@trezor/blockchain-link-types/src';
import { SolanaValidParsedTxWithMeta } from '@trezor/blockchain-link-types/src/solana';
import {
extractAccountBalanceDiff,

View File

@@ -1,8 +1,8 @@
import BigNumber from 'bignumber.js';
import { isNotUndefined, topologicalSort } from '@trezor/utils';
import type { Transaction, EnhancedVinVout } from '@trezor/blockchain-link-types/lib/common';
import type { VinVout } from '@trezor/blockchain-link-types/lib/blockbook';
import type { Transaction, EnhancedVinVout } from '@trezor/blockchain-link-types/src/common';
import type { VinVout } from '@trezor/blockchain-link-types/src/blockbook';
export type Addresses = ({ address: string } | string)[] | string;

View File

@@ -19,28 +19,40 @@
"blockbook",
"javascript"
],
"main": "./lib/index.js",
"files": [
"lib/",
"!lib/ui",
"!**/*.map"
],
"types": "lib/index.d.ts",
"typings": "lib/index.d.ts",
"main": "src/index.ts",
"browser": {
"socks-proxy-agent": "./lib/utils/socks-proxy-agent.js",
"ws": "./lib/utils/ws.js"
"socks-proxy-agent": "./src/utils/socks-proxy-agent.ts",
"ws": "./src/utils/ws.ts"
},
"react-native": {
"__comment__": "Hotfix for issue where RN metro bundler resolve relatives paths wrong",
"ws": "@trezor/blockchain-link/lib/utils/ws-native.js",
"socks-proxy-agent": "@trezor/blockchain-link/lib/utils/socks-proxy-agent.js"
"ws": "@trezor/blockchain-link/src/utils/ws-native.ts",
"socks-proxy-agent": "@trezor/blockchain-link/src/utils/socks-proxy-agent.ts"
},
"publishConfig": {
"main": "./lib/index.js",
"types": "lib/index.d.ts",
"typings": "lib/index.d.ts",
"browser": {
"socks-proxy-agent": "./lib/utils/socks-proxy-agent.js",
"ws": "./lib/utils/ws.js"
},
"react-native": {
"__comment__": "Hotfix for issue where RN metro bundler resolve relatives paths wrong",
"ws": "@trezor/blockchain-link/lib/utils/ws-native.js",
"socks-proxy-agent": "@trezor/blockchain-link/lib/utils/socks-proxy-agent.js"
}
},
"scripts": {
"dev": "webpack serve --config ./webpack/dev.js",
"dev:electrum": "yarn g:tsx watch ./src/workers/electrum/devrun.ts",
"dev:module": "USE_MODULES=true webpack serve --config ./webpack/dev.js",
"build:lib": "yarn g:rimraf lib && yarn g:tsc --build ./tsconfig.lib.json",
"build:lib": "yarn g:rimraf lib && yarn g:tsc --build tsconfig.lib.json && ../../scripts/replace-imports.sh ./lib",
"build:workers": "yarn g:rimraf build && yarn build:workers-web && yarn build:workers-module",
"build:workers-web": "webpack --config ./webpack/workers.web.js",
"build:workers-module": "webpack --config ./webpack/workers.module.js",

View File

@@ -1,11 +1,11 @@
import { createDeferred, createDeferredManager, TypedEmitter } from '@trezor/utils';
import { CustomError } from '@trezor/blockchain-link-types/lib/constants/errors';
import { MESSAGES, RESPONSES } from '@trezor/blockchain-link-types/lib/constants';
import { CustomError } from '@trezor/blockchain-link-types/src/constants/errors';
import { MESSAGES, RESPONSES } from '@trezor/blockchain-link-types/src/constants';
import { Throttler } from './workers/throttler';
import type { BlockchainSettings } from '@trezor/blockchain-link-types';
import type * as ResponseTypes from '@trezor/blockchain-link-types/lib/responses';
import type * as MessageTypes from '@trezor/blockchain-link-types/lib/messages';
import type { Events } from '@trezor/blockchain-link-types/lib/events';
import type * as ResponseTypes from '@trezor/blockchain-link-types/src/responses';
import type * as MessageTypes from '@trezor/blockchain-link-types/src/messages';
import type { Events } from '@trezor/blockchain-link-types/src/events';
const workerWrapper = (factory: BlockchainSettings['worker']): Worker | Promise<Worker> => {
if (typeof factory === 'function') return factory();
@@ -358,13 +358,13 @@ export type BlockchainLinkResponse<T extends keyof BlockchainLinkInterface> =
: never;
// reexport types
export type { Message } from '@trezor/blockchain-link-types/lib/messages';
export type { Message } from '@trezor/blockchain-link-types/src/messages';
export type {
Response,
BlockEvent,
NotificationEvent,
FiatRatesEvent,
} from '@trezor/blockchain-link-types/lib/responses';
} from '@trezor/blockchain-link-types/src/responses';
export type {
Address,
AccountAddresses,
@@ -382,4 +382,4 @@ export type {
Transaction,
TransactionDetail,
Utxo,
} from '@trezor/blockchain-link-types/lib/common';
} from '@trezor/blockchain-link-types/src/common';

View File

@@ -3,7 +3,7 @@ import { createDeferred } from '@trezor/utils';
import { createDeferredManager } from '@trezor/utils';
import { TypedEmitter } from '@trezor/utils';
import { CustomError } from '@trezor/blockchain-link-types/lib/constants/errors';
import { CustomError } from '@trezor/blockchain-link-types/src/constants/errors';
interface Subscription<T> {
id: string;

View File

@@ -6,12 +6,12 @@
// new BlockchainLink({ worker: () => new BlockchainLinkModule() });
import SocksProxyAgent from 'socks-proxy-agent';
import { CustomError } from '@trezor/blockchain-link-types/lib/constants/errors';
import { CustomError } from '@trezor/blockchain-link-types/src/constants/errors';
import { WorkerState } from './state';
import { prioritizeEndpoints } from './utils';
import { MESSAGES, RESPONSES } from '@trezor/blockchain-link-types/lib/constants';
import { MESSAGES, RESPONSES } from '@trezor/blockchain-link-types/src/constants';
import type { Response, BlockchainSettings } from '@trezor/blockchain-link-types';
import type { Message } from '@trezor/blockchain-link-types/lib/messages';
import type { Message } from '@trezor/blockchain-link-types/src/messages';
// self is not declared in TS Webworker lib typings
declare const self: { postMessage: (...args: any[]) => any };

View File

@@ -1,16 +1,16 @@
import { CustomError } from '@trezor/blockchain-link-types/lib/constants/errors';
import { MESSAGES, RESPONSES } from '@trezor/blockchain-link-types/lib/constants';
import { CustomError } from '@trezor/blockchain-link-types/src/constants/errors';
import { MESSAGES, RESPONSES } from '@trezor/blockchain-link-types/src/constants';
import { BaseWorker, CONTEXT, ContextType } from '../baseWorker';
import { BlockbookAPI } from './websocket';
import * as utils from '@trezor/blockchain-link-utils/lib/blockbook';
import * as utils from '@trezor/blockchain-link-utils/src/blockbook';
import type { Response, SubscriptionAccountInfo } from '@trezor/blockchain-link-types';
import type {
AddressNotification,
BlockNotification,
FiatRatesNotification,
MempoolTransactionNotification,
} from '@trezor/blockchain-link-types/lib/blockbook';
import type * as MessageTypes from '@trezor/blockchain-link-types/lib/messages';
} from '@trezor/blockchain-link-types/src/blockbook';
import type * as MessageTypes from '@trezor/blockchain-link-types/src/messages';
type Context = ContextType<BlockbookAPI>;
type Request<T> = T & Context;

View File

@@ -1,6 +1,6 @@
import WebSocket from 'ws';
import { CustomError } from '@trezor/blockchain-link-types/lib/constants/errors';
import { CustomError } from '@trezor/blockchain-link-types/src/constants/errors';
import type {
BlockNotification,
MempoolTransactionNotification,
@@ -8,17 +8,17 @@ import type {
Send,
FiatRatesNotification,
FilterRequestParams,
} from '@trezor/blockchain-link-types/lib/blockbook';
} from '@trezor/blockchain-link-types/src/blockbook';
import type {
GetFiatRatesForTimestamps,
GetFiatRatesTickersList,
GetCurrentFiatRates,
} from '@trezor/blockchain-link-types/lib/messages';
} from '@trezor/blockchain-link-types/src/messages';
import type {
AccountInfoParams,
EstimateFeeParams,
AccountBalanceHistoryParams,
} from '@trezor/blockchain-link-types/lib/params';
} from '@trezor/blockchain-link-types/src/params';
import { BaseWebsocket } from '../baseWebsocket';

View File

@@ -1,19 +1,19 @@
import { CustomError } from '@trezor/blockchain-link-types/lib/constants/errors';
import { MESSAGES, RESPONSES } from '@trezor/blockchain-link-types/lib/constants';
import { CustomError } from '@trezor/blockchain-link-types/src/constants/errors';
import { MESSAGES, RESPONSES } from '@trezor/blockchain-link-types/src/constants';
import { BaseWorker, CONTEXT, ContextType } from '../baseWorker';
import { BlockfrostAPI } from './websocket';
import {
transformUtxos,
transformAccountInfo,
transformTransaction,
} from '@trezor/blockchain-link-utils/lib/blockfrost';
import type { SubscriptionAccountInfo } from '@trezor/blockchain-link-types/lib/common';
} from '@trezor/blockchain-link-utils/src/blockfrost';
import type { SubscriptionAccountInfo } from '@trezor/blockchain-link-types/src/common';
import type { Response } from '@trezor/blockchain-link-types';
import type {
BlockfrostTransaction,
BlockContent,
} from '@trezor/blockchain-link-types/lib/blockfrost';
import type * as MessageTypes from '@trezor/blockchain-link-types/lib/messages';
} from '@trezor/blockchain-link-types/src/blockfrost';
import type * as MessageTypes from '@trezor/blockchain-link-types/src/messages';
type Context = ContextType<BlockfrostAPI>;
type Request<T> = T & Context;

View File

@@ -4,12 +4,12 @@ import type {
Send,
BlockContent,
BlockfrostTransaction,
} from '@trezor/blockchain-link-types/lib/blockfrost';
} from '@trezor/blockchain-link-types/src/blockfrost';
import type {
AccountInfoParams,
EstimateFeeParams,
AccountBalanceHistoryParams,
} from '@trezor/blockchain-link-types/lib/params';
} from '@trezor/blockchain-link-types/src/params';
import { BaseWebsocket } from '../baseWebsocket';

View File

@@ -1,5 +1,5 @@
import { ElectrumClient } from './electrum';
import { Status } from '@trezor/blockchain-link-types/lib/electrum';
import { Status } from '@trezor/blockchain-link-types/src/electrum';
type Cache = {
[descriptor: string]: [Status, any];

View File

@@ -1,5 +1,5 @@
import { Network, networks } from '@trezor/utxo-lib';
import { ElectrumAPI, BlockHeader, Version } from '@trezor/blockchain-link-types/lib/electrum';
import { ElectrumAPI, BlockHeader, Version } from '@trezor/blockchain-link-types/src/electrum';
import { JsonRpcClientOptions } from './json-rpc';
import { BatchingJsonRpcClient } from './batching';
import type { ISocket } from '../sockets/interface';

View File

@@ -1,5 +1,5 @@
import { CustomError } from '@trezor/blockchain-link-types/lib/constants/errors';
import { MESSAGES, RESPONSES } from '@trezor/blockchain-link-types/lib/constants';
import { CustomError } from '@trezor/blockchain-link-types/src/constants/errors';
import { MESSAGES, RESPONSES } from '@trezor/blockchain-link-types/src/constants';
import { BaseWorker, CONTEXT, ContextType } from '../baseWorker';
import * as M from './methods';
import * as L from './listeners';
@@ -7,7 +7,7 @@ import { createSocket } from './sockets';
import { CachingElectrumClient } from './client/caching';
import type { ElectrumClient } from './client/electrum';
import type { Response } from '@trezor/blockchain-link-types';
import { Message } from '@trezor/blockchain-link-types/lib/messages';
import { Message } from '@trezor/blockchain-link-types/src/messages';
type BlockListener = ReturnType<typeof L.blockListener>;
type TxListener = ReturnType<typeof L.txListener>;

View File

@@ -1,8 +1,8 @@
import { throwError } from '@trezor/utils';
import { RESPONSES } from '@trezor/blockchain-link-types/lib/constants';
import { RESPONSES } from '@trezor/blockchain-link-types/src/constants';
import { blockheaderToBlockhash } from '../utils';
import type { BaseWorker } from '../../baseWorker';
import type { BlockHeader, ElectrumAPI } from '@trezor/blockchain-link-types/lib/electrum';
import type { BlockHeader, ElectrumAPI } from '@trezor/blockchain-link-types/src/electrum';
export const blockListener = (worker: BaseWorker<ElectrumAPI>) => {
const { state } = worker;

View File

@@ -1,14 +1,14 @@
import { throwError } from '@trezor/utils';
import { RESPONSES } from '@trezor/blockchain-link-types/lib/constants';
import { RESPONSES } from '@trezor/blockchain-link-types/src/constants';
import { createAddressManager, getTransactions } from '../utils';
import { transformTransaction } from '../../../../../blockchain-link-utils/lib/blockbook';
import { transformTransaction } from '@trezor/blockchain-link-utils/src/blockbook';
import type { BaseWorker } from '../../baseWorker';
import type {
ElectrumAPI,
HistoryTx,
StatusChange,
} from '@trezor/blockchain-link-types/lib/electrum';
import type { Subscribe, Unsubscribe } from '@trezor/blockchain-link-types/lib/messages';
} from '@trezor/blockchain-link-types/src/electrum';
import type { Subscribe, Unsubscribe } from '@trezor/blockchain-link-types/src/messages';
type Payload<T extends { type: string; payload: any }> = Extract<
T['payload'],

View File

@@ -1,6 +1,6 @@
import { Api, btcToSat } from '../utils';
import type { EstimateFee as Req } from '@trezor/blockchain-link-types/lib/messages';
import type { EstimateFee as Res } from '@trezor/blockchain-link-types/lib/responses';
import type { EstimateFee as Req } from '@trezor/blockchain-link-types/src/messages';
import type { EstimateFee as Res } from '@trezor/blockchain-link-types/src/responses';
const estimateFee: Api<Req, Res> = (client, payload) =>
Promise.all(

View File

@@ -2,11 +2,11 @@ import BigNumber from 'bignumber.js';
import { discovery } from '@trezor/utxo-lib';
import { sumVinVout } from '@trezor/blockchain-link-utils';
import { Api, tryGetScripthash, getTransactions, discoverAddress, AddressHistory } from '../utils';
import { transformTransaction } from '@trezor/blockchain-link-utils/lib/blockbook';
import type { GetAccountBalanceHistory as Req } from '@trezor/blockchain-link-types/lib/messages';
import type { GetAccountBalanceHistory as Res } from '@trezor/blockchain-link-types/lib/responses';
import type { AccountAddresses, Transaction } from '@trezor/blockchain-link-types/lib/common';
import type { HistoryTx } from '@trezor/blockchain-link-types/lib/electrum';
import { transformTransaction } from '@trezor/blockchain-link-utils/src/blockbook';
import type { GetAccountBalanceHistory as Req } from '@trezor/blockchain-link-types/src/messages';
import type { GetAccountBalanceHistory as Res } from '@trezor/blockchain-link-types/src/responses';
import type { AccountAddresses, Transaction } from '@trezor/blockchain-link-types/src/common';
import type { HistoryTx } from '@trezor/blockchain-link-types/src/electrum';
const transformAddress = (addr: AddressHistory) => ({
address: addr.address,

View File

@@ -1,11 +1,11 @@
import { discovery } from '@trezor/utxo-lib';
import { sortTxsFromLatest } from '@trezor/blockchain-link-utils';
import { Api, tryGetScripthash, discoverAddress, AddressHistory, getTransactions } from '../utils';
import { transformTransaction } from '@trezor/blockchain-link-utils/lib/blockbook';
import type { ElectrumAPI } from '@trezor/blockchain-link-types/lib/electrum';
import type { GetAccountInfo as Req } from '@trezor/blockchain-link-types/lib/messages';
import type { GetAccountInfo as Res } from '@trezor/blockchain-link-types/lib/responses';
import type { VinVout } from '@trezor/blockchain-link-types/lib/blockbook';
import { transformTransaction } from '@trezor/blockchain-link-utils/src/blockbook';
import type { ElectrumAPI } from '@trezor/blockchain-link-types/src/electrum';
import type { GetAccountInfo as Req } from '@trezor/blockchain-link-types/src/messages';
import type { GetAccountInfo as Res } from '@trezor/blockchain-link-types/src/responses';
import type { VinVout } from '@trezor/blockchain-link-types/src/blockbook';
import type { Address, Transaction } from '@trezor/blockchain-link-types';
// const PAGE_DEFAULT = 0;

View File

@@ -1,9 +1,9 @@
import { throwError } from '@trezor/utils';
import { discovery } from '@trezor/utxo-lib';
import { Api, tryGetScripthash, discoverAddress } from '../utils';
import type { GetAccountUtxo as Req } from '@trezor/blockchain-link-types/lib/messages';
import type { GetAccountUtxo as Res } from '@trezor/blockchain-link-types/lib/responses';
import type { Utxo } from '@trezor/blockchain-link-types/lib/electrum';
import type { GetAccountUtxo as Req } from '@trezor/blockchain-link-types/src/messages';
import type { GetAccountUtxo as Res } from '@trezor/blockchain-link-types/src/responses';
import type { Utxo } from '@trezor/blockchain-link-types/src/electrum';
const transformUtxo =
(currentHeight: number, addressInfo: { address?: string; path?: string } = {}) =>

View File

@@ -1,6 +1,6 @@
import { Api, blockheaderToBlockhash } from '../utils';
import type { GetBlockHash as Req } from '@trezor/blockchain-link-types/lib/messages';
import type { GetBlockHash as Res } from '@trezor/blockchain-link-types/lib/responses';
import type { GetBlockHash as Req } from '@trezor/blockchain-link-types/src/messages';
import type { GetBlockHash as Res } from '@trezor/blockchain-link-types/src/responses';
const getBlockHash: Api<Req, Res> = async (client, payload) => {
const blockheader = await client.request('blockchain.block.header', payload);

View File

@@ -1,7 +1,7 @@
import { throwError } from '@trezor/utils';
import { Api, blockheaderToBlockhash } from '../utils';
import type { GetInfo as Req } from '@trezor/blockchain-link-types/lib/messages';
import type { GetInfo as Res } from '@trezor/blockchain-link-types/lib/responses';
import type { GetInfo as Req } from '@trezor/blockchain-link-types/src/messages';
import type { GetInfo as Res } from '@trezor/blockchain-link-types/src/responses';
const getInfo: Api<Req, Res> = client => {
const {

View File

@@ -1,7 +1,7 @@
import { Api, getTransactions } from '../utils';
import { transformTransaction } from '@trezor/blockchain-link-utils/lib/blockbook';
import type { GetTransaction as Req } from '@trezor/blockchain-link-types/lib/messages';
import type { GetTransaction as Res } from '@trezor/blockchain-link-types/lib/responses';
import { transformTransaction } from '@trezor/blockchain-link-utils/src/blockbook';
import type { GetTransaction as Req } from '@trezor/blockchain-link-types/src/messages';
import type { GetTransaction as Res } from '@trezor/blockchain-link-types/src/responses';
const getTransaction: Api<Req, Res> = async (client, payload) => {
const [tx] = await getTransactions(client, [{ tx_hash: payload, height: -1 }]);

View File

@@ -1,6 +1,6 @@
import { Api } from '../utils';
import type { PushTransaction as Req } from '@trezor/blockchain-link-types/lib/messages';
import type { PushTransaction as Res } from '@trezor/blockchain-link-types/lib/responses';
import type { PushTransaction as Req } from '@trezor/blockchain-link-types/src/messages';
import type { PushTransaction as Res } from '@trezor/blockchain-link-types/src/responses';
const pushTransaction: Api<Req, Res> = async (client, payload) => {
const res = await client.request('blockchain.transaction.broadcast', payload);

View File

@@ -1,5 +1,5 @@
import { parseElectrumUrl } from '@trezor/utils';
import { CustomError } from '@trezor/blockchain-link-types/lib/constants/errors';
import { CustomError } from '@trezor/blockchain-link-types/src/constants/errors';
import { TcpSocket } from './tcp';
import { TlsSocket } from './tls';
import { TorSocket } from './tor';

View File

@@ -1,7 +1,7 @@
import { isNotUndefined, arrayDistinct, objectPartition } from '@trezor/utils';
import { addressToScripthash } from './transform';
import type { Network } from '@trezor/utxo-lib';
import type { AccountAddresses, SubscriptionAccountInfo } from '@trezor/blockchain-link-types/lib';
import type { AccountAddresses, SubscriptionAccountInfo } from '@trezor/blockchain-link-types/src';
type AddressMap = { [address: string]: string };
type AccountMap = { [descriptor: string]: AccountAddresses };

View File

@@ -1,5 +1,5 @@
import { addressToScripthash } from './transform';
import type { ElectrumAPI, HistoryTx } from '@trezor/blockchain-link-types/lib/electrum';
import type { ElectrumAPI, HistoryTx } from '@trezor/blockchain-link-types/src/electrum';
export type AddressHistory = {
address: string;

View File

@@ -1,5 +1,5 @@
import type { Response } from '@trezor/blockchain-link-types/lib';
import type { ElectrumAPI } from '@trezor/blockchain-link-types/lib/electrum';
import type { Response } from '@trezor/blockchain-link-types/src';
import type { ElectrumAPI } from '@trezor/blockchain-link-types/src/electrum';
export * from './addressManager';
export * from './discovery';

View File

@@ -1,6 +1,6 @@
import { arrayToDictionary, arrayDistinct } from '@trezor/utils';
import { btcToSat } from './transform';
import type { Transaction as BlockbookTransaction } from '@trezor/blockchain-link-types/lib/blockbook';
import type { Transaction as BlockbookTransaction } from '@trezor/blockchain-link-types/src/blockbook';
import type {
ElectrumAPI,
TransactionVerbose,
@@ -8,7 +8,7 @@ import type {
TxCoinbase,
TxOut,
HistoryTx,
} from '@trezor/blockchain-link-types/lib/electrum';
} from '@trezor/blockchain-link-types/src/electrum';
const transformOpReturn = (hex: string) => {
const [, _len, data] = hex.match(/^6a(?:4c)?([0-9a-f]{2})([0-9a-f]*)$/i) ?? [];

View File

@@ -1,12 +1,12 @@
import { RippleAPI, APIOptions } from 'ripple-lib';
import { RippleError } from 'ripple-lib/dist/npm/common/errors';
import BigNumber from 'bignumber.js';
import { CustomError } from '@trezor/blockchain-link-types/lib/constants/errors';
import { MESSAGES, RESPONSES } from '@trezor/blockchain-link-types/lib/constants';
import { CustomError } from '@trezor/blockchain-link-types/src/constants/errors';
import { MESSAGES, RESPONSES } from '@trezor/blockchain-link-types/src/constants';
import { BaseWorker, CONTEXT, ContextType } from '../baseWorker';
import * as utils from '@trezor/blockchain-link-utils/lib/ripple';
import * as utils from '@trezor/blockchain-link-utils/src/ripple';
import type { Response, SubscriptionAccountInfo, AccountInfo } from '@trezor/blockchain-link-types';
import type * as MessageTypes from '@trezor/blockchain-link-types/lib/messages';
import type * as MessageTypes from '@trezor/blockchain-link-types/src/messages';
type Context = ContextType<RippleAPI>;
type Request<T> = T & Context;

View File

@@ -9,18 +9,18 @@ import type {
SolanaValidParsedTxWithMeta,
ParsedTransactionWithMeta,
SolanaTokenAccountInfo,
} from '@trezor/blockchain-link-types/lib/solana';
import type * as MessageTypes from '@trezor/blockchain-link-types/lib/messages';
import { CustomError } from '@trezor/blockchain-link-types/lib/constants/errors';
} from '@trezor/blockchain-link-types/src/solana';
import type * as MessageTypes from '@trezor/blockchain-link-types/src/messages';
import { CustomError } from '@trezor/blockchain-link-types/src/constants/errors';
import { BaseWorker, ContextType, CONTEXT } from '../baseWorker';
import { MESSAGES, RESPONSES } from '@trezor/blockchain-link-types/lib/constants';
import { MESSAGES, RESPONSES } from '@trezor/blockchain-link-types/src/constants';
import { Connection, Message, PublicKey } from '@solana/web3.js';
import { solanaUtils } from '@trezor/blockchain-link-utils';
import {
transformTokenInfo,
TOKEN_PROGRAM_PUBLIC_KEY,
} from '@trezor/blockchain-link-utils/lib/solana';
} from '@trezor/blockchain-link-utils/src/solana';
import { TOKEN_ACCOUNT_LAYOUT } from './tokenUtils';
export type SolanaAPI = Connection;

View File

@@ -1,4 +1,4 @@
import { CustomError } from '@trezor/blockchain-link-types/lib/constants/errors';
import { CustomError } from '@trezor/blockchain-link-types/src/constants/errors';
import type { SubscriptionAccountInfo } from '@trezor/blockchain-link-types';
export class WorkerState {

View File

@@ -1,5 +1,5 @@
import { BackendWebsocketServerMock } from '@trezor/e2e-utils';
import BlockchainLink from '../../lib';
import BlockchainLink from '../../src';
import { blockbookWorkerFactory, blockbookModuleFactory } from './worker';
const backends = [

View File

@@ -1,5 +1,5 @@
import { BackendWebsocketServerMock } from '@trezor/e2e-utils';
import BlockchainLink from '../../lib';
import BlockchainLink from '../../src';
import { blockfrostWorkerFactory, blockfrostModuleFactory } from './worker';
const backends = [

View File

@@ -1,5 +1,5 @@
import { BackendWebsocketServerMock } from '@trezor/e2e-utils';
import BlockchainLink from '../../lib';
import BlockchainLink from '../../src';
import {
rippleWorkerFactory,
rippleModuleFactory,

View File

@@ -1,7 +1,7 @@
import ElectrumWorker from '../../lib/workers/electrum';
import type { Message } from '@trezor/blockchain-link-types/lib/messages';
import type { Response } from '@trezor/blockchain-link-types/lib/responses';
import { GET_ACCOUNT_INFO, HANDSHAKE } from '@trezor/blockchain-link-types/lib/constants/messages';
import ElectrumWorker from '../../src/workers/electrum';
import type { Message } from '@trezor/blockchain-link-types/src/messages';
import type { Response } from '@trezor/blockchain-link-types/src/responses';
import { GET_ACCOUNT_INFO, HANDSHAKE } from '@trezor/blockchain-link-types/src/constants/messages';
const TCP_CONFIG = '127.0.0.1:50001:t';
const NETWORK = 'REGTEST';

View File

@@ -1,5 +1,5 @@
import { BackendWebsocketServerMock } from '@trezor/e2e-utils';
import BlockchainLink from '../../lib';
import BlockchainLink from '../../src';
import { rippleWorkerFactory, rippleModuleFactory } from './worker';
const backends = [

View File

@@ -1,6 +1,6 @@
import { AccountInfoParams } from '@trezor/blockchain-link-types';
import BlockchainLink from '../../lib';
import SolanaWorker, { SolanaAPI } from '../../lib/workers/solana';
import BlockchainLink from '../../src';
import SolanaWorker, { SolanaAPI } from '../../src/workers/solana';
const id = 79;
const descriptor = '2MLmmoKgCrxVEzMeGatnjdABYS5RXsQSNikcWrmnvQna';

View File

@@ -9,12 +9,12 @@ export const rippleWorkerFactory = () => {
if (typeof Worker === 'undefined') {
return new TinyWorker(() => {
// eslint-disable-next-line import/no-extraneous-dependencies
require('@trezor/blockchain-link/lib/workers/ripple');
require('@trezor/blockchain-link/src/workers/ripple');
});
// return new TinyWorker('./build/module/blockbook-worker.js');
// return new TinyWorker(() => {
// require('@babel/register')({ cache: true });
// require('../../../lib/workers/ripple/index.js');
// require('../../../src/workers/ripple/index.js');
// });
}
@@ -27,12 +27,12 @@ export const blockbookWorkerFactory = () => {
if (typeof Worker === 'undefined') {
return new TinyWorker(() => {
// eslint-disable-next-line import/no-extraneous-dependencies
require('@trezor/blockchain-link/lib/workers/blockbook');
require('@trezor/blockchain-link/src/workers/blockbook');
});
// return new TinyWorker('./build/module/blockbook-worker.js');
// return new TinyWorker(() => {
// require('@babel/register')({ cache: true });
// require('../../../lib/workers/blockbook/index.js');
// require('../../../src/workers/blockbook/index.js');
// });
}
@@ -45,7 +45,7 @@ export const blockfrostWorkerFactory = () => {
if (typeof Worker === 'undefined') {
return new TinyWorker(() => {
// eslint-disable-next-line import/no-extraneous-dependencies
require('@trezor/blockchain-link/lib/workers/blockfrost');
require('@trezor/blockchain-link/src/workers/blockfrost');
});
// return new TinyWorker('./build/module/blockfrost-worker.js');
}

View File

@@ -1,4 +1,4 @@
import { CustomError } from '@trezor/blockchain-link-types/lib/constants/errors';
import { CustomError } from '@trezor/blockchain-link-types/src/constants/errors';
describe('Custom errors', () => {
it('Error with predefined code and predefined message', () => {

View File

@@ -1,6 +1,6 @@
import { scheduleAction, arrayShuffle, urlToOnion } from '@trezor/utils';
import { TypedEmitter } from '@trezor/utils';
import type { BlockbookAPI } from '@trezor/blockchain-link/lib/workers/blockbook/websocket';
import type { BlockbookAPI } from '@trezor/blockchain-link/src/workers/blockbook/websocket';
import { RequestOptions, resetIdentityCircuit } from '../utils/http';
import type {

View File

@@ -1,4 +1,4 @@
import { BlockbookAPI } from '@trezor/blockchain-link/lib/workers/blockbook/websocket';
import { BlockbookAPI } from '@trezor/blockchain-link/src/workers/blockbook/websocket';
import { HTTP_REQUEST_TIMEOUT, WS_CONNECT_TIMEOUT } from '../constants';
import { resetIdentityCircuit } from '../utils/http';

View File

@@ -1,6 +1,6 @@
import { arrayDistinct } from '@trezor/utils';
import { deriveAddresses as deriveNewAddresses, Network } from '@trezor/utxo-lib';
import { getAddressType } from '@trezor/utxo-lib/lib/address';
import { getAddressType } from '@trezor/utxo-lib/src/address';
import type { VinVout, PrederivedAddress } from '../types/backend';

View File

@@ -1,4 +1,4 @@
import { transformTransaction } from '@trezor/blockchain-link-utils/lib/blockbook';
import { transformTransaction } from '@trezor/blockchain-link-utils/src/blockbook';
import type { BroadcastedTransactionDetails } from '../types';
import type { Transaction, AccountAddresses } from '../types/backend';

View File

@@ -1,6 +1,6 @@
import type { Network } from '@trezor/utxo-lib';
import { sortTxsFromLatest } from '@trezor/blockchain-link-utils';
import { sumAddressValues } from '@trezor/blockchain-link/lib/workers/electrum/methods/getAccountInfo';
import { sumAddressValues } from '@trezor/blockchain-link/src/workers/electrum/methods/getAccountInfo';
import { isTxConfirmed, doesTxContainAddress } from './backendUtils';
import type {

View File

@@ -1,5 +1,5 @@
import { createCooldown } from '@trezor/utils';
import { transformTransaction } from '@trezor/blockchain-link-utils/lib/blockbook';
import { transformTransaction } from '@trezor/blockchain-link-utils/src/blockbook';
import { getMultiFilter } from './filters';
import { doesTxContainAddress } from './backendUtils';

View File

@@ -11,7 +11,7 @@ import type {
Transaction as BlockbookTransaction,
VinVout,
FilterResponse,
} from '@trezor/blockchain-link-types/lib/blockbook';
} from '@trezor/blockchain-link-types/src/blockbook';
import type { CoinjoinBackendClient } from '../backend/CoinjoinBackendClient';
import type { MempoolController } from '../backend/CoinjoinMempoolController';

View File

@@ -1,4 +1,4 @@
import { BlockbookAPI } from '@trezor/blockchain-link/lib/workers/blockbook/websocket';
import { BlockbookAPI } from '@trezor/blockchain-link/src/workers/blockbook/websocket';
import { blockbookUtils } from '@trezor/blockchain-link-utils';
import { CoinjoinBackend } from '../../src';

View File

@@ -14,7 +14,7 @@
"scripts": {
"lint:js": "yarn g:eslint '**/*.{ts,tsx,js}'",
"type-check": "yarn g:tsc --build",
"build:lib": "yarn g:rimraf lib && yarn g:tsc --build ./tsconfig.lib.json"
"build:lib": "yarn g:rimraf lib && yarn g:tsc --build tsconfig.lib.json && ../../scripts/replace-imports.sh ./lib"
},
"dependencies": {
"@trezor/analytics": "workspace:*"

View File

@@ -33,7 +33,7 @@
"scripts": {
"lint:js": "yarn g:eslint '**/*.{ts,tsx,js}'",
"test:unit": "yarn g:jest",
"build:lib": "yarn g:rimraf lib && yarn g:tsc --build ./tsconfig.lib.json",
"build:lib": "yarn g:rimraf lib && yarn g:tsc --build tsconfig.lib.json && ../../scripts/replace-imports.sh ./lib",
"type-check": "yarn g:tsc --build tsconfig.json",
"prepublishOnly": "yarn tsx ../../scripts/prepublishNPM.js",
"prepublish": "yarn tsx ../../scripts/prepublish.js"

View File

@@ -8,7 +8,7 @@ import { TypedEmitter } from '@trezor/utils';
import { scheduleAction } from '@trezor/utils';
// TODO: so logger should be probably moved to connect common, or this file should be moved to connect
// import type { Log } from '@trezor/connect/lib/utils/debug';
// import type { Log } from '@trezor/connect/src/utils/debug';
type Log = {
log: (...args: any[]) => void;
error: (...args: any[]) => void;

View File

@@ -1,7 +1,7 @@
import {
CardanoNativeScriptHashDisplayFormat,
CardanoTxSigningMode,
} from '@trezor/protobuf/lib/messages-schema';
} from '@trezor/protobuf/src/messages-schema';
export const cardanoDerivationType = {
name: 'derivationType',

View File

@@ -1,4 +1,4 @@
import { CardanoNativeScriptType } from '@trezor/protobuf/lib/messages-schema';
import { CardanoNativeScriptType } from '@trezor/protobuf/src/messages-schema';
import { cardanoDerivationType, cardanoNativeScriptHashDisplayFormat } from './common';

View File

@@ -169,11 +169,11 @@ const config: webpack.Configuration = {
'process.env.__TREZOR_CONNECT_SRC': JSON.stringify(process.env.__TREZOR_CONNECT_SRC),
'process.env.COMMIT_HASH': JSON.stringify(commitHash),
}),
// Imports from @trezor/connect-web in @trezor/connect-explorer package need to be replaced by imports from @trezor/connect-webextension/lib/proxy
// Imports from @trezor/connect-web in @trezor/connect-explorer package need to be replaced by imports from @trezor/connect-webextension/src/proxy
// in order to work properly with @trezor/connect-webextension service worker.
new webpack.NormalModuleReplacementPlugin(
/@trezor\/connect-web$/,
'@trezor/connect-webextension/lib/proxy',
'@trezor/connect-webextension/src/proxy',
),
],
};

View File

@@ -4,8 +4,8 @@
"private": true,
"scripts": {
"lint:js": "yarn g:eslint '**/*.{ts,tsx,js}'",
"build:iframe": "TS_NODE_PROJECT=\"tsconfig.json\" yarn webpack --config ./webpack/prod.webpack.config.ts",
"build:core-module": "TS_NODE_PROJECT=\"tsconfig.json\" yarn webpack --config ./webpack/core.webpack.config.ts",
"build:iframe": "TS_NODE_PROJECT=\"tsconfig.json\" yarn webpack --config ./webpack/prod.webpack.config.ts --stats-children",
"build:core-module": "TS_NODE_PROJECT=\"tsconfig.json\" yarn webpack --config ./webpack/core.webpack.config.ts --stats-children",
"build": "yarn g:rimraf build && yarn build:iframe && yarn build:core-module",
"___NOTE__": "iframe build is one of the prerequisites of suite-web. build:lib script provides it together with other libraries",
"build:lib": "yarn build",

View File

@@ -20,16 +20,6 @@ export const config: webpack.Configuration = {
mode: process.env.NODE_ENV === 'production' ? 'production' : 'development',
module: {
rules: [
{
test: /\.(js|ts)$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-typescript'],
},
},
},
{
test: (input: string) => input.includes('background-sharedworker'),
loader: 'worker-loader',
@@ -80,6 +70,16 @@ export const config: webpack.Configuration = {
filename: './workers/blockfrost-worker.[contenthash].js',
},
},
{
test: /\.(js|ts)$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-typescript'],
},
},
},
],
},
resolve: {

View File

@@ -36,6 +36,6 @@
"lint:js": "yarn g:eslint '**/*.{ts,tsx,js}'",
"test:unit": "yarn g:jest -c ../../jest.config.base.js",
"type-check": "yarn g:tsc --build tsconfig.json",
"build:lib": "yarn g:rimraf ./lib && yarn g:tsc --build tsconfig.lib.json"
"build:lib": "yarn g:rimraf ./lib && yarn g:tsc --build tsconfig.lib.json && ../../scripts/replace-imports.sh ./lib"
}
}

View File

@@ -40,6 +40,6 @@
"lint:js": "yarn g:eslint '**/*.{ts,tsx,js}'",
"test:unit": "jest -c ../../jest.config.base.js",
"type-check": "yarn g:tsc --build tsconfig.json",
"build:lib": "yarn g:rimraf ./lib && yarn g:tsc --build tsconfig.lib.json"
"build:lib": "yarn g:rimraf ./lib && yarn g:tsc --build tsconfig.lib.json && ../../scripts/replace-imports.sh ./lib"
}
}

View File

@@ -16,9 +16,9 @@ import {
IFrameCallMessage,
IFrameLogRequest,
CoreEventMessage,
} from '@trezor/connect/lib/exports';
import type { Core } from '@trezor/connect/lib/core';
import { config } from '@trezor/connect/lib/data/config';
} from '@trezor/connect/src/exports';
import type { Core } from '@trezor/connect/src/core';
import { config } from '@trezor/connect/src/data/config';
import { parseConnectSettings } from '@trezor/connect-iframe/src/connectSettings';
import { initLogWriterWithSrcPath } from '@trezor/connect-iframe/src/sharedLoggerUtils';
@@ -37,7 +37,7 @@ import {
showView,
} from './view/common';
import { isPhishingDomain } from './utils/isPhishingDomain';
import { initLog, setLogWriter, LogWriter } from '@trezor/connect/lib/utils/debug';
import { initLog, setLogWriter, LogWriter } from '@trezor/connect/src/utils/debug';
const log = initLog('@trezor/connect-popup');
const proxyLogger = initLog('@trezor/connect-webextension');

View File

@@ -10,7 +10,7 @@ import {
TRANSPORT,
WEBEXTENSION,
} from '@trezor/connect';
import { TREZOR_USB_DESCRIPTORS } from '@trezor/transport/lib/constants';
import { TREZOR_USB_DESCRIPTORS } from '@trezor/transport/src/constants';
import { SUITE_BRIDGE_URL, SUITE_UDEV_URL, TREZOR_SUPPORT_URL } from '@trezor/urls';
import { container, getState, showView, postMessage } from './common';
import { reactEventBus } from '@trezor/connect-ui/src/utils/eventBus';

View File

@@ -1,5 +1,5 @@
import { PopupHandshake, PopupMethodInfo, IFrameLoaded } from '@trezor/connect';
import type { Core } from '@trezor/connect/lib/core';
import type { Core } from '@trezor/connect/src/core';
import type { OriginBoundState } from '@trezor/connect-common';
export type State = Partial<PopupHandshake['payload']> &

View File

@@ -19,7 +19,10 @@
"javascript"
],
"sideEffects": false,
"main": "lib/index",
"main": "src/index.ts",
"publishConfig": {
"main": "lib/index.js"
},
"files": [
"lib/",
"!**/*.map"
@@ -29,7 +32,7 @@
"lint:js": "yarn g:eslint '**/*.{ts,tsx,js}'",
"type-check": "yarn g:tsc --build",
"test:unit": "yarn g:jest",
"build:lib": "yarn g:rimraf ./lib && yarn g:tsc --build tsconfig.lib.json",
"build:lib": "yarn g:rimraf ./lib && yarn g:tsc --build tsconfig.lib.json && ../../scripts/replace-imports.sh ./lib",
"dev": "yarn g:rimraf build && TS_NODE_PROJECT=\"tsconfig.lib.json\" yarn webpack --config ./webpack/dev.webpack.config.ts",
"build:inline": "TS_NODE_PROJECT=\"tsconfig.lib.json\" webpack --config ./webpack/inline.webpack.config.ts",
"build:webextension": "TS_NODE_PROJECT=\"tsconfig.lib.json\" yarn webpack --config ./webpack/prod.webpack.config.ts",

View File

@@ -1,5 +1,5 @@
import { parseConnectSettings as parseSettings } from '@trezor/connect/lib/data/connectSettings';
import type { ConnectSettings } from '@trezor/connect/lib/types';
import { parseConnectSettings as parseSettings } from '@trezor/connect/src/data/connectSettings';
import type { ConnectSettings } from '@trezor/connect/src/types';
export const getEnv = () => {
if (typeof chrome !== 'undefined' && typeof chrome.runtime?.onConnect !== 'undefined') {

View File

@@ -1,11 +1,11 @@
// origin: https://github.com/trezor/connect/blob/develop/src/js/iframe/builder.js
import { createDeferred } from '@trezor/utils';
import * as ERRORS from '@trezor/connect/lib/constants/errors';
import { IFRAME, CoreRequestMessage } from '@trezor/connect/lib/events';
import type { ConnectSettings } from '@trezor/connect/lib/types';
import { getOrigin } from '@trezor/connect/lib/utils/urlUtils';
import { setLogWriter, LogMessage, LogWriter } from '@trezor/connect/lib/utils/debug';
import * as ERRORS from '@trezor/connect/src/constants/errors';
import { IFRAME, CoreRequestMessage } from '@trezor/connect/src/events';
import type { ConnectSettings } from '@trezor/connect/src/types';
import { getOrigin } from '@trezor/connect/src/utils/urlUtils';
import { setLogWriter, LogMessage, LogWriter } from '@trezor/connect/src/utils/debug';
import css from './inlineStyles';
export let instance: HTMLIFrameElement | null;

View File

@@ -2,7 +2,7 @@ import EventEmitter from 'events';
// NOTE: @trezor/connect part is intentionally not imported from the index due to NormalReplacementPlugin
// in packages/suite-build/configs/web.webpack.config.ts
import * as ERRORS from '@trezor/connect/lib/constants/errors';
import * as ERRORS from '@trezor/connect/src/constants/errors';
import {
POPUP,
IFRAME,
@@ -19,11 +19,11 @@ import {
UiResponseEvent,
CallMethod,
CoreEventMessage,
} from '@trezor/connect/lib/events';
import type { ConnectSettings, Manifest } from '@trezor/connect/lib/types';
import { factory } from '@trezor/connect/lib/factory';
import { initLog } from '@trezor/connect/lib/utils/debug';
import { config } from '@trezor/connect/lib/data/config';
} from '@trezor/connect/src/events';
import type { ConnectSettings, Manifest } from '@trezor/connect/src/types';
import { factory } from '@trezor/connect/src/factory';
import { initLog } from '@trezor/connect/src/utils/debug';
import { config } from '@trezor/connect/src/data/config';
import { createDeferredManager } from '@trezor/utils';
import * as iframe from './iframe';
@@ -331,4 +331,4 @@ const TrezorConnect = factory({
});
export default TrezorConnect;
export * from '@trezor/connect/lib/exports';
export * from '@trezor/connect/src/exports';

View File

@@ -2,11 +2,11 @@
import EventEmitter from 'events';
import { createDeferred, Deferred } from '@trezor/utils';
import { POPUP, IFRAME, UI, CoreEventMessage, IFrameLoaded } from '@trezor/connect/lib/events';
import type { ConnectSettings } from '@trezor/connect/lib/types';
import { getOrigin } from '@trezor/connect/lib/utils/urlUtils';
import { POPUP, IFRAME, UI, CoreEventMessage, IFrameLoaded } from '@trezor/connect/src/events';
import type { ConnectSettings } from '@trezor/connect/src/types';
import { getOrigin } from '@trezor/connect/src/utils/urlUtils';
import { showPopupRequest } from './showPopupRequest';
import { Log } from '@trezor/connect/lib/utils/debug';
import { Log } from '@trezor/connect/src/utils/debug';
import { ServiceWorkerWindowChannel } from '../channels/serviceworker-window';
import {

View File

@@ -1,7 +1,7 @@
// origin: https://github.com/trezor/connect/blob/develop/src/js/webusb/extensionPermissions.js
import { config } from '@trezor/connect/lib/data/config';
import { WEBEXTENSION } from '@trezor/connect/lib/events';
import { config } from '@trezor/connect/src/data/config';
import { WEBEXTENSION } from '@trezor/connect/src/events';
// This file is hosted on https://connect.trezor.io/*/extension-permissions.html
// It's included WITHIN webextension application in trezor-usb-permissions.html to allow pairing webusb and trezor.io domain properly.

View File

@@ -1,6 +1,6 @@
// origin: https://github.com/trezor/connect/blob/develop/src/js/webusb/index.js
import { config } from '@trezor/connect/lib/data/config';
import { config } from '@trezor/connect/src/data/config';
// handle message received from connect.js
const onload = () => {

View File

@@ -20,7 +20,10 @@
"serviceworker",
"webextension"
],
"main": "lib/index",
"main": "src/index.ts",
"publishConfig": {
"main": "lib/index.js"
},
"files": [
"build/trezor-connect-webextension.js",
"build/trezor-connect-webextension.min.js",
@@ -30,7 +33,7 @@
"scripts": {
"lint:js": "yarn g:eslint '**/*.{ts,tsx,js}'",
"test:e2e": "yarn xvfb-maybe -- playwright test --config=./e2e/playwright.config.ts",
"build:lib": "yarn g:rimraf ./lib && yarn g:tsc --build tsconfig.lib.json",
"build:lib": "yarn g:rimraf ./lib && yarn g:tsc --build tsconfig.lib.json && ../../scripts/replace-imports.sh ./lib",
"build:content-script": "TS_NODE_PROJECT=\"tsconfig.lib.json\" webpack --config ./webpack/content-script.webpack.config.ts",
"build:inline": "TS_NODE_PROJECT=\"tsconfig.lib.json\" webpack --config ./webpack/inline.webpack.config.ts",
"build:webextension": "TS_NODE_PROJECT=\"tsconfig.lib.json\" yarn webpack --config ./webpack/prod.webpack.config.ts",

View File

@@ -1,7 +1,7 @@
import {
parseConnectSettings as parseSettings,
ConnectSettings,
} from '@trezor/connect/lib/exports';
} from '@trezor/connect/src/exports';
export const getEnv = () => 'webextension' as const;

View File

@@ -1,4 +1,4 @@
import { WindowServiceWorkerChannel } from '@trezor/connect-web/lib/channels/window-serviceworker';
import { WindowServiceWorkerChannel } from '@trezor/connect-web/src/channels/window-serviceworker';
/**
* communication between service worker and both webextension and popup manager

View File

@@ -11,9 +11,9 @@ import {
Manifest,
UiResponseEvent,
CallMethod,
} from '@trezor/connect/lib/exports';
import { factory } from '@trezor/connect/lib/factory';
import { initLog, setLogWriter, LogMessage, LogWriter } from '@trezor/connect/lib/utils/debug';
} from '@trezor/connect/src/exports';
import { factory } from '@trezor/connect/src/factory';
import { initLog, setLogWriter, LogMessage, LogWriter } from '@trezor/connect/src/utils/debug';
// Import as src not lib due to webpack issues with inlining content script later
import { ServiceWorkerWindowChannel } from '@trezor/connect-web/src/channels/serviceworker-window';
import * as popup from '@trezor/connect-web/src/popup';
@@ -235,4 +235,4 @@ initProxyChannel();
// eslint-disable-next-line import/no-default-export
export default TrezorConnect;
export * from '@trezor/connect/lib/exports';
export * from '@trezor/connect/src/exports';

View File

@@ -10,9 +10,9 @@ import {
ConnectSettings,
Manifest,
CallMethod,
} from '@trezor/connect/lib/exports';
import { factory } from '@trezor/connect/lib/factory';
import { WindowServiceWorkerChannel } from '@trezor/connect-web/lib/channels/window-serviceworker';
} from '@trezor/connect/src/exports';
import { factory } from '@trezor/connect/src/factory';
import { WindowServiceWorkerChannel } from '@trezor/connect-web/src/channels/window-serviceworker';
const eventEmitter = new EventEmitter();
let _channel: any;
@@ -129,4 +129,4 @@ const TrezorConnect = factory({
// eslint-disable-next-line import/no-default-export
export default TrezorConnect;
export * from '@trezor/connect/lib/exports';
export * from '@trezor/connect/src/exports';

View File

@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/prefer-ts-expect-error */
// @ts-ignore
import commonFixtures from '../../../../submodules/trezor-common/tests/fixtures/stellar/sign_tx.json';
import { Messages } from '@trezor/transport/lib';
import { Messages } from '@trezor/transport/src';
// operations are in protobuf format (snake_case)

View File

@@ -125,7 +125,7 @@ module.exports = config => {
// replace ws module used in ./tests/websocket-client.js
new webpack.NormalModuleReplacementPlugin(
/ws$/,
'@trezor/blockchain-link/lib/utils/ws',
'@trezor/blockchain-link/src/utils/ws',
),
new webpack.DefinePlugin({

View File

@@ -19,16 +19,21 @@
"javascript"
],
"sideEffects": false,
"main": "lib/index",
"main": "src/index.ts",
"browser": {
"./lib/index": "./lib/index-browser",
"./lib/utils/assets": "./lib/utils/assets-browser",
"./lib/workers/workers": "./lib/workers/workers-browser"
"./src/index": "./src/index-browser.ts",
"./src/index.ts": "./src/index-browser.ts",
"./src/utils/assets": "./src/utils/assets-browser.ts",
"./src/workers/workers": "./src/workers/workers-browser.ts"
},
"react-native": {
"./lib/index": "./lib/index",
"./lib/workers/workers": "./lib/workers/workers-react-native",
"./lib/utils/assets": "./lib/utils/assets-native"
"publishConfig": {
"main": "lib/index.js",
"browser": {
"./lib/index.js": "./lib/index-browser.js",
"./lib/index": "./lib/index-browser.js",
"./lib/utils/assets": "./lib/utils/assets-browser.js",
"./lib/workers/workers": "./lib/workers/workers-browser.js"
}
},
"files": [
"lib/",
@@ -38,7 +43,7 @@
"lint:js": "yarn g:eslint '**/*.{ts,tsx,js}'",
"test:unit": "jest --version && jest",
"type-check": "yarn g:tsc --build",
"build:lib": "yarn g:rimraf ./lib && yarn g:tsc --build tsconfig.lib.json",
"build:lib": "yarn g:rimraf ./lib && yarn g:tsc --build tsconfig.lib.json && ../../scripts/replace-imports.sh ./lib",
"version:beta": "yarn g:tsx scripts/bump-version.ts prerelease",
"version:patch": "yarn g:tsx scripts/bump-version.ts patch",
"version:minor": "yarn g:tsx scripts/bump-version.ts minor",

View File

@@ -12,7 +12,7 @@ import { TypedError } from '../../constants/errors';
import type {
TxInput as BitcoinJsInput,
TxOutput as BitcoinJsOutput,
} from '@trezor/utxo-lib/lib/transaction/base';
} from '@trezor/utxo-lib/src/transaction/base';
import type {
CoinInfo,
AccountAddresses,

View File

@@ -1,6 +1,6 @@
// origin: https://github.com/trezor/connect/blob/develop/src/data/config.json
import { TREZOR_USB_DESCRIPTORS } from '@trezor/transport/lib/constants';
import { TREZOR_USB_DESCRIPTORS } from '@trezor/transport/src/constants';
export const config = {
webusb: TREZOR_USB_DESCRIPTORS,

View File

@@ -2,9 +2,9 @@ import { serializeError } from '../constants/errors';
import type { MessageFactoryFn } from '../types/utils';
import type { Transport } from '@trezor/transport';
import { TRANSPORT } from '@trezor/transport/lib/constants';
import { TRANSPORT } from '@trezor/transport/src/constants';
export { TRANSPORT } from '@trezor/transport/lib/constants';
export { TRANSPORT } from '@trezor/transport/src/constants';
export const TRANSPORT_EVENT = 'TRANSPORT_EVENT';
export interface BridgeInfo {

View File

@@ -1,5 +1,5 @@
import type { AccountAddresses } from '@trezor/blockchain-link';
import type { Transaction as BlockbookTransaction } from '@trezor/blockchain-link-types/lib/blockbook';
import type { Transaction as BlockbookTransaction } from '@trezor/blockchain-link-types/src/blockbook';
import type { PROTO } from '../../../constants';
import type { AccountTransaction } from '../../account';
import { DerivationPath, ProtoWithDerivationPath } from '../../params';

View File

@@ -1,7 +1,7 @@
import BlockbookWorker from '@trezor/blockchain-link/lib/workers/blockbook';
import RippleWorker from '@trezor/blockchain-link/lib/workers/ripple';
import BlockfrostWorker from '@trezor/blockchain-link/lib/workers/blockfrost';
import SolanaWorker from '@trezor/blockchain-link/lib/workers/solana';
import BlockbookWorker from '@trezor/blockchain-link/src/workers/blockbook';
import RippleWorker from '@trezor/blockchain-link/src/workers/ripple';
import BlockfrostWorker from '@trezor/blockchain-link/src/workers/blockfrost';
import SolanaWorker from '@trezor/blockchain-link/src/workers/solana';
const ElectrumWorker = undefined;

View File

@@ -1,8 +0,0 @@
import BlockbookWorker from '@trezor/blockchain-link/lib/workers/blockbook';
import RippleWorker from '@trezor/blockchain-link/lib/workers/ripple';
import BlockfrostWorker from '@trezor/blockchain-link/lib/workers/blockfrost';
import SolanaWorker from '@trezor/blockchain-link/lib/workers/solana';
const ElectrumWorker = undefined;
export { BlockbookWorker, RippleWorker, BlockfrostWorker, ElectrumWorker, SolanaWorker };

View File

@@ -0,0 +1,8 @@
import BlockbookWorker from '@trezor/blockchain-link/src/workers/blockbook';
import RippleWorker from '@trezor/blockchain-link/src/workers/ripple';
import BlockfrostWorker from '@trezor/blockchain-link/src/workers/blockfrost';
import SolanaWorker from '@trezor/blockchain-link/src/workers/solana';
const ElectrumWorker = undefined;
export { BlockbookWorker, RippleWorker, BlockfrostWorker, ElectrumWorker, SolanaWorker };

View File

@@ -1,26 +1,26 @@
import type { BaseWorker } from '@trezor/blockchain-link/lib/workers/baseWorker';
import type { BaseWorker } from '@trezor/blockchain-link/src/workers/baseWorker';
type WorkerAsyncImporter = () => Promise<BaseWorker<unknown>>;
const BlockbookWorker: WorkerAsyncImporter = () =>
import(
/* webpackChunkName: "blockbook-worker" */ '@trezor/blockchain-link/lib/workers/blockbook'
/* webpackChunkName: "blockbook-worker" */ '@trezor/blockchain-link/src/workers/blockbook'
).then(w => w.default());
const RippleWorker: WorkerAsyncImporter = () =>
import(
/* webpackChunkName: "ripple-worker" */ '@trezor/blockchain-link/lib/workers/ripple'
/* webpackChunkName: "ripple-worker" */ '@trezor/blockchain-link/src/workers/ripple'
).then(w => w.default());
const BlockfrostWorker: WorkerAsyncImporter = () =>
import(
/* webpackChunkName: "blockfrost-worker" */ '@trezor/blockchain-link/lib/workers/blockfrost'
/* webpackChunkName: "blockfrost-worker" */ '@trezor/blockchain-link/src/workers/blockfrost'
).then(w => w.default());
const ElectrumWorker: WorkerAsyncImporter = () =>
import(
/* webpackChunkName: "electrum-worker" */ '@trezor/blockchain-link/lib/workers/electrum'
/* webpackChunkName: "electrum-worker" */ '@trezor/blockchain-link/src/workers/electrum'
).then(w => w.default());
const SolanaWorker: WorkerAsyncImporter = () =>
import(
/* webpackChunkName: "solana-worker" */ '@trezor/blockchain-link/lib/workers/solana'
/* webpackChunkName: "solana-worker" */ '@trezor/blockchain-link/src/workers/solana'
).then(w => w.default());
export { BlockbookWorker, RippleWorker, BlockfrostWorker, ElectrumWorker, SolanaWorker };

View File

@@ -3,6 +3,7 @@
"compilerOptions": {
"outDir": "lib",
"target": "es2019",
"lib": ["es2019", "webworker"],
// note: do not remove tslib from package.json. It might seem that it is not used
// but it is required due to importHelpers: true
"importHelpers": true

View File

@@ -23,7 +23,7 @@
"scripts": {
"lint:js": "yarn g:eslint '**/*.{ts,tsx,js}'",
"type-check": "yarn g:tsc --build",
"build:lib": "yarn g:rimraf ./lib && yarn g:tsc --build tsconfig.lib.json",
"build:lib": "yarn g:rimraf ./lib && yarn g:tsc --build tsconfig.lib.json && ../../scripts/replace-imports.sh ./lib",
"prepublishOnly": "yarn tsx ../../scripts/prepublishNPM.js",
"prepublish": "yarn tsx ../../scripts/prepublish.js"
},

View File

@@ -27,7 +27,7 @@
"lint:js": "yarn g:eslint '**/*.{ts,tsx,js}'",
"test:unit": "yarn g:jest -c ../../jest.config.base.js",
"type-check": "yarn g:tsc --build",
"build:lib": "yarn g:rimraf ./lib && yarn g:tsc --build tsconfig.lib.json",
"build:lib": "yarn g:rimraf ./lib && yarn g:tsc --build tsconfig.lib.json && ../../scripts/replace-imports.sh ./lib",
"update:schema": "yarn workspace @trezor/schema-utils codegen $(pwd)/src/messages.ts > src/messages-schema.ts && yarn g:prettier --write src/messages-schema.ts && yarn g:eslint --fix src/messages-schema.ts",
"update:protobuf": "./scripts/protobuf-build.sh && yarn g:prettier --write \"{messages.json,src/messages.ts}\" && yarn g:eslint --fix src/messages.ts",
"prepublishOnly": "yarn tsx ../../scripts/prepublishNPM.js",

View File

@@ -23,7 +23,7 @@
"lint:js": "yarn g:eslint '**/*.{ts,tsx,js}'",
"test:unit": "yarn g:jest -c ../../jest.config.base.js",
"type-check": "yarn g:tsc --build",
"build:lib": "yarn g:rimraf ./lib && yarn g:tsc --build tsconfig.lib.json",
"build:lib": "yarn g:rimraf ./lib && yarn g:tsc --build tsconfig.lib.json && ../../scripts/replace-imports.sh ./lib",
"prepublishOnly": "yarn tsx ../../scripts/prepublishNPM.js",
"prepublish": "yarn tsx ../../scripts/prepublish.js"
},

View File

@@ -15,7 +15,7 @@
"test:unit": "yarn g:jest",
"lint:js": "yarn g:eslint '**/*.{ts,tsx,js}'",
"type-check": "yarn g:tsc --build",
"build:lib": "rimraf ./lib && yarn g:tsc --build tsconfig.lib.json",
"build:lib": "rimraf ./lib && yarn g:tsc --build tsconfig.lib.json && ../../scripts/replace-imports.sh ./lib",
"codegen": "ts-node --skip-project ./src/codegen.ts",
"prepublishOnly": "yarn tsx ../../scripts/prepublishNPM.js",
"prepublish": "yarn tsx ../../scripts/prepublish.js"

Some files were not shown because too many files have changed in this diff Show More