Skip to content

Commit

Permalink
refactor: ConvertGasToZeta RPC now takes chainID instead chainName st…
Browse files Browse the repository at this point in the history
…ring.

This is more precise and less ambiguous.
  • Loading branch information
brewmaster012 committed Jul 25, 2023
1 parent 8f3a7e1 commit e997a2d
Show file tree
Hide file tree
Showing 3 changed files with 134 additions and 150 deletions.
2 changes: 1 addition & 1 deletion proto/crosschain/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ message QueryLastZetaHeightResponse {
}

message QueryConvertGasToZetaRequest {
string chain = 1;
int64 chainId = 1;
string gasLimit = 2;
}

Expand Down
6 changes: 3 additions & 3 deletions x/crosschain/keeper/zeta_conversion_rate.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (

func (k Keeper) ConvertGasToZeta(context context.Context, request *types.QueryConvertGasToZetaRequest) (*types.QueryConvertGasToZetaResponse, error) {
ctx := sdk.UnwrapSDKContext(context)
chainName := common.ParseChainName(request.Chain)
chain := k.zetaObserverKeeper.GetParams(ctx).GetChainFromChainName(chainName)
chain := common.GetChainFromChainID(request.ChainId)

if chain == nil {
return nil, zetaObserverTypes.ErrSupportedChains
}
Expand All @@ -24,7 +24,7 @@ func (k Keeper) ConvertGasToZeta(context context.Context, request *types.QueryCo
return nil, status.Error(codes.InvalidArgument, "invalid request: param chain")
}
gasLimit := math.NewUintFromString(request.GasLimit)
outTxGasFee := medianGasPrice.Mul(gasLimit)
outTxGasFee := medianGasPrice.Mul(gasLimit).MulUint64(2) //FIXME: parameterize this to sync with where this fee is charged
zrc20, err := k.fungibleKeeper.QuerySystemContractGasCoinZRC20(ctx, big.NewInt(chain.ChainId))
if err != nil {
return nil, status.Error(codes.NotFound, "zrc20 not found")
Expand Down
Loading

0 comments on commit e997a2d

Please sign in to comment.