|
|
|
|
@@ -85,7 +85,7 @@ func (c *estimateTransferFeeCommand) Execute(ctx context.Context, req *chainv1.E
|
|
|
|
|
return gsresponse.InvalidArgument[chainv1.EstimateTransferFeeResponse](c.deps.Logger, mservice.ChainGateway, err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
feeMoney, err := estimateNetworkFee(ctx, c.deps.Logger, networkCfg, sourceWallet, destinationAddress, amount)
|
|
|
|
|
feeMoney, err := estimateNetworkFee(ctx, c.deps.Logger, networkCfg, c.deps.RPCTimeout, sourceWallet, destinationAddress, amount)
|
|
|
|
|
if err != nil {
|
|
|
|
|
c.deps.Logger.Warn("fee estimation failed", zap.Error(err))
|
|
|
|
|
return gsresponse.Auto[chainv1.EstimateTransferFeeResponse](c.deps.Logger, mservice.ChainGateway, err)
|
|
|
|
|
@@ -98,7 +98,7 @@ func (c *estimateTransferFeeCommand) Execute(ctx context.Context, req *chainv1.E
|
|
|
|
|
return gsresponse.Success(resp)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func estimateNetworkFee(ctx context.Context, logger mlogger.Logger, network shared.Network, wallet *model.ManagedWallet, destination string, amount *moneyv1.Money) (*moneyv1.Money, error) {
|
|
|
|
|
func estimateNetworkFee(ctx context.Context, logger mlogger.Logger, network shared.Network, timeout time.Duration, wallet *model.ManagedWallet, destination string, amount *moneyv1.Money) (*moneyv1.Money, error) {
|
|
|
|
|
rpcURL := strings.TrimSpace(network.RPCURL)
|
|
|
|
|
if rpcURL == "" {
|
|
|
|
|
return nil, merrors.InvalidArgument("network rpc url not configured")
|
|
|
|
|
@@ -122,7 +122,6 @@ func estimateNetworkFee(ctx context.Context, logger mlogger.Logger, network shar
|
|
|
|
|
}
|
|
|
|
|
defer client.Close()
|
|
|
|
|
|
|
|
|
|
timeout := c.deps.RPCTimeout
|
|
|
|
|
if timeout <= 0 {
|
|
|
|
|
timeout = 15 * time.Second
|
|
|
|
|
}
|
|
|
|
|
|