Skip to content

Commit

Permalink
chore: syncing last changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Picodes committed Dec 19, 2024
2 parents e055253 + de6c327 commit 44db095
Show file tree
Hide file tree
Showing 59 changed files with 1,330 additions and 394 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/update_production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Trigger production deployment

on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'

defaults:
run:
shell: bash

jobs:
tag-image:
runs-on: ubuntu-latest
env:
IMAGE_URL: europe-west1-docker.pkg.dev/angle-artifacts/angle-docker-registry/merkl-app
steps:
- uses: 'google-github-actions/auth@v0'
with:
credentials_json: '${{ secrets.GCLOUD_SECRET_ARTIFACTS }}'
- name: Login to Docker
run: gcloud auth configure-docker europe-west1-docker.pkg.dev
- name: Pull and tag image
run: |
export SHORT_SHA=${GITHUB_SHA:0:7}
export VERSION=${GITHUB_REF#refs/tags/}
docker pull $IMAGE_URL:$SHORT_SHA
docker tag $IMAGE_URL:$SHORT_SHA $IMAGE_URL:$VERSION
docker push $IMAGE_URL:$VERSION
trigger-production-deployment:
runs-on: ubuntu-latest
needs: tag-image
steps:
- name: Install dependencies
run: |
sudo snap install yq
- name: Clone deployments repo
uses: actions/checkout@v3
with:
repository: AngleProtocol/deployments
token: ${{ secrets.ACCESS_TOKEN }}
path: deployments
- name: Modify config.production.yaml and push to deployments
run: |
cd deployments
export VERSION=${GITHUB_REF#refs/tags/}
yq -i '.merkl-app.version = strenv(VERSION)' ./config.production.yaml
git config --global user.email "[email protected]"
git config --global user.name "BaptistG"
git add ./config.production.yaml
git commit -m "Update config.production.yaml with merkl-app version $VERSION"
git push
68 changes: 68 additions & 0 deletions .github/workflows/update_staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Build image and trigger staging deployment

on:
workflow_dispatch:
push:
branches:
- main

defaults:
run:
shell: bash

jobs:
build-image:
runs-on: ubuntu-latest
env:
IMAGE_URL: europe-west1-docker.pkg.dev/angle-artifacts/angle-docker-registry/merkl-app
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
token: '${{ secrets.ACCESS_TOKEN }}'
- uses: actions/setup-node@v3
with:
node-version: 18
- uses: 'google-github-actions/auth@v0'
with:
credentials_json: '${{ secrets.GCLOUD_SECRET_ARTIFACTS }}'
- name: Login to Docker
run: gcloud auth configure-docker europe-west1-docker.pkg.dev
- name: Build image
run: |
export SHORT_SHA=${GITHUB_SHA:0:7}
docker pull $IMAGE_URL:latest || true
docker build --cache-from $IMAGE_URL:latest --tag $IMAGE_URL:$SHORT_SHA --tag $IMAGE_URL:latest .
- name: Push image
run: |
export SHORT_SHA=${GITHUB_SHA:0:7}
docker push $IMAGE_URL:$SHORT_SHA
trigger-staging-deployment:
runs-on: ubuntu-latest
needs: build-image
steps:
- name: Install dependencies
run: |
sudo snap install yq
- name: Clone deployments repo
uses: actions/checkout@v3
with:
repository: AngleProtocol/deployments
token: ${{ secrets.ACCESS_TOKEN }}
path: deployments
- name: Modify config.staging.yaml and push to deployments
run: |
cd deployments
export SHORT_SHA=${GITHUB_SHA:0:7}
yq -i '.merkl-app.version = strenv(SHORT_SHA)' ./config.staging.yaml
git config --global user.email "[email protected]"
git config --global user.name "BaptistG"
git add ./config.staging.yaml
git commit -m "Update config.staging.yaml with merkl-app version $SHORT_SHA"
git push
4 changes: 4 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"recommendations": [],
"unwantedRecommendations": []
}
18 changes: 18 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"editor.codeActionsOnSave": {
"source.organizeImports.biome": "explicit"
},
"editor.defaultFormatter": "biomejs.biome",
"[typescript]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[javascript]": {
"editor.defaultFormatter": "biomejs.biome"
},
"editor.formatOnSave": true,
"editor.formatOnType": false,
"editor.foldingImportsByDefault": true,
"editor.foldingHighlight": true,
"editor.foldingStrategy": "auto",
"files.eol": "\n"
}
Binary file modified bun.lockb
Binary file not shown.
23 changes: 14 additions & 9 deletions merkl.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { createColoring } from "dappkit";
import { createConfig } from "src/config/type";
import hero from "src/customer/assets/images/hero.jpg?url";
import { v4 as uuidv4 } from "uuid";
import { http, createClient, custom } from "viem";

