@polkadot/types/interfaces#BountyStatus TypeScript Examples

The following examples show how to use @polkadot/types/interfaces#BountyStatus. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: determineUnassignCuratorAction.ts    From crust-apps with Apache License 2.0 6 votes vote down vote up
export function determineUnassignCuratorAction (roles: UserRole[], status: BountyStatus, blocksUntilUpdate?: BN): ValidUnassignCuratorAction[] {
  const actions: ValidUnassignCuratorAction[] = [];

  if (status.isCuratorProposed && roles.includes('Member')) {
    actions.push('UnassignCurator');
  }

  if (status.isActive) {
    if (roles.includes('Member')) {
      actions.push('SlashCuratorMotion');
    }

    if (roles.includes('User') && blocksUntilUpdate && blocksUntilUpdate.lt(BN_ZERO)) {
      actions.push('SlashCuratorAction');
    }
  }

  if (status.isPendingPayout && roles.includes('Member')) {
    actions.push('SlashCuratorMotion');
  }

  return actions;
}
Example #2
Source File: getBountyStatus.ts    From crust-apps with Apache License 2.0 6 votes vote down vote up
getBountyStatus = (status: BountyStatus): BountyStatusType => {
  const statusAsString = status.type as StatusName;

  let result: BountyStatusType = {
    beneficiary: undefined,
    bountyStatus: statusAsString,
    curator: undefined,
    unlockAt: undefined,
    updateDue: undefined
  };

  if (status.isCuratorProposed) {
    result = {
      ...result,
      bountyStatus: 'CuratorProposed',
      curator: status.asCuratorProposed.curator
    };
  }

  if (status.isActive) {
    result = {
      ...result,
      curator: status.asActive.curator,
      updateDue: status.asActive.updateDue
    };
  }

  if (status.isPendingPayout) {
    result = {
      ...result,
      beneficiary: status.asPendingPayout.beneficiary,
      bountyStatus: 'PendingPayout',
      curator: status.asPendingPayout.curator,
      unlockAt: status.asPendingPayout.unlockAt
    };
  }

  return result;
}
Example #3
Source File: bountyFactory.ts    From crust-apps with Apache License 2.0 6 votes vote down vote up
public bountyStatusWith = ({ curator = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY', status = 'Active', updateDue = 100000 } = {}): BountyStatus => {
    if (status === 'Active') {
      return this.#registry.createType('BountyStatus', { active: { curator, updateDue }, status });
    }

    if (status === 'CuratorProposed') {
      return this.#registry.createType('BountyStatus', { curatorProposed: { curator }, status });
    }

    throw new Error('Unsupported status');
  };
Example #4
Source File: extendedStatuses.ts    From crust-apps with Apache License 2.0 5 votes vote down vote up
function validMethods (status: BountyStatus): string[] {
  return validProposalNames[status.type as StatusName];
}
Example #5
Source File: extendedStatuses.ts    From crust-apps with Apache License 2.0 5 votes vote down vote up
function bestValidProposalName (bountyProposals: DeriveCollectiveProposal[], status: BountyStatus): string | undefined {
  const methods = bountyProposals.map(({ proposal }) => proposal.method);

  return validMethods(status).find((method) => methods.includes(method));
}
Example #6
Source File: extendedStatuses.ts    From crust-apps with Apache License 2.0 5 votes vote down vote up
export function proposalNameToDisplay (bountyProposal: DeriveCollectiveProposal, status: BountyStatus): string | undefined {
  if (bountyProposal.proposal.method !== 'unassignCurator') { return bountyProposal.proposal.method; }

  return status.isCuratorProposed ? 'unassignCurator' : 'slashCurator';
}
Example #7
Source File: extendedStatuses.ts    From crust-apps with Apache License 2.0 5 votes vote down vote up
export function getProposalToDisplay (bountyProposals: DeriveCollectiveProposal[], status: BountyStatus): DeriveCollectiveProposal | null {
  const method = bestValidProposalName(bountyProposals, status);

  return getProposalByMethod(bountyProposals, method) ?? null;
}
Example #8
Source File: useBountyStatus.ts    From crust-apps with Apache License 2.0 5 votes vote down vote up
export function useBountyStatus (status: BountyStatus): BountyStatusType {
  const updateStatus = useCallback(() => getBountyStatus(status), [status]);

  return updateStatus();
}
Example #9
Source File: bountiesPage.tsx    From crust-apps with Apache License 2.0 5 votes vote down vote up
aBountyStatus: (status: string) => BountyStatus;
Example #10
Source File: bountiesPage.tsx    From crust-apps with Apache License 2.0 5 votes vote down vote up
bountyStatusWith: ({ curator, status }: { curator?: string, status?: string, }) => BountyStatus;
Example #11
Source File: bountyFactory.ts    From crust-apps with Apache License 2.0 5 votes vote down vote up
public aBountyStatus = (status: string): BountyStatus =>
    this.#registry.createType('BountyStatus', status);