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

escrow_v4 source realm

Constants 5

const PlatformFeePct, CancelFeePct, AutoRefundBlks, AutoResolveBlks, UnfundedExpiryBlks, MaxTitleLen, MaxDescLen, MaxMilestones, MinMilestoneAmount, maxMilestonesArgLen, MaxActivePerClient

 1const (
 2	// PlatformFeePct is only the fail-safe fallback rate (see resolveFee); the
 3	// live rate is cfg.GetFeeBPS(laneService), read at each payout.
 4	PlatformFeePct = 2
 5	// CancelFeePct is paid to the freelancer from each funded milestone when
 6	// the client cancels. Escrow-internal, not a protocol fee.
 7	CancelFeePct = 5
 8	// Timeouts, in blocks, as in v3 (sized at 3 s per block; at gnoland-1's
 9	// ~3.3 s they are ~33 and ~31 days). Blocks inside a pause's blocking
10	// window do not count (see the pause section).
11	AutoRefundBlks  = int64(864000)
12	AutoResolveBlks = int64(806400)
13	// UnfundedExpiryBlks: a contract none of whose milestones was ever funded
14	// can be cancelled by anyone after this many blocks, freeing its slot.
15	UnfundedExpiryBlks = AutoRefundBlks
16
17	MaxTitleLen        = 200  // bytes, after sanitising (also bounds the input)
18	MaxDescLen         = 5000 // bytes, after sanitising (also bounds the input)
19	MaxMilestones      = 20
20	MinMilestoneAmount = int64(1000) // 0.001 GNOT: below ~50 ugnot a 2% fee truncates to 0
21	// maxMilestonesArgLen bounds the raw milestones argument before parsing:
22	// 20 entries of a 200-byte title, a 19-digit amount and separators, with
23	// room for surrounding spaces.
24	maxMilestonesArgLen = MaxMilestones * (MaxTitleLen + 64)
25
26	// MaxActivePerClient bounds the open contracts one client address may
27	// hold. It counts only contracts the address created, never those naming
28	// it as freelancer, so nobody can use up someone else's slots, and it
29	// bounds what one key can lock (five of the largest contracts are about
30	// 15 GNOT of storage deposit). There is no global cap: nothing iterates
31	// over every contract, so a global number would bound no gas and would
32	// only give a funded attacker a switch to turn escrow off for everyone.
33	MaxActivePerClient = 5
34)
source

const MaxPauseBlks, PauseCooldownBlks

1const (
2	// MaxPauseBlks is the blocking window: about 7 days at gnoland-1's
3	// observed average of about 3.3 s per block (7*24*3600/3.3 = 183,273).
4	MaxPauseBlks = int64(183273)
5	// PauseCooldownBlks is the minimum gap between an Unpause and the next
6	// Pause, so a pause can hold exits shut at most half of the time.
7	PauseCooldownBlks = MaxPauseBlks
8)
source

const RenderPageSize

1const RenderPageSize = 20
source

RenderPageSize is the number of contracts listed per home page.

Functions 38

func AcceptFeeRecipient

crossing Action
1func AcceptFeeRecipient(cur realm)
source

AcceptFeeRecipient completes the rotation. Only the staged address may call it, which proves it can transact.

func AcceptOwnership

crossing Action
1func AcceptOwnership(cur realm)
source

AcceptOwnership completes the handoff. Only the staged address may call it, so the outgoing admin cannot collapse the two steps into one.

func ArchiveContract

crossing Action
1func ArchiveContract(cur realm, contractId string)
source

ArchiveContract deletes a settled contract (completed or cancelled, with nothing escrowed). Client only. The freed bytes shrink the realm's storage, and the chain refunds their storage deposit to the signer of this message (see DESIGN.md), so the client, who paid for the contract when creating it, gets that deposit back. The id is never reused. The ContractArchived event is the permanent record; nothing of the contract stays in realm state.

func CancelContract

crossing Action
1func CancelContract(cur realm, contractId string)
source

CancelContract cancels an active contract. Client only. Funded milestones are refunded minus CancelFeePct, which goes to the freelancer; completed milestones are paid to the freelancer minus the service fee.

func ClaimDisputeTimeout

crossing Action
1func ClaimDisputeTimeout(cur realm, contractId string, milestoneIdx int)
source

ClaimDisputeTimeout resolves a dispute the admin has not acted on within AutoResolveBlks (blocking-window blocks excluded), following the pre-dispute status: a delivered milestone (MsCompleted) pays the freelancer minus the fee, an undelivered one (MsFunded) refunds the client. Anyone may call.

func ClaimRefund

crossing Action
1func ClaimRefund(cur realm, contractId string, milestoneIdx int)
source

ClaimRefund refunds a funded milestone nobody completed within AutoRefundBlks (blocking-window blocks excluded). Anyone may call; the client receives the funds. If no milestone then holds funds the contract is cancelled, pending milestones included (v3 behaviour).

func CompleteMilestone

crossing Action
1func CompleteMilestone(cur realm, contractId string, milestoneIdx int)
source

CompleteMilestone marks a funded milestone delivered. Freelancer only.

func CreateContract

crossing Action
1func CreateContract(cur realm, freelancer address, title, description, milestones string) string
source

CreateContract creates a new escrow contract with milestones, as the caller's client. Milestones format: "title1:amount1,title2:amount2". The caller must be a user (a direct call or the user's own run script), so a realm cannot mint client identities with cur.Sub to hold slots.

func ExpireUnfunded

crossing Action
1func ExpireUnfunded(cur realm, contractId string)
source

ExpireUnfunded cancels a contract none of whose milestones was ever funded, once UnfundedExpiryBlks have passed since creation (blocking-window blocks excluded). Anyone may call. It frees the client's slot and moves no coins; it does not delete, so the storage deposit stays for the client's ArchiveContract.

