Skip to content

Commit 86bb029

Browse files
committed
Lint
1 parent 6b58f54 commit 86bb029

File tree

6 files changed

+13
-19
lines changed

6 files changed

+13
-19
lines changed

src/anchor/coder/events.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ import { Idl, Event, EventCoder } from '@coral-xyz/anchor'
22
import { IdlEvent } from '@coral-xyz/anchor/dist/cjs/idl'
33

44
export class PythOracleEventCoder implements EventCoder {
5-
constructor(_idl: Idl) {}
6-
75
decode<E extends IdlEvent = IdlEvent, T = Record<string, string>>(_log: string): Event<E, T> | null {
86
throw new Error('Pyth oracle program does not have events')
97
}

src/anchor/coder/idl.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,9 @@ export class IdlCoder {
9797
}
9898
return IdlCoder.typeDefLayout(filtered[0], types, fieldName)
9999
} else if ('array' in field.type) {
100-
let arrayTy = field.type.array[0]
101-
let arrayLen = field.type.array[1]
102-
let innerLayout = IdlCoder.fieldLayout(
100+
const arrayTy = field.type.array[0]
101+
const arrayLen = field.type.array[1]
102+
const innerLayout = IdlCoder.fieldLayout(
103103
{
104104
name: undefined,
105105
type: arrayTy,
@@ -122,7 +122,7 @@ export class IdlCoder {
122122
})
123123
return borsh.struct(fieldLayouts, name)
124124
} else if (typeDef.type.kind === 'enum') {
125-
let variants = typeDef.type.variants.map((variant: IdlEnumVariant) => {
125+
const variants = typeDef.type.variants.map((variant: IdlEnumVariant) => {
126126
const name = camelCase(variant.name)
127127
if (variant.fields === undefined) {
128128
return borsh.struct([], name)

src/anchor/coder/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ export class PythOracleCoder implements Coder {
1818

1919
constructor(idl: Idl) {
2020
this.accounts = new PythOracleAccountCoder(idl)
21-
this.events = new PythOracleEventCoder(idl)
21+
this.events = new PythOracleEventCoder()
2222
this.instruction = new PythOracleInstructionCoder(idl)
23-
this.state = new PythOracleStateCoder(idl)
24-
this.types = new PythOracleTypesCoder(idl)
23+
this.state = new PythOracleStateCoder()
24+
this.types = new PythOracleTypesCoder()
2525
}
2626
}

src/anchor/coder/instructions.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export class PythOracleInstructionCoder implements InstructionCoder {
3939
const discriminatorLayouts = new Map()
4040
const ixDiscriminator = new Map()
4141
idl.instructions.forEach((ix) => {
42-
let pythIx = ix as PythIdlInstruction
42+
const pythIx = ix as PythIdlInstruction
4343
let discriminatorLength: number
4444
if (pythIx.discriminant) {
4545
discriminatorLayouts.set(bs58.encode(Buffer.from(pythIx.discriminant.value)), {
@@ -51,7 +51,7 @@ export class PythOracleInstructionCoder implements InstructionCoder {
5151
} else {
5252
throw new Error(`All instructions must have a discriminator`)
5353
}
54-
if (this.discriminatorLength && this.discriminatorLength != discriminatorLength) {
54+
if (this.discriminatorLength && this.discriminatorLength !== discriminatorLength) {
5555
throw new Error(`All instructions must have the same discriminator length`)
5656
} else {
5757
this.discriminatorLength = discriminatorLength
@@ -87,7 +87,7 @@ export class PythOracleInstructionCoder implements InstructionCoder {
8787

8888
private static parseIxLayout(idl: Idl): Map<string, Layout> {
8989
const ixLayouts = idl.instructions.map((ix): [string, Layout<unknown>] => {
90-
let fieldLayouts = ix.args.map((arg: IdlField) =>
90+
const fieldLayouts = ix.args.map((arg: IdlField) =>
9191
IdlCoder.fieldLayout(arg, Array.from([...(idl.accounts ?? []), ...(idl.types ?? [])])),
9292
)
9393
const name = camelCase(ix.name)
@@ -104,9 +104,9 @@ export class PythOracleInstructionCoder implements InstructionCoder {
104104
if (typeof ix === 'string') {
105105
ix = encoding === 'hex' ? Buffer.from(ix, 'hex') : Buffer.from(bs58.decode(ix))
106106
}
107-
let sighash = bs58.encode(ix.subarray(0, this.discriminatorLength))
108-
let data = ix.subarray(this.discriminatorLength)
109-
const decoder = this.discriminatorLayouts.get(sighash)
107+
const discriminator = bs58.encode(ix.subarray(0, this.discriminatorLength))
108+
const data = ix.subarray(this.discriminatorLength)
109+
const decoder = this.discriminatorLayouts.get(discriminator)
110110
if (!decoder) {
111111
return null
112112
}

src/anchor/coder/state.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import { Idl, StateCoder } from '@coral-xyz/anchor'
22

33
export class PythOracleStateCoder implements StateCoder {
4-
constructor(_idl: Idl) {}
5-
64
encode<T = any>(_name: string, _account: T): Promise<Buffer> {
75
throw new Error('Not implemented')
86
}

src/anchor/coder/types.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import { Idl, TypesCoder } from '@coral-xyz/anchor'
22

33
export class PythOracleTypesCoder implements TypesCoder {
4-
constructor(_idl: Idl) {}
5-
64
encode<T = any>(_name: string, _type: T): Buffer {
75
throw new Error('Pyth oracle does not have user-defined types')
86
}

0 commit comments

Comments
 (0)