mirror of
https://github.com/logos-blockchain/logos-execution-zone-wallet-ui.git
synced 2026-07-30 06:33:29 +00:00
fix: manual serialization added
This commit is contained in:
parent
cc74428466
commit
0470bc331b
14
flake.lock
generated
14
flake.lock
generated
@ -1828,11 +1828,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1780948815,
|
||||
"narHash": "sha256-NiBHv3Fb6kGcbz4zSHSGMBMqReXtsPEt1DaqxGfQotA=",
|
||||
"lastModified": 1781025483,
|
||||
"narHash": "sha256-3u/CjYuKD31W4jeODJOk5uE90r0nLB826VVaCs2OZKI=",
|
||||
"owner": "logos-co",
|
||||
"repo": "logos-module-builder",
|
||||
"rev": "b841fdc1d9a60f470e924a0da78ec5978c1b0a1b",
|
||||
"rev": "aa5b5d354d9970ea12d5342e5c3324142cc4d680",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@ -11386,17 +11386,17 @@
|
||||
"nix-bundle-lgx": "nix-bundle-lgx_22"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1781017146,
|
||||
"narHash": "sha256-nm+Tn0U5Y0rO0k272UtXf2KYnbFZhotNgrp5aWbRSCo=",
|
||||
"lastModified": 1781090578,
|
||||
"narHash": "sha256-IiOhB1nNvOeSBw9cOiuIJ2e62Mg7MX0+P9i6OPT6UQQ=",
|
||||
"owner": "logos-blockchain",
|
||||
"repo": "logos-execution-zone-module",
|
||||
"rev": "32c16c000a7a5845629c42ead71629216e9e5261",
|
||||
"rev": "09f539a13662ae1a177e66cceb42a881307d92ca",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "logos-blockchain",
|
||||
"repo": "logos-execution-zone-module",
|
||||
"rev": "32c16c000a7a5845629c42ead71629216e9e5261",
|
||||
"rev": "09f539a13662ae1a177e66cceb42a881307d92ca",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
|
||||
@ -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/logos-execution-zone-module?rev=32c16c000a7a5845629c42ead71629216e9e5261";
|
||||
logos_execution_zone.url = "github:logos-blockchain/logos-execution-zone-module?rev=09f539a13662ae1a177e66cceb42a881307d92ca";
|
||||
};
|
||||
|
||||
outputs = inputs@{ logos-module-builder, ... }:
|
||||
|
||||
@ -225,12 +225,22 @@ bool LEZWalletBackend::syncToBlock(quint64 blockId)
|
||||
QString LEZWalletBackend::transferPublic(QString fromHex, QString toHex, QString amountStr)
|
||||
{
|
||||
QStringList account_ids = { fromHex, toHex };
|
||||
QJsonArray signing_requirements = { true, false };
|
||||
QJsonArray elf_json = m_logos->logos_execution_zone.authenticated_transfer_elf();
|
||||
QStringList signing_requirements = { "true", "false" };
|
||||
QStringList elf_json = m_logos->logos_execution_zone.authenticated_transfer_elf();
|
||||
// No dependencies
|
||||
QJsonArray program_dependencies;
|
||||
QStringList program_dependencies;
|
||||
|
||||
// Instruction encoding
|
||||
// Instruction encoding, the hardest part
|
||||
// RISC0 consumes not bytes, but uint32_t words
|
||||
// construction of which is dependant on Rust serialization
|
||||
// In this exact case instruction is:
|
||||
//
|
||||
// Instruction::Transfer {
|
||||
// amount: u128
|
||||
// }
|
||||
//
|
||||
// which encodes to [0, word_1, word_2, word_3, word_4]
|
||||
// where 0 - is Transfer enum identifier and words is from le representation of u128.
|
||||
const QString amountHex = amountToLe16Hex(amountStr);
|
||||
if (amountHex.isEmpty()) return QStringLiteral("Error: Invalid amount.");
|
||||
|
||||
@ -239,25 +249,28 @@ QString LEZWalletBackend::transferPublic(QString fromHex, QString toHex, QString
|
||||
return QStringLiteral("Error: Invalid amount.");
|
||||
}
|
||||
|
||||
QList<uint8_t> input_data_raw;
|
||||
input_data_raw.reserve(17);
|
||||
input_data_raw.append(0);
|
||||
for (int i = 0; i < 16; i++) {
|
||||
input_data_raw.append(amount[i]);
|
||||
QList<uint32_t> amount_words;
|
||||
amount_words.reserve(5);
|
||||
amount_words.append(0);
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
uint32_t word = static_cast<uint32_t>(amount[i * 4])
|
||||
| static_cast<uint32_t>(amount[i * 4 + 1]) << 8
|
||||
| static_cast<uint32_t>(amount[i * 4 + 2]) << 16
|
||||
| static_cast<uint32_t>(amount[i * 4 + 3]) << 24;
|
||||
amount_words.append(word);
|
||||
}
|
||||
|
||||
QJsonArray input_data_raw_json;
|
||||
for (size_t i = 0; i < input_data_raw.size(); ++i) {
|
||||
input_data_raw_json.append(static_cast<int>(input_data_raw[i]));
|
||||
QStringList amount_list;
|
||||
amount_list.reserve(amount_words.size());
|
||||
for (const uint32_t word : amount_words) {
|
||||
amount_list.append(QString::number(word));
|
||||
}
|
||||
|
||||
QJsonArray input_data = m_logos->logos_execution_zone.serialization_helper(input_data_raw_json);
|
||||
|
||||
const QStringList& account_ids_ref = account_ids;
|
||||
const QJsonArray& signing_requirements_ref = signing_requirements;
|
||||
const QJsonArray& input_data_ref = input_data;
|
||||
const QJsonArray& elf_json_ref = elf_json;
|
||||
const QJsonArray& program_dependencies_ref = program_dependencies;
|
||||
const QStringList& signing_requirements_ref = signing_requirements;
|
||||
const QStringList& input_data_ref = amount_list;
|
||||
const QStringList& elf_json_ref = elf_json;
|
||||
const QStringList& program_dependencies_ref = program_dependencies;
|
||||
|
||||
return m_logos->logos_execution_zone.send_generic_public_transaction(account_ids_ref, signing_requirements_ref, input_data_ref, elf_json_ref, program_dependencies_ref);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user