From 9633d49374b31d4f54e7a67c60fe5478d7b6b3d6 Mon Sep 17 00:00:00 2001 From: Shreerang Kale Date: Tue, 22 Jul 2025 17:38:05 +0530 Subject: [PATCH] Update method to get registry config on client side --- .env.example | 2 +- src/components/PaymentModal.tsx | 4 ++-- src/config/index.ts | 13 ++++++++++++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/.env.example b/.env.example index 81a004c..51a6106 100644 --- a/.env.example +++ b/.env.example @@ -21,8 +21,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_PRICING_RECORD_LRN= -REGISTRY_GAS_PRICE=0.001 REGISTRY_BOND_ID= REGISTRY_AUTHORITY= REGISTRY_USER_KEY= diff --git a/src/components/PaymentModal.tsx b/src/components/PaymentModal.tsx index bcec2f4..cb00475 100644 --- a/src/components/PaymentModal.tsx +++ b/src/components/PaymentModal.tsx @@ -22,7 +22,7 @@ assert(process.env.NEXT_PUBLIC_PRICING_RECORD_LRN, 'DEPLOYMENT_RECORD_LRN is req const PRICING_RECORD_LRN = process.env.NEXT_PUBLIC_PRICING_RECORD_LRN; const SUPPORTED_CURRENCY = "USD"; -const VALID_PRICING_RECORD_TYPE = "webapp-deployment"; +const VALID_PRICING_RECORD_FOR = "webapp-deployment"; interface DeploymentCostInfo { amount: string; @@ -61,7 +61,7 @@ export default function PaymentModal({ const result = await registry.resolveNames([PRICING_RECORD_LRN!]) const PricingRecordAttributes: PricingRecordAttributes = result[0].attributes; - if (PricingRecordAttributes.type !== VALID_PRICING_RECORD_TYPE) { + if (PricingRecordAttributes.for !== VALID_PRICING_RECORD_FOR) { throw new Error(`Incorrect pricing record type: ${PricingRecordAttributes.type}. Please provide correct pricing record lrn`) } diff --git a/src/config/index.ts b/src/config/index.ts index 6ce836a..9afd1ea 100644 --- a/src/config/index.ts +++ b/src/config/index.ts @@ -7,7 +7,7 @@ let registryInstance: Registry | null = null; export const getRegistry = (): Registry => { if (!registryInstance) { - const config = getRegistryConfig(); + const config = getClientRegistryConfig(); const gasPrice = GasPrice.fromString(config.fee.gasPrice + ALNT_DENOM); registryInstance = new Registry( @@ -19,6 +19,17 @@ export const getRegistry = (): Registry => { return registryInstance; }; +export const getClientRegistryConfig = () => { + return { + 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 || '0.001', + }, + }; +}; + export const getRegistryConfig = (): RegistryConfig => { // Validate required environment variables const requiredEnvVars = [