Skip to content
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

General updates and fixes for demo #265

Merged
merged 10 commits into from
Sep 5, 2022
4 changes: 2 additions & 2 deletions richContracts.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"title": "Swapr fees",
"tags": ["DXgov", "Guilds", "permissions"],
"networks": {
"5": "0x7d5Cc70B1d1778B8bEdeaD40283056CDb71E32B2",
"5": "0x885b28d6b93087623483af5e5f7362bd6d8a0a6b",
"1337": "0x0000000000000000000000000000000000000000"
},
"functions": [
Expand All @@ -80,7 +80,7 @@
"name": "swapFee",
"title": "Swap Fee %",
"defaultValue": "",
"description": "Address of contract / receiver in case of asset"
"description": "Fee to be set for pair (10 = 0.1%)"
}
],
"shortDescription": "Sets the swap fee for a given pool on swapr",
Expand Down
8 changes: 4 additions & 4 deletions src/Modules/Guilds/Wrappers/GuildSidebarWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ import { useState } from 'react';
import { WalletModal } from 'components/Web3Modals';
import useTotalLocked from 'hooks/Guilds/ether-swr/guild/useTotalLocked';
import StakeTokensModalWrapper from './StakeTokensModalWrapper';
import { useAccount, useEnsAvatar, useEnsName } from 'wagmi';
import { useAccount } from 'wagmi';
import { isReadOnly } from 'provider/wallets';
import useENSAvatar from 'hooks/Guilds/ens/useENSAvatar';

