Skip to content

Commit

Permalink
[Protobuf] Update version to 3.19.2 (#1903)
Browse files Browse the repository at this point in the history
* update protobuf version (kotlin)
* bump protobuf version for android
* gen enum aliases for swift
  • Loading branch information
hewigovens authored Jan 10, 2022
1 parent 3113900 commit 6da8518
Show file tree
Hide file tree
Showing 13 changed files with 96 additions and 76 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ lib/protobuf
# Generated files
jni/cpp/generated
jni/java/wallet/core/jni
jni/java/wallet/core/proto
swift/Sources/Generated
swift/wallet-core/
src/Generated
Expand Down
9 changes: 7 additions & 2 deletions WalletCore.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Pod::Spec.new do |s|
end

s.subspec 'Core' do |ss|
protobuf_source_dir = 'build/local/src/protobuf/protobuf-3.14.0'
protobuf_source_dir = 'build/local/src/protobuf/protobuf-3.19.2'
include_dir = 'build/local/include'
ss.source_files =
'src/**/*.{c,cc,cpp,h}',
Expand Down Expand Up @@ -57,11 +57,15 @@ Pod::Spec.new do |s|
"#{protobuf_source_dir}/src/google/protobuf/extension_set_heavy.cc",
"#{protobuf_source_dir}/src/google/protobuf/field_mask.pb.cc",
"#{protobuf_source_dir}/src/google/protobuf/generated_enum_util.cc",
"#{protobuf_source_dir}/src/google/protobuf/generated_message_bases.cc",
"#{protobuf_source_dir}/src/google/protobuf/generated_message_reflection.cc",
"#{protobuf_source_dir}/src/google/protobuf/generated_message_table_driven.cc",
"#{protobuf_source_dir}/src/google/protobuf/generated_message_table_driven_lite.cc",
"#{protobuf_source_dir}/src/google/protobuf/generated_message_tctable_full.cc",
"#{protobuf_source_dir}/src/google/protobuf/generated_message_tctable_lite.cc",
"#{protobuf_source_dir}/src/google/protobuf/generated_message_util.cc",
"#{protobuf_source_dir}/src/google/protobuf/implicit_weak_message.cc",
"#{protobuf_source_dir}/src/google/protobuf/inlined_string_field.cc",
"#{protobuf_source_dir}/src/google/protobuf/io/coded_stream.cc",
"#{protobuf_source_dir}/src/google/protobuf/io/gzip_stream.cc",
"#{protobuf_source_dir}/src/google/protobuf/io/io_win32.cc",
Expand All @@ -78,6 +82,7 @@ Pod::Spec.new do |s|
"#{protobuf_source_dir}/src/google/protobuf/parse_context.cc",
"#{protobuf_source_dir}/src/google/protobuf/reflection_ops.cc",
"#{protobuf_source_dir}/src/google/protobuf/repeated_field.cc",
"#{protobuf_source_dir}/src/google/protobuf/repeated_ptr_field.cc",
"#{protobuf_source_dir}/src/google/protobuf/service.cc",
"#{protobuf_source_dir}/src/google/protobuf/source_context.pb.cc",
"#{protobuf_source_dir}/src/google/protobuf/struct.pb.cc",
Expand Down Expand Up @@ -111,7 +116,6 @@ Pod::Spec.new do |s|
"#{protobuf_source_dir}/src/google/protobuf/util/internal/protostream_objectsource.cc",
"#{protobuf_source_dir}/src/google/protobuf/util/internal/protostream_objectwriter.cc",
"#{protobuf_source_dir}/src/google/protobuf/util/internal/type_info.cc",
"#{protobuf_source_dir}/src/google/protobuf/util/internal/type_info_test_helper.cc",
"#{protobuf_source_dir}/src/google/protobuf/util/internal/utility.cc",
"#{protobuf_source_dir}/src/google/protobuf/util/json_util.cc",
"#{protobuf_source_dir}/src/google/protobuf/util/message_differencer.cc",
Expand All @@ -120,6 +124,7 @@ Pod::Spec.new do |s|
"#{protobuf_source_dir}/src/google/protobuf/wire_format.cc",
"#{protobuf_source_dir}/src/google/protobuf/wire_format_lite.cc",
"#{protobuf_source_dir}/src/google/protobuf/wrappers.pb.cc"

ss.exclude_files =
'trezor-crypto/include/TrezorCrypto/base58.h',
'trezor-crypto/crypto/monero',
Expand Down
4 changes: 1 addition & 3 deletions android/trustwalletcore/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ android {
}

dependencies {
implementation 'io.grpc:grpc-protobuf:1.34.0'
implementation 'io.grpc:grpc-protobuf:1.43.2'
}

apply from: 'maven-push.gradle'


67 changes: 45 additions & 22 deletions cmake/Protobuf.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
set(protobuf_SOURCE_DIR ${CMAKE_SOURCE_DIR}/build/local/src/protobuf/protobuf-3.14.0)
set(protobuf_source_dir ${CMAKE_SOURCE_DIR}/build/local/src/protobuf/protobuf-3.14.0)
set(protobuf_SOURCE_DIR ${CMAKE_SOURCE_DIR}/build/local/src/protobuf/protobuf-3.19.2)
set(protobuf_source_dir ${CMAKE_SOURCE_DIR}/build/local/src/protobuf/protobuf-3.19.2)

# sort + uniq -u
# https://github.com/protocolbuffers/protobuf/blob/master/cmake/libprotobuf.cmake
Expand All @@ -24,11 +24,15 @@ set(protobuf_SOURCE_FILES
${protobuf_source_dir}/src/google/protobuf/extension_set_heavy.cc
${protobuf_source_dir}/src/google/protobuf/field_mask.pb.cc
${protobuf_source_dir}/src/google/protobuf/generated_enum_util.cc
${protobuf_source_dir}/src/google/protobuf/generated_message_bases.cc
${protobuf_source_dir}/src/google/protobuf/generated_message_reflection.cc
${protobuf_source_dir}/src/google/protobuf/generated_message_table_driven.cc
${protobuf_source_dir}/src/google/protobuf/generated_message_table_driven_lite.cc
${protobuf_source_dir}/src/google/protobuf/generated_message_tctable_full.cc
${protobuf_source_dir}/src/google/protobuf/generated_message_tctable_lite.cc
${protobuf_source_dir}/src/google/protobuf/generated_message_util.cc
${protobuf_source_dir}/src/google/protobuf/implicit_weak_message.cc
${protobuf_source_dir}/src/google/protobuf/inlined_string_field.cc
${protobuf_source_dir}/src/google/protobuf/io/coded_stream.cc
${protobuf_source_dir}/src/google/protobuf/io/gzip_stream.cc
${protobuf_source_dir}/src/google/protobuf/io/io_win32.cc
Expand All @@ -45,6 +49,7 @@ set(protobuf_SOURCE_FILES
${protobuf_source_dir}/src/google/protobuf/parse_context.cc
${protobuf_source_dir}/src/google/protobuf/reflection_ops.cc
${protobuf_source_dir}/src/google/protobuf/repeated_field.cc
${protobuf_source_dir}/src/google/protobuf/repeated_ptr_field.cc
${protobuf_source_dir}/src/google/protobuf/service.cc
${protobuf_source_dir}/src/google/protobuf/source_context.pb.cc
${protobuf_source_dir}/src/google/protobuf/struct.pb.cc
Expand Down Expand Up @@ -78,7 +83,6 @@ set(protobuf_SOURCE_FILES
${protobuf_source_dir}/src/google/protobuf/util/internal/protostream_objectsource.cc
${protobuf_source_dir}/src/google/protobuf/util/internal/protostream_objectwriter.cc
${protobuf_source_dir}/src/google/protobuf/util/internal/type_info.cc
${protobuf_source_dir}/src/google/protobuf/util/internal/type_info_test_helper.cc
${protobuf_source_dir}/src/google/protobuf/util/internal/utility.cc
${protobuf_source_dir}/src/google/protobuf/util/json_util.cc
${protobuf_source_dir}/src/google/protobuf/util/message_differencer.cc
Expand All @@ -94,6 +98,7 @@ set(protobuf_HEADER_FILES
${protobuf_source_dir}/src/google/protobuf/any.pb.h
${protobuf_source_dir}/src/google/protobuf/api.pb.h
${protobuf_source_dir}/src/google/protobuf/arena.h
${protobuf_source_dir}/src/google/protobuf/arena_impl.h
${protobuf_source_dir}/src/google/protobuf/arenastring.h
${protobuf_source_dir}/src/google/protobuf/compiler/importer.h
${protobuf_source_dir}/src/google/protobuf/compiler/parser.h
Expand All @@ -103,63 +108,81 @@ set(protobuf_HEADER_FILES
${protobuf_source_dir}/src/google/protobuf/duration.pb.h
${protobuf_source_dir}/src/google/protobuf/dynamic_message.h
${protobuf_source_dir}/src/google/protobuf/empty.pb.h
${protobuf_source_dir}/src/google/protobuf/explicitly_constructed.h
${protobuf_source_dir}/src/google/protobuf/extension_set.h
${protobuf_source_dir}/src/google/protobuf/extension_set_inl.h
${protobuf_source_dir}/src/google/protobuf/field_access_listener.h
${protobuf_source_dir}/src/google/protobuf/field_mask.pb.h
${protobuf_source_dir}/src/google/protobuf/generated_enum_reflection.h
${protobuf_source_dir}/src/google/protobuf/generated_enum_util.h
${protobuf_source_dir}/src/google/protobuf/generated_message_bases.h
${protobuf_source_dir}/src/google/protobuf/generated_message_reflection.h
${protobuf_source_dir}/src/google/protobuf/generated_message_table_driven.h
${protobuf_source_dir}/src/google/protobuf/generated_message_table_driven_lite.h
${protobuf_source_dir}/src/google/protobuf/generated_message_tctable_decl.h
${protobuf_source_dir}/src/google/protobuf/generated_message_tctable_impl.h
${protobuf_source_dir}/src/google/protobuf/generated_message_tctable_impl.inc
${protobuf_source_dir}/src/google/protobuf/generated_message_util.h
${protobuf_source_dir}/src/google/protobuf/has_bits.h
${protobuf_source_dir}/src/google/protobuf/implicit_weak_message.h
${protobuf_source_dir}/src/google/protobuf/inlined_string_field.h
${protobuf_source_dir}/src/google/protobuf/io/coded_stream.h
${protobuf_source_dir}/src/google/protobuf/io/gzip_stream.h
${protobuf_source_dir}/src/google/protobuf/io/io_win32.h
${protobuf_source_dir}/src/google/protobuf/io/printer.h
${protobuf_source_dir}/src/google/protobuf/io/strtod.h
${protobuf_source_dir}/src/google/protobuf/io/tokenizer.h
${protobuf_source_dir}/src/google/protobuf/io/zero_copy_stream.h
${protobuf_source_dir}/src/google/protobuf/io/zero_copy_stream_impl.h
${protobuf_source_dir}/src/google/protobuf/io/zero_copy_stream_impl_lite.h
${protobuf_source_dir}/src/google/protobuf/map.h
${protobuf_source_dir}/src/google/protobuf/map_entry.h
${protobuf_source_dir}/src/google/protobuf/map_entry_lite.h
${protobuf_source_dir}/src/google/protobuf/map_field.h
${protobuf_source_dir}/src/google/protobuf/map_field_inl.h
${protobuf_source_dir}/src/google/protobuf/map_field_lite.h
${protobuf_source_dir}/src/google/protobuf/map_type_handler.h
${protobuf_source_dir}/src/google/protobuf/message.h
${protobuf_source_dir}/src/google/protobuf/message_lite.h
${protobuf_source_dir}/src/google/protobuf/metadata.h
${protobuf_source_dir}/src/google/protobuf/metadata_lite.h
${protobuf_source_dir}/src/google/protobuf/parse_context.h
${protobuf_source_dir}/src/google/protobuf/port.h
${protobuf_source_dir}/src/google/protobuf/reflection.h
${protobuf_source_dir}/src/google/protobuf/reflection_ops.h
${protobuf_source_dir}/src/google/protobuf/repeated_field.h
${protobuf_source_dir}/src/google/protobuf/repeated_ptr_field.h
${protobuf_source_dir}/src/google/protobuf/service.h
${protobuf_source_dir}/src/google/protobuf/source_context.pb.h
${protobuf_source_dir}/src/google/protobuf/struct.pb.h
${protobuf_source_dir}/src/google/protobuf/stubs/bytestream.h
${protobuf_source_dir}/src/google/protobuf/stubs/callback.h
${protobuf_source_dir}/src/google/protobuf/stubs/casts.h
${protobuf_source_dir}/src/google/protobuf/stubs/common.h
${protobuf_source_dir}/src/google/protobuf/stubs/int128.h
${protobuf_source_dir}/src/google/protobuf/stubs/hash.h
${protobuf_source_dir}/src/google/protobuf/stubs/logging.h
${protobuf_source_dir}/src/google/protobuf/stubs/macros.h
${protobuf_source_dir}/src/google/protobuf/stubs/map_util.h
${protobuf_source_dir}/src/google/protobuf/stubs/mutex.h
${protobuf_source_dir}/src/google/protobuf/stubs/once.h
${protobuf_source_dir}/src/google/protobuf/stubs/platform_macros.h
${protobuf_source_dir}/src/google/protobuf/stubs/port.h
${protobuf_source_dir}/src/google/protobuf/stubs/status.h
${protobuf_source_dir}/src/google/protobuf/stubs/statusor.h
${protobuf_source_dir}/src/google/protobuf/stubs/stl_util.h
${protobuf_source_dir}/src/google/protobuf/stubs/stringpiece.h
${protobuf_source_dir}/src/google/protobuf/stubs/stringprintf.h
${protobuf_source_dir}/src/google/protobuf/stubs/strutil.h
${protobuf_source_dir}/src/google/protobuf/stubs/substitute.h
${protobuf_source_dir}/src/google/protobuf/stubs/time.h
${protobuf_source_dir}/src/google/protobuf/stubs/template_util.h
${protobuf_source_dir}/src/google/protobuf/text_format.h
${protobuf_source_dir}/src/google/protobuf/timestamp.pb.h
${protobuf_source_dir}/src/google/protobuf/type.pb.h
${protobuf_source_dir}/src/google/protobuf/unknown_field_set.h
${protobuf_source_dir}/src/google/protobuf/util/delimited_message_util.h
${protobuf_source_dir}/src/google/protobuf/util/field_comparator.h
${protobuf_source_dir}/src/google/protobuf/util/field_mask_util.h
${protobuf_source_dir}/src/google/protobuf/util/internal/datapiece.h
${protobuf_source_dir}/src/google/protobuf/util/internal/default_value_objectwriter.h
${protobuf_source_dir}/src/google/protobuf/util/internal/error_listener.h
${protobuf_source_dir}/src/google/protobuf/util/internal/field_mask_utility.h
${protobuf_source_dir}/src/google/protobuf/util/internal/json_escaping.h
${protobuf_source_dir}/src/google/protobuf/util/internal/json_objectwriter.h
${protobuf_source_dir}/src/google/protobuf/util/internal/json_stream_parser.h
${protobuf_source_dir}/src/google/protobuf/util/internal/object_writer.h
${protobuf_source_dir}/src/google/protobuf/util/internal/proto_writer.h
${protobuf_source_dir}/src/google/protobuf/util/internal/protostream_objectsource.h
${protobuf_source_dir}/src/google/protobuf/util/internal/protostream_objectwriter.h
${protobuf_source_dir}/src/google/protobuf/util/internal/type_info.h
${protobuf_source_dir}/src/google/protobuf/util/internal/type_info_test_helper.h
${protobuf_source_dir}/src/google/protobuf/util/internal/utility.h
${protobuf_source_dir}/src/google/protobuf/util/json_util.h
${protobuf_source_dir}/src/google/protobuf/util/message_differencer.h
${protobuf_source_dir}/src/google/protobuf/util/time_util.h
${protobuf_source_dir}/src/google/protobuf/util/type_resolver.h
${protobuf_source_dir}/src/google/protobuf/util/type_resolver_util.h
${protobuf_source_dir}/src/google/protobuf/wire_format.h
${protobuf_source_dir}/src/google/protobuf/wire_format_lite.h
Expand Down
2 changes: 1 addition & 1 deletion docs/registry.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ This list is generated from [./registry.json](../registry.json)
| 145 | Bitcoin Cash | BCH | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/bitcoincash/info/logo.png" width="32" /> | <https://bitcoincash.org> |
| 148 | Stellar | XLM | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/stellar/info/logo.png" width="32" /> | <https://stellar.org> |
| 156 | Bitcoin Gold | BTG | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/bitcoingold/info/logo.png" width="32" /> | <https://bitcoingold.org> |
| 165 | Nano | NANO | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/nano/info/logo.png" width="32" /> | <https://nano.org> |
| 165 | Nano | XNO | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/nano/info/logo.png" width="32" /> | <https://nano.org> |
| 175 | Ravencoin | RVN | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ravencoin/info/logo.png" width="32" /> | <https://ravencoin.org> |
| 178 | POA Network | POA | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/poa/info/logo.png" width="32" /> | <https://poa.network> |
| 194 | EOS | EOS | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/eos/info/logo.png" width="32" /> | <http://eos.io> |
Expand Down
41 changes: 30 additions & 11 deletions protobuf-plugin/swift_typealias.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include <google/protobuf/descriptor.pb.h>
#include <google/protobuf/io/printer.h>
#include <google/protobuf/io/zero_copy_stream.h>
#include <iostream>
#include <string>

using namespace google::protobuf;

Expand All @@ -26,31 +28,48 @@ class Generator : public compiler::CodeGenerator {
"// file LICENSE at the root of the source code distribution tree.\n"
"\n"
);

std::vector<std::string> names;
std::vector<std::tuple<std::string, std::string>> aliases;

for (int i = 0; i < file->message_type_count(); i += 1) {
auto message = file->message_type(i);
auto parts = Generator::getParts(message->full_name());
const auto* message = file->message_type(i);
names.emplace_back(message->full_name());
}

for (int i = 0; i < file->enum_type_count(); i += 1) {
const auto* enum_type = file->enum_type(i);
names.emplace_back(enum_type->full_name());
}

for (auto& name : names) {
auto parts = Generator::getParts(name);
if (parts.size() < 3 || parts[0] != "TW") {
std::cerr << "Invalid proto name '" << message->full_name() << "'" << std::endl;
std::cerr << "Invalid proto name '" << name << "'" << std::endl;
continue;
}
std::string def = "public typealias ";

std::string alias = "";
for (auto i = 0; i < parts.size(); i += 1) {
if (i == 0 || i == 2) {
continue;
}
def += parts[i];
alias += parts[i];
}

def += " = ";

std::string type = "";
for (auto& part : parts) {
def += part + "_";
type += part + "_";
}
def = def.substr(0, def.size() - 1);
def += ";\n";
printer.Print(def.c_str());
type = type.substr(0, type.size() - 1);

aliases.emplace_back(std::make_tuple(alias, type));
}

for (auto& alias : aliases) {
std::string line = "public typealias " + std::get<0>(alias) + " = " + std::get<1>(alias) + "\n";
printer.Print(line.c_str());
}
return true;
}

Expand Down
4 changes: 3 additions & 1 deletion src/Ripple/Transaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include "../BinaryCoding.h"
#include "../HexCoding.h"

#include <algorithm>

using namespace TW;
using namespace TW::Ripple;

Expand Down Expand Up @@ -84,7 +86,7 @@ Data Transaction::serializeAmount(int64_t amount) {
Data Transaction::serializeAddress(Address address) {
auto data = Data(20);
if (!address.bytes.empty()) {
std::copy(&address.bytes[0] + 1, &address.bytes[0] + MIN(address.bytes.size(), 21), &data[0]);
std::copy(&address.bytes[0] + 1, &address.bytes[0] + std::min(address.bytes.size(), size_t(21)), &data[0]);
}
return data;
}
2 changes: 1 addition & 1 deletion swift/cpp.xcconfig.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
// file LICENSE at the root of the source code distribution tree.

HEADER_SEARCH_PATHS = $(SRCROOT)/../src @Boost_INCLUDE_DIRS@
SYSTEM_HEADER_SEARCH_PATHS = $(SRCROOT)/../src/build/local/include $(SRCROOT)/../build/local/src/protobuf/protobuf-3.14.0/src
SYSTEM_HEADER_SEARCH_PATHS = $(SRCROOT)/../src/build/local/include $(SRCROOT)/../build/local/src/protobuf/protobuf-3.19.2/src
6 changes: 5 additions & 1 deletion swift/project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,15 @@ targets:
- protobuf/google/protobuf/extension_set_heavy.cc
- protobuf/google/protobuf/field_mask.pb.cc
- protobuf/google/protobuf/generated_enum_util.cc
- protobuf/google/protobuf/generated_message_bases.cc
- protobuf/google/protobuf/generated_message_reflection.cc
- protobuf/google/protobuf/generated_message_table_driven.cc
- protobuf/google/protobuf/generated_message_table_driven_lite.cc
- protobuf/google/protobuf/generated_message_tctable_full.cc
- protobuf/google/protobuf/generated_message_tctable_lite.cc
- protobuf/google/protobuf/generated_message_util.cc
- protobuf/google/protobuf/implicit_weak_message.cc
- protobuf/google/protobuf/inlined_string_field.cc
- protobuf/google/protobuf/io/coded_stream.cc
- protobuf/google/protobuf/io/gzip_stream.cc
- protobuf/google/protobuf/io/io_win32.cc
Expand All @@ -178,6 +182,7 @@ targets:
- protobuf/google/protobuf/parse_context.cc
- protobuf/google/protobuf/reflection_ops.cc
- protobuf/google/protobuf/repeated_field.cc
- protobuf/google/protobuf/repeated_ptr_field.cc
- protobuf/google/protobuf/service.cc
- protobuf/google/protobuf/source_context.pb.cc
- protobuf/google/protobuf/struct.pb.cc
Expand Down Expand Up @@ -211,7 +216,6 @@ targets:
- protobuf/google/protobuf/util/internal/protostream_objectsource.cc
- protobuf/google/protobuf/util/internal/protostream_objectwriter.cc
- protobuf/google/protobuf/util/internal/type_info.cc
- protobuf/google/protobuf/util/internal/type_info_test_helper.cc
- protobuf/google/protobuf/util/internal/utility.cc
- protobuf/google/protobuf/util/json_util.cc
- protobuf/google/protobuf/util/message_differencer.cc
Expand Down
2 changes: 1 addition & 1 deletion swift/protobuf
Loading

0 comments on commit 6da8518

Please sign in to comment.