func FundMilestone

crossing Action
1func FundMilestone(cur realm, contractId string, milestoneIdx int)
source

FundMilestone deposits exactly the milestone amount. Client only, and only as a direct user call: the tx-level send lands on the message's target realm, so from an intermediary realm the coins would never reach escrow while the milestone was marked funded.

func GetActiveCount

Action
1func GetActiveCount() int
source

GetActiveCount returns the number of open contracts (not completed or cancelled).

func GetClientActiveCount

Action
1func GetClientActiveCount(client address) int
source

GetClientActiveCount returns the open contracts created by client, bounded by MaxActivePerClient.

func GetClientContractsJSON

Action
1func GetClientContractsJSON(client address, before string, limit int) string
source

GetClientContractsJSON pages the live contracts a client created, newest first: {"items":[{"id","status","createdAtHeight"}...],"next":cursor|null}. before is "" for the first page or the previous page's next cursor; limit is clamped to 1..50.

func GetCreatedCount

Action
1func GetCreatedCount() int
source

GetCreatedCount returns every contract ever created; ids run from 0 to GetCreatedCount()-1 and are never reused.

func GetLiveCount

Action
1func GetLiveCount() int
source

GetLiveCount returns the contracts still stored: open ones plus settled ones their client has not archived.

func IsPaused

Action
1func IsPaused() bool
source

IsPaused reports whether the pause flag is set. Exits may already have reopened: see PauseState().ExitsOpen.

func Pause

crossing Action
1func Pause(cur realm)
source

Pause stops new money and, for MaxPauseBlks, every other state change. Admin only. Refused while paused and during the cooldown after an Unpause.

func ProposeFeeRecipient

crossing Action
1func ProposeFeeRecipient(cur realm, recipient address)
source

ProposeFeeRecipient stages a new fallback fee recipient. Admin only.

func RaiseDispute

crossing Action
1func RaiseDispute(cur realm, contractId string, milestoneIdx int)
source

RaiseDispute escalates a funded or completed milestone to the admin. Client or freelancer.

func RealmAddress

Action
1func RealmAddress() string
source

RealmAddress is the NF-2 canonical name for the realm's own address.

func ReleaseFunds

crossing Action
1func ReleaseFunds(cur realm, contractId string, milestoneIdx int)
source

ReleaseFunds pays a completed milestone to the freelancer, minus the fee. Client, or admin as the trusted arbiter (v3 behaviour).

func ResolveDispute

crossing Action
1func ResolveDispute(cur realm, contractId string, milestoneIdx int, refundClient bool)
source

ResolveDispute settles a disputed milestone. Admin only. refundClient=true refunds the client in full; false pays the freelancer minus the fee. The contract then returns to active, stays disputed if another milestone still is, or settles: completed if every milestone is released, cancelled if every milestone is released or refunded.

func TotalLiabilities

Action
1func TotalLiabilities() int64
source

TotalLiabilities returns the ugnot the realm owes across funded, completed and disputed milestones.

func TransferOwnership

crossing Action
1func TransferOwnership(cur realm, newAdmin address)
source

TransferOwnership stages a handoff to newAdmin. Admin only. Calling it again replaces the staged address.

func Unpause

crossing Action
1func Unpause(cur realm)
source

Unpause resumes normal operation and starts the cooldown. Admin only.

Types 8

type Contract

struct
 1type Contract struct {
 2	ID          string
 3	Client      address
 4	Freelancer  address
 5	Title       string
 6	Description string
 7	Status      ContractStatus
 8	CreatedAt   int64 // block height
 9	Milestones  []Milestone
10
11	createdPauseMark int64 // pausedBlocksAt(CreatedAt), for UnfundedExpiryBlks
12}
source

type GovernanceContract

struct
1type GovernanceContract struct {
2	Exists                  bool
3	ID, ContentHash, Status string
4	Client, Freelancer      address
5	Count                   int
6	Milestones              [20]GovernanceMilestone
7}
source

type GovernanceFeeTerms

struct
1type GovernanceFeeTerms struct {
2	RawBPS, EffectiveBPS                             int64
3	RawTreasury, FallbackTreasury, EffectiveTreasury address
4}
source

type GovernanceMilestone

struct
1type GovernanceMilestone struct {
2	ID                                int
3	Amount                            int64
4	Status                            string
5	FundedAt, CompletedAt, DisputedAt int64
6	PreDisputeStatus                  string
7}
source

type Milestone

struct
 1type Milestone struct {
 2	ID               int // equals the milestone's index
 3	Title            string
 4	Amount           int64 // ugnot
 5	Status           MilestoneStatus
 6	FundedAt         int64           // block height (0 if not funded)
 7	CompletedAt      int64           // block height (0 if not completed)
 8	DisputedAt       int64           // block height (0 if not disputed)
 9	PreDisputeStatus MilestoneStatus // status before dispute (MsFunded or MsCompleted)
10
11	fundedPauseMark   int64 // pausedBlocksAt(FundedAt), for AutoRefundBlks
12	disputedPauseMark int64 // pausedBlocksAt(DisputedAt), for AutoResolveBlks
13}
source

type PauseInfo

struct
1type PauseInfo struct {
2	Paused        bool  // set by Pause, cleared only by Unpause
3	PausedAt      int64 // height of the current pause (0 when not paused)
4	ExitsReopenAt int64 // PausedAt + MaxPauseBlks (0 when not paused)
5	ExitsOpen     bool  // false only inside a blocking window
6	CooldownUntil int64 // first height at which Pause is accepted
7	PausedBlocks  int64 // total blocking-window blocks so far (clocks skip them)
8}
source

PauseInfo is the read-back of the pause state.

Imports 13

Source Files 4