mirror of
https://github.com/logos-blockchain/lez-programs.git
synced 2026-08-25 22:21:16 +00:00
The Pools page shipped with a hardcoded four-pair sample. Replace it with a config-driven "known pools" list, mirroring how the Swap token picker reads TOKENS_CONFIG: the app loads a flat JSON array from the AMM_POOLS_CONFIG environment variable and renders one row per entry. Adding pairs is a config edit — no app change. Pool discovery is an app concern, so the config is read in the backend (AmmUiBackend::poolList, Qt JSON) rather than the amm_module — the module is shedding app-specific view surface (tokenList/newPositionContext), so pools go where tokens are heading, not where they are today. poolList() fails soft to an empty list when AMM_POOLS_CONFIG is unset/unreadable/not an array, and skips individual entries missing tokenA/tokenB/a numeric feeBps. Each entry carries the display symbols (tokenA/tokenB), feeBps, and the on-chain identifiers (poolId, tokenADefinitionId, tokenBDefinitionId) so a row can later be resolved against chain state. PoolsPage takes injected backend/runtime and loads via runtime.watch(backend.poolList()); the Repeater renders entries generically. The AMM testnet setup script now emits amm-pools.json from a POOL_SPECS array (one line per seeded pool, currently the seeded TKA/TKB pool) and prints AMM_POOLS_CONFIG in the launch instructions. Adds amm-pools.json.example, a README section, and gitignores the runtime config files.
104 lines
3.0 KiB
QML
104 lines
3.0 KiB
QML
import QtQuick 2.15
|
|
import QtQuick.Controls 2.15
|
|
import QtQuick.Layouts 1.15
|
|
|
|
import Logos.Theme
|
|
|
|
import "pages"
|
|
|
|
Item {
|
|
id: root
|
|
|
|
// Backend replica + account model, bridged from the C++ backend.
|
|
readonly property var backend: logos.module("amm_ui")
|
|
readonly property var accountModel: logos.model("amm_ui", "accountModel")
|
|
|
|
property bool ready: false
|
|
|
|
Connections {
|
|
target: logos
|
|
function onViewModuleReadyChanged(moduleName, isReady) {
|
|
if (moduleName === "amm_ui")
|
|
root.ready = isReady && root.backend !== null
|
|
}
|
|
}
|
|
|
|
Component.onCompleted: {
|
|
root.ready = root.backend !== null && logos.isViewModuleReady("amm_ui")
|
|
}
|
|
|
|
// Connectivity banner: shown when a wallet is open but its configured
|
|
// sequencer doesn't answer reachability probes (so transactions will fail).
|
|
Rectangle {
|
|
id: connectionBanner
|
|
anchors.top: parent.top
|
|
anchors.left: parent.left
|
|
anchors.right: parent.right
|
|
z: 101
|
|
|
|
readonly property bool show: root.ready
|
|
&& root.backend
|
|
&& root.backend.isWalletOpen
|
|
&& root.backend.sequencerAddr.length > 0
|
|
&& !root.backend.sequencerReachable
|
|
|
|
height: show ? 32 : 0
|
|
visible: height > 0
|
|
clip: true
|
|
color: Theme.palette.warning
|
|
|
|
Behavior on height { NumberAnimation { duration: 150; easing.type: Easing.OutCubic } }
|
|
|
|
Text {
|
|
anchors.centerIn: parent
|
|
width: parent.width - 40
|
|
horizontalAlignment: Text.AlignHCenter
|
|
elide: Text.ElideMiddle
|
|
font.pixelSize: 12
|
|
font.weight: Font.Medium
|
|
color: Theme.palette.background
|
|
text: qsTr("Unable to connect to network")
|
|
}
|
|
}
|
|
|
|
// The app is always usable; the wallet is opt-in via the navbar "Connect"
|
|
// control. Trade/Liquidity render immediately on launch.
|
|
NavBar {
|
|
id: navbar
|
|
anchors.top: connectionBanner.bottom
|
|
anchors.left: parent.left
|
|
anchors.right: parent.right
|
|
z: 100
|
|
|
|
backend: root.ready ? root.backend : null
|
|
accountModel: root.accountModel
|
|
}
|
|
|
|
Item {
|
|
anchors.top: navbar.bottom
|
|
anchors.left: parent.left
|
|
anchors.right: parent.right
|
|
anchors.bottom: parent.bottom
|
|
|
|
SwapPage {
|
|
anchors.fill: parent
|
|
visible: navbar.currentIndex === 0
|
|
backend: root.ready ? root.backend : null
|
|
}
|
|
|
|
LiquidityPage {
|
|
anchors.fill: parent
|
|
backend: root.ready ? root.backend : null
|
|
runtime: logos
|
|
visible: navbar.currentIndex === 1
|
|
}
|
|
|
|
PoolsPage {
|
|
anchors.fill: parent
|
|
backend: root.ready ? root.backend : null
|
|
runtime: logos
|
|
visible: navbar.currentIndex === 2
|
|
}
|
|
}
|
|
}
|