@did-pay/util 1.12.11 → 1.12.12
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/lib/nft.js +15 -1
- package/package.json +2 -2
package/lib/nft.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const last = require('lodash/last');
|
|
2
2
|
const get = require('lodash/get');
|
|
3
|
+
const moment = require('moment');
|
|
3
4
|
|
|
4
5
|
const getNftExpirationDate = (asset) => last(get(asset, 'data.value.expirationDate', []));
|
|
5
6
|
|
|
@@ -10,4 +11,17 @@ const isNFTExpired = (asset) => {
|
|
|
10
11
|
|
|
11
12
|
const isDateExpired = (expirationDate) => !!expirationDate && new Date(expirationDate).getTime() <= Date.now();
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
const canRenewExpiredNFT = (expirationDate, retainDays) => {
|
|
15
|
+
const isExpired = isDateExpired(expirationDate);
|
|
16
|
+
if (!isExpired) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (!retainDays || retainDays <= 0) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return moment(expirationDate).add(retainDays, 'days').isAfter(moment());
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
module.exports = { isNFTExpired, getNftExpirationDate, isDateExpired, canRenewExpiredNFT };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@did-pay/util",
|
|
3
|
-
"version": "1.12.
|
|
3
|
+
"version": "1.12.12",
|
|
4
4
|
"description": "Common library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"util"
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"lodash": "^4.17.21",
|
|
37
37
|
"moment": "^2.29.4"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "7eec49a48762720b425c72369f112822347835bc"
|
|
40
40
|
}
|