Skip to content

Commit d4aa3cb

Browse files
committed
refactor: resolve internal review
1 parent cdfaa41 commit d4aa3cb

File tree

7 files changed

+11
-17
lines changed

7 files changed

+11
-17
lines changed

contract/p/gnoswap/consts/consts.gno

+3-3
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,11 @@ const (
112112

113113
// TIMESTAMP & DAY
114114
const (
115-
SECOND_IN_MILLISECOND = 1000
115+
MILLISECONDS_PER_SECOND = 1000
116116

117117
// in seconds
118-
TIMESTAMP_DAY = 86400
119-
TIMESTAMP_YEAR = 31536000
118+
SECONDS_PER_DAY = 86400
119+
TIMESTAMP_YEAR = 31536000
120120

121121
DAY_PER_YEAR = 365
122122
)

contract/r/gnoswap/common/tick_math.gno

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ var (
1515
binaryLogTree = NewBinaryLogTree()
1616

1717
shift1By32Left = u256.MustFromDecimal("4294967296") // (1 << 32)
18-
maxTick = int32(887272)
1918
)
2019

2120
// TreeValue wraps u256.Uint to implement custom value type for avl.Tree
@@ -356,7 +355,7 @@ func abs(x int32) int32 {
356355

357356
// assertValidTickRange validates that the absolute tick value is within the acceptable range.
358357
func assertValidTickRange(absTick int32) {
359-
if absTick > maxTick {
358+
if absTick > consts.MAX_TICK {
360359
panic(newErrorWithDetail(
361360
errOutOfRange,
362361
ufmt.Sprintf("abs tick is out of range (larger than 887272), abs tick: %d", absTick),

contract/r/gnoswap/gnft/gnft.gno

+1-6
Original file line numberDiff line numberDiff line change
@@ -248,12 +248,7 @@ func SetApprovalForAll(operator std.Address, approved bool) error {
248248
// - std.Address: The address approved to manage the token. Returns an empty address if no approval exists.
249249
// - error: Returns an error if the lookup fails or the token ID is invalid.
250250
func GetApproved(tid grc721.TokenID) (std.Address, error) {
251-
addr, err := gnft.GetApproved(tid)
252-
if err != nil {
253-
return "", err
254-
}
255-
256-
return addr, nil
251+
return gnft.GetApproved(tid)
257252
}
258253

259254
// IsApprovedForAll checks if an operator is approved to manage all tokens of an owner.

contract/r/gnoswap/gns/halving.gno

+3-3
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ var (
4444

4545
var (
4646
blockPerYear = consts.TIMESTAMP_YEAR / consts.BLOCK_GENERATION_INTERVAL
47-
blockPerDay = consts.TIMESTAMP_DAY / consts.BLOCK_GENERATION_INTERVAL
47+
blockPerDay = consts.SECONDS_PER_DAY / consts.BLOCK_GENERATION_INTERVAL
4848

49-
avgBlockTimeMs int64 = consts.SECOND_IN_MILLISECOND * consts.BLOCK_GENERATION_INTERVAL
49+
avgBlockTimeMs int64 = consts.MILLISECONDS_PER_SECOND * consts.BLOCK_GENERATION_INTERVAL
5050
perBlockMint = avl.NewTree() // height => uint64
5151
)
5252

@@ -425,7 +425,7 @@ func setAvgBlockTimeInMs(ms int64) {
425425

426426
yearEndTimestamp := GetHalvingYearTimestamp(year) + consts.TIMESTAMP_YEAR
427427
timeLeftForYear := yearEndTimestamp - now
428-
numBlock := (timeLeftForYear * consts.SECOND_IN_MILLISECOND) / ms
428+
numBlock := (timeLeftForYear * consts.MILLISECONDS_PER_SECOND) / ms
429429
yearEndHeight := height + numBlock
430430

431431
if year == currentYear {

contract/r/gnoswap/gns/utils.gno

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func i64Min(x, y int64) int64 {
5858
}
5959

6060
func secToMs(sec int64) int64 {
61-
return sec * consts.SECOND_IN_MILLISECOND
61+
return sec * consts.MILLISECONDS_PER_SECOND
6262
}
6363

6464
func formatUint(v interface{}) string {

contract/r/gnoswap/gov/staker/clean_delegation_stat_history.gno

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
)
88

99
// default one day
10-
var thresholdVotingWeightBlockHeight = consts.TIMESTAMP_DAY / consts.BLOCK_GENERATION_INTERVAL
10+
var thresholdVotingWeightBlockHeight = consts.SECONDS_PER_DAY / consts.BLOCK_GENERATION_INTERVAL
1111

1212
var (
1313
lastCleanedHeight uint64 = 0

contract/r/gnoswap/launchpad/launchpad.gno

+1-1
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ func createTier(
632632
time: startTime,
633633
}
634634

635-
durationSecond := duration * TIMESTAMP_DAY
635+
durationSecond := duration * consts.SECONDS_PER_DAY
636636
endTime := startTime + durationSecond
637637
durationHeight := convertTimeToHeight(durationSecond)
638638
endHeight := startHeight + durationHeight

0 commit comments

Comments
 (0)