Skip to content

Commit 8ad7d25

Browse files
authored
Add export for post message layout with deserialize fn (#497)
1 parent b87a15e commit 8ad7d25

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

platforms/solana/protocols/core/src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ registerProtocol(_platform, 'WormholeCore', SolanaWormholeCore);
77
export * from './core.js';
88
export * from './types.js';
99
export * as utils from './utils/index.js';
10+
export * from './postMessageLayout.js';

platforms/solana/protocols/core/src/postMessageLayout.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import type { Layout } from '@wormhole-foundation/sdk-connect';
2-
import { layoutItems } from '@wormhole-foundation/sdk-connect';
2+
import {
3+
LayoutToType,
4+
deserializeLayout,
5+
layoutItems,
6+
} from '@wormhole-foundation/sdk-connect';
37

48
/** Binary layout for postMessage account */
59
export const postMessageLayout = [
@@ -16,3 +20,9 @@ export const postMessageLayout = [
1620
{ name: 'payloadLength', binary: 'uint', size: 4, endianness: 'little' },
1721
{ name: 'payload', binary: 'bytes' },
1822
] as const satisfies Layout;
23+
24+
export function deserializePostMessage(
25+
data: Uint8Array,
26+
): LayoutToType<typeof postMessageLayout> {
27+
return deserializeLayout(postMessageLayout, data);
28+
}

0 commit comments

Comments
 (0)