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

type.gno

1.30 Kb · 41 lines
 1package referral
 2
 3const zeroAddress = address("")
 4
 5// selfAddress is cached at package initialization to ensure consistent comparison.
 6var selfAddress address
 7
 8func init(cur realm) {
 9	selfAddress = cur.Address()
10}
11
12// contractAddress returns the address of the referral contract.
13// This is used as a sentinel value for removing referrals.
14func contractAddress() address {
15	return selfAddress
16}
17
18// isRemovalRequest checks if the given address indicates a removal request.
19// Removal is indicated by passing the contract's own address as the referral.
20func isRemovalRequest(refAddr address) bool {
21	return refAddr == selfAddress
22}
23
24// ReferralKeeper defines the interface for managing referral relationships.
25type ReferralKeeper interface {
26	// register creates or updates a referral relationship between addresses.
27	// Setting refAddr to the contract's own address removes the referral.
28	register(addr, refAddr address) (address, error)
29
30	// has returns true if a referral exists for the given address.
31	has(addr address) bool
32
33	// get retrieves the referral address for a given address.
34	get(addr address) (address, error)
35
36	// isEmpty returns true if no referrals exist in the system.
37	isEmpty() bool
38
39	// getLastOpTimestamp returns the last operation timestamp for an address.
40	getLastOpTimestamp(addr address) (int64, error)
41}