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

subscriptions state

Back to all declarations

Denom

untyped string

Denom is the only asset this realm accepts.

Value

"ugnot"

MaxFeeBps

int64

MaxFeeBps is the hard protocol-fee cap: 1000 bps = 10%.

Value

1000

PlanActive

untyped string

Plan status values.

Value

"active"

PlanRetired

untyped string

Plan status values.

Value

"retired"

SubActive

untyped string

Subscription status values. Cancelled and Expired are terminal.

Value

"active"

SubCancelled

untyped string

Subscription status values. Cancelled and Expired are terminal.

Value

"cancelled"

SubExpired

untyped string

Subscription status values. Cancelled and Expired are terminal.

Value

"expired"

MaxTitleLen

untyped bigint

Input bounds.

Value

(80 <untyped> bigint)

MaxDescLen

untyped bigint

Input bounds.

Value

(2000 <untyped> bigint)

MinPrice

int64

Input bounds.

Value

1

MinPeriodBlocks

int64

Input bounds.

Value

10

MaxPeriodBlocks

int64

Input bounds.

Value

7500000

MaxPlansPerProvider

untyped bigint

Input bounds.

Value

(20 <untyped> bigint)

MaxSubsPerSubscriber

untyped bigint

Input bounds.

Value

(100 <untyped> bigint)

RenderLimit

untyped bigint

Input bounds.

Value

(20 <untyped> bigint)

plan

type

Value

subscriptions.plan

sub

type

Value

subscriptions.sub

admin

.uverse.address

// may set fee, fee recipient, stage successor

Value

<gnolang.StringValue>

pendingAdmin

.uverse.address

// staged by TransferAdmin, completes via AcceptAdmin

Value

<zero>

feeRecipient

.uverse.address

// may withdraw fees and sweep surplus

Value

<gnolang.StringValue>

feeBps

int64

// fee snapshotted into NEW plans

Value

0

self

.uverse.address

// this realm's address, captured at deploy

Value

<gnolang.StringValue>

nextPlan

int64

Value

2

nextSub

int64

Value

2

activeByKey

*v0.Tree

// padID(planID)|subscriber -> int64 sub id, while Active

Open
OID
014e9d…a80d:17
activeByKey details

Inspect pointer

latestByKey

*v0.Tree

// padID(planID)|subscriber -> most recent sub id, never removed

Open
OID
014e9d…a80d:20
latestByKey details

Inspect pointer

providerNum

*v0.Tree

// address -> \*int64, live plans per provider

Open
OID
014e9d…a80d:23
providerNum details

Inspect pointer

subNum

*v0.Tree

// address -> \*int64, Active subs per subscriber

Open
OID
014e9d…a80d:26
subNum details

Inspect pointer

CreatePlan

func(title string, description string, price int64, periodBlocks int64, maxFeeBps int64) int64

CreatePlan publishes a subscription plan and returns its id. No coins are accepted; the storage deposit the caller pays is the anti-spam. The current protocol fee is snapshotted into the plan and must not exceed maxFeeBps, the ceiling the provider signed for — pass MaxFeeBps to accept any legal fee. Plans are immutable once created: price and period changes are a new plan, so nothing a subscriber agreed to can move underneath them.

Open
OID
014e9d…a80d:35
CreatePlan details

Inspect func

RetirePlan

func(planID int64)

RetirePlan takes a plan off the market: no new subscriptions and no renewals. Provider only. Existing entitlements run to their paidThrough untouched; refusing renewals is subscriber protection — nobody keeps paying for a service whose provider announced its end. The provider's plan-quota slot frees.

Open
OID
014e9d…a80d:36
RetirePlan details

Inspect func

Subscribe

func(planID int64) int64

