@bosonprotocol/core-sdk 1.7.0 → 1.7.1-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/getExchangeState.d.ts +9 -0
- package/dist/cjs/exchanges/getExchangeState.d.ts.map +1 -0
- package/dist/cjs/exchanges/getExchangeState.js +20 -0
- package/dist/cjs/exchanges/getExchangeState.js.map +1 -0
- package/dist/cjs/exchanges/index.d.ts +1 -0
- package/dist/cjs/exchanges/index.d.ts.map +1 -1
- package/dist/cjs/exchanges/index.js +4 -0
- package/dist/cjs/exchanges/index.js.map +1 -1
- package/dist/esm/exchanges/getExchangeState.d.ts +9 -0
- package/dist/esm/exchanges/getExchangeState.d.ts.map +1 -0
- package/dist/esm/exchanges/getExchangeState.js +16 -0
- package/dist/esm/exchanges/getExchangeState.js.map +1 -0
- package/dist/esm/exchanges/index.d.ts +1 -0
- package/dist/esm/exchanges/index.d.ts.map +1 -1
- package/dist/esm/exchanges/index.js +1 -0
- package/dist/esm/exchanges/index.js.map +1 -1
- package/package.json +2 -2
- package/src/exchanges/getExchangeState.ts +25 -0
- package/src/exchanges/index.ts +1 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { subgraph } from "..";
|
|
2
|
+
import { ExchangeState } from "../subgraph";
|
|
3
|
+
export declare enum ExtendedExchangeState {
|
|
4
|
+
NotRedeemableYet = "NOT REDEEMABLE YET",
|
|
5
|
+
Expired = "EXPIRED"
|
|
6
|
+
}
|
|
7
|
+
export declare type AllExchangeStates = ExtendedExchangeState | ExchangeState;
|
|
8
|
+
export declare function getExchangeState(exchange: subgraph.ExchangeFieldsFragment): AllExchangeStates;
|
|
9
|
+
//# sourceMappingURL=getExchangeState.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getExchangeState.d.ts","sourceRoot":"","sources":["../../../src/exchanges/getExchangeState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,oBAAY,qBAAqB;IAC/B,gBAAgB,uBAAuB;IACvC,OAAO,YAAY;CACpB;AAED,oBAAY,iBAAiB,GAAG,qBAAqB,GAAG,aAAa,CAAC;AAEtE,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,QAAQ,CAAC,sBAAsB,GACxC,iBAAiB,CAYnB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getExchangeState = exports.ExtendedExchangeState = void 0;
|
|
4
|
+
var ExtendedExchangeState;
|
|
5
|
+
(function (ExtendedExchangeState) {
|
|
6
|
+
ExtendedExchangeState["NotRedeemableYet"] = "NOT REDEEMABLE YET";
|
|
7
|
+
ExtendedExchangeState["Expired"] = "EXPIRED";
|
|
8
|
+
})(ExtendedExchangeState = exports.ExtendedExchangeState || (exports.ExtendedExchangeState = {}));
|
|
9
|
+
function getExchangeState(exchange) {
|
|
10
|
+
const { offer } = exchange;
|
|
11
|
+
if (Number(offer.voucherRedeemableFromDate) * 1000 > Date.now()) {
|
|
12
|
+
return ExtendedExchangeState.NotRedeemableYet;
|
|
13
|
+
}
|
|
14
|
+
if (Number(exchange.validUntilDate) * 1000 < Date.now()) {
|
|
15
|
+
return ExtendedExchangeState.Expired;
|
|
16
|
+
}
|
|
17
|
+
return exchange.state;
|
|
18
|
+
}
|
|
19
|
+
exports.getExchangeState = getExchangeState;
|
|
20
|
+
//# sourceMappingURL=getExchangeState.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getExchangeState.js","sourceRoot":"","sources":["../../../src/exchanges/getExchangeState.ts"],"names":[],"mappings":";;;AAGA,IAAY,qBAGX;AAHD,WAAY,qBAAqB;IAC/B,gEAAuC,CAAA;IACvC,4CAAmB,CAAA;AACrB,CAAC,EAHW,qBAAqB,GAArB,6BAAqB,KAArB,6BAAqB,QAGhC;AAID,SAAgB,gBAAgB,CAC9B,QAAyC;IAEzC,MAAM,EAAE,KAAK,EAAE,GAAG,QAAQ,CAAC;IAE3B,IAAI,MAAM,CAAC,KAAK,CAAC,yBAAyB,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE,EAAE;QAC/D,OAAO,qBAAqB,CAAC,gBAAgB,CAAC;KAC/C;IAED,IAAI,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE,EAAE;QACvD,OAAO,qBAAqB,CAAC,OAAO,CAAC;KACtC;IAED,OAAO,QAAQ,CAAC,KAAK,CAAC;AACxB,CAAC;AAdD,4CAcC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/exchanges/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,KAAK,MAAM,aAAa,CAAC;AACrC,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/exchanges/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,KAAK,MAAM,aAAa,CAAC;AACrC,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC"}
|
|
@@ -15,6 +15,9 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
19
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
20
|
+
};
|
|
18
21
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
22
|
if (mod && mod.__esModule) return mod;
|
|
20
23
|
var result = {};
|
|
@@ -24,6 +27,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
27
|
};
|
|
25
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
29
|
exports.subgraph = exports.iface = exports.handler = void 0;
|
|
30
|
+
__exportStar(require("./getExchangeState"), exports);
|
|
27
31
|
exports.handler = __importStar(require("./handler"));
|
|
28
32
|
exports.iface = __importStar(require("./interface"));
|
|
29
33
|
exports.subgraph = __importStar(require("./subgraph"));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/exchanges/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/exchanges/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAmC;AACnC,qDAAqC;AACrC,qDAAqC;AACrC,uDAAuC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { subgraph } from "..";
|
|
2
|
+
import { ExchangeState } from "../subgraph";
|
|
3
|
+
export declare enum ExtendedExchangeState {
|
|
4
|
+
NotRedeemableYet = "NOT REDEEMABLE YET",
|
|
5
|
+
Expired = "EXPIRED"
|
|
6
|
+
}
|
|
7
|
+
export declare type AllExchangeStates = ExtendedExchangeState | ExchangeState;
|
|
8
|
+
export declare function getExchangeState(exchange: subgraph.ExchangeFieldsFragment): AllExchangeStates;
|
|
9
|
+
//# sourceMappingURL=getExchangeState.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getExchangeState.d.ts","sourceRoot":"","sources":["../../../src/exchanges/getExchangeState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,oBAAY,qBAAqB;IAC/B,gBAAgB,uBAAuB;IACvC,OAAO,YAAY;CACpB;AAED,oBAAY,iBAAiB,GAAG,qBAAqB,GAAG,aAAa,CAAC;AAEtE,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,QAAQ,CAAC,sBAAsB,GACxC,iBAAiB,CAYnB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export var ExtendedExchangeState;
|
|
2
|
+
(function (ExtendedExchangeState) {
|
|
3
|
+
ExtendedExchangeState["NotRedeemableYet"] = "NOT REDEEMABLE YET";
|
|
4
|
+
ExtendedExchangeState["Expired"] = "EXPIRED";
|
|
5
|
+
})(ExtendedExchangeState || (ExtendedExchangeState = {}));
|
|
6
|
+
export function getExchangeState(exchange) {
|
|
7
|
+
const { offer } = exchange;
|
|
8
|
+
if (Number(offer.voucherRedeemableFromDate) * 1000 > Date.now()) {
|
|
9
|
+
return ExtendedExchangeState.NotRedeemableYet;
|
|
10
|
+
}
|
|
11
|
+
if (Number(exchange.validUntilDate) * 1000 < Date.now()) {
|
|
12
|
+
return ExtendedExchangeState.Expired;
|
|
13
|
+
}
|
|
14
|
+
return exchange.state;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=getExchangeState.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getExchangeState.js","sourceRoot":"","sources":["../../../src/exchanges/getExchangeState.ts"],"names":[],"mappings":"AAGA,MAAM,CAAN,IAAY,qBAGX;AAHD,WAAY,qBAAqB;IAC/B,gEAAuC,CAAA;IACvC,4CAAmB,CAAA;AACrB,CAAC,EAHW,qBAAqB,KAArB,qBAAqB,QAGhC;AAID,MAAM,UAAU,gBAAgB,CAC9B,QAAyC;IAEzC,MAAM,EAAE,KAAK,EAAE,GAAG,QAAQ,CAAC;IAE3B,IAAI,MAAM,CAAC,KAAK,CAAC,yBAAyB,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE,EAAE;QAC/D,OAAO,qBAAqB,CAAC,gBAAgB,CAAC;KAC/C;IAED,IAAI,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE,EAAE;QACvD,OAAO,qBAAqB,CAAC,OAAO,CAAC;KACtC;IAED,OAAO,QAAQ,CAAC,KAAK,CAAC;AACxB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/exchanges/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,KAAK,MAAM,aAAa,CAAC;AACrC,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/exchanges/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,KAAK,MAAM,aAAa,CAAC;AACrC,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/exchanges/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,KAAK,MAAM,aAAa,CAAC;AACrC,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/exchanges/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,KAAK,MAAM,aAAa,CAAC;AACrC,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bosonprotocol/core-sdk",
|
|
3
|
-
"version": "1.7.0",
|
|
3
|
+
"version": "1.7.1-alpha.0",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"ts-jest": "^27.1.3",
|
|
50
50
|
"typescript": "^4.5.5"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "aa86cce10a97e2c9e00ef633dfdbfd791441b0f3"
|
|
53
53
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { subgraph } from "..";
|
|
2
|
+
import { ExchangeState } from "../subgraph";
|
|
3
|
+
|
|
4
|
+
export enum ExtendedExchangeState {
|
|
5
|
+
NotRedeemableYet = "NOT REDEEMABLE YET",
|
|
6
|
+
Expired = "EXPIRED"
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export type AllExchangeStates = ExtendedExchangeState | ExchangeState;
|
|
10
|
+
|
|
11
|
+
export function getExchangeState(
|
|
12
|
+
exchange: subgraph.ExchangeFieldsFragment
|
|
13
|
+
): AllExchangeStates {
|
|
14
|
+
const { offer } = exchange;
|
|
15
|
+
|
|
16
|
+
if (Number(offer.voucherRedeemableFromDate) * 1000 > Date.now()) {
|
|
17
|
+
return ExtendedExchangeState.NotRedeemableYet;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (Number(exchange.validUntilDate) * 1000 < Date.now()) {
|
|
21
|
+
return ExtendedExchangeState.Expired;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return exchange.state;
|
|
25
|
+
}
|
package/src/exchanges/index.ts
CHANGED