diff --git a/packages/connect-examples/electron-example/package.json b/packages/connect-examples/electron-example/package.json index 06e53fc65..72c3daa33 100644 --- a/packages/connect-examples/electron-example/package.json +++ b/packages/connect-examples/electron-example/package.json @@ -2,7 +2,7 @@ "name": "hardware-example", "productName": "HardwareExample", "executableName": "onekey-hardware-example", - "version": "1.0.15", + "version": "1.0.16-alpha.0", "author": "OneKey", "description": "End-to-end encrypted workspaces for teams", "main": "dist/index.js", diff --git a/packages/connect-examples/expo-example/package.json b/packages/connect-examples/expo-example/package.json index 78b9cebe9..466d9ecb6 100644 --- a/packages/connect-examples/expo-example/package.json +++ b/packages/connect-examples/expo-example/package.json @@ -1,6 +1,6 @@ { "name": "expo-example", - "version": "1.0.15", + "version": "1.0.16-alpha.0", "scripts": { "start": "CONNECT_SRC=https://localhost:8087/ yarn expo start --dev-client", "android": "yarn expo run:android", @@ -19,10 +19,10 @@ "@noble/ed25519": "^2.1.0", "@noble/hashes": "^1.3.3", "@noble/secp256k1": "^1.7.1", - "@onekeyfe/hd-ble-sdk": "^1.0.15", - "@onekeyfe/hd-common-connect-sdk": "^1.0.15", - "@onekeyfe/hd-core": "^1.0.15", - "@onekeyfe/hd-web-sdk": "^1.0.15", + "@onekeyfe/hd-ble-sdk": "^1.0.16-alpha.0", + "@onekeyfe/hd-common-connect-sdk": "^1.0.16-alpha.0", + "@onekeyfe/hd-core": "^1.0.16-alpha.0", + "@onekeyfe/hd-web-sdk": "^1.0.16-alpha.0", "@onekeyfe/react-native-ble-plx": "3.0.0", "@polkadot/util-crypto": "13.1.1", "@react-native-async-storage/async-storage": "1.21.0", diff --git a/packages/core/__tests__/benfen.test.ts b/packages/core/__tests__/benfen.test.ts new file mode 100644 index 000000000..e63198688 --- /dev/null +++ b/packages/core/__tests__/benfen.test.ts @@ -0,0 +1,16 @@ +import { publicKeyToAddress, hex2BfcAddress } from '../src/api/benfen/normalize'; + +describe('Benfen Address Normalization', () => { + it('publicKeyToBFCAddress', () => { + // Test case with a known public key and its expected address + const publicKey = '6e9c9ef745cc3a250168db15526d18075dc52849d49f8a6ea5477c1c264b4848'; + const expectedHexAddress = '0xb4ced58018b75d7ba72a10fa97c09b7bf66533ff104bf9db1bfdb004b17d8eaa'; + const expectedAddress = + 'BFCb4ced58018b75d7ba72a10fa97c09b7bf66533ff104bf9db1bfdb004b17d8eaa2e35'; + + const hexAddress = publicKeyToAddress(publicKey); + const bfcAddress = hex2BfcAddress(hexAddress); + expect(hexAddress).toBe(expectedHexAddress); + expect(bfcAddress).toBe(expectedAddress); + }); +}); diff --git a/packages/core/__tests__/checkBootloaderReleast.test.js b/packages/core/__tests__/checkBootloaderReleast.test.js index 421a27418..e6b2ee107 100644 --- a/packages/core/__tests__/checkBootloaderReleast.test.js +++ b/packages/core/__tests__/checkBootloaderReleast.test.js @@ -1,5 +1,11 @@ /* eslint-disable @typescript-eslint/no-var-requires */ -const { shouldUpdateBootloaderForClassicAndMini } = require('../src/api/firmware/bootloaderHelper'); +import { shouldUpdateBootloaderForClassicAndMini } from '../src/api/firmware/bootloaderHelper'; + +// Add mock for config module +jest.mock('../src/data/config', () => ({ + getSDKVersion: () => '1.0.0', + DEFAULT_DOMAIN: 'https://jssdk.onekey.so/1.0.0/', +})); const fixtures = [ { diff --git a/packages/core/jest.config.js b/packages/core/jest.config.js index 4c22e9dfb..4f08d66df 100644 --- a/packages/core/jest.config.js +++ b/packages/core/jest.config.js @@ -2,4 +2,5 @@ module.exports = { preset: '../../jest.config.js', testEnvironment: 'node', modulePathIgnorePatterns: ['node_modules', '/lib', '/libDev'], + collectCoverage: true, }; diff --git a/packages/core/package.json b/packages/core/package.json index ad4cf3cd7..1dea384e1 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@onekeyfe/hd-core", - "version": "1.0.15", + "version": "1.0.16-alpha.0", "description": "> TODO: description", "author": "OneKey", "homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme", @@ -25,8 +25,8 @@ "url": "https://github.com/OneKeyHQ/hardware-js-sdk/issues" }, "dependencies": { - "@onekeyfe/hd-shared": "^1.0.15", - "@onekeyfe/hd-transport": "^1.0.15", + "@onekeyfe/hd-shared": "^1.0.16-alpha.0", + "@onekeyfe/hd-transport": "^1.0.16-alpha.0", "axios": "^0.27.2", "bignumber.js": "^9.0.2", "bytebuffer": "^5.0.1", diff --git a/packages/core/src/api/benfen/normalize.ts b/packages/core/src/api/benfen/normalize.ts index b05351993..2cb4bd0f6 100644 --- a/packages/core/src/api/benfen/normalize.ts +++ b/packages/core/src/api/benfen/normalize.ts @@ -43,7 +43,7 @@ export function hex2BfcAddress(hexAddress: string): string { const hex = hexAddress.replace(/^0x/, '').padStart(64, '0').toLowerCase(); // 使用SHA-256计算校验和 - const hash = sha256(hexToBytes(hex)); + const hash = sha256(new TextEncoder().encode(hex)); const checksumHex = bytesToHex(hash).slice(0, 4); // 返回BFC格式地址 diff --git a/packages/hd-ble-sdk/package.json b/packages/hd-ble-sdk/package.json index 7d678cfcd..f0e62b5c6 100644 --- a/packages/hd-ble-sdk/package.json +++ b/packages/hd-ble-sdk/package.json @@ -1,6 +1,6 @@ { "name": "@onekeyfe/hd-ble-sdk", - "version": "1.0.15", + "version": "1.0.16-alpha.0", "author": "OneKey", "homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme", "license": "ISC", @@ -20,8 +20,8 @@ "lint:fix": "eslint . --fix" }, "dependencies": { - "@onekeyfe/hd-core": "^1.0.15", - "@onekeyfe/hd-shared": "^1.0.15", - "@onekeyfe/hd-transport-react-native": "^1.0.15" + "@onekeyfe/hd-core": "^1.0.16-alpha.0", + "@onekeyfe/hd-shared": "^1.0.16-alpha.0", + "@onekeyfe/hd-transport-react-native": "^1.0.16-alpha.0" } } diff --git a/packages/hd-common-connect-sdk/package.json b/packages/hd-common-connect-sdk/package.json index ef4671c2b..062e97dc0 100644 --- a/packages/hd-common-connect-sdk/package.json +++ b/packages/hd-common-connect-sdk/package.json @@ -1,6 +1,6 @@ { "name": "@onekeyfe/hd-common-connect-sdk", - "version": "1.0.15", + "version": "1.0.16-alpha.0", "author": "OneKey", "homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme", "license": "ISC", @@ -20,10 +20,10 @@ "lint:fix": "eslint . --fix" }, "dependencies": { - "@onekeyfe/hd-core": "^1.0.15", - "@onekeyfe/hd-shared": "^1.0.15", - "@onekeyfe/hd-transport-http": "^1.0.15", - "@onekeyfe/hd-transport-lowlevel": "^1.0.15", - "@onekeyfe/hd-transport-webusb": "^1.0.15" + "@onekeyfe/hd-core": "^1.0.16-alpha.0", + "@onekeyfe/hd-shared": "^1.0.16-alpha.0", + "@onekeyfe/hd-transport-http": "^1.0.16-alpha.0", + "@onekeyfe/hd-transport-lowlevel": "^1.0.16-alpha.0", + "@onekeyfe/hd-transport-webusb": "^1.0.16-alpha.0" } } diff --git a/packages/hd-transport-http/package.json b/packages/hd-transport-http/package.json index 755c128fc..ad23bdab4 100644 --- a/packages/hd-transport-http/package.json +++ b/packages/hd-transport-http/package.json @@ -1,6 +1,6 @@ { "name": "@onekeyfe/hd-transport-http", - "version": "1.0.15", + "version": "1.0.16-alpha.0", "description": "hardware http transport", "author": "OneKey", "homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme", @@ -24,8 +24,8 @@ "url": "https://github.com/OneKeyHQ/hardware-js-sdk/issues" }, "dependencies": { - "@onekeyfe/hd-shared": "^1.0.15", - "@onekeyfe/hd-transport": "^1.0.15", + "@onekeyfe/hd-shared": "^1.0.16-alpha.0", + "@onekeyfe/hd-transport": "^1.0.16-alpha.0", "axios": "^0.27.2" } } diff --git a/packages/hd-transport-lowlevel/package.json b/packages/hd-transport-lowlevel/package.json index 9bbafff27..5478cc810 100644 --- a/packages/hd-transport-lowlevel/package.json +++ b/packages/hd-transport-lowlevel/package.json @@ -1,6 +1,6 @@ { "name": "@onekeyfe/hd-transport-lowlevel", - "version": "1.0.15", + "version": "1.0.16-alpha.0", "homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme", "license": "MIT", "main": "dist/index.js", @@ -19,7 +19,7 @@ "lint:fix": "eslint . --fix" }, "dependencies": { - "@onekeyfe/hd-shared": "^1.0.15", - "@onekeyfe/hd-transport": "^1.0.15" + "@onekeyfe/hd-shared": "^1.0.16-alpha.0", + "@onekeyfe/hd-transport": "^1.0.16-alpha.0" } } diff --git a/packages/hd-transport-react-native/package.json b/packages/hd-transport-react-native/package.json index 81d14eb96..a6d8fc2ea 100644 --- a/packages/hd-transport-react-native/package.json +++ b/packages/hd-transport-react-native/package.json @@ -1,6 +1,6 @@ { "name": "@onekeyfe/hd-transport-react-native", - "version": "1.0.15", + "version": "1.0.16-alpha.0", "homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme", "license": "MIT", "main": "dist/index.js", @@ -19,8 +19,8 @@ "lint:fix": "eslint . --fix" }, "dependencies": { - "@onekeyfe/hd-shared": "^1.0.15", - "@onekeyfe/hd-transport": "^1.0.15", + "@onekeyfe/hd-shared": "^1.0.16-alpha.0", + "@onekeyfe/hd-transport": "^1.0.16-alpha.0", "@onekeyfe/react-native-ble-plx": "3.0.1", "react-native-ble-manager": "^8.1.0" } diff --git a/packages/hd-transport-webusb/package.json b/packages/hd-transport-webusb/package.json index d0f78ac27..2d3949976 100644 --- a/packages/hd-transport-webusb/package.json +++ b/packages/hd-transport-webusb/package.json @@ -1,6 +1,6 @@ { "name": "@onekeyfe/hd-transport-webusb", - "version": "1.0.15", + "version": "1.0.16-alpha.0", "author": "OneKey", "homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme", "license": "MIT", @@ -20,8 +20,8 @@ "lint:fix": "eslint . --fix" }, "dependencies": { - "@onekeyfe/hd-shared": "^1.0.15", - "@onekeyfe/hd-transport": "^1.0.15" + "@onekeyfe/hd-shared": "^1.0.16-alpha.0", + "@onekeyfe/hd-transport": "^1.0.16-alpha.0" }, "devDependencies": { "@types/w3c-web-usb": "^1.0.6" diff --git a/packages/hd-transport/package.json b/packages/hd-transport/package.json index b560bf97f..e410bc3ca 100644 --- a/packages/hd-transport/package.json +++ b/packages/hd-transport/package.json @@ -1,6 +1,6 @@ { "name": "@onekeyfe/hd-transport", - "version": "1.0.15", + "version": "1.0.16-alpha.0", "description": "> TODO: description", "author": "OneKey", "homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme", diff --git a/packages/hd-web-sdk/package.json b/packages/hd-web-sdk/package.json index 282790362..1ab06f882 100644 --- a/packages/hd-web-sdk/package.json +++ b/packages/hd-web-sdk/package.json @@ -1,6 +1,6 @@ { "name": "@onekeyfe/hd-web-sdk", - "version": "1.0.15", + "version": "1.0.16-alpha.0", "author": "OneKey", "homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme", "license": "ISC", @@ -21,10 +21,10 @@ }, "dependencies": { "@onekeyfe/cross-inpage-provider-core": "^0.0.17", - "@onekeyfe/hd-core": "^1.0.15", - "@onekeyfe/hd-shared": "^1.0.15", - "@onekeyfe/hd-transport-http": "^1.0.15", - "@onekeyfe/hd-transport-webusb": "^1.0.15" + "@onekeyfe/hd-core": "^1.0.16-alpha.0", + "@onekeyfe/hd-shared": "^1.0.16-alpha.0", + "@onekeyfe/hd-transport-http": "^1.0.16-alpha.0", + "@onekeyfe/hd-transport-webusb": "^1.0.16-alpha.0" }, "devDependencies": { "@babel/plugin-proposal-optional-chaining": "^7.17.12", diff --git a/packages/shared/package.json b/packages/shared/package.json index 56a0f32c7..55bf8b176 100644 --- a/packages/shared/package.json +++ b/packages/shared/package.json @@ -1,6 +1,6 @@ { "name": "@onekeyfe/hd-shared", - "version": "1.0.15", + "version": "1.0.16-alpha.0", "description": "Hardware SDK's shared tool library", "keywords": [ "Hardware-SDK",