Skip to content

Commit 2a8de83

Browse files
D4ryl00jefft0
andauthored
feat: update gno dependency and add EstimateGas API function (#195)
fixes #9 The gno's EstimateGas function takes a signed transaction as a parameter. So we created a utility function in gnonative to temporarily sign a transaction to estimate the gas wanted value, then update the transaction's GasWanted field if asked by the front, with the given security margin. In this PR, I also removed the Buf's registry dependency for the expo code. Instead, we copy API files locally in a vendor directory. This PR updates our Gno dependency, which only compiles on 64-bit architecture. In this PR, I bumped goland to 1.23.x, so don't forget to do `asdf install`. --------- Signed-off-by: D4ryl00 <[email protected]> Co-authored-by: Jeff Thompson <[email protected]>
1 parent 0bb37cb commit 2a8de83

34 files changed

+4890
-4343
lines changed

.tool-versions

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ ruby 3.2.2
33
cocoapods 1.15.2
44
java openjdk-17.0.2
55
yarn 1.22.19
6-
golang 1.22.5
6+
golang 1.23.7
77
buf 1.39.0

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ $(gnocore_aar): $(bind_init_files) $(go_deps)
147147
$(gomobile) bind -v \
148148
-cache $(cache_dir)/android-gnonative \
149149
-javapkg=gnolang.gno \
150-
-o $@ -target android -androidapi 21 ./framework/service
150+
-o $@ -target android/arm64,android/amd64 -androidapi 21 ./framework/service
151151
_bind.clean.android:
152152
rm -rf $(gnocore_jar) $(gnocore_aar)
153153

api/gen/csharp/Gnonativetypes.cs

Lines changed: 683 additions & 30 deletions
Large diffs are not rendered by default.

api/gen/csharp/Rpc.cs

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ static RpcReflection() {
4545
"ARIZChRFcnJUb29NYW55U2lnbmF0dXJlcxDWARIUCg9FcnJOb1NpZ25hdHVy",
4646
"ZXMQ1wESEwoORXJyR2FzT3ZlcmZsb3cQ2AESFgoRRXJySW52YWxpZFBrZ1Bh",
4747
"dGgQ2QESEwoORXJyS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RvMw=="));
132134
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
133135
new pbr::FileDescriptor[] { global::Land.Gno.Gnonative.V1.GnonativetypesReflection.Descriptor, },
134136
new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Land.Gno.Gnonative.V1.ErrCode), }, null, new pbr::GeneratedClrTypeInfo[] {

api/gen/csharp/RpcGrpc.cs

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,10 @@ static T __Helper_DeserializeMessage<T>(grpc::DeserializationContext context, gl
151151
[global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)]
152152
static readonly grpc::Marshaller<global::Land.Gno.Gnonative.V1.MakeTxResponse> __Marshaller_land_gno_gnonative_v1_MakeTxResponse = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Land.Gno.Gnonative.V1.MakeTxResponse.Parser));
153153
[global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)]
154+
static readonly grpc::Marshaller<global::Land.Gno.Gnonative.V1.EstimateGasRequest> __Marshaller_land_gno_gnonative_v1_EstimateGasRequest = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Land.Gno.Gnonative.V1.EstimateGasRequest.Parser));
155+
[global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)]
156+
static readonly grpc::Marshaller<global::Land.Gno.Gnonative.V1.EstimateGasResponse> __Marshaller_land_gno_gnonative_v1_EstimateGasResponse = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Land.Gno.Gnonative.V1.EstimateGasResponse.Parser));
157+
[global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)]
154158
static readonly grpc::Marshaller<global::Land.Gno.Gnonative.V1.SignTxRequest> __Marshaller_land_gno_gnonative_v1_SignTxRequest = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Land.Gno.Gnonative.V1.SignTxRequest.Parser));
155159
[global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)]
156160
static readonly grpc::Marshaller<global::Land.Gno.Gnonative.V1.SignTxResponse> __Marshaller_land_gno_gnonative_v1_SignTxResponse = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Land.Gno.Gnonative.V1.SignTxResponse.Parser));
@@ -403,6 +407,14 @@ static T __Helper_DeserializeMessage<T>(grpc::DeserializationContext context, gl
403407
__Marshaller_land_gno_gnonative_v1_RunRequest,
404408
__Marshaller_land_gno_gnonative_v1_MakeTxResponse);
405409

