assert.gno
0.92 Kb ยท 29 lines
1package common
2
3// AssertIsUserSendGNOTAmount validates that the user sent the expected GNOT amount.
4// Panics with errNotSupportedCoins if unsupported native coins were sent.
5// Panics with errInvalidGNOTAmount if the GNOT amount doesn't match the expected amount.
6//
7// Parameters:
8// - amount: expected GNOT amount in ugnot
9//
10// Use this when a function requires native GNOT payment.
11func AssertIsUserSendGNOTAmount(amount int64) {
12 if hasUnsupportedNativeCoins() {
13 panic(errNotSupportedCoins)
14 }
15
16 if !isUserSendGNOTAmount(amount) {
17 panic(errInvalidGNOTAmount)
18 }
19}
20
21// AssertIsNotHandleNativeCoin validates that no native coins were sent with the transaction.
22// Panics with errNotHandleNativeCoin if any native coins were sent.
23//
24// Use this when a function should only work with GRC20 tokens and not accept native coins.
25func AssertIsNotHandleNativeCoin() {
26 if ExistsUserSendCoins() {
27 panic(errNotHandleNativeCoin)
28 }
29}