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

(launch, govern) feat: support mode network #120

Merged
merged 2 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ NEXT_PUBLIC_WALLET_PROJECT_ID=__URL__
NEXT_PUBLIC_SOLANA_MAINNET_BETA_URL=__value__
NEXT_PUBLIC_AUTONOLAS_SUB_GRAPH_URL=__URL__
NEXT_PUBLIC_OPTIMISM_URL=__URL__
NEXT_PUBLIC_MODE_URL=__URL__
NEXT_PUBLIC_IS_CONNECTED_TO_LOCAL=__TRUE_OR_FALSE__

# testnets
NEXT_PUBLIC_MAINNET_TEST_RPC=__URL__
NEXT_PUBLIC_GNOSIS_TEST_RPC=__URL__
NEXT_PUBLIC_POLYGON_TEST_RPC=__URL__
NEXT_PUBLIC_MODE_TEST_RPC=__URL__
NEXT_PUBLIC_IS_CONNECTED_TO_TEST_NET=

# registry
Expand Down
8 changes: 5 additions & 3 deletions apps/govern/common-util/config/wagmi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,26 @@ import {
mainnet,
optimism,
polygon,
mode,
} from 'wagmi/chains';
import { coinbaseWallet, injected, safe, walletConnect } from 'wagmi/connectors';

import { RPC_URLS } from 'common-util/constants/rpcs';

import { virtualGnosis, virtualMainnet, virtualPolygon } from '../../tenderly.config';
import { virtualGnosis, virtualMainnet, virtualPolygon, virtualMode } from '../../tenderly.config';
import { RPC_URLS } from 'libs/util-constants/src';

const mainnetChain =
process.env.NEXT_PUBLIC_IS_CONNECTED_TO_TEST_NET === 'true' ? virtualMainnet : mainnet;
const gnosisChain =
process.env.NEXT_PUBLIC_IS_CONNECTED_TO_TEST_NET === 'true' ? virtualGnosis : gnosis;
const polygonChain =
process.env.NEXT_PUBLIC_IS_CONNECTED_TO_TEST_NET === 'true' ? virtualPolygon : polygon;
const modeChain = process.env.NEXT_PUBLIC_IS_CONNECTED_TO_TEST_NET === 'true' ? virtualMode : mode;

export const SUPPORTED_CHAINS: [Chain, ...Chain[]] = [
mainnetChain,
gnosisChain,
polygonChain,
modeChain,
optimism,
base,
arbitrum,
Expand Down
19 changes: 0 additions & 19 deletions apps/govern/common-util/constants/rpcs.ts

This file was deleted.

2 changes: 1 addition & 1 deletion apps/govern/common-util/functions/frontend-library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
} from '@autonolas/frontend-library';

import { SUPPORTED_CHAINS } from 'common-util/config/wagmi';
import { RPC_URLS } from 'common-util/constants/rpcs';
import { RPC_URLS } from 'libs/util-constants/src';

