Class: MarketModuleImpl
market/market.module.MarketModuleImpl
Implements
Table of contents
Constructors
Properties
Methods
- buildDemandDetails
- buildScanSpecification
- publishAndRefreshDemand
- collectMarketProposalEvents
- collectAllOfferProposals
- negotiateProposal
- proposeAgreement
- terminateAgreement
- collectDraftOfferProposals
- signAgreementFromPool
- estimateBudget
- fetchAgreement
- scan
Constructors
constructor
• new MarketModuleImpl(deps
, options?
): MarketModuleImpl
Parameters
Name | Type |
---|---|
deps | Object |
deps.logger | Logger |
deps.yagna | YagnaApi |
deps.paymentApi | IPaymentApi |
deps.activityApi | IActivityApi |
deps.marketApi | IMarketApi |
deps.networkApi | INetworkApi |
deps.networkModule | NetworkModule |
deps.fileServer | IFileServer |
deps.storageProvider | StorageProvider |
options? | Partial <MarketModuleOptions > |
Returns
Defined in
src/market/market.module.ts:243
Properties
events
• events: EventEmitter
<MarketEvents
, any
>
Implementation of
Defined in
src/market/market.module.ts:236
Methods
buildDemandDetails
▸ buildDemandDetails(demandOptions
, orderOptions
, allocation
): Promise
<DemandSpecification
>
Build a DemandSpecification based on the given options and allocation. You can obtain an allocation using the payment module. The method returns a DemandSpecification that can be used to publish the demand to the market, for example using the publishDemand
method.
Parameters
Name | Type |
---|---|
demandOptions | OrderDemandOptions |
orderOptions | OrderMarketOptions |
allocation | Allocation |
Returns
Promise
<DemandSpecification
>
Implementation of
MarketModule.buildDemandDetails
Defined in
src/market/market.module.ts:269
buildScanSpecification
▸ buildScanSpecification(options
): ScanSpecification
Build a ScanSpecification that can be used to scan the market for offers. The difference between this method and buildDemandDetails
is that this method does not require an allocation, doesn't inherit payment properties from GolemNetwork
settings and doesn't provide any defaults. If you wish to set the payment platform, you need to specify it in the ScanOptions.
Parameters
Name | Type |
---|---|
options | ScanOptions |
Returns
Implementation of
MarketModule.buildScanSpecification
Defined in
src/market/market.module.ts:302
publishAndRefreshDemand
▸ publishAndRefreshDemand(demandSpecification
): Observable
<Demand
>
Publishes the specified demand and re-publishes it based on demandSpecification.expirationSec interval
Parameters
Name | Type |
---|---|
demandSpecification | DemandSpecification |
Returns
Observable
<Demand
>
Implementation of
MarketModule.publishAndRefreshDemand
Defined in
src/market/market.module.ts:339
collectMarketProposalEvents
▸ collectMarketProposalEvents(demand
): Observable
<MarketProposalEvent
>
Return an observable that will emit values representing various events related to this demand
Parameters
Name | Type |
---|---|
demand | Demand |
Returns
Observable
<MarketProposalEvent
>
Implementation of
MarketModule.collectMarketProposalEvents
Defined in
src/market/market.module.ts:409
collectAllOfferProposals
▸ collectAllOfferProposals(demand
): Observable
<OfferProposal
>
Subscribes to the proposals for the given demand. If an error occurs, the observable will emit an error and complete. Keep in mind that since this method returns an observable, nothing will happen until you subscribe to it.
This method will just yield all the proposals that will be found for that demand without any additional logic.
The collectDraftOfferProposals is a more specialized variant of offer collection, which includes negotiations and demand re-subscription logic
Parameters
Name | Type |
---|---|
demand | Demand |
Returns
Observable
<OfferProposal
>
Implementation of
MarketModule.collectAllOfferProposals
Defined in
src/market/market.module.ts:416
negotiateProposal
▸ negotiateProposal(offerProposal
, counterDemand
): Promise
<OfferCounterProposal
>
Sends a counter-offer to the provider. Note that to get the provider's response to your counter you should listen to events returned by collectDemandOfferEvents
.
Parameters
Name | Type |
---|---|
offerProposal | OfferProposal |
counterDemand | DemandSpecification |
Returns
Promise
<OfferCounterProposal
>
The counter-proposal that the requestor made to the Provider
Implementation of
MarketModule.negotiateProposal
Defined in
src/market/market.module.ts:423
proposeAgreement
▸ proposeAgreement(proposal
, options?
): Promise
<Agreement
>
Internally
- ya-ts-client createAgreement
- ya-ts-client approveAgreement
- ya-ts-client "wait for approval"
Parameters
Name | Type |
---|---|
proposal | OfferProposal |
options? | AgreementOptions |
Returns
Promise
<Agreement
>
Returns when the provider accepts the agreement, rejects otherwise. The resulting agreement is ready to create activities from.
Implementation of
Defined in
src/market/market.module.ts:444
terminateAgreement
▸ terminateAgreement(agreement
, reason?
): Promise
<Agreement
>
Parameters
Name | Type |
---|---|
agreement | Agreement |
reason? | string |
Returns
Promise
<Agreement
>
The Agreement that has been terminated via Yagna
Implementation of
MarketModule.terminateAgreement
Defined in
src/market/market.module.ts:455
collectDraftOfferProposals
▸ collectDraftOfferProposals(options
): Observable
<OfferProposal
>
Creates a demand for the given package and allocation and starts collecting, filtering and negotiating proposals. The method returns an observable that emits a batch of draft proposals every time the buffer is full. The method will automatically negotiate the proposals until they are moved to the Draft
state. Keep in mind that since this method returns an observable, nothing will happen until you subscribe to it. Unsubscribing from the observable will stop the process and remove the demand from the market.
Parameters
Name | Type |
---|---|
options | Object |
options.demandSpecification | DemandSpecification |
options.pricing | PricingOptions |
options.filter? | OfferProposalFilter |
options.minProposalsBatchSize? | number |
options.proposalsBatchReleaseTimeoutMs? | number |
Returns
Observable
<OfferProposal
>
Implementation of
MarketModule.collectDraftOfferProposals
Defined in
src/market/market.module.ts:467
signAgreementFromPool
▸ signAgreementFromPool(draftProposalPool
, agreementOptions?
, signalOrTimeout?
): Promise
<Agreement
>
Acquire a proposal from the pool and sign an agreement with the provider. If signing the agreement fails, destroy the proposal and try again with another one. The method returns an agreement that's ready to be used. Optionally, you can provide a timeout in milliseconds or an AbortSignal that can be used to cancel the operation early. If the operation is cancelled, the method will throw an error. Note that this method will respect the acquire timeout set in the pool and will throw an error if no proposal is available within the specified time.
Parameters
Name | Type | Description |
---|---|---|
draftProposalPool | DraftOfferProposalPool | The pool of draft proposals to acquire from |
agreementOptions? | AgreementOptions | options used to sign the agreement such as expiration or waitingForApprovalTimeout |
signalOrTimeout? | number | AbortSignal | The timeout in milliseconds or an AbortSignal that will be used to cancel the operation |
Returns
Promise
<Agreement
>
Example
const agreement = await marketModule.signAgreementFromPool(draftProposalPool, 10_000); // throws TimeoutError if the operation takes longer than 10 seconds
Example
const signal = AbortSignal.timeout(10_000);
const agreement = await marketModule.signAgreementFromPool(draftProposalPool, signal); // throws TimeoutError if the operation takes longer than 10 seconds
Implementation of
MarketModule.signAgreementFromPool
Defined in
src/market/market.module.ts:528
estimateBudget
▸ estimateBudget(«destructured»
): number
Estimate the budget for the given order and maximum numbers of agreemnets. Keep in mind that this is just an estimate and the actual cost may vary. The method returns the estimated budget in GLM.
Parameters
Name | Type |
---|---|
«destructured» | Object |
› order | MarketOrderSpec |
› maxAgreements | number |
Returns
number
Implementation of
Defined in
src/market/market.module.ts:628
fetchAgreement
▸ fetchAgreement(agreementId
): Promise
<Agreement
>
Fetch the most up-to-date agreement details from the yagna
Parameters
Name | Type |
---|---|
agreementId | string |
Returns
Promise
<Agreement
>
Implementation of
Defined in
src/market/market.module.ts:653
scan
▸ scan(scanSpecification
): Observable
<ScannedOffer
>
Scan the market for offers that match the given demand specification.
Parameters
Name | Type |
---|---|
scanSpecification | ScanSpecification |
Returns
Observable
<ScannedOffer
>
Implementation of
Defined in
Was this helpful?