Skip to content

Commit a34c4b7

Browse files
author
Alex Kwiatkowski
committed
Return etherscan host in JSON-API metadata
1 parent e850866 commit a34c4b7

File tree

5 files changed

+20
-10
lines changed

5 files changed

+20
-10
lines changed

explorer/client/@types/link-stats/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ interface IJobRun {
1515
createdAt: string
1616
finishedAt?: string
1717
chainlinkNode: IChainlinkNode
18+
etherscanHost: string
1819
taskRuns: ITaskRun[]
1920
}
2021

explorer/client/src/components/JobRuns/Details.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,10 @@ const Details = ({ classes, jobRun }: IProps) => {
169169
<Row className={classes.bottomRow}>
170170
<Key>Tasks</Key>
171171
<BaseItem sm={12} md={8} className={classes.task}>
172-
<TaskRuns taskRuns={jobRun.taskRuns} />
172+
<TaskRuns
173+
taskRuns={jobRun.taskRuns}
174+
etherscanHost={jobRun.etherscanHost}
175+
/>
173176
</BaseItem>
174177
</Row>
175178
</div>

explorer/client/src/components/JobRuns/EtherscanLink.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ const styles = ({ palette, spacing }: Theme) =>
2828

2929
interface IProps extends WithStyles<typeof styles> {
3030
txHash: string
31+
host: string
3132
}
3233

33-
const host = process.env.ETHERSCAN_HOST || 'ropsten.etherscan.io'
34-
const url = (txHash: string) => `https://${host}/tx/${txHash}`
34+
const url = (host: string, txHash: string) => `https://${host}/tx/${txHash}`
3535

36-
const Details = ({ classes, txHash }: IProps) => {
36+
const Details = ({ classes, host, txHash }: IProps) => {
3737
return (
3838
<a
39-
href={url(txHash)}
39+
href={url(host, txHash)}
4040
target="_blank"
4141
rel="noopener noreferrer"
4242
className={classes.link}>

explorer/client/src/components/JobRuns/TaskRuns.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,11 @@ const styles = ({ spacing, palette }: Theme) =>
3939
})
4040

4141
interface IProps extends WithStyles<typeof styles> {
42+
etherscanHost: string
4243
taskRuns?: ITaskRun[]
4344
}
4445

45-
const TaskRuns = ({ taskRuns, classes }: IProps) => {
46+
const TaskRuns = ({ etherscanHost, taskRuns, classes }: IProps) => {
4647
return (
4748
<ul className={classes.container}>
4849
{taskRuns &&
@@ -60,7 +61,7 @@ const TaskRuns = ({ taskRuns, classes }: IProps) => {
6061
</Grid>
6162
<Grid item xs={9}>
6263
{run.transactionHash && (
63-
<EtherscanLink txHash={run.transactionHash} />
64+
<EtherscanLink txHash={run.transactionHash} host={etherscanHost} />
6465
)}
6566
</Grid>
6667
</Grid>

explorer/src/serializers/jobRunSerializer.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,20 @@ export const taskRuns = {
3636
]
3737
}
3838

39-
const jobRunsSerializer = (run: JobRun) => {
39+
const ETHERSCAN_HOST = process.env.ETHERSCAN_HOST || 'ropsten.etherscan.io'
40+
41+
const jobRunSerializer = (run: JobRun) => {
4042
const opts = {
4143
attributes: BASE_ATTRIBUTES.concat(['taskRuns']),
4244
keyForAttribute: 'camelCase',
4345
chainlinkNode: chainlinkNode,
44-
taskRuns: taskRuns
46+
taskRuns: taskRuns,
47+
meta: {
48+
etherscanHost: ETHERSCAN_HOST
49+
}
4550
} as SerializerOptions
4651

4752
return new JSONAPISerializer('job_runs', opts).serialize(run)
4853
}
4954

50-
export default jobRunsSerializer
55+
export default jobRunSerializer

0 commit comments

Comments
 (0)