Add CLI for releasing funds of provider auction winners
Some checks failed
Lint / lint (18.x) (pull_request) Successful in 1m9s
Tests / cli_tests (18.x) (pull_request) Failing after 1m13s

This commit is contained in:
IshaVenikar 2024-09-23 18:55:07 +05:30 committed by Prathamesh Musale
parent fa734a4ff8
commit cbf319e97e
2 changed files with 42 additions and 0 deletions

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);
};