@onekeyfe/hd-transport 1.2.10-alpha.2 → 1.2.10
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__/solana-offchain-message-v1.test.js +33 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +26 -109027
- package/dist/protocols/index.d.ts.map +1 -1
- package/dist/serialization/protobuf/messages.d.ts +1 -1
- package/dist/serialization/protobuf/messages.d.ts.map +1 -1
- package/jest.config.js +0 -3
- package/package.json +4 -6
- package/scripts/protobuf-build.sh +0 -7
- package/src/protocols/index.ts +23 -10
- package/src/serialization/protobuf/messages.ts +6 -12
- package/__tests__/static-protobuf.test.js +0 -436
- package/scripts/protobuf-static-csp.js +0 -103
- package/scripts/protobuf-static.js +0 -85
- package/src/serialization/protobuf/generated/codecs.d.ts +0 -3
- package/src/serialization/protobuf/generated/codecs.js +0 -108990
- package/src/serialization/protobuf/legacy-protocol-info.json +0 -16
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const { parseConfigure, createMessageFromName } = require('../src/serialization/protobuf/messages');
|
|
2
|
+
const { encode } = require('../src/serialization/protobuf/encode');
|
|
3
|
+
const schema = require('../../core/src/data/messages/messages.json');
|
|
4
|
+
|
|
5
|
+
describe('Solana off-chain message Protocol V1 wire contract', () => {
|
|
6
|
+
const root = parseConfigure(schema);
|
|
7
|
+
|
|
8
|
+
test('encodes required signers as field 6', () => {
|
|
9
|
+
const { Message } = createMessageFromName(root, 'SolanaSignOffChainMessage');
|
|
10
|
+
const requiredSigners = ['11'.repeat(32), '22'.repeat(32)];
|
|
11
|
+
const encoded = Buffer.from(
|
|
12
|
+
encode(Message, {
|
|
13
|
+
address_n: [0x8000002c, 0x800001f5, 0x80000000, 0x80000000],
|
|
14
|
+
message: '01020304',
|
|
15
|
+
message_version: 'MESSAGE_VERSION_1',
|
|
16
|
+
required_signers: requiredSigners,
|
|
17
|
+
}).toBuffer()
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
// Check the wire tag independently of the SDK schema: field 6, wire type 2.
|
|
21
|
+
const expectedSignersPayload = Buffer.concat(
|
|
22
|
+
requiredSigners.map(signer =>
|
|
23
|
+
Buffer.concat([Buffer.from([0x32, 0x20]), Buffer.from(signer, 'hex')])
|
|
24
|
+
)
|
|
25
|
+
);
|
|
26
|
+
expect(encoded.subarray(-expectedSignersPayload.length)).toEqual(expectedSignersPayload);
|
|
27
|
+
|
|
28
|
+
const decoded = Message.decode(new Uint8Array(encoded));
|
|
29
|
+
expect(decoded.required_signers.map(signer => Buffer.from(signer).toString('hex'))).toEqual(
|
|
30
|
+
requiredSigners
|
|
31
|
+
);
|
|
32
|
+
});
|
|
33
|
+
});
|
package/dist/index.d.ts
CHANGED
|
@@ -52,7 +52,7 @@ declare namespace index {
|
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
declare function parseConfigure(data: protobuf.INamespace
|
|
55
|
+
declare function parseConfigure(data: protobuf.INamespace): protobuf.Root;
|
|
56
56
|
|
|
57
57
|
declare const PROTO_HEAD_SOF = 90;
|
|
58
58
|
declare const PROTO_PRE_HEAD_SIZE = 4;
|