From 8e590b9563725a833346f26491e3f4759c31c66f Mon Sep 17 00:00:00 2001 From: Shreerang Kale Date: Fri, 25 Jul 2025 11:29:21 +0530 Subject: [PATCH] Add script to run commands for publishing records from container --- .env.example | 5 +- deploy/README.md | 29 ++++-- deploy/config.yml | 10 +- deploy/laconic-cli.sh | 50 +++++++++ deploy/publish-pricing.md | 168 +++++++++++++++++-------------- src/app/api/registry/route.ts | 6 -- src/app/page.tsx | 10 -- src/components/StatusDisplay.tsx | 4 - src/config/index.ts | 12 +-- src/types/index.ts | 3 - 10 files changed, 170 insertions(+), 127 deletions(-) create mode 100755 deploy/laconic-cli.sh diff --git a/.env.example b/.env.example index 9690332..e4f5829 100644 --- a/.env.example +++ b/.env.example @@ -16,9 +16,8 @@ NEXT_PUBLIC_EXAMPLE_URL=https://git.vdb.to/cerc-io/test-progressive-web-app NEXT_PUBLIC_REGISTRY_CHAIN_ID=laconic-mainnet NEXT_PUBLIC_REGISTRY_RPC_ENDPOINT=https://laconicd-mainnet-1.laconic.com NEXT_PUBLIC_REGISTRY_GQL_ENDPOINT=https://laconicd-mainnet-1.laconic.com/graphql -NEXT_PUBLIC_REGISTRY_GAS_PRICE=0.001 -NEXT_PUBLIC_ALNT_COST_LRN= -NEXT_PUBLIC_DEPLOYMENT_COST_LRN= +NEXT_PUBLIC_ALNT_COST_LRN=lrn://laconic/pricing/alnt +NEXT_PUBLIC_DEPLOYMENT_COST_LRN=lrn://laconic/pricing/webapp-deployment REGISTRY_BOND_ID= REGISTRY_AUTHORITY= REGISTRY_USER_KEY= diff --git a/deploy/README.md b/deploy/README.md index be5ed5f..71a087f 100644 --- a/deploy/README.md +++ b/deploy/README.md @@ -1,17 +1,26 @@ # Deploy +## Prerequisites + +This project requires pricing records for cost of deployment and cost of alnt to be published + +- Cost of deployment: `lrn://laconic/pricing/webapp-deployment` +- Cost of alnt: `lrn://laconic/pricing/alnt` + +If these records are not available, [follow these steps to publish them](./publish-pricing.md) + ## Setup ### gor-deploy -* Clone the repo: +- Clone the repo: ```bash git clone git@git.vdb.to:LaconicNetwork/gor-deploy.git cd gor-deploy/deploy ``` -* Build registry CLI image: +- Build registry CLI image: ```bash docker build -t cerc/laconic-registry-cli . @@ -19,13 +28,13 @@ # Builds image cerc/laconic-registry-cli:latest ``` -* Configure `userKey` and `bondId` in the [registry CLI config](./config.yml): +- Configure `userKey` and `bondId` in the [registry CLI config](./config.yml): ```bash nano config.yml ``` -* Add configuration for registry operations: +- Add configuration for registry operations: ```bash cp .registry.env.example .registry.env @@ -34,7 +43,7 @@ nano .registry.env ``` -* Add configuration for the app: +- Add configuration for the app: ```bash curl -s https://git.vdb.to/LaconicNetwork/gor-deploy/src/branch/main/.env.example -o .app.env @@ -45,9 +54,7 @@ ## Run -### gor-deploy - -* Deploy `gor-deploy` App: +- Deploy `gor-deploy` App: ```bash # In gor-deploy/deploy dir @@ -58,13 +65,13 @@ ./deploy.sh ``` -* Check deployment logs on deployer UI: +- Check deployment logs on deployer UI: -* Visit deployed app: +- Visit deployed app: ### Remove deployment -* Remove deployment: +- Remove deployment: ```bash # In gor-deploy/deploy dir diff --git a/deploy/config.yml b/deploy/config.yml index 0ae673d..5320dd5 100644 --- a/deploy/config.yml +++ b/deploy/config.yml @@ -1,9 +1,9 @@ # Registry CLI config services: registry: - rpcEndpoint: 'https://laconicd-mainnet-1.laconic.com' - gqlEndpoint: 'https://laconicd-mainnet-1.laconic.com/api' - userKey: - bondId: - chainId: laconic-mainnet + rpcEndpoint: 'http://host.docker.internal:26657' + gqlEndpoint: 'http://host.docker.internal:9473/graphql' + userKey: 30289fd5adf6040e7e3cb37a39657a1e1de99f12260ba20929b1a151345dc07a + bondId: '' + chainId: laconic_9000-1 gasPrice: 0.001alnt diff --git a/deploy/laconic-cli.sh b/deploy/laconic-cli.sh new file mode 100755 index 0000000..2325582 --- /dev/null +++ b/deploy/laconic-cli.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# Laconic Registry CLI Docker wrapper script +# This script wraps the Docker command to run laconic registry CLI commands +# Run this script from the deploy directory + +# Check if docker is available +if ! command -v docker &> /dev/null; then + echo "Error: Docker is not installed or not in PATH" + exit 1 +fi + +# Check if the cerc/laconic-registry-cli image exists +if ! docker image inspect cerc/laconic-registry-cli &> /dev/null; then + echo "Error: cerc/laconic-registry-cli Docker image not found" + echo "Please build the image first: docker build -t cerc/laconic-registry-cli ." + exit 1 +fi + +# Get current directory (should be deploy directory) +CURRENT_DIR="$(pwd)" +PROJECT_ROOT="$(dirname "$CURRENT_DIR")" + +# Verify we're in the deploy directory +if [ ! -f "config.yml" ] || [ ! -f "laconic-cli.sh" ]; then + echo "Error: This script must be run from the deploy directory" + echo "Current directory: $CURRENT_DIR" + echo "Please cd to the deploy directory and run: ./laconic-cli.sh" + exit 1 +fi + +# Set up volume mounts +DEPLOY_MOUNT="-v $CURRENT_DIR:/app/deploy" +OUT_MOUNT="" + +# Create out directory if it doesn't exist and always mount it +if [ ! -d "out" ]; then + mkdir -p "out" +fi +OUT_MOUNT="-v $CURRENT_DIR/out:/app/out" + +# Run the Docker command with processed arguments +docker run --rm \ + --add-host=host.docker.internal:host-gateway \ + $DEPLOY_MOUNT \ + $OUT_MOUNT \ + -w /app/deploy \ + cerc/laconic-registry-cli \ + laconic registry -c config.yml \ + "$@" diff --git a/deploy/publish-pricing.md b/deploy/publish-pricing.md index 7133299..79b077a 100644 --- a/deploy/publish-pricing.md +++ b/deploy/publish-pricing.md @@ -1,35 +1,36 @@ # publish-pricing -## Prerequisites - -- Install packages: - - ```bash - npm install - ``` - ## Setup +- Clone the repo: + + ```bash + git clone git@git.vdb.to:LaconicNetwork/gor-deploy.git + cd gor-deploy/deploy + ``` + +- Build the Docker container: + + ```bash + docker build -t cerc/laconic-registry-cli . + + # Builds image cerc/laconic-registry-cli:latest + ``` + +- Make the CLI script executable: + + ```bash + chmod +x laconic-cli.sh + ``` + - Configure `userKey` in the [registry CLI config](./config.yml): + NOTE: User key should be of the account that owns the `laconic` authority + ```bash nano config.yml ``` -## Create Bond (optional) - -- Create bond: - - ```bash - npm run laconic -- bond create --type alnt --quantity 100000000 - ``` - -- Get bond info: - - ```bash - npm run laconic -- bond get --id - ``` - ## Publish Record NOTE: Publishing record requires a bond with enough funds, if you don't have a bond check [steps to create bond](#create-bond-optional) @@ -48,18 +49,18 @@ NOTE: Publishing record requires a bond with enough funds, if you don't have a b - Amount calculation: - Cost of 1 deployment is `12960` in terms of `alnt` or `5` in terms of `USD` - - So cost of 1 `alnt` comes out be `0.000385802 USD` rounded off to 6 decimals + - Hence, cost of 1 `alnt` comes out be `0.000385802 USD` rounded off to 6 decimals - Publish the record: ```bash - npm run laconic -- record publish --filename deploy/pricing.yml --bond-id + ./laconic-cli.sh record publish --filename pricing.yml --bond-id ``` - Get record info: ```bash - npm run laconic -- record get --id + ./laconic-cli.sh record get --id ``` ### Publish Record for Cost of Deployment @@ -77,73 +78,29 @@ NOTE: Publishing record requires a bond with enough funds, if you don't have a b - Publish the record: ```bash - npm run laconic -- record publish --filename deploy/pricing.yml --bond-id + ./laconic-cli.sh record publish --filename pricing.yml --bond-id ``` - Get record info: ```bash - npm run laconic -- record get --id - ``` - -## Reserve a New Authority (optional) - -- Reserve authority: - - ```bash - npm run laconic -- authority reserve laconic - ``` - -- Check authority info: - - ```bash - npm run laconic -- authority whois laconic - ``` - - - Note down auction ID from authority info as it is required in next steps - -- Get auction info: - - ```bash - npm run laconic -- auction get - ``` - -- Commit an auction bid: - - ```bash - npm run laconic -- auction bid commit 25000000 alnt - - Reveal file: ./out/bafyreiay2rccax64yn4ljhvzvm3jkbebvzheyucuma5jlbpzpzd5i5gjuy.json - ``` - -- Reveal bid: - - ```bash - npm run laconic -- auction bid reveal ./out/bafyreiay2rccax64yn4ljhvzvm3jkbebvzheyucuma5jlbpzpzd5i5gjuy.json - ``` - -### Set Authority Bond - -- Set authority bond after winning auction: - - ```bash - npm run laconic -- authority bond set laconic + ./laconic-cli.sh record get --id ``` ## Set Record Name -NOTE: To set record name an authority with an authority bond is required +NOTE: To set record name an authority with an authority bond is required, if you don't have an authority check [steps to reserve a new authority](#reserve-a-new-authority-optional) - Set record name for cost of alnt record ```bash - npm run laconic -- name set lrn:///pricing/alnt + ./laconic-cli.sh name set lrn://laconic/pricing/alnt ``` - Set record name for cost of deployment record ```bash - npm run laconic -- name set lrn:///pricing/webapp-deployment + ./laconic-cli.sh name set lrn://laconic/pricing/webapp-deployment ``` ## Delete Record Name @@ -151,5 +108,66 @@ NOTE: To set record name an authority with an authority bond is required - Delete record name: ```bash - npm run laconic -- name delete + ./laconic-cli.sh name delete + ``` + +## Create Bond (optional) + +- Create bond: + + ```bash + ./laconic-cli.sh bond create --type alnt --quantity 100000000 + ``` + +- Get bond info: + + ```bash + ./laconic-cli.sh bond get --id + ``` + +## Reserve a New Authority (optional) + +Below steps are used to reserve `laconic` authority + +- Reserve authority: + + ```bash + ./laconic-cli.sh authority reserve laconic + ``` + +- Check authority info: + + ```bash + ./laconic-cli.sh authority whois laconic + ``` + + - Note down auction ID from authority info as it is required in next steps + +- Get auction info: + + ```bash + ./laconic-cli.sh auction get + ``` + +- Commit an auction bid: + + ```bash + ./laconic-cli.sh auction bid commit 25000000 alnt + + # Path inside container + Reveal file: /app/deploy/out/bafyreiay2rccax64yn4ljhvzvm3jkbebvzheyucuma5jlbpzpzd5i5gjuy.json + ``` + +- Reveal bid: + + ```bash + ./laconic-cli.sh auction bid reveal /app/deploy/out/bafyreiay2rccax64yn4ljhvzvm3jkbebvzheyucuma5jlbpzpzd5i5gjuy.json + ``` + +### Set Authority Bond + +- Set authority bond after winning auction: + + ```bash + ./laconic-cli.sh authority bond set laconic ``` diff --git a/src/app/api/registry/route.ts b/src/app/api/registry/route.ts index fc83a11..69d9dcb 100644 --- a/src/app/api/registry/route.ts +++ b/src/app/api/registry/route.ts @@ -3,9 +3,7 @@ import { NextRequest, NextResponse } from 'next/server'; import axios from 'axios'; import assert from 'assert'; -import { GasPrice } from '@cosmjs/stargate'; import { Connection } from '@solana/web3.js'; -import { DENOM as ALNT_DENOM } from '@cerc-io/registry-sdk'; import { verifyUnusedSolanaPayment } from '@/utils/solana-verify'; import { transferLNTTokens } from '@/services/laconic-transfer'; @@ -302,10 +300,6 @@ export async function POST(request: NextRequest) { const deployerLrn = process.env.DEPLOYER_LRN!; - // Create Registry client instance - const gasPrice = GasPrice.fromString(config.fee.gasPrice + ALNT_DENOM); - console.log('Using manual gas price:', gasPrice); - const registry = getRegistry() // Create LRN for the application with commit hash diff --git a/src/app/page.tsx b/src/app/page.tsx index eba62d2..862f6cc 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -29,8 +29,6 @@ export default function Home() { const [dns, setDns] = useState(null); const [appName, setAppName] = useState(null); const [repoUrl, setRepoUrl] = useState(null); - const [commitHash, setCommitHash] = useState(null); - const [shortCommitHash, setShortCommitHash] = useState(null); const [error, setError] = useState(null); const handleConnectWallet = () => { @@ -72,12 +70,6 @@ export default function Home() { if (result.repoUrl) { setRepoUrl(result.repoUrl); } - if (result.commitHash) { - setCommitHash(result.commitHash); - } - if (result.shortCommitHash) { - setShortCommitHash(result.shortCommitHash); - } setStatus('success'); } else { setStatus('error'); @@ -162,8 +154,6 @@ export default function Home() { dns={dns || undefined} appName={appName || undefined} repoUrl={repoUrl || undefined} - commitHash={commitHash || undefined} - shortCommitHash={shortCommitHash || undefined} error={error || undefined} /> diff --git a/src/components/StatusDisplay.tsx b/src/components/StatusDisplay.tsx index 715d628..8c518c7 100644 --- a/src/components/StatusDisplay.tsx +++ b/src/components/StatusDisplay.tsx @@ -9,8 +9,6 @@ interface StatusDisplayProps { dns?: string; appName?: string; repoUrl?: string; - commitHash?: string; - shortCommitHash?: string; error?: string; } @@ -23,8 +21,6 @@ export default function StatusDisplay({ dns, appName, repoUrl, - commitHash, - shortCommitHash, error, }: StatusDisplayProps) { // Get domain suffix from environment variable diff --git a/src/config/index.ts b/src/config/index.ts index 0a9954b..bbd2591 100644 --- a/src/config/index.ts +++ b/src/config/index.ts @@ -1,5 +1,4 @@ -import { Registry, DENOM as ALNT_DENOM } from '@cerc-io/registry-sdk'; -import { GasPrice } from '@cosmjs/stargate'; +import { Registry } from '@cerc-io/registry-sdk'; import { RegistryConfig } from '../types'; @@ -8,12 +7,11 @@ let registryInstance: Registry | null = null; export const getRegistry = (): Registry => { if (!registryInstance) { const config = getClientRegistryConfig(); - const gasPrice = GasPrice.fromString(config.fee.gasPrice + ALNT_DENOM); registryInstance = new Registry( config.gqlEndpoint, config.rpcEndpoint, - { chainId: config.chainId, gasPrice } + { chainId: config.chainId } ); } return registryInstance; @@ -24,9 +22,6 @@ export const getClientRegistryConfig = () => { chainId: process.env.NEXT_PUBLIC_REGISTRY_CHAIN_ID!, rpcEndpoint: process.env.NEXT_PUBLIC_REGISTRY_RPC_ENDPOINT!, gqlEndpoint: process.env.NEXT_PUBLIC_REGISTRY_GQL_ENDPOINT!, - fee: { - gasPrice: process.env.NEXT_PUBLIC_REGISTRY_GAS_PRICE!, - }, }; }; @@ -54,8 +49,5 @@ export const getRegistryConfig = (): RegistryConfig => { bondId: process.env.REGISTRY_BOND_ID!, authority: process.env.REGISTRY_AUTHORITY!, privateKey: process.env.REGISTRY_USER_KEY!, - fee: { - gasPrice: process.env.REGISTRY_GAS_PRICE || '0.001', - }, }; }; diff --git a/src/types/index.ts b/src/types/index.ts index 72615d6..9ad6560 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -27,9 +27,6 @@ export interface RegistryConfig { bondId: string; authority: string; privateKey: string; - fee: { - gasPrice: string; - }; } export interface CreateRecordResponse {