Skip to content

Commit

Permalink
chore: rename issue => mint
Browse files Browse the repository at this point in the history
  • Loading branch information
Nebulis committed Dec 24, 2019
1 parent 7a1e54b commit 8247ea0
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 49 deletions.
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Verifier } from "./types/core";
import { openAttestationHash } from "./verifiers/openAttestationHash";
import { openAttestationDnsTxt } from "./verifiers/openAttestationDnsTxt";
import { openAttestationEthereumDocumentStoreIssued } from "./verifiers/openAttestationEthereumDocumentStoreIssued";
import { openAttestationEthereumTokenRegistryIssued } from "./verifiers/openAttestationEthereumTokenRegistryIssued";
import { openAttestationEthereumTokenRegistryMinted } from "./verifiers/openAttestationEthereumTokenRegistryMinted";
import { openAttestationEthereumDocumentStoreRevoked } from "./verifiers/openAttestationEthereumDocumentStoreRevoked";
import { isValid } from "./validator";

Expand All @@ -13,7 +13,7 @@ const openAttestationVerifiers: Verifier<
>[] = [
openAttestationHash,
openAttestationEthereumDocumentStoreIssued,
openAttestationEthereumTokenRegistryIssued,
openAttestationEthereumTokenRegistryMinted,
openAttestationEthereumDocumentStoreRevoked,
openAttestationDnsTxt
];
Expand Down
16 changes: 16 additions & 0 deletions src/issued/verify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,19 @@ export const verifyIssued = async (
details
};
};

export const verifyMinted = async (
document: WrappedDocument<v2.OpenAttestationDocument | v3.OpenAttestationDocument>,
smartContracts: OpenAttestationContract[] = []
) => {
const { details, issuedOnAll } = await verifyIssued(document, smartContracts);
return {
details: details.map(({ issued, ...rest }) => {
return {
...rest,
minted: issued
};
}),
mintedOnAll: issuedOnAll
};
};
Original file line number Diff line number Diff line change
@@ -1,100 +1,100 @@
import { openAttestationEthereumTokenRegistryIssued } from "./openAttestationEthereumTokenRegistryIssued";
import { openAttestationEthereumTokenRegistryMinted } from "./openAttestationEthereumTokenRegistryMinted";
import { documentRopstenNotIssuedWithTokenRegistry } from "../../test/fixtures/v2/documentRopstenNotIssuedWithTokenRegistry";
import { documentRopstenValidWithToken } from "../../test/fixtures/v2/documentRopstenValidWithToken";
import { documentRopstenValidWithTokenRegistry as v3documentRopstenValidWithTokenRegistry } from "../../test/fixtures/v3/documentRopstenValid";
import { documentRopstenNotIssuedWithTokenRegistry as v3documentRopstenNotIssuedWithTokenRegistry } from "../../test/fixtures/v3/documentRopstenNotIssuedWithTokenRegistry";

