Skip to content

Commit

Permalink
chore(grpc): update proto documents (#1375)
Browse files Browse the repository at this point in the history
  • Loading branch information
b00f authored Jun 27, 2024
1 parent 30a1233 commit 5eb3c50
Show file tree
Hide file tree
Showing 49 changed files with 3,108 additions and 3,149 deletions.
4 changes: 2 additions & 2 deletions crypto/address.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ var TreasuryAddress = Address{0}

type Address [AddressSize]byte

// AddressFromString decodes the string encoding of an address and returns
// the Address if text is a valid encoding for a known address type.
// AddressFromString decodes the input string and returns the Address
// if the string is a valid bech32m encoding of an address.
func AddressFromString(text string) (Address, error) {
if text == treasuryAddressString {
return TreasuryAddress, nil
Expand Down
4 changes: 2 additions & 2 deletions crypto/bls/private_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ type PrivateKey struct {
fr bls12381.Fr
}

// PrivateKeyFromString decodes the string encoding of a BLS private key
// and returns the private key if text is a valid encoding for BLS private key.
// PrivateKeyFromString decodes the input string and returns the PrivateKey
// if the string is a valid bech32m encoding of a BLS public key.
func PrivateKeyFromString(text string) (*PrivateKey, error) {
// Decode the bech32m encoded private key.
hrp, typ, data, err := bech32m.DecodeToBase256WithTypeNoLimit(text)
Expand Down
4 changes: 2 additions & 2 deletions crypto/bls/public_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ type PublicKey struct {
data []byte // Raw public key data.
}

// PublicKeyFromString decodes the string encoding of a BLS public key
// and returns the public key if text is a valid encoding for BLS public key.
// PublicKeyFromString decodes the input string and returns the PublicKey
// if the string is a valid bech32m encoding of a BLS public key.
func PublicKeyFromString(text string) (*PublicKey, error) {
// Decode the bech32m encoded public key.
hrp, typ, data, err := bech32m.DecodeToBase256WithTypeNoLimit(text)
Expand Down
2 changes: 1 addition & 1 deletion crypto/bls/signature.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type Signature struct {
}

// SignatureFromString decodes the input string and returns the Signature
// if the string is a valid hex encoding of a BLS signature.
// if the string is a valid hexadecimal encoding of a BLS signature.
func SignatureFromString(text string) (*Signature, error) {
data, err := hex.DecodeString(text)
if err != nil {
Expand Down
5 changes: 5 additions & 0 deletions crypto/hash/hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ func Hash160(data []byte) []byte {
return h.Sum(nil)
}

// FromString decodes the input string and returns the Hash
// if the string is a valid hexadecimal encoding of a hash.
func FromString(str string) (Hash, error) {
data, err := hex.DecodeString(str)
if err != nil {
Expand All @@ -45,6 +47,7 @@ func FromString(str string) (Hash, error) {
return FromBytes(data)
}

// FromBytes constructs a Hash from the raw bytes.
func FromBytes(data []byte) (Hash, error) {
if len(data) != HashSize {
return Hash{}, fmt.Errorf("Hash should be %d bytes, but it is %v bytes", HashSize, len(data))
Expand All @@ -62,10 +65,12 @@ func CalcHash(data []byte) Hash {
return h
}

// String returns the hex-encoded string representation of the hash.
func (h Hash) String() string {
return hex.EncodeToString(h[:])
}

// Bytes returns the raw byte representation of the hash.
func (h Hash) Bytes() []byte {
return h[:]
}
Expand Down
3 changes: 0 additions & 3 deletions www/grpc/buf/json-rpc-md.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ All the amounts and values in gRPC endpoints are in NanoPAC units,
which are atomic and the smallest unit in the Pactus blockchain.
Each PAC is equivalent to 1,000,000,000 or 10<sup>9</sup> NanoPACs.

All binary data, including hash and transaction data,
are encoded using the [base64](https://en.wikipedia.org/wiki/Base64) decoder.

<h2>JSON-RPC Services</h2>

<div id="toc-container">
Expand Down
2 changes: 1 addition & 1 deletion www/grpc/buf/openapi.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ openapiOptions:
option:
info:
title: Pactus APIs
version: "1.1"
version: "1.2"
description: |
Each node in the Pactus network can be configured to use the [gRPC](https://grpc.io/) protocol for communication.
Here you can find the list of all gRPC methods and messages.
Expand Down
2 changes: 1 addition & 1 deletion www/grpc/gen/dart/blockchain.pb.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1701,7 +1701,7 @@ class VoteInfo extends $pb.GeneratedMessage {
class ConsensusInfo extends $pb.GeneratedMessage {
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'ConsensusInfo', package: const $pb.PackageName(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'pactus'), createEmptyInstance: create)
..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'address')
..aOB(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'Active', protoName: 'Active')
..aOB(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'active')
..a<$core.int>(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'height', $pb.PbFieldType.OU3)
..a<$core.int>(4, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'round', $pb.PbFieldType.O3)
..pc<VoteInfo>(5, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'votes', $pb.PbFieldType.PM, subBuilder: VoteInfo.create)
Expand Down
4 changes: 2 additions & 2 deletions www/grpc/gen/dart/blockchain.pbjson.dart
Original file line number Diff line number Diff line change
Expand Up @@ -330,15 +330,15 @@ const ConsensusInfo$json = const {
'1': 'ConsensusInfo',
'2': const [
const {'1': 'address', '3': 1, '4': 1, '5': 9, '10': 'address'},
const {'1': 'Active', '3': 2, '4': 1, '5': 8, '10': 'Active'},
const {'1': 'active', '3': 2, '4': 1, '5': 8, '10': 'active'},
const {'1': 'height', '3': 3, '4': 1, '5': 13, '10': 'height'},
const {'1': 'round', '3': 4, '4': 1, '5': 5, '10': 'round'},
const {'1': 'votes', '3': 5, '4': 3, '5': 11, '6': '.pactus.VoteInfo', '10': 'votes'},
],
};

/// Descriptor for `ConsensusInfo`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List consensusInfoDescriptor = $convert.base64Decode('Cg1Db25zZW5zdXNJbmZvEhgKB2FkZHJlc3MYASABKAlSB2FkZHJlc3MSFgoGQWN0aXZlGAIgASgIUgZBY3RpdmUSFgoGaGVpZ2h0GAMgASgNUgZoZWlnaHQSFAoFcm91bmQYBCABKAVSBXJvdW5kEiYKBXZvdGVzGAUgAygLMhAucGFjdHVzLlZvdGVJbmZvUgV2b3Rlcw==');
final $typed_data.Uint8List consensusInfoDescriptor = $convert.base64Decode('Cg1Db25zZW5zdXNJbmZvEhgKB2FkZHJlc3MYASABKAlSB2FkZHJlc3MSFgoGYWN0aXZlGAIgASgIUgZhY3RpdmUSFgoGaGVpZ2h0GAMgASgNUgZoZWlnaHQSFAoFcm91bmQYBCABKAVSBXJvdW5kEiYKBXZvdGVzGAUgAygLMhAucGFjdHVzLlZvdGVJbmZvUgV2b3Rlcw==');
const $core.Map<$core.String, $core.dynamic> BlockchainServiceBase$json = const {
'1': 'Blockchain',
'2': const [
Expand Down
10 changes: 5 additions & 5 deletions www/grpc/gen/dart/network.pb.dart
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ class PeerInfo extends $pb.GeneratedMessage {
..aOS(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'agent')
..aOS(4, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'peerId')
..pPS(5, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'consensusKeys')
..pPS(6, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'consensusAddress')
..pPS(6, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'consensusAddresses')
..a<$core.int>(7, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'services', $pb.PbFieldType.OU3)
..aOS(8, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'lastBlockHash')
..a<$core.int>(9, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'height', $pb.PbFieldType.OU3)
Expand All @@ -472,7 +472,7 @@ class PeerInfo extends $pb.GeneratedMessage {
$core.String? agent,
$core.String? peerId,
$core.Iterable<$core.String>? consensusKeys,
$core.Iterable<$core.String>? consensusAddress,
$core.Iterable<$core.String>? consensusAddresses,
$core.int? services,
$core.String? lastBlockHash,
$core.int? height,
Expand Down Expand Up @@ -504,8 +504,8 @@ class PeerInfo extends $pb.GeneratedMessage {
if (consensusKeys != null) {
_result.consensusKeys.addAll(consensusKeys);
}
if (consensusAddress != null) {
_result.consensusAddress.addAll(consensusAddress);
if (consensusAddresses != null) {
_result.consensusAddresses.addAll(consensusAddresses);
}
if (services != null) {
_result.services = services;
Expand Down Expand Up @@ -612,7 +612,7 @@ class PeerInfo extends $pb.GeneratedMessage {
$core.List<$core.String> get consensusKeys => $_getList(4);

@$pb.TagNumber(6)
$core.List<$core.String> get consensusAddress => $_getList(5);
$core.List<$core.String> get consensusAddresses => $_getList(5);

@$pb.TagNumber(7)
$core.int get services => $_getIZ(6);
Expand Down
4 changes: 2 additions & 2 deletions www/grpc/gen/dart/network.pbjson.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ const PeerInfo$json = const {
const {'1': 'agent', '3': 3, '4': 1, '5': 9, '10': 'agent'},
const {'1': 'peer_id', '3': 4, '4': 1, '5': 9, '10': 'peerId'},
const {'1': 'consensus_keys', '3': 5, '4': 3, '5': 9, '10': 'consensusKeys'},
const {'1': 'consensus_address', '3': 6, '4': 3, '5': 9, '10': 'consensusAddress'},
const {'1': 'consensus_addresses', '3': 6, '4': 3, '5': 9, '10': 'consensusAddresses'},
const {'1': 'services', '3': 7, '4': 1, '5': 13, '10': 'services'},
const {'1': 'last_block_hash', '3': 8, '4': 1, '5': 9, '10': 'lastBlockHash'},
const {'1': 'height', '3': 9, '4': 1, '5': 13, '10': 'height'},
Expand Down Expand Up @@ -143,7 +143,7 @@ const PeerInfo_ReceivedBytesEntry$json = const {
};

/// Descriptor for `PeerInfo`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List peerInfo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zGBMgASgFUg10b3RhbFNlc3Npb25zEi0KEmNvbXBsZXRlZF9zZXNzaW9ucxgUIAEoBVIRY29tcGxldGVkU2Vzc2lvbnMaPAoOU2VudEJ5dGVzRW50cnkSEAoDa2V5GAEgASgFUgNrZXkSFAoFdmFsdWUYAiABKANSBXZhbHVlOgI4ARpAChJSZWNlaXZlZEJ5dGVzRW50cnkSEAoDa2V5GAEgASgFUgNrZXkSFAoFdmFsdWUYAiABKANSBXZhbHVlOgI4AQ==');
const $core.Map<$core.String, $core.dynamic> NetworkServiceBase$json = const {
'1': 'Network',
'2': const [
Expand Down
Loading

0 comments on commit 5eb3c50

Please sign in to comment.