diff --git a/flake.lock b/flake.lock index e6aacfa..ba798d6 100644 --- a/flake.lock +++ b/flake.lock @@ -1574,17 +1574,17 @@ "rust-rapidsnark": "rust-rapidsnark" }, "locked": { - "lastModified": 1782126008, - "narHash": "sha256-kPOgwMn1NyDkG8DLhN9xJPbwv8Dig0m5m1pm9SUk6tA=", + "lastModified": 1782215423, + "narHash": "sha256-KkVt9SWYIe+z7rQgxIN86bSShgvdj4KlnSOKFyUbLNU=", "owner": "logos-blockchain", "repo": "lssa", - "rev": "ca64789a90019e193797d63dfdb68b770ddf621d", + "rev": "4d055c71a77d4b3aa147dfe8e1673afb3217840b", "type": "github" }, "original": { "owner": "logos-blockchain", "repo": "lssa", - "rev": "ca64789a90019e193797d63dfdb68b770ddf621d", + "rev": "4d055c71a77d4b3aa147dfe8e1673afb3217840b", "type": "github" } }, @@ -2194,11 +2194,11 @@ "rust-overlay": "rust-overlay_2" }, "locked": { - "lastModified": 1782083712, - "narHash": "sha256-Pfm1dW38HNpnohJgY+g3V9i0Li9f6xD5fwB+y7ZiIZI=", + "lastModified": 1782146416, + "narHash": "sha256-WkkDTc8p0YkZ5H1w9KmYih0WFT1+k/yjPKXtM3Mt6+E=", "owner": "logos-co", "repo": "logos-module-builder", - "rev": "42aaf22c3af9cb8e5842a2df6eece3b4627a9ac3", + "rev": "f4942648c28127d4ef4d4b467b22bd33873ab4fa", "type": "github" }, "original": { @@ -9221,11 +9221,11 @@ ] }, "locked": { - "lastModified": 1777575342, - "narHash": "sha256-l/tL39ZVNz3nWpE9zWpC/kg11QHSQJ2HHp3W3yv1pNI=", + "lastModified": 1781872378, + "narHash": "sha256-ZHh+krtTbn6Qt7Hm3+shrhAAGCFa7FXt8ajYqx+Nt1o=", "owner": "logos-co", "repo": "logos-package", - "rev": "118ccc4efd04eb0c4d541be8db7f1075e014ac39", + "rev": "ab885df3641e9adb61ff16e42d3e6f63b24db8f6", "type": "github" }, "original": { @@ -12425,11 +12425,11 @@ ] }, "locked": { - "lastModified": 1774455641, - "narHash": "sha256-HrVJguPxhIoZMCH+x8Wooa0tE6slUhgNOU6P89t2uQc=", + "lastModified": 1776974030, + "narHash": "sha256-lQ/tc/owFa7Yjh8MXe0Fn2GodQXVGmpOZwe5gBEcENA=", "owner": "logos-co", "repo": "nix-bundle-dir", - "rev": "3d155cab09051703a0b02ff2de166a53c30cbca8", + "rev": "4937262f55cf8be942263255dd0801e3e3878bc9", "type": "github" }, "original": { @@ -12952,11 +12952,11 @@ ] }, "locked": { - "lastModified": 1777575520, - "narHash": "sha256-HOwg1N4NfGYq579IppVPpVjPDZfYQGndXGlcl1VRXXo=", + "lastModified": 1781872587, + "narHash": "sha256-zl9odZ1Tq7QBAYJVrXiLSC47FVYra3kIakb/TeGPoZI=", "owner": "logos-co", "repo": "nix-bundle-lgx", - "rev": "3c44d99b9d8dbd8a135b44b5b328e6175650305e", + "rev": "b49074a8e1157832002b11d3d254c1aaa4b96680", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 4fae2b6..3f310a6 100644 --- a/flake.nix +++ b/flake.nix @@ -4,7 +4,7 @@ inputs = { logos-module-builder.url = "github:logos-co/logos-module-builder"; 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, ... }: diff --git a/src/logos_execution_zone_wallet_module.cpp b/src/logos_execution_zone_wallet_module.cpp index 37be5fc..605a1ec 100644 --- a/src/logos_execution_zone_wallet_module.cpp +++ b/src/logos_execution_zone_wallet_module.cpp @@ -1043,20 +1043,22 @@ std::string LogosExecutionZoneWalletModule::create_new( return {}; } - FfiCreateWalletResult create_result = wallet_ffi_create_new(config_path.c_str(), storage_path.c_str(), password.c_str()); - if (!create_result.wallet) { + FfiCreateWalletOutput create_output = wallet_ffi_create_new(config_path.c_str(), storage_path.c_str(), password.c_str()); + if (!create_output.wallet) { fprintf(stderr, "create_new: wallet_ffi_create_new returned null\n"); return {}; } - walletHandle = create_result.wallet; - std::string mnemonic = *create_result.mnemonic; + walletHandle = create_output.wallet; + std::string mnemonic(create_output.mnemonic); + + wallet_ffi_free_string(create_output.mnemonic); return mnemonic; } -int64_t LogosExecutionZoneWalletModule::restore_storage(const std::string& mnemonic, const std::string password) { - const WalletFfiError error = wallet_ffi_restore_data(walletHandle, mnemonic.c_str(), password.c_str()); +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(), depth); if (error != SUCCESS) { fprintf(stderr, "restore_storage: wallet FFI error %d\n", error); return error; diff --git a/src/logos_execution_zone_wallet_module.h b/src/logos_execution_zone_wallet_module.h index 0d72032..7d2feaa 100644 --- a/src/logos_execution_zone_wallet_module.h +++ b/src/logos_execution_zone_wallet_module.h @@ -34,7 +34,7 @@ public: int64_t open(const std::string& config_path, const std::string& storage_path); 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 === std::string create_account_public(); diff --git a/tests/mocks/mock_wallet_ffi.cpp b/tests/mocks/mock_wallet_ffi.cpp index 7acabd8..56fd37b 100644 --- a/tests/mocks/mock_wallet_ffi.cpp +++ b/tests/mocks/mock_wallet_ffi.cpp @@ -47,16 +47,15 @@ extern "C" { // === 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"); const int ok = LOGOS_CMOCK_RETURN(int, "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"); - const char** mn = (const char**)&mn_char; - result.mnemonic = mn; - result.wallet = ok ? reinterpret_cast(&g_fakeWallet) : nullptr; - return result; + output.mnemonic = mn_char; + output.wallet = ok ? reinterpret_cast(&g_fakeWallet) : nullptr; + return output; } WalletHandle* wallet_ffi_open(const char*, const char*) { @@ -74,7 +73,7 @@ void wallet_ffi_destroy(WalletHandle*) { 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"); const int err = LOGOS_CMOCK_RETURN(int, "wallet_ffi_restore_data"); return static_cast(err); diff --git a/tests/stubs/wallet_ffi.h b/tests/stubs/wallet_ffi.h index c1aa13c..46ff0d6 100644 --- a/tests/stubs/wallet_ffi.h +++ b/tests/stubs/wallet_ffi.h @@ -156,22 +156,22 @@ typedef struct FfiTransactionResult { uintptr_t secrets_size; } FfiTransactionResult; -typedef struct FfiCreateWalletResult { +typedef struct FfiCreateWalletOutput { struct WalletHandle *wallet; /** * C compatible(null terminated) string. */ - const char **mnemonic; -} FfiCreateWalletResult; + char *mnemonic; +} FfiCreateWalletOutput; // === 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); int wallet_ffi_save(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 ===