JS API Reference

Interface: IMarketApi

market/api.IMarketApi

Implemented by

Table of contents

Methods

Methods

publishDemandSpecification

publishDemandSpecification(specification): 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
specificationDemandSpecification

Returns

Promise<Demand>

Defined in

src/market/api.ts:48


unpublishDemand

unpublishDemand(demand): Promise<void>

Remove the given demand from the market.

Parameters

NameType
demandDemand

Returns

Promise<void>

Defined in

src/market/api.ts:53


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

Defined in

src/market/api.ts:69


collectAgreementEvents

collectAgreementEvents(): Observable<AgreementEvent>

Start looking at the Agreement related events

Returns

Observable<AgreementEvent>

Defined in

src/market/api.ts:74


counterProposal

counterProposal(receivedProposal, specification): Promise<OfferCounterProposal>

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

Parameters

NameType
receivedProposalOfferProposal
specificationDemandSpecification

Returns

Promise<OfferCounterProposal>

Defined in

src/market/api.ts:79


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>

Defined in

src/market/api.ts:89


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>

Defined in

src/market/api.ts:97


getAgreement

getAgreement(id): Promise<Agreement>

Retrieves an agreement based on the provided ID.

Parameters

NameType
idstring

Returns

Promise<Agreement>

Defined in

src/market/api.ts:102


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)

Defined in

src/market/api.ts:111


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

Defined in

src/market/api.ts:120


confirmAgreement

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

Confirms the agreement with the provider

Parameters

NameType
agreementAgreement
options?AgreementOptions

Returns

Promise<Agreement>

Defined in

src/market/api.ts:125


terminateAgreement

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

Terminates an agreement.

Parameters

NameType
agreementAgreement
reason?string

Returns

Promise<Agreement>

Defined in

src/market/api.ts:130


getAgreementState

getAgreementState(id): Promise<AgreementState>

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

Parameters

NameType
idstring

Returns

Promise<AgreementState>

Defined in

src/market/api.ts:135


scan

scan(scanSpecification): Observable<ScannedOffer>

Scan the market for offers that match the given specification.

Parameters

NameType
scanSpecificationScanSpecification

Returns

Observable<ScannedOffer>

Defined in

src/market/api.ts:140