Skip to content

Commit

Permalink
chore: update test4.gno.land backup
Browse files Browse the repository at this point in the history
  • Loading branch information
gfanton authored and github-actions[bot] committed Sep 28, 2024
1 parent 86b86bc commit f4daced
Show file tree
Hide file tree
Showing 276 changed files with 22,667 additions and 10 deletions.
21 changes: 12 additions & 9 deletions test4.gno.land/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## TXs
```
19691
19758
```

## addpkgs
Expand All @@ -11,18 +11,18 @@

## top realm calls
```
4218 "gno.land/r/demo/wugnot"
4226 "gno.land/r/demo/wugnot"
1142 "gno.land/r/gnoswap/gns"
834 "gno.land/r/gnoswap/v2/gns"
837 "gno.land/r/gnoswap/v2/gns"
764 "gno.land/r/gnoswap/router"
755 "gno.land/r/gnoswap/position"
671 "gno.land/r/gnoswap/v2/router"
674 "gno.land/r/gnoswap/v2/router"
654 "gno.land/r/gnoswap/gnft"
608 "gno.land/r/onbloc/usdc"
609 "gno.land/r/onbloc/usdc"
569 "gno.land/r/onbloc/foo"
549 "gno.land/r/gnoswap/v2/position"
550 "gno.land/r/gnoswap/v2/position"
390 "gno.land/r/gnoswap/v2/staker"
367 "gno.land/r/gnoswap/v2/gnft"
368 "gno.land/r/gnoswap/v2/gnft"
341 "gno.land/r/onbloc/bar"
320 "gno.land/r/gnoswap/staker"
256 "gno.land/r/onbloc/baz"
Expand All @@ -32,17 +32,19 @@
112 "gno.land/r/gnoswap/pool"
92 "gno.land/r/gov/dao"
86 "gno.land/r/demo/users"
81 "gno.land/r/teritori/social_feeds"
85 "gno.land/r/teritori/social_feeds"
70 "gno.land/r/g1ngywvql2ql7t8uzl63w60eqcejkwg4rm4lxdw9/candy20"
42 "gno.land/r/gnoswap/v2/pool"
30 "gno.land/r/onbloc/qux"
26 "gno.land/r/g1w6886hdj2tet0seyw6kn8fl92sx06prgd9w9j8/game/v3/diceroller"
25 "gno.land/r/varmeta/demo/v403/domain/registrar"
21 "gno.land/r/g1w62226g8hykfmtuasvz80rdf0jl6phgxsphh5v/testing/openocean"
20 "gno.land/r/g1w6886hdj2tet0seyw6kn8fl92sx06prgd9w9j8/games/diceroller"
19 "gno.land/r/teritori/profile"
18 "gno.land/r/teritori/projects_manager"
18 "gno.land/r/varmeta/demo/v1/domain/registrar"
15 "gno.land/r/varmeta/demo/v3/domain/registrar"
12 "gno.land/r/varmeta/demo/v405/domain/registrar"
11 "gno.land/r/demo/flippando"
11 "gno.land/r/g1ngywvql2ql7t8uzl63w60eqcejkwg4rm4lxdw9/minus"
11 "gno.land/r/g1w6886hdj2tet0seyw6kn8fl92sx06prgd9w9j8/vmt"
Expand All @@ -65,9 +67,9 @@
6 "gno.land/r/g1w6886hdj2tet0seyw6kn8fl92sx06prgd9w9j8/game/v2/diceroller"
6 "gno.land/r/g1w6886hdj2tet0seyw6kn8fl92sx06prgd9w9j8/games/v2/diceroller"
6 "gno.land/r/varmeta/demo/v38/domain/registrar"
6 "gno.land/r/varmeta/demo/v402/domain/registrar"
6 "gno.land/r/villaquiranm/grc20_launchpad"
5 "gno.land/r/demo/art/millipede"
5 "gno.land/r/varmeta/demo/v402/domain/registrar"
5 "gno.land/r/varmeta/demo1/domain/registrar"
4 "gno.land/r/demo/domain/registrar"
4 "gno.land/r/demo/user"
Expand Down Expand Up @@ -103,6 +105,7 @@
1 "gno.land/r/gnoswap/v2/emission"
1 "gno.land/r/mikecito/grc20_launchpad"
1 "gno.land/r/varmeta/demo/v32/domain/registrar"
1 "gno.land/r/varmeta/demo/v406/domain/registrar"
```

