Add registry gas price config

This commit is contained in:
Shreerang Kale 2025-07-25 19:02:50 +05:30
parent 68080b61b3
commit b6f4b4067f
3 changed files with 35 additions and 14 deletions

View File

@ -22,6 +22,7 @@ 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_GQL_ENDPOINT=https://laconicd-mainnet-1.laconic.com/graphql
NEXT_PUBLIC_ALNT_COST_LRN=lrn://laconic/pricing/alnt NEXT_PUBLIC_ALNT_COST_LRN=lrn://laconic/pricing/alnt
NEXT_PUBLIC_DEPLOYMENT_COST_LRN=lrn://laconic/pricing/webapp-deployment NEXT_PUBLIC_DEPLOYMENT_COST_LRN=lrn://laconic/pricing/webapp-deployment
REGISTRY_GAS_PRICE=0.001
REGISTRY_BOND_ID= REGISTRY_BOND_ID=
REGISTRY_AUTHORITY= REGISTRY_AUTHORITY=
REGISTRY_USER_KEY= REGISTRY_USER_KEY=

View File

@ -190,19 +190,32 @@ export default function PaymentModal({
</label> </label>
<div className="space-y-3"> <div className="space-y-3">
<div className="relative"> <div className="relative">
<input {loadingPrice ? (
type="text" <div className="w-full p-3 rounded-md flex items-center" style={{
value={`$${deploymentCost ? deploymentCost.toPrecision(2) : null}`} background: 'var(--muted-light)',
disabled={true}
className="w-full p-3 pr-12 rounded-md"
style={{
background: 'var(--card-bg)',
border: '1px solid var(--input-border)', border: '1px solid var(--input-border)',
color: 'var(--foreground)', color: 'var(--muted)'
opacity: '0.7' }}>
}} <svg className="animate-spin h-4 w-4 mr-2" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
readOnly <circle className="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="4"></circle>
/> <path className="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
</svg>
</div>
) : (
<input
type="text"
value={`$${deploymentCost ? deploymentCost.toPrecision(2) : null}`}
disabled={true}
className="w-full p-3 pr-12 rounded-md"
style={{
background: 'var(--card-bg)',
border: '1px solid var(--input-border)',
color: 'var(--foreground)',
opacity: '0.7'
}}
readOnly
/>
)}
<div className="absolute inset-y-0 right-0 flex items-center pr-3 pointer-events-none"> <div className="absolute inset-y-0 right-0 flex items-center pr-3 pointer-events-none">
<span className="text-sm font-medium" style={{ color: 'var(--muted)' }}>USD</span> <span className="text-sm font-medium" style={{ color: 'var(--muted)' }}>USD</span>
</div> </div>

View File

@ -1,17 +1,24 @@
import { Registry } from '@cerc-io/registry-sdk'; import { DENOM as ALNT_DENOM, Registry } from '@cerc-io/registry-sdk';
import { RegistryConfig } from '../types'; import { RegistryConfig } from '../types';
import { GasPrice } from '@cosmjs/stargate';
let registryInstance: Registry | null = null; let registryInstance: Registry | null = null;
export const getRegistry = (): Registry => { export const getRegistry = (): Registry => {
if (!registryInstance) { if (!registryInstance) {
const config = getClientRegistryConfig(); const config = getClientRegistryConfig();
const REGISTRY_GAS_PRICE = process.env.REGISTRY_GAS_PRICE;
const gasPrice = REGISTRY_GAS_PRICE ? GasPrice.fromString( REGISTRY_GAS_PRICE + ALNT_DENOM) : undefined;
registryInstance = new Registry( registryInstance = new Registry(
config.gqlEndpoint, config.gqlEndpoint,
config.rpcEndpoint, config.rpcEndpoint,
{ chainId: config.chainId } {
chainId: config.chainId,
gasPrice,
}
); );
} }
return registryInstance; return registryInstance;