export const getProvider = () => {
const provider = getProviderFn(SUPPORTED_CHAINS, RPC_URLS);
Expand Down
2 changes: 1 addition & 1 deletion apps/govern/common-util/functions/requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
import { getEstimatedGasLimit, sendTransaction } from 'libs/util-functions/src';

import { SUPPORTED_CHAINS, wagmiConfig } from 'common-util/config/wagmi';
import { RPC_URLS } from 'common-util/constants/rpcs';

import { getAddressFromBytes32 } from './addresses';
import { getUnixNextWeekStartTimestamp } from './time';
Expand All @@ -24,6 +23,7 @@ import {
getVeOlasContract,
getVoteWeightingContract,
} from './web3';
import { RPC_URLS } from 'libs/util-constants/src';

type VoteForNomineeWeightsParams = {
account: Address | undefined;
Expand Down
2 changes: 1 addition & 1 deletion apps/govern/components/Contracts/EditVotes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const getColumns = (
value={allocations[index].weight}
status={isError ? 'error' : undefined}
onChange={(value) => {
if (value) {
if (typeof value === 'number') {
Tanya-atatakai marked this conversation as resolved.
Show resolved Hide resolved
setAllocation(value, index);
}
}}
Expand Down
3 changes: 2 additions & 1 deletion apps/govern/jest.setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Object.defineProperty(window, 'matchMedia', {
})),
});

const { mainnet, optimism, gnosis, polygon, base, arbitrum, celo } = require('viem/chains');
const { mainnet, optimism, gnosis, polygon, base, arbitrum, celo, mode } = require('viem/chains');

jest.mock('wagmi/chains', () => ({
mainnet,
Expand All @@ -31,4 +31,5 @@ jest.mock('wagmi/chains', () => ({
base,
arbitrum,
celo,
mode,
}));
52 changes: 7 additions & 45 deletions apps/govern/tenderly.config.ts
Original file line number Diff line number Diff line change
@@ -1,46 +1,8 @@
import { defineChain } from 'viem';
import {
virtualGnosis,
virtualMainnet,
virtualPolygon,
virtualMode,
} from 'libs/util-constants/src';

export const virtualMainnet = defineChain({
id: 1,
name: 'Virtual Mainnet',
nativeCurrency: { name: 'vETH', symbol: 'vETH', decimals: 18 },
rpcUrls: {
default: { http: [`${process.env.NEXT_PUBLIC_MAINNET_TEST_RPC}`] },
},
blockExplorers: {
default: {
name: 'Tenderly Explorer',
url: '',
},
},
});

export const virtualGnosis = defineChain({
id: 100,
name: 'Virtual Gnosis Chain',
nativeCurrency: { name: 'vXDAI', symbol: 'vXDAI', decimals: 18 },
rpcUrls: {
default: { http: [`${process.env.NEXT_PUBLIC_GNOSIS_TEST_RPC}`] },
},
blockExplorers: {
default: {
name: 'Tenderly Explorer',
url: '',
},
},
});

export const virtualPolygon = defineChain({
id: 137,
name: 'Virtual Polygon',
nativeCurrency: { name: 'vMATIC', symbol: 'vMATIC', decimals: 18 },
rpcUrls: {
default: { http: [`${process.env.NEXT_PUBLIC_POLYGON_TEST_RPC}`] },
},
blockExplorers: {
default: {
name: 'Tenderly Explorer',
url: '',
},
},
});
export { virtualGnosis, virtualMainnet, virtualPolygon, virtualMode };
10 changes: 6 additions & 4 deletions apps/launch/common-util/config/wagmi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,26 @@ import {
mainnet,
optimism,
polygon,
mode,
} from 'wagmi/chains';
import { coinbaseWallet, injected, safe, walletConnect } from 'wagmi/connectors';

import { LAUNCH_RPC_URLS } from 'common-util/constants/rpcs';

import { virtualGnosis, virtualMainnet, virtualPolygon } from '../../tenderly.config';
import { virtualGnosis, virtualMainnet, virtualPolygon, virtualMode } from '../../tenderly.config';
import { RPC_URLS } from 'libs/util-constants/src';

const mainnetChain =
process.env.NEXT_PUBLIC_IS_CONNECTED_TO_TEST_NET === 'true' ? virtualMainnet : mainnet;
const gnosisChain =
process.env.NEXT_PUBLIC_IS_CONNECTED_TO_TEST_NET === 'true' ? virtualGnosis : gnosis;
const polygonChain =
process.env.NEXT_PUBLIC_IS_CONNECTED_TO_TEST_NET === 'true' ? virtualPolygon : polygon;
const modeChain = process.env.NEXT_PUBLIC_IS_CONNECTED_TO_TEST_NET === 'true' ? virtualMode : mode;

export const SUPPORTED_CHAINS: [Chain, ...Chain[]] = [
mainnetChain,
gnosisChain,
polygonChain,
modeChain,
optimism,
base,
arbitrum,
Expand Down Expand Up @@ -56,7 +58,7 @@ export const wagmiConfig = createConfig({
}),
],
transports: SUPPORTED_CHAINS.reduce(
(acc, chain) => Object.assign(acc, { [chain.id]: http(LAUNCH_RPC_URLS[chain.id]) }),
(acc, chain) => Object.assign(acc, { [chain.id]: http(RPC_URLS[chain.id]) }),
{},
),
});
7 changes: 0 additions & 7 deletions apps/launch/common-util/constants/rpcs.ts

This file was deleted.

16 changes: 11 additions & 5 deletions apps/launch/common-util/constants/stakingContract.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Address } from 'viem';
import { arbitrum, base, celo, gnosis, mainnet, optimism, polygon } from 'viem/chains';
import { arbitrum, base, celo, gnosis, mainnet, optimism, polygon, mode } from 'viem/chains';

export const CONTRACT_TEMPLATES = [
{
Expand Down Expand Up @@ -37,20 +37,22 @@ export type ChainId =
| typeof polygon.id
| typeof base.id
| typeof arbitrum.id
| typeof celo.id;
| typeof celo.id
| typeof mode.id;

type Addresses = {
[key in ChainId]: Address;
};

export const IMPLEMENTATION_ADDRESSES: Addresses = {
export const STAKING_TOKEN_ADDRESSES: Addresses = {
[mainnet.id]: '0x0Dc23eEf3bC64CF3cbd8f9329B57AE4C4f28d5d2',
[optimism.id]: '0x63C2c53c09dE534Dd3bc0b7771bf976070936bAC',
[gnosis.id]: '0xEa00be6690a871827fAfD705440D20dd75e67AB1',
[polygon.id]: '0x4aba1Cf7a39a51D75cBa789f5f21cf4882162519',
[base.id]: '0xEB5638eefE289691EcE01943f768EDBF96258a80',
[arbitrum.id]: '0x04b0007b2aFb398015B76e5f22993a1fddF83644',
[celo.id]: '0xe1E1B286EbE95b39F785d8069f2248ae9C41b7a9',
[mode.id]: '0xE49CB081e8d96920C38aA7AB90cb0294ab4Bc8EA',
Tanya-atatakai marked this conversation as resolved.
Show resolved Hide resolved
};

export const SERVICE_REGISTRY_ADDRESSES: Addresses = {
Expand All @@ -61,6 +63,7 @@ export const SERVICE_REGISTRY_ADDRESSES: Addresses = {
[base.id]: '0x3C1fF68f5aa342D296d4DEe4Bb1cACCA912D95fE',
[arbitrum.id]: '0xE3607b00E75f6405248323A9417ff6b39B244b50',
[celo.id]: '0xE3607b00E75f6405248323A9417ff6b39B244b50',
[mode.id]: '0x3C1fF68f5aa342D296d4DEe4Bb1cACCA912D95fE',
};

export const SERVICE_REGISTRY_TOKEN_UTILITY_ADDRESSES: Addresses = {
Expand All @@ -71,20 +74,22 @@ export const SERVICE_REGISTRY_TOKEN_UTILITY_ADDRESSES: Addresses = {
[base.id]: '0x34C895f302D0b5cf52ec0Edd3945321EB0f83dd5',
[arbitrum.id]: '0x3d77596beb0f130a4415df3D2D8232B3d3D31e44',
[celo.id]: '0x3d77596beb0f130a4415df3D2D8232B3d3D31e44',
[mode.id]: '0x34C895f302D0b5cf52ec0Edd3945321EB0f83dd5',
};

export const STAKING_TOKEN_ADDRESSES: Addresses = {
export const OLAS_ADDRESSES: Addresses = {
[mainnet.id]: '0x0001A500A6B18995B03f44bb040A5fFc28E45CB0',
[optimism.id]: '0xFC2E6e6BCbd49ccf3A5f029c79984372DcBFE527',
[gnosis.id]: '0xcE11e14225575945b8E6Dc0D4F2dD4C570f79d9f',
[polygon.id]: '0xFEF5d947472e72Efbb2E388c730B7428406F2F95',
[base.id]: '0x54330d28ca3357F294334BDC454a032e7f353416',
[arbitrum.id]: '0x3d77596beb0f130a4415df3D2D8232B3d3D31e44',
[celo.id]: '0xaCFfAe8e57Ec6E394Eb1b41939A8CF7892DbDc51',
[mode.id]: '0xcfD1D50ce23C46D3Cf6407487B2F8934e96DC8f9',
Tanya-atatakai marked this conversation as resolved.
Show resolved Hide resolved
};

export const isSupportedChainId = (chainId: number): chainId is ChainId => {
return chainId in IMPLEMENTATION_ADDRESSES;
return chainId in STAKING_TOKEN_ADDRESSES;
};

type BlockNumbers = {
Expand All @@ -99,4 +104,5 @@ export const blockNumbers: BlockNumbers = {
[base.id]: 17310019,
[arbitrum.id]: 233883523,
[celo.id]: 26748574,
[mode.id]: 14444647,
};
4 changes: 2 additions & 2 deletions apps/launch/common-util/functions/frontend-library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import {
} from '@autonolas/frontend-library';

import { SUPPORTED_CHAINS } from 'common-util/config/wagmi';
import { LAUNCH_RPC_URLS } from 'common-util/constants/rpcs';
import { RPC_URLS } from 'libs/util-constants/src';

export const getProvider = () => {
const provider = getProviderFn(SUPPORTED_CHAINS, LAUNCH_RPC_URLS);
const provider = getProviderFn(SUPPORTED_CHAINS, RPC_URLS);
// not connected, return fallback URL
if (typeof provider === 'string') return provider;
// coinbase injected multi wallet provider
Expand Down
4 changes: 2 additions & 2 deletions apps/launch/common-util/functions/stakingContract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
ChainId,
SERVICE_REGISTRY_ADDRESSES,
SERVICE_REGISTRY_TOKEN_UTILITY_ADDRESSES,
STAKING_TOKEN_ADDRESSES,
OLAS_ADDRESSES,
} from 'common-util/constants/stakingContract';

type StakingContractValues = {
Expand Down Expand Up @@ -65,7 +65,7 @@ export const getStakingContractInitPayload = ({

const contractInterface = new ethers.Interface(STAKING_TOKEN.abi);
const serviceRegistryTokenUtilityAddress = SERVICE_REGISTRY_TOKEN_UTILITY_ADDRESSES[chainId];
const tokenAddress = STAKING_TOKEN_ADDRESSES[chainId];
const tokenAddress = OLAS_ADDRESSES[chainId];

const encodedPayload = contractInterface.encodeFunctionData('initialize', [
stakingParams,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ describe('<CreateStakingContract />', () => {

await clickCreateContractButton();
expect(
screen.getByText('Minimum service staking deposit, OLAS must be at least 1 and at most 1000'),
screen.getByText(/Minimum service staking deposit, OLAS must be at least 1 and at most 1000/),
).toBeInTheDocument();
});

Expand Down
4 changes: 2 additions & 2 deletions apps/launch/components/MyStakingContracts/Create/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import {
CONTRACT_DEFAULT_VALUES,
CONTRACT_TEMPLATES,
IMPLEMENTATION_ADDRESSES,
STAKING_TOKEN_ADDRESSES,
isSupportedChainId,
} from 'common-util/constants/stakingContract';
import { URL } from 'common-util/constants/urls';
Expand Down Expand Up @@ -147,7 +147,7 @@
try {
const metadataHash = await getIpfsHash({ name: contractName, description });

const implementation = IMPLEMENTATION_ADDRESSES[chain.id];
const implementation = STAKING_TOKEN_ADDRESSES[chain.id];
const initPayload = getStakingContractInitPayload({
metadataHash,
maxNumServices,
Expand Down Expand Up @@ -189,7 +189,7 @@
router.push(`/${networkName}/${URL.myStakingContracts}`);
}
} catch (error) {
console.log(error);

Check warning on line 192 in apps/launch/components/MyStakingContracts/Create/index.tsx

View workflow job for this annotation

GitHub Actions / build

Unexpected console statement

const { message, transactionHash } = getErrorInfo(Feature.CREATE, error as Error);
setError({ message, transactionHash });
Expand Down
4 changes: 2 additions & 2 deletions apps/launch/components/MyStakingContracts/Details/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import styled from 'styled-components';
import { EXPLORER_URLS, GOVERN_URL, UNICODE_SYMBOLS } from 'libs/util-constants/src';
import { truncateAddress } from 'libs/util-functions/src';

import { ChainId, IMPLEMENTATION_ADDRESSES } from 'common-util/constants/stakingContract';
import { ChainId, STAKING_TOKEN_ADDRESSES } from 'common-util/constants/stakingContract';
import { URL } from 'common-util/constants/urls';
import { useAppSelector } from 'store/index';
import { MyStakingContract } from 'types/index';
Expand Down Expand Up @@ -128,7 +128,7 @@ const Template: FC<{ template: string }> = ({ template }) => {
{networkId ? (
<a
href={`${EXPLORER_URLS[networkId]}/address/${
IMPLEMENTATION_ADDRESSES[networkId as ChainId]
STAKING_TOKEN_ADDRESSES[networkId as ChainId]
}`}
target="_blank"
rel="noreferrer"
Expand Down
4 changes: 2 additions & 2 deletions apps/launch/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ const { pathsToModuleNameMapper } = require('ts-jest');
const { compilerOptions } = require('../../tsconfig.base.json');

module.exports = {
displayName: 'govern',
displayName: 'launch',
preset: '../../jest.preset.js',
testEnvironment: 'jsdom',

testTimeout: 10000,
moduleNameMapper: {
...pathsToModuleNameMapper(compilerOptions.paths, { prefix: resolve(__dirname, '../..') }),
'^util/(.*)$': '<rootDir>/util/$1',
Expand Down
3 changes: 2 additions & 1 deletion apps/launch/jest.setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Object.defineProperty(window, 'matchMedia', {
})),
});

const { mainnet, optimism, gnosis, polygon, base, arbitrum, celo } = require('viem/chains');
const { mainnet, optimism, gnosis, polygon, base, arbitrum, celo, mode } = require('viem/chains');

jest.mock('wagmi/chains', () => ({
mainnet,
Expand All @@ -31,6 +31,7 @@ jest.mock('wagmi/chains', () => ({
base,
arbitrum,
celo,
mode,
}));

jest.mock('common-util/config/wagmi', () => ({
Expand Down
Loading
Loading