From 2c13c51e4fbfabd6a6527761c380bc2bef31fbcb Mon Sep 17 00:00:00 2001 From: Peter <> Date: Fri, 20 Sep 2019 22:02:25 +0400 Subject: [PATCH] Update API --- submodules/MtProtoKit/TON/TON.h | 16 +- submodules/MtProtoKit/TON/TON.mm | 62 +++- submodules/TelegramApi/Sources/Api0.swift | 19 +- submodules/TelegramApi/Sources/Api1.swift | 286 ++---------------- submodules/TelegramApi/Sources/Api3.swift | 69 ----- .../TelegramCore/ApplyUpdateMessage.swift | 2 +- .../TelegramCore/MessageReactionList.swift | 4 +- .../TelegramCore/MessageReactions.swift | 5 +- .../ReactionsMessageAttribute.swift | 8 +- .../TelegramCore/StoreMessage_Telegram.swift | 15 +- .../TelegramCore/UpdateMessageService.swift | 4 +- .../TelegramCore/UpdatesApiUtils.swift | 23 +- .../TelegramCore/TelegramCore/Wallets.swift | 35 ++- .../TelegramUI/TelegramUI/AppDelegate.swift | 2 +- submodules/WalletUI/BUCK | 1 + .../WalletUI/Sources/WalletInfoScreen.swift | 25 +- .../Sources/WalletInfoTransactionItem.swift | 136 ++++++++- .../tonlib-src/crypto/block/check-proof.cpp | 3 + .../ton/tonlib-src/crypto/block/check-proof.h | 14 +- .../ton/tonlib-src/crypto/openssl/bignum.cpp | 3 +- .../ton/tonlib-src/crypto/openssl/bignum.h | 2 +- .../third-party/wingetopt/CMakeLists.txt | 2 +- .../tl/generate/auto/tl/ton_api.cpp | 201 +++++++++++- .../tonlib-src/tl/generate/auto/tl/ton_api.h | 114 ++++++- .../tl/generate/auto/tl/ton_api.hpp | 12 + .../tl/generate/auto/tl/ton_api_json.cpp | 96 +++++- .../tl/generate/auto/tl/ton_api_json.h | 8 + .../tl/generate/auto/tl/tonlib_api.cpp | 111 ++++++- .../tl/generate/auto/tl/tonlib_api.h | 95 +++++- .../tl/generate/auto/tl/tonlib_api.hpp | 9 + .../tl/generate/auto/tl/tonlib_api_json.cpp | 150 ++++++++- .../tl/generate/auto/tl/tonlib_api_json.h | 6 + .../tonlib-src/tl/generate/scheme/ton_api.tl | 9 +- .../tonlib-src/tl/generate/scheme/ton_api.tlo | Bin 50984 -> 51664 bytes .../tl/generate/scheme/tonlib_api.tl | 20 +- .../tl/generate/scheme/tonlib_api.tlo | Bin 8696 -> 9420 bytes .../ton/tonlib-src/tonlib/.CMakeLists.txt.swp | Bin 16384 -> 0 bytes .../ton/tonlib-src/tonlib/CMakeLists.txt | 2 + .../tonlib-src/tonlib/test/.online.cpp.swp | Bin 0 -> 24576 bytes .../ton/tonlib-src/tonlib/test/offline.cpp | 15 +- .../ton/tonlib-src/tonlib/test/online.cpp | 10 +- .../tonlib/tonlib/BlockchainInfoStorage.cpp | 0 .../tonlib/tonlib/BlockchainInfoStorage.h | 11 + .../tonlib-src/tonlib/tonlib/ExtClient.cpp | 6 +- .../ton/tonlib-src/tonlib/tonlib/ExtClient.h | 5 +- .../tonlib/tonlib/ExtClientOutbound.cpp | 66 ++++ .../tonlib/tonlib/ExtClientOutbound.h | 37 +++ .../tonlib-src/tonlib/tonlib/LastBlock.cpp | 72 +++-- .../ton/tonlib-src/tonlib/tonlib/LastBlock.h | 32 +- .../tonlib-src/tonlib/tonlib/TonlibClient.cpp | 140 +++++++-- .../tonlib-src/tonlib/tonlib/TonlibClient.h | 12 + .../tonlib-src/tonlib/tonlib/tonlib-cli.cpp | 109 ++++++- 52 files changed, 1524 insertions(+), 560 deletions(-) delete mode 100644 submodules/ton/tonlib-src/tonlib/.CMakeLists.txt.swp create mode 100644 submodules/ton/tonlib-src/tonlib/test/.online.cpp.swp create mode 100644 submodules/ton/tonlib-src/tonlib/tonlib/BlockchainInfoStorage.cpp create mode 100644 submodules/ton/tonlib-src/tonlib/tonlib/BlockchainInfoStorage.h create mode 100644 submodules/ton/tonlib-src/tonlib/tonlib/ExtClientOutbound.cpp create mode 100644 submodules/ton/tonlib-src/tonlib/tonlib/ExtClientOutbound.h diff --git a/submodules/MtProtoKit/TON/TON.h b/submodules/MtProtoKit/TON/TON.h index 2a00816caa..21051e8dee 100644 --- a/submodules/MtProtoKit/TON/TON.h +++ b/submodules/MtProtoKit/TON/TON.h @@ -51,18 +51,28 @@ NS_ASSUME_NONNULL_BEGIN @interface TONTransaction : NSObject @property (nonatomic, strong, readonly) NSData * _Nonnull data; -@property (nonatomic, strong, readonly) TONTransactionId * _Nonnull previousTransactionId; +@property (nonatomic, strong, readonly) TONTransactionId * _Nonnull transactionId; +@property (nonatomic, readonly) int64_t timestamp; @property (nonatomic, readonly) int64_t fee; @property (nonatomic, strong, readonly) TONTransactionMessage * _Nullable inMessage; @property (nonatomic, strong, readonly) NSArray * _Nonnull outMessages; -- (instancetype)initWithData:(NSData * _Nonnull)data previousTransactionId:(TONTransactionId * _Nonnull)previousTransactionId inMessage:(TONTransactionMessage * _Nullable)inMessage outMessages:(NSArray * _Nonnull)outMessages; +- (instancetype)initWithData:(NSData * _Nonnull)data transactionId:(TONTransactionId * _Nonnull)transactionId timestamp:(int64_t)timestamp fee:(int64_t)fee inMessage:(TONTransactionMessage * _Nullable)inMessage outMessages:(NSArray * _Nonnull)outMessages; + +@end + +@interface TONExternalRequest : NSObject + +@property (nonatomic, strong, readonly) NSData * _Nonnull data; +@property (nonatomic, copy, readonly) void (^onResult)(NSData * _Nullable, NSString * _Nullable); + +- (instancetype)initWithData:(NSData * _Nonnull)data onResult:(void (^)(NSData * _Nullable, NSString * _Nullable))onResult; @end @interface TON : NSObject -- (instancetype)initWithKeystoreDirectory:(NSString *)keystoreDirectory config:(NSString *)config; +- (instancetype)initWithKeystoreDirectory:(NSString *)keystoreDirectory config:(NSString *)config performExternalRequest:(void (^)(TONExternalRequest * _Nonnull))performExternalRequest; - (MTSignal *)createKeyWithLocalPassword:(NSData *)localPassword mnemonicPassword:(NSData *)mnemonicPassword; - (MTSignal *)getTestWalletAccountAddressWithPublicKey:(NSString *)publicKey; diff --git a/submodules/MtProtoKit/TON/TON.mm b/submodules/MtProtoKit/TON/TON.mm index 0376016504..a1d75df6eb 100644 --- a/submodules/MtProtoKit/TON/TON.mm +++ b/submodules/MtProtoKit/TON/TON.mm @@ -105,11 +105,13 @@ static TONTransactionMessage * _Nullable parseTransactionMessage(tonlib_api::obj @implementation TONTransaction -- (instancetype)initWithData:(NSData * _Nonnull)data previousTransactionId:(TONTransactionId * _Nonnull)previousTransactionId inMessage:(TONTransactionMessage * _Nullable)inMessage outMessages:(NSArray * _Nonnull)outMessages { +- (instancetype)initWithData:(NSData * _Nonnull)data transactionId:(TONTransactionId * _Nonnull)transactionId timestamp:(int64_t)timestamp fee:(int64_t)fee inMessage:(TONTransactionMessage * _Nullable)inMessage outMessages:(NSArray * _Nonnull)outMessages { self = [super init]; if (self != nil) { _data = data; - _previousTransactionId = previousTransactionId; + _transactionId = transactionId; + _timestamp = timestamp; + _fee = fee; _inMessage = inMessage; _outMessages = outMessages; } @@ -118,6 +120,19 @@ static TONTransactionMessage * _Nullable parseTransactionMessage(tonlib_api::obj @end +@implementation TONExternalRequest + +- (instancetype)initWithData:(NSData * _Nonnull)data onResult:(void (^)(NSData * _Nullable, NSString * _Nullable))onResult { + self = [super init]; + if (self != nil) { + _data = data; + _onResult = [onResult copy]; + } + return self; +} + +@end + using tonlib_api::make_object; @interface TONReceiveThreadParams : NSObject @@ -197,7 +212,7 @@ typedef enum { } } -- (instancetype)initWithKeystoreDirectory:(NSString *)keystoreDirectory config:(NSString *)config { +- (instancetype)initWithKeystoreDirectory:(NSString *)keystoreDirectory config:(NSString *)config performExternalRequest:(void (^)(TONExternalRequest * _Nonnull))performExternalRequest { self = [super init]; if (self != nil) { _requestHandlersLock = [[NSLock alloc] init]; @@ -208,9 +223,40 @@ typedef enum { _client = std::make_shared(); + std::weak_ptr weakClient = _client; + NSLock *requestHandlersLock = _requestHandlersLock; NSMutableDictionary *requestHandlers = _requestHandlers; NSThread *thread = [[NSThread alloc] initWithTarget:[self class] selector:@selector(receiveThread:) object:[[TONReceiveThreadParams alloc] initWithClient:_client received:^(tonlib::Client::Response &response) { + if (response.object->get_id() == tonlib_api::updateSendLiteServerQuery::ID) { + auto result = tonlib_api::move_object_as(response.object); + int64_t requestId = result->id_; + NSData *data = makeData(result->data_); + if (performExternalRequest) { + performExternalRequest([[TONExternalRequest alloc] initWithData:data onResult:^(NSData * _Nullable result, NSString * _Nullable error) { + auto strongClient = weakClient.lock(); + if (strongClient != nullptr) { + if (result != nil) { + auto query = make_object( + requestId, + makeString(result) + ); + strongClient->send({ 1, std::move(query) }); + } else if (error != nil) { + auto query = make_object( + requestId, + make_object( + 400, + error.UTF8String + ) + ); + strongClient->send({ 1, std::move(query) }); + } + } + }]); + } + return; + } NSNumber *requestId = @(response.id); [requestHandlersLock lock]; TONRequestHandler *handler = requestHandlers[requestId]; @@ -252,7 +298,11 @@ typedef enum { } }]; - auto query = make_object(make_object(configString.UTF8String, keystoreDirectory.UTF8String)); + auto query = make_object(make_object( + configString.UTF8String, + keystoreDirectory.UTF8String, + false + )); _client->send({ requestId, std::move(query) }); return [[MTBlockDisposable alloc] initWithBlock:^{ @@ -656,7 +706,7 @@ typedef enum { auto result = tonlib_api::move_object_as(object); NSMutableArray *transactions = [[NSMutableArray alloc] init]; for (auto &it : result->transactions_) { - TONTransactionId *previousTransactionId = [[TONTransactionId alloc] initWithLt:it->previous_transaction_id_->lt_ transactionHash:makeData(it->previous_transaction_id_->hash_)]; + TONTransactionId *transactionId = [[TONTransactionId alloc] initWithLt:it->transaction_id_->lt_ transactionHash:makeData(it->transaction_id_->hash_)]; TONTransactionMessage *inMessage = parseTransactionMessage(it->in_msg_); NSMutableArray * outMessages = [[NSMutableArray alloc] init]; for (auto &messageIt : it->out_msgs_) { @@ -665,7 +715,7 @@ typedef enum { [outMessages addObject:outMessage]; } } - [transactions addObject:[[TONTransaction alloc] initWithData:makeData(it->data_) previousTransactionId:previousTransactionId inMessage:inMessage outMessages:outMessages]]; + [transactions addObject:[[TONTransaction alloc] initWithData:makeData(it->data_) transactionId:transactionId timestamp:it->utime_ fee:it->fee_ inMessage:inMessage outMessages:outMessages]]; } [subscriber putNext:transactions]; [subscriber putCompletion]; diff --git a/submodules/TelegramApi/Sources/Api0.swift b/submodules/TelegramApi/Sources/Api0.swift index 3b3cef1da1..11218fef0c 100644 --- a/submodules/TelegramApi/Sources/Api0.swift +++ b/submodules/TelegramApi/Sources/Api0.swift @@ -5,7 +5,6 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[570911930] = { return $0.readInt64() } dict[571523412] = { return $0.readDouble() } dict[-1255641564] = { return parseString($0) } - dict[-475111160] = { return Api.MessageReactionsList.parse_messageReactionsList($0) } dict[-1240849242] = { return Api.messages.StickerSet.parse_stickerSet($0) } dict[-457104426] = { return Api.InputGeoPoint.parse_inputGeoPointEmpty($0) } dict[-206066487] = { return Api.InputGeoPoint.parse_inputGeoPoint($0) } @@ -96,7 +95,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[483104362] = { return Api.RichText.parse_textPhone($0) } dict[136105807] = { return Api.RichText.parse_textImage($0) } dict[894777186] = { return Api.RichText.parse_textAnchor($0) } - dict[-1684333439] = { return Api.UserFull.parse_userFull($0) } + dict[-302941166] = { return Api.UserFull.parse_userFull($0) } dict[-292807034] = { return Api.InputChannel.parse_inputChannelEmpty($0) } dict[-1343524562] = { return Api.InputChannel.parse_inputChannel($0) } dict[414687501] = { return Api.DcOption.parse_dcOption($0) } @@ -167,7 +166,6 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[-1777000467] = { return Api.PrivacyKey.parse_privacyKeyProfilePhoto($0) } dict[-778378131] = { return Api.PrivacyKey.parse_privacyKeyPhoneNumber($0) } dict[1124062251] = { return Api.PrivacyKey.parse_privacyKeyAddedByPhone($0) } - dict[963559926] = { return Api.PrivacyKey.parse_privacyKeyWalletAddress($0) } dict[522914557] = { return Api.Update.parse_updateNewMessage($0) } dict[1318109142] = { return Api.Update.parse_updateMessageID($0) } dict[-1576161051] = { return Api.Update.parse_updateDeleteMessages($0) } @@ -242,7 +240,6 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[967122427] = { return Api.Update.parse_updateNewScheduledMessage($0) } dict[-1870238482] = { return Api.Update.parse_updateDeleteScheduledMessages($0) } dict[-2112423005] = { return Api.Update.parse_updateTheme($0) } - dict[357013699] = { return Api.Update.parse_updateMessageReactions($0) } dict[1558266229] = { return Api.PopularContact.parse_popularContact($0) } dict[-373643672] = { return Api.FolderPeer.parse_folderPeer($0) } dict[367766557] = { return Api.ChannelParticipant.parse_channelParticipant($0) } @@ -284,7 +281,6 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[1012306921] = { return Api.InputTheme.parse_inputTheme($0) } dict[-175567375] = { return Api.InputTheme.parse_inputThemeSlug($0) } dict[1158290442] = { return Api.messages.FoundGifs.parse_foundGifs($0) } - dict[-1199954735] = { return Api.MessageReactions.parse_messageReactions($0) } dict[-1132476723] = { return Api.FileLocation.parse_fileLocationToBeDeprecated($0) } dict[-716006138] = { return Api.Poll.parse_poll($0) } dict[423314455] = { return Api.InputNotifyPeer.parse_inputNotifyUsers($0) } @@ -452,7 +448,6 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[1461304012] = { return Api.InputPrivacyKey.parse_inputPrivacyKeyProfilePhoto($0) } dict[55761658] = { return Api.InputPrivacyKey.parse_inputPrivacyKeyPhoneNumber($0) } dict[-786326563] = { return Api.InputPrivacyKey.parse_inputPrivacyKeyAddedByPhone($0) } - dict[-640916697] = { return Api.InputPrivacyKey.parse_inputPrivacyKeyWalletAddress($0) } dict[235081943] = { return Api.help.RecentMeUrls.parse_recentMeUrls($0) } dict[-1606526075] = { return Api.ReplyMarkup.parse_replyKeyboardHide($0) } dict[-200242528] = { return Api.ReplyMarkup.parse_replyKeyboardForceReply($0) } @@ -564,7 +559,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[-1820043071] = { return Api.User.parse_user($0) } dict[-2082087340] = { return Api.Message.parse_messageEmpty($0) } dict[-1642487306] = { return Api.Message.parse_messageService($0) } - dict[-1752573244] = { return Api.Message.parse_message($0) } + dict[1160515173] = { return Api.Message.parse_message($0) } dict[186120336] = { return Api.messages.RecentStickers.parse_recentStickersNotModified($0) } dict[586395571] = { return Api.messages.RecentStickers.parse_recentStickers($0) } dict[-182231723] = { return Api.InputFileLocation.parse_inputEncryptedFileLocation($0) } @@ -618,7 +613,6 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[-1625153079] = { return Api.InputWebFileLocation.parse_inputWebFileGeoPointLocation($0) } dict[-332168592] = { return Api.MessageFwdHeader.parse_messageFwdHeader($0) } dict[398898678] = { return Api.help.Support.parse_support($0) } - dict[1873957073] = { return Api.ReactionCount.parse_reactionCount($0) } dict[1474492012] = { return Api.MessagesFilter.parse_inputMessagesFilterEmpty($0) } dict[-1777752804] = { return Api.MessagesFilter.parse_inputMessagesFilterPhotos($0) } dict[-1614803355] = { return Api.MessagesFilter.parse_inputMessagesFilterVideo($0) } @@ -646,7 +640,6 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[-1449145777] = { return Api.upload.CdnFile.parse_cdnFile($0) } dict[1984136919] = { return Api.wallet.LiteResponse.parse_liteResponse($0) } dict[415997816] = { return Api.help.InviteText.parse_inviteText($0) } - dict[-764945220] = { return Api.MessageUserReaction.parse_messageUserReaction($0) } dict[-1937807902] = { return Api.BotInlineMessage.parse_botInlineMessageText($0) } dict[982505656] = { return Api.BotInlineMessage.parse_botInlineMessageMediaGeo($0) } dict[1984755728] = { return Api.BotInlineMessage.parse_botInlineMessageMediaAuto($0) } @@ -846,8 +839,6 @@ public struct Api { public static func serializeObject(_ object: Any, buffer: Buffer, boxed: Swift.Bool) { switch object { - case let _1 as Api.MessageReactionsList: - _1.serialize(buffer, boxed) case let _1 as Api.messages.StickerSet: _1.serialize(buffer, boxed) case let _1 as Api.InputGeoPoint: @@ -980,8 +971,6 @@ public struct Api { _1.serialize(buffer, boxed) case let _1 as Api.messages.FoundGifs: _1.serialize(buffer, boxed) - case let _1 as Api.MessageReactions: - _1.serialize(buffer, boxed) case let _1 as Api.FileLocation: _1.serialize(buffer, boxed) case let _1 as Api.Poll: @@ -1272,8 +1261,6 @@ public struct Api { _1.serialize(buffer, boxed) case let _1 as Api.help.Support: _1.serialize(buffer, boxed) - case let _1 as Api.ReactionCount: - _1.serialize(buffer, boxed) case let _1 as Api.MessagesFilter: _1.serialize(buffer, boxed) case let _1 as Api.messages.Dialogs: @@ -1286,8 +1273,6 @@ public struct Api { _1.serialize(buffer, boxed) case let _1 as Api.help.InviteText: _1.serialize(buffer, boxed) - case let _1 as Api.MessageUserReaction: - _1.serialize(buffer, boxed) case let _1 as Api.BotInlineMessage: _1.serialize(buffer, boxed) case let _1 as Api.InputPeerNotifySettings: diff --git a/submodules/TelegramApi/Sources/Api1.swift b/submodules/TelegramApi/Sources/Api1.swift index 6d32d35cea..c564b24423 100644 --- a/submodules/TelegramApi/Sources/Api1.swift +++ b/submodules/TelegramApi/Sources/Api1.swift @@ -1,66 +1,4 @@ public extension Api { - public enum MessageReactionsList: TypeConstructorDescription { - case messageReactionsList(flags: Int32, count: Int32, reactions: [Api.MessageUserReaction], users: [Api.User], nextOffset: String?) - - public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { - switch self { - case .messageReactionsList(let flags, let count, let reactions, let users, let nextOffset): - if boxed { - buffer.appendInt32(-475111160) - } - serializeInt32(flags, buffer: buffer, boxed: false) - serializeInt32(count, buffer: buffer, boxed: false) - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(reactions.count)) - for item in reactions { - item.serialize(buffer, true) - } - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(users.count)) - for item in users { - item.serialize(buffer, true) - } - if Int(flags) & Int(1 << 0) != 0 {serializeString(nextOffset!, buffer: buffer, boxed: false)} - break - } - } - - public func descriptionFields() -> (String, [(String, Any)]) { - switch self { - case .messageReactionsList(let flags, let count, let reactions, let users, let nextOffset): - return ("messageReactionsList", [("flags", flags), ("count", count), ("reactions", reactions), ("users", users), ("nextOffset", nextOffset)]) - } - } - - public static func parse_messageReactionsList(_ reader: BufferReader) -> MessageReactionsList? { - var _1: Int32? - _1 = reader.readInt32() - var _2: Int32? - _2 = reader.readInt32() - var _3: [Api.MessageUserReaction]? - if let _ = reader.readInt32() { - _3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.MessageUserReaction.self) - } - var _4: [Api.User]? - if let _ = reader.readInt32() { - _4 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self) - } - var _5: String? - if Int(_1!) & Int(1 << 0) != 0 {_5 = parseString(reader) } - let _c1 = _1 != nil - let _c2 = _2 != nil - let _c3 = _3 != nil - let _c4 = _4 != nil - let _c5 = (Int(_1!) & Int(1 << 0) == 0) || _5 != nil - if _c1 && _c2 && _c3 && _c4 && _c5 { - return Api.MessageReactionsList.messageReactionsList(flags: _1!, count: _2!, reactions: _3!, users: _4!, nextOffset: _5) - } - else { - return nil - } - } - - } public enum InputGeoPoint: TypeConstructorDescription { case inputGeoPointEmpty case inputGeoPoint(lat: Double, long: Double) @@ -2650,13 +2588,13 @@ public extension Api { } public enum UserFull: TypeConstructorDescription { - case userFull(flags: Int32, user: Api.User, about: String?, settings: Api.PeerSettings, profilePhoto: Api.Photo?, notifySettings: Api.PeerNotifySettings, botInfo: Api.BotInfo?, pinnedMsgId: Int32?, commonChatsCount: Int32, folderId: Int32?, walletAddress: String?) + case userFull(flags: Int32, user: Api.User, about: String?, settings: Api.PeerSettings, profilePhoto: Api.Photo?, notifySettings: Api.PeerNotifySettings, botInfo: Api.BotInfo?, pinnedMsgId: Int32?, commonChatsCount: Int32, folderId: Int32?) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { - case .userFull(let flags, let user, let about, let settings, let profilePhoto, let notifySettings, let botInfo, let pinnedMsgId, let commonChatsCount, let folderId, let walletAddress): + case .userFull(let flags, let user, let about, let settings, let profilePhoto, let notifySettings, let botInfo, let pinnedMsgId, let commonChatsCount, let folderId): if boxed { - buffer.appendInt32(-1684333439) + buffer.appendInt32(-302941166) } serializeInt32(flags, buffer: buffer, boxed: false) user.serialize(buffer, true) @@ -2668,15 +2606,14 @@ public extension Api { if Int(flags) & Int(1 << 6) != 0 {serializeInt32(pinnedMsgId!, buffer: buffer, boxed: false)} serializeInt32(commonChatsCount, buffer: buffer, boxed: false) if Int(flags) & Int(1 << 11) != 0 {serializeInt32(folderId!, buffer: buffer, boxed: false)} - if Int(flags) & Int(1 << 13) != 0 {serializeString(walletAddress!, buffer: buffer, boxed: false)} break } } public func descriptionFields() -> (String, [(String, Any)]) { switch self { - case .userFull(let flags, let user, let about, let settings, let profilePhoto, let notifySettings, let botInfo, let pinnedMsgId, let commonChatsCount, let folderId, let walletAddress): - return ("userFull", [("flags", flags), ("user", user), ("about", about), ("settings", settings), ("profilePhoto", profilePhoto), ("notifySettings", notifySettings), ("botInfo", botInfo), ("pinnedMsgId", pinnedMsgId), ("commonChatsCount", commonChatsCount), ("folderId", folderId), ("walletAddress", walletAddress)]) + case .userFull(let flags, let user, let about, let settings, let profilePhoto, let notifySettings, let botInfo, let pinnedMsgId, let commonChatsCount, let folderId): + return ("userFull", [("flags", flags), ("user", user), ("about", about), ("settings", settings), ("profilePhoto", profilePhoto), ("notifySettings", notifySettings), ("botInfo", botInfo), ("pinnedMsgId", pinnedMsgId), ("commonChatsCount", commonChatsCount), ("folderId", folderId)]) } } @@ -2711,8 +2648,6 @@ public extension Api { _9 = reader.readInt32() var _10: Int32? if Int(_1!) & Int(1 << 11) != 0 {_10 = reader.readInt32() } - var _11: String? - if Int(_1!) & Int(1 << 13) != 0 {_11 = parseString(reader) } let _c1 = _1 != nil let _c2 = _2 != nil let _c3 = (Int(_1!) & Int(1 << 1) == 0) || _3 != nil @@ -2723,9 +2658,8 @@ public extension Api { let _c8 = (Int(_1!) & Int(1 << 6) == 0) || _8 != nil let _c9 = _9 != nil let _c10 = (Int(_1!) & Int(1 << 11) == 0) || _10 != nil - let _c11 = (Int(_1!) & Int(1 << 13) == 0) || _11 != nil - if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 && _c10 && _c11 { - return Api.UserFull.userFull(flags: _1!, user: _2!, about: _3, settings: _4!, profilePhoto: _5, notifySettings: _6!, botInfo: _7, pinnedMsgId: _8, commonChatsCount: _9!, folderId: _10, walletAddress: _11) + if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 && _c10 { + return Api.UserFull.userFull(flags: _1!, user: _2!, about: _3, settings: _4!, profilePhoto: _5, notifySettings: _6!, botInfo: _7, pinnedMsgId: _8, commonChatsCount: _9!, folderId: _10) } else { return nil @@ -3972,7 +3906,6 @@ public extension Api { case privacyKeyProfilePhoto case privacyKeyPhoneNumber case privacyKeyAddedByPhone - case privacyKeyWalletAddress public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { @@ -4023,12 +3956,6 @@ public extension Api { buffer.appendInt32(1124062251) } - break - case .privacyKeyWalletAddress: - if boxed { - buffer.appendInt32(963559926) - } - break } } @@ -4051,8 +3978,6 @@ public extension Api { return ("privacyKeyPhoneNumber", []) case .privacyKeyAddedByPhone: return ("privacyKeyAddedByPhone", []) - case .privacyKeyWalletAddress: - return ("privacyKeyWalletAddress", []) } } @@ -4080,9 +4005,6 @@ public extension Api { public static func parse_privacyKeyAddedByPhone(_ reader: BufferReader) -> PrivacyKey? { return Api.PrivacyKey.privacyKeyAddedByPhone } - public static func parse_privacyKeyWalletAddress(_ reader: BufferReader) -> PrivacyKey? { - return Api.PrivacyKey.privacyKeyWalletAddress - } } public enum Update: TypeConstructorDescription { @@ -4160,7 +4082,6 @@ public extension Api { case updateNewScheduledMessage(message: Api.Message) case updateDeleteScheduledMessages(peer: Api.Peer, messages: [Int32]) case updateTheme(theme: Api.Theme) - case updateMessageReactions(peer: Api.Peer, msgId: Int32, reactions: Api.MessageReactions) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { @@ -4785,14 +4706,6 @@ public extension Api { } theme.serialize(buffer, true) break - case .updateMessageReactions(let peer, let msgId, let reactions): - if boxed { - buffer.appendInt32(357013699) - } - peer.serialize(buffer, true) - serializeInt32(msgId, buffer: buffer, boxed: false) - reactions.serialize(buffer, true) - break } } @@ -4946,8 +4859,6 @@ public extension Api { return ("updateDeleteScheduledMessages", [("peer", peer), ("messages", messages)]) case .updateTheme(let theme): return ("updateTheme", [("theme", theme)]) - case .updateMessageReactions(let peer, let msgId, let reactions): - return ("updateMessageReactions", [("peer", peer), ("msgId", msgId), ("reactions", reactions)]) } } @@ -6206,27 +6117,6 @@ public extension Api { return nil } } - public static func parse_updateMessageReactions(_ reader: BufferReader) -> Update? { - var _1: Api.Peer? - if let signature = reader.readInt32() { - _1 = Api.parse(reader, signature: signature) as? Api.Peer - } - var _2: Int32? - _2 = reader.readInt32() - var _3: Api.MessageReactions? - if let signature = reader.readInt32() { - _3 = Api.parse(reader, signature: signature) as? Api.MessageReactions - } - let _c1 = _1 != nil - let _c2 = _2 != nil - let _c3 = _3 != nil - if _c1 && _c2 && _c3 { - return Api.Update.updateMessageReactions(peer: _1!, msgId: _2!, reactions: _3!) - } - else { - return nil - } - } } public enum PopularContact: TypeConstructorDescription { @@ -7182,50 +7072,6 @@ public extension Api { } } - } - public enum MessageReactions: TypeConstructorDescription { - case messageReactions(flags: Int32, results: [Api.ReactionCount]) - - public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { - switch self { - case .messageReactions(let flags, let results): - if boxed { - buffer.appendInt32(-1199954735) - } - serializeInt32(flags, buffer: buffer, boxed: false) - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(results.count)) - for item in results { - item.serialize(buffer, true) - } - break - } - } - - public func descriptionFields() -> (String, [(String, Any)]) { - switch self { - case .messageReactions(let flags, let results): - return ("messageReactions", [("flags", flags), ("results", results)]) - } - } - - public static func parse_messageReactions(_ reader: BufferReader) -> MessageReactions? { - var _1: Int32? - _1 = reader.readInt32() - var _2: [Api.ReactionCount]? - if let _ = reader.readInt32() { - _2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.ReactionCount.self) - } - let _c1 = _1 != nil - let _c2 = _2 != nil - if _c1 && _c2 { - return Api.MessageReactions.messageReactions(flags: _1!, results: _2!) - } - else { - return nil - } - } - } public enum FileLocation: TypeConstructorDescription { case fileLocationToBeDeprecated(volumeId: Int64, localId: Int32) @@ -11074,7 +10920,6 @@ public extension Api { case inputPrivacyKeyProfilePhoto case inputPrivacyKeyPhoneNumber case inputPrivacyKeyAddedByPhone - case inputPrivacyKeyWalletAddress public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { @@ -11125,12 +10970,6 @@ public extension Api { buffer.appendInt32(-786326563) } - break - case .inputPrivacyKeyWalletAddress: - if boxed { - buffer.appendInt32(-640916697) - } - break } } @@ -11153,8 +10992,6 @@ public extension Api { return ("inputPrivacyKeyPhoneNumber", []) case .inputPrivacyKeyAddedByPhone: return ("inputPrivacyKeyAddedByPhone", []) - case .inputPrivacyKeyWalletAddress: - return ("inputPrivacyKeyWalletAddress", []) } } @@ -11182,9 +11019,6 @@ public extension Api { public static func parse_inputPrivacyKeyAddedByPhone(_ reader: BufferReader) -> InputPrivacyKey? { return Api.InputPrivacyKey.inputPrivacyKeyAddedByPhone } - public static func parse_inputPrivacyKeyWalletAddress(_ reader: BufferReader) -> InputPrivacyKey? { - return Api.InputPrivacyKey.inputPrivacyKeyWalletAddress - } } public enum ReplyMarkup: TypeConstructorDescription { @@ -14350,7 +14184,7 @@ public extension Api { public enum Message: TypeConstructorDescription { case messageEmpty(id: Int32) case messageService(flags: Int32, id: Int32, fromId: Int32?, toId: Api.Peer, replyToMsgId: Int32?, date: Int32, action: Api.MessageAction) - case message(flags: Int32, id: Int32, fromId: Int32?, toId: Api.Peer, fwdFrom: Api.MessageFwdHeader?, viaBotId: Int32?, replyToMsgId: Int32?, date: Int32, message: String, media: Api.MessageMedia?, replyMarkup: Api.ReplyMarkup?, entities: [Api.MessageEntity]?, views: Int32?, editDate: Int32?, postAuthor: String?, groupedId: Int64?, reactions: Api.MessageReactions?, restrictionReason: [Api.RestrictionReason]?) + case message(flags: Int32, id: Int32, fromId: Int32?, toId: Api.Peer, fwdFrom: Api.MessageFwdHeader?, viaBotId: Int32?, replyToMsgId: Int32?, date: Int32, message: String, media: Api.MessageMedia?, replyMarkup: Api.ReplyMarkup?, entities: [Api.MessageEntity]?, views: Int32?, editDate: Int32?, postAuthor: String?, groupedId: Int64?, restrictionReason: [Api.RestrictionReason]?) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { @@ -14372,9 +14206,9 @@ public extension Api { serializeInt32(date, buffer: buffer, boxed: false) action.serialize(buffer, true) break - case .message(let flags, let id, let fromId, let toId, let fwdFrom, let viaBotId, let replyToMsgId, let date, let message, let media, let replyMarkup, let entities, let views, let editDate, let postAuthor, let groupedId, let reactions, let restrictionReason): + case .message(let flags, let id, let fromId, let toId, let fwdFrom, let viaBotId, let replyToMsgId, let date, let message, let media, let replyMarkup, let entities, let views, let editDate, let postAuthor, let groupedId, let restrictionReason): if boxed { - buffer.appendInt32(-1752573244) + buffer.appendInt32(1160515173) } serializeInt32(flags, buffer: buffer, boxed: false) serializeInt32(id, buffer: buffer, boxed: false) @@ -14396,7 +14230,6 @@ public extension Api { if Int(flags) & Int(1 << 15) != 0 {serializeInt32(editDate!, buffer: buffer, boxed: false)} if Int(flags) & Int(1 << 16) != 0 {serializeString(postAuthor!, buffer: buffer, boxed: false)} if Int(flags) & Int(1 << 17) != 0 {serializeInt64(groupedId!, buffer: buffer, boxed: false)} - if Int(flags) & Int(1 << 20) != 0 {reactions!.serialize(buffer, true)} if Int(flags) & Int(1 << 22) != 0 {buffer.appendInt32(481674261) buffer.appendInt32(Int32(restrictionReason!.count)) for item in restrictionReason! { @@ -14412,8 +14245,8 @@ public extension Api { return ("messageEmpty", [("id", id)]) case .messageService(let flags, let id, let fromId, let toId, let replyToMsgId, let date, let action): return ("messageService", [("flags", flags), ("id", id), ("fromId", fromId), ("toId", toId), ("replyToMsgId", replyToMsgId), ("date", date), ("action", action)]) - case .message(let flags, let id, let fromId, let toId, let fwdFrom, let viaBotId, let replyToMsgId, let date, let message, let media, let replyMarkup, let entities, let views, let editDate, let postAuthor, let groupedId, let reactions, let restrictionReason): - return ("message", [("flags", flags), ("id", id), ("fromId", fromId), ("toId", toId), ("fwdFrom", fwdFrom), ("viaBotId", viaBotId), ("replyToMsgId", replyToMsgId), ("date", date), ("message", message), ("media", media), ("replyMarkup", replyMarkup), ("entities", entities), ("views", views), ("editDate", editDate), ("postAuthor", postAuthor), ("groupedId", groupedId), ("reactions", reactions), ("restrictionReason", restrictionReason)]) + case .message(let flags, let id, let fromId, let toId, let fwdFrom, let viaBotId, let replyToMsgId, let date, let message, let media, let replyMarkup, let entities, let views, let editDate, let postAuthor, let groupedId, let restrictionReason): + return ("message", [("flags", flags), ("id", id), ("fromId", fromId), ("toId", toId), ("fwdFrom", fwdFrom), ("viaBotId", viaBotId), ("replyToMsgId", replyToMsgId), ("date", date), ("message", message), ("media", media), ("replyMarkup", replyMarkup), ("entities", entities), ("views", views), ("editDate", editDate), ("postAuthor", postAuthor), ("groupedId", groupedId), ("restrictionReason", restrictionReason)]) } } @@ -14504,13 +14337,9 @@ public extension Api { if Int(_1!) & Int(1 << 16) != 0 {_15 = parseString(reader) } var _16: Int64? if Int(_1!) & Int(1 << 17) != 0 {_16 = reader.readInt64() } - var _17: Api.MessageReactions? - if Int(_1!) & Int(1 << 20) != 0 {if let signature = reader.readInt32() { - _17 = Api.parse(reader, signature: signature) as? Api.MessageReactions - } } - var _18: [Api.RestrictionReason]? + var _17: [Api.RestrictionReason]? if Int(_1!) & Int(1 << 22) != 0 {if let _ = reader.readInt32() { - _18 = Api.parseVector(reader, elementSignature: 0, elementType: Api.RestrictionReason.self) + _17 = Api.parseVector(reader, elementSignature: 0, elementType: Api.RestrictionReason.self) } } let _c1 = _1 != nil let _c2 = _2 != nil @@ -14528,10 +14357,9 @@ public extension Api { let _c14 = (Int(_1!) & Int(1 << 15) == 0) || _14 != nil let _c15 = (Int(_1!) & Int(1 << 16) == 0) || _15 != nil let _c16 = (Int(_1!) & Int(1 << 17) == 0) || _16 != nil - let _c17 = (Int(_1!) & Int(1 << 20) == 0) || _17 != nil - let _c18 = (Int(_1!) & Int(1 << 22) == 0) || _18 != nil - if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 && _c10 && _c11 && _c12 && _c13 && _c14 && _c15 && _c16 && _c17 && _c18 { - return Api.Message.message(flags: _1!, id: _2!, fromId: _3, toId: _4!, fwdFrom: _5, viaBotId: _6, replyToMsgId: _7, date: _8!, message: _9!, media: _10, replyMarkup: _11, entities: _12, views: _13, editDate: _14, postAuthor: _15, groupedId: _16, reactions: _17, restrictionReason: _18) + let _c17 = (Int(_1!) & Int(1 << 22) == 0) || _17 != nil + if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 && _c10 && _c11 && _c12 && _c13 && _c14 && _c15 && _c16 && _c17 { + return Api.Message.message(flags: _1!, id: _2!, fromId: _3, toId: _4!, fwdFrom: _5, viaBotId: _6, replyToMsgId: _7, date: _8!, message: _9!, media: _10, replyMarkup: _11, entities: _12, views: _13, editDate: _14, postAuthor: _15, groupedId: _16, restrictionReason: _17) } else { return nil @@ -16024,48 +15852,6 @@ public extension Api { } } - } - public enum ReactionCount: TypeConstructorDescription { - case reactionCount(flags: Int32, reaction: String, count: Int32) - - public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { - switch self { - case .reactionCount(let flags, let reaction, let count): - if boxed { - buffer.appendInt32(1873957073) - } - serializeInt32(flags, buffer: buffer, boxed: false) - serializeString(reaction, buffer: buffer, boxed: false) - serializeInt32(count, buffer: buffer, boxed: false) - break - } - } - - public func descriptionFields() -> (String, [(String, Any)]) { - switch self { - case .reactionCount(let flags, let reaction, let count): - return ("reactionCount", [("flags", flags), ("reaction", reaction), ("count", count)]) - } - } - - public static func parse_reactionCount(_ reader: BufferReader) -> ReactionCount? { - var _1: Int32? - _1 = reader.readInt32() - var _2: String? - _2 = parseString(reader) - var _3: Int32? - _3 = reader.readInt32() - let _c1 = _1 != nil - let _c2 = _2 != nil - let _c3 = _3 != nil - if _c1 && _c2 && _c3 { - return Api.ReactionCount.reactionCount(flags: _1!, reaction: _2!, count: _3!) - } - else { - return nil - } - } - } public enum MessagesFilter: TypeConstructorDescription { case inputMessagesFilterEmpty @@ -16378,44 +16164,6 @@ public extension Api { } } - } - public enum MessageUserReaction: TypeConstructorDescription { - case messageUserReaction(userId: Int32, reaction: String) - - public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { - switch self { - case .messageUserReaction(let userId, let reaction): - if boxed { - buffer.appendInt32(-764945220) - } - serializeInt32(userId, buffer: buffer, boxed: false) - serializeString(reaction, buffer: buffer, boxed: false) - break - } - } - - public func descriptionFields() -> (String, [(String, Any)]) { - switch self { - case .messageUserReaction(let userId, let reaction): - return ("messageUserReaction", [("userId", userId), ("reaction", reaction)]) - } - } - - public static func parse_messageUserReaction(_ reader: BufferReader) -> MessageUserReaction? { - var _1: Int32? - _1 = reader.readInt32() - var _2: String? - _2 = parseString(reader) - let _c1 = _1 != nil - let _c2 = _2 != nil - if _c1 && _c2 { - return Api.MessageUserReaction.messageUserReaction(userId: _1!, reaction: _2!) - } - else { - return nil - } - } - } public enum BotInlineMessage: TypeConstructorDescription { case botInlineMessageText(flags: Int32, message: String, entities: [Api.MessageEntity]?, replyMarkup: Api.ReplyMarkup?) diff --git a/submodules/TelegramApi/Sources/Api3.swift b/submodules/TelegramApi/Sources/Api3.swift index 0b3668e6b5..15affdff86 100644 --- a/submodules/TelegramApi/Sources/Api3.swift +++ b/submodules/TelegramApi/Sources/Api3.swift @@ -3161,61 +3161,6 @@ public extension Api { return result }) } - - public static func sendReaction(flags: Int32, peer: Api.InputPeer, msgId: Int32, reaction: String?) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { - let buffer = Buffer() - buffer.appendInt32(627641572) - serializeInt32(flags, buffer: buffer, boxed: false) - peer.serialize(buffer, true) - serializeInt32(msgId, buffer: buffer, boxed: false) - if Int(flags) & Int(1 << 0) != 0 {serializeString(reaction!, buffer: buffer, boxed: false)} - return (FunctionDescription(name: "messages.sendReaction", parameters: [("flags", flags), ("peer", peer), ("msgId", msgId), ("reaction", reaction)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Updates? in - let reader = BufferReader(buffer) - var result: Api.Updates? - if let signature = reader.readInt32() { - result = Api.parse(reader, signature: signature) as? Api.Updates - } - return result - }) - } - - public static func getMessagesReactions(peer: Api.InputPeer, id: [Int32]) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { - let buffer = Buffer() - buffer.appendInt32(-1950707482) - peer.serialize(buffer, true) - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(id.count)) - for item in id { - serializeInt32(item, buffer: buffer, boxed: false) - } - return (FunctionDescription(name: "messages.getMessagesReactions", parameters: [("peer", peer), ("id", id)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Updates? in - let reader = BufferReader(buffer) - var result: Api.Updates? - if let signature = reader.readInt32() { - result = Api.parse(reader, signature: signature) as? Api.Updates - } - return result - }) - } - - public static func getMessageReactionsList(flags: Int32, peer: Api.InputPeer, id: Int32, reaction: String?, offset: String?, limit: Int32) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { - let buffer = Buffer() - buffer.appendInt32(363935594) - serializeInt32(flags, buffer: buffer, boxed: false) - peer.serialize(buffer, true) - serializeInt32(id, buffer: buffer, boxed: false) - if Int(flags) & Int(1 << 0) != 0 {serializeString(reaction!, buffer: buffer, boxed: false)} - if Int(flags) & Int(1 << 1) != 0 {serializeString(offset!, buffer: buffer, boxed: false)} - serializeInt32(limit, buffer: buffer, boxed: false) - return (FunctionDescription(name: "messages.getMessageReactionsList", parameters: [("flags", flags), ("peer", peer), ("id", id), ("reaction", reaction), ("offset", offset), ("limit", limit)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.MessageReactionsList? in - let reader = BufferReader(buffer) - var result: Api.MessageReactionsList? - if let signature = reader.readInt32() { - result = Api.parse(reader, signature: signature) as? Api.MessageReactionsList - } - return result - }) - } } public struct channels { public static func readHistory(channel: Api.InputChannel, maxId: Int32) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { @@ -5890,20 +5835,6 @@ public extension Api { return result }) } - - public static func setWalletAddress(walletAddress: String) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { - let buffer = Buffer() - buffer.appendInt32(1588431790) - serializeString(walletAddress, buffer: buffer, boxed: false) - return (FunctionDescription(name: "account.setWalletAddress", parameters: [("walletAddress", walletAddress)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Bool? in - let reader = BufferReader(buffer) - var result: Api.Bool? - if let signature = reader.readInt32() { - result = Api.parse(reader, signature: signature) as? Api.Bool - } - return result - }) - } } public struct wallet { public static func sendLiteRequest(body: Buffer) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { diff --git a/submodules/TelegramCore/TelegramCore/ApplyUpdateMessage.swift b/submodules/TelegramCore/TelegramCore/ApplyUpdateMessage.swift index a4f3da726e..2f691fe3e5 100644 --- a/submodules/TelegramCore/TelegramCore/ApplyUpdateMessage.swift +++ b/submodules/TelegramCore/TelegramCore/ApplyUpdateMessage.swift @@ -57,7 +57,7 @@ func applyUpdateMessage(postbox: Postbox, stateManager: AccountStateManager, mes var updatedTimestamp: Int32? if let apiMessage = apiMessage { switch apiMessage { - case let .message(_, _, _, _, _, _, _, date, _, _, _, _, _, _, _, _, _, _): + case let .message(_, _, _, _, _, _, _, date, _, _, _, _, _, _, _, _, _): updatedTimestamp = date case .messageEmpty: break diff --git a/submodules/TelegramCore/TelegramCore/MessageReactionList.swift b/submodules/TelegramCore/TelegramCore/MessageReactionList.swift index bbae3101af..8fb9c00fdd 100644 --- a/submodules/TelegramCore/TelegramCore/MessageReactionList.swift +++ b/submodules/TelegramCore/TelegramCore/MessageReactionList.swift @@ -82,7 +82,7 @@ private final class MessageReactionCategoryContext { self.state.loadingMore = true self.statePromise.set(self.state) - var flags: Int32 = 0 + /*var flags: Int32 = 0 var reaction: String? switch self.category { case .all: @@ -150,7 +150,7 @@ private final class MessageReactionCategoryContext { }) }, error: { _ in - })) + }))*/ } } diff --git a/submodules/TelegramCore/TelegramCore/MessageReactions.swift b/submodules/TelegramCore/TelegramCore/MessageReactions.swift index bb804ff08c..81e41c2c09 100644 --- a/submodules/TelegramCore/TelegramCore/MessageReactions.swift +++ b/submodules/TelegramCore/TelegramCore/MessageReactions.swift @@ -61,7 +61,8 @@ private enum RequestUpdateMessageReactionError { } private func requestUpdateMessageReaction(postbox: Postbox, network: Network, stateManager: AccountStateManager, messageId: MessageId) -> Signal { - return postbox.transaction { transaction -> (Peer, String?)? in + return .complete() + /*return postbox.transaction { transaction -> (Peer, String?)? in guard let peer = transaction.getPeer(messageId.peerId) else { return nil } @@ -117,7 +118,7 @@ private func requestUpdateMessageReaction(postbox: Postbox, network: Network, st |> introduceError(RequestUpdateMessageReactionError.self) |> ignoreValues } - } + }*/ } private final class ManagedApplyPendingMessageReactionsActionsHelper { diff --git a/submodules/TelegramCore/TelegramCore/ReactionsMessageAttribute.swift b/submodules/TelegramCore/TelegramCore/ReactionsMessageAttribute.swift index 92cd9f78cd..ce3ab1104c 100644 --- a/submodules/TelegramCore/TelegramCore/ReactionsMessageAttribute.swift +++ b/submodules/TelegramCore/TelegramCore/ReactionsMessageAttribute.swift @@ -46,7 +46,7 @@ public final class ReactionsMessageAttribute: MessageAttribute { encoder.encodeObjectArray(self.reactions, forKey: "r") } - func withUpdatedResults(_ reactions: Api.MessageReactions) -> ReactionsMessageAttribute { + /*func withUpdatedResults(_ reactions: Api.MessageReactions) -> ReactionsMessageAttribute { switch reactions { case let .messageReactions(flags, results): let min = (flags & (1 << 0)) != 0 @@ -74,7 +74,7 @@ public final class ReactionsMessageAttribute: MessageAttribute { } return ReactionsMessageAttribute(reactions: reactions) } - } + }*/ } public func mergedMessageReactions(attributes: [MessageAttribute]) -> ReactionsMessageAttribute? { @@ -147,7 +147,7 @@ public final class PendingReactionsMessageAttribute: MessageAttribute { } } -extension ReactionsMessageAttribute { +/*extension ReactionsMessageAttribute { convenience init(apiReactions: Api.MessageReactions) { switch apiReactions { case let .messageReactions(_, results): @@ -159,4 +159,4 @@ extension ReactionsMessageAttribute { }) } } -} +}*/ diff --git a/submodules/TelegramCore/TelegramCore/StoreMessage_Telegram.swift b/submodules/TelegramCore/TelegramCore/StoreMessage_Telegram.swift index ce92e2195e..c98c79d0f3 100644 --- a/submodules/TelegramCore/TelegramCore/StoreMessage_Telegram.swift +++ b/submodules/TelegramCore/TelegramCore/StoreMessage_Telegram.swift @@ -111,7 +111,10 @@ public func tagsForStoreMessage(incoming: Bool, attributes: [MessageAttribute], func apiMessagePeerId(_ messsage: Api.Message) -> PeerId? { switch messsage { - case let .message(flags, _, fromId, toId, _, _, _, _, _, _, _, _, _, _, _, _, _, _): + case let .message(message): + let flags = message.flags + let fromId = message.fromId + let toId = message.toId switch toId { case let .peerUser(userId): return PeerId(namespace: Namespaces.Peer.CloudUser, id: (flags & Int32(2)) != 0 ? userId : (fromId ?? userId)) @@ -136,7 +139,7 @@ func apiMessagePeerId(_ messsage: Api.Message) -> PeerId? { func apiMessagePeerIds(_ message: Api.Message) -> [PeerId] { switch message { - case let .message(flags, _, fromId, toId, fwdHeader, viaBotId, _, _, _, media, _, entities, _, _, _, _, _, _): + case let .message(flags, _, fromId, toId, fwdHeader, viaBotId, _, _, _, media, _, entities, _, _, _, _, _): let peerId: PeerId switch toId { case let .peerUser(userId): @@ -240,7 +243,7 @@ func apiMessagePeerIds(_ message: Api.Message) -> [PeerId] { func apiMessageAssociatedMessageIds(_ message: Api.Message) -> [MessageId]? { switch message { - case let .message(flags, _, fromId, toId, _, _, replyToMsgId, _, _, _, _, _, _, _, _, _, _, _): + case let .message(flags, _, fromId, toId, _, _, replyToMsgId, _, _, _, _, _, _, _, _, _, _): if let replyToMsgId = replyToMsgId { let peerId: PeerId switch toId { @@ -382,7 +385,7 @@ func messageTextEntitiesFromApiEntities(_ entities: [Api.MessageEntity]) -> [Mes extension StoreMessage { convenience init?(apiMessage: Api.Message, namespace: MessageId.Namespace = Namespaces.Message.Cloud) { switch apiMessage { - case let .message(flags, id, fromId, toId, fwdFrom, viaBotId, replyToMsgId, date, message, media, replyMarkup, entities, views, editDate, postAuthor, groupingId, reactions, restrictionReason): + case let .message(flags, id, fromId, toId, fwdFrom, viaBotId, replyToMsgId, date, message, media, replyMarkup, entities, views, editDate, postAuthor, groupingId, restrictionReason): let peerId: PeerId var authorId: PeerId? switch toId { @@ -537,9 +540,9 @@ extension StoreMessage { attributes.append(ContentRequiresValidationMessageAttribute()) } - if let reactions = reactions { + /*if let reactions = reactions { attributes.append(ReactionsMessageAttribute(apiReactions: reactions)) - } + }*/ if let restrictionReason = restrictionReason { attributes.append(RestrictedContentMessageAttribute(rules: restrictionReason.map(RestrictionRule.init(apiReason:)))) diff --git a/submodules/TelegramCore/TelegramCore/UpdateMessageService.swift b/submodules/TelegramCore/TelegramCore/UpdateMessageService.swift index b493d4bc81..94d242405b 100644 --- a/submodules/TelegramCore/TelegramCore/UpdateMessageService.swift +++ b/submodules/TelegramCore/TelegramCore/UpdateMessageService.swift @@ -69,7 +69,7 @@ class UpdateMessageService: NSObject, MTMessageService { self.putNext(groups) } case let .updateShortChatMessage(flags, id, fromId, chatId, message, pts, ptsCount, date, fwdFrom, viaBotId, replyToMsgId, entities): - let generatedMessage = Api.Message.message(flags: flags, id: id, fromId: fromId, toId: Api.Peer.peerChat(chatId: chatId), fwdFrom: fwdFrom, viaBotId: viaBotId, replyToMsgId: replyToMsgId, date: date, message: message, media: Api.MessageMedia.messageMediaEmpty, replyMarkup: nil, entities: entities, views: nil, editDate: nil, postAuthor: nil, groupedId: nil, reactions: nil, restrictionReason: nil) + let generatedMessage = Api.Message.message(flags: flags, id: id, fromId: fromId, toId: Api.Peer.peerChat(chatId: chatId), fwdFrom: fwdFrom, viaBotId: viaBotId, replyToMsgId: replyToMsgId, date: date, message: message, media: Api.MessageMedia.messageMediaEmpty, replyMarkup: nil, entities: entities, views: nil, editDate: nil, postAuthor: nil, groupedId: nil, restrictionReason: nil) let update = Api.Update.updateNewMessage(message: generatedMessage, pts: pts, ptsCount: ptsCount) let groups = groupUpdates([update], users: [], chats: [], date: date, seqRange: nil) if groups.count != 0 { @@ -86,7 +86,7 @@ class UpdateMessageService: NSObject, MTMessageService { generatedToId = Api.Peer.peerUser(userId: self.peerId.id) } - let generatedMessage = Api.Message.message(flags: flags, id: id, fromId: generatedFromId, toId: generatedToId, fwdFrom: fwdFrom, viaBotId: viaBotId, replyToMsgId: replyToMsgId, date: date, message: message, media: Api.MessageMedia.messageMediaEmpty, replyMarkup: nil, entities: entities, views: nil, editDate: nil, postAuthor: nil, groupedId: nil, reactions: nil, restrictionReason: nil) + let generatedMessage = Api.Message.message(flags: flags, id: id, fromId: generatedFromId, toId: generatedToId, fwdFrom: fwdFrom, viaBotId: viaBotId, replyToMsgId: replyToMsgId, date: date, message: message, media: Api.MessageMedia.messageMediaEmpty, replyMarkup: nil, entities: entities, views: nil, editDate: nil, postAuthor: nil, groupedId: nil, restrictionReason: nil) let update = Api.Update.updateNewMessage(message: generatedMessage, pts: pts, ptsCount: ptsCount) let groups = groupUpdates([update], users: [], chats: [], date: date, seqRange: nil) if groups.count != 0 { diff --git a/submodules/TelegramCore/TelegramCore/UpdatesApiUtils.swift b/submodules/TelegramCore/TelegramCore/UpdatesApiUtils.swift index 651711a391..2bfba3dcce 100644 --- a/submodules/TelegramCore/TelegramCore/UpdatesApiUtils.swift +++ b/submodules/TelegramCore/TelegramCore/UpdatesApiUtils.swift @@ -100,8 +100,8 @@ extension Api.MessageMedia { extension Api.Message { var rawId: Int32 { switch self { - case let .message(_, id, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _): - return id + case let .message(message): + return message.id case let .messageEmpty(id): return id case let .messageService(_, id, _, _, _, _, _): @@ -111,7 +111,12 @@ extension Api.Message { func id(namespace: MessageId.Namespace = Namespaces.Message.Cloud) -> MessageId? { switch self { - case let .message(flags, id, fromId, toId, _, _, _, _, _, _, _, _, _, _, _, _, _, _): + case let .message(message): + let flags = message.flags + let id = message.id + let fromId = message.fromId + let toId = message.toId + let peerId: PeerId switch toId { case let .peerUser(userId): @@ -146,10 +151,10 @@ extension Api.Message { var timestamp: Int32? { switch self { - case let .message(_, _, _, _, _, _, _, date, _, _, _, _, _, _, _, _, _, _): - return date - case let .messageService(_, _, _, _, _, date, _): - return date + case let .message(message): + return message.date + case let .messageService(messageService): + return messageService.date case .messageEmpty: return nil } @@ -157,8 +162,8 @@ extension Api.Message { var preCachedResources: [(MediaResource, Data)]? { switch self { - case let .message(_, _, _, _, _, _, _, _, _, media, _, _, _, _, _, _, _, _): - return media?.preCachedResources + case let .message(message): + return message.media?.preCachedResources default: return nil } diff --git a/submodules/TelegramCore/TelegramCore/Wallets.swift b/submodules/TelegramCore/TelegramCore/Wallets.swift index 3218b41de7..f06d3308ac 100644 --- a/submodules/TelegramCore/TelegramCore/Wallets.swift +++ b/submodules/TelegramCore/TelegramCore/Wallets.swift @@ -25,12 +25,14 @@ private final class TonInstanceImpl { private let queue: Queue private let basePath: String private let config: String + private let network: Network private var instance: TON? - init(queue: Queue, basePath: String, config: String) { + init(queue: Queue, basePath: String, config: String, network: Network) { self.queue = queue self.basePath = basePath self.config = config + self.network = network } func withInstance(_ f: (TON) -> Void) { @@ -38,7 +40,17 @@ private final class TonInstanceImpl { if let current = self.instance { instance = current } else { - instance = TON(keystoreDirectory: self.basePath + "/ton-keystore", config: self.config) + let network = self.network + instance = TON(keystoreDirectory: self.basePath + "/ton-keystore", config: self.config, performExternalRequest: { request in + let _ = (network.request(Api.functions.wallet.sendLiteRequest(body: Buffer(data: request.data)))).start(next: { result in + switch result { + case let .liteResponse(response): + request.onResult(response.makeData(), nil) + } + }, error: { error in + request.onResult(nil, error.errorDescription) + }) + }) self.instance = instance } f(instance) @@ -49,11 +61,11 @@ public final class TonInstance { private let queue: Queue private let impl: QueueLocalObject - public init(basePath: String, config: String) { + public init(basePath: String, config: String, network: Network) { self.queue = .mainQueue() let queue = self.queue self.impl = QueueLocalObject(queue: queue, generate: { - return TonInstanceImpl(queue: queue, basePath: basePath, config: config) + return TonInstanceImpl(queue: queue, basePath: basePath, config: config, network: network) }) } @@ -557,7 +569,8 @@ private extension WalletTransactionMessage { public final class WalletTransaction: Equatable { public let data: Data - public let previousTransactionId: WalletTransactionId + public let transactionId: WalletTransactionId + public let timestamp: Int64 public let fee: Int64 public let inMessage: WalletTransactionMessage? public let outMessages: [WalletTransactionMessage] @@ -574,9 +587,10 @@ public final class WalletTransaction: Equatable { return value } - init(data: Data, previousTransactionId: WalletTransactionId, fee: Int64, inMessage: WalletTransactionMessage?, outMessages: [WalletTransactionMessage]) { + init(data: Data, transactionId: WalletTransactionId, timestamp: Int64, fee: Int64, inMessage: WalletTransactionMessage?, outMessages: [WalletTransactionMessage]) { self.data = data - self.previousTransactionId = previousTransactionId + self.transactionId = transactionId + self.timestamp = timestamp self.fee = fee self.inMessage = inMessage self.outMessages = outMessages @@ -586,7 +600,10 @@ public final class WalletTransaction: Equatable { if lhs.data != rhs.data { return false } - if lhs.previousTransactionId != rhs.previousTransactionId { + if lhs.transactionId != rhs.transactionId { + return false + } + if lhs.timestamp != rhs.timestamp { return false } if lhs.fee != rhs.fee { @@ -604,7 +621,7 @@ public final class WalletTransaction: Equatable { private extension WalletTransaction { convenience init(tonTransaction: TONTransaction) { - self.init(data: tonTransaction.data, previousTransactionId: WalletTransactionId(tonTransactionId: tonTransaction.previousTransactionId), fee: tonTransaction.fee, inMessage: tonTransaction.inMessage.flatMap(WalletTransactionMessage.init(tonTransactionMessage:)), outMessages: tonTransaction.outMessages.map(WalletTransactionMessage.init(tonTransactionMessage:))) + self.init(data: tonTransaction.data, transactionId: WalletTransactionId(tonTransactionId: tonTransaction.transactionId), timestamp: tonTransaction.timestamp, fee: tonTransaction.fee, inMessage: tonTransaction.inMessage.flatMap(WalletTransactionMessage.init(tonTransactionMessage:)), outMessages: tonTransaction.outMessages.map(WalletTransactionMessage.init(tonTransactionMessage:))) } } diff --git a/submodules/TelegramUI/TelegramUI/AppDelegate.swift b/submodules/TelegramUI/TelegramUI/AppDelegate.swift index ed7d9a9fff..ca189bad2b 100644 --- a/submodules/TelegramUI/TelegramUI/AppDelegate.swift +++ b/submodules/TelegramUI/TelegramUI/AppDelegate.swift @@ -923,7 +923,7 @@ final class SharedApplicationContext { return accountAndSettings.flatMap { account, limitsConfiguration, callListSettings in var tonContext: TonContext? if let path = getAppBundle().path(forResource: "cfg", ofType: "txt"), let data = try? Data(contentsOf: URL(fileURLWithPath: path)), let config = String(data: data, encoding: .utf8) { - tonContext = TonContext(instance: TonInstance(basePath: account.basePath, config: config), keychain: tonKeychain) + tonContext = TonContext(instance: TonInstance(basePath: account.basePath, config: config, network: account.network), keychain: tonKeychain) } let context = AccountContextImpl(sharedContext: sharedApplicationContext.sharedContext, account: account, tonContext: tonContext, limitsConfiguration: limitsConfiguration) return AuthorizedApplicationContext(sharedApplicationContext: sharedApplicationContext, mainWindow: self.mainWindow, watchManagerArguments: watchManagerArgumentsPromise.get(), context: context, accountManager: sharedApplicationContext.sharedContext.accountManager, showCallsTab: callListSettings.showTab, reinitializedNotificationSettings: { diff --git a/submodules/WalletUI/BUCK b/submodules/WalletUI/BUCK index 50f1f0f3ef..966110be52 100644 --- a/submodules/WalletUI/BUCK +++ b/submodules/WalletUI/BUCK @@ -20,6 +20,7 @@ static_library( "//submodules/AlertUI:AlertUI", "//submodules/MergeLists:MergeLists", "//submodules/ItemListUI:ItemListUI", + "//submodules/TelegramStringFormatting:TelegramStringFormatting", ], frameworks = [ "$SDKROOT/System/Library/Frameworks/Foundation.framework", diff --git a/submodules/WalletUI/Sources/WalletInfoScreen.swift b/submodules/WalletUI/Sources/WalletInfoScreen.swift index 42427ac5ca..4536e3758f 100644 --- a/submodules/WalletUI/Sources/WalletInfoScreen.swift +++ b/submodules/WalletUI/Sources/WalletInfoScreen.swift @@ -280,16 +280,16 @@ private struct WalletInfoListEntry: Equatable, Comparable, Identifiable { let item: WalletTransaction var stableId: WalletTransactionId { - return self.item.previousTransactionId + return self.item.transactionId } static func <(lhs: WalletInfoListEntry, rhs: WalletInfoListEntry) -> Bool { return lhs.index < rhs.index } - func item(theme: PresentationTheme, action: @escaping (WalletTransaction) -> Void) -> ListViewItem { + func item(theme: PresentationTheme, strings: PresentationStrings, action: @escaping (WalletTransaction) -> Void) -> ListViewItem { let item = self.item - return WalletInfoTransactionItem(theme: theme, walletTransaction: self.item, action: { + return WalletInfoTransactionItem(theme: theme, strings: strings, walletTransaction: self.item, action: { action(item) }) } @@ -299,8 +299,8 @@ private func preparedTransition(from fromEntries: [WalletInfoListEntry], to toEn let (deleteIndices, indicesAndItems, updateIndices) = mergeListsStableWithUpdates(leftList: fromEntries, rightList: toEntries) let deletions = deleteIndices.map { ListViewDeleteItem(index: $0, directionHint: nil) } - let insertions = indicesAndItems.map { ListViewInsertItem(index: $0.0, previousIndex: $0.2, item: $0.1.item(theme: presentationData.theme, action: action), directionHint: nil) } - let updates = updateIndices.map { ListViewUpdateItem(index: $0.0, previousIndex: $0.2, item: $0.1.item(theme: presentationData.theme, action: action), directionHint: nil) } + let insertions = indicesAndItems.map { ListViewInsertItem(index: $0.0, previousIndex: $0.2, item: $0.1.item(theme: presentationData.theme, strings: presentationData.strings, action: action), directionHint: nil) } + let updates = updateIndices.map { ListViewUpdateItem(index: $0.0, previousIndex: $0.2, item: $0.1.item(theme: presentationData.theme, strings: presentationData.strings, action: action), directionHint: nil) } return WalletInfoListTransaction(deletions: deletions, insertions: insertions, updates: updates) } @@ -460,7 +460,7 @@ private final class WalletInfoScreenNode: ViewControllerTracingNode { listViewCurve = .Default(duration: duration) } - self.listNode.transaction(deleteIndices: [], insertIndicesAndItems: [], updateIndicesAndItems: [], options: [.Synchronous, .LowLatency], scrollToItem: nil, updateSizeAndInsets: ListViewUpdateSizeAndInsets(size: layout.size, insets: UIEdgeInsets(top: topInset, left: 0.0, bottom: layout.intrinsicInsets.bottom, right: 0.0), scrollIndicatorInsets: UIEdgeInsets(top: topInset + 3.0, left: 0.0, bottom: layout.intrinsicInsets.bottom, right: 0.0), duration: duration, curve: listViewCurve), stationaryItemRange: nil, updateOpaqueState: nil, completion: { _ in }) + self.listNode.transaction(deleteIndices: [], insertIndicesAndItems: [], updateIndicesAndItems: [], options: [.Synchronous, .LowLatency], scrollToItem: nil, updateSizeAndInsets: ListViewUpdateSizeAndInsets(size: layout.size, insets: UIEdgeInsets(top: topInset, left: 0.0, bottom: layout.intrinsicInsets.bottom, right: 0.0), headerInsets: UIEdgeInsets(top: navigationHeight, left: 0.0, bottom: layout.intrinsicInsets.bottom, right: 0.0), scrollIndicatorInsets: UIEdgeInsets(top: topInset + 3.0, left: 0.0, bottom: layout.intrinsicInsets.bottom, right: 0.0), duration: duration, curve: listViewCurve), stationaryItemRange: nil, updateOpaqueState: nil, completion: { _ in }) let emptyNodeHeight = self.emptyNode.updateLayout(width: layout.size.width, transition: transition) let maxEmptyNodeHeight: CGFloat = max(100.0, layout.size.height - headerHeight) @@ -496,7 +496,7 @@ private final class WalletInfoScreenNode: ViewControllerTracingNode { return } self.loadingMoreTransactions = true - self.transactionListDisposable.set((getWalletTransactions(address: self.address, previousId: self.currentEntries?.last?.item.previousTransactionId, tonInstance: self.tonContext.instance) + self.transactionListDisposable.set((getWalletTransactions(address: self.address, previousId: self.currentEntries?.last?.item.transactionId, tonInstance: self.tonContext.instance) |> deliverOnMainQueue).start(next: { [weak self] transactions in guard let strongSelf = self else { return @@ -522,10 +522,10 @@ private final class WalletInfoScreenNode: ViewControllerTracingNode { } } else { updatedEntries = self.currentEntries ?? [] - var existingIds = Set(updatedEntries.map { $0.item.previousTransactionId }) + var existingIds = Set(updatedEntries.map { $0.item.transactionId }) for transaction in transactions { - if !existingIds.contains(transaction.previousTransactionId) { - existingIds.insert(transaction.previousTransactionId) + if !existingIds.contains(transaction.transactionId) { + existingIds.insert(transaction.transactionId) updatedEntries.append(WalletInfoListEntry(index: updatedEntries.count, item: transaction)) } } @@ -575,7 +575,7 @@ private final class WalletInfoScreenNode: ViewControllerTracingNode { } func formatBalanceText(_ value: Int64) -> String { - var balanceText = "\(value)" + var balanceText = "\(abs(value))" while balanceText.count < 10 { balanceText.insert("0", at: balanceText.startIndex) } @@ -591,5 +591,8 @@ func formatBalanceText(_ value: Int64) -> String { break } } + if value < 0 { + balanceText.insert("-", at: balanceText.startIndex) + } return balanceText } diff --git a/submodules/WalletUI/Sources/WalletInfoTransactionItem.swift b/submodules/WalletUI/Sources/WalletInfoTransactionItem.swift index 83abb555c3..c0fd06ba88 100644 --- a/submodules/WalletUI/Sources/WalletInfoTransactionItem.swift +++ b/submodules/WalletUI/Sources/WalletInfoTransactionItem.swift @@ -6,6 +6,7 @@ import SwiftSignalKit import TelegramPresentationData import ItemListUI import TelegramCore +import TelegramStringFormatting private let transactionIcon = UIImage(bundleImageName: "Wallet/TransactionGem")?.precomposed() @@ -14,16 +15,32 @@ class WalletInfoTransactionItem: ListViewItem { let walletTransaction: WalletTransaction let action: () -> Void - init(theme: PresentationTheme, walletTransaction: WalletTransaction, action: @escaping () -> Void) { + fileprivate let header: WalletInfoTransactionDateHeader? + + init(theme: PresentationTheme, strings: PresentationStrings, walletTransaction: WalletTransaction, action: @escaping () -> Void) { self.theme = theme self.walletTransaction = walletTransaction self.action = action + self.header = WalletInfoTransactionDateHeader(timestamp: Int32(clamping: walletTransaction.timestamp), theme: theme, strings: strings) + } + + func getDateAtBottom(top: ListViewItem?, bottom: ListViewItem?) -> Bool { + var dateAtBottom = false + if let top = top as? WalletInfoTransactionItem, top.header != nil { + if top.header?.id != self.header?.id { + dateAtBottom = true + } + } else { + dateAtBottom = true + } + + return dateAtBottom } func nodeConfiguredForParams(async: @escaping (@escaping () -> Void) -> Void, params: ListViewItemLayoutParams, synchronousLoads: Bool, previousItem: ListViewItem?, nextItem: ListViewItem?, completion: @escaping (ListViewItemNode, @escaping () -> (Signal?, (ListViewItemApply) -> Void)) -> Void) { async { let node = WalletInfoTransactionItemNode() - let (layout, apply) = node.asyncLayout()(self, params, previousItem != nil, nextItem != nil) + let (layout, apply) = node.asyncLayout()(self, params, previousItem != nil, nextItem != nil, self.getDateAtBottom(top: previousItem, bottom: nextItem)) node.contentSize = layout.contentSize node.insets = layout.insets @@ -42,7 +59,7 @@ class WalletInfoTransactionItem: ListViewItem { let makeLayout = nodeValue.asyncLayout() async { - let (layout, apply) = makeLayout(self, params, previousItem != nil, nextItem != nil) + let (layout, apply) = makeLayout(self, params, previousItem != nil, nextItem != nil, self.getDateAtBottom(top: previousItem, bottom: nextItem)) Queue.mainQueue().async { completion(layout, { _ in apply() @@ -131,7 +148,7 @@ class WalletInfoTransactionItemNode: ListViewItemNode { self.addSubnode(self.activateArea) } - func asyncLayout() -> (_ item: WalletInfoTransactionItem, _ params: ListViewItemLayoutParams, _ hasPrevious: Bool, _ hasNext: Bool) -> (ListViewItemNodeLayout, () -> Void) { + func asyncLayout() -> (_ item: WalletInfoTransactionItem, _ params: ListViewItemLayoutParams, _ hasPrevious: Bool, _ hasNext: Bool, _ dateAtBottom: Bool) -> (ListViewItemNodeLayout, () -> Void) { let makeTitleLayout = TextNode.asyncLayout(self.titleNode) let makeDirectionLayout = TextNode.asyncLayout(self.directionNode) let makeTextLayout = TextNode.asyncLayout(self.textNode) @@ -139,7 +156,7 @@ class WalletInfoTransactionItemNode: ListViewItemNode { let currentItem = self.item - return { item, params, hasPrevious, hasNext in + return { item, params, hasPrevious, hasNext, dateHeaderAtBottom in var updatedTheme: PresentationTheme? if currentItem?.theme !== item.theme { @@ -180,7 +197,8 @@ class WalletInfoTransactionItemNode: ListViewItemNode { text = "" } } - let dateText = " " + + let dateText = stringForMessageTimestamp(timestamp: Int32(clamping: item.walletTransaction.timestamp), dateTimeFormat: PresentationDateTimeFormat(timeFormat: PresentationTimeFormat.military, dateFormat: .dayFirst, dateSeparator: ".", decimalSeparator: ".", groupingSeparator: ",")) let (dateLayout, dateApply) = makeDateLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: dateText, font: dateFont, textColor: item.theme.list.itemSecondaryTextColor), backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: params.width - leftInset - leftInset - 20.0, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets())) @@ -191,7 +209,7 @@ class WalletInfoTransactionItemNode: ListViewItemNode { let (textLayout, textApply) = makeTextLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: text, font: textFont, textColor: item.theme.list.itemPrimaryTextColor), backgroundColor: nil, maximumNumberOfLines: 0, truncationType: .end, constrainedSize: CGSize(width: params.width - leftInset - leftInset, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets())) let contentSize: CGSize - let insets: UIEdgeInsets + var insets: UIEdgeInsets let separatorHeight = UIScreenPixel let itemBackgroundColor: UIColor @@ -206,6 +224,11 @@ class WalletInfoTransactionItemNode: ListViewItemNode { contentSize = CGSize(width: params.width, height: topInset + titleLayout.size.height + titleSpacing + textLayout.size.height + bottomInset) insets = UIEdgeInsets(top: 0.0, left: 0.0, bottom: 0.0, right: 0.0) + var topHighlightInset: CGFloat = 0.0 + if dateHeaderAtBottom, let header = item.header { + insets.top += header.height - 4.0 + topHighlightInset = 4.0 + } let layout = ListViewItemNodeLayout(contentSize: contentSize, insets: insets) @@ -252,7 +275,7 @@ class WalletInfoTransactionItemNode: ListViewItemNode { strongSelf.textNode.frame = CGRect(origin: CGPoint(x: leftInset, y: titleFrame.maxY + titleSpacing), size: textLayout.size) strongSelf.dateNode.frame = CGRect(origin: CGPoint(x: params.width - leftInset - dateLayout.size.width, y: topInset), size: dateLayout.size) - strongSelf.highlightedBackgroundNode.frame = CGRect(origin: CGPoint(x: 0.0, y: -UIScreenPixel), size: CGSize(width: params.width, height: layout.contentSize.height + UIScreenPixel * 2.0)) + strongSelf.highlightedBackgroundNode.frame = CGRect(origin: CGPoint(x: 0.0, y: topHighlightInset + -UIScreenPixel), size: CGSize(width: params.width, height: layout.contentSize.height + UIScreenPixel * 2.0 - topHighlightInset)) } }) } @@ -303,4 +326,101 @@ class WalletInfoTransactionItemNode: ListViewItemNode { override func animateRemoved(_ currentTimestamp: Double, duration: Double) { self.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.15, removeOnCompletion: false) } + + override func header() -> ListViewItemHeader? { + return self.item?.header + } +} + +private let timezoneOffset: Int32 = { + let nowTimestamp = Int32(CFAbsoluteTimeGetCurrent() + NSTimeIntervalSince1970) + var now: time_t = time_t(nowTimestamp) + var timeinfoNow: tm = tm() + localtime_r(&now, &timeinfoNow) + return Int32(timeinfoNow.tm_gmtoff) +}() + +private final class WalletInfoTransactionDateHeader: ListViewItemHeader { + private let timestamp: Int32 + private let roundedTimestamp: Int32 + private let month: Int32 + private let year: Int32 + + let id: Int64 + let theme: PresentationTheme + let strings: PresentationStrings + + init(timestamp: Int32, theme: PresentationTheme, strings: PresentationStrings) { + self.timestamp = timestamp + self.theme = theme + self.strings = strings + + var time: time_t = time_t(timestamp + timezoneOffset) + var timeinfo: tm = tm() + localtime_r(&time, &timeinfo) + + self.roundedTimestamp = timeinfo.tm_year * 100 + timeinfo.tm_mon + self.month = timeinfo.tm_mon + self.year = timeinfo.tm_year + + self.id = Int64(self.roundedTimestamp) + } + + let stickDirection: ListViewItemHeaderStickDirection = .top + + let height: CGFloat = 40.0 + + func node() -> ListViewItemHeaderNode { + return WalletInfoTransactionDateHeaderNode(theme: self.theme, strings: self.strings, roundedTimestamp: self.roundedTimestamp, month: self.month, year: self.year) + } +} + +private let sectionTitleFont = Font.semibold(17.0) + +final class WalletInfoTransactionDateHeaderNode: ListViewItemHeaderNode { + var theme: PresentationTheme + var strings: PresentationStrings + let titleNode: ASTextNode + let backgroundNode: ASDisplayNode + + init(theme: PresentationTheme, strings: PresentationStrings, roundedTimestamp: Int32, month: Int32, year: Int32) { + self.theme = theme + self.strings = strings + + self.backgroundNode = ASDisplayNode() + self.backgroundNode.isLayerBacked = true + self.backgroundNode.backgroundColor = theme.list.plainBackgroundColor.withAlphaComponent(0.9) + + self.titleNode = ASTextNode() + self.titleNode.isUserInteractionEnabled = false + + super.init() + + let dateText = stringForMonth(strings: strings, month: month, ofYear: year) + + self.addSubnode(self.backgroundNode) + self.addSubnode(self.titleNode) + self.titleNode.attributedText = NSAttributedString(string: dateText, font: sectionTitleFont, textColor: theme.list.itemPrimaryTextColor) + self.titleNode.maximumNumberOfLines = 1 + self.titleNode.truncationMode = .byTruncatingTail + } + + func updateThemeAndStrings(theme: PresentationTheme, strings: PresentationStrings) { + self.theme = theme + if let attributedString = self.titleNode.attributedText?.mutableCopy() as? NSMutableAttributedString { + attributedString.addAttribute(NSAttributedString.Key.foregroundColor, value: theme.list.itemPrimaryTextColor, range: NSMakeRange(0, attributedString.length)) + self.titleNode.attributedText = attributedString + } + + self.strings = strings + + self.backgroundNode.backgroundColor = theme.list.plainBackgroundColor.withAlphaComponent(0.9) + self.setNeedsLayout() + } + + override func updateLayout(size: CGSize, leftInset: CGFloat, rightInset: CGFloat) { + let titleSize = self.titleNode.measure(CGSize(width: size.width - leftInset - rightInset - 24.0, height: CGFloat.greatestFiniteMagnitude)) + self.titleNode.frame = CGRect(origin: CGPoint(x: leftInset + 16.0, y: floor((size.height - titleSize.height) / 2.0)), size: titleSize) + self.backgroundNode.frame = CGRect(origin: CGPoint(), size: size) + } } diff --git a/submodules/ton/tonlib-src/crypto/block/check-proof.cpp b/submodules/ton/tonlib-src/crypto/block/check-proof.cpp index e8316f5d67..a856c876ee 100644 --- a/submodules/ton/tonlib-src/crypto/block/check-proof.cpp +++ b/submodules/ton/tonlib-src/crypto/block/check-proof.cpp @@ -258,6 +258,7 @@ td::Result Transaction::validate() { } Info res; res.blkid = blkid; + res.now = trans.now; res.prev_trans_lt = trans.prev_trans_lt; res.prev_trans_hash = trans.prev_trans_hash; res.transaction = root; @@ -281,6 +282,8 @@ td::Result TransactionList::validate() const { Info res; auto current_lt = lt; auto current_hash = hash; + res.lt = lt; + res.hash = hash; for (auto& root : list) { const auto& blkid = blkids[c++]; Transaction transaction; diff --git a/submodules/ton/tonlib-src/crypto/block/check-proof.h b/submodules/ton/tonlib-src/crypto/block/check-proof.h index e9c43a7074..664028155d 100644 --- a/submodules/ton/tonlib-src/crypto/block/check-proof.h +++ b/submodules/ton/tonlib-src/crypto/block/check-proof.h @@ -60,6 +60,7 @@ struct Transaction { struct Info { ton::BlockIdExt blkid; + td::uint32 now; ton::LogicalTime prev_trans_lt; ton::Bits256 prev_trans_hash; td::Ref transaction; @@ -74,21 +75,12 @@ struct TransactionList { td::BufferSlice transactions_boc; struct Info { + ton::LogicalTime lt; + ton::Bits256 hash; std::vector transactions; }; td::Result validate() const; }; -struct BlockChain { - ton::BlockIdExt from; - ton::BlockIdExt to; - td::int32 mode; - td::BufferSlice proof; - - using Info = std::unique_ptr; - - td::Result validate() const; -}; - } // namespace block diff --git a/submodules/ton/tonlib-src/crypto/openssl/bignum.cpp b/submodules/ton/tonlib-src/crypto/openssl/bignum.cpp index a696cb5ac3..275b01bb1d 100644 --- a/submodules/ton/tonlib-src/crypto/openssl/bignum.cpp +++ b/submodules/ton/tonlib-src/crypto/openssl/bignum.cpp @@ -209,7 +209,8 @@ Bignum& Bignum::import_lsb(const unsigned char* buffer, std::size_t size) { size--; } if (!size) { - bn_assert(BN_zero(val)); + // Use BN_set_word, because from 1.1.0 BN_zero may return void + bn_assert(BN_set_word(val, 0)); return *this; } unsigned char tmp_buff[1024]; diff --git a/submodules/ton/tonlib-src/crypto/openssl/bignum.h b/submodules/ton/tonlib-src/crypto/openssl/bignum.h index e9ebd4fa14..40d7d58239 100644 --- a/submodules/ton/tonlib-src/crypto/openssl/bignum.h +++ b/submodules/ton/tonlib-src/crypto/openssl/bignum.h @@ -79,7 +79,7 @@ class Bignum { } Bignum(const bin_string& bs) { val = BN_new(); - set_dec_str(bs.str); + set_raw_bytes(bs.str); } Bignum(const dec_string& ds) { val = BN_new(); diff --git a/submodules/ton/tonlib-src/third-party/wingetopt/CMakeLists.txt b/submodules/ton/tonlib-src/third-party/wingetopt/CMakeLists.txt index 3700633b00..415f5e6627 100644 --- a/submodules/ton/tonlib-src/third-party/wingetopt/CMakeLists.txt +++ b/submodules/ton/tonlib-src/third-party/wingetopt/CMakeLists.txt @@ -3,5 +3,5 @@ cmake_minimum_required(VERSION 2.8) add_definitions(-D_CRT_SECURE_NO_WARNINGS) add_library(wingetopt src/getopt.c src/getopt.h) -target_include_directories(wingetopt PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src) +target_include_directories(wingetopt PUBLIC $) diff --git a/submodules/ton/tonlib-src/tl/generate/auto/tl/ton_api.cpp b/submodules/ton/tonlib-src/tl/generate/auto/tl/ton_api.cpp index 1cbe0e2418..8d4a3f1c23 100644 --- a/submodules/ton/tonlib-src/tl/generate/auto/tl/ton_api.cpp +++ b/submodules/ton/tonlib-src/tl/generate/auto/tl/ton_api.cpp @@ -334,6 +334,10 @@ object_ptr Object::fetch(td::TlParser &p) { return engine_validator_dhtServersStatus::fetch(p); case engine_validator_electionBid::ID: return engine_validator_electionBid::fetch(p); + case engine_validator_fullNodeMaster::ID: + return engine_validator_fullNodeMaster::fetch(p); + case engine_validator_fullNodeSlave::ID: + return engine_validator_fullNodeSlave::fetch(p); case validator_groupMember::ID: return validator_groupMember::fetch(p); case engine_validator_jsonConfig::ID: @@ -650,6 +654,10 @@ object_ptr Function::fetch(td::TlParser &p) { return tonNode_preparePersistentState::fetch(p); case tonNode_prepareZeroState::ID: return tonNode_prepareZeroState::fetch(p); + case tonNode_query::ID: + return tonNode_query::fetch(p); + case tonNode_slave_sendExtMessage::ID: + return tonNode_slave_sendExtMessage::fetch(p); case validatorSession_downloadCandidate::ID: return validatorSession_downloadCandidate::fetch(p); case validatorSession_ping::ID: @@ -7635,18 +7643,22 @@ engine_validator_config::engine_validator_config() , dht_() , validators_() , fullnode_() + , fullnodeslave_() + , fullnodemasters_() , liteservers_() , control_() , gc_() {} -engine_validator_config::engine_validator_config(std::int32_t out_port_, std::vector> &&addrs_, std::vector> &&adnl_, std::vector> &&dht_, std::vector> &&validators_, td::Bits256 const &fullnode_, std::vector> &&liteservers_, std::vector> &&control_, object_ptr &&gc_) +engine_validator_config::engine_validator_config(std::int32_t out_port_, std::vector> &&addrs_, std::vector> &&adnl_, std::vector> &&dht_, std::vector> &&validators_, td::Bits256 const &fullnode_, object_ptr &&fullnodeslave_, std::vector> &&fullnodemasters_, std::vector> &&liteservers_, std::vector> &&control_, object_ptr &&gc_) : out_port_(out_port_) , addrs_(std::move(addrs_)) , adnl_(std::move(adnl_)) , dht_(std::move(dht_)) , validators_(std::move(validators_)) , fullnode_(fullnode_) + , fullnodeslave_(std::move(fullnodeslave_)) + , fullnodemasters_(std::move(fullnodemasters_)) , liteservers_(std::move(liteservers_)) , control_(std::move(control_)) , gc_(std::move(gc_)) @@ -7666,6 +7678,8 @@ engine_validator_config::engine_validator_config(td::TlParser &p) , dht_(TlFetchVector>::parse(p)) , validators_(TlFetchVector>::parse(p)) , fullnode_(TlFetchInt256::parse(p)) + , fullnodeslave_(TlFetchObject::parse(p)) + , fullnodemasters_(TlFetchVector>::parse(p)) , liteservers_(TlFetchVector>::parse(p)) , control_(TlFetchVector>::parse(p)) , gc_(TlFetchObject::parse(p)) @@ -7680,6 +7694,8 @@ void engine_validator_config::store(td::TlStorerCalcLength &s) const { TlStoreVector::store(dht_, s); TlStoreVector::store(validators_, s); TlStoreBinary::store(fullnode_, s); + TlStoreObject::store(fullnodeslave_, s); + TlStoreVector::store(fullnodemasters_, s); TlStoreVector::store(liteservers_, s); TlStoreVector::store(control_, s); TlStoreObject::store(gc_, s); @@ -7693,6 +7709,8 @@ void engine_validator_config::store(td::TlStorerUnsafe &s) const { TlStoreVector::store(dht_, s); TlStoreVector::store(validators_, s); TlStoreBinary::store(fullnode_, s); + TlStoreObject::store(fullnodeslave_, s); + TlStoreVector::store(fullnodemasters_, s); TlStoreVector::store(liteservers_, s); TlStoreVector::store(control_, s); TlStoreObject::store(gc_, s); @@ -7707,6 +7725,8 @@ void engine_validator_config::store(td::TlStorerToString &s, const char *field_n { const std::vector> &v = dht_; const std::uint32_t multiplicity = static_cast(v.size()); const auto vector_name = "vector[" + td::to_string(multiplicity)+ "]"; s.store_class_begin("dht", vector_name.c_str()); for (std::uint32_t i = 0; i < multiplicity; i++) { if (v[i] == nullptr) { s.store_field("", "null"); } else { v[i]->store(s, ""); } } s.store_class_end(); } { const std::vector> &v = validators_; const std::uint32_t multiplicity = static_cast(v.size()); const auto vector_name = "vector[" + td::to_string(multiplicity)+ "]"; s.store_class_begin("validators", vector_name.c_str()); for (std::uint32_t i = 0; i < multiplicity; i++) { if (v[i] == nullptr) { s.store_field("", "null"); } else { v[i]->store(s, ""); } } s.store_class_end(); } s.store_field("fullnode", fullnode_); + if (fullnodeslave_ == nullptr) { s.store_field("fullnodeslave", "null"); } else { fullnodeslave_->store(s, "fullnodeslave"); } + { const std::vector> &v = fullnodemasters_; const std::uint32_t multiplicity = static_cast(v.size()); const auto vector_name = "vector[" + td::to_string(multiplicity)+ "]"; s.store_class_begin("fullnodemasters", vector_name.c_str()); for (std::uint32_t i = 0; i < multiplicity; i++) { if (v[i] == nullptr) { s.store_field("", "null"); } else { v[i]->store(s, ""); } } s.store_class_end(); } { const std::vector> &v = liteservers_; const std::uint32_t multiplicity = static_cast(v.size()); const auto vector_name = "vector[" + td::to_string(multiplicity)+ "]"; s.store_class_begin("liteservers", vector_name.c_str()); for (std::uint32_t i = 0; i < multiplicity; i++) { if (v[i] == nullptr) { s.store_field("", "null"); } else { v[i]->store(s, ""); } } s.store_class_end(); } { const std::vector> &v = control_; const std::uint32_t multiplicity = static_cast(v.size()); const auto vector_name = "vector[" + td::to_string(multiplicity)+ "]"; s.store_class_begin("control", vector_name.c_str()); for (std::uint32_t i = 0; i < multiplicity; i++) { if (v[i] == nullptr) { s.store_field("", "null"); } else { v[i]->store(s, ""); } } s.store_class_end(); } if (gc_ == nullptr) { s.store_field("gc", "null"); } else { gc_->store(s, "gc"); } @@ -7896,6 +7916,100 @@ void engine_validator_electionBid::store(td::TlStorerToString &s, const char *fi } } +engine_validator_fullNodeMaster::engine_validator_fullNodeMaster() + : port_() + , adnl_() +{} + +engine_validator_fullNodeMaster::engine_validator_fullNodeMaster(std::int32_t port_, td::Bits256 const &adnl_) + : port_(port_) + , adnl_(adnl_) +{} + +const std::int32_t engine_validator_fullNodeMaster::ID; + +object_ptr engine_validator_fullNodeMaster::fetch(td::TlParser &p) { + return make_object(p); +} + +engine_validator_fullNodeMaster::engine_validator_fullNodeMaster(td::TlParser &p) +#define FAIL(error) p.set_error(error) + : port_(TlFetchInt::parse(p)) + , adnl_(TlFetchInt256::parse(p)) +#undef FAIL +{} + +void engine_validator_fullNodeMaster::store(td::TlStorerCalcLength &s) const { + (void)sizeof(s); + TlStoreBinary::store(port_, s); + TlStoreBinary::store(adnl_, s); +} + +void engine_validator_fullNodeMaster::store(td::TlStorerUnsafe &s) const { + (void)sizeof(s); + TlStoreBinary::store(port_, s); + TlStoreBinary::store(adnl_, s); +} + +void engine_validator_fullNodeMaster::store(td::TlStorerToString &s, const char *field_name) const { + if (!LOG_IS_STRIPPED(ERROR)) { + s.store_class_begin(field_name, "engine_validator_fullNodeMaster"); + s.store_field("port", port_); + s.store_field("adnl", adnl_); + s.store_class_end(); + } +} + +engine_validator_fullNodeSlave::engine_validator_fullNodeSlave() + : ip_() + , port_() + , adnl_() +{} + +engine_validator_fullNodeSlave::engine_validator_fullNodeSlave(std::int32_t ip_, std::int32_t port_, object_ptr &&adnl_) + : ip_(ip_) + , port_(port_) + , adnl_(std::move(adnl_)) +{} + +const std::int32_t engine_validator_fullNodeSlave::ID; + +object_ptr engine_validator_fullNodeSlave::fetch(td::TlParser &p) { + return make_object(p); +} + +engine_validator_fullNodeSlave::engine_validator_fullNodeSlave(td::TlParser &p) +#define FAIL(error) p.set_error(error) + : ip_(TlFetchInt::parse(p)) + , port_(TlFetchInt::parse(p)) + , adnl_(TlFetchObject::parse(p)) +#undef FAIL +{} + +void engine_validator_fullNodeSlave::store(td::TlStorerCalcLength &s) const { + (void)sizeof(s); + TlStoreBinary::store(ip_, s); + TlStoreBinary::store(port_, s); + TlStoreBoxedUnknown::store(adnl_, s); +} + +void engine_validator_fullNodeSlave::store(td::TlStorerUnsafe &s) const { + (void)sizeof(s); + TlStoreBinary::store(ip_, s); + TlStoreBinary::store(port_, s); + TlStoreBoxedUnknown::store(adnl_, s); +} + +void engine_validator_fullNodeSlave::store(td::TlStorerToString &s, const char *field_name) const { + if (!LOG_IS_STRIPPED(ERROR)) { + s.store_class_begin(field_name, "engine_validator_fullNodeSlave"); + s.store_field("ip", ip_); + s.store_field("port", port_); + if (adnl_ == nullptr) { s.store_field("adnl", "null"); } else { adnl_->store(s, "adnl"); } + s.store_class_end(); + } +} + validator_groupMember::validator_groupMember() : public_key_hash_() , adnl_() @@ -15371,6 +15485,91 @@ tonNode_prepareZeroState::ReturnType tonNode_prepareZeroState::fetch_result(td:: #undef FAIL } +tonNode_query::tonNode_query() { +} + +const std::int32_t tonNode_query::ID; + +object_ptr tonNode_query::fetch(td::TlParser &p) { + return make_object(p); +} + +tonNode_query::tonNode_query(td::TlParser &p) +#define FAIL(error) p.set_error(error) +#undef FAIL +{ + (void)p; +} + +void tonNode_query::store(td::TlStorerCalcLength &s) const { + (void)sizeof(s); + s.store_binary(1777542355); +} + +void tonNode_query::store(td::TlStorerUnsafe &s) const { + (void)sizeof(s); + s.store_binary(1777542355); +} + +void tonNode_query::store(td::TlStorerToString &s, const char *field_name) const { + if (!LOG_IS_STRIPPED(ERROR)) { + s.store_class_begin(field_name, "tonNode_query"); + s.store_class_end(); + } +} + +tonNode_query::ReturnType tonNode_query::fetch_result(td::TlParser &p) { +#define FAIL(error) p.set_error(error); return ReturnType() + return TlFetchBoxed, 695225504>::parse(p); +#undef FAIL +} + +tonNode_slave_sendExtMessage::tonNode_slave_sendExtMessage() + : message_() +{} + +tonNode_slave_sendExtMessage::tonNode_slave_sendExtMessage(object_ptr &&message_) + : message_(std::move(message_)) +{} + +const std::int32_t tonNode_slave_sendExtMessage::ID; + +object_ptr tonNode_slave_sendExtMessage::fetch(td::TlParser &p) { + return make_object(p); +} + +tonNode_slave_sendExtMessage::tonNode_slave_sendExtMessage(td::TlParser &p) +#define FAIL(error) p.set_error(error) + : message_(TlFetchObject::parse(p)) +#undef FAIL +{} + +void tonNode_slave_sendExtMessage::store(td::TlStorerCalcLength &s) const { + (void)sizeof(s); + s.store_binary(2067425040); + TlStoreObject::store(message_, s); +} + +void tonNode_slave_sendExtMessage::store(td::TlStorerUnsafe &s) const { + (void)sizeof(s); + s.store_binary(2067425040); + TlStoreObject::store(message_, s); +} + +void tonNode_slave_sendExtMessage::store(td::TlStorerToString &s, const char *field_name) const { + if (!LOG_IS_STRIPPED(ERROR)) { + s.store_class_begin(field_name, "tonNode_slave_sendExtMessage"); + if (message_ == nullptr) { s.store_field("message", "null"); } else { message_->store(s, "message"); } + s.store_class_end(); + } +} + +tonNode_slave_sendExtMessage::ReturnType tonNode_slave_sendExtMessage::fetch_result(td::TlParser &p) { +#define FAIL(error) p.set_error(error); return ReturnType() + return TlFetchBoxed::parse(p); +#undef FAIL +} + validatorSession_downloadCandidate::validatorSession_downloadCandidate() : round_() , id_() diff --git a/submodules/ton/tonlib-src/tl/generate/auto/tl/ton_api.h b/submodules/ton/tonlib-src/tl/generate/auto/tl/ton_api.h index bf451210a8..3387d77f77 100644 --- a/submodules/ton/tonlib-src/tl/generate/auto/tl/ton_api.h +++ b/submodules/ton/tonlib-src/tl/generate/auto/tl/ton_api.h @@ -234,6 +234,10 @@ class engine_validator_dhtServersStatus; class engine_validator_electionBid; +class engine_validator_fullNodeMaster; + +class engine_validator_fullNodeSlave; + class validator_groupMember; class engine_validator_jsonConfig; @@ -4210,15 +4214,17 @@ class engine_validator_config final : public Object { std::vector> dht_; std::vector> validators_; td::Bits256 fullnode_; + object_ptr fullnodeslave_; + std::vector> fullnodemasters_; std::vector> liteservers_; std::vector> control_; object_ptr gc_; engine_validator_config(); - engine_validator_config(std::int32_t out_port_, std::vector> &&addrs_, std::vector> &&adnl_, std::vector> &&dht_, std::vector> &&validators_, td::Bits256 const &fullnode_, std::vector> &&liteservers_, std::vector> &&control_, object_ptr &&gc_); + engine_validator_config(std::int32_t out_port_, std::vector> &&addrs_, std::vector> &&adnl_, std::vector> &&dht_, std::vector> &&validators_, td::Bits256 const &fullnode_, object_ptr &&fullnodeslave_, std::vector> &&fullnodemasters_, std::vector> &&liteservers_, std::vector> &&control_, object_ptr &&gc_); - static const std::int32_t ID = -1061804008; + static const std::int32_t ID = 17126390; std::int32_t get_id() const final { return ID; } @@ -4335,6 +4341,57 @@ class engine_validator_electionBid final : public Object { void store(td::TlStorerToString &s, const char *field_name) const final; }; +class engine_validator_fullNodeMaster final : public Object { + public: + std::int32_t port_; + td::Bits256 adnl_; + + engine_validator_fullNodeMaster(); + + engine_validator_fullNodeMaster(std::int32_t port_, td::Bits256 const &adnl_); + + static const std::int32_t ID = -2071595416; + std::int32_t get_id() const final { + return ID; + } + + static object_ptr fetch(td::TlParser &p); + + explicit engine_validator_fullNodeMaster(td::TlParser &p); + + void store(td::TlStorerCalcLength &s) const final; + + void store(td::TlStorerUnsafe &s) const final; + + void store(td::TlStorerToString &s, const char *field_name) const final; +}; + +class engine_validator_fullNodeSlave final : public Object { + public: + std::int32_t ip_; + std::int32_t port_; + object_ptr adnl_; + + engine_validator_fullNodeSlave(); + + engine_validator_fullNodeSlave(std::int32_t ip_, std::int32_t port_, object_ptr &&adnl_); + + static const std::int32_t ID = -2010813575; + std::int32_t get_id() const final { + return ID; + } + + static object_ptr fetch(td::TlParser &p); + + explicit engine_validator_fullNodeSlave(td::TlParser &p); + + void store(td::TlStorerCalcLength &s) const final; + + void store(td::TlStorerUnsafe &s) const final; + + void store(td::TlStorerToString &s, const char *field_name) const final; +}; + class validator_groupMember final : public Object { public: td::Bits256 public_key_hash_; @@ -8459,6 +8516,59 @@ class tonNode_prepareZeroState final : public Function { static ReturnType fetch_result(td::TlParser &p); }; +class tonNode_query final : public Function { + public: + + tonNode_query(); + + static const std::int32_t ID = 1777542355; + std::int32_t get_id() const final { + return ID; + } + + using ReturnType = object_ptr; + + static object_ptr fetch(td::TlParser &p); + + explicit tonNode_query(td::TlParser &p); + + void store(td::TlStorerCalcLength &s) const final; + + void store(td::TlStorerUnsafe &s) const final; + + void store(td::TlStorerToString &s, const char *field_name) const final; + + static ReturnType fetch_result(td::TlParser &p); +}; + +class tonNode_slave_sendExtMessage final : public Function { + public: + object_ptr message_; + + tonNode_slave_sendExtMessage(); + + explicit tonNode_slave_sendExtMessage(object_ptr &&message_); + + static const std::int32_t ID = 2067425040; + std::int32_t get_id() const final { + return ID; + } + + using ReturnType = bool; + + static object_ptr fetch(td::TlParser &p); + + explicit tonNode_slave_sendExtMessage(td::TlParser &p); + + void store(td::TlStorerCalcLength &s) const final; + + void store(td::TlStorerUnsafe &s) const final; + + void store(td::TlStorerToString &s, const char *field_name) const final; + + static ReturnType fetch_result(td::TlParser &p); +}; + class validatorSession_downloadCandidate final : public Function { public: std::int32_t round_; diff --git a/submodules/ton/tonlib-src/tl/generate/auto/tl/ton_api.hpp b/submodules/ton/tonlib-src/tl/generate/auto/tl/ton_api.hpp index 41791fb838..6471596805 100644 --- a/submodules/ton/tonlib-src/tl/generate/auto/tl/ton_api.hpp +++ b/submodules/ton/tonlib-src/tl/generate/auto/tl/ton_api.hpp @@ -479,6 +479,12 @@ bool downcast_call(Object &obj, const T &func) { case engine_validator_electionBid::ID: func(static_cast(obj)); return true; + case engine_validator_fullNodeMaster::ID: + func(static_cast(obj)); + return true; + case engine_validator_fullNodeSlave::ID: + func(static_cast(obj)); + return true; case validator_groupMember::ID: func(static_cast(obj)); return true; @@ -952,6 +958,12 @@ bool downcast_call(Function &obj, const T &func) { case tonNode_prepareZeroState::ID: func(static_cast(obj)); return true; + case tonNode_query::ID: + func(static_cast(obj)); + return true; + case tonNode_slave_sendExtMessage::ID: + func(static_cast(obj)); + return true; case validatorSession_downloadCandidate::ID: func(static_cast(obj)); return true; diff --git a/submodules/ton/tonlib-src/tl/generate/auto/tl/ton_api_json.cpp b/submodules/ton/tonlib-src/tl/generate/auto/tl/ton_api_json.cpp index 1b02d348ce..58e145707d 100644 --- a/submodules/ton/tonlib-src/tl/generate/auto/tl/ton_api_json.cpp +++ b/submodules/ton/tonlib-src/tl/generate/auto/tl/ton_api_json.cpp @@ -625,11 +625,13 @@ Result tl_constructor_from_string(ton_api::Object *object, const std::str {"engine.adnlProxy.config", 1848000769}, {"engine.adnlProxy.port", -117344950}, {"engine.dht.config", -197295930}, - {"engine.validator.config", -1061804008}, + {"engine.validator.config", 17126390}, {"engine.validator.controlQueryError", 1999018527}, {"engine.validator.dhtServerStatus", -1323440290}, {"engine.validator.dhtServersStatus", 725155112}, {"engine.validator.electionBid", 598899261}, + {"engine.validator.fullNodeMaster", -2071595416}, + {"engine.validator.fullNodeSlave", -2010813575}, {"validator.groupMember", -1953208860}, {"engine.validator.jsonConfig", 321753611}, {"engine.validator.keyHash", -1027168946}, @@ -792,6 +794,8 @@ Result tl_constructor_from_string(ton_api::Function *object, const std::s {"tonNode.prepareBlockProof", -2024000760}, {"tonNode.preparePersistentState", -18209122}, {"tonNode.prepareZeroState", 1104021541}, + {"tonNode.query", 1777542355}, + {"tonNode.slave.sendExtMessage", 2067425040}, {"validatorSession.downloadCandidate", -520274443}, {"validatorSession.ping", 1745111469} }; @@ -3094,6 +3098,18 @@ Status from_json(ton_api::engine_validator_config &to, JsonObject &from) { TRY_STATUS(from_json(to.fullnode_, value)); } } + { + TRY_RESULT(value, get_json_object_field(from, "fullnodeslave", JsonValue::Type::Null, true)); + if (value.type() != JsonValue::Type::Null) { + TRY_STATUS(from_json(to.fullnodeslave_, value)); + } + } + { + TRY_RESULT(value, get_json_object_field(from, "fullnodemasters", JsonValue::Type::Null, true)); + if (value.type() != JsonValue::Type::Null) { + TRY_STATUS(from_json(to.fullnodemasters_, value)); + } + } { TRY_RESULT(value, get_json_object_field(from, "liteservers", JsonValue::Type::Null, true)); if (value.type() != JsonValue::Type::Null) { @@ -3180,6 +3196,42 @@ Status from_json(ton_api::engine_validator_electionBid &to, JsonObject &from) { } return Status::OK(); } +Status from_json(ton_api::engine_validator_fullNodeMaster &to, JsonObject &from) { + { + TRY_RESULT(value, get_json_object_field(from, "port", JsonValue::Type::Null, true)); + if (value.type() != JsonValue::Type::Null) { + TRY_STATUS(from_json(to.port_, value)); + } + } + { + TRY_RESULT(value, get_json_object_field(from, "adnl", JsonValue::Type::Null, true)); + if (value.type() != JsonValue::Type::Null) { + TRY_STATUS(from_json(to.adnl_, value)); + } + } + return Status::OK(); +} +Status from_json(ton_api::engine_validator_fullNodeSlave &to, JsonObject &from) { + { + TRY_RESULT(value, get_json_object_field(from, "ip", JsonValue::Type::Null, true)); + if (value.type() != JsonValue::Type::Null) { + TRY_STATUS(from_json(to.ip_, value)); + } + } + { + TRY_RESULT(value, get_json_object_field(from, "port", JsonValue::Type::Null, true)); + if (value.type() != JsonValue::Type::Null) { + TRY_STATUS(from_json(to.port_, value)); + } + } + { + TRY_RESULT(value, get_json_object_field(from, "adnl", JsonValue::Type::Null, true)); + if (value.type() != JsonValue::Type::Null) { + TRY_STATUS(from_json(to.adnl_, value)); + } + } + return Status::OK(); +} Status from_json(ton_api::validator_groupMember &to, JsonObject &from) { { TRY_RESULT(value, get_json_object_field(from, "public_key_hash", JsonValue::Type::Null, true)); @@ -5505,6 +5557,18 @@ Status from_json(ton_api::tonNode_prepareZeroState &to, JsonObject &from) { } return Status::OK(); } +Status from_json(ton_api::tonNode_query &to, JsonObject &from) { + return Status::OK(); +} +Status from_json(ton_api::tonNode_slave_sendExtMessage &to, JsonObject &from) { + { + TRY_RESULT(value, get_json_object_field(from, "message", JsonValue::Type::Null, true)); + if (value.type() != JsonValue::Type::Null) { + TRY_STATUS(from_json(to.message_, value)); + } + } + return Status::OK(); +} Status from_json(ton_api::validatorSession_downloadCandidate &to, JsonObject &from) { { TRY_RESULT(value, get_json_object_field(from, "round", JsonValue::Type::Null, true)); @@ -6647,6 +6711,10 @@ void to_json(JsonValueScope &jv, const ton_api::engine_validator_config &object) jo << ctie("dht", ToJson(object.dht_)); jo << ctie("validators", ToJson(object.validators_)); jo << ctie("fullnode", ToJson(object.fullnode_)); + if (object.fullnodeslave_) { + jo << ctie("fullnodeslave", ToJson(object.fullnodeslave_)); + } + jo << ctie("fullnodemasters", ToJson(object.fullnodemasters_)); jo << ctie("liteservers", ToJson(object.liteservers_)); jo << ctie("control", ToJson(object.control_)); if (object.gc_) { @@ -6678,6 +6746,21 @@ void to_json(JsonValueScope &jv, const ton_api::engine_validator_electionBid &ob jo << ctie("adnl_addr", ToJson(object.adnl_addr_)); jo << ctie("to_send_payload", ToJson(JsonBytes{object.to_send_payload_})); } +void to_json(JsonValueScope &jv, const ton_api::engine_validator_fullNodeMaster &object) { + auto jo = jv.enter_object(); + jo << ctie("@type", "engine.validator.fullNodeMaster"); + jo << ctie("port", ToJson(object.port_)); + jo << ctie("adnl", ToJson(object.adnl_)); +} +void to_json(JsonValueScope &jv, const ton_api::engine_validator_fullNodeSlave &object) { + auto jo = jv.enter_object(); + jo << ctie("@type", "engine.validator.fullNodeSlave"); + jo << ctie("ip", ToJson(object.ip_)); + jo << ctie("port", ToJson(object.port_)); + if (object.adnl_) { + jo << ctie("adnl", ToJson(object.adnl_)); + } +} void to_json(JsonValueScope &jv, const ton_api::validator_groupMember &object) { auto jo = jv.enter_object(); jo << ctie("@type", "validator.groupMember"); @@ -7745,6 +7828,17 @@ void to_json(JsonValueScope &jv, const ton_api::tonNode_prepareZeroState &object jo << ctie("block", ToJson(object.block_)); } } +void to_json(JsonValueScope &jv, const ton_api::tonNode_query &object) { + auto jo = jv.enter_object(); + jo << ctie("@type", "tonNode.query"); +} +void to_json(JsonValueScope &jv, const ton_api::tonNode_slave_sendExtMessage &object) { + auto jo = jv.enter_object(); + jo << ctie("@type", "tonNode.slave.sendExtMessage"); + if (object.message_) { + jo << ctie("message", ToJson(object.message_)); + } +} void to_json(JsonValueScope &jv, const ton_api::validatorSession_downloadCandidate &object) { auto jo = jv.enter_object(); jo << ctie("@type", "validatorSession.downloadCandidate"); diff --git a/submodules/ton/tonlib-src/tl/generate/auto/tl/ton_api_json.h b/submodules/ton/tonlib-src/tl/generate/auto/tl/ton_api_json.h index f26f1ddd0a..a7e2b68ab8 100644 --- a/submodules/ton/tonlib-src/tl/generate/auto/tl/ton_api_json.h +++ b/submodules/ton/tonlib-src/tl/generate/auto/tl/ton_api_json.h @@ -204,6 +204,8 @@ Status from_json(ton_api::engine_validator_controlQueryError &to, JsonObject &fr Status from_json(ton_api::engine_validator_dhtServerStatus &to, JsonObject &from); Status from_json(ton_api::engine_validator_dhtServersStatus &to, JsonObject &from); Status from_json(ton_api::engine_validator_electionBid &to, JsonObject &from); +Status from_json(ton_api::engine_validator_fullNodeMaster &to, JsonObject &from); +Status from_json(ton_api::engine_validator_fullNodeSlave &to, JsonObject &from); Status from_json(ton_api::validator_groupMember &to, JsonObject &from); Status from_json(ton_api::engine_validator_jsonConfig &to, JsonObject &from); Status from_json(ton_api::engine_validator_keyHash &to, JsonObject &from); @@ -357,6 +359,8 @@ Status from_json(ton_api::tonNode_prepareBlock &to, JsonObject &from); Status from_json(ton_api::tonNode_prepareBlockProof &to, JsonObject &from); Status from_json(ton_api::tonNode_preparePersistentState &to, JsonObject &from); Status from_json(ton_api::tonNode_prepareZeroState &to, JsonObject &from); +Status from_json(ton_api::tonNode_query &to, JsonObject &from); +Status from_json(ton_api::tonNode_slave_sendExtMessage &to, JsonObject &from); Status from_json(ton_api::validatorSession_downloadCandidate &to, JsonObject &from); Status from_json(ton_api::validatorSession_ping &to, JsonObject &from); void to_json(JsonValueScope &jv, const ton_api::Hashable &object); @@ -534,6 +538,8 @@ void to_json(JsonValueScope &jv, const ton_api::engine_validator_controlQueryErr void to_json(JsonValueScope &jv, const ton_api::engine_validator_dhtServerStatus &object); void to_json(JsonValueScope &jv, const ton_api::engine_validator_dhtServersStatus &object); void to_json(JsonValueScope &jv, const ton_api::engine_validator_electionBid &object); +void to_json(JsonValueScope &jv, const ton_api::engine_validator_fullNodeMaster &object); +void to_json(JsonValueScope &jv, const ton_api::engine_validator_fullNodeSlave &object); void to_json(JsonValueScope &jv, const ton_api::validator_groupMember &object); void to_json(JsonValueScope &jv, const ton_api::engine_validator_jsonConfig &object); void to_json(JsonValueScope &jv, const ton_api::engine_validator_keyHash &object); @@ -703,6 +709,8 @@ void to_json(JsonValueScope &jv, const ton_api::tonNode_prepareBlock &object); void to_json(JsonValueScope &jv, const ton_api::tonNode_prepareBlockProof &object); void to_json(JsonValueScope &jv, const ton_api::tonNode_preparePersistentState &object); void to_json(JsonValueScope &jv, const ton_api::tonNode_prepareZeroState &object); +void to_json(JsonValueScope &jv, const ton_api::tonNode_query &object); +void to_json(JsonValueScope &jv, const ton_api::tonNode_slave_sendExtMessage &object); void to_json(JsonValueScope &jv, const ton_api::validatorSession_downloadCandidate &object); void to_json(JsonValueScope &jv, const ton_api::validatorSession_ping &object); inline void to_json(JsonValueScope &jv, const ton::ton_api::Object &object) { diff --git a/submodules/ton/tonlib-src/tl/generate/auto/tl/tonlib_api.cpp b/submodules/ton/tonlib-src/tl/generate/auto/tl/tonlib_api.cpp index acd9c81126..8deb110d68 100644 --- a/submodules/ton/tonlib-src/tl/generate/auto/tl/tonlib_api.cpp +++ b/submodules/ton/tonlib-src/tl/generate/auto/tl/tonlib_api.cpp @@ -187,11 +187,13 @@ void ok::store(td::TlStorerToString &s, const char *field_name) const { options::options() : config_() , keystore_directory_() + , use_callbacks_for_network_() {} -options::options(std::string const &config_, std::string const &keystore_directory_) +options::options(std::string const &config_, std::string const &keystore_directory_, bool use_callbacks_for_network_) : config_(std::move(config_)) , keystore_directory_(std::move(keystore_directory_)) + , use_callbacks_for_network_(use_callbacks_for_network_) {} const std::int32_t options::ID; @@ -201,6 +203,28 @@ void options::store(td::TlStorerToString &s, const char *field_name) const { s.store_class_begin(field_name, "options"); s.store_field("config", config_); s.store_field("keystore_directory", keystore_directory_); + s.store_field("use_callbacks_for_network", use_callbacks_for_network_); + s.store_class_end(); + } +} + +updateSendLiteServerQuery::updateSendLiteServerQuery() + : id_() + , data_() +{} + +updateSendLiteServerQuery::updateSendLiteServerQuery(std::int64_t id_, std::string const &data_) + : id_(id_) + , data_(std::move(data_)) +{} + +const std::int32_t updateSendLiteServerQuery::ID; + +void updateSendLiteServerQuery::store(td::TlStorerToString &s, const char *field_name) const { + if (!LOG_IS_STRIPPED(ERROR)) { + s.store_class_begin(field_name, "updateSendLiteServerQuery"); + s.store_field("id", id_); + s.store_bytes_field("data", data_); s.store_class_end(); } } @@ -339,13 +363,15 @@ raw_accountState::raw_accountState() , code_() , data_() , last_transaction_id_() + , sync_utime_() {} -raw_accountState::raw_accountState(std::int64_t balance_, std::string const &code_, std::string const &data_, object_ptr &&last_transaction_id_) +raw_accountState::raw_accountState(std::int64_t balance_, std::string const &code_, std::string const &data_, object_ptr &&last_transaction_id_, std::int64_t sync_utime_) : balance_(balance_) , code_(std::move(code_)) , data_(std::move(data_)) , last_transaction_id_(std::move(last_transaction_id_)) + , sync_utime_(sync_utime_) {} const std::int32_t raw_accountState::ID; @@ -357,6 +383,7 @@ void raw_accountState::store(td::TlStorerToString &s, const char *field_name) co s.store_bytes_field("code", code_); s.store_bytes_field("data", data_); if (last_transaction_id_ == nullptr) { s.store_field("last_transaction_id", "null"); } else { last_transaction_id_->store(s, "last_transaction_id"); } + s.store_field("sync_utime", sync_utime_); s.store_class_end(); } } @@ -407,16 +434,18 @@ void raw_message::store(td::TlStorerToString &s, const char *field_name) const { } raw_transaction::raw_transaction() - : data_() - , previous_transaction_id_() + : utime_() + , data_() + , transaction_id_() , fee_() , in_msg_() , out_msgs_() {} -raw_transaction::raw_transaction(std::string const &data_, object_ptr &&previous_transaction_id_, std::int64_t fee_, object_ptr &&in_msg_, std::vector> &&out_msgs_) - : data_(std::move(data_)) - , previous_transaction_id_(std::move(previous_transaction_id_)) +raw_transaction::raw_transaction(std::int64_t utime_, std::string const &data_, object_ptr &&transaction_id_, std::int64_t fee_, object_ptr &&in_msg_, std::vector> &&out_msgs_) + : utime_(utime_) + , data_(std::move(data_)) + , transaction_id_(std::move(transaction_id_)) , fee_(fee_) , in_msg_(std::move(in_msg_)) , out_msgs_(std::move(out_msgs_)) @@ -427,8 +456,9 @@ const std::int32_t raw_transaction::ID; void raw_transaction::store(td::TlStorerToString &s, const char *field_name) const { if (!LOG_IS_STRIPPED(ERROR)) { s.store_class_begin(field_name, "raw_transaction"); + s.store_field("utime", utime_); s.store_bytes_field("data", data_); - if (previous_transaction_id_ == nullptr) { s.store_field("previous_transaction_id", "null"); } else { previous_transaction_id_->store(s, "previous_transaction_id"); } + if (transaction_id_ == nullptr) { s.store_field("transaction_id", "null"); } else { transaction_id_->store(s, "transaction_id"); } s.store_field("fee", fee_); if (in_msg_ == nullptr) { s.store_field("in_msg", "null"); } else { in_msg_->store(s, "in_msg"); } { const std::vector> &v = out_msgs_; const std::uint32_t multiplicity = static_cast(v.size()); const auto vector_name = "vector[" + td::to_string(multiplicity)+ "]"; s.store_class_begin("out_msgs", vector_name.c_str()); for (std::uint32_t i = 0; i < multiplicity; i++) { if (v[i] == nullptr) { s.store_field("", "null"); } else { v[i]->store(s, ""); } } s.store_class_end(); } @@ -438,10 +468,12 @@ void raw_transaction::store(td::TlStorerToString &s, const char *field_name) con raw_transactions::raw_transactions() : transactions_() + , previous_transaction_id_() {} -raw_transactions::raw_transactions(std::vector> &&transactions_) +raw_transactions::raw_transactions(std::vector> &&transactions_, object_ptr &&previous_transaction_id_) : transactions_(std::move(transactions_)) + , previous_transaction_id_(std::move(previous_transaction_id_)) {} const std::int32_t raw_transactions::ID; @@ -450,6 +482,7 @@ void raw_transactions::store(td::TlStorerToString &s, const char *field_name) co if (!LOG_IS_STRIPPED(ERROR)) { s.store_class_begin(field_name, "raw_transactions"); { const std::vector> &v = transactions_; const std::uint32_t multiplicity = static_cast(v.size()); const auto vector_name = "vector[" + td::to_string(multiplicity)+ "]"; s.store_class_begin("transactions", vector_name.c_str()); for (std::uint32_t i = 0; i < multiplicity; i++) { if (v[i] == nullptr) { s.store_field("", "null"); } else { v[i]->store(s, ""); } } s.store_class_end(); } + if (previous_transaction_id_ == nullptr) { s.store_field("previous_transaction_id", "null"); } else { previous_transaction_id_->store(s, "previous_transaction_id"); } s.store_class_end(); } } @@ -458,12 +491,14 @@ testGiver_accountState::testGiver_accountState() : balance_() , seqno_() , last_transaction_id_() + , sync_utime_() {} -testGiver_accountState::testGiver_accountState(std::int64_t balance_, std::int32_t seqno_, object_ptr &&last_transaction_id_) +testGiver_accountState::testGiver_accountState(std::int64_t balance_, std::int32_t seqno_, object_ptr &&last_transaction_id_, std::int64_t sync_utime_) : balance_(balance_) , seqno_(seqno_) , last_transaction_id_(std::move(last_transaction_id_)) + , sync_utime_(sync_utime_) {} const std::int32_t testGiver_accountState::ID; @@ -474,6 +509,7 @@ void testGiver_accountState::store(td::TlStorerToString &s, const char *field_na s.store_field("balance", balance_); s.store_field("seqno", seqno_); if (last_transaction_id_ == nullptr) { s.store_field("last_transaction_id", "null"); } else { last_transaction_id_->store(s, "last_transaction_id"); } + s.store_field("sync_utime", sync_utime_); s.store_class_end(); } } @@ -482,12 +518,14 @@ testWallet_accountState::testWallet_accountState() : balance_() , seqno_() , last_transaction_id_() + , sync_utime_() {} -testWallet_accountState::testWallet_accountState(std::int64_t balance_, std::int32_t seqno_, object_ptr &&last_transaction_id_) +testWallet_accountState::testWallet_accountState(std::int64_t balance_, std::int32_t seqno_, object_ptr &&last_transaction_id_, std::int64_t sync_utime_) : balance_(balance_) , seqno_(seqno_) , last_transaction_id_(std::move(last_transaction_id_)) + , sync_utime_(sync_utime_) {} const std::int32_t testWallet_accountState::ID; @@ -498,6 +536,7 @@ void testWallet_accountState::store(td::TlStorerToString &s, const char *field_n s.store_field("balance", balance_); s.store_field("seqno", seqno_); if (last_transaction_id_ == nullptr) { s.store_field("last_transaction_id", "null"); } else { last_transaction_id_->store(s, "last_transaction_id"); } + s.store_field("sync_utime", sync_utime_); s.store_class_end(); } } @@ -522,10 +561,14 @@ void testWallet_initialAccountState::store(td::TlStorerToString &s, const char * uninited_accountState::uninited_accountState() : balance_() + , last_transaction_id_() + , sync_utime_() {} -uninited_accountState::uninited_accountState(std::int64_t balance_) +uninited_accountState::uninited_accountState(std::int64_t balance_, object_ptr &&last_transaction_id_, std::int64_t sync_utime_) : balance_(balance_) + , last_transaction_id_(std::move(last_transaction_id_)) + , sync_utime_(sync_utime_) {} const std::int32_t uninited_accountState::ID; @@ -534,6 +577,8 @@ void uninited_accountState::store(td::TlStorerToString &s, const char *field_nam if (!LOG_IS_STRIPPED(ERROR)) { s.store_class_begin(field_name, "uninited_accountState"); s.store_field("balance", balance_); + if (last_transaction_id_ == nullptr) { s.store_field("last_transaction_id", "null"); } else { last_transaction_id_->store(s, "last_transaction_id"); } + s.store_field("sync_utime", sync_utime_); s.store_class_end(); } } @@ -826,6 +871,48 @@ void init::store(td::TlStorerToString &s, const char *field_name) const { } } +onLiteServerQueryError::onLiteServerQueryError() + : id_() + , error_() +{} + +onLiteServerQueryError::onLiteServerQueryError(std::int64_t id_, object_ptr &&error_) + : id_(id_) + , error_(std::move(error_)) +{} + +const std::int32_t onLiteServerQueryError::ID; + +void onLiteServerQueryError::store(td::TlStorerToString &s, const char *field_name) const { + if (!LOG_IS_STRIPPED(ERROR)) { + s.store_class_begin(field_name, "onLiteServerQueryError"); + s.store_field("id", id_); + if (error_ == nullptr) { s.store_field("error", "null"); } else { error_->store(s, "error"); } + s.store_class_end(); + } +} + +onLiteServerQueryResult::onLiteServerQueryResult() + : id_() + , bytes_() +{} + +onLiteServerQueryResult::onLiteServerQueryResult(std::int64_t id_, std::string const &bytes_) + : id_(id_) + , bytes_(std::move(bytes_)) +{} + +const std::int32_t onLiteServerQueryResult::ID; + +void onLiteServerQueryResult::store(td::TlStorerToString &s, const char *field_name) const { + if (!LOG_IS_STRIPPED(ERROR)) { + s.store_class_begin(field_name, "onLiteServerQueryResult"); + s.store_field("id", id_); + s.store_bytes_field("bytes", bytes_); + s.store_class_end(); + } +} + options_setConfig::options_setConfig() : config_() {} diff --git a/submodules/ton/tonlib-src/tl/generate/auto/tl/tonlib_api.h b/submodules/ton/tonlib-src/tl/generate/auto/tl/tonlib_api.h index c07d383c72..bbca471746 100644 --- a/submodules/ton/tonlib-src/tl/generate/auto/tl/tonlib_api.h +++ b/submodules/ton/tonlib-src/tl/generate/auto/tl/tonlib_api.h @@ -64,6 +64,8 @@ class ok; class options; +class updateSendLiteServerQuery; + class generic_AccountState; class generic_InitialAccountState; @@ -246,12 +248,30 @@ class options final : public Object { public: std::string config_; std::string keystore_directory_; + bool use_callbacks_for_network_; options(); - options(std::string const &config_, std::string const &keystore_directory_); + options(std::string const &config_, std::string const &keystore_directory_, bool use_callbacks_for_network_); - static const std::int32_t ID = -876766471; + static const std::int32_t ID = -952483001; + std::int32_t get_id() const final { + return ID; + } + + void store(td::TlStorerToString &s, const char *field_name) const final; +}; + +class updateSendLiteServerQuery final : public Object { + public: + std::int64_t id_; + std::string data_; + + updateSendLiteServerQuery(); + + updateSendLiteServerQuery(std::int64_t id_, std::string const &data_); + + static const std::int32_t ID = -1555130916; std::int32_t get_id() const final { return ID; } @@ -386,12 +406,13 @@ class raw_accountState final : public Object { std::string code_; std::string data_; object_ptr last_transaction_id_; + std::int64_t sync_utime_; raw_accountState(); - raw_accountState(std::int64_t balance_, std::string const &code_, std::string const &data_, object_ptr &&last_transaction_id_); + raw_accountState(std::int64_t balance_, std::string const &code_, std::string const &data_, object_ptr &&last_transaction_id_, std::int64_t sync_utime_); - static const std::int32_t ID = -550396199; + static const std::int32_t ID = 461615898; std::int32_t get_id() const final { return ID; } @@ -436,17 +457,18 @@ class raw_message final : public Object { class raw_transaction final : public Object { public: + std::int64_t utime_; std::string data_; - object_ptr previous_transaction_id_; + object_ptr transaction_id_; std::int64_t fee_; object_ptr in_msg_; std::vector> out_msgs_; raw_transaction(); - raw_transaction(std::string const &data_, object_ptr &&previous_transaction_id_, std::int64_t fee_, object_ptr &&in_msg_, std::vector> &&out_msgs_); + raw_transaction(std::int64_t utime_, std::string const &data_, object_ptr &&transaction_id_, std::int64_t fee_, object_ptr &&in_msg_, std::vector> &&out_msgs_); - static const std::int32_t ID = -463758736; + static const std::int32_t ID = -1159530820; std::int32_t get_id() const final { return ID; } @@ -457,12 +479,13 @@ class raw_transaction final : public Object { class raw_transactions final : public Object { public: std::vector> transactions_; + object_ptr previous_transaction_id_; raw_transactions(); - explicit raw_transactions(std::vector> &&transactions_); + raw_transactions(std::vector> &&transactions_, object_ptr &&previous_transaction_id_); - static const std::int32_t ID = -442987753; + static const std::int32_t ID = 240548986; std::int32_t get_id() const final { return ID; } @@ -475,12 +498,13 @@ class testGiver_accountState final : public Object { std::int64_t balance_; std::int32_t seqno_; object_ptr last_transaction_id_; + std::int64_t sync_utime_; testGiver_accountState(); - testGiver_accountState(std::int64_t balance_, std::int32_t seqno_, object_ptr &&last_transaction_id_); + testGiver_accountState(std::int64_t balance_, std::int32_t seqno_, object_ptr &&last_transaction_id_, std::int64_t sync_utime_); - static const std::int32_t ID = 2037609684; + static const std::int32_t ID = 860930426; std::int32_t get_id() const final { return ID; } @@ -493,12 +517,13 @@ class testWallet_accountState final : public Object { std::int64_t balance_; std::int32_t seqno_; object_ptr last_transaction_id_; + std::int64_t sync_utime_; testWallet_accountState(); - testWallet_accountState(std::int64_t balance_, std::int32_t seqno_, object_ptr &&last_transaction_id_); + testWallet_accountState(std::int64_t balance_, std::int32_t seqno_, object_ptr &&last_transaction_id_, std::int64_t sync_utime_); - static const std::int32_t ID = 105752218; + static const std::int32_t ID = 305698744; std::int32_t get_id() const final { return ID; } @@ -525,12 +550,14 @@ class testWallet_initialAccountState final : public Object { class uninited_accountState final : public Object { public: std::int64_t balance_; + object_ptr last_transaction_id_; + std::int64_t sync_utime_; uninited_accountState(); - explicit uninited_accountState(std::int64_t balance_); + uninited_accountState(std::int64_t balance_, object_ptr &&last_transaction_id_, std::int64_t sync_utime_); - static const std::int32_t ID = -1992757598; + static const std::int32_t ID = 1768941188; std::int32_t get_id() const final { return ID; } @@ -801,6 +828,44 @@ class init final : public Function { void store(td::TlStorerToString &s, const char *field_name) const final; }; +class onLiteServerQueryError final : public Function { + public: + std::int64_t id_; + object_ptr error_; + + onLiteServerQueryError(); + + onLiteServerQueryError(std::int64_t id_, object_ptr &&error_); + + static const std::int32_t ID = -677427533; + std::int32_t get_id() const final { + return ID; + } + + using ReturnType = object_ptr; + + void store(td::TlStorerToString &s, const char *field_name) const final; +}; + +class onLiteServerQueryResult final : public Function { + public: + std::int64_t id_; + std::string bytes_; + + onLiteServerQueryResult(); + + onLiteServerQueryResult(std::int64_t id_, std::string const &bytes_); + + static const std::int32_t ID = 2056444510; + std::int32_t get_id() const final { + return ID; + } + + using ReturnType = object_ptr; + + void store(td::TlStorerToString &s, const char *field_name) const final; +}; + class options_setConfig final : public Function { public: std::string config_; diff --git a/submodules/ton/tonlib-src/tl/generate/auto/tl/tonlib_api.hpp b/submodules/ton/tonlib-src/tl/generate/auto/tl/tonlib_api.hpp index 1bbc15cd0c..6631b6d8f0 100644 --- a/submodules/ton/tonlib-src/tl/generate/auto/tl/tonlib_api.hpp +++ b/submodules/ton/tonlib-src/tl/generate/auto/tl/tonlib_api.hpp @@ -44,6 +44,9 @@ bool downcast_call(Object &obj, const T &func) { case options::ID: func(static_cast(obj)); return true; + case updateSendLiteServerQuery::ID: + func(static_cast(obj)); + return true; case generic_accountStateRaw::ID: func(static_cast(obj)); return true; @@ -148,6 +151,12 @@ bool downcast_call(Function &obj, const T &func) { case init::ID: func(static_cast(obj)); return true; + case onLiteServerQueryError::ID: + func(static_cast(obj)); + return true; + case onLiteServerQueryResult::ID: + func(static_cast(obj)); + return true; case options_setConfig::ID: func(static_cast(obj)); return true; diff --git a/submodules/ton/tonlib-src/tl/generate/auto/tl/tonlib_api_json.cpp b/submodules/ton/tonlib-src/tl/generate/auto/tl/tonlib_api_json.cpp index 3667853c8f..1b35ee3e61 100644 --- a/submodules/ton/tonlib-src/tl/generate/auto/tl/tonlib_api_json.cpp +++ b/submodules/ton/tonlib-src/tl/generate/auto/tl/tonlib_api_json.cpp @@ -49,7 +49,8 @@ Result tl_constructor_from_string(tonlib_api::Object *object, const std:: {"inputKey", 869287093}, {"key", -1978362923}, {"ok", -722616727}, - {"options", -876766471}, + {"options", -952483001}, + {"updateSendLiteServerQuery", -1555130916}, {"generic.accountStateRaw", -1387096685}, {"generic.accountStateTestWallet", -1041955397}, {"generic.accountStateTestGiver", 1134654598}, @@ -57,15 +58,15 @@ Result tl_constructor_from_string(tonlib_api::Object *object, const std:: {"generic.initialAccountStateRaw", -1178429153}, {"generic.initialAccountStateTestWallet", 710924204}, {"internal.transactionId", -989527262}, - {"raw.accountState", -550396199}, + {"raw.accountState", 461615898}, {"raw.initialAccountState", 777456197}, {"raw.message", -1131081640}, - {"raw.transaction", -463758736}, - {"raw.transactions", -442987753}, - {"testGiver.accountState", 2037609684}, - {"testWallet.accountState", 105752218}, + {"raw.transaction", -1159530820}, + {"raw.transactions", 240548986}, + {"testGiver.accountState", 860930426}, + {"testWallet.accountState", 305698744}, {"testWallet.initialAccountState", -1231516227}, - {"uninited.accountState", -1992757598} + {"uninited.accountState", 1768941188} }; auto it = m.find(str); if (it == m.end()) { @@ -89,6 +90,8 @@ Result tl_constructor_from_string(tonlib_api::Function *object, const std {"importKey", -1607900903}, {"importPemKey", 76385617}, {"init", -2014661877}, + {"onLiteServerQueryError", -677427533}, + {"onLiteServerQueryResult", 2056444510}, {"options.setConfig", 21225546}, {"raw.getAccountAddress", -521283849}, {"raw.getAccountState", 663706721}, @@ -215,6 +218,27 @@ Status from_json(tonlib_api::options &to, JsonObject &from) { TRY_STATUS(from_json(to.keystore_directory_, value)); } } + { + TRY_RESULT(value, get_json_object_field(from, "use_callbacks_for_network", JsonValue::Type::Null, true)); + if (value.type() != JsonValue::Type::Null) { + TRY_STATUS(from_json(to.use_callbacks_for_network_, value)); + } + } + return Status::OK(); +} +Status from_json(tonlib_api::updateSendLiteServerQuery &to, JsonObject &from) { + { + TRY_RESULT(value, get_json_object_field(from, "id", JsonValue::Type::Null, true)); + if (value.type() != JsonValue::Type::Null) { + TRY_STATUS(from_json(to.id_, value)); + } + } + { + TRY_RESULT(value, get_json_object_field(from, "data", JsonValue::Type::Null, true)); + if (value.type() != JsonValue::Type::Null) { + TRY_STATUS(from_json_bytes(to.data_, value)); + } + } return Status::OK(); } Status from_json(tonlib_api::generic_accountStateRaw &to, JsonObject &from) { @@ -311,6 +335,12 @@ Status from_json(tonlib_api::raw_accountState &to, JsonObject &from) { TRY_STATUS(from_json(to.last_transaction_id_, value)); } } + { + TRY_RESULT(value, get_json_object_field(from, "sync_utime", JsonValue::Type::Null, true)); + if (value.type() != JsonValue::Type::Null) { + TRY_STATUS(from_json(to.sync_utime_, value)); + } + } return Status::OK(); } Status from_json(tonlib_api::raw_initialAccountState &to, JsonObject &from) { @@ -350,6 +380,12 @@ Status from_json(tonlib_api::raw_message &to, JsonObject &from) { return Status::OK(); } Status from_json(tonlib_api::raw_transaction &to, JsonObject &from) { + { + TRY_RESULT(value, get_json_object_field(from, "utime", JsonValue::Type::Null, true)); + if (value.type() != JsonValue::Type::Null) { + TRY_STATUS(from_json(to.utime_, value)); + } + } { TRY_RESULT(value, get_json_object_field(from, "data", JsonValue::Type::Null, true)); if (value.type() != JsonValue::Type::Null) { @@ -357,9 +393,9 @@ Status from_json(tonlib_api::raw_transaction &to, JsonObject &from) { } } { - TRY_RESULT(value, get_json_object_field(from, "previous_transaction_id", JsonValue::Type::Null, true)); + TRY_RESULT(value, get_json_object_field(from, "transaction_id", JsonValue::Type::Null, true)); if (value.type() != JsonValue::Type::Null) { - TRY_STATUS(from_json(to.previous_transaction_id_, value)); + TRY_STATUS(from_json(to.transaction_id_, value)); } } { @@ -389,6 +425,12 @@ Status from_json(tonlib_api::raw_transactions &to, JsonObject &from) { TRY_STATUS(from_json(to.transactions_, value)); } } + { + TRY_RESULT(value, get_json_object_field(from, "previous_transaction_id", JsonValue::Type::Null, true)); + if (value.type() != JsonValue::Type::Null) { + TRY_STATUS(from_json(to.previous_transaction_id_, value)); + } + } return Status::OK(); } Status from_json(tonlib_api::testGiver_accountState &to, JsonObject &from) { @@ -410,6 +452,12 @@ Status from_json(tonlib_api::testGiver_accountState &to, JsonObject &from) { TRY_STATUS(from_json(to.last_transaction_id_, value)); } } + { + TRY_RESULT(value, get_json_object_field(from, "sync_utime", JsonValue::Type::Null, true)); + if (value.type() != JsonValue::Type::Null) { + TRY_STATUS(from_json(to.sync_utime_, value)); + } + } return Status::OK(); } Status from_json(tonlib_api::testWallet_accountState &to, JsonObject &from) { @@ -431,6 +479,12 @@ Status from_json(tonlib_api::testWallet_accountState &to, JsonObject &from) { TRY_STATUS(from_json(to.last_transaction_id_, value)); } } + { + TRY_RESULT(value, get_json_object_field(from, "sync_utime", JsonValue::Type::Null, true)); + if (value.type() != JsonValue::Type::Null) { + TRY_STATUS(from_json(to.sync_utime_, value)); + } + } return Status::OK(); } Status from_json(tonlib_api::testWallet_initialAccountState &to, JsonObject &from) { @@ -449,6 +503,18 @@ Status from_json(tonlib_api::uninited_accountState &to, JsonObject &from) { TRY_STATUS(from_json(to.balance_, value)); } } + { + TRY_RESULT(value, get_json_object_field(from, "last_transaction_id", JsonValue::Type::Null, true)); + if (value.type() != JsonValue::Type::Null) { + TRY_STATUS(from_json(to.last_transaction_id_, value)); + } + } + { + TRY_RESULT(value, get_json_object_field(from, "sync_utime", JsonValue::Type::Null, true)); + if (value.type() != JsonValue::Type::Null) { + TRY_STATUS(from_json(to.sync_utime_, value)); + } + } return Status::OK(); } Status from_json(tonlib_api::changeLocalPassword &to, JsonObject &from) { @@ -655,6 +721,36 @@ Status from_json(tonlib_api::init &to, JsonObject &from) { } return Status::OK(); } +Status from_json(tonlib_api::onLiteServerQueryError &to, JsonObject &from) { + { + TRY_RESULT(value, get_json_object_field(from, "id", JsonValue::Type::Null, true)); + if (value.type() != JsonValue::Type::Null) { + TRY_STATUS(from_json(to.id_, value)); + } + } + { + TRY_RESULT(value, get_json_object_field(from, "error", JsonValue::Type::Null, true)); + if (value.type() != JsonValue::Type::Null) { + TRY_STATUS(from_json(to.error_, value)); + } + } + return Status::OK(); +} +Status from_json(tonlib_api::onLiteServerQueryResult &to, JsonObject &from) { + { + TRY_RESULT(value, get_json_object_field(from, "id", JsonValue::Type::Null, true)); + if (value.type() != JsonValue::Type::Null) { + TRY_STATUS(from_json(to.id_, value)); + } + } + { + TRY_RESULT(value, get_json_object_field(from, "bytes", JsonValue::Type::Null, true)); + if (value.type() != JsonValue::Type::Null) { + TRY_STATUS(from_json_bytes(to.bytes_, value)); + } + } + return Status::OK(); +} Status from_json(tonlib_api::options_setConfig &to, JsonObject &from) { { TRY_RESULT(value, get_json_object_field(from, "config", JsonValue::Type::Null, true)); @@ -862,6 +958,13 @@ void to_json(JsonValueScope &jv, const tonlib_api::options &object) { jo << ctie("@type", "options"); jo << ctie("config", ToJson(object.config_)); jo << ctie("keystore_directory", ToJson(object.keystore_directory_)); + jo << ctie("use_callbacks_for_network", ToJson(object.use_callbacks_for_network_)); +} +void to_json(JsonValueScope &jv, const tonlib_api::updateSendLiteServerQuery &object) { + auto jo = jv.enter_object(); + jo << ctie("@type", "updateSendLiteServerQuery"); + jo << ctie("id", ToJson(JsonInt64{object.id_})); + jo << ctie("data", ToJson(JsonBytes{object.data_})); } void to_json(JsonValueScope &jv, const tonlib_api::generic_AccountState &object) { tonlib_api::downcast_call(const_cast(object), [&jv](const auto &object) { to_json(jv, object); }); @@ -926,6 +1029,7 @@ void to_json(JsonValueScope &jv, const tonlib_api::raw_accountState &object) { if (object.last_transaction_id_) { jo << ctie("last_transaction_id", ToJson(object.last_transaction_id_)); } + jo << ctie("sync_utime", ToJson(object.sync_utime_)); } void to_json(JsonValueScope &jv, const tonlib_api::raw_initialAccountState &object) { auto jo = jv.enter_object(); @@ -943,9 +1047,10 @@ void to_json(JsonValueScope &jv, const tonlib_api::raw_message &object) { void to_json(JsonValueScope &jv, const tonlib_api::raw_transaction &object) { auto jo = jv.enter_object(); jo << ctie("@type", "raw.transaction"); + jo << ctie("utime", ToJson(object.utime_)); jo << ctie("data", ToJson(JsonBytes{object.data_})); - if (object.previous_transaction_id_) { - jo << ctie("previous_transaction_id", ToJson(object.previous_transaction_id_)); + if (object.transaction_id_) { + jo << ctie("transaction_id", ToJson(object.transaction_id_)); } jo << ctie("fee", ToJson(JsonInt64{object.fee_})); if (object.in_msg_) { @@ -957,6 +1062,9 @@ void to_json(JsonValueScope &jv, const tonlib_api::raw_transactions &object) { auto jo = jv.enter_object(); jo << ctie("@type", "raw.transactions"); jo << ctie("transactions", ToJson(object.transactions_)); + if (object.previous_transaction_id_) { + jo << ctie("previous_transaction_id", ToJson(object.previous_transaction_id_)); + } } void to_json(JsonValueScope &jv, const tonlib_api::testGiver_accountState &object) { auto jo = jv.enter_object(); @@ -966,6 +1074,7 @@ void to_json(JsonValueScope &jv, const tonlib_api::testGiver_accountState &objec if (object.last_transaction_id_) { jo << ctie("last_transaction_id", ToJson(object.last_transaction_id_)); } + jo << ctie("sync_utime", ToJson(object.sync_utime_)); } void to_json(JsonValueScope &jv, const tonlib_api::testWallet_accountState &object) { auto jo = jv.enter_object(); @@ -975,6 +1084,7 @@ void to_json(JsonValueScope &jv, const tonlib_api::testWallet_accountState &obje if (object.last_transaction_id_) { jo << ctie("last_transaction_id", ToJson(object.last_transaction_id_)); } + jo << ctie("sync_utime", ToJson(object.sync_utime_)); } void to_json(JsonValueScope &jv, const tonlib_api::testWallet_initialAccountState &object) { auto jo = jv.enter_object(); @@ -985,6 +1095,10 @@ void to_json(JsonValueScope &jv, const tonlib_api::uninited_accountState &object auto jo = jv.enter_object(); jo << ctie("@type", "uninited.accountState"); jo << ctie("balance", ToJson(JsonInt64{object.balance_})); + if (object.last_transaction_id_) { + jo << ctie("last_transaction_id", ToJson(object.last_transaction_id_)); + } + jo << ctie("sync_utime", ToJson(object.sync_utime_)); } void to_json(JsonValueScope &jv, const tonlib_api::changeLocalPassword &object) { auto jo = jv.enter_object(); @@ -1093,6 +1207,20 @@ void to_json(JsonValueScope &jv, const tonlib_api::init &object) { jo << ctie("options", ToJson(object.options_)); } } +void to_json(JsonValueScope &jv, const tonlib_api::onLiteServerQueryError &object) { + auto jo = jv.enter_object(); + jo << ctie("@type", "onLiteServerQueryError"); + jo << ctie("id", ToJson(JsonInt64{object.id_})); + if (object.error_) { + jo << ctie("error", ToJson(object.error_)); + } +} +void to_json(JsonValueScope &jv, const tonlib_api::onLiteServerQueryResult &object) { + auto jo = jv.enter_object(); + jo << ctie("@type", "onLiteServerQueryResult"); + jo << ctie("id", ToJson(JsonInt64{object.id_})); + jo << ctie("bytes", ToJson(JsonBytes{object.bytes_})); +} void to_json(JsonValueScope &jv, const tonlib_api::options_setConfig &object) { auto jo = jv.enter_object(); jo << ctie("@type", "options.setConfig"); diff --git a/submodules/ton/tonlib-src/tl/generate/auto/tl/tonlib_api_json.h b/submodules/ton/tonlib-src/tl/generate/auto/tl/tonlib_api_json.h index 84134f3bd5..3021c65ae1 100644 --- a/submodules/ton/tonlib-src/tl/generate/auto/tl/tonlib_api_json.h +++ b/submodules/ton/tonlib-src/tl/generate/auto/tl/tonlib_api_json.h @@ -25,6 +25,7 @@ Status from_json(tonlib_api::inputKey &to, JsonObject &from); Status from_json(tonlib_api::key &to, JsonObject &from); Status from_json(tonlib_api::ok &to, JsonObject &from); Status from_json(tonlib_api::options &to, JsonObject &from); +Status from_json(tonlib_api::updateSendLiteServerQuery &to, JsonObject &from); Status from_json(tonlib_api::generic_accountStateRaw &to, JsonObject &from); Status from_json(tonlib_api::generic_accountStateTestWallet &to, JsonObject &from); Status from_json(tonlib_api::generic_accountStateTestGiver &to, JsonObject &from); @@ -55,6 +56,8 @@ Status from_json(tonlib_api::importEncryptedKey &to, JsonObject &from); Status from_json(tonlib_api::importKey &to, JsonObject &from); Status from_json(tonlib_api::importPemKey &to, JsonObject &from); Status from_json(tonlib_api::init &to, JsonObject &from); +Status from_json(tonlib_api::onLiteServerQueryError &to, JsonObject &from); +Status from_json(tonlib_api::onLiteServerQueryResult &to, JsonObject &from); Status from_json(tonlib_api::options_setConfig &to, JsonObject &from); Status from_json(tonlib_api::raw_getAccountAddress &to, JsonObject &from); Status from_json(tonlib_api::raw_getAccountState &to, JsonObject &from); @@ -78,6 +81,7 @@ void to_json(JsonValueScope &jv, const tonlib_api::inputKey &object); void to_json(JsonValueScope &jv, const tonlib_api::key &object); void to_json(JsonValueScope &jv, const tonlib_api::ok &object); void to_json(JsonValueScope &jv, const tonlib_api::options &object); +void to_json(JsonValueScope &jv, const tonlib_api::updateSendLiteServerQuery &object); void to_json(JsonValueScope &jv, const tonlib_api::generic_AccountState &object); void to_json(JsonValueScope &jv, const tonlib_api::generic_accountStateRaw &object); void to_json(JsonValueScope &jv, const tonlib_api::generic_accountStateTestWallet &object); @@ -110,6 +114,8 @@ void to_json(JsonValueScope &jv, const tonlib_api::importEncryptedKey &object); void to_json(JsonValueScope &jv, const tonlib_api::importKey &object); void to_json(JsonValueScope &jv, const tonlib_api::importPemKey &object); void to_json(JsonValueScope &jv, const tonlib_api::init &object); +void to_json(JsonValueScope &jv, const tonlib_api::onLiteServerQueryError &object); +void to_json(JsonValueScope &jv, const tonlib_api::onLiteServerQueryResult &object); void to_json(JsonValueScope &jv, const tonlib_api::options_setConfig &object); void to_json(JsonValueScope &jv, const tonlib_api::raw_getAccountAddress &object); void to_json(JsonValueScope &jv, const tonlib_api::raw_getAccountState &object); diff --git a/submodules/ton/tonlib-src/tl/generate/scheme/ton_api.tl b/submodules/ton/tonlib-src/tl/generate/scheme/ton_api.tl index a4212bb814..073595ce56 100644 --- a/submodules/ton/tonlib-src/tl/generate/scheme/ton_api.tl +++ b/submodules/ton/tonlib-src/tl/generate/scheme/ton_api.tl @@ -367,6 +367,10 @@ tonNode.downloadZeroState block:tonNode.blockIdExt = tonNode.Data; tonNode.downloadBlockProof block:tonNode.blockIdExt = tonNode.Data; tonNode.downloadBlockProofLink block:tonNode.blockIdExt = tonNode.Data; +tonNode.slave.sendExtMessage message:tonNode.externalMessage = True; + +tonNode.query = Object; + ---types--- // bit 0 - started @@ -482,9 +486,12 @@ engine.controlInterface id:int256 port:int allowed:(vector engine.controlProcess engine.gc ids:(vector int256) = engine.Gc; engine.dht.config dht:(vector engine.dht) gc:engine.gc = engine.dht.Config; +engine.validator.fullNodeMaster port:int adnl:int256 = engine.validator.FullNodeMaster; +engine.validator.fullNodeSlave ip:int port:int adnl:PublicKey = engine.validator.FullNodeSlave; engine.validator.config out_port:int addrs:(vector engine.Addr) adnl:(vector engine.adnl) dht:(vector engine.dht) - validators:(vector engine.validator) fullnode:int256 + validators:(vector engine.validator) fullnode:int256 fullnodeslave:engine.validator.fullNodeSlave + fullnodemasters:(vector engine.validator.fullNodeMaster) liteservers:(vector engine.liteServer) control:(vector engine.controlInterface) gc:engine.gc = engine.validator.Config; diff --git a/submodules/ton/tonlib-src/tl/generate/scheme/ton_api.tlo b/submodules/ton/tonlib-src/tl/generate/scheme/ton_api.tlo index 10e98bde912e0131c4910aa5c5919abe484d8146..00dc97c4e01c909e9d9d044767f1066cac991239 100644 GIT binary patch delta 484 zcmZ3{$9!QjGw-9>`c@23uxul*x**H9U{=P>7J@pADjDBeTjW#o(lhf?^~w@+GE)*u z@{9D`N^^4j@>5cM6N^hyizaT6P_E2Y?U2K%E;uK#EOp{~$;~N354agQHoMC04qydY zB0f2Bs|Zh8W;%#-^O%qi_vFHjI+FwQKb!KV0WHY`T2c(s3~?TZZQDVRO^i_2NwW>Q7ka|g*gvTku#eP%om$IiXBWD z?KgL>*exq_S>7XF8y!_UFa>FE<$sChKCLIu%>~ic00AU`nWdHyG delta 111 zcmcaGnR!JYGw-9>`c@23uw)~zx*&^$# = raw.Transaction; -raw.transactions transactions:vector = raw.Transactions; +raw.transaction utime:int53 data:bytes transaction_id:internal.transactionId fee:int64 in_msg:raw.message out_msgs:vector = raw.Transaction; +raw.transactions transactions:vector previous_transaction_id:internal.transactionId = raw.Transactions; testWallet.initialAccountState public_key:string = testWallet.InitialAccountState; -testWallet.accountState balance:int64 seqno:int32 last_transaction_id:internal.transactionId = testWallet.AccountState; +testWallet.accountState balance:int64 seqno:int32 last_transaction_id:internal.transactionId sync_utime:int53 = testWallet.AccountState; -testGiver.accountState balance:int64 seqno:int32 last_transaction_id:internal.transactionId = testGiver.AccountState; +testGiver.accountState balance:int64 seqno:int32 last_transaction_id:internal.transactionId sync_utime:int53= testGiver.AccountState; -uninited.accountState balance:int64 = uninited.AccountState; +uninited.accountState balance:int64 last_transaction_id:internal.transactionId sync_utime:int53 = uninited.AccountState; generic.initialAccountStateRaw initital_account_state:raw.initialAccountState = generic.InitialAccountState; generic.initialAccountStateTestWallet initital_account_state:testWallet.initialAccountState = generic.InitialAccountState; @@ -51,6 +51,8 @@ generic.accountStateTestWallet account_state:testWallet.accountState = generic.A generic.accountStateTestGiver account_state:testGiver.accountState = generic.AccountState; generic.accountStateUninited account_state:uninited.accountState = generic.AccountState; +updateSendLiteServerQuery id:int64 data:bytes = Update; + ---functions--- init options:options = Ok; @@ -89,5 +91,7 @@ testGiver.sendGrams destination:accountAddress seqno:int32 amount:int64 = Ok; generic.getAccountState account_address:accountAddress = generic.AccountState; generic.sendGrams private_key:inputKey source:accountAddress destination:accountAddress amount:int64 = Ok; -runTests dir:string = Ok; +onLiteServerQueryResult id:int64 bytes:bytes = Ok; +onLiteServerQueryError id:int64 error:error = Ok; +runTests dir:string = Ok; diff --git a/submodules/ton/tonlib-src/tl/generate/scheme/tonlib_api.tlo b/submodules/ton/tonlib-src/tl/generate/scheme/tonlib_api.tlo index 4971c24f989c589eca985cd0277f47494727e155..7d87ccac80f8c60377aeecb6efe0bc2109fd84ef 100644 GIT binary patch delta 1119 zcmb7D&ui0Q7*5(RU2W}>wb8ZPIwzYlq0Gt()`2jnKPHU%qo|i+$=ax4F{w%Fe&9tN z(u>&cQ#|b8LH__H6GVz^Fx+Ja4~i%gM=1kA#gls2!MtDEx+w_DC12jW@AJOT^FH6N z#PSJWWp@7nReQQizMpuG=5dg&k~inbqT`8yB|PCMdsps{JaV1QWd%blsUaM5E}}N` zRy$sI7Et*|OK1lG zH>o*8QWYJ}?_c?cow(#VIoQ7TXi|LFY%cDYOOiy1_wX`A{aBd*Noq zyQe<8mT*NNM#lZ(c^rdrLwPc8QdF|Tk|8EV?V6~a&WqY4MZte)>97!>p+m}2c%J9+ zY74?EYzI!UZUjl@wAW4BREyhX!e_=O+XQpg0eG3KzI*g;kb~2N@jfAwQS*wCG%T$w zc!)zQ20!Jy34WQq9EGMHeNxG!^M-T<@+b-zd|SG4i6&nZRc8eVW|ZrpSU&D`FfC-2sg}{PE+U|aw#Q=EW!^~9cKY(XMJue&o17t=gEiLg# zXCLM|slzI C{(ijx delta 601 zcmX@(`NNs_(QJJy1}IRP$oqX_iO6IL#wQ?3fGLIL=d8V_Cs#1-nH<4U^QTwwak}ovJGnv%c6G{os-wF>M*Kq zzR7x=MHFNbdwxMlW`15Vh<)>zkPp-3tz7<-C$Moq>~Y~#9YGaFS&)1AixSKA zN{SNmiW8GTjsS^)+`u}SkwYA+k7e=+VV%hfL|7)@5vni*selE|RXMI0kY@$ZOeqE` z0EvT4Vw~J6Y^;H-tH_y6hr_n*AV>wWNnq~?h)8gP7$B|8lMO}kL5>yyi6AQlhvx&J zQV;`0DI|0jh*m&?T1HHQ6BOnUml%pDPZp5o;01}mjFaAcRE(J&64VOv3X`A6J%I$C zjFbh0!J(i6iBbcF6fk4+422v<379KE2En`p65A}JFmtgc6Dn|k3JM6M9(n;m1!{ZaNI~L{grMO)8HKr>D{Z%TCv2<+vMg_+G1AS+}=Y)r;b&6z{}C-HNXT z0|f(j%0NGE&pz}3nV&nGoad8MAEhTg*u2wGi~a=z1p@^G1p@^G1p@^G1p@^G1q1&> z48*;A$mg-%d*qt8^E4Y@G^@n z-wU?!rxn_v$D(O7`MJef)D5UsGgWxTv8q+lK2EpO^L+GSZ7=X*uNy?u2lb(5y;jv0*Nl42GEBwPD%O&^ ztku++bhIJ*#tfuu8;Y6b(CUTWRXb*RE=PNc3F)b8ViA^DMZ(+OQ0c0wEUCJ&2l83q zdhKaWX$0v?o_b-o$HJHkcrXub==FxGo0@9Ss#ZI1EmxHlgHFv}@K4XOonAMLnQKM6 zomSV6AoD0bJwb}{hdPe$u^{HEVu>M=j#D$lYtw0^(WrvDcZzl=z zWnq>n^cRjrz`u7du&I%kwK{l(INXgO|a^VV7enH*MKsIjW(>e7%#i1Rf; zPvp^=UXhzu6M?TLTZbA!d8SA8PFe!FMN0_V;?gcTz23}7FR7Okx`C5hA0>HUq`c&4 z1FC#WaBbN=FImh%DrQzKbIDSgW*wHPQf)4&#_d|4ti4JXd<*N7UvKlc2H z#w_f3f$a-3$aa|1kL{MvIkf2lH7LorwR!Ab_r7S1KZc32eIm)SHIXcOjix!Vt13MLnLpPH7c9`|HM zG7iebx?qX-U@8alq&+Sp6A316DH!aQ{l+hF#B{d^}T%_Jx`~i<8aW z;QUI(u-(A-y_nJ1htq&LhH~QbEdM+!bp~$533q#Omur>P!f!~oX;Kf}fZv&gbMNq5 z%0U(Y4zFey)vOHm9tDqwyRei?r9=0*wb77V;%1n+Vo6ONz6(h6o;TE7=rz?cRU^G$ zjrggI87s#uip%`E7qG<0G~h<~&8z~Fa;Ch#y!;;w+-@H*av~gQ=eF5yR5rX$&u40o zNEY|8(k9r=HdqfBr0O{%6|xU=&$Hc;$|aTzIKHyw_2wTQ=`yks7~g}|GFp{e&1iLQ zJ)_lPMZA14W1{uhRhr55T=;=8<+ks)U@3Ankn#nTvv|04#kvV~yQ zfZ2xe$(AO!2G3C(2i7e&vbqzCdrU$5@Vse9d6L zBjsYpx#Gc|bH$lm=gNonovYj5V6yY^Rs5h0HYRtUFBALcWtlseIJeo`eafxcmxmAMnC4LOucf3~~44z(wE!a09XS zAA#2Z9*2Je*a5Br2Jj)^Ux>Z`4BP;o23#PG%Rh?36E8p}&-bT!{sj@0bpGP%kTjg4Q*$x{ljQAZ>^h@UE z(JW?OL_}*|qUsLfRM`p(8^1I1M93qQmK}Lc8k||UPVu3wHqwjJxm6BLn&w`Te`;%p z&`#V1R+*1PT_ggSiJVZ%6H!Kk=V!(K78bBvPLcd>CJEk1>~x<)k;;-y$bPY)HlJ%u zvx*~8#O-Cfax#@$PLpE@T+*CHUbvIQSSpoeoQd~xayQ2R35pBk_{q{%h>CM6G(1Z- zEE+cp&xMwIz8$x_VW+e?c{1MkPA4>yLt^-zgKPKX>F#tYXOr<8|J|LWA9z>#%<9Dm zIPUIDA_H)@XL(yBlT0$}GRME$+wlTCD%kC@=)XOYUyl8<>DOCZcs_H`;C}hAI_#Iz zG-lcE$6Y>2oJ7VvXLP_cX~VY=K6@5u}QZy-8z~TlQy5`JwR$0g~vCLo()(`d0vJ(p))_{phP5Y zv-vrhnv+?%!{zHvUAutHv1-;ErX^*FWdisPH;8|t2$L%UIo~WOn6CZg_ z6VEBErlDHOqM>S4xE6k)cpD`#LSdqc$rVX>W}e3%qCJ=76Rj2+~0nqo+4VK?Jb g+_LTd6ILnr{6odzMi?!dT+Gj#tTH<{FPI_!2Gs_Y;s5{u diff --git a/submodules/ton/tonlib-src/tonlib/CMakeLists.txt b/submodules/ton/tonlib-src/tonlib/CMakeLists.txt index 76f1a06c80..6c2f11a423 100644 --- a/submodules/ton/tonlib-src/tonlib/CMakeLists.txt +++ b/submodules/ton/tonlib-src/tonlib/CMakeLists.txt @@ -9,6 +9,7 @@ set(TONLIB_SOURCE tonlib/Config.cpp tonlib/ExtClient.cpp tonlib/ExtClientLazy.cpp + tonlib/ExtClientOutbound.cpp tonlib/GenericAccount.cpp tonlib/KeyStorage.cpp tonlib/LastBlock.cpp @@ -21,6 +22,7 @@ set(TONLIB_SOURCE tonlib/Config.h tonlib/ExtClient.h tonlib/ExtClientLazy.h + tonlib/ExtClientOutbound.h tonlib/GenericAccount.h tonlib/KeyStorage.h tonlib/LastBlock.h diff --git a/submodules/ton/tonlib-src/tonlib/test/.online.cpp.swp b/submodules/ton/tonlib-src/tonlib/test/.online.cpp.swp new file mode 100644 index 0000000000000000000000000000000000000000..f03547aa930ae6896420d7fd927d7dccdeaaf1c9 GIT binary patch literal 24576 zcmeHPeT*bWb?=-%0h<^cMIjD$c?tIHd3I*+&OYDGo`>u$d*{vV-L7Znay~4p-7{S? z+uok;ad*${O-@d%00IG#5kWD=68r}WjwLV&iui*>Hi1AwL?W3e;2;G^f|6juA3?T) zMSib7`fH~5b+O5-J1QarIYMXWuJl1b%yci_uh5?_2&cQ z%ilH(D+swaJTObQw))JAcHzuPt9{h>H)d7?zvB9B%gsIXJG#Sa+qZc&@;!pA@_ZS`mG}dp1Xg!`h7-ye?E8r zGWGkY`hJ5NK#!v?PrfD`m~ddife8mD9GGxm!hs0~CLEY>V8Ve32PPbtaNz%d0~P{) zI{W`83dC{#ujBup{Gwre8Tb{4RF9Od34+Aye#cR*z)P<&jBf*91fB$bANT;^04IPl z@Ot3Ct~QKs0M7wW1CIfJ2s{F~z;6Oez%+0L@cpYmEAS-n0bm1I0FDAT0XG6y0#^Xf zU1=Ea1x^CD0>2FW07;O)2R;jgz>UB&NPK)AI18)+E5I^v0;mJO4!j0<1__Y&0yhCS z0KWoU4g3g+mwyGm3w#Io4DdnV&A<)7uL86-&tFWUB(iHY$BPc$&bmA@Tb65iZC+Y% z9qvW9u(tRvvyhsFQQ&x8X4!VY!*H5iz!Dpb1w0xA9t($F+e9&lUD6NrtPO7Ztp|BK zIwFfWOsntIYE;Q_+&RYs6GP6o+y20d=4Ge#()4tt=bz)I6`KA=X?mt^$p)qx)||tT zgOCVG_n8`N&PY>BgPC11n(84pIXMsN^#mWX4L+oQrh8D2QMbXM9kDZ(>+%S*f0$Yl z2jr)KoXphGeZABlv|Oic;@@B_Z-al8w%;FO>SacJUgPaSz}Ez~OH-msW@>tx28)@! zld&AHKZr1=dI?XaACOC8_M;#}Tijkqg7`%=mZn+T_d=R5y2+8J=+Cn(nPJQ|5F!L7 z;hE-~k{{~2!NY+Y9cc)OY7YB+H45sbH0?q*)C8 zWJQCpR$B}LKPYkfJ5#4>B(u!auO8&z>T)v~gE4Cm`SL!yE5q&_$?4gM?nWt>OU;@0xb{NrDt+w=b5@<*YJ_~m*E}TeuaBO;JpOU08o$DvXR5Uv=8>!Hh zfVVjmskCo)R`jvC?zo(lpcPy`soDu6aABXa8Z`aVLjxWRrymxNN##w}nAnA-_N*Rf z$yKa;t;Sv6gB>#IJ~1W#C>o`o7Fuibwly@PBlvddxzb)ac%8(HEEUPsoFV2I+br~Q z-~A=Jme@SeLOx59E5{}(!@kw#YKi9z<1LQYb_X_RQ;}UAM2;I)`+g8rL#OLmZdh5L z8r$Y%KWwl1u4}bie$RjpI5iy87uXlLzGZW}s6jt+e2i3Zn+%{JVocv1EMPbcBi<`` zxM6v=UvzUt3>>af$zD*|f>kGZu;Fr)1Nxn87iiJ)+auS+ zQ*<@enN+Fjg4nFGPpDf>QA4-@%iXft8{;1rOE>oE#q-e?eJ@*KbQD%vbem$bEL&`X z{c^_`+cn)5d*Rr-$2mCXwACJ&BfCXoR>j{LlGSVvsk_-5;0Tpe&O{KHem^5}`VJH% zFEMU4a?J-r-^+GJqZ4FB6mhAj{ZlUG|TqfD*c(^=c5^AXCMT7tFQ_% zbl5%vr@J1p{j>Y-oWY;NtO?`M4Xhqp69OKx<>ggFwC)6ck3kez=nn#Dvd{wNcr04y ztRMLF6n5fu?x9uaGaEfcoH-F&=K-&XKKS`I7vc|B!Giw4N-@#z5PdSJYzUpKu%!;e z1>Hlm?u2aIlcLMkAQFwOfHTjJm=7THtEk7EjFESJ-%7ajFKg?EIRI4 zLyR85MZ@GWlwg1~-OTR@UJzqSA-odNo4QClAq+9d^1-424K0tYz<#f-Eyo1*eB0>^ z1!vI#+jJrjN@I$i&VnVq0bB~d1+Rd(e*DyFCWPH`*{X1l*s{~+*v)BOXsu{Ff+HES zjvt5%q9+iJg5V9&hae0@lJN!eLpckKsg_hz!8Nsbv=vyvup+5i!a%m|(6eP`h0J0! zq63QJB@+_)JgtYEV%9-W*@KVLxn=7Z7uo3NbSi=e{!m^4UNUYB+HSbbE_4h19V8m*P$uKRr&)QU(^HywyfOUP+w;Fjg&l>jTj zD$`s_Xf7n*7s@=%EN{qMC|#n%f&z$x@M*(!4A_z~dn~{#*ZfWdaydJOD8{x(c;*;~ zxFVict#qJ(2^}IJR0PZk6>mcq1DIaeqP0~S9 zYhq&G3ZQ}=mSeB7ilj~zqq>(F6#qYm`1B>jvK0Rx#TR`j_J11qW8g{PBS00n26!29 z|9=C|1K$9i1D*kVU=Q#-;{T_B4+3qV2`mGY7nlLcz*mtI_zLhj;2prfBQNkZ;A6m} zzSO>a*1-u#f6!HVN12+M00;MK%|RCaF`fv(P^=)}$P z%JI@-qp{MMW=D>|4>e_iu+)`N3w~lFRoMoejL6(8PG;z4D)~n#86Jm9BFUk1B&_I@ zNh5CCdbF2RMlq8nQzXsngeAq-*#zVC^fY)yACW@Pa}n%7q9IN?Y?~<6PbO(n!3dGi zV=Bv|7emEFagHYDyKbOYPg2$jxV4eyO3`9w7g6S<#I+pWol}b0AzD+`M#RT5BfLe5O!FWw2{NXx7YG|AxAc>W+M>LfZZ>{^Y(h=)Zp`0T zO4v3og@vk0a3##@Z~p(%QNMb6LaMb&|A3dxc_ZPF@9v zFYLkqrv`95C#si5g$UGBlN=b#LI4RRcTbQ`yGOM$ct);^h zb*h(Yg1v{BlUQoqS7v4D$Hm&SpMg{e4yvtF?-e^&ufW>eg)CgGwh`|YD?|Q}=bPZZ z_(!5dLa297KS^BvY;;XZbnawSuH85Z*Rv7}84IW4D_tD@$x|2mA-(`@aSL3iuT8N5Dsb4+A#>uLG_Eo<)rRQD6hO4EQ_5 z_#X!z0V1Fe*uV>j>AwYh6ZjBt6Yw%(`kw&b1UkSCz%K#U1OJ8?|D(X;Kn*wyPz}J> zfzJXD06#`-|Bt}?fp-J%0v-U~0sISM`%eNUa2B{1XaIKr40tW@1Y-U>foG8y`2=t; z&;afM=v@CroZG)2;K18}!@wbc&i3B~e0q;zybtIBU7!Oz0MJ=J@%b|sbCw^+9-|AK zzH-S*N@+_-{q8rvM7p=x{zU(@7f5?0l}uZ!qMc4Oj<>j1NC7Vx#9C!<5A2tm0p&7a zO8ldp5uIKp@$XlmA;wuMO-);=`L(shM$=rpr&Q!BARC{p0ZBp+RhwbPt1g&^Kil%{ zT#pJ`Y!hdUs9MpEbTjrSYBdosVAnU1*0oYa8}O&>oGq@PS|y~EeQCOaAUN%hYl7%| z7h_WP72RZ}F*1r)Ks`p0VrMtSIC9;pIk`IsF6JfU)edCnf#kRJQPV^u`?P8*lrXn? z>@IP$Pz-1d#1>eqspSP%)4>i-VbCNOb8F);dJD>!qhM5i^wZ<%-KEEv-@jvq=hjmW zDh)`w;AnITBKh)jSDEbU7fBCMublF+LX^}7nUKpQaHZZ8`BAb}7@?&`NwOm`qlJJe zA2PT0vGmb+V!2ah2cmL3bL1|qfEL5qGHb@OOBo2U@r+mqwP-t^lRSfhCE*duCOS?R z*$vl6Rt1hf{iOUFL@4p-#58H^S+w`xamT*HwVFITrCO^Ln;}~zYL%`lyO6q%WssFQ ziXqus;0db0X6mV{S{$|35G!}|$y1T9Zj0;Nii9h!Q7aX-0Il^>p5U^af-JT(<7zvD zh!!%CkLxh$`);|P%6_Ox?vpXfJLEy(%*U1d^*rA5J*Pc2t{_lrjG!A61*tn1F*(mu zeDj2;3pDi1QbI+ScHW^3i;EURN%R;wF0-l1RGD>9V8Qi_s#TojIuVE>o2Y8_;72i* zb)GDWh^J&=+@jlp6)iA=wrpL(sx638?^Z==v2Yc{6V}#GSeYjxoJfZqs#&FgI!@hc zE7*^?JyxzFJq%Q7$~w!0GTjFVRFcVi{b*>)>uT_k<}@GG ze6*oG==Du839C(~)Fw`XBR?3%Ga+I|cOE^K7)-ltaIX?0#PIof$P3BHf~fdX^@+kN z^((=^D_KFe4X-iio=clcY@lKqv1|#YM1(=ro+~GG+A=F_BNmthjDGl?p(=8;8MzHW zZKlK#K8jzcD@6-c>0*<>U05z@@5v)&qJNo}NIMxL6QH4qAuH*sKGp|UDgLK$^dS}h z>-YN~N31^sTn4;=c>dkMCNKaZpbq?litp#~{X@j^KLGv{_%Lt`_%-0`i0A42{#t-y z`mX_>1D*yx4ZIU*0egV=A(np-C;_(uROA2Wi02!?Vc-z32lx@<_#Xl<094Qa31A4E z2d028AclVwI1fa?+kgsC25tj>jM)A$;GKX2bb$_VGhhHuAjaHP1Ze+HZG!arVb9`)XI(2z(pNoMyrJ4=tU%6^_=9)#{In*rydBHOXTB_0xub~Opw>GE-!igL$9Y1_PSa?Xc>6mGC` zlS=B!(^gn7mR3Sq@#5$-BSYYhIV1fy>Da3N z#yM+Q&q7#+QTMReq0+9PrnSrtrrg8}g~owO$h-+bw2lg8YU$c zB{zSh6>vwfSdwyK3clC{(36Rs(`H%RQ$gwU!{T)^%`o-73%=!^EdDtfitZrZ6mtf> zyE3xbXmfO2^=cbs5O*cJnP6zt2$AL3-g>AwkzR=!XOSX*TDub?;m$bT?!@Hgw`z=m zD5Xd5KWWm(&aOWZ{Hk?j^C9%9}D; zzVD*iT<_FdEs`cqdqc{Rz^fm`!!#MTzv;EfCB*+h-YxCbql-Dn0GQ@>i#$Js9>Y}% l$#l_5RuoTUT}-NOZBFF}$WTeCkWUHcbeztMYp?zl{9jLB+)V%g literal 0 HcmV?d00001 diff --git a/submodules/ton/tonlib-src/tonlib/test/offline.cpp b/submodules/ton/tonlib-src/tonlib/test/offline.cpp index 5d41803417..d5d86dba24 100644 --- a/submodules/ton/tonlib-src/tonlib/test/offline.cpp +++ b/submodules/ton/tonlib-src/tonlib/test/offline.cpp @@ -172,16 +172,17 @@ TEST(Tonlib, InitClose) { { Client client; sync_send(client, make_object()).ensure(); - sync_send(client, make_object(make_object("", "."))).ensure_error(); + sync_send(client, make_object(make_object("", ".", false))).ensure_error(); } { Client client; sync_send(client, make_object(nullptr)).ensure_error(); - sync_send(client, make_object(make_object("fdajkfldsjkafld", "."))) + sync_send(client, make_object(make_object("fdajkfldsjkafld", ".", false))) .ensure_error(); - sync_send(client, make_object(make_object("", "fdhskfds"))).ensure_error(); - sync_send(client, make_object(make_object("", "."))).ensure(); - sync_send(client, make_object(make_object("", "."))).ensure_error(); + sync_send(client, make_object(make_object("", "fdhskfds", false))) + .ensure_error(); + sync_send(client, make_object(make_object("", ".", false))).ensure(); + sync_send(client, make_object(make_object("", ".", false))).ensure_error(); td::Slice bad_config = R"abc( { @@ -194,7 +195,7 @@ TEST(Tonlib, InitClose) { sync_send(client, make_object()).ensure_error(); sync_send(client, make_object()).ensure(); sync_send(client, make_object()).ensure_error(); - sync_send(client, make_object(make_object("", "."))).ensure_error(); + sync_send(client, make_object(make_object("", ".", false))).ensure_error(); } } @@ -289,7 +290,7 @@ TEST(Tonlib, KeysApi) { Client client; // init - sync_send(client, make_object(make_object("", "."))).ensure(); + sync_send(client, make_object(make_object("", ".", false))).ensure(); auto local_password = td::SecureString("local password"); auto mnemonic_password = td::SecureString("mnemonic password"); { diff --git a/submodules/ton/tonlib-src/tonlib/test/online.cpp b/submodules/ton/tonlib-src/tonlib/test/online.cpp index 89a9eaa7d4..8f5a73e9a0 100644 --- a/submodules/ton/tonlib-src/tonlib/test/online.cpp +++ b/submodules/ton/tonlib-src/tonlib/test/online.cpp @@ -170,12 +170,12 @@ void dump_transaction_history(Client& client, std::string address) { make_object(address), std::move(tid))) .move_as_ok(); CHECK(got_transactions->transactions_.size() > 0); - CHECK(got_transactions->transactions_[0]->previous_transaction_id_->lt_ < lt); + CHECK(got_transactions->previous_transaction_id_->lt_ < lt); for (auto& txn : got_transactions->transactions_) { LOG(ERROR) << to_string(txn); cnt++; } - tid = std::move(got_transactions->transactions_.back()->previous_transaction_id_); + tid = std::move(got_transactions->previous_transaction_id_); } LOG(ERROR) << cnt; } @@ -196,7 +196,8 @@ int main(int argc, char* argv[]) { Client client; { - sync_send(client, make_object(make_object(global_config_str, "."))).ensure(); + sync_send(client, make_object(make_object(global_config_str, ".", false))) + .ensure(); } //dump_transaction_history(client, get_test_giver_address(client)); auto wallet_a = create_wallet(client); @@ -208,7 +209,8 @@ int main(int argc, char* argv[]) { return 0; { // init - sync_send(client, make_object(make_object(global_config_str, "."))).ensure(); + sync_send(client, make_object(make_object(global_config_str, ".", false))) + .ensure(); auto key = sync_send(client, make_object( td::SecureString("local"), td::SecureString("mnemonic"), td::SecureString())) diff --git a/submodules/ton/tonlib-src/tonlib/tonlib/BlockchainInfoStorage.cpp b/submodules/ton/tonlib-src/tonlib/tonlib/BlockchainInfoStorage.cpp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/submodules/ton/tonlib-src/tonlib/tonlib/BlockchainInfoStorage.h b/submodules/ton/tonlib-src/tonlib/tonlib/BlockchainInfoStorage.h new file mode 100644 index 0000000000..4a249cffa2 --- /dev/null +++ b/submodules/ton/tonlib-src/tonlib/tonlib/BlockchainInfoStorage.h @@ -0,0 +1,11 @@ +#pragma once + +#include "tonlib/LastBlock.h" + +namespace tonlib { +class BlockchainInfoStorage { + td::Status set_directory(std::string directory); + td::Result get_state(ZeroStateIdExt); + void save_state(LastBlock::State state); +}; +} // namespace tonlib diff --git a/submodules/ton/tonlib-src/tonlib/tonlib/ExtClient.cpp b/submodules/ton/tonlib-src/tonlib/tonlib/ExtClient.cpp index 56ba74772a..5633363dab 100644 --- a/submodules/ton/tonlib-src/tonlib/tonlib/ExtClient.cpp +++ b/submodules/ton/tonlib-src/tonlib/tonlib/ExtClient.cpp @@ -21,10 +21,10 @@ #include "tonlib/LastBlock.h" namespace tonlib { -void ExtClient::with_last_block(td::Promise promise) { +void ExtClient::with_last_block(td::Promise promise) { auto query_id = last_block_queries_.create(std::move(promise)); - td::Promise P = [query_id, self = this, - actor_id = td::actor::actor_id()](td::Result result) { + td::Promise P = [query_id, self = this, + actor_id = td::actor::actor_id()](td::Result result) { send_lambda(actor_id, [self, query_id, result = std::move(result)]() mutable { self->last_block_queries_.extract(query_id).set_result(std::move(result)); }); diff --git a/submodules/ton/tonlib-src/tonlib/tonlib/ExtClient.h b/submodules/ton/tonlib-src/tonlib/tonlib/ExtClient.h index bacc473ec1..8f92ea9e1b 100644 --- a/submodules/ton/tonlib-src/tonlib/tonlib/ExtClient.h +++ b/submodules/ton/tonlib-src/tonlib/tonlib/ExtClient.h @@ -29,6 +29,7 @@ namespace tonlib { class LastBlock; +struct LastBlockInfo; struct ExtClientRef { td::actor::ActorId andl_ext_client_; td::actor::ActorId last_block_actor_; @@ -49,7 +50,7 @@ class ExtClient { return client_; } - void with_last_block(td::Promise promise); + void with_last_block(td::Promise promise); template void send_query(QueryT query, td::Promise promise) { @@ -74,7 +75,7 @@ class ExtClient { private: ExtClientRef client_; td::Container> queries_; - td::Container> last_block_queries_; + td::Container> last_block_queries_; void send_raw_query(td::BufferSlice query, td::Promise promise); }; diff --git a/submodules/ton/tonlib-src/tonlib/tonlib/ExtClientOutbound.cpp b/submodules/ton/tonlib-src/tonlib/tonlib/ExtClientOutbound.cpp new file mode 100644 index 0000000000..a20a8c59f2 --- /dev/null +++ b/submodules/ton/tonlib-src/tonlib/tonlib/ExtClientOutbound.cpp @@ -0,0 +1,66 @@ + +/* + This file is part of TON Blockchain Library. + + TON Blockchain Library is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + TON Blockchain Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with TON Blockchain Library. If not, see . + + Copyright 2017-2019 Telegram Systems LLP +*/ +#include "ExtClientOutbound.h" +#include +namespace tonlib { + +class ExtClientOutboundImp : public ExtClientOutbound { + public: + ExtClientOutboundImp(td::unique_ptr callback) : callback_(std::move(callback)) { + } + + void check_ready(td::Promise promise) override { + promise.set_error(td::Status::Error("Not supported")); + } + + void send_query(std::string name, td::BufferSlice data, td::Timestamp timeout, + td::Promise promise) override { + auto query_id = next_query_id_++; + queries_[query_id] = std::move(promise); + callback_->request(query_id, data.as_slice().str()); + } + + void on_query_result(td::int64 id, td::Result r_data, td::Promise promise) override { + auto it = queries_.find(id); + if (it == queries_.end()) { + promise.set_error(td::Status::Error(400, "Unknown query id")); + } + it->second.set_result(std::move(r_data)); + queries_.erase(it); + promise.set_value(td::Unit()); + } + + private: + td::unique_ptr callback_; + td::int64 next_query_id_{1}; + std::map> queries_; + + void tear_down() override { + for (auto &it : queries_) { + it.second.set_error(td::Status::Error(400, "Query cancelled")); + } + queries_.clear(); + } +}; + +td::actor::ActorOwn ExtClientOutbound::create(td::unique_ptr callback) { + return td::actor::create_actor("ExtClientOutbound", std::move(callback)); +} +} // namespace tonlib diff --git a/submodules/ton/tonlib-src/tonlib/tonlib/ExtClientOutbound.h b/submodules/ton/tonlib-src/tonlib/tonlib/ExtClientOutbound.h new file mode 100644 index 0000000000..3635fd1a0f --- /dev/null +++ b/submodules/ton/tonlib-src/tonlib/tonlib/ExtClientOutbound.h @@ -0,0 +1,37 @@ +/* + This file is part of TON Blockchain Library. + + TON Blockchain Library is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + TON Blockchain Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with TON Blockchain Library. If not, see . + + Copyright 2017-2019 Telegram Systems LLP +*/ +#pragma once +#include "td/actor/actor.h" + +#include "adnl/adnl-ext-client.h" + +namespace tonlib { +class ExtClientOutbound : public ton::adnl::AdnlExtClient { + public: + class Callback { + public: + virtual ~Callback() { + } + virtual void request(td::int64 id, std::string data) = 0; + }; + virtual void on_query_result(td::int64 id, td::Result r_data, td::Promise promise) = 0; + static td::actor::ActorOwn create(td::unique_ptr callback); +}; + +} // namespace tonlib diff --git a/submodules/ton/tonlib-src/tonlib/tonlib/LastBlock.cpp b/submodules/ton/tonlib-src/tonlib/tonlib/LastBlock.cpp index 16eb3eb7e2..f4754023c9 100644 --- a/submodules/ton/tonlib-src/tonlib/tonlib/LastBlock.cpp +++ b/submodules/ton/tonlib-src/tonlib/tonlib/LastBlock.cpp @@ -23,15 +23,12 @@ #include "lite-client/lite-client-common.h" namespace tonlib { -LastBlock::LastBlock(ExtClientRef client, ton::ZeroStateIdExt zero_state_id, ton::BlockIdExt last_block_id, - td::actor::ActorShared<> parent) { - zero_state_id_ = std::move(zero_state_id); - mc_last_block_id_ = std::move(last_block_id); +LastBlock::LastBlock(ExtClientRef client, State state, td::unique_ptr callback) + : state_(std::move(state)), callback_(std::move(callback)) { client_.set_client(client); - parent_ = std::move(parent); } -void LastBlock::get_last_block(td::Promise promise) { +void LastBlock::get_last_block(td::Promise promise) { if (promises_.empty()) { do_get_last_block(); } @@ -39,13 +36,16 @@ void LastBlock::get_last_block(td::Promise promise) { } void LastBlock::do_get_last_block() { - client_.send_query(ton::lite_api::liteServer_getMasterchainInfo(), - [this](auto r_info) { this->on_masterchain_info(std::move(r_info)); }); - return; + //client_.send_query(ton::lite_api::liteServer_getMasterchainInfo(), + //[this](auto r_info) { this->on_masterchain_info(std::move(r_info)); }); + //return; + //liteServer.getBlockProof mode:# known_block:tonNode.blockIdExt target_block:mode.0?tonNode.blockIdExt = liteServer.PartialBlockProof; client_.send_query( - ton::lite_api::liteServer_getBlockProof(0, create_tl_lite_block_id(mc_last_block_id_), nullptr), - [this, from = mc_last_block_id_](auto r_block_proof) { this->on_block_proof(from, std::move(r_block_proof)); }); + ton::lite_api::liteServer_getBlockProof(0, create_tl_lite_block_id(state_.last_key_block_id), nullptr), + [this, from = state_.last_key_block_id](auto r_block_proof) { + this->on_block_proof(from, std::move(r_block_proof)); + }); } td::Result LastBlock::process_block_proof( @@ -60,6 +60,12 @@ td::Result LastBlock::process_block_proof( } TRY_STATUS(chain->validate()); update_mc_last_block(chain->to); + if (chain->has_key_block) { + update_mc_last_key_block(chain->key_blkid); + } + if (chain->has_utime) { + update_utime(chain->last_utime); + } return chain->complete; } @@ -68,14 +74,16 @@ void LastBlock::on_block_proof( td::Result> r_block_proof) { auto r_is_ready = process_block_proof(from, std::move(r_block_proof)); if (r_is_ready.is_error()) { - LOG(WARNING) << "Failed liteServer_getBlockProof " << r_block_proof.error(); + LOG(WARNING) << "Failed liteServer_getBlockProof " << r_is_ready.error(); return; } auto is_ready = r_is_ready.move_as_ok(); if (is_ready) { for (auto& promise : promises_) { - auto copy = mc_last_block_id_; - promise.set_value(std::move(copy)); + LastBlockInfo res; + res.id = state_.last_block_id; + res.utime = state_.utime; + promise.set_value(std::move(res)); } promises_.clear(); } else { @@ -93,8 +101,10 @@ void LastBlock::on_masterchain_info( LOG(WARNING) << "Failed liteServer_getMasterchainInfo " << r_info.error(); } for (auto& promise : promises_) { - auto copy = mc_last_block_id_; - promise.set_value(std::move(copy)); + LastBlockInfo res; + res.id = state_.last_block_id; + res.utime = state_.utime; + promise.set_value(std::move(res)); } promises_.clear(); } @@ -105,17 +115,17 @@ void LastBlock::update_zero_state(ton::ZeroStateIdExt zero_state_id) { return; } - if (!zero_state_id_.is_valid()) { + if (!state_.zero_state_id.is_valid()) { LOG(INFO) << "Init zerostate: " << zero_state_id.to_str(); - zero_state_id_ = std::move(zero_state_id); + state_.zero_state_id = std::move(zero_state_id); return; } - if (zero_state_id_ == zero_state_id_) { + if (state_.zero_state_id == state_.zero_state_id) { return; } - LOG(FATAL) << "Masterchain zerostate mismatch: expected: " << zero_state_id_.to_str() << ", found " + LOG(FATAL) << "Masterchain zerostate mismatch: expected: " << state_.zero_state_id.to_str() << ", found " << zero_state_id.to_str(); // TODO: all other updates will be inconsitent. // One will have to restart ton client @@ -126,9 +136,25 @@ void LastBlock::update_mc_last_block(ton::BlockIdExt mc_block_id) { LOG(ERROR) << "Ignore invalid masterchain block"; return; } - if (!mc_last_block_id_.is_valid() || mc_last_block_id_.id.seqno < mc_block_id.id.seqno) { - mc_last_block_id_ = mc_block_id; - LOG(INFO) << "Update masterchain block id: " << mc_last_block_id_.to_str(); + if (!state_.last_block_id.is_valid() || state_.last_block_id.id.seqno < mc_block_id.id.seqno) { + state_.last_block_id = mc_block_id; + LOG(INFO) << "Update masterchain block id: " << state_.last_block_id.to_str(); + } +} +void LastBlock::update_mc_last_key_block(ton::BlockIdExt mc_key_block_id) { + if (!mc_key_block_id.is_valid()) { + LOG(ERROR) << "Ignore invalid masterchain block"; + return; + } + if (!state_.last_key_block_id.is_valid() || state_.last_key_block_id.id.seqno < mc_key_block_id.id.seqno) { + state_.last_key_block_id = mc_key_block_id; + LOG(INFO) << "Update masterchain key block id: " << state_.last_key_block_id.to_str(); + } +} + +void LastBlock::update_utime(td::int64 utime) { + if (state_.utime < utime) { + state_.utime = utime; } } } // namespace tonlib diff --git a/submodules/ton/tonlib-src/tonlib/tonlib/LastBlock.h b/submodules/ton/tonlib-src/tonlib/tonlib/LastBlock.h index 79a6527705..968f21bddb 100644 --- a/submodules/ton/tonlib-src/tonlib/tonlib/LastBlock.h +++ b/submodules/ton/tonlib-src/tonlib/tonlib/LastBlock.h @@ -22,21 +22,35 @@ #include "tonlib/ExtClient.h" namespace tonlib { +struct LastBlockInfo { + ton::BlockIdExt id; + td::int64 utime{0}; +}; class LastBlock : public td::actor::Actor { public: - explicit LastBlock(ExtClientRef client, ton::ZeroStateIdExt zero_state_id, ton::BlockIdExt last_block_id, - td::actor::ActorShared<> parent); + struct State { + ton::ZeroStateIdExt zero_state_id; + ton::BlockIdExt last_key_block_id; + ton::BlockIdExt last_block_id; + td::int64 utime{0}; + }; - void get_last_block(td::Promise promise); + class Callback { + public: + virtual ~Callback() { + } + virtual void on_state_changes(State state) = 0; + }; + + explicit LastBlock(ExtClientRef client, State state, td::unique_ptr callback); + void get_last_block(td::Promise promise); private: ExtClient client_; - ton::ZeroStateIdExt zero_state_id_; - ton::BlockIdExt mc_last_block_id_; + State state_; + td::unique_ptr callback_; - std::vector> promises_; - - td::actor::ActorShared<> parent_; + std::vector> promises_; void do_get_last_block(); void on_masterchain_info(td::Result> r_info); @@ -49,5 +63,7 @@ class LastBlock : public td::actor::Actor { void update_zero_state(ton::ZeroStateIdExt zero_state_id); void update_mc_last_block(ton::BlockIdExt mc_block_id); + void update_mc_last_key_block(ton::BlockIdExt mc_key_block_id); + void update_utime(td::int64 utime); }; } // namespace tonlib diff --git a/submodules/ton/tonlib-src/tonlib/tonlib/TonlibClient.cpp b/submodules/ton/tonlib-src/tonlib/tonlib/TonlibClient.cpp index 489abb6e7b..7b48876f93 100644 --- a/submodules/ton/tonlib-src/tonlib/tonlib/TonlibClient.cpp +++ b/submodules/ton/tonlib-src/tonlib/tonlib/TonlibClient.cpp @@ -19,6 +19,7 @@ #include "TonlibClient.h" #include "tonlib/ExtClientLazy.h" +#include "tonlib/ExtClientOutbound.h" #include "tonlib/GenericAccount.h" #include "tonlib/LastBlock.h" #include "tonlib/TestWallet.h" @@ -73,6 +74,7 @@ struct RawAccountState { td::Ref code; td::Ref data; block::AccountState::Info info; + td::int64 sync_utime = 0; }; td::Result to_balance_or_throw(td::Ref balance_ref) { @@ -169,7 +171,7 @@ class GetRawAccountState : public td::actor::Actor { block::StdAddress address_; td::Promise promise_; ExtClient client_; - ton::BlockIdExt last_block_; + LastBlockInfo last_block_; void with_account_state(td::Result> r_account_state) { promise_.set_result(TRY_VM(do_with_account_state(std::move(r_account_state)))); @@ -180,10 +182,11 @@ class GetRawAccountState : public td::actor::Actor { td::Result> r_account_state) { TRY_RESULT(raw_account_state, std::move(r_account_state)); auto account_state = create_account_state(std::move(raw_account_state)); - TRY_RESULT(info, account_state.validate(last_block_, address_)); + TRY_RESULT(info, account_state.validate(last_block_.id, address_)); auto serialized_state = account_state.state.clone(); RawAccountState res; res.info = std::move(info); + res.sync_utime = last_block_.utime; auto cell = res.info.root; if (cell.is_null()) { return res; @@ -222,14 +225,14 @@ class GetRawAccountState : public td::actor::Actor { } void start_up() override { - client_.with_last_block([self = this](td::Result r_last_block) { + client_.with_last_block([self = this](td::Result r_last_block) { if (r_last_block.is_error()) { return self->check(r_last_block.move_as_error()); } self->last_block_ = r_last_block.move_as_ok(); self->client_.send_query( - ton::lite_api::liteServer_getAccountState(ton::create_tl_lite_block_id(self->last_block_), + ton::lite_api::liteServer_getAccountState(ton::create_tl_lite_block_id(self->last_block_.id), ton::create_tl_object( self->address_.workchain, self->address_.addr)), [self](auto r_state) { self->with_account_state(std::move(r_state)); }); @@ -263,28 +266,68 @@ ExtClientRef TonlibClient::get_client_ref() { return ref; } + +void TonlibClient::proxy_request(td::int64 query_id, std::string data) { + callback_->on_result(0, tonlib_api::make_object(query_id, data)); +} + void TonlibClient::init_ext_client() { - auto lite_clients_size = config_.lite_clients.size(); - CHECK(lite_clients_size != 0); - auto lite_client_id = td::Random::fast(0, td::narrow_cast(lite_clients_size) - 1); - auto& lite_client = config_.lite_clients[lite_client_id]; - class Callback : public ExtClientLazy::Callback { + if (use_callbacks_for_network_) { + class Callback : public ExtClientOutbound::Callback { + public: + explicit Callback(td::actor::ActorShared parent) : parent_(std::move(parent)) { + } + + void request(td::int64 id, std::string data) override { + send_closure(parent_, &TonlibClient::proxy_request, id, std::move(data)); + } + + private: + td::actor::ActorShared parent_; + }; + ref_cnt_++; + auto client = ExtClientOutbound::create(td::make_unique(td::actor::actor_shared(this))); + ext_client_outbound_ = client.get(); + raw_client_ = std::move(client); + } else { + auto lite_clients_size = config_.lite_clients.size(); + CHECK(lite_clients_size != 0); + auto lite_client_id = td::Random::fast(0, td::narrow_cast(lite_clients_size) - 1); + auto& lite_client = config_.lite_clients[lite_client_id]; + class Callback : public ExtClientLazy::Callback { + public: + explicit Callback(td::actor::ActorShared<> parent) : parent_(std::move(parent)) { + } + + private: + td::actor::ActorShared<> parent_; + }; + ref_cnt_++; + raw_client_ = ExtClientLazy::create(lite_client.adnl_id, lite_client.address, + td::make_unique(td::actor::actor_shared())); + } +} +void TonlibClient::init_last_block() { + ref_cnt_++; + class Callback : public LastBlock::Callback { public: - explicit Callback(td::actor::ActorShared<> parent) : parent_(std::move(parent)) { + Callback(td::actor::ActorShared client) : client_(std::move(client)) { + } + void on_state_changes(LastBlock::State state) override { + //TODO } private: - td::actor::ActorShared<> parent_; + td::actor::ActorShared client_; }; - ref_cnt_++; - raw_client_ = ExtClientLazy::create(lite_client.adnl_id, lite_client.address, - td::make_unique(td::actor::actor_shared())); - ref_cnt_++; - raw_last_block_ = td::actor::create_actor( - "LastBlock", get_client_ref(), - ton::ZeroStateIdExt(config_.zero_state_id.id.workchain, config_.zero_state_id.root_hash, - config_.zero_state_id.file_hash), - config_.zero_state_id, td::actor::actor_shared()); + LastBlock::State state; + //state.zero_state_id = ton::ZeroStateIdExt(config_.zero_state_id.id.workchain, config_.zero_state_id.root_hash, + //config_.zero_state_id.file_hash), + state.last_block_id = config_.zero_state_id; + state.last_key_block_id = config_.zero_state_id; + + raw_last_block_ = td::actor::create_actor("LastBlock", get_client_ref(), std::move(state), + td::make_unique(td::actor::actor_shared(this))); client_.set_client(get_client_ref()); } @@ -426,6 +469,7 @@ td::Status TonlibClient::do_request(const tonlib_api::init& request, return td::Status::Error(400, "Field options must not be empty"); } TRY_STATUS(key_storage_.set_directory(request.options_->keystore_directory_)); + use_callbacks_for_network_ = request.options_->use_callbacks_for_network_; if (!request.options_->config_.empty()) { TRY_STATUS(set_config(std::move(request.options_->config_))); } @@ -444,6 +488,7 @@ td::Status TonlibClient::set_config(std::string config) { } config_ = std::move(new_config); init_ext_client(); + init_last_block(); return td::Status::OK(); } @@ -454,6 +499,7 @@ td::Status TonlibClient::do_request(const tonlib_api::close& request, promise.set_value(tonlib_api::make_object()); return td::Status::OK(); } + td::Status TonlibClient::do_request(const tonlib_api::options_setConfig& request, td::Promise>&& promise) { TRY_STATUS(set_config(request.config_)); @@ -461,6 +507,10 @@ td::Status TonlibClient::do_request(const tonlib_api::options_setConfig& request return td::Status::OK(); } +tonlib_api::object_ptr empty_transaction_id() { + return tonlib_api::make_object(0, std::string(32, 0)); +} + tonlib_api::object_ptr to_transaction_id(const block::AccountState::Info& info) { return tonlib_api::make_object(info.last_trans_lt, info.last_trans_hash.as_slice().str()); @@ -482,7 +532,7 @@ td::Result> to_raw_accountS .str(); } return tonlib_api::make_object(raw_state.balance, std::move(code), std::move(data), - to_transaction_id(raw_state.info)); + to_transaction_id(raw_state.info), raw_state.sync_utime); } td::Result to_std_address_or_throw(td::Ref cs) { @@ -591,7 +641,7 @@ td::Result> to_raw_transacti } } return tonlib_api::make_object( - data, + info.now, data, tonlib_api::make_object(info.prev_trans_lt, info.prev_trans_hash.as_slice().str()), fees, std::move(in_msg), std::move(out_msgs)); @@ -608,7 +658,14 @@ td::Result> to_raw_transact TRY_RESULT(raw_transaction, to_raw_transaction(std::move(transaction))); transactions.push_back(std::move(raw_transaction)); } - return tonlib_api::make_object(std::move(transactions)); + + auto transaction_id = + tonlib_api::make_object(info.lt, info.hash.as_slice().str()); + for (auto& transaction : transactions) { + std::swap(transaction->transaction_id_, transaction_id); + } + + return tonlib_api::make_object(std::move(transactions), std::move(transaction_id)); } td::Result> to_testWallet_accountState( @@ -622,8 +679,8 @@ td::Result> to_testW if (seqno == cs.fetch_ulong_eof) { return td::Status::Error("Failed to parse seq_no"); } - return tonlib_api::make_object(raw_state.balance, static_cast(seqno), - to_transaction_id(raw_state.info)); + return tonlib_api::make_object( + raw_state.balance, static_cast(seqno), to_transaction_id(raw_state.info), raw_state.sync_utime); } td::Result> to_testGiver_accountState( @@ -637,15 +694,16 @@ td::Result> to_testGi if (seqno == cs.fetch_ulong_eof) { return td::Status::Error("Failed to parse seq_no"); } - return tonlib_api::make_object(raw_state.balance, static_cast(seqno), - to_transaction_id(raw_state.info)); + return tonlib_api::make_object( + raw_state.balance, static_cast(seqno), to_transaction_id(raw_state.info), raw_state.sync_utime); } td::Result> to_generic_accountState( RawAccountState&& raw_state) { if (raw_state.code.is_null()) { return tonlib_api::make_object( - tonlib_api::make_object(raw_state.balance)); + tonlib_api::make_object(raw_state.balance, empty_transaction_id(), + raw_state.sync_utime)); } auto code_hash = raw_state.code->prefetch_ref()->get_hash(); @@ -1019,4 +1077,30 @@ td::Status TonlibClient::do_request(const tonlib_api::changeLocalPassword& reque return td::Status::OK(); } +td::Status TonlibClient::do_request(const tonlib_api::onLiteServerQueryResult& request, + td::Promise>&& promise) { + send_closure(ext_client_outbound_, &ExtClientOutbound::on_query_result, request.id_, td::BufferSlice(request.bytes_), + [promise = std::move(promise)](td::Result res) mutable { + if (res.is_ok()) { + promise.set_value(tonlib_api::make_object()); + } else { + promise.set_error(res.move_as_error()); + } + }); + return td::Status::OK(); +} +td::Status TonlibClient::do_request(const tonlib_api::onLiteServerQueryError& request, + td::Promise>&& promise) { + send_closure(ext_client_outbound_, &ExtClientOutbound::on_query_result, request.id_, + td::Status::Error(request.error_->code_, request.error_->message_), + [promise = std::move(promise)](td::Result res) mutable { + if (res.is_ok()) { + promise.set_value(tonlib_api::make_object()); + } else { + promise.set_error(res.move_as_error()); + } + }); + return td::Status::OK(); +} + } // namespace tonlib diff --git a/submodules/ton/tonlib-src/tonlib/tonlib/TonlibClient.h b/submodules/ton/tonlib-src/tonlib/tonlib/TonlibClient.h index 244506c850..0e36a28921 100644 --- a/submodules/ton/tonlib-src/tonlib/tonlib/TonlibClient.h +++ b/submodules/ton/tonlib-src/tonlib/tonlib/TonlibClient.h @@ -22,6 +22,7 @@ #include "tonlib/Config.h" #include "tonlib/ExtClient.h" +#include "tonlib/ExtClientOutbound.h" #include "tonlib/KeyStorage.h" #include "td/actor/actor.h" @@ -44,6 +45,9 @@ class TonlibClient : public td::actor::Actor { td::unique_ptr callback_; Config config_; + bool use_callbacks_for_network_{false}; + td::actor::ActorId ext_client_outbound_; + // KeyStorage KeyStorage key_storage_; @@ -54,6 +58,7 @@ class TonlibClient : public td::actor::Actor { ExtClientRef get_client_ref(); void init_ext_client(); + void init_last_block(); bool is_closing_{false}; td::uint32 ref_cnt_{1}; @@ -130,5 +135,12 @@ class TonlibClient : public td::actor::Actor { td::Status do_request(const tonlib_api::changeLocalPassword& request, td::Promise>&& promise); + + td::Status do_request(const tonlib_api::onLiteServerQueryResult& request, + td::Promise>&& promise); + td::Status do_request(const tonlib_api::onLiteServerQueryError& request, + td::Promise>&& promise); + + void proxy_request(td::int64 query_id, std::string data); }; } // namespace tonlib diff --git a/submodules/ton/tonlib-src/tonlib/tonlib/tonlib-cli.cpp b/submodules/ton/tonlib-src/tonlib/tonlib/tonlib-cli.cpp index 8de1133fbe..cdbec51be9 100644 --- a/submodules/ton/tonlib-src/tonlib/tonlib/tonlib-cli.cpp +++ b/submodules/ton/tonlib-src/tonlib/tonlib/tonlib-cli.cpp @@ -5,12 +5,17 @@ #include "td/utils/Parser.h" #include "td/utils/port/signals.h" #include "td/utils/port/path.h" +#include "td/utils/Random.h" #include "terminal/terminal.h" #include "tonlib/TonlibClient.h" #include "tonlib/TonlibCallback.h" +#include "tonlib/ExtClientLazy.h" + +#include "auto/tl/tonlib_api.hpp" + #include #include @@ -20,6 +25,7 @@ class TonlibCli : public td::actor::Actor { bool enable_readline{true}; std::string config; std::string key_dir{"."}; + bool use_callbacks_for_network{false}; }; TonlibCli(Options options) : options_(std::move(options)) { } @@ -39,6 +45,8 @@ class TonlibCli : public td::actor::Actor { std::map>> query_handlers_; + td::actor::ActorOwn raw_client_; + bool is_closing_{false}; td::uint32 ref_cnt_{1}; @@ -79,8 +87,28 @@ class TonlibCli : public td::actor::Actor { load_keys(); + if (options_.use_callbacks_for_network) { + auto config = tonlib::Config::parse(options_.config).move_as_ok(); + auto lite_clients_size = config.lite_clients.size(); + CHECK(lite_clients_size != 0); + auto lite_client_id = td::Random::fast(0, td::narrow_cast(lite_clients_size) - 1); + auto& lite_client = config.lite_clients[lite_client_id]; + class Callback : public tonlib::ExtClientLazy::Callback { + public: + explicit Callback(td::actor::ActorShared<> parent) : parent_(std::move(parent)) { + } + + private: + td::actor::ActorShared<> parent_; + }; + ref_cnt_++; + raw_client_ = tonlib::ExtClientLazy::create(lite_client.adnl_id, lite_client.address, + td::make_unique(td::actor::actor_shared())); + } + using tonlib_api::make_object; - send_query(make_object(make_object(options_.config, options_.key_dir)), + send_query(make_object(make_object(options_.config, options_.key_dir, + options_.use_callbacks_for_network)), [](auto r_ok) { LOG_IF(ERROR, r_ok.is_error()) << r_ok.error(); td::TerminalIO::out() << "Tonlib is inited\n"; @@ -121,6 +149,8 @@ class TonlibCli : public td::actor::Actor { td::TerminalIO::out() << "exportkey [key_id] - export key\n"; td::TerminalIO::out() << "setconfig - set lite server config\n"; td::TerminalIO::out() << "getstate - get state of simple wallet with requested key\n"; + td::TerminalIO::out() + << "gethistory - get history fo simple wallet with requested key (last 10 transactions)\n"; td::TerminalIO::out() << "init - init simple wallet with requested key\n"; td::TerminalIO::out() << "transfer - transfer of grams from " " to .\n" @@ -145,6 +175,8 @@ class TonlibCli : public td::actor::Actor { set_config(parser.read_word()); } else if (cmd == "getstate") { get_state(parser.read_word()); + } else if (cmd == "gethistory") { + get_history(parser.read_word()); } else if (cmd == "init") { init_simple_wallet(parser.read_word()); } else if (cmd == "transfer") { @@ -157,7 +189,31 @@ class TonlibCli : public td::actor::Actor { } } + void on_adnl_result(td::uint64 id, td::Result res) { + using tonlib_api::make_object; + if (res.is_ok()) { + send_query(make_object(id, res.move_as_ok().as_slice().str()), + [](auto r_ok) { LOG_IF(ERROR, r_ok.is_error()) << r_ok.error(); }); + LOG(ERROR) << "!!!"; + } else { + send_query(make_object( + id, make_object(res.error().code(), res.error().message().str())), + [](auto r_ok) { LOG_IF(ERROR, r_ok.is_error()) << r_ok.error(); }); + } + } + void on_tonlib_result(std::uint64_t id, tonlib_api::object_ptr result) { + if (id == 0) { + if (result->get_id() == tonlib_api::updateSendLiteServerQuery::ID) { + auto update = tonlib_api::move_object_as(std::move(result)); + CHECK(!raw_client_.empty()); + send_closure(raw_client_, &ton::adnl::AdnlExtClient::send_query, "query", td::BufferSlice(update->data_), + td::Timestamp::in(5), + [actor_id = actor_id(this), id = update->id_](td::Result res) { + send_closure(actor_id, &TonlibCli::on_adnl_result, id, std::move(res)); + }); + } + } auto it = query_handlers_.find(id); if (it == query_handlers_.end()) { return; @@ -468,6 +524,53 @@ class TonlibCli : public td::actor::Actor { td::TerminalIO::out() << to_string(r_res.ok()); }); } + void get_history(td::Slice key) { + if (key.empty()) { + dump_keys(); + td::TerminalIO::out() << "Choose public key (hex prefix or #N)"; + cont_ = [this](td::Slice key) { this->get_state(key); }; + return; + } + auto r_address = to_account_address(key, false); + if (r_address.is_error()) { + td::TerminalIO::out() << "Unknown key id: [" << key << "]\n"; + return; + } + auto address = r_address.move_as_ok(); + using tonlib_api::make_object; + send_query(make_object( + ton::move_tl_object_as(std::move(address.address))), + [this, key = key.str()](auto r_res) { + if (r_res.is_error()) { + td::TerminalIO::out() << "Can't get state: " << r_res.error() << "\n"; + return; + } + this->get_history(key, *r_res.move_as_ok()); + }); + } + + void get_history(td::Slice key, tonlib_api::generic_AccountState& state) { + auto r_address = to_account_address(key, false); + if (r_address.is_error()) { + td::TerminalIO::out() << "Unknown key id: [" << key << "]\n"; + return; + } + auto address = r_address.move_as_ok(); + + tonlib_api::object_ptr transaction_id; + downcast_call(state, [&](auto& state) { transaction_id = std::move(state.account_state_->last_transaction_id_); }); + + send_query( + tonlib_api::make_object( + ton::move_tl_object_as(std::move(address.address)), std::move(transaction_id)), + [](auto r_res) { + if (r_res.is_error()) { + td::TerminalIO::out() << "Can't get transactions: " << r_res.error() << "\n"; + return; + } + td::TerminalIO::out() << to_string(r_res.move_as_ok()) << "\n"; + }); + } void transfer(td::Slice from, td::Slice to, td::Slice grams) { auto r_from_address = to_account_address(from, true); @@ -591,6 +694,10 @@ int main(int argc, char* argv[]) { options.config = std::move(data); return td::Status::OK(); }); + p.add_option('c', "use_callbacks_for_network (for debug)", "do not use this", [&]() { + options.use_callbacks_for_network = true; + return td::Status::OK(); + }); auto S = p.run(argc, argv); if (S.is_error()) {