From a8f749d69b382190b8e248127659fe2672da378b Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Tue, 1 Oct 2019 15:02:19 -0400 Subject: [PATCH 1/4] add missing package --- package.json | 3 ++- yarn.lock | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 76664d6..71617e1 100644 --- a/package.json +++ b/package.json @@ -24,8 +24,8 @@ "@babel/preset-env": "^7.1.6", "add-module-exports-webpack-plugin": "^1.0.0", "babel-loader": "^8.0.4", - "ganache-core": "^2.7.0", "cross-env": "^5.2.0", + "ganache-core": "^2.7.0", "npm-run-all": "^4.1.5", "rimraf": "^2.6.2", "webpack": "4.39.1", @@ -36,6 +36,7 @@ }, "dependencies": { "fast-deep-equal": "^2.0.1", + "hex2dec": "^1.1.2", "lokijs": "^1.5.6", "object-hash": "^1.3.1", "rxjs": "^6.5.2", diff --git a/yarn.lock b/yarn.lock index 2ce2990..615e073 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3995,6 +3995,11 @@ heap@0.2.6: resolved "https://registry.yarnpkg.com/heap/-/heap-0.2.6.tgz#087e1f10b046932fc8594dd9e6d378afc9d1e5ac" integrity sha1-CH4fELBGky/IWU3Z5tN4r8nR5aw= +hex2dec@^1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/hex2dec/-/hex2dec-1.1.2.tgz#8e1ce4bef36a74f7d5723c3fb3090c2860077338" + integrity sha512-Yu+q/XWr2fFQ11tHxPq4p4EiNkb2y+lAacJNhAdRXVfRIcDH6gi7htWFnnlIzvqHMHoWeIsfXlNAjZInpAOJDA== + hmac-drbg@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/hmac-drbg/-/hmac-drbg-1.0.1.tgz#d2745701025a6c775a6c545793ed502fc0c649a1" From 4bb65350897db8ddf299c0469b46baf461a0753b Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Tue, 1 Oct 2019 15:03:14 -0400 Subject: [PATCH 2/4] update README --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 103d4e9..d42683d 100644 --- a/README.md +++ b/README.md @@ -119,5 +119,14 @@ Thank you for considering to help out with the source code! We welcome contribut If you'd like to contribute to Phoenix, please fork, fix, commit and send a pull request for the maintainers to review and merge into the main code base. If you wish to submit more complex changes though, please check up with the core devs first on #embark-status channel to ensure those changes are in line with the general philosophy of the project and/or get some early feedback which can make both your efforts much lighter as well as our review and merge procedures quick and simple. +To build: + +* `yarn` +* `yarn build` + +```js +const Subspace = require('./src/index.js'); +``` + ## License MIT \ No newline at end of file From ed324f457913cb078eeeda616c8a17bab7002e76 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Tue, 1 Oct 2019 15:11:37 -0400 Subject: [PATCH 3/4] remove old file --- poc.js | 43 ------------------------------------------- 1 file changed, 43 deletions(-) delete mode 100644 poc.js diff --git a/poc.js b/poc.js deleted file mode 100644 index 75201dd..0000000 --- a/poc.js +++ /dev/null @@ -1,43 +0,0 @@ -const { ReplaySubject } = require('rxjs'); -const { map, scan } = require('rxjs/operators'); - -const { exhaustMap, takeLast, take } = require('rxjs/operators'); - -let _scan = scan((acc, curr) => { - acc.push(curr); - if (acc.length > 4) { - acc.shift(); - } - return acc; -}, []) - -let _average = map(arr => arr.reduce((acc, current) => acc + current, 0) / arr.length) - -let sub = new ReplaySubject(); -sub.next(1) -sub.next(2) -sub.next(3) -sub.next(4) - -// sub.pipe(_scan, _average).subscribe((v) => { -sub.pipe(takeLast(2)).subscribe((v) => { - console.log("got value " + v) -}) - -// result: -// got value 1 -// got value 1.5 -// got value 2 -// got value 2.5 - -// wanted result: -// got value 2.5 - -console.dir("---------") - -sub.next(5) -sub.next(6) - -// expected afterwards -// got value 3.5 -// got value 4.5 From 5e91eac2f5889dd26222511cbd0b7f5485a9266a Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Tue, 1 Oct 2019 15:11:53 -0400 Subject: [PATCH 4/4] rename references to new name --- .gitignore | 1 + .npmignore | 1 + README.md | 25 ++++++++++++------------- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index 2e6cd7f..b532b70 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ node_modules/ .vscode/ phoenix.db +subspace.db TODO test.js /dist/ diff --git a/.npmignore b/.npmignore index 49ac7b9..f0eb651 100644 --- a/.npmignore +++ b/.npmignore @@ -1,6 +1,7 @@ node_modules/ .vscode/ phoenix.db +subspace.db examples/ test/ .editorconfig diff --git a/README.md b/README.md index d42683d..e6f18d8 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,16 @@ -Phoenix +Subspace === ## Overview -Phoenix is a framework agnostic JS library that embraces reactive programming with RxJS, by observing asynchronous changes in Smart Contracts, and providing methods to track and subscribe to events, changes to the state of contracts and address balances, and react to these changes and events via callbacks. +Subspace is a framework agnostic JS library that embraces reactive programming with RxJS, by observing asynchronous changes in Smart Contracts, and providing methods to track and subscribe to events, changes to the state of contracts and address balances, and react to these changes and events via callbacks. ### Documentation TODO: link here - ### Install -Phoenix can be used in browser, node and native script environments. You can install it through `npm` or `yarn`: +Subspace can be used in browser, node and native script environments. You can install it through `npm` or `yarn`: ``` -npm install --save phoenix +npm install --save @statusim/subspace ``` ### Usage @@ -19,23 +18,23 @@ npm install --save phoenix #### Import into a dApp ```js // ESM (might require babel / browserify) -import Phoenix from 'phoenix'; +import Subspace from '@statusim/subspace'; // CommonJS -const Phoenix = require('phoenix'); +const Subspace = require('@statusim/subspace'); ``` ### Initializing the library -To interact with the EVM, Phoenix requires a valid websockets Web3 provider. +To interact with the EVM, Subspace requires a valid websockets Web3 provider. ```js -const subspace = new Phoenix(web3.currentProvider); +const subspace = new Subspace(web3.currentProvider); await subspace.init(); ``` -In addition to the provider, `Phoenix` also accepts an `options` object with settings that can change its behavior: -- `dbFilename` - Name of the database where the information will be stored (default 'phoenix.db') +In addition to the provider, `Subspace` also accepts an `options` object with settings that can change its behavior: +- `dbFilename` - Name of the database where the information will be stored (default 'subspace.db') - `callInterval` - Interval of time in milliseconds to query a contract/address to determine changes in state or balance (default: obtain data every block). ### API @@ -108,7 +107,7 @@ subscription.unsubscribe(); ``` #### Cleanup -If Phoenix `subspace` is not needed anymore, you need to invoke `clean()` to dispose and perform the cleanup necessary to remove the internal subscriptions and interval timers created by Phoenix during its normal execution. Any subscription created via the tracking methods must be unsubscribed manually (in the current version). +If Subspace `subspace` is not needed anymore, you need to invoke `clean()` to dispose and perform the cleanup necessary to remove the internal subscriptions and interval timers created by Subspace during its normal execution. Any subscription created via the tracking methods must be unsubscribed manually (in the current version). ``` subspace.clean(); @@ -117,7 +116,7 @@ subspace.clean(); ## Contribution Thank you for considering to help out with the source code! We welcome contributions from anyone on the internet, and are grateful for even the smallest of fixes! -If you'd like to contribute to Phoenix, please fork, fix, commit and send a pull request for the maintainers to review and merge into the main code base. If you wish to submit more complex changes though, please check up with the core devs first on #embark-status channel to ensure those changes are in line with the general philosophy of the project and/or get some early feedback which can make both your efforts much lighter as well as our review and merge procedures quick and simple. +If you'd like to contribute to Subspace, please fork, fix, commit and send a pull request for the maintainers to review and merge into the main code base. If you wish to submit more complex changes though, please check up with the core devs first on #embark-status channel to ensure those changes are in line with the general philosophy of the project and/or get some early feedback which can make both your efforts much lighter as well as our review and merge procedures quick and simple. To build: