@ensdomains/ensjs 3.0.0-alpha.58 → 3.0.0-alpha.59

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.
@@ -86,6 +86,8 @@ function generateSingleRecordCall(namehash, resolver, type) {
86
86
  if (encoded.error)
87
87
  throw new Error(encoded.error);
88
88
  _contentHash = encoded.encoded;
89
+ } else {
90
+ _contentHash = "0x";
89
91
  }
90
92
  return resolver.interface.encodeFunctionData("setContenthash", [
91
93
  namehash,
@@ -130,7 +132,7 @@ const generateRecordCallArray = (namehash, records, resolver) => {
130
132
  resolver.interface.encodeFunctionData("clearRecords", [namehash])
131
133
  );
132
134
  }
133
- if (records.contentHash) {
135
+ if (typeof records.contentHash === "string") {
134
136
  const data = generateSingleRecordCall(
135
137
  namehash,
136
138
  resolver,
@@ -55,6 +55,8 @@ function generateSingleRecordCall(namehash, resolver, type) {
55
55
  if (encoded.error)
56
56
  throw new Error(encoded.error);
57
57
  _contentHash = encoded.encoded;
58
+ } else {
59
+ _contentHash = "0x";
58
60
  }
59
61
  return resolver.interface.encodeFunctionData("setContenthash", [
60
62
  namehash,
@@ -99,7 +101,7 @@ var generateRecordCallArray = (namehash, records, resolver) => {
99
101
  resolver.interface.encodeFunctionData("clearRecords", [namehash])
100
102
  );
101
103
  }
102
- if (records.contentHash) {
104
+ if (typeof records.contentHash === "string") {
103
105
  const data = generateSingleRecordCall(
104
106
  namehash,
105
107
  resolver,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ensdomains/ensjs",
3
- "version": "3.0.0-alpha.58",
3
+ "version": "3.0.0-alpha.59",
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 { PublicResolver__factory } from '../generated'
2
2
  import { namehash } from './normalise'
3
- import { generateSetAddr } from './recordHelpers'
3
+ import { generateRecordCallArray, generateSetAddr } from './recordHelpers'
4
4
 
5
5
  describe('generateSetAddr()', () => {
6
6
  it('should allow empty string as address', () => {
@@ -17,3 +17,20 @@ describe('generateSetAddr()', () => {
17
17
  ).not.toThrowError()
18
18
  })
19
19
  })
20
+
21
+ describe('generateRecordCallArray()', () => {
22
+ it('should allow empty string as contenthash', () => {
23
+ expect(
24
+ generateRecordCallArray(
25
+ namehash('test'),
26
+ { contentHash: '' },
27
+ PublicResolver__factory.connect(
28
+ '0x0000000000000000000000000000000000000000',
29
+ undefined as any,
30
+ ),
31
+ ),
32
+ ).toEqual([
33
+ '0x304e6ade04f740db81dc36c853ab4205bddd785f46e79ccedca351fc6dfcbd8cc9a33dd600000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000',
34
+ ])
35
+ })
36
+ })
@@ -99,6 +99,8 @@ export function generateSingleRecordCall<T extends RecordTypes>(
99
99
  const encoded = encodeContenthash(record)
100
100
  if (encoded.error) throw new Error(encoded.error)
101
101
  _contentHash = encoded.encoded as string
102
+ } else {
103
+ _contentHash = '0x'
102
104
  }
103
105
  return resolver.interface.encodeFunctionData('setContenthash', [
104
106
  namehash,
@@ -150,7 +152,7 @@ export const generateRecordCallArray = (
150
152
  )
151
153
  }
152
154
 
153
- if (records.contentHash) {
155
+ if (typeof records.contentHash === 'string') {
154
156
  const data = generateSingleRecordCall(
155
157
  namehash,
156
158
  resolver,