Skip to content

Commit

Permalink
chore: more comments
Browse files Browse the repository at this point in the history
  • Loading branch information
r3v4s committed Feb 19, 2024
1 parent 1a0c567 commit 2cc6fe2
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 17 deletions.
16 changes: 8 additions & 8 deletions _setup/gnft/gnft.gno
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func mintNNFT(owner std.Address, n uint64) {
func BalanceOf(user users.AddressOrName) uint64 {
balance, err := nft.BalanceOf(user.Resolve())
if err != nil {
panic(err)
panic(err.Error())
}

return balance
Expand All @@ -42,7 +42,7 @@ func BalanceOf(user users.AddressOrName) uint64 {
func OwnerOf(tid grc721.TokenID) std.Address {
owner, err := nft.OwnerOf(tid)
if err != nil {
panic(err)
panic(err.Error())
}

return owner
Expand All @@ -56,7 +56,7 @@ func GetApproved(tid grc721.TokenID) (std.Address, bool) {
addr, err := nft.GetApproved(tid)
if err != nil {
return "", false
// panic(err)
// panic(err.Error())
}

return addr, true
Expand All @@ -67,21 +67,21 @@ func GetApproved(tid grc721.TokenID) (std.Address, bool) {
func Approve(user users.AddressOrName, tid grc721.TokenID) {
err := nft.Approve(user.Resolve(), tid)
if err != nil {
panic(err)
panic(err.Error())
}
}

func SetApprovalForAll(user users.AddressOrName, approved bool) {
err := nft.SetApprovalForAll(user.Resolve(), approved)
if err != nil {
panic(err)
panic(err.Error())
}
}

func TransferFrom(from, to users.AddressOrName, tid grc721.TokenID) {
err := nft.TransferFrom(from.Resolve(), to.Resolve(), tid)
if err != nil {
panic(err)
panic(err.Error())
}
}

Expand All @@ -93,7 +93,7 @@ func Mint(to users.AddressOrName, tid grc721.TokenID) {
assertIsAdmin(caller)
err := nft.Mint(to.Resolve(), tid)
if err != nil {
panic(err)
panic(err.Error())
}
}

Expand All @@ -103,7 +103,7 @@ func Burn(tid grc721.TokenID) {
assertIsAdmin(caller)
err := nft.Burn(tid)
if err != nil {
panic(err)
panic(err.Error())
}
}

Expand Down
6 changes: 3 additions & 3 deletions _setup/gns/gns.gno
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ var (
)

const (
admin std.Address = "g12l9splsyngcgefrwa52x5a7scc29e9v086m6p4" // r3v4_xxx: CHANGE WHEN DEPLOYING TO OFFICIAL NETWORK
INTERNAL_REWARD_ACCOUNT std.Address = "g1paqttvcjcluuya9n9twyw7yacv54mt7ld3gvzm" // r3v4_xxx: CHANGE WHEN DEPLOYING TO OFFICIAL NETWORK
admin std.Address = "g12l9splsyngcgefrwa52x5a7scc29e9v086m6p4" // GSA, r3v4_xxx: CHANGE WHEN DEPLOYING TO OFFICIAL NETWORK
INTERNAL_REWARD_ACCOUNT std.Address = "g1paqttvcjcluuya9n9twyw7yacv54mt7ld3gvzm" // IRA, r3v4_xxx: CHANGE WHEN DEPLOYING TO OFFICIAL NETWORK
)

func init() {
Expand All @@ -27,7 +27,7 @@ func init() {
gns.Mint(INTERNAL_REWARD_ACCOUNT, 400_000_000_000_000) // @INTERNAL_REWARD_ACCOUNT
gns.Mint(std.Address("g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5"), 100_000_000_000) // default test1

stakerAddr := std.DerivePkgAddr("gno.land/r/demo/staker")
stakerAddr := std.DerivePkgAddr("gno.land/r/demo/staker") // r3v4_xxx: CHANGE WHEN DEPLOYING TO OFFICIAL NETWORK
admins = append(admins, string(stakerAddr))
admins = append(admins, string(admin))

Expand Down
9 changes: 8 additions & 1 deletion consts/consts.gno
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import (

// GNOSWAP SERVICE
const (
GNOSWAP_ADMIN std.Address = "g12l9splsyngcgefrwa52x5a7scc29e9v086m6p4"
GNOSWAP_ADMIN std.Address = "g12l9splsyngcgefrwa52x5a7scc29e9v086m6p4" // GSA, r3v4_xxx: CHANGE WHEN DEPLOYING TO OFFICIAL NETWORK
INTERNAL_REWARD_ACCOUNT std.Address = "g1paqttvcjcluuya9n9twyw7yacv54mt7ld3gvzm"

// 500 GNS as creation fee (r3v4_xxx: 500 or 500_000_000)
POOL_CREATION_FEE uint64 = 500
Expand Down Expand Up @@ -35,6 +36,12 @@ const (

GOV_PATH string = "gno.land/r/demo/gov"
GOV_ADDR std.Address = std.DerivePkgAddr(GOV_PATH)

GNS_PATH string = "gno.land/r/demo/gns"
GNS_ADDR std.Address = std.DerivePkgAddr(GNS_PATH)

GNFT_PATH string = "gno.land/r/demo/gnft"
GNFT_ADDR std.Address = std.DerivePkgAddr(GNFT_PATH)
)

// NUMBER
Expand Down
2 changes: 1 addition & 1 deletion router/_TEST_INIT_basic_test.gno
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func init() {

wugnot.Approve(a2u(poolAddr), 500_000_000_000_000)

std.TestSetPrevAddr(std.Address("g1paqttvcjcluuya9n9twyw7yacv54mt7ld3gvzm")) // r3v4_xxx: CHANGE WHEN DEPLOYING TO OFFICIAL NETWORK
std.TestSetPrevAddr(std.Address("g1paqttvcjcluuya9n9twyw7yacv54mt7ld3gvzm")) // IRA, r3v4_xxx: CHANGE WHEN DEPLOYING TO OFFICIAL NETWORK
gns.Approve(a2u(stakerAddr), 500_000_000_000_000) // to create internal incentive
}

Expand Down
8 changes: 4 additions & 4 deletions router/router_register.gno
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"std"

"gno.land/r/demo/users"
)

const APPROVED_CALLER = "g12l9splsyngcgefrwa52x5a7scc29e9v086m6p4" // r3v4_xxx: CHANGE WHEN DEPLOYING TO OFFICIAL NETWORK
"gno.land/r/demo/consts"
)

var registered = []GRC20Pair{}

Expand Down Expand Up @@ -51,7 +51,7 @@ func RegisterGRC20Interface(pkgPath string, igrc20 GRC20Interface) {
// r3v4_xxx: however must be used in production

// caller := std.GetOrigCaller()
// if caller != APPROVED_CALLER {
// if caller != consts.GNOSWAP_ADMIN {
// panic("unauthorized address to register")
// }

Expand All @@ -67,7 +67,7 @@ func UnregisterGRC20Interface(pkgPath string) {

// only admin can unregister
caller := std.GetOrigCaller()
if caller != APPROVED_CALLER {
if caller != consts.GNOSWAP_ADMIN {
panic("unauthorized address to unregister")
}

Expand Down

0 comments on commit 2cc6fe2

Please sign in to comment.