Skip to content

Commit

Permalink
Merge pull request #16 from valory-xyz/mohan/debug-details
Browse files Browse the repository at this point in the history
feat: debug details page
  • Loading branch information
mohandast52 authored Mar 20, 2024
2 parents d2039f7 + 633b18f commit 61fab73
Show file tree
Hide file tree
Showing 56 changed files with 209 additions and 186 deletions.
3 changes: 2 additions & 1 deletion apps/autonolas-registry/common-util/ContractUtils/myList.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import includes from 'lodash/includes';
import { getFirstAndLastIndex } from 'common-util/List/functions';

import { getFirstAndLastIndex } from '../List/functions';

export const filterByOwner = (results, { searchValue, account }) => (results || []).filter((e) => {
const search = (searchValue || '').trim().toLowerCase();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import {
DEFAULT_SERVICE_CREATION_ETH_TOKEN_ZEROS,
NAV_TYPES,
HASH_DETAILS_STATE,
} from 'util/constants';
import { typePropType } from 'common-util/propTypes';
} from '../../util/constants';
import { typePropType } from '../propTypes';
import { Circle } from '../svg/Circle';
import { useHelpers } from '../hooks';
import { useMetadata } from '../hooks/useMetadata';
Expand Down
6 changes: 3 additions & 3 deletions apps/autonolas-registry/common-util/Details/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import {
import { get } from 'lodash';
import { Loader, NA } from '@autonolas/frontend-library';

import { NAV_TYPES } from 'util/constants';
import { useMetadata } from 'common-util/hooks/useMetadata';
import { typePropType } from 'common-util/propTypes';
import { NAV_TYPES } from '../../util/constants';
import { useMetadata } from '../hooks/useMetadata';
import { typePropType } from '../propTypes';
import { IpfsHashGenerationModal } from '../List/IpfsHashGenerationModal';
import { useDetails } from './useDetails';
import { NftImage } from './NFTImage';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import {
Button, Form, Input, Space, Radio,
} from 'antd';
import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons';
import { addressValidator } from 'common-util/functions';

import { addressValidator } from '../functions';

export const FormList = ({ inputOneLabel, inputTwoLabel, buttonText }) => (
<Form.List
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import PropTypes from 'prop-types';
import { Button, Form, Typography } from 'antd';

import { useHelpers } from 'common-util/hooks';
import { RegistryForm } from 'common-util/TransactionHelpers/RegistryForm';
import { useHelpers } from '../hooks';
import { RegistryForm } from '../TransactionHelpers/RegistryForm';
import { FormList } from './FormList';
import { DynamicFormContainer } from './styles';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable import/no-unresolved */
import { create } from 'ipfs-http-client';
import { base16 } from 'multiformats/bases/base16';
import { HASH_PREFIXES } from 'util/constants';

import { HASH_PREFIXES } from '../../../util/constants';

const ipfs = create({
host: process.env.NEXT_PUBLIC_REGISTRY_URL,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import React, { Fragment, useState } from 'react';
import PropTypes from 'prop-types';
import isNil from 'lodash/isNil';
import {
Form, Input, Button, Select,
} from 'antd';
import { Form, Input, Button, Select } from 'antd';
import { notifyError, notifySuccess } from '@autonolas/frontend-library';

import { HASH_PREFIXES } from 'util/constants';
import { HASH_PREFIXES } from '../../../util/constants';
import { useHelpers } from '../../hooks';
import { notifyWrongNetwork } from '../../functions';
import { getIpfsHashHelper } from './helpers';
Expand Down Expand Up @@ -191,7 +189,7 @@ export const IpfsHashGenerationModal = ({
]}
>
<Input
addonBefore={(
addonBefore={
<Select
defaultValue={hashType}
className="select-before"
Expand All @@ -204,7 +202,7 @@ export const IpfsHashGenerationModal = ({
{HASH_PREFIXES.type2}
</Select.Option>
</Select>
)}
}
/>
</Form.Item>

Expand Down
2 changes: 1 addition & 1 deletion apps/autonolas-registry/common-util/List/ListCommon.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Link from 'next/link';
import { Alert, Button } from 'antd';
import { ExportOutlined } from '@ant-design/icons';

import { EmptyMessage, RegisterFooter } from 'components/styles';
import { EmptyMessage, RegisterFooter } from '../../components/styles';
import { useHelpers } from '../hooks';

// ----------- functions -----------
Expand Down
19 changes: 10 additions & 9 deletions apps/autonolas-registry/common-util/List/ListTable/helpers.jsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import { useState } from 'react';
import {
Input, Space, Button, Typography,
} from 'antd';
import { Input, Space, Button, Typography } from 'antd';
import { SearchOutlined } from '@ant-design/icons';
import {
AddressLink,
areAddressesEqual,
NA,
} from '@autonolas/frontend-library';

import { NAV_TYPES, SERVICE_STATE, TOTAL_VIEW_COUNT } from 'util/constants';
import {
NAV_TYPES,
SERVICE_STATE,
TOTAL_VIEW_COUNT,
} from '../../../util/constants';

const { Title } = Typography;

export const getTableColumns = (
type,
{
onViewClick, onUpdateClick, isMobile, chainName, account, chainId,
},
{ onViewClick, onUpdateClick, isMobile, chainName, account, chainId },
) => {
const addressLinkProps = {
chainId,
Expand Down Expand Up @@ -109,8 +109,9 @@ export const getTableColumns = (
fixed: 'right',
render: (_text, record) => {
// only show update button for pre-registration state
const canUpdate = ['1'].includes(record.state)
&& areAddressesEqual(record.owner, account);
const canUpdate =
['1'].includes(record.state) &&
areAddressesEqual(record.owner, account);

return (
<Space size="middle">
Expand Down
6 changes: 3 additions & 3 deletions apps/autonolas-registry/common-util/List/ListTable/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import PropTypes from 'prop-types';
import { Table } from 'antd';
import { Loader, useScreen } from '@autonolas/frontend-library';

import { TOTAL_VIEW_COUNT } from 'util/constants';
import { ListEmptyMessage } from 'common-util/List/ListCommon';
import { useHelpers } from 'common-util/hooks';
import { TOTAL_VIEW_COUNT } from '../../../util/constants';
import { ListEmptyMessage } from '../../List/ListCommon';
import { useHelpers } from '../../hooks';
import { fetchDataSource, getTableColumns } from './helpers';

const ListTable = ({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import PropTypes from 'prop-types';
import { Form, Input, Tooltip } from 'antd';
import { LinkOutlined } from '@ant-design/icons';
import { GATEWAY_URL, HASH_PREFIX } from 'util/constants';

import { GATEWAY_URL, HASH_PREFIX } from '../../../util/constants';
import { getBase16Validator } from '../IpfsHashGenerationModal';

export const FormItemHash = ({ listType, hashValue }) => (
Expand All @@ -23,7 +24,7 @@ export const FormItemHash = ({ listType, hashValue }) => (
<Input
disabled
addonBefore={HASH_PREFIX}
addonAfter={(
addonAfter={
<Tooltip
title={
hashValue
Expand All @@ -43,7 +44,7 @@ export const FormItemHash = ({ listType, hashValue }) => (
}}
/>
</Tooltip>
)}
}
/>
</Form.Item>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { Button, Form, Input } from 'antd';
import isNil from 'lodash/isNil';
import { isValidAddress } from '@autonolas/frontend-library';

import { useHelpers } from 'common-util/hooks';
import { RegistryForm } from 'common-util/TransactionHelpers/RegistryForm';
import { useHelpers } from '../../hooks';
import { RegistryForm } from '../../TransactionHelpers/RegistryForm';
import { IpfsHashGenerationModal } from '../IpfsHashGenerationModal';
import { DependencyLabel } from '../ListCommon';
import { FormItemHash } from './helpers';
Expand Down
2 changes: 1 addition & 1 deletion apps/autonolas-registry/common-util/List/functions.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TOTAL_VIEW_COUNT } from 'util/constants';
import { TOTAL_VIEW_COUNT } from '../../util/constants';

/**
* @example
Expand Down
16 changes: 9 additions & 7 deletions apps/autonolas-registry/common-util/Login/LoginV2.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ import {
useScreen,
} from '@autonolas/frontend-library';

import { setUserBalance } from 'store/setup';
import { isAddressProhibited } from 'common-util/functions';
import { useHelpers } from 'common-util/hooks';
import { YellowButton } from 'common-util/YellowButton';
import { setUserBalance } from '../../store/setup';
import { isAddressProhibited } from '../functions';
import { useHelpers } from '../hooks';
import { YellowButton } from '../YellowButton';
import { SolanaWallet } from './SolanaWallet';
import { projectId, ethereumClient } from './config';

Expand Down Expand Up @@ -77,8 +77,9 @@ export const LoginV2 = ({
try {
// This is the initial `provider` that is returned when
// using web3Modal to connect. Can be MetaMask or WalletConnect.
const modalProvider = connector?.options?.getProvider?.()
|| (await connector?.getProvider?.());
const modalProvider =
connector?.options?.getProvider?.() ||
(await connector?.getProvider?.());

if (modalProvider) {
// *******************************************************
Expand Down Expand Up @@ -141,7 +142,8 @@ export const LoginV2 = ({
}
}, [isConnectedToWrongNetwork, onSwitchNetwork]);

const hideWrongNetwork = isNil(walletConnectedChain?.id) || walletConnectedChain?.id === chainId;
const hideWrongNetwork =
isNil(walletConnectedChain?.id) || walletConnectedChain?.id === chainId;

return (
<LoginContainer>
Expand Down
1 change: 0 additions & 1 deletion apps/autonolas-registry/common-util/Login/SolanaWallet.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable jest/require-hook */
import {
WalletModalProvider as ReactUIWalletModalProvider,
WalletMultiButton,
Expand Down
6 changes: 3 additions & 3 deletions apps/autonolas-registry/common-util/Login/config.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ import {
} from 'wagmi/chains';
import { SafeConnector } from 'wagmi/connectors/safe';
import { jsonRpcProvider } from 'wagmi/providers/jsonRpc';

import { SOLANA_CHAIN_NAMES, VM_TYPE } from 'util/constants';
import { RPC_URLS } from 'common-util/Contracts';
import { web3 } from '@project-serum/anchor';

import { SOLANA_CHAIN_NAMES, VM_TYPE } from '../../util/constants';
import { RPC_URLS } from '../Contracts';

export const projectId = process.env.NEXT_PUBLIC_WALLET_PROJECT_ID;

export const SUPPORTED_CHAINS = [
Expand Down
3 changes: 2 additions & 1 deletion apps/autonolas-registry/common-util/YellowButton.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Button, ConfigProvider } from 'antd';
import PropTypes from 'prop-types';
import { EXTRA_COLORS } from 'util/constants';

import { EXTRA_COLORS } from '../util/constants';

export const YellowButton = ({ children, ...props }) => (
<ConfigProvider
Expand Down
27 changes: 14 additions & 13 deletions apps/autonolas-registry/common-util/functions/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,10 @@ import {
} from '@autonolas/frontend-library';
import { PublicKey } from '@solana/web3.js';

import { RPC_URLS } from 'common-util/Contracts';
import { SUPPORTED_CHAINS } from 'common-util/Login';
import {
EVM_SUPPORTED_CHAINS,
SVM_SUPPORTED_CHAINS,
} from 'common-util/Login/config';
import { VM_TYPE } from 'util/constants';
import { VM_TYPE } from '../../util/constants';
import { RPC_URLS } from '../Contracts';
import { SUPPORTED_CHAINS } from '../Login';
import { EVM_SUPPORTED_CHAINS, SVM_SUPPORTED_CHAINS } from '../Login/config';
import prohibitedAddresses from '../../data/prohibited-addresses.json';

export const getModalProvider = () => window?.MODAL_PROVIDER;
Expand All @@ -27,9 +24,10 @@ export const getChainId = (chainId = null) => {
if (chainId) return chainId;

// chainId fetched from sessionStorage
const chainIdfromSessionStorage = typeof sessionStorage === 'undefined'
? 1
: Number(sessionStorage.getItem('chainId'));
const chainIdfromSessionStorage =
typeof sessionStorage === 'undefined'
? 1
: Number(sessionStorage.getItem('chainId'));

// if chainId is not supported, throw error
if (!EVM_SUPPORTED_CHAINS.find((e) => e.id === chainIdfromSessionStorage)) {
Expand Down Expand Up @@ -89,7 +87,8 @@ export const getEthersProvider = () => {
return new ethers.providers.Web3Provider(provider, 'any');
};

export const getIsValidChainId = (chainId) => getIsValidChainIdFn(SUPPORTED_CHAINS, chainId);
export const getIsValidChainId = (chainId) =>
getIsValidChainIdFn(SUPPORTED_CHAINS, chainId);

export const getChainIdOrDefaultToMainnet = (chainId) => {
const x = getChainIdOrDefaultToMainnetFn(SUPPORTED_CHAINS, chainId);
Expand All @@ -109,7 +108,8 @@ const isMethodsBuilderInstance = (builderIns, registryAddress) => {
throw new Error('sendTransaction: Input must be an object.');
}

const programId = '_programId' in builderIns ? builderIns?._programId?.toString() : null; // eslint-disable-line no-underscore-dangle
const programId =
'_programId' in builderIns ? builderIns?._programId?.toString() : null; // eslint-disable-line no-underscore-dangle

// Check if the programId is the same as the registry address
const hasProgramId = programId === registryAddress;
Expand Down Expand Up @@ -196,7 +196,8 @@ export const isPageWithSolana = (path) => {
if (!path) return false;
if (!isString(path)) return false;

const checkPath = (e) => path.toLowerCase().includes(e.networkName.toLowerCase());
const checkPath = (e) =>
path.toLowerCase().includes(e.networkName.toLowerCase());
return SVM_SUPPORTED_CHAINS.some(checkPath);
};

Expand Down
4 changes: 2 additions & 2 deletions apps/autonolas-registry/common-util/functions/requests.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { notifyError } from '@autonolas/frontend-library';

import { DEFAULT_SERVICE_CREATION_ETH_TOKEN_ZEROS } from 'util/constants';
import { getServiceOwnerMultisigContract } from 'common-util/Contracts';
import { DEFAULT_SERVICE_CREATION_ETH_TOKEN_ZEROS } from '../../util/constants';
import { getServiceOwnerMultisigContract } from '../Contracts';
import { checkIfGnosisSafe, getEthersProvider } from './index';

const FALLBACK_HANDLER_STORAGE_SLOT = '0x6c9a6c4a39284e37ed1cf53d337577d14212a4870fb976a4366c693b939918d5';
Expand Down
Loading

0 comments on commit 61fab73

Please sign in to comment.