Skip to content

Commit

Permalink
chore: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Raiden1411 committed Jul 20, 2023
1 parent cb2fb2b commit ac85db5
Showing 1 changed file with 99 additions and 99 deletions.
198 changes: 99 additions & 99 deletions src/human-readable/formatAbiParameter.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,115 +6,115 @@ import type { FormatAbiParameter } from './formatAbiParameter.js'
import { formatAbiParameter } from './formatAbiParameter.js'

test('FormatAbiParameter', () => {
// string
expectTypeOf<
FormatAbiParameter<{
readonly type: 'address'
readonly name: 'from'
}>
>().toEqualTypeOf<'address from'>()
expectTypeOf<
FormatAbiParameter<{
readonly type: 'address'
readonly name: 'from'
readonly indexed: true
}>
>().toEqualTypeOf<'address indexed from'>()
// string
expectTypeOf<
FormatAbiParameter<{
readonly type: 'address'
readonly name: 'from'
}>
>().toEqualTypeOf<'address from'>()
expectTypeOf<
FormatAbiParameter<{
readonly type: 'address'
readonly name: 'from'
readonly indexed: true
}>
>().toEqualTypeOf<'address indexed from'>()

expectTypeOf<
FormatAbiParameter<{
type: 'address'
name: 'address'
}>
>().toEqualTypeOf<'address Error: "address" is a protected Solidity keyword.'>()
expectTypeOf<
FormatAbiParameter<{
type: 'address'
name: 'address'
}>
>().toEqualTypeOf<'address Error: "address" is a protected Solidity keyword.'>()

expectTypeOf<
FormatAbiParameter<{
type: 'address'
name: '123'
}>
>().toEqualTypeOf<'address Error: Identifier "123" cannot be a number string.'>()
expectTypeOf<
FormatAbiParameter<{
type: 'address'
name: '123'
}>
>().toEqualTypeOf<'address Error: Identifier "123" cannot be a number string.'>()

// Array
expectTypeOf<
FormatAbiParameter<{
readonly type: 'tuple'
readonly components: readonly [
{
readonly name: 'name'
readonly type: 'string'
},
]
}>
>().toEqualTypeOf<'(string name)'>()
// Array
expectTypeOf<
FormatAbiParameter<{
readonly type: 'tuple'
readonly components: readonly [
{
readonly name: 'name'
readonly type: 'string'
},
]
}>
>().toEqualTypeOf<'(string name)'>()

expectTypeOf<
FormatAbiParameter<{
readonly type: 'tuple'
readonly components: readonly [
{
readonly type: 'string'
readonly name: 'bar'
},
]
readonly name: 'foo'
}>
>().toEqualTypeOf<'(string bar) foo'>()
expectTypeOf<
FormatAbiParameter<{
readonly type: 'tuple'
readonly components: readonly [
{
readonly type: 'string'
readonly name: 'bar'
},
]
readonly name: 'foo'
}>
>().toEqualTypeOf<'(string bar) foo'>()

expectTypeOf<
FormatAbiParameter<{
readonly components: [
{
readonly components: [
{
readonly type: 'string'
readonly name: 'foo'
},
]
readonly type: 'tuple'
},
]
readonly type: 'tuple'
}>
>().toEqualTypeOf<'((string foo))'>()
expectTypeOf<
FormatAbiParameter<{
readonly components: [
{
readonly components: [
{
readonly type: 'string'
readonly name: 'foo'
},
]
readonly type: 'tuple'
},
]
readonly type: 'tuple'
}>
>().toEqualTypeOf<'((string foo))'>()

expectTypeOf<
FormatAbiParameter<{
readonly components: [
expectTypeOf<
FormatAbiParameter<{
readonly components: [
{
readonly components: [
{
readonly components: [
{
readonly components: [
{
readonly components: [
{
readonly components: [
{
readonly type: 'string'
},
]
readonly type: 'tuple'
},
]
readonly type: 'tuple'
},
]
readonly type: 'tuple'
readonly components: [
{
readonly type: 'string'
},
]
readonly type: 'tuple'
},
]
readonly type: 'tuple'
}>
>().toEqualTypeOf<'((((string))))'>()
]
readonly type: 'tuple'
},
]
readonly type: 'tuple'
},
]
readonly type: 'tuple'
}>
>().toEqualTypeOf<'((((string))))'>()
})

test('formatAbiParameter', () => {
expectTypeOf(
formatAbiParameter({
type: 'tuple',
components: [{ type: 'string' }],
}),
).toEqualTypeOf<'(string)'>()
expectTypeOf(
formatAbiParameter({
type: 'tuple',
components: [{ type: 'string' }],
}),
).toEqualTypeOf<'(string)'>()

const param = { type: 'address' }
const param2: AbiParameter = param
expectTypeOf(formatAbiParameter(param)).toEqualTypeOf<string>()
expectTypeOf(formatAbiParameter(param2)).toEqualTypeOf<string>()
const param = { type: 'address' }
const param2: AbiParameter = param
expectTypeOf(formatAbiParameter(param)).toEqualTypeOf<string>()
expectTypeOf(formatAbiParameter(param2)).toEqualTypeOf<string>()
})

0 comments on commit ac85db5

Please sign in to comment.