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 1 commit
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.

10 changes: 8 additions & 2 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,7 +37,8 @@ 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;
Expand All @@ -51,6 +52,7 @@ export const IMPLEMENTATION_ADDRESSES: Addresses = {
[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,6 +74,7 @@ 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 = {
Expand All @@ -81,6 +85,7 @@ export const STAKING_TOKEN_ADDRESSES: Addresses = {
[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 => {
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
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
9 changes: 7 additions & 2 deletions apps/launch/tenderly.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import { virtualGnosis, virtualMainnet, virtualPolygon } from 'libs/util-constants/src';
import {
virtualGnosis,
virtualMainnet,
virtualPolygon,
virtualMode,
} from 'libs/util-constants/src';

export { virtualGnosis, virtualMainnet, virtualPolygon };
export { virtualGnosis, virtualMainnet, virtualPolygon, virtualMode };
2 changes: 2 additions & 0 deletions libs/common-middleware/src/lib/cspHeader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,13 @@ const ALLOWED_ORIGINS = [
'https://alfajores-forno.celo-testnet.org',
'https://api.web3modal.com/',
'https://rpc.ankr.com/',
'https://mainnet.mode.network/',

// tenderly
'https://virtual.mainnet.rpc.tenderly.co/',
'https://virtual.gnosis.rpc.tenderly.co/',
'https://virtual.polygon.rpc.tenderly.co/',
'https://virtual.mode.rpc.tenderly.co/',
'https://rpc.tenderly.co/fork/',
// others
'https://api.thegraph.com/',
Expand Down
4 changes: 3 additions & 1 deletion libs/util-constants/src/lib/chains.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { Chain, arbitrum, base, celo, gnosis, mainnet, optimism, polygon } from 'viem/chains';
import { Chain, arbitrum, base, celo, gnosis, mainnet, mode, optimism, polygon } from 'viem/chains';

export const CHAIN_NAMES: Record<string, string> = {
1: mainnet.name,
10: optimism.name,
100: gnosis.name,
137: polygon.name,
8_453: base.name,
34_443: mode.name,
42_161: arbitrum.name,
42_220: celo.name,
};
Expand All @@ -16,6 +17,7 @@ export const CHAINS: Record<string, Chain> = {
100: gnosis,
137: polygon,
8_453: base,
34_443: mode,
42_161: arbitrum,
42_220: celo,
};
6 changes: 5 additions & 1 deletion libs/util-constants/src/lib/rpcUrls.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { arbitrum, base, celo, gnosis, mainnet, optimism, polygon } from 'wagmi/chains';
import { arbitrum, base, celo, gnosis, mainnet, optimism, polygon, mode } from 'wagmi/chains';

import { STAGING_CHAIN_ID } from '@autonolas/frontend-library';

Expand All @@ -18,6 +18,10 @@ export const RPC_URLS: Record<number, string> = {
? process.env.NEXT_PUBLIC_POLYGON_TEST_RPC
: process.env.NEXT_PUBLIC_POLYGON_URL) ?? polygon.rpcUrls.default.http[0],
8453: process.env.NEXT_PUBLIC_BASE_URL ?? base.rpcUrls.default.http[0],
34443:
(process.env.NEXT_PUBLIC_IS_CONNECTED_TO_TEST_NET === 'true'
? process.env.NEXT_PUBLIC_MODE_TEST_RPC
: process.env.NEXT_PUBLIC_MODE_URL) ?? mode.rpcUrls.default.http[0],
42161: process.env.NEXT_PUBLIC_ARBITRUM_URL ?? arbitrum.rpcUrls.default.http[0],
42220: process.env.NEXT_PUBLIC_CELO_URL ?? celo.rpcUrls.default.http[0],
[STAGING_CHAIN_ID]: 'http://127.0.0.1:8545',
Expand Down
15 changes: 15 additions & 0 deletions libs/util-constants/src/lib/tenderly.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,18 @@ export const virtualPolygon = defineChain({
},
},
});

export const virtualMode = defineChain({
id: 34443,
name: 'Mode Mainnet',
nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 },
rpcUrls: {
default: { http: [`${process.env.NEXT_PUBLIC_MODE_TEST_RPC}`] },
},
blockExplorers: {
default: {
name: 'Tenderly Explorer',
url: '',
},
},
});
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
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 STAKING_FACTORY = {
contractName: 'StakingFactory',
Expand All @@ -10,6 +10,7 @@ export const STAKING_FACTORY = {
[base.id]: '0x1cEe30D08943EB58EFF84DD1AB44a6ee6FEff63a',
[arbitrum.id]: '0xEB5638eefE289691EcE01943f768EDBF96258a80',
[celo.id]: '0x1c2cD884127b080F940b7546c1e9aaf525b1FA55',
[mode.id]: '0x75D529FAe220bC8db714F0202193726b46881B76',
},
Tanya-atatakai marked this conversation as resolved.
Show resolved Hide resolved
abi: [
{
Expand Down
Loading