1
0
Fork 0
mirror of https://github.com/ton-blockchain/ton synced 2025-03-09 15:40:10 +00:00

Tonlib fix (#743)

* Fix building messages with long body (#709)

* Fix returning slice in tonlib (#734)

---------

Co-authored-by: SpyCheese <mikle98@yandex.ru>
This commit is contained in:
EmelyanenkoK 2023-07-14 15:23:22 +03:00 committed by GitHub
parent 08cfc4c6ee
commit 9b34217bf0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 4 deletions

View file

@ -55,18 +55,21 @@ td::Ref<vm::Cell> WalletInterface::create_int_message(const Gift &gift) {
} else {
cbi.store_zeroes(1);
}
cbi.store_zeroes(1);
store_gift_message(cbi, gift);
return cbi.finalize();
}
void WalletInterface::store_gift_message(vm::CellBuilder &cb, const Gift &gift) {
if (gift.body.not_null()) {
auto body = vm::load_cell_slice(gift.body);
//TODO: handle error
CHECK(cb.append_cellslice_bool(body));
if (cb.can_extend_by(1 + body.size(), body.size_refs())) {
CHECK(cb.store_zeroes_bool(1) && cb.append_cellslice_bool(body));
} else {
CHECK(cb.store_ones_bool(1) && cb.store_ref_bool(gift.body));
}
return;
}
cb.store_zeroes(1);
if (gift.is_encrypted) {
cb.store_long(0x2167da4b, 32);
} else {

View file

@ -73,6 +73,8 @@ class WalletInterface : public SmartContract {
td::uint32 valid_until = std::numeric_limits<td::uint32>::max()) const;
static td::Ref<vm::Cell> create_int_message(const Gift &gift);
private:
static void store_gift_message(vm::CellBuilder &cb, const Gift &gift);
};

View file

@ -4290,7 +4290,7 @@ auto to_tonlib_api(const vm::StackEntry& entry, int& limit) -> td::Result<tonlib
return tonlib_api::make_object<tonlib_api::tvm_stackEntryNumber>(
tonlib_api::make_object<tonlib_api::tvm_numberDecimal>(dec_string(entry.as_int())));
case vm::StackEntry::Type::t_slice:
return tonlib_api::make_object<tonlib_api::tvm_stackEntryCell>(tonlib_api::make_object<tonlib_api::tvm_cell>(
return tonlib_api::make_object<tonlib_api::tvm_stackEntrySlice>(tonlib_api::make_object<tonlib_api::tvm_slice>(
to_bytes(vm::CellBuilder().append_cellslice(entry.as_slice()).finalize())));
case vm::StackEntry::Type::t_cell:
return tonlib_api::make_object<tonlib_api::tvm_stackEntryCell>(