Skip to content

Commit c5123e7

Browse files
committed
feat: use std.Address (rather then users.AddressOrName)
1 parent 9402d11 commit c5123e7

File tree

217 files changed

+2223
-3614
lines changed

Some content is hidden

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

217 files changed

+2223
-3614
lines changed

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -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/emission/_helper_test.gno

+1-1
Original file line numberDiff line numberDiff line change
@@ -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
}

Diff for: contract/r/gnoswap/emission/distribution.gno

+7-7
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import (
44
"std"
55
"strconv"
66

7-
"gno.land/r/gnoswap/v1/consts"
8-
"gno.land/r/gnoswap/v1/gns"
9-
107
"gno.land/p/demo/avl"
118
"gno.land/p/demo/ufmt"
9+
10+
"gno.land/r/gnoswap/v1/consts"
11+
"gno.land/r/gnoswap/v1/gns"
1212
)
1313

1414
const (
@@ -176,22 +176,22 @@ func calculateAmount(amount, bptPct uint64) uint64 {
176176
func transferToTarget(target int, amount uint64) {
177177
switch target {
178178
case LIQUIDITY_STAKER:
179-
gns.Transfer(a2u(consts.STAKER_ADDR), amount)
179+
gns.Transfer(consts.STAKER_ADDR, amount)
180180
distributedToStaker += amount
181181
accuDistributedToStaker += amount
182182

183183
case DEVOPS:
184-
gns.Transfer(a2u(consts.DEV_OPS), amount)
184+
gns.Transfer(consts.DEV_OPS, amount)
185185
distributedToDevOps += amount
186186
accuDistributedToDevOps += amount
187187

188188
case COMMUNITY_POOL:
189-
gns.Transfer(a2u(consts.COMMUNITY_POOL_ADDR), amount)
189+
gns.Transfer(consts.COMMUNITY_POOL_ADDR, amount)
190190
distributedToCommunityPool += amount
191191
accuDistributedToCommunityPool += amount
192192

193193
case GOV_STAKER:
194-
gns.Transfer(a2u(consts.GOV_STAKER_ADDR), amount)
194+
gns.Transfer(consts.GOV_STAKER_ADDR, amount)
195195
distributedToGovStaker += amount
196196
accuDistributedToGovStaker += amount
197197

Diff for: contract/r/gnoswap/emission/distribution_test.gno

+1-1
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ func TestTransferToTarget(t *testing.T) {
264264
target: LIQUIDITY_STAKER,
265265
setup: func() {
266266
std.TestSetRealm(adminRealm)
267-
gns.Transfer(a2u(consts.EMISSION_ADDR), 100000) // give enough balance for emission
267+
gns.Transfer(consts.EMISSION_ADDR, 100000) // give enough balance for emission
268268
},
269269
amount: 100,
270270
verify: func() {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func MintAndDistributeGns() uint64 {
2727
return 0
2828
}
2929
// Mint new tokens and add any leftover amounts from previous distribution
30-
mintedEmissionRewardAmount := gns.MintGns(a2u(consts.EMISSION_ADDR))
30+
mintedEmissionRewardAmount := gns.MintGns(consts.EMISSION_ADDR)
3131
if hasLeftGNSAmount() {
3232
mintedEmissionRewardAmount += GetLeftGNSAmount()
3333
setLeftGNSAmount(0)

Diff for: contract/r/gnoswap/emission/utils.gno

-6
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,12 @@ import (
55
"strconv"
66

77
"gno.land/p/demo/ufmt"
8-
pusers "gno.land/p/demo/users"
98

109
"gno.land/r/gnoswap/v1/common"
1110
)
1211

1312
const MAX_BPS_PCT uint64 = 10000
1413

15-
// a2u converts std.Address to pusers.AddressOrName.
16-
func a2u(addr std.Address) pusers.AddressOrName {
17-
return pusers.AddressOrName(addr)
18-
}
19-
2014
// getPrevRealm returns object of the previous realm.
2115
func getPrevRealm() std.Realm {
2216
return std.PrevRealm()

Diff for: contract/r/gnoswap/gnft/utils.gno

-13
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55

66
"gno.land/p/demo/grc/grc721"
77
"gno.land/p/demo/ufmt"
8-
pusers "gno.land/p/demo/users"
98
)
109

1110
// getPrevAsString returns the address and package path of the previous realm.
@@ -19,18 +18,6 @@ func getPrevAddr() std.Address {
1918
return std.PrevRealm().Addr()
2019
}
2120

22-
// a2u converts std.Address to pusers.AddressOrName.
23-
// pusers is a package that contains the user-related functions.
24-
//
25-
// Input:
26-
// - addr: the address to convert
27-
//
28-
// Output:
29-
// - pusers.AddressOrName: the converted address
30-
func a2u(addr std.Address) pusers.AddressOrName {
31-
return pusers.AddressOrName(addr)
32-
}
33-
3421
// tid converts uint64 to grc721.TokenID.
3522
//
3623
// Input:

0 commit comments

Comments
 (0)