accept-invitation.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import { flags } from '@oclif/command'
  2. import { acceptStorageBucketInvitation } from '../../services/runtime/extrinsics'
  3. import ApiCommandBase from '../../command-base/ApiCommandBase'
  4. import logger from '../../services/logger'
  5. export default class OperatorAcceptInvitation extends ApiCommandBase {
  6. static description = 'Accept pending storage bucket invitation.'
  7. static flags = {
  8. worker: flags.integer({
  9. char: 'w',
  10. required: true,
  11. description: 'Storage operator worker ID',
  12. }),
  13. bucket: flags.integer({
  14. char: 'b',
  15. required: true,
  16. description: 'Storage bucket ID',
  17. }),
  18. ...ApiCommandBase.flags,
  19. }
  20. async run(): Promise<void> {
  21. const { flags } = this.parse(OperatorAcceptInvitation)
  22. const worker = flags.worker ?? 0
  23. const bucket = flags.bucket ?? 0
  24. logger.info('Accepting pending storage bucket invitation...')
  25. if (flags.dev) {
  26. await this.ensureDevelopmentChain()
  27. }
  28. const account = this.getAccount(flags)
  29. const api = await this.getApi()
  30. const success = await acceptStorageBucketInvitation(
  31. api,
  32. account,
  33. worker,
  34. bucket
  35. )
  36. this.exitAfterRuntimeCall(success)
  37. }
  38. }