Skip to content

Commit

Permalink
Populate to the best effort the block context of Transactions in a Fa…
Browse files Browse the repository at this point in the history
…ctoidBlock
  • Loading branch information
PaulBernier committed Mar 16, 2019
1 parent 37dd5ab commit 67599fb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

### Changed

* BlockContext populated for transactions in a `FactoidBlock` object (except `directoryBlockKeyMR` that is not available).

## [1.0.0]

### Added
Expand Down
7 changes: 6 additions & 1 deletion src/blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,12 @@ class FactoidBlock {
this.previousLedgerKeyMR = fb.prevledgerkeymr;
this.entryCreditRate = fb.exchrate;
this.directoryBlockHeight = fb.dbheight;
this.transactions = fb.transactions.map(t => new Transaction(t));
this.transactions = fb.transactions.map(t => new Transaction(t,
{
factoidBlockKeyMR: this.keyMR,
directoryBlockHeight: this.directoryBlockHeight,
// directoryBlockKeyMR is not available
}));
}

/**
Expand Down
3 changes: 3 additions & 0 deletions test/get.integration.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,9 @@ describe('Get information from Factom blockchain', function () {
assert.instanceOf(coinbaseTx, Transaction);
assert.equal(coinbaseTx.totalInputs, 0);
assert.equal(coinbaseTx.totalFactoidOutputs, 6398208000);
assert.isObject(coinbaseTx.blockContext);
assert.equal(coinbaseTx.blockContext.factoidBlockKeyMR, '4b2572326cc04f4bff215800bc3f48b2e64f2002f0c2b592e09b003ea3f36bdd');
assert.equal(coinbaseTx.blockContext.directoryBlockHeight, 55010);
}

it('should get Factoid Block', async function () {
Expand Down

0 comments on commit 67599fb

Please sign in to comment.