Skip to content

Commit b193a05

Browse files
authored
chore: In responses, add Hash and Height (#198)
In goclient, the `ResultBroadcastTxCommit` contains the [transaction hash and height](https://github.com/gnolang/gno/blob/84abee0162e9253ef3bfa475f5b4b1fc5ef4f8c3/tm2/pkg/bft/rpc/core/types/responses.go#L160-L161). In Gno Key Mobile, we have a use case for showing the transaction hash. So update the gRPC types `CallResponse`, etc. to include the hash and height. * In `gnonativetypes`, add `Hash` and `Height` to responses where possible * Run `make regenerate` * In the `gnoNativeService` API, put the `Hash` and `Height` in the response Here is test code for [dSocial `broadcastTxCommit`](https://github.com/gnoverse/dsocial/blob/b25344b553bf350812052a9efe98f1db6e276848/mobile/redux/features/linkingSlice.ts#L99) . ``` for await (const res of await gnonative.broadcastTxCommit(signedTx)) { console.log("broadcasted tx: ", res); console.log("broadcasted TX HASH: ", Buffer.from(res.hash).toString('base64')); } ``` It prints `broadcasted TX HASH: djAPQOCWlCPeGC6j+pAuCzYw32dyiQCmJ/7uwf/d6r4=` Signed-off-by: Jeff Thompson <[email protected]>
1 parent 4a9b0ee commit b193a05

File tree

12 files changed

+592
-81
lines changed

12 files changed

+592
-81
lines changed

api/gen/csharp/Gnonativetypes.cs

Lines changed: 372 additions & 48 deletions
Large diffs are not rendered by default.

api/gen/csharp/RpcGrpc.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,7 @@ public abstract partial class GnoNativeServiceBase
870870
}
871871

872872
/// <summary>
873-
/// EstimateGas estimate the least amount of gas required for the transaction to go through on the chain (minimum gas wanted), with a security margin.
873+
/// EstimateGas estimates the least amount of gas required for the transaction to go through on the chain (minimum gas wanted), with a security margin.
874874
/// If UpdateTx is true, then update the transaction with the gasWanted amount.
875875
/// </summary>
876876
/// <param name="request">The request received from the client.</param>
@@ -2452,7 +2452,7 @@ protected GnoNativeServiceClient(ClientBaseConfiguration configuration) : base(c
24522452
return CallInvoker.AsyncUnaryCall(__Method_MakeRunTx, null, options, request);
24532453
}
24542454
/// <summary>
2455-
/// EstimateGas estimate the least amount of gas required for the transaction to go through on the chain (minimum gas wanted), with a security margin.
2455+
/// EstimateGas estimates the least amount of gas required for the transaction to go through on the chain (minimum gas wanted), with a security margin.
24562456
/// If UpdateTx is true, then update the transaction with the gasWanted amount.
24572457
/// </summary>
24582458
/// <param name="request">The request to send to the server.</param>
@@ -2466,7 +2466,7 @@ protected GnoNativeServiceClient(ClientBaseConfiguration configuration) : base(c
24662466
return EstimateGas(request, new grpc::CallOptions(headers, deadline, cancellationToken));
24672467
}
24682468
/// <summary>
2469-
/// EstimateGas estimate the least amount of gas required for the transaction to go through on the chain (minimum gas wanted), with a security margin.
2469+
/// EstimateGas estimates the least amount of gas required for the transaction to go through on the chain (minimum gas wanted), with a security margin.
24702470
/// If UpdateTx is true, then update the transaction with the gasWanted amount.
24712471
/// </summary>
24722472
/// <param name="request">The request to send to the server.</param>
@@ -2478,7 +2478,7 @@ protected GnoNativeServiceClient(ClientBaseConfiguration configuration) : base(c
24782478
return CallInvoker.BlockingUnaryCall(__Method_EstimateGas, null, options, request);
24792479
}
24802480
/// <summary>
2481-
/// EstimateGas estimate the least amount of gas required for the transaction to go through on the chain (minimum gas wanted), with a security margin.
2481+
/// EstimateGas estimates the least amount of gas required for the transaction to go through on the chain (minimum gas wanted), with a security margin.
24822482
/// If UpdateTx is true, then update the transaction with the gasWanted amount.
24832483
/// </summary>
24842484
/// <param name="request">The request to send to the server.</param>
@@ -2492,7 +2492,7 @@ protected GnoNativeServiceClient(ClientBaseConfiguration configuration) : base(c
24922492
return EstimateGasAsync(request, new grpc::CallOptions(headers, deadline, cancellationToken));
24932493
}
24942494
/// <summary>
2495-
/// EstimateGas estimate the least amount of gas required for the transaction to go through on the chain (minimum gas wanted), with a security margin.
2495+
/// EstimateGas estimates the least amount of gas required for the transaction to go through on the chain (minimum gas wanted), with a security margin.
24962496
/// If UpdateTx is true, then update the transaction with the gasWanted amount.
24972497
/// </summary>
24982498
/// <param name="request">The request to send to the server.</param>

api/gen/es/gnonativetypes_pb.ts

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1992,6 +1992,20 @@ export class CallResponse extends Message<CallResponse> {
19921992
*/
19931993
result = new Uint8Array(0);
19941994

1995+
/**
1996+
* The transaction hash
1997+
*
1998+
* @generated from field: bytes hash = 2;
1999+
*/
2000+
hash = new Uint8Array(0);
2001+
2002+
/**
2003+
* The transaction height
2004+
*
2005+
* @generated from field: sint64 height = 3;
2006+
*/
2007+
height = protoInt64.zero;
2008+
19952009
constructor(data?: PartialMessage<CallResponse>) {
19962010
super();
19972011
proto3.util.initPartial(data, this);
@@ -2001,6 +2015,8 @@ export class CallResponse extends Message<CallResponse> {
20012015
static readonly typeName = "land.gno.gnonative.v1.CallResponse";
20022016
static readonly fields: FieldList = proto3.util.newFieldList(() => [
20032017
{ no: 1, name: "result", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
2018+
{ no: 2, name: "hash", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
2019+
{ no: 3, name: "height", kind: "scalar", T: 18 /* ScalarType.SINT64 */ },
20042020
]);
20052021

20062022
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): CallResponse {
@@ -2139,6 +2155,20 @@ export class SendRequest extends Message<SendRequest> {
21392155
* @generated from message land.gno.gnonative.v1.SendResponse
21402156
*/
21412157
export class SendResponse extends Message<SendResponse> {
2158+
/**
2159+
* The transaction hash
2160+
*
2161+
* @generated from field: bytes hash = 1;
2162+
*/
2163+
hash = new Uint8Array(0);
2164+
2165+
/**
2166+
* The transaction height
2167+
*
2168+
* @generated from field: sint64 height = 2;
2169+
*/
2170+
height = protoInt64.zero;
2171+
21422172
constructor(data?: PartialMessage<SendResponse>) {
21432173
super();
21442174
proto3.util.initPartial(data, this);
@@ -2147,6 +2177,8 @@ export class SendResponse extends Message<SendResponse> {
21472177
static readonly runtime: typeof proto3 = proto3;
21482178
static readonly typeName = "land.gno.gnonative.v1.SendResponse";
21492179
static readonly fields: FieldList = proto3.util.newFieldList(() => [
2180+
{ no: 1, name: "hash", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
2181+
{ no: 2, name: "height", kind: "scalar", T: 18 /* ScalarType.SINT64 */ },
21502182
]);
21512183

21522184
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): SendResponse {
@@ -2292,6 +2324,20 @@ export class RunResponse extends Message<RunResponse> {
22922324
*/
22932325
result = "";
22942326

2327+
/**
2328+
* The transaction hash
2329+
*
2330+
* @generated from field: bytes hash = 2;
2331+
*/
2332+
hash = new Uint8Array(0);
2333+
2334+
/**
2335+
* The transaction height
2336+
*
2337+
* @generated from field: sint64 height = 3;
2338+
*/
2339+
height = protoInt64.zero;
2340+
22952341
constructor(data?: PartialMessage<RunResponse>) {
22962342
super();
22972343
proto3.util.initPartial(data, this);
@@ -2301,6 +2347,8 @@ export class RunResponse extends Message<RunResponse> {
23012347
static readonly typeName = "land.gno.gnonative.v1.RunResponse";
23022348
static readonly fields: FieldList = proto3.util.newFieldList(() => [
23032349
{ no: 1, name: "result", kind: "scalar", T: 9 /* ScalarType.STRING */ },
2350+
{ no: 2, name: "hash", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
2351+
{ no: 3, name: "height", kind: "scalar", T: 18 /* ScalarType.SINT64 */ },
23042352
]);
23052353

23062354
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): RunResponse {
@@ -2481,7 +2529,7 @@ export class EstimateGasRequest extends Message<EstimateGasRequest> {
24812529

24822530
/**
24832531
* The security margin to apply to the estimated gas amount.
2484-
* This number is represents a decimal numeral value with two decimals precision, without the decimal separator. E.g. 1 means 0.01 and 10000 means 100.00.
2532+
* This number represents a decimal numeral value with two decimals precision, without the decimal separator. E.g. 1 means 0.01 and 10000 means 100.00.
24852533
* It will be multiplied by the estimated gas amount.
24862534
*
24872535
* @generated from field: uint32 security_margin = 3;
@@ -2637,6 +2685,20 @@ export class BroadcastTxCommitResponse extends Message<BroadcastTxCommitResponse
26372685
*/
26382686
result = new Uint8Array(0);
26392687

2688+
/**
2689+
* The transaction hash
2690+
*
2691+
* @generated from field: bytes hash = 2;
2692+
*/
2693+
hash = new Uint8Array(0);
2694+
2695+
/**
2696+
* The transaction height
2697+
*
2698+
* @generated from field: sint64 height = 3;
2699+
*/
2700+
height = protoInt64.zero;
2701+
26402702
constructor(data?: PartialMessage<BroadcastTxCommitResponse>) {
26412703
super();
26422704
proto3.util.initPartial(data, this);
@@ -2646,6 +2708,8 @@ export class BroadcastTxCommitResponse extends Message<BroadcastTxCommitResponse
26462708
static readonly typeName = "land.gno.gnonative.v1.BroadcastTxCommitResponse";
26472709
static readonly fields: FieldList = proto3.util.newFieldList(() => [
26482710
{ no: 1, name: "result", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
2711+
{ no: 2, name: "hash", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
2712+
{ no: 3, name: "height", kind: "scalar", T: 18 /* ScalarType.SINT64 */ },
26492713
]);
26502714

26512715
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): BroadcastTxCommitResponse {

api/gen/es/rpc_connect.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ export const GnoNativeService = {
372372
kind: MethodKind.Unary,
373373
},
374374
/**
375-
* EstimateGas estimate the least amount of gas required for the transaction to go through on the chain (minimum gas wanted), with a security margin.
375+
* EstimateGas estimates the least amount of gas required for the transaction to go through on the chain (minimum gas wanted), with a security margin.
376376
* If UpdateTx is true, then update the transaction with the gasWanted amount.
377377
*
378378
* @generated from rpc land.gno.gnonative.v1.GnoNativeService.EstimateGas

api/gen/go/_goconnect/rpc.connect.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)