@ensdomains/ensjs 3.0.0-alpha.30 → 3.0.0-alpha.31

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/README.md CHANGED
@@ -253,6 +253,11 @@ It allows `withProvider` to act as a new ENS instance without having to await a
253
253
 
254
254
  ## Individual Functions
255
255
 
256
+ ### Utils
257
+
258
+ Utils can be imported at follows
259
+ `import { encodeContenthash } from '@ensdomains/ensjs/utils/contentHash'`
260
+
256
261
  ### getFuses
257
262
 
258
263
  Gets the fuses for a specified wrapped name.
@@ -36,6 +36,12 @@ const mapDomain = (domain) => {
36
36
  };
37
37
  const mapWrappedDomain = (wrappedDomain) => {
38
38
  const domain = mapDomain(wrappedDomain.domain);
39
+ if (domain.registration) {
40
+ domain.registration = {
41
+ expiryDate: new Date(parseInt(domain.registration.expiryDate) * 1e3),
42
+ registrationDate: new Date(domain.registration.registrationDate * 1e3)
43
+ };
44
+ }
39
45
  return {
40
46
  expiryDate: new Date(parseInt(wrappedDomain.expiryDate) * 1e3),
41
47
  fuses: (0, import_fuses.decodeFuses)(wrappedDomain.fuses),
@@ -14,6 +14,12 @@ var mapDomain = (domain) => {
14
14
  };
15
15
  var mapWrappedDomain = (wrappedDomain) => {
16
16
  const domain = mapDomain(wrappedDomain.domain);
17
+ if (domain.registration) {
18
+ domain.registration = {
19
+ expiryDate: new Date(parseInt(domain.registration.expiryDate) * 1e3),
20
+ registrationDate: new Date(domain.registration.registrationDate * 1e3)
21
+ };
22
+ }
17
23
  return {
18
24
  expiryDate: new Date(parseInt(wrappedDomain.expiryDate) * 1e3),
19
25
  fuses: decodeFuses(wrappedDomain.fuses),
@@ -1,6 +1,6 @@
1
1
  import { ethers } from 'ethers';
2
2
  import { ENSArgs } from '..';
3
- import { FuseOptions } from '../@types/FuseOptions';
3
+ import { FuseOptions } from '../utils/fuses';
4
4
  import { Expiry } from '../utils/wrapper';
5
5
  declare type BaseArgs = {
6
6
  owner: string;
@@ -14,6 +14,10 @@ export declare type Name = {
14
14
  registrationDate?: Date;
15
15
  expiryDate?: Date;
16
16
  fuses?: CurrentFuses;
17
+ registration?: {
18
+ expiryDate: Date;
19
+ registrationDate: Date;
20
+ };
17
21
  type: 'domain' | 'registration' | 'wrappedDomain';
18
22
  };
19
23
  declare type BaseParams = {
@@ -1,6 +1,6 @@
1
1
  import { ethers } from 'ethers';
2
2
  import { ENSArgs } from '..';
3
- import type { FuseOptions } from '../@types/FuseOptions';
3
+ import { FuseOptions } from '../utils/fuses';
4
4
  import { Expiry } from '../utils/wrapper';
5
5
  export default function ({ contracts, signer, getExpiry, }: ENSArgs<'contracts' | 'signer' | 'getExpiry'>, name: string, { wrappedOwner, fuseOptions, expiry, resolverAddress, }: {
6
6
  wrappedOwner: string;
@@ -8,6 +8,9 @@ export declare const fuseEnum: {
8
8
  readonly CANNOT_CREATE_SUBDOMAIN: 32;
9
9
  readonly PARENT_CANNOT_CONTROL: 64;
10
10
  };
11
+ export declare type FuseOptions = {
12
+ -readonly [K in keyof typeof fuseEnum]?: boolean;
13
+ };
11
14
  export declare const unnamedFuses: readonly [128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912, 1073741824, 2147483648, 4294967296];
12
15
  declare const fullFuseEnum: {
13
16
  CAN_DO_EVERYTHING: number;
@@ -1,3 +1,3 @@
1
- import { FuseOptions } from '../@types/FuseOptions';
1
+ import { FuseOptions } from './fuses';
2
2
  declare const _default: (fuseOptions: FuseOptions) => string;
3
3
  export default _default;
@@ -1,6 +1,6 @@
1
1
  import { BigNumberish } from 'ethers';
2
- import type { FuseOptions } from '../@types/FuseOptions';
3
2
  import type { PublicResolver } from '../generated';
3
+ import { FuseOptions } from './fuses';
4
4
  import { RecordOptions } from './recordHelpers';
5
5
  export declare const MAX_INT_64: bigint;
6
6
  export declare type BaseRegistrationParams = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ensdomains/ensjs",
3
- "version": "3.0.0-alpha.30",
3
+ "version": "3.0.0-alpha.31",
4
4
  "description": "ENS javascript library for contract interaction",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.mjs",
@@ -1,6 +1,6 @@
1
1
  import { BigNumber, ethers } from 'ethers'
2
2
  import { ENSArgs } from '..'
3
- import { FuseOptions } from '../@types/FuseOptions'
3
+ import { FuseOptions } from '../utils/fuses'
4
4
  import generateFuseInput from '../utils/generateFuseInput'
5
5
  import { namehash } from '../utils/normalise'
6
6
  import { Expiry, makeExpiry, wrappedLabelLengthCheck } from '../utils/wrapper'
@@ -17,6 +17,10 @@ export type Name = {
17
17
  registrationDate?: Date
18
18
  expiryDate?: Date
19
19
  fuses?: CurrentFuses
20
+ registration?: {
21
+ expiryDate: Date
22
+ registrationDate: Date
23
+ }
20
24
  type: 'domain' | 'registration' | 'wrappedDomain'
21
25
  }
22
26
 
@@ -66,6 +70,12 @@ const mapDomain = (domain: any) => {
66
70
 
67
71
  const mapWrappedDomain = (wrappedDomain: any) => {
68
72
  const domain = mapDomain(wrappedDomain.domain)
73
+ if (domain.registration) {
74
+ domain.registration = {
75
+ expiryDate: new Date(parseInt(domain.registration.expiryDate) * 1000),
76
+ registrationDate: new Date(domain.registration.registrationDate * 1000),
77
+ }
78
+ }
69
79
  return {
70
80
  expiryDate: new Date(parseInt(wrappedDomain.expiryDate) * 1000),
71
81
  fuses: decodeFuses(wrappedDomain.fuses),
@@ -53,8 +53,8 @@ describe('wrapName', () => {
53
53
  const tx = await ensInstance.wrapName('test123.eth', {
54
54
  wrappedOwner: accounts[2],
55
55
  fuseOptions: {
56
- cannotUnwrap: true,
57
- cannotSetTtl: true,
56
+ CANNOT_UNWRAP: true,
57
+ CANNOT_SET_TTL: true,
58
58
  },
59
59
  addressOrIndex: 1,
60
60
  })
@@ -1,6 +1,6 @@
1
1
  import { BigNumber, ethers } from 'ethers'
2
2
  import { ENSArgs } from '..'
3
- import type { FuseOptions } from '../@types/FuseOptions'
3
+ import { FuseOptions } from '../utils/fuses'
4
4
  import generateFuseInput from '../utils/generateFuseInput'
5
5
  import { hexEncodeName } from '../utils/hexEncodedName'
6
6
  import { Expiry, makeExpiry, wrappedLabelLengthCheck } from '../utils/wrapper'
@@ -19,6 +19,8 @@ export const fuseEnum = {
19
19
  PARENT_CANNOT_CONTROL,
20
20
  } as const
21
21
 
22
+ export type FuseOptions = { -readonly [K in keyof typeof fuseEnum]?: boolean }
23
+
22
24
  export const unnamedFuses = [
23
25
  128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144,
24
26
  524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864,
@@ -1,6 +1,5 @@
1
1
  import { ethers } from 'ethers'
2
- import { FuseOptions } from '../@types/FuseOptions'
3
- import fuses from './fuses'
2
+ import fuses, { FuseOptions } from './fuses'
4
3
 
5
4
  export default (fuseOptions: FuseOptions) => {
6
5
  const fuseKeys = Object.keys(fuseOptions).filter(
@@ -1,6 +1,6 @@
1
1
  import { BigNumberish, utils } from 'ethers'
2
- import type { FuseOptions } from '../@types/FuseOptions'
3
2
  import type { PublicResolver } from '../generated'
3
+ import { FuseOptions } from './fuses'
4
4
  import generateFuseInput from './generateFuseInput'
5
5
  import { labelhash } from './labels'
6
6
  import { namehash } from './normalise'
@@ -1,9 +0,0 @@
1
- export type FuseOptions = {
2
- cannotUnwrap: true
3
- cannotBurnFuses?: boolean
4
- cannotTransfer?: boolean
5
- cannotSetResolver?: boolean
6
- cannotSetTtl?: boolean
7
- cannotCreateSubdomain?: boolean
8
- parentCannotControl?: boolean
9
- }