@bosonprotocol/core-sdk 1.12.0-alpha.2 → 1.12.0-alpha.3

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.
Files changed (60) hide show
  1. package/dist/cjs/core-sdk.d.ts +30 -0
  2. package/dist/cjs/core-sdk.d.ts.map +1 -1
  3. package/dist/cjs/core-sdk.js +131 -1
  4. package/dist/cjs/core-sdk.js.map +1 -1
  5. package/dist/cjs/disputes/handler.d.ts +61 -0
  6. package/dist/cjs/disputes/handler.d.ts.map +1 -0
  7. package/dist/cjs/disputes/handler.js +104 -0
  8. package/dist/cjs/disputes/handler.js.map +1 -0
  9. package/dist/cjs/disputes/index.d.ts +4 -0
  10. package/dist/cjs/disputes/index.d.ts.map +1 -0
  11. package/dist/cjs/disputes/index.js +30 -0
  12. package/dist/cjs/disputes/index.js.map +1 -0
  13. package/dist/cjs/disputes/interface.d.ts +30 -0
  14. package/dist/cjs/disputes/interface.d.ts.map +1 -0
  15. package/dist/cjs/disputes/interface.js +74 -0
  16. package/dist/cjs/disputes/interface.js.map +1 -0
  17. package/dist/cjs/disputes/subgraph.d.ts +6 -0
  18. package/dist/cjs/disputes/subgraph.d.ts.map +1 -0
  19. package/dist/cjs/disputes/subgraph.js +30 -0
  20. package/dist/cjs/disputes/subgraph.js.map +1 -0
  21. package/dist/cjs/subgraph.d.ts +408 -0
  22. package/dist/cjs/subgraph.d.ts.map +1 -1
  23. package/dist/cjs/subgraph.js +104 -2
  24. package/dist/cjs/subgraph.js.map +1 -1
  25. package/dist/cjs/utils/graphql.d.ts +16 -0
  26. package/dist/cjs/utils/graphql.d.ts.map +1 -1
  27. package/dist/esm/core-sdk.d.ts +30 -0
  28. package/dist/esm/core-sdk.d.ts.map +1 -1
  29. package/dist/esm/core-sdk.js +110 -1
  30. package/dist/esm/core-sdk.js.map +1 -1
  31. package/dist/esm/disputes/handler.d.ts +61 -0
  32. package/dist/esm/disputes/handler.d.ts.map +1 -0
  33. package/dist/esm/disputes/handler.js +62 -0
  34. package/dist/esm/disputes/handler.js.map +1 -0
  35. package/dist/esm/disputes/index.d.ts +4 -0
  36. package/dist/esm/disputes/index.d.ts.map +1 -0
  37. package/dist/esm/disputes/index.js +4 -0
  38. package/dist/esm/disputes/index.js.map +1 -0
  39. package/dist/esm/disputes/interface.d.ts +30 -0
  40. package/dist/esm/disputes/interface.d.ts.map +1 -0
  41. package/dist/esm/disputes/interface.js +61 -0
  42. package/dist/esm/disputes/interface.js.map +1 -0
  43. package/dist/esm/disputes/subgraph.d.ts +6 -0
  44. package/dist/esm/disputes/subgraph.d.ts.map +1 -0
  45. package/dist/esm/disputes/subgraph.js +15 -0
  46. package/dist/esm/disputes/subgraph.js.map +1 -0
  47. package/dist/esm/subgraph.d.ts +408 -0
  48. package/dist/esm/subgraph.d.ts.map +1 -1
  49. package/dist/esm/subgraph.js +102 -0
  50. package/dist/esm/subgraph.js.map +1 -1
  51. package/dist/esm/utils/graphql.d.ts +16 -0
  52. package/dist/esm/utils/graphql.d.ts.map +1 -1
  53. package/package.json +4 -3
  54. package/src/core-sdk.ts +168 -1
  55. package/src/disputes/handler.ts +132 -0
  56. package/src/disputes/index.ts +3 -0
  57. package/src/disputes/interface.ts +90 -0
  58. package/src/disputes/queries.graphql +56 -0
  59. package/src/disputes/subgraph.ts +34 -0
  60. package/src/subgraph.ts +503 -0
