Skip to content

Commit

Permalink
Remame consts
Browse files Browse the repository at this point in the history
  • Loading branch information
anxolin committed Aug 24, 2023
1 parent e7f2ae0 commit fa68c36
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/composable/types/Twap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const MAX_UINT32 = BigNumber.from(2).pow(32).sub(1) // 2^32 - 1
export const MAX_FREQUENCY = BigNumber.from(365 * 24 * 60 * 60) // 1 year

// Define the ABI tuple for the TWAPData struct
const TWAP_DATA_ABI = [
const TWAP_STRUCT_ABI = [
'tuple(address sellToken, address buyToken, address receiver, uint256 partSellAmount, uint256 minPartLimit, uint256 t0, uint256 n, uint256 t, uint256 span, bytes32 appData)',
]

Expand Down Expand Up @@ -238,7 +238,7 @@ export class Twap extends ConditionalOrder<TwapData, TwapStruct> {
}

// Verify that the staticInput derived from the data is ABI-encodable
if (!isValidAbi(TWAP_DATA_ABI, [this.staticInput])) return 'InvalidData'
if (!isValidAbi(TWAP_STRUCT_ABI, [this.staticInput])) return 'InvalidData'

// No errors
return undefined
Expand Down Expand Up @@ -278,7 +278,7 @@ export class Twap extends ConditionalOrder<TwapData, TwapStruct> {
* @returns {string} The ABI-encoded TWAP order.
*/
encodeStaticInput(): string {
return super.encodeStaticInputHelper(TWAP_DATA_ABI, this.staticInput)
return super.encodeStaticInputHelper(TWAP_STRUCT_ABI, this.staticInput)
}

/**
Expand All @@ -290,7 +290,7 @@ export class Twap extends ConditionalOrder<TwapData, TwapStruct> {
return super.deserializeHelper(
s,
TWAP_ADDRESS,
TWAP_DATA_ABI,
TWAP_STRUCT_ABI,
(struct: TwapStruct, salt: string) =>
new Twap({
handler: TWAP_ADDRESS,
Expand Down
6 changes: 3 additions & 3 deletions src/composable/utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { decodeParams, encodeParams, isValidAbi } from './utils'
import { TwapStruct, transformDataToStruct } from './types/Twap'
import { TWAP_PARAMS_TEST } from './types/twap.spec'

const TWAP_DATA_ABI = [
const TWAP_STRUCT_ABI = [
'tuple(address sellToken, address buyToken, address receiver, uint256 partSellAmount, uint256 minPartLimit, uint256 t0, uint256 n, uint256 t, uint256 span, bytes32 appData)',
]

Expand Down Expand Up @@ -39,10 +39,10 @@ describe('decodeParams', () => {

describe('isValidAbi', () => {
test('isValidAbi: Fails if invalid params', () => {
expect(isValidAbi(TWAP_DATA_ABI, ['0x0'])).toEqual(false)
expect(isValidAbi(TWAP_STRUCT_ABI, ['0x0'])).toEqual(false)
})

test('isValidAbi: Happy path', () => {
expect(isValidAbi(TWAP_DATA_ABI, [TWAP_STRUCT])).toEqual(true)
expect(isValidAbi(TWAP_STRUCT_ABI, [TWAP_STRUCT])).toEqual(true)
})
})

0 comments on commit fa68c36

Please sign in to comment.