-
Notifications
You must be signed in to change notification settings - Fork 2
/
nft.go
71 lines (59 loc) · 1.51 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
67
68
69
70
71
package types
import (
"github.com/Electronic-Signatures-Industries/ancon-protocol/x/anconprotocol/exported"
sdk "github.com/cosmos/cosmos-sdk/types"
)
var _ exported.NFT = BaseNFT{}
// NewAnconNFT creates a new NFT instance
func NewAnconNFT(id, name string, owner sdk.AccAddress, uri, didOwner string, price uint64) BaseNFT {
return BaseNFT{
Id: id,
Name: name,
Owner: owner.String(),
DidOwner: didOwner,
URI: uri,
Price: price,
}
}
// NewBaseNFT creates a new NFT instance
func NewBaseNFT(id, name string, owner sdk.AccAddress, uri, didOwner string) BaseNFT {
return BaseNFT{
Id: id,
Name: name,
Owner: owner.String(),
DidOwner: didOwner,
URI: uri,
}
}
// 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
}
// 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)
}