Subscribe pays for the first billing period of a plan and returns the new subscription id. The transaction must attach EXACTLY the plan's price in ugnot — over- and underpayment are both refused, so a mistaken double-attach cannot silently become a donation. One subscriber holds at most one live subscription per plan: if an Active one exists the call is refused (the renewal path is Renew, never a second Subscribe — that is the duplicate-payment guard at the identity level); an incumbent past its grace window is collapsed to Expired in place, so a fresh start never waits on housekeeping. The payment settles immediately: price minus the plan's snapshotted fee to the provider's claimable balance, fee to the protocol pot. Entitlement runs from this block: paidThrough = height + periodBlocks.

Open
OID
014e9d…a80d:37
Subscribe details

Inspect func

Renew

func(subID int64)

Renew pays for the next billing period of the caller's own subscription. The transaction must attach exactly the subscription's price. The renewal window is deterministic and stated in the header: accepted iff paidThrough - height \<= periodBlocks (at most one full unstarted period prepaid — the duplicate-payment bound) and height \< paidThrough + periodBlocks (the grace bound, exclusive — a renewal always buys at least one block). Extension is always FROM paidThrough, so period boundaries never drift, and a renewal inside grace covers the lapsed span — that is the price of keeping the original schedule, and it is the documented, deterministic choice.

Open
OID
014e9d…a80d:38
Renew details

Inspect func

Cancel

func(subID int64)

Cancel ends the caller's own subscription. Terminal: it can never be renewed afterwards, by anyone. No refund and no funds move — every payment settled when it was made, and the entitlement already bought (height \< paidThrough) remains until it runs out. The plan slot and the subscriber's quota slot free immediately.

Open
OID
014e9d…a80d:39
Cancel details

Inspect func

Expire

func(subID int64)

Expire marks a lapsed subscription Expired once its grace window is over: height >= paidThrough + periodBlocks. Permissionless by design — like the sibling realms' valves, no slot's liveness may depend on either party showing up. No funds move.

Open
OID
014e9d…a80d:40
Expire details

Inspect func

Claim

func(amount int64)

Claim sends amount ugnot of the caller's claimable balance back to the caller. Providers earn into this balance at every payment.

Open
OID
014e9d…a80d:41
Claim details

Inspect func

ClaimAll

func()

ClaimAll sends the caller's entire claimable balance back to the caller. Fails if there is nothing to claim.

Open
OID
014e9d…a80d:42
ClaimAll details

Inspect func

WithdrawFees

func()

WithdrawFees sends the accrued fee pot to the fee recipient. Only the fee recipient may call it, and only the pot moves.

Open
OID
014e9d…a80d:43
WithdrawFees details

Inspect func

SweepDenom

func(denom string)

SweepDenom recovers out-of-band coins (sent by raw bank transfer, outside any entrypoint) to the fee recipient. For the ledger denom the reserve is Liabilities() — user balances and the fee pot are structurally unreachable. Fee recipient only.

Open
OID
014e9d…a80d:44
SweepDenom details

Inspect func

SetFeeBps

func(bps int64)

SetFeeBps sets the protocol fee snapshotted into FUTURE plans. Bounded by MaxFeeBps; existing plans and subscriptions are untouched — their fee was fixed the moment the provider consented to it.

Open
OID
014e9d…a80d:45
SetFeeBps details

Inspect func

SetFeeRecipient

func(recipient .uverse.address)

SetFeeRecipient points future fee withdrawals and sweeps at a new address. Admin only. The zero address is refused — it would strand the pot.

Open
OID
014e9d…a80d:46
SetFeeRecipient details

Inspect func

TransferAdmin

func(successor .uverse.address)

TransferAdmin stages a two-step admin handover. The successor holds nothing until AcceptAdmin.

Open
OID
014e9d…a80d:47
TransferAdmin details

Inspect func

AcceptAdmin

func()

AcceptAdmin completes the handover; only the staged successor may.

Open
OID
014e9d…a80d:48
AcceptAdmin details

Inspect func

Entitled

func(subID int64) bool

