-
Notifications
You must be signed in to change notification settings - Fork 141
fix: display base token page in prividium mode for non-admins #583
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -90,6 +90,7 @@ | |
|
|
||
| <TableBodyColumn :data-heading="t('transfers.table.direction')"> | ||
| <TransactionDirectionTableCell | ||
| v-if="!forToken" | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why? |
||
| :data-testid="$testId.direction" | ||
| class="transfers-in-out" | ||
| :text="getTransferDirection(item)" | ||
|
|
@@ -167,12 +168,17 @@ const props = defineProps({ | |
| required: true, | ||
| default: () => null, | ||
| }, | ||
| forToken: { | ||
| type: Boolean, | ||
| default: false, | ||
| }, | ||
| }); | ||
|
|
||
| const { data, load, total, pending, pageSize } = useTransfers( | ||
| computed(() => { | ||
| return props.address; | ||
| }) | ||
| }), | ||
| { forToken: props.forToken } | ||
| ); | ||
|
|
||
| function getTransferDirection(item: Transfer): Direction { | ||
|
|
@@ -185,7 +191,7 @@ const toDate = new Date(); | |
| watch( | ||
| [activePage, () => props.address], | ||
| ([page]) => { | ||
| load(page, toDate); | ||
| load(page, props.forToken ? undefined : toDate); | ||
| }, | ||
| { immediate: true } | ||
| ); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,23 +6,30 @@ import { FetchError } from "ohmyfetch"; | |
| import useContext from "./useContext"; | ||
| import { FetchInstance } from "./useFetchInstance"; | ||
|
|
||
| import { isAddress, isBlockNumber, isTransactionHash } from "@/utils/validators"; | ||
| import { isAddress, isAddressEqual, isBlockNumber, isTransactionHash } from "@/utils/validators"; | ||
|
|
||
| export default (context = useContext()) => { | ||
| const router = useRouter(); | ||
| const isRequestPending = ref(false); | ||
| const isRequestFailed = ref(false); | ||
|
|
||
| const isPrividiumBaseTokenAddress = (address: string) => | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this feature something specific to Prividium? I'd imagine that any network with a custom base token would want to show a token-based view. |
||
| !!context.currentNetwork.value.prividium && isAddressEqual(address, context.currentNetwork.value.baseTokenAddress); | ||
|
|
||
| const getSearchRoute = (param: string) => { | ||
| try { | ||
| const searchRoutes = [ | ||
| { | ||
| if (isAddress(param)) { | ||
| const isBaseTokenAddress = isPrividiumBaseTokenAddress(param); | ||
| return { | ||
| routeParam: { address: param }, | ||
| apiRoute: "address", | ||
| isValid: () => isAddress(param), | ||
| routeName: "address", | ||
| isValid: () => true, | ||
| routeName: isBaseTokenAddress ? "token" : "address", | ||
| prefetch: true, | ||
| }, | ||
| }; | ||
| } | ||
|
|
||
| const searchRoutes = [ | ||
| { | ||
| routeParam: { id: param }, | ||
| apiRoute: "blocks", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,13 +9,22 @@ export type Transfer = Api.Response.Transfer & { | |
| toNetwork: NetworkOrigin; | ||
| }; | ||
|
|
||
| export default (address: ComputedRef<string>, context = useContext()) => { | ||
| interface UseTransferOptions { | ||
| forToken?: boolean; | ||
| } | ||
|
|
||
| export default ( | ||
| address: ComputedRef<string>, | ||
| { forToken = false }: UseTransferOptions = {}, | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd rather add another composable |
||
| context = useContext() | ||
| ) => { | ||
| return useFetchCollection<Transfer, Api.Response.Transfer>( | ||
| () => | ||
| new URL( | ||
| `/address/${address.value}/transfers?toDate=${new Date().toISOString()}`, | ||
| context.currentNetwork.value.apiUrl | ||
| ), | ||
| () => { | ||
| const path = forToken | ||
| ? `/tokens/${address.value}/transfers` | ||
| : `/address/${address.value}/transfers?toDate=${new Date().toISOString()}`; | ||
| return new URL(path, context.currentNetwork.value.apiUrl); | ||
| }, | ||
| (transfer: Api.Response.Transfer): Transfer => ({ | ||
| ...transfer, | ||
| token: transfer.token || { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why only for base token?