Skip to content

Commit 0d982e4

Browse files
committed
Merge branch 'launchpad-pr' of https://github.com/gnoswap-labs/gnoswap into launchpad-pr
2 parents 8282e2d + fff7413 commit 0d982e4

File tree

293 files changed

+3550
-6574
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

293 files changed

+3550
-6574
lines changed

Diff for: contract/r/gnoswap/consts/consts.gno renamed to contract/p/gnoswap/consts/consts.gno

-15
Original file line numberDiff line numberDiff line change
@@ -135,18 +135,3 @@ const (
135135
// REF: https://github.com/gnolang/gno/pull/2401#discussion_r1648064219
136136
ZERO_ADDRESS std.Address = "g100000000000000000000000000000000dnmcnx"
137137
)
138-
139-
// EMISSION
140-
// TODO:
141-
// This is a temporary solution to prevent the emission from being refactored.
142-
// 1. After refactoring, remove this var
143-
var (
144-
EMISSION_REFACTORED bool = true
145-
)
146-
147-
func setEmissionRefactored(value bool) {
148-
caller := std.PrevRealm().Addr()
149-
if caller == ADMIN {
150-
EMISSION_REFACTORED = value
151-
}
152-
}

Diff for: contract/p/gnoswap/consts/gno.mod

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module gno.land/p/gnoswap/consts

Diff for: contract/r/gnoswap/common/access.gno

+1-10
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"std"
55

66
"gno.land/p/demo/ufmt"
7-
"gno.land/r/gnoswap/v1/consts"
7+
"gno.land/p/gnoswap/consts"
88
)
99

