refactor(modules/amm): drop status/code from swap_exact_in_plan

The plan op is internal plumbing — its only consumer is the module's
swapExactInput, which just forwards the four tx-submission fields to the
wallet. Collapse its response onto the FFI envelope: return { programId,
accountIds, signingRequirements, instruction } directly and route the
recoverable domain failures (same_token_pair, config_unavailable) through
Err -> { ok: false, error } instead of a nested { status, code } object.
Also drop the deadlineMs echo — it's unused (the deadline is already encoded
in the instruction bytes). swapExactInput now treats any non-ok plan as a
failure. No behavior change for the UI: the plan JSON never crosses the
module boundary.
This commit is contained in:
r4bbit
2026-08-06 14:31:49 +02:00
parent bf1f76b051
commit b2f0e4b851
2 changed files with 43 additions and 17 deletions
+2 -2
View File
@@ -637,8 +637,8 @@ std::string AmmModuleImpl::swapExactInput(const std::string& def_a_hex,
{"minOut", min_out_decimal},
{"deadlineMs", deadline_decimal},
});
if (!planResult.ok || jStr(planResult.value, "status") != "ready") {
AMM_TRACE("swapExactInput: FAIL amm_swap_exact_in_plan not ready");
if (!planResult.ok) {
AMM_TRACE("swapExactInput: FAIL amm_swap_exact_in_plan: " << planResult.error);
return {};
}
const json plan = planResult.value;