Coder Social home page Coder Social logo

Comments (9)

petertonysmith94 avatar petertonysmith94 commented on September 26, 2024 1

Hey @luisburigo, hope you are well.

I have been playing around with your example (thank you btw), not 100% on the root cause just yet. I did find a potential workaround (hopefully it can unblock you).

abi ContractA {
  fn method(contract_b_id: ContractId);
}

impl ContractA for Contract {
  fn method(contract_b_id: ContractId) {
    let contract_b = abi(ContractB, contract_b_id.into());
    let result = contract_b.method();
  }
}

With the expected result of:

return new RequireRevertError(receipt, reason);
             ^
RequireRevertError: The script reverted with reason RequireFailed

from fuels-ts.

arboleya avatar arboleya commented on September 26, 2024 1

The issue is that we need the ABI of all contracts before being able to decode their logs. One suggested solution would be to, in case the ABI is missing and we can't decode logs, to just print a warning and move on instead of throwing.

This is subject to further analysis, of course.

from fuels-ts.

nedsalk avatar nedsalk commented on September 26, 2024 1

@luisburigo I just took a look at your code and you didn't add contract B into the call so the library doesn't know how to decode it. You should do this:

    const contractAAbi = ContractAAbi__factory.connect(contractA, wallet);
    const contractBAbi = ContractBAbi__factory.connect(contractB, wallet);
    const result = await contractAAbi.functions.method({
        value: contractB
    })
    .addContracts([contractBAbi]) //  <------- this was missing
    .txParams({
        gasPrice: 1,
        gasLimit: 1_000_000,
    })

from fuels-ts.

arboleya avatar arboleya commented on September 26, 2024 1

Can we close this?

from fuels-ts.

luisburigo avatar luisburigo commented on September 26, 2024

Repository to reproduce the error: https://github.com/luisburigo/fuel-ts-issue.git

from fuels-ts.

luisburigo avatar luisburigo commented on September 26, 2024

I debugged the code and found the error in this function:

export function getDecodedLogs<T = unknown>(
receipts: Array<TransactionResultReceipt>,
abiInterface: Interface
): T[] {
return receipts.reduce((logs: T[], r) => {
if (r.type === ReceiptType.LogData) {
logs.push(abiInterface.decodeLog(r.data, r.val1.toNumber(), r.id)[0]);
}
if (r.type === ReceiptType.Log) {
logs.push(abiInterface.decodeLog(new U64Coder().encode(r.val0), r.val1.toNumber(), r.id)[0]);
}
return logs;
}, []);

from fuels-ts.

luisburigo avatar luisburigo commented on September 26, 2024

Hey, @petertonysmith94 @arboleya thanks for the response.

This code in the description is just an example. In my contracts, I use the correct abi.

In this repo https://github.com/luisburigo/fuel-ts-issue there is an example of this bug.

from fuels-ts.

petertonysmith94 avatar petertonysmith94 commented on September 26, 2024

@luisburigo I just took a look at your code and you didn't add contract B into the call so the library doesn't know how to decode it. You should do this:

    const contractAAbi = ContractAAbi__factory.connect(contractA, wallet);
    const contractBAbi = ContractBAbi__factory.connect(contractB, wallet);
    const result = await contractAAbi.functions.method({
        value: contractB
    })
    .addContracts([contractBAbi]) //  <------- this was missing
    .txParams({
        gasPrice: 1,
        gasLimit: 1_000_000,
    })

Look at that, thanks for the share ❤️

Link to the documentation on inter-contract calls.

from fuels-ts.

luisburigo avatar luisburigo commented on September 26, 2024

@luisburigo I just took a look at your code and you didn't add contract B into the call so the library doesn't know how to decode it. You should do this:

    const contractAAbi = ContractAAbi__factory.connect(contractA, wallet);
    const contractBAbi = ContractBAbi__factory.connect(contractB, wallet);
    const result = await contractAAbi.functions.method({
        value: contractB
    })
    .addContracts([contractBAbi]) //  <------- this was missing
    .txParams({
        gasPrice: 1,
        gasLimit: 1_000_000,
    })

Look at that, thanks for the share ❤️

Link to the documentation on inter-contract calls.

Thanks @petertonysmith94 ❤️❤️

from fuels-ts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.