1010
const (
@@ -98,15 +98,6 @@ func EmissionOnly(caller std.Address) error {
9898
return nil
9999
}
100100

101-
// DEPRECATED
102-
// TODO: remove after r/grc20reg is applied for all contracts
103-
func TokenRegisterOnly(caller std.Address) error {
104-
if caller != consts.TOKEN_REGISTER {
105-
return ufmt.Errorf(ErrNoPermission, caller.String())
106-
}
107-
return nil
108-
}
109-
110101
// UserOnly checks if the caller is a user.
111102
func UserOnly(prev std.Realm) error {
112103
if !prev.IsUser() {

Diff for: contract/r/gnoswap/common/access_test.gno

+1-11
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"gno.land/p/demo/testutils"
88
"gno.land/p/demo/uassert"
99

10-
"gno.land/r/gnoswap/v1/consts"
10+
"gno.land/p/gnoswap/consts"
1111
)
1212

1313
var (
@@ -115,16 +115,6 @@ func TestEmissionOnly(t *testing.T) {
115115
})
116116
}
117117

118-
func TestTokenRegisterOnly(t *testing.T) {
119-
t.Run("caller is token register", func(t *testing.T) {
120-
uassert.NoError(t, TokenRegisterOnly(consts.TOKEN_REGISTER))
121-
})
122-
123-
t.Run("caller is not token register", func(t *testing.T) {
124-
uassert.Error(t, TokenRegisterOnly(addr01))
125-
})
126-
}
127-
128118
func TestUserOnly(t *testing.T) {
129119
t.Run("caller is user", func(t *testing.T) {
130120
uassert.NoError(t, UserOnly(std.NewUserRealm(addr01)))

Diff for: contract/r/gnoswap/common/halt.gno

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"strconv"
66

77
"gno.land/p/demo/ufmt"
8-
"gno.land/r/gnoswap/v1/consts"
8+
"gno.land/p/gnoswap/consts"
99
)
1010

1111
// halted is a global flag that indicates whether the GnoSwap is currently halted.
@@ -90,11 +90,11 @@ func SetHalt(halt bool) {
9090
func setHalt(halt bool) {
9191
halted = halt
9292

93-
prevAddr, prevRealm := getPrevAsString()
93+
prevAddr, prevPkgPath := getPrevAsString()
9494
std.Emit(
9595
"setHalt",
9696
"prevAddr", prevAddr,
97-
"prevRealm", prevRealm,
97+
"prevRealm", prevPkgPath,
9898
"halt", strconv.FormatBool(halt),
9999
)
100100
}

Diff for: contract/r/gnoswap/common/halt_test.gno

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66

77
"gno.land/p/demo/uassert"
88

9-
"gno.land/r/gnoswap/v1/consts"
9+
"gno.land/p/gnoswap/consts"
1010
)
1111

1212
var (

Diff for: contract/r/gnoswap/common/limit_caller_test.gno

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"testing"
66

77
"gno.land/p/demo/uassert"
8-
"gno.land/r/gnoswap/v1/consts"
8+
"gno.land/p/gnoswap/consts"
99
)
1010

1111
func TestSetLimitCaller(t *testing.T) {

Diff for: contract/r/gnoswap/common/liquidity_amounts.gno

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ package common
22

33
import (
44
"gno.land/p/demo/ufmt"
5+
"gno.land/p/gnoswap/consts"
56
u256 "gno.land/p/gnoswap/uint256"
6-
"gno.land/r/gnoswap/v1/consts"
77
)
88

99
// toAscendingOrder checks if the first value is greater than

Diff for: contract/r/gnoswap/common/liquidity_amounts_test.gno

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import (
55

66
"gno.land/p/demo/uassert"
77
"gno.land/p/demo/ufmt"
8+
"gno.land/p/gnoswap/consts"
89
u256 "gno.land/p/gnoswap/uint256"
9-
"gno.land/r/gnoswap/v1/consts"
1010
)
1111

1212
func TestToAscendingOrder(t *testing.T) {

Diff for: contract/r/gnoswap/common/math.gno

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
i256 "gno.land/p/gnoswap/int256"
77
u256 "gno.land/p/gnoswap/uint256"
88

9-
"gno.land/r/gnoswap/v1/consts"
9+
"gno.land/p/gnoswap/consts"
1010
)
1111

1212
// I64Min returns the minimum of two int64 values

Diff for: contract/r/gnoswap/community_pool/community_pool.gno

+3-2
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,12 @@ func transferToken(tokenPath string, to std.Address, amount uint64) {
2929
teller := common.GetTokenTeller(tokenPath)
3030
checkErr(teller.Transfer(to, amount))
3131

32-
prevAddr, prevRealm := getPrevAsString()
32+
prevAddr, prevPkgPath := getPrevAsString()
33+
3334
std.Emit(
3435
"TransferToken",
3536
"prevAddr", prevAddr,
36-
"prevRealm", prevRealm,
37+
"prevRealm", prevPkgPath,
3738
"tokenPath", tokenPath,
3839
"to", to.String(),
3940
"amount", strconv.FormatUint(amount, 10),

Diff for: contract/r/gnoswap/community_pool/community_pool_test.gno

+6-6
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import (
77
"gno.land/p/demo/testutils"
88
"gno.land/p/demo/uassert"
99

10+
"gno.land/p/gnoswap/consts"
1011
"gno.land/r/gnoswap/v1/common"
11-
"gno.land/r/gnoswap/v1/consts"
1212

1313
"gno.land/r/gnoswap/v1/gns"
1414
)
@@ -62,7 +62,7 @@ func TestTransferTokenByAdmin(t *testing.T) {
6262
name: "panic if not enough balance",
6363
setup: func() {
6464
std.TestSetRealm(adminRealm)
65-
gns.Transfer(common.AddrToUser(consts.COMMUNITY_POOL_ADDR), 10_000)
65+
gns.Transfer(consts.COMMUNITY_POOL_ADDR, 10_000)
6666
},
6767
caller: adminRealm,
6868
tokenPath: consts.GNS_PATH,
@@ -95,9 +95,9 @@ func TestTransferTokenByAdmin(t *testing.T) {
9595
TransferTokenByAdmin(tt.tokenPath, tt.to, tt.amount)
9696
})
9797
} else {
98-
receiverOldBalance := gns.BalanceOf(common.AddrToUser(tt.to))
98+
receiverOldBalance := gns.BalanceOf(tt.to)
9999
TransferTokenByAdmin(tt.tokenPath, tt.to, tt.amount)
100-
receiverNewBalance := gns.BalanceOf(common.AddrToUser(tt.to))
100+
receiverNewBalance := gns.BalanceOf(tt.to)
101101
uassert.Equal(t, receiverNewBalance-receiverOldBalance, tt.amount)
102102
}
103103
})
@@ -175,9 +175,9 @@ func TestTransferToken(t *testing.T) {
175175
TransferToken(tt.tokenPath, tt.to, tt.amount)
176176
})
177177
} else {
178-
receiverOldBalance := gns.BalanceOf(common.AddrToUser(tt.to))
178+
receiverOldBalance := gns.BalanceOf(tt.to)
179179
TransferToken(tt.tokenPath, tt.to, tt.amount)
180-
receiverNewBalance := gns.BalanceOf(common.AddrToUser(tt.to))
180+
receiverNewBalance := gns.BalanceOf(tt.to)
181181
uassert.Equal(t, receiverNewBalance-receiverOldBalance, tt.amount)
182182
}
183183
})

Diff for: contract/r/gnoswap/community_pool/tests/init_token_register_test.gno

-143
This file was deleted.

Diff for: contract/r/gnoswap/community_pool/tests/init_variable_and_helper_test.gno

-31
This file was deleted.

Diff for: contract/r/gnoswap/consts/gno.mod

-1
This file was deleted.

Diff for: contract/r/gnoswap/emission/_test_helper.gno renamed to contract/r/gnoswap/emission/_helper_test.gno

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77

88
"gno.land/p/demo/avl"
99

10-
"gno.land/r/gnoswap/v1/consts"
10+
"gno.land/p/gnoswap/consts"
1111
"gno.land/r/gnoswap/v1/gns"
1212
)
1313

@@ -40,5 +40,5 @@ func resetObject(t *testing.T) {
4040
func gnsBalance(t *testing.T, addr std.Address) uint64 {
4141
t.Helper()
4242

43-
return gns.BalanceOf(a2u(addr))
43+
return gns.BalanceOf(addr)
4444
}

0 commit comments

Comments
 (0)