Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
LeonmanRolls committed Jul 13, 2023
1 parent 2dee3b6 commit 07164d7
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
6 changes: 4 additions & 2 deletions packages/ensjs/src/utils/encoders/encodeAbi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ describe('encodeAbi', () => {
const data = { foo: 'bar' }
const result = await encodeAbi({ encodeAs: 'zlib', data })
expect(result.contentType).toEqual(2)
expect(result.encodedData).toEqual('0x789cab564acbcf57b2524a4a2c52aa05001d7a0434')
expect(result.encodedData).toEqual(
'0x789cab564acbcf57b2524a4a2c52aa05001d7a0434',
)
})

it('encodes data as cbor', async () => {
Expand All @@ -28,4 +30,4 @@ describe('encodeAbi', () => {
expect(result.contentType).toEqual(8)
expect(result.encodedData).toEqual('0x666f6f3d626172')
})
})
})
14 changes: 8 additions & 6 deletions packages/ensjs/src/utils/encoders/encodeSetAbi.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { encodeSetAbi, EncodeSetAbiParameters } from './encodeSetAbi'

describe('encodeSetAbi', () => {
const namehash = '0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef'
const namehash =
'0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef'
const contentType = 0
const encodedData = null

Expand All @@ -12,20 +13,21 @@ describe('encodeSetAbi', () => {
}

it('encodes the setABI function data correctly', () => {
const expected = '0x623195b01234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000'
const expected =
'0x623195b01234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000'
const result = encodeSetAbi(parameters)
expect(result).toEqual(expected)
})

it('encodes the setABI function data correctly with encodedData', () => {
const encodedData = '0xabcdef123456'
const parametersWithEncodedData: EncodeSetAbiParameters = {
namehash,
contentType,
encodedData,
encodedData: '0xabcdef123456',
}
const expected = '0x623195b01234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000006abcdef1234560000000000000000000000000000000000000000000000000000'
const expected =
'0x623195b01234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000006abcdef1234560000000000000000000000000000000000000000000000000000'
const result = encodeSetAbi(parametersWithEncodedData)
expect(result).toEqual(expected)
})
})
})
5 changes: 3 additions & 2 deletions packages/ensjs/src/utils/encoders/encodeSetAddr.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { encodeSetAddr, EncodeSetAddrParameters } from './encodeSetAddr'

const namehash = '0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef'
const namehash =
'0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef'

describe('encodeSetAddr', () => {
const testCases: Array<[string, EncodeSetAddrParameters, string]> = [
Expand Down Expand Up @@ -56,4 +57,4 @@ describe('encodeSetAddr', () => {
expect(encodeSetAddr(parameters)).toEqual(expectedOutput)
})
})
})
})
3 changes: 2 additions & 1 deletion packages/ensjs/src/utils/encoders/encodeSetText.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ describe('encodeSetText', () => {
}

it('encodes the function data correctly', () => {
const expected = '0x10f13a8c1234567890123456789012345678901234567890123456789012345678901234000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000005656d61696c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001074657374406578616d706c652e636f6d00000000000000000000000000000000'
const expected =
'0x10f13a8c1234567890123456789012345678901234567890123456789012345678901234000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000005656d61696c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001074657374406578616d706c652e636f6d00000000000000000000000000000000'
const result = encodeSetText(parameters)
expect(result).toEqual(expected)
})
Expand Down

0 comments on commit 07164d7

Please sign in to comment.