Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable referencing chain extension methods from separate file #1719

Open
cmichi opened this issue Mar 17, 2023 · 1 comment
Open

Enable referencing chain extension methods from separate file #1719

cmichi opened this issue Mar 17, 2023 · 1 comment
Labels
A-ink_lang [ink_lang] Work item B-research Research task that has open questions that need to be resolved.

Comments

@cmichi
Copy link
Collaborator

cmichi commented Mar 17, 2023

Escalated from this StackExchange question.

It could be that this issue is solved "automatically" with #259, but I'm not sure.

Description

We should make it possible to reference a chain extension method in a separate file.

For example, it should be possible to modify our rand-extension example in roughly the following way.

The following is only pseudo-code to explain what should be possible in the big picture. The API and types have to be figured out by whoever implements this ticket. The code does not work at this time.

(1) Add mod utils; to rand-extension/lib.rs.

(2) The fn update in lib.rs should be modified:

-            let new_random = self.env().extension().fetch_random(subject)?;
+            let new_random = crate::utils::new_random(&self.env().extension(), subject);

(3) Create a file utils.rs:

pub fn new_random(rand_extension_instance: &FetchRandomInstance, subject: [u8; 32]) -> [u8; 32]
where
{
    rand_extension_instance.fetch_random(subject).unwrap()
}
@cmichi cmichi added A-ink_lang [ink_lang] Work item B-research Research task that has open questions that need to be resolved. labels Mar 17, 2023
@xgreenx
Copy link
Collaborator

xgreenx commented Mar 19, 2023

On the way to solving the #259, we need to solve this problem=) I created a separate task to track it #1722

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ink_lang [ink_lang] Work item B-research Research task that has open questions that need to be resolved.
Projects
None yet
Development

No branches or pull requests

2 participants