410+
[global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)]
411+
static readonly grpc::Method<global::Land.Gno.Gnonative.V1.EstimateGasRequest, global::Land.Gno.Gnonative.V1.EstimateGasResponse> __Method_EstimateGas = new grpc::Method<global::Land.Gno.Gnonative.V1.EstimateGasRequest, global::Land.Gno.Gnonative.V1.EstimateGasResponse>(
412+
grpc::MethodType.Unary,
413+
__ServiceName,
414+
"EstimateGas",
415+
__Marshaller_land_gno_gnonative_v1_EstimateGasRequest,
416+
__Marshaller_land_gno_gnonative_v1_EstimateGasResponse);
417+
406418
[global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)]
407419
static readonly grpc::Method<global::Land.Gno.Gnonative.V1.SignTxRequest, global::Land.Gno.Gnonative.V1.SignTxResponse> __Method_SignTx = new grpc::Method<global::Land.Gno.Gnonative.V1.SignTxRequest, global::Land.Gno.Gnonative.V1.SignTxResponse>(
408420
grpc::MethodType.Unary,
@@ -857,6 +869,19 @@ public abstract partial class GnoNativeServiceBase
857869
throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, ""));
858870
}
859871

872+
/// <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.
874+
/// If UpdateTx is true, then update the transaction with the gasWanted amount.
875+
/// </summary>
876+
/// <param name="request">The request received from the client.</param>
877+
/// <param name="context">The context of the server-side call handler being invoked.</param>
878+
/// <returns>The response to send back to the client (wrapped by a task).</returns>
879+
[global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)]
880+
public virtual global::System.Threading.Tasks.Task<global::Land.Gno.Gnonative.V1.EstimateGasResponse> EstimateGas(global::Land.Gno.Gnonative.V1.EstimateGasRequest request, grpc::ServerCallContext context)
881+
{
882+
throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, ""));
883+
}
884+
860885
/// <summary>
861886
/// Sign the transaction using the account with the given address.
862887
/// If there is no activated account with the given address, return [ErrCode](#land.gno.gnonative.v1.ErrCode).ErrNoActiveAccount.
@@ -2427,6 +2452,58 @@ protected GnoNativeServiceClient(ClientBaseConfiguration configuration) : base(c
24272452
return CallInvoker.AsyncUnaryCall(__Method_MakeRunTx, null, options, request);
24282453
}
24292454
/// <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.
2456+
/// If UpdateTx is true, then update the transaction with the gasWanted amount.
2457+
/// </summary>
2458+
/// <param name="request">The request to send to the server.</param>
2459+
/// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
2460+
/// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
2461+
/// <param name="cancellationToken">An optional token for canceling the call.</param>
2462+
/// <returns>The response received from the server.</returns>
2463+
[global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)]
2464+
public virtual global::Land.Gno.Gnonative.V1.EstimateGasResponse EstimateGas(global::Land.Gno.Gnonative.V1.EstimateGasRequest request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken))
2465+
{
2466+
return EstimateGas(request, new grpc::CallOptions(headers, deadline, cancellationToken));
2467+
}
2468+
/// <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.
2470+
/// If UpdateTx is true, then update the transaction with the gasWanted amount.
2471+
/// </summary>
2472+
/// <param name="request">The request to send to the server.</param>
2473+
/// <param name="options">The options for the call.</param>
2474+
/// <returns>The response received from the server.</returns>
2475+
[global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)]
2476+
public virtual global::Land.Gno.Gnonative.V1.EstimateGasResponse EstimateGas(global::Land.Gno.Gnonative.V1.EstimateGasRequest request, grpc::CallOptions options)
2477+
{
2478+
return CallInvoker.BlockingUnaryCall(__Method_EstimateGas, null, options, request);
2479+
}
2480+
/// <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.
2482+
/// If UpdateTx is true, then update the transaction with the gasWanted amount.
2483+
/// </summary>
2484+
/// <param name="request">The request to send to the server.</param>
2485+
/// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
2486+
/// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
2487+
/// <param name="cancellationToken">An optional token for canceling the call.</param>
2488+
/// <returns>The call object.</returns>
2489+
[global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)]
2490+
public virtual grpc::AsyncUnaryCall<global::Land.Gno.Gnonative.V1.EstimateGasResponse> EstimateGasAsync(global::Land.Gno.Gnonative.V1.EstimateGasRequest request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken))
2491+
{
2492+
return EstimateGasAsync(request, new grpc::CallOptions(headers, deadline, cancellationToken));
2493+
}
2494+
/// <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.
2496+
/// If UpdateTx is true, then update the transaction with the gasWanted amount.
2497+
/// </summary>
2498+
/// <param name="request">The request to send to the server.</param>
2499+
/// <param name="options">The options for the call.</param>
2500+
/// <returns>The call object.</returns>
2501+
[global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)]
2502+
public virtual grpc::AsyncUnaryCall<global::Land.Gno.Gnonative.V1.EstimateGasResponse> EstimateGasAsync(global::Land.Gno.Gnonative.V1.EstimateGasRequest request, grpc::CallOptions options)
2503+
{
2504+
return CallInvoker.AsyncUnaryCall(__Method_EstimateGas, null, options, request);
2505+
}
2506+
/// <summary>
24302507
/// Sign the transaction using the account with the given address.
24312508
/// If there is no activated account with the given address, return [ErrCode](#land.gno.gnonative.v1.ErrCode).ErrNoActiveAccount.
24322509
/// If the password is wrong, return [ErrCode](#land.gno.gnonative.v1.ErrCode).ErrDecryptionFailed.
@@ -2764,6 +2841,7 @@ protected override GnoNativeServiceClient NewInstance(ClientBaseConfiguration co
27642841
.AddMethod(__Method_MakeCallTx, serviceImpl.MakeCallTx)
27652842
.AddMethod(__Method_MakeSendTx, serviceImpl.MakeSendTx)
27662843
.AddMethod(__Method_MakeRunTx, serviceImpl.MakeRunTx)
2844+
.AddMethod(__Method_EstimateGas, serviceImpl.EstimateGas)
27672845
.AddMethod(__Method_SignTx, serviceImpl.SignTx)
27682846
.AddMethod(__Method_BroadcastTxCommit, serviceImpl.BroadcastTxCommit)
27692847
.AddMethod(__Method_AddressToBech32, serviceImpl.AddressToBech32)
@@ -2808,6 +2886,7 @@ public static void BindService(grpc::ServiceBinderBase serviceBinder, GnoNativeS
28082886
serviceBinder.AddMethod(__Method_MakeCallTx, serviceImpl == null ? null : new grpc::UnaryServerMethod<global::Land.Gno.Gnonative.V1.CallRequest, global::Land.Gno.Gnonative.V1.MakeTxResponse>(serviceImpl.MakeCallTx));
28092887
serviceBinder.AddMethod(__Method_MakeSendTx, serviceImpl == null ? null : new grpc::UnaryServerMethod<global::Land.Gno.Gnonative.V1.SendRequest, global::Land.Gno.Gnonative.V1.MakeTxResponse>(serviceImpl.MakeSendTx));
28102888
serviceBinder.AddMethod(__Method_MakeRunTx, serviceImpl == null ? null : new grpc::UnaryServerMethod<global::Land.Gno.Gnonative.V1.RunRequest, global::Land.Gno.Gnonative.V1.MakeTxResponse>(serviceImpl.MakeRunTx));
2889+
serviceBinder.AddMethod(__Method_EstimateGas, serviceImpl == null ? null : new grpc::UnaryServerMethod<global::Land.Gno.Gnonative.V1.EstimateGasRequest, global::Land.Gno.Gnonative.V1.EstimateGasResponse>(serviceImpl.EstimateGas));
28112890
serviceBinder.AddMethod(__Method_SignTx, serviceImpl == null ? null : new grpc::UnaryServerMethod<global::Land.Gno.Gnonative.V1.SignTxRequest, global::Land.Gno.Gnonative.V1.SignTxResponse>(serviceImpl.SignTx));
28122891
serviceBinder.AddMethod(__Method_BroadcastTxCommit, serviceImpl == null ? null : new grpc::ServerStreamingServerMethod<global::Land.Gno.Gnonative.V1.BroadcastTxCommitRequest, global::Land.Gno.Gnonative.V1.BroadcastTxCommitResponse>(serviceImpl.BroadcastTxCommit));
28132892
serviceBinder.AddMethod(__Method_AddressToBech32, serviceImpl == null ? null : new grpc::UnaryServerMethod<global::Land.Gno.Gnonative.V1.AddressToBech32Request, global::Land.Gno.Gnonative.V1.AddressToBech32Response>(serviceImpl.AddressToBech32));

0 commit comments

Comments
 (0)