Skip to content

Commit

Permalink
add integration testing
Browse files Browse the repository at this point in the history
wow the integration test has gotten very small and looking good
  • Loading branch information
dbeal-eth committed Sep 26, 2024
1 parent 1cfd107 commit 3eaec0a
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 225 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules
coverage
out
package-lock.json
dist
Expand Down
34 changes: 34 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"homepage": "https://github.com/Synthetixio/erc7412#readme",
"dependencies": {
"@usecannon/cli": "^2.17.0",
"debug": "^4.3.7",
"node-fetch": "^2.6.12",
"typechain": "^8.3.1",
"viem": "^2.20.0"
Expand All @@ -36,6 +37,7 @@
"@pythnetwork/pyth-sdk-solidity": "^2.2.1"
},
"devDependencies": {
"@types/debug": "^4.1.12",
"@types/jest": "^29.5.12",
"@types/node-fetch": "^2.6.4",
"@typescript-eslint/eslint-plugin": "^6.16.0",
Expand Down
11 changes: 8 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ import IERC7412 from '../out/IERC7412.sol/IERC7412.json'
import { type OracleAdapter } from './types'
import { parseError } from './parseError'

import Debug from 'debug'

import ITrustedMulticallForwarder from '../out/ITrustedMulticallForwarder.sol/ITrustedMulticallForwarder.json'
import { getWETHAddress } from './constants'

const debug = Debug('erc7412')

const TRUSTED_MULTICALL_FORWARDER_ADDRESS: viem.Address = '0xE2C5658cC5C448B48141168f3e475dF8f65A1e3e'

export const LEGACY_ODR_ERROR = [
Expand Down Expand Up @@ -52,11 +56,9 @@ export async function callWithOffchainData(
try {
result = await client.call(makeTrustedForwarderMulticall([...prependedTxns, ...transactions] as TransactionRequest[]))
} catch (caughtErr) {
console.error('an error occured', caughtErr)
prependedTxns.push(...(await resolvePrependTransaction(caughtErr, client, adapters)))
continue
}
console.log('got result', result)
if (result.data === undefined) {
throw new Error('missing return data from multicall')
}
Expand Down Expand Up @@ -89,6 +91,7 @@ export function resolveAdapterCalls(
data: parseError(origError as viem.CallExecutionError)
})
}
debug('parsing error of type', err.errorName)
if (err.errorName === 'Errors') {
const errorsList = err.args?.[0] as viem.Hex[]

Expand All @@ -114,7 +117,7 @@ export function resolveAdapterCalls(
return { [oracleAddress]: [{ query: oracleQuery, fee }] }
}
} catch (err) {
console.log('had unexpected failure', err)
console.error('had unexpected failure', err)
}

// if we get to this point then we cant parse the error so we should make sure to send the original
Expand Down Expand Up @@ -166,5 +169,7 @@ export async function resolvePrependTransaction(
}
}

debug('adding oracle update calls', priceUpdateTxs.length)

return priceUpdateTxs
}
Loading

0 comments on commit 3eaec0a

Please sign in to comment.