diff --git a/package.json b/package.json index 9f0bcf5..445c086 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "demux-eos", - "version": "0.0.1", + "version": "1.0.0", "description": "Demux-js Action Reader implementations for EOSIO blockchains", "main": "dist/index.js", "types": "dist/index.d.ts", @@ -14,7 +14,6 @@ "@types/jest": "^23.1.4", "@types/node": "^10.5.1", "@types/request-promise-native": "^1.0.15", - "demux-js": "0.0.1-docs", "eslint": "^4.9.0", "eslint-config-airbnb-base": "12.1.0", "eslint-plugin-import": "^2.7.0", @@ -26,13 +25,14 @@ "typedoc": "^0.11.1", "typescript": "^2.9.2" }, - "peerDependencies": { - "demux-js": "0.0.1-docs" - }, "dependencies": { + "demux-js": "^1.0.2", "request": "^2.87.0", "request-promise-native": "^1.0.5" }, + "peerDependencies": { + "demux-js": "^1.0.2" + }, "scripts": { "release": "release-it", "compile": "tsc", @@ -40,5 +40,22 @@ "lint": "tslint -c tslint.json src/**/*.ts", "test": "jest", "build-docs": "./build-docs.sh" + }, + "jest": { + "moduleFileExtensions": [ + "ts", + "tsx", + "js" + ], + "transform": { + "^.+\\.(tsx?)$": "ts-jest" + }, + "globals": { + "ts-jest": { + "tsConfigFile": "tsconfig.json" + } + }, + "testRegex": "(/src/.*(\\.|/)(test|spec))\\.(jsx?|tsx?)$", + "testEnvironment": "node" } } diff --git a/src/NodeosActionReader.test.ts b/src/NodeosActionReader.test.ts index d489517..d15e477 100644 --- a/src/NodeosActionReader.test.ts +++ b/src/NodeosActionReader.test.ts @@ -148,10 +148,12 @@ describe("NodeosActionReader", () => { type: "testing::action2", }, ], - blockHash: "000f4241873a9aef0daefd47d8821495b6f61c4d1c73544419eb0ddc22a9e906", - blockNumber: 20, - previousBlockHash: "000f42401b5636c3c1d88f31fe0e503654091fb822b0ffe21c7d35837fc9f3d8", - timestamp: new Date("2018-06-16T05:59:49.500"), + blockInfo: { + blockHash: "000f4241873a9aef0daefd47d8821495b6f61c4d1c73544419eb0ddc22a9e906", + blockNumber: 20, + previousBlockHash: "000f42401b5636c3c1d88f31fe0e503654091fb822b0ffe21c7d35837fc9f3d8", + timestamp: new Date("2018-06-16T05:59:49.500"), + } }) }) }) diff --git a/src/NodeosActionReader.ts b/src/NodeosActionReader.ts index e89ef2a..47e4a8d 100644 --- a/src/NodeosActionReader.ts +++ b/src/NodeosActionReader.ts @@ -1,9 +1,7 @@ -import { readers } from "demux-js" +import { AbstractActionReader } from "demux-js" import { NodeosBlock } from "./NodeosBlock" import request from "request-promise-native" -export const { AbstractActionReader } = readers - /** * Reads from an EOSIO nodeos node to get blocks of actions. * It is important to note that deferred transactions will not be included, diff --git a/src/NodeosBlock.ts b/src/NodeosBlock.ts index 4f30790..e85244e 100644 --- a/src/NodeosBlock.ts +++ b/src/NodeosBlock.ts @@ -1,18 +1,17 @@ -import { Block } from "demux-js" +import { Block, BlockInfo } from "demux-js" import { EosAction } from "./interfaces" export class NodeosBlock implements Block { public actions: EosAction[] - public blockHash: string - public blockNumber: number - public previousBlockHash: string - public timestamp: Date + public blockInfo: BlockInfo constructor(rawBlock: any) { this.actions = this.collectActionsFromBlock(rawBlock) - this.blockNumber = rawBlock.block_num - this.blockHash = rawBlock.id - this.previousBlockHash = rawBlock.previous - this.timestamp = new Date(rawBlock.timestamp) + this.blockInfo = { + blockNumber: rawBlock.block_num, + blockHash: rawBlock.id, + previousBlockHash: rawBlock.previous, + timestamp: new Date(rawBlock.timestamp), + } } protected collectActionsFromBlock(rawBlock: any): EosAction[] { diff --git a/yarn.lock b/yarn.lock index b960cc4..a0873c9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -952,10 +952,6 @@ buffer-from@^1.0.0: version "1.1.1" resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" -buffer-writer@1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/buffer-writer/-/buffer-writer-1.0.1.tgz#22a936901e3029afcd7547eb4487ceb697a3bf08" - builtin-modules@^1.0.0, builtin-modules@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-1.1.1.tgz#270f076c5a72c02f5b65a47df94c5fe3a278892f" @@ -1189,7 +1185,7 @@ combined-stream@1.0.6, combined-stream@~1.0.6: dependencies: delayed-stream "~1.0.0" -commander@2.17.1, commander@^2.12.1: +commander@^2.12.1: version "2.17.1" resolved "https://registry.yarnpkg.com/commander/-/commander-2.17.1.tgz#bd77ab7de6de94205ceacc72f1716d29f20a77bf" @@ -1573,14 +1569,9 @@ delegates@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/delegates/-/delegates-1.0.0.tgz#84c6e159b81904fdca59a0ef44cd870d31250f9a" -demux-js@0.0.1-docs: - version "0.0.1-docs" - resolved "https://registry.yarnpkg.com/demux-js/-/demux-js-0.0.1-docs.tgz#5ce14f04c146326f8ab222ff2c30e9796c560948" - dependencies: - massive "^5.1.3" - pg-promise "^8.4.5" - request "^2.87.0" - request-promise-native "^1.0.5" +demux-js@1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/demux-js/-/demux-js-1.0.2.tgz#60852a597ecf11eb41b6b4483f496b626ed4f966" detect-indent@5.0.0: version "5.0.0" @@ -2235,7 +2226,7 @@ glob-to-regexp@^0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/glob-to-regexp/-/glob-to-regexp-0.3.0.tgz#8c5a1494d2066c570cc3bfe4496175acc4d502ab" -glob@7.1.2, glob@^7.0.0, glob@^7.0.3, glob@^7.0.5, glob@^7.1.1, glob@^7.1.2: +glob@^7.0.0, glob@^7.0.3, glob@^7.0.5, glob@^7.1.1, glob@^7.1.2: version "7.1.2" resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15" dependencies: @@ -3479,10 +3470,6 @@ makeerror@1.0.x: dependencies: tmpl "1.0.x" -manakin@0.5.1: - version "0.5.1" - resolved "https://registry.yarnpkg.com/manakin/-/manakin-0.5.1.tgz#c4a7116f6b00df3d5f1a37ad3ca515d22065a658" - map-cache@^0.2.2: version "0.2.2" resolved "https://registry.yarnpkg.com/map-cache/-/map-cache-0.2.2.tgz#c32abd0bd6525d9b051645bb4f26ac5dc98a0dbf" @@ -3505,16 +3492,6 @@ marked@^0.3.17: version "0.3.19" resolved "https://registry.yarnpkg.com/marked/-/marked-0.3.19.tgz#5d47f709c4c9fc3c216b6d46127280f40b39d790" -massive@^5.1.3: - version "5.2.0" - resolved "https://registry.yarnpkg.com/massive/-/massive-5.2.0.tgz#7b734c54c2230db37f161737d1339f3d9e4f879f" - dependencies: - commander "2.17.1" - glob "7.1.2" - lodash "4.17.10" - pg-promise "8.4.5" - pg-query-stream "1.1.1" - math-random@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/math-random/-/math-random-1.0.1.tgz#8b3aac588b8a66e4975e3cdea67f7bb329601fac" @@ -3977,10 +3954,6 @@ package-json@^4.0.0: registry-url "^3.0.3" semver "^5.1.0" -packet-reader@0.3.1: - version "0.3.1" - resolved "https://registry.yarnpkg.com/packet-reader/-/packet-reader-0.3.1.tgz#cd62e60af8d7fea8a705ec4ff990871c46871f27" - parse-github-repo-url@^1.3.0: version "1.4.1" resolved "https://registry.yarnpkg.com/parse-github-repo-url/-/parse-github-repo-url-1.4.1.tgz#9e7d8bb252a6cb6ba42595060b7bf6df3dbc1f50" @@ -4073,64 +4046,6 @@ performance-now@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b" -pg-connection-string@0.1.3: - version "0.1.3" - resolved "https://registry.yarnpkg.com/pg-connection-string/-/pg-connection-string-0.1.3.tgz#da1847b20940e42ee1492beaf65d49d91b245df7" - -pg-cursor@1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/pg-cursor/-/pg-cursor-1.3.0.tgz#b220f1908976b7b40daa373c7ada5fca823ab0d9" - -pg-minify@0.5.4: - version "0.5.4" - resolved "https://registry.yarnpkg.com/pg-minify/-/pg-minify-0.5.4.tgz#89d5261cacfd44dd7927fa052222a404e9b2a3c9" - -pg-pool@~2.0.3: - version "2.0.3" - resolved "https://registry.yarnpkg.com/pg-pool/-/pg-pool-2.0.3.tgz#c022032c8949f312a4f91fb6409ce04076be3257" - -pg-promise@8.4.5, pg-promise@^8.4.5: - version "8.4.5" - resolved "https://registry.yarnpkg.com/pg-promise/-/pg-promise-8.4.5.tgz#d1af0838938a84dd841cfbcd1d6605f77733fbe3" - dependencies: - manakin "0.5.1" - pg "7.4.3" - pg-minify "0.5.4" - spex "2.0.2" - -pg-query-stream@1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/pg-query-stream/-/pg-query-stream-1.1.1.tgz#65e97436ef809d1e160eba84ebf11b9e4742eab4" - dependencies: - pg-cursor "1.3.0" - -pg-types@~1.12.1: - version "1.12.1" - resolved "https://registry.yarnpkg.com/pg-types/-/pg-types-1.12.1.tgz#d64087e3903b58ffaad279e7595c52208a14c3d2" - dependencies: - postgres-array "~1.0.0" - postgres-bytea "~1.0.0" - postgres-date "~1.0.0" - postgres-interval "^1.1.0" - -pg@7.4.3: - version "7.4.3" - resolved "https://registry.yarnpkg.com/pg/-/pg-7.4.3.tgz#f7b6f93f5340ecc2596afbb94a13e3d6b609834b" - dependencies: - buffer-writer "1.0.1" - packet-reader "0.3.1" - pg-connection-string "0.1.3" - pg-pool "~2.0.3" - pg-types "~1.12.1" - pgpass "1.x" - semver "4.3.2" - -pgpass@1.x: - version "1.0.2" - resolved "https://registry.yarnpkg.com/pgpass/-/pgpass-1.0.2.tgz#2a7bb41b6065b67907e91da1b07c1847c877b306" - dependencies: - split "^1.0.0" - pify@^2.0.0, pify@^2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c" @@ -4173,24 +4088,6 @@ posix-character-classes@^0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/posix-character-classes/-/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab" -postgres-array@~1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/postgres-array/-/postgres-array-1.0.2.tgz#8e0b32eb03bf77a5c0a7851e0441c169a256a238" - -postgres-bytea@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/postgres-bytea/-/postgres-bytea-1.0.0.tgz#027b533c0aa890e26d172d47cf9ccecc521acd35" - -postgres-date@~1.0.0: - version "1.0.3" - resolved "https://registry.yarnpkg.com/postgres-date/-/postgres-date-1.0.3.tgz#e2d89702efdb258ff9d9cee0fe91bd06975257a8" - -postgres-interval@^1.1.0: - version "1.1.2" - resolved "https://registry.yarnpkg.com/postgres-interval/-/postgres-interval-1.1.2.tgz#bf71ff902635f21cb241a013fc421d81d1db15a9" - dependencies: - xtend "^4.0.0" - prelude-ls@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" @@ -4660,10 +4557,6 @@ semver-diff@^2.0.0: version "5.5.0" resolved "https://registry.yarnpkg.com/semver/-/semver-5.5.0.tgz#dc4bbc7a6ca9d916dee5d43516f0092b58f7b8ab" -semver@4.3.2: - version "4.3.2" - resolved "https://registry.yarnpkg.com/semver/-/semver-4.3.2.tgz#c7a07158a80bedd052355b770d82d6640f803be7" - semver@5.4.1: version "5.4.1" resolved "https://registry.yarnpkg.com/semver/-/semver-5.4.1.tgz#e059c09d8571f0540823733433505d3a2f00b18e" @@ -4822,10 +4715,6 @@ spdx-license-ids@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-3.0.0.tgz#7a7cd28470cc6d3a1cfe6d66886f6bc430d3ac87" -spex@2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/spex/-/spex-2.0.2.tgz#e8c8d633a4c67af642dded701ec2350c9de964a0" - split-string@^3.0.1, split-string@^3.0.2: version "3.1.0" resolved "https://registry.yarnpkg.com/split-string/-/split-string-3.1.0.tgz#7cb09dda3a86585705c64b39a6466038682e8fe2" @@ -5468,7 +5357,7 @@ xml-name-validator@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-3.0.0.tgz#6ae73e06de4d8c6e47f9fb181f78d648ad457c6a" -xtend@^4.0.0, xtend@~4.0.1: +xtend@~4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.1.tgz#a5c6d532be656e23db820efb943a1f04998d63af"