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

chore: add support for skale testnet #8

Open
wants to merge 11 commits into
base: merge-changes-develop
Choose a base branch
from
6 changes: 4 additions & 2 deletions apps/mana/src/eth/rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import {
evmGoerli,
evmSepolia,
evmLineaGoerli,
EvmNetworkConfig
EvmNetworkConfig,
evmSkaleTestnet
} from '@snapshot-labs/sx';
import fetch from 'cross-fetch';
import { createWalletProxy } from './dependencies';
Expand All @@ -21,7 +22,8 @@ export const NETWORKS = new Map<number, EvmNetworkConfig>([
[1, evmMainnet],
[5, evmGoerli],
[11155111, evmSepolia],
[59140, evmLineaGoerli]
[59140, evmLineaGoerli],
[1444673419, evmSkaleTestnet]
]);

export const createNetworkHandler = (chainId: number) => {
Expand Down
36 changes: 36 additions & 0 deletions apps/subgraph-api/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash

set -e


if ! which docker 2>&1 > /dev/null; then
echo "Please install 'docker' first"
exit 1
fi

if ! which docker-compose 2>&1 > /dev/null; then
echo "Please install 'docker-compose' first"
exit 1
fi

# Start graph node
docker-compose up -d


until curl -o /dev/null -s http://localhost:8040/metrics; do
>&2 echo "Graph node is unavailable - sleeping for while......"
sleep 2
done

>&2 echo "Graph node is Up is up - executing command"

echo "Installing dependencies"
yarn

echo "Building app"
yarn run codegen
yarn run build

echo "Pushing app to local graph node"
yarn run create-local
yarn run deploy-local
36 changes: 36 additions & 0 deletions apps/subgraph-api/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
version: '3.8'
services:
graph-node:
image: graphprotocol/graph-node
ports:
- '8000:8000'
- '8001:8001'
- '8020:8020'
- '8030:8030'
- '8040:8040'
depends_on:
- postgres
environment:
postgres_host: postgres
postgres_user: postgres
postgres_pass: password
postgres_db: graph
ipfs: 'https://api.thegraph.com/ipfs/'
ethereum: 'mainnet:https://testnet.skalenodes.com/v1/juicy-low-small-testnet'
GRAPH_LOG: info
postgres:
image: postgres:15.4
ports:
- '5432:5432'
command: ['postgres', '-cshared_preload_libraries=pg_stat_statements', '-cmax_connections=200']
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: graph
POSTGRES_INITDB_ARGS: '-E UTF8 --locale=C'
volumes:
- ./initdb.d:/docker-entrypoint-initdb.d
- pg:/var/lib/postgresql/data
volumes:
pg:
driver: local
2 changes: 1 addition & 1 deletion apps/subgraph-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"deploy": "graph deploy --node https://api.thegraph.com/deploy/ snapshot-labs/sx-subgraph",
"create-local": "graph create --node http://localhost:8020/ snapshot-labs/sx-subgraph",
"remove-local": "graph remove --node http://localhost:8020/ snapshot-labs/sx-subgraph",
"deploy-local": "yarn create-local && graph deploy --node http://localhost:8020/ --network sepolia -l `LC_ALL=C tr -dc a-z0-9 </dev/urandom | head -c 32` snapshot-labs/sx-subgraph",
"deploy-local": "yarn create-local && graph deploy --node http://localhost:8020/ snapshot-labs/sx-subgraph --version-label v0.0.4",
"deploy-goerli": "graph deploy --node https://api.thegraph.com/deploy/ snapshot-labs/sx-subgraph",
"deploy-linea-testnet": "graph deploy --network linea-testnet --studio sx-linea-testnet",
"deploy-studio": "graph deploy --studio -l v${npm_package_version}",
Expand Down
7 changes: 4 additions & 3 deletions apps/subgraph-api/src/mapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ import {
toChecksumAddress,
} from './helpers'

const MASTER_SPACE = Address.fromString('0xB1870f2Dc79862c5a06090344bfbBCA07483dAEe')
const MASTER_SIMPLE_QUORUM_AVATAR = Address.fromString('0x6560B2eEEa07642F2CA3ebD100C07A1c1f66F2Ea')
const MASTER_SPACE = Address.fromString('0xae55A5603ba260eb38a1567774395f3e1871707B')
const MASTER_SIMPLE_QUORUM_AVATAR = Address.fromString('0x84CfB838FA4F868560f03eA633b1bDC6e958bf63')
const MASTER_AXIOM = Address.fromString('0xaC6dbd42Ed254E9407fe0D2798784d0110979DC2')
const MASTER_SIMPLE_QUORUM_TIMELOCK = Address.fromString(
'0x6791408d253CF326BcA01a41ab909254a64F2cDa'
'0x44f9E596315CFd27FDbB3041251fFD4D97684f25'
)

const CHAIN_IDS = new Map<string, i32>()
Expand All @@ -65,6 +65,7 @@ CHAIN_IDS.set('optimism', 10)
CHAIN_IDS.set('matic', 137)
CHAIN_IDS.set('arbitrum-one', 42161)
CHAIN_IDS.set('linea-testnet', 59140)
CHAIN_IDS.set('skale-testnet', 1444673419)

export function handleProxyDeployed(event: ProxyDeployed): void {
let network = dataSource.network()
Expand Down
20 changes: 10 additions & 10 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: mainnet
source:
abi: ProxyFactory
address: '0x542922aF76e8b55076a54b15fD972156f5B143B0'
startBlock: 5386251
address: '0x96f98916be07BCdB2556349b13D5F404B78E13D7'
startBlock: 1403270
mapping:
kind: ethereum/events
apiVersion: 0.0.7
Expand All @@ -31,7 +31,7 @@ dataSources:
templates:
- kind: ethereum
name: Space
network: sepolia
network: mainnet
source:
abi: Space
mapping:
Expand Down Expand Up @@ -81,7 +81,7 @@ templates:
file: ./src/mapping.ts
- kind: ethereum
name: AxiomExecutionStrategy
network: sepolia
network: mainnet
source:
abi: AxiomExecutionStrategy
mapping:
Expand All @@ -99,7 +99,7 @@ templates:
file: ./src/mapping.ts
- kind: ethereum
name: TimelockExecutionStrategy
network: sepolia
network: mainnet
source:
abi: TimelockExecutionStrategy
mapping:
Expand Down Expand Up @@ -129,7 +129,7 @@ templates:
abis:
- name: Space
file: ./abis/Space.json
network: sepolia
network: mainnet
- name: ProposalMetadata
kind: file/ipfs
mapping:
Expand All @@ -142,7 +142,7 @@ templates:
abis:
- name: Space
file: ./abis/Space.json
network: sepolia
network: mainnet
- name: StrategiesParsedMetadataData
kind: file/ipfs
mapping:
Expand All @@ -155,7 +155,7 @@ templates:
abis:
- name: Space
file: ./abis/Space.json
network: sepolia
network: mainnet
- name: VotingPowerValidationStrategyMetadata
kind: file/ipfs
mapping:
Expand All @@ -168,4 +168,4 @@ templates:
abis:
- name: Space
file: ./abis/Space.json
network: sepolia
network: mainnet
2 changes: 1 addition & 1 deletion apps/ui/.env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VITE_ENABLED_NETWORKS=sep
VITE_ENABLED_NETWORKS=skale-testnet
VITE_MANA_URL=https://mana.pizza
VITE_HIGHLIGHT_URL=https://testnet.highlight.red
VITE_IPFS_GATEWAY=snapshot.4everland.link
Expand Down
2 changes: 1 addition & 1 deletion apps/ui/src/components/App/Sidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const spacesStore = useSpacesStore();
<template>
<div class="w-[72px] border-r fixed left-0 top-0 bottom-0 text-center">
<router-link
:to="{ path: '/sep:0x22fcfBE907139a3f970ad8B7A3FC4D0c1b698a98' }"
:to="{ path: '/skale-testnet:0xbA0012E25e9D2f4b88a59e20086789d6458f6DF0' }"
class="h-[72px] block"
>
<IH-stop class="inline-block my-4 w-[32px] h-[32px] text-skin-link" />
Expand Down
2 changes: 1 addition & 1 deletion apps/ui/src/components/App/Topnav.vue
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ watch(route, to => {
</div>
<router-link
v-else
:to="{ path: '/sep:0x22fcfBE907139a3f970ad8B7A3FC4D0c1b698a98' }"
:to="{ path: '/skale-testnet:0xbA0012E25e9D2f4b88a59e20086789d6458f6DF0' }"
class="flex items-center"
style="font-size: 24px"
>
Expand Down
3 changes: 2 additions & 1 deletion apps/ui/src/helpers/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ export const CHAIN_IDS = {
eth: 1,
gor: 5,
sep: 11155111,
'linea-testnet': 59140
'linea-testnet': 59140,
'skale-testnet': 1444673419
};

export const COINGECKO_ASSET_PLATFORMS = {
Expand Down
3 changes: 2 additions & 1 deletion apps/ui/src/helpers/link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ const UNISWAP_CHAINS_BY_NETWORK = {
'43114': 'avalanche',
'42220': 'celo',
'11155111': 'sepolia',
'5': 'goerli'
'5': 'goerli',
'1444673419': 'skale-testnet'
};

export function getSwapLink(strategy: string, address: string, chainId?: number) {
Expand Down
3 changes: 2 additions & 1 deletion apps/ui/src/helpers/opensea.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ const OPENSEA_CHAINS: Record<number, ChainItem> = {
1: { name: 'ethereum', isTestnet: false },
10: { name: 'optimism', isTestnet: false },
137: { name: 'matic', isTestnet: false },
42161: { name: 'arbitrum', isTestnet: false }
42161: { name: 'arbitrum', isTestnet: false },
1444673419: { name: 'skale-testnet', isTestnet: true }
};

export async function getNfts(address: string, chainId: number): Promise<ApiNft[]> {
Expand Down
7 changes: 5 additions & 2 deletions apps/ui/src/helpers/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ import { StaticJsonRpcProvider } from '@ethersproject/providers';
const providers: Record<number, StaticJsonRpcProvider | undefined> = {};

export function getProvider(networkId: number): StaticJsonRpcProvider {
const url = `https://rpc.snapshotx.xyz/${networkId}`;
// const url = `https://rpc.snapshotx.xyz/${networkId}`;

let provider = providers[networkId];

if (!provider) {
provider = new StaticJsonRpcProvider({ url, timeout: 25000 }, networkId);
provider = new StaticJsonRpcProvider(
{ url: 'https://testnet.skalenodes.com/v1/juicy-low-small-testnet', timeout: 25000 },
networkId
);
providers[networkId] = provider;
}

Expand Down
10 changes: 6 additions & 4 deletions apps/ui/src/networks/evm/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import {
evmGoerli,
evmSepolia,
evmLineaGoerli,
EvmNetworkConfig
EvmNetworkConfig,
evmSkaleTestnet
} from '@snapshot-labs/sx';
import { MANA_URL, executionCall } from '@/helpers/mana';
import { CHAIN_IDS } from '@/helpers/constants';
Expand Down Expand Up @@ -54,7 +55,8 @@ const CONFIGS: Record<number, EvmNetworkConfig> = {
1: evmMainnet,
5: evmGoerli,
11155111: evmSepolia,
59140: evmLineaGoerli
59140: evmLineaGoerli,
1444673419: evmSkaleTestnet
};

export function createActions(
Expand Down Expand Up @@ -151,7 +153,7 @@ export function createActions(
authenticators: params.authenticators.map(config => config.address),
votingStrategies: Array.from({ length: MAX_MERKLE_VOTING_STRATEGIES }, (_, i) => {
return {
addr: '0x76F31B102b2F80BE9E2B0611571c33C10147Ec29',
addr: '0x7347CCfEd3074AaB4a8B705A830DAeF02fb88D95',
params: abiCoder.encode(['uint256'], [BigInt(i + 1)])
};
}),
Expand All @@ -160,7 +162,7 @@ export function createActions(
}),
proposalValidationStrategy: {
addr: params.validationStrategy.address,
params: abiCoder.encode(['uint256', 'uint256'], [BigInt(1), BigInt(10)])
params: abiCoder.encode(['uint256', 'uint256'], [BigInt(1), BigInt(10)]) // !NOTE: check here. maxActiveProposal, cooldown
},
metadataUri: `ipfs://${pinned.cid}`,
proposalValidationStrategyMetadataUri,
Expand Down
11 changes: 10 additions & 1 deletion apps/ui/src/networks/evm/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ export const METADATA: Record<string, Metadata> = {
apiUrl: 'https://thegraph.goerli.zkevm.consensys.net/subgraphs/name/snapshot-labs/sx-subgraph',
avatar: 'ipfs://bafkreibn4mjs54bnmvkrkiaiwp47gvcz6bervg2kr5ubknytfyz6l5wbs4',
blockTime: 13.52926
},
'skale-testnet': {
name: 'Skale Testnet',
chainId: 1444673419,
apiUrl: 'https://34.170.76.2/subgraphs/name/snapshot-labs/sx-subgraph',
avatar: 'ipfs://bafkreid7ndxh6y2ljw2jhbisodiyrhcy2udvnwqgon5wgells3kh4si5z4',
blockTime: 6.7 // !NOTE: block time needs to precise else voting duration will be inaccurate
}
};

Expand Down Expand Up @@ -124,7 +131,9 @@ export function createEvmNetwork(networkId: NetworkID): Network {
chainId,
baseChainId: chainId,
currentChainId: currentChainId ?? chainId,
supportsSimulation: ['eth', 'gor', 'sep', 'oeth', 'matic', 'arb1'].includes(networkId),
supportsSimulation: ['eth', 'gor', 'sep', 'oeth', 'matic', 'arb1', 'skale-testnet'].includes(
networkId
),
managerConnectors: EVM_CONNECTORS,
actions: createActions(provider, helpers, chainId),
api,
Expand Down
7 changes: 5 additions & 2 deletions apps/ui/src/networks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ const ethereumNetwork = createEvmNetwork('eth');
const goerliNetwork = createEvmNetwork('gor');
const sepoliaNetwork = createEvmNetwork('sep');
const lineaTestnetNetwork = createEvmNetwork('linea-testnet');
const skaleTestnetNetwork = createEvmNetwork('skale-testnet');

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', 'gor', 'sep', 'sn', 'sn-sep'];
: ['s', 's-tn', 'eth', 'matic', 'arb1', 'oeth', 'gor', 'sep', 'skale-testnet', 'sn', 'sn-sep'];

export const evmNetworks: NetworkID[] = [
'eth',
Expand All @@ -28,7 +29,8 @@ export const evmNetworks: NetworkID[] = [
'oeth',
'gor',
'sep',
'linea-testnet'
'linea-testnet',
'skale-testnet'
];
export const offchainNetworks: NetworkID[] = ['s', 's-tn'];

Expand All @@ -47,6 +49,7 @@ export const getNetwork = (id: NetworkID) => {
if (id === 'sn') return starknetNetwork;
if (id === 'sn-tn') return starknetTestnetNetwork;
if (id === 'sn-sep') return starknetSepoliaNetwork;
if (id === 'skale-testnet') return skaleTestnetNetwork;

throw new Error(`Unknown network ${id}`);
};
Expand Down
2 changes: 1 addition & 1 deletion apps/ui/src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const routes: any[] = [
{
path: '/',
name: 'landing',
redirect: '/sep:0x22fcfBE907139a3f970ad8B7A3FC4D0c1b698a98',
redirect: '/skale-testnet:0xbA0012E25e9D2f4b88a59e20086789d6458f6DF0',
component: Landing
},
{
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 @@ -13,6 +13,7 @@ export type NetworkID =
| 'gor'
| 'sep'
| 'linea-testnet'
| 'skale-testnet'
| 'sn'
| 'sn-tn'
| 'sn-sep';
Expand Down
3 changes: 2 additions & 1 deletion apps/ui/src/views/Space.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ watchEffect(() => {
offchainNetworks.includes(space.value.network) ? 'space' : 'space-sx',
space.value.id,
16,
getCacheHash(space.value.avatar)
'',
space.value.avatar
);
setFavicon(faviconUrl);
});
Expand Down
Loading