diff --git a/packages/backend/src/registry.ts b/packages/backend/src/registry.ts index dfb95d80..14ac2888 100644 --- a/packages/backend/src/registry.ts +++ b/packages/backend/src/registry.ts @@ -4,6 +4,7 @@ import { inc as semverInc } from 'semver'; import { DateTime } from 'luxon'; import { Registry as LaconicRegistry } from '@cerc-io/registry-sdk'; +import { Util } from '@cerc-io/registry-sdk/src/util'; import { RegistryConfig } from './config'; import { @@ -13,7 +14,7 @@ import { ApplicationDeploymentRemovalRequest } from './entity/Deployment'; import { AppDeploymentRecord, AppDeploymentRemovalRecord, PackageJSON } from './types'; -import { parseGasAndFees, sleep } from './utils'; +import { sleep } from './utils'; const log = debug('snowball:registry'); @@ -100,7 +101,7 @@ export class Registry { ...(packageJSON.version && { app_version: packageJSON.version }) }; - const fee = parseGasAndFees(this.registryConfig.fee.gas, this.registryConfig.fee.fees); + const fee = Util.parseGasAndFees(this.registryConfig.fee.gas, this.registryConfig.fee.fees); const result = await this.registry.setRecord( { @@ -192,7 +193,7 @@ export class Registry { await sleep(SLEEP_DURATION); - const fee = parseGasAndFees(this.registryConfig.fee.gas, this.registryConfig.fee.fees); + const fee = Util.parseGasAndFees(this.registryConfig.fee.gas, this.registryConfig.fee.fees); const result = await this.registry.setRecord( { @@ -286,7 +287,7 @@ export class Registry { deployment: data.deploymentId }; - const fee = parseGasAndFees(this.registryConfig.fee.gas, this.registryConfig.fee.fees); + const fee = Util.parseGasAndFees(this.registryConfig.fee.gas, this.registryConfig.fee.fees); const result = await this.registry.setRecord( { diff --git a/packages/backend/src/utils.ts b/packages/backend/src/utils.ts index 8d3d1eb0..629a7f81 100644 --- a/packages/backend/src/utils.ts +++ b/packages/backend/src/utils.ts @@ -80,23 +80,3 @@ export const loadAndSaveData = async ( export const sleep = async (ms: number): Promise => new Promise((resolve) => setTimeout(resolve, ms)); - -export const parseGasAndFees = (gas?: string, fees?: string): StdFee | number | undefined => { - // If fees is not given or a number, treat it as a gas estimation multiplier - if (fees === null || fees === undefined) { - return undefined; - } - - const isFeesANumber = !isNaN(Number(fees)); - if (isFeesANumber) { - return Number(fees); - } - - // If fees is not a gas estimation multiplier, gas is required - assert(gas, 'Invalid gas.'); - - return { - amount: parseCoins(String(fees)), - gas: String(gas) - }; -}; diff --git a/packages/backend/test/initialize-registry.ts b/packages/backend/test/initialize-registry.ts index 414bd88f..a0ca4979 100644 --- a/packages/backend/test/initialize-registry.ts +++ b/packages/backend/test/initialize-registry.ts @@ -1,8 +1,9 @@ import debug from 'debug'; import { Registry } from '@cerc-io/registry-sdk'; +import { Util } from '@cerc-io/registry-sdk/src/util'; -import { getConfig, parseGasAndFees } from '../src/utils'; +import { getConfig } from '../src/utils'; const log = debug('snowball:initialize-registry'); @@ -20,7 +21,7 @@ async function main () { const bondId = await registry.getNextBondId(registryConfig.privateKey); log('bondId:', bondId); - const fee = parseGasAndFees(registryConfig.fee.gas, registryConfig.fee.fees); + const fee = Util.parseGasAndFees(registryConfig.fee.gas, registryConfig.fee.fees); await registry.createBond( { denom: DENOM, amount: BOND_AMOUNT }, diff --git a/packages/backend/test/publish-deploy-records.ts b/packages/backend/test/publish-deploy-records.ts index 7fca02cb..029e2f89 100644 --- a/packages/backend/test/publish-deploy-records.ts +++ b/packages/backend/test/publish-deploy-records.ts @@ -3,8 +3,9 @@ import { DataSource } from 'typeorm'; import path from 'path'; import { Registry } from '@cerc-io/registry-sdk'; +import { Util } from '@cerc-io/registry-sdk/src/util'; -import { getConfig, parseGasAndFees } from '../src/utils'; +import { getConfig } from '../src/utils'; import { Deployment, DeploymentStatus, Environment } from '../src/entity/Deployment'; const log = debug('snowball:publish-deploy-records'); @@ -59,7 +60,7 @@ async function main() { url }; - const fee = parseGasAndFees(registryConfig.fee.gas, registryConfig.fee.fees); + const fee = Util.parseGasAndFees(registryConfig.fee.gas, registryConfig.fee.fees); const result = await registry.setRecord( { diff --git a/packages/backend/test/publish-deployment-removal-records.ts b/packages/backend/test/publish-deployment-removal-records.ts index 97f237db..fd13b0f4 100644 --- a/packages/backend/test/publish-deployment-removal-records.ts +++ b/packages/backend/test/publish-deployment-removal-records.ts @@ -3,8 +3,9 @@ import { DataSource } from 'typeorm'; import path from 'path'; import { Registry } from '@cerc-io/registry-sdk'; +import { Util } from '@cerc-io/registry-sdk/src/util'; -import { getConfig, parseGasAndFees } from '../src/utils'; +import { getConfig } from '../src/utils'; import { Deployment, DeploymentStatus } from '../src/entity/Deployment'; const log = debug('snowball:publish-deployment-removal-records'); @@ -45,7 +46,7 @@ async function main () { request: deployment.applicationDeploymentRemovalRequestId, } - const fee = parseGasAndFees(registryConfig.fee.gas, registryConfig.fee.fees); + const fee = Util.parseGasAndFees(registryConfig.fee.gas, registryConfig.fee.fees); const result = await registry.setRecord( { diff --git a/packages/deployer/config.staging.yml b/packages/deployer/config.staging.yml index 4e0780c0..b2c8f7db 100644 --- a/packages/deployer/config.staging.yml +++ b/packages/deployer/config.staging.yml @@ -5,6 +5,6 @@ services: userKey: 87d00f66a73e2ca428adeb49ba9164d0ad9a87edc60e33d46ad3031b9c5701fe bondId: 89c75c7bc5759861d10285aff6f9e7227d6855e446b77ad5d8324822dfec7deb chainId: laconic_9000-1 - gas: 200000 - fees: 200000alnt - gasPrice: + gas: + fees: + gasPrice: 1 diff --git a/packages/deployer/config.yml b/packages/deployer/config.yml index 2d26ebe9..b793bb2b 100644 --- a/packages/deployer/config.yml +++ b/packages/deployer/config.yml @@ -5,6 +5,6 @@ services: userKey: 489c9dd3931c2a2d4dd77973302dc5eb01e2a49552f9d932c58d9da823512311 bondId: 99c0e9aec0ac1b8187faa579be3b54f93fafb6060ac1fd29170b860df605be32 chainId: laconic_9000-1 - gas: 200000 - fees: 200000alnt - gasPrice: + gas: + fees: + gasPrice: 1