const GuildSidebarWrapper = () => {
const [isStakeModalOpen, setIsStakeModalOpen] = useState(false);
Expand All @@ -29,8 +30,7 @@ const GuildSidebarWrapper = () => {
const { data: guildToken } = useERC20Info(guildConfig?.token);
const { data: numberOfMembers } = useGuildMemberTotal(guildAddress);
const { address: userAddress, connector } = useAccount();
const { data: ensName } = useEnsName({ address: userAddress });
const { data: ensAvatar } = useEnsAvatar({ addressOrName: userAddress });
const { ensName, imageUrl } = useENSAvatar(userAddress);
const { data: unlockedAt } = useVoterLockTimestamp(guildAddress, userAddress);
const { data: userVotingPower } = useVotingPowerOf({
contractAddress: guildAddress,
Expand Down Expand Up @@ -65,7 +65,7 @@ const GuildSidebarWrapper = () => {
guildToken={guildToken}
isRepGuild={isRepGuild}
userWalletAddress={userAddress}
userEnsAvatar={{ ensName, imageUrl: ensAvatar }}
userEnsAvatar={{ ensName, imageUrl }}
userVotingPower={userVotingPower}
userVotingPowerPercent={votingPowerPercent}
unlockedAt={unlockedAt}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ const ERC20TransferInfoLine: React.FC<ActionViewProps> = ({
if (!decodedCall) return null;

if (decodedCall.callType === SupportedAction.ERC20_TRANSFER) {
const token = tokens.find(token => token.address === decodedCall.to);
const token = tokens.find(
token => token.address?.toLowerCase() === decodedCall.to?.toLowerCase()
);
return {
source: decodedCall.from,
token,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { Flex } from 'components/primitives/Layout';
import { useNetwork } from 'wagmi';
import { useTokenList } from 'hooks/Guilds/tokens/useTokenList';
import { resolveUri } from 'utils/url';
import { shortenAddress } from 'utils';

const SetPermissionsInfoLine: React.FC<ActionViewProps> = ({
decodedCall,
Expand Down Expand Up @@ -36,7 +37,10 @@ const SetPermissionsInfoLine: React.FC<ActionViewProps> = ({
const { tokens } = useTokenList(chain?.id);

let currentToken = useMemo(() => {
return tokens.filter(token => token?.address === parsedData?.asset)[0];
return tokens.filter(
token =>
token?.address?.toLowerCase() === parsedData?.asset?.toLowerCase()
)[0];
}, [tokens, parsedData]);

return (
Expand All @@ -56,7 +60,7 @@ const SetPermissionsInfoLine: React.FC<ActionViewProps> = ({
<Flex margin={'0 0.5rem'}>{currentToken.symbol}</Flex>
</>
) : (
t('anyToken')
shortenAddress(parsedData?.to)
)}
</Segment>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ const validateAssetTransferPermission = (
amount: null,
functionName: null,
};
const allowedAmount = BigNumber.from(amount);
if (activeTab === 0) {
if (!tokenAddress || tokenAddress === ZERO_ADDRESS) {
errors.tokenAddress = t('tokenAddressIsRequired');
Expand Down Expand Up @@ -63,13 +62,8 @@ const validateAssetTransferPermission = (
}

if (activeTab === TABS.FUNCTION_CALL) {
// only validate for function_call. asset transfer set maxAmount by default.
if (!amount || !BigNumber.isBigNumber(amount)) {
errors.amount = t('amountIsRequired');
} else {
if (allowedAmount && allowedAmount?.lte(0)) {
errors.amount = t('amountCannotBeZero');
}
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/components/AddressButton/AddressButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ const AddressButton: React.FC<AddressButtonProps> = ({
</IconHolder>
{isDesktop && (
<AddressText>
{ensName || address ? (
{ensName ? (
ensName
) : address ? (
showFullAddress ? (
address
) : (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ exports[`AddressButton Should render properly with full props 1`] = `
<span
class="c6"
>
0x7970...0928
test.eth
</span>
<div
class="c7 c8"
Expand Down Expand Up @@ -290,7 +290,7 @@ exports[`AddressButton Should render properly with partial props 1`] = `
<span
class="c6"
>
0x7970...0928
test.eth
</span>
</button>

Expand Down
2 changes: 1 addition & 1 deletion src/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const Header = () => {
onClick={() => navigate(`/${chain.network}`)}
size={2}
>
<strong>{t('guilds.guilds')}</strong>
<strong>{t('projectDavi.projectDavi')}</strong>
</ClickableHeading>
<MenuItems>
<NetworkButton />
Expand Down
2 changes: 1 addition & 1 deletion src/components/Header/__snapshots__/Header.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ exports[`Header Should match snapshot 1`] = `
size="2"
>
<strong>
guilds.guilds
projectDavi.projectDavi
</strong>
</h2>
<div
Expand Down
4 changes: 1 addition & 3 deletions src/components/SwaprPicker/SwaprPicker.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,7 @@ describe('SwaprPicker', () => {
const optionOne = await waitFor(() => result.getByText('XDOGE - DON'));
fireEvent.click(optionOne);

const addressButton = await waitFor(() =>
result.getByText('0x003a...6c1b')
);
const addressButton = await waitFor(() => result.getByText('test.eth'));

expect(addressButton).toBeInTheDocument();
});
Expand Down
4 changes: 2 additions & 2 deletions src/components/WalletButton/WalletButton.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import WalletButton from './WalletButton';
import { render } from 'utils/tests';
import { shortenAddress, ZERO_ADDRESS } from 'utils';
import { ZERO_ADDRESS } from 'utils';
import { mockChain } from 'components/Web3Modals/fixtures';
import wagmi from 'wagmi';

Expand Down Expand Up @@ -57,6 +57,6 @@ describe('WalletButton', () => {

const { container, getByText } = render(<WalletButton />);
expect(container).toMatchSnapshot();
expect(getByText(shortenAddress(mockAddress))).toBeInTheDocument();
expect(getByText('test.eth')).toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ exports[`WalletButton Should match snapshot and display connected address 1`] =
<span
class="c6"
>
0x0000...0000
test.eth
</span>
</button>

Expand Down
10 changes: 9 additions & 1 deletion src/configs/goerli/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,20 @@
},
"tokens": [
{
"address": "0x2c212B56cE6c73646f7259EF1daAA52e515e73C6",
"address": "0x2f9343cf18baacf57ac4a4e20188b9b00cfce3f1",
"name": "SWAPR",
"decimals": 18,
"symbol": "SWPR",
"fetchPrice": true,
"logoURI": "https://s2.coinmarketcap.com/static/img/coins/200x200/12368.png"
},
{
"address": "0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6",
"name": "Wrapped ETH",
"decimals": 18,
"symbol": "WETH",
"fetchPrice": true,
"logoURI": "https://assets.coingecko.com/coins/images/2518/thumb/weth.png?1547036627"
}
],
"version": 1
Expand Down
2 changes: 1 addition & 1 deletion src/configs/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const RICH_CONTRACT_DATA_REGISTRY = 'QmfV1ughR6ZDHbt5rB5E7vvcYGCJis5ei4Whh2wFD864jN';
export const RICH_CONTRACT_DATA_REGISTRY = 'QmVnfCaowKgZrFV5vpx7w77GU7sxsPkgUrHeRbZZVpTtWi';
6 changes: 4 additions & 2 deletions src/hooks/Guilds/contracts/useDecodedCall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,11 @@ export const decodeCall = async (
};
}

// Detect using the Guild calls registry.
// Detect using the rich contract data registry.
const matchedRichContractData = contracts?.find(
contract => contract.networks[chainId] === call.to
contract =>
contract.networks[chainId].toLocaleLowerCase() ===
call.to.toLocaleLowerCase()
);
let matchedContract = matchedRichContractData
? getContractInterfaceFromRichContractData(matchedRichContractData)
Expand Down
1 change: 1 addition & 0 deletions src/hooks/Guilds/ens/useENSPublicResolverContract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export function useENSAvatarUri(ensName: string, chainId?: number) {
contractInterface: ensPublicResolver.abi,
functionName: 'text',
args: [convertToNameHash(ensName), 'avatar'],
chainId: supportedChainId,
});
return {
avatarUri: data?.toString(),
Expand Down
8 changes: 3 additions & 5 deletions src/hooks/Guilds/ens/utils.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { isSupportedChainId } from 'components/ActionsBuilder/SupportedActions/UpdateENSContent/utils';
import { MAINNET_ID, GOERLI_ID } from 'utils';
import { MAINNET_ID } from 'utils';

export const isAvailableOnENS = (chainId: number) => {
const validChainId = isSupportedChainId(chainId);
const ensNetworks = [MAINNET_ID, GOERLI_ID];
return ensNetworks.includes(validChainId);
const ensNetworks = [MAINNET_ID];
return ensNetworks.includes(chainId);
};
1 change: 1 addition & 0 deletions src/hooks/Guilds/ether-swr/guild/useSnapshotId.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type UseSnapshotIdHook = (args: UseSnapshotIdProps) => SWRResponse<BigNumber>;

const useSnapshotId: UseSnapshotIdHook = ({ contractAddress, proposalId }) => {
const { isSnapshotGuild } = useGuildImplementationTypeConfig(contractAddress);

return useEtherSWR(
isSnapshotGuild && proposalId && contractAddress
? [contractAddress, 'getProposalSnapshotId', proposalId]
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/Guilds/useSwaprFetchPairs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const useSwaprFetchPairs = async (
): Promise<[SwaprFetchPairsInterface[], string]> => {
const networkApiPair = {
1: 'https://api.thegraph.com/subgraphs/name/dxgraphs/swapr-mainnet-v2', //mainnet
5: 'https://api.thegraph.com/subgraphs/name/dxgraphs/swapr-xdai-v2', // goerly
5: 'https://api.thegraph.com/subgraphs/name/dxgraphs/swapr-goerli', // goerly
100: 'https://api.thegraph.com/subgraphs/name/dxgraphs/swapr-xdai-v2', // gnosis
1337: 'https://api.thegraph.com/subgraphs/name/dxgraphs/swapr-xdai-v2', //localhost
42161:
Expand Down
6 changes: 4 additions & 2 deletions src/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
"guild": "Guild",
"guilds": "Guilds"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can remove this key

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can keep these here for now since we may still use elements in future using the language of guilds

},
"projectDavi": {
"projectDavi": "Project-DAVI"
},
"proposals": "Proposals",
"proposals_zero": "No proposals",
"proposals_one": "{{count}} proposal",
Expand Down Expand Up @@ -57,9 +60,8 @@
"mint": "Mint",
"toAddress": "To Address",
"anyAddress": "Any Address",
"anyToken": "any token",
"maxValue": "Max Value",
"unkownToken": "Unknown token",
"unknownToken": "Unknown token",
"functionName": "Function Name",
"functionSignature": "Function Signature",
"assetTransfer": "Asset Transfer",
Expand Down