Get error when try to add contract to other contract call

I updated SwayLend market contract to latest versions and also to beta 4. I have function on frontend that check MaxBorrowAmount from contract state, on previous beta3 I was using this code to be able to get value

 updateMaxBorrowAmount = async (marketContract: MarketAbi) => {
    const { addressInput } = this.rootStore.accountStore;
    if (addressInput == null) return;
    const { priceOracle } = this.rootStore.settingsStore.currentVersionConfig;
    const oracle = new Contract(
    const { value } = await marketContract.functions
      .txParams({ gasLimit: (1e8).toString() })
    this.setMaxBorrowBaseTokenAmount(new BN(value.toString()));

Contract abis are here:

But after update it started to fail with next error:

Did way how to connect other contract change?

There’s something failing on the transaction simulation since “decodeCallResult” is throwing an error.

However, the error wrapper is falling to catch an undefined value in the Transaction result. This might be an issue beyond your specific case. I’ll escalate this.

Meanwhile, I recommend you to set “txParams.gasLimit” as a number rather than an string. I don’t see anything else that might be wrong with your transaction simulation.

@sway There seems to be a bug in our revert reason-parsing logic for the simulate function. I’ll file an issue for this.

Instead of simulate-ing, if you call this transaction - do you see a revert reason?

Please also make sure that you specified/initialized the storageSlots when you deployed your contract. I was facing a similar issue this morning and it was fixed once I deployed the contract with storageSlots specified

1 Like

Thanks for the suggestion but in my contract I have everywhere catches that would prevent failing if the variable is not initialized, like below.

let balance = storage.user_collateral.get((account, asset_config.asset_id)).try_read().unwrap_or(0);

Also would like to notify you that the Rust tests are passing successfully for this contract, we just have some problems with typescript SDK due to updates

But it’s really interesting to hear about how to initialize storage slots, probably it will make my contract cleaner, please have a look at new topic here

Changed into number and also tried to make call, it still fails

Hi there!
I’ll scalate this issue.

Follow-up issue:

1 Like

An issue for the “out of gas” error was opened as well.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.