Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(grpc): merge raw transaction methods to one rpc method #1500

Merged
merged 22 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/shell/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func main() {

sh.PreRun = func(_ *cobra.Command, _ []string) {
cls()
cmd.PrintInfoMsgf("Welcome to PactusBlockchain shell\n\n- Home: https//pactus.org\n- " +
cmd.PrintInfoMsgf("Welcome to PactusBlockchain shell\n\n- Home: https://pactus.org\n- " +
"Docs: https://docs.pactus.org")
cmd.PrintLine()
_prefix = fmt.Sprintf("pactus@%s > ", serverAddr)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ require (
github.com/libp2p/go-libp2p-pubsub v0.12.0
github.com/manifoldco/promptui v0.9.0
github.com/multiformats/go-multiaddr v0.13.0
github.com/pacviewer/jrpc-gateway v0.4.0
github.com/pacviewer/jrpc-gateway v0.5.0
github.com/pelletier/go-toml v1.9.5
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.20.4
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
Expand Down Expand Up @@ -400,8 +400,8 @@ github.com/opencontainers/runtime-spec v1.2.0 h1:z97+pHb3uELt/yiAWD691HNHQIF07bE
github.com/opencontainers/runtime-spec v1.2.0/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
github.com/openzipkin/zipkin-go v0.1.1/go.mod h1:NtoC/o8u3JlF1lSlyPNswIbeQH9bJTmOf0Erfk+hxe8=
github.com/pacviewer/jrpc-gateway v0.4.0 h1:kHv0aJGRBIoKioVqTopRDM0W9E5WRaHr+EGSLoXwYXs=
github.com/pacviewer/jrpc-gateway v0.4.0/go.mod h1:UD39xHvA8M8WWkyIHfHSlI94Gtb9LPnHhm/X+LvNfA4=
github.com/pacviewer/jrpc-gateway v0.5.0 h1:zQAtUsy9oLiNYbnv7l1yv34ZTbkF6zYgtAqRZLXc59U=
github.com/pacviewer/jrpc-gateway v0.5.0/go.mod h1:jj1tMRRRc+MhydrEmJpIzfOvLDU+hGylhdvG7kqCrsk=
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 h1:onHthvaw9LFnH4t2DcNVpwGmV9E1BkGknEliJkfwQj0=
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58/go.mod h1:DXv8WO4yhMYhSNPKjeNKa5WY9YCIEBRbNzFFPJbWO6Y=
github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8=
Expand Down
13 changes: 2 additions & 11 deletions www/grpc/buf/grpc-gateway.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,8 @@ http:
- selector: pactus.Transaction.CalculateFee
get: "/pactus/transaction/calculate_fee"

- selector: pactus.Transaction.GetRawTransferTransaction
Ja7ad marked this conversation as resolved.
Show resolved Hide resolved
get: "/pactus/transaction/get_raw_transfer_transaction"

- selector: pactus.Transaction.GetRawBondTransaction
get: "/pactus/transaction/get_raw_bond_transaction"

- selector: pactus.Transaction.GetRawUnbondTransaction
get: "/pactus/transaction/get_raw_unbond_transaction"

- selector: pactus.Transaction.GetRawWithdrawTransaction
get: "/pactus/transaction/get_raw_withdraw_transaction"
- selector: pactus.Transaction.GetRawTransaction
get: "/pactus/transaction/get_raw_transaction"

# Network APIs
- selector: pactus.Network.GetNetworkInfo
Expand Down
222 changes: 206 additions & 16 deletions www/grpc/gen/dart/transaction.pb.dart
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,164 @@ class BroadcastTransactionResponse extends $pb.GeneratedMessage {
void clearId() => clearField(1);
}

enum GetRawTransactionRequest_Payload {
transfer,
bond,
unbond,
withdraw,
notSet
}

class GetRawTransactionRequest extends $pb.GeneratedMessage {
static const $core.Map<$core.int, GetRawTransactionRequest_Payload> _GetRawTransactionRequest_PayloadByTag = {
4 : GetRawTransactionRequest_Payload.transfer,
5 : GetRawTransactionRequest_Payload.bond,
6 : GetRawTransactionRequest_Payload.unbond,
7 : GetRawTransactionRequest_Payload.withdraw,
0 : GetRawTransactionRequest_Payload.notSet
};
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'GetRawTransactionRequest', package: const $pb.PackageName(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'pactus'), createEmptyInstance: create)
..oo(0, [4, 5, 6, 7])
..a<$core.int>(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'lockTime', $pb.PbFieldType.OU3)
..aOS(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'memo')
..aInt64(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'fee')
..aOM<PayloadTransfer>(4, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'transfer', subBuilder: PayloadTransfer.create)
..aOM<PayloadBond>(5, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'bond', subBuilder: PayloadBond.create)
..aOM<PayloadUnbond>(6, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'unbond', subBuilder: PayloadUnbond.create)
..aOM<PayloadWithdraw>(7, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'withdraw', subBuilder: PayloadWithdraw.create)
..hasRequiredFields = false
;

GetRawTransactionRequest._() : super();
factory GetRawTransactionRequest({
$core.int? lockTime,
$core.String? memo,
$fixnum.Int64? fee,
PayloadTransfer? transfer,
PayloadBond? bond,
PayloadUnbond? unbond,
PayloadWithdraw? withdraw,
}) {
final _result = create();
if (lockTime != null) {
_result.lockTime = lockTime;
}
if (memo != null) {
_result.memo = memo;
}
if (fee != null) {
_result.fee = fee;
}
if (transfer != null) {
_result.transfer = transfer;
}
if (bond != null) {
_result.bond = bond;
}
if (unbond != null) {
_result.unbond = unbond;
}
if (withdraw != null) {
_result.withdraw = withdraw;
}
return _result;
}
factory GetRawTransactionRequest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
factory GetRawTransactionRequest.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')
GetRawTransactionRequest clone() => GetRawTransactionRequest()..mergeFromMessage(this);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
'Will be removed in next major version')
GetRawTransactionRequest copyWith(void Function(GetRawTransactionRequest) updates) => super.copyWith((message) => updates(message as GetRawTransactionRequest)) as GetRawTransactionRequest; // ignore: deprecated_member_use
$pb.BuilderInfo get info_ => _i;
@$core.pragma('dart2js:noInline')
static GetRawTransactionRequest create() => GetRawTransactionRequest._();
GetRawTransactionRequest createEmptyInstance() => create();
static $pb.PbList<GetRawTransactionRequest> createRepeated() => $pb.PbList<GetRawTransactionRequest>();
@$core.pragma('dart2js:noInline')
static GetRawTransactionRequest getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<GetRawTransactionRequest>(create);
static GetRawTransactionRequest? _defaultInstance;

GetRawTransactionRequest_Payload whichPayload() => _GetRawTransactionRequest_PayloadByTag[$_whichOneof(0)]!;
void clearPayload() => clearField($_whichOneof(0));

@$pb.TagNumber(1)
$core.int get lockTime => $_getIZ(0);
@$pb.TagNumber(1)
set lockTime($core.int v) { $_setUnsignedInt32(0, v); }
@$pb.TagNumber(1)
$core.bool hasLockTime() => $_has(0);
@$pb.TagNumber(1)
void clearLockTime() => clearField(1);

@$pb.TagNumber(2)
$core.String get memo => $_getSZ(1);
@$pb.TagNumber(2)
set memo($core.String v) { $_setString(1, v); }
@$pb.TagNumber(2)
$core.bool hasMemo() => $_has(1);
@$pb.TagNumber(2)
void clearMemo() => clearField(2);

@$pb.TagNumber(3)
$fixnum.Int64 get fee => $_getI64(2);
@$pb.TagNumber(3)
set fee($fixnum.Int64 v) { $_setInt64(2, v); }
@$pb.TagNumber(3)
$core.bool hasFee() => $_has(2);
@$pb.TagNumber(3)
void clearFee() => clearField(3);

@$pb.TagNumber(4)
PayloadTransfer get transfer => $_getN(3);
@$pb.TagNumber(4)
set transfer(PayloadTransfer v) { setField(4, v); }
@$pb.TagNumber(4)
$core.bool hasTransfer() => $_has(3);
@$pb.TagNumber(4)
void clearTransfer() => clearField(4);
@$pb.TagNumber(4)
PayloadTransfer ensureTransfer() => $_ensure(3);

@$pb.TagNumber(5)
PayloadBond get bond => $_getN(4);
@$pb.TagNumber(5)
set bond(PayloadBond v) { setField(5, v); }
@$pb.TagNumber(5)
$core.bool hasBond() => $_has(4);
@$pb.TagNumber(5)
void clearBond() => clearField(5);
@$pb.TagNumber(5)
PayloadBond ensureBond() => $_ensure(4);

@$pb.TagNumber(6)
PayloadUnbond get unbond => $_getN(5);
@$pb.TagNumber(6)
set unbond(PayloadUnbond v) { setField(6, v); }
@$pb.TagNumber(6)
$core.bool hasUnbond() => $_has(5);
@$pb.TagNumber(6)
void clearUnbond() => clearField(6);
@$pb.TagNumber(6)
PayloadUnbond ensureUnbond() => $_ensure(5);

@$pb.TagNumber(7)
PayloadWithdraw get withdraw => $_getN(6);
@$pb.TagNumber(7)
set withdraw(PayloadWithdraw v) { setField(7, v); }
@$pb.TagNumber(7)
$core.bool hasWithdraw() => $_has(6);
@$pb.TagNumber(7)
void clearWithdraw() => clearField(7);
@$pb.TagNumber(7)
PayloadWithdraw ensureWithdraw() => $_ensure(6);
}

class GetRawTransferTransactionRequest extends $pb.GeneratedMessage {
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'GetRawTransferTransactionRequest', package: const $pb.PackageName(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'pactus'), createEmptyInstance: create)
..a<$core.int>(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'lockTime', $pb.PbFieldType.OU3)
Expand Down Expand Up @@ -826,17 +984,22 @@ class GetRawWithdrawTransactionRequest extends $pb.GeneratedMessage {
class GetRawTransactionResponse extends $pb.GeneratedMessage {
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'GetRawTransactionResponse', 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') ? '' : 'rawTransaction')
..aOS(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'id')
..hasRequiredFields = false
;

GetRawTransactionResponse._() : super();
factory GetRawTransactionResponse({
$core.String? rawTransaction,
$core.String? id,
}) {
final _result = create();
if (rawTransaction != null) {
_result.rawTransaction = rawTransaction;
}
if (id != null) {
_result.id = id;
}
return _result;
}
factory GetRawTransactionResponse.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
Expand Down Expand Up @@ -868,6 +1031,15 @@ class GetRawTransactionResponse extends $pb.GeneratedMessage {
$core.bool hasRawTransaction() => $_has(0);
@$pb.TagNumber(1)
void clearRawTransaction() => clearField(1);

@$pb.TagNumber(2)
$core.String get id => $_getSZ(1);
@$pb.TagNumber(2)
set id($core.String v) { $_setString(1, v); }
@$pb.TagNumber(2)
$core.bool hasId() => $_has(1);
@$pb.TagNumber(2)
void clearId() => clearField(2);
}

class PayloadTransfer extends $pb.GeneratedMessage {
Expand Down Expand Up @@ -950,6 +1122,7 @@ class PayloadBond extends $pb.GeneratedMessage {
..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'sender')
..aOS(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'receiver')
..aInt64(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'stake')
..aOS(4, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'publicKey')
..hasRequiredFields = false
;

Expand All @@ -958,6 +1131,7 @@ class PayloadBond extends $pb.GeneratedMessage {
$core.String? sender,
$core.String? receiver,
$fixnum.Int64? stake,
$core.String? publicKey,
}) {
final _result = create();
if (sender != null) {
Expand All @@ -969,6 +1143,9 @@ class PayloadBond extends $pb.GeneratedMessage {
if (stake != null) {
_result.stake = stake;
}
if (publicKey != null) {
_result.publicKey = publicKey;
}
return _result;
}
factory PayloadBond.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
Expand Down Expand Up @@ -1018,6 +1195,15 @@ class PayloadBond extends $pb.GeneratedMessage {
$core.bool hasStake() => $_has(2);
@$pb.TagNumber(3)
void clearStake() => clearField(3);

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

class PayloadSortition extends $pb.GeneratedMessage {
Expand Down Expand Up @@ -1130,24 +1316,24 @@ class PayloadUnbond extends $pb.GeneratedMessage {

class PayloadWithdraw extends $pb.GeneratedMessage {
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'PayloadWithdraw', 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') ? '' : 'from')
..aOS(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'to')
..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'validatorAddress')
..aOS(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'accountAddress')
..aInt64(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'amount')
..hasRequiredFields = false
;

PayloadWithdraw._() : super();
factory PayloadWithdraw({
$core.String? from,
$core.String? to,
$core.String? validatorAddress,
$core.String? accountAddress,
$fixnum.Int64? amount,
}) {
final _result = create();
if (from != null) {
_result.from = from;
if (validatorAddress != null) {
_result.validatorAddress = validatorAddress;
}
if (to != null) {
_result.to = to;
if (accountAddress != null) {
_result.accountAddress = accountAddress;
}
if (amount != null) {
_result.amount = amount;
Expand Down Expand Up @@ -1176,22 +1362,22 @@ class PayloadWithdraw extends $pb.GeneratedMessage {
static PayloadWithdraw? _defaultInstance;

@$pb.TagNumber(1)
$core.String get from => $_getSZ(0);
$core.String get validatorAddress => $_getSZ(0);
@$pb.TagNumber(1)
set from($core.String v) { $_setString(0, v); }
set validatorAddress($core.String v) { $_setString(0, v); }
@$pb.TagNumber(1)
$core.bool hasFrom() => $_has(0);
$core.bool hasValidatorAddress() => $_has(0);
@$pb.TagNumber(1)
void clearFrom() => clearField(1);
void clearValidatorAddress() => clearField(1);

@$pb.TagNumber(2)
$core.String get to => $_getSZ(1);
$core.String get accountAddress => $_getSZ(1);
@$pb.TagNumber(2)
set to($core.String v) { $_setString(1, v); }
set accountAddress($core.String v) { $_setString(1, v); }
@$pb.TagNumber(2)
$core.bool hasTo() => $_has(1);
$core.bool hasAccountAddress() => $_has(1);
@$pb.TagNumber(2)
void clearTo() => clearField(2);
void clearAccountAddress() => clearField(2);

@$pb.TagNumber(3)
$fixnum.Int64 get amount => $_getI64(2);
Expand Down Expand Up @@ -1493,6 +1679,10 @@ class TransactionApi {
var emptyResponse = BroadcastTransactionResponse();
return _client.invoke<BroadcastTransactionResponse>(ctx, 'Transaction', 'BroadcastTransaction', request, emptyResponse);
}
$async.Future<GetRawTransactionResponse> getRawTransaction($pb.ClientContext? ctx, GetRawTransactionRequest request) {
var emptyResponse = GetRawTransactionResponse();
return _client.invoke<GetRawTransactionResponse>(ctx, 'Transaction', 'GetRawTransaction', request, emptyResponse);
}
$async.Future<GetRawTransactionResponse> getRawTransferTransaction($pb.ClientContext? ctx, GetRawTransferTransactionRequest request) {
var emptyResponse = GetRawTransactionResponse();
return _client.invoke<GetRawTransactionResponse>(ctx, 'Transaction', 'GetRawTransferTransaction', request, emptyResponse);
Expand Down
Loading
Loading