Skip to content

Commit

Permalink
[APP] chainlist api rollback
Browse files Browse the repository at this point in the history
  • Loading branch information
Kwonhyukjoon committed Oct 27, 2023
1 parent 5528884 commit 492026b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 36 deletions.
45 changes: 16 additions & 29 deletions app/src/main/java/wannabit/io/cosmostaion/dao/Param.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,24 @@ public class Param {
@SerializedName("block_time")
public Double block_time;

@SerializedName("gas_price")
public GasPrice mGasPrice;

@SerializedName("params")
public Params mParams;

public class GasPrice {
@SerializedName("chain")
public String chain;

@SerializedName("base")
public String base;

@SerializedName("rate")
public ArrayList<String> rate;
}

public class Params {
@SerializedName("chainlist_params")
public ChainListParam mChainListParam;

@SerializedName("iris_minting_params")
public IrisMintingParams mIrisMintingParams;
Expand Down Expand Up @@ -510,8 +522,8 @@ public int getUnbonding(BaseChain baseChain) {
}

public ArrayList<String> getGasRate() {
if (mParams.mChainListParam != null && mParams.mChainListParam.fee != null) {
return mParams.mChainListParam.fee.rate;
if (mGasPrice != null && mGasPrice.rate.size() > 0) {
return mGasPrice.rate;
}
return null;
}
Expand Down Expand Up @@ -543,31 +555,6 @@ public BigDecimal getVetoThreshold(ChainConfig chainConfig) {
return BigDecimal.ZERO;
}

public class ChainListParam {
@SerializedName("fee")
public Fee fee;

@SerializedName("isSimulable")
public Boolean isSimulable;

@SerializedName("simul_gas_multiply")
public String simulGasMultiply;

@SerializedName("fee_threshold")
public String feeThreshold;

@SerializedName("endpoint_url")
public ArrayList<String> endpointUrlList;

public class Fee {
@SerializedName("base")
public String base;

@SerializedName("rate")
public ArrayList<String> rate;
}
}

public class IrisMintingParams {
@SerializedName("result")
public Result mResult;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,13 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
btnTxt.setText(mFeeInfo.get(i).title);
}

if (getBaseDao().mParam != null && getBaseDao().mParam.mParams != null && getBaseDao().mParam.mParams.mChainListParam != null) {
mSelectedFeeInfo = Integer.parseInt(getBaseDao().mParam.mParams.mChainListParam.fee.base);
if (getBaseDao().mParam != null && getBaseDao().mParam.mGasPrice != null && getBaseDao().mParam.mGasPrice.base != null) {
mSelectedFeeInfo = Integer.parseInt(getBaseDao().mParam.mGasPrice.base);
}

mButtonGroup.setPosition(mSelectedFeeInfo, false);
mButtonGroup.setOnPositionChangedListener(position -> {
if (mChainConfig.baseChain().equals(BaseChain.ASSETMANTLE_MAIN)) { return; }
mSelectedFeeInfo = position;
onCalculateFees();
onCheckTxType();
Expand Down Expand Up @@ -278,14 +279,13 @@ private void onUpdateView() {

@Override
public void onRefreshTab() {
if (getBaseDao().mParam.mParams.mChainListParam.isSimulable) {
onCheckTxType();
} else {
if (mChainConfig.baseChain().equals(BaseChain.ASSETMANTLE_MAIN)) {
onUpdateView();
WDp.setDpCoin(getActivity(), getBaseDao(), mChainConfig, mFee.amount.get(0), mGasDenom, mGasAmount);
mSimulPassed = true;
return;
}
onCheckTxType();
}

@Override
Expand Down Expand Up @@ -561,7 +561,11 @@ public void onTaskResponse(TaskResult result) {
} else {
Abci.GasInfo gasInfo = ((Abci.GasInfo) result.resultData);
long gasused = gasInfo.getGasUsed();
mFeeGasAmount = new BigDecimal((long) ((double) gasused * Double.parseDouble(getBaseDao().mParam.mParams.mChainListParam.simulGasMultiply)));
if (mChainConfig.baseChain().equals(BaseChain.IXO_MAIN)) {
mFeeGasAmount = new BigDecimal((long) ((double) gasused * 3d));
} else {
mFeeGasAmount = new BigDecimal((long) ((double) gasused * 1.5d));
}
}
mSimulPassed = true;
Toast.makeText(getContext(), getString(R.string.str_gas_checked), Toast.LENGTH_SHORT).show();
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/wannabit/io/cosmostaion/utils/WDp.java
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ public static ArrayList<FeeInfo> getFeeInfos(Context c, BaseData baseData) {

public static boolean isTxFeePayable(Context c, BaseData baseData, ChainConfig chainConfig) {
if (isGRPC(chainConfig.baseChain())) {
if (baseData == null || baseData.mParam == null || baseData.mParam.mParams.mChainListParam == null) return false;
if (baseData == null || baseData.mParam == null || baseData.mParam.mGasPrice == null) return false;

if (chainConfig.baseChain().equals(SIF_MAIN)) {
if (new BigDecimal("100000000000000000").compareTo(baseData.getAvailable(chainConfig.mainDenom())) < 0) {
Expand Down

0 comments on commit 492026b

Please sign in to comment.