@bosonprotocol/core-sdk 1.44.1-alpha.1 → 1.45.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/exchanges/handler.d.ts +11 -1
- package/dist/cjs/exchanges/handler.d.ts.map +1 -1
- package/dist/cjs/exchanges/handler.js +38 -0
- package/dist/cjs/exchanges/handler.js.map +1 -1
- package/dist/cjs/exchanges/interface.d.ts +3 -0
- package/dist/cjs/exchanges/interface.d.ts.map +1 -1
- package/dist/cjs/exchanges/interface.js +21 -0
- package/dist/cjs/exchanges/interface.js.map +1 -1
- package/dist/cjs/exchanges/mixin.d.ts +17 -4
- package/dist/cjs/exchanges/mixin.d.ts.map +1 -1
- package/dist/cjs/exchanges/mixin.js +27 -3
- package/dist/cjs/exchanges/mixin.js.map +1 -1
- package/dist/cjs/offers/renderContractualAgreement.d.ts.map +1 -1
- package/dist/cjs/offers/renderContractualAgreement.js +1 -1
- package/dist/cjs/offers/renderContractualAgreement.js.map +1 -1
- package/dist/cjs/subgraph.d.ts +938 -265
- package/dist/cjs/subgraph.d.ts.map +1 -1
- package/dist/cjs/subgraph.js +295 -75
- package/dist/cjs/subgraph.js.map +1 -1
- package/dist/cjs/utils/graphql.d.ts +32 -32
- package/dist/esm/exchanges/handler.d.ts +11 -1
- package/dist/esm/exchanges/handler.d.ts.map +1 -1
- package/dist/esm/exchanges/handler.js +36 -1
- package/dist/esm/exchanges/handler.js.map +1 -1
- package/dist/esm/exchanges/interface.d.ts +3 -0
- package/dist/esm/exchanges/interface.d.ts.map +1 -1
- package/dist/esm/exchanges/interface.js +23 -0
- package/dist/esm/exchanges/interface.js.map +1 -1
- package/dist/esm/exchanges/mixin.d.ts +17 -4
- package/dist/esm/exchanges/mixin.d.ts.map +1 -1
- package/dist/esm/exchanges/mixin.js +32 -4
- package/dist/esm/exchanges/mixin.js.map +1 -1
- package/dist/esm/offers/renderContractualAgreement.d.ts.map +1 -1
- package/dist/esm/offers/renderContractualAgreement.js +1 -0
- package/dist/esm/offers/renderContractualAgreement.js.map +1 -1
- package/dist/esm/subgraph.d.ts +938 -265
- package/dist/esm/subgraph.d.ts.map +1 -1
- package/dist/esm/subgraph.js +289 -75
- package/dist/esm/subgraph.js.map +1 -1
- package/dist/esm/utils/graphql.d.ts +32 -32
- package/package.json +3 -3
- package/src/accounts/queries.graphql +1 -0
- package/src/exchanges/handler.ts +74 -2
- package/src/exchanges/interface.ts +38 -1
- package/src/exchanges/mixin.ts +72 -11
- package/src/exchanges/queries.graphql +1 -0
- package/src/offers/queries.graphql +6 -0
- package/src/offers/renderContractualAgreement.ts +1 -0
- package/src/subgraph.ts +1153 -397
package/src/exchanges/mixin.ts
CHANGED
|
@@ -4,7 +4,8 @@ import {
|
|
|
4
4
|
TransactionResponse,
|
|
5
5
|
TransactionRequest,
|
|
6
6
|
Log,
|
|
7
|
-
Web3LibAdapter
|
|
7
|
+
Web3LibAdapter,
|
|
8
|
+
SellerOfferArgs
|
|
8
9
|
} from "@bosonprotocol/common";
|
|
9
10
|
import { BigNumberish, BigNumber } from "@ethersproject/bignumber";
|
|
10
11
|
import { getValueFromLogs } from "../utils/logs";
|
|
@@ -18,7 +19,8 @@ import {
|
|
|
18
19
|
expireVoucher,
|
|
19
20
|
commitToConditionalOffer,
|
|
20
21
|
getExchangeTokenId,
|
|
21
|
-
parseTokenId
|
|
22
|
+
parseTokenId,
|
|
23
|
+
commitToBuyerOffer
|
|
22
24
|
} from "./handler";
|
|
23
25
|
import { getExchangeById, getExchanges } from "./subgraph";
|
|
24
26
|
import { bosonExchangeHandlerIface } from "./interface";
|
|
@@ -53,8 +55,8 @@ export class ExchangesMixin<T extends Web3LibAdapter> extends BaseCoreSDK<T> {
|
|
|
53
55
|
}
|
|
54
56
|
|
|
55
57
|
/**
|
|
56
|
-
* Commits to
|
|
57
|
-
* This transaction only succeeds if the seller has deposited funds.
|
|
58
|
+
* Commits to a seller initiated offer by calling the `ExchangeCommitFacet`.
|
|
59
|
+
* This transaction only succeeds if the seller has deposited enough funds to lock the offer's sellerDeposit.
|
|
58
60
|
* @param offerId - ID of offer to commit to.
|
|
59
61
|
* @param overrides - Optional overrides.
|
|
60
62
|
* @returns Transaction response.
|
|
@@ -104,6 +106,57 @@ export class ExchangesMixin<T extends Web3LibAdapter> extends BaseCoreSDK<T> {
|
|
|
104
106
|
}
|
|
105
107
|
}
|
|
106
108
|
|
|
109
|
+
/**
|
|
110
|
+
* Commits to a buyer initiated offer by calling the `ExchangeCommitFacet`.
|
|
111
|
+
* This transaction only succeeds if the buyer has deposited enough funds to lock the offer's price.
|
|
112
|
+
* @param offerId - ID of offer to commit to.
|
|
113
|
+
* @param overrides - Optional overrides.
|
|
114
|
+
* @returns Transaction response.
|
|
115
|
+
*/
|
|
116
|
+
public async commitToBuyerOffer(
|
|
117
|
+
offerId: BigNumberish,
|
|
118
|
+
sellerParams: SellerOfferArgs,
|
|
119
|
+
overrides: Partial<{
|
|
120
|
+
returnTxInfo: true;
|
|
121
|
+
}>
|
|
122
|
+
): Promise<TransactionRequest>;
|
|
123
|
+
public async commitToBuyerOffer(
|
|
124
|
+
offerId: BigNumberish,
|
|
125
|
+
sellerParams?: SellerOfferArgs,
|
|
126
|
+
overrides?: Partial<{
|
|
127
|
+
returnTxInfo?: false | undefined;
|
|
128
|
+
}>
|
|
129
|
+
): Promise<TransactionResponse>;
|
|
130
|
+
public async commitToBuyerOffer(
|
|
131
|
+
offerId: BigNumberish,
|
|
132
|
+
sellerParams: SellerOfferArgs = {},
|
|
133
|
+
overrides: Partial<{
|
|
134
|
+
returnTxInfo?: boolean;
|
|
135
|
+
}> = {}
|
|
136
|
+
): Promise<TransactionResponse | TransactionRequest> {
|
|
137
|
+
const { returnTxInfo } = overrides;
|
|
138
|
+
|
|
139
|
+
const commitArgs = {
|
|
140
|
+
offerId,
|
|
141
|
+
sellerParams: sellerParams || {},
|
|
142
|
+
web3Lib: this._web3Lib,
|
|
143
|
+
subgraphUrl: this._subgraphUrl,
|
|
144
|
+
contractAddress: this._protocolDiamond
|
|
145
|
+
} as const satisfies Parameters<typeof commitToBuyerOffer>[0];
|
|
146
|
+
|
|
147
|
+
if (returnTxInfo === true) {
|
|
148
|
+
return commitToBuyerOffer({
|
|
149
|
+
...commitArgs,
|
|
150
|
+
returnTxInfo: true
|
|
151
|
+
});
|
|
152
|
+
} else {
|
|
153
|
+
return commitToBuyerOffer({
|
|
154
|
+
...commitArgs,
|
|
155
|
+
returnTxInfo: false
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
107
160
|
/**
|
|
108
161
|
* Commits to a conditional offer by calling the `ExchangeHandlerContract`.
|
|
109
162
|
* This transaction only succeeds if the seller has deposited funds.
|
|
@@ -162,17 +215,25 @@ export class ExchangesMixin<T extends Web3LibAdapter> extends BaseCoreSDK<T> {
|
|
|
162
215
|
}
|
|
163
216
|
|
|
164
217
|
/**
|
|
165
|
-
* Utility method to retrieve the created `exchangeId` from logs after calling `commitToOffer`.
|
|
218
|
+
* Utility method to retrieve the created `exchangeId` from logs after calling `commitToOffer` or `commitToBuyerOffer`.
|
|
166
219
|
* @param logs - Logs to search in.
|
|
167
220
|
* @returns Created exchange id.
|
|
168
221
|
*/
|
|
169
222
|
public getCommittedExchangeIdFromLogs(logs: Log[]): string | null {
|
|
170
|
-
return
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
223
|
+
return (
|
|
224
|
+
getValueFromLogs({
|
|
225
|
+
iface: bosonExchangeHandlerIface,
|
|
226
|
+
logs,
|
|
227
|
+
eventArgsKey: "exchangeId",
|
|
228
|
+
eventName: "BuyerCommitted"
|
|
229
|
+
}) ||
|
|
230
|
+
getValueFromLogs({
|
|
231
|
+
iface: bosonExchangeHandlerIface,
|
|
232
|
+
logs,
|
|
233
|
+
eventArgsKey: "exchangeId",
|
|
234
|
+
eventName: "SellerCommitted"
|
|
235
|
+
})
|
|
236
|
+
);
|
|
176
237
|
}
|
|
177
238
|
|
|
178
239
|
/**
|
|
@@ -133,7 +133,10 @@ fragment BaseOfferFields on Offer {
|
|
|
133
133
|
id
|
|
134
134
|
createdAt
|
|
135
135
|
price
|
|
136
|
+
sellerId
|
|
136
137
|
sellerDeposit
|
|
138
|
+
buyerId
|
|
139
|
+
creator
|
|
137
140
|
protocolFee
|
|
138
141
|
agentFee
|
|
139
142
|
agentId
|
|
@@ -172,6 +175,9 @@ fragment BaseOfferFields on Offer {
|
|
|
172
175
|
seller {
|
|
173
176
|
...BaseSellerFields
|
|
174
177
|
}
|
|
178
|
+
buyer {
|
|
179
|
+
...BaseBuyerFields
|
|
180
|
+
}
|
|
175
181
|
collection {
|
|
176
182
|
...BaseOfferCollectionFields
|
|
177
183
|
}
|
|
@@ -175,6 +175,7 @@ function convertExistingOfferData(offerDataSubGraph: OfferFieldsFragment): {
|
|
|
175
175
|
return {
|
|
176
176
|
offerData: {
|
|
177
177
|
...offerDataSubGraph,
|
|
178
|
+
collectionIndex: offerDataSubGraph.collectionIndex || 0,
|
|
178
179
|
validFromDateInMS: offerDataSubGraph.validFromDate,
|
|
179
180
|
validUntilDateInMS: offerDataSubGraph.validUntilDate,
|
|
180
181
|
voucherRedeemableFromDateInMS:
|