-
Notifications
You must be signed in to change notification settings - Fork 1
/
sellerConfigInfo.ts
50 lines (44 loc) · 1.78 KB
/
sellerConfigInfo.ts
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
import { Query, Resolver } from 'type-graphql';
import 'reflect-metadata';
import assert from 'assert';
import { getChain } from '../../chains';
import { SellerConfigInfo } from '../model/sellerConfigInfo.model';
import { BuyerChainClient } from '../../wsClient';
import { WalletClient } from '../../walletClient';
@Resolver()
export class SellerConfigInfoResolver {
@Query(() => SellerConfigInfo)
async sellerConfigInfo(): Promise<SellerConfigInfo> {
const { config } = getChain();
assert(config != null);
const registrationPrice = await (
await BuyerChainClient.getInstance().init()
).getDomainRegistrationPrice(config.sellerChain.token);
const walletClient = await WalletClient.getInstance().init();
await walletClient.init();
assert(registrationPrice != null);
return new SellerConfigInfo({
isServiceOperational: !config.sellerIndexer.processingDisabled,
sellerChain: config.sellerChain.chainName,
sellerChainPrefix: config.sellerChain.prefix,
sellerTreasuryAccount: WalletClient.addressFromAnyToFormatted(
walletClient.account.sellerTreasuryPubKey,
28
),
sellerApiAuthTokenManager: WalletClient.addressFromAnyToFormatted(
walletClient.account.sellerIndexerAuthTokenMngEd25519.publicKey,
28
),
dmnRegPendingOrderExpTime: config.sellerIndexer.dmnRegPendingOrderExpTime,
domainHostChain: config.buyerChain.chainName,
domainHostChainPrefix: config.buyerChain.prefix,
sellerToken: {
name: config.sellerChain.token.name,
decimal: config.sellerChain.token.decimal
},
remarkProtName: config.sellerChain.remark.protName,
remarkProtVersion: config.sellerChain.remark.version,
domainRegistrationPriceFixed: registrationPrice
});
}
}