@bosonprotocol/core-sdk 1.6.0-alpha.6 → 1.6.0-alpha.7
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/offers/getOfferStatus.d.ts +9 -0
- package/dist/cjs/offers/getOfferStatus.d.ts.map +1 -0
- package/dist/cjs/offers/getOfferStatus.js +26 -0
- package/dist/cjs/offers/getOfferStatus.js.map +1 -0
- package/dist/cjs/offers/index.d.ts +1 -0
- package/dist/cjs/offers/index.d.ts.map +1 -1
- package/dist/cjs/offers/index.js +1 -0
- package/dist/cjs/offers/index.js.map +1 -1
- package/dist/esm/offers/getOfferStatus.d.ts +9 -0
- package/dist/esm/offers/getOfferStatus.d.ts.map +1 -0
- package/dist/esm/offers/getOfferStatus.js +22 -0
- package/dist/esm/offers/getOfferStatus.js.map +1 -0
- package/dist/esm/offers/index.d.ts +1 -0
- package/dist/esm/offers/index.d.ts.map +1 -1
- package/dist/esm/offers/index.js +1 -0
- package/dist/esm/offers/index.js.map +1 -1
- package/package.json +3 -3
- package/src/offers/getOfferStatus.ts +27 -0
- package/src/offers/index.ts +1 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { subgraph } from "..";
|
|
2
|
+
export declare enum OfferState {
|
|
3
|
+
VOIDED = "VOIDED",
|
|
4
|
+
NOT_YET_VALID = "NOT YET VALID",
|
|
5
|
+
EXPIRED = "EXPIRED",
|
|
6
|
+
VALID = "VALID"
|
|
7
|
+
}
|
|
8
|
+
export declare function getOfferStatus(offer: subgraph.OfferFieldsFragment): OfferState;
|
|
9
|
+
//# sourceMappingURL=getOfferStatus.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getOfferStatus.d.ts","sourceRoot":"","sources":["../../../src/offers/getOfferStatus.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAE9B,oBAAY,UAAU;IACpB,MAAM,WAAW;IACjB,aAAa,kBAAkB;IAC/B,OAAO,YAAY;IACnB,KAAK,UAAU;CAChB;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,QAAQ,CAAC,mBAAmB,cAiBjE"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getOfferStatus = exports.OfferState = void 0;
|
|
4
|
+
var OfferState;
|
|
5
|
+
(function (OfferState) {
|
|
6
|
+
OfferState["VOIDED"] = "VOIDED";
|
|
7
|
+
OfferState["NOT_YET_VALID"] = "NOT YET VALID";
|
|
8
|
+
OfferState["EXPIRED"] = "EXPIRED";
|
|
9
|
+
OfferState["VALID"] = "VALID";
|
|
10
|
+
})(OfferState = exports.OfferState || (exports.OfferState = {}));
|
|
11
|
+
function getOfferStatus(offer) {
|
|
12
|
+
const toTimeStamp = (numberString) => Number(numberString) * 1000;
|
|
13
|
+
const timeNow = Date.now();
|
|
14
|
+
if (offer.voidedAt) {
|
|
15
|
+
return OfferState.VOIDED;
|
|
16
|
+
}
|
|
17
|
+
if (toTimeStamp(offer.validFromDate) > timeNow) {
|
|
18
|
+
return OfferState.NOT_YET_VALID;
|
|
19
|
+
}
|
|
20
|
+
if (toTimeStamp(offer.validUntilDate) < timeNow) {
|
|
21
|
+
return OfferState.EXPIRED;
|
|
22
|
+
}
|
|
23
|
+
return OfferState.VALID;
|
|
24
|
+
}
|
|
25
|
+
exports.getOfferStatus = getOfferStatus;
|
|
26
|
+
//# sourceMappingURL=getOfferStatus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getOfferStatus.js","sourceRoot":"","sources":["../../../src/offers/getOfferStatus.ts"],"names":[],"mappings":";;;AAEA,IAAY,UAKX;AALD,WAAY,UAAU;IACpB,+BAAiB,CAAA;IACjB,6CAA+B,CAAA;IAC/B,iCAAmB,CAAA;IACnB,6BAAe,CAAA;AACjB,CAAC,EALW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAKrB;AAED,SAAgB,cAAc,CAAC,KAAmC;IAChE,MAAM,WAAW,GAAG,CAAC,YAAoB,EAAE,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC;IAC1E,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAE3B,IAAI,KAAK,CAAC,QAAQ,EAAE;QAClB,OAAO,UAAU,CAAC,MAAM,CAAC;KAC1B;IAED,IAAI,WAAW,CAAC,KAAK,CAAC,aAAa,CAAC,GAAG,OAAO,EAAE;QAC9C,OAAO,UAAU,CAAC,aAAa,CAAC;KACjC;IAED,IAAI,WAAW,CAAC,KAAK,CAAC,cAAc,CAAC,GAAG,OAAO,EAAE;QAC/C,OAAO,UAAU,CAAC,OAAO,CAAC;KAC3B;IAED,OAAO,UAAU,CAAC,KAAK,CAAC;AAC1B,CAAC;AAjBD,wCAiBC"}
|
|
@@ -3,6 +3,7 @@ export * as subgraph from "./subgraph";
|
|
|
3
3
|
export * as iface from "./interface";
|
|
4
4
|
export * as storage from "./storage";
|
|
5
5
|
export * from "./types";
|
|
6
|
+
export * from "./getOfferStatus";
|
|
6
7
|
export declare const validation: {
|
|
7
8
|
createOfferArgsSchema: import("yup/lib/object").OptionalObjectSchema<{
|
|
8
9
|
price: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/offers/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,KAAK,MAAM,aAAa,CAAC;AACrC,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,cAAc,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/offers/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,KAAK,MAAM,aAAa,CAAC;AACrC,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,cAAc,SAAS,CAAC;AACxB,cAAc,kBAAkB,CAAC;AAEjC,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAEtB,CAAC"}
|
package/dist/cjs/offers/index.js
CHANGED
|
@@ -33,6 +33,7 @@ exports.subgraph = __importStar(require("./subgraph"));
|
|
|
33
33
|
exports.iface = __importStar(require("./interface"));
|
|
34
34
|
exports.storage = __importStar(require("./storage"));
|
|
35
35
|
__exportStar(require("./types"), exports);
|
|
36
|
+
__exportStar(require("./getOfferStatus"), exports);
|
|
36
37
|
exports.validation = {
|
|
37
38
|
createOfferArgsSchema: common_1.utils.validation.createOfferArgsSchema
|
|
38
39
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/offers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAA8C;AAE9C,qDAAqC;AACrC,uDAAuC;AACvC,qDAAqC;AACrC,qDAAqC;AACrC,0CAAwB;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/offers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAA8C;AAE9C,qDAAqC;AACrC,uDAAuC;AACvC,qDAAqC;AACrC,qDAAqC;AACrC,0CAAwB;AACxB,mDAAiC;AAEpB,QAAA,UAAU,GAAG;IACxB,qBAAqB,EAAE,cAAK,CAAC,UAAU,CAAC,qBAAqB;CAC9D,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { subgraph } from "..";
|
|
2
|
+
export declare enum OfferState {
|
|
3
|
+
VOIDED = "VOIDED",
|
|
4
|
+
NOT_YET_VALID = "NOT YET VALID",
|
|
5
|
+
EXPIRED = "EXPIRED",
|
|
6
|
+
VALID = "VALID"
|
|
7
|
+
}
|
|
8
|
+
export declare function getOfferStatus(offer: subgraph.OfferFieldsFragment): OfferState;
|
|
9
|
+
//# sourceMappingURL=getOfferStatus.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getOfferStatus.d.ts","sourceRoot":"","sources":["../../../src/offers/getOfferStatus.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAE9B,oBAAY,UAAU;IACpB,MAAM,WAAW;IACjB,aAAa,kBAAkB;IAC/B,OAAO,YAAY;IACnB,KAAK,UAAU;CAChB;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,QAAQ,CAAC,mBAAmB,cAiBjE"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export var OfferState;
|
|
2
|
+
(function (OfferState) {
|
|
3
|
+
OfferState["VOIDED"] = "VOIDED";
|
|
4
|
+
OfferState["NOT_YET_VALID"] = "NOT YET VALID";
|
|
5
|
+
OfferState["EXPIRED"] = "EXPIRED";
|
|
6
|
+
OfferState["VALID"] = "VALID";
|
|
7
|
+
})(OfferState || (OfferState = {}));
|
|
8
|
+
export function getOfferStatus(offer) {
|
|
9
|
+
const toTimeStamp = (numberString) => Number(numberString) * 1000;
|
|
10
|
+
const timeNow = Date.now();
|
|
11
|
+
if (offer.voidedAt) {
|
|
12
|
+
return OfferState.VOIDED;
|
|
13
|
+
}
|
|
14
|
+
if (toTimeStamp(offer.validFromDate) > timeNow) {
|
|
15
|
+
return OfferState.NOT_YET_VALID;
|
|
16
|
+
}
|
|
17
|
+
if (toTimeStamp(offer.validUntilDate) < timeNow) {
|
|
18
|
+
return OfferState.EXPIRED;
|
|
19
|
+
}
|
|
20
|
+
return OfferState.VALID;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=getOfferStatus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getOfferStatus.js","sourceRoot":"","sources":["../../../src/offers/getOfferStatus.ts"],"names":[],"mappings":"AAEA,MAAM,CAAN,IAAY,UAKX;AALD,WAAY,UAAU;IACpB,+BAAiB,CAAA;IACjB,6CAA+B,CAAA;IAC/B,iCAAmB,CAAA;IACnB,6BAAe,CAAA;AACjB,CAAC,EALW,UAAU,KAAV,UAAU,QAKrB;AAED,MAAM,UAAU,cAAc,CAAC,KAAmC;IAChE,MAAM,WAAW,GAAG,CAAC,YAAoB,EAAE,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC;IAC1E,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAE3B,IAAI,KAAK,CAAC,QAAQ,EAAE;QAClB,OAAO,UAAU,CAAC,MAAM,CAAC;KAC1B;IAED,IAAI,WAAW,CAAC,KAAK,CAAC,aAAa,CAAC,GAAG,OAAO,EAAE;QAC9C,OAAO,UAAU,CAAC,aAAa,CAAC;KACjC;IAED,IAAI,WAAW,CAAC,KAAK,CAAC,cAAc,CAAC,GAAG,OAAO,EAAE;QAC/C,OAAO,UAAU,CAAC,OAAO,CAAC;KAC3B;IAED,OAAO,UAAU,CAAC,KAAK,CAAC;AAC1B,CAAC"}
|
|
@@ -3,6 +3,7 @@ export * as subgraph from "./subgraph";
|
|
|
3
3
|
export * as iface from "./interface";
|
|
4
4
|
export * as storage from "./storage";
|
|
5
5
|
export * from "./types";
|
|
6
|
+
export * from "./getOfferStatus";
|
|
6
7
|
export declare const validation: {
|
|
7
8
|
createOfferArgsSchema: import("yup/lib/object").OptionalObjectSchema<{
|
|
8
9
|
price: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/offers/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,KAAK,MAAM,aAAa,CAAC;AACrC,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,cAAc,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/offers/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,KAAK,MAAM,aAAa,CAAC;AACrC,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,cAAc,SAAS,CAAC;AACxB,cAAc,kBAAkB,CAAC;AAEjC,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAEtB,CAAC"}
|
package/dist/esm/offers/index.js
CHANGED
|
@@ -4,6 +4,7 @@ export * as subgraph from "./subgraph";
|
|
|
4
4
|
export * as iface from "./interface";
|
|
5
5
|
export * as storage from "./storage";
|
|
6
6
|
export * from "./types";
|
|
7
|
+
export * from "./getOfferStatus";
|
|
7
8
|
export const validation = {
|
|
8
9
|
createOfferArgsSchema: utils.validation.createOfferArgsSchema
|
|
9
10
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/offers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAE9C,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,KAAK,MAAM,aAAa,CAAC;AACrC,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,cAAc,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/offers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAE9C,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,KAAK,MAAM,aAAa,CAAC;AACrC,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,cAAc,SAAS,CAAC;AACxB,cAAc,kBAAkB,CAAC;AAEjC,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,qBAAqB,EAAE,KAAK,CAAC,UAAU,CAAC,qBAAqB;CAC9D,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.7",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"access": "restricted"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@bosonprotocol/common": "^1.6.0-alpha.
|
|
34
|
+
"@bosonprotocol/common": "^1.6.0-alpha.7",
|
|
35
35
|
"@ethersproject/abi": "^5.5.0",
|
|
36
36
|
"@ethersproject/address": "^5.5.0",
|
|
37
37
|
"@ethersproject/bignumber": "^5.5.0",
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"ts-jest": "^27.1.3",
|
|
50
50
|
"typescript": "^4.5.5"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "84f844e8c6e25839004fb4cece3df6f47bb2aca9"
|
|
53
53
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { subgraph } from "..";
|
|
2
|
+
|
|
3
|
+
export enum OfferState {
|
|
4
|
+
VOIDED = "VOIDED",
|
|
5
|
+
NOT_YET_VALID = "NOT YET VALID",
|
|
6
|
+
EXPIRED = "EXPIRED",
|
|
7
|
+
VALID = "VALID"
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function getOfferStatus(offer: subgraph.OfferFieldsFragment) {
|
|
11
|
+
const toTimeStamp = (numberString: string) => Number(numberString) * 1000;
|
|
12
|
+
const timeNow = Date.now();
|
|
13
|
+
|
|
14
|
+
if (offer.voidedAt) {
|
|
15
|
+
return OfferState.VOIDED;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (toTimeStamp(offer.validFromDate) > timeNow) {
|
|
19
|
+
return OfferState.NOT_YET_VALID;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (toTimeStamp(offer.validUntilDate) < timeNow) {
|
|
23
|
+
return OfferState.EXPIRED;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return OfferState.VALID;
|
|
27
|
+
}
|
package/src/offers/index.ts
CHANGED
|
@@ -5,6 +5,7 @@ export * as subgraph from "./subgraph";
|
|
|
5
5
|
export * as iface from "./interface";
|
|
6
6
|
export * as storage from "./storage";
|
|
7
7
|
export * from "./types";
|
|
8
|
+
export * from "./getOfferStatus";
|
|
8
9
|
|
|
9
10
|
export const validation = {
|
|
10
11
|
createOfferArgsSchema: utils.validation.createOfferArgsSchema
|