mirror of
https://github.com/logos-blockchain/lez-programs.git
synced 2026-08-26 06:31:19 +00:00
feat(wallet): humanize shared wallet experience
Consolidate wallet account decoding and portfolio handling around the shared Rust IDL decoder. Simplify AMM wallet integration, remove obsolete caches and network plumbing, and cover account selection and live flows.
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "WalletProvider.h"
|
||||
|
||||
class FakeWalletProvider final : public WalletProvider {
|
||||
@@ -23,6 +25,9 @@ public:
|
||||
bool lastAccountWasPublic = false;
|
||||
WalletPaths lastPaths;
|
||||
WalletTransaction lastTransaction;
|
||||
bool deferAsync = false;
|
||||
SessionCallback pendingConnectCallback;
|
||||
SnapshotCallback pendingSnapshotCallback;
|
||||
|
||||
WalletSession connect(const WalletPaths& paths) override
|
||||
{
|
||||
@@ -31,6 +36,16 @@ public:
|
||||
return connectResult;
|
||||
}
|
||||
|
||||
void connectAsync(const WalletPaths& paths, SessionCallback callback) override
|
||||
{
|
||||
++connectCalls;
|
||||
lastPaths = paths;
|
||||
if (deferAsync)
|
||||
pendingConnectCallback = std::move(callback);
|
||||
else
|
||||
callback(connectResult);
|
||||
}
|
||||
|
||||
WalletCreation createWallet(const WalletPaths& paths,
|
||||
const QString&) override
|
||||
{
|
||||
@@ -46,6 +61,16 @@ public:
|
||||
return snapshotResult;
|
||||
}
|
||||
|
||||
void snapshotAsync(bool forceRefresh, SnapshotCallback callback) override
|
||||
{
|
||||
++snapshotCalls;
|
||||
lastForceRefresh = forceRefresh;
|
||||
if (deferAsync)
|
||||
pendingSnapshotCallback = std::move(callback);
|
||||
else
|
||||
callback(snapshotResult);
|
||||
}
|
||||
|
||||
void clearSnapshot() override { ++clearCalls; }
|
||||
|
||||
WalletAccountCreation createAccount(bool isPublic) override
|
||||
@@ -72,4 +97,19 @@ public:
|
||||
}
|
||||
|
||||
void disconnect() override { ++disconnectCalls; }
|
||||
|
||||
void finishConnect()
|
||||
{
|
||||
SessionCallback callback = std::move(pendingConnectCallback);
|
||||
if (callback)
|
||||
callback(connectResult);
|
||||
}
|
||||
|
||||
void finishSnapshot()
|
||||
{
|
||||
SnapshotCallback callback = std::move(pendingSnapshotCallback);
|
||||
if (callback)
|
||||
callback(snapshotResult);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user