Skip to content

Commit 8b1478a

Browse files
authored
Merge branch 'main' into horizon-mainnet
2 parents ba43bc9 + 16b83ad commit 8b1478a

File tree

4 files changed

+37
-4
lines changed

4 files changed

+37
-4
lines changed

.gitignore

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ yarn-debug.log*
33
yarn-error.log*
44
node.log
55

6-
# Core dumps
7-
core
8-
core.*
9-
106
# Dependency directories
117
node_modules/
128
.pnpm-store/

packages/toolshed/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010

1111
- Updated dependencies
1212
- @graphprotocol/address-book@1.1.0
13+
## 1.0.3
14+
15+
### Patch Changes
16+
17+
- Add fn to parse custom errors to toolshed package
1318

1419
## 1.0.2
1520

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
}

packages/toolshed/src/core/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ export * from './accounts'
22
export * from './allocation'
33
export * from './attestations'
44
export * from './constants'
5+
export * from './custom-errors'
56
export * from './disputes'
67
export * from './graph-tally'
78
export * from './poi'

0 commit comments

Comments
 (0)