Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

payable.gno

0.80 Kb · 30 lines
 1package memba_notes_v1
 2
 3import "chain/runtime/unsafe"
 4
 5// Inert activation uses the original package creator as OriginCaller, not the
 6// enabling approver. Runtime e75fef82c keeper_inert.go pins this behavior.
 7func init() { admin = unsafe.OriginCaller() }
 8func assertNoCoins() {
 9	if !unsafe.OriginSend().IsZero() {
10		panic("notes: no coins")
11	}
12}
13func assertCreatePayment(cur realm, maxFee int64) {
14	if !cur.Previous().IsUserCall() {
15		panic("notes: create directly from your account")
16	}
17	if maxFee < 0 || createFee > maxFee {
18		panic("notes: fee exceeds maximum")
19	}
20	coins := unsafe.OriginSend()
21	if createFee == 0 {
22		if !coins.IsZero() {
23			panic("notes: exact fee required")
24		}
25		return
26	}
27	if len(coins) != 1 || coins[0].Denom != "ugnot" || coins[0].Amount != createFee {
28		panic("notes: exact fee required")
29	}
30}