Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages

name: Lint, Test, and Build

on:
pull_request:
types:
- closed
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
- name: Install dependencies
run: npm install
- name: Build
run: npm run build
42 changes: 42 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages

name: Lint, Test, and Build

on:
release:
types: [created]
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
- name: Install dependencies
run: npm install
- name: Build
run: npm run build
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Authenticate to Google Cloud
uses: "google-github-actions/auth@v2"
with:
credentials_json: "${{ secrets.GCP_CREDENTIALS }}"
- name: Set up Google Cloud SDK
uses: google-github-actions/setup-gcloud@v2
with:
project_id: mesh-432507
install_components: "gcloud"
- name: Prerun GCP auth
run: |
gcloud auth configure-docker asia-southeast1-docker.pkg.dev
- name: Deploy Backend
run: npm run deploy
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,8 @@ yarn-error.log*
*.pem

*/**/.Build
package-lock.json
package-lock.json

# GCP
key.json
service-account.json
4 changes: 2 additions & 2 deletions apps/mesh-cloud/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"copy-to-clipboard": "^3.3.3",
"geist": "^1.3.0",
"lucide-react": "^0.436.0",
"next": "^14.2.4",
"next": "^15.2.0",
"next-auth": "^4.24.7",
"react": "^18.3.1",
"react-dom": "^18.3.1",
Expand Down Expand Up @@ -74,4 +74,4 @@
"initVersion": "7.37.0"
},
"packageManager": "npm@10.7.0"
}
}
4 changes: 1 addition & 3 deletions apps/mesh-cloud/src/apps/dev/transaction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ export function SelectNetwork({
return (
<Select onValueChange={setValue}>
<SelectTrigger className="w-[180px]">
<SelectValue
placeholder={placeholder ? placeholder : "Select a Network"}
/>
<SelectValue placeholder={placeholder ?? "Select a Network"} />
</SelectTrigger>
<SelectContent>
<SelectGroup>
Expand Down
2 changes: 2 additions & 0 deletions apps/mesh-cloud/src/apps/mesh-utils/serializeNativeScript.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ export default function SerializeNativeScript() {
],
};

console.log("EXPRESS_BACKEND_URL", EXPRESS_BACKEND_URL);

const res = await axios.post(
`${EXPRESS_BACKEND_URL}users/meshUtilities/serializers/serializeNativeScript`,
{
Expand Down
11 changes: 7 additions & 4 deletions apps/mesh-cloud/src/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ export const env = createEnv({
* `NEXT_PUBLIC_`.
*/
client: {
NEXT_PUBLIC_BACKEND_URL: z.string().url(),
NEXT_PUBLIC_BLOCKFROST_API_KEY_PREPROD: z.string(),
// NEXT_PUBLIC_EXPRESS_BACKEND_URL: z.string().url(),
// NEXT_PUBLIC_BLOCKFROST_API_KEY_PREPROD: z.string(),
},

/**
Expand All @@ -46,10 +46,13 @@ export const env = createEnv({
NODE_ENV: process.env.NODE_ENV,
// NEXTAUTH_SECRET: process.env.NEXTAUTH_SECRET,
// NEXTAUTH_URL: process.env.NEXTAUTH_URL,
NEXT_PUBLIC_BACKEND_URL: process.env.NEXT_PUBLIC_BACKEND_URL,
// NEXT_PUBLIC_EXPRESS_BACKEND_URL: process.env.NEXT_PUBLIC_EXPRESS_BACKEND_URL,
// DISCORD_CLIENT_ID: process.env.DISCORD_CLIENT_ID,
// DISCORD_CLIENT_SECRET: process.env.DISCORD_CLIENT_SECRET,
NEXT_PUBLIC_BLOCKFROST_API_KEY_PREPROD: process.env.NEXT_PUBLIC_BLOCKFROST_API_KEY_PREPROD
// BLOCKFROST_API_KEY_PREPROD: process.env.BLOCKFROST_API_KEY_PREPROD,
// BLOCKFROST_API_KEY_TESTNET: process.env.BLOCKFROST_API_KEY_TESTNET,
// BLOCKFROST_API_KEY_MAINNET: process.env.BLOCKFROST_API_KEY_MAINNET,
// BLOCKFROST_API_KEY_PREVIEW: process.env.BLOCKFROST_API_KEY_PREVIEW,
},
/**
* Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially
Expand Down
11 changes: 9 additions & 2 deletions apps/mesh-cloud/src/hooks/useValidateStaking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,19 @@ import {
import { useWallet } from "@meshsdk/react";
import { useCallback, useEffect, useState } from "react";

const blockfrostApiKey = process.env.NEXT_PUBLIC_BLOCKFROST_API_KEY_PREPROD!;
const meshPoolId = process.env.NEXT_PUBLIC_MESH_POOL_ID!;
const meshDRepId = process.env.NEXT_PUBLIC_MESH_DREP_ID!; // (Leon, 10/08/2024) - Use CIP-105 DRep ID for backward compatibility, as current Mesh csl does not support CIP-129 yet

export function getProvider(network = "preprod") {
const blockchainProvider = new BlockfrostProvider(
`/api/blockfrost/${network}/`,
);
blockchainProvider.setSubmitTxToBytes(false);
return blockchainProvider;
}

export const useValidateStaking = () => {
const blockchainProvider = new BlockfrostProvider(blockfrostApiKey);
const blockchainProvider = getProvider("mainnet");

const walletInfo = useWallet();

Expand Down
3 changes: 1 addition & 2 deletions apps/mesh-cloud/src/lib/axios.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import axios from "axios";
import { env } from "@/env";

const url = env.NEXT_PUBLIC_BACKEND_URL;
const url = process.env.NEXT_PUBLIC_YACI_BACKEND_URL;

export const instance = axios.create({
baseURL: url,
Expand Down
81 changes: 81 additions & 0 deletions apps/mesh-cloud/src/pages/api/blockfrost/[...slug].ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import type { NextApiRequest, NextApiResponse } from "next";
import axios from "axios";

import { toBytes } from "@meshsdk/common";

export default async function handler(
_req: NextApiRequest,
_res: NextApiResponse,
) {
try {
let { slug } = _req.query;
slug = slug as string[];

const network = slug[0];
let key = process.env.BLOCKFROST_API_KEY_PREPROD;
switch (network) {
case "testnet":
key = process.env.BLOCKFROST_API_KEY_TESTNET;
break;
case "mainnet":
key = process.env.BLOCKFROST_API_KEY_MAINNET;
break;
case "preview":
key = process.env.BLOCKFROST_API_KEY_PREVIEW;
break;
}

const axiosInstance = axios.create({
baseURL: `https://cardano-${network}.blockfrost.io/api/v0`,
headers: { project_id: key },
});

/**
* get url from slug
*/
let url = slug?.slice(1).join("/");

// get params if exists
const params = _req.query;
delete _req.query.slug;
if (Object.keys(params).length > 0) {
url += "?";

for (const key in params) {
url += `${key}=${params[key] as string}&`;
}
}

// end get params if exists
if (url == "tx/submit") {
const body = _req.body;

const headers = { "Content-Type": "application/cbor" };
const { data, status } = await axiosInstance.post(
"tx/submit",
toBytes(body),
{
headers,
},
);
_res.status(status).json(data);
} else if (url == "utils/txs/evaluate") {
const body = _req.body;

const headers = { "Content-Type": "application/cbor" };
const { status, data } = await axiosInstance.post(
"utils/txs/evaluate",
body,
{
headers,
},
);
_res.status(status).json(data);
} else {
const { data, status } = await axiosInstance.get(`${url}`);
_res.status(status).json(data);
}
} catch (error) {
_res.status(500).json(error);
}
}
2 changes: 1 addition & 1 deletion backend/express/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@
"turbo": "^2.1.3",
"typescript": "^5.6.3"
}
}
}
2 changes: 1 addition & 1 deletion backend/express/scripts/deploy-cloud-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fi
if [ "$1" == "express" ]; then
echo "Parameter is 'express'. Running commands..."

docker buildx build --platform linux/amd64 -t mesh-cloud-backend-server-image .
docker buildx build --platform linux/amd64 -t mesh-cloud-backend-server-image --load .
docker tag mesh-cloud-backend-server-image asia-southeast1-docker.pkg.dev/mesh-432507/mesh-saas-repo/mesh-cloud-backend-server-image
docker push asia-southeast1-docker.pkg.dev/mesh-432507/mesh-saas-repo/mesh-cloud-backend-server-image:latest
gcloud run deploy mesh-cloud-backend-server-image --image=asia-southeast1-docker.pkg.dev/mesh-432507/mesh-saas-repo/mesh-cloud-backend-server-image:latest --project mesh-432507 --region=asia-southeast1 --allow-unauthenticated
Expand Down
2 changes: 1 addition & 1 deletion backend/yaci/scripts/deploy-cloud-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fi
if [ "$1" == "yaci" ]; then
echo "Parameter is 'yaci'. Running commands..."

docker buildx build --platform linux/amd64 -t yaci-backend-image .
docker buildx build --platform linux/amd64 -t yaci-backend-image --load .
docker tag yaci-backend-image asia-southeast1-docker.pkg.dev/mesh-432507/mesh-saas-repo/yaci-backend-image
docker push asia-southeast1-docker.pkg.dev/mesh-432507/mesh-saas-repo/yaci-backend-image:latest
gcloud run deploy yaci-backend-image --image=asia-southeast1-docker.pkg.dev/mesh-432507/mesh-saas-repo/yaci-backend-image:latest --project mesh-432507 --region=asia-southeast1 --allow-unauthenticated
Expand Down
1 change: 1 addition & 0 deletions documentation/start_yaci_custom_pp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Starting YACI with custom Protocol Parameters
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"dev": "turbo dev",
"lint": "turbo lint",
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
"clean": "turbo run clean && rm -rf .turbo && rm -rf dist && rm -rf node_modules && rm package-lock.json"
"clean": "turbo run clean && rm -rf .turbo && rm -rf dist && rm -rf node_modules && rm package-lock.json",
"deploy": "turbo run sh:deploy"
},
"devDependencies": {
"prettier": "^3.2.5",
Expand All @@ -23,4 +24,4 @@
"apps/*",
"backend/*"
]
}
}
9 changes: 8 additions & 1 deletion turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
"$schema": "https://turbo.build/schema.json",
"ui": "tui",
"tasks": {
"sh:deploy": {
"dependsOn": [
"^build"
]
},
"build": {
"dependsOn": [
"^build:backend",
Expand Down Expand Up @@ -40,7 +45,9 @@
]
},
"dev": {
"dependsOn": ["^build"],
"dependsOn": [
"^build"
],
"cache": false,
"persistent": true
},
Expand Down