@bosonprotocol/core-sdk 1.6.0-alpha.3 → 1.6.0-alpha.4
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 +5 -9
- package/dist/cjs/accounts/subgraph.d.ts.map +1 -1
- package/dist/cjs/accounts/subgraph.js +8 -56
- package/dist/cjs/accounts/subgraph.js.map +1 -1
- package/dist/cjs/accounts/types.d.ts +0 -10
- package/dist/cjs/accounts/types.d.ts.map +1 -1
- package/dist/cjs/core-sdk.d.ts +7 -8
- package/dist/cjs/core-sdk.d.ts.map +1 -1
- package/dist/cjs/core-sdk.js +1 -1
- package/dist/cjs/core-sdk.js.map +1 -1
- package/dist/cjs/funds/index.d.ts +0 -1
- package/dist/cjs/funds/index.d.ts.map +1 -1
- package/dist/cjs/funds/index.js +0 -4
- package/dist/cjs/funds/index.js.map +1 -1
- package/dist/cjs/funds/subgraph.d.ts +2 -4
- package/dist/cjs/funds/subgraph.d.ts.map +1 -1
- package/dist/cjs/funds/subgraph.js +6 -26
- package/dist/cjs/funds/subgraph.js.map +1 -1
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +2 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/offers/subgraph.d.ts +7 -8
- package/dist/cjs/offers/subgraph.d.ts.map +1 -1
- package/dist/cjs/offers/subgraph.js +14 -95
- package/dist/cjs/offers/subgraph.js.map +1 -1
- package/dist/cjs/offers/types.d.ts +0 -50
- package/dist/cjs/offers/types.d.ts.map +1 -1
- package/dist/cjs/subgraph.d.ts +2510 -0
- package/dist/cjs/subgraph.d.ts.map +1 -0
- package/dist/cjs/subgraph.js +360 -0
- package/dist/cjs/subgraph.js.map +1 -0
- package/dist/cjs/utils/graphql.d.ts +28 -0
- package/dist/cjs/utils/graphql.d.ts.map +1 -0
- package/dist/cjs/utils/graphql.js +11 -0
- package/dist/cjs/utils/graphql.js.map +1 -0
- package/dist/esm/accounts/subgraph.d.ts +5 -9
- package/dist/esm/accounts/subgraph.d.ts.map +1 -1
- package/dist/esm/accounts/subgraph.js +7 -55
- package/dist/esm/accounts/subgraph.js.map +1 -1
- package/dist/esm/accounts/types.d.ts +0 -10
- package/dist/esm/accounts/types.d.ts.map +1 -1
- package/dist/esm/core-sdk.d.ts +7 -8
- package/dist/esm/core-sdk.d.ts.map +1 -1
- package/dist/esm/core-sdk.js +1 -1
- package/dist/esm/core-sdk.js.map +1 -1
- package/dist/esm/funds/index.d.ts +0 -1
- package/dist/esm/funds/index.d.ts.map +1 -1
- package/dist/esm/funds/index.js +0 -1
- package/dist/esm/funds/index.js.map +1 -1
- package/dist/esm/funds/subgraph.d.ts +2 -4
- package/dist/esm/funds/subgraph.d.ts.map +1 -1
- package/dist/esm/funds/subgraph.js +5 -25
- package/dist/esm/funds/subgraph.js.map +1 -1
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/offers/subgraph.d.ts +7 -8
- package/dist/esm/offers/subgraph.d.ts.map +1 -1
- package/dist/esm/offers/subgraph.js +12 -100
- package/dist/esm/offers/subgraph.js.map +1 -1
- package/dist/esm/offers/types.d.ts +0 -50
- package/dist/esm/offers/types.d.ts.map +1 -1
- package/dist/esm/subgraph.d.ts +2510 -0
- package/dist/esm/subgraph.d.ts.map +1 -0
- package/dist/esm/subgraph.js +353 -0
- package/dist/esm/subgraph.js.map +1 -0
- package/dist/esm/utils/graphql.d.ts +28 -0
- package/dist/esm/utils/graphql.d.ts.map +1 -0
- package/dist/esm/utils/graphql.js +7 -0
- package/dist/esm/utils/graphql.js.map +1 -0
- package/package.json +7 -4
- package/src/accounts/queries.graphql +35 -0
- package/src/accounts/subgraph.ts +12 -70
- package/src/accounts/types.ts +0 -12
- package/src/core-sdk.ts +9 -8
- package/src/funds/index.ts +0 -1
- package/src/funds/queries.graphql +17 -0
- package/src/funds/subgraph.ts +8 -31
- package/src/index.ts +1 -0
- package/src/offers/queries.graphql +75 -0
- package/src/offers/subgraph.ts +26 -113
- package/src/offers/types.ts +0 -51
- package/src/subgraph.ts +2876 -0
- package/src/utils/graphql.ts +7 -0
- package/dist/cjs/funds/types.d.ts +0 -12
- package/dist/cjs/funds/types.d.ts.map +0 -1
- package/dist/cjs/funds/types.js +0 -3
- package/dist/cjs/funds/types.js.map +0 -1
- package/dist/cjs/utils/errors.d.ts +0 -10
- package/dist/cjs/utils/errors.d.ts.map +0 -1
- package/dist/cjs/utils/errors.js +0 -12
- package/dist/cjs/utils/errors.js.map +0 -1
- package/dist/cjs/utils/subgraph.d.ts +0 -8
- package/dist/cjs/utils/subgraph.d.ts.map +0 -1
- package/dist/cjs/utils/subgraph.js +0 -46
- package/dist/cjs/utils/subgraph.js.map +0 -1
- package/dist/esm/funds/types.d.ts +0 -12
- package/dist/esm/funds/types.d.ts.map +0 -1
- package/dist/esm/funds/types.js +0 -2
- package/dist/esm/funds/types.js.map +0 -1
- package/dist/esm/utils/errors.d.ts +0 -10
- package/dist/esm/utils/errors.d.ts.map +0 -1
- package/dist/esm/utils/errors.js +0 -10
- package/dist/esm/utils/errors.js.map +0 -1
- package/dist/esm/utils/subgraph.d.ts +0 -8
- package/dist/esm/utils/subgraph.d.ts.map +0 -1
- package/dist/esm/utils/subgraph.js +0 -28
- package/dist/esm/utils/subgraph.js.map +0 -1
- package/src/funds/types.ts +0 -11
- package/src/utils/errors.ts +0 -14
- package/src/utils/subgraph.ts +0 -43
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare function getSubgraphSdk(subgraphUrl: string): {
|
|
2
|
+
getSellerByOperatorQuery(variables: import("../subgraph").Exact<{
|
|
3
|
+
operator: string;
|
|
4
|
+
fundsTokenAddress?: string;
|
|
5
|
+
}>, requestHeaders?: Record<string, string> | import("graphql-request/dist/types.dom").Headers | string[][]): Promise<import("../subgraph").GetSellerByOperatorQueryQuery>;
|
|
6
|
+
getSellerByAdminQuery(variables: import("../subgraph").Exact<{
|
|
7
|
+
admin: string;
|
|
8
|
+
fundsTokenAddress?: string;
|
|
9
|
+
}>, requestHeaders?: Record<string, string> | import("graphql-request/dist/types.dom").Headers | string[][]): Promise<import("../subgraph").GetSellerByAdminQueryQuery>;
|
|
10
|
+
getSellerByClerkQuery(variables: import("../subgraph").Exact<{
|
|
11
|
+
clerk: string;
|
|
12
|
+
fundsTokenAddress?: string;
|
|
13
|
+
}>, requestHeaders?: Record<string, string> | import("graphql-request/dist/types.dom").Headers | string[][]): Promise<import("../subgraph").GetSellerByClerkQueryQuery>;
|
|
14
|
+
getFundsByAccountIdQuery(variables: import("../subgraph").Exact<{
|
|
15
|
+
accountId: string;
|
|
16
|
+
}>, requestHeaders?: Record<string, string> | import("graphql-request/dist/types.dom").Headers | string[][]): Promise<import("../subgraph").GetFundsByAccountIdQueryQuery>;
|
|
17
|
+
getOfferByIdQuery(variables: import("../subgraph").Exact<{
|
|
18
|
+
offerId: string;
|
|
19
|
+
}>, requestHeaders?: Record<string, string> | import("graphql-request/dist/types.dom").Headers | string[][]): Promise<import("../subgraph").GetOfferByIdQueryQuery>;
|
|
20
|
+
getAllOffersOfOperatorQuery(variables: import("../subgraph").Exact<{
|
|
21
|
+
operator: string;
|
|
22
|
+
first?: number;
|
|
23
|
+
skip?: number;
|
|
24
|
+
orderBy?: import("../subgraph").Offer_OrderBy;
|
|
25
|
+
orderDirection?: import("../subgraph").OrderDirection;
|
|
26
|
+
}>, requestHeaders?: Record<string, string> | import("graphql-request/dist/types.dom").Headers | string[][]): Promise<import("../subgraph").GetAllOffersOfOperatorQueryQuery>;
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=graphql.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql.d.ts","sourceRoot":"","sources":["../../../src/utils/graphql.ts"],"names":[],"mappings":"AAGA,wBAAgB,cAAc,CAAC,WAAW,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;EAGjD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql.js","sourceRoot":"","sources":["../../../src/utils/graphql.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,MAAM,UAAU,cAAc,CAAC,WAAmB;IAChD,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC,WAAW,CAAC,CAAC;IAC9C,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC;AACxB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bosonprotocol/core-sdk",
|
|
3
|
-
"version": "1.6.0-alpha.
|
|
3
|
+
"version": "1.6.0-alpha.4",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
"scripts": {
|
|
9
9
|
"dev": "tsc --watch --preserveWatchOutput ",
|
|
10
10
|
"lint": "eslint --ignore-path ../../.gitignore --ext .js,.ts .",
|
|
11
|
+
"lint:fix": "npm run lint -- --fix",
|
|
11
12
|
"build": "rimraf dist && tsc && tsc --build tsconfig.cjs.json",
|
|
12
13
|
"test": "jest",
|
|
13
14
|
"clean": "rimraf dist coverage .turbo node_modules"
|
|
@@ -30,13 +31,15 @@
|
|
|
30
31
|
"access": "restricted"
|
|
31
32
|
},
|
|
32
33
|
"dependencies": {
|
|
33
|
-
"@bosonprotocol/common": "^1.6.0-alpha.
|
|
34
|
+
"@bosonprotocol/common": "^1.6.0-alpha.4",
|
|
34
35
|
"@ethersproject/abi": "^5.5.0",
|
|
35
36
|
"@ethersproject/address": "^5.5.0",
|
|
36
37
|
"@ethersproject/bignumber": "^5.5.0",
|
|
37
38
|
"@ethersproject/constants": "^5.5.0",
|
|
38
39
|
"@ethersproject/units": "^5.5.0",
|
|
39
|
-
"cross-fetch": "^3.1.5"
|
|
40
|
+
"cross-fetch": "^3.1.5",
|
|
41
|
+
"graphql": "^16.5.0",
|
|
42
|
+
"graphql-request": "^4.3.0"
|
|
40
43
|
},
|
|
41
44
|
"devDependencies": {
|
|
42
45
|
"eslint": "^8.10.0",
|
|
@@ -46,5 +49,5 @@
|
|
|
46
49
|
"ts-jest": "^27.1.3",
|
|
47
50
|
"typescript": "^4.5.5"
|
|
48
51
|
},
|
|
49
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "1c0b75626796800f55c0a0d8f178ea7e17f5e678"
|
|
50
53
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
query getSellerByOperatorQuery($operator: Bytes!, $fundsTokenAddress: Bytes) {
|
|
2
|
+
sellers(where: { operator: $operator }) {
|
|
3
|
+
...SellerFields
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
query getSellerByAdminQuery($admin: Bytes!, $fundsTokenAddress: Bytes) {
|
|
8
|
+
sellers(where: { admin: $admin }) {
|
|
9
|
+
...SellerFields
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
query getSellerByClerkQuery($clerk: Bytes!, $fundsTokenAddress: Bytes) {
|
|
14
|
+
sellers(where: { clerk: $clerk }) {
|
|
15
|
+
...SellerFields
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
fragment SellerFields on Seller {
|
|
20
|
+
id
|
|
21
|
+
operator
|
|
22
|
+
admin
|
|
23
|
+
clerk
|
|
24
|
+
treasury
|
|
25
|
+
active
|
|
26
|
+
funds(where: { tokenAddress: $fundsTokenAddress }) {
|
|
27
|
+
availableAmount
|
|
28
|
+
token {
|
|
29
|
+
address
|
|
30
|
+
decimals
|
|
31
|
+
name
|
|
32
|
+
symbol
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
package/src/accounts/subgraph.ts
CHANGED
|
@@ -1,47 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export const sellerFieldsFragment = `
|
|
5
|
-
fragment sellerFields on Seller {
|
|
6
|
-
id
|
|
7
|
-
operator
|
|
8
|
-
admin
|
|
9
|
-
clerk
|
|
10
|
-
treasury
|
|
11
|
-
active
|
|
12
|
-
funds(where: {
|
|
13
|
-
tokenAddress: $fundsTokenAddress
|
|
14
|
-
}) {
|
|
15
|
-
availableAmount
|
|
16
|
-
token {
|
|
17
|
-
address
|
|
18
|
-
decimals
|
|
19
|
-
name
|
|
20
|
-
symbol
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
`;
|
|
25
|
-
|
|
26
|
-
export const getSellerByOperatorQuery = `
|
|
27
|
-
query GetSellersByOperator($operator: String!, $fundsTokenAddress: String) {
|
|
28
|
-
sellers(where: {
|
|
29
|
-
operator: $operator
|
|
30
|
-
}) {
|
|
31
|
-
...sellerFields
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
${sellerFieldsFragment}
|
|
35
|
-
`;
|
|
1
|
+
import { getSubgraphSdk } from "../utils/graphql";
|
|
2
|
+
import { SellerFieldsFragment } from "../subgraph";
|
|
36
3
|
|
|
37
4
|
export async function getSellerByOperator(
|
|
38
5
|
subgraphUrl: string,
|
|
39
6
|
operatorAddress: string,
|
|
40
7
|
fundsTokenAddress?: string
|
|
41
|
-
): Promise<
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
}>(subgraphUrl, getSellerByOperatorQuery, {
|
|
8
|
+
): Promise<SellerFieldsFragment> {
|
|
9
|
+
const sdk = getSubgraphSdk(subgraphUrl);
|
|
10
|
+
const { sellers = [] } = await sdk.getSellerByOperatorQuery({
|
|
45
11
|
operator: operatorAddress,
|
|
46
12
|
fundsTokenAddress
|
|
47
13
|
});
|
|
@@ -49,25 +15,13 @@ export async function getSellerByOperator(
|
|
|
49
15
|
return sellers[0];
|
|
50
16
|
}
|
|
51
17
|
|
|
52
|
-
export const getSellerByAdminQuery = `
|
|
53
|
-
query GetSellersByAdmin($admin: String!, $fundsToken: String) {
|
|
54
|
-
sellers(where: {
|
|
55
|
-
admin: $admin
|
|
56
|
-
}) {
|
|
57
|
-
...sellerFields
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
${sellerFieldsFragment}
|
|
61
|
-
`;
|
|
62
|
-
|
|
63
18
|
export async function getSellerByAdmin(
|
|
64
19
|
subgraphUrl: string,
|
|
65
20
|
adminAddress: string,
|
|
66
21
|
fundsTokenAddress?: string
|
|
67
|
-
): Promise<
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
}>(subgraphUrl, getSellerByAdminQuery, {
|
|
22
|
+
): Promise<SellerFieldsFragment> {
|
|
23
|
+
const sdk = getSubgraphSdk(subgraphUrl);
|
|
24
|
+
const { sellers = [] } = await sdk.getSellerByAdminQuery({
|
|
71
25
|
admin: adminAddress,
|
|
72
26
|
fundsTokenAddress
|
|
73
27
|
});
|
|
@@ -75,25 +29,13 @@ export async function getSellerByAdmin(
|
|
|
75
29
|
return sellers[0];
|
|
76
30
|
}
|
|
77
31
|
|
|
78
|
-
export const getSellerByClerkQuery = `
|
|
79
|
-
query GetSellersByOperator($clerk: String!, $fundsToken: String) {
|
|
80
|
-
sellers(where: {
|
|
81
|
-
clerk: $clerk
|
|
82
|
-
}) {
|
|
83
|
-
...sellerFields
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
${sellerFieldsFragment}
|
|
87
|
-
`;
|
|
88
|
-
|
|
89
32
|
export async function getSellerByClerk(
|
|
90
33
|
subgraphUrl: string,
|
|
91
34
|
clerkAddress: string,
|
|
92
35
|
fundsTokenAddress?: string
|
|
93
|
-
): Promise<
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
}>(subgraphUrl, getSellerByClerkQuery, {
|
|
36
|
+
): Promise<SellerFieldsFragment> {
|
|
37
|
+
const sdk = getSubgraphSdk(subgraphUrl);
|
|
38
|
+
const { sellers = [] } = await sdk.getSellerByClerkQuery({
|
|
97
39
|
clerk: clerkAddress,
|
|
98
40
|
fundsTokenAddress
|
|
99
41
|
});
|
|
@@ -105,7 +47,7 @@ export async function getSellerByAddress(
|
|
|
105
47
|
subgraphUrl: string,
|
|
106
48
|
address: string,
|
|
107
49
|
fundsTokenAddress?: string
|
|
108
|
-
): Promise<
|
|
50
|
+
): Promise<SellerFieldsFragment> {
|
|
109
51
|
const [operator, admin, clerk] = await Promise.all([
|
|
110
52
|
getSellerByOperator(subgraphUrl, address, fundsTokenAddress),
|
|
111
53
|
getSellerByAdmin(subgraphUrl, address, fundsTokenAddress),
|
package/src/accounts/types.ts
CHANGED
|
@@ -1,13 +1 @@
|
|
|
1
|
-
import { RawFundsEntityFromSubgraph } from "../funds/types";
|
|
2
|
-
|
|
3
1
|
export { CreateSellerArgs } from "@bosonprotocol/common";
|
|
4
|
-
|
|
5
|
-
export type RawSellerFromSubgraph = {
|
|
6
|
-
id: string;
|
|
7
|
-
operator: string;
|
|
8
|
-
admin: string;
|
|
9
|
-
clerk: string;
|
|
10
|
-
treasury: string;
|
|
11
|
-
active: boolean;
|
|
12
|
-
funds: Omit<RawFundsEntityFromSubgraph, "id" | "accountId">[];
|
|
13
|
-
};
|
package/src/core-sdk.ts
CHANGED
|
@@ -15,8 +15,9 @@ import * as offers from "./offers";
|
|
|
15
15
|
import * as orchestration from "./orchestration";
|
|
16
16
|
import * as erc20 from "./erc20";
|
|
17
17
|
import * as funds from "./funds";
|
|
18
|
+
import * as subgraph from "./subgraph";
|
|
19
|
+
|
|
18
20
|
import { getValueFromLogs } from "./utils/logs";
|
|
19
|
-
import { MultiQueryOpts } from "./utils/subgraph";
|
|
20
21
|
|
|
21
22
|
export class CoreSDK {
|
|
22
23
|
private _web3Lib: Web3LibAdapter;
|
|
@@ -80,7 +81,7 @@ export class CoreSDK {
|
|
|
80
81
|
public async getSellerByOperator(
|
|
81
82
|
operator: string,
|
|
82
83
|
fundsTokenAddress?: string
|
|
83
|
-
): Promise<
|
|
84
|
+
): Promise<subgraph.SellerFieldsFragment> {
|
|
84
85
|
return accounts.subgraph.getSellerByOperator(
|
|
85
86
|
this._subgraphUrl,
|
|
86
87
|
operator,
|
|
@@ -91,7 +92,7 @@ export class CoreSDK {
|
|
|
91
92
|
public async getSellerByClerk(
|
|
92
93
|
clerk: string,
|
|
93
94
|
fundsTokenAddress?: string
|
|
94
|
-
): Promise<
|
|
95
|
+
): Promise<subgraph.SellerFieldsFragment> {
|
|
95
96
|
return accounts.subgraph.getSellerByClerk(
|
|
96
97
|
this._subgraphUrl,
|
|
97
98
|
clerk,
|
|
@@ -102,7 +103,7 @@ export class CoreSDK {
|
|
|
102
103
|
public async getSellerByAddress(
|
|
103
104
|
address: string,
|
|
104
105
|
fundsTokenAddress?: string
|
|
105
|
-
): Promise<
|
|
106
|
+
): Promise<subgraph.SellerFieldsFragment> {
|
|
106
107
|
return accounts.subgraph.getSellerByAddress(
|
|
107
108
|
this._subgraphUrl,
|
|
108
109
|
address,
|
|
@@ -177,7 +178,7 @@ export class CoreSDK {
|
|
|
177
178
|
|
|
178
179
|
public async getOfferById(
|
|
179
180
|
offerId: BigNumberish
|
|
180
|
-
): Promise<
|
|
181
|
+
): Promise<subgraph.OfferFieldsFragment> {
|
|
181
182
|
return offers.subgraph.getOfferById(this._subgraphUrl, offerId);
|
|
182
183
|
}
|
|
183
184
|
|
|
@@ -186,8 +187,8 @@ export class CoreSDK {
|
|
|
186
187
|
operatorAddress: string;
|
|
187
188
|
// TODO: add support for sellerId, adminAddress, clerkAddress, treasuryAddress
|
|
188
189
|
},
|
|
189
|
-
opts
|
|
190
|
-
): Promise<
|
|
190
|
+
opts?: offers.subgraph.MultiQueryOpts
|
|
191
|
+
): Promise<subgraph.OfferFieldsFragment[]> {
|
|
191
192
|
if (sellerFilter.operatorAddress) {
|
|
192
193
|
return offers.subgraph.getAllOffersOfOperator(
|
|
193
194
|
this._subgraphUrl,
|
|
@@ -286,7 +287,7 @@ export class CoreSDK {
|
|
|
286
287
|
|
|
287
288
|
public async getFundsByAccountId(
|
|
288
289
|
accountId: BigNumberish
|
|
289
|
-
): Promise<
|
|
290
|
+
): Promise<subgraph.FundsEntityFieldsFragment[]> {
|
|
290
291
|
return funds.subgraph.getFundsByAccountId(this._subgraphUrl, accountId);
|
|
291
292
|
}
|
|
292
293
|
}
|
package/src/funds/index.ts
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
query getFundsByAccountIdQuery($accountId: BigInt!) {
|
|
2
|
+
fundsEntities(where: { accountId: $accountId }) {
|
|
3
|
+
...FundsEntityFields
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
fragment FundsEntityFields on FundsEntity {
|
|
8
|
+
id
|
|
9
|
+
availableAmount
|
|
10
|
+
token {
|
|
11
|
+
address
|
|
12
|
+
name
|
|
13
|
+
symbol
|
|
14
|
+
decimals
|
|
15
|
+
}
|
|
16
|
+
accountId
|
|
17
|
+
}
|
package/src/funds/subgraph.ts
CHANGED
|
@@ -1,39 +1,16 @@
|
|
|
1
1
|
import { BigNumberish } from "@ethersproject/bignumber";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
export const fundsEntityFieldsFragment = `
|
|
6
|
-
fragment fundsEntityFields on FundsEntity {
|
|
7
|
-
id
|
|
8
|
-
availableAmount
|
|
9
|
-
token {
|
|
10
|
-
address
|
|
11
|
-
name
|
|
12
|
-
symbol
|
|
13
|
-
decimals
|
|
14
|
-
}
|
|
15
|
-
accountId
|
|
16
|
-
}
|
|
17
|
-
`;
|
|
18
|
-
|
|
19
|
-
export const getFundsByAccountIdQuery = `
|
|
20
|
-
query GetFundsByAccountIdQuery($accountId: String!) {
|
|
21
|
-
fundsEntities(where: {
|
|
22
|
-
accountId: $accountId
|
|
23
|
-
}) {
|
|
24
|
-
...fundsEntityFields
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
${fundsEntityFieldsFragment}
|
|
28
|
-
`;
|
|
2
|
+
import { getSubgraphSdk } from "../utils/graphql";
|
|
3
|
+
import { FundsEntityFieldsFragment } from "../subgraph";
|
|
29
4
|
|
|
30
5
|
export async function getFundsByAccountId(
|
|
31
6
|
subgraphUrl: string,
|
|
32
7
|
accountId: BigNumberish
|
|
33
|
-
): Promise<
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
8
|
+
): Promise<FundsEntityFieldsFragment[]> {
|
|
9
|
+
const subgraphSdk = getSubgraphSdk(subgraphUrl);
|
|
10
|
+
|
|
11
|
+
const { fundsEntities = [] } = await subgraphSdk.getFundsByAccountIdQuery({
|
|
12
|
+
accountId: accountId.toString()
|
|
13
|
+
});
|
|
37
14
|
|
|
38
15
|
return fundsEntities;
|
|
39
16
|
}
|
package/src/index.ts
CHANGED
|
@@ -6,6 +6,7 @@ export * as exchanges from "./exchanges";
|
|
|
6
6
|
export * as orchestration from "./orchestration";
|
|
7
7
|
export * as erc20 from "./erc20";
|
|
8
8
|
export * as funds from "./funds";
|
|
9
|
+
export * as subgraph from "./subgraph";
|
|
9
10
|
|
|
10
11
|
export { defaultConfigs, getDefaultConfig } from "@bosonprotocol/common";
|
|
11
12
|
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
query getOfferByIdQuery($offerId: ID!) {
|
|
2
|
+
offer(id: $offerId) {
|
|
3
|
+
...OfferFields
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
query getAllOffersOfOperatorQuery(
|
|
8
|
+
$operator: Bytes!
|
|
9
|
+
$first: Int
|
|
10
|
+
$skip: Int
|
|
11
|
+
$orderBy: Offer_orderBy
|
|
12
|
+
$orderDirection: OrderDirection
|
|
13
|
+
) {
|
|
14
|
+
sellers(where: { operator: $operator }) {
|
|
15
|
+
offers(
|
|
16
|
+
first: $first
|
|
17
|
+
skip: $skip
|
|
18
|
+
orderBy: $orderBy
|
|
19
|
+
orderDirection: $orderDirection
|
|
20
|
+
) {
|
|
21
|
+
...OfferFields
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
fragment OfferFields on Offer {
|
|
27
|
+
id
|
|
28
|
+
createdAt
|
|
29
|
+
price
|
|
30
|
+
sellerDeposit
|
|
31
|
+
protocolFee
|
|
32
|
+
buyerCancelPenalty
|
|
33
|
+
quantityAvailable
|
|
34
|
+
quantityInitial
|
|
35
|
+
validFromDate
|
|
36
|
+
validUntilDate
|
|
37
|
+
voucherRedeemableFromDate
|
|
38
|
+
voucherRedeemableUntilDate
|
|
39
|
+
fulfillmentPeriodDuration
|
|
40
|
+
voucherValidDuration
|
|
41
|
+
resolutionPeriodDuration
|
|
42
|
+
metadataUri
|
|
43
|
+
offerChecksum
|
|
44
|
+
voidedAt
|
|
45
|
+
disputeResolverId
|
|
46
|
+
seller {
|
|
47
|
+
id
|
|
48
|
+
operator
|
|
49
|
+
admin
|
|
50
|
+
clerk
|
|
51
|
+
treasury
|
|
52
|
+
active
|
|
53
|
+
}
|
|
54
|
+
exchangeToken {
|
|
55
|
+
address
|
|
56
|
+
decimals
|
|
57
|
+
name
|
|
58
|
+
symbol
|
|
59
|
+
}
|
|
60
|
+
metadata {
|
|
61
|
+
name
|
|
62
|
+
description
|
|
63
|
+
externalUrl
|
|
64
|
+
schemaUrl
|
|
65
|
+
type
|
|
66
|
+
}
|
|
67
|
+
exchanges {
|
|
68
|
+
id
|
|
69
|
+
committedDate
|
|
70
|
+
redeemedDate
|
|
71
|
+
finalizedDate
|
|
72
|
+
expired
|
|
73
|
+
disputed
|
|
74
|
+
}
|
|
75
|
+
}
|
package/src/offers/subgraph.ts
CHANGED
|
@@ -1,130 +1,43 @@
|
|
|
1
1
|
import { BigNumberish } from "@ethersproject/bignumber";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
`;
|
|
15
|
-
|
|
16
|
-
export const offerFieldsFragment = `
|
|
17
|
-
fragment offerFields on Offer {
|
|
18
|
-
id
|
|
19
|
-
createdAt
|
|
20
|
-
price
|
|
21
|
-
sellerDeposit
|
|
22
|
-
protocolFee
|
|
23
|
-
buyerCancelPenalty
|
|
24
|
-
quantityAvailable
|
|
25
|
-
quantityInitial
|
|
26
|
-
validFromDate
|
|
27
|
-
validUntilDate
|
|
28
|
-
voucherRedeemableFromDate
|
|
29
|
-
voucherRedeemableUntilDate
|
|
30
|
-
fulfillmentPeriodDuration
|
|
31
|
-
voucherValidDuration
|
|
32
|
-
resolutionPeriodDuration
|
|
33
|
-
metadataUri
|
|
34
|
-
offerChecksum
|
|
35
|
-
voidedAt
|
|
36
|
-
disputeResolverId
|
|
37
|
-
seller {
|
|
38
|
-
id
|
|
39
|
-
operator
|
|
40
|
-
admin
|
|
41
|
-
clerk
|
|
42
|
-
treasury
|
|
43
|
-
active
|
|
44
|
-
}
|
|
45
|
-
exchangeToken {
|
|
46
|
-
address
|
|
47
|
-
decimals
|
|
48
|
-
name
|
|
49
|
-
symbol
|
|
50
|
-
}
|
|
51
|
-
metadata {
|
|
52
|
-
name
|
|
53
|
-
description
|
|
54
|
-
externalUrl
|
|
55
|
-
schemaUrl
|
|
56
|
-
type
|
|
57
|
-
}
|
|
58
|
-
exchanges {
|
|
59
|
-
...exchangeFields
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
${exchangeFieldsFragment}
|
|
63
|
-
`;
|
|
64
|
-
|
|
65
|
-
export const getOfferByIdQuery = `
|
|
66
|
-
query GetOfferById($offerId: ID!) {
|
|
67
|
-
offer(id: $offerId) {
|
|
68
|
-
...offerFields
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
${offerFieldsFragment}
|
|
72
|
-
`;
|
|
2
|
+
import { getSubgraphSdk } from "../utils/graphql";
|
|
3
|
+
import {
|
|
4
|
+
OfferFieldsFragment,
|
|
5
|
+
OrderDirection,
|
|
6
|
+
Offer_OrderBy
|
|
7
|
+
} from "../subgraph";
|
|
8
|
+
|
|
9
|
+
export type MultiQueryOpts = {
|
|
10
|
+
orderBy: Offer_OrderBy;
|
|
11
|
+
orderDirection: OrderDirection;
|
|
12
|
+
};
|
|
73
13
|
|
|
74
14
|
export async function getOfferById(
|
|
75
15
|
subgraphUrl: string,
|
|
76
16
|
offerId: BigNumberish
|
|
77
|
-
): Promise<
|
|
78
|
-
const
|
|
79
|
-
subgraphUrl,
|
|
80
|
-
getOfferByIdQuery,
|
|
81
|
-
{ offerId: offerId.toString() }
|
|
82
|
-
);
|
|
17
|
+
): Promise<OfferFieldsFragment> {
|
|
18
|
+
const subgraphSdk = getSubgraphSdk(subgraphUrl);
|
|
83
19
|
|
|
84
|
-
|
|
85
|
-
|
|
20
|
+
const { offer } = await subgraphSdk.getOfferByIdQuery({
|
|
21
|
+
offerId: offerId.toString()
|
|
22
|
+
});
|
|
86
23
|
|
|
87
|
-
|
|
88
|
-
query GetAllOffersOfOperatorQuery(
|
|
89
|
-
$operator: String!,
|
|
90
|
-
$first: Int,
|
|
91
|
-
$skip: Int,
|
|
92
|
-
$orderBy: String,
|
|
93
|
-
$orderDirection: String
|
|
94
|
-
) {
|
|
95
|
-
sellers(where: {
|
|
96
|
-
operator: $operator
|
|
97
|
-
}) {
|
|
98
|
-
offers(
|
|
99
|
-
first: $first
|
|
100
|
-
skip: $skip
|
|
101
|
-
orderBy: $orderBy
|
|
102
|
-
orderDirection: $orderDirection
|
|
103
|
-
) {
|
|
104
|
-
...offerFields
|
|
105
|
-
}
|
|
106
|
-
}
|
|
24
|
+
return offer;
|
|
107
25
|
}
|
|
108
|
-
${offerFieldsFragment}
|
|
109
|
-
`;
|
|
110
26
|
|
|
111
27
|
export async function getAllOffersOfOperator(
|
|
112
28
|
subgraphUrl: string,
|
|
113
29
|
operatorAddress: string,
|
|
114
|
-
opts
|
|
115
|
-
): Promise<
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
}
|
|
119
|
-
operator: operatorAddress
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
orderBy: "createdAt",
|
|
123
|
-
orderDirection: "desc",
|
|
124
|
-
...opts
|
|
30
|
+
opts?: MultiQueryOpts
|
|
31
|
+
): Promise<OfferFieldsFragment[]> {
|
|
32
|
+
const subgraphSdk = getSubgraphSdk(subgraphUrl);
|
|
33
|
+
|
|
34
|
+
const { sellers = [] } = await subgraphSdk.getAllOffersOfOperatorQuery({
|
|
35
|
+
operator: operatorAddress,
|
|
36
|
+
orderBy: opts?.orderBy,
|
|
37
|
+
orderDirection: opts?.orderDirection
|
|
125
38
|
});
|
|
126
39
|
|
|
127
|
-
if (!sellers) {
|
|
40
|
+
if (!sellers || sellers.length === 0) {
|
|
128
41
|
return [];
|
|
129
42
|
}
|
|
130
43
|
|
package/src/offers/types.ts
CHANGED
|
@@ -1,52 +1 @@
|
|
|
1
1
|
export { CreateOfferArgs } from "@bosonprotocol/common";
|
|
2
|
-
|
|
3
|
-
export type RawOfferFromSubgraph = {
|
|
4
|
-
id: string;
|
|
5
|
-
createdAt: string;
|
|
6
|
-
price: string;
|
|
7
|
-
sellerDeposit: string;
|
|
8
|
-
protocolFee: string;
|
|
9
|
-
buyerCancelPenalty: string;
|
|
10
|
-
quantityAvailable: string;
|
|
11
|
-
quantityInitial: string;
|
|
12
|
-
validFromDate: string;
|
|
13
|
-
validUntilDate: string;
|
|
14
|
-
voucherRedeemableFromDate: string;
|
|
15
|
-
voucherRedeemableUntilDate: string;
|
|
16
|
-
fulfillmentPeriodDuration: string;
|
|
17
|
-
voucherValidDuration: string;
|
|
18
|
-
resolutionPeriodDuration: string;
|
|
19
|
-
metadataUri: string;
|
|
20
|
-
offerChecksum: string;
|
|
21
|
-
voidedAt: null | string;
|
|
22
|
-
disputeResolverId: string;
|
|
23
|
-
seller: {
|
|
24
|
-
id: string;
|
|
25
|
-
operator: string;
|
|
26
|
-
admin: string;
|
|
27
|
-
clerk: string;
|
|
28
|
-
treasury: string;
|
|
29
|
-
active: boolean;
|
|
30
|
-
};
|
|
31
|
-
exchangeToken: {
|
|
32
|
-
address: string;
|
|
33
|
-
decimals: string;
|
|
34
|
-
name: string;
|
|
35
|
-
symbol: string;
|
|
36
|
-
};
|
|
37
|
-
metadata: null | {
|
|
38
|
-
name: string;
|
|
39
|
-
description: string;
|
|
40
|
-
externalUrl: string;
|
|
41
|
-
schemaUrl: string;
|
|
42
|
-
type: string;
|
|
43
|
-
};
|
|
44
|
-
exchanges: {
|
|
45
|
-
id: string;
|
|
46
|
-
committedDate: string;
|
|
47
|
-
disputed: boolean;
|
|
48
|
-
expired: boolean;
|
|
49
|
-
finalizedDate: string;
|
|
50
|
-
redeemedDate: string;
|
|
51
|
-
}[];
|
|
52
|
-
};
|