import {
arbitrum,
astar,
Expand Down Expand Up @@ -45,7 +47,10 @@ export default createConfig({
appName: "Merkl",
modes: ["dark", "light"],
defaultTheme: "ignite",
deposit: false,
tags: [],
opportunityNavigationMode: "direct",
rewardsNavigationMode: "chain",
deposit: true,
themes: {
ignite: {
base: createColoring(["#1755F4", "#FF7900", "#0D1530"], ["#1755F4", "#FF7900", "#FFFFFF"]),
Expand Down Expand Up @@ -88,43 +93,43 @@ export default createConfig({
home: {
icon: "RiHomeFill",
route: "/",
key: crypto.randomUUID(),
key: uuidv4(),
},
opportunities: {
icon: "RiPlanetFill",
route: "/opportunities",
key: crypto.randomUUID(),
key: uuidv4(),
},
// protocols: {
// icon: "RiVipCrown2Fill",
// route: "/protocols",
// key: crypto.randomUUID(),
// key: uuidv4(),
// },
// bridge: {
// icon: "RiCompassesLine",
// route: "/bridge",
// key: crypto.randomUUID(),
// key: uuidv4(),
// },
docs: {
icon: "RiFile4Fill",
external: true,
route: "https://docs.merkl.xyz/",
key: crypto.randomUUID(),
key: uuidv4(),
},
faq: {
icon: "RiQuestionFill",
route: "/faq",
key: crypto.randomUUID(),
key: uuidv4(),
},
// terms: {
// icon: "RiCompassesLine",
// route: "/terms",
// key: crypto.randomUUID(),
// key: uuidv4(),
// },
// privacy: {
// icon: "RiInformationFill",
// route: "/privacy",
// key: crypto.randomUUID(),
// key: uuidv4(),
// },
},
socials: {
Expand Down
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,13 @@
"serve": "remix-serve ./build/server/index.js",
"typecheck": "tsc"
},
"workspaces": [
"packages/*"
],
"workspaces": ["packages/*"],
"dependencies": {
"@acab/ecsstatic": "^0.8.0",
"@ariakit/react": "^0.4.12",
"@elysiajs/eden": "^1.1.3",
"@emotion/css": "^11.13.4",
"@merkl/api": "0.10.156",
"@merkl/api": "0.10.188",
"@radix-ui/react-accordion": "^1.2.1",
"@radix-ui/react-scroll-area": "^1.2.0",
"@remix-run/dev": "^2.11.2",
Expand Down Expand Up @@ -49,6 +47,7 @@
"tailwindcss": "^3.4.12",
"tailwindcss-animate": "^1.0.7",
"typedoc": "^0.26.7",
"uuid": "^11.0.3",
"viem": "2.21.54",
"vite-plugin-dts": "^4.2.1",
"wagmi": "^2.12.29",
Expand Down
43 changes: 0 additions & 43 deletions src/api/opportunity/opportunity.ts

This file was deleted.

4 changes: 2 additions & 2 deletions src/api/services/campaigns/campaign.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ export abstract class CampaignService {
const action = new URL(request.url).searchParams.get("action");
const chainId = new URL(request.url).searchParams.get("chain");
const page = new URL(request.url).searchParams.get("page");

const test = new URL(request.url).searchParams.get("test") ?? undefined;
const items = new URL(request.url).searchParams.get("items");
const search = new URL(request.url).searchParams.get("search");
const [sort, order] = new URL(request.url).searchParams.get("sort")?.split("-") ?? [];

const filters = Object.assign(
{ status, action, chainId, items, sort, order, name: search, page },
{ status, action, chainId, items, sort, order, name: search, page, test },
override ?? {},
page !== null && { page: Number(page) - 1 },
);
Expand Down
20 changes: 20 additions & 0 deletions src/api/services/claims.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { api } from "../index.server";
import { fetchWithLogs } from "../utils";

export abstract class ClaimsService {
static async #fetch<R, T extends { data: R; status: number; response: Response }>(
call: () => Promise<T>,
resource = "Claims",
): Promise<NonNullable<T["data"]>> {
const { data, status } = await fetchWithLogs(call);

if (status === 404) throw new Response(`${resource} not found`, { status });
if (status === 500) throw new Response(`${resource} unavailable`, { status });
if (data == null) throw new Response(`${resource} unavailable`, { status });
return data;
}

static async getForUser(address: string) {
return await ClaimsService.#fetch(async () => api.v4.claims({ address }).get());
}
}
56 changes: 56 additions & 0 deletions src/api/services/interaction.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { api as clientApi } from "src/api/index.client";
import { fetchWithLogs } from "../utils";

export abstract class InteractionService {
static async #fetch<R, T extends { data: R; status: number; response: Response }>(
call: () => Promise<T>,
resource = "Chain",
): Promise<NonNullable<T["data"]>> {
const { data, status } = await fetchWithLogs(call);

if (status === 404) throw new Response(`${resource} not found`, { status });
if (status === 500) throw new Response(`${resource} unavailable`, { status });
if (data == null) throw new Response(`${resource} unavailable`, { status });
return data;
}

/**
* Client side
* @param chainId
* @param protocolId
* @param identifier
*/
static async getTarget(chainId: number, protocolId: string, identifier: string) {
const targets = await InteractionService.#fetch(() =>
clientApi.v4.interaction.targets.get({
query: { chainId, protocolId, identifier },
}),
);

//TODO: opportunity/:id/target instead of taking the first result and expecting unique
return targets?.[0];
}

/**
* Client side
*/
static async getTransaction(payload: Parameters<typeof clientApi.v4.interaction.transaction.get>[0]["query"]) {
const transaction = await InteractionService.#fetch(() =>
clientApi.v4.interaction.transaction.get({
query: payload,
}),
);

return transaction;
}

static async getBalances(chainId: number, address: string) {
const tokens = await InteractionService.#fetch(() =>
clientApi.v4.tokens.balances.get({
query: { chainId: chainId, userAddress: address },
}),
);

return tokens;
}
}
Loading

0 comments on commit 44db095

Please sign in to comment.