Skip to content

Commit

Permalink
fix: not exists firmware crash issues (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
ByteZhang1024 authored Mar 21, 2024
1 parent 81386c7 commit 14b8441
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 56 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
"@headlessui/react": "^1.7.2",
"@heroicons/react": "^2.0.11",
"@noble/hashes": "^1.1.3",
"@onekeyfe/hd-core": "0.3.40",
"@onekeyfe/hd-shared": "0.3.40",
"@onekeyfe/hd-web-sdk": "0.3.40",
"@onekeyfe/hd-core": "0.3.41",
"@onekeyfe/hd-shared": "0.3.41",
"@onekeyfe/hd-web-sdk": "0.3.41",
"@onekeyfe/ui-components": "^1.0.0",
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.3",
"@reduxjs/toolkit": "^1.8.5",
Expand Down
2 changes: 1 addition & 1 deletion src/components/Firmware/Firmware.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ const ConfirmUpdate: FC = () => {
const firmwareField = selectedReleaseInfo?.firmwareField;
if (firmwareField) {
const version =
releaseMap[device.deviceType][firmwareField]?.[0].version;
releaseMap[device.deviceType]?.[firmwareField]?.[0]?.version;
const checkBridgeRelease = await serviceHardware.checkBridgeRelease(
version?.join('.') ?? ''
);
Expand Down
41 changes: 29 additions & 12 deletions src/components/Firmware/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,25 @@ const Table: FC<{ tabType: TabType }> = ({ tabType }) => {
device?.features ?? ({} as Features),
tabType
);
const releaseData = firmwareFields.map((firmwareField) => {
const item = releaseInfo[firmwareField];
const data = {
version:
Array.isArray(item?.[0].version) && item?.[0].version.join('.'),
changelog: item?.[0].changelog[locale],
data: item,
firmwareField,
};
return data;
});
setDataSource(releaseData as DataSource[]);
const releaseData = firmwareFields
.map((firmwareField) => {
const item = releaseInfo?.[firmwareField];
const firmwarePackage = item?.[0];

if (!firmwarePackage) return undefined;

const data = {
version:
Array.isArray(firmwarePackage.version) &&
firmwarePackage.version?.join('.'),
changelog: firmwarePackage.changelog?.[locale],
data: item,
firmwareField,
};
return data;
})
.filter((item) => item !== undefined) as DataSource[];
setDataSource(releaseData);
}, [getReleaseInfo, tabType, locale, device]);

return (
Expand Down Expand Up @@ -142,6 +149,16 @@ const Table: FC<{ tabType: TabType }> = ({ tabType }) => {
</td>
</tr>
))}
{dataSource.length === 0 && (
<tr>
<td
colSpan={2}
className="py-4 pl-4 pr-3 text-sm font-normal text-gray-700 sm:pl-6"
>
{intl.formatMessage({ id: 'TR_NO_FIRMWARE_AVAILABLE' })}
</td>
</tr>
)}
</tbody>
</table>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/hardware/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ class ServiceHardware {
params.binary = fw;
} else if (firmwareField) {
const version =
releaseMap[device.deviceType][firmwareField]?.[0].version;
releaseMap[device.deviceType][firmwareField]?.[0]?.version;
params.version = version;
}
params.updateType = state.runtime.selectedUploadType;
Expand Down
2 changes: 1 addition & 1 deletion src/hardware/instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const getHardwareSDKInstance = memoizee(
}
const settings: Partial<ConnectSettings> = {
debug: true,
connectSrc: 'https://jssdk.onekey.so/0.3.40/',
connectSrc: 'https://jssdk.onekey.so/0.3.41/',
preRelease: false,
fetchConfig: true,
};
Expand Down
5 changes: 3 additions & 2 deletions src/locales/en-US.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"TR_CLOSE": "close",
"TR_RES_REPAIR": "For OneKey Touch device, if there are problems such as picture display, you can click the fix button to restore the resources",
"TR_RES_REPAIR": "For {0} device, if there are problems such as picture display, you can click the fix button to restore the resources",
"TR_CLICK_TO_REPAIR": "click to fix",
"TR_FIRMWARE_UPDATE_1": "Please first upgrade your OneKey Touch firmware to {version} or above",
"TR_FIRMWARE_UPDATE_2": "current version",
Expand Down Expand Up @@ -230,5 +230,6 @@
"TR_ERASE_SUCCESS": "Erase device successfully",
"TR_USE_DESKTOP_CLIENT_TO_INSTALL": "Please use the OneKey desktop client to update",
"TR_REQUIRES_UPDATING_OF_ONEKEY_BRIDGE": "Requires updating of OneKey Bridge",
"TR_ONEKEY_BRIDGE_STR_IS_NOW_AVAILABLE_DO_YOU_WANT_TO_DOWNLOAD": "OneKey Bridge {0} is now available, Do you want to download?"
"TR_ONEKEY_BRIDGE_STR_IS_NOW_AVAILABLE_DO_YOU_WANT_TO_DOWNLOAD": "OneKey Bridge {0} is now available, Do you want to download?",
"TR_NO_FIRMWARE_AVAILABLE": "No firmware available"
}
3 changes: 2 additions & 1 deletion src/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -230,5 +230,6 @@
"TR_ERASE_SUCCESS": "擦除设备成功",
"TR_USE_DESKTOP_CLIENT_TO_INSTALL": "请使用 OneKey 桌面客户端更新",
"TR_REQUIRES_UPDATING_OF_ONEKEY_BRIDGE": "需要更新 OneKey Bridge",
"TR_ONEKEY_BRIDGE_STR_IS_NOW_AVAILABLE_DO_YOU_WANT_TO_DOWNLOAD": "OneKey Bridge {0} 现已发布,是否要前往下载?"
"TR_ONEKEY_BRIDGE_STR_IS_NOW_AVAILABLE_DO_YOU_WANT_TO_DOWNLOAD": "OneKey Bridge {0} 现已发布,是否要前往下载?",
"TR_NO_FIRMWARE_AVAILABLE": "没有可用的固件"
}
2 changes: 1 addition & 1 deletion src/utils/touchFirmware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const downloadLegacyTouchFirmware = async (
) => {
const state = store.getState();
const releaseMap = state.runtime.releaseMap;
const url = releaseMap.touch[firmwareField]?.[0].url;
const url = releaseMap.touch[firmwareField]?.[0]?.url;
const response = await axios.request({
url,
withCredentials: false,
Expand Down
68 changes: 34 additions & 34 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2156,61 +2156,61 @@
resolved "https://registry.yarnpkg.com/@onekeyfe/cross-inpage-provider-types/-/cross-inpage-provider-types-0.0.17.tgz#0c88c1a2febac44ec1600e0e59da732579cbd045"
integrity sha512-QqjIPXQHb3UG9w79ujjL5L5Qd6oCrymQ/x2J2rYICtr56G6shHTmUvRZxAvne0ZsLv8UBGqZWbepVdnPipehYQ==

"@onekeyfe/[email protected].40", "@onekeyfe/hd-core@^0.3.40":
version "0.3.40"
resolved "https://registry.yarnpkg.com/@onekeyfe/hd-core/-/hd-core-0.3.40.tgz#869f0f370228c0f971aed088ae6517bed336251f"
integrity sha512-c9ML8S8OMP/eIG7geKFm5O6XiGCsEMKZfKvwJV4TPARtBgkfW0TsTksRlQJpEGxm9hJKhQsQdCQIkXELXYlN7w==
"@onekeyfe/[email protected].41", "@onekeyfe/hd-core@^0.3.41":
version "0.3.41"
resolved "https://registry.yarnpkg.com/@onekeyfe/hd-core/-/hd-core-0.3.41.tgz#71dbd4db8ae3616e09ec78cf0b023ca49cb3d21d"
integrity sha512-g6txoAazxP84zBUHr8ig7LTrJ4gU2ZTLvn+Cms4ZVH97iH4lY06kfY8eJWZ09hrH+7ke4uXS5vLmi4UeLrtn/A==
dependencies:
"@onekeyfe/hd-shared" "^0.3.40"
"@onekeyfe/hd-transport" "^0.3.40"
"@onekeyfe/hd-shared" "^0.3.41"
"@onekeyfe/hd-transport" "^0.3.41"
axios "^0.27.2"
bignumber.js "^9.0.2"
bytebuffer "^5.0.1"
jszip "^3.10.1"
parse-uri "^1.0.7"
semver "^7.3.7"

"@onekeyfe/[email protected].40", "@onekeyfe/hd-shared@^0.3.40":
version "0.3.40"
resolved "https://registry.yarnpkg.com/@onekeyfe/hd-shared/-/hd-shared-0.3.40.tgz#cf655e6db8c46183313b79d24d69cfcd60dfbeab"
integrity sha512-AzhzTDtEyjYTmWj+ZFCCHLWmF70EyBNOZZh7aYpmkCUXdP7GQn1Wnf1bFkDrN3kU6pXJCR6roxC1PCGeE3n0dQ==
"@onekeyfe/[email protected].41", "@onekeyfe/hd-shared@^0.3.41":
version "0.3.41"
resolved "https://registry.yarnpkg.com/@onekeyfe/hd-shared/-/hd-shared-0.3.41.tgz#17524e7657c9aebad93c103b963aa3fd1619da66"
integrity sha512-PwlVCqCYArbzijhKUpik9lxfeSgQBZZoB4HD5JuihOQ3KSkSFvNMbswqD+Xv629lUSBHIfHiAyHmX7vLwQa2Aw==

"@onekeyfe/hd-transport-http@^0.3.40":
version "0.3.40"
resolved "https://registry.yarnpkg.com/@onekeyfe/hd-transport-http/-/hd-transport-http-0.3.40.tgz#0bc7ba04a0e619dd5744ac86f478ab83ba288c03"
integrity sha512-+iQowv+Z3fDDskByk0ZiKlDgv+WCz1lRqsGhTpoHzlYpYalGN/iKjaoFOWGD0w5mm8na36np0F8FO7tXC6YnXg==
"@onekeyfe/hd-transport-http@^0.3.41":
version "0.3.41"
resolved "https://registry.yarnpkg.com/@onekeyfe/hd-transport-http/-/hd-transport-http-0.3.41.tgz#12ba68a4ee8725d91dc57f3ad99cc62e6cd2de59"
integrity sha512-+0Q0OGZ+nrN4z0wq11OJhr9JMZ5UsgNUM0p4+BL0lSr0jpcO6ukiRA9b/4Se9K711TZyLjXc6AwUsg7u4RE6RQ==
dependencies:
"@onekeyfe/hd-shared" "^0.3.40"
"@onekeyfe/hd-transport" "^0.3.40"
"@onekeyfe/hd-shared" "^0.3.41"
"@onekeyfe/hd-transport" "^0.3.41"
axios "^0.27.2"

"@onekeyfe/hd-transport-webusb@^0.3.40":
version "0.3.40"
resolved "https://registry.yarnpkg.com/@onekeyfe/hd-transport-webusb/-/hd-transport-webusb-0.3.40.tgz#87215bab920f1ff56abe004f74e1fd1d3254f87d"
integrity sha512-ma9NTLMxznZlavxeFMd0b02T4/urGOCLFK7EuH187Hyeq1QGK6QlK7FQS20Qwc/4NMH5xyEJl8Xggrofw6FXQg==
"@onekeyfe/hd-transport-webusb@^0.3.41":
version "0.3.41"
resolved "https://registry.yarnpkg.com/@onekeyfe/hd-transport-webusb/-/hd-transport-webusb-0.3.41.tgz#98a6a36a4f804200f2e7b5c59d3ff8b895d3ce21"
integrity sha512-OJRR9eYzowABC1zNa/edEIYp8B299mRxNLKutyYecQhbDarBTX3LqQERppdnRy4Ptmrgm/Lz/mqKXdegoeUkXg==
dependencies:
"@onekeyfe/hd-shared" "^0.3.40"
"@onekeyfe/hd-transport" "^0.3.40"
"@onekeyfe/hd-shared" "^0.3.41"
"@onekeyfe/hd-transport" "^0.3.41"

"@onekeyfe/hd-transport@^0.3.40":
version "0.3.40"
resolved "https://registry.yarnpkg.com/@onekeyfe/hd-transport/-/hd-transport-0.3.40.tgz#380566709289ac4085f6c25f312afa15669e0687"
integrity sha512-m0IuPrdd9pwvTxt8809MzlixCW1NHrrVBsYY95Fgn+7xSiKboBrGJV2Lih1oHvHOH4bKJoxgpKDMFOjMDBTyuA==
"@onekeyfe/hd-transport@^0.3.41":
version "0.3.41"
resolved "https://registry.yarnpkg.com/@onekeyfe/hd-transport/-/hd-transport-0.3.41.tgz#fb869085dfc1d7926533181762d04ccac40bfd87"
integrity sha512-vXctzTv4mLEuALjgo98ROpQL/Y1hjAheixe9IDVAPOGsxtfA5ioCGjt2jjdOLRw30a92bcHRWmuYDV0tG5irkg==
dependencies:
bytebuffer "^5.0.1"
long "^4.0.0"
protobufjs "^6.11.2"

"@onekeyfe/[email protected].40":
version "0.3.40"
resolved "https://registry.yarnpkg.com/@onekeyfe/hd-web-sdk/-/hd-web-sdk-0.3.40.tgz#c79d57c073f16ddfdb9efb84e88515d0ee81e779"
integrity sha512-9n51ViweBEfdDGY8C/sVrUvl175pqbhq6+xrc6548NpgZe1Dd/BPP3g3SM3br1fPNbOa03Z1u3PRbLxQ/WvDoQ==
"@onekeyfe/[email protected].41":
version "0.3.41"
resolved "https://registry.yarnpkg.com/@onekeyfe/hd-web-sdk/-/hd-web-sdk-0.3.41.tgz#f9ad7404fa9d5b2f5a957f0a83408b41cd6c139a"
integrity sha512-6AMu1c3seSX+LF5HecKbXSlDZp8ATrQQtEToiqS+ViMIwftyZDKYVR9wdWYlC5Ubm/TF3MCcn+7BIHHywXfQkw==
dependencies:
"@onekeyfe/cross-inpage-provider-core" "^0.0.17"
"@onekeyfe/hd-core" "^0.3.40"
"@onekeyfe/hd-shared" "^0.3.40"
"@onekeyfe/hd-transport-http" "^0.3.40"
"@onekeyfe/hd-transport-webusb" "^0.3.40"
"@onekeyfe/hd-core" "^0.3.41"
"@onekeyfe/hd-shared" "^0.3.41"
"@onekeyfe/hd-transport-http" "^0.3.41"
"@onekeyfe/hd-transport-webusb" "^0.3.41"

"@onekeyfe/ui-components@^1.0.0":
version "1.0.0"
Expand Down

0 comments on commit 14b8441

Please sign in to comment.