/
utils.go
53 lines (48 loc) · 1.21 KB
/
utils.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
package tokenmeta
import (
"strconv"
"github.com/portto/solana-go-sdk/common"
)
func GetTokenMetaPubkey(mint common.PublicKey) (common.PublicKey, error) {
metadataAccount, _, err := common.FindProgramAddress(
[][]byte{
[]byte("metadata"),
common.MetaplexTokenMetaProgramID.Bytes(),
mint.Bytes(),
},
common.MetaplexTokenMetaProgramID,
)
if err != nil {
return common.PublicKey{}, err
}
return metadataAccount, nil
}
func GetMasterEdition(mint common.PublicKey) (common.PublicKey, error) {
msaterEdtion, _, err := common.FindProgramAddress(
[][]byte{
[]byte("metadata"),
common.MetaplexTokenMetaProgramID.Bytes(),
mint.Bytes(),
[]byte("edition"),
},
common.MetaplexTokenMetaProgramID,
)
if err != nil {
return common.PublicKey{}, err
}
return msaterEdtion, nil
}
func GetEditionMark(mint common.PublicKey, edition uint64) (common.PublicKey, error) {
editionNumber := edition / EDITION_MARKER_BIT_SIZE
pubkey, _, err := common.FindProgramAddress(
[][]byte{
[]byte("metadata"),
common.MetaplexTokenMetaProgramID.Bytes(),
mint.Bytes(),
[]byte("edition"),
[]byte(strconv.FormatUint(editionNumber, 10)),
},
common.MetaplexTokenMetaProgramID,
)
return pubkey, err
}