Update method to get registry config on client side
This commit is contained in:
parent
6c2ee093a2
commit
9633d49374
@ -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=
|
||||
|
@ -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`)
|
||||
}
|
||||
|
||||
|
@ -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 = [
|
||||
|
Loading…
Reference in New Issue
Block a user