Skip to content

Commit

Permalink
feat: implement get validator address for grpc (#975)
Browse files Browse the repository at this point in the history
  • Loading branch information
amirvalhalla authored Jan 28, 2024
1 parent 2131c2d commit 1e831ae
Show file tree
Hide file tree
Showing 19 changed files with 2,207 additions and 142 deletions.
3 changes: 3 additions & 0 deletions www/grpc/buf/grpc-gateway.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ http:
get: "/v1/network/node"

# Wallet APIs
- selector: pactus.Wallet.GetValidatorAddress
get: "/v1/wallets/validator_address/{public_key}"

- selector: pactus.Wallet.CreateWallet
get: "/v1/wallets/create/wallet_name/{wallet_name}/mnemonic/{mnemonic}/language/{language}"

Expand Down
4 changes: 4 additions & 0 deletions www/grpc/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ func (s *Server) startGateway(grpcAddr string) error {
if err != nil {
return err
}
err = pactus.RegisterWalletHandler(s.ctx, gwMux, conn)
if err != nil {
return err
}

oa, err := s.getOpenAPIHandler()
if err != nil {
Expand Down
98 changes: 98 additions & 0 deletions www/grpc/gen/dart/wallet.pb.dart
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,100 @@ class LockWalletResponse extends $pb.GeneratedMessage {
void clearWalletName() => clearField(1);
}

class GetValidatorAddressRequest extends $pb.GeneratedMessage {
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'GetValidatorAddressRequest', 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') ? '' : 'publicKey')
..hasRequiredFields = false
;

GetValidatorAddressRequest._() : super();
factory GetValidatorAddressRequest({
$core.String? publicKey,
}) {
final _result = create();
if (publicKey != null) {
_result.publicKey = publicKey;
}
return _result;
}
factory GetValidatorAddressRequest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
factory GetValidatorAddressRequest.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.deepCopy] instead. '
'Will be removed in next major version')
GetValidatorAddressRequest clone() => GetValidatorAddressRequest()..mergeFromMessage(this);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
'Will be removed in next major version')
GetValidatorAddressRequest copyWith(void Function(GetValidatorAddressRequest) updates) => super.copyWith((message) => updates(message as GetValidatorAddressRequest)) as GetValidatorAddressRequest; // ignore: deprecated_member_use
$pb.BuilderInfo get info_ => _i;
@$core.pragma('dart2js:noInline')
static GetValidatorAddressRequest create() => GetValidatorAddressRequest._();
GetValidatorAddressRequest createEmptyInstance() => create();
static $pb.PbList<GetValidatorAddressRequest> createRepeated() => $pb.PbList<GetValidatorAddressRequest>();
@$core.pragma('dart2js:noInline')
static GetValidatorAddressRequest getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<GetValidatorAddressRequest>(create);
static GetValidatorAddressRequest? _defaultInstance;

@$pb.TagNumber(1)
$core.String get publicKey => $_getSZ(0);
@$pb.TagNumber(1)
set publicKey($core.String v) { $_setString(0, v); }
@$pb.TagNumber(1)
$core.bool hasPublicKey() => $_has(0);
@$pb.TagNumber(1)
void clearPublicKey() => clearField(1);
}

class GetValidatorAddressResponse extends $pb.GeneratedMessage {
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'GetValidatorAddressResponse', 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')
..hasRequiredFields = false
;

GetValidatorAddressResponse._() : super();
factory GetValidatorAddressResponse({
$core.String? address,
}) {
final _result = create();
if (address != null) {
_result.address = address;
}
return _result;
}
factory GetValidatorAddressResponse.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
factory GetValidatorAddressResponse.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.deepCopy] instead. '
'Will be removed in next major version')
GetValidatorAddressResponse clone() => GetValidatorAddressResponse()..mergeFromMessage(this);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
'Will be removed in next major version')
GetValidatorAddressResponse copyWith(void Function(GetValidatorAddressResponse) updates) => super.copyWith((message) => updates(message as GetValidatorAddressResponse)) as GetValidatorAddressResponse; // ignore: deprecated_member_use
$pb.BuilderInfo get info_ => _i;
@$core.pragma('dart2js:noInline')
static GetValidatorAddressResponse create() => GetValidatorAddressResponse._();
GetValidatorAddressResponse createEmptyInstance() => create();
static $pb.PbList<GetValidatorAddressResponse> createRepeated() => $pb.PbList<GetValidatorAddressResponse>();
@$core.pragma('dart2js:noInline')
static GetValidatorAddressResponse getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<GetValidatorAddressResponse>(create);
static GetValidatorAddressResponse? _defaultInstance;

