diff --git a/.eslintrc.js b/.eslintrc.js index 2bee9d92..5d6e74a7 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -24,5 +24,15 @@ module.exports = { }, env: { browser: true, + node: true, }, + overrides: [ + { + files: ["*.cjs"], + rules: { + "@typescript-eslint/no-var-requires": "off", + "@typescript-eslint/no-unsafe-assignment": "off" + } + } + ] }; diff --git a/package.json b/package.json index b2071b76..d76f8cfe 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,9 @@ "example": "cd ./packages/example && yarn dev", "example-build": "cd ./packages/example && yarn --registry 'https://registry.npmjs.org' && yarn build", "update-version": "lerna version --no-git-tag-version --exact", - "swap-lock-registry": "npx swap-lock-registry --yarn --parallel --url https://registry.yarnpkg.com yarn.lock" + "swap-lock-registry": "npx swap-lock-registry --yarn --parallel --url https://registry.yarnpkg.com yarn.lock", + "test:e2e": "cd ./packages/e2e && yarn test:headed", + "test:e2e:hub": "cd ./packages/providers/inpage-providers-hub && yarn test:headed" }, "devDependencies": { "@testing-library/react-hooks": "^7.0.2", diff --git a/packages/core/src/versionInfo.ts b/packages/core/src/versionInfo.ts index 7510fa27..30337256 100644 --- a/packages/core/src/versionInfo.ts +++ b/packages/core/src/versionInfo.ts @@ -1,5 +1,5 @@ -const version = '2.1.21'; +const version = '2.1.23'; const versionBuild = '2020-0101-1'; export default { diff --git a/packages/e2e/.gitignore b/packages/e2e/.gitignore new file mode 100644 index 00000000..123beb53 --- /dev/null +++ b/packages/e2e/.gitignore @@ -0,0 +1,4 @@ +node_modules/ +test-results/ +playwright-report/ +playwright/.cache/ \ No newline at end of file diff --git a/packages/e2e/dotEnvInit.js b/packages/e2e/dotEnvInit.js new file mode 100644 index 00000000..79db9f74 --- /dev/null +++ b/packages/e2e/dotEnvInit.js @@ -0,0 +1,20 @@ +import dotenv from 'dotenv'; +import path from 'path'; +import { fileURLToPath } from 'url'; + +function setupDotEnv() { + const __filename = fileURLToPath(import.meta.url); + const __dirname = path.dirname(__filename); + + const results = [ + dotenv.config({ + path: path.resolve(__dirname, '../../.env'), + }), + ]; + const errorResult = results.find((result) => result.error); + + if (errorResult) { + throw errorResult.error; + } +} +setupDotEnv(); diff --git a/packages/e2e/package.json b/packages/e2e/package.json new file mode 100644 index 00000000..9c6acdf8 --- /dev/null +++ b/packages/e2e/package.json @@ -0,0 +1,45 @@ +{ + "private": true, + "name": "@onekeyfe/e2e", + "version": "2.1.23", + "keywords": [ + "cross-inpage-provider" + ], + "author": "dev-fe@onekey.so", + "repository": "https://github.com/OneKeyHQ/cross-inpage-provider", + "license": "Apache-2.0", + "publishConfig": { + "access": "public" + }, + "type": "module", + "files": [ + "dist/*" + ], + "exports": { + "types": "./dist/index.d.ts", + "import": "./dist/index.js", + "require": "./dist/cjs/index.js" + }, + "types": "./dist/index.d.ts", + "module": "./dist/index.js", + "main": "./dist/cjs/index.js", + "scripts": { + "env": "node dotEnvInit.js", + "report": "yarn env && npx playwright show-report", + "test": "yarn env && npx playwright test", + "test:headed": "yarn env && npx playwright test --headed && yarn report", + "test:ui": "yarn env && npx playwright test --ui" + }, + "dependencies": { + "@onekeyfe/inpage-providers-hub": "2.1.23", + "@onekeyfe/cross-inpage-provider-injected": "2.1.23", + "@onekeyfe/cross-inpage-provider-types": "2.1.23", + "lodash-es": "^4.17.21" + }, + "devDependencies": { + "@playwright/test": "^1.49.1", + "@types/lodash-es": "^4.17.12", + "@types/node": "^20.12.7", + "playwright": "^1.49.1" + } +} diff --git a/packages/e2e/playwright.config.ts b/packages/e2e/playwright.config.ts new file mode 100644 index 00000000..9ab9f58a --- /dev/null +++ b/packages/e2e/playwright.config.ts @@ -0,0 +1,22 @@ +import { defineConfig, devices } from '@playwright/test'; + +export default defineConfig({ + testDir: './tests', + testMatch: ['**/*.e2e.ts', '**/*.e2e.js'], + fullyParallel: true, + forbidOnly: !!process.env.CI, + retries: process.env.CI ? 2 : 0, + workers: process.env.CI ? 1 : undefined, + reporter: 'html', + use: { + baseURL: 'http://localhost:3000', + trace: 'on-first-retry', + }, + projects: [ + { + name: 'chromium', + use: { ...devices['Desktop Chrome'] }, + }, + ], + outputDir: 'test-results', +}); diff --git a/packages/e2e/playwright2.config.ts b/packages/e2e/playwright2.config.ts new file mode 100644 index 00000000..781a043f --- /dev/null +++ b/packages/e2e/playwright2.config.ts @@ -0,0 +1,39 @@ +import { defineConfig, devices } from '@playwright/test'; + +/** + * Read environment variables from file. + * https://github.com/motdotla/dotenv + */ +// require('dotenv').config(); + +/** + * See https://playwright.dev/docs/test-configuration. + */ +export default defineConfig({ + testDir: './src', + testMatch: '*.spec.ts', + timeout: 1000 * 60, + fullyParallel: false, + forbidOnly: !!process.env.CI, + retries: 0, + workers: process.env.CI ? 1 : undefined, + reporter: [['html', { outputFolder: 'reports' }]], + + use: { + screenshot: 'on', + trace: 'on', + // video: 'on', + }, + + projects: [ + { + name: 'chromium', + use: { ...devices['Desktop Chrome'], viewport: { width: 1920, height: 800 } }, + }, + + { + name: 'Mobile Chrome', + use: { ...devices['iPhone 6'] }, + }, + ], +}); diff --git a/packages/e2e/tests/bing.e2e.ts b/packages/e2e/tests/bing.e2e.ts new file mode 100644 index 00000000..804946dc --- /dev/null +++ b/packages/e2e/tests/bing.e2e.ts @@ -0,0 +1,64 @@ +// 在文件顶部添加这个声明 +declare global { + interface Window { + $1key: { + hello: () => string; + }; + } +} + +import { expect, test } from '@playwright/test'; + +test.skip('Bing search test', async ({ page }) => { + // 打开 Bing + await page.goto('https://www.baidu.com'); + + // 等待搜索输入框出现并输入内容 + const searchInput = page.locator('#kw'); + await searchInput.fill('hemoglobin consists of click to select chainsmokers songs'); + await searchInput.press('Enter'); + + // 等待搜索结果出现 + await page.waitForSelector('.result.c-container.xpath-log.new-pmd'); + + // 获取第二个搜索结果 + const secondResult = page.locator('.result.c-container.xpath-log.new-pmd').nth(1); + + // 使用 evaluate 来高亮元素 + await secondResult.evaluate((element) => { + element.style.backgroundColor = 'yellow'; + element.style.border = '2px solid red'; + }); + + const init1key = () => { + window.$1key = { + hello: () => 'world', + }; + }; + + // 注入全局变量 + await page.evaluate(init1key); + + // 验证 $1key 全局变量存在 + const hasOneKey = await page.evaluate(() => { + return window.$1key !== undefined; + }); + expect(hasOneKey).toBe(true); + + // 验证 $1key.hello 方法存在且可调用 + const hasHelloMethod = await page.evaluate(() => { + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call + const result = window.$1key ? window.$1key.hello() : ''; + return result; + }); + expect(hasHelloMethod).toBe('world'); + + // 截个图(可选) + await page.screenshot({ path: 'test-results/screenshots/bing-search.png' }); + + // 验证搜索结果存在 + await expect(secondResult).toBeVisible(); + + // 设置浏览器在测试完成后保持打开状态 + await page.pause(); +}); diff --git a/packages/e2e/tests/dapp.e2e.ts b/packages/e2e/tests/dapp.e2e.ts new file mode 100644 index 00000000..22bc3a83 --- /dev/null +++ b/packages/e2e/tests/dapp.e2e.ts @@ -0,0 +1,37 @@ +import * as fs from 'fs'; +import * as path from 'path'; + +import { connectButtonData } from '@onekeyfe/inpage-providers-hub'; + +const injectedCode = fs.readFileSync( + path.resolve( + 'node_modules/@onekeyfe/cross-inpage-provider-injected/dist/injected/injectedNative.js', + ), + 'utf-8', +); + +import { expect, test } from '@playwright/test'; + +test('dapp-test', async ({ page }) => { + console.log(connectButtonData.sitesConfig[0]); + + // await page.goto('https://dapp-example.onekeytest.com'); + // https://app.uniswap.org/ + await page.goto('https://app.uniswap.org/'); + + // eval injectedCode + await page.evaluate(injectedCode); + + // 验证 $onekey 全局变量存在 + const hasOneKey = await page.evaluate(() => { + // @ts-ignore + return window.$onekey !== undefined; + }); + expect(hasOneKey).toBe(true); + + // 截个图(可选) + await page.screenshot({ path: 'test-results/screenshots/dapp-test.png' }); + + // 设置浏览器在测试完成后保持打开状态 + await page.pause(); +}); diff --git a/packages/e2e/tests/example.e2e.ts b/packages/e2e/tests/example.e2e.ts new file mode 100644 index 00000000..00d30781 --- /dev/null +++ b/packages/e2e/tests/example.e2e.ts @@ -0,0 +1,6 @@ +import { test, expect } from '@playwright/test'; + +test.skip('basic test', async ({ page }) => { + await page.goto('https://example.walletconnect.org'); + await expect(page).toHaveTitle(/React/); +}); \ No newline at end of file diff --git a/packages/e2e/tsconfig.json b/packages/e2e/tsconfig.json new file mode 100644 index 00000000..723c632b --- /dev/null +++ b/packages/e2e/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "baseUrl": ".", + "paths": { + "@/*": ["./src/*"] + } + }, + "include": ["**/*.ts", "**/*.tsx", "dotEnvInit.js"], + "exclude": ["node_modules"] +} \ No newline at end of file diff --git a/packages/e2e/yarn.lock b/packages/e2e/yarn.lock new file mode 100644 index 00000000..c00d0dfd --- /dev/null +++ b/packages/e2e/yarn.lock @@ -0,0 +1,58 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"@playwright/test@^1.49.1": + version "1.49.1" + resolved "https://registry.yarnpkg.com/@playwright/test/-/test-1.49.1.tgz#55fa360658b3187bfb6371e2f8a64f50ef80c827" + integrity sha512-Ky+BVzPz8pL6PQxHqNRW1k3mIyv933LML7HktS8uik0bUXNCdPhoS/kLihiO1tMf/egaJb4IutXd7UywvXEW+g== + dependencies: + playwright "1.49.1" + +"@types/lodash-es@^4.17.12": + version "4.17.12" + resolved "https://registry.yarnpkg.com/@types/lodash-es/-/lodash-es-4.17.12.tgz#65f6d1e5f80539aa7cfbfc962de5def0cf4f341b" + integrity sha512-0NgftHUcV4v34VhXm8QBSftKVXtbkBG3ViCjs6+eJ5a6y6Mi/jiFGPc1sC7QK+9BFhWrURE3EOggmWaSxL9OzQ== + dependencies: + "@types/lodash" "*" + +"@types/lodash@*": + version "4.17.13" + resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.17.13.tgz#786e2d67cfd95e32862143abe7463a7f90c300eb" + integrity sha512-lfx+dftrEZcdBPczf9d0Qv0x+j/rfNCMuC6OcfXmO8gkfeNAY88PgKUbvG56whcN23gc27yenwF6oJZXGFpYxg== + +"@types/node@^20.12.7": + version "20.17.10" + resolved "https://registry.yarnpkg.com/@types/node/-/node-20.17.10.tgz#3f7166190aece19a0d1d364d75c8b0b5778c1e18" + integrity sha512-/jrvh5h6NXhEauFFexRin69nA0uHJ5gwk4iDivp/DeoEua3uwCUto6PC86IpRITBOs4+6i2I56K5x5b6WYGXHA== + dependencies: + undici-types "~6.19.2" + +fsevents@2.3.2: + version "2.3.2" + resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a" + integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA== + +lodash-es@^4.17.21: + version "4.17.21" + resolved "https://registry.yarnpkg.com/lodash-es/-/lodash-es-4.17.21.tgz#43e626c46e6591b7750beb2b50117390c609e3ee" + integrity sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw== + +playwright-core@1.49.1: + version "1.49.1" + resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-1.49.1.tgz#32c62f046e950f586ff9e35ed490a424f2248015" + integrity sha512-BzmpVcs4kE2CH15rWfzpjzVGhWERJfmnXmniSyKeRZUs9Ws65m+RGIi7mjJK/euCegfn3i7jvqWeWyHe9y3Vgg== + +playwright@1.49.1, playwright@^1.49.1: + version "1.49.1" + resolved "https://registry.yarnpkg.com/playwright/-/playwright-1.49.1.tgz#830266dbca3008022afa7b4783565db9944ded7c" + integrity sha512-VYL8zLoNTBxVOrJBbDuRgDWa3i+mfQgDTrL8Ah9QXZ7ax4Dsj0MSq5bYgytRnDVVe+njoKnfsYkH3HzqVj5UZA== + dependencies: + playwright-core "1.49.1" + optionalDependencies: + fsevents "2.3.2" + +undici-types@~6.19.2: + version "6.19.8" + resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-6.19.8.tgz#35111c9d1437ab83a7cdc0abae2f26d88eda0a02" + integrity sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw== diff --git a/packages/example/server/wrappers/walletsData.ts b/packages/example/server/wrappers/walletsData.ts index cf2e7295..7f0a24f1 100644 --- a/packages/example/server/wrappers/walletsData.ts +++ b/packages/example/server/wrappers/walletsData.ts @@ -88,7 +88,9 @@ export function tryParsePublicKey(stateInit: StateInit): Buffer | null { if (wallet.init.code.equals(stateInit.code)) { return loadData(stateInit.data.beginParse()).publicKey; } - } catch (e) {} + } catch (e) { + // ignore + } } return null; diff --git a/packages/injected/webpack.config.cjs b/packages/injected/webpack.config.cjs index 3b1c2749..f7dab222 100644 --- a/packages/injected/webpack.config.cjs +++ b/packages/injected/webpack.config.cjs @@ -16,6 +16,10 @@ const commonConfig = { // secp256k1 required in @solana/web3.js index.iife.js // './precomputed/secp256k1': path.resolve(__dirname, 'development/resolveAlias/secp256k1-mock'), // '@solana/web3.js': path.resolve(__dirname, 'development/resolveAlias/@solana-web3'), + tronweb: path.resolve( + __dirname, + 'node_modules/@onekeyfe/inpage-providers-hub/node_modules/@onekeyfe/onekey-tron-provider/node_modules/tronweb/dist/TronWeb.js', + ), }, extensions: ['.js', '.jsx', '.ts', '.tsx', '.d.ts'], fallback: { diff --git a/packages/providers/inpage-providers-hub/package.json b/packages/providers/inpage-providers-hub/package.json index 67ce2f81..1212d864 100644 --- a/packages/providers/inpage-providers-hub/package.json +++ b/packages/providers/inpage-providers-hub/package.json @@ -26,6 +26,7 @@ "prebuild": "rm -rf dist", "build": "tsc && tsc --project tsconfig.cjs.json", "test": "npx playwright test", + "test:headed": "npx playwright test --headed", "test:report": "npx playwright show-report reports", "start": "tsc --watch" }, @@ -50,10 +51,12 @@ "@onekeyfe/onekey-ton-provider": "2.1.23", "@onekeyfe/onekey-tron-provider": "2.1.23", "@onekeyfe/onekey-webln-provider": "2.1.23", + "lodash-es": "^4.17.21", "web3": "^1.7.3" }, "devDependencies": { "@playwright/test": "^1.43.1", + "@types/lodash-es": "^4.17.12", "@types/node": "^20.12.7", "playwright": "^1.43.1" } diff --git a/packages/providers/inpage-providers-hub/src/connectButtonHack/hackConnectButton.ts b/packages/providers/inpage-providers-hub/src/connectButtonHack/hackConnectButton.ts index 911a4600..9512cc6c 100644 --- a/packages/providers/inpage-providers-hub/src/connectButtonHack/hackConnectButton.ts +++ b/packages/providers/inpage-providers-hub/src/connectButtonHack/hackConnectButton.ts @@ -3,7 +3,7 @@ import { Logger, checkWalletSwitchEnable, } from '@onekeyfe/cross-inpage-provider-core'; -import { throttle, ThrottleSettings } from 'lodash'; +import { throttle, ThrottleSettings } from 'lodash-es'; import { IInjectedProviderNames } from '@onekeyfe/cross-inpage-provider-types'; import type { IWindowOneKeyHub } from '../injectWeb3Provider'; diff --git a/packages/providers/inpage-providers-hub/src/connectButtonHack/sites/aave.ts b/packages/providers/inpage-providers-hub/src/connectButtonHack/sites/aave.ts index ca5afe13..07bff3ac 100644 --- a/packages/providers/inpage-providers-hub/src/connectButtonHack/sites/aave.ts +++ b/packages/providers/inpage-providers-hub/src/connectButtonHack/sites/aave.ts @@ -1,7 +1,7 @@ import { hackConnectButton } from '../hackConnectButton'; import { IInjectedProviderNames } from '@onekeyfe/cross-inpage-provider-types'; import { WALLET_CONNECT_INFO } from '../consts'; -import { last } from 'lodash'; +import { last } from 'lodash-es'; export default () => hackConnectButton({ urls: ['aave.com', 'app.aave.com', 'www.aave.com'], diff --git a/packages/providers/inpage-providers-hub/src/index.ts b/packages/providers/inpage-providers-hub/src/index.ts index b4881a8d..e3e2fe14 100644 --- a/packages/providers/inpage-providers-hub/src/index.ts +++ b/packages/providers/inpage-providers-hub/src/index.ts @@ -1 +1,9 @@ +import { sitesConfig } from './connectButtonHack/universal/config'; +import { createWalletId } from './connectButtonHack/universal/utils'; + +export const connectButtonData = { + sitesConfig, + createWalletId, +}; + export * from './injectWeb3Provider'; diff --git a/packages/providers/inpage-providers-hub/yarn.lock b/packages/providers/inpage-providers-hub/yarn.lock index 22f1113e..26d7a6f1 100644 --- a/packages/providers/inpage-providers-hub/yarn.lock +++ b/packages/providers/inpage-providers-hub/yarn.lock @@ -227,6 +227,18 @@ dependencies: "@types/node" "*" +"@types/lodash-es@^4.17.12": + version "4.17.12" + resolved "https://registry.yarnpkg.com/@types/lodash-es/-/lodash-es-4.17.12.tgz#65f6d1e5f80539aa7cfbfc962de5def0cf4f341b" + integrity sha512-0NgftHUcV4v34VhXm8QBSftKVXtbkBG3ViCjs6+eJ5a6y6Mi/jiFGPc1sC7QK+9BFhWrURE3EOggmWaSxL9OzQ== + dependencies: + "@types/lodash" "*" + +"@types/lodash@*": + version "4.17.13" + resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.17.13.tgz#786e2d67cfd95e32862143abe7463a7f90c300eb" + integrity sha512-lfx+dftrEZcdBPczf9d0Qv0x+j/rfNCMuC6OcfXmO8gkfeNAY88PgKUbvG56whcN23gc27yenwF6oJZXGFpYxg== + "@types/node@*": version "17.0.27" resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.27.tgz#f4df3981ae8268c066e8f49995639f855469081e" @@ -1555,6 +1567,11 @@ keyv@^3.0.0: dependencies: json-buffer "3.0.0" +lodash-es@^4.17.21: + version "4.17.21" + resolved "https://registry.yarnpkg.com/lodash-es/-/lodash-es-4.17.21.tgz#43e626c46e6591b7750beb2b50117390c609e3ee" + integrity sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw== + lowercase-keys@^1.0.0, lowercase-keys@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/lowercase-keys/-/lowercase-keys-1.0.1.tgz#6f9e30b47084d971a7c820ff15a6c5167b74c26f" diff --git a/packages/providers/onekey-cosmos-provider/package.json b/packages/providers/onekey-cosmos-provider/package.json index 478e942d..852c650f 100644 --- a/packages/providers/onekey-cosmos-provider/package.json +++ b/packages/providers/onekey-cosmos-provider/package.json @@ -34,7 +34,11 @@ "@onekeyfe/cross-inpage-provider-types": "2.1.23", "@onekeyfe/extension-bridge-injected": "2.1.23", "eth-rpc-errors": "^4.0.3", + "lodash-es": "^4.17.21", "long": "^5.2.1", "mitt": "^3.0.0" + }, + "devDependencies": { + "@types/lodash-es": "^4.17.12" } } diff --git a/packages/providers/onekey-cosmos-provider/src/OnekeyCosmosProvider.ts b/packages/providers/onekey-cosmos-provider/src/OnekeyCosmosProvider.ts index 8e1bf85f..ea93fb76 100644 --- a/packages/providers/onekey-cosmos-provider/src/OnekeyCosmosProvider.ts +++ b/packages/providers/onekey-cosmos-provider/src/OnekeyCosmosProvider.ts @@ -29,7 +29,7 @@ import type { // @ts-ignore import Long from 'long'; import { CosmJSOfflineSigner, CosmJSOfflineSignerOnlyAmino } from './cosmjs'; -import { isArray } from 'lodash'; +import { isArray } from 'lodash-es'; import { JSONUint8Array } from './utils/uint8-array'; const PROVIDER_EVENTS = { diff --git a/packages/providers/onekey-cosmos-provider/yarn.lock b/packages/providers/onekey-cosmos-provider/yarn.lock index 34f4214f..946ee93a 100644 --- a/packages/providers/onekey-cosmos-provider/yarn.lock +++ b/packages/providers/onekey-cosmos-provider/yarn.lock @@ -7,6 +7,18 @@ resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.3.0.tgz#085fd70f6d7d9d109671090ccae1d3bec62554a1" integrity sha512-ilHEACi9DwqJB0pw7kv+Apvh50jiiSyR/cQ3y4W7lOR5mhvn/50FLUfsnfJz0BDZtl/RR16kXvptiv6q1msYZg== +"@types/lodash-es@^4.17.12": + version "4.17.12" + resolved "https://registry.yarnpkg.com/@types/lodash-es/-/lodash-es-4.17.12.tgz#65f6d1e5f80539aa7cfbfc962de5def0cf4f341b" + integrity sha512-0NgftHUcV4v34VhXm8QBSftKVXtbkBG3ViCjs6+eJ5a6y6Mi/jiFGPc1sC7QK+9BFhWrURE3EOggmWaSxL9OzQ== + dependencies: + "@types/lodash" "*" + +"@types/lodash@*": + version "4.17.13" + resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.17.13.tgz#786e2d67cfd95e32862143abe7463a7f90c300eb" + integrity sha512-lfx+dftrEZcdBPczf9d0Qv0x+j/rfNCMuC6OcfXmO8gkfeNAY88PgKUbvG56whcN23gc27yenwF6oJZXGFpYxg== + eth-rpc-errors@^4.0.3: version "4.0.3" resolved "https://registry.npmjs.org/eth-rpc-errors/-/eth-rpc-errors-4.0.3.tgz" @@ -19,6 +31,11 @@ fast-safe-stringify@^2.0.6: resolved "https://registry.yarnpkg.com/fast-safe-stringify/-/fast-safe-stringify-2.1.1.tgz#c406a83b6e70d9e35ce3b30a81141df30aeba884" integrity sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA== +lodash-es@^4.17.21: + version "4.17.21" + resolved "https://registry.yarnpkg.com/lodash-es/-/lodash-es-4.17.21.tgz#43e626c46e6591b7750beb2b50117390c609e3ee" + integrity sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw== + long@^5.2.1: version "5.2.1" resolved "https://registry.yarnpkg.com/long/-/long-5.2.1.tgz#e27595d0083d103d2fa2c20c7699f8e0c92b897f" diff --git a/packages/providers/onekey-tron-provider/@types/tronweb.d.ts b/packages/providers/onekey-tron-provider/@types/tronweb.d.ts index 0ada3f2e..cc2ecbcb 100644 --- a/packages/providers/onekey-tron-provider/@types/tronweb.d.ts +++ b/packages/providers/onekey-tron-provider/@types/tronweb.d.ts @@ -57,7 +57,7 @@ type HttpProvider = { request(endpoint: string, payload: unknown, method = 'get'): Promise; }; -declare module 'tronweb/dist/TronWeb' { +declare module 'tronweb' { export class TronWeb { ready: boolean; constructor(options: any); diff --git a/packages/providers/onekey-tron-provider/package.json b/packages/providers/onekey-tron-provider/package.json index e3eecbf5..34a6d506 100644 --- a/packages/providers/onekey-tron-provider/package.json +++ b/packages/providers/onekey-tron-provider/package.json @@ -28,6 +28,7 @@ "start": "tsc --watch" }, "dependencies": { + "lodash-es": "^4.17.21", "@noble/secp256k1": "1.7.1", "@onekeyfe/cross-inpage-provider-core": "2.1.23", "@onekeyfe/cross-inpage-provider-errors": "2.1.23", @@ -36,5 +37,8 @@ "querystring": "^0.2.1", "sunweb": "^1.0.7", "tronweb": "^5.3.2" + }, + "devDependencies": { + "@types/lodash-es": "^4.17.12" } } diff --git a/packages/providers/onekey-tron-provider/src/ProviderTron.ts b/packages/providers/onekey-tron-provider/src/ProviderTron.ts index 16dba59a..61e44e86 100644 --- a/packages/providers/onekey-tron-provider/src/ProviderTron.ts +++ b/packages/providers/onekey-tron-provider/src/ProviderTron.ts @@ -1,9 +1,9 @@ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ import dequal from 'fast-deep-equal'; -import TronWeb, { UnsignedTransaction, SignedTransaction } from 'tronweb/dist/TronWeb'; +import TronWeb, { UnsignedTransaction, SignedTransaction } from 'tronweb'; import SunWeb from 'sunweb'; -import { isEmpty } from 'lodash'; +import { isEmpty } from 'lodash-es'; import { IInpageProviderConfig, checkWalletSwitchEnable, diff --git a/packages/providers/onekey-tron-provider/src/types.ts b/packages/providers/onekey-tron-provider/src/types.ts index b590049d..aa0693b4 100644 --- a/packages/providers/onekey-tron-provider/src/types.ts +++ b/packages/providers/onekey-tron-provider/src/types.ts @@ -1,5 +1,5 @@ import { IJsonRpcRequest } from '@onekeyfe/cross-inpage-provider-types'; -import TronWeb, { UnsignedTransaction, SignedTransaction } from 'tronweb/dist/TronWeb'; +import TronWeb, { UnsignedTransaction, SignedTransaction } from 'tronweb'; import { ProviderTronBase } from './ProviderTronBase'; diff --git a/packages/providers/onekey-tron-provider/yarn.lock b/packages/providers/onekey-tron-provider/yarn.lock index c611250b..796ee7dc 100644 --- a/packages/providers/onekey-tron-provider/yarn.lock +++ b/packages/providers/onekey-tron-provider/yarn.lock @@ -254,6 +254,18 @@ resolved "https://registry.yarnpkg.com/@tronweb3/google-protobuf/-/google-protobuf-3.21.2.tgz#0964cf83ed7826d31c3cb4e4ecf07655681631c9" integrity sha512-IVcT2GfWX3K6tHUVhs14NP5uzKhQt4KeDya1g9ACxuZsUzsaoGUIGzceK2Ltu7xp1YV94AaHOf4yxLAivlvEkQ== +"@types/lodash-es@^4.17.12": + version "4.17.12" + resolved "https://registry.yarnpkg.com/@types/lodash-es/-/lodash-es-4.17.12.tgz#65f6d1e5f80539aa7cfbfc962de5def0cf4f341b" + integrity sha512-0NgftHUcV4v34VhXm8QBSftKVXtbkBG3ViCjs6+eJ5a6y6Mi/jiFGPc1sC7QK+9BFhWrURE3EOggmWaSxL9OzQ== + dependencies: + "@types/lodash" "*" + +"@types/lodash@*": + version "4.17.13" + resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.17.13.tgz#786e2d67cfd95e32862143abe7463a7f90c300eb" + integrity sha512-lfx+dftrEZcdBPczf9d0Qv0x+j/rfNCMuC6OcfXmO8gkfeNAY88PgKUbvG56whcN23gc27yenwF6oJZXGFpYxg== + "@types/node@18.15.13": version "18.15.13" resolved "https://registry.yarnpkg.com/@types/node/-/node-18.15.13.tgz#f64277c341150c979e42b00e4ac289290c9df469" @@ -410,6 +422,11 @@ js-sha3@0.8.0: resolved "https://registry.yarnpkg.com/js-sha3/-/js-sha3-0.8.0.tgz#b9b7a5da73afad7dedd0f8c463954cbde6818840" integrity sha512-gF1cRrHhIzNfToc802P800N8PpXS+evLLXfsVpowqmAFR9uwbi89WvXg2QspOmXL8QL86J4T1EpFu+yUkwJY3Q== +lodash-es@^4.17.21: + version "4.17.21" + resolved "https://registry.yarnpkg.com/lodash-es/-/lodash-es-4.17.21.tgz#43e626c46e6591b7750beb2b50117390c609e3ee" + integrity sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw== + lodash@^4.17.21: version "4.17.21" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"