Skip to content

Commit

Permalink
modified tests and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
buffalojoec committed Aug 31, 2023
1 parent fc2df04 commit b19cb57
Show file tree
Hide file tree
Showing 2 changed files with 487 additions and 393 deletions.
14 changes: 13 additions & 1 deletion libraries/tlv-account-resolution/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,21 @@ let mut buffer = vec![0; account_size];
ExtraAccountMetaList::init::<MyInstruction>(&mut buffer, &extra_metas).unwrap();

// Off-chain, you can add the additional accounts directly from the account data
// You need to provide the resolver a way to fetch account data off-chain
let client = RpcClient::new_mock("succeeds".to_string());
let program_id = Pubkey::new_unique();
let mut instruction = Instruction::new_with_bytes(program_id, &[0, 1, 2], vec![]);
ExtraAccountMetaList::add_to_instruction::<MyInstruction>(&mut instruction, &buffer).unwrap();
ExtraAccountMetaList::add_to_instruction::<_, _, MyInstruction>(
&mut instruction,
|address: &Pubkey| {
client
.get_account(address)
.map_ok(|acct| Some(acct.data))
},
&buffer,
)
.await
.unwrap();

// On-chain, you can add the additional accounts *and* account infos
let mut cpi_instruction = Instruction::new_with_bytes(program_id, &[0, 1, 2], vec![]);
Expand Down
Loading

0 comments on commit b19cb57

Please sign in to comment.