-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add Phalcon Explorer shortcut for Solana txns
- Loading branch information
Showing
35 changed files
with
563 additions
and
86 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
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
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,34 @@ | ||
import React, { type FC } from 'react' | ||
|
||
import { PHALCON_EXPLORER_DOMAIN } from '@common/config/uri' | ||
import { getChainSimpleName } from '@common/utils' | ||
import { PHALCON_SUPPORT_LIST } from '@common/constants' | ||
import { IconPhalcon } from '@common/components' | ||
|
||
interface Props { | ||
txHash: string | ||
} | ||
|
||
const ParsersBtn: FC<Props> = ({ txHash }) => { | ||
const chain = getChainSimpleName() | ||
|
||
const pathname = PHALCON_SUPPORT_LIST.find( | ||
item => item.chain === chain | ||
)?.pathname | ||
|
||
const handleClick = (e: React.MouseEvent<SVGSVGElement, MouseEvent>) => { | ||
e.preventDefault() | ||
window.open(`${PHALCON_EXPLORER_DOMAIN}/tx/${pathname}/${txHash}`, '_blank') | ||
} | ||
|
||
if (!chain) return null | ||
return ( | ||
<IconPhalcon | ||
mode="dark" | ||
style={{ verticalAlign: 'sub' }} | ||
onClick={handleClick} | ||
/> | ||
) | ||
} | ||
|
||
export default ParsersBtn |
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,3 +1,5 @@ | ||
export { default as renderFundFlowButton } from './fund-flow' | ||
export { default as renderMainAddressLabel } from './main-address-label' | ||
export { default as renderTxPageAddressLabels } from './tx-address-labels' | ||
export { default as renderAlternativeParsers } from './quick2parsers' | ||
export { default as renderTransactionHashPhalconLink } from './transaction-hash-phalcon-link' |
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,17 @@ | ||
import { createRoot } from 'react-dom/client' | ||
import $ from 'jquery' | ||
|
||
import { ParsersButton } from '../components' | ||
|
||
const renderAlternativeParsers = async () => { | ||
const container = $( | ||
'.card table .list tr:first-of-type > td:last-child > div' | ||
).first() | ||
const txHash = container.text().trim() | ||
const rootEl = $('<span class="font-size-tiny me-2"></span>') | ||
container.prepend(rootEl) | ||
|
||
createRoot(rootEl[0]).render(<ParsersButton txHash={txHash} />) | ||
} | ||
|
||
export default renderAlternativeParsers |
85 changes: 85 additions & 0 deletions
85
src/content/solanaexpl/feat-scripts/transaction-hash-phalcon-link.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,85 @@ | ||
import React, { type FC, type ReactNode } from 'react' | ||
import isMobile from 'is-mobile' | ||
import { createRoot } from 'react-dom/client' | ||
|
||
import { PHALCON_SUPPORT_LIST } from '@common/constants' | ||
import { getChainSimpleName } from '@common/utils' | ||
import { PHALCON_EXPLORER_DOMAIN } from '@common/config/uri' | ||
import { IconPhalcon } from '@common/components' | ||
|
||
const PhalconExplorerButton: FC<{ hash: string }> = ({ hash }) => { | ||
const chain = getChainSimpleName() | ||
|
||
const pathname = PHALCON_SUPPORT_LIST.find( | ||
item => item.chain === chain | ||
)?.pathname | ||
|
||
const handleClick = (e: React.MouseEvent<SVGSVGElement, MouseEvent>) => { | ||
e.preventDefault() | ||
window.open(`${PHALCON_EXPLORER_DOMAIN}/tx/${pathname}/${hash}`, '_blank') | ||
} | ||
|
||
if (!chain) return null | ||
return <IconPhalcon mode="dark" onClick={handleClick} /> | ||
} | ||
|
||
const appendIconToElement = (el: HTMLElement, reactNode: ReactNode) => { | ||
if (!isMobile()) { | ||
el.onmouseover = () => { | ||
const btnEls = el.querySelectorAll<HTMLElement>( | ||
'.__metadock-copy-address-btn__' | ||
) | ||
if (btnEls.length) { | ||
btnEls.forEach(btnEl => { | ||
btnEl.style.display = 'inline-flex' | ||
}) | ||
} | ||
} | ||
el.onmouseout = () => { | ||
const btnEls = el.querySelectorAll<HTMLElement>( | ||
'.__metadock-copy-address-btn__' | ||
) | ||
if (btnEls.length) { | ||
btnEls.forEach(btnEl => { | ||
btnEl.style.display = 'none' | ||
}) | ||
} | ||
} | ||
} | ||
|
||
el.setAttribute( | ||
'style', | ||
'padding-right:20px;position:relative;width:fit-content;' | ||
) | ||
|
||
const rootEl = document.createElement('span') | ||
rootEl.classList.add('__metadock-copy-address-btn__') | ||
rootEl.setAttribute( | ||
'style', | ||
`position:absolute;right:0;display:${ | ||
isMobile() ? 'inline-flex' : 'none' | ||
};top: 50%;transform: translateY(-50%)` | ||
) | ||
el?.appendChild(rootEl) | ||
createRoot(rootEl).render(reactNode) | ||
} | ||
|
||
const renderTransactionHashPhalconLink = async () => { | ||
const txnTags = document.querySelectorAll<HTMLElement>( | ||
"table a[href^='/tx/']" | ||
) | ||
for (let i = 0; i < txnTags.length; i++) { | ||
const el = txnTags[i] | ||
const href = el.getAttribute('href') | ||
if (!href) continue | ||
const txnHash = href.substring(href.lastIndexOf('/') + 1) | ||
let targetEl: HTMLElement | null = null | ||
if (!el.parentElement) return | ||
targetEl = el.parentElement.parentElement | ||
if (targetEl && txnHash) { | ||
appendIconToElement(targetEl, <PhalconExplorerButton hash={txnHash} />) | ||
} | ||
} | ||
} | ||
|
||
export default renderTransactionHashPhalconLink |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import React, { type FC } from 'react' | ||
|
||
import { PHALCON_EXPLORER_DOMAIN } from '@common/config/uri' | ||
import { getChainSimpleName } from '@common/utils' | ||
import { PHALCON_SUPPORT_LIST } from '@common/constants' | ||
import { IconPhalcon } from '@common/components' | ||
|
||
interface Props { | ||
txHash: string | ||
} | ||
|
||
const ParsersBtn: FC<Props> = ({ txHash }) => { | ||
const chain = getChainSimpleName() | ||
|
||
const pathname = PHALCON_SUPPORT_LIST.find( | ||
item => item.chain === chain | ||
)?.pathname | ||
|
||
const handleClick = (e: React.MouseEvent<SVGSVGElement, MouseEvent>) => { | ||
e.preventDefault() | ||
window.open(`${PHALCON_EXPLORER_DOMAIN}/tx/${pathname}/${txHash}`, '_blank') | ||
} | ||
|
||
if (!chain) return null | ||
return <IconPhalcon mode="dark" onClick={handleClick} /> | ||
} | ||
|
||
export default ParsersBtn |
Oops, something went wrong.