Add command to create an auction and add auction CLI tests #83

Merged
nabarun merged 13 commits from deep-stack/laconic-registry-cli:iv-create-auction-cmds into main 2024-09-25 13:57:56 +00:00
2 changed files with 42 additions and 0 deletions
Showing only changes of commit cbf319e97e - Show all commits

View File

@ -755,3 +755,11 @@ laconic registry auction get $AUCTION
}
]
```
Release provider winning funds:
```bash
laconic registry auction release-funds $AUCTION
{"success": true}
```

View File

@ -0,0 +1,34 @@
import { Arguments } from 'yargs';
import assert from 'assert';
import { Account, Registry } from '@cerc-io/registry-sdk';
import { getConfig, getConnectionInfo, getGasAndFees, getGasPrice, txOutput } from '../../../util';
export const command = 'release-funds [auction-id]';
export const desc = 'Release funds of provider auction winners.';
export const handler = async (argv: Arguments) => {
const auctionId = argv.auctionId as string;
assert(auctionId, 'Invalid auction ID.');
const { services: { registry: registryConfig } } = getConfig(argv.config as string);
const { rpcEndpoint, gqlEndpoint, privateKey, chainId } = getConnectionInfo(argv, registryConfig);
assert(rpcEndpoint, 'Invalid registry RPC endpoint.');
assert(gqlEndpoint, 'Invalid registry GQL endpoint.');
assert(privateKey, 'Invalid Transaction Key.');
assert(chainId, 'Invalid registry Chain ID.');
const account = new Account(Buffer.from(privateKey, 'hex'));
await account.init();
const gasPrice = getGasPrice(argv, registryConfig);
const registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId, gasPrice });
const fee = getGasAndFees(argv, registryConfig);
const result = await registry.releaseFunds({ auctionId }, privateKey, fee);
const success = '{"success": true}';
txOutput(result, success, argv.output, argv.verbose);
};