## top faucet requesters
Expand Down
67 changes: 67 additions & 0 deletions test4.gno.land/backup_1979828-2011551.jsonl

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package domain

import (
"time"
)

// Trait represents a key-value pair with an optional display type for metadata attributes
type Trait struct {
DisplayType string // Optional display type (e.g., "date", "number", etc.)
TraitType string // Type of the trait (e.g., "age", "height", etc.)
Value string // Value of the trait
}

// Metadata represents the metadata associated with a domain
type Metadata struct {
Avatar string // URL or identifier for an avatar image
RegistrationTime time.Time // The time when the domain was registered
ExpirationTime time.Time // The time when the domain will be expire
Attributes []Trait // Additional attributes of the domain
Description string // A description of the domain
ContactInfo string // Contact information for the domain owner
RenewalFee string // The fee required to renew the domain, represented as a string
}

// NewMetadata creates a new Metadata instance
func NewMetadata(avatar, description, contactInfo, renewalFee string,
registrationTime, expirationTime time.Time, attributes []Trait,
) Metadata {
return Metadata{
Avatar: avatar,
RegistrationTime: registrationTime,
ExpirationTime: expirationTime,
RenewalFee: renewalFee,
Attributes: attributes,
Description: description,
ContactInfo: contactInfo,
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,236 @@
package domain

import (
"std"
"time"

"gno.land/p/demo/avl"
"gno.land/p/varmeta/demo/v4/grc/grc721"
)

// domainRegistry represents a registry for domain names with metadata
type domainRegistry struct {
domains grc721.IGRC721 // Interface for basic NFT functionality
metadata *avl.Tree // AVL tree for storing domain metadata
expDate time.Time
}

// DomainRegistry defines the methods for managing domain names and metadata
type DomainRegistry interface {
BalanceOf(owner std.Address) (uint64, error)
OwnerOf(domainName string) (std.Address, error)
SafeTransferFrom(from, to std.Address, domainName string) error
TransferFrom(from, to std.Address, domainName string) error
Approve(approved std.Address, domainName string) error
SetApprovalForAll(operator std.Address, approved bool) error
GetApproved(domainName string) (std.Address, error)
IsApprovedForAll(owner, operator std.Address) bool
Mint(to std.Address, domainName string) error

RegisterDomain(owner std.Address, domainName string, metadata Metadata, dur time.Duration) error
SetDomainData(domainName string, metadata Metadata) error
GetDomainData(domainName string, field MetadataField) (Metadata, error)
GetDomainFields(domainName string, fields []MetadataField) (Metadata, error)
RenewDomain(domainName string, additionalDuration time.Duration) error
GetExpirationDate(domainName string) time.Time
SetExpirationDate(domainName string, expDate time.Time) bool
}

// NewDomainRegistry creates a new domain registry with metadata extensions
func NewDomainRegistry(name, symbol string) *domainRegistry {
registry := grc721.NewBasicNFT(name, symbol)

return &domainRegistry{
domains: registry,
metadata: avl.NewTree(),
}
}

// RegisterDomain registers a new domain with the given metadata
func (d *domainRegistry) RegisterDomain(owner std.Address, domainName string, metadata Metadata, dur time.Duration) error {
err := d.domains.Mint(owner, grc721.TokenID(domainName))
if err != nil {
return err
}
d.expDate = time.Now().Add(dur)
d.metadata.Set(domainName, metadata)

return nil
}

// RenewDomain extends the expiration time of a domain name
func (d *domainRegistry) RenewDomain(domainName string, additionalDuration time.Duration) error {
_, found := d.metadata.Get(domainName)
if !found {
return ErrInvalidDomainName
}

owner, err := d.domains.OwnerOf(grc721.TokenID(domainName))
if err != nil {
return err
}

caller := std.PrevRealm().Addr()
if caller != owner {
return ErrUnauthorized
}

// set new expiration date
d.expDate = d.expDate.Add(additionalDuration)
return nil
}

// SetDomainData sets the metadata for a given domain name
func (d *domainRegistry) SetDomainData(domainName string, metadata Metadata) error {
owner, err := d.domains.OwnerOf(grc721.TokenID(domainName))
if err != nil {
return err
}

caller := std.PrevRealm().Addr()
if caller != owner {
return ErrUnauthorized
}

d.metadata.Set(domainName, metadata)
return nil
}

// GetDomainFields retrieves multiple fields of metadata for a given domain
func (d *domainRegistry) GetDomainFields(domainName string, fields []MetadataField) (Metadata, error) {
data, found := d.metadata.Get(domainName)
if !found {
return Metadata{}, ErrInvalidDomainName
}

metadata := data.(Metadata)

if len(fields) == 0 {
return metadata, nil
}

var result Metadata
for _, field := range fields {
switch field {
case FieldAvatar:
result.Avatar = metadata.Avatar
case FieldRegistrationTime:
result.RegistrationTime = metadata.RegistrationTime
case FieldExpirationTime:
result.ExpirationTime = metadata.ExpirationTime
case FieldRenewalFee:
result.RenewalFee = metadata.RenewalFee
case FieldAttributes:
result.Attributes = metadata.Attributes
case FieldDescription:
result.Description = metadata.Description
case FieldContactInfo:
result.ContactInfo = metadata.ContactInfo
default:
return Metadata{}, ErrInvalidMetadataField
}
}

return result, nil
}

// GetDomainData retrieves metadata for a given domain
func (d *domainRegistry) GetDomainData(domainName string, field MetadataField) (Metadata, error) {
data, found := d.metadata.Get(domainName)
if !found {
return Metadata{}, ErrInvalidDomainName
}

metadata := data.(Metadata)

switch field {
case FieldAvatar:
return Metadata{
Avatar: metadata.Avatar,
}, nil
case FieldRegistrationTime:
return Metadata{
RegistrationTime: metadata.RegistrationTime,
}, nil
case FieldExpirationTime:
return Metadata{
ExpirationTime: metadata.ExpirationTime,
}, nil
case FieldRenewalFee:
return Metadata{
RenewalFee: metadata.RenewalFee,
}, nil
case FieldAttributes:
return Metadata{
Attributes: metadata.Attributes,
}, nil
case FieldDescription:
return Metadata{
Description: metadata.Description,
}, nil
case FieldContactInfo:
return Metadata{
ContactInfo: metadata.ContactInfo,
}, nil
default:
return Metadata{}, ErrInvalidMetadataField
}
}

// BalanceOf returns the number of domains owned by a given address
func (d *domainRegistry) BalanceOf(owner std.Address) (uint64, error) {
return d.domains.BalanceOf(owner)
}

// OwnerOf returns the owner of a given domain name
func (d *domainRegistry) OwnerOf(domainName string) (std.Address, error) {
return d.domains.OwnerOf(grc721.TokenID(domainName))
}

// SafeTransferFrom safely transfers a domain from one address to another
func (d *domainRegistry) SafeTransferFrom(from, to std.Address, domainName string) error {
return d.domains.SafeTransferFrom(from, to, grc721.TokenID(domainName))
}

// TransferFrom transfers a domain from one address to another
func (d *domainRegistry) TransferFrom(from, to std.Address, domainName string) error {
return d.domains.TransferFrom(from, to, grc721.TokenID(domainName))
}

// Approve grants approval to another address to manage a specific domain
func (d *domainRegistry) Approve(approved std.Address, domainName string) error {
return d.domains.Approve(approved, grc721.TokenID(domainName))
}

// SetApprovalForAll sets approval for an operator to manage all domains of the owner
func (d *domainRegistry) SetApprovalForAll(operator std.Address, approved bool) error {
return d.domains.SetApprovalForAll(operator, approved)
}

// GetApproved returns the approved address for a specific domain
func (d *domainRegistry) GetApproved(domainName string) (std.Address, error) {
return d.domains.GetApproved(grc721.TokenID(domainName))
}

// IsApprovedForAll checks if an operator is approved to manage all domains of the owner
func (d *domainRegistry) IsApprovedForAll(owner, operator std.Address) bool {
return d.domains.IsApprovedForAll(owner, operator)
}

// Mint creates a new domain for a given address
func (d *domainRegistry) Mint(to std.Address, domainName string) error {
return d.domains.Mint(to, grc721.TokenID(domainName))
}

func (d *domainRegistry) GetExpirationDate(domainName string) time.Time {
return d.expDate
}

func (d *domainRegistry) SetExpirationDate(domainName string, expDate time.Time) bool {
_, found := d.metadata.Get(domainName)
if !found {
return false
}
d.expDate = expDate
return true
}
Loading

0 comments on commit f4daced

Please sign in to comment.