accept-invitation.ts 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. import AccountsCommandBase from '../../command-base/accounts'
  2. import DefaultCommandBase, { flags } from '../../command-base/default'
  3. export default class OperatorAcceptInvitation extends AccountsCommandBase {
  4. static description = `Accept pending distribution bucket operator invitation.
  5. Requires the invited distribution group worker role key.`
  6. static flags = {
  7. bucketId: flags.bucketId({
  8. required: true,
  9. }),
  10. workerId: flags.integer({
  11. char: 'w',
  12. description: 'ID of the invited operator (distribution group worker)',
  13. required: true,
  14. }),
  15. ...DefaultCommandBase.flags,
  16. }
  17. async run(): Promise<void> {
  18. const { bucketId, workerId } = this.parse(OperatorAcceptInvitation).flags
  19. const workerKey = await this.getDistributorWorkerRoleKey(workerId)
  20. this.log(`Accepting distribution bucket operator invitation...`, {
  21. bucketId: bucketId.toHuman(),
  22. workerId,
  23. })
  24. await this.sendAndFollowTx(
  25. await this.getDecodedPair(workerKey),
  26. this.api.tx.storage.acceptDistributionBucketInvitation(workerId, bucketId)
  27. )
  28. this.log('Invitation succesfully accepted!')
  29. }
  30. }