mirror of
https://github.com/logos-blockchain/lez-programs.git
synced 2026-08-25 06:01:11 +00:00
fix(amm-client): align update config with current ABI
This commit is contained in:
@@ -300,9 +300,7 @@ pub struct InitializePlanInput {
|
||||
|
||||
pub struct UpdateConfigPlanInput<'a> {
|
||||
pub context: &'a AmmContext,
|
||||
pub token_program_id: Option<ProgramId>,
|
||||
pub twap_oracle_program_id: Option<ProgramId>,
|
||||
pub new_authority: Option<AccountId>,
|
||||
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![
|
||||
|
||||
@@ -958,9 +958,7 @@ enum CommitmentGuards {
|
||||
authority: AccountId,
|
||||
},
|
||||
UpdateConfig {
|
||||
token_program_id: Option<ProgramId>,
|
||||
twap_oracle_program_id: Option<ProgramId>,
|
||||
new_authority: Option<AccountId>,
|
||||
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 } => {
|
||||
|
||||
@@ -114,12 +114,8 @@ enum PlanRequest {
|
||||
},
|
||||
UpdateConfig {
|
||||
context: ContextInput,
|
||||
#[serde(rename = "tokenProgramId")]
|
||||
token_program_id: Option<ProgramIdInput>,
|
||||
#[serde(rename = "twapOracleProgramId")]
|
||||
twap_oracle_program_id: Option<ProgramIdInput>,
|
||||
#[serde(rename = "newAuthority")]
|
||||
new_authority: Option<String>,
|
||||
new_authority: String,
|
||||
},
|
||||
CreatePriceObservations {
|
||||
context: ContextInput,
|
||||
@@ -873,19 +869,12 @@ pub fn plan_json(value: Value) -> Result<Value, WireError> {
|
||||
})),
|
||||
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!({
|
||||
|
||||
@@ -76,9 +76,7 @@ fn all_plans() -> Vec<TransactionPlan> {
|
||||
}),
|
||||
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]
|
||||
|
||||
Reference in New Issue
Block a user