File tree Expand file tree Collapse file tree 5 files changed +39
-5
lines changed Expand file tree Collapse file tree 5 files changed +39
-5
lines changed Original file line number Diff line number Diff line change @@ -3,10 +3,6 @@ yarn-debug.log*
33yarn-error.log *
44node.log
55
6- # Core dumps
7- core
8- core. *
9-
106# Dependency directories
117node_modules /
128.pnpm-store /
Original file line number Diff line number Diff line change 11# @graphprotocol/toolshed
22
3+ ## 1.0.3
4+
5+ ### Patch Changes
6+
7+ - Add fn to parse custom errors to toolshed package
8+
39## 1.0.2
410
511### Patch Changes
Original file line number Diff line number Diff line change 11{
22 "name" : " @graphprotocol/toolshed" ,
3- "version" : " 1.0.2 " ,
3+ "version" : " 1.0.3 " ,
44 "publishConfig" : {
55 "access" : " public"
66 },
Original file line number Diff line number Diff line change 1+ import { getInterface } from '@graphprotocol/interfaces'
2+ import { ErrorDescription } from 'ethers'
3+
4+ export function parseCustomError ( error : string ) : string | null {
5+ const interfaces = [
6+ getInterface ( 'HorizonStaking' ) ,
7+ getInterface ( 'SubgraphService' ) ,
8+ getInterface ( 'PaymentsEscrow' ) ,
9+ getInterface ( 'GraphTallyCollector' ) ,
10+ getInterface ( 'GraphPayments' ) ,
11+ ]
12+
13+ let decodedError : ErrorDescription | null = null
14+ for ( const iface of interfaces ) {
15+ decodedError = iface . parseError ( error )
16+ if ( decodedError ) {
17+ break
18+ }
19+ }
20+
21+ if ( ! decodedError ) {
22+ return null
23+ }
24+
25+ const argStrings = decodedError . fragment . inputs . map ( ( input , i ) => {
26+ const value = decodedError . args [ i ]
27+ return `${ input . name } : ${ value } `
28+ } )
29+
30+ return `${ decodedError . name } (${ argStrings . join ( ', ' ) } )`
31+ }
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ export * from './accounts'
22export * from './allocation'
33export * from './attestations'
44export * from './constants'
5+ export * from './custom-errors'
56export * from './disputes'
67export * from './graph-tally'
78export * from './poi'
You can’t perform that action at this time.
0 commit comments