Skip to content

Commit

Permalink
fix: build (#231)
Browse files Browse the repository at this point in the history
* fix build

* update test cases

* update issue template
  • Loading branch information
maxklenk authored Nov 1, 2024
1 parent cf429fe commit 12810ec
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 44 deletions.
4 changes: 0 additions & 4 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,3 @@
- [ ] I have performed a self-review of my code
- [ ] This pull request is as small as possible and only tackles one problem
- [ ] I have added tests that cover the functionality / test the bug

# GitHub Copilot

copilot:all
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"parse-call-data": "ts-node --transpile-only src/cli.ts",
"lint": "eslint .",
"lint:fix": "eslint --fix .",
"test": "jest"
"test": "jest",
"pre-commit": "pnpm lint:fix && pnpm build && pnpm test"
},
"files": [
"dist",
Expand Down
3 changes: 1 addition & 2 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { stringify } from './lib/stringify'
import { parseCallDataString } from './parse-call-data-string'
import {
bridge,
bridgeSwap,
feeBridge,
stargateSwap,
swap,
Expand All @@ -22,7 +21,7 @@ const run = async () => {

const callDataStrings =
process.argv.length === 2
? [swap, bridge, stargateSwap, bridgeSwap, swapBridge, feeBridge]
? [swap, bridge, stargateSwap, swapBridge, feeBridge]
: process.argv.slice(2)

const parsed = await Promise.all(
Expand Down
47 changes: 12 additions & 35 deletions src/parser/parser.acceptance.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { isStringObject } from 'util/types'
import { AbiCache, CacheType, initCache } from '../abi-cache'
import {
bridge,
bridgeSwap,
collectTokenInsuranceFees,
feeBridge,
optimizedSwap,
Expand All @@ -17,12 +16,7 @@ import {
import { AMAROK_PAYLOAD_ABI } from './calldata-parsers/abis/amarok'
import { STARGATE_PAYLOAD_ABI } from './calldata-parsers/abis/stargate'
import { parseCallData } from './calldata-parsers/parse-call-data'
import {
AmarokDataStruct,
CallDataInformation,
StargateDataStruct,
SwapDataStruct,
} from './parameter-map'
import { CallDataInformation, SwapDataStruct } from './parameter-map'
import { listToSwapData } from './build-parameter-map'

const validateAndExtract = (
Expand Down Expand Up @@ -90,8 +84,7 @@ describe('Acceptance tests', () => {
expect(swapDataCalls.every(isCalldataInformation)).toBe(true)
})

// eslint-disable-next-line jest/no-disabled-tests
it.skip('should parse a swap(fee-collection) + bridge transfer', () => {
it('should parse a swap(fee-collection) + bridge transfer', () => {
const results = parseCallData(feeBridge, cache)
const result = validateAndExtract(results)
const swapData = validateAndExtractSwapData(result)
Expand All @@ -101,41 +94,21 @@ describe('Acceptance tests', () => {
expect(swapDataCalls.every(isCalldataInformation)).toBe(true)
})

// eslint-disable-next-line jest/no-disabled-tests
it.skip('bridge + swap transfer', () => {
const results = parseCallData(bridgeSwap, cache)
const result = validateAndExtract(results)

const amarokData = result.functionParameters._amarokData as AmarokDataStruct

expect(amarokData).toBeDefined()

const [toolCallData] = amarokData.callData as CallDataInformation[]

expect(toolCallData).toBeDefined()

const rawCallData =
'0x0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000552008c0f6870c2f77e5cc1d2eb9bdff03e30ea0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000001b02da8cb0d097eb8d57a175b88c7d8b479975060000000000000000000000001b02da8cb0d097eb8d57a175b88c7d8b479975060000000000000000000000002791bca1f2de4661ed88a30c99a7a9449aa841740000000000000000000000000b3f868e0be5597d5db7feb59e1cadbb0fdda50a00000000000000000000000000000000000000000000000000000000000ec8b500000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010438ed173900000000000000000000000000000000000000000000000000000000000ec8b50000000000000000000000000000000000000000000000000ab39f39a4a41bd800000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000dd1305150d27aecc60c066630105db419977e367000000000000000000000000000000000000000000000000000000006411c21700000000000000000000000000000000000000000000000000000000000000020000000000000000000000002791bca1f2de4661ed88a30c99a7a9449aa841740000000000000000000000000b3f868e0be5597d5db7feb59e1cadbb0fdda50a00000000000000000000000000000000000000000000000000000000'
const parsed = AbiCoder.defaultAbiCoder().decode(
AMAROK_PAYLOAD_ABI,
rawCallData
)

expect(toolCallData.functionParameters).toStrictEqual(parsed)
})

it('swap + stargate + swap transfer', () => {
const results = parseCallData(stargateSwap, cache)
const result = validateAndExtract(results)
const stargateData = result.functionParameters
._stargateData as StargateDataStruct
const stargateData = result.functionParameters._stargateData

expect(stargateData).toBeDefined()

if (!stargateData) return

const toolCallData = stargateData.callData

expect(toolCallData).toBeDefined()

if (typeof toolCallData === 'string') return

const rawCallData =
'0xe4062395cfea8e25cd957ffcec1fcad26d4007a21a7eedef7631ff6940ef48bf000000000000000000000000000000000000000000000000000000000000008000000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab1000000000000000000000000552008c0f6870c2f77e5cc1d2eb9bdff03e30ea000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000d01319f4b65b79124549de409d36f25e04b3e551000000000000000000000000d01319f4b65b79124549de409d36f25e04b3e551000000000000000000000000ff970a61a04b1ca14834a43f5de4533ebddb5cc800000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab100000000000000000000000000000000000000000000000000000000001cf96c00000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000010438ed173900000000000000000000000000000000000000000000000000000000001cf96c0000000000000000000000000000000000000000000000000003725db9f3984c00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000be27f03c8e6a61e2a4b1ee7940dbcb9204744d1c0000000000000000000000000000000000000000000000000000000064ca49e20000000000000000000000000000000000000000000000000000000000000002000000000000000000000000ff970a61a04b1ca14834a43f5de4533ebddb5cc800000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab100000000000000000000000000000000000000000000000000000000'
const parsed = AbiCoder.defaultAbiCoder().decode(
Expand All @@ -154,14 +127,18 @@ describe('Acceptance tests', () => {
it('swap + amarok + swap transfer', () => {
const results = parseCallData(swapAmarokSwap, cache)
const result = validateAndExtract(results)
const amarokData = result.functionParameters._amarokData as AmarokDataStruct
const amarokData = result.functionParameters._amarokData

expect(amarokData).toBeDefined()

if (!amarokData) return

const toolCallData = amarokData.callData

expect(toolCallData).toBeDefined()

if (typeof toolCallData === 'string') return

const rawCallData =
'0x0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000044d51423298160e91492da091acd9acd6697bab0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000010ed43c718714eb63d5aa57b78b54704e256024e00000000000000000000000010ed43c718714eb63d5aa57b78b54704e256024e0000000000000000000000001af3f329e8be154074d8769d1ffa4ee058b1dbc300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f176bfca6293ced00000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000010418cbafe50000000000000000000000000000000000000000000000000f176bfca6293ced000000000000000000000000000000000000000000000000000fb29df7ac71a000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000be27f03c8e6a61e2a4b1ee7940dbcb9204744d1c0000000000000000000000000000000000000000000000000000000064c92b7700000000000000000000000000000000000000000000000000000000000000020000000000000000000000001af3f329e8be154074d8769d1ffa4ee058b1dbc3000000000000000000000000bb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c00000000000000000000000000000000000000000000000000000000'
const parsed = AbiCoder.defaultAbiCoder().decode(
Expand Down
Loading

0 comments on commit 12810ec

Please sign in to comment.