@ensdomains/ensjs 3.0.0-alpha.56 → 3.0.0-alpha.57
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/functions/getWrapperData.js +10 -2
- package/dist/cjs/utils/consts.js +2 -0
- package/dist/esm/functions/getWrapperData.mjs +10 -2
- package/dist/esm/utils/consts.mjs +2 -0
- package/dist/types/utils/consts.d.ts +1 -0
- package/package.json +1 -1
- package/src/functions/getWrapperData.test.ts +18 -0
- package/src/functions/getWrapperData.ts +11 -4
- package/src/utils/consts.ts +1 -0
|
@@ -21,7 +21,7 @@ __export(getWrapperData_exports, {
|
|
|
21
21
|
default: () => getWrapperData_default
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(getWrapperData_exports);
|
|
24
|
-
var
|
|
24
|
+
var import_consts = require("../utils/consts");
|
|
25
25
|
var import_fuses = require("../utils/fuses");
|
|
26
26
|
var import_normalise = require("../utils/normalise");
|
|
27
27
|
const raw = async ({ contracts }, name) => {
|
|
@@ -39,7 +39,15 @@ const decode = async ({ contracts }, data) => {
|
|
|
39
39
|
data
|
|
40
40
|
);
|
|
41
41
|
const fuseObj = (0, import_fuses.decodeFuses)(fuses);
|
|
42
|
-
|
|
42
|
+
let expiryDate;
|
|
43
|
+
if (expiry.gt(0)) {
|
|
44
|
+
const msBigNumber = expiry.mul(1e3);
|
|
45
|
+
if (msBigNumber.gte(import_consts.MAX_DATE_INT)) {
|
|
46
|
+
expiryDate = new Date(import_consts.MAX_DATE_INT);
|
|
47
|
+
} else {
|
|
48
|
+
expiryDate = new Date(msBigNumber.toNumber());
|
|
49
|
+
}
|
|
50
|
+
}
|
|
43
51
|
return {
|
|
44
52
|
...fuseObj,
|
|
45
53
|
expiryDate,
|
package/dist/cjs/utils/consts.js
CHANGED
|
@@ -19,10 +19,12 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
var consts_exports = {};
|
|
20
20
|
__export(consts_exports, {
|
|
21
21
|
EMPTY_ADDRESS: () => EMPTY_ADDRESS,
|
|
22
|
+
MAX_DATE_INT: () => MAX_DATE_INT,
|
|
22
23
|
MAX_INT_64: () => MAX_INT_64,
|
|
23
24
|
MINIMUM_DOT_ETH_CHARS: () => MINIMUM_DOT_ETH_CHARS
|
|
24
25
|
});
|
|
25
26
|
module.exports = __toCommonJS(consts_exports);
|
|
26
27
|
const EMPTY_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
27
28
|
const MAX_INT_64 = BigInt("18446744073709551615");
|
|
29
|
+
const MAX_DATE_INT = 864e13;
|
|
28
30
|
const MINIMUM_DOT_ETH_CHARS = 3;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/functions/getWrapperData.ts
|
|
2
|
-
import {
|
|
2
|
+
import { MAX_DATE_INT } from "../utils/consts.mjs";
|
|
3
3
|
import { decodeFuses } from "../utils/fuses.mjs";
|
|
4
4
|
import { namehash } from "../utils/normalise.mjs";
|
|
5
5
|
var raw = async ({ contracts }, name) => {
|
|
@@ -17,7 +17,15 @@ var decode = async ({ contracts }, data) => {
|
|
|
17
17
|
data
|
|
18
18
|
);
|
|
19
19
|
const fuseObj = decodeFuses(fuses);
|
|
20
|
-
|
|
20
|
+
let expiryDate;
|
|
21
|
+
if (expiry.gt(0)) {
|
|
22
|
+
const msBigNumber = expiry.mul(1e3);
|
|
23
|
+
if (msBigNumber.gte(MAX_DATE_INT)) {
|
|
24
|
+
expiryDate = new Date(MAX_DATE_INT);
|
|
25
|
+
} else {
|
|
26
|
+
expiryDate = new Date(msBigNumber.toNumber());
|
|
27
|
+
}
|
|
28
|
+
}
|
|
21
29
|
return {
|
|
22
30
|
...fuseObj,
|
|
23
31
|
expiryDate,
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
// src/utils/consts.ts
|
|
2
2
|
var EMPTY_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
3
3
|
var MAX_INT_64 = BigInt("18446744073709551615");
|
|
4
|
+
var MAX_DATE_INT = 864e13;
|
|
4
5
|
var MINIMUM_DOT_ETH_CHARS = 3;
|
|
5
6
|
export {
|
|
6
7
|
EMPTY_ADDRESS,
|
|
8
|
+
MAX_DATE_INT,
|
|
7
9
|
MAX_INT_64,
|
|
8
10
|
MINIMUM_DOT_ETH_CHARS
|
|
9
11
|
};
|
package/package.json
CHANGED
|
@@ -69,4 +69,22 @@ describe('getWrapperData', () => {
|
|
|
69
69
|
expect(Number.isNaN(result.expiryDate?.getTime())).toBe(false)
|
|
70
70
|
}
|
|
71
71
|
})
|
|
72
|
+
it('should return correct expiry for large expiry', async () => {
|
|
73
|
+
const result = await ensInstance.getWrapperData('wrapped-big-duration.eth')
|
|
74
|
+
expect(result).toBeTruthy()
|
|
75
|
+
if (result) {
|
|
76
|
+
expect(result.expiryDate).toBeInstanceOf(Date)
|
|
77
|
+
expect(result.expiryDate!.getFullYear()).toBe(275760)
|
|
78
|
+
expect(Number.isNaN(result.expiryDate?.getTime())).toBe(false)
|
|
79
|
+
}
|
|
80
|
+
})
|
|
81
|
+
it('should return correct max expiry for expiry larger than maximum for date', async () => {
|
|
82
|
+
const result = await ensInstance.getWrapperData('wrapped-max-duration.eth')
|
|
83
|
+
expect(result).toBeTruthy()
|
|
84
|
+
if (result) {
|
|
85
|
+
expect(result.expiryDate).toBeInstanceOf(Date)
|
|
86
|
+
expect(result.expiryDate!.getFullYear()).toBe(275760)
|
|
87
|
+
expect(Number.isNaN(result.expiryDate?.getTime())).toBe(false)
|
|
88
|
+
}
|
|
89
|
+
})
|
|
72
90
|
})
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BigNumber } from '@ethersproject/bignumber'
|
|
2
2
|
import { ENSArgs } from '../index'
|
|
3
|
+
import { MAX_DATE_INT } from '../utils/consts'
|
|
3
4
|
import { decodeFuses } from '../utils/fuses'
|
|
4
5
|
import { namehash } from '../utils/normalise'
|
|
5
6
|
|
|
@@ -21,10 +22,16 @@ const decode = async ({ contracts }: ENSArgs<'contracts'>, data: string) => {
|
|
|
21
22
|
|
|
22
23
|
const fuseObj = decodeFuses(fuses)
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
let expiryDate: Date | undefined
|
|
26
|
+
|
|
27
|
+
if (expiry.gt(0)) {
|
|
28
|
+
const msBigNumber = expiry.mul(1000)
|
|
29
|
+
if (msBigNumber.gte(MAX_DATE_INT)) {
|
|
30
|
+
expiryDate = new Date(MAX_DATE_INT)
|
|
31
|
+
} else {
|
|
32
|
+
expiryDate = new Date(msBigNumber.toNumber())
|
|
33
|
+
}
|
|
34
|
+
}
|
|
28
35
|
|
|
29
36
|
return {
|
|
30
37
|
...fuseObj,
|
package/src/utils/consts.ts
CHANGED