update-voucher-limits.ts 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import ApiCommandBase from '../../command-base/ApiCommandBase'
  2. import { updateStorageBucketsVoucherMaxLimits } from '../../services/runtime/extrinsics'
  3. import { flags } from '@oclif/command'
  4. import logger from '../../services/logger'
  5. /**
  6. * CLI command:
  7. * Updates maximum values for storage bucket voucher limits.
  8. *
  9. * @remarks
  10. * Storage working group leader command. Requires storage WG leader priviliges.
  11. * Shell command: "leader:update-voucher-limits"
  12. */
  13. export default class LeaderUpdateVoucherLimits extends ApiCommandBase {
  14. static description =
  15. 'Update VoucherMaxObjectsSizeLimit and VoucherMaxObjectsNumberLimit for the Joystream node storage.'
  16. static flags = {
  17. objects: flags.integer({
  18. char: 'o',
  19. required: true,
  20. description: `New 'max voucher object number limit' value`,
  21. }),
  22. size: flags.integer({
  23. char: 's',
  24. required: true,
  25. description: `New 'max voucher object size limit' value`,
  26. }),
  27. ...ApiCommandBase.flags,
  28. }
  29. async run(): Promise<void> {
  30. const { flags } = this.parse(LeaderUpdateVoucherLimits)
  31. logger.info('Updating global storage bucket voucher limits....')
  32. if (flags.dev) {
  33. await this.ensureDevelopmentChain()
  34. }
  35. const account = this.getAccount(flags)
  36. const objectsLimit = flags.objects
  37. const sizeLimit = flags.size
  38. const api = await this.getApi()
  39. const success = await updateStorageBucketsVoucherMaxLimits(api, account, sizeLimit, objectsLimit)
  40. this.exitAfterRuntimeCall(success)
  41. }
  42. }