Skip to content

MorpheusAIs/dashboard-subgraphs

Repository files navigation

Morpheus Subgraph Implementation

This repository contains the subgraph implementations for the Morpheus protocol, supporting three networks: Base, Arbitrum, and Arbitrum Sepolia.

Structure

The repository is organized as follows:

morpheus-subgraph/
├── schema.graphql                # Schema for Base and Arbitrum
├── schema-sepolia.graphql        # Schema for Arbitrum Sepolia
├── base-subgraph.yaml            # Subgraph manifest for Base
├── arbitrum-subgraph.yaml        # Subgraph manifest for Arbitrum
├── arbitrum-sepolia-subgraph.yaml # Subgraph manifest for Arbitrum Sepolia
├── src/
│   ├── subnet-registry-mapping.ts        # Mapping for Subnet entities
│   ├── builders-project-registry-mapping.ts  # Mapping for Base/Arbitrum builders
│   ├── builder-subnet-registry-mapping.ts    # Mapping for Arbitrum Sepolia builders
│   └── provider-registry-mapping.ts      # Mapping for Provider entities
├── abis/                        # Contract ABIs
└── generated/                   # Generated AssemblyScript types (created during build)

Prerequisites

  1. Install the Graph CLI:

    npm install -g @graphprotocol/graph-cli
  2. Install dependencies:

    npm install

Deployment Instructions

1. Base Network (Satsuma)

  1. Get access to Satsuma and create a new subgraph
  2. Generate the AssemblyScript types:
    graph codegen --config base-subgraph.yaml
  3. Build the subgraph:
    graph build --config base-subgraph.yaml
  4. Deploy to Satsuma:
    graph deploy --config base-subgraph.yaml --node https://subgraph.satsuma-prod.com/api/deploy --ipfs https://ipfs.satsuma-prod.com --access-token YOUR_SATSUMA_TOKEN

2. Arbitrum Network (The Graph Studio)

  1. Create a new subgraph in The Graph Studio
  2. Generate the AssemblyScript types:
    graph codegen --config arbitrum-subgraph.yaml
  3. Build the subgraph:
    graph build --config arbitrum-subgraph.yaml
  4. Authenticate with The Graph:
    graph auth --studio YOUR_DEPLOY_KEY
  5. Deploy to The Graph Studio:
    graph deploy --studio your-subgraph-name

3. Arbitrum Sepolia Network (Satsuma)

  1. Get access to Satsuma and create a new subgraph
  2. Generate the AssemblyScript types:
    graph codegen --config arbitrum-sepolia-subgraph.yaml
  3. Build the subgraph:
    graph build --config arbitrum-sepolia-subgraph.yaml
  4. Deploy to Satsuma:
    graph deploy --config arbitrum-sepolia-subgraph.yaml --node https://subgraph.satsuma-prod.com/api/deploy --ipfs https://ipfs.satsuma-prod.com --access-token YOUR_SATSUMA_TOKEN

Smart Contract Addresses

Before deploying, make sure to update the contract addresses in each subgraph.yaml file:

Base Network

  • SubnetRegistry: 0x...
  • BuildersProjectRegistry: 0x...
  • ProviderRegistry: 0x...

Arbitrum Network

  • SubnetRegistry: 0x...
  • BuildersProjectRegistry: 0x...
  • ProviderRegistry: 0x...

Arbitrum Sepolia Network

  • SubnetRegistry: 0x...
  • BuilderSubnetRegistry: 0x...
  • ProviderRegistry: 0x...

You can get the current contract addresses by checking the existing subgraphs or asking the protocol team.

Client Implementation

In your NextJS application, you should create an adapter layer to handle the differences between these subgraphs. See the morpheus-subgraph-schema.md document for detailed examples of how to build this adapter.

This is a Next.js project bootstrapped with create-next-app.

Getting Started

First, run the development server:

npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev

Open http://localhost:3000 with your browser to see the result.

You can start editing the page by modifying app/page.tsx. The page auto-updates as you edit the file.

This project uses next/font to automatically optimize and load Geist, a new font family for Vercel.

Learn More

To learn more about Next.js, take a look at the following resources:

You can check out the Next.js GitHub repository - your feedback and contributions are welcome!

Deploy on Vercel

The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.

Check out our Next.js deployment documentation for more details.

Network Support

This project supports multiple networks including both mainnet and testnet environments:

Supported Networks

Mainnet

  • Ethereum
  • Arbitrum One
  • Base

Testnet

  • Arbitrum Sepolia

Features

  • Visual Indicators: Clear testnet indicator in the navbar when using test networks
  • Network-Specific Balances: Displays MOR token balances for the appropriate networks
  • Contract Address Management: Centralized contract address configuration in config/networks.ts
  • Type Safety: Fully typed with TypeScript for better developer experience

Implementation Details

The network functionality is implemented using:

  1. Configuration: A centralized configuration system in config/networks.ts that defines all networks and contract addresses
  2. Wagmi Integration: Uses wagmi hooks for blockchain interactions and network state management
  3. UI Components:
    • mor-balance.tsx: Displays MOR token balances for relevant networks
    • testnet-indicator.tsx: Shows a clear visual indicator when on testnet

Usage

To access network state and contract addresses in your components:

import { useChainId } from 'wagmi'
import { morTokenContracts } from '@/lib/contracts'

function MyComponent() {
  const chainId = useChainId()
  const isTestnet = chainId === 421614 // Arbitrum Sepolia
  
  // Use the network state in your component
  // ...
}

Best Practices

  1. Always check the current chainId before making transactions
  2. Use the contract addresses from config instead of hardcoding addresses
  3. Handle both mainnet and testnet cases in your components
  4. Test thoroughly on testnets before deploying to mainnet

About

Subgraph recreation from Morpheus Dashboard v1

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published