All files / src/plugins verifier.ts

100% Statements 12/12
100% Branches 0/0
100% Functions 2/2
100% Lines 12/12

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 4027x   27x                 27x 27x 27x       4x 4x                 27x         15x 15x 15x   15x      
export { MinaNFTVerifier };
 
import {
  method,
  DeployArgs,
  Permissions,
  SmartContract,
  PublicKey,
  Field,
} from "o1js";
 
import { RedactedMinaNFTMapStateProof } from "./redactedmap";
import { MinaNFTContract } from "../contract/nft";
import { Metadata } from "../contract/metadata";
 
class MinaNFTVerifier extends SmartContract {
  async deploy(args: DeployArgs) {
    super.deploy(args);
    this.account.permissions.set({
      ...Permissions.default(),
      setDelegate: Permissions.proof(),
      incrementNonce: Permissions.proof(),
      setVotingFor: Permissions.proof(),
      setTiming: Permissions.proof(),
    });
  }
 
  @method async verifyRedactedMetadata(
    nft: PublicKey,
    tokenId: Field,
    proof: RedactedMinaNFTMapStateProof
  ) {
    const minanft = new MinaNFTContract(nft, tokenId);
    const nftMetadata: Metadata = minanft.metadata.get();
    Metadata.assertEquals(nftMetadata, proof.publicInput.originalRoot);
 
    proof.verify();
  }
}