-
Notifications
You must be signed in to change notification settings - Fork 3
/
Metaplex.js
54 lines (46 loc) · 1.24 KB
/
Metaplex.js
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
import {NativeModules} from 'react-native';
const {Metaplex} = NativeModules;
class MetaplexBridge {
constructor(environment, ownerPublicKey) {
// environment -> devnet/mainnet/testnet | default -> mainnet
// ownerPublicKey -> public key of owner wallet
Metaplex.create(environment, ownerPublicKey);
}
findByMint(mintKey) {
// finds nft for given mint key
const promise = new Promise((resolve, reject) => {
Metaplex.findByMint(mintKey, (data, error) => {
if (error) {
reject(error);
}
resolve(data);
});
});
return promise;
}
findAllByOwner(ownerPublicKey) {
// find all nfts by a given owner public key
const promise = new Promise((resolve, reject) => {
Metaplex.findAllByOwner(ownerPublicKey, (data, error) => {
if (error) {
reject(error);
}
resolve(data);
});
});
return promise;
}
metadata(mintKey) {
// finds nft metadata for given mint key
const promise = new Promise((resolve, reject) => {
Metaplex.metadata(mintKey, (data, error) => {
if (error) {
reject(error);
}
resolve(data);
});
});
return promise;
}
}
export default MetaplexBridge;