diff --git a/README.md b/README.md index 7afa70c..50b0f76 100644 --- a/README.md +++ b/README.md @@ -755,3 +755,11 @@ laconic registry auction get $AUCTION } ] ``` + +Release provider winning funds: + +```bash +laconic registry auction release-funds $AUCTION + +{"success": true} +``` diff --git a/src/cmds/registry-cmds/auction-cmds/release-funds.ts b/src/cmds/registry-cmds/auction-cmds/release-funds.ts new file mode 100644 index 0000000..f555f3a --- /dev/null +++ b/src/cmds/registry-cmds/auction-cmds/release-funds.ts @@ -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); +};