Skip to content

Commit

Permalink
Use subsquid aquarium (#239)
Browse files Browse the repository at this point in the history
Co-authored-by: Marin Petrunić <[email protected]>
  • Loading branch information
Tbaut and mpetrunic authored Jul 11, 2023
1 parent 01cb0f1 commit 0a49c77
Show file tree
Hide file tree
Showing 95 changed files with 7,686 additions and 4,560 deletions.
125 changes: 18 additions & 107 deletions .github/workflows/deploy-squid-stage.yaml
Original file line number Diff line number Diff line change
@@ -1,121 +1,32 @@
# naming convention: <project>/<environment>/<task>
name: multix/stage/deploy
name: subsquid aquarium deployment

on:
push:
paths:
- 'packages/squid/**'
- 'squid/**'
- '.github/workflows/deploy-squid-stage.yaml'
branches:
- main
# - ci/* # run this workflow if the branch starts with ci/*

env:
# secrets are listed here to simplify the readability
AWS_REGION: '${{ secrets.AWS_REGION }}'
AWS_ACCOUNT_ID: '${{ secrets.AWS_ACCOUNT_ID }}'
AWS_ROLE_NAME: '${{ secrets.AWS_ROLE_NAME }}'
APP_STAGE: 'stage'
DOCKER_REGISTRY: 'ghcr.io'
DOCKER_TAG: 'latest'
ENV_FILE: '${{ secrets.ENV_FILE }}'
- ci/* # run this workflow if the branch starts with "ci/""

jobs:
push:
name: push
runs-on: ubuntu-latest
strategy:
matrix:
target: ['squid-indexer', 'graphql-server']

permissions:
contents: read
id-token: write
packages: write

steps:
- name: checkout the source code
uses: actions/checkout@v3

- name: setup docker buildx
uses: docker/setup-buildx-action@v2

- name: login to ghcr
uses: docker/login-action@v2
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: docker build image
uses: docker/build-push-action@v4
env:
BUILDX_NO_DEFAULT_ATTESTATIONS: 1
with:
context: .
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
provenance: false
target: ${{ matrix.target }}
platforms: |
linux/amd64
tags: |
${{ env.DOCKER_REGISTRY }}/chainsafe/multix-${{ matrix.target }}:${{ env.DOCKER_TAG }}
${{ env.DOCKER_REGISTRY }}/chainsafe/multix-${{ matrix.target }}:${{ github.sha }}
deploy:
needs: push
name: deploy
runs-on: self-hosted
strategy:
matrix:
network: ['kusama', 'polkadot', 'rococo', 'phala', 'khala']

permissions:
contents: read
id-token: write

runs-on: ubuntu-latest
defaults:
run:
working-directory: squid
steps:
- name: checkout the source code
uses: actions/checkout@v3

- name: setup nodejs with yarn cache
uses: actions/setup-node@v3
continue-on-error: true
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version-file: '.node-version'
cache: 'yarn'

- name: install dependencies in root and squid package
run: |
corepack enable
yarn workspaces focus multix-squid
- name: generate squid code
run: yarn workspace multix-squid codegen

- name: build the squid package
run: yarn workspace multix-squid build

- name: generate database credentials
env:
SECRET_NAME: '${{ env.APP_STAGE }}/multix/${{ matrix.network }}'
run: generate-credentials "${{ env.SECRET_NAME }}" "${{ env.AWS_REGION }}"

- name: stop current service
env:
AWS_CLUSTER_NAME: 'multix-${{ env.APP_STAGE }}'
run: stop-service "${{ env.AWS_CLUSTER_NAME }}" "${{ matrix.network }}" "${{ env.AWS_REGION }}"

- name: dump database
run: drop-tables

- name: run migration
node-version: 16
cache: 'npm'
- name: install @subsquid/cli
run: npm install --location=global @subsquid/cli
- name: auth subsquid
run: |
source "${{ env.ENV_FILE }}"
yarn workspace multix-squid db:migrate
- name: cleanup credentials
if: always()
run: cleanup-credentials
sqd auth -k ${{ secrets.SUBSQUID_DEPLOYMENT_KEY }}
- name: deploy subsquid
id: deploy
run: sqd deploy -u .
8 changes: 4 additions & 4 deletions .github/workflows/lint-squid.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name: Lint squid
on:
pull_request:
paths: ['packages/squid/**/*', '.github/workflows/lint-squid.yaml']
paths: ['squid/**/*', '.github/workflows/lint-squid.yaml']
jobs:
extract:
name: eslint
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./packages/squid/
working-directory: ./squid/
steps:
- uses: actions/checkout@v3

Expand All @@ -23,7 +23,7 @@ jobs:
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}

- name: install packages
run: corepack enable && yarn install --immutable
run: npm ci

- name: lint
run: yarn squid:lint
run: npm run lint
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ target
node_modules
lib
build
builds
.env
*DS_Store
*.tsbuildinfo
Expand Down
7 changes: 4 additions & 3 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
.yarn
/packages/squid/db/**/*
/packages/squid/src/types/**/*
/packages/squid/src/model/**/*
/squid/db/**/*
/squid/src/types/**/*
/squid/src/model/**/*
/squid/lib/**/*
/packages/ui/src/gql/**/*
/packages/ui/src/interfaces/**/*
/packages/ui/types-and-hooks.tsx
Expand Down
9 changes: 0 additions & 9 deletions .prettierrc

