Compare commits

...
Author SHA1 Message Date
prathamesh 47f670bdde Increment package version (#87)
Lint / lint (18.x) (push) Successful in 1m10s
Publish npm package to gitea / npm_publish (18.x) (release) Successful in 1m32s
Tests / cli_tests (18.x) (push) Successful in 14m50s
Reviewed-on: #87
Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
Co-committed-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
2024-10-30 13:26:02 +00:00
prathamesh 3be0c0aecf Update lock file (#86)
Lint / lint (18.x) (push) Successful in 1m14s
Tests / cli_tests (18.x) (push) Successful in 14m51s
Reviewed-on: #86
Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
Co-committed-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
2024-10-23 06:23:51 +00:00
prathameshandIshaVenikar 936ad73a89 Use registry-sdk methods to parse gas and fees (#85)
Lint / lint (18.x) (push) Successful in 1m12s
Tests / cli_tests (18.x) (push) Successful in 14m53s
Part of [Service provider auctions for web deployments](https://www.notion.so/Service-provider-auctions-for-web-deployments-104a6b22d47280dbad51d28aa3a91d75)

Co-authored-by: IshaVenikar <ishavenikar7@gmail.com>
Reviewed-on: #85
Co-authored-by: Prathamesh Musale <prathamesh@noreply.git.vdb.to>
Co-committed-by: Prathamesh Musale <prathamesh@noreply.git.vdb.to>
2024-10-08 03:47:11 +00:00
nabarunandprathamesh c770d14bd9 Get tx fees from config for auction tests (#84)
Lint / lint (18.x) (push) Successful in 1m10s
Tests / cli_tests (18.x) (push) Successful in 15m5s
Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
Reviewed-on: #84
Co-authored-by: Nabarun <nabarun@deepstacksoft.com>
Co-committed-by: Nabarun <nabarun@deepstacksoft.com>
2024-09-25 16:00:42 +00:00
5 changed files with 27 additions and 36 deletions
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "@cerc-io/laconic-registry-cli",
"version": "0.2.9",
"version": "0.2.10",
"main": "index.js",
"repository": "git@github.com:cerc-io/laconic-registry-cli.git",
"author": "",
@@ -29,7 +29,7 @@
"typescript": "^4.6.3"
},
"dependencies": {
"@cerc-io/registry-sdk": "^0.2.10",
"@cerc-io/registry-sdk": "^0.2.11",
"@cosmjs/stargate": "^0.32.2",
"fs-extra": "^10.1.0",
"js-yaml": "^3.14.1",
+3 -23
View File
@@ -1,28 +1,8 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import assert from 'assert';
import { Arguments } from 'yargs';
import { StdFee, GasPrice, parseCoins } from '@cosmjs/stargate';
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)
};
};
import { parseGasAndFees, getGasPrice as registryGetGasPrice } from '@cerc-io/registry-sdk';
import { StdFee, GasPrice } from '@cosmjs/stargate';
export const getGasAndFees = (argv: Arguments, config: any = {}): StdFee | number | undefined => {
return parseGasAndFees(
@@ -33,5 +13,5 @@ export const getGasAndFees = (argv: Arguments, config: any = {}): StdFee | numbe
export const getGasPrice = (argv: Arguments, config: any = {}): GasPrice | undefined => {
const gasPriceString = argv.gasPrice || config.gasPrice;
return gasPriceString != null ? GasPrice.fromString(String(gasPriceString)) : undefined;
return registryGetGasPrice(gasPriceString);
};
+5 -3
View File
@@ -19,7 +19,8 @@ import {
getAuctionObj,
getBidObj,
updateGasAndFeesConfig,
AUCTION_STATUS
AUCTION_STATUS,
getFeesConfig
} from './helpers';
describe('Test laconic CLI commands', () => {
@@ -715,13 +716,14 @@ describe('Test laconic CLI commands', () => {
}, (AUCTION_COMMIT_DURATION + 5) * 1000);
});
describe.only('Provider Auction operations', () => {
describe('Provider Auction operations', () => {
const txFees = getFeesConfig();
const commitFee = 1000;
const revealFee = 1000;
const maxPrice = 1000000;
const numProviders = 2;
const bidderInitialBlanace = 1000000000;
const txFees = 200000;
testAuctionId = '5e9dd5501e965f25db4fa62635d0ce5f6c59d73ab1a2ea999f8c5bf2f6fb6350';
const bidderAccounts = [
+13 -4
View File
@@ -2,11 +2,15 @@ import fs from 'fs';
import path from 'path';
import yaml from 'js-yaml';
import { SpawnSyncReturns, spawnSync } from 'child_process';
import { Arguments } from 'yargs';
import { getConfig } from '../src/util';
import { StdFee } from '@cosmjs/stargate';
import { getConfig, getGasAndFees } from '../src/util';
export const CHAIN_ID = 'laconic_9000-1';
export const TOKEN_TYPE = 'alnt';
export const CONFIG_FILE = 'config.yml';
export enum AUCTION_STATUS {
COMMIT = 'commit',
@@ -133,9 +137,14 @@ export async function delay (ms: number): Promise<any> {
return new Promise((resolve) => setTimeout(resolve, ms));
}
export function getFeesConfig (): number {
const { services: { registry: registryConfig } } = getConfig(CONFIG_FILE);
const fee = getGasAndFees({} as Arguments, registryConfig);
return Number((fee as StdFee).amount[0].amount);
}
export function updateGasAndFeesConfig (gas?: string | null, fees?: string | null, gasPrice?: string | null): void {
const configFilePath = './config.yml';
const config = getConfig(path.resolve(configFilePath));
const config = getConfig(path.resolve(CONFIG_FILE));
if (gas) {
config.services.registry.gas = gas;
@@ -156,7 +165,7 @@ export function updateGasAndFeesConfig (gas?: string | null, fees?: string | nul
}
try {
fs.writeFileSync(configFilePath, yaml.dump(config), 'utf8');
fs.writeFileSync(CONFIG_FILE, yaml.dump(config), 'utf8');
} catch (e) {
console.error('Error writing config file:', e);
throw e;
+4 -4
View File
@@ -302,10 +302,10 @@
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
"@cerc-io/registry-sdk@^0.2.10":
version "0.2.10"
resolved "https://git.vdb.to/api/packages/cerc-io/npm/%40cerc-io%2Fregistry-sdk/-/0.2.10/registry-sdk-0.2.10.tgz#15773ea36a862585cdcb0991cbf075736f845f96"
integrity sha512-xxVD7ylrN951TFoSFbluz7mt4SwSCv7z+yry3jGd8v8TWnycoBMMrrYSTfETs6Ydxwziiz/uLrRwk59vFZxLEA==
"@cerc-io/registry-sdk@^0.2.11":
version "0.2.11"
resolved "https://git.vdb.to/api/packages/cerc-io/npm/%40cerc-io%2Fregistry-sdk/-/0.2.11/registry-sdk-0.2.11.tgz#019b792c68f440f2cfca5af2f49e1205bb33ba72"
integrity sha512-IipqJzaBQEXMNH6yWFG2E/o0U6IAXw35PBMHx6QIboVu/sMNLIsWy1P8MmR8C8xYsmHOhgXLsC4hYSeFMXrqFw==
dependencies:
"@cosmjs/amino" "^0.28.1"
"@cosmjs/crypto" "^0.28.1"