Giter Club home page Giter Club logo

Comments (1)

evan-schott avatar evan-schott commented on September 21, 2024

Thank you for pointing this out! One of the main aims of the recently merged Futures PR is to provide more intuitive syntax for situations like this. This fix is already applied in the mainnet branch and will be a part of the next leo release.

To provide some clarity, in this case the error is caused because c.aleo/foobar does not infer that b.aleo/bar has on-chain logic. On the other hand, b.aleo/bar is able to infer that it has on-chain logic since the nested call to a.aleo/bar has an attached finalize scope.

The new futures syntax requires all transitions and functions that interact with on-chain state to be labeled as async. Async functions contain the on-chain logic (previously labeled as finalize), and async transitions call the async functions just as transitions used to call finalizes of the same name.

Our hope is that this syntax makes it more clear that if a nested call has on-chain logic, then all external transitions that call it must also have on-chain logic. Here is your example translated to the new syntax.

Let me know if you have any questions.

// The 'a' program.
program a.aleo {

    mapping dummy: bool => u8;

    async transition bar(x: u8) -> Future {
        return finalize_bar(x);
    }

    async function finalize_bar(x: u8) {
        Mapping::set(dummy, true, x);
    }
}


import a.aleo;

// The 'b' program.
program b.aleo {
    
    transition foo() -> u8 {
        return 0u8;
    }

    async transition bar(x: u8) -> Future {
        return finalize_bar(a.aleo/bar(x));
    }

    async function finalize_bar(f: Future) {
        f.await();
    }
}

import a.aleo;
import b.aleo;

// The 'c' program.
program c.aleo {
    async transition foobar() -> Future {
        let x: u8 = b.aleo/foo();
        return finalize_foobar(b.aleo/bar(x));
    }

    async function finalize_foobar(f: Future) {
        f.await();
    }
}

from leo.

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.