forked from Colm3na/polkastats-backend-v3
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathopalAPI.ts
More file actions
58 lines (50 loc) · 1.66 KB
/
opalAPI.ts
File metadata and controls
58 lines (50 loc) · 1.66 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
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
import { CollectionInfoWithSchema, TokenPropertiesResult, UniqueTokenDecoded } from '@unique-nft/sdk/tokens';
import {
UpDataStructsCollectionLimits,
UpDataStructsRpcCollection,
UpDataStructsTokenData,
} from '@unique-nft/unique-mainnet-types';
import { ImplementOpalAPI } from '../implement/implementOpalAPI';
import AbstractAPI from './abstractAPI';
type CollectionData = {
collection: UpDataStructsRpcCollection | null,
effectiveCollectionLimits: UpDataStructsCollectionLimits | null
collectionSdk: CollectionInfoWithSchema | null
};
export class OpalAPI extends AbstractAPI {
impl: ImplementOpalAPI;
async getCollection(id): Promise<CollectionData> {
const [collection, effectiveCollectionLimits, collectionSdk] = await Promise.all([
this.impl.impGetCollection(id),
this.impl.impGetEffectiveCollectionLimits(id),
this.impl.impGetCollectionSdk(id)
]);
return {
collection,
effectiveCollectionLimits,
collectionSdk
};
}
async getToken(collectionId, tokenId): Promise<{
rawToken: UpDataStructsTokenData | null,
tokenDecoded: UniqueTokenDecoded | null,
tokenProperties: TokenPropertiesResult | null
}> {
const [rawToken, tokenDecoded, tokenProperties] = await Promise.all([
this.impl.impGetToken(collectionId, tokenId),
this.impl.impGetTokenSdk(collectionId, tokenId),
this.impl.impGetTokenPropertiesSdk(collectionId, tokenId)
]);
return {
rawToken,
tokenDecoded,
tokenProperties
};
}
getCollectionCount() {
return this.impl.impGetCollectionCount();
}
getTokenCount(collectionId) {
return this.impl.impGetTokenCount(collectionId);
}
}