Skip to content

Commit 4f09634

Browse files
committed
Ignore memo program when running tasks
1 parent e2e4756 commit 4f09634

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

solana-programs/programs/tuktuk/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "tuktuk"
3-
version = "0.2.2"
3+
version = "0.2.3"
44
description = "Created with Anchor"
55
edition = "2021"
66

@@ -22,4 +22,3 @@ anchor-lang = { workspace = true, features = ["init-if-needed"] }
2222
anchor-spl = { workspace = true }
2323
bytemuck = "1.10.0"
2424
solana-zk-sdk = { workspace = true }
25-

solana-programs/programs/tuktuk/src/instructions/run_task_v0.rs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ impl TasksAccountHeaderV0 {
4444
}
4545
}
4646

47+
const MEMO_PROGRAM_ID: Pubkey = pubkey!("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr");
48+
4749
// Add new iterator struct for reading tasks
4850
pub struct TasksIterator<'a> {
4951
data: &'a mut &'a [u8],
@@ -205,13 +207,17 @@ impl<'a, 'info> TaskProcessor<'a, 'info> {
205207
}
206208

207209
// Pass free tasks as remaining accounts so the task can know which IDs will be used
208-
let free_tasks = &self.ctx.remaining_accounts[self.free_task_index..];
209-
accounts.extend(free_tasks.iter().cloned());
210-
account_infos.extend(free_tasks.iter().map(|acct| AccountMeta {
211-
pubkey: acct.key(),
212-
is_signer: false,
213-
is_writable: false,
214-
}));
210+
let program_id = remaining_accounts[ix.program_id_index as usize].key;
211+
// Ignore memo program because it expects every account passed to be a signer.
212+
if *program_id != MEMO_PROGRAM_ID {
213+
let free_tasks = &self.ctx.remaining_accounts[self.free_task_index..];
214+
accounts.extend(free_tasks.iter().cloned());
215+
account_infos.extend(free_tasks.iter().map(|acct| AccountMeta {
216+
pubkey: acct.key(),
217+
is_signer: false,
218+
is_writable: false,
219+
}));
220+
}
215221

216222
let signer_seeds: Vec<Vec<&[u8]>> = self
217223
.signers
@@ -221,7 +227,7 @@ impl<'a, 'info> TaskProcessor<'a, 'info> {
221227

222228
solana_program::program::invoke_signed(
223229
&Instruction {
224-
program_id: *remaining_accounts[ix.program_id_index as usize].key,
230+
program_id: *program_id,
225231
accounts: account_infos,
226232
data: ix.data.clone(),
227233
},

0 commit comments

Comments
 (0)