Skip to content

Commit

Permalink
Merge pull request #122 from ensdomains/feat-add-cannot-approve
Browse files Browse the repository at this point in the history
update fuses for CANNOT_APPROVE
  • Loading branch information
LeonmanRolls authored Mar 21, 2023
2 parents 4504264 + 825d3b0 commit b4ea3e4
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 7 deletions.
8 changes: 7 additions & 1 deletion packages/ensjs/src/functions/getWrapperData.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ describe('getWrapperData', () => {
})
it('should return with other correct fuses', async () => {
const tx = await ensInstance.setFuses('wrapped.eth', {
named: ['CANNOT_UNWRAP', 'CANNOT_CREATE_SUBDOMAIN', 'CANNOT_SET_TTL'],
named: [
'CANNOT_UNWRAP',
'CANNOT_CREATE_SUBDOMAIN',
'CANNOT_SET_TTL',
'CANNOT_APPROVE',
],
addressOrIndex: 1,
})
await tx.wait()
Expand All @@ -52,6 +57,7 @@ describe('getWrapperData', () => {
expect(result.child.CANNOT_UNWRAP).toBe(true)
expect(result.child.CANNOT_CREATE_SUBDOMAIN).toBe(true)
expect(result.child.CANNOT_SET_TTL).toBe(true)
expect(result.child.CANNOT_APPROVE).toBe(true)
expect(result.parent.IS_DOT_ETH).toBe(true)
}
})
Expand Down
27 changes: 22 additions & 5 deletions packages/ensjs/src/functions/setFuses.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,12 @@ describe('setFuses', () => {
describe('Array', () => {
it('should return a setFuses transaction from a named fuse array and succeed', async () => {
const tx = await ensInstance.setFuses('wrapped.eth', {
named: ['CANNOT_UNWRAP', 'CANNOT_CREATE_SUBDOMAIN', 'CANNOT_SET_TTL'],
named: [
'CANNOT_UNWRAP',
'CANNOT_CREATE_SUBDOMAIN',
'CANNOT_SET_TTL',
'CANNOT_APPROVE',
],
addressOrIndex: accounts[1],
})
expect(tx).toBeTruthy()
Expand All @@ -87,6 +92,7 @@ describe('setFuses', () => {
'CANNOT_CREATE_SUBDOMAIN',
'CANNOT_SET_TTL',
'PARENT_CANNOT_CONTROL',
'CANNOT_APPROVE',
])
})
it('should return a setFuses transaction from an unnamed fuse array and succeed', async () => {
Expand All @@ -110,7 +116,12 @@ describe('setFuses', () => {
})
it('should return a setFuses transaction from both an unnamed and named fuse array and succeed', async () => {
const tx = await ensInstance.setFuses('wrapped.eth', {
named: ['CANNOT_UNWRAP', 'CANNOT_CREATE_SUBDOMAIN', 'CANNOT_SET_TTL'],
named: [
'CANNOT_UNWRAP',
'CANNOT_CREATE_SUBDOMAIN',
'CANNOT_SET_TTL',
'CANNOT_APPROVE',
],
unnamed: [128, 256, 512],
addressOrIndex: accounts[1],
})
Expand All @@ -124,6 +135,7 @@ describe('setFuses', () => {
'CANNOT_CREATE_SUBDOMAIN',
'CANNOT_SET_TTL',
'PARENT_CANNOT_CONTROL',
'CANNOT_APPROVE',
])
checkUnnamedFuses(fuses, [128, 256, 512])
})
Expand Down Expand Up @@ -154,7 +166,7 @@ describe('setFuses', () => {
describe('Number', () => {
it('should return a setFuses transaction from a number and succeed', async () => {
const tx = await ensInstance.setFuses('wrapped.eth', {
number: 49,
number: 113,
addressOrIndex: accounts[1],
})
expect(tx).toBeTruthy()
Expand All @@ -166,6 +178,7 @@ describe('setFuses', () => {
'CANNOT_UNWRAP',
'CANNOT_CREATE_SUBDOMAIN',
'CANNOT_SET_TTL',
'CANNOT_APPROVE',
'PARENT_CANNOT_CONTROL',
])
})
Expand Down Expand Up @@ -224,7 +237,7 @@ describe('setChildFuses', () => {
const tx = await ensInstance.setChildFuses(
'test.wrapped-with-subnames.eth',
{
fuses: 65537,
fuses: 65537 + 64,
addressOrIndex: accounts[1],
},
)
Expand All @@ -235,6 +248,10 @@ describe('setChildFuses', () => {
namehash('test.wrapped-with-subnames.eth'),
)

checkFuses(fuses, ['CANNOT_UNWRAP', 'PARENT_CANNOT_CONTROL'])
checkFuses(fuses, [
'CANNOT_UNWRAP',
'PARENT_CANNOT_CONTROL',
'CANNOT_APPROVE',
])
})
})
4 changes: 3 additions & 1 deletion packages/ensjs/src/utils/fuses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const CANNOT_TRANSFER = 4
const CANNOT_SET_RESOLVER = 8
const CANNOT_SET_TTL = 16
const CANNOT_CREATE_SUBDOMAIN = 32
const CANNOT_APPROVE = 64

// parent named fuses
const PARENT_CANNOT_CONTROL = 0x10000
Expand All @@ -26,6 +27,7 @@ export const childFuseEnum = {
CANNOT_SET_RESOLVER,
CANNOT_SET_TTL,
CANNOT_CREATE_SUBDOMAIN,
CANNOT_APPROVE,
} as const

export const parentFuseEnum = {
Expand All @@ -50,7 +52,7 @@ export const fullFuseEnum = {
}

export const unnamedChildFuses = [
64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768,
128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768,
] as const

export const unnamedParentFuses = [
Expand Down

0 comments on commit b4ea3e4

Please sign in to comment.