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

Community realm. Read the code first. Community realm, deployed by its author. Read the code before you interact or send coins.

nft.gno

2.78 Kb · 72 lines
 1package nslogic
 2
 3import (
 4	"strings"
 5
 6	"gno.land/r/nym-mnsrehearsal001/nsdata/v1"
 7)
 8
 9// This realm only exposes the WRITE side of the GRC-721 surface. Reads
10// (BalanceOf, OwnerOf, TokenURI, GetApproved, IsApprovedForAll, and
11// every listing/status/profile query) have no authorization check to
12// perform and are served directly by nsdata — no reason to duplicate
13// them here.
14
15func isDomainToken(tid string) bool {
16	return strings.HasPrefix(tid, "*")
17}
18
19// isTokenValid checks the underlying domain/name's expiry via nsdata's
20// own validity reads — the anti-scam pattern (an expired name must not
21// be sellable) enforced at the transfer boundary, not just at read time.
22func isTokenValid(tid string) bool {
23	if isDomainToken(tid) {
24		return nsdata.IsDomainValid(tid[1:])
25	}
26	label, domainLabel := splitTokenID(tid)
27	return nsdata.IsNameValid(label, domainLabel)
28}
29
30// assertNotFrozen is the check that made freezing mean something.
31//
32// FreezeName set a bit that only ever gated RE-REGISTRATION after a
33// lapse. Transfer, approval, listing and sale all ignored it, so the one
34// manual lever the takedown process relies on did nothing about the case
35// it exists for: a disputed or stolen name could be approved to a fresh
36// wallet, listed and sold while the interface showed it as frozen.
37//
38// The bit was already stored and already readable — GetNameInfo returns
39// it — so this needs no change to the permanent vault, only the read
40// that was never performed.
41func assertNotFrozen(tid string) {
42	label, domainLabel := splitTokenID(tid)
43	_, _, _, _, frozen, _ := nsdata.GetNameInfo(label, domainLabel)
44	if frozen {
45		panic("nslogic: this name is frozen and cannot be transferred or approved")
46	}
47}
48
49/*
50THERE ARE NO TRANSFER OR APPROVAL FUNCTIONS HERE ANY MORE.
51
52Approve, SetApprovalForAll, TransferFrom and SafeTransferFrom lived in this
53realm, and they could only work while this realm was the one place a
54transfer could happen. In this generation ownership is in nsnft, and nsnft
55sees whoever calls it as the caller — so a logic realm calling in on a
56user's behalf would be refused as not approved, correctly. A logic realm
57that COULD move people's tokens would be a logic realm that could steal
58them.
59
60So: holders approve and transfer on nsnft directly, and marketplaces —
61ours included — settle as approved operators there.
62
63The two policies these wrappers enforced moved to where they bind every
64path, not just ours:
65  - frozen names: a hold bit on the token in nsnft (nsdata.SetNameFrozen)
66  - free-tier names: a hold bit set at mint (nsdata.RegisterNameRecord)
67Expired names are refused by our marketplace and never resolve; an
68external marketplace can move an expired token, as with any NFT. See
69MIGRATION.md, second attempt, rule 6.
70
71The helpers above stay because the marketplace-facing reads use them.
72*/