JS API Reference

Class: MarketApiAdapter

shared/yagna/adapters/market-api-adapter.MarketApiAdapter

Implements

Table of contents

Constructors

Methods

Constructors

constructor

new MarketApiAdapter(yagnaApi, agreementRepo, proposalRepo, demandRepo, logger): MarketApiAdapter

Parameters

NameType
yagnaApiYagnaApi
agreementRepoIAgreementRepository
proposalRepoIProposalRepository
demandRepoIDemandRepository
loggerLogger

Returns

MarketApiAdapter

Defined in

src/shared/yagna/adapters/market-api-adapter.ts:45

Methods

publishDemandSpecification

publishDemandSpecification(spec): Promise<Demand>

Creates a new demand based on the given specification and publishes it to the market. Keep in mind that the demand lasts for a limited time and needs to be refreshed periodically (see refreshDemand method). Use unpublishDemand to remove the demand from the market.

Parameters

NameType
specDemandSpecification

Returns

Promise<Demand>

Implementation of

IMarketApi.publishDemandSpecification

Defined in

src/shared/yagna/adapters/market-api-adapter.ts:53


unpublishDemand

unpublishDemand(demand): Promise<void>

Remove the given demand from the market.

Parameters

NameType
demandDemand

Returns

Promise<void>

Implementation of

IMarketApi.unpublishDemand

Defined in

src/shared/yagna/adapters/market-api-adapter.ts:66


collectMarketProposalEvents

collectMarketProposalEvents(demand): Observable<MarketProposalEvent>

"Publishes" the demand on the network and stats to listen (event polling) for the events representing the feedback

The feedback can fall into four categories:

  • (Initial) We will receive initial offer proposals that were matched by the yagna node which we're using
  • (Negotiations) We will receive responses from providers with draft offer proposals if we decided to counter the initial proposal
  • (Negotiations) We will receive an event representing rejection of our counter-proposal by the provider
  • (Negotiations) We will receive a question from the provider about a certain property as part of the negotiation process (protocol piece not by yagna 0.15)

Parameters

NameType
demandDemand

Returns

Observable<MarketProposalEvent>

A complex object that allows subscribing to these categories of feedback mentioned above

Implementation of

IMarketApi.collectMarketProposalEvents

Defined in

src/shared/yagna/adapters/market-api-adapter.ts:74


counterProposal

counterProposal(receivedProposal, demand): Promise<OfferCounterProposal>

Sends a counter-proposal to the given proposal. Returns the newly created counter-proposal.

Parameters

NameType
receivedProposalOfferProposal
demandDemandSpecification

Returns

Promise<OfferCounterProposal>

Implementation of

IMarketApi.counterProposal

Defined in

src/shared/yagna/adapters/market-api-adapter.ts:159


rejectProposal

rejectProposal(receivedProposal, reason): Promise<void>

Sends a "reject" response for the proposal that was received from the Provider as part of the negotiation process

On the protocol level this means that no further counter-proposals will be generated by the Requestor

Parameters

NameTypeDescription
receivedProposalOfferProposalThe proposal from the provider
reasonstringUser readable reason that should be presented to the Provider

Returns

Promise<void>

Implementation of

IMarketApi.rejectProposal

Defined in

src/shared/yagna/adapters/market-api-adapter.ts:182


getPaymentRelatedDemandDecorations(allocationId): Promise<DemandBodyPrototype>

Fetches payment related decorations, based on the given allocation ID.

Parameters

NameTypeDescription
allocationIdstringThe ID of the allocation that will be used to pay for computations related to the demand

Returns

Promise<DemandBodyPrototype>

Implementation of

IMarketApi.getPaymentRelatedDemandDecorations

Defined in

src/shared/yagna/adapters/market-api-adapter.ts:212


confirmAgreement

confirmAgreement(agreement, options?): Promise<Agreement>

Confirms the agreement with the provider

Parameters

NameType
agreementAgreement
options?AgreementOptions

Returns

Promise<Agreement>

Implementation of

IMarketApi.confirmAgreement

Defined in

src/shared/yagna/adapters/market-api-adapter.ts:216


createAgreement

createAgreement(proposal, options?): Promise<Agreement>

Request creating an agreement from the provided proposal

Use this method if you want to decide what should happen with the agreement after it is created

Parameters

NameType
proposalOfferProposal
options?AgreementOptions

Returns

Promise<Agreement>

An agreement that's in a "Proposal" state (not yet usable for activity creation)

Implementation of

IMarketApi.createAgreement

Defined in

src/shared/yagna/adapters/market-api-adapter.ts:237


proposeAgreement

proposeAgreement(proposal, options?): Promise<Agreement>

Request creating an agreement from the provided proposal, send it to the Provider and wait for approval

Use this method when you want to quickly finalize the deal with the Provider, but be ready for a rejection

Parameters

NameType
proposalOfferProposal
options?AgreementOptions

Returns

Promise<Agreement>

An agreement that's already in an "Approved" state and can be used to create activities on the Provider

Implementation of

IMarketApi.proposeAgreement

Defined in

src/shared/yagna/adapters/market-api-adapter.ts:274


getAgreement

getAgreement(id): Promise<Agreement>

Retrieves an agreement based on the provided ID.

Parameters

NameType
idstring

Returns

Promise<Agreement>

Implementation of

IMarketApi.getAgreement

Defined in

src/shared/yagna/adapters/market-api-adapter.ts:291


getAgreementState

getAgreementState(id): Promise<AgreementState>

Retrieves the state of an agreement based on the provided agreement ID.

Parameters

NameType
idstring

Returns

Promise<AgreementState>

Implementation of

IMarketApi.getAgreementState

Defined in

src/shared/yagna/adapters/market-api-adapter.ts:295


terminateAgreement

terminateAgreement(agreement, reason?): Promise<Agreement>

Terminates an agreement.

Parameters

NameTypeDefault value
agreementAgreementundefined
reasonstring"Finished"

Returns

Promise<Agreement>

Implementation of

IMarketApi.terminateAgreement

Defined in

src/shared/yagna/adapters/market-api-adapter.ts:300


collectAgreementEvents

collectAgreementEvents(): Observable<AgreementEvent>

Start looking at the Agreement related events

Returns

Observable<AgreementEvent>

Implementation of

IMarketApi.collectAgreementEvents

Defined in

src/shared/yagna/adapters/market-api-adapter.ts:329


scan

scan(spec): Observable<ScannedOffer>

Scan the market for offers that match the given specification.

Parameters

NameType
specScanSpecification

Returns

Observable<ScannedOffer>

Implementation of

IMarketApi.scan

Defined in

src/shared/yagna/adapters/market-api-adapter.ts:403

Was this helpful?