How to use the @celo/contractkit/lib/identity.ClaimTypes.KEYBASE function in @celo/contractkit

To help you get started, we’ve selected a few @celo/contractkit examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github celo-org / celo-monorepo / packages / leaderboard / src / board.ts View on Github external
async function getClaims(
  kit: ContractKit,
  address: string,
  data: IdentityMetadataWrapper
): Promise {
  if (address.substr(0, 2) === '0x') {
    address = address.substr(2)
  }
  const res = [address]
  const accounts = await kit.contracts.getAccounts()
  for (const claim of data.claims) {
    switch (claim.type) {
      case ClaimTypes.KEYBASE:
        break
      case ClaimTypes.ACCOUNT:
        try {
          const status = await verifyAccountClaim(claim, '0x' + address, accounts.getMetadataURL)
          if (status) console.error('Cannot verify claim:', status)
          else {
            console.log('Claim success', address, claim.address)
            res.push(claim.address)
          }
        } catch (err) {
          console.error('Cannot fetch metadata', err)
        }
      default:
        break
    }
  }
github celo-org / celo-monorepo / packages / cli / src / utils / identity.ts View on Github external
const verifiable = VERIFIABLE_CLAIM_TYPES.includes(claim.type)
    const validatable = VALIDATABLE_CLAIM_TYPES.includes(claim.type)
    const status = verifiable
      ? await verifyClaim(claim, metadata.data.meta.address, metadataURLGetter)
      : validatable
        ? await validateClaim(claim, metadata.data.meta.address, kit)
        : 'N/A'
    let extra = ''
    switch (claim.type) {
      case ClaimTypes.ATTESTATION_SERVICE_URL:
        extra = `URL: ${claim.url}`
        break
      case ClaimTypes.DOMAIN:
        extra = `Domain: ${claim.domain}`
        break
      case ClaimTypes.KEYBASE:
        extra = `Username: ${claim.username}`
        break
      case ClaimTypes.NAME:
        extra = `Name: "${claim.name}"`
        break
      default:
        extra = JSON.stringify(claim)
        break
    }
    return {
      type: claim.type,
      extra,
      status: verifiable
        ? status
          ? `Could not verify: ${status}`
          : 'Verified!'