accept-invitation.ts 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. /**
  6. * CLI command:
  7. * Accepts pending invitation for the storage bucket.
  8. *
  9. * @remarks
  10. * Storage provider (operator) command. Requires an additional worker ID for
  11. * runtime verification.
  12. * Shell command: "operator:accept-invitation"
  13. */
  14. export default class OperatorAcceptInvitation extends ApiCommandBase {
  15. static description = 'Accept pending storage bucket invitation.'
  16. static flags = {
  17. workerId: flags.integer({
  18. char: 'w',
  19. required: true,
  20. description: 'Storage operator worker ID',
  21. }),
  22. bucketId: flags.integer({
  23. char: 'i',
  24. required: true,
  25. description: 'Storage bucket ID',
  26. }),
  27. transactorAccountId: flags.string({
  28. char: 't',
  29. required: true,
  30. description: 'Transactor account ID (public key)',
  31. }),
  32. ...ApiCommandBase.flags,
  33. }
  34. async run(): Promise<void> {
  35. const { flags } = this.parse(OperatorAcceptInvitation)
  36. const worker = flags.workerId
  37. const bucket = flags.bucketId
  38. const transactorAccountId = flags.transactorAccountId
  39. logger.info('Accepting pending storage bucket invitation...')
  40. if (flags.dev) {
  41. await this.ensureDevelopmentChain()
  42. }
  43. const account = this.getAccount(flags)
  44. const api = await this.getApi()
  45. const success = await acceptStorageBucketInvitation(api, account, worker, bucket, transactorAccountId)
  46. this.exitAfterRuntimeCall(success)
  47. }
  48. }