@bosonprotocol/core-sdk 1.6.0-alpha.8 → 1.6.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/accounts/subgraph.d.ts +9 -5
- package/dist/cjs/accounts/subgraph.d.ts.map +1 -1
- package/dist/cjs/accounts/subgraph.js +26 -22
- package/dist/cjs/accounts/subgraph.js.map +1 -1
- package/dist/cjs/core-sdk.d.ts +14 -11
- package/dist/cjs/core-sdk.d.ts.map +1 -1
- package/dist/cjs/core-sdk.js +61 -19
- package/dist/cjs/core-sdk.js.map +1 -1
- package/dist/cjs/exchanges/handler.d.ts +18 -0
- package/dist/cjs/exchanges/handler.d.ts.map +1 -1
- package/dist/cjs/exchanges/handler.js +82 -6
- package/dist/cjs/exchanges/handler.js.map +1 -1
- package/dist/cjs/exchanges/interface.d.ts +5 -0
- package/dist/cjs/exchanges/interface.d.ts.map +1 -1
- package/dist/cjs/exchanges/interface.js +31 -1
- package/dist/cjs/exchanges/interface.js.map +1 -1
- package/dist/cjs/exchanges/subgraph.d.ts +4 -4
- package/dist/cjs/exchanges/subgraph.d.ts.map +1 -1
- package/dist/cjs/exchanges/subgraph.js +9 -11
- package/dist/cjs/exchanges/subgraph.js.map +1 -1
- package/dist/cjs/funds/subgraph.d.ts +4 -2
- package/dist/cjs/funds/subgraph.d.ts.map +1 -1
- package/dist/cjs/funds/subgraph.js +13 -7
- package/dist/cjs/funds/subgraph.js.map +1 -1
- package/dist/cjs/offers/interface.d.ts.map +1 -1
- package/dist/cjs/offers/interface.js +11 -4
- package/dist/cjs/offers/interface.js.map +1 -1
- package/dist/cjs/offers/subgraph.d.ts +4 -4
- package/dist/cjs/offers/subgraph.d.ts.map +1 -1
- package/dist/cjs/offers/subgraph.js +7 -12
- package/dist/cjs/offers/subgraph.js.map +1 -1
- package/dist/cjs/subgraph.d.ts +531 -121
- package/dist/cjs/subgraph.d.ts.map +1 -1
- package/dist/cjs/subgraph.js +229 -101
- package/dist/cjs/subgraph.js.map +1 -1
- package/dist/cjs/utils/graphql.d.ts +82 -29
- package/dist/cjs/utils/graphql.d.ts.map +1 -1
- package/dist/esm/accounts/subgraph.d.ts +9 -5
- package/dist/esm/accounts/subgraph.d.ts.map +1 -1
- package/dist/esm/accounts/subgraph.js +37 -18
- package/dist/esm/accounts/subgraph.js.map +1 -1
- package/dist/esm/core-sdk.d.ts +14 -11
- package/dist/esm/core-sdk.d.ts.map +1 -1
- package/dist/esm/core-sdk.js +49 -19
- package/dist/esm/core-sdk.js.map +1 -1
- package/dist/esm/exchanges/handler.d.ts +18 -0
- package/dist/esm/exchanges/handler.d.ts.map +1 -1
- package/dist/esm/exchanges/handler.js +73 -6
- package/dist/esm/exchanges/handler.js.map +1 -1
- package/dist/esm/exchanges/interface.d.ts +5 -0
- package/dist/esm/exchanges/interface.d.ts.map +1 -1
- package/dist/esm/exchanges/interface.js +25 -0
- package/dist/esm/exchanges/interface.js.map +1 -1
- package/dist/esm/exchanges/subgraph.d.ts +4 -4
- package/dist/esm/exchanges/subgraph.d.ts.map +1 -1
- package/dist/esm/exchanges/subgraph.js +8 -10
- package/dist/esm/exchanges/subgraph.js.map +1 -1
- package/dist/esm/funds/subgraph.d.ts +4 -2
- package/dist/esm/funds/subgraph.d.ts.map +1 -1
- package/dist/esm/funds/subgraph.js +11 -5
- package/dist/esm/funds/subgraph.js.map +1 -1
- package/dist/esm/offers/interface.d.ts.map +1 -1
- package/dist/esm/offers/interface.js +11 -4
- package/dist/esm/offers/interface.js.map +1 -1
- package/dist/esm/offers/subgraph.d.ts +4 -4
- package/dist/esm/offers/subgraph.d.ts.map +1 -1
- package/dist/esm/offers/subgraph.js +7 -10
- package/dist/esm/offers/subgraph.js.map +1 -1
- package/dist/esm/subgraph.d.ts +531 -121
- package/dist/esm/subgraph.d.ts.map +1 -1
- package/dist/esm/subgraph.js +234 -100
- package/dist/esm/subgraph.js.map +1 -1
- package/dist/esm/utils/graphql.d.ts +82 -29
- package/dist/esm/utils/graphql.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/accounts/queries.graphql +89 -17
- package/src/accounts/subgraph.ts +58 -23
- package/src/core-sdk.ts +82 -35
- package/src/exchanges/handler.ts +123 -6
- package/src/exchanges/interface.ts +28 -0
- package/src/exchanges/queries.graphql +23 -23
- package/src/exchanges/subgraph.ts +21 -20
- package/src/funds/queries.graphql +20 -2
- package/src/funds/subgraph.ts +27 -8
- package/src/offers/interface.ts +16 -6
- package/src/offers/queries.graphql +43 -22
- package/src/offers/subgraph.ts +18 -20
- package/src/subgraph.ts +807 -262
|
@@ -1,34 +1,35 @@
|
|
|
1
1
|
import { getSubgraphSdk } from "../utils/graphql";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
ExchangeFieldsFragment,
|
|
4
|
+
GetExchangesQueryQueryVariables,
|
|
5
|
+
GetExchangeByIdQueryQueryVariables
|
|
6
|
+
} from "../subgraph";
|
|
3
7
|
import { BigNumberish } from "@ethersproject/bignumber";
|
|
4
8
|
|
|
5
|
-
export type
|
|
6
|
-
|
|
7
|
-
"
|
|
9
|
+
export type SingleExchangeQueryVariables = Omit<
|
|
10
|
+
GetExchangeByIdQueryQueryVariables,
|
|
11
|
+
"exchangeId"
|
|
8
12
|
>;
|
|
9
13
|
|
|
10
|
-
export async function
|
|
14
|
+
export async function getExchanges(
|
|
11
15
|
subgraphUrl: string,
|
|
12
|
-
|
|
13
|
-
): Promise<ExchangeFieldsFragment> {
|
|
16
|
+
queryVars: GetExchangesQueryQueryVariables = {}
|
|
17
|
+
): Promise<ExchangeFieldsFragment[]> {
|
|
14
18
|
const sdk = getSubgraphSdk(subgraphUrl);
|
|
15
|
-
const {
|
|
16
|
-
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
return exchange;
|
|
19
|
+
const { exchanges = [] } = await sdk.getExchangesQuery(queryVars);
|
|
20
|
+
return exchanges;
|
|
20
21
|
}
|
|
21
22
|
|
|
22
|
-
export async function
|
|
23
|
+
export async function getExchangeById(
|
|
23
24
|
subgraphUrl: string,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
): Promise<ExchangeFieldsFragment
|
|
25
|
+
exchangeId: BigNumberish,
|
|
26
|
+
queryVars: SingleExchangeQueryVariables = {}
|
|
27
|
+
): Promise<ExchangeFieldsFragment> {
|
|
27
28
|
const sdk = getSubgraphSdk(subgraphUrl);
|
|
28
|
-
const {
|
|
29
|
-
|
|
30
|
-
...
|
|
29
|
+
const { exchange } = await sdk.getExchangeByIdQuery({
|
|
30
|
+
exchangeId: exchangeId.toString(),
|
|
31
|
+
...queryVars
|
|
31
32
|
});
|
|
32
33
|
|
|
33
|
-
return
|
|
34
|
+
return exchange;
|
|
34
35
|
}
|
|
@@ -1,5 +1,23 @@
|
|
|
1
|
-
query
|
|
2
|
-
|
|
1
|
+
query getFundsById($fundsId: ID!) {
|
|
2
|
+
fundsEntity(id: $fundsId) {
|
|
3
|
+
...FundsEntityFields
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
query getFunds(
|
|
8
|
+
$fundsSkip: Int
|
|
9
|
+
$fundsFirst: Int
|
|
10
|
+
$fundsOrderBy: FundsEntity_orderBy
|
|
11
|
+
$fundsOrderDirection: OrderDirection
|
|
12
|
+
$fundsFilter: FundsEntity_filter
|
|
13
|
+
) {
|
|
14
|
+
fundsEntities(
|
|
15
|
+
skip: $fundsSkip
|
|
16
|
+
first: $fundsFirst
|
|
17
|
+
orderBy: $fundsOrderBy
|
|
18
|
+
orderDirection: $fundsOrderDirection
|
|
19
|
+
where: $fundsFilter
|
|
20
|
+
) {
|
|
3
21
|
...FundsEntityFields
|
|
4
22
|
}
|
|
5
23
|
}
|
package/src/funds/subgraph.ts
CHANGED
|
@@ -1,16 +1,35 @@
|
|
|
1
|
-
import { BigNumberish } from "@ethersproject/bignumber";
|
|
2
1
|
import { getSubgraphSdk } from "../utils/graphql";
|
|
3
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
FundsEntityFieldsFragment,
|
|
4
|
+
GetFundsByIdQueryVariables,
|
|
5
|
+
GetFundsQueryVariables
|
|
6
|
+
} from "../subgraph";
|
|
7
|
+
import { BigNumberish } from "@ethersproject/bignumber";
|
|
4
8
|
|
|
5
|
-
export
|
|
9
|
+
export type SingleFundsQueryVariables = Omit<
|
|
10
|
+
GetFundsByIdQueryVariables,
|
|
11
|
+
"fundsId"
|
|
12
|
+
>;
|
|
13
|
+
|
|
14
|
+
export async function getFunds(
|
|
6
15
|
subgraphUrl: string,
|
|
7
|
-
|
|
16
|
+
queryVars: GetFundsQueryVariables = {}
|
|
8
17
|
): Promise<FundsEntityFieldsFragment[]> {
|
|
9
|
-
const
|
|
18
|
+
const sdk = getSubgraphSdk(subgraphUrl);
|
|
19
|
+
const { fundsEntities = [] } = await sdk.getFunds(queryVars);
|
|
20
|
+
return fundsEntities;
|
|
21
|
+
}
|
|
10
22
|
|
|
11
|
-
|
|
12
|
-
|
|
23
|
+
export async function getFundsById(
|
|
24
|
+
subgraphUrl: string,
|
|
25
|
+
fundsId: BigNumberish,
|
|
26
|
+
queryVars: SingleFundsQueryVariables = {}
|
|
27
|
+
): Promise<FundsEntityFieldsFragment> {
|
|
28
|
+
const sdk = getSubgraphSdk(subgraphUrl);
|
|
29
|
+
const { fundsEntity } = await sdk.getFundsById({
|
|
30
|
+
fundsId: fundsId.toString(),
|
|
31
|
+
...queryVars
|
|
13
32
|
});
|
|
14
33
|
|
|
15
|
-
return
|
|
34
|
+
return fundsEntity;
|
|
16
35
|
}
|
package/src/offers/interface.ts
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
} from "@bosonprotocol/common";
|
|
8
8
|
import { Interface } from "@ethersproject/abi";
|
|
9
9
|
import { getAddress } from "@ethersproject/address";
|
|
10
|
+
import { BigNumber } from "@ethersproject/bignumber";
|
|
10
11
|
import { CreateOfferArgs } from "./types";
|
|
11
12
|
|
|
12
13
|
export const bosonOfferHandlerIface = new Interface(abis.IBosonOfferHandlerABI);
|
|
@@ -49,8 +50,7 @@ export function argsToOfferDatesStruct(
|
|
|
49
50
|
const {
|
|
50
51
|
validFromDateInMS,
|
|
51
52
|
validUntilDateInMS,
|
|
52
|
-
voucherRedeemableFromDateInMS
|
|
53
|
-
voucherRedeemableUntilDateInMS
|
|
53
|
+
voucherRedeemableFromDateInMS
|
|
54
54
|
} = args;
|
|
55
55
|
|
|
56
56
|
return {
|
|
@@ -59,9 +59,10 @@ export function argsToOfferDatesStruct(
|
|
|
59
59
|
voucherRedeemableFrom: utils.timestamp.msToSec(
|
|
60
60
|
voucherRedeemableFromDateInMS
|
|
61
61
|
),
|
|
62
|
-
voucherRedeemableUntil:
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
voucherRedeemableUntil:
|
|
63
|
+
// NOTE: Field `voucherRedeemableUntil` not yet fully supported in protocol.
|
|
64
|
+
// Therefore converting to `voucherValid` field.
|
|
65
|
+
"0"
|
|
65
66
|
};
|
|
66
67
|
}
|
|
67
68
|
|
|
@@ -70,13 +71,22 @@ export function argsToOfferDurationsStruct(
|
|
|
70
71
|
): Partial<OfferDurationsStruct> {
|
|
71
72
|
const {
|
|
72
73
|
fulfillmentPeriodDurationInMS,
|
|
74
|
+
voucherRedeemableUntilDateInMS,
|
|
75
|
+
voucherRedeemableFromDateInMS,
|
|
73
76
|
voucherValidDurationInMS = 0,
|
|
74
77
|
resolutionPeriodDurationInMS
|
|
75
78
|
} = args;
|
|
76
79
|
|
|
77
80
|
return {
|
|
78
81
|
fulfillmentPeriod: utils.timestamp.msToSec(fulfillmentPeriodDurationInMS),
|
|
79
|
-
voucherValid: utils.timestamp.msToSec(
|
|
82
|
+
voucherValid: utils.timestamp.msToSec(
|
|
83
|
+
voucherValidDurationInMS ||
|
|
84
|
+
// NOTE: Field `voucherRedeemableUntil` not yet fully supported in protocol.
|
|
85
|
+
// Therefore converting to `voucherValid` field.
|
|
86
|
+
BigNumber.from(voucherRedeemableUntilDateInMS).sub(
|
|
87
|
+
BigNumber.from(voucherRedeemableFromDateInMS)
|
|
88
|
+
)
|
|
89
|
+
),
|
|
80
90
|
resolutionPeriod: utils.timestamp.msToSec(resolutionPeriodDurationInMS)
|
|
81
91
|
};
|
|
82
92
|
}
|
|
@@ -1,29 +1,55 @@
|
|
|
1
|
-
query getOfferByIdQuery(
|
|
1
|
+
query getOfferByIdQuery(
|
|
2
|
+
$offerId: ID!
|
|
3
|
+
$exchangesSkip: Int
|
|
4
|
+
$exchangesFirst: Int
|
|
5
|
+
$exchangesOrderBy: Exchange_orderBy
|
|
6
|
+
$exchangesOrderDirection: OrderDirection
|
|
7
|
+
$exchangesFilter: Exchange_filter
|
|
8
|
+
$includeExchanges: Boolean = false
|
|
9
|
+
) {
|
|
2
10
|
offer(id: $offerId) {
|
|
3
11
|
...OfferFields
|
|
4
12
|
}
|
|
5
13
|
}
|
|
6
14
|
|
|
7
|
-
query
|
|
8
|
-
$
|
|
9
|
-
$
|
|
10
|
-
$
|
|
11
|
-
$
|
|
12
|
-
$
|
|
15
|
+
query getOffersQuery(
|
|
16
|
+
$offersSkip: Int
|
|
17
|
+
$offersFirst: Int
|
|
18
|
+
$offersOrderBy: Offer_orderBy
|
|
19
|
+
$offersOrderDirection: OrderDirection
|
|
20
|
+
$offersFilter: Offer_filter
|
|
21
|
+
$exchangesSkip: Int
|
|
22
|
+
$exchangesFirst: Int
|
|
23
|
+
$exchangesOrderBy: Exchange_orderBy
|
|
24
|
+
$exchangesOrderDirection: OrderDirection
|
|
25
|
+
$exchangesFilter: Exchange_filter
|
|
26
|
+
$includeExchanges: Boolean = false
|
|
13
27
|
) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
28
|
+
offers(
|
|
29
|
+
skip: $offersSkip
|
|
30
|
+
first: $offersFirst
|
|
31
|
+
orderBy: $offersOrderBy
|
|
32
|
+
orderDirection: $offersOrderDirection
|
|
33
|
+
where: $offersFilter
|
|
34
|
+
) {
|
|
35
|
+
...OfferFields
|
|
23
36
|
}
|
|
24
37
|
}
|
|
25
38
|
|
|
26
39
|
fragment OfferFields on Offer {
|
|
40
|
+
...BaseOfferFields
|
|
41
|
+
exchanges(
|
|
42
|
+
skip: $exchangesSkip
|
|
43
|
+
first: $exchangesFirst
|
|
44
|
+
orderBy: $exchangesOrderBy
|
|
45
|
+
orderDirection: $exchangesOrderDirection
|
|
46
|
+
where: $exchangesFilter
|
|
47
|
+
) @include(if: $includeExchanges) {
|
|
48
|
+
...BaseExchangeFields
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
fragment BaseOfferFields on Offer {
|
|
27
53
|
id
|
|
28
54
|
createdAt
|
|
29
55
|
price
|
|
@@ -44,12 +70,7 @@ fragment OfferFields on Offer {
|
|
|
44
70
|
voidedAt
|
|
45
71
|
disputeResolverId
|
|
46
72
|
seller {
|
|
47
|
-
|
|
48
|
-
operator
|
|
49
|
-
admin
|
|
50
|
-
clerk
|
|
51
|
-
treasury
|
|
52
|
-
active
|
|
73
|
+
...BaseSellerFields
|
|
53
74
|
}
|
|
54
75
|
exchangeToken {
|
|
55
76
|
address
|
package/src/offers/subgraph.ts
CHANGED
|
@@ -1,40 +1,38 @@
|
|
|
1
1
|
import { BigNumberish } from "@ethersproject/bignumber";
|
|
2
2
|
import { getSubgraphSdk } from "../utils/graphql";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
import {
|
|
4
|
+
OfferFieldsFragment,
|
|
5
|
+
GetOfferByIdQueryQueryVariables,
|
|
6
|
+
GetOffersQueryQueryVariables
|
|
7
|
+
} from "../subgraph";
|
|
8
|
+
|
|
9
|
+
export type SingleOfferQueryVariables = Omit<
|
|
10
|
+
GetOfferByIdQueryQueryVariables,
|
|
11
|
+
"offerId"
|
|
8
12
|
>;
|
|
9
13
|
|
|
10
14
|
export async function getOfferById(
|
|
11
15
|
subgraphUrl: string,
|
|
12
|
-
offerId: BigNumberish
|
|
16
|
+
offerId: BigNumberish,
|
|
17
|
+
queryVars: SingleOfferQueryVariables = {}
|
|
13
18
|
): Promise<OfferFieldsFragment> {
|
|
14
19
|
const subgraphSdk = getSubgraphSdk(subgraphUrl);
|
|
15
|
-
|
|
16
20
|
const { offer } = await subgraphSdk.getOfferByIdQuery({
|
|
17
|
-
offerId: offerId.toString()
|
|
21
|
+
offerId: offerId.toString(),
|
|
22
|
+
...queryVars
|
|
18
23
|
});
|
|
19
24
|
|
|
20
25
|
return offer;
|
|
21
26
|
}
|
|
22
27
|
|
|
23
|
-
export async function
|
|
28
|
+
export async function getOffers(
|
|
24
29
|
subgraphUrl: string,
|
|
25
|
-
|
|
26
|
-
opts: AllOffersQueryOpts = {}
|
|
30
|
+
queryVars: GetOffersQueryQueryVariables = {}
|
|
27
31
|
): Promise<OfferFieldsFragment[]> {
|
|
28
32
|
const subgraphSdk = getSubgraphSdk(subgraphUrl);
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
operator: operatorAddress,
|
|
32
|
-
...opts
|
|
33
|
+
const { offers = [] } = await subgraphSdk.getOffersQuery({
|
|
34
|
+
...queryVars
|
|
33
35
|
});
|
|
34
36
|
|
|
35
|
-
|
|
36
|
-
return [];
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return sellers[0].offers;
|
|
37
|
+
return offers;
|
|
40
38
|
}
|