Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
47f670bdde | ||
|
|
3be0c0aecf | ||
|
|
936ad73a89 | ||
|
|
c770d14bd9 |
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@cerc-io/laconic-registry-cli",
|
"name": "@cerc-io/laconic-registry-cli",
|
||||||
"version": "0.2.9",
|
"version": "0.2.10",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"repository": "git@github.com:cerc-io/laconic-registry-cli.git",
|
"repository": "git@github.com:cerc-io/laconic-registry-cli.git",
|
||||||
"author": "",
|
"author": "",
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
"typescript": "^4.6.3"
|
"typescript": "^4.6.3"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@cerc-io/registry-sdk": "^0.2.10",
|
"@cerc-io/registry-sdk": "^0.2.11",
|
||||||
"@cosmjs/stargate": "^0.32.2",
|
"@cosmjs/stargate": "^0.32.2",
|
||||||
"fs-extra": "^10.1.0",
|
"fs-extra": "^10.1.0",
|
||||||
"js-yaml": "^3.14.1",
|
"js-yaml": "^3.14.1",
|
||||||
|
|||||||
+3
-23
@@ -1,28 +1,8 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-unused-vars */
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||||
import assert from 'assert';
|
|
||||||
import { Arguments } from 'yargs';
|
import { Arguments } from 'yargs';
|
||||||
|
|
||||||
import { StdFee, GasPrice, parseCoins } from '@cosmjs/stargate';
|
import { parseGasAndFees, getGasPrice as registryGetGasPrice } from '@cerc-io/registry-sdk';
|
||||||
|
import { StdFee, GasPrice } 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)
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
export const getGasAndFees = (argv: Arguments, config: any = {}): StdFee | number | undefined => {
|
export const getGasAndFees = (argv: Arguments, config: any = {}): StdFee | number | undefined => {
|
||||||
return parseGasAndFees(
|
return parseGasAndFees(
|
||||||
@@ -33,5 +13,5 @@ export const getGasAndFees = (argv: Arguments, config: any = {}): StdFee | numbe
|
|||||||
|
|
||||||
export const getGasPrice = (argv: Arguments, config: any = {}): GasPrice | undefined => {
|
export const getGasPrice = (argv: Arguments, config: any = {}): GasPrice | undefined => {
|
||||||
const gasPriceString = argv.gasPrice || config.gasPrice;
|
const gasPriceString = argv.gasPrice || config.gasPrice;
|
||||||
return gasPriceString != null ? GasPrice.fromString(String(gasPriceString)) : undefined;
|
return registryGetGasPrice(gasPriceString);
|
||||||
};
|
};
|
||||||
|
|||||||
+5
-3
@@ -19,7 +19,8 @@ import {
|
|||||||
getAuctionObj,
|
getAuctionObj,
|
||||||
getBidObj,
|
getBidObj,
|
||||||
updateGasAndFeesConfig,
|
updateGasAndFeesConfig,
|
||||||
AUCTION_STATUS
|
AUCTION_STATUS,
|
||||||
|
getFeesConfig
|
||||||
} from './helpers';
|
} from './helpers';
|
||||||
|
|
||||||
describe('Test laconic CLI commands', () => {
|
describe('Test laconic CLI commands', () => {
|
||||||
@@ -715,13 +716,14 @@ describe('Test laconic CLI commands', () => {
|
|||||||
}, (AUCTION_COMMIT_DURATION + 5) * 1000);
|
}, (AUCTION_COMMIT_DURATION + 5) * 1000);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe.only('Provider Auction operations', () => {
|
describe('Provider Auction operations', () => {
|
||||||
|
const txFees = getFeesConfig();
|
||||||
|
|
||||||
const commitFee = 1000;
|
const commitFee = 1000;
|
||||||
const revealFee = 1000;
|
const revealFee = 1000;
|
||||||
const maxPrice = 1000000;
|
const maxPrice = 1000000;
|
||||||
const numProviders = 2;
|
const numProviders = 2;
|
||||||
const bidderInitialBlanace = 1000000000;
|
const bidderInitialBlanace = 1000000000;
|
||||||
const txFees = 200000;
|
|
||||||
testAuctionId = '5e9dd5501e965f25db4fa62635d0ce5f6c59d73ab1a2ea999f8c5bf2f6fb6350';
|
testAuctionId = '5e9dd5501e965f25db4fa62635d0ce5f6c59d73ab1a2ea999f8c5bf2f6fb6350';
|
||||||
|
|
||||||
const bidderAccounts = [
|
const bidderAccounts = [
|
||||||
|
|||||||
+13
-4
@@ -2,11 +2,15 @@ import fs from 'fs';
|
|||||||
import path from 'path';
|
import path from 'path';
|
||||||
import yaml from 'js-yaml';
|
import yaml from 'js-yaml';
|
||||||
import { SpawnSyncReturns, spawnSync } from 'child_process';
|
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 CHAIN_ID = 'laconic_9000-1';
|
||||||
export const TOKEN_TYPE = 'alnt';
|
export const TOKEN_TYPE = 'alnt';
|
||||||
|
export const CONFIG_FILE = 'config.yml';
|
||||||
|
|
||||||
export enum AUCTION_STATUS {
|
export enum AUCTION_STATUS {
|
||||||
COMMIT = 'commit',
|
COMMIT = 'commit',
|
||||||
@@ -133,9 +137,14 @@ export async function delay (ms: number): Promise<any> {
|
|||||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
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 {
|
export function updateGasAndFeesConfig (gas?: string | null, fees?: string | null, gasPrice?: string | null): void {
|
||||||
const configFilePath = './config.yml';
|
const config = getConfig(path.resolve(CONFIG_FILE));
|
||||||
const config = getConfig(path.resolve(configFilePath));
|
|
||||||
|
|
||||||
if (gas) {
|
if (gas) {
|
||||||
config.services.registry.gas = gas;
|
config.services.registry.gas = gas;
|
||||||
@@ -156,7 +165,7 @@ export function updateGasAndFeesConfig (gas?: string | null, fees?: string | nul
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
fs.writeFileSync(configFilePath, yaml.dump(config), 'utf8');
|
fs.writeFileSync(CONFIG_FILE, yaml.dump(config), 'utf8');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('Error writing config file:', e);
|
console.error('Error writing config file:', e);
|
||||||
throw e;
|
throw e;
|
||||||
|
|||||||
@@ -302,10 +302,10 @@
|
|||||||
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
|
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
|
||||||
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
|
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
|
||||||
|
|
||||||
"@cerc-io/registry-sdk@^0.2.10":
|
"@cerc-io/registry-sdk@^0.2.11":
|
||||||
version "0.2.10"
|
version "0.2.11"
|
||||||
resolved "https://git.vdb.to/api/packages/cerc-io/npm/%40cerc-io%2Fregistry-sdk/-/0.2.10/registry-sdk-0.2.10.tgz#15773ea36a862585cdcb0991cbf075736f845f96"
|
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-xxVD7ylrN951TFoSFbluz7mt4SwSCv7z+yry3jGd8v8TWnycoBMMrrYSTfETs6Ydxwziiz/uLrRwk59vFZxLEA==
|
integrity sha512-IipqJzaBQEXMNH6yWFG2E/o0U6IAXw35PBMHx6QIboVu/sMNLIsWy1P8MmR8C8xYsmHOhgXLsC4hYSeFMXrqFw==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@cosmjs/amino" "^0.28.1"
|
"@cosmjs/amino" "^0.28.1"
|
||||||
"@cosmjs/crypto" "^0.28.1"
|
"@cosmjs/crypto" "^0.28.1"
|
||||||
|
|||||||
Reference in New Issue
Block a user