zink icon indicating copy to clipboard operation
zink copied to clipboard

Introduce program interface of zink contracts

Open clearloop opened this issue 11 months ago • 0 comments

Describe the feature

as we can see in the current addition test, calling with ABI has really bad experience in developing

it should be just

let info = contract.addition(1u64, 1u64);

for reaching this goal, we need to generate contract CPIs in zink proc-macros,

#[zink::contract]
impl Addition {
  pub fn addition(&self, x: u64, y: u64) -> u64 {
    x + y
  }
}

// which generates
struct Addition {
  source_bytecode: Vec<u8>,
  vm: EVM
}

impl Addition {
   pub fn addition(&mut self, x: u64, y: u64) -> Result<Info<u64>> {
        // sth like below
         self.evm.execute([
          "addition(uint64,uint64)".as_bytes(),
          &x.to_bytes32(),
          &y.to_bytes32(),
        ])
   }
}

Solution

No response

clearloop avatar Nov 03 '24 12:11 clearloop