Skip to content

Commit

Permalink
Merge branch 'develop' into fix/proposal-members-list
Browse files Browse the repository at this point in the history
  • Loading branch information
sepehr2github committed May 22, 2024
2 parents dcffc8a + a62dac8 commit c7848c9
Show file tree
Hide file tree
Showing 20 changed files with 157 additions and 139 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@
"dependencies": {
"@apollo/client": "^3.5.8",
"@aragon/ods": "^1.0.20",
"@aragon/sdk-client": "^1.22.1",
"@aragon/sdk-client-common": "^1.14.1",
"@aragon/osx-commons-configs": "^0.4.0",
"@aragon/sdk-client": "^1.23.5",
"@aragon/sdk-client-common": "^1.15.3",
"@playwright/test": "^1.42.1",
"@radix-ui/react-accordion": "^1.1.2",
"@radix-ui/react-dialog": "^1.0.4",
Expand Down
6 changes: 2 additions & 4 deletions src/containers/createDaoDialog/utils/createDaoUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ import {
PluginSetupProcessor__factory,
} from '@aragon/osx-ethers';
import {parseUnits} from 'ethers/lib/utils';
import {
PluginInstallItem,
SupportedNetwork as SdkSupportedNetworks,
} from '@aragon/sdk-client-common';
import {PluginInstallItem} from '@aragon/sdk-client-common';
import {SupportedNetworks as SdkSupportedNetworks} from '@aragon/osx-commons-configs';
import {
GaslessPluginVotingSettings,
GaslessVotingClient,
Expand Down
17 changes: 9 additions & 8 deletions src/containers/settings/versionInfoCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import {useTranslation} from 'react-i18next';
import {Link} from '@aragon/ods-old';
import {IconType} from '@aragon/ods';
import {
LIVE_CONTRACTS,
SupportedNetworksArray,
SupportedVersion,
} from '@aragon/sdk-client-common';
SupportedNetworks,
SupportedVersions,
getNetworkDeployments,
} from '@aragon/osx-commons-configs';

import {useNetwork} from 'context/network';
import {AppVersion, CHAIN_METADATA} from 'utils/constants';
Expand Down Expand Up @@ -35,14 +35,15 @@ export const VersionInfoCard: React.FC<{

let OSxAddress = '';
const translatedNetwork = translateToNetworkishName(network);
const currentVersion = `v${versions?.join('.')}` as SupportedVersions;
if (
translatedNetwork !== 'unsupported' &&
SupportedNetworksArray.includes(translatedNetwork)
Object.values(SupportedNetworks).includes(translatedNetwork) &&
Object.values(SupportedVersions).includes(currentVersion)
) {
OSxAddress =
LIVE_CONTRACTS[versions?.join('.') as SupportedVersion]?.[
translatedNetwork
]?.daoFactoryAddress;
getNetworkDeployments(translatedNetwork)[currentVersion]?.DAOFactory
.address ?? '';
}

let pluginName = '';
Expand Down
21 changes: 9 additions & 12 deletions src/context/update.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@ import {
TokenVotingClient,
TokenVotingPluginPrepareUpdateParams,
} from '@aragon/sdk-client';
import {
ApplyUpdateParams,
SupportedVersion,
VersionTag,
} from '@aragon/sdk-client-common';
import {ApplyUpdateParams, VersionTag} from '@aragon/sdk-client-common';
import {SupportedVersions} from '@aragon/osx-commons-configs';
import React, {
createContext,
ReactElement,
Expand Down Expand Up @@ -173,27 +170,27 @@ const UpdateProvider: React.FC<{children: ReactElement}> = ({children}) => {
if (versions) {
const OSXVersions = new Map();

Object.keys(SupportedVersion).forEach(key => {
Object.keys(SupportedVersions).forEach(key => {
if (
compareVersions(
SupportedVersion[key as keyof typeof SupportedVersion],
SupportedVersions[key as keyof typeof SupportedVersions],
versions.join('.')
) === 1
) {
OSXVersions.set(
SupportedVersion[key as keyof typeof SupportedVersion],
SupportedVersions[key as keyof typeof SupportedVersions],
{
version: SupportedVersion[
key as keyof typeof SupportedVersion
version: SupportedVersions[
key as keyof typeof SupportedVersions
] as string,
...(key === 'LATEST' && {isLatest: true}),
} as OSX
);

if (key === 'LATEST') {
setValue('osSelectedVersion', {
version: SupportedVersion[
key as keyof typeof SupportedVersion
version: SupportedVersions[
key as keyof typeof SupportedVersions
] as string,
});
}
Expand Down
15 changes: 7 additions & 8 deletions src/hooks/useClient.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import {Client, Context as SdkContext, ContextParams} from '@aragon/sdk-client';
import {
LIVE_CONTRACTS,
SupportedVersion,
SupportedNetworksArray,
} from '@aragon/sdk-client-common';
getLatestNetworkDeployment,
SupportedNetworks as SdkSupportedNetworks,
} from '@aragon/osx-commons-configs';

import {useNetwork} from 'context/network';
import React, {
Expand Down Expand Up @@ -55,7 +54,7 @@ export const UseClientProvider: React.FC<{children: ReactNode}> = ({
// when network not supported by the SDK, don't set network
if (
translatedNetwork === 'unsupported' ||
!SupportedNetworksArray.includes(translatedNetwork)
!Object.values(SdkSupportedNetworks).includes(translatedNetwork)
) {
return;
}
Expand All @@ -66,11 +65,11 @@ export const UseClientProvider: React.FC<{children: ReactNode}> = ({
headers: {'X-API-KEY': import.meta.env.VITE_GATEWAY_IPFS_API_KEY},
},
];
const daoFactoryAddress =
getLatestNetworkDeployment(translatedNetwork)?.DAOFactory.address ?? '';

const contextParams: ContextParams = {
daoFactoryAddress:
LIVE_CONTRACTS[SupportedVersion.LATEST][translatedNetwork]
.daoFactoryAddress,
DAOFactory: daoFactoryAddress,
network: translatedNetwork,
signer: signer ?? undefined,
web3Providers: aragonGateway.buildRpcUrl(network)!,
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/useUpdateExists.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {SupportedVersion} from '@aragon/sdk-client-common';
import {SupportedVersions} from '@aragon/osx-commons-configs';

import {usePluginVersions} from 'services/aragon-sdk/queries/use-plugin-versions';
import {useProtocolVersion} from 'services/aragon-sdk/queries/use-protocol-version';
Expand All @@ -17,7 +17,7 @@ export const useUpdateExists = (): boolean => {
const {data: installedProtocol} = useProtocolVersion(daoAddress);

// check whether protocol update exists
const latestProtocolVersion = SupportedVersion.LATEST as string;
const latestProtocolVersion = SupportedVersions.V1_3_0 as string;
const installedProtocolVersion = installedProtocol?.join('.');

const protocolUpdateExists = !!(
Expand Down
9 changes: 3 additions & 6 deletions src/pages/explore.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
import {
SupportedNetworksArray,
SupportedNetwork,
} from '@aragon/sdk-client-common';
import React, {useEffect} from 'react';
import 'react-responsive-carousel/lib/styles/carousel.min.css';
import styled from 'styled-components';
Expand All @@ -12,6 +8,7 @@ import {DaoExplorer} from 'containers/daoExplorer';
import Hero from 'containers/hero';
import {useNetwork} from 'context/network';
import {translateToNetworkishName} from 'utils/library';
import {SupportedNetworks} from '@aragon/osx-commons-configs';

export const Explore: React.FC = () => {
const {network, setNetwork} = useNetwork();
Expand All @@ -20,10 +17,10 @@ export const Explore: React.FC = () => {
//FIXME: temporarily when network not supported by the SDK, default to ethereum
const translatedNetwork = translateToNetworkishName(
network
) as SupportedNetwork;
) as SupportedNetworks;

// when network not supported by the SDK, don't set network
if (!SupportedNetworksArray.includes(translatedNetwork)) {
if (!Object.values(SupportedNetworks).includes(translatedNetwork)) {
console.warn('Unsupported network, defaulting to ethereum');
setNetwork('ethereum');
}
Expand Down
25 changes: 12 additions & 13 deletions src/services/actionEncoder/actionEncoderService.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
import {
DaoAction,
LIVE_CONTRACTS,
SupportedNetworksArray,
SupportedVersion,
TokenType,
hexToBytes,
} from '@aragon/sdk-client-common';
import {DaoAction, TokenType, hexToBytes} from '@aragon/sdk-client-common';
import {IEncodeActionParams} from './actionEncoderService.api';
import {ethers} from 'ethers';
import {isNativeToken} from 'utils/tokens';
Expand All @@ -30,6 +23,11 @@ import {
isGaslessVotingSettings,
isMultisigVotingSettings,
} from 'services/aragon-sdk/queries/use-voting-settings';
import {
SupportedNetworks,
getNetworkDeployments,
SupportedVersions,
} from '@aragon/osx-commons-configs';

class ActionEncoderService {
encodeActions = async (
Expand Down Expand Up @@ -206,18 +204,19 @@ class ActionEncoderService {
case 'os_update': {
if (
translatedNetwork !== 'unsupported' &&
SupportedNetworksArray.includes(translatedNetwork) &&
Object.values(SupportedNetworks).includes(translatedNetwork) &&
daoAddress &&
versions
) {
const daoFactoryAddress =
getNetworkDeployments(translatedNetwork)[
action.inputs.version as SupportedVersions
]?.DAOFactory.address;
actionPromises.push(
Promise.resolve(
client.encoding.daoUpdateAction(daoAddress, {
previousVersion: versions as [number, number, number],
daoFactoryAddress:
LIVE_CONTRACTS[action.inputs.version as SupportedVersion][
translatedNetwork
].daoFactoryAddress,
daoFactoryAddress,
})
)
);
Expand Down
5 changes: 4 additions & 1 deletion src/services/aragon-sdk/queryHelpers/proposal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,11 @@ export const QueryMultisigProposal = gql`
executed
approvalReached
isSignaling
approvers(first: 1000) {
approvals(first: 1000) {
id
approver {
address
}
}
}
}
Expand Down
7 changes: 5 additions & 2 deletions src/services/aragon-sdk/queryHelpers/proposals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,17 @@ export const QueryMultisigProposals = gql`
executed
approvalReached
isSignaling
approvals
approvalCount
startDate
endDate
executionDate
executionBlockNumber
creationBlockNumber
approvers {
approvals {
id
approver {
address
}
}
actions {
to
Expand Down
4 changes: 1 addition & 3 deletions src/services/aragon-sdk/selectors/proposal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -488,9 +488,7 @@ export function toMultisigProposal(
}),
status: computeMultisigProposalStatus(proposal),
// eslint-disable-next-line @typescript-eslint/no-explicit-any
approvals: proposal.approvers.map((approver: any) =>
approver.id.slice(0, 42)
),
approvals: proposal.approvals.map(approval => approval.approver.address),
};
}

Expand Down
2 changes: 1 addition & 1 deletion src/services/aragon-sdk/selectors/proposals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export function toMultisigProposalListItem(
title: metadata.title,
summary: metadata.summary,
},
approvals: proposal.approvers.map(approver => approver.id.slice(0, 42)),
approvals: proposal.approvals.map(approval => approval.approver.address),
actions: proposal.actions.map((action: SubgraphAction): DaoAction => {
return {
data: hexToBytes(action.data),
Expand Down
3 changes: 2 additions & 1 deletion src/services/transactions/transactionsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
import {ITransaction} from './domain/transaction';
import {decodeProposalId, hexToBytes} from '@aragon/sdk-client-common';
import {isMultisigClient, isTokenVotingClient} from 'hooks/usePluginClient';
import {ContractNames} from '@aragon/osx-commons-configs';

class TransactionsService {
buildCreateDaoTransaction = async (
Expand All @@ -36,7 +37,7 @@ class TransactionsService {
} = params;

const signer = client.web3.getConnectedSigner();
const daoFactoryAddress = client.web3.getAddress('daoFactoryAddress');
const daoFactoryAddress = client.web3.getAddress(ContractNames.DAO_FACTORY);

const daoFactoryInstance = DAOFactory__factory.connect(
daoFactoryAddress,
Expand Down
13 changes: 5 additions & 8 deletions src/utils/aragonGateway.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
import {
LIVE_CONTRACTS,
SupportedVersion,
SupportedNetwork as SdkSupportedNetworks,
} from '@aragon/sdk-client-common';
import {JsonRpcProvider, Networkish} from '@ethersproject/providers';
import {
CHAIN_METADATA,
Expand All @@ -11,6 +6,10 @@ import {
getSupportedNetworkByChainId,
} from './constants';
import {translateToNetworkishName} from './library';
import {
SupportedNetworks as SdkSupportedNetworks,
getLatestNetworkDeployment,
} from '@aragon/osx-commons-configs';

class AragonGateway {
private rpcVersion = '1.0';
Expand Down Expand Up @@ -38,11 +37,10 @@ class AragonGateway {

if (NETWORKS_WITH_CUSTOM_REGISTRY.includes(network)) {
options.ensAddress =
LIVE_CONTRACTS[SupportedVersion.LATEST][sdkNetwork]?.ensRegistryAddress;
getLatestNetworkDeployment(sdkNetwork)?.ENSRegistry?.address;
}

const rpcUrl = this.buildRpcUrl(network)!;

return new JsonRpcProvider(rpcUrl, options);
};

Expand All @@ -58,7 +56,6 @@ class AragonGateway {
const {gatewayNetwork} = CHAIN_METADATA[network];
const gatewayKey = import.meta.env.VITE_GATEWAY_RPC_API_KEY;
const rpcUrl = `${this.baseUrl}/v${this.rpcVersion}/rpc/${gatewayNetwork}/${gatewayKey}`;

return rpcUrl;
};

Expand Down
10 changes: 5 additions & 5 deletions src/utils/constants/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ export const pinataFileAPI = 'https://api.pinata.cloud/pinning/pinFileToIPFS';

export const SUBGRAPH_API_URL: SubgraphNetworkUrl = {
arbitrum:
'https://subgraph.satsuma-prod.com/qHR2wGfc5RLi6/aragon/osx-arbitrum/version/v1.4.0/api',
'https://subgraph.satsuma-prod.com/qHR2wGfc5RLi6/aragon/osx-arbitrum/version/v1.4.2/api',

base: 'https://subgraph.satsuma-prod.com/qHR2wGfc5RLi6/aragon/osx-baseMainnet/version/v1.4.0/api',
base: 'https://subgraph.satsuma-prod.com/qHR2wGfc5RLi6/aragon/osx-baseMainnet/version/v1.4.2/api',

ethereum:
'https://subgraph.satsuma-prod.com/qHR2wGfc5RLi6/aragon/osx-mainnet/version/v1.4.0/api',
'https://subgraph.satsuma-prod.com/qHR2wGfc5RLi6/aragon/osx-mainnet/version/v1.4.2/api',

polygon:
'https://subgraph.satsuma-prod.com/qHR2wGfc5RLi6/aragon/osx-polygon/version/v1.4.0/api',
'https://subgraph.satsuma-prod.com/qHR2wGfc5RLi6/aragon/osx-polygon/version/v1.4.2/api',
sepolia:
'https://subgraph.satsuma-prod.com/qHR2wGfc5RLi6/aragon/osx-sepolia/version/v1.4.0/api',
'https://subgraph.satsuma-prod.com/qHR2wGfc5RLi6/aragon/osx-sepolia/version/v1.4.2/api',
unsupported: undefined,
};

Expand Down
2 changes: 1 addition & 1 deletion src/utils/constants/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export const CHAIN_METADATA: Record<SupportedNetworks, ChainData> = {
id: 137,
name: i18n.t('explore.modal.filterDAOs.label.polygon'),
domain: 'L2 Blockchain',
logo: 'https://assets.coingecko.com/coins/images/4713/large/matic-token-icon.png?1624446912',
logo: 'https://assets.coingecko.com/coins/images/4713/large/polygon.png',
explorer: 'https://polygonscan.com/',
explorerName: 'Polygonscan',
isTestnet: false,
Expand Down
Loading

0 comments on commit c7848c9

Please sign in to comment.