Skip to content

Refactor the import macro for foreign language contract integration #313

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

Open
clearloop opened this issue Mar 15, 2025 · 0 comments
Open

Comments

@clearloop
Copy link
Member

clearloop commented Mar 15, 2025

the import! macro located in /crates/zink/abi/abi_macro, is currently written for tests, based on the logic of parsing ABI into rust signatures, we'd introduce the interface of foreign language integration with it

// struct Foo(Address);
import!("Foo", "../foo.json")

// we haven't had this interface yet but let's assume we have
struct MyContract {
  foo: Foo, // this is the address of Foo 
};

impl MyContract {
   fn get_bar(&self) -> i32 {
      // run contract call
      //
      // evm::contract_all(
      //   address: foo.address, 
      //    method: "bar", 
      //    args: []
      // );
      self.foo.bar()
   }
}

contracts with this macro would be pretty like the -sys crates in rust, we can simply wrap some ABIs and make them a zink library, for example, we can wrap the whole openzepplin libraries for zink contracts to use, and as a result, for calling these libraries, we can keep our interface, like

use foo_zsys::Foo;

struct MyContract {
  foo: Foo,
}

// ...

which would be the same calling a contract written in zink!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

1 participant