@onekeyfe/hd-core 1.2.0-alpha.107 → 1.2.0-alpha.108
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__tests__/DeviceCommands.test.ts +140 -26
- package/__tests__/base64Data.test.ts +70 -0
- package/__tests__/device-lifecycle-events.test.ts +113 -2
- package/__tests__/device-pool-state.test.ts +25 -0
- package/__tests__/deviceSettings.test.ts +0 -1
- package/__tests__/deviceUploadNft.test.ts +33 -4
- package/__tests__/firmware-update/firmware-update-v4-install-poll.test.ts +178 -0
- package/__tests__/get-device-state.test.ts +52 -13
- package/__tests__/logBlockEvent.test.ts +13 -1
- package/__tests__/protocol-v2.test.ts +762 -124
- package/__tests__/refresh-device-state.test.ts +3 -1
- package/__tests__/resourceBase64Boundary.test.ts +48 -0
- package/__tests__/ton-sign-message.test.ts +84 -0
- package/dist/api/FirmwareUpdateV4.d.ts +10 -3
- package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
- package/dist/api/UploadPortfolio.d.ts +1 -1
- package/dist/api/UploadPortfolio.d.ts.map +1 -1
- package/dist/api/helpers/base64Data.d.ts +16 -0
- package/dist/api/helpers/base64Data.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceUploadNft.d.ts +2 -3
- package/dist/api/protocol-v2/DeviceUploadNft.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceUploadWallpaper.d.ts +2 -3
- package/dist/api/protocol-v2/DeviceUploadWallpaper.d.ts.map +1 -1
- package/dist/api/ton/TonSignMessage.d.ts.map +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/device/Device.d.ts +7 -2
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/device/DeviceCommands.d.ts.map +1 -1
- package/dist/device/DevicePool.d.ts.map +1 -1
- package/dist/events/logBlockEvent.d.ts.map +1 -1
- package/dist/index.d.ts +11 -14
- package/dist/index.js +455 -200
- package/dist/protocols/protocol-v2/features.d.ts +9 -1
- package/dist/protocols/protocol-v2/features.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/index.d.ts +2 -2
- package/dist/protocols/protocol-v2/index.d.ts.map +1 -1
- package/dist/types/api/protocolV2.d.ts +1 -1
- package/dist/types/api/protocolV2.d.ts.map +1 -1
- package/dist/utils/pro2Nft.d.ts +7 -0
- package/dist/utils/pro2Nft.d.ts.map +1 -1
- package/package.json +6 -4
- package/src/api/FirmwareUpdateV4.ts +326 -174
- package/src/api/UploadPortfolio.ts +9 -2
- package/src/api/helpers/base64Data.ts +85 -0
- package/src/api/protocol-v2/DeviceUploadNft.ts +56 -8
- package/src/api/protocol-v2/DeviceUploadWallpaper.ts +37 -18
- package/src/api/ton/TonSignMessage.ts +5 -3
- package/src/core/index.ts +6 -2
- package/src/device/Device.ts +53 -31
- package/src/device/DeviceCommands.ts +4 -14
- package/src/device/DevicePool.ts +6 -2
- package/src/events/logBlockEvent.ts +14 -1
- package/src/protocols/protocol-v2/features.ts +19 -2
- package/src/protocols/protocol-v2/index.ts +2 -0
- package/src/types/api/protocolV2.ts +1 -1
- package/src/utils/deviceSettings.ts +1 -1
- package/src/utils/pro2Nft.ts +31 -8
|
@@ -68,7 +68,7 @@ export declare function deviceUploadNft(
|
|
|
68
68
|
export declare function uploadPortfolio(
|
|
69
69
|
connectId: string,
|
|
70
70
|
params: {
|
|
71
|
-
|
|
71
|
+
packageBase64: string;
|
|
72
72
|
timeoutMs?: number | string;
|
|
73
73
|
}
|
|
74
74
|
): Response<FileInfo & { portfolioUpdated: true }>;
|
|
@@ -200,7 +200,7 @@ export const getAutoShutDownOptions = (
|
|
|
200
200
|
return withNever([60_000, 120_000, 300_000, 600_000], protocol);
|
|
201
201
|
case EDeviceType.Pro2:
|
|
202
202
|
case EDeviceType.Neo:
|
|
203
|
-
return withNever([60_000, 120_000, 300_000, 600_000
|
|
203
|
+
return withNever([60_000, 120_000, 300_000, 600_000], protocol);
|
|
204
204
|
default:
|
|
205
205
|
return [];
|
|
206
206
|
}
|
package/src/utils/pro2Nft.ts
CHANGED
|
@@ -109,6 +109,34 @@ export function buildPro2NftBundle(options: {
|
|
|
109
109
|
const { image, thumbnail, title, subtitle, timestampMs } = options;
|
|
110
110
|
assertImage('image', image, PRO2_NFT_IMAGE_WIDTH, PRO2_NFT_IMAGE_HEIGHT);
|
|
111
111
|
assertImage('thumbnail', thumbnail, PRO2_NFT_THUMBNAIL_WIDTH, PRO2_NFT_THUMBNAIL_HEIGHT);
|
|
112
|
+
const encodedImage = encodePro2Image({ ...image, alphaMode: 'black-background' }).data;
|
|
113
|
+
const encodedThumbnail = encodePro2Image({
|
|
114
|
+
...thumbnail,
|
|
115
|
+
alphaMode: 'black-background',
|
|
116
|
+
}).data;
|
|
117
|
+
return buildPro2NftBundleFromEncodedImages({
|
|
118
|
+
image: encodedImage,
|
|
119
|
+
thumbnail: encodedThumbnail,
|
|
120
|
+
title,
|
|
121
|
+
subtitle,
|
|
122
|
+
timestampMs,
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export function buildPro2NftBundleFromEncodedImages(options: {
|
|
127
|
+
image: Uint8Array;
|
|
128
|
+
thumbnail: Uint8Array;
|
|
129
|
+
title: string;
|
|
130
|
+
subtitle: string;
|
|
131
|
+
timestampMs: number;
|
|
132
|
+
}): Pro2NftBundle {
|
|
133
|
+
const { image, thumbnail, title, subtitle, timestampMs } = options;
|
|
134
|
+
if (!(image instanceof Uint8Array) || image.byteLength === 0) {
|
|
135
|
+
throw invalidParameter('Parameter [image] must contain encoded NFT image data.');
|
|
136
|
+
}
|
|
137
|
+
if (!(thumbnail instanceof Uint8Array) || thumbnail.byteLength === 0) {
|
|
138
|
+
throw invalidParameter('Parameter [thumbnail] must contain encoded NFT thumbnail data.');
|
|
139
|
+
}
|
|
112
140
|
const titleLength = typeof title === 'string' ? utf8Length(title) : 0;
|
|
113
141
|
const subtitleLength =
|
|
114
142
|
typeof subtitle === 'string' ? utf8Length(subtitle) : Number.POSITIVE_INFINITY;
|
|
@@ -122,21 +150,16 @@ export function buildPro2NftBundle(options: {
|
|
|
122
150
|
throw invalidParameter('Parameter [timestampMs] must be a positive safe integer.');
|
|
123
151
|
}
|
|
124
152
|
|
|
125
|
-
const encodedImage = encodePro2Image({ ...image, alphaMode: 'black-background' }).data;
|
|
126
|
-
const encodedThumbnail = encodePro2Image({
|
|
127
|
-
...thumbnail,
|
|
128
|
-
alphaMode: 'black-background',
|
|
129
|
-
}).data;
|
|
130
153
|
const metadata = new TextEncoder().encode(JSON.stringify({ title, subtitle }));
|
|
131
154
|
if (metadata.byteLength === 0 || metadata.byteLength > 512) {
|
|
132
155
|
throw invalidParameter('Pro2 NFT metadata must contain 1 to 512 UTF-8 bytes.');
|
|
133
156
|
}
|
|
134
157
|
|
|
135
|
-
const hash8 = bytesToHex(blake2s(
|
|
158
|
+
const hash8 = bytesToHex(blake2s(image)).slice(0, 8);
|
|
136
159
|
return {
|
|
137
160
|
basename: `nft-${hash8}-${timestampMs}`,
|
|
138
|
-
image
|
|
139
|
-
thumbnail
|
|
161
|
+
image,
|
|
162
|
+
thumbnail,
|
|
140
163
|
metadata,
|
|
141
164
|
};
|
|
142
165
|
}
|