import { TxTag, TxTags } from '@polymathnetwork/polymesh-sdk/polkadot/types';

export enum PermissionGroup {
  PortfolioManagement = 'portfolioManagement',
  TokenManagement = 'tokenManagement',
  AdvancedTokenManagement = 'advancedTokenManagement',
  Distribution = 'distribution',
  ManageApprovedAttestationProviders = 'manageApprovedAttestationProviders',
  ManageAttestations = 'manageAttestations',
  Minting = 'minting',
  ManageRules = 'manageRules',
  CorporateActions = 'corporateActions',
}

export type PermissionTemplate = {
  group: PermissionGroup;
  transactions: TxTag[];
}[];

export const permissionTemplates: PermissionTemplate = [
  {
    group: PermissionGroup.PortfolioManagement,
    transactions: [
      TxTags.identity.AddInvestorUniquenessClaim,
      TxTags.portfolio.MovePortfolioFunds,
      TxTags.settlement.AddAndAffirmInstruction,
      TxTags.settlement.AffirmInstruction,
      TxTags.settlement.AddInstruction,
      TxTags.settlement.RejectInstruction,
      TxTags.settlement.CreateVenue,
    ],
  },
  {
    group: PermissionGroup.TokenManagement,
    transactions: [
      TxTags.asset.MakeDivisible,
      TxTags.asset.RenameAsset,
      TxTags.asset.SetFundingRound,
      TxTags.asset.AddDocuments,
      TxTags.asset.RemoveDocuments,
    ],
  },
  {
    group: PermissionGroup.AdvancedTokenManagement,
    transactions: [
      TxTags.asset.Freeze,
      TxTags.asset.Unfreeze,
      TxTags.identity.AddAuthorization,
      TxTags.identity.RemoveAuthorization,
    ],
  },
  {
    group: PermissionGroup.Distribution,
    transactions: [
      TxTags.identity.AddInvestorUniquenessClaim,
      TxTags.settlement.CreateVenue,
      TxTags.settlement.AddAndAffirmInstruction,
    ],
  },
  {
    group: PermissionGroup.Minting,
    transactions: [TxTags.asset.Issue],
  },
  {
    group: PermissionGroup.ManageApprovedAttestationProviders,
    transactions: [
      TxTags.complianceManager.AddDefaultTrustedClaimIssuer,
      TxTags.complianceManager.RemoveDefaultTrustedClaimIssuer,
    ],
  },
  {
    group: PermissionGroup.ManageAttestations,
    transactions: [TxTags.identity.AddClaim, TxTags.identity.RevokeClaim],
  },
  {
    group: PermissionGroup.ManageRules,
    transactions: [
      TxTags.complianceManager.AddComplianceRequirement,
      TxTags.complianceManager.RemoveComplianceRequirement,
      TxTags.complianceManager.ChangeComplianceRequirement,
      TxTags.complianceManager.PauseAssetCompliance,
      TxTags.complianceManager.ResumeAssetCompliance,
      TxTags.complianceManager.ResetAssetCompliance,
    ],
  },
  {
    group: PermissionGroup.CorporateActions,
    transactions: [
      TxTags.checkpoint.CreateSchedule,
      TxTags.checkpoint.RemoveSchedule,
      TxTags.checkpoint.CreateCheckpoint,
      TxTags.corporateAction.InitiateCorporateAction,
      TxTags.capitalDistribution.Distribute,
      TxTags.capitalDistribution.Claim,
      TxTags.identity.AddInvestorUniquenessClaim,
    ],
  },
];
