Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions create-and-update/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use borsh::{BorshDeserialize, BorshSerialize};
use light_sdk::{
account::LightAccount,
address::v2::derive_address,
cpi::{v1::CpiAccounts, CpiSigner},
cpi::{v2::CpiAccounts, CpiSigner},
derive_light_cpi_signer,
instruction::{account_meta::CompressedAccountMeta, PackedAddressTreeInfo, ValidityProof},
LightDiscriminator, LightHasher,
Expand All @@ -25,7 +25,7 @@ pub mod create_and_update {

use super::*;
use light_sdk::cpi::{
v1::LightSystemProgramCpi, InvokeLightSystemProgram, LightCpiInstruction,
v2::LightSystemProgramCpi, InvokeLightSystemProgram, LightCpiInstruction,
};

/// Creates a new compressed account with initial data
Expand Down Expand Up @@ -64,7 +64,9 @@ pub mod create_and_update {
);
LightSystemProgramCpi::new_cpi(LIGHT_CPI_SIGNER, proof)
.with_light_account(data_account)?
.with_new_addresses(&[address_tree_info.into_new_address_params_packed(address_seed)])
.with_new_addresses(&[
address_tree_info.into_new_address_params_assigned_packed(address_seed, Some(0))
])
.invoke(light_cpi_accounts)?;

Ok(())
Expand Down Expand Up @@ -118,7 +120,7 @@ pub mod create_and_update {
.with_light_account(updated_data_account)?
.with_new_addresses(&[new_account
.address_tree_info
.into_new_address_params_packed(new_address_seed)])
.into_new_address_params_assigned_packed(new_address_seed, Some(0))])
.invoke(light_cpi_accounts)?;

msg!(
Expand Down Expand Up @@ -236,8 +238,10 @@ pub mod create_and_update {
.with_light_account(first_data_account)?
.with_light_account(second_data_account)?
.with_new_addresses(&[
address_tree_info.into_new_address_params_packed(first_address_seed),
address_tree_info.into_new_address_params_packed(second_address_seed),
address_tree_info
.into_new_address_params_assigned_packed(first_address_seed, Some(0)),
address_tree_info
.into_new_address_params_assigned_packed(second_address_seed, Some(1)),
])
.invoke(light_cpi_accounts)?;

Expand Down
6 changes: 3 additions & 3 deletions create-and-update/tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ where
{
let mut remaining_accounts = PackedAccounts::default();
let config = SystemAccountMetaConfig::new(create_and_update::ID);
remaining_accounts.add_system_accounts(config)?;
remaining_accounts.add_system_accounts_v2(config)?;

let rpc_result = rpc
.get_validity_proof(
Expand Down Expand Up @@ -255,7 +255,7 @@ where
{
let mut remaining_accounts = PackedAccounts::default();
let config = SystemAccountMetaConfig::new(create_and_update::ID);
remaining_accounts.add_system_accounts(config)?;
remaining_accounts.add_system_accounts_v2(config)?;

let hash = existing_account.hash;

Expand Down Expand Up @@ -334,7 +334,7 @@ where
{
let mut remaining_accounts = PackedAccounts::default();
let config = SystemAccountMetaConfig::new(create_and_update::ID);
remaining_accounts.add_system_accounts(config)?;
remaining_accounts.add_system_accounts_v2(config)?;

let first_hash = first_account.hash;
let second_hash = second_account.hash;
Expand Down
2 changes: 1 addition & 1 deletion create-and-update/tests/test_create_two_accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ where
{
let mut remaining_accounts = PackedAccounts::default();
let config = SystemAccountMetaConfig::new(create_and_update::ID);
remaining_accounts.add_system_accounts(config)?;
remaining_accounts.add_system_accounts_v2(config)?;

let rpc_result = rpc
.get_validity_proof(
Expand Down