Skip to content

Commit

Permalink
fix: seals.create
Browse files Browse the repository at this point in the history
  • Loading branch information
mvayngrib committed Feb 4, 2018
1 parent 0d8bbca commit 6751569
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
9 changes: 8 additions & 1 deletion lib/seals.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions src/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ import {
IDebug,
ILiveDeliveryOpts,
ISendOpts,
IBatchSendOpts
IBatchSendOpts,
IECMiniPubKey
} from './types'
import Logger from './logger'

Expand Down Expand Up @@ -107,7 +108,7 @@ export default class Provider {
return keys
}

public getMyChainKey = async ():Promise<any> => {
public getMyChainKey = async ():Promise<IECMiniPubKey> => {
const { network } = this
if (network.flavor === 'corda') return

Expand Down
13 changes: 13 additions & 0 deletions src/seals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
bindAll,
summarizeObject
} from './utils'
import { getLinks } from './crypto'
import { prettify } from './string-utils'
import dbUtils = require('./db-utils')
import types = require('./typeforce-types')
Expand Down Expand Up @@ -284,6 +285,13 @@ export default class Seals {
}

private createSealRecord = async (opts:SealRecordOpts):Promise<void> => {
if (!opts.key && opts.write) {
opts = {
...opts,
key: await this.provider.getMyChainKey()
}
}

const seal = this.getNewSealParams(opts)
try {
await this.table.put({
Expand Down Expand Up @@ -563,12 +571,17 @@ export default class Seals {

private getNewSealParams = ({
key,
object,
link,
permalink,
counterparty,
watchType=WATCH_TYPE.this,
write
}:SealRecordOpts) => {
if (!(link && permalink) && object) {
({ link, permalink } = getLinks(object))
}

const { blockchain, network } = this
// the next version's previous is the current version
// the tx for next version will have a predictable seal based on the current version's link
Expand Down

0 comments on commit 6751569

Please sign in to comment.