Skip to content

Commit

Permalink
feat: add Base to SnapshotX (#1039)
Browse files Browse the repository at this point in the history
* feat: add Base to SnapshotX

* chore: use production subgraph
  • Loading branch information
Sekhmet authored Dec 12, 2024
1 parent e4a618e commit b1142ec
Show file tree
Hide file tree
Showing 13 changed files with 80 additions and 22 deletions.
2 changes: 2 additions & 0 deletions apps/mana/src/eth/rpc.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
clients,
evmArbitrum,
evmBase,
evmMainnet,
EvmNetworkConfig,
evmOptimism,
Expand All @@ -15,6 +16,7 @@ import { rpcError, rpcSuccess } from '../utils';
export const NETWORKS = new Map<number, EvmNetworkConfig>([
[10, evmOptimism],
[137, evmPolygon],
[8453, evmBase],
[42161, evmArbitrum],
[1, evmMainnet],
[11155111, evmSepolia]
Expand Down
10 changes: 10 additions & 0 deletions apps/subgraph-api/networks.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,15 @@
"address": "0x0000000000021210000000000000000000000000",
"startBlock": 157825417
}
},
"base": {
"ProxyFactory": {
"address": "0x4b4f7f64be813ccc66aefc3bfce2baa01188631c",
"startBlock": 23524251
},
"L1AvatarExecutionStrategyFactory": {
"address": "0x0000000000021210000000000000000000000000",
"startBlock": 23524251
}
}
}
3 changes: 2 additions & 1 deletion apps/subgraph-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"deploy-studio-sepolia": "yarn deploy-studio --network sepolia sx-sepolia",
"deploy-studio-optimism": "yarn deploy-studio --network optimism sx-optimism",
"deploy-studio-polygon": "yarn deploy-studio --network matic sx-polygon",
"deploy-studio-arbitrum": "yarn deploy-studio --network arbitrum-one sx-arbitrum"
"deploy-studio-arbitrum": "yarn deploy-studio --network arbitrum-one sx-arbitrum",
"deploy-studio-base": "yarn deploy-studio --network base sx-base"
},
"dependencies": {
"@graphprotocol/graph-cli": "0.72.1",
Expand Down
1 change: 1 addition & 0 deletions apps/subgraph-api/src/mapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ CHAIN_IDS.set('mainnet', 1)
CHAIN_IDS.set('sepolia', 11155111)
CHAIN_IDS.set('optimism', 10)
CHAIN_IDS.set('matic', 137)
CHAIN_IDS.set('base', 8453)
CHAIN_IDS.set('arbitrum-one', 42161)

export function handleProxyDeployed(event: ProxyDeployed): void {
Expand Down
28 changes: 14 additions & 14 deletions apps/subgraph-api/subgraph.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ schema:
dataSources:
- kind: ethereum
name: ProxyFactory
network: sepolia
network: base
source:
abi: ProxyFactory
address: "0x4b4f7f64be813ccc66aefc3bfce2baa01188631c"
startBlock: 4519171
startBlock: 23524251
mapping:
kind: ethereum/events
apiVersion: 0.0.7
Expand All @@ -30,11 +30,11 @@ dataSources:
file: ./src/mapping.ts
- kind: ethereum
name: L1AvatarExecutionStrategyFactory
network: sepolia
network: base
source:
abi: L1AvatarExecutionStrategyFactory
address: "0x27981a29ec87f2fbf873a2dcb0325405648ffce1"
startBlock: 6078978
address: "0x0000000000021210000000000000000000000000"
startBlock: 23524251
mapping:
kind: ethereum/events
apiVersion: 0.0.7
Expand All @@ -51,7 +51,7 @@ dataSources:
templates:
- kind: ethereum
name: Space
network: sepolia
network: base
source:
abi: Space
mapping:
Expand Down Expand Up @@ -103,7 +103,7 @@ templates:
file: ./src/mapping.ts
- kind: ethereum
name: AxiomExecutionStrategy
network: sepolia
network: base
source:
abi: AxiomExecutionStrategy
mapping:
Expand All @@ -121,7 +121,7 @@ templates:
file: ./src/mapping.ts
- kind: ethereum
name: TimelockExecutionStrategy
network: sepolia
network: base
source:
abi: TimelockExecutionStrategy
mapping:
Expand Down Expand Up @@ -151,7 +151,7 @@ templates:
abis:
- name: Space
file: ./abis/Space.json
network: sepolia
network: base
- name: ProposalMetadata
kind: file/ipfs
mapping:
Expand All @@ -164,7 +164,7 @@ templates:
abis:
- name: Space
file: ./abis/Space.json
network: sepolia
network: base
- name: VoteMetadata
kind: file/ipfs
mapping:
Expand All @@ -177,7 +177,7 @@ templates:
abis:
- name: Space
file: ./abis/Space.json
network: sepolia
network: base
- name: StrategiesParsedMetadataData
kind: file/ipfs
mapping:
Expand All @@ -190,7 +190,7 @@ templates:
abis:
- name: Space
file: ./abis/Space.json
network: sepolia
network: base
- name: VotingPowerValidationStrategyMetadata
kind: file/ipfs
mapping:
Expand All @@ -203,10 +203,10 @@ templates:
abis:
- name: Space
file: ./abis/Space.json
network: sepolia
network: base
- name: L1AvatarExecutionStrategy
kind: ethereum
network: sepolia
network: base
source:
abi: L1AvatarExecutionStrategy
mapping:
Expand Down
4 changes: 3 additions & 1 deletion apps/ui/src/helpers/connectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ export default {
options: {
projectId: 'e6454bd61aba40b786e866a69bd4c5c6',
chains: [],
optionalChains: [1, 10, 56, 100, 250, 4002, 42161, 137, 1088, 11155111],
optionalChains: [
1, 10, 56, 100, 250, 4002, 8453, 42161, 137, 1088, 11155111
],
optionalMethods: ['eth_sendTransaction', 'eth_signTypedData_v4'],
showQrModal: true
}
Expand Down
3 changes: 3 additions & 0 deletions apps/ui/src/helpers/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const CHAIN_IDS: Record<Exclude<NetworkID, 's' | 's-tn'>, ChainId> = {
eth: 1,
oeth: 10,
matic: 137,
base: 8453,
arb1: 42161,
sep: 11155111,
// Starknet
Expand All @@ -24,13 +25,15 @@ export const COINGECKO_ASSET_PLATFORMS = {
1: 'ethereum',
10: 'optimistic-ethereum',
137: 'polygon-pos',
8453: 'base',
42161: 'arbitrum-one'
};

export const COINGECKO_BASE_ASSETS = {
1: 'ethereum',
10: 'ethereum',
137: 'matic-network',
8453: 'ethereum',
42161: 'ethereum'
};

Expand Down
1 change: 1 addition & 0 deletions apps/ui/src/helpers/etherscan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export async function getABI(chainId: number, address: string) {
if (chainId === 1) apiHost = 'https://api.etherscan.io';
else if (chainId === 10) apiHost = 'https://api-optimistic.etherscan.io';
else if (chainId === 137) apiHost = 'https://api.polygonscan.com';
else if (chainId === 8453) apiHost = 'https://basescan.io';
else if (chainId === 42161) apiHost = 'https://api.arbiscan.io';
else if (chainId === 11155111) apiHost = 'https://api-sepolia.etherscan.io';
else throw new Error('Unsupported chainId');
Expand Down
2 changes: 2 additions & 0 deletions apps/ui/src/networks/evm/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { formatBytes32String } from '@ethersproject/strings';
import {
clients,
evmArbitrum,
evmBase,
evmMainnet,
EvmNetworkConfig,
evmOptimism,
Expand Down Expand Up @@ -49,6 +50,7 @@ import { EDITOR_APP_NAME } from '../common/constants';
const CONFIGS: Record<number, EvmNetworkConfig> = {
10: evmOptimism,
137: evmPolygon,
8453: evmBase,
42161: evmArbitrum,
1: evmMainnet,
11155111: evmSepolia
Expand Down
19 changes: 16 additions & 3 deletions apps/ui/src/networks/evm/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ export const METADATA: Record<string, Metadata> = {
avatar: 'ipfs://QmfF4kwhGL8QosUXvgq2KWCmavhKBvwD6kbhs7L4p5ZAWb',
blockTime: 2
},
base: {
name: 'Base',
chainId: 8453,
apiUrl:
'https://api.studio.thegraph.com/query/23545/sx-base/version/latest',
avatar: 'ipfs://QmaxRoHpxZd8PqccAynherrMznMufG6sdmHZLihkECXmZv',
blockTime: 2
},
eth: {
name: 'Ethereum',
chainId: 1,
Expand Down Expand Up @@ -121,9 +129,14 @@ export function createEvmNetwork(networkId: NetworkID): Network {
chainId,
baseChainId: chainId,
currentChainId: currentChainId ?? chainId,
supportsSimulation: ['eth', 'sep', 'oeth', 'matic', 'arb1'].includes(
networkId
),
supportsSimulation: [
'eth',
'sep',
'oeth',
'matic',
'base',
'arb1'
].includes(networkId),
managerConnectors: EVM_CONNECTORS,
actions: createActions(provider, helpers, chainId),
api,
Expand Down
24 changes: 22 additions & 2 deletions apps/ui/src/networks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,35 @@ const starknetNetwork = createStarknetNetwork('sn');
const starknetSepoliaNetwork = createStarknetNetwork('sn-sep');
const polygonNetwork = createEvmNetwork('matic');
const arbitrumNetwork = createEvmNetwork('arb1');
const baseNetwork = createEvmNetwork('base');
const optimismNetwork = createEvmNetwork('oeth');
const ethereumNetwork = createEvmNetwork('eth');
const sepoliaNetwork = createEvmNetwork('sep');

export const enabledNetworks: NetworkID[] = import.meta.env
.VITE_ENABLED_NETWORKS
? (import.meta.env.VITE_ENABLED_NETWORKS.split(',') as NetworkID[])
: ['s', 's-tn', 'eth', 'matic', 'arb1', 'oeth', 'sep', 'sn', 'sn-sep'];
: [
's',
's-tn',
'eth',
'matic',
'arb1',
'base',
'oeth',
'sep',
'sn',
'sn-sep'
];

export const evmNetworks: NetworkID[] = ['eth', 'matic', 'arb1', 'oeth', 'sep'];
export const evmNetworks: NetworkID[] = [
'eth',
'matic',
'arb1',
'base',
'oeth',
'sep'
];
export const offchainNetworks: NetworkID[] = ['s', 's-tn'];
export const starknetNetworks: NetworkID[] = ['sn', 'sn-sep'];
// This network is used for aliases/follows/profiles/explore page.
Expand All @@ -34,6 +53,7 @@ export const getNetwork = (id: NetworkID) => {
if (id === 's-tn') return snapshotTestnetNetwork;
if (id === 'matic') return polygonNetwork;
if (id === 'arb1') return arbitrumNetwork;
if (id === 'base') return baseNetwork;
if (id === 'oeth') return optimismNetwork;
if (id === 'eth') return ethereumNetwork;
if (id === 'sep') return sepoliaNetwork;
Expand Down
1 change: 1 addition & 0 deletions apps/ui/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export type NetworkID =
| 'matic'
| 'arb1'
| 'oeth'
| 'base'
| 'sep'
| 'sn'
| 'sn-sep';
Expand Down
4 changes: 3 additions & 1 deletion packages/sx.js/src/evmNetworks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,13 @@ export const evmNetworks = {
}
}),
matic: createStandardConfig(137),
arb1: createStandardConfig(42161)
arb1: createStandardConfig(42161),
base: createStandardConfig(8453)
} as const;

export const evmMainnet = createEvmConfig('eth');
export const evmSepolia = createEvmConfig('sep');
export const evmOptimism = createEvmConfig('oeth');
export const evmPolygon = createEvmConfig('matic');
export const evmArbitrum = createEvmConfig('arb1');
export const evmBase = createEvmConfig('base');

0 comments on commit b1142ec

Please sign in to comment.