mirror of
https://github.com/logos-blockchain/lez-programs.git
synced 2026-07-25 08:13:12 +00:00
61 lines
3.0 KiB
Plaintext
61 lines
3.0 KiB
Plaintext
// QtRO view contract for the AMM UI backend. PROPs auto-sync to every QML
|
|
// replica; SLOTs are the async surface QML calls via logos.watch(...).
|
|
// The account list is exposed separately as a Q_PROPERTY model on the backend
|
|
// (reached from QML via logos.model("amm_ui", "accountModel")).
|
|
class AmmUiBackend
|
|
{
|
|
PROP(bool isWalletOpen READONLY)
|
|
PROP(bool walletExists READONLY)
|
|
PROP(QString configPath READONLY)
|
|
PROP(QString storagePath READONLY)
|
|
PROP(QString walletHome READONLY)
|
|
PROP(int lastSyncedBlock READONLY)
|
|
PROP(int currentBlockHeight READONLY)
|
|
PROP(QString sequencerAddr READONLY)
|
|
// Whether the configured sequencer answered the last reachability probe.
|
|
// Defaults true so the UI doesn't flash a warning before the first check.
|
|
PROP(bool sequencerReachable READONLY)
|
|
|
|
// Account management
|
|
SLOT(QString createAccountPublic())
|
|
SLOT(QString createAccountPrivate())
|
|
SLOT(void refreshAccounts())
|
|
SLOT(void refreshBalances())
|
|
SLOT(QString getBalance(QString accountIdHex, bool isPublic))
|
|
|
|
// Wallet lifecycle. createNewDefault() is the happy path: it creates a
|
|
// fresh per-app wallet at walletHome with no path picking. createNew()
|
|
// keeps explicit paths for an "advanced" flow. Both return the new wallet's
|
|
// BIP39 mnemonic (empty on failure) so the UI can force a seed-phrase backup
|
|
// before the wallet is usable — this is the only chance to record it.
|
|
SLOT(QString createNewDefault(QString password))
|
|
SLOT(QString createNew(QString configPath, QString storagePath, QString password))
|
|
|
|
// Re-open the existing on-disk wallet after a disconnect.
|
|
SLOT(bool openExisting())
|
|
// Close this app's wallet view (lock); does not delete the wallet and, in
|
|
// Basecamp, does not close the wallet other apps share.
|
|
SLOT(void disconnectWallet())
|
|
|
|
// Settings. Rewrites the wallet config's sequencer_addr and re-opens the
|
|
// wallet so the new network takes effect immediately.
|
|
SLOT(bool changeSequencerAddr(QString url))
|
|
|
|
// Misc
|
|
SLOT(void copyToClipboard(QString text))
|
|
|
|
// AMM
|
|
// Derives the AMM pool's PDAs (config/pool/vaults/current-tick) from the
|
|
// deployed AMM program's ELF (see AMM_PROGRAM_BIN) and reads the pool's
|
|
// on-chain reserves. Returns `{ exists: false }` if the AMM program bin
|
|
// isn't configured, the AMM isn't initialized, or the pool has no
|
|
// liquidity yet.
|
|
SLOT(QVariantMap resolvePool(QString defAHex, QString defBHex))
|
|
// Submits a real on-chain SwapExactInput transaction against the pool for
|
|
// (defAHex, defBHex). amountInDecimal/minOutDecimal are decimal-string
|
|
// u128 amounts in base units; deadlineDecimal is a decimal-string u64
|
|
// unix timestamp. Returns the tx hash, or an empty string on failure
|
|
// (no pool, unreadable AMM_PROGRAM_BIN, bad inputs, or a failed tx).
|
|
SLOT(QString swapExactInput(QString defAHex, QString defBHex, QString userInputHoldingHex, QString userOutputHoldingHex, QString amountInDecimal, QString minOutDecimal, QString deadlineDecimal))
|
|
}
|