1- import type {
2- AddressType ,
3- NetworkProvider ,
4- } from 'cashscript' ;
51import {
62 Contract ,
73 ElectrumNetworkProvider ,
84 TransactionBuilder ,
95} from 'cashscript' ;
6+ import type {
7+ AddressType ,
8+ NetworkProvider ,
9+ } from 'cashscript' ;
10+ import { chaingraphURL } from '../config.js' ;
1011import { NameService } from '../services/name.service.js' ;
1112import { RegistryService } from '../services/registry.service.js' ;
1213import { AuctionTransactionBuilder } from '../transactions/auction.builder.js' ;
1314import { BidTransactionBuilder } from '../transactions/bid.builder.js' ;
1415import { ClaimNameTransactionBuilder } from '../transactions/claim.builder.js' ;
15- import { RecordsTransactionBuilder } from '../transactions/records.builder.js' ;
1616import { PenalisationTransactionBuilder } from '../transactions/penalisation.builder.js' ;
17+ import { RecordsTransactionBuilder } from '../transactions/records.builder.js' ;
18+ import { AccumulationTransactionBuilder } from '../transactions/accumulation.builder.js' ;
19+ import { UtxoManager } from './utxo.manager.js' ;
1720import {
1821 constructContracts ,
1922 lookupAddressCore ,
23+ resolveNameCore ,
2024} from '../util/index.js' ;
2125import type {
2226 AccumulateParams ,
2327 CreateAuctionParams ,
2428 CreateBidParams ,
29+ CreateClaimNameParams ,
2530 CreateRecordsParams ,
26- NameInfo ,
2731 GetAuctionsResponse ,
2832 GetRecordsParams ,
2933 LookupAddressParams ,
3034 ManagerConfig ,
35+ NameInfo ,
3136 PastAuctionResponse ,
3237 PenaliseDuplicateAuctionParams ,
3338 PenaliseIllegalAuctionParams ,
3439 PenalizeInvalidNameParams ,
3540 ResolveNameParams ,
36- CreateClaimNameParams ,
3741} from '../interfaces/index.js' ;
3842import { LookupAddressCoreResponse } from '../interfaces/resolver.js' ;
39- import { resolveNameCore } from '../util/index.js' ;
40- import { chaingraphURL } from '../config.js' ;
4143import type { ParsedRecordsInterface } from '../util/parser.js' ;
42- import { UtxoManager } from './utxo.manager.js' ;
43- import { AccumulationTransactionBuilder } from '../transactions/accumulation.builder.js' ;
4444
4545
4646export class BitcannManager
4747{
48- // Config to build the contracts in the BitCANN system.
49- public category : string ;
50- public minStartingBid : number ;
51- public minBidIncreasePercentage : number ;
52- public inactivityExpiryTime : number ;
53- public minWaitTime : number ;
54- public tld : string ;
55- public creatorIncentiveAddress : string ;
56- public options : { provider : NetworkProvider ; addressType : AddressType } ;
57-
58- // Network provider to use for BCH network operations.
59- public networkProvider : NetworkProvider ;
60- public chaingraphUrl : string ;
61-
62- // Contracts in the BitCANN system.
63- public contracts : Record < string , Contract > ;
64-
65- public utxoManager : UtxoManager ;
66- public accumulationTransactionBuilder : AccumulationTransactionBuilder ;
67- public claimNameTransactionBuilder : ClaimNameTransactionBuilder ;
68- public auctionTransactionBuilder : AuctionTransactionBuilder ;
69- public bidTransactionBuilder : BidTransactionBuilder ;
70- public recordsTransactionBuilder : RecordsTransactionBuilder ;
71- public penalisationTransactionBuilder : PenalisationTransactionBuilder ;
72-
73- public nameService : NameService ;
74- public registryService : RegistryService ;
48+ /**
49+ * The category of the name.
50+ */
51+ private category : string ;
52+ /**
53+ * The minimum starting bid for the name.
54+ */
55+ private minStartingBid : number ;
56+ /**
57+ * The minimum bid increase percentage for the name.
58+ */
59+ private minBidIncreasePercentage : number ;
60+ /**
61+ * The inactivity expiry time before the name can be considered expired.
62+ */
63+ private inactivityExpiryTime : number ;
64+ /**
65+ * The minimum wait time for the name.
66+ */
67+ private minWaitTime : number ;
68+ /**
69+ * The TLD of the name.
70+ */
71+ private tld : string ;
72+ /**
73+ * The creator incentive address for the protocol.
74+ */
75+ private creatorIncentiveAddress : string ;
76+ /**
77+ * The options for the name contract.
78+ */
79+ private options : { provider : NetworkProvider ; addressType : AddressType } ;
80+ /**
81+ * The network provider to use for BCH network operations.
82+ */
83+ private networkProvider : NetworkProvider ;
84+ /**
85+ * The Chaingraph URL to use for lookups.
86+ */
87+ private chaingraphUrl : string ;
88+ /**
89+ * The contracts in the BitCANN system.
90+ */
91+ private contracts : Record < string , Contract > ;
92+ /**
93+ * The UTXO manager for builders and
94+ */
95+ private utxoManager : UtxoManager ;
96+ /**
97+ * The builder for accumulation transactions.
98+ */
99+ private accumulationTransactionBuilder : AccumulationTransactionBuilder ;
100+ /**
101+ * The builder for claim name transactions.
102+ */
103+ private claimNameTransactionBuilder : ClaimNameTransactionBuilder ;
104+ /**
105+ * The builder for auction transactions.
106+ */
107+ private auctionTransactionBuilder : AuctionTransactionBuilder ;
108+ /**
109+ * The builder for bid transactions.
110+ */
111+ private bidTransactionBuilder : BidTransactionBuilder ;
112+ /**
113+ * The builder for records transactions.
114+ */
115+ private recordsTransactionBuilder : RecordsTransactionBuilder ;
116+ /**
117+ * The builder for penalisation transactions.
118+ */
119+ private penalisationTransactionBuilder : PenalisationTransactionBuilder ;
120+ /**
121+ * The service for registry operations.
122+ */
123+ private registryService : RegistryService ;
124+ /**
125+ * The service for name operations.
126+ */
127+ private nameService : NameService ;
75128
129+ /**
130+ * Constructs a new BitcannManager.
131+ *
132+ * @param {ManagerConfig } config - The configuration for the manager.
133+ */
76134 constructor ( config : ManagerConfig )
77135 {
78136 this . category = config . category ;
@@ -168,6 +226,7 @@ export class BitcannManager
168226 this . category ,
169227 this . tld ,
170228 this . options ,
229+ this . chaingraphUrl ,
171230 ) ;
172231
173232 this . registryService = new RegistryService (
@@ -193,14 +252,7 @@ export class BitcannManager
193252 */
194253 public async getRecords ( { name } : GetRecordsParams ) : Promise < ParsedRecordsInterface >
195254 {
196- return this . nameService . fetchRecords ( {
197- name,
198- category : this . category ,
199- tld : this . tld ,
200- options : this . options ,
201- // @ts -ignore
202- electrumClient : this . networkProvider . electrum ,
203- } ) ;
255+ return this . nameService . fetchRecords ( { name } ) ;
204256 }
205257
206258 /**
@@ -210,13 +262,7 @@ export class BitcannManager
210262 */
211263 public async getAuctions ( ) : Promise < GetAuctionsResponse [ ] >
212264 {
213- return this . registryService . getAuctions ( {
214- category : this . category ,
215- networkProvider : this . networkProvider ,
216- contracts : this . contracts ,
217- // @ts -ignore
218- electrumClient : this . networkProvider . electrum ,
219- } ) ;
265+ return this . registryService . getAuctions ( ) ;
220266 }
221267
222268 /**
@@ -227,12 +273,7 @@ export class BitcannManager
227273 */
228274 public async getHistory ( ) : Promise < PastAuctionResponse [ ] >
229275 {
230- return this . registryService . getPastAuctions ( {
231- category : this . category ,
232- Factory : this . contracts . Factory ,
233- // @ts -ignore
234- electrumClient : this . networkProvider . electrum ,
235- } ) ;
276+ return this . registryService . getPastAuctions ( ) ;
236277 }
237278
238279 /**
@@ -243,13 +284,7 @@ export class BitcannManager
243284 */
244285 public async getName ( name : string ) : Promise < NameInfo >
245286 {
246- return this . nameService . getName ( {
247- name,
248- category : this . category ,
249- tld : this . tld ,
250- options : this . options ,
251- registryContract : this . contracts . Registry ,
252- } ) ;
287+ return this . nameService . getName ( { name } ) ;
253288 }
254289
255290 /**
@@ -273,6 +308,7 @@ export class BitcannManager
273308 options : this . options ,
274309 // @ts -ignore
275310 electrumClient : this . networkProvider . electrum ,
311+ chaingraphUrl : this . chaingraphUrl ,
276312 useElectrum,
277313 useChaingraph,
278314 } ) ;
0 commit comments