From 621acddec915d8fb15f75c8bdeddf211aed97613 Mon Sep 17 00:00:00 2001 From: rajkharvar Date: Tue, 7 May 2024 14:24:22 +0530 Subject: [PATCH 01/11] chore: init skale testnet changes --- apps/subgraph-api/deploy.sh | 36 +++++++++++++++++++ apps/subgraph-api/docker-compose.yml | 36 +++++++++++++++++++ apps/subgraph-api/package.json | 2 +- apps/subgraph-api/src/mapping.ts | 1 + apps/subgraph-api/subgraph.yaml | 18 +++++----- apps/ui/.env | 2 +- apps/ui/src/helpers/link.ts | 3 +- apps/ui/src/helpers/opensea.ts | 3 +- apps/ui/src/helpers/provider.ts | 7 ++-- apps/ui/src/networks/evm/index.ts | 11 +++++- apps/ui/src/networks/index.ts | 7 ++-- apps/ui/src/types.ts | 1 + .../src/clients/evm/ethereum-tx/index.ts | 4 +-- packages/sx.js/src/evmNetworks.ts | 30 ++++++++++++++++ packages/sx.js/src/utils/merkleVoting.ts | 2 +- packages/sx.js/src/utils/space.ts | 2 +- 16 files changed, 143 insertions(+), 22 deletions(-) create mode 100755 apps/subgraph-api/deploy.sh create mode 100644 apps/subgraph-api/docker-compose.yml diff --git a/apps/subgraph-api/deploy.sh b/apps/subgraph-api/deploy.sh new file mode 100755 index 000000000..14eae97a8 --- /dev/null +++ b/apps/subgraph-api/deploy.sh @@ -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" +npm i + +echo "Building app" +npm run codegen +npm run build + +echo "Pushing app to local graph node" +npm run create-local +npm run deploy-local \ No newline at end of file diff --git a/apps/subgraph-api/docker-compose.yml b/apps/subgraph-api/docker-compose.yml new file mode 100644 index 000000000..166aefde4 --- /dev/null +++ b/apps/subgraph-api/docker-compose.yml @@ -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 diff --git a/apps/subgraph-api/package.json b/apps/subgraph-api/package.json index 63b7dbe47..ab103e8cd 100644 --- a/apps/subgraph-api/package.json +++ b/apps/subgraph-api/package.json @@ -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 = { 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 { diff --git a/apps/ui/src/helpers/provider.ts b/apps/ui/src/helpers/provider.ts index 77596d4c9..0697866b5 100644 --- a/apps/ui/src/helpers/provider.ts +++ b/apps/ui/src/helpers/provider.ts @@ -3,12 +3,15 @@ import { StaticJsonRpcProvider } from '@ethersproject/providers'; const providers: Record = {}; 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; } diff --git a/apps/ui/src/networks/evm/index.ts b/apps/ui/src/networks/evm/index.ts index c6a454ccb..efbeab377 100644 --- a/apps/ui/src/networks/evm/index.ts +++ b/apps/ui/src/networks/evm/index.ts @@ -74,6 +74,13 @@ export const METADATA: Record = { 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: 'http://localhost:8000/subgraphs/name/snapshot-labs/sx-subgraph', + avatar: 'ipfs://bafkreid7ndxh6y2ljw2jhbisodiyrhcy2udvnwqgon5wgells3kh4si5z4', + blockTime: 3 } }; @@ -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, diff --git a/apps/ui/src/networks/index.ts b/apps/ui/src/networks/index.ts index 1ae9e9afd..2c1fb6cc9 100644 --- a/apps/ui/src/networks/index.ts +++ b/apps/ui/src/networks/index.ts @@ -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', @@ -28,7 +29,8 @@ export const evmNetworks: NetworkID[] = [ 'oeth', 'gor', 'sep', - 'linea-testnet' + 'linea-testnet', + 'skale-testnet' ]; export const offchainNetworks: NetworkID[] = ['s', 's-tn']; @@ -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}`); }; diff --git a/apps/ui/src/types.ts b/apps/ui/src/types.ts index f6cdf38a2..a8f10ecd0 100644 --- a/apps/ui/src/types.ts +++ b/apps/ui/src/types.ts @@ -13,6 +13,7 @@ export type NetworkID = | 'gor' | 'sep' | 'linea-testnet' + | 'skale-testnet' | 'sn' | 'sn-tn' | 'sn-sep'; diff --git a/packages/sx.js/src/clients/evm/ethereum-tx/index.ts b/packages/sx.js/src/clients/evm/ethereum-tx/index.ts index c364e6e71..acb28f824 100644 --- a/packages/sx.js/src/clients/evm/ethereum-tx/index.ts +++ b/packages/sx.js/src/clients/evm/ethereum-tx/index.ts @@ -4,7 +4,7 @@ import { keccak256 } from '@ethersproject/solidity'; import randomBytes from 'randombytes'; import { getAuthenticator } from '../../../authenticators/evm'; import { getStrategiesWithParams } from '../../../strategies/evm'; -import { evmGoerli } from '../../../networks'; +import { evmSkaleTestnet } from '../../../networks'; import SpaceAbi from './abis/Space.json'; import ProxyFactoryAbi from './abis/ProxyFactory.json'; import AvatarExecutionStrategyAbi from './abis/AvatarExecutionStrategy.json'; @@ -102,7 +102,7 @@ export class EthereumTx { networkConfig: EvmNetworkConfig; constructor(opts?: { networkConfig: EvmNetworkConfig }) { - this.networkConfig = opts?.networkConfig || evmGoerli; + this.networkConfig = opts?.networkConfig || evmSkaleTestnet; } async deployAvatarExecution({ diff --git a/packages/sx.js/src/evmNetworks.ts b/packages/sx.js/src/evmNetworks.ts index c6e62fd55..ccab29212 100644 --- a/packages/sx.js/src/evmNetworks.ts +++ b/packages/sx.js/src/evmNetworks.ts @@ -159,6 +159,35 @@ export const evmNetworks = { Axiom: null, Isokratia: null } + }, + 'skale-testnet': { + Meta: { + eip712ChainId: 11155111, + proxyFactory: '0x542922aF76e8b55076a54b15fD972156f5B143B0', + masterSpace: '0xB1870f2Dc79862c5a06090344bfbBCA07483dAEe' + }, + Authenticators: { + EthSig: '0x38b4B21b498a0983aE8028442FEB48BB91A9B75e', + EthTx: '0xA927DEcf7E163b779592711fF866a58d1a5Cc270' + }, + Strategies: { + Vanilla: '0x63E60ae42844dAf91C9Bcf8057731AA97012eD0a', + Comp: '0x5Df7743a11136E11010c3F6976C28a8aF5D681a7', + OZVotes: '0x9b528301AE02C4141eB9e870e36C14bE2E0Ec48F', + Whitelist: '0x4ea6CD1c54e67f650aE9bb8f1C126a2a9226510A', + MerkleVoting: '0x76F31B102b2F80BE9E2B0611571c33C10147Ec29' + }, + ProposalValidations: { + VotingPower: '0x975201328596612a8F46263D4216355B6D94DFF7', + WhitelistAndActiveProposalsLimiter: '0xc72dC228cB23871E24C12439D04a8792a888333d' + }, + ExecutionStrategies: { + SimpleQuorumAvatar: '0x38afdA9bD192300C128C22278D71D492dB1Ac238', + SimpleQuorumTimelock: '0xf2A1C2f2098161af98b2Cc7E382AB7F3ba86Ebc4', + SimpleQuorumVanilla: '0x6560B2eEEa07642F2CA3ebD100C07A1c1f66F2Ea', + Axiom: null, + Isokratia: null + } } } as const; @@ -169,3 +198,4 @@ export const evmOptimism = createEvmConfig('oeth'); export const evmPolygon = createEvmConfig('matic'); export const evmArbitrum = createEvmConfig('arb1'); export const evmLineaGoerli = createEvmConfig('linea-testnet'); +export const evmSkaleTestnet = createEvmConfig('skale-testnet'); diff --git a/packages/sx.js/src/utils/merkleVoting.ts b/packages/sx.js/src/utils/merkleVoting.ts index 460e172a2..c35833b77 100644 --- a/packages/sx.js/src/utils/merkleVoting.ts +++ b/packages/sx.js/src/utils/merkleVoting.ts @@ -3,7 +3,7 @@ import { Contract } from '@ethersproject/contracts'; import MerkleVotingABI from '../abis/MerkleVoting.json'; -const MERKLE_VOTING_RPC_PROVIDER = 'https://ethereum-sepolia-rpc.publicnode.com'; +const MERKLE_VOTING_RPC_PROVIDER = 'https://testnet.skalenodes.com/v1/juicy-low-small-testnet'; const MERKLE_VOTING_API = 'https://35.185.190.187'; export async function getMerkleVotingParams( diff --git a/packages/sx.js/src/utils/space.ts b/packages/sx.js/src/utils/space.ts index ad740ddcc..a43900173 100644 --- a/packages/sx.js/src/utils/space.ts +++ b/packages/sx.js/src/utils/space.ts @@ -3,7 +3,7 @@ import { Contract } from '@ethersproject/contracts'; import SpaceABI from '../abis/Space.json'; -const PROVIDER_URL = 'https://ethereum-sepolia-rpc.publicnode.com'; +const PROVIDER_URL = 'https://testnet.skalenodes.com/v1/juicy-low-small-testnet'; export function getNextProposalId(space: string) { const provider = new JsonRpcProvider(PROVIDER_URL); From d53fdb8836814384e958025298d69da9b2779b62 Mon Sep 17 00:00:00 2001 From: rajkharvar Date: Wed, 8 May 2024 10:40:15 +0530 Subject: [PATCH 02/11] chore: more changes for supporting skale network --- apps/mana/src/eth/rpc.ts | 6 ++++-- apps/ui/src/helpers/constants.ts | 3 ++- apps/ui/src/networks/evm/actions.ts | 6 ++++-- apps/ui/src/networks/evm/index.ts | 2 +- packages/sx.js/src/evmNetworks.ts | 2 +- 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/apps/mana/src/eth/rpc.ts b/apps/mana/src/eth/rpc.ts index 0d5ca46c2..db7558284 100644 --- a/apps/mana/src/eth/rpc.ts +++ b/apps/mana/src/eth/rpc.ts @@ -8,7 +8,8 @@ import { evmGoerli, evmSepolia, evmLineaGoerli, - EvmNetworkConfig + EvmNetworkConfig, + evmSkaleTestnet } from '@snapshot-labs/sx'; import fetch from 'cross-fetch'; import { createWalletProxy } from './dependencies'; @@ -21,7 +22,8 @@ export const NETWORKS = new Map([ [1, evmMainnet], [5, evmGoerli], [11155111, evmSepolia], - [59140, evmLineaGoerli] + [59140, evmLineaGoerli], + [1444673419, evmSkaleTestnet] ]); export const createNetworkHandler = (chainId: number) => { diff --git a/apps/ui/src/helpers/constants.ts b/apps/ui/src/helpers/constants.ts index 738995bda..080d21914 100644 --- a/apps/ui/src/helpers/constants.ts +++ b/apps/ui/src/helpers/constants.ts @@ -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 = { diff --git a/apps/ui/src/networks/evm/actions.ts b/apps/ui/src/networks/evm/actions.ts index afa78a286..e69d9ccff 100644 --- a/apps/ui/src/networks/evm/actions.ts +++ b/apps/ui/src/networks/evm/actions.ts @@ -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'; @@ -54,7 +55,8 @@ const CONFIGS: Record = { 1: evmMainnet, 5: evmGoerli, 11155111: evmSepolia, - 59140: evmLineaGoerli + 59140: evmLineaGoerli, + 1444673419: evmSkaleTestnet }; export function createActions( diff --git a/apps/ui/src/networks/evm/index.ts b/apps/ui/src/networks/evm/index.ts index efbeab377..aa1454e9c 100644 --- a/apps/ui/src/networks/evm/index.ts +++ b/apps/ui/src/networks/evm/index.ts @@ -80,7 +80,7 @@ export const METADATA: Record = { chainId: 1444673419, apiUrl: 'http://localhost:8000/subgraphs/name/snapshot-labs/sx-subgraph', avatar: 'ipfs://bafkreid7ndxh6y2ljw2jhbisodiyrhcy2udvnwqgon5wgells3kh4si5z4', - blockTime: 3 + blockTime: 10 } }; diff --git a/packages/sx.js/src/evmNetworks.ts b/packages/sx.js/src/evmNetworks.ts index ccab29212..0bc2666c5 100644 --- a/packages/sx.js/src/evmNetworks.ts +++ b/packages/sx.js/src/evmNetworks.ts @@ -162,7 +162,7 @@ export const evmNetworks = { }, 'skale-testnet': { Meta: { - eip712ChainId: 11155111, + eip712ChainId: 1444673419, proxyFactory: '0x542922aF76e8b55076a54b15fD972156f5B143B0', masterSpace: '0xB1870f2Dc79862c5a06090344bfbBCA07483dAEe' }, From 57d2e576422d4ab34cedb600feb9b0b27e8b4f6b Mon Sep 17 00:00:00 2001 From: rajkharvar Date: Wed, 8 May 2024 12:58:16 +0530 Subject: [PATCH 03/11] chore: update block time for skale testnet --- apps/ui/src/networks/evm/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/ui/src/networks/evm/index.ts b/apps/ui/src/networks/evm/index.ts index aa1454e9c..98be9c36f 100644 --- a/apps/ui/src/networks/evm/index.ts +++ b/apps/ui/src/networks/evm/index.ts @@ -80,7 +80,7 @@ export const METADATA: Record = { chainId: 1444673419, apiUrl: 'http://localhost:8000/subgraphs/name/snapshot-labs/sx-subgraph', avatar: 'ipfs://bafkreid7ndxh6y2ljw2jhbisodiyrhcy2udvnwqgon5wgells3kh4si5z4', - blockTime: 10 + blockTime: 6.7 // !NOTE: block time needs to precise else voting duration will be inaccurate } }; From 388cd95682bae26815475715dcfd450265e97ec0 Mon Sep 17 00:00:00 2001 From: rajkharvar Date: Wed, 8 May 2024 13:01:05 +0530 Subject: [PATCH 04/11] chore: use yarn instead of npm in deploy script --- apps/subgraph-api/deploy.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/subgraph-api/deploy.sh b/apps/subgraph-api/deploy.sh index 14eae97a8..a02f1e152 100755 --- a/apps/subgraph-api/deploy.sh +++ b/apps/subgraph-api/deploy.sh @@ -25,12 +25,12 @@ done >&2 echo "Graph node is Up is up - executing command" echo "Installing dependencies" -npm i +yarn echo "Building app" -npm run codegen -npm run build +yarn run codegen +yarn run build echo "Pushing app to local graph node" -npm run create-local -npm run deploy-local \ No newline at end of file +yarn run create-local +yarn run deploy-local \ No newline at end of file From 8b831eb422d5bcf9789ed2e87b445aeefc62c048 Mon Sep 17 00:00:00 2001 From: rajkharvar Date: Wed, 8 May 2024 17:11:11 +0530 Subject: [PATCH 05/11] chore: update skale testnet indexer endpoint --- apps/ui/src/networks/evm/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/ui/src/networks/evm/index.ts b/apps/ui/src/networks/evm/index.ts index 98be9c36f..cc8b0482a 100644 --- a/apps/ui/src/networks/evm/index.ts +++ b/apps/ui/src/networks/evm/index.ts @@ -78,7 +78,7 @@ export const METADATA: Record = { 'skale-testnet': { name: 'Skale Testnet', chainId: 1444673419, - apiUrl: 'http://localhost:8000/subgraphs/name/snapshot-labs/sx-subgraph', + 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 } From e2bca1f0d8ca6ed7ccbdae5b1491f92863a5a234 Mon Sep 17 00:00:00 2001 From: rajkharvar Date: Wed, 8 May 2024 18:17:54 +0530 Subject: [PATCH 06/11] chore: add redirect to new space --- apps/ui/src/components/App/Sidebar.vue | 2 +- apps/ui/src/components/App/Topnav.vue | 2 +- apps/ui/src/router.ts | 2 +- packages/sx.js/src/clients/evm/ethereum-tx/index.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/ui/src/components/App/Sidebar.vue b/apps/ui/src/components/App/Sidebar.vue index c18340f9c..80647ea13 100644 --- a/apps/ui/src/components/App/Sidebar.vue +++ b/apps/ui/src/components/App/Sidebar.vue @@ -8,7 +8,7 @@ const spacesStore = useSpacesStore();