export async function verifyProof(link, identity) {
// Generate an array of valid chain IDs from the demo configuration
const chains = blockchains.map(chain => chain.chainId);
// Create a proof helper based on the identity results from anchor-link
const proof = IdentityProof.from(identity.proof);
// Check to see if the chainId from the proof is valid for this demo
const chain = chains.find(id => ChainId.from(id).equals(proof.chainId));
if (!chain) {
throw new Error("Unsupported chain supplied in identity proof");
}
// Load the account data from a blockchain API
let account: API.v1.AccountObject;
try {
account = await link.client.v1.chain.get_account(proof.signer.actor);
} catch (error) {
if (error instanceof APIError && error.code === 0) {
throw new Error("No such account");
} else {
throw error;
}
}