forked from Colm3na/polkastats-backend-v3
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathimplementOpalAPI.ts
More file actions
32 lines (27 loc) · 1.15 KB
/
implementOpalAPI.ts
File metadata and controls
32 lines (27 loc) · 1.15 KB
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
import {
UpDataStructsCollectionLimits,
UpDataStructsRpcCollection,
UpDataStructsTokenData,
} from '@unique-nft/quartz-mainnet-types';
import ImplementorAPI from './implementorAPI';
export class ImplementOpalAPI extends ImplementorAPI {
async impGetCollection(collectionId): Promise<UpDataStructsRpcCollection | null> {
const result = await this.api.rpc.unique.collectionById(collectionId);
return result.isSome ? result.value : null;
}
async impGetEffectiveCollectionLimits(collectionId): Promise<UpDataStructsCollectionLimits | null> {
const result = await this.api.rpc.unique.effectiveCollectionLimits(collectionId);
return result.isSome ? result.value : null;
}
async impGetCollectionCount() {
const collectionStats = await this.api.rpc.unique.collectionStats();
return collectionStats?.created.toNumber();
}
async impGetToken(collectionId, tokenId): Promise<UpDataStructsTokenData> {
const tokenData = await this.api.rpc.unique.tokenData(collectionId, tokenId);
return tokenData || null;
}
async impGetTokenCount(collectionId) {
return (await this.api.rpc.unique.lastTokenId(collectionId)).toNumber();
}
}