Search Apps Documentation Source Content File Folder Download Copy Actions Download

type.gno

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