fix: suggestions fix

This commit is contained in:
Pravdyvy 2026-06-23 15:18:02 +03:00
parent 2322cb596e
commit 4abb7d1dbb
6 changed files with 37 additions and 36 deletions

32
flake.lock generated
View File

@ -1574,17 +1574,17 @@
"rust-rapidsnark": "rust-rapidsnark" "rust-rapidsnark": "rust-rapidsnark"
}, },
"locked": { "locked": {
"lastModified": 1782126008, "lastModified": 1782215423,
"narHash": "sha256-kPOgwMn1NyDkG8DLhN9xJPbwv8Dig0m5m1pm9SUk6tA=", "narHash": "sha256-KkVt9SWYIe+z7rQgxIN86bSShgvdj4KlnSOKFyUbLNU=",
"owner": "logos-blockchain", "owner": "logos-blockchain",
"repo": "lssa", "repo": "lssa",
"rev": "ca64789a90019e193797d63dfdb68b770ddf621d", "rev": "4d055c71a77d4b3aa147dfe8e1673afb3217840b",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "logos-blockchain", "owner": "logos-blockchain",
"repo": "lssa", "repo": "lssa",
"rev": "ca64789a90019e193797d63dfdb68b770ddf621d", "rev": "4d055c71a77d4b3aa147dfe8e1673afb3217840b",
"type": "github" "type": "github"
} }
}, },
@ -2194,11 +2194,11 @@
"rust-overlay": "rust-overlay_2" "rust-overlay": "rust-overlay_2"
}, },
"locked": { "locked": {
"lastModified": 1782083712, "lastModified": 1782146416,
"narHash": "sha256-Pfm1dW38HNpnohJgY+g3V9i0Li9f6xD5fwB+y7ZiIZI=", "narHash": "sha256-WkkDTc8p0YkZ5H1w9KmYih0WFT1+k/yjPKXtM3Mt6+E=",
"owner": "logos-co", "owner": "logos-co",
"repo": "logos-module-builder", "repo": "logos-module-builder",
"rev": "42aaf22c3af9cb8e5842a2df6eece3b4627a9ac3", "rev": "f4942648c28127d4ef4d4b467b22bd33873ab4fa",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -9221,11 +9221,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1777575342, "lastModified": 1781872378,
"narHash": "sha256-l/tL39ZVNz3nWpE9zWpC/kg11QHSQJ2HHp3W3yv1pNI=", "narHash": "sha256-ZHh+krtTbn6Qt7Hm3+shrhAAGCFa7FXt8ajYqx+Nt1o=",
"owner": "logos-co", "owner": "logos-co",
"repo": "logos-package", "repo": "logos-package",
"rev": "118ccc4efd04eb0c4d541be8db7f1075e014ac39", "rev": "ab885df3641e9adb61ff16e42d3e6f63b24db8f6",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -12425,11 +12425,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1774455641, "lastModified": 1776974030,
"narHash": "sha256-HrVJguPxhIoZMCH+x8Wooa0tE6slUhgNOU6P89t2uQc=", "narHash": "sha256-lQ/tc/owFa7Yjh8MXe0Fn2GodQXVGmpOZwe5gBEcENA=",
"owner": "logos-co", "owner": "logos-co",
"repo": "nix-bundle-dir", "repo": "nix-bundle-dir",
"rev": "3d155cab09051703a0b02ff2de166a53c30cbca8", "rev": "4937262f55cf8be942263255dd0801e3e3878bc9",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -12952,11 +12952,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1777575520, "lastModified": 1781872587,
"narHash": "sha256-HOwg1N4NfGYq579IppVPpVjPDZfYQGndXGlcl1VRXXo=", "narHash": "sha256-zl9odZ1Tq7QBAYJVrXiLSC47FVYra3kIakb/TeGPoZI=",
"owner": "logos-co", "owner": "logos-co",
"repo": "nix-bundle-lgx", "repo": "nix-bundle-lgx",
"rev": "3c44d99b9d8dbd8a135b44b5b328e6175650305e", "rev": "b49074a8e1157832002b11d3d254c1aaa4b96680",
"type": "github" "type": "github"
}, },
"original": { "original": {

View File

@ -4,7 +4,7 @@
inputs = { inputs = {
logos-module-builder.url = "github:logos-co/logos-module-builder"; logos-module-builder.url = "github:logos-co/logos-module-builder";
nix-bundle-lgx.url = "github:logos-co/nix-bundle-lgx"; nix-bundle-lgx.url = "github:logos-co/nix-bundle-lgx";
logos-execution-zone.url = "github:logos-blockchain/lssa?rev=ca64789a90019e193797d63dfdb68b770ddf621d"; # latest mnemonic updates, to be replaced after merging logos-execution-zone.url = "github:logos-blockchain/lssa?rev=4d055c71a77d4b3aa147dfe8e1673afb3217840b"; # latest mnemonic updates, to be replaced after merging
}; };
outputs = inputs@{ logos-module-builder, ... }: outputs = inputs@{ logos-module-builder, ... }:

View File

@ -1043,20 +1043,22 @@ std::string LogosExecutionZoneWalletModule::create_new(
return {}; return {};
} }
FfiCreateWalletResult create_result = wallet_ffi_create_new(config_path.c_str(), storage_path.c_str(), password.c_str()); FfiCreateWalletOutput create_output = wallet_ffi_create_new(config_path.c_str(), storage_path.c_str(), password.c_str());
if (!create_result.wallet) { if (!create_output.wallet) {
fprintf(stderr, "create_new: wallet_ffi_create_new returned null\n"); fprintf(stderr, "create_new: wallet_ffi_create_new returned null\n");
return {}; return {};
} }
walletHandle = create_result.wallet; walletHandle = create_output.wallet;
std::string mnemonic = *create_result.mnemonic; std::string mnemonic(create_output.mnemonic);
wallet_ffi_free_string(create_output.mnemonic);
return mnemonic; return mnemonic;
} }
int64_t LogosExecutionZoneWalletModule::restore_storage(const std::string& mnemonic, const std::string password) { int64_t LogosExecutionZoneWalletModule::restore_storage(const std::string& mnemonic, const std::string password, uint32_t depth) {
const WalletFfiError error = wallet_ffi_restore_data(walletHandle, mnemonic.c_str(), password.c_str()); const WalletFfiError error = wallet_ffi_restore_data(walletHandle, mnemonic.c_str(), password.c_str(), depth);
if (error != SUCCESS) { if (error != SUCCESS) {
fprintf(stderr, "restore_storage: wallet FFI error %d\n", error); fprintf(stderr, "restore_storage: wallet FFI error %d\n", error);
return error; return error;

View File

@ -34,7 +34,7 @@ public:
int64_t open(const std::string& config_path, const std::string& storage_path); int64_t open(const std::string& config_path, const std::string& storage_path);
int64_t save(); int64_t save();
int64_t restore_storage(const std::string& mnemonic, const std::string password); int64_t restore_storage(const std::string& mnemonic, const std::string password, uint32_t depth);
// === Account Management === // === Account Management ===
std::string create_account_public(); std::string create_account_public();

View File

@ -47,16 +47,15 @@ extern "C" {
// === Lifecycle === // === Lifecycle ===
FfiCreateWalletResult wallet_ffi_create_new(const char*, const char*, const char*) { FfiCreateWalletOutput wallet_ffi_create_new(const char*, const char*, const char*) {
LOGOS_CMOCK_RECORD("wallet_ffi_create_new"); LOGOS_CMOCK_RECORD("wallet_ffi_create_new");
const int ok = LOGOS_CMOCK_RETURN(int, "wallet_ffi_create_new"); const int ok = LOGOS_CMOCK_RETURN(int, "wallet_ffi_create_new");
const char* mnemonic_ok = LOGOS_CMOCK_RETURN_STRING("wallet_ffi_create_new"); const char* mnemonic_ok = LOGOS_CMOCK_RETURN_STRING("wallet_ffi_create_new");
FfiCreateWalletResult result; FfiCreateWalletOutput output;
char* mn_char = strdup((mnemonic_ok && *mnemonic_ok) ? mnemonic_ok : "word word"); char* mn_char = strdup((mnemonic_ok && *mnemonic_ok) ? mnemonic_ok : "word word");
const char** mn = (const char**)&mn_char; output.mnemonic = mn_char;
result.mnemonic = mn; output.wallet = ok ? reinterpret_cast<WalletHandle*>(&g_fakeWallet) : nullptr;
result.wallet = ok ? reinterpret_cast<WalletHandle*>(&g_fakeWallet) : nullptr; return output;
return result;
} }
WalletHandle* wallet_ffi_open(const char*, const char*) { WalletHandle* wallet_ffi_open(const char*, const char*) {
@ -74,7 +73,7 @@ void wallet_ffi_destroy(WalletHandle*) {
LOGOS_CMOCK_RECORD("wallet_ffi_destroy"); LOGOS_CMOCK_RECORD("wallet_ffi_destroy");
} }
WalletFfiError wallet_ffi_restore_data(WalletHandle*, const char*, const char*) { WalletFfiError wallet_ffi_restore_data(WalletHandle*, const char*, const char*, uint32_t) {
LOGOS_CMOCK_RECORD("wallet_ffi_restore_data"); LOGOS_CMOCK_RECORD("wallet_ffi_restore_data");
const int err = LOGOS_CMOCK_RETURN(int, "wallet_ffi_restore_data"); const int err = LOGOS_CMOCK_RETURN(int, "wallet_ffi_restore_data");
return static_cast<WalletFfiError>(err); return static_cast<WalletFfiError>(err);

View File

@ -156,22 +156,22 @@ typedef struct FfiTransactionResult {
uintptr_t secrets_size; uintptr_t secrets_size;
} FfiTransactionResult; } FfiTransactionResult;
typedef struct FfiCreateWalletResult { typedef struct FfiCreateWalletOutput {
struct WalletHandle *wallet; struct WalletHandle *wallet;
/** /**
* C compatible(null terminated) string. * C compatible(null terminated) string.
*/ */
const char **mnemonic; char *mnemonic;
} FfiCreateWalletResult; } FfiCreateWalletOutput;
// === Lifecycle === // === Lifecycle ===
FfiCreateWalletResult wallet_ffi_create_new(const char* config_path, const char* storage_path, const char* password); FfiCreateWalletOutput wallet_ffi_create_new(const char* config_path, const char* storage_path, const char* password);
WalletHandle* wallet_ffi_open(const char* config_path, const char* storage_path); WalletHandle* wallet_ffi_open(const char* config_path, const char* storage_path);
int wallet_ffi_save(WalletHandle* handle); int wallet_ffi_save(WalletHandle* handle);
void wallet_ffi_destroy(WalletHandle* handle); void wallet_ffi_destroy(WalletHandle* handle);
WalletFfiError wallet_ffi_restore_data(WalletHandle *handle, const char *mnemonic, const char *password); WalletFfiError wallet_ffi_restore_data(WalletHandle *handle, const char *mnemonic, const char *password, uint32_t depth);
// === Account management === // === Account management ===