@@ -0,0 +1,90 @@
1
+ import { abis } from "@bosonprotocol/common";
2
+ import { Interface } from "@ethersproject/abi";
3
+ import { BigNumberish } from "@ethersproject/bignumber";
4
+ import { BytesLike } from "@ethersproject/bytes";
5
+
6
+ export const bosonDisputeHandlerIface = new Interface(
7
+ abis.IBosonDisputeHandlerABI
8
+ );
9
+
10
+ export function encodeDecideDispute(args: {
11
+ exchangeId: BigNumberish;
12
+ buyerPercent: BigNumberish;
13
+ }) {
14
+ return bosonDisputeHandlerIface.encodeFunctionData("decideDispute", [
15
+ args.exchangeId,
16
+ args.buyerPercent
17
+ ]);
18
+ }
19
+
20
+ export function encodeEscalateDispute(exchangeId: BigNumberish) {
21
+ return bosonDisputeHandlerIface.encodeFunctionData("escalateDispute", [
22
+ exchangeId
23
+ ]);
24
+ }
25
+
26
+ export function encodeExpireDispute(exchangeId: BigNumberish) {
27
+ return bosonDisputeHandlerIface.encodeFunctionData("expireDispute", [
28
+ exchangeId
29
+ ]);
30
+ }
31
+
32
+ export function encodeExpireDisputeBatch(exchangeIds: BigNumberish[]) {
33
+ return bosonDisputeHandlerIface.encodeFunctionData("expireDispute", [
34
+ exchangeIds
35
+ ]);
36
+ }
37
+
38
+ export function encodeExpireEscalatedDispute(exchangeId: BigNumberish) {
39
+ return bosonDisputeHandlerIface.encodeFunctionData("expireEscalatedDispute", [
40
+ exchangeId
41
+ ]);
42
+ }
43
+
44
+ export function encodeExtendDisputeTimeout(args: {
45
+ exchangeId: BigNumberish;
46
+ newDisputeTimeout: BigNumberish;
47
+ }) {
48
+ return bosonDisputeHandlerIface.encodeFunctionData("extendDisputeTimeout", [
49
+ args.exchangeId,
50
+ args.newDisputeTimeout
51
+ ]);
52
+ }
53
+
54
+ export function encodeRaiseDispute(args: {
55
+ exchangeId: BigNumberish;
56
+ complaint: string;
57
+ }) {
58
+ return bosonDisputeHandlerIface.encodeFunctionData("raiseDispute", [
59
+ args.exchangeId,
60
+ args.complaint
61
+ ]);
62
+ }
63
+
64
+ export function encodeRefuseEscalatedDispute(exchangeId: BigNumberish) {
65
+ return bosonDisputeHandlerIface.encodeFunctionData("refuseEscalatedDispute", [
66
+ exchangeId
67
+ ]);
68
+ }
69
+
70
+ export function encodeResolveDispute(args: {
71
+ exchangeId: BigNumberish;
72
+ buyerPercent: BigNumberish;
73
+ sigR: BytesLike;
74
+ sigS: BytesLike;
75
+ sigV: BigNumberish;
76
+ }) {
77
+ return bosonDisputeHandlerIface.encodeFunctionData("resolveDispute", [
78
+ args.exchangeId,
79
+ args.buyerPercent,
80
+ args.sigR,
81
+ args.sigS,
82
+ args.sigV
83
+ ]);
84
+ }
85
+
86
+ export function encodeRetractDispute(exchangeId: BigNumberish) {
87
+ return bosonDisputeHandlerIface.encodeFunctionData("retractDispute", [
88
+ exchangeId
89
+ ]);
90
+ }
@@ -0,0 +1,56 @@
1
+ query getDisputeByIdQuery(
2
+ $disputeId: ID!
3
+ $offersSkip: Int
4
+ $offersFirst: Int
5
+ $offersOrderBy: Offer_orderBy
6
+ $offersOrderDirection: OrderDirection
7
+ $offersFilter: Offer_filter
8
+ $includeOffers: Boolean = false
9
+ ) {
10
+ dispute(id: $disputeId) {
11
+ ...DisputeFields
12
+ }
13
+ }
14
+
15
+ query getDisputesQuery(
16
+ $disputesSkip: Int
17
+ $disputesFirst: Int
18
+ $disputesOrderBy: Dispute_orderBy
19
+ $disputesOrderDirection: OrderDirection
20
+ $disputesFilter: Dispute_filter
21
+ ) {
22
+ disputes(
23
+ skip: $disputesSkip
24
+ first: $disputesFirst
25
+ orderBy: $disputesOrderBy
26
+ orderDirection: $disputesOrderDirection
27
+ where: $disputesFilter
28
+ ) {
29
+ ...DisputeFields
30
+ }
31
+ }
32
+
33
+ fragment DisputeFields on Dispute {
34
+ ...BaseDisputeFields
35
+ }
36
+
37
+ fragment BaseDisputeFields on Dispute {
38
+ id
39
+ exchangeId
40
+ complaint
41
+ state
42
+ buyerPercent
43
+ disputedDate
44
+ escalatedDate
45
+ finalizedDate
46
+ timeout
47
+ exchange {
48
+ ...BaseExchangeFields
49
+ }
50
+ seller {
51
+ ...BaseSellerFields
52
+ }
53
+ buyer {
54
+ ...BaseBuyerFields
55
+ }
56
+ }
@@ -0,0 +1,34 @@
1
+ import { getSubgraphSdk } from "../utils/graphql";
2
+ import {
3
+ DisputeFieldsFragment,
4
+ GetDisputesQueryQueryVariables,
5
+ GetDisputeByIdQueryQueryVariables
6
+ } from "../subgraph";
7
+ import { BigNumberish } from "@ethersproject/bignumber";
8
+
9
+ export type SingleDisputeQueryVariables = Omit<
10
+ GetDisputeByIdQueryQueryVariables,
11
+ "disputeId"
12
+ >;
13
+
14
+ export async function getDisputeById(
15
+ subgraphUrl: string,
16
+ disputeId: BigNumberish,
17
+ queryVars: SingleDisputeQueryVariables = {}
18
+ ): Promise<DisputeFieldsFragment> {
19
+ const sdk = getSubgraphSdk(subgraphUrl);
20
+ const { dispute } = await sdk.getDisputeByIdQuery({
21
+ disputeId: disputeId.toString(),
22
+ ...queryVars
23
+ });
24
+ return dispute;
25
+ }
26
+
27
+ export async function getDisputes(
28
+ subgraphUrl: string,
29
+ queryVars: GetDisputesQueryQueryVariables = {}
30
+ ): Promise<DisputeFieldsFragment[]> {
31
+ const sdk = getSubgraphSdk(subgraphUrl);
32
+ const { disputes = [] } = await sdk.getDisputesQuery(queryVars);
33
+ return disputes;
34
+ }