Closed kazai777 closed 6 months ago
Hi @kazai777. Resolve
is a function in the users realm, not a method on the struct from the users package.
https://github.com/gnolang/gno/blob/master/examples/gno.land/r/demo/users/users.gno#L238
Also, importing both the users realm and package should be fine -- you'll just need to alias one of the names to avoid a conflict. I think something like this is what you're looking for.
package ethtoken
import (
"gno.land/p/demo/grc/grc20"
"gno.land/p/demo/ufmt"
"gno.land/p/demo/users"
usersRealm "gno.land/r/demo/users"
"std"
)
var (
ethtoken *grc20.AdminToken
admin std.Address
)
func init() {
ethtoken = grc20.NewAdminToken("Ethereum", "ETH", 4)
ethtoken.Mint(std.GetOrigCaller(), 1000000000)
}
func TotalSupply() uint64 {
return ethtoken.TotalSupply()
}
func BalanceOf(owner users.AddressOrName) uint64 {
balance, err := ethtoken.BalanceOf(usersRealm.Resolve(owner))
if err != nil {
panic(err)
}
return balance
}
Thank you @deelawn for your answer.
[name AddressOrName not declared]
Description
Hi, I have an error with the import of the realm 'users' in local environment. This problem does not occur when I use the 'gno playground'.
Your environment
Actual behaviour
When I use the
AddressOrName()
that I use with the realm importgno.land/r/demo/users
I get the error below. But if I import thegno.land/p/demo/users
package, I no longer get this error. The problem is that if my realm uses functions from both the realm and the users package I'm stuck, because I can't import both, and importing only the users realm doesn't seem to give access to the users package functions. I don't get this error on the 'gno playground' using the same code.Logs
My code
My gno.mod