LemonNekoGH / easinteraction-for-cadence

Easinteraction is a tool that help users to generate code for easier contract interaction.
https://docs.easi-gen.lemonneko.moe/
MIT License
6 stars 0 forks source link

Add nested type support: struct/resource methods #13

Closed LemonNekoGH closed 1 year ago

LemonNekoGH commented 1 year ago

Methods of nested struct or resource is for query script. Standalone call is unuseful because it will not chang Blockchain's state, should not generate go methods code for them.

LemonNekoGH commented 1 year ago

No that is incorrect, they can change Blockchain state, and they can get Blockchain state. There is a contract with a struct

pub contract Example {
  priv let name: String

  pub struct ExampleStruct {
    pub fun getName(): String {
      return Example.name // return blockchain state 🤯
    }

    pub fun setName(_ n: String) {
      Example.name = n // change blockchain state 🤯
    }
  }

  init() {
    self.name = ""
  }
}
LemonNekoGH commented 1 year ago

But how do we position the instance of struct/resource? We can only construct the type and invoke function...