This file was deleted.

11 changes: 11 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const config = {
tabWidth: 2,
semi: false,
singleQuote: true,
arrowParens: 'always',
singleAttributePerLine: true,
printWidth: 100,
trailingComma: 'none'
}

module.exports = { ...config }
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ services:
build:
context: .
target: graphql-server
env_file: packages/squid/.env
env_file: squid/.env
environment:
DB_HOST: db
ports:
Expand All @@ -21,7 +21,7 @@ services:
build:
context: .
target: squid-indexer
env_file: packages/squid/.env
env_file: squid/.env
environment:
DB_HOST: db
PROCESSOR_PROMETHEUS_PORT: 3000
Expand Down
11 changes: 1 addition & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,7 @@
"lint:fix": "yarn workspaces foreach run lint:fix",
"formatAll": "prettier --write .",
"ui:start": "yarn workspace multix-ui start",
"ui:lint": "yarn workspace multix-ui lint",
"squid:start": "yarn squid:build && yarn squid:codegen && yarn squid:migrate && yarn squid:start:indexer",
"squid:lint": "yarn workspace multix-squid lint",
"squid:codegen": "yarn workspace multix-squid codegen",
"squid:typegen": "yarn workspace multix-squid typegen",
"squid:build": "yarn workspace multix-squid build",
"squid:install": "yarn workspaces focus multix-squid",
"squid:migrate": "yarn workspace multix-squid db:migrate",
"squid:start:indexer": "yarn workspace multix-squid start:indexer",
"squid:start:graphql-server": "yarn workspace multix-squid start:graphql-server"
"ui:lint": "yarn workspace multix-ui lint"
},
"devDependencies": {
"eslint-config-prettier": "^8.8.0",
Expand Down
28 changes: 0 additions & 28 deletions packages/squid/.env.example

This file was deleted.

30 changes: 0 additions & 30 deletions packages/squid/src/processorHandlers/handleNewMultisigCalls.ts

This file was deleted.

3 changes: 0 additions & 3 deletions packages/squid/src/util/getAccountMultisigId.ts

This file was deleted.

8 changes: 0 additions & 8 deletions packages/squid/src/util/getMultisigCallId.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/ui/graphql.config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"overwrite": true,
"schema": "https://kusama.multix.chainsafe.io/graphql",
"schema": "http://localhost:4350/graphql",
"documents": "src/**/*.graphql",
"generates": {
"src/gql/": {
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/components/AccountEditName.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Grid } from '@mui/material'
import { ChangeEvent, useCallback, useEffect, useMemo, useState } from 'react'
import { ChangeEvent, useCallback, useMemo, useState } from 'react'
import { useAccounts } from '../contexts/AccountsContext'
import { useAccountNames } from '../contexts/AccountNamesContext'
import AccountDisplay from './AccountDisplay'
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/components/Header/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Box, IconButton, Toolbar, Typography } from '@mui/material'
import { Box, IconButton, Toolbar } from '@mui/material'
import { Button } from '../library'
import { styled } from '@mui/material/styles'
import { useMemo } from 'react'
Expand Down
8 changes: 5 additions & 3 deletions packages/ui/src/components/MultisigCompactDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { useEffect, useState } from 'react'
import { useQuery } from '@tanstack/react-query'
import { fetchData } from '../fetcher'
import { useNetwork } from '../contexts/NetworkContext'
import { useAccountId } from '../hooks/useAccountId'

interface Props {
address: string
Expand All @@ -22,13 +23,14 @@ interface Props {
const MultisigCompactDisplay = ({ className, address, expanded = false }: Props) => {
const [signatories, setSignatories] = useState<string[]>([])
const { selectedNetworkInfo } = useNetwork()
const accountId = useAccountId(address)
// we can't use the useMultisigById that got generated in types-and-hooks because we need a dynamic url
// to fetch for the right network
const { data, error, isFetching } = useQuery<MultisigByIdQuery, unknown, MultisigByIdQuery>(
['MultisigById', { account: address }],
['MultisigById', { id: accountId }],
fetchData<MultisigByIdQuery, MultisigByIdQueryVariables>(
MultisigByIdDocument,
{ account: address },
{ id: accountId },
undefined,
selectedNetworkInfo?.httpGraphqlUrl
)
Expand All @@ -47,7 +49,7 @@ const MultisigCompactDisplay = ({ className, address, expanded = false }: Props)

if (data?.accounts[0]) {
// this is a query by id, so it should return just 1 account
setSignatories(data.accounts[0].signatories.map(({ signatory }) => signatory.id))
setSignatories(data.accounts[0].signatories.map(({ signatory }) => signatory.address))
setThreshold(data.accounts[0].threshold)
setBadge(AccountBadge.MULTI)
}
Expand Down
Loading

0 comments on commit 0a49c77

Please sign in to comment.