refactor(amm): drop the new-position schema version tag

The add-liquidity flow stamped a `new-position.v1` schema tag on every
request and response and validated it across all three layers — the QML
plugin, the amm_module core module, and the amm_client Rust crate. It was a
cross-version compatibility guard, but these artifacts always ship together,
so the contract is honored implicitly, and the swap view already works fine
without one. Dropping it makes the liquidity view consistent with swap and
removes a layer of ceremony.

- amm_client: remove PositionRequest.schema and the unsupported_schema check
  in compute_quote; drop QuoteCommitment.schema (changes quoteHash, which is
  internal-only) and every "schema" response stamp; delete the SCHEMA /
  NEW_POSITION_SCHEMA constants and the public export.
- amm_module: remove the SCHEMA constant and its four response stamps.
- AmmUiBackend: remove its local NEW_POSITION_SCHEMA and the stamps in
  loadingContext() / newPositionError().
- QML: drop the "schema" fields from the request/envelope builders and relax
  the validity gates to check status / canSubmit instead (the sole check in
  NewPositionFlow now guards on a missing `status`); strip the now-dead
  schema fields from the liquidity QML test fixtures.
- Also removes the last stale comment references to the deleted *Runtime
  classes.
This commit is contained in:
r4bbit
2026-08-03 15:39:56 +02:00
parent 23963b22f0
commit 27da99aa57
19 changed files with 27 additions and 87 deletions
+1 -1
View File
@@ -28,7 +28,7 @@ methods (the module API is generated from the header) are:
`definitionId`/`holding` normalized to hex.
- `newPositionContext(request, walletOpen, refreshWalletAccounts)` — the
add-liquidity view state (available tokens, fee tiers, warnings) as a
`new-position.v1` map.
context map.
- `quoteNewPosition(request, walletOpen)` — prices an add-liquidity request
against current on-chain state (read-only).
- `submitNewPosition(request, quoteHash, walletOpen, freshLpId)` — submits an
+1 -9
View File
@@ -47,10 +47,6 @@ constexpr char AMM_PROGRAM_BIN_ENV[] = "AMM_PROGRAM_BIN";
// Absolute path to the JSON token-list config consumed by tokenList().
constexpr char TOKENS_CONFIG_ENV[] = "TOKENS_CONFIG";
// new-position.v1 response schema tag (matches the app-side NewPositionRuntime
// and the Rust client's NEW_POSITION_SCHEMA).
constexpr char SCHEMA[] = "new-position.v1";
int hexVal(char c) {
if (c >= '0' && c <= '9') return c - '0';
if (c >= 'a' && c <= 'f') return c - 'a' + 10;
@@ -233,7 +229,7 @@ FfiResult call(char* (*op)(const char*), const json& request) {
return {true, *it};
}
// new-position.v1 envelope builders (ported from NewPositionRuntime).
// new-position response envelope builders.
json issue(const std::string& code, const json& blockingFields = json::array()) {
return {
{"code", code},
@@ -249,7 +245,6 @@ json publicError(const std::string& code,
json error = issue(code, blockingFields);
error["details"] = details;
return {
{"schema", SCHEMA},
{"status", "error"},
{"canSubmit", false},
{"code", code},
@@ -264,7 +259,6 @@ json contextState(const std::string& status,
const std::string& network_fingerprint,
const std::string& code = {}) {
json state = {
{"schema", SCHEMA},
{"status", status},
{"networkId", network_id},
{"networkFingerprint", network_fingerprint},
@@ -750,7 +744,6 @@ LogosMap AmmModuleImpl::submitNewPosition(const LogosMap& request,
if (quote.value("requiresFreshLp", false)) {
if (fresh_lp_id.empty()) {
return json{
{"schema", SCHEMA},
{"status", "requires_fresh_lp"},
{"quote", quote},
};
@@ -794,7 +787,6 @@ LogosMap AmmModuleImpl::submitNewPosition(const LogosMap& request,
if (transaction_id.empty()) return publicError("wallet_submission_failed");
return {
{"schema", SCHEMA},
{"status", "submitted"},
{"transactionId", transaction_id},
{"deadlineMs", plan.value("deadlineMs", json())},
+8 -8
View File
@@ -17,10 +17,10 @@
// `logos_execution_zone` wallet module (reached via modules().logos_execution_zone).
//
// The same surface is consumed by the QML UI (via modules().amm_module) and
// headlessly (logoscore call amm_module ...). Ported from the app-side
// SwapRuntime / NewPositionRuntime orchestration (apps/amm/src) plus the
// backend's network-context derivation, made Qt-free (std::string / LogosMap /
// LogosList / nlohmann::json) as the universal authoring model requires.
// headlessly (logoscore call amm_module ...). The swap / add-liquidity
// orchestration and the backend's network-context derivation are made Qt-free
// (std::string / LogosMap / LogosList / nlohmann::json) as the universal
// authoring model requires.
//
// Public methods ARE the module's API; the Qt plugin glue is generated from
// this header because metadata.json sets "interface": "universal". Keep the
@@ -65,7 +65,7 @@ public:
LogosList tokenList();
/// New-position (add-liquidity) view state: reads the AMM config + the
/// user's wallet accounts and returns the `new-position.v1` context map the
/// user's wallet accounts and returns the new-position context map the
/// UI renders (available tokens, fee tiers, warnings). `wallet_open` gates
/// whether wallet accounts are included; `refresh_wallet_accounts` forces a
/// fresh read rather than a cached one.
@@ -74,7 +74,7 @@ public:
bool refresh_wallet_accounts);
/// Prices an add-liquidity request against current on-chain state and
/// returns the `new-position.v1` quote map (quoteHash, canSubmit,
/// returns the new-position quote map (quoteHash, canSubmit,
/// requiresFreshLp, amounts, warnings). Read-only — no submission.
LogosMap quoteNewPosition(const LogosMap& request, bool wallet_open);
@@ -84,7 +84,7 @@ public:
/// WITHOUT submitting — the caller (the app backend, which owns the wallet
/// keyset) creates the account and calls again with its id. Otherwise builds
/// the plan (injecting the fresh LP account when given) and submits, then
/// returns the `new-position.v1` submitted/error map.
/// returns the new-position submitted/error map.
LogosMap submitNewPosition(const LogosMap& request,
const std::string& quote_hash,
bool wallet_open,
@@ -138,7 +138,7 @@ private:
// Builds the { networkId, networkFingerprint, ammProgramId, request,
// snapshot } input shared by quoteNewPosition / submitNewPosition. On a
// recoverable precondition failure, sets *error to a new-position.v1 error
// recoverable precondition failure, sets *error to a new-position error
// map and returns a null json.
nlohmann::json buildQuoteInput(const LogosMap& request,
const Network& net,