@$pb.TagNumber(1)
$core.String get address => $_getSZ(0);
@$pb.TagNumber(1)
set address($core.String v) { $_setString(0, v); }
@$pb.TagNumber(1)
$core.bool hasAddress() => $_has(0);
@$pb.TagNumber(1)
void clearAddress() => clearField(1);
}

class UnlockWalletRequest extends $pb.GeneratedMessage {
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'UnlockWalletRequest', 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') ? '' : 'walletName')
Expand Down Expand Up @@ -714,5 +808,9 @@ class WalletApi {
var emptyResponse = SignRawTransactionResponse();
return _client.invoke<SignRawTransactionResponse>(ctx, 'Wallet', 'SignRawTransaction', request, emptyResponse);
}
$async.Future<GetValidatorAddressResponse> getValidatorAddress($pb.ClientContext? ctx, GetValidatorAddressRequest request) {
var emptyResponse = GetValidatorAddressResponse();
return _client.invoke<GetValidatorAddressResponse>(ctx, 'Wallet', 'GetValidatorAddress', request, emptyResponse);
}
}

25 changes: 24 additions & 1 deletion www/grpc/gen/dart/wallet.pbjson.dart
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,26 @@ const LockWalletResponse$json = const {

/// Descriptor for `LockWalletResponse`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List lockWalletResponseDescriptor = $convert.base64Decode('ChJMb2NrV2FsbGV0UmVzcG9uc2USHwoLd2FsbGV0X25hbWUYASABKAlSCndhbGxldE5hbWU=');
@$core.Deprecated('Use getValidatorAddressRequestDescriptor instead')
const GetValidatorAddressRequest$json = const {
'1': 'GetValidatorAddressRequest',
'2': const [
const {'1': 'public_key', '3': 1, '4': 1, '5': 9, '10': 'publicKey'},
],
};

/// Descriptor for `GetValidatorAddressRequest`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List getValidatorAddressRequestDescriptor = $convert.base64Decode('ChpHZXRWYWxpZGF0b3JBZGRyZXNzUmVxdWVzdBIdCgpwdWJsaWNfa2V5GAEgASgJUglwdWJsaWNLZXk=');
@$core.Deprecated('Use getValidatorAddressResponseDescriptor instead')
const GetValidatorAddressResponse$json = const {
'1': 'GetValidatorAddressResponse',
'2': const [
const {'1': 'address', '3': 1, '4': 1, '5': 9, '10': 'address'},
],
};

/// Descriptor for `GetValidatorAddressResponse`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List getValidatorAddressResponseDescriptor = $convert.base64Decode('ChtHZXRWYWxpZGF0b3JBZGRyZXNzUmVzcG9uc2USGAoHYWRkcmVzcxgBIAEoCVIHYWRkcmVzcw==');
@$core.Deprecated('Use unlockWalletRequestDescriptor instead')
const UnlockWalletRequest$json = const {
'1': 'UnlockWalletRequest',
Expand Down Expand Up @@ -145,6 +165,7 @@ const $core.Map<$core.String, $core.dynamic> WalletServiceBase$json = const {
const {'1': 'LockWallet', '2': '.pactus.LockWalletRequest', '3': '.pactus.LockWalletResponse'},
const {'1': 'UnlockWallet', '2': '.pactus.UnlockWalletRequest', '3': '.pactus.UnlockWalletResponse'},
const {'1': 'SignRawTransaction', '2': '.pactus.SignRawTransactionRequest', '3': '.pactus.SignRawTransactionResponse'},
const {'1': 'GetValidatorAddress', '2': '.pactus.GetValidatorAddressRequest', '3': '.pactus.GetValidatorAddressResponse'},
],
};

Expand All @@ -162,7 +183,9 @@ const $core.Map<$core.String, $core.Map<$core.String, $core.dynamic>> WalletServ
'.pactus.UnlockWalletResponse': UnlockWalletResponse$json,
'.pactus.SignRawTransactionRequest': SignRawTransactionRequest$json,
'.pactus.SignRawTransactionResponse': SignRawTransactionResponse$json,
'.pactus.GetValidatorAddressRequest': GetValidatorAddressRequest$json,
'.pactus.GetValidatorAddressResponse': GetValidatorAddressResponse$json,
};

