Skip to content

Commit a02cf6b

Browse files
committed
add lut, fix tests
1 parent f97ee03 commit a02cf6b

File tree

4 files changed

+251
-404
lines changed

4 files changed

+251
-404
lines changed

programs/portal/src/instructions/resolve_execute.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use crate::{
2525
},
2626
instructions::{
2727
ext_swap::{accounts::SwapGlobal, types::WhitelistedExtension},
28-
get_inbox_recipient_token_account, RedeemArgs, ReleaseInboundArgs,
28+
get_inbox_recipient_token_account, RedeemArgs, ReleaseInboundArgs, LUT,
2929
},
3030
messages::ValidatedTransceiverMessage,
3131
ntt_messages::{ChainId, TransceiverMessage, TransceiverMessageData, WormholeTransceiver},
@@ -78,6 +78,7 @@ pub fn resolve_execute_vaa_v1<'a>(
7878
let inbox_item = pda(&[InboxItem::SEED_PREFIX, message_hash.as_ref()]);
7979
let swap_global = Pubkey::find_program_address(&[GLOBAL_SEED], &ext_swap::ID).0;
8080
let result_account = pda(&[RESOLVER_RESULT_ACCOUNT_SEED]);
81+
let lut_account = pda(&[b"lut"]);
8182

8283
// Check for missing accounts
8384
{
@@ -110,6 +111,11 @@ pub fn resolve_execute_vaa_v1<'a>(
110111
missing.push(System::id());
111112
}
112113

114+
// Contains the address of the portal lut
115+
if find_account(ctx.remaining_accounts, lut_account).is_none() {
116+
missing.push(lut_account);
117+
}
118+
113119
if !missing.is_empty() {
114120
// Placeholder for payer we know is missing
115121
missing.push(RESOLVER_PUBKEY_PAYER);
@@ -167,6 +173,7 @@ pub fn resolve_execute_vaa_v1<'a>(
167173
let config_data = deserialize_account::<Config>(ctx.remaining_accounts, config)?;
168174
let swap_global_data = deserialize_account::<SwapGlobal>(ctx.remaining_accounts, swap_global)?;
169175
let mint_data = deserialize_account::<Mint>(ctx.remaining_accounts, config_data.mint)?;
176+
let lut_data = deserialize_account::<LUT>(ctx.remaining_accounts, lut_account)?;
170177

171178
let token_program = find_account(ctx.remaining_accounts, config_data.mint)
172179
.unwrap()
@@ -190,6 +197,12 @@ pub fn resolve_execute_vaa_v1<'a>(
190197
message.ntt_manager_payload.id.as_ref(),
191198
]);
192199

200+
// Get LUTs for instructions
201+
let mut address_lookup_tables = vec![lut_data.address];
202+
if !config_data.resolve_lut.eq(&Pubkey::default()) {
203+
address_lookup_tables.push(config_data.resolve_lut);
204+
}
205+
193206
let receive_message = SerializableInstruction {
194207
program_id: crate::ID,
195208
data: ReceiveWormholeMessage {}.data(),
@@ -384,7 +397,7 @@ pub fn resolve_execute_vaa_v1<'a>(
384397
ret.set_inner(ExecutorAccountResolverResult(Resolver::Resolved(
385398
InstructionGroups(vec![InstructionGroup {
386399
instructions: vec![receive_message, redeem, release_inbound_mint],
387-
address_lookup_tables: Vec::new(),
400+
address_lookup_tables,
388401
}]),
389402
)));
390403
ret.exit(ctx.program_id)?;
@@ -495,7 +508,7 @@ pub fn resolve_execute_vaa_v1<'a>(
495508
ret.set_inner(ExecutorAccountResolverResult(Resolver::Resolved(
496509
InstructionGroups(vec![InstructionGroup {
497510
instructions: vec![receive_message, redeem, release_inbound_mint],
498-
address_lookup_tables: Vec::new(),
511+
address_lookup_tables,
499512
}]),
500513
)));
501514
ret.exit(ctx.program_id)?;

tests/programs/vaa_resolver.json

Lines changed: 0 additions & 209 deletions
This file was deleted.

0 commit comments

Comments
 (0)