Class: MarketApiAdapter
shared/yagna/adapters/market-api-adapter.MarketApiAdapter
Implements
Table of contents
Constructors
Methods
- publishDemandSpecification
- unpublishDemand
- collectMarketProposalEvents
- counterProposal
- rejectProposal
- getPaymentRelatedDemandDecorations
- confirmAgreement
- createAgreement
- proposeAgreement
- getAgreement
- getAgreementState
- terminateAgreement
- collectAgreementEvents
- scan
Constructors
constructor
• new MarketApiAdapter(yagnaApi
, agreementRepo
, proposalRepo
, demandRepo
, logger
): MarketApiAdapter
Parameters
Name | Type |
---|---|
yagnaApi | YagnaApi |
agreementRepo | IAgreementRepository |
proposalRepo | IProposalRepository |
demandRepo | IDemandRepository |
logger | Logger |
Returns
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
Name | Type |
---|---|
spec | DemandSpecification |
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
Name | Type |
---|---|
demand | Demand |
Returns
Promise
<void
>
Implementation of
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
Name | Type |
---|---|
demand | Demand |
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
Name | Type |
---|---|
receivedProposal | OfferProposal |
demand | DemandSpecification |
Returns
Promise
<OfferCounterProposal
>
Implementation of
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
Name | Type | Description |
---|---|---|
receivedProposal | OfferProposal | The proposal from the provider |
reason | string | User readable reason that should be presented to the Provider |
Returns
Promise
<void
>
Implementation of
Defined in
src/shared/yagna/adapters/market-api-adapter.ts:182
getPaymentRelatedDemandDecorations
▸ getPaymentRelatedDemandDecorations(allocationId
): Promise
<DemandBodyPrototype
>
Fetches payment related decorations, based on the given allocation ID.
Parameters
Name | Type | Description |
---|---|---|
allocationId | string | The 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
Name | Type |
---|---|
agreement | Agreement |
options? | AgreementOptions |
Returns
Promise
<Agreement
>
Implementation of
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
Name | Type |
---|---|
proposal | OfferProposal |
options? | AgreementOptions |
Returns
Promise
<Agreement
>
An agreement that's in a "Proposal" state (not yet usable for activity creation)
Implementation of
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
Name | Type |
---|---|
proposal | OfferProposal |
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
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
Name | Type |
---|---|
id | string |
Returns
Promise
<Agreement
>
Implementation of
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
Name | Type |
---|---|
id | string |
Returns
Promise
<AgreementState
>
Implementation of
Defined in
src/shared/yagna/adapters/market-api-adapter.ts:295
terminateAgreement
▸ terminateAgreement(agreement
, reason?
): Promise
<Agreement
>
Terminates an agreement.
Parameters
Name | Type | Default value |
---|---|---|
agreement | Agreement | undefined |
reason | string | "Finished" |
Returns
Promise
<Agreement
>
Implementation of
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
Name | Type |
---|---|
spec | ScanSpecification |
Returns
Observable
<ScannedOffer
>
Implementation of
Defined in
Was this helpful?