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

refactor: remove unused code and move consts from r to p #486

Merged
merged 2 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -135,18 +135,3 @@ const (
// REF: https://github.com/gnolang/gno/pull/2401#discussion_r1648064219
ZERO_ADDRESS std.Address = "g100000000000000000000000000000000dnmcnx"
)

// EMISSION
// TODO:
// This is a temporary solution to prevent the emission from being refactored.
// 1. After refactoring, remove this var
var (
EMISSION_REFACTORED bool = true
)

func setEmissionRefactored(value bool) {
caller := std.PrevRealm().Addr()
if caller == ADMIN {
EMISSION_REFACTORED = value
}
}
1 change: 1 addition & 0 deletions contract/p/gnoswap/consts/gno.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module gno.land/p/gnoswap/consts
11 changes: 1 addition & 10 deletions contract/r/gnoswap/common/access.gno
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"std"

"gno.land/p/demo/ufmt"
"gno.land/r/gnoswap/v1/consts"
"gno.land/p/gnoswap/consts"
)

const (
Expand Down Expand Up @@ -98,15 +98,6 @@ func EmissionOnly(caller std.Address) error {
return nil
}

// DEPRECATED
// TODO: remove after r/grc20reg is applied for all contracts
func TokenRegisterOnly(caller std.Address) error {
if caller != consts.TOKEN_REGISTER {
return ufmt.Errorf(ErrNoPermission, caller.String())
}
return nil
}

// UserOnly checks if the caller is a user.
func UserOnly(prev std.Realm) error {
if !prev.IsUser() {
Expand Down
12 changes: 1 addition & 11 deletions contract/r/gnoswap/common/access_test.gno
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"gno.land/p/demo/testutils"
"gno.land/p/demo/uassert"

"gno.land/r/gnoswap/v1/consts"
"gno.land/p/gnoswap/consts"
)

var (
Expand Down Expand Up @@ -115,16 +115,6 @@ func TestEmissionOnly(t *testing.T) {
})
}

func TestTokenRegisterOnly(t *testing.T) {
t.Run("caller is token register", func(t *testing.T) {
uassert.NoError(t, TokenRegisterOnly(consts.TOKEN_REGISTER))
})

t.Run("caller is not token register", func(t *testing.T) {
uassert.Error(t, TokenRegisterOnly(addr01))
})
}

func TestUserOnly(t *testing.T) {
t.Run("caller is user", func(t *testing.T) {
uassert.NoError(t, UserOnly(std.NewUserRealm(addr01)))
Expand Down
2 changes: 1 addition & 1 deletion contract/r/gnoswap/common/halt.gno
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"strconv"

"gno.land/p/demo/ufmt"
"gno.land/r/gnoswap/v1/consts"
"gno.land/p/gnoswap/consts"
)

// halted is a global flag that indicates whether the GnoSwap is currently halted.
Expand Down
2 changes: 1 addition & 1 deletion contract/r/gnoswap/common/halt_test.gno
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"gno.land/p/demo/uassert"

"gno.land/r/gnoswap/v1/consts"
"gno.land/p/gnoswap/consts"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion contract/r/gnoswap/common/limit_caller_test.gno
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"testing"

"gno.land/p/demo/uassert"
"gno.land/r/gnoswap/v1/consts"
"gno.land/p/gnoswap/consts"
)

func TestSetLimitCaller(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion contract/r/gnoswap/common/liquidity_amounts.gno
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package common

import (
"gno.land/p/demo/ufmt"
"gno.land/p/gnoswap/consts"
u256 "gno.land/p/gnoswap/uint256"
"gno.land/r/gnoswap/v1/consts"
)

// toAscendingOrder checks if the first value is greater than
Expand Down
2 changes: 1 addition & 1 deletion contract/r/gnoswap/common/liquidity_amounts_test.gno
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (

"gno.land/p/demo/uassert"
"gno.land/p/demo/ufmt"
"gno.land/p/gnoswap/consts"
u256 "gno.land/p/gnoswap/uint256"
"gno.land/r/gnoswap/v1/consts"
)

func TestToAscendingOrder(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion contract/r/gnoswap/common/math.gno
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
i256 "gno.land/p/gnoswap/int256"
u256 "gno.land/p/gnoswap/uint256"

"gno.land/r/gnoswap/v1/consts"
"gno.land/p/gnoswap/consts"
)

// I64Min returns the minimum of two int64 values
Expand Down
2 changes: 1 addition & 1 deletion contract/r/gnoswap/community_pool/community_pool_test.gno
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"gno.land/p/demo/testutils"
"gno.land/p/demo/uassert"

"gno.land/p/gnoswap/consts"
"gno.land/r/gnoswap/v1/common"
"gno.land/r/gnoswap/v1/consts"

"gno.land/r/gnoswap/v1/gns"
)
Expand Down
1 change: 0 additions & 1 deletion contract/r/gnoswap/consts/gno.mod

This file was deleted.

2 changes: 1 addition & 1 deletion contract/r/gnoswap/emission/_helper_test.gno
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

"gno.land/p/demo/avl"

"gno.land/r/gnoswap/v1/consts"
"gno.land/p/gnoswap/consts"
"gno.land/r/gnoswap/v1/gns"
)

Expand Down
2 changes: 1 addition & 1 deletion contract/r/gnoswap/emission/distribution.gno
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"gno.land/p/demo/avl"
"gno.land/p/demo/ufmt"

"gno.land/r/gnoswap/v1/consts"
"gno.land/p/gnoswap/consts"
"gno.land/r/gnoswap/v1/gns"
)

