Skip to content

Commit

Permalink
refactor: VerifiableClaimSigner Singleton (#985)
Browse files Browse the repository at this point in the history
  • Loading branch information
lautarodragan authored Aug 15, 2019
1 parent c8458aa commit 59f1c3d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/app.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { getVerifiableClaimSigner } from '@po.et/poet-js'
import { MongoClient } from 'mongodb'
import * as Pino from 'pino'

Expand Down Expand Up @@ -70,6 +71,7 @@ export async function app(localVars: any = {}) {
logger: logger.child({ file: 'WorkController' }),
mainnetNode,
testnetNode,
verifiableClaimSigner: getVerifiableClaimSigner(),
},
})

Expand Down
10 changes: 8 additions & 2 deletions src/controllers/WorkController.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { configureCreateVerifiableClaim, getVerifiableClaimSigner, SignedVerifiableClaim } from '@po.et/poet-js'
import {
configureCreateVerifiableClaim,
SignedVerifiableClaim,
VerifiableClaimSigner,
} from '@po.et/poet-js'
import * as Pino from 'pino'
import { pipeP } from 'ramda'

Expand Down Expand Up @@ -26,13 +30,15 @@ interface Dependencies {
readonly logger: Pino.Logger
readonly mainnetNode: PoetNode
readonly testnetNode: PoetNode
readonly verifiableClaimSigner: VerifiableClaimSigner
}

export const WorkController = ({
dependencies: {
logger,
mainnetNode,
testnetNode,
verifiableClaimSigner,
},
}: Arguments): WorkController => {
const networkToNode = (network: Network) => network === Network.LIVE ? mainnetNode : testnetNode
Expand Down Expand Up @@ -65,7 +71,7 @@ export const WorkController = ({

const createAndSignClaim = pipeP(
configureCreateVerifiableClaim({ issuer, context: { ...legacyContext, ...context, ...aboutContext} }),
getVerifiableClaimSigner().configureSignVerifiableClaim({ privateKey }),
verifiableClaimSigner.configureSignVerifiableClaim({ privateKey }),
)

const { content, ...newWork } = claim
Expand Down

0 comments on commit 59f1c3d

Please sign in to comment.