/// Descriptor for `Wallet`. Decode as a `google.protobuf.ServiceDescriptorProto`.
final $typed_data.Uint8List walletServiceDescriptor = $convert.base64Decode('CgZXYWxsZXQSSQoMQ3JlYXRlV2FsbGV0EhsucGFjdHVzLkNyZWF0ZVdhbGxldFJlcXVlc3QaHC5wYWN0dXMuQ3JlYXRlV2FsbGV0UmVzcG9uc2USQwoKTG9hZFdhbGxldBIZLnBhY3R1cy5Mb2FkV2FsbGV0UmVxdWVzdBoaLnBhY3R1cy5Mb2FkV2FsbGV0UmVzcG9uc2USSQoMVW5sb2FkV2FsbGV0EhsucGFjdHVzLlVubG9hZFdhbGxldFJlc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cxIiLnBhY3R1cy5HZXRWYWxpZGF0b3JBZGRyZXNzUmVxdWVzdBojLnBhY3R1cy5HZXRWYWxpZGF0b3JBZGRyZXNzUmVzcG9uc2U=');
3 changes: 3 additions & 0 deletions www/grpc/gen/dart/wallet.pbserver.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ abstract class WalletServiceBase extends $pb.GeneratedService {
$async.Future<$3.LockWalletResponse> lockWallet($pb.ServerContext ctx, $3.LockWalletRequest request);
$async.Future<$3.UnlockWalletResponse> unlockWallet($pb.ServerContext ctx, $3.UnlockWalletRequest request);
$async.Future<$3.SignRawTransactionResponse> signRawTransaction($pb.ServerContext ctx, $3.SignRawTransactionRequest request);
$async.Future<$3.GetValidatorAddressResponse> getValidatorAddress($pb.ServerContext ctx, $3.GetValidatorAddressRequest request);

$pb.GeneratedMessage createRequest($core.String method) {
switch (method) {
Expand All @@ -31,6 +32,7 @@ abstract class WalletServiceBase extends $pb.GeneratedService {
case 'LockWallet': return $3.LockWalletRequest();
case 'UnlockWallet': return $3.UnlockWalletRequest();
case 'SignRawTransaction': return $3.SignRawTransactionRequest();
case 'GetValidatorAddress': return $3.GetValidatorAddressRequest();
default: throw $core.ArgumentError('Unknown method: $method');
}
}
Expand All @@ -43,6 +45,7 @@ abstract class WalletServiceBase extends $pb.GeneratedService {
case 'LockWallet': return this.lockWallet(ctx, request as $3.LockWalletRequest);
case 'UnlockWallet': return this.unlockWallet(ctx, request as $3.UnlockWalletRequest);
case 'SignRawTransaction': return this.signRawTransaction(ctx, request as $3.SignRawTransactionRequest);
case 'GetValidatorAddress': return this.getValidatorAddress(ctx, request as $3.GetValidatorAddressRequest);
default: throw $core.ArgumentError('Unknown method: $method');
}
}
Expand Down
Loading

0 comments on commit 1e831ae

Please sign in to comment.