-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1397 from input-output-hk/fix-explorer-sanchonet-…
…respin Switch explorer to run on preview & clear TVL on Finalized
- Loading branch information
Showing
12 changed files
with
111 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
NETWORK_URL=preview |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
/** @type {import('next').NextConfig} */ | ||
const nextConfig = { | ||
output: 'export' | ||
}; | ||
output: 'export', | ||
env: { | ||
NETWORK_URL: process.env.NETWORK_URL | ||
}, | ||
}; | ||
|
||
export default nextConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
hydra-explorer/web/src/providers/CardanoExplorer/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
"use client" // This is a client component 👈🏽 | ||
|
||
import React, { PropsWithChildren, useContext } from "react" | ||
|
||
export interface CardanoExplorer { | ||
mintPolicy: (policyId: string) => string | ||
tx: (txIn: string) => string | ||
block: (blockHash: string) => string | ||
address: (addr: string) => string | ||
} | ||
|
||
const CardanoExplorerContext: React.Context<CardanoExplorer> = | ||
React.createContext({} as CardanoExplorer) | ||
|
||
export const useCardanoExplorer = () => { | ||
const context = useContext(CardanoExplorerContext) | ||
if (!context) { | ||
throw new Error("useCardanoExplorer must be used within a CardanoExplorerProvider") | ||
} | ||
return context | ||
} | ||
|
||
export type CardanoExplorerProps = { | ||
network: string | ||
} | ||
|
||
export const CardanoExplorerProvider: React.FC<PropsWithChildren<CardanoExplorerProps>> = | ||
({ network, children }) => { | ||
const cexplorer: CardanoExplorer = { | ||
mintPolicy: (policyId: string) => `https://${network}.cexplorer.io/policy/${policyId}/mint`, | ||
tx: (txIn: string) => `https://${network}.cexplorer.io/tx/${txIn}`, | ||
block: (blockHash: string) => `https://${network}.cexplorer.io/block/${blockHash}`, | ||
address: (addr: string) => `https://${network}.cexplorer.io/address/${addr}` | ||
} | ||
|
||
return ( | ||
<CardanoExplorerContext.Provider value={cexplorer}> | ||
{children} | ||
</CardanoExplorerContext.Provider> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
import { HeadState } from "./app/model" | ||
|
||
export const totalLovelaceValueLocked = (head: HeadState) => { | ||
if (head.status == "Finalized" || head.status == "Aborted" ) return 0 | ||
return (head.members || []).reduce((total, member) => { | ||
if (member.commits && Object.keys(member.commits).length > 0) { | ||
return total + Object.values(member.commits).reduce((memberTotal, commit) => { | ||
const memberTotal = Object.values(member.commits).reduce((memberTotal, commit) => { | ||
return memberTotal + commit.value.lovelace | ||
}, 0) | ||
return total + memberTotal | ||
} | ||
return total | ||
}, 0) | ||
} | ||
} |