这是indexloc提供的服务,不要输入任何密码
Skip to content

Refactor the import macro for foreign language contract integration #313

@clearloop

Description

@clearloop

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions