diff --git a/Cargo.lock b/Cargo.lock index 932538e97ddbe..3b22e064b3e6d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -15193,6 +15193,7 @@ dependencies = [ "async-trait", "axum 0.7.5", "bcs", + "bytes", "diffy", "documented", "fastcrypto", @@ -15205,8 +15206,10 @@ dependencies = [ "prometheus", "prost 0.13.3", "prost-build", + "prost-types 0.13.3", "rand 0.8.5", "reqwest 0.12.5", + "roaring", "schemars", "serde", "serde_json", @@ -15218,6 +15221,8 @@ dependencies = [ "tap", "thiserror", "tokio", + "tonic 0.12.3", + "tonic-build", "url", ] @@ -16967,13 +16972,14 @@ dependencies = [ [[package]] name = "tonic-build" -version = "0.12.1" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "568392c5a2bd0020723e3f387891176aabafe36fd9fcd074ad309dfa0c8eb964" +checksum = "9557ce109ea773b399c9b9e5dca39294110b74f1f342cb347a80d1fce8c26a11" dependencies = [ "prettyplease", "proc-macro2 1.0.87", "prost-build", + "prost-types 0.13.3", "quote 1.0.35", "syn 2.0.79", ] diff --git a/crates/sui-rpc-api/Cargo.toml b/crates/sui-rpc-api/Cargo.toml index 19a15bc05a5bc..24863b48ec454 100644 --- a/crates/sui-rpc-api/Cargo.toml +++ b/crates/sui-rpc-api/Cargo.toml @@ -27,7 +27,6 @@ prometheus.workspace = true openapiv3 = { git = "https://github.com/bmwill/openapiv3.git", rev = "ca4b4845b7c159a39f5c68ad8f7f76cb6f4d6963" } schemars.workspace = true documented = "0.6.0" -prost.workspace = true fastcrypto.workspace = true sui-types.workspace = true @@ -36,6 +35,14 @@ sui-protocol-config.workspace = true move-binary-format.workspace = true move-core-types.workspace = true +# dependencies for the protobuf definitions +roaring.workspace = true +tonic.workspace = true +prost.workspace = true +prost-types = "0.13.3" +bytes.workspace = true + [dev-dependencies] diffy = "0.3" prost-build = "0.13.3" +tonic-build = "0.12.3" diff --git a/crates/sui-rpc-api/proto/google/protobuf/empty.proto b/crates/sui-rpc-api/proto/google/protobuf/empty.proto new file mode 100644 index 0000000000000..b87c89dcfce9e --- /dev/null +++ b/crates/sui-rpc-api/proto/google/protobuf/empty.proto @@ -0,0 +1,51 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +syntax = "proto3"; + +package google.protobuf; + +option go_package = "google.golang.org/protobuf/types/known/emptypb"; +option java_package = "com.google.protobuf"; +option java_outer_classname = "EmptyProto"; +option java_multiple_files = true; +option objc_class_prefix = "GPB"; +option csharp_namespace = "Google.Protobuf.WellKnownTypes"; +option cc_enable_arenas = true; + +// A generic empty message that you can re-use to avoid defining duplicated +// empty messages in your APIs. A typical example is to use it as the request +// or the response type of an API method. For instance: +// +// service Foo { +// rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); +// } +// +message Empty {} diff --git a/crates/sui-rpc-api/proto/google/protobuf/timestamp.proto b/crates/sui-rpc-api/proto/google/protobuf/timestamp.proto new file mode 100644 index 0000000000000..06750ab1f127d --- /dev/null +++ b/crates/sui-rpc-api/proto/google/protobuf/timestamp.proto @@ -0,0 +1,133 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +syntax = "proto3"; + +package google.protobuf; + +option csharp_namespace = "Google.Protobuf.WellKnownTypes"; +option cc_enable_arenas = true; +option go_package = "github.com/golang/protobuf/ptypes/timestamp"; +option java_package = "com.google.protobuf"; +option java_outer_classname = "TimestampProto"; +option java_multiple_files = true; +option objc_class_prefix = "GPB"; + +// A Timestamp represents a point in time independent of any time zone +// or calendar, represented as seconds and fractions of seconds at +// nanosecond resolution in UTC Epoch time. It is encoded using the +// Proleptic Gregorian Calendar which extends the Gregorian calendar +// backwards to year one. It is encoded assuming all minutes are 60 +// seconds long, i.e. leap seconds are "smeared" so that no leap second +// table is needed for interpretation. Range is from +// 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. +// By restricting to that range, we ensure that we can convert to +// and from RFC 3339 date strings. +// See [https://www.ietf.org/rfc/rfc3339.txt](https://www.ietf.org/rfc/rfc3339.txt). +// +// # Examples +// +// Example 1: Compute Timestamp from POSIX `time()`. +// +// Timestamp timestamp; +// timestamp.set_seconds(time(NULL)); +// timestamp.set_nanos(0); +// +// Example 2: Compute Timestamp from POSIX `gettimeofday()`. +// +// struct timeval tv; +// gettimeofday(&tv, NULL); +// +// Timestamp timestamp; +// timestamp.set_seconds(tv.tv_sec); +// timestamp.set_nanos(tv.tv_usec * 1000); +// +// Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`. +// +// FILETIME ft; +// GetSystemTimeAsFileTime(&ft); +// UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime; +// +// // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z +// // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z. +// Timestamp timestamp; +// timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL)); +// timestamp.set_nanos((INT32) ((ticks % 10000000) * 100)); +// +// Example 4: Compute Timestamp from Java `System.currentTimeMillis()`. +// +// long millis = System.currentTimeMillis(); +// +// Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000) +// .setNanos((int) ((millis % 1000) * 1000000)).build(); +// +// +// Example 5: Compute Timestamp from current time in Python. +// +// timestamp = Timestamp() +// timestamp.GetCurrentTime() +// +// # JSON Mapping +// +// In JSON format, the Timestamp type is encoded as a string in the +// [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the +// format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z" +// where {year} is always expressed using four digits while {month}, {day}, +// {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional +// seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution), +// are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone +// is required, though only UTC (as indicated by "Z") is presently supported. +// +// For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past +// 01:30 UTC on January 15, 2017. +// +// In JavaScript, one can convert a Date object to this format using the +// standard [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString] +// method. In Python, a standard `datetime.datetime` object can be converted +// to this format using [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) +// with the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one +// can use the Joda Time's [`ISODateTimeFormat.dateTime()`]( +// http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime--) +// to obtain a formatter capable of generating timestamps in this format. +// +// +message Timestamp { + + // Represents seconds of UTC time since Unix epoch + // 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to + // 9999-12-31T23:59:59Z inclusive. + int64 seconds = 1; + + // Non-negative fractions of a second at nanosecond resolution. Negative + // second values with fractions must still have non-negative nanos values + // that count forward in time. Must be from 0 to 999,999,999 + // inclusive. + int32 nanos = 2; +} diff --git a/crates/sui-rpc-api/proto/rest.proto b/crates/sui-rpc-api/proto/rest.proto deleted file mode 100644 index b94e5b73d2637..0000000000000 --- a/crates/sui-rpc-api/proto/rest.proto +++ /dev/null @@ -1,157 +0,0 @@ -syntax = "proto3"; - -package sui.rest; - -// Sui `TransactionData` type serialized as Bcs -message Transaction { - bytes transaction = 1; -} - -// Sui `TransactionEffects` type serialized as Bcs -message TransactionEffects { - bytes effects = 1; -} - -// Sui `TransactionEvents` type serialized as Bcs -message TransactionEvents { - bytes events = 1; -} - -// Sui `Object` type serialized as Bcs -message Object { - bytes object = 1; -} - -// Sui `CheckpointSummary` type serialized as Bcs -message CheckpointSummary { - bytes summary = 1; -} - -// Sui `CheckpointContents` type serialized as Bcs -message CheckpointContents { - bytes contents = 1; -} - -// Sui `UserSignature` type serialized as bytes -message UserSignature { - bytes signature = 1; -} - -// Sui `ValidatorAggregatedSignature` type serialized as Bcs -message ValidatorAggregatedSignature { - bytes signature = 1; -} - -message GetTransactionResponse { - // The digest of this transaction - bytes digest = 1; - optional Transaction transaction = 2; - repeated UserSignature signatures = 3; - optional TransactionEffects effects = 4; - optional TransactionEvents events = 5; - optional uint64 checkpoint = 6; - optional uint64 timestamp_ms = 7; -} - -message GetObjectResponse { - // The digest of this object - bytes digest = 1; - optional Object object = 2; -} - -message GetCheckpointResponse { - // The digest of this CheckpointSummary - bytes digest = 1; - optional CheckpointSummary summary = 2; - optional ValidatorAggregatedSignature signature = 3; - optional CheckpointContents contents = 4; -} - -message FullCheckpoint { - optional CheckpointSummary summary = 1; - optional ValidatorAggregatedSignature signature = 2; - optional CheckpointContents contents = 3; - repeated CheckpointTransaction transactions = 4; -} - -message CheckpointTransaction { - optional Transaction transaction = 1; - repeated UserSignature signatures = 2; - optional TransactionEffects effects = 3; - optional TransactionEvents events = 4; - repeated Object input_objects = 5; - repeated Object output_objects = 6; -} - -message ListCheckpointResponse { - repeated GetCheckpointResponse checkpoints = 1; -} - -message ListTransactionsResponse { - repeated GetTransactionResponse transactions = 1; -} - -message Address { - bytes address = 1; -} - -message TypeTag { - string type_tag = 1; -} - -message I128 { - bytes little_endian_bytes = 1; -} - -message BalanceChange { - Address address = 1; - TypeTag coin_type = 2; - I128 amount = 3; -} - -message EffectsFinality { - optional ValidatorAggregatedSignature signature = 1; - optional uint64 checkpoint = 2; - optional bool quorum_executed = 3; -} - -message TransactionExecutionResponse { - optional TransactionEffects effects = 1; - optional EffectsFinality finality = 2; - optional TransactionEvents events = 3; - repeated BalanceChange balance_changes = 4; - repeated Object input_objects = 5; - repeated Object output_objects = 6; -} - -message TransactionSimulationResponse { - optional TransactionEffects effects = 1; - optional TransactionEvents events = 2; - repeated BalanceChange balance_changes = 3; - repeated Object input_objects = 4; - repeated Object output_objects = 5; -} - -message ResolveTransactionResponse { - optional Transaction transaction = 1; - optional TransactionSimulationResponse simulation = 2; -} - -message ExecuteTransactionRequest { - optional Transaction transaction = 1; - repeated UserSignature signatures = 2; -} - -message SimulateTransactionRequest { - optional Transaction transaction = 1; -} - -message ValidatorCommittee { - uint64 epoch = 1; - repeated ValidatorCommitteeMember members = 2; -} - -message ValidatorCommitteeMember { - bytes public_key = 1; - uint64 stake = 2; -} diff --git a/crates/sui-rpc-api/proto/sui.node.v2.proto b/crates/sui-rpc-api/proto/sui.node.v2.proto new file mode 100644 index 0000000000000..8cf251479a2e9 --- /dev/null +++ b/crates/sui-rpc-api/proto/sui.node.v2.proto @@ -0,0 +1,352 @@ +syntax = "proto3"; + +package sui.node.v2; + +import "google/protobuf/empty.proto"; +import "google/protobuf/timestamp.proto"; +import "sui.types.proto"; + +// +// Rpc Node interface +// + +service Node { + rpc GetNodeInfo(google.protobuf.Empty) returns (GetNodeInfoResponse); + rpc GetCommittee(GetCommitteeRequest) returns (GetCommitteeResponse); + + rpc GetObject(GetObjectRequest) returns (GetObjectResponse); + rpc GetTransaction(GetTransactionRequest) returns (GetTransactionResponse); + rpc GetCheckpoint(GetCheckpointRequest) returns (GetCheckpointResponse); + rpc GetFullCheckpoint(GetFullCheckpointRequest) returns (GetFullCheckpointResponse); + + rpc ExecuteTransaction(ExecuteTransactionRequest) returns (ExecuteTransactionResponse); +} + +message GetNodeInfoResponse { + // The chain identifier of the chain that this Node is on + optional sui.types.Digest chain_id = 1; + + // Human readable name of the chain that this Node is on + optional string chain = 2; + + // Current epoch of the Node based on its highest executed checkpoint + optional uint64 epoch = 3; + + // Checkpoint height of the most recently executed checkpoint + optional uint64 checkpoint_height = 4; + + // Unix timestamp of the most recently executed checkpoint + optional google.protobuf.Timestamp timestamp = 5; + + // The lowest checkpoint for which checkpoints and transaction data is available + optional uint64 lowest_available_checkpoint = 6; + + // The lowest checkpoint for which object data is available + optional uint64 lowest_available_checkpoint_objects = 7; + + optional string software_version = 8; +} + +message GetCommitteeRequest { + optional uint64 epoch = 1; +} + +message GetCommitteeResponse { + optional sui.types.ValidatorCommittee committee = 1; +} + +message GetTransactionRequest { + optional sui.types.Digest digest = 1; + + optional GetTransactionOptions options = 3; +} + +message GetTransactionOptions { + // Include the sui.types.Transaction message in the response. + // + // Defaults to true if not included + optional bool transaction = 1; + // Include the Transaction formatted as BCS in the response. + // + // Defaults to false if not included + optional bool transaction_bcs = 2; + // Include the set of sui.types.UserSignature's in the response. + // + // Defaults to true if not included + optional bool signatures = 3; + // Include the sui.types.TransactionEffects message in the response. + // + // Defaults to true if not included + optional bool effects = 4; + // Include the TransactionEffects formatted as BCS in the response. + // + // Defaults to false if not included + optional bool effects_bcs = 5; + // Include the sui.types.TransactionEvents message in the response. + // + // Defaults to true if not included + optional bool events = 6; + // Include the TransactionEvents formatted as BCS in the response. + // + // Defaults to false if not included + optional bool events_bcs = 7; +} + +message GetTransactionResponse { + // The digest of this transaction + optional sui.types.Digest digest = 1; + optional sui.types.Transaction transaction = 2; + optional sui.types.Bcs transaction_bcs = 3; + optional UserSignatures signatures = 4; + optional sui.types.TransactionEffects effects = 5; + optional sui.types.Bcs effects_bcs = 6; + optional sui.types.TransactionEvents events = 7; + optional sui.types.Bcs events_bcs = 8; + optional uint64 checkpoint = 9; + optional google.protobuf.Timestamp timestamp = 10; +} + +message UserSignatures { + repeated sui.types.UserSignature signatures = 1; +} + +message GetObjectRequest { + optional sui.types.ObjectId object_id = 1; + optional uint64 version = 2; + + optional GetObjectOptions options = 3; +} + +message GetObjectOptions { + // Include the sui.types.Object message in the response. + // + // Defaults to true if not included + optional bool object = 1; + // Include the Object formatted as BCS in the response. + // + // Defaults to false if not included + optional bool object_bcs = 2; +} + +message GetObjectResponse { + optional sui.types.ObjectId object_id = 1; + optional uint64 version = 2; + // The digest of this object + optional sui.types.Digest digest = 3; + + optional sui.types.Object object = 4; + optional sui.types.Bcs object_bcs = 5; +} + +message GetCheckpointRequest { + optional uint64 sequence_number = 1; + optional sui.types.Digest digest = 2; + + optional GetCheckpointOptions options = 3; +} + +message GetCheckpointOptions { + // Include the sui.types.CheckpointSummary in the response. + // + // Defaults to true if not included + optional bool summary = 3; + // Include the CheckpointSummary formatted as BCS in the response. + // + // Defaults to false if not included + optional bool summary_bcs = 4; + // Include the sui.types.ValidatorAggregatedSignature in the response. + // + // Defaults to true if not included + optional bool signature = 5; + // Include the sui.types.CheckpointContents message in the response. + // + // Defaults to false if not included + optional bool contents = 6; + // Include the CheckpointContents formatted as BCS in the response. + // + // Defaults to false if not included + optional bool contents_bcs = 7; +} + +message GetCheckpointResponse { + // The sequence number of this Checkpoint + optional uint64 sequence_number = 1; + // The digest of this Checkpoint's CheckpointSummary + optional sui.types.Digest digest = 2; + + optional sui.types.CheckpointSummary summary = 3; + optional sui.types.Bcs summary_bcs = 4; + optional sui.types.ValidatorAggregatedSignature signature = 5; + optional sui.types.CheckpointContents contents = 6; + optional sui.types.Bcs contents_bcs = 7; +} + +message GetFullCheckpointRequest { + optional uint64 sequence_number = 1; + optional sui.types.Digest digest = 2; + + optional GetFullCheckpointOptions options = 3; +} + +message GetFullCheckpointOptions { + // Include the sui.types.CheckpointSummary in the response. + // + // Defaults to true if not included + optional bool summary = 3; + // Include the CheckpointSummary formatted as BCS in the response. + // + // Defaults to false if not included + optional bool summary_bcs = 4; + // Include the sui.types.ValidatorAggregatedSignature in the response. + // + // Defaults to true if not included + optional bool signature = 5; + // Include the sui.types.CheckpointContents message in the response. + // + // Defaults to false if not included + optional bool contents = 6; + // Include the CheckpointContents formatted as BCS in the response. + // + // Defaults to false if not included + optional bool contents_bcs = 7; + + // Include the sui.types.Transaction message in the response. + // + // Defaults to true if not included + optional bool transaction = 8; + // Include the Transaction formatted as BCS in the response. + // + // Defaults to false if not included + optional bool transaction_bcs = 9; + // Include the sui.types.TransactionEffects message in the response. + // + // Defaults to true if not included + optional bool effects = 10; + // Include the TransactionEffects formatted as BCS in the response. + // + // Defaults to false if not included + optional bool effects_bcs = 11; + // Include the sui.types.TransactionEvents message in the response. + // + // Defaults to true if not included + optional bool events = 12; + // Include the TransactionEvents formatted as BCS in the response. + // + // Defaults to false if not included + optional bool events_bcs = 13; + + optional bool input_objects = 14; + optional bool output_objects = 15; + + // Include the sui.types.Object message in the response. + // + // Defaults to true if not included + optional bool object = 16; + // Include the Object formatted as BCS in the response. + // + // Defaults to false if not included + optional bool object_bcs = 17; +} + +message GetFullCheckpointResponse { + // The sequence number of this Checkpoint + optional uint64 sequence_number = 1; + // The digest of this Checkpoint's CheckpointSummary + optional sui.types.Digest digest = 2; + + optional sui.types.CheckpointSummary summary = 3; + optional sui.types.Bcs summary_bcs = 4; + optional sui.types.ValidatorAggregatedSignature signature = 5; + optional sui.types.CheckpointContents contents = 6; + optional sui.types.Bcs contents_bcs = 7; + + repeated FullCheckpointTransaction transactions = 8; +} + +message FullCheckpointTransaction { + // The digest of this transaction + optional sui.types.Digest digest = 1; + optional sui.types.Transaction transaction = 2; + optional sui.types.Bcs transaction_bcs = 3; + + optional sui.types.TransactionEffects effects = 5; + optional sui.types.Bcs effects_bcs = 6; + optional sui.types.TransactionEvents events = 7; + optional sui.types.Bcs events_bcs = 8; + + optional FullCheckpointObjects input_objects = 11; + optional FullCheckpointObjects output_objects = 12; +} + +message FullCheckpointObjects { + repeated FullCheckpointObject objects = 1; +} + +message FullCheckpointObject { + optional sui.types.ObjectId object_id = 1; + optional uint64 version = 2; + // The digest of this object + optional sui.types.Digest digest = 3; + + optional sui.types.Object object = 4; + optional sui.types.Bcs object_bcs = 5; +} + +message BalanceChange { + optional sui.types.Address address = 1; + optional sui.types.TypeTag coin_type = 2; + optional sui.types.I128 amount = 3; +} + +message BalanceChanges { + repeated BalanceChange balance_changes = 4; +} + +message EffectsFinality { + oneof finality { + sui.types.ValidatorAggregatedSignature certified = 1; + uint64 checkpointed = 2; + google.protobuf.Empty quorum_executed = 3; + } +} + +message ExecuteTransactionResponse { + optional EffectsFinality finality = 1; + optional sui.types.TransactionEffects effects = 2; + optional sui.types.Bcs effects_bcs = 3; + optional sui.types.TransactionEvents events = 4; + optional sui.types.Bcs events_bcs = 5; + optional BalanceChanges balance_changes = 6; +} + +message ExecuteTransactionRequest { + optional sui.types.Transaction transaction = 1; + optional sui.types.Bcs transaction_bcs = 2; + repeated sui.types.UserSignature signatures = 3; + + optional ExecuteTransactionOptions options = 4; +} + +message ExecuteTransactionOptions { + // Include the sui.types.TransactionEffects message in the response. + // + // Defaults to true if not included + optional bool effects = 4; + // Include the TransactionEffects formatted as BCS in the response. + // + // Defaults to false if not included + optional bool effects_bcs = 5; + // Include the sui.types.TransactionEvents message in the response. + // + // Defaults to true if not included + optional bool events = 6; + // Include the TransactionEvents formatted as BCS in the response. + // + // Defaults to false if not included + optional bool events_bcs = 7; + + // Include the BalanceChanges in the response. + // + // Defaults to false if not included + optional bool balance_changes = 8; +} diff --git a/crates/sui-rpc-api/proto/sui.types.proto b/crates/sui-rpc-api/proto/sui.types.proto new file mode 100644 index 0000000000000..2404383a89b72 --- /dev/null +++ b/crates/sui-rpc-api/proto/sui.types.proto @@ -0,0 +1,1038 @@ +// Protobuf definitions of public Sui core types +// +// This file contains a complete set of protobuf definitions for all of the +// public sui core types. All sui types are intended to have a 1:1 mapping to a +// protobuf message defined in this file and be able to roundtrip to/from their +// rust and protobuf definitions assuming a sufficiently up-to-date version of +// both these definitions. + +syntax = "proto3"; + +package sui.types; + +import "google/protobuf/empty.proto"; + +message Address { + optional bytes address = 1; +} + +message ObjectId { + optional bytes object_id = 1; +} + +message Digest { + optional bytes digest = 1; +} + +message Bcs { + optional bytes bcs = 1; +} + +// Primitives {{{ + +// Little-endian encoded u128 +message U128 { + optional bytes bytes = 1; +} + +// Little-endian encoded i128 +message I128 { + optional bytes bytes = 1; +} + +// Little-endian encoded u256 +message U256 { + optional bytes bytes = 1; +} + +// End Primitives }}} + +// Checkpoint {{{ + +message CheckpointSummary { + optional uint64 epoch = 1; + optional uint64 sequence_number = 2; + optional uint64 total_network_transactions = 3; + optional Digest content_digest = 4; + optional Digest previous_digest = 5; + + optional GasCostSummary epoch_rolling_gas_cost_summary = 6; + + optional uint64 timestamp_ms = 7; + + repeated CheckpointCommitment commitments = 8; + optional EndOfEpochData end_of_epoch_data = 9; + optional bytes version_specific_data = 10; +} + +message CheckpointCommitment { + oneof commitment { + Digest ecmh_live_object_set = 1; + } +} + +message EndOfEpochData { + repeated ValidatorCommitteeMember next_epoch_committee = 1; + optional uint64 next_epoch_protocol_version = 2; + repeated CheckpointCommitment epoch_commitments = 3; +} + +message CheckpointedTransactionInfo { + // TransactionDigest + optional Digest transaction = 1; + // EffectsDigest + optional Digest effects = 2; + repeated UserSignature signatures = 3; +} + +message CheckpointContents { + message V1 { + repeated CheckpointedTransactionInfo transactions = 1; + } + + oneof contents { + V1 v1 = 1; + } +} + +// End Checkpoint }}} + +// TransactionEvents {{{ + +message TransactionEvents { + repeated Event events = 1; +} + +message Event { + optional ObjectId package_id = 1; + optional Identifier module = 2; + optional Address sender = 3; + optional StructTag event_type = 4; + optional bytes contents = 5; +} + +// End TransactionEvents }}} + +// Object {{{ + +message ObjectReference { + optional ObjectId object_id = 1; + optional uint64 version = 2; + optional Digest digest = 3; +} + +message MovePackage { + optional ObjectId id = 1; + optional uint64 version = 2; + repeated MoveModule modules = 3; + repeated TypeOrigin type_origin_table = 4; + repeated UpgradeInfo linkage_table = 5; +} + +message MoveModule { + optional Identifier name = 1; + optional bytes contents = 2; +} + +message TypeOrigin { + optional Identifier module_name = 1; + optional Identifier struct_name = 2; + optional ObjectId package_id = 3; +} + +message UpgradeInfo { + optional ObjectId original_id = 1; + optional ObjectId upgraded_id = 2; + optional uint64 upgraded_version = 3; +} + +message Owner { + oneof kind { + Address address = 1; + ObjectId object = 2; + uint64 shared = 3; + google.protobuf.Empty immutable = 4; + } +} + +message MoveStruct { + optional ObjectId object_id = 1; + optional StructTag object_type = 2; + optional bool has_public_transfer = 3; + optional uint64 version = 4; + optional bytes contents = 5; +} + +message Object { + optional ObjectId object_id = 1; + optional uint64 version = 2; + optional Owner owner = 3; + + optional ObjectData object = 4; + + optional Digest previous_transaction = 5; + optional uint64 storage_rebate = 6; +} + +message ObjectData { + oneof kind { + MoveStruct struct = 1; + MovePackage package = 2; + } +} + +message GenesisObject { + optional ObjectId object_id = 1; + optional uint64 version = 2; + optional Owner owner = 3; + optional ObjectData object = 4; +} + +// End Object }}} + +// GasCostSummary {{{ + +message GasCostSummary { + optional uint64 computation_cost = 1; + optional uint64 storage_cost = 2; + optional uint64 storage_rebate = 3; + optional uint64 non_refundable_storage_fee = 4; +} + +// End GasCostSummary }}} + +// Move {{{ + +message Identifier { + optional bytes identifier = 1; +} + +message StructTag { + optional Address address = 1; + optional Identifier module = 2; + optional Identifier name = 3; + repeated TypeTag type_parameters = 4; +} + +message TypeTag { + oneof tag { + google.protobuf.Empty U8 = 1; + google.protobuf.Empty U16 = 2; + google.protobuf.Empty U32 = 3; + google.protobuf.Empty U64 = 4; + google.protobuf.Empty U128 = 5; + google.protobuf.Empty U256 = 6; + google.protobuf.Empty Bool = 7; + google.protobuf.Empty Address = 8; + google.protobuf.Empty Signer = 9; + TypeTag vector = 10; + StructTag struct = 11; + } +} + +message MoveStructValue { + optional StructTag struct_type = 1; + repeated MoveField fields = 2; +} + +message MoveField { + optional Identifier name = 1; + optional MoveValue value = 2; +} + +message MoveVariant { + optional StructTag enum_type = 1; + optional Identifier variant_name = 2; + optional uint32 tag = 3; + repeated MoveField fields = 4; +} + +message MoveValue { + oneof kind { + bool bool = 2; + uint32 u8 = 3; + uint32 u16 = 4; + uint32 u32 = 5; + uint64 u64 = 6; + U128 u128 = 7; + U256 u256 = 8; + Address address = 9; + MoveVector vector = 10; + MoveStructValue struct = 11; + Address signer = 12; + MoveVariant variant = 13; + } +} + +message MoveVector { + repeated MoveValue values = 1; +} + +// End Move }}} + +// Transaction {{{ + +message Transaction { + message TransactionV1 { + optional TransactionKind kind = 1; + optional Address sender = 2; + optional GasPayment gas_payment = 3; + optional TransactionExpiration expiration = 4; + } + + oneof version { + TransactionV1 v1 = 1; + } +} + +message GasPayment { + repeated ObjectReference objects = 1; + optional Address owner = 2; + optional uint64 price = 3; + optional uint64 budget = 4; +} + +message TransactionExpiration { + oneof expiration { + google.protobuf.Empty none = 1; + uint64 epoch = 2; + } +} + +message RandomnessStateUpdate { + optional uint64 epoch = 1; + optional uint64 randomness_round = 2; + optional bytes random_bytes = 3; + optional uint64 randomness_object_initial_shared_version = 4; +} + +message TransactionKind { + oneof kind { + ProgrammableTransaction programmable_transaction = 1; + ChangeEpoch change_epoch = 2; + GenesisTransaction genesis = 200; + ConsensusCommitPrologue consensus_commit_prologue_v1 = 201; + AuthenticatorStateUpdate authenticator_state_update = 3; + EndOfEpochTransaction end_of_epoch = 4; + RandomnessStateUpdate randomness_state_update = 5; + ConsensusCommitPrologue consensus_commit_prologue_v2 = 202; + ConsensusCommitPrologue consensus_commit_prologue_v3 = 6; + } +} + +message ProgrammableTransaction { + repeated Input inputs = 1; + repeated Command commands = 2; +} + +message Input { + oneof kind { + bytes pure = 1; + ObjectReference immutable_or_owned = 2; + SharedObjectInput shared = 3; + ObjectReference receiving = 4; + } +} + +message SharedObjectInput { + optional ObjectId object_id = 1; + optional uint64 initial_shared_version = 2; + optional bool mutable = 3; +} + +message Command { + oneof command { + MoveCall move_call = 1; + TransferObjects transfer_objects = 2; + SplitCoins split_coins = 3; + MergeCoins merge_coins = 4; + Publish publish = 5; + MakeMoveVector make_move_vector = 6; + Upgrade upgrade = 7; + } +} + +message MoveCall { + optional ObjectId package = 1; + optional Identifier module = 2; + optional Identifier function = 3; + repeated TypeTag type_arguments = 4; + repeated Argument arguments = 5; +} + +message TransferObjects { + repeated Argument objects = 1; + optional Argument address = 2; +} + +message SplitCoins { + optional Argument coin = 1; + repeated Argument amounts = 2; +} + +message MergeCoins { + optional Argument coin = 1; + repeated Argument coins_to_merge = 2; +} + +message Publish { + repeated bytes modules = 1; + repeated ObjectId dependencies = 2; +} + +message MakeMoveVector { + optional TypeTag element_type = 1; + repeated Argument elements = 2; +} + +message Upgrade { + repeated bytes modules = 1; + repeated ObjectId dependencies = 2; + optional ObjectId package = 3; + optional Argument ticket = 4; +} + +message Argument { + oneof kind { + google.protobuf.Empty gas = 1; + uint32 input = 2; + uint32 result = 3; + NestedResult nested_result = 4; + } +} + +message NestedResult { + optional uint32 result = 1; + optional uint32 subresult = 2; +} + +message ChangeEpoch { + // The next (to become) epoch ID. + optional uint64 epoch = 1; + // The protocol version in effect in the new epoch. + optional uint64 protocol_version = 2; + // The total amount of gas charged for storage during the epoch. + optional uint64 storage_charge = 3; + // The total amount of gas charged for computation during the epoch. + optional uint64 computation_charge = 4; + // The amount of storage rebate refunded to the txn senders. + optional uint64 storage_rebate = 5; + // The non-refundable storage fee. + optional uint64 non_refundable_storage_fee = 6; + // Unix timestamp when epoch started + optional uint64 epoch_start_timestamp_ms = 7; + // System packages (specifically framework and move stdlib) that are written before the new + // epoch starts. This tracks framework upgrades on chain. When executing the ChangeEpoch txn, + // the validator must write out the modules below. Modules are provided with the version they + // will be upgraded to, their modules in serialized form (which include their package ID), and + // a list of their transitive dependencies. + repeated SystemPackage system_packages = 8; +} + +message SystemPackage { + optional uint64 version = 1; + repeated bytes modules = 2; + repeated ObjectId dependencies = 3; +} + +message GenesisTransaction { + repeated GenesisObject objects = 1; +} + +message ConsensusCommitPrologue { + optional uint64 epoch = 1; + optional uint64 round = 2; + optional uint64 commit_timestamp_ms = 3; + optional Digest consensus_commit_digest = 4; + optional uint64 sub_dag_index = 5; + optional ConsensusDeterminedVersionAssignments consensus_determined_version_assignments = 6; +} + +message VersionAssignment { + optional ObjectId object_id = 1; + optional uint64 version = 2; +} + +message CancelledTransaction { + optional Digest digest = 1; + repeated VersionAssignment version_assignments = 2; +} + +message CancelledTransactions { + repeated CancelledTransaction cancelled_transactions = 1; +} + +message ConsensusDeterminedVersionAssignments { + oneof kind { + CancelledTransactions cancelled_transactions = 1; + } +} + +message AuthenticatorStateUpdate { + optional uint64 epoch = 1; + optional uint64 round = 2; + repeated ActiveJwk new_active_jwks = 3; + optional uint64 authenticator_object_initial_shared_version = 4; +} + +message ActiveJwk { + optional JwkId id = 1; + optional Jwk jwk = 2; + optional uint64 epoch = 3; +} + +message JwkId { + optional bytes iss = 1; + optional bytes kid = 2; +} + +message Jwk { + // Key type parameter, + optional bytes kty = 1; + // RSA public exponent, + optional bytes e = 2; + // RSA modulus, + optional bytes n = 3; + // Algorithm parameter, + optional bytes alg = 4; +} + +message EndOfEpochTransaction { + repeated EndOfEpochTransactionKind transactions = 1; +} + +message EndOfEpochTransactionKind { + oneof kind { + ChangeEpoch change_epoch = 1; + AuthenticatorStateExpire authenticator_state_expire = 2; + + // Use higher field numbers for kinds which happen infrequently + google.protobuf.Empty authenticator_state_create = 200; + google.protobuf.Empty randomness_state_create = 201; + google.protobuf.Empty deny_list_state_create = 202; + Digest bridge_state_create = 203; + uint64 bridge_committee_init = 204; + } +} + +message AuthenticatorStateExpire { + optional uint64 min_epoch = 1; + optional uint64 authenticator_object_initial_shared_version = 2; +} + +// End Transaction }}} + +// TransactionEffects {{{ + +message TransactionEffects { + oneof version { + TransactionEffectsV1 v1 = 1; + TransactionEffectsV2 v2 = 2; + } +} + +message TransactionEffectsV1 { + /// The status of the execution + optional ExecutionStatus status = 1; + /// The epoch when this transaction was executed. + optional uint64 epoch = 2; + optional GasCostSummary gas_used = 3; + /// The version that every modified (mutated or deleted) object had before it was modified by + /// this transaction. + repeated ModifiedAtVersion modified_at_versions = 4; + /// The object references of the shared objects used in this transaction. Empty if no shared objects were used. + repeated ObjectReference shared_objects = 5; + /// The transaction digest + optional Digest transaction_digest = 6; + + /// ObjectReference and owner of new objects created. + repeated ObjectReferenceWithOwner created = 7; + /// ObjectReference and owner of mutated objects, including gas object. + repeated ObjectReferenceWithOwner mutated = 8; + /// ObjectReference and owner of objects that are unwrapped in this transaction. + /// Unwrapped objects are objects that were wrapped into other objects in the past, + /// and just got extracted out. + repeated ObjectReferenceWithOwner unwrapped = 9; + /// Object Refs of objects now deleted (the new refs). + repeated ObjectReference deleted = 10; + /// Object refs of objects previously wrapped in other objects but now deleted. + repeated ObjectReference unwrapped_then_deleted = 11; + /// Object refs of objects now wrapped in other objects. + repeated ObjectReference wrapped = 12; + /// The updated gas object reference. Have a dedicated field for convenient access. + /// It's also included in mutated. + optional ObjectReferenceWithOwner gas_object = 13; + /// The digest of the events emitted during execution, + /// can be None if the transaction does not emit any event. + optional Digest events_digest = 14; + /// The set of transaction digests this transaction depends on. + repeated Digest dependencies = 15; +} + +message ObjectReferenceWithOwner { + optional ObjectReference reference = 1; + optional Owner owner = 2; +} + +message ModifiedAtVersion { + optional ObjectId object_id = 1; + optional uint64 version = 2; +} + +message TransactionEffectsV2 { + /// The status of the execution + optional ExecutionStatus status = 1; + /// The epoch when this transaction was executed. + optional uint64 epoch = 2; + optional GasCostSummary gas_used = 3; + /// The transaction digest + optional Digest transaction_digest = 4; + /// The updated gas object reference, as an index into the `changed_objects` vector. + /// Having a dedicated field for convenient access. + /// System transaction that don't require gas will leave this as None. + optional uint32 gas_object_index = 5; + + /// The digest of the events emitted during execution, + /// can be None if the transaction does not emit any event. + optional Digest events_digest = 6; + + /// The set of transaction digests this transaction depends on. + repeated Digest dependencies = 7; + + /// The version number of all the written Move objects by this transaction. + optional uint64 lamport_version = 8; + + /// Objects whose state are changed in the object store. + repeated ChangedObject changed_objects = 9; + + /// Shared objects that are not mutated in this transaction. Unlike owned objects, + /// read-only shared objects' version are not committed in the transaction, + /// and in order for a node to catch up and execute it without consensus sequencing, + /// the version needs to be committed in the effects. + repeated UnchangedSharedObject unchanged_shared_objects = 10; + + /// Auxiliary data that are not protocol-critical, generated as part of the effects but are stored separately. + /// Storing it separately allows us to avoid bloating the effects with data that are not critical. + /// It also provides more flexibility on the format and type of the data. + optional Digest auxiliary_data_digest = 11; +} + +message ChangedObject { + optional ObjectId object_id = 1; + + oneof input_state { + google.protobuf.Empty not_exist = 2; + ObjectExist exist = 3; + } + + oneof output_state { + google.protobuf.Empty removed = 4; + ObjectWrite object_write = 5; + PackageWrite package_write = 6; + } + + oneof id_operation { + google.protobuf.Empty none = 7; + google.protobuf.Empty created = 8; + google.protobuf.Empty deleted = 9; + } +} + +message ObjectExist { + optional uint64 version = 1; + optional Digest digest = 2; + optional Owner owner = 3; +} + +message ObjectWrite { + optional Digest digest = 2; + optional Owner owner = 3; +} + +message PackageWrite { + optional uint64 version = 1; + optional Digest digest = 2; +} + +message UnchangedSharedObject { + optional ObjectId object_id = 1; + + oneof kind { + ReadOnlyRoot read_only_root = 2; + uint64 mutate_deleted = 3; + uint64 read_deleted = 4; + uint64 cancelled = 5; + google.protobuf.Empty per_epoch_config = 6; + } +} + +message ReadOnlyRoot { + optional uint64 version = 1; + optional Digest digest = 2; +} + +// End TransactionEffects }}} + +// ExecutionStatus {{{ + +message ExecutionStatus { + optional bool success = 1; + optional FailureStatus status = 2; +} + +message SizeError { + optional uint64 size = 1; + optional uint64 max_size = 2; +} + +message MoveError { + optional MoveLocation location = 1; + optional uint64 abort_code = 2; +} + +message FailureStatus { + optional uint64 command = 1; + oneof execution_error { + /// Insufficient Gas + google.protobuf.Empty insufficient_gas = 2; + /// Invalid Gas Object. + google.protobuf.Empty invalid_gas_object = 3; + /// Invariant Violation + google.protobuf.Empty invariant_violation = 4; + /// Attempted to used feature that is not supported yet + google.protobuf.Empty feature_not_yet_supported = 5; + /// Move object is larger than the maximum allowed size + SizeError object_too_big = 6; + /// Package is larger than the maximum allowed size + SizeError package_too_big = 7; + /// Circular Object Ownership + ObjectId circular_object_ownership = 8; + + // + // Coin errors + // + /// Insufficient coin balance for requested operation + google.protobuf.Empty insufficient_coin_balance = 9; + /// Coin balance overflowed an u64 + google.protobuf.Empty coin_balance_overflow = 10; + + // + // Publish/Upgrade errors + // + /// Publish Error, Non-zero Address. + /// The modules in the package must have their self-addresses set to zero. + google.protobuf.Empty publish_error_non_zero_address = 11; + + /// Sui Move Bytecode Verification Error. + google.protobuf.Empty sui_move_verification_error = 12; + + // + // MoveVm Errors + // + /// Error from a non-abort instruction. + /// Possible causes: + /// Arithmetic error, stack overflow, max value depth, etc." + MoveError move_primitive_runtime_error = 13; + /// Move runtime abort + MoveError move_abort = 14; + /// Bytecode verification error. + google.protobuf.Empty vm_verification_or_deserialization_error = 15; + /// MoveVm invariant violation + google.protobuf.Empty vm_invariant_violation = 16; + + // + // Programmable Transaction Errors + // + /// Function not found + google.protobuf.Empty function_not_found = 17; + /// Arity mismatch for Move function. + /// The number of arguments does not match the number of parameters + google.protobuf.Empty arity_mismatch = 18; + /// Type arity mismatch for Move function. + /// Mismatch between the number of actual versus expected type arguments. + google.protobuf.Empty type_arity_mismatch = 19; + /// Non Entry Function Invoked. Move Call must start with an entry function. + google.protobuf.Empty non_entry_function_invoked = 20; + /// Invalid command argument + CommandArgumentError command_argument_error = 21; + /// Type argument error + TypeArgumentError type_argument_error = 22; + /// Unused result without the drop ability. + NestedResult unused_value_without_drop = 23; + /// Invalid public Move function signature. + /// Unsupported return type for return value + uint32 invalid_public_function_return_type = 24; + /// Invalid Transfer Object, object does not have public transfer. + google.protobuf.Empty invalid_transfer_object = 25; + + // + // Post-execution errors + // + /// Effects from the transaction are too large + SizeError effects_too_large = 26; + + /// Publish or Upgrade is missing dependency + google.protobuf.Empty publish_upgrade_missing_dependency = 27; + + /// Publish or Upgrade dependency downgrade. + /// + /// Indirect (transitive) dependency of published or upgraded package has been assigned an + /// on-chain version that is less than the version required by one of the package's + /// transitive dependencies. + google.protobuf.Empty publish_upgrade_dependency_downgrade = 28; + + /// Invalid package upgrade + PackageUpgradeError package_upgrade_error = 29; + + /// Indicates the transaction tried to write objects too large to storage + SizeError written_objects_too_large = 30; + + /// Certificate is on the deny list + google.protobuf.Empty certificate_denied = 31; + + /// Sui Move Bytecode verification timed out. + google.protobuf.Empty sui_move_verification_timedout = 32; + + /// The requested shared object operation is not allowed + google.protobuf.Empty shared_object_operation_not_allowed = 33; + + /// Requested shared object has been deleted + google.protobuf.Empty input_object_deleted = 34; + + /// Certificate is cancelled due to congestion on shared objects + CongestedObjectsError execution_cancelled_due_to_shared_object_congestion = 35; + + /// Address is denied for this coin type + AddressDeniedForCoinError address_denied_for_coin = 36; + + /// Coin type is globally paused for use + string coin_type_global_pause = 37; + + /// Certificate is cancelled because randomness could not be generated this epoch + google.protobuf.Empty execution_cancelled_due_to_randomness_unavailable = 38; + } +} + +message AddressDeniedForCoinError { + optional Address address = 1; + optional string coin_type = 2; +} + +message CongestedObjectsError { + repeated ObjectId congested_objects = 1; +} + +message MoveLocation { + optional ObjectId package = 1; + optional Identifier module = 2; + optional uint32 function = 3; + optional uint32 instruction = 4; + optional Identifier function_name = 5; +} + +message CommandArgumentError { + optional uint32 argument = 1; + + oneof kind { + /// The type of the value does not match the expected type + google.protobuf.Empty type_mismatch = 2; + /// The argument cannot be deserialized into a value of the specified type + google.protobuf.Empty invalid_bcs_bytes = 3; + /// The argument cannot be instantiated from raw bytes + google.protobuf.Empty invalid_usage_of_pure_argument = 4; + /// Invalid argument to private entry function. + /// Private entry functions cannot take arguments from other Move functions. + google.protobuf.Empty invalid_argument_to_private_entry_function = 5; + /// Out of bounds access to input or results + uint32 index_out_of_bounds = 6; + /// Out of bounds access to subresult + NestedResult secondary_index_out_of_bounds = 7; + /// Invalid usage of result. + /// Expected a single result but found either no return value or multiple. + uint32 invalid_result_arity = 8; + /// Invalid usage of Gas coin. + /// The Gas coin can only be used by-value with a TransferObjects command. + google.protobuf.Empty invalid_gas_coin_usage = 9; + /// Invalid usage of move value. + // Mutably borrowed values require unique usage. + // Immutably borrowed values cannot be taken or borrowed mutably. + // Taken values cannot be used again. + google.protobuf.Empty invalid_value_usage = 10; + /// Immutable objects cannot be passed by-value. + google.protobuf.Empty invalid_object_by_value = 11; + /// Immutable objects cannot be passed by mutable reference, &mut. + google.protobuf.Empty invalid_object_by_mut_ref = 12; + /// Shared object operations such a wrapping, freezing, or converting to owned are not + /// allowed. + google.protobuf.Empty shared_object_operation_not_allowed = 13; + } +} + +message PackageUpgradeError { + oneof kind { + ObjectId unable_to_fetch_package = 2; + ObjectId not_a_package = 3; + google.protobuf.Empty incompatible_upgrade = 4; + Digest digets_does_not_match = 5; + uint32 unknown_upgrade_policy = 6; + PackageIdDoesNotMatch package_id_does_not_match = 7; + } +} + +message PackageIdDoesNotMatch { + optional ObjectId package_id = 1; + optional ObjectId object_id = 2; +} + +message TypeArgumentError { + optional uint32 type_argument = 1; + + oneof kind { + google.protobuf.Empty type_not_found = 2; + google.protobuf.Empty constraint_not_satisfied = 3; + } +} + +// End ExecutionStatus }}} + +// Signatures {{{ + +message UserSignature { + oneof signature { + SimpleSignature simple = 1; + MultisigAggregatedSignature multisig = 2; + ZkLoginAuthenticator zklogin = 3; + PasskeyAuthenticator passkey = 4; + } +} + +// note: values do not match their bcs serialized values +enum SignatureScheme { + SIGNATURE_SCHEME_UNKNOWN = 0; + SIGNATURE_SCHEME_ED25519 = 1; + SIGNATURE_SCHEME_SECP256K1 = 2; + SIGNATURE_SCHEME_SECP256R1 = 3; + SIGNATURE_SCHEME_MULTISIG = 4; + SIGNATURE_SCHEME_BLS12381 = 5; + SIGNATURE_SCHEME_ZKLOGIN = 6; + SIGNATURE_SCHEME_PASSKEY = 7; +} + +message SimpleSignature { + optional SignatureScheme scheme = 1; + optional bytes signature = 2; + optional bytes public_key = 3; +} + +message ZkLoginPublicIdentifier { + optional bytes iss = 1; + optional Bn254FieldElement address_seed = 2; +} + +message MultisigMemberPublicKey { + oneof scheme { + bytes ed25519 = 1; + bytes secp256k1 = 2; + bytes secp256r1 = 3; + ZkLoginPublicIdentifier zklogin = 4; + } +} + +message MultisigMember { + optional MultisigMemberPublicKey public_key = 1; + optional uint32 weight = 2; +} + +message MultisigCommittee { + repeated MultisigMember members = 1; + optional uint32 threshold = 2; +} + +message MultisigAggregatedSignature { + repeated MultisigMemberSignature signatures = 1; + optional uint32 bitmap = 2; + optional RoaringBitmap legacy_bitmap = 3; + optional MultisigCommittee committee = 4; +} + +message MultisigMemberSignature { + oneof signature { + bytes ed25519 = 1; + bytes secp256k1 = 2; + bytes secp256r1 = 3; + ZkLoginAuthenticator zklogin = 4; + } +} + +message ZkLoginAuthenticator { + optional ZkLoginInputs inputs = 1; + optional uint64 max_epoch = 2; + optional SimpleSignature signature = 3; +} + +message ZkLoginInputs { + optional ZkLoginProof proof_points = 1; + optional ZkLoginClaim iss_base64_details = 2; + optional bytes header_base64 = 3; + optional Bn254FieldElement address_seed = 4; +} + +message ZkLoginProof { + optional CircomG1 a = 1; + optional CircomG2 b = 2; + optional CircomG1 c = 3; +} + +message ZkLoginClaim { + optional bytes value = 1; + optional uint32 index_mod_4 = 2; +} + +message CircomG1 { + optional Bn254FieldElement e0 = 1; + optional Bn254FieldElement e1 = 2; + optional Bn254FieldElement e2 = 3; +} + +message CircomG2 { + optional Bn254FieldElement e00 = 1; + optional Bn254FieldElement e01 = 2; + + optional Bn254FieldElement e10 = 3; + optional Bn254FieldElement e11 = 4; + + optional Bn254FieldElement e20 = 5; + optional Bn254FieldElement e21 = 6; +} + +message Bn254FieldElement { + optional bytes element = 1; +} + +message PasskeyAuthenticator { + optional bytes authenticator_data = 1; + optional bytes client_data_json = 2; + optional SimpleSignature signature = 3; +} + +message ValidatorCommittee { + optional uint64 epoch = 1; + repeated ValidatorCommitteeMember members = 2; +} + +message ValidatorCommitteeMember { + optional bytes public_key = 1; + optional uint64 stake = 2; +} + +message ValidatorAggregatedSignature { + optional uint64 epoch = 1; + optional bytes signature = 2; + optional RoaringBitmap bitmap = 3; +} + +message RoaringBitmap { + optional bytes bitmap = 1; +} + +// End Signatures }}} diff --git a/crates/sui-rpc-api/src/proto/generated/sui.node.v2.rs b/crates/sui-rpc-api/src/proto/generated/sui.node.v2.rs new file mode 100644 index 0000000000000..50757016c38a4 --- /dev/null +++ b/crates/sui-rpc-api/src/proto/generated/sui.node.v2.rs @@ -0,0 +1,1178 @@ +// This file is @generated by prost-build. +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetNodeInfoResponse { + /// The chain identifier of the chain that this Node is on + #[prost(message, optional, tag = "1")] + pub chain_id: ::core::option::Option, + /// Human readable name of the chain that this Node is on + #[prost(string, optional, tag = "2")] + pub chain: ::core::option::Option<::prost::alloc::string::String>, + /// Current epoch of the Node based on its highest executed checkpoint + #[prost(uint64, optional, tag = "3")] + pub epoch: ::core::option::Option, + /// Checkpoint height of the most recently executed checkpoint + #[prost(uint64, optional, tag = "4")] + pub checkpoint_height: ::core::option::Option, + /// Unix timestamp of the most recently executed checkpoint + #[prost(message, optional, tag = "5")] + pub timestamp: ::core::option::Option<::prost_types::Timestamp>, + /// The lowest checkpoint for which checkpoints and transaction data is available + #[prost(uint64, optional, tag = "6")] + pub lowest_available_checkpoint: ::core::option::Option, + /// The lowest checkpoint for which object data is available + #[prost(uint64, optional, tag = "7")] + pub lowest_available_checkpoint_objects: ::core::option::Option, + #[prost(string, optional, tag = "8")] + pub software_version: ::core::option::Option<::prost::alloc::string::String>, +} +#[derive(Clone, Copy, PartialEq, ::prost::Message)] +pub struct GetCommitteeRequest { + #[prost(uint64, optional, tag = "1")] + pub epoch: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetCommitteeResponse { + #[prost(message, optional, tag = "1")] + pub committee: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetTransactionRequest { + #[prost(message, optional, tag = "1")] + pub digest: ::core::option::Option, + #[prost(message, optional, tag = "3")] + pub options: ::core::option::Option, +} +#[derive(Clone, Copy, PartialEq, ::prost::Message)] +pub struct GetTransactionOptions { + /// Include the sui.types.Transaction message in the response. + /// + /// Defaults to true if not included + #[prost(bool, optional, tag = "1")] + pub transaction: ::core::option::Option, + /// Include the Transaction formatted as BCS in the response. + /// + /// Defaults to false if not included + #[prost(bool, optional, tag = "2")] + pub transaction_bcs: ::core::option::Option, + /// Include the set of sui.types.UserSignature's in the response. + /// + /// Defaults to true if not included + #[prost(bool, optional, tag = "3")] + pub signatures: ::core::option::Option, + /// Include the sui.types.TransactionEffects message in the response. + /// + /// Defaults to true if not included + #[prost(bool, optional, tag = "4")] + pub effects: ::core::option::Option, + /// Include the TransactionEffects formatted as BCS in the response. + /// + /// Defaults to false if not included + #[prost(bool, optional, tag = "5")] + pub effects_bcs: ::core::option::Option, + /// Include the sui.types.TransactionEvents message in the response. + /// + /// Defaults to true if not included + #[prost(bool, optional, tag = "6")] + pub events: ::core::option::Option, + /// Include the TransactionEvents formatted as BCS in the response. + /// + /// Defaults to false if not included + #[prost(bool, optional, tag = "7")] + pub events_bcs: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetTransactionResponse { + /// The digest of this transaction + #[prost(message, optional, tag = "1")] + pub digest: ::core::option::Option, + #[prost(message, optional, tag = "2")] + pub transaction: ::core::option::Option, + #[prost(message, optional, tag = "3")] + pub transaction_bcs: ::core::option::Option, + #[prost(message, optional, tag = "4")] + pub signatures: ::core::option::Option, + #[prost(message, optional, tag = "5")] + pub effects: ::core::option::Option, + #[prost(message, optional, tag = "6")] + pub effects_bcs: ::core::option::Option, + #[prost(message, optional, tag = "7")] + pub events: ::core::option::Option, + #[prost(message, optional, tag = "8")] + pub events_bcs: ::core::option::Option, + #[prost(uint64, optional, tag = "9")] + pub checkpoint: ::core::option::Option, + #[prost(message, optional, tag = "10")] + pub timestamp: ::core::option::Option<::prost_types::Timestamp>, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct UserSignatures { + #[prost(message, repeated, tag = "1")] + pub signatures: ::prost::alloc::vec::Vec, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetObjectRequest { + #[prost(message, optional, tag = "1")] + pub object_id: ::core::option::Option, + #[prost(uint64, optional, tag = "2")] + pub version: ::core::option::Option, + #[prost(message, optional, tag = "3")] + pub options: ::core::option::Option, +} +#[derive(Clone, Copy, PartialEq, ::prost::Message)] +pub struct GetObjectOptions { + /// Include the sui.types.Object message in the response. + /// + /// Defaults to true if not included + #[prost(bool, optional, tag = "1")] + pub object: ::core::option::Option, + /// Include the Object formatted as BCS in the response. + /// + /// Defaults to false if not included + #[prost(bool, optional, tag = "2")] + pub object_bcs: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetObjectResponse { + #[prost(message, optional, tag = "1")] + pub object_id: ::core::option::Option, + #[prost(uint64, optional, tag = "2")] + pub version: ::core::option::Option, + /// The digest of this object + #[prost(message, optional, tag = "3")] + pub digest: ::core::option::Option, + #[prost(message, optional, tag = "4")] + pub object: ::core::option::Option, + #[prost(message, optional, tag = "5")] + pub object_bcs: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetCheckpointRequest { + #[prost(uint64, optional, tag = "1")] + pub sequence_number: ::core::option::Option, + #[prost(message, optional, tag = "2")] + pub digest: ::core::option::Option, + #[prost(message, optional, tag = "3")] + pub options: ::core::option::Option, +} +#[derive(Clone, Copy, PartialEq, ::prost::Message)] +pub struct GetCheckpointOptions { + /// Include the sui.types.CheckpointSummary in the response. + /// + /// Defaults to true if not included + #[prost(bool, optional, tag = "3")] + pub summary: ::core::option::Option, + /// Include the CheckpointSummary formatted as BCS in the response. + /// + /// Defaults to false if not included + #[prost(bool, optional, tag = "4")] + pub summary_bcs: ::core::option::Option, + /// Include the sui.types.ValidatorAggregatedSignature in the response. + /// + /// Defaults to true if not included + #[prost(bool, optional, tag = "5")] + pub signature: ::core::option::Option, + /// Include the sui.types.CheckpointContents message in the response. + /// + /// Defaults to false if not included + #[prost(bool, optional, tag = "6")] + pub contents: ::core::option::Option, + /// Include the CheckpointContents formatted as BCS in the response. + /// + /// Defaults to false if not included + #[prost(bool, optional, tag = "7")] + pub contents_bcs: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetCheckpointResponse { + /// The sequence number of this Checkpoint + #[prost(uint64, optional, tag = "1")] + pub sequence_number: ::core::option::Option, + /// The digest of this Checkpoint's CheckpointSummary + #[prost(message, optional, tag = "2")] + pub digest: ::core::option::Option, + #[prost(message, optional, tag = "3")] + pub summary: ::core::option::Option, + #[prost(message, optional, tag = "4")] + pub summary_bcs: ::core::option::Option, + #[prost(message, optional, tag = "5")] + pub signature: ::core::option::Option< + super::super::types::ValidatorAggregatedSignature, + >, + #[prost(message, optional, tag = "6")] + pub contents: ::core::option::Option, + #[prost(message, optional, tag = "7")] + pub contents_bcs: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetFullCheckpointRequest { + #[prost(uint64, optional, tag = "1")] + pub sequence_number: ::core::option::Option, + #[prost(message, optional, tag = "2")] + pub digest: ::core::option::Option, + #[prost(message, optional, tag = "3")] + pub options: ::core::option::Option, +} +#[derive(Clone, Copy, PartialEq, ::prost::Message)] +pub struct GetFullCheckpointOptions { + /// Include the sui.types.CheckpointSummary in the response. + /// + /// Defaults to true if not included + #[prost(bool, optional, tag = "3")] + pub summary: ::core::option::Option, + /// Include the CheckpointSummary formatted as BCS in the response. + /// + /// Defaults to false if not included + #[prost(bool, optional, tag = "4")] + pub summary_bcs: ::core::option::Option, + /// Include the sui.types.ValidatorAggregatedSignature in the response. + /// + /// Defaults to true if not included + #[prost(bool, optional, tag = "5")] + pub signature: ::core::option::Option, + /// Include the sui.types.CheckpointContents message in the response. + /// + /// Defaults to false if not included + #[prost(bool, optional, tag = "6")] + pub contents: ::core::option::Option, + /// Include the CheckpointContents formatted as BCS in the response. + /// + /// Defaults to false if not included + #[prost(bool, optional, tag = "7")] + pub contents_bcs: ::core::option::Option, + /// Include the sui.types.Transaction message in the response. + /// + /// Defaults to true if not included + #[prost(bool, optional, tag = "8")] + pub transaction: ::core::option::Option, + /// Include the Transaction formatted as BCS in the response. + /// + /// Defaults to false if not included + #[prost(bool, optional, tag = "9")] + pub transaction_bcs: ::core::option::Option, + /// Include the sui.types.TransactionEffects message in the response. + /// + /// Defaults to true if not included + #[prost(bool, optional, tag = "10")] + pub effects: ::core::option::Option, + /// Include the TransactionEffects formatted as BCS in the response. + /// + /// Defaults to false if not included + #[prost(bool, optional, tag = "11")] + pub effects_bcs: ::core::option::Option, + /// Include the sui.types.TransactionEvents message in the response. + /// + /// Defaults to true if not included + #[prost(bool, optional, tag = "12")] + pub events: ::core::option::Option, + /// Include the TransactionEvents formatted as BCS in the response. + /// + /// Defaults to false if not included + #[prost(bool, optional, tag = "13")] + pub events_bcs: ::core::option::Option, + #[prost(bool, optional, tag = "14")] + pub input_objects: ::core::option::Option, + #[prost(bool, optional, tag = "15")] + pub output_objects: ::core::option::Option, + /// Include the sui.types.Object message in the response. + /// + /// Defaults to true if not included + #[prost(bool, optional, tag = "16")] + pub object: ::core::option::Option, + /// Include the Object formatted as BCS in the response. + /// + /// Defaults to false if not included + #[prost(bool, optional, tag = "17")] + pub object_bcs: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetFullCheckpointResponse { + /// The sequence number of this Checkpoint + #[prost(uint64, optional, tag = "1")] + pub sequence_number: ::core::option::Option, + /// The digest of this Checkpoint's CheckpointSummary + #[prost(message, optional, tag = "2")] + pub digest: ::core::option::Option, + #[prost(message, optional, tag = "3")] + pub summary: ::core::option::Option, + #[prost(message, optional, tag = "4")] + pub summary_bcs: ::core::option::Option, + #[prost(message, optional, tag = "5")] + pub signature: ::core::option::Option< + super::super::types::ValidatorAggregatedSignature, + >, + #[prost(message, optional, tag = "6")] + pub contents: ::core::option::Option, + #[prost(message, optional, tag = "7")] + pub contents_bcs: ::core::option::Option, + #[prost(message, repeated, tag = "8")] + pub transactions: ::prost::alloc::vec::Vec, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct FullCheckpointTransaction { + /// The digest of this transaction + #[prost(message, optional, tag = "1")] + pub digest: ::core::option::Option, + #[prost(message, optional, tag = "2")] + pub transaction: ::core::option::Option, + #[prost(message, optional, tag = "3")] + pub transaction_bcs: ::core::option::Option, + #[prost(message, optional, tag = "5")] + pub effects: ::core::option::Option, + #[prost(message, optional, tag = "6")] + pub effects_bcs: ::core::option::Option, + #[prost(message, optional, tag = "7")] + pub events: ::core::option::Option, + #[prost(message, optional, tag = "8")] + pub events_bcs: ::core::option::Option, + #[prost(message, optional, tag = "11")] + pub input_objects: ::core::option::Option, + #[prost(message, optional, tag = "12")] + pub output_objects: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct FullCheckpointObjects { + #[prost(message, repeated, tag = "1")] + pub objects: ::prost::alloc::vec::Vec, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct FullCheckpointObject { + #[prost(message, optional, tag = "1")] + pub object_id: ::core::option::Option, + #[prost(uint64, optional, tag = "2")] + pub version: ::core::option::Option, + /// The digest of this object + #[prost(message, optional, tag = "3")] + pub digest: ::core::option::Option, + #[prost(message, optional, tag = "4")] + pub object: ::core::option::Option, + #[prost(message, optional, tag = "5")] + pub object_bcs: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct BalanceChange { + #[prost(message, optional, tag = "1")] + pub address: ::core::option::Option, + #[prost(message, optional, tag = "2")] + pub coin_type: ::core::option::Option, + #[prost(message, optional, tag = "3")] + pub amount: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct BalanceChanges { + #[prost(message, repeated, tag = "4")] + pub balance_changes: ::prost::alloc::vec::Vec, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct EffectsFinality { + #[prost(oneof = "effects_finality::Finality", tags = "1, 2, 3")] + pub finality: ::core::option::Option, +} +/// Nested message and enum types in `EffectsFinality`. +pub mod effects_finality { + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Finality { + #[prost(message, tag = "1")] + Certified(super::super::super::types::ValidatorAggregatedSignature), + #[prost(uint64, tag = "2")] + Checkpointed(u64), + #[prost(message, tag = "3")] + QuorumExecuted(()), + } +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ExecuteTransactionResponse { + #[prost(message, optional, tag = "1")] + pub finality: ::core::option::Option, + #[prost(message, optional, tag = "2")] + pub effects: ::core::option::Option, + #[prost(message, optional, tag = "3")] + pub effects_bcs: ::core::option::Option, + #[prost(message, optional, tag = "4")] + pub events: ::core::option::Option, + #[prost(message, optional, tag = "5")] + pub events_bcs: ::core::option::Option, + #[prost(message, optional, tag = "6")] + pub balance_changes: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ExecuteTransactionRequest { + #[prost(message, optional, tag = "1")] + pub transaction: ::core::option::Option, + #[prost(message, optional, tag = "2")] + pub transaction_bcs: ::core::option::Option, + #[prost(message, repeated, tag = "3")] + pub signatures: ::prost::alloc::vec::Vec, + #[prost(message, optional, tag = "4")] + pub options: ::core::option::Option, +} +#[derive(Clone, Copy, PartialEq, ::prost::Message)] +pub struct ExecuteTransactionOptions { + /// Include the sui.types.TransactionEffects message in the response. + /// + /// Defaults to true if not included + #[prost(bool, optional, tag = "4")] + pub effects: ::core::option::Option, + /// Include the TransactionEffects formatted as BCS in the response. + /// + /// Defaults to false if not included + #[prost(bool, optional, tag = "5")] + pub effects_bcs: ::core::option::Option, + /// Include the sui.types.TransactionEvents message in the response. + /// + /// Defaults to true if not included + #[prost(bool, optional, tag = "6")] + pub events: ::core::option::Option, + /// Include the TransactionEvents formatted as BCS in the response. + /// + /// Defaults to false if not included + #[prost(bool, optional, tag = "7")] + pub events_bcs: ::core::option::Option, + /// Include the BalanceChanges in the response. + /// + /// Defaults to false if not included + #[prost(bool, optional, tag = "8")] + pub balance_changes: ::core::option::Option, +} +/// Generated client implementations. +pub mod node_client { + #![allow( + unused_variables, + dead_code, + missing_docs, + clippy::wildcard_imports, + clippy::let_unit_value, + )] + use tonic::codegen::*; + use tonic::codegen::http::Uri; + #[derive(Debug, Clone)] + pub struct NodeClient { + inner: tonic::client::Grpc, + } + impl NodeClient { + /// Attempt to create a new client by connecting to a given endpoint. + pub async fn connect(dst: D) -> Result + where + D: TryInto, + D::Error: Into, + { + let conn = tonic::transport::Endpoint::new(dst)?.connect().await?; + Ok(Self::new(conn)) + } + } + impl NodeClient + where + T: tonic::client::GrpcService, + T::Error: Into, + T::ResponseBody: Body + std::marker::Send + 'static, + ::Error: Into + std::marker::Send, + { + pub fn new(inner: T) -> Self { + let inner = tonic::client::Grpc::new(inner); + Self { inner } + } + pub fn with_origin(inner: T, origin: Uri) -> Self { + let inner = tonic::client::Grpc::with_origin(inner, origin); + Self { inner } + } + pub fn with_interceptor( + inner: T, + interceptor: F, + ) -> NodeClient> + where + F: tonic::service::Interceptor, + T::ResponseBody: Default, + T: tonic::codegen::Service< + http::Request, + Response = http::Response< + >::ResponseBody, + >, + >, + , + >>::Error: Into + std::marker::Send + std::marker::Sync, + { + NodeClient::new(InterceptedService::new(inner, interceptor)) + } + /// Compress requests with the given encoding. + /// + /// This requires the server to support it otherwise it might respond with an + /// error. + #[must_use] + pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self { + self.inner = self.inner.send_compressed(encoding); + self + } + /// Enable decompressing responses. + #[must_use] + pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self { + self.inner = self.inner.accept_compressed(encoding); + self + } + /// Limits the maximum size of a decoded message. + /// + /// Default: `4MB` + #[must_use] + pub fn max_decoding_message_size(mut self, limit: usize) -> Self { + self.inner = self.inner.max_decoding_message_size(limit); + self + } + /// Limits the maximum size of an encoded message. + /// + /// Default: `usize::MAX` + #[must_use] + pub fn max_encoding_message_size(mut self, limit: usize) -> Self { + self.inner = self.inner.max_encoding_message_size(limit); + self + } + pub async fn get_node_info( + &mut self, + request: impl tonic::IntoRequest<()>, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static( + "/sui.node.v2.Node/GetNodeInfo", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert(GrpcMethod::new("sui.node.v2.Node", "GetNodeInfo")); + self.inner.unary(req, path, codec).await + } + pub async fn get_committee( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static( + "/sui.node.v2.Node/GetCommittee", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert(GrpcMethod::new("sui.node.v2.Node", "GetCommittee")); + self.inner.unary(req, path, codec).await + } + pub async fn get_object( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static( + "/sui.node.v2.Node/GetObject", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert(GrpcMethod::new("sui.node.v2.Node", "GetObject")); + self.inner.unary(req, path, codec).await + } + pub async fn get_transaction( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static( + "/sui.node.v2.Node/GetTransaction", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert(GrpcMethod::new("sui.node.v2.Node", "GetTransaction")); + self.inner.unary(req, path, codec).await + } + pub async fn get_checkpoint( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static( + "/sui.node.v2.Node/GetCheckpoint", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert(GrpcMethod::new("sui.node.v2.Node", "GetCheckpoint")); + self.inner.unary(req, path, codec).await + } + pub async fn get_full_checkpoint( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static( + "/sui.node.v2.Node/GetFullCheckpoint", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert(GrpcMethod::new("sui.node.v2.Node", "GetFullCheckpoint")); + self.inner.unary(req, path, codec).await + } + pub async fn execute_transaction( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static( + "/sui.node.v2.Node/ExecuteTransaction", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert(GrpcMethod::new("sui.node.v2.Node", "ExecuteTransaction")); + self.inner.unary(req, path, codec).await + } + } +} +/// Generated server implementations. +pub mod node_server { + #![allow( + unused_variables, + dead_code, + missing_docs, + clippy::wildcard_imports, + clippy::let_unit_value, + )] + use tonic::codegen::*; + /// Generated trait containing gRPC methods that should be implemented for use with NodeServer. + #[async_trait] + pub trait Node: std::marker::Send + std::marker::Sync + 'static { + async fn get_node_info( + &self, + request: tonic::Request<()>, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; + async fn get_committee( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; + async fn get_object( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; + async fn get_transaction( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; + async fn get_checkpoint( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; + async fn get_full_checkpoint( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; + async fn execute_transaction( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; + } + #[derive(Debug)] + pub struct NodeServer { + inner: Arc, + accept_compression_encodings: EnabledCompressionEncodings, + send_compression_encodings: EnabledCompressionEncodings, + max_decoding_message_size: Option, + max_encoding_message_size: Option, + } + impl NodeServer { + pub fn new(inner: T) -> Self { + Self::from_arc(Arc::new(inner)) + } + pub fn from_arc(inner: Arc) -> Self { + Self { + inner, + accept_compression_encodings: Default::default(), + send_compression_encodings: Default::default(), + max_decoding_message_size: None, + max_encoding_message_size: None, + } + } + pub fn with_interceptor( + inner: T, + interceptor: F, + ) -> InterceptedService + where + F: tonic::service::Interceptor, + { + InterceptedService::new(Self::new(inner), interceptor) + } + /// Enable decompressing requests with the given encoding. + #[must_use] + pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self { + self.accept_compression_encodings.enable(encoding); + self + } + /// Compress responses with the given encoding, if the client supports it. + #[must_use] + pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self { + self.send_compression_encodings.enable(encoding); + self + } + /// Limits the maximum size of a decoded message. + /// + /// Default: `4MB` + #[must_use] + pub fn max_decoding_message_size(mut self, limit: usize) -> Self { + self.max_decoding_message_size = Some(limit); + self + } + /// Limits the maximum size of an encoded message. + /// + /// Default: `usize::MAX` + #[must_use] + pub fn max_encoding_message_size(mut self, limit: usize) -> Self { + self.max_encoding_message_size = Some(limit); + self + } + } + impl tonic::codegen::Service> for NodeServer + where + T: Node, + B: Body + std::marker::Send + 'static, + B::Error: Into + std::marker::Send + 'static, + { + type Response = http::Response; + type Error = std::convert::Infallible; + type Future = BoxFuture; + fn poll_ready( + &mut self, + _cx: &mut Context<'_>, + ) -> Poll> { + Poll::Ready(Ok(())) + } + fn call(&mut self, req: http::Request) -> Self::Future { + match req.uri().path() { + "/sui.node.v2.Node/GetNodeInfo" => { + #[allow(non_camel_case_types)] + struct GetNodeInfoSvc(pub Arc); + impl tonic::server::UnaryService<()> for GetNodeInfoSvc { + type Response = super::GetNodeInfoResponse; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call(&mut self, request: tonic::Request<()>) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::get_node_info(&inner, request).await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let method = GetNodeInfoSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/sui.node.v2.Node/GetCommittee" => { + #[allow(non_camel_case_types)] + struct GetCommitteeSvc(pub Arc); + impl tonic::server::UnaryService + for GetCommitteeSvc { + type Response = super::GetCommitteeResponse; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::get_committee(&inner, request).await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let method = GetCommitteeSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/sui.node.v2.Node/GetObject" => { + #[allow(non_camel_case_types)] + struct GetObjectSvc(pub Arc); + impl tonic::server::UnaryService + for GetObjectSvc { + type Response = super::GetObjectResponse; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::get_object(&inner, request).await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let method = GetObjectSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/sui.node.v2.Node/GetTransaction" => { + #[allow(non_camel_case_types)] + struct GetTransactionSvc(pub Arc); + impl< + T: Node, + > tonic::server::UnaryService + for GetTransactionSvc { + type Response = super::GetTransactionResponse; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::get_transaction(&inner, request).await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let method = GetTransactionSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/sui.node.v2.Node/GetCheckpoint" => { + #[allow(non_camel_case_types)] + struct GetCheckpointSvc(pub Arc); + impl< + T: Node, + > tonic::server::UnaryService + for GetCheckpointSvc { + type Response = super::GetCheckpointResponse; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::get_checkpoint(&inner, request).await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let method = GetCheckpointSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/sui.node.v2.Node/GetFullCheckpoint" => { + #[allow(non_camel_case_types)] + struct GetFullCheckpointSvc(pub Arc); + impl< + T: Node, + > tonic::server::UnaryService + for GetFullCheckpointSvc { + type Response = super::GetFullCheckpointResponse; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::get_full_checkpoint(&inner, request).await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let method = GetFullCheckpointSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/sui.node.v2.Node/ExecuteTransaction" => { + #[allow(non_camel_case_types)] + struct ExecuteTransactionSvc(pub Arc); + impl< + T: Node, + > tonic::server::UnaryService + for ExecuteTransactionSvc { + type Response = super::ExecuteTransactionResponse; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::execute_transaction(&inner, request).await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let method = ExecuteTransactionSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + _ => { + Box::pin(async move { + let mut response = http::Response::new(empty_body()); + let headers = response.headers_mut(); + headers + .insert( + tonic::Status::GRPC_STATUS, + (tonic::Code::Unimplemented as i32).into(), + ); + headers + .insert( + http::header::CONTENT_TYPE, + tonic::metadata::GRPC_CONTENT_TYPE, + ); + Ok(response) + }) + } + } + } + } + impl Clone for NodeServer { + fn clone(&self) -> Self { + let inner = self.inner.clone(); + Self { + inner, + accept_compression_encodings: self.accept_compression_encodings, + send_compression_encodings: self.send_compression_encodings, + max_decoding_message_size: self.max_decoding_message_size, + max_encoding_message_size: self.max_encoding_message_size, + } + } + } + /// Generated gRPC service name + pub const SERVICE_NAME: &str = "sui.node.v2.Node"; + impl tonic::server::NamedService for NodeServer { + const NAME: &'static str = SERVICE_NAME; + } +} diff --git a/crates/sui-rpc-api/src/proto/generated/sui.types.rs b/crates/sui-rpc-api/src/proto/generated/sui.types.rs new file mode 100644 index 0000000000000..fd14675edd166 --- /dev/null +++ b/crates/sui-rpc-api/src/proto/generated/sui.types.rs @@ -0,0 +1,1553 @@ +// This file is @generated by prost-build. +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Address { + #[prost(bytes = "bytes", optional, tag = "1")] + pub address: ::core::option::Option<::prost::bytes::Bytes>, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ObjectId { + #[prost(bytes = "bytes", optional, tag = "1")] + pub object_id: ::core::option::Option<::prost::bytes::Bytes>, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Digest { + #[prost(bytes = "bytes", optional, tag = "1")] + pub digest: ::core::option::Option<::prost::bytes::Bytes>, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Bcs { + #[prost(bytes = "bytes", optional, tag = "1")] + pub bcs: ::core::option::Option<::prost::bytes::Bytes>, +} +/// Little-endian encoded u128 +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct U128 { + #[prost(bytes = "bytes", optional, tag = "1")] + pub bytes: ::core::option::Option<::prost::bytes::Bytes>, +} +/// Little-endian encoded i128 +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct I128 { + #[prost(bytes = "bytes", optional, tag = "1")] + pub bytes: ::core::option::Option<::prost::bytes::Bytes>, +} +/// Little-endian encoded u256 +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct U256 { + #[prost(bytes = "bytes", optional, tag = "1")] + pub bytes: ::core::option::Option<::prost::bytes::Bytes>, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct CheckpointSummary { + #[prost(uint64, optional, tag = "1")] + pub epoch: ::core::option::Option, + #[prost(uint64, optional, tag = "2")] + pub sequence_number: ::core::option::Option, + #[prost(uint64, optional, tag = "3")] + pub total_network_transactions: ::core::option::Option, + #[prost(message, optional, tag = "4")] + pub content_digest: ::core::option::Option, + #[prost(message, optional, tag = "5")] + pub previous_digest: ::core::option::Option, + #[prost(message, optional, tag = "6")] + pub epoch_rolling_gas_cost_summary: ::core::option::Option, + #[prost(uint64, optional, tag = "7")] + pub timestamp_ms: ::core::option::Option, + #[prost(message, repeated, tag = "8")] + pub commitments: ::prost::alloc::vec::Vec, + #[prost(message, optional, tag = "9")] + pub end_of_epoch_data: ::core::option::Option, + #[prost(bytes = "bytes", optional, tag = "10")] + pub version_specific_data: ::core::option::Option<::prost::bytes::Bytes>, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct CheckpointCommitment { + #[prost(oneof = "checkpoint_commitment::Commitment", tags = "1")] + pub commitment: ::core::option::Option, +} +/// Nested message and enum types in `CheckpointCommitment`. +pub mod checkpoint_commitment { + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Commitment { + #[prost(message, tag = "1")] + EcmhLiveObjectSet(super::Digest), + } +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct EndOfEpochData { + #[prost(message, repeated, tag = "1")] + pub next_epoch_committee: ::prost::alloc::vec::Vec, + #[prost(uint64, optional, tag = "2")] + pub next_epoch_protocol_version: ::core::option::Option, + #[prost(message, repeated, tag = "3")] + pub epoch_commitments: ::prost::alloc::vec::Vec, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct CheckpointedTransactionInfo { + /// TransactionDigest + #[prost(message, optional, tag = "1")] + pub transaction: ::core::option::Option, + /// EffectsDigest + #[prost(message, optional, tag = "2")] + pub effects: ::core::option::Option, + #[prost(message, repeated, tag = "3")] + pub signatures: ::prost::alloc::vec::Vec, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct CheckpointContents { + #[prost(oneof = "checkpoint_contents::Contents", tags = "1")] + pub contents: ::core::option::Option, +} +/// Nested message and enum types in `CheckpointContents`. +pub mod checkpoint_contents { + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct V1 { + #[prost(message, repeated, tag = "1")] + pub transactions: ::prost::alloc::vec::Vec, + } + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Contents { + #[prost(message, tag = "1")] + V1(V1), + } +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct TransactionEvents { + #[prost(message, repeated, tag = "1")] + pub events: ::prost::alloc::vec::Vec, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Event { + #[prost(message, optional, tag = "1")] + pub package_id: ::core::option::Option, + #[prost(message, optional, tag = "2")] + pub module: ::core::option::Option, + #[prost(message, optional, tag = "3")] + pub sender: ::core::option::Option
, + #[prost(message, optional, tag = "4")] + pub event_type: ::core::option::Option, + #[prost(bytes = "bytes", optional, tag = "5")] + pub contents: ::core::option::Option<::prost::bytes::Bytes>, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ObjectReference { + #[prost(message, optional, tag = "1")] + pub object_id: ::core::option::Option, + #[prost(uint64, optional, tag = "2")] + pub version: ::core::option::Option, + #[prost(message, optional, tag = "3")] + pub digest: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct MovePackage { + #[prost(message, optional, tag = "1")] + pub id: ::core::option::Option, + #[prost(uint64, optional, tag = "2")] + pub version: ::core::option::Option, + #[prost(message, repeated, tag = "3")] + pub modules: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag = "4")] + pub type_origin_table: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag = "5")] + pub linkage_table: ::prost::alloc::vec::Vec, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct MoveModule { + #[prost(message, optional, tag = "1")] + pub name: ::core::option::Option, + #[prost(bytes = "bytes", optional, tag = "2")] + pub contents: ::core::option::Option<::prost::bytes::Bytes>, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct TypeOrigin { + #[prost(message, optional, tag = "1")] + pub module_name: ::core::option::Option, + #[prost(message, optional, tag = "2")] + pub struct_name: ::core::option::Option, + #[prost(message, optional, tag = "3")] + pub package_id: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct UpgradeInfo { + #[prost(message, optional, tag = "1")] + pub original_id: ::core::option::Option, + #[prost(message, optional, tag = "2")] + pub upgraded_id: ::core::option::Option, + #[prost(uint64, optional, tag = "3")] + pub upgraded_version: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Owner { + #[prost(oneof = "owner::Kind", tags = "1, 2, 3, 4")] + pub kind: ::core::option::Option, +} +/// Nested message and enum types in `Owner`. +pub mod owner { + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Kind { + #[prost(message, tag = "1")] + Address(super::Address), + #[prost(message, tag = "2")] + Object(super::ObjectId), + #[prost(uint64, tag = "3")] + Shared(u64), + #[prost(message, tag = "4")] + Immutable(()), + } +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct MoveStruct { + #[prost(message, optional, tag = "1")] + pub object_id: ::core::option::Option, + #[prost(message, optional, tag = "2")] + pub object_type: ::core::option::Option, + #[prost(bool, optional, tag = "3")] + pub has_public_transfer: ::core::option::Option, + #[prost(uint64, optional, tag = "4")] + pub version: ::core::option::Option, + #[prost(bytes = "bytes", optional, tag = "5")] + pub contents: ::core::option::Option<::prost::bytes::Bytes>, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Object { + #[prost(message, optional, tag = "1")] + pub object_id: ::core::option::Option, + #[prost(uint64, optional, tag = "2")] + pub version: ::core::option::Option, + #[prost(message, optional, tag = "3")] + pub owner: ::core::option::Option, + #[prost(message, optional, tag = "4")] + pub object: ::core::option::Option, + #[prost(message, optional, tag = "5")] + pub previous_transaction: ::core::option::Option, + #[prost(uint64, optional, tag = "6")] + pub storage_rebate: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ObjectData { + #[prost(oneof = "object_data::Kind", tags = "1, 2")] + pub kind: ::core::option::Option, +} +/// Nested message and enum types in `ObjectData`. +pub mod object_data { + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Kind { + #[prost(message, tag = "1")] + Struct(super::MoveStruct), + #[prost(message, tag = "2")] + Package(super::MovePackage), + } +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GenesisObject { + #[prost(message, optional, tag = "1")] + pub object_id: ::core::option::Option, + #[prost(uint64, optional, tag = "2")] + pub version: ::core::option::Option, + #[prost(message, optional, tag = "3")] + pub owner: ::core::option::Option, + #[prost(message, optional, tag = "4")] + pub object: ::core::option::Option, +} +#[derive(Clone, Copy, PartialEq, ::prost::Message)] +pub struct GasCostSummary { + #[prost(uint64, optional, tag = "1")] + pub computation_cost: ::core::option::Option, + #[prost(uint64, optional, tag = "2")] + pub storage_cost: ::core::option::Option, + #[prost(uint64, optional, tag = "3")] + pub storage_rebate: ::core::option::Option, + #[prost(uint64, optional, tag = "4")] + pub non_refundable_storage_fee: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Identifier { + #[prost(bytes = "bytes", optional, tag = "1")] + pub identifier: ::core::option::Option<::prost::bytes::Bytes>, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct StructTag { + #[prost(message, optional, tag = "1")] + pub address: ::core::option::Option
, + #[prost(message, optional, tag = "2")] + pub module: ::core::option::Option, + #[prost(message, optional, tag = "3")] + pub name: ::core::option::Option, + #[prost(message, repeated, tag = "4")] + pub type_parameters: ::prost::alloc::vec::Vec, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct TypeTag { + #[prost(oneof = "type_tag::Tag", tags = "1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11")] + pub tag: ::core::option::Option, +} +/// Nested message and enum types in `TypeTag`. +pub mod type_tag { + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Tag { + #[prost(message, tag = "1")] + U8(()), + #[prost(message, tag = "2")] + U16(()), + #[prost(message, tag = "3")] + U32(()), + #[prost(message, tag = "4")] + U64(()), + #[prost(message, tag = "5")] + U128(()), + #[prost(message, tag = "6")] + U256(()), + #[prost(message, tag = "7")] + Bool(()), + #[prost(message, tag = "8")] + Address(()), + #[prost(message, tag = "9")] + Signer(()), + #[prost(message, tag = "10")] + Vector(::prost::alloc::boxed::Box), + #[prost(message, tag = "11")] + Struct(super::StructTag), + } +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct MoveStructValue { + #[prost(message, optional, tag = "1")] + pub struct_type: ::core::option::Option, + #[prost(message, repeated, tag = "2")] + pub fields: ::prost::alloc::vec::Vec, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct MoveField { + #[prost(message, optional, tag = "1")] + pub name: ::core::option::Option, + #[prost(message, optional, tag = "2")] + pub value: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct MoveVariant { + #[prost(message, optional, tag = "1")] + pub enum_type: ::core::option::Option, + #[prost(message, optional, tag = "2")] + pub variant_name: ::core::option::Option, + #[prost(uint32, optional, tag = "3")] + pub tag: ::core::option::Option, + #[prost(message, repeated, tag = "4")] + pub fields: ::prost::alloc::vec::Vec, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct MoveValue { + #[prost(oneof = "move_value::Kind", tags = "2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13")] + pub kind: ::core::option::Option, +} +/// Nested message and enum types in `MoveValue`. +pub mod move_value { + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Kind { + #[prost(bool, tag = "2")] + Bool(bool), + #[prost(uint32, tag = "3")] + U8(u32), + #[prost(uint32, tag = "4")] + U16(u32), + #[prost(uint32, tag = "5")] + U32(u32), + #[prost(uint64, tag = "6")] + U64(u64), + #[prost(message, tag = "7")] + U128(super::U128), + #[prost(message, tag = "8")] + U256(super::U256), + #[prost(message, tag = "9")] + Address(super::Address), + #[prost(message, tag = "10")] + Vector(super::MoveVector), + #[prost(message, tag = "11")] + Struct(super::MoveStructValue), + #[prost(message, tag = "12")] + Signer(super::Address), + #[prost(message, tag = "13")] + Variant(super::MoveVariant), + } +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct MoveVector { + #[prost(message, repeated, tag = "1")] + pub values: ::prost::alloc::vec::Vec, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Transaction { + #[prost(oneof = "transaction::Version", tags = "1")] + pub version: ::core::option::Option, +} +/// Nested message and enum types in `Transaction`. +pub mod transaction { + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct TransactionV1 { + #[prost(message, optional, tag = "1")] + pub kind: ::core::option::Option, + #[prost(message, optional, tag = "2")] + pub sender: ::core::option::Option, + #[prost(message, optional, tag = "3")] + pub gas_payment: ::core::option::Option, + #[prost(message, optional, tag = "4")] + pub expiration: ::core::option::Option, + } + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Version { + #[prost(message, tag = "1")] + V1(TransactionV1), + } +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GasPayment { + #[prost(message, repeated, tag = "1")] + pub objects: ::prost::alloc::vec::Vec, + #[prost(message, optional, tag = "2")] + pub owner: ::core::option::Option
, + #[prost(uint64, optional, tag = "3")] + pub price: ::core::option::Option, + #[prost(uint64, optional, tag = "4")] + pub budget: ::core::option::Option, +} +#[derive(Clone, Copy, PartialEq, ::prost::Message)] +pub struct TransactionExpiration { + #[prost(oneof = "transaction_expiration::Expiration", tags = "1, 2")] + pub expiration: ::core::option::Option, +} +/// Nested message and enum types in `TransactionExpiration`. +pub mod transaction_expiration { + #[derive(Clone, Copy, PartialEq, ::prost::Oneof)] + pub enum Expiration { + #[prost(message, tag = "1")] + None(()), + #[prost(uint64, tag = "2")] + Epoch(u64), + } +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct RandomnessStateUpdate { + #[prost(uint64, optional, tag = "1")] + pub epoch: ::core::option::Option, + #[prost(uint64, optional, tag = "2")] + pub randomness_round: ::core::option::Option, + #[prost(bytes = "bytes", optional, tag = "3")] + pub random_bytes: ::core::option::Option<::prost::bytes::Bytes>, + #[prost(uint64, optional, tag = "4")] + pub randomness_object_initial_shared_version: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct TransactionKind { + #[prost(oneof = "transaction_kind::Kind", tags = "1, 2, 200, 201, 3, 4, 5, 202, 6")] + pub kind: ::core::option::Option, +} +/// Nested message and enum types in `TransactionKind`. +pub mod transaction_kind { + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Kind { + #[prost(message, tag = "1")] + ProgrammableTransaction(super::ProgrammableTransaction), + #[prost(message, tag = "2")] + ChangeEpoch(super::ChangeEpoch), + #[prost(message, tag = "200")] + Genesis(super::GenesisTransaction), + #[prost(message, tag = "201")] + ConsensusCommitPrologueV1(super::ConsensusCommitPrologue), + #[prost(message, tag = "3")] + AuthenticatorStateUpdate(super::AuthenticatorStateUpdate), + #[prost(message, tag = "4")] + EndOfEpoch(super::EndOfEpochTransaction), + #[prost(message, tag = "5")] + RandomnessStateUpdate(super::RandomnessStateUpdate), + #[prost(message, tag = "202")] + ConsensusCommitPrologueV2(super::ConsensusCommitPrologue), + #[prost(message, tag = "6")] + ConsensusCommitPrologueV3(super::ConsensusCommitPrologue), + } +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ProgrammableTransaction { + #[prost(message, repeated, tag = "1")] + pub inputs: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag = "2")] + pub commands: ::prost::alloc::vec::Vec, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Input { + #[prost(oneof = "input::Kind", tags = "1, 2, 3, 4")] + pub kind: ::core::option::Option, +} +/// Nested message and enum types in `Input`. +pub mod input { + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Kind { + #[prost(bytes, tag = "1")] + Pure(::prost::bytes::Bytes), + #[prost(message, tag = "2")] + ImmutableOrOwned(super::ObjectReference), + #[prost(message, tag = "3")] + Shared(super::SharedObjectInput), + #[prost(message, tag = "4")] + Receiving(super::ObjectReference), + } +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct SharedObjectInput { + #[prost(message, optional, tag = "1")] + pub object_id: ::core::option::Option, + #[prost(uint64, optional, tag = "2")] + pub initial_shared_version: ::core::option::Option, + #[prost(bool, optional, tag = "3")] + pub mutable: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Command { + #[prost(oneof = "command::Command", tags = "1, 2, 3, 4, 5, 6, 7")] + pub command: ::core::option::Option, +} +/// Nested message and enum types in `Command`. +pub mod command { + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Command { + #[prost(message, tag = "1")] + MoveCall(super::MoveCall), + #[prost(message, tag = "2")] + TransferObjects(super::TransferObjects), + #[prost(message, tag = "3")] + SplitCoins(super::SplitCoins), + #[prost(message, tag = "4")] + MergeCoins(super::MergeCoins), + #[prost(message, tag = "5")] + Publish(super::Publish), + #[prost(message, tag = "6")] + MakeMoveVector(super::MakeMoveVector), + #[prost(message, tag = "7")] + Upgrade(super::Upgrade), + } +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct MoveCall { + #[prost(message, optional, tag = "1")] + pub package: ::core::option::Option, + #[prost(message, optional, tag = "2")] + pub module: ::core::option::Option, + #[prost(message, optional, tag = "3")] + pub function: ::core::option::Option, + #[prost(message, repeated, tag = "4")] + pub type_arguments: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag = "5")] + pub arguments: ::prost::alloc::vec::Vec, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct TransferObjects { + #[prost(message, repeated, tag = "1")] + pub objects: ::prost::alloc::vec::Vec, + #[prost(message, optional, tag = "2")] + pub address: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct SplitCoins { + #[prost(message, optional, tag = "1")] + pub coin: ::core::option::Option, + #[prost(message, repeated, tag = "2")] + pub amounts: ::prost::alloc::vec::Vec, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct MergeCoins { + #[prost(message, optional, tag = "1")] + pub coin: ::core::option::Option, + #[prost(message, repeated, tag = "2")] + pub coins_to_merge: ::prost::alloc::vec::Vec, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Publish { + #[prost(bytes = "bytes", repeated, tag = "1")] + pub modules: ::prost::alloc::vec::Vec<::prost::bytes::Bytes>, + #[prost(message, repeated, tag = "2")] + pub dependencies: ::prost::alloc::vec::Vec, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct MakeMoveVector { + #[prost(message, optional, tag = "1")] + pub element_type: ::core::option::Option, + #[prost(message, repeated, tag = "2")] + pub elements: ::prost::alloc::vec::Vec, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Upgrade { + #[prost(bytes = "bytes", repeated, tag = "1")] + pub modules: ::prost::alloc::vec::Vec<::prost::bytes::Bytes>, + #[prost(message, repeated, tag = "2")] + pub dependencies: ::prost::alloc::vec::Vec, + #[prost(message, optional, tag = "3")] + pub package: ::core::option::Option, + #[prost(message, optional, tag = "4")] + pub ticket: ::core::option::Option, +} +#[derive(Clone, Copy, PartialEq, ::prost::Message)] +pub struct Argument { + #[prost(oneof = "argument::Kind", tags = "1, 2, 3, 4")] + pub kind: ::core::option::Option, +} +/// Nested message and enum types in `Argument`. +pub mod argument { + #[derive(Clone, Copy, PartialEq, ::prost::Oneof)] + pub enum Kind { + #[prost(message, tag = "1")] + Gas(()), + #[prost(uint32, tag = "2")] + Input(u32), + #[prost(uint32, tag = "3")] + Result(u32), + #[prost(message, tag = "4")] + NestedResult(super::NestedResult), + } +} +#[derive(Clone, Copy, PartialEq, ::prost::Message)] +pub struct NestedResult { + #[prost(uint32, optional, tag = "1")] + pub result: ::core::option::Option, + #[prost(uint32, optional, tag = "2")] + pub subresult: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ChangeEpoch { + /// The next (to become) epoch ID. + #[prost(uint64, optional, tag = "1")] + pub epoch: ::core::option::Option, + /// The protocol version in effect in the new epoch. + #[prost(uint64, optional, tag = "2")] + pub protocol_version: ::core::option::Option, + /// The total amount of gas charged for storage during the epoch. + #[prost(uint64, optional, tag = "3")] + pub storage_charge: ::core::option::Option, + /// The total amount of gas charged for computation during the epoch. + #[prost(uint64, optional, tag = "4")] + pub computation_charge: ::core::option::Option, + /// The amount of storage rebate refunded to the txn senders. + #[prost(uint64, optional, tag = "5")] + pub storage_rebate: ::core::option::Option, + /// The non-refundable storage fee. + #[prost(uint64, optional, tag = "6")] + pub non_refundable_storage_fee: ::core::option::Option, + /// Unix timestamp when epoch started + #[prost(uint64, optional, tag = "7")] + pub epoch_start_timestamp_ms: ::core::option::Option, + /// System packages (specifically framework and move stdlib) that are written before the new + /// epoch starts. This tracks framework upgrades on chain. When executing the ChangeEpoch txn, + /// the validator must write out the modules below. Modules are provided with the version they + /// will be upgraded to, their modules in serialized form (which include their package ID), and + /// a list of their transitive dependencies. + #[prost(message, repeated, tag = "8")] + pub system_packages: ::prost::alloc::vec::Vec, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct SystemPackage { + #[prost(uint64, optional, tag = "1")] + pub version: ::core::option::Option, + #[prost(bytes = "bytes", repeated, tag = "2")] + pub modules: ::prost::alloc::vec::Vec<::prost::bytes::Bytes>, + #[prost(message, repeated, tag = "3")] + pub dependencies: ::prost::alloc::vec::Vec, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GenesisTransaction { + #[prost(message, repeated, tag = "1")] + pub objects: ::prost::alloc::vec::Vec, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ConsensusCommitPrologue { + #[prost(uint64, optional, tag = "1")] + pub epoch: ::core::option::Option, + #[prost(uint64, optional, tag = "2")] + pub round: ::core::option::Option, + #[prost(uint64, optional, tag = "3")] + pub commit_timestamp_ms: ::core::option::Option, + #[prost(message, optional, tag = "4")] + pub consensus_commit_digest: ::core::option::Option, + #[prost(uint64, optional, tag = "5")] + pub sub_dag_index: ::core::option::Option, + #[prost(message, optional, tag = "6")] + pub consensus_determined_version_assignments: ::core::option::Option< + ConsensusDeterminedVersionAssignments, + >, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct VersionAssignment { + #[prost(message, optional, tag = "1")] + pub object_id: ::core::option::Option, + #[prost(uint64, optional, tag = "2")] + pub version: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct CancelledTransaction { + #[prost(message, optional, tag = "1")] + pub digest: ::core::option::Option, + #[prost(message, repeated, tag = "2")] + pub version_assignments: ::prost::alloc::vec::Vec, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct CancelledTransactions { + #[prost(message, repeated, tag = "1")] + pub cancelled_transactions: ::prost::alloc::vec::Vec, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ConsensusDeterminedVersionAssignments { + #[prost(oneof = "consensus_determined_version_assignments::Kind", tags = "1")] + pub kind: ::core::option::Option, +} +/// Nested message and enum types in `ConsensusDeterminedVersionAssignments`. +pub mod consensus_determined_version_assignments { + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Kind { + #[prost(message, tag = "1")] + CancelledTransactions(super::CancelledTransactions), + } +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct AuthenticatorStateUpdate { + #[prost(uint64, optional, tag = "1")] + pub epoch: ::core::option::Option, + #[prost(uint64, optional, tag = "2")] + pub round: ::core::option::Option, + #[prost(message, repeated, tag = "3")] + pub new_active_jwks: ::prost::alloc::vec::Vec, + #[prost(uint64, optional, tag = "4")] + pub authenticator_object_initial_shared_version: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ActiveJwk { + #[prost(message, optional, tag = "1")] + pub id: ::core::option::Option, + #[prost(message, optional, tag = "2")] + pub jwk: ::core::option::Option, + #[prost(uint64, optional, tag = "3")] + pub epoch: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct JwkId { + #[prost(bytes = "bytes", optional, tag = "1")] + pub iss: ::core::option::Option<::prost::bytes::Bytes>, + #[prost(bytes = "bytes", optional, tag = "2")] + pub kid: ::core::option::Option<::prost::bytes::Bytes>, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Jwk { + /// Key type parameter, <> + #[prost(bytes = "bytes", optional, tag = "1")] + pub kty: ::core::option::Option<::prost::bytes::Bytes>, + /// RSA public exponent, <> + #[prost(bytes = "bytes", optional, tag = "2")] + pub e: ::core::option::Option<::prost::bytes::Bytes>, + /// RSA modulus, <> + #[prost(bytes = "bytes", optional, tag = "3")] + pub n: ::core::option::Option<::prost::bytes::Bytes>, + /// Algorithm parameter, <> + #[prost(bytes = "bytes", optional, tag = "4")] + pub alg: ::core::option::Option<::prost::bytes::Bytes>, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct EndOfEpochTransaction { + #[prost(message, repeated, tag = "1")] + pub transactions: ::prost::alloc::vec::Vec, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct EndOfEpochTransactionKind { + #[prost( + oneof = "end_of_epoch_transaction_kind::Kind", + tags = "1, 2, 200, 201, 202, 203, 204" + )] + pub kind: ::core::option::Option, +} +/// Nested message and enum types in `EndOfEpochTransactionKind`. +pub mod end_of_epoch_transaction_kind { + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Kind { + #[prost(message, tag = "1")] + ChangeEpoch(super::ChangeEpoch), + #[prost(message, tag = "2")] + AuthenticatorStateExpire(super::AuthenticatorStateExpire), + /// Use higher field numbers for kinds which happen infrequently + #[prost(message, tag = "200")] + AuthenticatorStateCreate(()), + #[prost(message, tag = "201")] + RandomnessStateCreate(()), + #[prost(message, tag = "202")] + DenyListStateCreate(()), + #[prost(message, tag = "203")] + BridgeStateCreate(super::Digest), + #[prost(uint64, tag = "204")] + BridgeCommitteeInit(u64), + } +} +#[derive(Clone, Copy, PartialEq, ::prost::Message)] +pub struct AuthenticatorStateExpire { + #[prost(uint64, optional, tag = "1")] + pub min_epoch: ::core::option::Option, + #[prost(uint64, optional, tag = "2")] + pub authenticator_object_initial_shared_version: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct TransactionEffects { + #[prost(oneof = "transaction_effects::Version", tags = "1, 2")] + pub version: ::core::option::Option, +} +/// Nested message and enum types in `TransactionEffects`. +pub mod transaction_effects { + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Version { + #[prost(message, tag = "1")] + V1(super::TransactionEffectsV1), + #[prost(message, tag = "2")] + V2(super::TransactionEffectsV2), + } +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct TransactionEffectsV1 { + /// / The status of the execution + #[prost(message, optional, tag = "1")] + pub status: ::core::option::Option, + /// / The epoch when this transaction was executed. + #[prost(uint64, optional, tag = "2")] + pub epoch: ::core::option::Option, + #[prost(message, optional, tag = "3")] + pub gas_used: ::core::option::Option, + /// / The version that every modified (mutated or deleted) object had before it was modified by + /// / this transaction. + #[prost(message, repeated, tag = "4")] + pub modified_at_versions: ::prost::alloc::vec::Vec, + /// / The object references of the shared objects used in this transaction. Empty if no shared objects were used. + #[prost(message, repeated, tag = "5")] + pub shared_objects: ::prost::alloc::vec::Vec, + /// / The transaction digest + #[prost(message, optional, tag = "6")] + pub transaction_digest: ::core::option::Option, + /// / ObjectReference and owner of new objects created. + #[prost(message, repeated, tag = "7")] + pub created: ::prost::alloc::vec::Vec, + /// / ObjectReference and owner of mutated objects, including gas object. + #[prost(message, repeated, tag = "8")] + pub mutated: ::prost::alloc::vec::Vec, + /// / ObjectReference and owner of objects that are unwrapped in this transaction. + /// / Unwrapped objects are objects that were wrapped into other objects in the past, + /// / and just got extracted out. + #[prost(message, repeated, tag = "9")] + pub unwrapped: ::prost::alloc::vec::Vec, + /// / Object Refs of objects now deleted (the new refs). + #[prost(message, repeated, tag = "10")] + pub deleted: ::prost::alloc::vec::Vec, + /// / Object refs of objects previously wrapped in other objects but now deleted. + #[prost(message, repeated, tag = "11")] + pub unwrapped_then_deleted: ::prost::alloc::vec::Vec, + /// / Object refs of objects now wrapped in other objects. + #[prost(message, repeated, tag = "12")] + pub wrapped: ::prost::alloc::vec::Vec, + /// / The updated gas object reference. Have a dedicated field for convenient access. + /// / It's also included in mutated. + #[prost(message, optional, tag = "13")] + pub gas_object: ::core::option::Option, + /// / The digest of the events emitted during execution, + /// / can be None if the transaction does not emit any event. + #[prost(message, optional, tag = "14")] + pub events_digest: ::core::option::Option, + /// / The set of transaction digests this transaction depends on. + #[prost(message, repeated, tag = "15")] + pub dependencies: ::prost::alloc::vec::Vec, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ObjectReferenceWithOwner { + #[prost(message, optional, tag = "1")] + pub reference: ::core::option::Option, + #[prost(message, optional, tag = "2")] + pub owner: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ModifiedAtVersion { + #[prost(message, optional, tag = "1")] + pub object_id: ::core::option::Option, + #[prost(uint64, optional, tag = "2")] + pub version: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct TransactionEffectsV2 { + /// / The status of the execution + #[prost(message, optional, tag = "1")] + pub status: ::core::option::Option, + /// / The epoch when this transaction was executed. + #[prost(uint64, optional, tag = "2")] + pub epoch: ::core::option::Option, + #[prost(message, optional, tag = "3")] + pub gas_used: ::core::option::Option, + /// / The transaction digest + #[prost(message, optional, tag = "4")] + pub transaction_digest: ::core::option::Option, + /// / The updated gas object reference, as an index into the `changed_objects` vector. + /// / Having a dedicated field for convenient access. + /// / System transaction that don't require gas will leave this as None. + #[prost(uint32, optional, tag = "5")] + pub gas_object_index: ::core::option::Option, + /// / The digest of the events emitted during execution, + /// / can be None if the transaction does not emit any event. + #[prost(message, optional, tag = "6")] + pub events_digest: ::core::option::Option, + /// / The set of transaction digests this transaction depends on. + #[prost(message, repeated, tag = "7")] + pub dependencies: ::prost::alloc::vec::Vec, + /// / The version number of all the written Move objects by this transaction. + #[prost(uint64, optional, tag = "8")] + pub lamport_version: ::core::option::Option, + /// / Objects whose state are changed in the object store. + #[prost(message, repeated, tag = "9")] + pub changed_objects: ::prost::alloc::vec::Vec, + /// / Shared objects that are not mutated in this transaction. Unlike owned objects, + /// / read-only shared objects' version are not committed in the transaction, + /// / and in order for a node to catch up and execute it without consensus sequencing, + /// / the version needs to be committed in the effects. + #[prost(message, repeated, tag = "10")] + pub unchanged_shared_objects: ::prost::alloc::vec::Vec, + /// / Auxiliary data that are not protocol-critical, generated as part of the effects but are stored separately. + /// / Storing it separately allows us to avoid bloating the effects with data that are not critical. + /// / It also provides more flexibility on the format and type of the data. + #[prost(message, optional, tag = "11")] + pub auxiliary_data_digest: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ChangedObject { + #[prost(message, optional, tag = "1")] + pub object_id: ::core::option::Option, + #[prost(oneof = "changed_object::InputState", tags = "2, 3")] + pub input_state: ::core::option::Option, + #[prost(oneof = "changed_object::OutputState", tags = "4, 5, 6")] + pub output_state: ::core::option::Option, + #[prost(oneof = "changed_object::IdOperation", tags = "7, 8, 9")] + pub id_operation: ::core::option::Option, +} +/// Nested message and enum types in `ChangedObject`. +pub mod changed_object { + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum InputState { + #[prost(message, tag = "2")] + NotExist(()), + #[prost(message, tag = "3")] + Exist(super::ObjectExist), + } + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum OutputState { + #[prost(message, tag = "4")] + Removed(()), + #[prost(message, tag = "5")] + ObjectWrite(super::ObjectWrite), + #[prost(message, tag = "6")] + PackageWrite(super::PackageWrite), + } + #[derive(Clone, Copy, PartialEq, ::prost::Oneof)] + pub enum IdOperation { + #[prost(message, tag = "7")] + None(()), + #[prost(message, tag = "8")] + Created(()), + #[prost(message, tag = "9")] + Deleted(()), + } +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ObjectExist { + #[prost(uint64, optional, tag = "1")] + pub version: ::core::option::Option, + #[prost(message, optional, tag = "2")] + pub digest: ::core::option::Option, + #[prost(message, optional, tag = "3")] + pub owner: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ObjectWrite { + #[prost(message, optional, tag = "2")] + pub digest: ::core::option::Option, + #[prost(message, optional, tag = "3")] + pub owner: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PackageWrite { + #[prost(uint64, optional, tag = "1")] + pub version: ::core::option::Option, + #[prost(message, optional, tag = "2")] + pub digest: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct UnchangedSharedObject { + #[prost(message, optional, tag = "1")] + pub object_id: ::core::option::Option, + #[prost(oneof = "unchanged_shared_object::Kind", tags = "2, 3, 4, 5, 6")] + pub kind: ::core::option::Option, +} +/// Nested message and enum types in `UnchangedSharedObject`. +pub mod unchanged_shared_object { + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Kind { + #[prost(message, tag = "2")] + ReadOnlyRoot(super::ReadOnlyRoot), + #[prost(uint64, tag = "3")] + MutateDeleted(u64), + #[prost(uint64, tag = "4")] + ReadDeleted(u64), + #[prost(uint64, tag = "5")] + Cancelled(u64), + #[prost(message, tag = "6")] + PerEpochConfig(()), + } +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ReadOnlyRoot { + #[prost(uint64, optional, tag = "1")] + pub version: ::core::option::Option, + #[prost(message, optional, tag = "2")] + pub digest: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ExecutionStatus { + #[prost(bool, optional, tag = "1")] + pub success: ::core::option::Option, + #[prost(message, optional, tag = "2")] + pub status: ::core::option::Option, +} +#[derive(Clone, Copy, PartialEq, ::prost::Message)] +pub struct SizeError { + #[prost(uint64, optional, tag = "1")] + pub size: ::core::option::Option, + #[prost(uint64, optional, tag = "2")] + pub max_size: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct MoveError { + #[prost(message, optional, tag = "1")] + pub location: ::core::option::Option, + #[prost(uint64, optional, tag = "2")] + pub abort_code: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct FailureStatus { + #[prost(uint64, optional, tag = "1")] + pub command: ::core::option::Option, + #[prost( + oneof = "failure_status::ExecutionError", + tags = "2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38" + )] + pub execution_error: ::core::option::Option, +} +/// Nested message and enum types in `FailureStatus`. +pub mod failure_status { + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum ExecutionError { + /// / Insufficient Gas + #[prost(message, tag = "2")] + InsufficientGas(()), + /// / Invalid Gas Object. + #[prost(message, tag = "3")] + InvalidGasObject(()), + /// / Invariant Violation + #[prost(message, tag = "4")] + InvariantViolation(()), + /// / Attempted to used feature that is not supported yet + #[prost(message, tag = "5")] + FeatureNotYetSupported(()), + /// / Move object is larger than the maximum allowed size + #[prost(message, tag = "6")] + ObjectTooBig(super::SizeError), + /// / Package is larger than the maximum allowed size + #[prost(message, tag = "7")] + PackageTooBig(super::SizeError), + /// / Circular Object Ownership + #[prost(message, tag = "8")] + CircularObjectOwnership(super::ObjectId), + /// + /// Coin errors + /// + /// / Insufficient coin balance for requested operation + #[prost(message, tag = "9")] + InsufficientCoinBalance(()), + /// / Coin balance overflowed an u64 + #[prost(message, tag = "10")] + CoinBalanceOverflow(()), + /// + /// Publish/Upgrade errors + /// + /// / Publish Error, Non-zero Address. + /// / The modules in the package must have their self-addresses set to zero. + #[prost(message, tag = "11")] + PublishErrorNonZeroAddress(()), + /// / Sui Move Bytecode Verification Error. + #[prost(message, tag = "12")] + SuiMoveVerificationError(()), + /// + /// MoveVm Errors + /// + /// / Error from a non-abort instruction. + /// / Possible causes: + /// / Arithmetic error, stack overflow, max value depth, etc." + #[prost(message, tag = "13")] + MovePrimitiveRuntimeError(super::MoveError), + /// / Move runtime abort + #[prost(message, tag = "14")] + MoveAbort(super::MoveError), + /// / Bytecode verification error. + #[prost(message, tag = "15")] + VmVerificationOrDeserializationError(()), + /// / MoveVm invariant violation + #[prost(message, tag = "16")] + VmInvariantViolation(()), + /// + /// Programmable Transaction Errors + /// + /// / Function not found + #[prost(message, tag = "17")] + FunctionNotFound(()), + /// / Arity mismatch for Move function. + /// / The number of arguments does not match the number of parameters + #[prost(message, tag = "18")] + ArityMismatch(()), + /// / Type arity mismatch for Move function. + /// / Mismatch between the number of actual versus expected type arguments. + #[prost(message, tag = "19")] + TypeArityMismatch(()), + /// / Non Entry Function Invoked. Move Call must start with an entry function. + #[prost(message, tag = "20")] + NonEntryFunctionInvoked(()), + /// / Invalid command argument + #[prost(message, tag = "21")] + CommandArgumentError(super::CommandArgumentError), + /// / Type argument error + #[prost(message, tag = "22")] + TypeArgumentError(super::TypeArgumentError), + /// / Unused result without the drop ability. + #[prost(message, tag = "23")] + UnusedValueWithoutDrop(super::NestedResult), + /// / Invalid public Move function signature. + /// / Unsupported return type for return value + #[prost(uint32, tag = "24")] + InvalidPublicFunctionReturnType(u32), + /// / Invalid Transfer Object, object does not have public transfer. + #[prost(message, tag = "25")] + InvalidTransferObject(()), + /// + /// Post-execution errors + /// + /// / Effects from the transaction are too large + #[prost(message, tag = "26")] + EffectsTooLarge(super::SizeError), + /// / Publish or Upgrade is missing dependency + #[prost(message, tag = "27")] + PublishUpgradeMissingDependency(()), + /// / Publish or Upgrade dependency downgrade. + /// / + /// / Indirect (transitive) dependency of published or upgraded package has been assigned an + /// / on-chain version that is less than the version required by one of the package's + /// / transitive dependencies. + #[prost(message, tag = "28")] + PublishUpgradeDependencyDowngrade(()), + /// / Invalid package upgrade + #[prost(message, tag = "29")] + PackageUpgradeError(super::PackageUpgradeError), + /// / Indicates the transaction tried to write objects too large to storage + #[prost(message, tag = "30")] + WrittenObjectsTooLarge(super::SizeError), + /// / Certificate is on the deny list + #[prost(message, tag = "31")] + CertificateDenied(()), + /// / Sui Move Bytecode verification timed out. + #[prost(message, tag = "32")] + SuiMoveVerificationTimedout(()), + /// / The requested shared object operation is not allowed + #[prost(message, tag = "33")] + SharedObjectOperationNotAllowed(()), + /// / Requested shared object has been deleted + #[prost(message, tag = "34")] + InputObjectDeleted(()), + /// / Certificate is cancelled due to congestion on shared objects + #[prost(message, tag = "35")] + ExecutionCancelledDueToSharedObjectCongestion(super::CongestedObjectsError), + /// / Address is denied for this coin type + #[prost(message, tag = "36")] + AddressDeniedForCoin(super::AddressDeniedForCoinError), + /// / Coin type is globally paused for use + #[prost(string, tag = "37")] + CoinTypeGlobalPause(::prost::alloc::string::String), + /// / Certificate is cancelled because randomness could not be generated this epoch + #[prost(message, tag = "38")] + ExecutionCancelledDueToRandomnessUnavailable(()), + } +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct AddressDeniedForCoinError { + #[prost(message, optional, tag = "1")] + pub address: ::core::option::Option
, + #[prost(string, optional, tag = "2")] + pub coin_type: ::core::option::Option<::prost::alloc::string::String>, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct CongestedObjectsError { + #[prost(message, repeated, tag = "1")] + pub congested_objects: ::prost::alloc::vec::Vec, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct MoveLocation { + #[prost(message, optional, tag = "1")] + pub package: ::core::option::Option, + #[prost(message, optional, tag = "2")] + pub module: ::core::option::Option, + #[prost(uint32, optional, tag = "3")] + pub function: ::core::option::Option, + #[prost(uint32, optional, tag = "4")] + pub instruction: ::core::option::Option, + #[prost(message, optional, tag = "5")] + pub function_name: ::core::option::Option, +} +#[derive(Clone, Copy, PartialEq, ::prost::Message)] +pub struct CommandArgumentError { + #[prost(uint32, optional, tag = "1")] + pub argument: ::core::option::Option, + #[prost( + oneof = "command_argument_error::Kind", + tags = "2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13" + )] + pub kind: ::core::option::Option, +} +/// Nested message and enum types in `CommandArgumentError`. +pub mod command_argument_error { + #[derive(Clone, Copy, PartialEq, ::prost::Oneof)] + pub enum Kind { + /// / The type of the value does not match the expected type + #[prost(message, tag = "2")] + TypeMismatch(()), + /// / The argument cannot be deserialized into a value of the specified type + #[prost(message, tag = "3")] + InvalidBcsBytes(()), + /// / The argument cannot be instantiated from raw bytes + #[prost(message, tag = "4")] + InvalidUsageOfPureArgument(()), + /// / Invalid argument to private entry function. + /// / Private entry functions cannot take arguments from other Move functions. + #[prost(message, tag = "5")] + InvalidArgumentToPrivateEntryFunction(()), + /// / Out of bounds access to input or results + #[prost(uint32, tag = "6")] + IndexOutOfBounds(u32), + /// / Out of bounds access to subresult + #[prost(message, tag = "7")] + SecondaryIndexOutOfBounds(super::NestedResult), + /// / Invalid usage of result. + /// / Expected a single result but found either no return value or multiple. + #[prost(uint32, tag = "8")] + InvalidResultArity(u32), + /// / Invalid usage of Gas coin. + /// / The Gas coin can only be used by-value with a TransferObjects command. + #[prost(message, tag = "9")] + InvalidGasCoinUsage(()), + /// / Invalid usage of move value. + /// Mutably borrowed values require unique usage. + /// Immutably borrowed values cannot be taken or borrowed mutably. + /// Taken values cannot be used again. + #[prost(message, tag = "10")] + InvalidValueUsage(()), + /// / Immutable objects cannot be passed by-value. + #[prost(message, tag = "11")] + InvalidObjectByValue(()), + /// / Immutable objects cannot be passed by mutable reference, &mut. + #[prost(message, tag = "12")] + InvalidObjectByMutRef(()), + /// / Shared object operations such a wrapping, freezing, or converting to owned are not + /// / allowed. + #[prost(message, tag = "13")] + SharedObjectOperationNotAllowed(()), + } +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PackageUpgradeError { + #[prost(oneof = "package_upgrade_error::Kind", tags = "2, 3, 4, 5, 6, 7")] + pub kind: ::core::option::Option, +} +/// Nested message and enum types in `PackageUpgradeError`. +pub mod package_upgrade_error { + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Kind { + #[prost(message, tag = "2")] + UnableToFetchPackage(super::ObjectId), + #[prost(message, tag = "3")] + NotAPackage(super::ObjectId), + #[prost(message, tag = "4")] + IncompatibleUpgrade(()), + #[prost(message, tag = "5")] + DigetsDoesNotMatch(super::Digest), + #[prost(uint32, tag = "6")] + UnknownUpgradePolicy(u32), + #[prost(message, tag = "7")] + PackageIdDoesNotMatch(super::PackageIdDoesNotMatch), + } +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PackageIdDoesNotMatch { + #[prost(message, optional, tag = "1")] + pub package_id: ::core::option::Option, + #[prost(message, optional, tag = "2")] + pub object_id: ::core::option::Option, +} +#[derive(Clone, Copy, PartialEq, ::prost::Message)] +pub struct TypeArgumentError { + #[prost(uint32, optional, tag = "1")] + pub type_argument: ::core::option::Option, + #[prost(oneof = "type_argument_error::Kind", tags = "2, 3")] + pub kind: ::core::option::Option, +} +/// Nested message and enum types in `TypeArgumentError`. +pub mod type_argument_error { + #[derive(Clone, Copy, PartialEq, ::prost::Oneof)] + pub enum Kind { + #[prost(message, tag = "2")] + TypeNotFound(()), + #[prost(message, tag = "3")] + ConstraintNotSatisfied(()), + } +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct UserSignature { + #[prost(oneof = "user_signature::Signature", tags = "1, 2, 3, 4")] + pub signature: ::core::option::Option, +} +/// Nested message and enum types in `UserSignature`. +pub mod user_signature { + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Signature { + #[prost(message, tag = "1")] + Simple(super::SimpleSignature), + #[prost(message, tag = "2")] + Multisig(super::MultisigAggregatedSignature), + #[prost(message, tag = "3")] + Zklogin(super::ZkLoginAuthenticator), + #[prost(message, tag = "4")] + Passkey(super::PasskeyAuthenticator), + } +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct SimpleSignature { + #[prost(enumeration = "SignatureScheme", optional, tag = "1")] + pub scheme: ::core::option::Option, + #[prost(bytes = "bytes", optional, tag = "2")] + pub signature: ::core::option::Option<::prost::bytes::Bytes>, + #[prost(bytes = "bytes", optional, tag = "3")] + pub public_key: ::core::option::Option<::prost::bytes::Bytes>, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ZkLoginPublicIdentifier { + #[prost(bytes = "bytes", optional, tag = "1")] + pub iss: ::core::option::Option<::prost::bytes::Bytes>, + #[prost(message, optional, tag = "2")] + pub address_seed: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct MultisigMemberPublicKey { + #[prost(oneof = "multisig_member_public_key::Scheme", tags = "1, 2, 3, 4")] + pub scheme: ::core::option::Option, +} +/// Nested message and enum types in `MultisigMemberPublicKey`. +pub mod multisig_member_public_key { + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Scheme { + #[prost(bytes, tag = "1")] + Ed25519(::prost::bytes::Bytes), + #[prost(bytes, tag = "2")] + Secp256k1(::prost::bytes::Bytes), + #[prost(bytes, tag = "3")] + Secp256r1(::prost::bytes::Bytes), + #[prost(message, tag = "4")] + Zklogin(super::ZkLoginPublicIdentifier), + } +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct MultisigMember { + #[prost(message, optional, tag = "1")] + pub public_key: ::core::option::Option, + #[prost(uint32, optional, tag = "2")] + pub weight: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct MultisigCommittee { + #[prost(message, repeated, tag = "1")] + pub members: ::prost::alloc::vec::Vec, + #[prost(uint32, optional, tag = "2")] + pub threshold: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct MultisigAggregatedSignature { + #[prost(message, repeated, tag = "1")] + pub signatures: ::prost::alloc::vec::Vec, + #[prost(uint32, optional, tag = "2")] + pub bitmap: ::core::option::Option, + #[prost(message, optional, tag = "3")] + pub legacy_bitmap: ::core::option::Option, + #[prost(message, optional, tag = "4")] + pub committee: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct MultisigMemberSignature { + #[prost(oneof = "multisig_member_signature::Signature", tags = "1, 2, 3, 4")] + pub signature: ::core::option::Option, +} +/// Nested message and enum types in `MultisigMemberSignature`. +pub mod multisig_member_signature { + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Signature { + #[prost(bytes, tag = "1")] + Ed25519(::prost::bytes::Bytes), + #[prost(bytes, tag = "2")] + Secp256k1(::prost::bytes::Bytes), + #[prost(bytes, tag = "3")] + Secp256r1(::prost::bytes::Bytes), + #[prost(message, tag = "4")] + Zklogin(super::ZkLoginAuthenticator), + } +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ZkLoginAuthenticator { + #[prost(message, optional, tag = "1")] + pub inputs: ::core::option::Option, + #[prost(uint64, optional, tag = "2")] + pub max_epoch: ::core::option::Option, + #[prost(message, optional, tag = "3")] + pub signature: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ZkLoginInputs { + #[prost(message, optional, tag = "1")] + pub proof_points: ::core::option::Option, + #[prost(message, optional, tag = "2")] + pub iss_base64_details: ::core::option::Option, + #[prost(bytes = "bytes", optional, tag = "3")] + pub header_base64: ::core::option::Option<::prost::bytes::Bytes>, + #[prost(message, optional, tag = "4")] + pub address_seed: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ZkLoginProof { + #[prost(message, optional, tag = "1")] + pub a: ::core::option::Option, + #[prost(message, optional, tag = "2")] + pub b: ::core::option::Option, + #[prost(message, optional, tag = "3")] + pub c: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ZkLoginClaim { + #[prost(bytes = "bytes", optional, tag = "1")] + pub value: ::core::option::Option<::prost::bytes::Bytes>, + #[prost(uint32, optional, tag = "2")] + pub index_mod_4: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct CircomG1 { + #[prost(message, optional, tag = "1")] + pub e0: ::core::option::Option, + #[prost(message, optional, tag = "2")] + pub e1: ::core::option::Option, + #[prost(message, optional, tag = "3")] + pub e2: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct CircomG2 { + #[prost(message, optional, tag = "1")] + pub e00: ::core::option::Option, + #[prost(message, optional, tag = "2")] + pub e01: ::core::option::Option, + #[prost(message, optional, tag = "3")] + pub e10: ::core::option::Option, + #[prost(message, optional, tag = "4")] + pub e11: ::core::option::Option, + #[prost(message, optional, tag = "5")] + pub e20: ::core::option::Option, + #[prost(message, optional, tag = "6")] + pub e21: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Bn254FieldElement { + #[prost(bytes = "bytes", optional, tag = "1")] + pub element: ::core::option::Option<::prost::bytes::Bytes>, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PasskeyAuthenticator { + #[prost(bytes = "bytes", optional, tag = "1")] + pub authenticator_data: ::core::option::Option<::prost::bytes::Bytes>, + #[prost(bytes = "bytes", optional, tag = "2")] + pub client_data_json: ::core::option::Option<::prost::bytes::Bytes>, + #[prost(message, optional, tag = "3")] + pub signature: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ValidatorCommittee { + #[prost(uint64, optional, tag = "1")] + pub epoch: ::core::option::Option, + #[prost(message, repeated, tag = "2")] + pub members: ::prost::alloc::vec::Vec, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ValidatorCommitteeMember { + #[prost(bytes = "bytes", optional, tag = "1")] + pub public_key: ::core::option::Option<::prost::bytes::Bytes>, + #[prost(uint64, optional, tag = "2")] + pub stake: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ValidatorAggregatedSignature { + #[prost(uint64, optional, tag = "1")] + pub epoch: ::core::option::Option, + #[prost(bytes = "bytes", optional, tag = "2")] + pub signature: ::core::option::Option<::prost::bytes::Bytes>, + #[prost(message, optional, tag = "3")] + pub bitmap: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct RoaringBitmap { + #[prost(bytes = "bytes", optional, tag = "1")] + pub bitmap: ::core::option::Option<::prost::bytes::Bytes>, +} +/// note: values do not match their bcs serialized values +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] +#[repr(i32)] +pub enum SignatureScheme { + Unknown = 0, + Ed25519 = 1, + Secp256k1 = 2, + Secp256r1 = 3, + Multisig = 4, + Bls12381 = 5, + Zklogin = 6, + Passkey = 7, +} +impl SignatureScheme { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + Self::Unknown => "SIGNATURE_SCHEME_UNKNOWN", + Self::Ed25519 => "SIGNATURE_SCHEME_ED25519", + Self::Secp256k1 => "SIGNATURE_SCHEME_SECP256K1", + Self::Secp256r1 => "SIGNATURE_SCHEME_SECP256R1", + Self::Multisig => "SIGNATURE_SCHEME_MULTISIG", + Self::Bls12381 => "SIGNATURE_SCHEME_BLS12381", + Self::Zklogin => "SIGNATURE_SCHEME_ZKLOGIN", + Self::Passkey => "SIGNATURE_SCHEME_PASSKEY", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "SIGNATURE_SCHEME_UNKNOWN" => Some(Self::Unknown), + "SIGNATURE_SCHEME_ED25519" => Some(Self::Ed25519), + "SIGNATURE_SCHEME_SECP256K1" => Some(Self::Secp256k1), + "SIGNATURE_SCHEME_SECP256R1" => Some(Self::Secp256r1), + "SIGNATURE_SCHEME_MULTISIG" => Some(Self::Multisig), + "SIGNATURE_SCHEME_BLS12381" => Some(Self::Bls12381), + "SIGNATURE_SCHEME_ZKLOGIN" => Some(Self::Zklogin), + "SIGNATURE_SCHEME_PASSKEY" => Some(Self::Passkey), + _ => None, + } + } +} diff --git a/crates/sui-rpc-api/src/proto/mod.rs b/crates/sui-rpc-api/src/proto/mod.rs index 539c2c6dab0ab..d9a6c7342e51f 100644 --- a/crates/sui-rpc-api/src/proto/mod.rs +++ b/crates/sui-rpc-api/src/proto/mod.rs @@ -1,618 +1,66 @@ -// Copyright (c) Mysten Labs, Inc. -// SPDX-License-Identifier: Apache-2.0 +pub mod node; +pub mod types; -#[path = "generated/sui.rest.rs"] -mod generated; -pub use generated::*; -use tap::Pipe; +type BoxError = Box; -// -// Transaction -// - -impl TryFrom<&sui_sdk_types::types::Transaction> for Transaction { - type Error = bcs::Error; - - fn try_from(value: &sui_sdk_types::types::Transaction) -> Result { - bcs::to_bytes(&value).map(|bytes| Self { - transaction: bytes.into(), - }) - } -} - -impl TryFrom<&Transaction> for sui_sdk_types::types::Transaction { - type Error = bcs::Error; - - fn try_from(value: &Transaction) -> Result { - bcs::from_bytes(&value.transaction) - } -} - -impl TryFrom<&sui_types::transaction::TransactionData> for Transaction { - type Error = bcs::Error; - - fn try_from(value: &sui_types::transaction::TransactionData) -> Result { - bcs::to_bytes(&value).map(|bytes| Self { - transaction: bytes.into(), - }) - } -} - -impl TryFrom<&Transaction> for sui_types::transaction::TransactionData { - type Error = bcs::Error; - - fn try_from(value: &Transaction) -> Result { - bcs::from_bytes(&value.transaction) - } -} - -// -// TransactionEffects -// - -impl TryFrom<&sui_sdk_types::types::TransactionEffects> for TransactionEffects { - type Error = bcs::Error; - - fn try_from(value: &sui_sdk_types::types::TransactionEffects) -> Result { - bcs::to_bytes(&value).map(|bytes| Self { - effects: bytes.into(), - }) - } -} - -impl TryFrom<&TransactionEffects> for sui_sdk_types::types::TransactionEffects { - type Error = bcs::Error; - - fn try_from(value: &TransactionEffects) -> Result { - bcs::from_bytes(&value.effects) - } -} - -impl TryFrom<&sui_types::effects::TransactionEffects> for TransactionEffects { - type Error = bcs::Error; - - fn try_from(value: &sui_types::effects::TransactionEffects) -> Result { - bcs::to_bytes(&value).map(|bytes| Self { - effects: bytes.into(), - }) - } -} - -impl TryFrom<&TransactionEffects> for sui_types::effects::TransactionEffects { - type Error = bcs::Error; - - fn try_from(value: &TransactionEffects) -> Result { - bcs::from_bytes(&value.effects) - } -} - -// -// TransactionEvents -// - -impl TryFrom<&sui_sdk_types::types::TransactionEvents> for TransactionEvents { - type Error = bcs::Error; - - fn try_from(value: &sui_sdk_types::types::TransactionEvents) -> Result { - bcs::to_bytes(&value).map(|bytes| Self { - events: bytes.into(), - }) - } -} - -impl TryFrom<&TransactionEvents> for sui_sdk_types::types::TransactionEvents { - type Error = bcs::Error; - - fn try_from(value: &TransactionEvents) -> Result { - bcs::from_bytes(&value.events) - } -} - -impl TryFrom<&sui_types::effects::TransactionEvents> for TransactionEvents { - type Error = bcs::Error; - - fn try_from(value: &sui_types::effects::TransactionEvents) -> Result { - bcs::to_bytes(&value).map(|bytes| Self { - events: bytes.into(), - }) - } -} - -impl TryFrom<&TransactionEvents> for sui_types::effects::TransactionEvents { - type Error = bcs::Error; - - fn try_from(value: &TransactionEvents) -> Result { - bcs::from_bytes(&value.events) - } -} - -// -// Object -// - -impl TryFrom<&sui_sdk_types::types::Object> for Object { - type Error = bcs::Error; - - fn try_from(value: &sui_sdk_types::types::Object) -> Result { - bcs::to_bytes(&value).map(|bytes| Self { - object: bytes.into(), - }) - } -} - -impl TryFrom<&Object> for sui_sdk_types::types::Object { - type Error = bcs::Error; - - fn try_from(value: &Object) -> Result { - bcs::from_bytes(&value.object) - } -} - -impl TryFrom<&sui_types::object::Object> for Object { - type Error = bcs::Error; - - fn try_from(value: &sui_types::object::Object) -> Result { - bcs::to_bytes(&value).map(|bytes| Self { - object: bytes.into(), - }) - } -} - -impl TryFrom<&Object> for sui_types::object::Object { - type Error = bcs::Error; - - fn try_from(value: &Object) -> Result { - bcs::from_bytes(&value.object) - } -} - -// -// CheckpointSummary -// - -impl TryFrom<&sui_sdk_types::types::CheckpointSummary> for CheckpointSummary { - type Error = bcs::Error; - - fn try_from(value: &sui_sdk_types::types::CheckpointSummary) -> Result { - bcs::to_bytes(&value).map(|bytes| Self { - summary: bytes.into(), - }) - } +#[derive(Debug)] +pub struct TryFromProtoError { + missing_field: Option<&'static str>, + source: Option, } -impl TryFrom<&CheckpointSummary> for sui_sdk_types::types::CheckpointSummary { - type Error = bcs::Error; +impl std::fmt::Display for TryFromProtoError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "error converting from protobuf")?; - fn try_from(value: &CheckpointSummary) -> Result { - bcs::from_bytes(&value.summary) - } -} - -impl TryFrom<&sui_types::messages_checkpoint::CheckpointSummary> for CheckpointSummary { - type Error = bcs::Error; - - fn try_from( - value: &sui_types::messages_checkpoint::CheckpointSummary, - ) -> Result { - bcs::to_bytes(&value).map(|bytes| Self { - summary: bytes.into(), - }) - } -} - -impl TryFrom<&CheckpointSummary> for sui_types::messages_checkpoint::CheckpointSummary { - type Error = bcs::Error; - - fn try_from(value: &CheckpointSummary) -> Result { - bcs::from_bytes(&value.summary) - } -} - -// -// CheckpointContents -// - -impl TryFrom<&sui_sdk_types::types::CheckpointContents> for CheckpointContents { - type Error = bcs::Error; - - fn try_from(value: &sui_sdk_types::types::CheckpointContents) -> Result { - bcs::to_bytes(&value).map(|bytes| Self { - contents: bytes.into(), - }) - } -} - -impl TryFrom<&CheckpointContents> for sui_sdk_types::types::CheckpointContents { - type Error = bcs::Error; - - fn try_from(value: &CheckpointContents) -> Result { - bcs::from_bytes(&value.contents) - } -} - -impl TryFrom<&sui_types::messages_checkpoint::CheckpointContents> for CheckpointContents { - type Error = bcs::Error; - - fn try_from( - value: &sui_types::messages_checkpoint::CheckpointContents, - ) -> Result { - bcs::to_bytes(&value).map(|bytes| Self { - contents: bytes.into(), - }) - } -} - -impl TryFrom<&CheckpointContents> for sui_types::messages_checkpoint::CheckpointContents { - type Error = bcs::Error; - - fn try_from(value: &CheckpointContents) -> Result { - bcs::from_bytes(&value.contents) - } -} - -// -// ValidatorAggregatedSignature -// - -impl TryFrom<&sui_sdk_types::types::ValidatorAggregatedSignature> for ValidatorAggregatedSignature { - type Error = bcs::Error; - - fn try_from( - value: &sui_sdk_types::types::ValidatorAggregatedSignature, - ) -> Result { - bcs::to_bytes(&value).map(|bytes| Self { - signature: bytes.into(), - }) - } -} - -impl TryFrom<&ValidatorAggregatedSignature> for sui_sdk_types::types::ValidatorAggregatedSignature { - type Error = bcs::Error; - - fn try_from(value: &ValidatorAggregatedSignature) -> Result { - bcs::from_bytes(&value.signature) - } -} - -impl TryFrom<&sui_types::crypto::AuthorityStrongQuorumSignInfo> for ValidatorAggregatedSignature { - type Error = bcs::Error; - - fn try_from( - value: &sui_types::crypto::AuthorityStrongQuorumSignInfo, - ) -> Result { - bcs::to_bytes(&value).map(|bytes| Self { - signature: bytes.into(), - }) - } -} - -impl TryFrom<&ValidatorAggregatedSignature> for sui_types::crypto::AuthorityStrongQuorumSignInfo { - type Error = bcs::Error; - - fn try_from(value: &ValidatorAggregatedSignature) -> Result { - bcs::from_bytes(&value.signature) - } -} - -// -// UserSignature -// - -impl TryFrom<&sui_sdk_types::types::UserSignature> for UserSignature { - type Error = bcs::Error; - - fn try_from(value: &sui_sdk_types::types::UserSignature) -> Result { - Ok(Self { - signature: value.to_bytes().into(), - }) - } -} - -impl TryFrom<&UserSignature> for sui_sdk_types::types::UserSignature { - type Error = bcs::Error; - - fn try_from(value: &UserSignature) -> Result { - Self::from_bytes(&value.signature).map_err(|e| bcs::Error::Custom(e.to_string())) - } -} - -impl TryFrom<&sui_types::signature::GenericSignature> for UserSignature { - type Error = bcs::Error; - - fn try_from(value: &sui_types::signature::GenericSignature) -> Result { - Ok(Self { - signature: sui_types::crypto::ToFromBytes::as_bytes(value) - .to_vec() - .into(), - }) - } -} - -impl TryFrom<&UserSignature> for sui_types::signature::GenericSignature { - type Error = bcs::Error; - - fn try_from(value: &UserSignature) -> Result { - sui_types::crypto::ToFromBytes::from_bytes(&value.signature) - .map_err(|e| bcs::Error::Custom(e.to_string())) - } -} - -// -// CheckpointTransaction -// - -impl TryFrom for CheckpointTransaction { - type Error = bcs::Error; - - fn try_from( - transaction: sui_types::full_checkpoint_content::CheckpointTransaction, - ) -> Result { - Ok(Self { - transaction: Some(Transaction::try_from( - &transaction.transaction.intent_message().value, - )?), - signatures: transaction - .transaction - .tx_signatures() - .iter() - .map(UserSignature::try_from) - .collect::>()?, - effects: Some(TransactionEffects::try_from(&transaction.effects)?), - events: transaction - .events - .as_ref() - .map(TransactionEvents::try_from) - .transpose()?, - input_objects: transaction - .input_objects - .iter() - .map(Object::try_from) - .collect::>()?, - output_objects: transaction - .output_objects - .iter() - .map(Object::try_from) - .collect::>()?, - }) - } -} - -impl TryFrom for sui_types::full_checkpoint_content::CheckpointTransaction { - type Error = bcs::Error; - - fn try_from(transaction: CheckpointTransaction) -> Result { - let transaction_data = transaction - .transaction - .ok_or_else(|| bcs::Error::Custom("missing transaction".into()))? - .pipe_ref(TryInto::try_into)?; - let user_signatures = transaction - .signatures - .iter() - .map(TryInto::try_into) - .collect::>()?; - - Ok(Self { - transaction: sui_types::transaction::Transaction::new( - sui_types::transaction::SenderSignedData::new(transaction_data, user_signatures), - ), - effects: transaction - .effects - .ok_or_else(|| bcs::Error::Custom("missing Effects".into()))? - .pipe_ref(TryInto::try_into)?, - events: transaction - .events - .as_ref() - .map(TryInto::try_into) - .transpose()?, - input_objects: transaction - .input_objects - .iter() - .map(TryInto::try_into) - .collect::>()?, - output_objects: transaction - .output_objects - .iter() - .map(TryInto::try_into) - .collect::>()?, - }) - } -} - -// -// FullCheckpoint -// - -impl TryFrom for FullCheckpoint { - type Error = bcs::Error; - - fn try_from( - c: sui_types::full_checkpoint_content::CheckpointData, - ) -> Result { - Ok(Self { - summary: Some(CheckpointSummary::try_from(c.checkpoint_summary.data())?), - signature: Some(ValidatorAggregatedSignature::try_from( - c.checkpoint_summary.auth_sig(), - )?), - contents: Some(CheckpointContents::try_from(&c.checkpoint_contents)?), - transactions: c - .transactions - .into_iter() - .map(TryInto::try_into) - .collect::>()?, - }) - } -} - -impl TryFrom for sui_types::full_checkpoint_content::CheckpointData { - type Error = bcs::Error; - - fn try_from(checkpoint: FullCheckpoint) -> Result { - let summary = checkpoint - .summary - .ok_or_else(|| bcs::Error::Custom("missing summary".into()))? - .pipe_ref(TryInto::try_into)?; - let signature = checkpoint - .signature - .ok_or_else(|| bcs::Error::Custom("missing signature".into()))? - .pipe_ref(TryInto::try_into)?; - let checkpoint_summary = - sui_types::messages_checkpoint::CertifiedCheckpointSummary::new_from_data_and_sig( - summary, signature, - ); - - let contents = checkpoint - .contents - .ok_or_else(|| bcs::Error::Custom("missing checkpoint contents".into()))? - .pipe_ref(TryInto::try_into)?; - - let transactions = checkpoint - .transactions - .into_iter() - .map(TryInto::try_into) - .collect::>()?; - - Ok(Self { - checkpoint_summary, - checkpoint_contents: contents, - transactions, - }) - } -} - -// -// Address -// - -impl From<&sui_sdk_types::types::Address> for Address { - fn from(value: &sui_sdk_types::types::Address) -> Self { - Self { - address: value.as_bytes().to_vec().into(), + if let Some(missing_field) = &self.missing_field { + write!(f, "missing_field: {missing_field}")?; } - } -} -impl TryFrom<&Address> for sui_sdk_types::types::Address { - type Error = bcs::Error; - - fn try_from(value: &Address) -> Result { - Self::from_bytes(&value.address).map_err(|e| bcs::Error::Custom(e.to_string())) - } -} - -impl TryFrom<&Address> for sui_types::base_types::SuiAddress { - type Error = bcs::Error; + if let Some(source) = &self.source { + write!(f, "source: {source}")?; + } - fn try_from(value: &Address) -> Result { - Self::from_bytes(&value.address).map_err(|e| bcs::Error::Custom(e.to_string())) + Ok(()) } } -// -// TypeTag -// - -impl From<&sui_sdk_types::types::TypeTag> for TypeTag { - fn from(value: &sui_sdk_types::types::TypeTag) -> Self { +impl TryFromProtoError { + pub fn missing(field: &'static str) -> Self { Self { - type_tag: value.to_string(), + missing_field: Some(field), + source: None, } } -} - -impl TryFrom<&TypeTag> for sui_sdk_types::types::TypeTag { - type Error = sui_sdk_types::types::TypeParseError; - - fn try_from(value: &TypeTag) -> Result { - value.type_tag.parse() - } -} - -impl TryFrom<&TypeTag> for sui_types::TypeTag { - type Error = bcs::Error; - - fn try_from(value: &TypeTag) -> Result { - value - .type_tag - .parse::() - .map_err(|e| bcs::Error::Custom(e.to_string())) - } -} - -// -// I128 -// -impl From for I128 { - fn from(value: i128) -> Self { + pub fn from_error>(error: E) -> Self { Self { - little_endian_bytes: value.to_le_bytes().to_vec().into(), + missing_field: None, + source: Some(error.into()), } } } -impl TryFrom<&I128> for i128 { - type Error = std::array::TryFromSliceError; - - fn try_from(value: &I128) -> Result { - Ok(i128::from_le_bytes( - value.little_endian_bytes.as_ref().try_into()?, - )) +impl From for TryFromProtoError { + fn from(value: std::num::TryFromIntError) -> Self { + Self::from_error(value) } } -// -// ValidatorCommitteeMember -// - -impl From<&sui_sdk_types::types::ValidatorCommitteeMember> for ValidatorCommitteeMember { - fn from(value: &sui_sdk_types::types::ValidatorCommitteeMember) -> Self { - Self { - public_key: value.public_key.as_bytes().to_vec().into(), - stake: value.stake, - } +impl From for TryFromProtoError { + fn from(value: std::str::Utf8Error) -> Self { + Self::from_error(value) } } -impl TryFrom for sui_sdk_types::types::ValidatorCommitteeMember { - type Error = bcs::Error; - - fn try_from(value: ValidatorCommitteeMember) -> Result { - Ok(Self { - public_key: sui_sdk_types::types::Bls12381PublicKey::from_bytes(&value.public_key) - .map_err(|e| bcs::Error::Custom(e.to_string()))?, - stake: value.stake, - }) +impl From for TryFromProtoError { + fn from(value: std::array::TryFromSliceError) -> Self { + Self::from_error(value) } } -// -// ValidatorCommittee -// - -impl From for ValidatorCommittee { - fn from(value: sui_sdk_types::types::ValidatorCommittee) -> Self { - Self { - epoch: value.epoch, - members: value - .members - .iter() - .map(ValidatorCommitteeMember::from) - .collect(), - } - } -} - -impl TryFrom for sui_sdk_types::types::ValidatorCommittee { - type Error = bcs::Error; - - fn try_from(value: ValidatorCommittee) -> Result { - Ok(Self { - epoch: value.epoch, - members: value - .members - .into_iter() - .map(TryInto::try_into) - .collect::>()?, - }) +impl From for TryFromProtoError { + fn from(_value: std::convert::Infallible) -> Self { + unreachable!() } } diff --git a/crates/sui-rpc-api/src/proto/node.rs b/crates/sui-rpc-api/src/proto/node.rs new file mode 100644 index 0000000000000..38cacb8506c04 --- /dev/null +++ b/crates/sui-rpc-api/src/proto/node.rs @@ -0,0 +1,966 @@ +use super::types::proto_to_timestamp_ms; +use super::types::timestamp_ms_to_proto; +use super::TryFromProtoError; +use tap::Pipe; + +#[rustfmt::skip] +#[path = "generated/sui.node.v2.rs"] +mod generated; +pub use generated::*; + +// +// BalanceChange +// + +impl From for BalanceChange { + fn from(value: sui_sdk_types::types::BalanceChange) -> Self { + Self { + address: Some(value.address.into()), + coin_type: Some(value.coin_type.into()), + amount: Some(value.amount.into()), + } + } +} + +impl TryFrom<&BalanceChange> for sui_sdk_types::types::BalanceChange { + type Error = TryFromProtoError; + + fn try_from(value: &BalanceChange) -> Result { + let address = value + .address + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("address"))? + .pipe(TryInto::try_into)?; + let coin_type = value + .coin_type + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("coin_type"))? + .pipe(TryInto::try_into)?; + let amount = value + .amount + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("amount"))? + .pipe(TryInto::try_into)?; + Ok(Self { + address, + coin_type, + amount, + }) + } +} + +// +// NodeInfo +// + +impl From for GetNodeInfoResponse { + fn from( + crate::types::NodeInfo { + chain_id, + chain, + epoch, + checkpoint_height, + timestamp_ms, + lowest_available_checkpoint, + lowest_available_checkpoint_objects, + software_version, + }: crate::types::NodeInfo, + ) -> Self { + Self { + chain_id: Some(chain_id.into()), + chain: Some(chain.into()), + epoch: Some(epoch), + checkpoint_height: Some(checkpoint_height), + timestamp: Some(timestamp_ms_to_proto(timestamp_ms)), + lowest_available_checkpoint, + lowest_available_checkpoint_objects, + software_version: Some(software_version.into()), + } + } +} + +impl TryFrom<&GetNodeInfoResponse> for crate::types::NodeInfo { + type Error = TryFromProtoError; + + fn try_from( + GetNodeInfoResponse { + chain_id, + chain, + epoch, + checkpoint_height, + timestamp, + lowest_available_checkpoint, + lowest_available_checkpoint_objects, + software_version, + }: &GetNodeInfoResponse, + ) -> Result { + let chain_id = chain_id + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("chain_id"))? + .pipe(TryInto::try_into)?; + let chain = chain + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("chain"))? + .to_owned() + .into(); + let timestamp_ms = timestamp + .ok_or_else(|| TryFromProtoError::missing("timestamp"))? + .pipe(proto_to_timestamp_ms)?; + + let epoch = epoch.ok_or_else(|| TryFromProtoError::missing("epoch"))?; + let checkpoint_height = + checkpoint_height.ok_or_else(|| TryFromProtoError::missing("checkpoint_height"))?; + + let software_version = software_version + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("software_version"))? + .to_owned() + .into(); + + Self { + chain_id, + chain, + epoch, + checkpoint_height, + timestamp_ms, + lowest_available_checkpoint: *lowest_available_checkpoint, + lowest_available_checkpoint_objects: *lowest_available_checkpoint_objects, + software_version, + } + .pipe(Ok) + } +} + +// +// GetObjectOptions +// + +impl From for GetObjectOptions { + fn from( + crate::types::GetObjectOptions { object, object_bcs }: crate::types::GetObjectOptions, + ) -> Self { + Self { object, object_bcs } + } +} + +impl From for crate::types::GetObjectOptions { + fn from(GetObjectOptions { object, object_bcs }: GetObjectOptions) -> Self { + Self { object, object_bcs } + } +} + +// +// ObjectResponse +// + +impl From for GetObjectResponse { + fn from( + crate::types::ObjectResponse { + object_id, + version, + digest, + object, + object_bcs, + }: crate::types::ObjectResponse, + ) -> Self { + Self { + object_id: Some(object_id.into()), + version: Some(version), + digest: Some(digest.into()), + object: object.map(Into::into), + object_bcs: object_bcs.map(Into::into), + } + } +} + +impl TryFrom<&GetObjectResponse> for crate::types::ObjectResponse { + type Error = TryFromProtoError; + + fn try_from( + GetObjectResponse { + object_id, + version, + digest, + object, + object_bcs, + }: &GetObjectResponse, + ) -> Result { + let object_id = object_id + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("object_id"))? + .pipe(TryInto::try_into)?; + let version = version.ok_or_else(|| TryFromProtoError::missing("version"))?; + let digest = digest + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("digest"))? + .pipe(TryInto::try_into)?; + + let object = object.as_ref().map(TryInto::try_into).transpose()?; + let object_bcs = object_bcs.as_ref().map(Into::into); + + Self { + object_id, + version, + digest, + object, + object_bcs, + } + .pipe(Ok) + } +} + +// +// GetCheckpointOptions +// + +impl From for GetCheckpointOptions { + fn from( + crate::types::GetCheckpointOptions { + summary, + summary_bcs, + signature, + contents, + contents_bcs, + }: crate::types::GetCheckpointOptions, + ) -> Self { + Self { + summary, + summary_bcs, + signature, + contents, + contents_bcs, + } + } +} + +impl From for crate::types::GetCheckpointOptions { + fn from( + GetCheckpointOptions { + summary, + summary_bcs, + signature, + contents, + contents_bcs, + }: GetCheckpointOptions, + ) -> Self { + Self { + summary, + summary_bcs, + signature, + contents, + contents_bcs, + } + } +} + +// +// GetTransactionOptions +// + +impl From for GetTransactionOptions { + fn from( + crate::types::GetTransactionOptions { + transaction, + transaction_bcs, + signatures, + effects, + effects_bcs, + events, + events_bcs, + }: crate::types::GetTransactionOptions, + ) -> Self { + Self { + transaction, + transaction_bcs, + signatures, + effects, + effects_bcs, + events, + events_bcs, + } + } +} + +impl From for crate::types::GetTransactionOptions { + fn from( + GetTransactionOptions { + transaction, + transaction_bcs, + signatures, + effects, + effects_bcs, + events, + events_bcs, + }: GetTransactionOptions, + ) -> Self { + Self { + transaction, + transaction_bcs, + signatures, + effects, + effects_bcs, + events, + events_bcs, + } + } +} + +// +// ExecuteTransactionOptions +// + +impl From for ExecuteTransactionOptions { + fn from( + crate::types::ExecuteTransactionOptions { + effects, + effects_bcs, + events, + events_bcs, + balance_changes, + }: crate::types::ExecuteTransactionOptions, + ) -> Self { + Self { + effects, + effects_bcs, + events, + events_bcs, + balance_changes, + } + } +} + +impl From for crate::types::ExecuteTransactionOptions { + fn from( + ExecuteTransactionOptions { + effects, + effects_bcs, + events, + events_bcs, + balance_changes, + }: ExecuteTransactionOptions, + ) -> Self { + Self { + effects, + effects_bcs, + events, + events_bcs, + balance_changes, + } + } +} + +// +// GetFullCheckpointOptions +// + +impl From for GetFullCheckpointOptions { + fn from( + crate::types::GetFullCheckpointOptions { + summary, + summary_bcs, + signature, + contents, + contents_bcs, + transaction, + transaction_bcs, + effects, + effects_bcs, + events, + events_bcs, + input_objects, + output_objects, + object, + object_bcs, + }: crate::types::GetFullCheckpointOptions, + ) -> Self { + Self { + summary, + summary_bcs, + signature, + contents, + contents_bcs, + transaction, + transaction_bcs, + effects, + effects_bcs, + events, + events_bcs, + input_objects, + output_objects, + object, + object_bcs, + } + } +} + +impl From for crate::types::GetFullCheckpointOptions { + fn from( + GetFullCheckpointOptions { + summary, + summary_bcs, + signature, + contents, + contents_bcs, + transaction, + transaction_bcs, + effects, + effects_bcs, + events, + events_bcs, + input_objects, + output_objects, + object, + object_bcs, + }: GetFullCheckpointOptions, + ) -> Self { + Self { + summary, + summary_bcs, + signature, + contents, + contents_bcs, + transaction, + transaction_bcs, + effects, + effects_bcs, + events, + events_bcs, + input_objects, + output_objects, + object, + object_bcs, + } + } +} + +// +// TransactionResponse +// + +impl From for GetTransactionResponse { + fn from( + crate::types::TransactionResponse { + digest, + transaction, + transaction_bcs, + signatures, + effects, + effects_bcs, + events, + events_bcs, + checkpoint, + timestamp_ms, + }: crate::types::TransactionResponse, + ) -> Self { + let signatures = signatures.map(|signatures| UserSignatures { + signatures: signatures.into_iter().map(Into::into).collect(), + }); + + Self { + digest: Some(digest.into()), + transaction: transaction.map(Into::into), + transaction_bcs: transaction_bcs.map(Into::into), + signatures, + effects: effects.map(Into::into), + effects_bcs: effects_bcs.map(Into::into), + events: events.map(Into::into), + events_bcs: events_bcs.map(Into::into), + checkpoint, + timestamp: timestamp_ms.map(timestamp_ms_to_proto), + } + } +} + +impl TryFrom<&GetTransactionResponse> for crate::types::TransactionResponse { + type Error = TryFromProtoError; + + fn try_from( + GetTransactionResponse { + digest, + transaction, + transaction_bcs, + signatures, + effects, + effects_bcs, + events, + events_bcs, + checkpoint, + timestamp, + }: &GetTransactionResponse, + ) -> Result { + let digest = digest + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("digest"))? + .pipe(TryInto::try_into)?; + + let transaction = transaction.as_ref().map(TryInto::try_into).transpose()?; + let transaction_bcs = transaction_bcs.as_ref().map(Into::into); + + let signatures = signatures + .as_ref() + .map(|signatures| { + signatures + .signatures + .iter() + .map(TryInto::try_into) + .collect::, _>>() + }) + .transpose()?; + + let effects = effects.as_ref().map(TryInto::try_into).transpose()?; + let effects_bcs = effects_bcs.as_ref().map(Into::into); + + let events = events.as_ref().map(TryInto::try_into).transpose()?; + let events_bcs = events_bcs.as_ref().map(Into::into); + + let timestamp_ms = timestamp.map(proto_to_timestamp_ms).transpose()?; + + Self { + digest, + transaction, + transaction_bcs, + signatures, + effects, + effects_bcs, + events, + events_bcs, + checkpoint: *checkpoint, + timestamp_ms, + } + .pipe(Ok) + } +} + +// +// CheckpointResponse +// + +impl From for GetCheckpointResponse { + fn from( + crate::types::CheckpointResponse { + sequence_number, + digest, + summary, + summary_bcs, + signature, + contents, + contents_bcs, + }: crate::types::CheckpointResponse, + ) -> Self { + Self { + sequence_number: Some(sequence_number), + digest: Some(digest.into()), + summary: summary.map(Into::into), + summary_bcs: summary_bcs.map(Into::into), + signature: signature.map(Into::into), + contents: contents.map(Into::into), + contents_bcs: contents_bcs.map(Into::into), + } + } +} + +impl TryFrom<&GetCheckpointResponse> for crate::types::CheckpointResponse { + type Error = TryFromProtoError; + + fn try_from( + GetCheckpointResponse { + sequence_number, + digest, + summary, + summary_bcs, + signature, + contents, + contents_bcs, + }: &GetCheckpointResponse, + ) -> Result { + let sequence_number = + sequence_number.ok_or_else(|| TryFromProtoError::missing("sequence_number"))?; + let digest = digest + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("digest"))? + .pipe(TryInto::try_into)?; + + let summary = summary.as_ref().map(TryInto::try_into).transpose()?; + let summary_bcs = summary_bcs.as_ref().map(Into::into); + + let signature = signature.as_ref().map(TryInto::try_into).transpose()?; + + let contents = contents.as_ref().map(TryInto::try_into).transpose()?; + let contents_bcs = contents_bcs.as_ref().map(Into::into); + + Self { + sequence_number, + digest, + summary, + summary_bcs, + signature, + contents, + contents_bcs, + } + .pipe(Ok) + } +} + +// +// FullCheckpointResponse +// + +impl From for GetFullCheckpointResponse { + fn from( + crate::types::FullCheckpointResponse { + sequence_number, + digest, + summary, + summary_bcs, + signature, + contents, + contents_bcs, + transactions, + }: crate::types::FullCheckpointResponse, + ) -> Self { + Self { + sequence_number: Some(sequence_number), + digest: Some(digest.into()), + summary: summary.map(Into::into), + summary_bcs: summary_bcs.map(Into::into), + signature: signature.map(Into::into), + contents: contents.map(Into::into), + contents_bcs: contents_bcs.map(Into::into), + transactions: transactions.into_iter().map(Into::into).collect(), + } + } +} + +impl TryFrom<&GetFullCheckpointResponse> for crate::types::FullCheckpointResponse { + type Error = TryFromProtoError; + + fn try_from( + GetFullCheckpointResponse { + sequence_number, + digest, + summary, + summary_bcs, + signature, + contents, + contents_bcs, + transactions, + }: &GetFullCheckpointResponse, + ) -> Result { + let sequence_number = + sequence_number.ok_or_else(|| TryFromProtoError::missing("sequence_number"))?; + let digest = digest + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("digest"))? + .pipe(TryInto::try_into)?; + + let summary = summary.as_ref().map(TryInto::try_into).transpose()?; + let summary_bcs = summary_bcs.as_ref().map(Into::into); + + let signature = signature.as_ref().map(TryInto::try_into).transpose()?; + + let contents = contents.as_ref().map(TryInto::try_into).transpose()?; + let contents_bcs = contents_bcs.as_ref().map(Into::into); + + let transactions = transactions + .iter() + .map(TryInto::try_into) + .collect::>()?; + + Self { + sequence_number, + digest, + summary, + summary_bcs, + signature, + contents, + contents_bcs, + transactions, + } + .pipe(Ok) + } +} + +// +// FullCheckpointObject +// + +impl From for FullCheckpointObject { + fn from( + crate::types::FullCheckpointObject { + object_id, + version, + digest, + object, + object_bcs, + }: crate::types::FullCheckpointObject, + ) -> Self { + Self { + object_id: Some(object_id.into()), + version: Some(version), + digest: Some(digest.into()), + object: object.map(Into::into), + object_bcs: object_bcs.map(Into::into), + } + } +} + +impl TryFrom<&FullCheckpointObject> for crate::types::FullCheckpointObject { + type Error = TryFromProtoError; + + fn try_from( + FullCheckpointObject { + object_id, + version, + digest, + object, + object_bcs, + }: &FullCheckpointObject, + ) -> Result { + let object_id = object_id + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("object_id"))? + .pipe(TryInto::try_into)?; + let version = version.ok_or_else(|| TryFromProtoError::missing("version"))?; + let digest = digest + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("digest"))? + .pipe(TryInto::try_into)?; + + let object = object.as_ref().map(TryInto::try_into).transpose()?; + let object_bcs = object_bcs.as_ref().map(Into::into); + + Self { + object_id, + version, + digest, + object, + object_bcs, + } + .pipe(Ok) + } +} + +// +// FullCheckpointTransaction +// + +impl From for FullCheckpointTransaction { + fn from( + crate::types::FullCheckpointTransaction { + digest, + transaction, + transaction_bcs, + effects, + effects_bcs, + events, + events_bcs, + input_objects, + output_objects, + }: crate::types::FullCheckpointTransaction, + ) -> Self { + let input_objects = input_objects.map(|objects| FullCheckpointObjects { + objects: objects.into_iter().map(Into::into).collect(), + }); + let output_objects = output_objects.map(|objects| FullCheckpointObjects { + objects: objects.into_iter().map(Into::into).collect(), + }); + Self { + digest: Some(digest.into()), + transaction: transaction.map(Into::into), + transaction_bcs: transaction_bcs.map(Into::into), + effects: effects.map(Into::into), + effects_bcs: effects_bcs.map(Into::into), + events: events.map(Into::into), + events_bcs: events_bcs.map(Into::into), + input_objects, + output_objects, + } + } +} + +impl TryFrom<&FullCheckpointTransaction> for crate::types::FullCheckpointTransaction { + type Error = TryFromProtoError; + + fn try_from( + FullCheckpointTransaction { + digest, + transaction, + transaction_bcs, + effects, + effects_bcs, + events, + events_bcs, + input_objects, + output_objects, + }: &FullCheckpointTransaction, + ) -> Result { + let digest = digest + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("digest"))? + .pipe(TryInto::try_into)?; + + let transaction = transaction.as_ref().map(TryInto::try_into).transpose()?; + let transaction_bcs = transaction_bcs.as_ref().map(Into::into); + + let effects = effects.as_ref().map(TryInto::try_into).transpose()?; + let effects_bcs = effects_bcs.as_ref().map(Into::into); + + let events = events.as_ref().map(TryInto::try_into).transpose()?; + let events_bcs = events_bcs.as_ref().map(Into::into); + + let input_objects = input_objects + .as_ref() + .map(|objects| { + objects + .objects + .iter() + .map(TryInto::try_into) + .collect::>() + }) + .transpose()?; + + let output_objects = output_objects + .as_ref() + .map(|objects| { + objects + .objects + .iter() + .map(TryInto::try_into) + .collect::>() + }) + .transpose()?; + + Self { + digest, + transaction, + transaction_bcs, + effects, + effects_bcs, + events, + events_bcs, + input_objects, + output_objects, + } + .pipe(Ok) + } +} + +// +// ExecuteTransactionResponse +// + +impl From for ExecuteTransactionResponse { + fn from( + crate::types::ExecuteTransactionResponse { + finality, + effects, + effects_bcs, + events, + events_bcs, + balance_changes, + }: crate::types::ExecuteTransactionResponse, + ) -> Self { + let balance_changes = balance_changes.map(|balance_changes| BalanceChanges { + balance_changes: balance_changes.into_iter().map(Into::into).collect(), + }); + Self { + finality: Some(finality.into()), + effects: effects.map(Into::into), + effects_bcs: effects_bcs.map(Into::into), + events: events.map(Into::into), + events_bcs: events_bcs.map(Into::into), + balance_changes, + } + } +} + +impl TryFrom<&ExecuteTransactionResponse> for crate::types::ExecuteTransactionResponse { + type Error = TryFromProtoError; + + fn try_from( + ExecuteTransactionResponse { + finality, + effects, + effects_bcs, + events, + events_bcs, + balance_changes, + }: &ExecuteTransactionResponse, + ) -> Result { + let finality = finality + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("finality"))? + .pipe(TryInto::try_into)?; + + let effects = effects.as_ref().map(TryInto::try_into).transpose()?; + let effects_bcs = effects_bcs.as_ref().map(Into::into); + + let events = events.as_ref().map(TryInto::try_into).transpose()?; + let events_bcs = events_bcs.as_ref().map(Into::into); + + let balance_changes = balance_changes + .as_ref() + .map(|balance_changes| { + balance_changes + .balance_changes + .iter() + .map(TryInto::try_into) + .collect::>() + }) + .transpose()?; + + Self { + finality, + effects, + effects_bcs, + events, + events_bcs, + balance_changes, + } + .pipe(Ok) + } +} + +// +// EffectsFinality +// + +impl From for crate::proto::node::EffectsFinality { + fn from(value: crate::types::EffectsFinality) -> Self { + use crate::proto::node::effects_finality::Finality; + use crate::types::EffectsFinality::*; + + let finality = match value { + Certified { signature } => Finality::Certified(signature.into()), + Checkpointed { checkpoint } => Finality::Checkpointed(checkpoint), + QuorumExecuted => Finality::QuorumExecuted(()), + }; + + Self { + finality: Some(finality), + } + } +} + +impl TryFrom<&crate::proto::node::EffectsFinality> for crate::types::EffectsFinality { + type Error = crate::proto::TryFromProtoError; + + fn try_from(value: &crate::proto::node::EffectsFinality) -> Result { + use crate::proto::node::effects_finality::Finality; + + match value + .finality + .as_ref() + .ok_or_else(|| crate::proto::TryFromProtoError::missing("finality"))? + { + Finality::Certified(signature) => Self::Certified { + signature: signature.try_into()?, + }, + Finality::Checkpointed(checkpoint) => Self::Checkpointed { + checkpoint: *checkpoint, + }, + Finality::QuorumExecuted(()) => Self::QuorumExecuted, + } + .pipe(Ok) + } +} diff --git a/crates/sui-rpc-api/src/proto/types/checkpoint.rs b/crates/sui-rpc-api/src/proto/types/checkpoint.rs new file mode 100644 index 0000000000000..255d5b62a60ef --- /dev/null +++ b/crates/sui-rpc-api/src/proto/types/checkpoint.rs @@ -0,0 +1,320 @@ +use super::TryFromProtoError; +use tap::Pipe; + +// +// CheckpointSummary +// + +impl From for super::CheckpointSummary { + fn from( + sui_sdk_types::types::CheckpointSummary { + epoch, + sequence_number, + network_total_transactions, + content_digest, + previous_digest, + epoch_rolling_gas_cost_summary, + timestamp_ms, + checkpoint_commitments, + end_of_epoch_data, + version_specific_data, + }: sui_sdk_types::types::CheckpointSummary, + ) -> Self { + Self { + epoch: Some(epoch), + sequence_number: Some(sequence_number), + total_network_transactions: Some(network_total_transactions), + content_digest: Some(content_digest.into()), + previous_digest: previous_digest.map(Into::into), + epoch_rolling_gas_cost_summary: Some(epoch_rolling_gas_cost_summary.into()), + timestamp_ms: Some(timestamp_ms), + commitments: checkpoint_commitments.into_iter().map(Into::into).collect(), + end_of_epoch_data: end_of_epoch_data.map(Into::into), + version_specific_data: Some(version_specific_data.into()), + } + } +} + +impl TryFrom<&super::CheckpointSummary> for sui_sdk_types::types::CheckpointSummary { + type Error = TryFromProtoError; + + fn try_from( + super::CheckpointSummary { + epoch, + sequence_number, + total_network_transactions, + content_digest, + previous_digest, + epoch_rolling_gas_cost_summary, + timestamp_ms, + commitments, + end_of_epoch_data, + version_specific_data, + }: &super::CheckpointSummary, + ) -> Result { + let epoch = epoch.ok_or_else(|| TryFromProtoError::missing("epoch"))?; + let sequence_number = + sequence_number.ok_or_else(|| TryFromProtoError::missing("sequence_number"))?; + let network_total_transactions = total_network_transactions + .ok_or_else(|| TryFromProtoError::missing("total_network_transactions"))?; + let content_digest = content_digest + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("content_digest"))? + .try_into()?; + let previous_digest = previous_digest + .as_ref() + .map(TryInto::try_into) + .transpose()?; + let epoch_rolling_gas_cost_summary = epoch_rolling_gas_cost_summary + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("epoch_rolling_gas_cost_summary"))? + .try_into()?; + + let timestamp_ms = + timestamp_ms.ok_or_else(|| TryFromProtoError::missing("timestamp_ms"))?; + + let checkpoint_commitments = commitments + .iter() + .map(TryInto::try_into) + .collect::>()?; + + let end_of_epoch_data = end_of_epoch_data + .as_ref() + .map(TryInto::try_into) + .transpose()?; + + let version_specific_data = version_specific_data + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("version_specific_data"))? + .to_vec(); + + Ok(Self { + epoch, + sequence_number, + network_total_transactions, + content_digest, + previous_digest, + epoch_rolling_gas_cost_summary, + timestamp_ms, + checkpoint_commitments, + end_of_epoch_data, + version_specific_data, + }) + } +} + +// +// GasCostSummary +// + +impl From for super::GasCostSummary { + fn from( + sui_sdk_types::types::GasCostSummary { + computation_cost, + storage_cost, + storage_rebate, + non_refundable_storage_fee, + }: sui_sdk_types::types::GasCostSummary, + ) -> Self { + Self { + computation_cost: Some(computation_cost), + storage_cost: Some(storage_cost), + storage_rebate: Some(storage_rebate), + non_refundable_storage_fee: Some(non_refundable_storage_fee), + } + } +} + +impl TryFrom<&super::GasCostSummary> for sui_sdk_types::types::GasCostSummary { + type Error = TryFromProtoError; + + fn try_from( + super::GasCostSummary { + computation_cost, + storage_cost, + storage_rebate, + non_refundable_storage_fee, + }: &super::GasCostSummary, + ) -> Result { + let computation_cost = + computation_cost.ok_or_else(|| TryFromProtoError::missing("computation_cost"))?; + let storage_cost = + storage_cost.ok_or_else(|| TryFromProtoError::missing("storage_cost"))?; + let storage_rebate = + storage_rebate.ok_or_else(|| TryFromProtoError::missing("storage_rebate"))?; + let non_refundable_storage_fee = non_refundable_storage_fee + .ok_or_else(|| TryFromProtoError::missing("non_refundable_storage_fee"))?; + Ok(Self { + computation_cost, + storage_cost, + storage_rebate, + non_refundable_storage_fee, + }) + } +} + +// +// CheckpointCommitment +// + +impl From for super::CheckpointCommitment { + fn from(value: sui_sdk_types::types::CheckpointCommitment) -> Self { + let commitment = match value { + sui_sdk_types::types::CheckpointCommitment::EcmhLiveObjectSet { digest } => { + super::checkpoint_commitment::Commitment::EcmhLiveObjectSet(digest.into()) + } + }; + + Self { + commitment: Some(commitment), + } + } +} + +impl TryFrom<&super::CheckpointCommitment> for sui_sdk_types::types::CheckpointCommitment { + type Error = TryFromProtoError; + + fn try_from(value: &super::CheckpointCommitment) -> Result { + match value + .commitment + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("commitment"))? + { + super::checkpoint_commitment::Commitment::EcmhLiveObjectSet(digest) => { + Self::EcmhLiveObjectSet { + digest: digest.try_into()?, + } + } + } + .pipe(Ok) + } +} + +// +// EndOfEpochData +// + +impl From for super::EndOfEpochData { + fn from( + sui_sdk_types::types::EndOfEpochData { + next_epoch_committee, + next_epoch_protocol_version, + epoch_commitments, + }: sui_sdk_types::types::EndOfEpochData, + ) -> Self { + Self { + next_epoch_committee: next_epoch_committee.into_iter().map(Into::into).collect(), + next_epoch_protocol_version: Some(next_epoch_protocol_version), + epoch_commitments: epoch_commitments.into_iter().map(Into::into).collect(), + } + } +} + +impl TryFrom<&super::EndOfEpochData> for sui_sdk_types::types::EndOfEpochData { + type Error = TryFromProtoError; + + fn try_from( + super::EndOfEpochData { + next_epoch_committee, + next_epoch_protocol_version, + epoch_commitments, + }: &super::EndOfEpochData, + ) -> Result { + let next_epoch_protocol_version = next_epoch_protocol_version + .ok_or_else(|| TryFromProtoError::missing("next_epoch_protocol_version"))?; + + Ok(Self { + next_epoch_committee: next_epoch_committee + .iter() + .map(TryInto::try_into) + .collect::>()?, + next_epoch_protocol_version, + epoch_commitments: epoch_commitments + .iter() + .map(TryInto::try_into) + .collect::>()?, + }) + } +} + +// +// CheckpointedTransactionInfo +// + +impl From for super::CheckpointedTransactionInfo { + fn from(value: sui_sdk_types::types::CheckpointTransactionInfo) -> Self { + Self { + transaction: Some(value.transaction.into()), + effects: Some(value.effects.into()), + signatures: value.signatures.into_iter().map(Into::into).collect(), + } + } +} + +impl TryFrom<&super::CheckpointedTransactionInfo> + for sui_sdk_types::types::CheckpointTransactionInfo +{ + type Error = TryFromProtoError; + + fn try_from(value: &super::CheckpointedTransactionInfo) -> Result { + let transaction = value + .transaction + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("transaction"))? + .try_into()?; + + let effects = value + .effects + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("effects"))? + .try_into()?; + + let signatures = value + .signatures + .iter() + .map(TryInto::try_into) + .collect::>()?; + + Ok(Self { + transaction, + effects, + signatures, + }) + } +} + +// +// CheckpointContents +// + +impl From for super::CheckpointContents { + fn from(value: sui_sdk_types::types::CheckpointContents) -> Self { + let contents = super::checkpoint_contents::Contents::V1(super::checkpoint_contents::V1 { + transactions: value.into_v1().into_iter().map(Into::into).collect(), + }); + + Self { + contents: Some(contents), + } + } +} + +impl TryFrom<&super::CheckpointContents> for sui_sdk_types::types::CheckpointContents { + type Error = TryFromProtoError; + + fn try_from(value: &super::CheckpointContents) -> Result { + match value + .contents + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("commitment"))? + { + super::checkpoint_contents::Contents::V1(v1) => Self::new( + v1.transactions + .iter() + .map(TryInto::try_into) + .collect::>()?, + ), + } + .pipe(Ok) + } +} diff --git a/crates/sui-rpc-api/src/proto/types/effects.rs b/crates/sui-rpc-api/src/proto/types/effects.rs new file mode 100644 index 0000000000000..1c20d4acef63e --- /dev/null +++ b/crates/sui-rpc-api/src/proto/types/effects.rs @@ -0,0 +1,634 @@ +use super::TryFromProtoError; +use tap::Pipe; + +// +// TransactionEffects +// + +impl From for super::TransactionEffects { + fn from(value: sui_sdk_types::types::TransactionEffects) -> Self { + use super::transaction_effects::Version; + use sui_sdk_types::types::TransactionEffects::*; + + let version = match value { + V1(v1) => Version::V1((*v1).into()), + V2(v2) => Version::V2((*v2).into()), + }; + + Self { + version: Some(version), + } + } +} + +impl TryFrom<&super::TransactionEffects> for sui_sdk_types::types::TransactionEffects { + type Error = TryFromProtoError; + + fn try_from(value: &super::TransactionEffects) -> Result { + use super::transaction_effects::Version::*; + + match value + .version + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("version"))? + { + V1(v1) => Self::V1(Box::new(v1.try_into()?)), + V2(v2) => Self::V2(Box::new(v2.try_into()?)), + } + .pipe(Ok) + } +} + +// +// TransactionEffectsV1 +// + +impl From for super::TransactionEffectsV1 { + fn from( + sui_sdk_types::types::TransactionEffectsV1 { + status, + epoch, + gas_used, + modified_at_versions, + shared_objects, + transaction_digest, + created, + mutated, + unwrapped, + deleted, + unwrapped_then_deleted, + wrapped, + gas_object, + events_digest, + dependencies, + }: sui_sdk_types::types::TransactionEffectsV1, + ) -> Self { + Self { + status: Some(status.into()), + epoch: Some(epoch), + gas_used: Some(gas_used.into()), + modified_at_versions: modified_at_versions.into_iter().map(Into::into).collect(), + shared_objects: shared_objects.into_iter().map(Into::into).collect(), + transaction_digest: Some(transaction_digest.into()), + created: created.into_iter().map(Into::into).collect(), + mutated: mutated.into_iter().map(Into::into).collect(), + unwrapped: unwrapped.into_iter().map(Into::into).collect(), + deleted: deleted.into_iter().map(Into::into).collect(), + unwrapped_then_deleted: unwrapped_then_deleted.into_iter().map(Into::into).collect(), + wrapped: wrapped.into_iter().map(Into::into).collect(), + gas_object: Some(gas_object.into()), + events_digest: events_digest.map(Into::into), + dependencies: dependencies.into_iter().map(Into::into).collect(), + } + } +} + +impl TryFrom<&super::TransactionEffectsV1> for sui_sdk_types::types::TransactionEffectsV1 { + type Error = TryFromProtoError; + + fn try_from( + super::TransactionEffectsV1 { + status, + epoch, + gas_used, + modified_at_versions, + shared_objects, + transaction_digest, + created, + mutated, + unwrapped, + deleted, + unwrapped_then_deleted, + wrapped, + gas_object, + events_digest, + dependencies, + }: &super::TransactionEffectsV1, + ) -> Result { + let status = status + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("status"))? + .try_into()?; + + let epoch = epoch.ok_or_else(|| TryFromProtoError::missing("epoch"))?; + + let gas_used = gas_used + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("gas_used"))? + .try_into()?; + + let transaction_digest = transaction_digest + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("transaction_digest"))? + .try_into()?; + + let modified_at_versions = modified_at_versions + .iter() + .map(TryInto::try_into) + .collect::>()?; + let shared_objects = shared_objects + .iter() + .map(TryInto::try_into) + .collect::>()?; + let created = created + .iter() + .map(TryInto::try_into) + .collect::>()?; + + let mutated = mutated + .iter() + .map(TryInto::try_into) + .collect::>()?; + + let unwrapped = unwrapped + .iter() + .map(TryInto::try_into) + .collect::>()?; + + let deleted = deleted + .iter() + .map(TryInto::try_into) + .collect::>()?; + + let unwrapped_then_deleted = unwrapped_then_deleted + .iter() + .map(TryInto::try_into) + .collect::>()?; + + let wrapped = wrapped + .iter() + .map(TryInto::try_into) + .collect::>()?; + + let gas_object = gas_object + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("gas_object"))? + .try_into()?; + + let events_digest = events_digest.as_ref().map(TryInto::try_into).transpose()?; + + let dependencies = dependencies + .iter() + .map(TryInto::try_into) + .collect::>()?; + + Ok(Self { + status, + epoch, + gas_used, + modified_at_versions, + shared_objects, + transaction_digest, + created, + mutated, + unwrapped, + deleted, + unwrapped_then_deleted, + wrapped, + gas_object, + events_digest, + dependencies, + }) + } +} + +// +// TransactionEffectsV2 +// + +impl From for super::TransactionEffectsV2 { + fn from( + sui_sdk_types::types::TransactionEffectsV2 { + status, + epoch, + gas_used, + transaction_digest, + gas_object_index, + events_digest, + dependencies, + lamport_version, + changed_objects, + unchanged_shared_objects, + auxiliary_data_digest, + }: sui_sdk_types::types::TransactionEffectsV2, + ) -> Self { + Self { + status: Some(status.into()), + epoch: Some(epoch), + gas_used: Some(gas_used.into()), + transaction_digest: Some(transaction_digest.into()), + gas_object_index, + events_digest: events_digest.map(Into::into), + dependencies: dependencies.into_iter().map(Into::into).collect(), + lamport_version: Some(lamport_version), + changed_objects: changed_objects.into_iter().map(Into::into).collect(), + unchanged_shared_objects: unchanged_shared_objects + .into_iter() + .map(Into::into) + .collect(), + auxiliary_data_digest: auxiliary_data_digest.map(Into::into), + } + } +} + +impl TryFrom<&super::TransactionEffectsV2> for sui_sdk_types::types::TransactionEffectsV2 { + type Error = TryFromProtoError; + + fn try_from( + super::TransactionEffectsV2 { + status, + epoch, + gas_used, + transaction_digest, + gas_object_index, + events_digest, + dependencies, + lamport_version, + changed_objects, + unchanged_shared_objects, + auxiliary_data_digest, + }: &super::TransactionEffectsV2, + ) -> Result { + let status = status + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("status"))? + .try_into()?; + let epoch = epoch.ok_or_else(|| TryFromProtoError::missing("epoch"))?; + + let gas_used = gas_used + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("gas_used"))? + .try_into()?; + + let transaction_digest = transaction_digest + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("transaction_digest"))? + .try_into()?; + + let events_digest = events_digest.as_ref().map(TryInto::try_into).transpose()?; + + let dependencies = dependencies + .iter() + .map(TryInto::try_into) + .collect::>()?; + + let lamport_version = + lamport_version.ok_or_else(|| TryFromProtoError::missing("lamport_version"))?; + + let changed_objects = changed_objects + .iter() + .map(TryInto::try_into) + .collect::>()?; + + let unchanged_shared_objects = unchanged_shared_objects + .iter() + .map(TryInto::try_into) + .collect::>()?; + + let auxiliary_data_digest = auxiliary_data_digest + .as_ref() + .map(TryInto::try_into) + .transpose()?; + + Ok(Self { + status, + epoch, + gas_used, + transaction_digest, + gas_object_index: *gas_object_index, + events_digest, + dependencies, + lamport_version, + changed_objects, + unchanged_shared_objects, + auxiliary_data_digest, + }) + } +} + +// +// ModifiedAtVersion +// + +impl From for super::ModifiedAtVersion { + fn from(value: sui_sdk_types::types::ModifiedAtVersion) -> Self { + Self { + object_id: Some(value.object_id.into()), + version: Some(value.version), + } + } +} + +impl TryFrom<&super::ModifiedAtVersion> for sui_sdk_types::types::ModifiedAtVersion { + type Error = TryFromProtoError; + + fn try_from(value: &super::ModifiedAtVersion) -> Result { + let object_id = value + .object_id + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("object_id"))? + .try_into()?; + let version = value + .version + .ok_or_else(|| TryFromProtoError::missing("version"))?; + + Ok(Self { object_id, version }) + } +} + +// +// ObjectReferenceWithOwner +// + +impl From for super::ObjectReferenceWithOwner { + fn from(value: sui_sdk_types::types::ObjectReferenceWithOwner) -> Self { + Self { + reference: Some(value.reference.into()), + owner: Some(value.owner.into()), + } + } +} + +impl TryFrom<&super::ObjectReferenceWithOwner> for sui_sdk_types::types::ObjectReferenceWithOwner { + type Error = TryFromProtoError; + + fn try_from(value: &super::ObjectReferenceWithOwner) -> Result { + let reference = value + .reference + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("reference"))? + .try_into()?; + + let owner = value + .owner + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("owner"))? + .try_into()?; + + Ok(Self { reference, owner }) + } +} + +// +// ChangedObject +// + +impl From for super::ChangedObject { + fn from(value: sui_sdk_types::types::ChangedObject) -> Self { + Self { + object_id: Some(value.object_id.into()), + input_state: Some(value.change.input_state.into()), + output_state: Some(value.change.output_state.into()), + id_operation: Some(value.change.id_operation.into()), + } + } +} + +impl TryFrom<&super::ChangedObject> for sui_sdk_types::types::ChangedObject { + type Error = TryFromProtoError; + + fn try_from(value: &super::ChangedObject) -> Result { + let object_id = value + .object_id + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("object_id"))? + .try_into()?; + + let input_state = value + .input_state + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("input_state"))? + .try_into()?; + + let output_state = value + .output_state + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("output_state"))? + .try_into()?; + + let id_operation = value + .id_operation + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("id_operation"))? + .try_into()?; + + Ok(Self { + object_id, + change: sui_sdk_types::types::EffectsObjectChange { + input_state, + output_state, + id_operation, + }, + }) + } +} + +// +// InputState +// + +impl From for super::changed_object::InputState { + fn from(value: sui_sdk_types::types::ObjectIn) -> Self { + match value { + sui_sdk_types::types::ObjectIn::NotExist => Self::NotExist(()), + sui_sdk_types::types::ObjectIn::Exist { + version, + digest, + owner, + } => Self::Exist(super::ObjectExist { + version: Some(version), + digest: Some(digest.into()), + owner: Some(owner.into()), + }), + } + } +} + +impl TryFrom<&super::changed_object::InputState> for sui_sdk_types::types::ObjectIn { + type Error = TryFromProtoError; + + fn try_from(value: &super::changed_object::InputState) -> Result { + use super::changed_object::InputState::*; + + match value { + NotExist(()) => Self::NotExist, + Exist(super::ObjectExist { + version, + digest, + owner, + }) => Self::Exist { + version: version.ok_or_else(|| TryFromProtoError::missing("version"))?, + digest: digest + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("digest"))? + .try_into()?, + owner: owner + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("owner"))? + .try_into()?, + }, + } + .pipe(Ok) + } +} + +// +// OutputState +// + +impl From for super::changed_object::OutputState { + fn from(value: sui_sdk_types::types::ObjectOut) -> Self { + use sui_sdk_types::types::ObjectOut::*; + match value { + NotExist => Self::Removed(()), + ObjectWrite { digest, owner } => Self::ObjectWrite(super::ObjectWrite { + digest: Some(digest.into()), + owner: Some(owner.into()), + }), + PackageWrite { version, digest } => Self::PackageWrite(super::PackageWrite { + version: Some(version), + digest: Some(digest.into()), + }), + } + } +} + +impl TryFrom<&super::changed_object::OutputState> for sui_sdk_types::types::ObjectOut { + type Error = TryFromProtoError; + + fn try_from(value: &super::changed_object::OutputState) -> Result { + use super::changed_object::OutputState::*; + + match value { + Removed(()) => Self::NotExist, + ObjectWrite(super::ObjectWrite { digest, owner }) => Self::ObjectWrite { + digest: digest + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("digest"))? + .try_into()?, + + owner: owner + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("owner"))? + .try_into()?, + }, + PackageWrite(super::PackageWrite { version, digest }) => Self::PackageWrite { + version: version.ok_or_else(|| TryFromProtoError::missing("version"))?, + digest: digest + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("digest"))? + .try_into()?, + }, + } + .pipe(Ok) + } +} + +// +// IdOperation +// + +impl From for super::changed_object::IdOperation { + fn from(value: sui_sdk_types::types::IdOperation) -> Self { + use sui_sdk_types::types::IdOperation::*; + + match value { + None => Self::None(()), + Created => Self::Created(()), + Deleted => Self::Deleted(()), + } + } +} + +impl TryFrom<&super::changed_object::IdOperation> for sui_sdk_types::types::IdOperation { + type Error = TryFromProtoError; + + fn try_from(value: &super::changed_object::IdOperation) -> Result { + use super::changed_object::IdOperation; + + match value { + IdOperation::None(()) => Self::None, + IdOperation::Created(()) => Self::Created, + IdOperation::Deleted(()) => Self::Deleted, + } + .pipe(Ok) + } +} + +// +// UnchangedSharedObject +// + +impl From for super::UnchangedSharedObject { + fn from(value: sui_sdk_types::types::UnchangedSharedObject) -> Self { + Self { + object_id: Some(value.object_id.into()), + kind: Some(value.kind.into()), + } + } +} + +impl TryFrom<&super::UnchangedSharedObject> for sui_sdk_types::types::UnchangedSharedObject { + type Error = TryFromProtoError; + + fn try_from(value: &super::UnchangedSharedObject) -> Result { + let object_id = value + .object_id + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("object_id"))? + .try_into()?; + + let kind = value + .kind + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("kind"))? + .try_into()?; + + Ok(Self { object_id, kind }) + } +} + +// +// UnchangedSharedKind +// + +impl From for super::unchanged_shared_object::Kind { + fn from(value: sui_sdk_types::types::UnchangedSharedKind) -> Self { + use sui_sdk_types::types::UnchangedSharedKind::*; + + match value { + ReadOnlyRoot { version, digest } => Self::ReadOnlyRoot(super::ReadOnlyRoot { + version: Some(version), + digest: Some(digest.into()), + }), + MutateDeleted { version } => Self::MutateDeleted(version), + ReadDeleted { version } => Self::ReadDeleted(version), + Cancelled { version } => Self::Cancelled(version), + PerEpochConfig => Self::PerEpochConfig(()), + } + } +} + +impl TryFrom<&super::unchanged_shared_object::Kind> for sui_sdk_types::types::UnchangedSharedKind { + type Error = TryFromProtoError; + + fn try_from(value: &super::unchanged_shared_object::Kind) -> Result { + use super::unchanged_shared_object::Kind::*; + + match value { + ReadOnlyRoot(super::ReadOnlyRoot { version, digest }) => Self::ReadOnlyRoot { + version: version.ok_or_else(|| TryFromProtoError::missing("version"))?, + + digest: digest + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("digest"))? + .try_into()?, + }, + MutateDeleted(version) => Self::MutateDeleted { version: *version }, + ReadDeleted(version) => Self::ReadDeleted { version: *version }, + Cancelled(version) => Self::Cancelled { version: *version }, + PerEpochConfig(()) => Self::PerEpochConfig, + } + .pipe(Ok) + } +} diff --git a/crates/sui-rpc-api/src/proto/types/events.rs b/crates/sui-rpc-api/src/proto/types/events.rs new file mode 100644 index 0000000000000..3b0b9e057c4cf --- /dev/null +++ b/crates/sui-rpc-api/src/proto/types/events.rs @@ -0,0 +1,87 @@ +use super::TryFromProtoError; + +// +// Event +// + +impl From for super::Event { + fn from(value: sui_sdk_types::types::Event) -> Self { + Self { + package_id: Some(value.package_id.into()), + module: Some(value.module.into()), + sender: Some(value.sender.into()), + event_type: Some(value.type_.into()), + contents: Some(value.contents.into()), + } + } +} + +impl TryFrom<&super::Event> for sui_sdk_types::types::Event { + type Error = TryFromProtoError; + + fn try_from(value: &super::Event) -> Result { + let package_id = value + .package_id + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("package_id"))? + .try_into()?; + + let module = value + .module + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("module"))? + .try_into()?; + + let sender = value + .sender + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("sender"))? + .try_into()?; + + let type_ = value + .event_type + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("event_type"))? + .try_into()?; + + let contents = value + .contents + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("contents"))? + .to_vec(); + + Ok(Self { + package_id, + module, + sender, + type_, + contents, + }) + } +} + +// +// TransactionEvents +// + +impl From for super::TransactionEvents { + fn from(value: sui_sdk_types::types::TransactionEvents) -> Self { + Self { + events: value.0.into_iter().map(Into::into).collect(), + } + } +} + +impl TryFrom<&super::TransactionEvents> for sui_sdk_types::types::TransactionEvents { + type Error = TryFromProtoError; + + fn try_from(value: &super::TransactionEvents) -> Result { + Ok(Self( + value + .events + .iter() + .map(TryInto::try_into) + .collect::>()?, + )) + } +} diff --git a/crates/sui-rpc-api/src/proto/types/execution_status.rs b/crates/sui-rpc-api/src/proto/types/execution_status.rs new file mode 100644 index 0000000000000..8c0586452c200 --- /dev/null +++ b/crates/sui-rpc-api/src/proto/types/execution_status.rs @@ -0,0 +1,520 @@ +use super::TryFromProtoError; +use tap::Pipe; + +// +// ExecutionStatus +// + +impl From for super::ExecutionStatus { + fn from(value: sui_sdk_types::types::ExecutionStatus) -> Self { + match value { + sui_sdk_types::types::ExecutionStatus::Success => Self { + success: Some(true), + status: None, + }, + sui_sdk_types::types::ExecutionStatus::Failure { error, command } => Self { + success: Some(false), + status: Some(super::FailureStatus { + command, + execution_error: Some(error.into()), + }), + }, + } + } +} + +impl TryFrom<&super::ExecutionStatus> for sui_sdk_types::types::ExecutionStatus { + type Error = TryFromProtoError; + + fn try_from(value: &super::ExecutionStatus) -> Result { + let success = value + .success + .ok_or_else(|| TryFromProtoError::missing("success"))?; + match (success, &value.status) { + (true, None) => Self::Success, + ( + false, + Some(super::FailureStatus { + command, + execution_error, + }), + ) => Self::Failure { + error: execution_error + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("execution_error"))? + .try_into()?, + command: *command, + }, + (true, Some(_)) | (false, None) => { + return Err(TryFromProtoError::from_error("invalid execution status")) + } + } + .pipe(Ok) + } +} + +// +// ExecutionError +// + +impl From for super::failure_status::ExecutionError { + fn from(value: sui_sdk_types::types::ExecutionError) -> Self { + use sui_sdk_types::types::ExecutionError::*; + match value { + InsufficientGas => Self::InsufficientGas(()), + InvalidGasObject => Self::InvalidGasObject(()), + InvariantViolation => Self::InvariantViolation(()), + FeatureNotYetSupported => Self::FeatureNotYetSupported(()), + ObjectTooBig { + object_size, + max_object_size, + } => Self::ObjectTooBig(super::SizeError { + size: Some(object_size), + max_size: Some(max_object_size), + }), + PackageTooBig { + object_size, + max_object_size, + } => Self::PackageTooBig(super::SizeError { + size: Some(object_size), + max_size: Some(max_object_size), + }), + CircularObjectOwnership { object } => Self::CircularObjectOwnership(object.into()), + InsufficientCoinBalance => Self::InsufficientCoinBalance(()), + CoinBalanceOverflow => Self::CoinBalanceOverflow(()), + PublishErrorNonZeroAddress => Self::PublishErrorNonZeroAddress(()), + SuiMoveVerificationError => Self::SuiMoveVerificationError(()), + MovePrimitiveRuntimeError { location } => { + Self::MovePrimitiveRuntimeError(super::MoveError { + location: location.map(Into::into), + abort_code: None, + }) + } + MoveAbort { location, code } => Self::MoveAbort(super::MoveError { + location: Some(location.into()), + abort_code: Some(code), + }), + VmVerificationOrDeserializationError => Self::VmVerificationOrDeserializationError(()), + VmInvariantViolation => Self::VmInvariantViolation(()), + FunctionNotFound => Self::FunctionNotFound(()), + ArityMismatch => Self::ArityMismatch(()), + TypeArityMismatch => Self::TypeArityMismatch(()), + NonEntryFunctionInvoked => Self::NonEntryFunctionInvoked(()), + CommandArgumentError { argument, kind } => { + Self::CommandArgumentError(super::CommandArgumentError { + argument: Some(argument.into()), + kind: Some(kind.into()), + }) + } + TypeArgumentError { + type_argument, + kind, + } => Self::TypeArgumentError(super::TypeArgumentError { + type_argument: Some(type_argument.into()), + kind: Some(kind.into()), + }), + UnusedValueWithoutDrop { result, subresult } => { + Self::UnusedValueWithoutDrop(super::NestedResult { + result: Some(result.into()), + subresult: Some(subresult.into()), + }) + } + InvalidPublicFunctionReturnType { index } => { + Self::InvalidPublicFunctionReturnType(index.into()) + } + InvalidTransferObject => Self::InvalidTransferObject(()), + EffectsTooLarge { + current_size, + max_size, + } => Self::EffectsTooLarge(super::SizeError { + size: Some(current_size), + max_size: Some(max_size), + }), + PublishUpgradeMissingDependency => Self::PublishUpgradeMissingDependency(()), + PublishUpgradeDependencyDowngrade => Self::PublishUpgradeDependencyDowngrade(()), + PackageUpgradeError { kind } => Self::PackageUpgradeError(super::PackageUpgradeError { + kind: Some(kind.into()), + }), + WrittenObjectsTooLarge { + object_size, + max_object_size, + } => Self::WrittenObjectsTooLarge(super::SizeError { + size: Some(object_size), + max_size: Some(max_object_size), + }), + CertificateDenied => Self::CertificateDenied(()), + SuiMoveVerificationTimedout => Self::SuiMoveVerificationTimedout(()), + SharedObjectOperationNotAllowed => Self::SharedObjectOperationNotAllowed(()), + InputObjectDeleted => Self::InputObjectDeleted(()), + ExecutionCancelledDueToSharedObjectCongestion { congested_objects } => { + Self::ExecutionCancelledDueToSharedObjectCongestion(super::CongestedObjectsError { + congested_objects: congested_objects.into_iter().map(Into::into).collect(), + }) + } + AddressDeniedForCoin { address, coin_type } => { + Self::AddressDeniedForCoin(super::AddressDeniedForCoinError { + coin_type: Some(coin_type), + address: Some(address.into()), + }) + } + CoinTypeGlobalPause { coin_type } => Self::CoinTypeGlobalPause(coin_type), + ExecutionCancelledDueToRandomnessUnavailable => { + Self::ExecutionCancelledDueToRandomnessUnavailable(()) + } + } + } +} + +impl TryFrom<&super::failure_status::ExecutionError> for sui_sdk_types::types::ExecutionError { + type Error = TryFromProtoError; + + fn try_from(value: &super::failure_status::ExecutionError) -> Result { + use super::failure_status::ExecutionError::*; + + match value { + InsufficientGas(()) => Self::InsufficientGas, + InvalidGasObject(()) => Self::InvalidGasObject, + InvariantViolation(()) => Self::InvariantViolation, + FeatureNotYetSupported(()) => Self::FeatureNotYetSupported, + ObjectTooBig(super::SizeError { size, max_size }) => Self::ObjectTooBig { + object_size: size.ok_or_else(|| TryFromProtoError::missing("size"))?, + max_object_size: max_size.ok_or_else(|| TryFromProtoError::missing("max_size"))?, + }, + PackageTooBig(super::SizeError { size, max_size }) => Self::PackageTooBig { + object_size: size.ok_or_else(|| TryFromProtoError::missing("size"))?, + max_object_size: max_size.ok_or_else(|| TryFromProtoError::missing("max_size"))?, + }, + CircularObjectOwnership(object) => Self::CircularObjectOwnership { + object: object.try_into()?, + }, + InsufficientCoinBalance(()) => Self::InsufficientCoinBalance, + CoinBalanceOverflow(()) => Self::CoinBalanceOverflow, + PublishErrorNonZeroAddress(()) => Self::PublishErrorNonZeroAddress, + SuiMoveVerificationError(()) => Self::SuiMoveVerificationError, + MovePrimitiveRuntimeError(super::MoveError { + location, + abort_code: _, + }) => Self::MovePrimitiveRuntimeError { + location: location.as_ref().map(TryInto::try_into).transpose()?, + }, + MoveAbort(super::MoveError { + location: Some(location), + abort_code: Some(abort_code), + }) => Self::MoveAbort { + location: location.try_into()?, + code: *abort_code, + }, + MoveAbort(_) => return Err(TryFromProtoError::missing("location or abort_code")), + VmVerificationOrDeserializationError(()) => Self::VmVerificationOrDeserializationError, + VmInvariantViolation(()) => Self::VmInvariantViolation, + FunctionNotFound(()) => Self::FunctionNotFound, + ArityMismatch(()) => Self::ArityMismatch, + TypeArityMismatch(()) => Self::TypeArityMismatch, + NonEntryFunctionInvoked(()) => Self::NonEntryFunctionInvoked, + CommandArgumentError(super::CommandArgumentError { argument, kind }) => { + Self::CommandArgumentError { + argument: argument + .ok_or_else(|| TryFromProtoError::missing("argument"))? + .try_into()?, + kind: kind + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("kind"))? + .try_into()?, + } + } + TypeArgumentError(super::TypeArgumentError { + type_argument, + kind, + }) => Self::TypeArgumentError { + type_argument: type_argument + .ok_or_else(|| TryFromProtoError::missing("type_argument"))? + .try_into()?, + kind: kind + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("kind"))? + .try_into()?, + }, + UnusedValueWithoutDrop(super::NestedResult { result, subresult }) => { + Self::UnusedValueWithoutDrop { + result: result + .ok_or_else(|| TryFromProtoError::missing("result"))? + .try_into()?, + subresult: subresult + .ok_or_else(|| TryFromProtoError::missing("subresult"))? + .try_into()?, + } + } + InvalidPublicFunctionReturnType(index) => Self::InvalidPublicFunctionReturnType { + index: (*index).try_into()?, + }, + InvalidTransferObject(()) => Self::InvalidTransferObject, + EffectsTooLarge(super::SizeError { size, max_size }) => Self::EffectsTooLarge { + current_size: size.ok_or_else(|| TryFromProtoError::missing("size"))?, + max_size: max_size.ok_or_else(|| TryFromProtoError::missing("max_size"))?, + }, + PublishUpgradeMissingDependency(()) => Self::PublishUpgradeMissingDependency, + PublishUpgradeDependencyDowngrade(()) => Self::PublishUpgradeDependencyDowngrade, + PackageUpgradeError(super::PackageUpgradeError { kind }) => Self::PackageUpgradeError { + kind: kind + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("kind"))? + .try_into()?, + }, + WrittenObjectsTooLarge(super::SizeError { size, max_size }) => { + Self::WrittenObjectsTooLarge { + object_size: size.ok_or_else(|| TryFromProtoError::missing("size"))?, + max_object_size: max_size + .ok_or_else(|| TryFromProtoError::missing("max_size"))?, + } + } + CertificateDenied(()) => Self::CertificateDenied, + SuiMoveVerificationTimedout(()) => Self::SuiMoveVerificationTimedout, + SharedObjectOperationNotAllowed(()) => Self::SharedObjectOperationNotAllowed, + InputObjectDeleted(()) => Self::InputObjectDeleted, + ExecutionCancelledDueToSharedObjectCongestion(super::CongestedObjectsError { + congested_objects, + }) => Self::ExecutionCancelledDueToSharedObjectCongestion { + congested_objects: congested_objects + .iter() + .map(TryInto::try_into) + .collect::>()?, + }, + AddressDeniedForCoin(super::AddressDeniedForCoinError { address, coin_type }) => { + Self::AddressDeniedForCoin { + address: address + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("address"))? + .try_into()?, + coin_type: coin_type + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("coin_type"))? + .to_owned(), + } + } + CoinTypeGlobalPause(coin_type) => Self::CoinTypeGlobalPause { + coin_type: coin_type.to_owned(), + }, + ExecutionCancelledDueToRandomnessUnavailable(()) => { + Self::ExecutionCancelledDueToRandomnessUnavailable + } + } + .pipe(Ok) + } +} + +// +// CommandArgumentError +// + +impl From for super::command_argument_error::Kind { + fn from(value: sui_sdk_types::types::CommandArgumentError) -> Self { + use sui_sdk_types::types::CommandArgumentError::*; + + match value { + TypeMismatch => Self::TypeMismatch(()), + InvalidBcsBytes => Self::InvalidBcsBytes(()), + InvalidUsageOfPureArgument => Self::InvalidUsageOfPureArgument(()), + InvalidArgumentToPrivateEntryFunction => { + Self::InvalidArgumentToPrivateEntryFunction(()) + } + IndexOutOfBounds { index } => Self::IndexOutOfBounds(index.into()), + SecondaryIndexOutOfBounds { result, subresult } => { + Self::SecondaryIndexOutOfBounds(super::NestedResult { + result: Some(result.into()), + subresult: Some(subresult.into()), + }) + } + InvalidResultArity { result } => Self::InvalidResultArity(result.into()), + InvalidGasCoinUsage => Self::InvalidGasCoinUsage(()), + InvalidValueUsage => Self::InvalidValueUsage(()), + InvalidObjectByValue => Self::InvalidObjectByValue(()), + InvalidObjectByMutRef => Self::InvalidObjectByMutRef(()), + SharedObjectOperationNotAllowed => Self::SharedObjectOperationNotAllowed(()), + } + } +} + +impl TryFrom<&super::command_argument_error::Kind> for sui_sdk_types::types::CommandArgumentError { + type Error = TryFromProtoError; + + fn try_from(value: &super::command_argument_error::Kind) -> Result { + use super::command_argument_error::Kind::*; + use super::NestedResult; + + match value { + TypeMismatch(()) => Self::TypeMismatch, + InvalidBcsBytes(()) => Self::InvalidBcsBytes, + InvalidUsageOfPureArgument(()) => Self::InvalidUsageOfPureArgument, + InvalidArgumentToPrivateEntryFunction(()) => { + Self::InvalidArgumentToPrivateEntryFunction + } + IndexOutOfBounds(index) => Self::IndexOutOfBounds { + index: (*index).try_into()?, + }, + SecondaryIndexOutOfBounds(NestedResult { result, subresult }) => { + Self::SecondaryIndexOutOfBounds { + result: result + .ok_or_else(|| TryFromProtoError::missing("result"))? + .try_into()?, + subresult: subresult + .ok_or_else(|| TryFromProtoError::missing("subresult"))? + .try_into()?, + } + } + InvalidResultArity(result) => Self::InvalidResultArity { + result: (*result).try_into()?, + }, + InvalidGasCoinUsage(()) => Self::InvalidGasCoinUsage, + InvalidValueUsage(()) => Self::InvalidValueUsage, + InvalidObjectByValue(()) => Self::InvalidObjectByValue, + InvalidObjectByMutRef(()) => Self::InvalidObjectByMutRef, + SharedObjectOperationNotAllowed(()) => Self::SharedObjectOperationNotAllowed, + } + .pipe(Ok) + } +} + +// +// TypeArgumentError +// + +impl From for super::type_argument_error::Kind { + fn from(value: sui_sdk_types::types::TypeArgumentError) -> Self { + use sui_sdk_types::types::TypeArgumentError::*; + + match value { + TypeNotFound => Self::TypeNotFound(()), + ConstraintNotSatisfied => Self::ConstraintNotSatisfied(()), + } + } +} + +impl TryFrom<&super::type_argument_error::Kind> for sui_sdk_types::types::TypeArgumentError { + type Error = TryFromProtoError; + + fn try_from(value: &super::type_argument_error::Kind) -> Result { + use super::type_argument_error::Kind::*; + + match value { + TypeNotFound(()) => Self::TypeNotFound, + ConstraintNotSatisfied(()) => Self::ConstraintNotSatisfied, + } + .pipe(Ok) + } +} + +// +// PackageUpgradeError +// + +impl From for super::package_upgrade_error::Kind { + fn from(value: sui_sdk_types::types::PackageUpgradeError) -> Self { + use sui_sdk_types::types::PackageUpgradeError::*; + + match value { + UnableToFetchPackage { package_id } => Self::UnableToFetchPackage(package_id.into()), + NotAPackage { object_id } => Self::NotAPackage(object_id.into()), + IncompatibleUpgrade => Self::IncompatibleUpgrade(()), + DigestDoesNotMatch { digest } => Self::DigetsDoesNotMatch(digest.into()), + UnknownUpgradePolicy { policy } => Self::UnknownUpgradePolicy(policy.into()), + PackageIdDoesNotMatch { + package_id, + ticket_id, + } => Self::PackageIdDoesNotMatch(super::PackageIdDoesNotMatch { + package_id: Some(package_id.into()), + object_id: Some(ticket_id.into()), + }), + } + } +} + +impl TryFrom<&super::package_upgrade_error::Kind> for sui_sdk_types::types::PackageUpgradeError { + type Error = TryFromProtoError; + + fn try_from(value: &super::package_upgrade_error::Kind) -> Result { + use super::package_upgrade_error::Kind::*; + + match value { + UnableToFetchPackage(package_id) => Self::UnableToFetchPackage { + package_id: package_id.try_into()?, + }, + NotAPackage(object_id) => Self::NotAPackage { + object_id: object_id.try_into()?, + }, + IncompatibleUpgrade(()) => Self::IncompatibleUpgrade, + DigetsDoesNotMatch(digest) => Self::DigestDoesNotMatch { + digest: digest.try_into()?, + }, + UnknownUpgradePolicy(policy) => Self::UnknownUpgradePolicy { + policy: (*policy).try_into()?, + }, + PackageIdDoesNotMatch(super::PackageIdDoesNotMatch { + package_id: Some(package_id), + object_id: Some(ticket_id), + }) => Self::PackageIdDoesNotMatch { + package_id: package_id.try_into()?, + ticket_id: ticket_id.try_into()?, + }, + PackageIdDoesNotMatch(_) => { + return Err(TryFromProtoError::missing( + "missing package_id or ticket_id", + )) + } + } + .pipe(Ok) + } +} + +// +// MoveLocation +// + +impl From for super::MoveLocation { + fn from(value: sui_sdk_types::types::MoveLocation) -> Self { + Self { + package: Some(value.package.into()), + module: Some(value.module.into()), + function: Some(value.function.into()), + instruction: Some(value.instruction.into()), + function_name: value.function_name.map(Into::into), + } + } +} + +impl TryFrom<&super::MoveLocation> for sui_sdk_types::types::MoveLocation { + type Error = TryFromProtoError; + + fn try_from(value: &super::MoveLocation) -> Result { + let package = value + .package + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("package"))? + .try_into()?; + let module = value + .module + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("module"))? + .try_into()?; + let function = value + .function + .ok_or_else(|| TryFromProtoError::missing("function"))? + .try_into()?; + let instruction = value + .instruction + .ok_or_else(|| TryFromProtoError::missing("instruction"))? + .try_into()?; + let function_name = value + .function_name + .as_ref() + .map(TryFrom::try_from) + .transpose()?; + + Ok(Self { + package, + module, + function, + instruction, + function_name, + }) + } +} diff --git a/crates/sui-rpc-api/src/proto/types/mod.rs b/crates/sui-rpc-api/src/proto/types/mod.rs new file mode 100644 index 0000000000000..c0614f2a44e87 --- /dev/null +++ b/crates/sui-rpc-api/src/proto/types/mod.rs @@ -0,0 +1,241 @@ +use super::TryFromProtoError; + +#[rustfmt::skip] +#[path = "../generated/sui.types.rs"] +pub mod generated; +pub use generated::*; + +mod checkpoint; +mod effects; +mod events; +mod execution_status; +mod move_types; +mod object; +mod signatures; +mod transaction_convert; + +// +// Address +// + +impl From for Address { + fn from(value: sui_sdk_types::types::Address) -> Self { + Self { + address: Some(value.as_bytes().to_vec().into()), + } + } +} + +impl TryFrom<&Address> for sui_sdk_types::types::Address { + type Error = TryFromProtoError; + + fn try_from(Address { address }: &Address) -> Result { + let address = address + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("address"))? + .as_ref() + .try_into()?; + + Ok(Self::new(address)) + } +} + +// +// ObjectId +// + +impl From for ObjectId { + fn from(value: sui_sdk_types::types::ObjectId) -> Self { + Self { + object_id: Some(value.as_bytes().to_vec().into()), + } + } +} + +impl TryFrom<&ObjectId> for sui_sdk_types::types::ObjectId { + type Error = TryFromProtoError; + + fn try_from(ObjectId { object_id }: &ObjectId) -> Result { + let object_id = object_id + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("object_id"))? + .as_ref() + .try_into()?; + + Ok(Self::new(object_id)) + } +} + +// +// Digest +// + +impl From for Digest { + fn from(value: sui_sdk_types::types::Digest) -> Self { + Self { + digest: Some(value.as_bytes().to_vec().into()), + } + } +} + +impl TryFrom<&Digest> for sui_sdk_types::types::Digest { + type Error = TryFromProtoError; + + fn try_from(Digest { digest }: &Digest) -> Result { + let digest = digest + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("digest"))? + .as_ref() + .try_into()?; + + Ok(Self::new(digest)) + } +} + +macro_rules! impl_digest_proto { + ($t:ident) => { + impl From for Digest { + fn from(value: sui_sdk_types::types::$t) -> Self { + sui_sdk_types::types::Digest::from(value).into() + } + } + + impl TryFrom<&Digest> for sui_sdk_types::types::$t { + type Error = TryFromProtoError; + + fn try_from(digest: &Digest) -> Result { + sui_sdk_types::types::Digest::try_from(digest).map(Into::into) + } + } + }; +} + +impl_digest_proto!(CheckpointDigest); +impl_digest_proto!(CheckpointContentsDigest); +impl_digest_proto!(TransactionDigest); +impl_digest_proto!(TransactionEffectsDigest); +impl_digest_proto!(TransactionEventsDigest); +impl_digest_proto!(ObjectDigest); +impl_digest_proto!(ConsensusCommitDigest); +impl_digest_proto!(EffectsAuxiliaryDataDigest); + +// +// TimeStamp +// + +pub fn timestamp_ms_to_proto(timestamp_ms: u64) -> prost_types::Timestamp { + let timestamp = std::time::Duration::from_millis(timestamp_ms); + prost_types::Timestamp { + seconds: timestamp.as_secs() as i64, + nanos: timestamp.subsec_nanos() as i32, + } +} + +pub fn proto_to_timestamp_ms(timestamp: prost_types::Timestamp) -> Result { + let seconds = std::time::Duration::from_secs(timestamp.seconds.try_into()?); + let nanos = std::time::Duration::from_nanos(timestamp.nanos.try_into()?); + + Ok((seconds + nanos).as_millis().try_into()?) +} + +// +// Bcs +// + +impl Bcs { + pub fn serialize(value: &T) -> Result { + bcs::to_bytes(value).map(|bcs| Self { + bcs: Some(bcs.into()), + }) + } + + pub fn deserialize<'de, T: serde::Deserialize<'de>>(&'de self) -> Result { + bcs::from_bytes(self.bcs.as_deref().unwrap_or(&[])) + } +} + +impl From> for Bcs { + fn from(value: Vec) -> Self { + Self { + bcs: Some(value.into()), + } + } +} + +impl From<&Bcs> for Vec { + fn from(value: &Bcs) -> Self { + value + .bcs + .as_ref() + .map(|bytes| bytes.to_vec()) + .unwrap_or_default() + } +} + +impl From for Vec { + fn from(value: Bcs) -> Self { + value + .bcs + .as_ref() + .map(|bytes| bytes.to_vec()) + .unwrap_or_default() + } +} + +impl From for Bcs { + fn from(value: prost::bytes::Bytes) -> Self { + Self { bcs: Some(value) } + } +} + +impl From<&Bcs> for prost::bytes::Bytes { + fn from(value: &Bcs) -> Self { + value.bcs.clone().unwrap_or_default() + } +} + +impl From for prost::bytes::Bytes { + fn from(value: Bcs) -> Self { + value.bcs.unwrap_or_default() + } +} + +// +// U128 +// + +impl From for U128 { + fn from(value: u128) -> Self { + Self { + bytes: Some(value.to_le_bytes().to_vec().into()), + } + } +} + +impl TryFrom<&U128> for u128 { + type Error = std::array::TryFromSliceError; + + fn try_from(value: &U128) -> Result { + Ok(u128::from_le_bytes(value.bytes().try_into()?)) + } +} + +// +// I128 +// + +impl From for I128 { + fn from(value: i128) -> Self { + Self { + bytes: Some(value.to_le_bytes().to_vec().into()), + } + } +} + +impl TryFrom<&I128> for i128 { + type Error = std::array::TryFromSliceError; + + fn try_from(value: &I128) -> Result { + Ok(i128::from_le_bytes(value.bytes().try_into()?)) + } +} diff --git a/crates/sui-rpc-api/src/proto/types/move_types.rs b/crates/sui-rpc-api/src/proto/types/move_types.rs new file mode 100644 index 0000000000000..7862c63b981ab --- /dev/null +++ b/crates/sui-rpc-api/src/proto/types/move_types.rs @@ -0,0 +1,132 @@ +use super::TryFromProtoError; +use tap::Pipe; + +// +// Identifier +// + +impl From for super::Identifier { + fn from(value: sui_sdk_types::types::Identifier) -> Self { + Self { + identifier: Some(value.into_inner().into_boxed_bytes().into()), + } + } +} + +impl TryFrom<&super::Identifier> for sui_sdk_types::types::Identifier { + type Error = TryFromProtoError; + + fn try_from(value: &super::Identifier) -> Result { + value + .identifier + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("identifier"))? + .as_ref() + .pipe(std::str::from_utf8)? + .pipe(Self::new) + .map_err(TryFromProtoError::from_error) + } +} + +// +// StructTag +// + +impl From for super::StructTag { + fn from(value: sui_sdk_types::types::StructTag) -> Self { + Self { + address: Some(value.address.into()), + module: Some(value.module.into()), + name: Some(value.name.into()), + type_parameters: value.type_params.into_iter().map(Into::into).collect(), + } + } +} + +impl TryFrom<&super::StructTag> for sui_sdk_types::types::StructTag { + type Error = TryFromProtoError; + + fn try_from(value: &super::StructTag) -> Result { + let address = value + .address + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("address"))? + .pipe(TryFrom::try_from)?; + let module = value + .module + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("module"))? + .pipe(TryFrom::try_from)?; + let name = value + .name + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("name"))? + .pipe(TryFrom::try_from)?; + let type_params = value + .type_parameters + .iter() + .map(TryInto::try_into) + .collect::>()?; + + Ok(Self { + address, + module, + name, + type_params, + }) + } +} + +// +// TypeTag +// + +impl From for super::TypeTag { + fn from(value: sui_sdk_types::types::TypeTag) -> Self { + use super::type_tag::Tag; + use sui_sdk_types::types::TypeTag; + + let tag = match value { + TypeTag::U8 => Tag::U8(()), + TypeTag::U16 => Tag::U16(()), + TypeTag::U32 => Tag::U32(()), + TypeTag::U64 => Tag::U64(()), + TypeTag::U128 => Tag::U128(()), + TypeTag::U256 => Tag::U256(()), + TypeTag::Bool => Tag::Bool(()), + TypeTag::Address => Tag::Address(()), + TypeTag::Signer => Tag::Signer(()), + TypeTag::Vector(type_tag) => Tag::Vector(Box::new((*type_tag).into())), + TypeTag::Struct(struct_tag) => Tag::Struct((*struct_tag).into()), + }; + + Self { tag: Some(tag) } + } +} + +impl TryFrom<&super::TypeTag> for sui_sdk_types::types::TypeTag { + type Error = TryFromProtoError; + + fn try_from(value: &super::TypeTag) -> Result { + use super::type_tag::Tag; + + match value + .tag + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("type_tag"))? + { + Tag::U8(()) => Self::U8, + Tag::U16(()) => Self::U16, + Tag::U32(()) => Self::U32, + Tag::U64(()) => Self::U64, + Tag::U128(()) => Self::U128, + Tag::U256(()) => Self::U256, + Tag::Bool(()) => Self::Bool, + Tag::Address(()) => Self::Address, + Tag::Signer(()) => Self::Signer, + Tag::Vector(type_tag) => Self::Vector(Box::new(type_tag.as_ref().try_into()?)), + Tag::Struct(struct_tag) => Self::Struct(Box::new(struct_tag.try_into()?)), + } + .pipe(Ok) + } +} diff --git a/crates/sui-rpc-api/src/proto/types/object.rs b/crates/sui-rpc-api/src/proto/types/object.rs new file mode 100644 index 0000000000000..6a7f434d40a0b --- /dev/null +++ b/crates/sui-rpc-api/src/proto/types/object.rs @@ -0,0 +1,422 @@ +use super::TryFromProtoError; +use tap::Pipe; + +// +// ObjectReference +// + +impl From for super::ObjectReference { + fn from(value: sui_sdk_types::types::ObjectReference) -> Self { + let (object_id, version, digest) = value.into_parts(); + Self { + object_id: Some(object_id.into()), + version: Some(version), + digest: Some(digest.into()), + } + } +} + +impl TryFrom<&super::ObjectReference> for sui_sdk_types::types::ObjectReference { + type Error = TryFromProtoError; + + fn try_from(value: &super::ObjectReference) -> Result { + let object_id = value + .object_id + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("object_id"))? + .try_into()?; + + let version = value + .version + .ok_or_else(|| TryFromProtoError::missing("version"))?; + + let digest = value + .digest + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("digest"))? + .try_into()?; + + Ok(Self::new(object_id, version, digest)) + } +} + +// +// Object +// + +impl From for super::Object { + fn from(value: sui_sdk_types::types::Object) -> Self { + Self { + object_id: Some(value.object_id().into()), + version: Some(value.version()), + owner: Some(value.owner().to_owned().into()), + object: Some(value.data().to_owned().into()), + previous_transaction: Some(value.previous_transaction().into()), + storage_rebate: Some(value.storage_rebate()), + } + } +} + +impl TryFrom<&super::Object> for sui_sdk_types::types::Object { + type Error = TryFromProtoError; + + fn try_from(value: &super::Object) -> Result { + let owner = value + .owner + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("owner"))? + .try_into()?; + let object_data = value + .object + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("object_data"))? + .try_into()?; + + let previous_transaction = value + .previous_transaction + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("previous_transaction"))? + .try_into()?; + let storage_rebate = value + .storage_rebate + .ok_or_else(|| TryFromProtoError::missing("storage_rebate"))?; + + Ok(Self::new( + object_data, + owner, + previous_transaction, + storage_rebate, + )) + } +} + +// +// Owner +// + +impl From for super::Owner { + fn from(value: sui_sdk_types::types::Owner) -> Self { + use super::owner::Kind; + use sui_sdk_types::types::Owner::*; + + let kind = match value { + Address(address) => Kind::Address(address.into()), + Object(object) => Kind::Object(object.into()), + Shared(version) => Kind::Shared(version), + Immutable => Kind::Immutable(()), + }; + + Self { kind: Some(kind) } + } +} + +impl TryFrom<&super::Owner> for sui_sdk_types::types::Owner { + type Error = TryFromProtoError; + + fn try_from(value: &super::Owner) -> Result { + use super::owner::Kind::*; + + match value + .kind + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("kind"))? + { + Address(address) => Self::Address(address.try_into()?), + Object(object) => Self::Object(object.try_into()?), + Shared(version) => Self::Shared(*version), + Immutable(()) => Self::Immutable, + } + .pipe(Ok) + } +} + +// +// ObjectData +// + +impl From for super::ObjectData { + fn from(value: sui_sdk_types::types::ObjectData) -> Self { + use super::object_data::Kind; + use sui_sdk_types::types::ObjectData::*; + + let kind = match value { + Struct(s) => Kind::Struct(s.into()), + Package(p) => Kind::Package(p.into()), + }; + + Self { kind: Some(kind) } + } +} + +impl TryFrom<&super::ObjectData> for sui_sdk_types::types::ObjectData { + type Error = TryFromProtoError; + + fn try_from(value: &super::ObjectData) -> Result { + use super::object_data::Kind::*; + + match value + .kind + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("kind"))? + { + Struct(s) => Self::Struct(s.try_into()?), + Package(p) => Self::Package(p.try_into()?), + } + .pipe(Ok) + } +} + +// +// MoveStruct +// + +impl From for super::MoveStruct { + fn from(value: sui_sdk_types::types::MoveStruct) -> Self { + Self { + object_id: Some(value.object_id().into()), + object_type: Some(value.object_type().to_owned().into()), + has_public_transfer: Some(value.has_public_transfer()), + version: Some(value.version()), + contents: Some(value.contents().to_vec().into()), + } + } +} + +impl TryFrom<&super::MoveStruct> for sui_sdk_types::types::MoveStruct { + type Error = TryFromProtoError; + + fn try_from( + super::MoveStruct { + object_id: _, + object_type, + has_public_transfer, + version, + contents, + }: &super::MoveStruct, + ) -> Result { + let object_type = object_type + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("object_type"))? + .try_into()?; + + let has_public_transfer = + has_public_transfer.ok_or_else(|| TryFromProtoError::missing("has_public_transfer"))?; + let version = version.ok_or_else(|| TryFromProtoError::missing("version"))?; + let contents = contents + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("contents"))? + .to_vec(); + + Self::new(object_type, has_public_transfer, version, contents) + .ok_or_else(|| TryFromProtoError::from_error("contents missing object_id")) + } +} + +// +// MovePackage +// + +impl From for super::MovePackage { + fn from(value: sui_sdk_types::types::MovePackage) -> Self { + let modules = value + .modules + .into_iter() + .map(|(name, contents)| super::MoveModule { + name: Some(name.into()), + contents: Some(contents.into()), + }) + .collect(); + + let type_origin_table = value + .type_origin_table + .into_iter() + .map(Into::into) + .collect(); + + let linkage_table = value + .linkage_table + .into_iter() + .map( + |( + original_id, + sui_sdk_types::types::UpgradeInfo { + upgraded_id, + upgraded_version, + }, + )| { + super::UpgradeInfo { + original_id: Some(original_id.into()), + upgraded_id: Some(upgraded_id.into()), + upgraded_version: Some(upgraded_version), + } + }, + ) + .collect(); + + Self { + id: Some(value.id.into()), + version: Some(value.version), + modules, + type_origin_table, + linkage_table, + } + } +} + +impl TryFrom<&super::MovePackage> for sui_sdk_types::types::MovePackage { + type Error = TryFromProtoError; + + fn try_from(value: &super::MovePackage) -> Result { + let id = value + .id + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("id"))? + .try_into()?; + + let modules = value + .modules + .iter() + .map(|module| { + let name = module + .name + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("name"))? + .try_into()?; + + let contents = module + .contents + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("contents"))? + .to_vec(); + + Ok((name, contents)) + }) + .collect::>()?; + + let type_origin_table = value + .type_origin_table + .iter() + .map(TryInto::try_into) + .collect::>()?; + + let linkage_table = value + .linkage_table + .iter() + .map(|upgrade_info| { + let original_id = upgrade_info + .original_id + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("original_id"))? + .try_into()?; + + let upgraded_id = upgrade_info + .upgraded_id + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("upgraded_id"))? + .try_into()?; + let upgraded_version = upgrade_info + .upgraded_version + .ok_or_else(|| TryFromProtoError::missing("upgraded_version"))?; + + Ok(( + original_id, + sui_sdk_types::types::UpgradeInfo { + upgraded_id, + upgraded_version, + }, + )) + }) + .collect::>()?; + + let version = value + .version + .ok_or_else(|| TryFromProtoError::missing("version"))?; + + Ok(Self { + id, + version, + modules, + type_origin_table, + linkage_table, + }) + } +} + +// +// TypeOrigin +// + +impl From for super::TypeOrigin { + fn from(value: sui_sdk_types::types::TypeOrigin) -> Self { + Self { + module_name: Some(value.module_name.into()), + struct_name: Some(value.struct_name.into()), + package_id: Some(value.package.into()), + } + } +} + +impl TryFrom<&super::TypeOrigin> for sui_sdk_types::types::TypeOrigin { + type Error = TryFromProtoError; + + fn try_from(value: &super::TypeOrigin) -> Result { + let module_name = value + .module_name + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("module_name"))? + .try_into()?; + + let struct_name = value + .struct_name + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("struct_name"))? + .try_into()?; + + let package = value + .package_id + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("package_id"))? + .try_into()?; + + Ok(Self { + module_name, + struct_name, + package, + }) + } +} + +// +// GenesisObject +// + +impl From for super::GenesisObject { + fn from(value: sui_sdk_types::types::GenesisObject) -> Self { + Self { + object_id: Some(value.object_id().into()), + version: Some(value.version()), + owner: Some(value.owner().to_owned().into()), + object: Some(value.data().to_owned().into()), + } + } +} + +impl TryFrom<&super::GenesisObject> for sui_sdk_types::types::GenesisObject { + type Error = TryFromProtoError; + + fn try_from(value: &super::GenesisObject) -> Result { + let object_data = value + .object + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("object_data"))? + .try_into()?; + + let owner = value + .owner + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("owner"))? + .try_into()?; + + Ok(Self::new(object_data, owner)) + } +} diff --git a/crates/sui-rpc-api/src/proto/types/signatures.rs b/crates/sui-rpc-api/src/proto/types/signatures.rs new file mode 100644 index 0000000000000..faaa3f3175e72 --- /dev/null +++ b/crates/sui-rpc-api/src/proto/types/signatures.rs @@ -0,0 +1,883 @@ +use super::TryFromProtoError; +use bytes::{BufMut, BytesMut}; +use tap::Pipe; + +// +// ValidatorAggregatedSignature +// + +impl From + for super::ValidatorAggregatedSignature +{ + fn from(value: sui_sdk_types::types::ValidatorAggregatedSignature) -> Self { + Self { + epoch: Some(value.epoch), + signature: Some(value.signature.as_bytes().to_vec().into()), + bitmap: Some(value.bitmap.into()), + } + } +} + +impl TryFrom<&super::ValidatorAggregatedSignature> + for sui_sdk_types::types::ValidatorAggregatedSignature +{ + type Error = TryFromProtoError; + + fn try_from(value: &super::ValidatorAggregatedSignature) -> Result { + let epoch = value + .epoch + .ok_or_else(|| TryFromProtoError::missing("epoch"))?; + let signature = value + .signature + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("signature"))? + .as_ref() + .pipe(sui_sdk_types::types::Bls12381Signature::from_bytes) + .map_err(TryFromProtoError::from_error)?; + let bitmap = value + .bitmap + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("bitmap"))? + .try_into()?; + + Ok(Self { + epoch, + signature, + bitmap, + }) + } +} + +// +// RoaringBitmap +// + +impl From for super::RoaringBitmap { + fn from(value: roaring::RoaringBitmap) -> Self { + Self::from(&value) + } +} + +impl From<&roaring::RoaringBitmap> for super::RoaringBitmap { + fn from(value: &roaring::RoaringBitmap) -> Self { + let mut buf = BytesMut::new().writer(); + value + .serialize_into(&mut buf) + .expect("writing to BytesMut can't fail"); + Self { + bitmap: Some(buf.into_inner().freeze()), + } + } +} + +impl TryFrom<&super::RoaringBitmap> for roaring::RoaringBitmap { + type Error = TryFromProtoError; + + fn try_from(value: &super::RoaringBitmap) -> Result { + value + .bitmap + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("bitmap"))? + .as_ref() + .pipe(roaring::RoaringBitmap::deserialize_from) + .map_err(TryFromProtoError::from_error) + } +} + +// +// ValidatorCommitteeMember +// + +impl From for super::ValidatorCommitteeMember { + fn from(value: sui_sdk_types::types::ValidatorCommitteeMember) -> Self { + Self { + public_key: Some(value.public_key.as_bytes().to_vec().into()), + stake: Some(value.stake), + } + } +} + +impl TryFrom<&super::ValidatorCommitteeMember> for sui_sdk_types::types::ValidatorCommitteeMember { + type Error = TryFromProtoError; + + fn try_from( + super::ValidatorCommitteeMember { public_key, stake }: &super::ValidatorCommitteeMember, + ) -> Result { + let public_key = public_key + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("public_key"))? + .as_ref() + .pipe(sui_sdk_types::types::Bls12381PublicKey::from_bytes) + .map_err(TryFromProtoError::from_error)?; + let stake = stake.ok_or_else(|| TryFromProtoError::missing("stake"))?; + Ok(Self { public_key, stake }) + } +} + +// +// ValidatorCommittee +// + +impl From for super::ValidatorCommittee { + fn from(value: sui_sdk_types::types::ValidatorCommittee) -> Self { + Self { + epoch: Some(value.epoch), + members: value.members.into_iter().map(Into::into).collect(), + } + } +} + +impl TryFrom<&super::ValidatorCommittee> for sui_sdk_types::types::ValidatorCommittee { + type Error = TryFromProtoError; + + fn try_from(value: &super::ValidatorCommittee) -> Result { + let epoch = value + .epoch + .ok_or_else(|| TryFromProtoError::missing("epoch"))?; + Ok(Self { + epoch, + members: value + .members + .iter() + .map(TryInto::try_into) + .collect::>()?, + }) + } +} + +// +// Bn254FieldElement +// + +impl From for super::Bn254FieldElement { + fn from(value: sui_sdk_types::types::Bn254FieldElement) -> Self { + Self { + element: Some(value.padded().to_vec().into()), + } + } +} + +impl TryFrom<&super::Bn254FieldElement> for sui_sdk_types::types::Bn254FieldElement { + type Error = TryFromProtoError; + + fn try_from(value: &super::Bn254FieldElement) -> Result { + Ok(Self::new( + value + .element + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("element"))? + .as_ref() + .try_into() + .map_err(TryFromProtoError::from_error)?, + )) + } +} + +// +// CircomG1 +// + +impl From for super::CircomG1 { + fn from(value: sui_sdk_types::types::CircomG1) -> Self { + let [e0, e1, e2] = value.0; + + Self { + e0: Some(e0.into()), + e1: Some(e1.into()), + e2: Some(e2.into()), + } + } +} + +impl TryFrom<&super::CircomG1> for sui_sdk_types::types::CircomG1 { + type Error = TryFromProtoError; + + fn try_from(value: &super::CircomG1) -> Result { + let e0 = value + .e0 + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("e0"))? + .try_into()?; + let e1 = value + .e1 + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("e1"))? + .try_into()?; + let e2 = value + .e2 + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("e2"))? + .try_into()?; + + Ok(Self([e0, e1, e2])) + } +} + +// +// CircomG2 +// + +impl From for super::CircomG2 { + fn from(value: sui_sdk_types::types::CircomG2) -> Self { + let [[e00, e01], [e10, e11], [e20, e21]] = value.0; + + Self { + e00: Some(e00.into()), + e01: Some(e01.into()), + e10: Some(e10.into()), + e11: Some(e11.into()), + e20: Some(e20.into()), + e21: Some(e21.into()), + } + } +} + +impl TryFrom<&super::CircomG2> for sui_sdk_types::types::CircomG2 { + type Error = TryFromProtoError; + + fn try_from(value: &super::CircomG2) -> Result { + let e00 = value + .e00 + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("e00"))? + .try_into()?; + let e01 = value + .e01 + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("e01"))? + .try_into()?; + + let e10 = value + .e10 + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("e10"))? + .try_into()?; + let e11 = value + .e11 + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("e11"))? + .try_into()?; + + let e20 = value + .e20 + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("e20"))? + .try_into()?; + let e21 = value + .e21 + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("e21"))? + .try_into()?; + + Ok(Self([[e00, e01], [e10, e11], [e20, e21]])) + } +} + +// +// ZkLoginClaim +// + +impl From for super::ZkLoginClaim { + fn from(value: sui_sdk_types::types::Claim) -> Self { + Self { + value: Some(value.value.into_bytes().into()), + index_mod_4: Some(value.index_mod_4.into()), + } + } +} + +impl TryFrom<&super::ZkLoginClaim> for sui_sdk_types::types::Claim { + type Error = TryFromProtoError; + + fn try_from( + super::ZkLoginClaim { value, index_mod_4 }: &super::ZkLoginClaim, + ) -> Result { + let value = value + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("value"))? + .as_ref() + .pipe(std::str::from_utf8)? + .into(); + let index_mod_4 = index_mod_4 + .ok_or_else(|| TryFromProtoError::missing("index_mod_4"))? + .try_into()?; + + Ok(Self { value, index_mod_4 }) + } +} + +// +// ZkLoginProof +// + +impl From for super::ZkLoginProof { + fn from(value: sui_sdk_types::types::ZkLoginProof) -> Self { + Self { + a: Some(value.a.into()), + b: Some(value.b.into()), + c: Some(value.c.into()), + } + } +} + +impl TryFrom<&super::ZkLoginProof> for sui_sdk_types::types::ZkLoginProof { + type Error = TryFromProtoError; + + fn try_from(value: &super::ZkLoginProof) -> Result { + let a = value + .a + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("a"))? + .try_into()?; + let b = value + .b + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("b"))? + .try_into()?; + let c = value + .c + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("c"))? + .try_into()?; + + Ok(Self { a, b, c }) + } +} + +// +// ZkLoginInputs +// + +impl From for super::ZkLoginInputs { + fn from(value: sui_sdk_types::types::ZkLoginInputs) -> Self { + Self { + proof_points: Some(value.proof_points.into()), + iss_base64_details: Some(value.iss_base64_details.into()), + header_base64: Some(value.header_base64.into_bytes().into()), + address_seed: Some(value.address_seed.into()), + } + } +} + +impl TryFrom<&super::ZkLoginInputs> for sui_sdk_types::types::ZkLoginInputs { + type Error = TryFromProtoError; + + fn try_from(value: &super::ZkLoginInputs) -> Result { + let proof_points = value + .proof_points + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("proof_points"))? + .try_into()?; + let iss_base64_details = value + .iss_base64_details + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("iss_base64_details"))? + .try_into()?; + let header_base64 = value + .header_base64 + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("header_base64"))? + .as_ref() + .pipe(std::str::from_utf8)? + .into(); + let address_seed = value + .address_seed + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("address_seed"))? + .try_into()?; + + Ok(Self { + proof_points, + iss_base64_details, + header_base64, + address_seed, + }) + } +} + +// +// ZkLoginAuthenticator +// + +impl From for super::ZkLoginAuthenticator { + fn from(value: sui_sdk_types::types::ZkLoginAuthenticator) -> Self { + Self { + inputs: Some(value.inputs.into()), + max_epoch: Some(value.max_epoch), + signature: Some(value.signature.into()), + } + } +} + +impl TryFrom<&super::ZkLoginAuthenticator> for sui_sdk_types::types::ZkLoginAuthenticator { + type Error = TryFromProtoError; + + fn try_from(value: &super::ZkLoginAuthenticator) -> Result { + let inputs = value + .inputs + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("inputs"))? + .try_into()?; + let max_epoch = value + .max_epoch + .ok_or_else(|| TryFromProtoError::missing("max_epoch"))?; + let signature = value + .signature + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("signature"))? + .try_into()?; + + Ok(Self { + inputs, + max_epoch, + signature, + }) + } +} + +// +// ZkLoginPublicIdentifier +// + +impl From<&sui_sdk_types::types::ZkLoginPublicIdentifier> for super::ZkLoginPublicIdentifier { + fn from(value: &sui_sdk_types::types::ZkLoginPublicIdentifier) -> Self { + Self { + iss: Some(value.iss().to_owned().into_bytes().into()), + address_seed: Some(value.address_seed().to_owned().into()), + } + } +} + +impl TryFrom<&super::ZkLoginPublicIdentifier> for sui_sdk_types::types::ZkLoginPublicIdentifier { + type Error = TryFromProtoError; + + fn try_from(value: &super::ZkLoginPublicIdentifier) -> Result { + let iss = value + .iss + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("iss"))? + .as_ref() + .pipe(std::str::from_utf8)? + .into(); + let address_seed = value + .address_seed + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("address_seed"))? + .try_into()?; + + Self::new(iss, address_seed) + .ok_or_else(|| TryFromProtoError::from_error("invalid iss"))? + .pipe(Ok) + } +} + +// +// SignatureScheme +// + +impl From for super::SignatureScheme { + fn from(value: sui_sdk_types::types::SignatureScheme) -> Self { + use sui_sdk_types::types::SignatureScheme::*; + + match value { + Ed25519 => Self::Ed25519, + Secp256k1 => Self::Secp256k1, + Secp256r1 => Self::Secp256r1, + Multisig => Self::Multisig, + Bls12381 => Self::Bls12381, + ZkLogin => Self::Zklogin, + Passkey => Self::Passkey, + } + } +} + +impl TryFrom<&super::SignatureScheme> for sui_sdk_types::types::SignatureScheme { + type Error = TryFromProtoError; + + fn try_from(value: &super::SignatureScheme) -> Result { + use super::SignatureScheme::*; + + match value { + Unknown => { + return Err(TryFromProtoError::missing( + "unknown SignatureScheme variant", + )) + } + Ed25519 => Self::Ed25519, + Secp256k1 => Self::Secp256k1, + Secp256r1 => Self::Secp256r1, + Multisig => Self::Multisig, + Bls12381 => Self::Bls12381, + Zklogin => Self::ZkLogin, + Passkey => Self::Passkey, + } + .pipe(Ok) + } +} + +// +// SimpleSignature +// + +impl From for super::SimpleSignature { + fn from(value: sui_sdk_types::types::SimpleSignature) -> Self { + let scheme: super::SignatureScheme = value.scheme().into(); + let (signature, public_key) = match &value { + sui_sdk_types::types::SimpleSignature::Ed25519 { + signature, + public_key, + } => (signature.as_bytes(), public_key.as_bytes()), + sui_sdk_types::types::SimpleSignature::Secp256k1 { + signature, + public_key, + } => (signature.as_bytes(), public_key.as_bytes()), + sui_sdk_types::types::SimpleSignature::Secp256r1 { + signature, + public_key, + } => (signature.as_bytes(), public_key.as_bytes()), + }; + + Self { + scheme: Some(scheme.into()), + signature: Some(signature.to_vec().into()), + public_key: Some(public_key.to_vec().into()), + } + } +} + +impl TryFrom<&super::SimpleSignature> for sui_sdk_types::types::SimpleSignature { + type Error = TryFromProtoError; + + fn try_from(value: &super::SimpleSignature) -> Result { + use super::SignatureScheme::*; + use sui_sdk_types::types::{Ed25519PublicKey, Ed25519Signature}; + use sui_sdk_types::types::{ + Secp256k1PublicKey, Secp256k1Signature, Secp256r1PublicKey, Secp256r1Signature, + }; + + let signature = value + .signature + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("signature"))?; + let public_key = value + .public_key + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("public_key"))?; + + match value.scheme() { + Ed25519 => Self::Ed25519 { + signature: Ed25519Signature::from_bytes(signature)?, + public_key: Ed25519PublicKey::from_bytes(public_key)?, + }, + Secp256k1 => Self::Secp256k1 { + signature: Secp256k1Signature::from_bytes(signature)?, + public_key: Secp256k1PublicKey::from_bytes(public_key)?, + }, + Secp256r1 => Self::Secp256r1 { + signature: Secp256r1Signature::from_bytes(signature)?, + public_key: Secp256r1PublicKey::from_bytes(public_key)?, + }, + Unknown | Multisig | Bls12381 | Zklogin | Passkey => { + return Err(TryFromProtoError::from_error( + "invalid or unknown signature scheme", + )) + } + } + .pipe(Ok) + } +} + +// +// PasskeyAuthenticator +// + +impl From for super::PasskeyAuthenticator { + fn from(value: sui_sdk_types::types::PasskeyAuthenticator) -> Self { + Self { + authenticator_data: Some(value.authenticator_data().to_vec().into()), + client_data_json: Some(value.client_data_json().as_bytes().to_vec().into()), + signature: Some(value.signature().into()), + } + } +} + +impl TryFrom<&super::PasskeyAuthenticator> for sui_sdk_types::types::PasskeyAuthenticator { + type Error = TryFromProtoError; + + fn try_from(value: &super::PasskeyAuthenticator) -> Result { + let authenticator_data = value + .authenticator_data + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("authenticator_data"))? + .to_vec(); + let client_data_json = value + .client_data_json + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("client_data_json"))? + .as_ref() + .pipe(std::str::from_utf8)? + .into(); + + let signature = value + .signature + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("signature"))? + .try_into()?; + + Self::new(authenticator_data, client_data_json, signature) + .ok_or_else(|| TryFromProtoError::from_error("invalid passkey")) + } +} + +// +// MultisigMemberPublicKey +// + +impl From<&sui_sdk_types::types::MultisigMemberPublicKey> for super::MultisigMemberPublicKey { + fn from(value: &sui_sdk_types::types::MultisigMemberPublicKey) -> Self { + use super::multisig_member_public_key::Scheme; + use sui_sdk_types::types::MultisigMemberPublicKey::*; + + let scheme = match value { + Ed25519(public_key) => Scheme::Ed25519(public_key.as_bytes().to_vec().into()), + Secp256k1(public_key) => Scheme::Secp256k1(public_key.as_bytes().to_vec().into()), + Secp256r1(public_key) => Scheme::Secp256r1(public_key.as_bytes().to_vec().into()), + ZkLogin(zklogin_id) => Scheme::Zklogin(zklogin_id.into()), + }; + + Self { + scheme: Some(scheme), + } + } +} + +impl TryFrom<&super::MultisigMemberPublicKey> for sui_sdk_types::types::MultisigMemberPublicKey { + type Error = TryFromProtoError; + + fn try_from(value: &super::MultisigMemberPublicKey) -> Result { + use super::multisig_member_public_key::Scheme; + use sui_sdk_types::types::{Ed25519PublicKey, Secp256k1PublicKey, Secp256r1PublicKey}; + + match value + .scheme + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("scheme"))? + { + Scheme::Ed25519(public_key) => Self::Ed25519(Ed25519PublicKey::from_bytes(public_key)?), + Scheme::Secp256k1(public_key) => { + Self::Secp256k1(Secp256k1PublicKey::from_bytes(public_key)?) + } + Scheme::Secp256r1(public_key) => { + Self::Secp256r1(Secp256r1PublicKey::from_bytes(public_key)?) + } + Scheme::Zklogin(zklogin_id) => Self::ZkLogin(zklogin_id.try_into()?), + } + .pipe(Ok) + } +} + +// +// MultisigMember +// + +impl From<&sui_sdk_types::types::MultisigMember> for super::MultisigMember { + fn from(value: &sui_sdk_types::types::MultisigMember) -> Self { + Self { + public_key: Some(value.public_key().into()), + weight: Some(value.weight().into()), + } + } +} + +impl TryFrom<&super::MultisigMember> for sui_sdk_types::types::MultisigMember { + type Error = TryFromProtoError; + + fn try_from(value: &super::MultisigMember) -> Result { + let public_key = value + .public_key + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("public_key"))? + .try_into()?; + let weight = value + .weight + .ok_or_else(|| TryFromProtoError::missing("weight"))? + .try_into()?; + + Ok(Self::new(public_key, weight)) + } +} + +// +// MultisigCommittee +// + +impl From<&sui_sdk_types::types::MultisigCommittee> for super::MultisigCommittee { + fn from(value: &sui_sdk_types::types::MultisigCommittee) -> Self { + Self { + members: value.members().iter().map(Into::into).collect(), + threshold: Some(value.threshold().into()), + } + } +} + +impl TryFrom<&super::MultisigCommittee> for sui_sdk_types::types::MultisigCommittee { + type Error = TryFromProtoError; + + fn try_from(value: &super::MultisigCommittee) -> Result { + let members = value + .members + .iter() + .map(TryInto::try_into) + .collect::>()?; + let threshold = value + .threshold + .ok_or_else(|| TryFromProtoError::missing("threshold"))? + .try_into()?; + + Ok(Self::new(members, threshold)) + } +} + +// +// MultisigMemberSignature +// + +impl From<&sui_sdk_types::types::MultisigMemberSignature> for super::MultisigMemberSignature { + fn from(value: &sui_sdk_types::types::MultisigMemberSignature) -> Self { + use super::multisig_member_signature::Signature; + use sui_sdk_types::types::MultisigMemberSignature::*; + + let signature = match value { + Ed25519(signautre) => Signature::Ed25519(signautre.as_bytes().to_vec().into()), + Secp256k1(signautre) => Signature::Secp256k1(signautre.as_bytes().to_vec().into()), + Secp256r1(signautre) => Signature::Secp256r1(signautre.as_bytes().to_vec().into()), + ZkLogin(zklogin_id) => Signature::Zklogin((**zklogin_id).clone().into()), + }; + + Self { + signature: Some(signature), + } + } +} + +impl TryFrom<&super::MultisigMemberSignature> for sui_sdk_types::types::MultisigMemberSignature { + type Error = TryFromProtoError; + + fn try_from(value: &super::MultisigMemberSignature) -> Result { + use super::multisig_member_signature::Signature; + use sui_sdk_types::types::{Ed25519Signature, Secp256k1Signature, Secp256r1Signature}; + + match value + .signature + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("signature"))? + { + Signature::Ed25519(signautre) => { + Self::Ed25519(Ed25519Signature::from_bytes(signautre)?) + } + Signature::Secp256k1(signautre) => { + Self::Secp256k1(Secp256k1Signature::from_bytes(signautre)?) + } + Signature::Secp256r1(signautre) => { + Self::Secp256r1(Secp256r1Signature::from_bytes(signautre)?) + } + Signature::Zklogin(zklogin_id) => Self::ZkLogin(Box::new(zklogin_id.try_into()?)), + } + .pipe(Ok) + } +} + +// +// MultisigAggregatedSignature +// + +impl From<&sui_sdk_types::types::MultisigAggregatedSignature> + for super::MultisigAggregatedSignature +{ + fn from(value: &sui_sdk_types::types::MultisigAggregatedSignature) -> Self { + Self { + signatures: value.signatures().iter().map(Into::into).collect(), + bitmap: Some(value.bitmap().into()), + legacy_bitmap: value.legacy_bitmap().map(Into::into), + committee: Some(value.committee().into()), + } + } +} + +impl TryFrom<&super::MultisigAggregatedSignature> + for sui_sdk_types::types::MultisigAggregatedSignature +{ + type Error = TryFromProtoError; + + fn try_from(value: &super::MultisigAggregatedSignature) -> Result { + let signatures = value + .signatures + .iter() + .map(TryInto::try_into) + .collect::>()?; + let bitmap = value + .bitmap + .ok_or_else(|| TryFromProtoError::missing("bitmap"))? + .try_into()?; + let legacy_bitmap = value + .legacy_bitmap + .as_ref() + .map(TryInto::try_into) + .transpose()?; + let committee = value + .committee + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("committee"))? + .try_into()?; + + let mut signature = Self::new(committee, signatures, bitmap); + + if let Some(legacy_bitmap) = legacy_bitmap { + signature.with_legacy_bitmap(legacy_bitmap); + } + + Ok(signature) + } +} + +// +// UserSignature +// + +impl From for super::UserSignature { + fn from(value: sui_sdk_types::types::UserSignature) -> Self { + use super::user_signature::Signature; + use sui_sdk_types::types::UserSignature::*; + + let signature = match value { + Simple(simple) => Signature::Simple(simple.into()), + Multisig(ref multisig) => Signature::Multisig(multisig.into()), + ZkLogin(zklogin) => Signature::Zklogin((*zklogin).into()), + Passkey(passkey) => Signature::Passkey(passkey.into()), + }; + + Self { + signature: Some(signature), + } + } +} + +impl TryFrom<&super::UserSignature> for sui_sdk_types::types::UserSignature { + type Error = TryFromProtoError; + + fn try_from(value: &super::UserSignature) -> Result { + use super::user_signature::Signature; + + match value + .signature + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("signature"))? + { + Signature::Simple(simple) => Self::Simple(simple.try_into()?), + Signature::Multisig(multisig) => Self::Multisig(multisig.try_into()?), + Signature::Zklogin(zklogin) => Self::ZkLogin(Box::new(zklogin.try_into()?)), + Signature::Passkey(passkey) => Self::Passkey(passkey.try_into()?), + } + .pipe(Ok) + } +} diff --git a/crates/sui-rpc-api/src/proto/types/transaction_convert.rs b/crates/sui-rpc-api/src/proto/types/transaction_convert.rs new file mode 100644 index 0000000000000..8e75493060744 --- /dev/null +++ b/crates/sui-rpc-api/src/proto/types/transaction_convert.rs @@ -0,0 +1,1388 @@ +use super::TryFromProtoError; +use tap::Pipe; + +// +// Transaction +// + +impl From for super::Transaction { + fn from(value: sui_sdk_types::types::Transaction) -> Self { + let version = super::transaction::Version::V1(value.into()); + + Self { + version: Some(version), + } + } +} + +impl TryFrom<&super::Transaction> for sui_sdk_types::types::Transaction { + type Error = TryFromProtoError; + + fn try_from(value: &super::Transaction) -> Result { + match value + .version + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("version"))? + { + super::transaction::Version::V1(v1) => Self::try_from(v1)?, + } + .pipe(Ok) + } +} + +// +// TransactionV1 +// + +impl From for super::transaction::TransactionV1 { + fn from(value: sui_sdk_types::types::Transaction) -> Self { + Self { + kind: Some(value.kind.into()), + sender: Some(value.sender.into()), + gas_payment: Some(value.gas_payment.into()), + expiration: Some(value.expiration.into()), + } + } +} + +impl TryFrom<&super::transaction::TransactionV1> for sui_sdk_types::types::Transaction { + type Error = TryFromProtoError; + + fn try_from(value: &super::transaction::TransactionV1) -> Result { + let kind = value + .kind + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("kind"))? + .try_into()?; + + let sender = value + .sender + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("sender"))? + .try_into()?; + + let gas_payment = value + .gas_payment + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("gas_payment"))? + .try_into()?; + + let expiration = value + .expiration + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("expiration"))? + .try_into()?; + + Ok(Self { + kind, + sender, + gas_payment, + expiration, + }) + } +} + +// +// GasPayment +// + +impl From for super::GasPayment { + fn from(value: sui_sdk_types::types::GasPayment) -> Self { + Self { + objects: value.objects.into_iter().map(Into::into).collect(), + owner: Some(value.owner.into()), + price: Some(value.price), + budget: Some(value.budget), + } + } +} + +impl TryFrom<&super::GasPayment> for sui_sdk_types::types::GasPayment { + type Error = TryFromProtoError; + + fn try_from(value: &super::GasPayment) -> Result { + let objects = value + .objects + .iter() + .map(TryInto::try_into) + .collect::>()?; + + let owner = value + .owner + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("owner"))? + .try_into()?; + let price = value + .price + .ok_or_else(|| TryFromProtoError::missing("price"))?; + let budget = value + .budget + .ok_or_else(|| TryFromProtoError::missing("budget"))?; + Ok(Self { + objects, + owner, + price, + budget, + }) + } +} + +// +// TransactionExpiration +// + +impl From for super::TransactionExpiration { + fn from(value: sui_sdk_types::types::TransactionExpiration) -> Self { + use super::transaction_expiration::Expiration; + use sui_sdk_types::types::TransactionExpiration::*; + + let expiration = match value { + None => Expiration::None(()), + Epoch(epoch) => Expiration::Epoch(epoch), + }; + + Self { + expiration: Some(expiration), + } + } +} + +impl TryFrom<&super::TransactionExpiration> for sui_sdk_types::types::TransactionExpiration { + type Error = TryFromProtoError; + + fn try_from(value: &super::TransactionExpiration) -> Result { + use super::transaction_expiration::Expiration; + + match value + .expiration + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("expiration"))? + { + Expiration::None(()) => Self::None, + Expiration::Epoch(epoch) => Self::Epoch(*epoch), + } + .pipe(Ok) + } +} + +// +// TransactionKind +// + +impl From for super::TransactionKind { + fn from(value: sui_sdk_types::types::TransactionKind) -> Self { + use super::transaction_kind::Kind; + use sui_sdk_types::types::TransactionKind::*; + + let kind = match value { + ProgrammableTransaction(ptb) => Kind::ProgrammableTransaction(ptb.into()), + ChangeEpoch(change_epoch) => Kind::ChangeEpoch(change_epoch.into()), + Genesis(genesis) => Kind::Genesis(genesis.into()), + ConsensusCommitPrologue(prologue) => Kind::ConsensusCommitPrologueV1(prologue.into()), + AuthenticatorStateUpdate(update) => Kind::AuthenticatorStateUpdate(update.into()), + EndOfEpoch(transactions) => Kind::EndOfEpoch(super::EndOfEpochTransaction { + transactions: transactions.into_iter().map(Into::into).collect(), + }), + RandomnessStateUpdate(update) => Kind::RandomnessStateUpdate(update.into()), + ConsensusCommitPrologueV2(prologue) => Kind::ConsensusCommitPrologueV2(prologue.into()), + ConsensusCommitPrologueV3(prologue) => Kind::ConsensusCommitPrologueV3(prologue.into()), + }; + + Self { kind: Some(kind) } + } +} + +impl TryFrom<&super::TransactionKind> for sui_sdk_types::types::TransactionKind { + type Error = TryFromProtoError; + + fn try_from(value: &super::TransactionKind) -> Result { + use super::transaction_kind::Kind; + + match value + .kind + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("kind"))? + { + Kind::ProgrammableTransaction(ptb) => Self::ProgrammableTransaction(ptb.try_into()?), + Kind::ChangeEpoch(change_epoch) => Self::ChangeEpoch(change_epoch.try_into()?), + Kind::Genesis(genesis) => Self::Genesis(genesis.try_into()?), + Kind::ConsensusCommitPrologueV1(prologue) => { + Self::ConsensusCommitPrologue(prologue.try_into()?) + } + Kind::AuthenticatorStateUpdate(update) => { + Self::AuthenticatorStateUpdate(update.try_into()?) + } + Kind::EndOfEpoch(super::EndOfEpochTransaction { transactions }) => Self::EndOfEpoch( + transactions + .iter() + .map(TryInto::try_into) + .collect::>()?, + ), + Kind::RandomnessStateUpdate(update) => Self::RandomnessStateUpdate(update.try_into()?), + Kind::ConsensusCommitPrologueV2(prologue) => { + Self::ConsensusCommitPrologueV2(prologue.try_into()?) + } + Kind::ConsensusCommitPrologueV3(prologue) => { + Self::ConsensusCommitPrologueV3(prologue.try_into()?) + } + } + .pipe(Ok) + } +} + +// +// ConsensusCommitPrologue +// + +impl From for super::ConsensusCommitPrologue { + fn from(value: sui_sdk_types::types::ConsensusCommitPrologue) -> Self { + Self { + epoch: Some(value.epoch), + round: Some(value.round), + commit_timestamp_ms: Some(value.commit_timestamp_ms), + consensus_commit_digest: None, + sub_dag_index: None, + consensus_determined_version_assignments: None, + } + } +} + +impl TryFrom<&super::ConsensusCommitPrologue> for sui_sdk_types::types::ConsensusCommitPrologue { + type Error = TryFromProtoError; + + fn try_from(value: &super::ConsensusCommitPrologue) -> Result { + let epoch = value + .epoch + .ok_or_else(|| TryFromProtoError::missing("epoch"))?; + let round = value + .round + .ok_or_else(|| TryFromProtoError::missing("round"))?; + let commit_timestamp_ms = value + .commit_timestamp_ms + .ok_or_else(|| TryFromProtoError::missing("commit_timestamp_ms"))?; + + Ok(Self { + epoch, + round, + commit_timestamp_ms, + }) + } +} + +impl From for super::ConsensusCommitPrologue { + fn from(value: sui_sdk_types::types::ConsensusCommitPrologueV2) -> Self { + Self { + epoch: Some(value.epoch), + round: Some(value.round), + commit_timestamp_ms: Some(value.commit_timestamp_ms), + consensus_commit_digest: Some(value.consensus_commit_digest.into()), + sub_dag_index: None, + consensus_determined_version_assignments: None, + } + } +} + +impl TryFrom<&super::ConsensusCommitPrologue> for sui_sdk_types::types::ConsensusCommitPrologueV2 { + type Error = TryFromProtoError; + + fn try_from(value: &super::ConsensusCommitPrologue) -> Result { + let epoch = value + .epoch + .ok_or_else(|| TryFromProtoError::missing("epoch"))?; + let round = value + .round + .ok_or_else(|| TryFromProtoError::missing("round"))?; + let commit_timestamp_ms = value + .commit_timestamp_ms + .ok_or_else(|| TryFromProtoError::missing("commit_timestamp_ms"))?; + + let consensus_commit_digest = value + .consensus_commit_digest + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("consensus_commit_digest"))? + .try_into()?; + + Ok(Self { + epoch, + round, + commit_timestamp_ms, + consensus_commit_digest, + }) + } +} + +impl From for super::ConsensusCommitPrologue { + fn from(value: sui_sdk_types::types::ConsensusCommitPrologueV3) -> Self { + Self { + epoch: Some(value.epoch), + round: Some(value.round), + commit_timestamp_ms: Some(value.commit_timestamp_ms), + consensus_commit_digest: Some(value.consensus_commit_digest.into()), + sub_dag_index: value.sub_dag_index, + consensus_determined_version_assignments: Some( + value.consensus_determined_version_assignments.into(), + ), + } + } +} + +impl TryFrom<&super::ConsensusCommitPrologue> for sui_sdk_types::types::ConsensusCommitPrologueV3 { + type Error = TryFromProtoError; + + fn try_from(value: &super::ConsensusCommitPrologue) -> Result { + let epoch = value + .epoch + .ok_or_else(|| TryFromProtoError::missing("epoch"))?; + let round = value + .round + .ok_or_else(|| TryFromProtoError::missing("round"))?; + let commit_timestamp_ms = value + .commit_timestamp_ms + .ok_or_else(|| TryFromProtoError::missing("commit_timestamp_ms"))?; + + let consensus_commit_digest = value + .consensus_commit_digest + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("consensus_commit_digest"))? + .try_into()?; + + let consensus_determined_version_assignments = value + .consensus_determined_version_assignments + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("consensus_determined_version_assignments"))? + .try_into()?; + + Ok(Self { + epoch, + round, + commit_timestamp_ms, + sub_dag_index: value.sub_dag_index, + consensus_commit_digest, + consensus_determined_version_assignments, + }) + } +} + +// +// ConsensusDeterminedVersionAssignments +// + +impl From + for super::ConsensusDeterminedVersionAssignments +{ + fn from(value: sui_sdk_types::types::ConsensusDeterminedVersionAssignments) -> Self { + use super::consensus_determined_version_assignments::Kind; + use sui_sdk_types::types::ConsensusDeterminedVersionAssignments::*; + + let kind = match value { + CancelledTransactions { + cancelled_transactions, + } => Kind::CancelledTransactions(super::CancelledTransactions { + cancelled_transactions: cancelled_transactions + .into_iter() + .map(Into::into) + .collect(), + }), + }; + + Self { kind: Some(kind) } + } +} + +impl TryFrom<&super::ConsensusDeterminedVersionAssignments> + for sui_sdk_types::types::ConsensusDeterminedVersionAssignments +{ + type Error = TryFromProtoError; + + fn try_from(value: &super::ConsensusDeterminedVersionAssignments) -> Result { + use super::consensus_determined_version_assignments::Kind; + + match value + .kind + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("kind"))? + { + Kind::CancelledTransactions(super::CancelledTransactions { + cancelled_transactions, + }) => Self::CancelledTransactions { + cancelled_transactions: cancelled_transactions + .iter() + .map(TryInto::try_into) + .collect::>()?, + }, + } + .pipe(Ok) + } +} + +// +// CancelledTransaction +// + +impl From for super::CancelledTransaction { + fn from(value: sui_sdk_types::types::CancelledTransaction) -> Self { + Self { + digest: Some(value.digest.into()), + version_assignments: value + .version_assignments + .into_iter() + .map(Into::into) + .collect(), + } + } +} + +impl TryFrom<&super::CancelledTransaction> for sui_sdk_types::types::CancelledTransaction { + type Error = TryFromProtoError; + + fn try_from(value: &super::CancelledTransaction) -> Result { + let digest = value + .digest + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("digest"))? + .try_into()?; + + let version_assignments = value + .version_assignments + .iter() + .map(TryInto::try_into) + .collect::>()?; + + Ok(Self { + digest, + version_assignments, + }) + } +} + +// +// VersionAssignment +// + +impl From for super::VersionAssignment { + fn from(value: sui_sdk_types::types::VersionAssignment) -> Self { + Self { + object_id: Some(value.object_id.into()), + version: Some(value.version), + } + } +} + +impl TryFrom<&super::VersionAssignment> for sui_sdk_types::types::VersionAssignment { + type Error = TryFromProtoError; + + fn try_from(value: &super::VersionAssignment) -> Result { + let object_id = value + .object_id + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("object_id"))? + .try_into()?; + let version = value + .version + .ok_or_else(|| TryFromProtoError::missing("version"))?; + + Ok(Self { object_id, version }) + } +} + +// +// GenesisTransaction +// + +impl From for super::GenesisTransaction { + fn from(value: sui_sdk_types::types::GenesisTransaction) -> Self { + Self { + objects: value.objects.into_iter().map(Into::into).collect(), + } + } +} + +impl TryFrom<&super::GenesisTransaction> for sui_sdk_types::types::GenesisTransaction { + type Error = TryFromProtoError; + + fn try_from(value: &super::GenesisTransaction) -> Result { + let objects = value + .objects + .iter() + .map(TryInto::try_into) + .collect::>()?; + + Ok(Self { objects }) + } +} + +// +// RandomnessStateUpdate +// + +impl From for super::RandomnessStateUpdate { + fn from(value: sui_sdk_types::types::RandomnessStateUpdate) -> Self { + Self { + epoch: Some(value.epoch), + randomness_round: Some(value.randomness_round), + random_bytes: Some(value.random_bytes.into()), + randomness_object_initial_shared_version: Some( + value.randomness_obj_initial_shared_version, + ), + } + } +} + +impl TryFrom<&super::RandomnessStateUpdate> for sui_sdk_types::types::RandomnessStateUpdate { + type Error = TryFromProtoError; + + fn try_from( + super::RandomnessStateUpdate { + epoch, + randomness_round, + random_bytes, + randomness_object_initial_shared_version, + }: &super::RandomnessStateUpdate, + ) -> Result { + let epoch = epoch.ok_or_else(|| TryFromProtoError::missing("epoch"))?; + let randomness_round = + randomness_round.ok_or_else(|| TryFromProtoError::missing("randomness_round"))?; + let random_bytes = random_bytes + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("random_bytes"))? + .to_vec(); + let randomness_obj_initial_shared_version = randomness_object_initial_shared_version + .ok_or_else(|| { + TryFromProtoError::missing("randomness_object_initial_shared_version") + })?; + Ok(Self { + epoch, + randomness_round, + random_bytes, + randomness_obj_initial_shared_version, + }) + } +} + +// +// AuthenticatorStateUpdate +// + +impl From for super::AuthenticatorStateUpdate { + fn from(value: sui_sdk_types::types::AuthenticatorStateUpdate) -> Self { + Self { + epoch: Some(value.epoch), + round: Some(value.round), + new_active_jwks: value.new_active_jwks.into_iter().map(Into::into).collect(), + authenticator_object_initial_shared_version: Some( + value.authenticator_obj_initial_shared_version, + ), + } + } +} + +impl TryFrom<&super::AuthenticatorStateUpdate> for sui_sdk_types::types::AuthenticatorStateUpdate { + type Error = TryFromProtoError; + + fn try_from( + super::AuthenticatorStateUpdate { + epoch, + round, + new_active_jwks, + authenticator_object_initial_shared_version, + }: &super::AuthenticatorStateUpdate, + ) -> Result { + let epoch = epoch.ok_or_else(|| TryFromProtoError::missing("epoch"))?; + let round = round.ok_or_else(|| TryFromProtoError::missing("round"))?; + let authenticator_obj_initial_shared_version = authenticator_object_initial_shared_version + .ok_or_else(|| { + TryFromProtoError::missing("authenticator_object_initial_shared_version") + })?; + Ok(Self { + epoch, + round, + new_active_jwks: new_active_jwks + .iter() + .map(TryInto::try_into) + .collect::>()?, + authenticator_obj_initial_shared_version, + }) + } +} + +// +// Jwk +// + +impl From for super::Jwk { + fn from(value: sui_sdk_types::types::Jwk) -> Self { + Self { + kty: Some(value.kty.into_bytes().into()), + e: Some(value.e.into_bytes().into()), + n: Some(value.n.into_bytes().into()), + alg: Some(value.alg.into_bytes().into()), + } + } +} + +impl TryFrom<&super::Jwk> for sui_sdk_types::types::Jwk { + type Error = TryFromProtoError; + + fn try_from(super::Jwk { kty, e, n, alg }: &super::Jwk) -> Result { + let kty = kty + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("kty"))? + .as_ref() + .pipe(std::str::from_utf8)? + .into(); + let e = e + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("e"))? + .as_ref() + .pipe(std::str::from_utf8)? + .into(); + let n = n + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("n"))? + .as_ref() + .pipe(std::str::from_utf8)? + .into(); + let alg = alg + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("alg"))? + .as_ref() + .pipe(std::str::from_utf8)? + .into(); + Ok(Self { kty, e, n, alg }) + } +} + +// +// JwkId +// + +impl From for super::JwkId { + fn from(value: sui_sdk_types::types::JwkId) -> Self { + Self { + iss: Some(value.iss.into_bytes().into()), + kid: Some(value.kid.into_bytes().into()), + } + } +} + +impl TryFrom<&super::JwkId> for sui_sdk_types::types::JwkId { + type Error = TryFromProtoError; + + fn try_from(super::JwkId { iss, kid }: &super::JwkId) -> Result { + let iss = iss + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("iss"))? + .as_ref() + .pipe(std::str::from_utf8)? + .into(); + let kid = kid + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("kid"))? + .as_ref() + .pipe(std::str::from_utf8)? + .into(); + Ok(Self { iss, kid }) + } +} + +// +// ActiveJwk +// + +impl From for super::ActiveJwk { + fn from(value: sui_sdk_types::types::ActiveJwk) -> Self { + Self { + id: Some(value.jwk_id.into()), + jwk: Some(value.jwk.into()), + epoch: Some(value.epoch), + } + } +} + +impl TryFrom<&super::ActiveJwk> for sui_sdk_types::types::ActiveJwk { + type Error = TryFromProtoError; + + fn try_from(value: &super::ActiveJwk) -> Result { + let jwk_id = value + .id + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("id"))? + .try_into()?; + + let jwk = value + .jwk + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("jwk"))? + .try_into()?; + + let epoch = value + .epoch + .ok_or_else(|| TryFromProtoError::missing("epoch"))?; + + Ok(Self { jwk_id, jwk, epoch }) + } +} + +// +// ChangeEpoch +// + +impl From for super::ChangeEpoch { + fn from(value: sui_sdk_types::types::ChangeEpoch) -> Self { + Self { + epoch: Some(value.epoch), + protocol_version: Some(value.protocol_version), + storage_charge: Some(value.storage_charge), + computation_charge: Some(value.computation_charge), + storage_rebate: Some(value.storage_rebate), + non_refundable_storage_fee: Some(value.non_refundable_storage_fee), + epoch_start_timestamp_ms: Some(value.epoch_start_timestamp_ms), + system_packages: value.system_packages.into_iter().map(Into::into).collect(), + } + } +} + +impl TryFrom<&super::ChangeEpoch> for sui_sdk_types::types::ChangeEpoch { + type Error = TryFromProtoError; + + fn try_from( + super::ChangeEpoch { + epoch, + protocol_version, + storage_charge, + computation_charge, + storage_rebate, + non_refundable_storage_fee, + epoch_start_timestamp_ms, + system_packages, + }: &super::ChangeEpoch, + ) -> Result { + let epoch = epoch.ok_or_else(|| TryFromProtoError::missing("epoch"))?; + let protocol_version = + protocol_version.ok_or_else(|| TryFromProtoError::missing("protocol_version"))?; + let storage_charge = + storage_charge.ok_or_else(|| TryFromProtoError::missing("storage_charge"))?; + let computation_charge = + computation_charge.ok_or_else(|| TryFromProtoError::missing("computation_charge"))?; + let storage_rebate = + storage_rebate.ok_or_else(|| TryFromProtoError::missing("storage_rebate"))?; + let non_refundable_storage_fee = non_refundable_storage_fee + .ok_or_else(|| TryFromProtoError::missing("non_refundable_storage_fee"))?; + let epoch_start_timestamp_ms = epoch_start_timestamp_ms + .ok_or_else(|| TryFromProtoError::missing("epoch_start_timestamp_ms"))?; + + Ok(Self { + epoch, + protocol_version, + storage_charge, + computation_charge, + storage_rebate, + non_refundable_storage_fee, + epoch_start_timestamp_ms, + system_packages: system_packages + .iter() + .map(TryInto::try_into) + .collect::>()?, + }) + } +} + +// +// SystemPackage +// + +impl From for super::SystemPackage { + fn from(value: sui_sdk_types::types::SystemPackage) -> Self { + Self { + version: Some(value.version), + modules: value.modules.into_iter().map(Into::into).collect(), + dependencies: value.dependencies.into_iter().map(Into::into).collect(), + } + } +} + +impl TryFrom<&super::SystemPackage> for sui_sdk_types::types::SystemPackage { + type Error = TryFromProtoError; + + fn try_from(value: &super::SystemPackage) -> Result { + Ok(Self { + version: value + .version + .ok_or_else(|| TryFromProtoError::missing("version"))?, + modules: value.modules.iter().map(|bytes| bytes.to_vec()).collect(), + dependencies: value + .dependencies + .iter() + .map(TryInto::try_into) + .collect::>()?, + }) + } +} + +// +// EndOfEpochTransactionkind +// + +impl From for super::EndOfEpochTransactionKind { + fn from(value: sui_sdk_types::types::EndOfEpochTransactionKind) -> Self { + use super::end_of_epoch_transaction_kind::Kind; + use sui_sdk_types::types::EndOfEpochTransactionKind::*; + + let kind = match value { + ChangeEpoch(change_epoch) => Kind::ChangeEpoch(change_epoch.into()), + AuthenticatorStateCreate => Kind::AuthenticatorStateCreate(()), + AuthenticatorStateExpire(expire) => Kind::AuthenticatorStateExpire(expire.into()), + RandomnessStateCreate => Kind::RandomnessStateCreate(()), + DenyListStateCreate => Kind::DenyListStateCreate(()), + BridgeStateCreate { chain_id } => Kind::BridgeStateCreate(chain_id.into()), + BridgeCommitteeInit { + bridge_object_version, + } => Kind::BridgeCommitteeInit(bridge_object_version), + }; + + Self { kind: Some(kind) } + } +} + +impl TryFrom<&super::EndOfEpochTransactionKind> + for sui_sdk_types::types::EndOfEpochTransactionKind +{ + type Error = TryFromProtoError; + + fn try_from(value: &super::EndOfEpochTransactionKind) -> Result { + use super::end_of_epoch_transaction_kind::Kind; + + match value + .kind + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("kind"))? + { + Kind::ChangeEpoch(change_epoch) => Self::ChangeEpoch(change_epoch.try_into()?), + Kind::AuthenticatorStateExpire(expire) => { + Self::AuthenticatorStateExpire(expire.try_into()?) + } + Kind::AuthenticatorStateCreate(()) => Self::AuthenticatorStateCreate, + Kind::RandomnessStateCreate(()) => Self::RandomnessStateCreate, + Kind::DenyListStateCreate(()) => Self::DenyListStateCreate, + Kind::BridgeStateCreate(digest) => Self::BridgeStateCreate { + chain_id: digest.try_into()?, + }, + Kind::BridgeCommitteeInit(version) => Self::BridgeCommitteeInit { + bridge_object_version: *version, + }, + } + .pipe(Ok) + } +} + +// +// AuthenticatorStateExpire +// + +impl From for super::AuthenticatorStateExpire { + fn from(value: sui_sdk_types::types::AuthenticatorStateExpire) -> Self { + Self { + min_epoch: Some(value.min_epoch), + authenticator_object_initial_shared_version: Some( + value.authenticator_object_initial_shared_version, + ), + } + } +} + +impl TryFrom<&super::AuthenticatorStateExpire> for sui_sdk_types::types::AuthenticatorStateExpire { + type Error = TryFromProtoError; + + fn try_from( + super::AuthenticatorStateExpire { + min_epoch, + authenticator_object_initial_shared_version, + }: &super::AuthenticatorStateExpire, + ) -> Result { + let min_epoch = min_epoch.ok_or_else(|| TryFromProtoError::missing("min_epoch"))?; + let authenticator_object_initial_shared_version = + authenticator_object_initial_shared_version.ok_or_else(|| { + TryFromProtoError::missing("authenticator_object_initial_shared_version") + })?; + Ok(Self { + min_epoch, + authenticator_object_initial_shared_version, + }) + } +} + +// +// ProgrammableTransaction +// + +impl From for super::ProgrammableTransaction { + fn from(value: sui_sdk_types::types::ProgrammableTransaction) -> Self { + Self { + inputs: value.inputs.into_iter().map(Into::into).collect(), + commands: value.commands.into_iter().map(Into::into).collect(), + } + } +} + +impl TryFrom<&super::ProgrammableTransaction> for sui_sdk_types::types::ProgrammableTransaction { + type Error = TryFromProtoError; + + fn try_from(value: &super::ProgrammableTransaction) -> Result { + Ok(Self { + inputs: value + .inputs + .iter() + .map(TryInto::try_into) + .collect::>()?, + commands: value + .commands + .iter() + .map(TryInto::try_into) + .collect::>()?, + }) + } +} + +// +// Input +// + +impl From for super::Input { + fn from(value: sui_sdk_types::types::Input) -> Self { + use super::input::Kind; + use sui_sdk_types::types::Input::*; + + let kind = match value { + Pure { value } => Kind::Pure(value.into()), + ImmutableOrOwned(reference) => Kind::ImmutableOrOwned(reference.into()), + Shared { + object_id, + initial_shared_version, + mutable, + } => Kind::Shared(super::SharedObjectInput { + object_id: Some(object_id.into()), + initial_shared_version: Some(initial_shared_version), + mutable: Some(mutable), + }), + Receiving(reference) => Kind::Receiving(reference.into()), + }; + + Self { kind: Some(kind) } + } +} + +impl TryFrom<&super::Input> for sui_sdk_types::types::Input { + type Error = TryFromProtoError; + + fn try_from(value: &super::Input) -> Result { + use super::input::Kind; + + match value + .kind + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("kind"))? + { + Kind::Pure(value) => Self::Pure { + value: value.to_vec(), + }, + Kind::ImmutableOrOwned(reference) => Self::ImmutableOrOwned(reference.try_into()?), + Kind::Shared(shared) => { + let object_id = shared + .object_id + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("object_id"))? + .try_into()?; + Self::Shared { + object_id, + initial_shared_version: shared + .initial_shared_version + .ok_or_else(|| TryFromProtoError::missing("initial_shared_version"))?, + mutable: shared + .mutable + .ok_or_else(|| TryFromProtoError::missing("mutable"))?, + } + } + Kind::Receiving(reference) => Self::Receiving(reference.try_into()?), + } + .pipe(Ok) + } +} + +// +// Argument +// + +impl From for super::Argument { + fn from(value: sui_sdk_types::types::Argument) -> Self { + use super::argument::Kind; + use sui_sdk_types::types::Argument::*; + + let kind = match value { + Gas => Kind::Gas(()), + Input(input) => Kind::Input(input.into()), + Result(result) => Kind::Result(result.into()), + NestedResult(result, subresult) => Kind::NestedResult(super::NestedResult { + result: Some(result.into()), + subresult: Some(subresult.into()), + }), + }; + + Self { kind: Some(kind) } + } +} + +impl TryFrom<&super::Argument> for sui_sdk_types::types::Argument { + type Error = TryFromProtoError; + + fn try_from(value: &super::Argument) -> Result { + use super::argument::Kind; + + match value + .kind + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("kind"))? + { + Kind::Gas(()) => Self::Gas, + Kind::Input(input) => Self::Input((*input).try_into()?), + Kind::Result(result) => Self::Result((*result).try_into()?), + Kind::NestedResult(super::NestedResult { result, subresult }) => Self::NestedResult( + result + .ok_or_else(|| TryFromProtoError::missing("result"))? + .try_into()?, + subresult + .ok_or_else(|| TryFromProtoError::missing("subresult"))? + .try_into()?, + ), + } + .pipe(Ok) + } +} + +// +// Command +// + +impl From for super::Command { + fn from(value: sui_sdk_types::types::Command) -> Self { + use super::command::Command; + use sui_sdk_types::types::Command::*; + + let command = match value { + MoveCall(move_call) => Command::MoveCall(move_call.into()), + TransferObjects(transfer_objects) => Command::TransferObjects(transfer_objects.into()), + SplitCoins(split_coins) => Command::SplitCoins(split_coins.into()), + MergeCoins(merge_coins) => Command::MergeCoins(merge_coins.into()), + Publish(publish) => Command::Publish(publish.into()), + MakeMoveVector(make_move_vector) => Command::MakeMoveVector(make_move_vector.into()), + Upgrade(upgrade) => Command::Upgrade(upgrade.into()), + }; + + Self { + command: Some(command), + } + } +} + +impl TryFrom<&super::Command> for sui_sdk_types::types::Command { + type Error = TryFromProtoError; + + fn try_from(value: &super::Command) -> Result { + use super::command::Command; + + match value + .command + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("command"))? + { + Command::MoveCall(move_call) => Self::MoveCall(move_call.try_into()?), + Command::TransferObjects(transfer_objects) => { + Self::TransferObjects(transfer_objects.try_into()?) + } + Command::SplitCoins(split_coins) => Self::SplitCoins(split_coins.try_into()?), + Command::MergeCoins(merge_coins) => Self::MergeCoins(merge_coins.try_into()?), + Command::Publish(publish) => Self::Publish(publish.try_into()?), + Command::MakeMoveVector(make_move_vector) => { + Self::MakeMoveVector(make_move_vector.try_into()?) + } + Command::Upgrade(upgrade) => Self::Upgrade(upgrade.try_into()?), + } + .pipe(Ok) + } +} + +// +// MoveCall +// + +impl From for super::MoveCall { + fn from(value: sui_sdk_types::types::MoveCall) -> Self { + Self { + package: Some(value.package.into()), + module: Some(value.module.into()), + function: Some(value.function.into()), + type_arguments: value.type_arguments.into_iter().map(Into::into).collect(), + arguments: value.arguments.into_iter().map(Into::into).collect(), + } + } +} + +impl TryFrom<&super::MoveCall> for sui_sdk_types::types::MoveCall { + type Error = TryFromProtoError; + + fn try_from(value: &super::MoveCall) -> Result { + let package = value + .package + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("package"))? + .try_into()?; + + let module = value + .module + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("module"))? + .try_into()?; + + let function = value + .function + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("function"))? + .try_into()?; + + let type_arguments = value + .type_arguments + .iter() + .map(TryInto::try_into) + .collect::>()?; + let arguments = value + .arguments + .iter() + .map(TryInto::try_into) + .collect::>()?; + + Ok(Self { + package, + module, + function, + type_arguments, + arguments, + }) + } +} + +// +// TransferObjects +// + +impl From for super::TransferObjects { + fn from(value: sui_sdk_types::types::TransferObjects) -> Self { + Self { + objects: value.objects.into_iter().map(Into::into).collect(), + address: Some(value.address.into()), + } + } +} + +impl TryFrom<&super::TransferObjects> for sui_sdk_types::types::TransferObjects { + type Error = TryFromProtoError; + + fn try_from(value: &super::TransferObjects) -> Result { + let objects = value + .objects + .iter() + .map(TryInto::try_into) + .collect::>()?; + + let address = value + .address + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("address"))? + .try_into()?; + + Ok(Self { objects, address }) + } +} + +// +// SplitCoins +// + +impl From for super::SplitCoins { + fn from(value: sui_sdk_types::types::SplitCoins) -> Self { + Self { + coin: Some(value.coin.into()), + amounts: value.amounts.into_iter().map(Into::into).collect(), + } + } +} + +impl TryFrom<&super::SplitCoins> for sui_sdk_types::types::SplitCoins { + type Error = TryFromProtoError; + + fn try_from(value: &super::SplitCoins) -> Result { + let coin = value + .coin + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("coin"))? + .try_into()?; + + let amounts = value + .amounts + .iter() + .map(TryInto::try_into) + .collect::>()?; + + Ok(Self { coin, amounts }) + } +} + +// +// MergeCoins +// + +impl From for super::MergeCoins { + fn from(value: sui_sdk_types::types::MergeCoins) -> Self { + Self { + coin: Some(value.coin.into()), + coins_to_merge: value.coins_to_merge.into_iter().map(Into::into).collect(), + } + } +} + +impl TryFrom<&super::MergeCoins> for sui_sdk_types::types::MergeCoins { + type Error = TryFromProtoError; + + fn try_from(value: &super::MergeCoins) -> Result { + let coin = value + .coin + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("coin"))? + .try_into()?; + + let coins_to_merge = value + .coins_to_merge + .iter() + .map(TryInto::try_into) + .collect::>()?; + + Ok(Self { + coin, + coins_to_merge, + }) + } +} + +// +// Publish +// + +impl From for super::Publish { + fn from(value: sui_sdk_types::types::Publish) -> Self { + Self { + modules: value.modules.into_iter().map(Into::into).collect(), + dependencies: value.dependencies.into_iter().map(Into::into).collect(), + } + } +} + +impl TryFrom<&super::Publish> for sui_sdk_types::types::Publish { + type Error = TryFromProtoError; + + fn try_from(value: &super::Publish) -> Result { + let modules = value.modules.iter().map(|bytes| bytes.to_vec()).collect(); + + let dependencies = value + .dependencies + .iter() + .map(TryInto::try_into) + .collect::>()?; + + Ok(Self { + modules, + dependencies, + }) + } +} + +// +// MakeMoveVector +// + +impl From for super::MakeMoveVector { + fn from(value: sui_sdk_types::types::MakeMoveVector) -> Self { + Self { + element_type: value.type_.map(Into::into), + elements: value.elements.into_iter().map(Into::into).collect(), + } + } +} + +impl TryFrom<&super::MakeMoveVector> for sui_sdk_types::types::MakeMoveVector { + type Error = TryFromProtoError; + + fn try_from(value: &super::MakeMoveVector) -> Result { + let element_type = value + .element_type + .as_ref() + .map(TryInto::try_into) + .transpose()?; + + let elements = value + .elements + .iter() + .map(TryInto::try_into) + .collect::>()?; + + Ok(Self { + type_: element_type, + elements, + }) + } +} + +// +// Upgrade +// + +impl From for super::Upgrade { + fn from(value: sui_sdk_types::types::Upgrade) -> Self { + Self { + modules: value.modules.into_iter().map(Into::into).collect(), + dependencies: value.dependencies.into_iter().map(Into::into).collect(), + package: Some(value.package.into()), + ticket: Some(value.ticket.into()), + } + } +} + +impl TryFrom<&super::Upgrade> for sui_sdk_types::types::Upgrade { + type Error = TryFromProtoError; + + fn try_from(value: &super::Upgrade) -> Result { + let modules = value.modules.iter().map(|bytes| bytes.to_vec()).collect(); + + let dependencies = value + .dependencies + .iter() + .map(TryInto::try_into) + .collect::>()?; + + let package = value + .package + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("package"))? + .try_into()?; + + let ticket = value + .ticket + .as_ref() + .ok_or_else(|| TryFromProtoError::missing("ticket"))? + .try_into()?; + + Ok(Self { + modules, + dependencies, + package, + ticket, + }) + } +} diff --git a/crates/sui-rpc-api/tests/bootstrap.rs b/crates/sui-rpc-api/tests/bootstrap.rs index d5e606dc0a446..08e3669ccd42e 100644 --- a/crates/sui-rpc-api/tests/bootstrap.rs +++ b/crates/sui-rpc-api/tests/bootstrap.rs @@ -1,7 +1,8 @@ // Copyright (c) Mysten Labs, Inc. // SPDX-License-Identifier: Apache-2.0 -use std::{fs, path::PathBuf, process::Command}; +use std::fs; +use std::path::PathBuf; #[test] fn bootstrap() { @@ -34,15 +35,17 @@ fn bootstrap() { let out_dir = root_dir.join("src").join("proto").join("generated"); - if let Err(error) = prost_build::Config::new() + if let Err(error) = tonic_build::configure() + .build_client(true) + .build_server(true) .bytes(["."]) .out_dir(&out_dir) .compile_protos(&proto_files[..], &[proto_dir]) { - panic!("failed to compile `rest` protobuf: {}", error); + panic!("failed to compile `sui` protos: {}", error); } - let status = Command::new("git") + let status = std::process::Command::new("git") .arg("diff") .arg("--exit-code") .arg("--")