diff --git a/packages/connect-examples/electron-example/package.json b/packages/connect-examples/electron-example/package.json index 1bdf2aa73..451194192 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-alpha.0", + "version": "1.0.15-alpha.1", "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 0dd07181c..05a1ab5bd 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-alpha.0", + "version": "1.0.15-alpha.1", "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-alpha.0", - "@onekeyfe/hd-common-connect-sdk": "^1.0.15-alpha.0", - "@onekeyfe/hd-core": "^1.0.15-alpha.0", - "@onekeyfe/hd-web-sdk": "^1.0.15-alpha.0", + "@onekeyfe/hd-ble-sdk": "^1.0.15-alpha.1", + "@onekeyfe/hd-common-connect-sdk": "^1.0.15-alpha.1", + "@onekeyfe/hd-core": "^1.0.15-alpha.1", + "@onekeyfe/hd-web-sdk": "^1.0.15-alpha.1", "@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/package.json b/packages/core/package.json index 5134763b8..98299ad46 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@onekeyfe/hd-core", - "version": "1.0.15-alpha.0", + "version": "1.0.15-alpha.1", "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-alpha.0", - "@onekeyfe/hd-transport": "^1.0.15-alpha.0", + "@onekeyfe/hd-shared": "^1.0.15-alpha.1", + "@onekeyfe/hd-transport": "^1.0.15-alpha.1", "axios": "^0.27.2", "bignumber.js": "^9.0.2", "bytebuffer": "^5.0.1", diff --git a/packages/core/src/api/benfen/BenfenGetAddress.ts b/packages/core/src/api/benfen/BenfenGetAddress.ts index 3050ba7c1..270b5c6bf 100644 --- a/packages/core/src/api/benfen/BenfenGetAddress.ts +++ b/packages/core/src/api/benfen/BenfenGetAddress.ts @@ -4,7 +4,7 @@ import { BaseMethod } from '../BaseMethod'; import { validateParams, validateResult } from '../helpers/paramsValidator'; import { serializedPath, validatePath } from '../helpers/pathUtils'; import { UI_REQUEST } from '../../constants/ui-request'; -import { publicKeyToAddress } from './normalize'; +import { hex2BfcAddress, publicKeyToAddress } from './normalize'; import { BenfenAddress, BenfenGetAddressParams } from '../../types'; import { supportBatchPublicKey } from '../../utils/deviceFeaturesUtils'; @@ -77,14 +77,15 @@ export default class BenfenGetAddress extends BaseMethod { validateParams(this.payload, [ { name: 'path', required: true }, { name: 'rawTx', type: 'hexString', required: true }, - { name: 'coinType', type: 'hexString', required: true }, + { name: 'coinType', type: 'string', required: true }, ]); const { path, rawTx, coinType } = this.payload; const addressN = validatePath(path, 3); + const coinTypeHex = coinType.startsWith('0x') + ? coinType.slice(2) + : Buffer.from(coinType).toString('hex'); this.params = { address_n: addressN, raw_tx: formatAnyHex(rawTx), - coin_type: formatAnyHex(coinType), + coin_type: formatAnyHex(coinTypeHex), }; } diff --git a/packages/core/src/api/benfen/normalize.ts b/packages/core/src/api/benfen/normalize.ts index e0ec6e4a1..3cbea04b3 100644 --- a/packages/core/src/api/benfen/normalize.ts +++ b/packages/core/src/api/benfen/normalize.ts @@ -1,5 +1,6 @@ import { bytesToHex, hexToBytes } from '@noble/hashes/utils'; import { blake2b } from '@noble/hashes/blake2b'; +import { sha256 } from '@noble/hashes/sha256'; export const BENFEN_ADDRESS_LENGTH = 32; export const PUBLIC_KEY_SIZE = 32; @@ -25,3 +26,20 @@ export function publicKeyToAddress(publicKey: string) { bytesToHex(blake2b(tmp, { dkLen: 32 })).slice(0, BENFEN_ADDRESS_LENGTH * 2) ); } + +export function hex2BfcAddress(hexAddress: string): string { + // 如果已经是BFC格式,直接返回 + if (/^BFC/i.test(hexAddress)) { + return hexAddress; + } + + // 移除0x前缀,补齐64位,转小写 + const hex = hexAddress.replace(/^0x/, '').padStart(64, '0').toLowerCase(); + + // 使用SHA-256计算校验和 + const hash = sha256(new TextEncoder().encode(hex)); + const checksumHex = bytesToHex(hash).slice(0, 4); + + // 返回BFC格式地址 + return `BFC${hex}${checksumHex}`; +} diff --git a/packages/core/src/api/sui/SuiGetAddress.ts b/packages/core/src/api/sui/SuiGetAddress.ts index dc49c578f..a92dd4125 100644 --- a/packages/core/src/api/sui/SuiGetAddress.ts +++ b/packages/core/src/api/sui/SuiGetAddress.ts @@ -80,7 +80,7 @@ export default class SuiGetAddress extends BaseMethod { 'SuiAddress', param ); - address = addressRes.message.address?.toLowerCase() ?? ''; + address = addressRes.message.address?.toLowerCase(); } else { address = publicKeyToAddress(publicKey); } diff --git a/packages/hd-ble-sdk/package.json b/packages/hd-ble-sdk/package.json index 000bfdc05..ede54a309 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-alpha.0", + "version": "1.0.15-alpha.1", "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-alpha.0", - "@onekeyfe/hd-shared": "^1.0.15-alpha.0", - "@onekeyfe/hd-transport-react-native": "^1.0.15-alpha.0" + "@onekeyfe/hd-core": "^1.0.15-alpha.1", + "@onekeyfe/hd-shared": "^1.0.15-alpha.1", + "@onekeyfe/hd-transport-react-native": "^1.0.15-alpha.1" } } diff --git a/packages/hd-common-connect-sdk/package.json b/packages/hd-common-connect-sdk/package.json index b1d229f71..187428894 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-alpha.0", + "version": "1.0.15-alpha.1", "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-alpha.0", - "@onekeyfe/hd-shared": "^1.0.15-alpha.0", - "@onekeyfe/hd-transport-http": "^1.0.15-alpha.0", - "@onekeyfe/hd-transport-lowlevel": "^1.0.15-alpha.0", - "@onekeyfe/hd-transport-webusb": "^1.0.15-alpha.0" + "@onekeyfe/hd-core": "^1.0.15-alpha.1", + "@onekeyfe/hd-shared": "^1.0.15-alpha.1", + "@onekeyfe/hd-transport-http": "^1.0.15-alpha.1", + "@onekeyfe/hd-transport-lowlevel": "^1.0.15-alpha.1", + "@onekeyfe/hd-transport-webusb": "^1.0.15-alpha.1" } } diff --git a/packages/hd-transport-http/package.json b/packages/hd-transport-http/package.json index 85c4e95ae..8e6dfa43f 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-alpha.0", + "version": "1.0.15-alpha.1", "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-alpha.0", - "@onekeyfe/hd-transport": "^1.0.15-alpha.0", + "@onekeyfe/hd-shared": "^1.0.15-alpha.1", + "@onekeyfe/hd-transport": "^1.0.15-alpha.1", "axios": "^0.27.2" } } diff --git a/packages/hd-transport-lowlevel/package.json b/packages/hd-transport-lowlevel/package.json index b5e156fca..b1d311322 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-alpha.0", + "version": "1.0.15-alpha.1", "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-alpha.0", - "@onekeyfe/hd-transport": "^1.0.15-alpha.0" + "@onekeyfe/hd-shared": "^1.0.15-alpha.1", + "@onekeyfe/hd-transport": "^1.0.15-alpha.1" } } diff --git a/packages/hd-transport-react-native/package.json b/packages/hd-transport-react-native/package.json index db8103903..d02aa5796 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-alpha.0", + "version": "1.0.15-alpha.1", "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-alpha.0", - "@onekeyfe/hd-transport": "^1.0.15-alpha.0", + "@onekeyfe/hd-shared": "^1.0.15-alpha.1", + "@onekeyfe/hd-transport": "^1.0.15-alpha.1", "@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 f20ce9fbd..da745c802 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-alpha.0", + "version": "1.0.15-alpha.1", "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-alpha.0", - "@onekeyfe/hd-transport": "^1.0.15-alpha.0" + "@onekeyfe/hd-shared": "^1.0.15-alpha.1", + "@onekeyfe/hd-transport": "^1.0.15-alpha.1" }, "devDependencies": { "@types/w3c-web-usb": "^1.0.6" diff --git a/packages/hd-transport/package.json b/packages/hd-transport/package.json index 521c7826b..685898ade 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-alpha.0", + "version": "1.0.15-alpha.1", "description": "> TODO: description", "author": "OneKey", "homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme", diff --git a/packages/hd-transport/src/types/messages.ts b/packages/hd-transport/src/types/messages.ts index f28300082..e75d32577 100644 --- a/packages/hd-transport/src/types/messages.ts +++ b/packages/hd-transport/src/types/messages.ts @@ -141,7 +141,7 @@ export type BenfenGetAddress = { // BenfenAddress export type BenfenAddress = { - address?: string; + address: string; }; // BenfenSignTx @@ -3720,7 +3720,7 @@ export type SuiGetAddress = { // SuiAddress export type SuiAddress = { - address?: string; + address: string; }; // SuiSignTx diff --git a/packages/hd-web-sdk/package.json b/packages/hd-web-sdk/package.json index 6183c68a0..dd47e6744 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-alpha.0", + "version": "1.0.15-alpha.1", "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-alpha.0", - "@onekeyfe/hd-shared": "^1.0.15-alpha.0", - "@onekeyfe/hd-transport-http": "^1.0.15-alpha.0", - "@onekeyfe/hd-transport-webusb": "^1.0.15-alpha.0" + "@onekeyfe/hd-core": "^1.0.15-alpha.1", + "@onekeyfe/hd-shared": "^1.0.15-alpha.1", + "@onekeyfe/hd-transport-http": "^1.0.15-alpha.1", + "@onekeyfe/hd-transport-webusb": "^1.0.15-alpha.1" }, "devDependencies": { "@babel/plugin-proposal-optional-chaining": "^7.17.12", diff --git a/packages/shared/package.json b/packages/shared/package.json index fc0acc608..88774453d 100644 --- a/packages/shared/package.json +++ b/packages/shared/package.json @@ -1,6 +1,6 @@ { "name": "@onekeyfe/hd-shared", - "version": "1.0.15-alpha.0", + "version": "1.0.15-alpha.1", "description": "Hardware SDK's shared tool library", "keywords": [ "Hardware-SDK",