describe("openAttestationEthereumTokenRegistryIssued", () => {
describe("v2", () => {
it("should return an invalid fragment when document with token registry has not been issued", async () => {
const fragment = await openAttestationEthereumTokenRegistryIssued.verify(
it("should return an invalid fragment when document with token registry has not been minted", async () => {
const fragment = await openAttestationEthereumTokenRegistryMinted.verify(
documentRopstenNotIssuedWithTokenRegistry,
{
network: "ropsten"
}
);
expect(fragment).toStrictEqual({
name: "OpenAttestationEthereumTokenRegistryIssued",
name: "OpenAttestationEthereumTokenRegistryMinted",
type: "DOCUMENT_STATUS",
data: {
details: [
{
address: "0xb53499ee758352fAdDfCed863d9ac35C809E2F20",
issued: false,
minted: false,
error:
'call revert exception (address="0xb53499ee758352fAdDfCed863d9ac35C809E2F20", args=["0x693c86fbb8f75ac56f865f5b3100e545875f2154b3749bdcf448c874a1d67ef3"], method="ownerOf(uint256)", errorSignature="Error(string)", errorArgs=[["ERC721: owner query for nonexistent token"]], reason=["ERC721: owner query for nonexistent token"], transaction={"to":{},"data":"0x6352211e693c86fbb8f75ac56f865f5b3100e545875f2154b3749bdcf448c874a1d67ef3"}, version=4.0.40)'
}
],
issuedOnAll: false
mintedOnAll: false
},
message: "Certificate has not been issued",
message: "Certificate has not been minted",
status: "INVALID"
});
});
it("should return a valid fragment when document with token registry has been issued", async () => {
const fragment = await openAttestationEthereumTokenRegistryIssued.verify(documentRopstenValidWithToken, {
it("should return a valid fragment when document with token registry has been minted", async () => {
const fragment = await openAttestationEthereumTokenRegistryMinted.verify(documentRopstenValidWithToken, {
network: "ropsten"
});
expect(fragment).toStrictEqual({
name: "OpenAttestationEthereumTokenRegistryIssued",
name: "OpenAttestationEthereumTokenRegistryMinted",
type: "DOCUMENT_STATUS",
data: {
details: [
{
address: "0xe59877ac86c0310e9ddaeb627f42fdee5f793fbe",
issued: true
minted: true
}
],
issuedOnAll: true
mintedOnAll: true
},
status: "VALID"
});
});
});
describe("v3", () => {
it("should return an invalid fragment when document with token registry has not been issued", async () => {
const fragment = await openAttestationEthereumTokenRegistryIssued.verify(
it("should return an invalid fragment when document with token registry has not been minted", async () => {
const fragment = await openAttestationEthereumTokenRegistryMinted.verify(
v3documentRopstenNotIssuedWithTokenRegistry,
{
network: "ropsten"
}
);
expect(fragment).toStrictEqual({
name: "OpenAttestationEthereumTokenRegistryIssued",
name: "OpenAttestationEthereumTokenRegistryMinted",
type: "DOCUMENT_STATUS",
data: {
details: [
{
address: "0xb53499ee758352fAdDfCed863d9ac35C809E2F20",
issued: false,
minted: false,
error:
'call revert exception (address="0xb53499ee758352fAdDfCed863d9ac35C809E2F20", args=["0x7c56cf6bac41a744060e515cac8eb177c8f3d2d56f705a0a7df884906623bddc"], method="ownerOf(uint256)", errorSignature="Error(string)", errorArgs=[["ERC721: owner query for nonexistent token"]], reason=["ERC721: owner query for nonexistent token"], transaction={"to":{},"data":"0x6352211e7c56cf6bac41a744060e515cac8eb177c8f3d2d56f705a0a7df884906623bddc"}, version=4.0.40)'
}
],
issuedOnAll: false
mintedOnAll: false
},
message: "Certificate has not been issued",
message: "Certificate has not been minted",
status: "INVALID"
});
});
it("should return a valid fragment when document with document store has been issued", async () => {
const fragment = await openAttestationEthereumTokenRegistryIssued.verify(
it("should return a valid fragment when document with document store has been minted", async () => {
const fragment = await openAttestationEthereumTokenRegistryMinted.verify(
v3documentRopstenValidWithTokenRegistry,
{
network: "ropsten"
}
);
expect(fragment).toStrictEqual({
name: "OpenAttestationEthereumTokenRegistryIssued",
name: "OpenAttestationEthereumTokenRegistryMinted",
type: "DOCUMENT_STATUS",
data: {
details: [
{
address: "0xb53499ee758352fAdDfCed863d9ac35C809E2F20",
issued: true
minted: true
}
],
issuedOnAll: true
mintedOnAll: true
},
status: "VALID"
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { getData, v2, v3, WrappedDocument } from "@govtechsg/open-attestation";
import { isWrappedV3Document, VerificationFragmentType, Verifier } from "../types/core";
import { verifyIssued } from "../issued/verify";
import { verifyMinted } from "../issued/verify";
import { getTokenRegistrySmartContract } from "../common/smartContract/documentToSmartContracts";

const name = "OpenAttestationEthereumTokenRegistryIssued";
const name = "OpenAttestationEthereumTokenRegistryMinted";
const type: VerificationFragmentType = "DOCUMENT_STATUS";
export const openAttestationEthereumTokenRegistryIssued: Verifier<
export const openAttestationEthereumTokenRegistryMinted: Verifier<
WrappedDocument<v2.OpenAttestationDocument> | WrappedDocument<v3.OpenAttestationDocument>
> = {
skip: () => {
Expand All @@ -26,13 +26,13 @@ export const openAttestationEthereumTokenRegistryIssued: Verifier<
},
verify: async (document, options) => {
const smartContracts = getTokenRegistrySmartContract(document, options);
const status = await verifyIssued(document, smartContracts);
if (!status.issuedOnAll) {
const status = await verifyMinted(document, smartContracts);
if (!status.mintedOnAll) {
return {
name,
type,
data: status,
message: "Certificate has not been issued",
message: "Certificate has not been minted",
status: "INVALID"
};
}
Expand Down
22 changes: 11 additions & 11 deletions src/verify.v2.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe("verify(integration)", () => {
},
{
message: 'Document issuers doesn\'t have "tokenRegistry" property or TOKEN_REGISTRY method',
name: "OpenAttestationEthereumTokenRegistryIssued",
name: "OpenAttestationEthereumTokenRegistryMinted",
status: "SKIPPED",
type: "DOCUMENT_STATUS"
},
Expand Down Expand Up @@ -101,7 +101,7 @@ describe("verify(integration)", () => {
},
{
message: 'Document issuers doesn\'t have "tokenRegistry" property or TOKEN_REGISTRY method',
name: "OpenAttestationEthereumTokenRegistryIssued",
name: "OpenAttestationEthereumTokenRegistryMinted",
status: "SKIPPED",
type: "DOCUMENT_STATUS"
},
Expand Down Expand Up @@ -158,7 +158,7 @@ describe("verify(integration)", () => {
},
{
message: 'Document issuers doesn\'t have "tokenRegistry" property or TOKEN_REGISTRY method',
name: "OpenAttestationEthereumTokenRegistryIssued",
name: "OpenAttestationEthereumTokenRegistryMinted",
status: "SKIPPED",
type: "DOCUMENT_STATUS"
},
Expand Down Expand Up @@ -211,13 +211,13 @@ describe("verify(integration)", () => {
details: [
{
address: "0xe59877ac86c0310e9ddaeb627f42fdee5f793fbe",
issued: true
minted: true
}
],
issuedOnAll: true
mintedOnAll: true
},
status: "VALID",
name: "OpenAttestationEthereumTokenRegistryIssued",
name: "OpenAttestationEthereumTokenRegistryMinted",
type: "DOCUMENT_STATUS"
},
{
Expand All @@ -242,7 +242,7 @@ describe("verify(integration)", () => {
]);
});

it("should fail for OpenAttestationEthereumTokenRegistryIssued when document with token registry was not issued ", async () => {
it("should fail for OpenAttestationEthereumTokenRegistryMinted when document with token registry was not issued ", async () => {
const results = await verify(documentRopstenRevokedWithToken, {
network: "ropsten"
});
Expand Down Expand Up @@ -270,14 +270,14 @@ describe("verify(integration)", () => {
address: "0x48399Fb88bcD031C556F53e93F690EEC07963Af3",
error:
'call revert exception (address="0x48399Fb88bcD031C556F53e93F690EEC07963Af3", args=["0x1e63c39cdd668da652484fd781f8c0812caadad0f6ebf71bf68bf3670242d1ef"], method="ownerOf(uint256)", errorSignature="Error(string)", errorArgs=[["ERC721: owner query for nonexistent token"]], reason=["ERC721: owner query for nonexistent token"], transaction={"to":{},"data":"0x6352211e1e63c39cdd668da652484fd781f8c0812caadad0f6ebf71bf68bf3670242d1ef"}, version=4.0.40)',
issued: false
minted: false
}
],
issuedOnAll: false
mintedOnAll: false
},
message: "Certificate has not been issued",
message: "Certificate has not been minted",
status: "INVALID",
name: "OpenAttestationEthereumTokenRegistryIssued",
name: "OpenAttestationEthereumTokenRegistryMinted",
type: "DOCUMENT_STATUS"
},
{
Expand Down
14 changes: 7 additions & 7 deletions src/verify.v3.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe("verify v3(integration)", () => {
},
{
message: 'Document issuers doesn\'t have "tokenRegistry" property or TOKEN_REGISTRY method',
name: "OpenAttestationEthereumTokenRegistryIssued",
name: "OpenAttestationEthereumTokenRegistryMinted",
status: "SKIPPED",
type: "DOCUMENT_STATUS"
},
Expand Down Expand Up @@ -97,7 +97,7 @@ describe("verify v3(integration)", () => {
},
{
message: 'Document issuers doesn\'t have "tokenRegistry" property or TOKEN_REGISTRY method',
name: "OpenAttestationEthereumTokenRegistryIssued",
name: "OpenAttestationEthereumTokenRegistryMinted",
status: "SKIPPED",
type: "DOCUMENT_STATUS"
},
Expand Down Expand Up @@ -157,7 +157,7 @@ describe("verify v3(integration)", () => {
},
{
message: 'Document issuers doesn\'t have "tokenRegistry" property or TOKEN_REGISTRY method',
name: "OpenAttestationEthereumTokenRegistryIssued",
name: "OpenAttestationEthereumTokenRegistryMinted",
status: "SKIPPED",
type: "DOCUMENT_STATUS"
},
Expand Down Expand Up @@ -218,7 +218,7 @@ describe("verify v3(integration)", () => {
},
{
message: 'Document issuers doesn\'t have "tokenRegistry" property or TOKEN_REGISTRY method',
name: "OpenAttestationEthereumTokenRegistryIssued",
name: "OpenAttestationEthereumTokenRegistryMinted",
status: "SKIPPED",
type: "DOCUMENT_STATUS"
},
Expand Down Expand Up @@ -274,13 +274,13 @@ describe("verify v3(integration)", () => {
details: [
{
address: "0xb53499ee758352fAdDfCed863d9ac35C809E2F20",
issued: true
minted: true
}
],
issuedOnAll: true
mintedOnAll: true
},
status: "VALID",
name: "OpenAttestationEthereumTokenRegistryIssued",
name: "OpenAttestationEthereumTokenRegistryMinted",
type: "DOCUMENT_STATUS"
},
{
Expand Down

0 comments on commit 8247ea0

Please sign in to comment.