-
Notifications
You must be signed in to change notification settings - Fork 652
/
postMessage.ts
48 lines (46 loc) · 1.18 KB
/
postMessage.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import {
PublicKey,
PublicKeyInitData,
SYSVAR_CLOCK_PUBKEY,
SYSVAR_RENT_PUBKEY,
SystemProgram,
} from "@solana/web3.js";
import {
deriveWormholeBridgeDataKey,
deriveFeeCollectorKey,
getEmitterKeys,
} from "../accounts";
/** All accounts required to make a cross-program invocation with the Core Bridge program */
export interface PostMessageAccounts {
bridge: PublicKey;
message: PublicKey;
emitter: PublicKey;
sequence: PublicKey;
payer: PublicKey;
feeCollector: PublicKey;
clock: PublicKey;
rent: PublicKey;
systemProgram: PublicKey;
}
export function getPostMessageAccounts(
wormholeProgramId: PublicKeyInitData,
payer: PublicKeyInitData,
emitterProgramId: PublicKeyInitData,
message: PublicKeyInitData
): PostMessageAccounts {
const { emitter, sequence } = getEmitterKeys(
emitterProgramId,
wormholeProgramId
);
return {
bridge: deriveWormholeBridgeDataKey(wormholeProgramId),
message: new PublicKey(message),
emitter,
sequence,
payer: new PublicKey(payer),
feeCollector: deriveFeeCollectorKey(wormholeProgramId),
clock: SYSVAR_CLOCK_PUBKEY,
rent: SYSVAR_RENT_PUBKEY,
systemProgram: SystemProgram.programId,
};
}