Add script to run commands for publishing records from container

This commit is contained in:
Shreerang Kale 2025-07-25 11:29:21 +05:30
parent 6690fa3899
commit 8f8a561aa9
9 changed files with 167 additions and 113 deletions

View File

@ -20,9 +20,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=

View File

@ -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: <https://webapp-deployer-ui.apps.vaasl.io/>
- Check deployment logs on deployer UI: <https://webapp-deployer-ui.apps.vaasl.io/>
* Visit deployed app: <https://gor-deploy.apps.vaasl.io>
- Visit deployed app: <https://gor-deploy.apps.vaasl.io>
### Remove deployment
* Remove deployment:
- Remove deployment:
```bash
# In gor-deploy/deploy dir

50
deploy/laconic-cli.sh Executable file
View File

@ -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 \
"$@"

View File

@ -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 <bond-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 <bond-id>
./laconic-cli.sh record publish --filename pricing.yml --bond-id <bond-id>
```
- Get record info:
```bash
npm run laconic -- record get --id <record-id>
./laconic-cli.sh record get --id <record-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 <bond-id>
./laconic-cli.sh record publish --filename pricing.yml --bond-id <bond-id>
```
- Get record info:
```bash
npm run laconic -- record get --id <record-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 <auction-id>
```
- Commit an auction bid:
```bash
npm run laconic -- auction bid commit <auction-id> 25000000 alnt
Reveal file: ./out/bafyreiay2rccax64yn4ljhvzvm3jkbebvzheyucuma5jlbpzpzd5i5gjuy.json
```
- Reveal bid:
```bash
npm run laconic -- auction bid reveal <auction-id> ./out/bafyreiay2rccax64yn4ljhvzvm3jkbebvzheyucuma5jlbpzpzd5i5gjuy.json
```
### Set Authority Bond
- Set authority bond after winning auction:
```bash
npm run laconic -- authority bond set laconic <bond-id>
./laconic-cli.sh record get --id <record-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://<authority>/pricing/alnt <record-id>
./laconic-cli.sh name set lrn://laconic/pricing/alnt <record-id>
```
- Set record name for cost of deployment record
```bash
npm run laconic -- name set lrn://<authority>/pricing/webapp-deployment <record-id>
./laconic-cli.sh name set lrn://laconic/pricing/webapp-deployment <record-id>
```
## 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 <record-name>
./laconic-cli.sh name delete <record-name>
```
## 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 <bond-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 <auction-id>
```
- Commit an auction bid:
```bash
./laconic-cli.sh auction bid commit <auction-id> 25000000 alnt
# Path inside container
Reveal file: /app/deploy/out/bafyreiay2rccax64yn4ljhvzvm3jkbebvzheyucuma5jlbpzpzd5i5gjuy.json
```
- Reveal bid:
```bash
./laconic-cli.sh auction bid reveal <auction-id> /app/deploy/out/bafyreiay2rccax64yn4ljhvzvm3jkbebvzheyucuma5jlbpzpzd5i5gjuy.json
```
### Set Authority Bond
- Set authority bond after winning auction:
```bash
./laconic-cli.sh authority bond set laconic <bond-id>
```

View File

@ -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';
@ -351,10 +349,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

View File

@ -17,9 +17,6 @@ assert(!IS_NAT_GOR_TRANSFER_ENABLED || process.env.NEXT_PUBLIC_GORBAGANA_RPC_URL
const GORBAGANA_RPC_URL = process.env.NEXT_PUBLIC_GORBAGANA_RPC_URL;
assert(process.env.NEXT_PUBLIC_SOLANA_RPC_URL, 'SOLANA_RPC_URL is required');
assert(process.env.NEXT_PUBLIC_PRICING_RECORD_LRN, 'DEPLOYMENT_RECORD_LRN is required');
export default function PaymentModal({
isOpen,
onClose,

View File

@ -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',
},
};
};

View File

@ -3,8 +3,8 @@ import assert from 'assert';
import { getRegistry } from '@/config';
import { CreateRecordResponse, PricingRecordAttributes, PaymentMethod } from '../types';
assert(process.env.NEXT_PUBLIC_DEPLOYMENT_COST_LRN, 'DEPLOYMENT_RECORD_LRN is required');
assert(process.env.NEXT_PUBLIC_ALNT_COST_LRN, 'DEPLOYMENT_RECORD_LRN is required');
assert(process.env.NEXT_PUBLIC_DEPLOYMENT_COST_LRN, 'DEPLOYMENT_COST_LRN is required');
assert(process.env.NEXT_PUBLIC_ALNT_COST_LRN, 'ALNT_COST_LRN is required');
const DEPLOYMENT_COST_LRN = process.env.NEXT_PUBLIC_DEPLOYMENT_COST_LRN;
const DEPLOYMENT = 'webapp-deployment';

View File

@ -10,9 +10,6 @@ export interface RegistryConfig {
bondId: string;
authority: string;
privateKey: string;
fee: {
gasPrice: string;
};
}
export interface CreateRecordResponse {