Expand Down
2 changes: 1 addition & 1 deletion contract/r/gnoswap/emission/distribution_test.gno
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"gno.land/p/demo/uassert"

"gno.land/r/gnoswap/v1/consts"
"gno.land/p/gnoswap/consts"
"gno.land/r/gnoswap/v1/gns"
)

Expand Down
2 changes: 1 addition & 1 deletion contract/r/gnoswap/emission/emission.gno
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"std"
"time"

"gno.land/r/gnoswap/v1/consts"
"gno.land/p/gnoswap/consts"
"gno.land/r/gnoswap/v1/gns"
)

Expand Down
2 changes: 1 addition & 1 deletion contract/r/gnoswap/gnft/gnft.gno
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"gno.land/p/demo/grc/grc721"
"gno.land/p/demo/ownable"
"gno.land/p/demo/ufmt"
"gno.land/p/gnoswap/consts"
"gno.land/r/gnoswap/v1/common"
"gno.land/r/gnoswap/v1/consts"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion contract/r/gnoswap/gnft/gnft_test.gno
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"gno.land/p/demo/testutils"
"gno.land/p/demo/uassert"

"gno.land/r/gnoswap/v1/consts"
"gno.land/p/gnoswap/consts"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion contract/r/gnoswap/gns/_helper_test.gno
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"gno.land/p/demo/grc/grc20"
"gno.land/p/demo/ownable"

"gno.land/r/gnoswap/v1/consts"
"gno.land/p/gnoswap/consts"
)

func resetObject(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion contract/r/gnoswap/gns/gns.gno
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

"gno.land/r/demo/grc20reg"

"gno.land/r/gnoswap/v1/consts"
"gno.land/p/gnoswap/consts"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion contract/r/gnoswap/gns/gns_test.gno
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"gno.land/p/demo/testutils"
"gno.land/p/demo/uassert"

"gno.land/r/gnoswap/v1/consts"
"gno.land/p/gnoswap/consts"
)

const (
Expand Down
4 changes: 1 addition & 3 deletions contract/r/gnoswap/gns/halving.gno
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

"gno.land/p/demo/avl"
"gno.land/p/demo/json"
"gno.land/r/gnoswap/v1/consts"
"gno.land/p/gnoswap/consts"
)

// init 12 years halving tier block
Expand Down Expand Up @@ -235,8 +235,6 @@ func GetEmission() uint64 {
}
}

// haven't reached the start of the halvings
// TODO: check if returning 0 is correct
return 0
}

Expand Down
2 changes: 1 addition & 1 deletion contract/r/gnoswap/gns/halving_test.gno
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"gno.land/p/demo/json"
"gno.land/p/demo/uassert"

"gno.land/r/gnoswap/v1/consts"
"gno.land/p/gnoswap/consts"
)

