-
Notifications
You must be signed in to change notification settings - Fork 30
/
nft.go
66 lines (53 loc) · 1.32 KB
/
nft.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package types
import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/irisnet/irismod/modules/nft/exported"
)
var _ exported.NFT = BaseNFT{}
// NewBaseNFT creates a new NFT instance
func NewBaseNFT(id, name string, owner sdk.AccAddress, uri, uriHash, data string) BaseNFT {
return BaseNFT{
Id: id,
Name: name,
Owner: owner.String(),
URI: uri,
UriHash: uriHash,
Data: data,
}
}
// GetID return the id of BaseNFT
func (bnft BaseNFT) GetID() string {
return bnft.Id
}
// GetName return the name of BaseNFT
func (bnft BaseNFT) GetName() string {
return bnft.Name
}
// GetOwner return the owner of BaseNFT
func (bnft BaseNFT) GetOwner() sdk.AccAddress {
owner, _ := sdk.AccAddressFromBech32(bnft.Owner)
return owner
}
// GetURI return the URI of BaseNFT
func (bnft BaseNFT) GetURI() string {
return bnft.URI
}
// GetURIHash return the UriHash of BaseNFT
func (bnft BaseNFT) GetURIHash() string {
return bnft.UriHash
}
// GetData return the Data of BaseNFT
func (bnft BaseNFT) GetData() string {
return bnft.Data
}
// ----------------------------------------------------------------------------
// NFT
// NFTs define a list of NFT
type NFTs []exported.NFT
// NewNFTs creates a new set of NFTs
func NewNFTs(nfts ...exported.NFT) NFTs {
if len(nfts) == 0 {
return NFTs{}
}
return NFTs(nfts)
}