How to use the @celo/contractkit/lib/identity.IdentityMetadataWrapper.fetchFromURL 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 / cli / src / commands / account / get-metadata.ts View on Github external
async run() {
    const { args } = this.parse(GetMetadata)
    const address = args.address
    const accounts = await this.kit.contracts.getAccounts()
    const metadataURL = await accounts.getMetadataURL(address)

    if (!metadataURL) {
      console.info('No metadata set for address')
      return
    }

    try {
      const metadata = await IdentityMetadataWrapper.fetchFromURL(metadataURL)
      console.info('Metadata contains the following claims: \n')
      displayMetadata(metadata)
    } catch (error) {
      console.error('Metadata could not be retrieved from ', metadataURL)
    }
  }
}
github celo-org / celo-monorepo / packages / leaderboard / src / board.ts View on Github external
lst.forEach(async (a) => {
    try {
      const url = await accounts.getMetadataURL(a)
      console.log(a, 'has url', url)
      let metadata: IdentityMetadataWrapper
      if (url == '') metadata = IdentityMetadataWrapper.fromEmpty(a)
      else metadata = await IdentityMetadataWrapper.fetchFromURL(url)
      processClaims(kit, a, metadata)
    } catch (err) {
      console.error('Bad address', a, err.toString())
    }
  })
}