Skip to content

Commit 4666b4a

Browse files
authored
feat: integrating latest dappflow redirect feature for clicks on account (#10)
* feat: integrating latest dappflow redirect feature; RIP algoexplorer * refactor: addressing pr comments
1 parent 661cb68 commit 4666b4a

File tree

4 files changed

+28
-12
lines changed
  • template_content/src/components
  • tests_generated
    • test_all_default_parameters_off/src/components
    • test_all_default_parameters_on_netlify/src/components
    • test_all_default_parameters_on_vercel/src/components

4 files changed

+28
-12
lines changed

template_content/src/components/Account.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
import { useWallet } from '@txnlab/use-wallet'
2+
import { useMemo } from 'react'
23
import { ellipseAddress } from '../utils/ellipseAddress'
34
import { getAlgodConfigFromViteEnvironment } from '../utils/network/getAlgoClientConfigs'
45

56
const Account = () => {
67
const { activeAddress } = useWallet()
78
const algoConfig = getAlgodConfigFromViteEnvironment()
9+
10+
const dappFlowNetworkName = useMemo(() => {
11+
return algoConfig.network === '' ? 'sandbox' : algoConfig.network.toLocaleLowerCase()
12+
}, [algoConfig.network])
13+
814
return (
915
<div>
1016
<a
1117
className="text-xl"
1218
target="_blank"
13-
href={`https://${
14-
['mainnet', ''].includes(algoConfig.network.toLowerCase()) ? '' : `${algoConfig.network.toLowerCase()}.`
15-
}algoexplorer.io/address/${activeAddress}`}
19+
href={`https://app.dappflow.org/setnetwork?name=${dappFlowNetworkName}&redirect=explorer/account/${activeAddress}/`}
1620
>
1721
Address: {ellipseAddress(activeAddress)}
1822
</a>

tests_generated/test_all_default_parameters_off/src/components/Account.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
import { useWallet } from '@txnlab/use-wallet'
2+
import { useMemo } from 'react'
23
import { ellipseAddress } from '../utils/ellipseAddress'
34
import { getAlgodConfigFromViteEnvironment } from '../utils/network/getAlgoClientConfigs'
45

56
const Account = () => {
67
const { activeAddress } = useWallet()
78
const algoConfig = getAlgodConfigFromViteEnvironment()
9+
10+
const dappFlowNetworkName = useMemo(() => {
11+
return algoConfig.network === '' ? 'sandbox' : algoConfig.network.toLocaleLowerCase()
12+
}, [algoConfig.network])
13+
814
return (
915
<div>
1016
<a
1117
className="text-xl"
1218
target="_blank"
13-
href={`https://${
14-
['mainnet', ''].includes(algoConfig.network.toLowerCase()) ? '' : `${algoConfig.network.toLowerCase()}.`
15-
}algoexplorer.io/address/${activeAddress}`}
19+
href={`https://app.dappflow.org/setnetwork?name=${dappFlowNetworkName}&redirect=explorer/account/${activeAddress}/`}
1620
>
1721
Address: {ellipseAddress(activeAddress)}
1822
</a>

tests_generated/test_all_default_parameters_on_netlify/src/components/Account.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
import { useWallet } from '@txnlab/use-wallet'
2+
import { useMemo } from 'react'
23
import { ellipseAddress } from '../utils/ellipseAddress'
34
import { getAlgodConfigFromViteEnvironment } from '../utils/network/getAlgoClientConfigs'
45

56
const Account = () => {
67
const { activeAddress } = useWallet()
78
const algoConfig = getAlgodConfigFromViteEnvironment()
9+
10+
const dappFlowNetworkName = useMemo(() => {
11+
return algoConfig.network === '' ? 'sandbox' : algoConfig.network.toLocaleLowerCase()
12+
}, [algoConfig.network])
13+
814
return (
915
<div>
1016
<a
1117
className="text-xl"
1218
target="_blank"
13-
href={`https://${
14-
['mainnet', ''].includes(algoConfig.network.toLowerCase()) ? '' : `${algoConfig.network.toLowerCase()}.`
15-
}algoexplorer.io/address/${activeAddress}`}
19+
href={`https://app.dappflow.org/setnetwork?name=${dappFlowNetworkName}&redirect=explorer/account/${activeAddress}/`}
1620
>
1721
Address: {ellipseAddress(activeAddress)}
1822
</a>

tests_generated/test_all_default_parameters_on_vercel/src/components/Account.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
import { useWallet } from '@txnlab/use-wallet'
2+
import { useMemo } from 'react'
23
import { ellipseAddress } from '../utils/ellipseAddress'
34
import { getAlgodConfigFromViteEnvironment } from '../utils/network/getAlgoClientConfigs'
45

56
const Account = () => {
67
const { activeAddress } = useWallet()
78
const algoConfig = getAlgodConfigFromViteEnvironment()
9+
10+
const dappFlowNetworkName = useMemo(() => {
11+
return algoConfig.network === '' ? 'sandbox' : algoConfig.network.toLocaleLowerCase()
12+
}, [algoConfig.network])
13+
814
return (
915
<div>
1016
<a
1117
className="text-xl"
1218
target="_blank"
13-
href={`https://${
14-
['mainnet', ''].includes(algoConfig.network.toLowerCase()) ? '' : `${algoConfig.network.toLowerCase()}.`
15-
}algoexplorer.io/address/${activeAddress}`}
19+
href={`https://app.dappflow.org/setnetwork?name=${dappFlowNetworkName}&redirect=explorer/account/${activeAddress}/`}
1620
>
1721
Address: {ellipseAddress(activeAddress)}
1822
</a>

0 commit comments

Comments
 (0)