delete-bucket.ts 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. import { flags } from '@oclif/command'
  2. import AccountsCommandBase from '../../command-base/accounts'
  3. import DefaultCommandBase from '../../command-base/default'
  4. export default class LeaderDeleteBucket extends AccountsCommandBase {
  5. static description = `Delete distribution bucket. The bucket must have no operators. Requires distribution working group leader permissions.`
  6. static flags = {
  7. bucketId: flags.integer({
  8. char: 'B',
  9. description: 'Distribution bucket id',
  10. required: true,
  11. }),
  12. familyId: flags.integer({
  13. char: 'f',
  14. description: 'Distribution bucket family id',
  15. required: true,
  16. }),
  17. ...DefaultCommandBase.flags,
  18. }
  19. async run(): Promise<void> {
  20. const { bucketId, familyId } = this.parse(LeaderDeleteBucket).flags
  21. const leadKey = await this.getDistributorLeadKey()
  22. this.log(`Deleting distribution bucket (${bucketId})...`)
  23. await this.sendAndFollowTx(
  24. await this.getDecodedPair(leadKey),
  25. this.api.tx.storage.deleteDistributionBucket(familyId, bucketId)
  26. )
  27. this.log('Bucket succesfully deleted!')
  28. }
  29. }