From ada5de7358901198cb64275eccde63690a22ff03 Mon Sep 17 00:00:00 2001 From: Ricardo Guilherme Schmidt <3esmit@gmail.com> Date: Mon, 10 Aug 2026 11:25:38 -0300 Subject: [PATCH] fix(amm-client): align update config with current ABI --- programs/amm/client/src/plan.rs | 6 +---- programs/amm/client/src/transaction.rs | 12 ++-------- programs/amm/client/src/wire.rs | 25 ++++----------------- programs/amm/client/tests/plan_contract.rs | 26 ++++++++++------------ 4 files changed, 19 insertions(+), 50 deletions(-) diff --git a/programs/amm/client/src/plan.rs b/programs/amm/client/src/plan.rs index f75fd76..20a8d37 100644 --- a/programs/amm/client/src/plan.rs +++ b/programs/amm/client/src/plan.rs @@ -300,9 +300,7 @@ pub struct InitializePlanInput { pub struct UpdateConfigPlanInput<'a> { pub context: &'a AmmContext, - pub token_program_id: Option, - pub twap_oracle_program_id: Option, - pub new_authority: Option, + pub new_authority: AccountId, } pub struct CreatePriceObservationsPlanInput<'a> { @@ -403,8 +401,6 @@ pub fn plan_update_config(input: UpdateConfigPlanInput<'_>) -> TransactionPlan { TransactionPlan::new( input.context.amm_program_id, Instruction::UpdateConfig { - token_program_id: input.token_program_id, - twap_oracle_program_id: input.twap_oracle_program_id, new_authority: input.new_authority, }, vec![ diff --git a/programs/amm/client/src/transaction.rs b/programs/amm/client/src/transaction.rs index 6ccb04c..2cda047 100644 --- a/programs/amm/client/src/transaction.rs +++ b/programs/amm/client/src/transaction.rs @@ -958,9 +958,7 @@ enum CommitmentGuards { authority: AccountId, }, UpdateConfig { - token_program_id: Option, - twap_oracle_program_id: Option, - new_authority: Option, + new_authority: AccountId, }, CreatePriceObservations { window_duration: u64, @@ -1006,13 +1004,7 @@ impl From<&amm_core::Instruction> for CommitmentGuards { twap_oracle_program_id: *twap_oracle_program_id, authority: *authority, }, - amm_core::Instruction::UpdateConfig { - token_program_id, - twap_oracle_program_id, - new_authority, - } => Self::UpdateConfig { - token_program_id: *token_program_id, - twap_oracle_program_id: *twap_oracle_program_id, + amm_core::Instruction::UpdateConfig { new_authority } => Self::UpdateConfig { new_authority: *new_authority, }, amm_core::Instruction::CreatePriceObservations { window_duration } => { diff --git a/programs/amm/client/src/wire.rs b/programs/amm/client/src/wire.rs index 5b55a3e..56b08f3 100644 --- a/programs/amm/client/src/wire.rs +++ b/programs/amm/client/src/wire.rs @@ -114,12 +114,8 @@ enum PlanRequest { }, UpdateConfig { context: ContextInput, - #[serde(rename = "tokenProgramId")] - token_program_id: Option, - #[serde(rename = "twapOracleProgramId")] - twap_oracle_program_id: Option, #[serde(rename = "newAuthority")] - new_authority: Option, + new_authority: String, }, CreatePriceObservations { context: ContextInput, @@ -873,19 +869,12 @@ pub fn plan_json(value: Value) -> Result { })), PlanRequest::UpdateConfig { context, - token_program_id, - twap_oracle_program_id, new_authority, } => { let context = context.into_context()?; - let new_authority = new_authority - .as_deref() - .map(|value| account_id(value, "newAuthority")) - .transpose()?; + let new_authority = account_id(&new_authority, "newAuthority")?; transaction_plan_json(&plan_update_config(UpdateConfigPlanInput { context: &context, - token_program_id: token_program_id.map(Into::into), - twap_oracle_program_id: twap_oracle_program_id.map(Into::into), new_authority, })) } @@ -1810,14 +1799,8 @@ fn instruction_args_json(instruction: &Instruction) -> Value { "twapOracleProgramId": program_id_words(*twap_oracle_program_id), "authority": authority.to_string(), }), - Instruction::UpdateConfig { - token_program_id, - twap_oracle_program_id, - new_authority, - } => json!({ - "tokenProgramId": token_program_id.map(program_id_words), - "twapOracleProgramId": twap_oracle_program_id.map(program_id_words), - "newAuthority": new_authority.map(|authority| authority.to_string()), + Instruction::UpdateConfig { new_authority } => json!({ + "newAuthority": new_authority.to_string(), }), Instruction::CreatePriceObservations { window_duration } | Instruction::CreateOraclePriceAccount { window_duration } => json!({ diff --git a/programs/amm/client/tests/plan_contract.rs b/programs/amm/client/tests/plan_contract.rs index e1ac077..3172ff1 100644 --- a/programs/amm/client/tests/plan_contract.rs +++ b/programs/amm/client/tests/plan_contract.rs @@ -76,9 +76,7 @@ fn all_plans() -> Vec { }), plan_update_config(UpdateConfigPlanInput { context: &context, - token_program_id: Some(program(16)), - twap_oracle_program_id: Some(program(78)), - new_authority: Some(account(10)), + new_authority: account(10), }), plan_create_price_observations(CreatePriceObservationsPlanInput { context: &context, @@ -175,24 +173,24 @@ fn every_instruction_round_trips_through_guest_codec() { } #[test] -fn update_config_none_options_round_trip() { +fn update_config_authority_round_trip() { + let expected_authority = account(10); let instruction = Instruction::UpdateConfig { - token_program_id: None, - twap_oracle_program_id: None, - new_authority: None, + new_authority: expected_authority, }; let words = encode_instruction(&instruction).expect("instruction must serialize"); let decoded: Instruction = risc0_zkvm::serde::from_slice(&words).expect("instruction must deserialize"); - assert!(matches!( - decoded, - Instruction::UpdateConfig { - token_program_id: None, - twap_oracle_program_id: None, - new_authority: None, + match decoded { + Instruction::UpdateConfig { new_authority } => { + assert_eq!(new_authority, expected_authority) } - )); + other => panic!( + "expected UpdateConfig, got variant index {}", + variant_index(&other) + ), + } } #[test]