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

GnoVM: Expose methods of exported struct variables to the MsgCall API #2835

Open
leohhhn opened this issue Sep 23, 2024 · 0 comments
Open

GnoVM: Expose methods of exported struct variables to the MsgCall API #2835

leohhhn opened this issue Sep 23, 2024 · 0 comments
Labels
📦 ⛰️ gno.land Issues or PRs gno.land package related 📦 🤖 gnovm Issues or PRs gnovm related

Comments

@leohhhn
Copy link
Contributor

leohhhn commented Sep 23, 2024

Description

If a realm has an exported variable of a custom struct type, which has exported methods with primitive arguments on it, these methods should be exposed to the MsgCall API in the following way:

package rlm 
// pkgpath is gno.land/r/leon/rlm

type Foo struct {
	num int
}

var MyFoo = &Foo{ num: 0 }

func (f *Foo) UpdateNum(newNum int) { // should be exposed
	f.num = newNum
}

func (f *Foo) unexportedMethod() { // should not be exposed
	...
}

func (f *Foo) ExportedComplexArgMethod(slice []*int) { // should not be exposed
	...
}

Users should be able to call the UpdateNum method like so:

gnokey maketx call -good-flag-name "gno.land/r/leon/rlm.MyFoo.UpdateNum" -arg "2" 

while not being able to call MyFoo.unexportedMethod() & MyFoo.ExportedComplexArgMethod().

The other issue is how to manage flags in gnokey; currently, the pkgpath and func flags are separate. Another semantic issue is that there is a distinction between functions and methods. Possibly, this can be solved with an -endpoint flag, which could have this usage:

gnokey maketx call -endpoint "gno.land/r/leon/rlm.MyFoo.UpdateNum" -arg "2"

I am not sure that this is the right way to use it in gnokey, so I am open to other suggestions.

@leohhhn leohhhn added 📦 🤖 gnovm Issues or PRs gnovm related 📦 ⛰️ gno.land Issues or PRs gno.land package related labels Sep 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 ⛰️ gno.land Issues or PRs gno.land package related 📦 🤖 gnovm Issues or PRs gnovm related
Projects
Status: Triage
Development

No branches or pull requests

1 participant