Entitled reports whether the subscription's paid entitlement covers the current block: height \< paidThrough. Status deliberately does not enter into it — a cancelled subscriber keeps what they paid for, and an expirable-but-unexpired one has already lapsed here.

Open
OID
014e9d…a80d:49
Entitled details

Inspect func

EntitledFor

func(planID int64, subscriber .uverse.address) bool

EntitledFor reports whether subscriber currently holds paid entitlement to planID, through their MOST RECENT subscription to it. This is the one-call integration surface for other realms and services, and it honors the entitlement contract across status: a cancelled subscription keeps answering true until its paidThrough — what was bought stays bought (audit finding Y1). One self-inflicted edge is fail-closed: cancelling a prepaid subscription and re-subscribing at once points this surface at the NEW, earlier paidThrough; the old subscription's remaining span stays queryable per-id via Entitled.

Open
OID
014e9d…a80d:50
EntitledFor details

Inspect func

ActiveSubID

func(planID int64, subscriber .uverse.address) (int64, bool)

ActiveSubID returns the caller-facing id of subscriber's live subscription to planID, or (0, false) if none is Active.

Open
OID
014e9d…a80d:51
ActiveSubID details

Inspect func

PlanInfo

func(planID int64) (provider .uverse.address, title string, price int64, periodBlocks int64, planFeeBps int64, status string, lifetimeSubs int64)
Open
OID
014e9d…a80d:52
PlanInfo details

Inspect func

SubInfo

func(subID int64) (planID int64, subscriber .uverse.address, provider .uverse.address, price int64, paidThrough int64, periods int64, status string)
Open
OID
014e9d…a80d:53
SubInfo details

Inspect func

PaidThrough

func(subID int64) int64

PaidThrough returns the absolute height a subscription is paid to.

Open
OID
014e9d…a80d:54
PaidThrough details

Inspect func

RenewableFrom

func(subID int64) (from int64, until int64)

RenewableFrom returns the earliest height at which Renew will accept a payment for this subscription, and the last height at which it still will (inclusive) — the deterministic window, precomputed for integrators. From until+1 the subscription is expirable instead; the two sets partition exactly.

Open
OID
014e9d…a80d:55
RenewableFrom details

Inspect func

PendingAdmin

func() .uverse.address
Open
OID
014e9d…a80d:57
PendingAdmin details

Inspect func

FeeRecipient

func() .uverse.address
Open
OID
014e9d…a80d:58
FeeRecipient details

Inspect func

BalanceOf

func(a .uverse.address) int64
Open
OID
014e9d…a80d:65
BalanceOf details

Inspect func

expireInPlace

func(s *subscriptions.sub)

expireInPlace flips an Active subscription to Expired and frees its slots. Callers have already established expirability.

Open
OID
014e9d…a80d:70
expireInPlace details

Inspect func

releaseSlots

func(s *subscriptions.sub)

releaseSlots removes the plan|subscriber activity index entry and decrements the subscriber's quota counter. Exactly once per terminal transition, which both terminal paths guarantee by requiring SubActive first.

Open
OID
014e9d…a80d:71
releaseSlots details

Inspect func

assertAdmin

func(caller .uverse.address)
Open
OID
014e9d…a80d:73
assertAdmin details

Inspect func

mustGetPlan

func(id int64) *subscriptions.plan
Open
OID
014e9d…a80d:74
mustGetPlan details

Inspect func

mustGetSub

func(id int64) *subscriptions.sub
Open
OID
014e9d…a80d:75
mustGetSub details

Inspect func

counter

func(tree *v0.Tree, a .uverse.address) *int64

counter returns the persistent per-address counter in tree, allocating a zero on first use.

Open
OID
014e9d…a80d:76
counter details