var (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (

"gno.land/p/demo/uassert"

"gno.land/p/gnoswap/consts"
"gno.land/r/gnoswap/v1/common"
"gno.land/r/gnoswap/v1/consts"
)

var (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"gno.land/p/demo/uassert"

"gno.land/r/gnoswap/v1/consts"
"gno.land/p/gnoswap/consts"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion contract/r/gnoswap/gns/tests/z1_filetest.gno
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"gno.land/p/demo/testutils"
"gno.land/p/demo/uassert"

"gno.land/r/gnoswap/v1/consts"
"gno.land/p/gnoswap/consts"
"gno.land/r/gnoswap/v1/gns"
)

Expand Down
2 changes: 1 addition & 1 deletion contract/r/gnoswap/gns/tests/z2_filetest.gno
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"gno.land/p/demo/testutils"
"gno.land/p/demo/uassert"

"gno.land/r/gnoswap/v1/consts"
"gno.land/p/gnoswap/consts"
"gno.land/r/gnoswap/v1/gns"
)

Expand Down
2 changes: 1 addition & 1 deletion contract/r/gnoswap/gns/tests/z3_filetest.gno
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"gno.land/p/demo/testutils"
"gno.land/p/demo/uassert"

"gno.land/r/gnoswap/v1/consts"
"gno.land/p/gnoswap/consts"
"gno.land/r/gnoswap/v1/gns"
)

Expand Down
2 changes: 1 addition & 1 deletion contract/r/gnoswap/gns/tests/z4_filetest.gno
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"gno.land/p/demo/uassert"
"gno.land/p/demo/ufmt"

"gno.land/r/gnoswap/v1/consts"
"gno.land/p/gnoswap/consts"
"gno.land/r/gnoswap/v1/gns"
)

Expand Down
2 changes: 1 addition & 1 deletion contract/r/gnoswap/gns/utils.gno
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (

"gno.land/p/demo/ufmt"

"gno.land/p/gnoswap/consts"
"gno.land/r/gnoswap/v1/common"
"gno.land/r/gnoswap/v1/consts"
)

func getPrev() (string, string) {
Expand Down
2 changes: 1 addition & 1 deletion contract/r/gnoswap/gov/governance/execute_test.gno
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package governance
import (
"errors"
"gno.land/p/demo/uassert"
"gno.land/r/gnoswap/v1/consts"
"gno.land/p/gnoswap/consts"
"testing"
)

Expand Down
4 changes: 2 additions & 2 deletions contract/r/gnoswap/gov/governance/fn_registry.gno
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package governance
import (
"std"

"gno.land/r/gnoswap/v1/consts"
"gno.land/p/gnoswap/consts"
"gno.land/r/gnoswap/v1/gns"

cp "gno.land/r/gnoswap/v1/community_pool"
Expand Down Expand Up @@ -190,4 +190,4 @@ func createParameterHandlers() *ParameterRegistry {
})

return registry
}
}
5 changes: 1 addition & 4 deletions contract/r/gnoswap/gov/governance/fn_registry_test.gno
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
package governance

import (
"std"
"testing"

"gno.land/p/demo/uassert"

"gno.land/r/gnoswap/v1/consts"
"gno.land/p/gnoswap/consts"

cn "gno.land/r/gnoswap/v1/common"
en "gno.land/r/gnoswap/v1/emission"
gs "gno.land/r/gnoswap/v1/gov/staker"
pl "gno.land/r/gnoswap/v1/pool"
pf "gno.land/r/gnoswap/v1/protocol_fee"
rr "gno.land/r/gnoswap/v1/router"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (

"gno.land/r/gnoswap/v1/gns"

"gno.land/r/gnoswap/v1/consts"
"gno.land/p/gnoswap/consts"
)

type FooToken struct{}
Expand Down
2 changes: 1 addition & 1 deletion contract/r/gnoswap/gov/governance/tests/_helper_test.gno
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package governance
import (
"std"

"gno.land/r/gnoswap/v1/consts"
"gno.land/p/gnoswap/consts"
)

var (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"gno.land/p/demo/uassert"

"gno.land/r/gnoswap/v1/consts"
"gno.land/p/gnoswap/consts"
"gno.land/r/gnoswap/v1/gns"

gs "gno.land/r/gnoswap/v1/gov/staker"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"gno.land/p/demo/testutils"
"gno.land/p/demo/uassert"

"gno.land/r/gnoswap/v1/consts"
"gno.land/p/gnoswap/consts"
gns "gno.land/r/gnoswap/v1/gns"

gs "gno.land/r/gnoswap/v1/gov/staker"
Expand Down
Loading
Loading