@onekeyfe/hd-transport 1.2.0-alpha.56 → 1.2.0-alpha.58
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.
|
@@ -208,18 +208,16 @@ describe('messages', () => {
|
|
|
208
208
|
test('Protocol V2 wallet recovery carries the expected wallet and seed domains on wire', () => {
|
|
209
209
|
const messages = parseConfigure(v2Messages);
|
|
210
210
|
const { Message } = createMessageFromName(messages, 'DeviceSessionGet');
|
|
211
|
-
const payload =
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
})
|
|
219
|
-
).finish();
|
|
211
|
+
const payload = encode(Message, {
|
|
212
|
+
btc_test_address: 'tb1qwallet',
|
|
213
|
+
seed_domains: [
|
|
214
|
+
generatedTypes.DeviceSessionSeedDomain.SeedDomain_Standard,
|
|
215
|
+
generatedTypes.DeviceSessionSeedDomain.SeedDomain_Cardano,
|
|
216
|
+
],
|
|
217
|
+
});
|
|
220
218
|
|
|
221
|
-
expect(
|
|
222
|
-
expect(Message.decode(payload)).toMatchObject({
|
|
219
|
+
expect(payload.toString('hex')).toBe('120a7462317177616c6c65741a020102');
|
|
220
|
+
expect(Message.decode(payload.toBuffer())).toMatchObject({
|
|
223
221
|
btc_test_address: 'tb1qwallet',
|
|
224
222
|
seed_domains: [
|
|
225
223
|
generatedTypes.DeviceSessionSeedDomain.SeedDomain_Standard,
|
package/dist/index.js
CHANGED
|
@@ -200,7 +200,10 @@ function patch(Message, payload) {
|
|
|
200
200
|
}
|
|
201
201
|
if (field.repeated) {
|
|
202
202
|
const RefMessage = Message.lookupTypeOrEnum(field.type);
|
|
203
|
-
patched[key] =
|
|
203
|
+
patched[key] =
|
|
204
|
+
RefMessage instanceof protobuf.Enum
|
|
205
|
+
? value.map((v) => transform(field.type, v))
|
|
206
|
+
: value.map((v) => patch(RefMessage, v));
|
|
204
207
|
}
|
|
205
208
|
else if (typeof value === 'object' && value !== null) {
|
|
206
209
|
const RefMessage = Message.lookupType(field.type);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encode.d.ts","sourceRoot":"","sources":["../../../src/serialization/protobuf/encode.ts"],"names":[],"mappings":"AACA,OAAO,UAAU,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"encode.d.ts","sourceRoot":"","sources":["../../../src/serialization/protobuf/encode.ts"],"names":[],"mappings":"AACA,OAAO,UAAU,MAAM,YAAY,CAAC;AAKpC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAmB7C,wBAAgB,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,OA+ChD;AAED,eAAO,MAAM,MAAM,YAAa,IAAI,QAAQ,OAAO,MAAM,EAAE,OAAO,CAAC,eASlE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hd-transport",
|
|
3
|
-
"version": "1.2.0-alpha.
|
|
3
|
+
"version": "1.2.0-alpha.58",
|
|
4
4
|
"description": "Transport layer abstractions and utilities for OneKey hardware SDK.",
|
|
5
5
|
"author": "OneKey",
|
|
6
6
|
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
|
|
@@ -28,5 +28,5 @@
|
|
|
28
28
|
"long": "^4.0.0",
|
|
29
29
|
"protobufjs": "^6.11.2"
|
|
30
30
|
},
|
|
31
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "43c11efeb7001741d4258c855b287993bc0a798e"
|
|
32
32
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Buffer } from 'buffer';
|
|
2
2
|
import ByteBuffer from 'bytebuffer';
|
|
3
|
+
import { Enum } from 'protobufjs/light';
|
|
3
4
|
|
|
4
5
|
import { isPrimitiveField } from '../../utils/protobuf';
|
|
5
6
|
|
|
@@ -49,7 +50,10 @@ export function patch(Message: Type, payload: any) {
|
|
|
49
50
|
// repeated
|
|
50
51
|
if (field.repeated) {
|
|
51
52
|
const RefMessage = Message.lookupTypeOrEnum(field.type);
|
|
52
|
-
patched[key] =
|
|
53
|
+
patched[key] =
|
|
54
|
+
RefMessage instanceof Enum
|
|
55
|
+
? value.map((v: any) => transform(field.type, v))
|
|
56
|
+
: value.map((v: any) => patch(RefMessage, v));
|
|
53
57
|
}
|
|
54
58
|
// message type
|
|
55
59
|
else if (typeof value === 'object' && value !== null) {
|