Giter Club home page Giter Club logo

Comments (2)

omerfirmak avatar omerfirmak commented on June 16, 2024 1

I am working on this for Juno.

I started writing Rust just yesterday, so this might be dumb. But I am wondering if it makes sense to constraint the trait to return &Felt.

Juno exports C symbols that Rust can call.

extern {
    fn JunoStateGetStorageAt(reader_handle: usize, contract_address: *const c_uchar,
                             storage_location: *const c_uchar) -> *const c_uchar;
}

and the reader implementation does some type conversions only and isn't stateful.

    fn get_storage_at(&mut self, storage_entry: &StorageEntry) -> Result<&Felt, StateError> {
        let addr = feltToJunoFelt(&storage_entry.0.0);
        let val = unsafe { JunoStateGetStorageAt(self.0, addr.as_ptr(), storage_entry.1.as_ptr()) };
        if val.is_null() {
            return Err(StateError::NoneContractState(storage_entry.0.clone()));
        }


        return Ok(&junoFeltToFelt(val))
    }

but since we are expected to return a borrowed value, we can't get away with just being a bridge and should have a storage of some sort to keep the Felts around. Even if it does have a storage, it wouldnt know when to clear a value from the storage, right?

My question is wouldn't returning a Felt here make more sense?

from starknet_in_rust.

antiyro avatar antiyro commented on June 16, 2024

#122

from starknet_in_rust.

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.