Inspect func
Denom : untyped string ="ugnot"
MaxFeeBps : int64 =1000
PlanActive : untyped string ="active"
PlanRetired : untyped string ="retired"
SubActive : untyped string ="active"
SubCancelled : untyped string ="cancelled"
SubExpired : untyped string ="expired"
MaxTitleLen : untyped bigint =(80 <untyped> bigint)
MaxDescLen : untyped bigint =(2000 <untyped> bigint)
MinPrice : int64 =1
MinPeriodBlocks : int64 =10
MaxPeriodBlocks : int64 =7500000
MaxPlansPerProvider : untyped bigint =(20 <untyped> bigint)
MaxSubsPerSubscriber : untyped bigint =(100 <untyped> bigint)
RenderLimit : untyped bigint =(20 <untyped> bigint)
plan : type =subscriptions.plan
sub : type =subscriptions.sub
admin : .uverse.address =<gnolang.StringValue>
pendingAdmin : .uverse.address =<zero>
feeRecipient : .uverse.address =<gnolang.StringValue>
feeBps : int64 =0
self : .uverse.address =<gnolang.StringValue>
nextPlan : int64 =2
nextSub : int64 =2
plans : *v0.Tree Inspect
subs : *v0.Tree Inspect
activeByKey : *v0.Tree Inspect
latestByKey : *v0.Tree Inspect
providerNum : *v0.Tree Inspect
subNum : *v0.Tree Inspect
ledger : *feeledger.Ledger Inspect
init.31 : func() Inspect
CreatePlan : func(title string, description string, price int64, periodBlocks int64, maxFeeBps int64) int64 Inspect
RetirePlan : func(planID int64) Inspect
Subscribe : func(planID int64) int64 Inspect
Renew : func(subID int64) Inspect
Cancel : func(subID int64) Inspect
Expire : func(subID int64) Inspect
Claim : func(amount int64) Inspect
ClaimAll : func() Inspect
WithdrawFees : func() Inspect
SweepDenom : func(denom string) Inspect
SetFeeBps : func(bps int64) Inspect
SetFeeRecipient : func(recipient .uverse.address) Inspect
TransferAdmin : func(successor .uverse.address) Inspect
AcceptAdmin : func() Inspect
Entitled : func(subID int64) bool Inspect
EntitledFor : func(planID int64, subscriber .uverse.address) bool Inspect
ActiveSubID : func(planID int64, subscriber .uverse.address) (int64, bool) Inspect
PlanInfo : func(planID int64) (provider .uverse.address, title string, price int64, periodBlocks int64, planFeeBps int64, status string, lifetimeSubs int64) Inspect
SubInfo : func(subID int64) (planID int64, subscriber .uverse.address, provider .uverse.address, price int64, paidThrough int64, periods int64, status string) Inspect
PaidThrough : func(subID int64) int64 Inspect
RenewableFrom : func(subID int64) (from int64, until int64) Inspect
Admin : func() .uverse.address Inspect
PendingAdmin : func() .uverse.address Inspect
FeeRecipient : func() .uverse.address Inspect
FeeBps : func() int64 Inspect
NumPlans : func() int64 Inspect
NumSubs : func() int64 Inspect
UsersTotal : func() int64 Inspect
FeesAccrued : func() int64 Inspect
Liabilities : func() int64 Inspect
BalanceOf : func(a .uverse.address) int64 Inspect
Address : func() .uverse.address Inspect
Held : func() int64 Inspect
Render : func(path string) string Inspect
renderHome : func() string Inspect
expireInPlace : func(s *subscriptions.sub) Inspect
releaseSlots : func(s *subscriptions.sub) Inspect
assertNoSend : func() Inspect
assertAdmin : func(caller .uverse.address) Inspect
mustGetPlan : func(id int64) *subscriptions.plan Inspect
mustGetSub : func(id int64) *subscriptions.sub Inspect
counter : func(tree *v0.Tree, a .uverse.address) *int64 Inspect
padID : func(id int64) string Inspect
itoa : func(n int64) string Inspect