Skip to content

Commit

Permalink
Merge pull request #14 from blockchain-certificates/chore/extract-typ…
Browse files Browse the repository at this point in the history
…es-to-explorer-lookup

Chore/extract types to explorer lookup
  • Loading branch information
raiseandfall authored Feb 24, 2021
2 parents f9ce6ad + 4d1d815 commit 6792dfe
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 59 deletions.
4 changes: 1 addition & 3 deletions src/MerkleProof2019.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { Decoder } from '@vaultie/lds-merkle-proof-2019';
import jsigs from 'jsonld-signatures';
import { lookForTx } from '@blockcerts/explorer-lookup';
import { lookForTx, ExplorerAPI, TransactionData } from '@blockcerts/explorer-lookup';
import { DecodedProof, JSONLDProof } from './models/Proof';
import getTransactionId from './helpers/getTransactionId';
import isTransactionIdValid from './inspectors/isTransactionIdValid';
import { ExplorerAPI } from './models/Explorers';
import { IBlockchainObject } from './constants/blockchains';
import getChain from './helpers/getChain';
import { TransactionData } from './models/TransactionData';
import computeLocalHash from './inspectors/computeLocalHash';
import ensureHashesEqual from './inspectors/ensureHashesEqual';
import ensureMerkleRootEqual from './inspectors/ensureMerkleRootEqual';
Expand Down
9 changes: 3 additions & 6 deletions src/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { ExplorerAPI } from './models/Explorers';
import { DecodedProof, JSONLDProof } from './models/Proof';
import { TransactionData } from './models/TransactionData';
import { IParsingFunctionAPI } from './explorers/explorer';
import { ExplorerAPI, TransactionData, IParsingFunctionAPI } from '@blockcerts/explorer-lookup';
import { IBlockchainObject } from './constants/blockchains';

export interface MerkleProof2019Options {
Expand All @@ -25,7 +23,7 @@ export interface MerkleProof2019VerificationResult {
error?: string;
}

declare class MerkleProof2019 {
export declare class MerkleProof2019 {
/* eslint-disable @typescript-eslint/no-empty-function, @typescript-eslint/no-useless-constructor */
public type: string;
public issuer: any; // TODO: define issuer type
Expand All @@ -51,7 +49,6 @@ declare class MerkleProof2019 {

export {
ExplorerAPI,
TransactionData,
IParsingFunctionAPI,
MerkleProof2019
TransactionData
};
36 changes: 0 additions & 36 deletions src/models/Explorers.ts

This file was deleted.

6 changes: 0 additions & 6 deletions src/models/TransactionData.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/utils/ensureExplorerAPIValidity.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ExplorerAPI } from '../models/Explorers';
import { ExplorerAPI } from '@blockcerts/explorer-lookup';

function isPriorityValid (explorerAPI: ExplorerAPI): boolean {
return explorerAPI.priority >= 0;
Expand Down
3 changes: 1 addition & 2 deletions tests/MerkleProof2019.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import sinon from 'sinon';
import * as explorerLookup from '@blockcerts/explorer-lookup';
import { MerkleProof2019, MerkleProof2019Options, MerkleProof2019VerificationResult } from '../src/MerkleProof2019';
import decodedProof, { assertionTransactionId } from './assertions/proof';
import { TransactionData } from '../src/models/TransactionData';
import { BLOCKCHAINS } from '../src/constants/blockchains';
import blockcertsV3Fixture, { documentHash } from './fixtures/blockcerts-v3';
import fixtureTransactionData from './fixtures/transactionData';
Expand Down Expand Up @@ -65,7 +64,7 @@ describe('MerkleProof2019 test suite', function () {
explorerAPIs: [{
serviceURL: 'https://explorer-example.com',
priority: 0,
parsingFunction: (): TransactionData => fixtureTransactionData
parsingFunction: (): explorerLookup.TransactionData => fixtureTransactionData
}]
};
const instance = new MerkleProof2019({ options: fixtureOptions, document: blockcertsV3Fixture });
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/transactionData.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TransactionData } from '../../src/models/TransactionData';
import { TransactionData } from '@blockcerts/explorer-lookup';

const fixtureTransactionData: TransactionData = {
remoteHash: '2b065c69c70432e9f082629939733afd2343e83f45939519986e9a09cf8ccd08',
Expand Down
3 changes: 1 addition & 2 deletions tests/utils/ensureExplorerAPIValidity.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ExplorerAPI } from '../../src/models/Explorers';
import { TransactionData } from '../../src/models/TransactionData';
import { ExplorerAPI, TransactionData } from '@blockcerts/explorer-lookup';
import ensureExplorerAPIValidity from '../../src/utils/ensureExplorerAPIValidity';

describe('ensureExplorerAPIValidity test suite', function () {
Expand Down
3 changes: 1 addition & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
"resolveJsonModule": true,
"esModuleInterop": true,
"skipLibCheck": true,
"outDir": "lib/esm",
"declaration": true
"outDir": "lib/esm"
},
"compileOnSave": false,
"exclude": [
Expand Down

0 comments on commit 6792dfe

Please sign in to comment.