throw new Error('Confirmed frontier block info subtype not found')
}
const confirmedFrontierSubtype = resConfirmedFrontierBlockInfo.subtype
- if (!['change', 'epoch', 'open', 'receive', 'send'].includes(confirmedFrontierSubtype)) {
- throw new RangeError('Invalid subtype for confirmed frontier block', { cause: confirmedFrontierSubtype })
}
if (!('contents' in resConfirmedFrontierBlockInfo) || resConfirmedFrontierBlockInfo.contents == null || typeof resConfirmedFrontierBlockInfo.contents !== 'object') {
throw new Error('Confirmed frontier block info contents not found')
confirmedFrontierContents[k] = v
}
const confirmedFrontierBlock = new Block(confirmedFrontierContents.account, confirmedFrontierContents.balance, confirmedFrontierContents.previous, confirmedFrontierContents.representative)
- if (typeof confirmedFrontierBlock[confirmedFrontierSubtype] !== 'function') {
- throw new TypeError('Unknown subtype of confirmed frontier block', { cause: confirmedFrontierSubtype })
- }
if (confirmedFrontierSubtype === 'epoch') {
confirmedFrontierBlock.epoch(accountInfo.account_version)
} else if (confirmedFrontierSubtype === 'change') {
confirmedFrontierBlock.change(confirmedFrontierContents.representative)
- } else {
+ } else if (confirmedFrontierSubtype === 'open' || confirmedFrontierSubtype === 'receive' || confirmedFrontierSubtype === 'send'{
confirmedFrontierBlock[confirmedFrontierSubtype](confirmedFrontierContents.link, 0)
+ } else {
+ throw new TypeError('Invalid confirmed frontier block subtype', { cause: confirmedFrontierSubtype })
}
confirmedFrontierBlock.signature = confirmedFrontierContents.signature
account.confirmed_frontier_block = confirmedFrontierBlock
frontierContents[k] = v
}
const frontierBlock = new Block(frontierContents.account, frontierContents.balance, frontierContents.previous, frontierContents.representative)
- if (typeof frontierBlock[frontierSubtype] !== 'function') {
- throw new TypeError('Unknown subtype of frontier block', { cause: frontierSubtype })
- }
if (frontierSubtype === 'epoch') {
frontierBlock.epoch(accountInfo.account_version)
} else if (frontierSubtype === 'change') {
frontierBlock.change(frontierContents.representative)
- } else {
+ } else if (frontierSubtype === 'open' || frontierSubtype === 'receive' || frontierSubtype === 'send') {
frontierBlock[frontierSubtype](frontierContents.link, 0)
+ } else {
+ throw new TypeError('Invalid frontier block subtype', { cause: frontierSubtype })
}
frontierBlock.signature = frontierContents.signature
account.frontier_block = frontierBlock
frontierBlock.epoch(account_version)
} else if (subtype === 'change') {
frontierBlock.change(representative)
- } else {
+ } else if (subtype === 'open' || subtype === 'receive' || subtype === 'send') {
frontierBlock[subtype](link, 0)
- }
+ } else {
+ throw new TypeError('Invalid frontier block subtype', { cause: subtype })
+ }
frontierBlock.signature = signature
account.frontier_block = frontierBlock
}