From 6790c3435f80513d79da48ab69ac8d865db3c763 Mon Sep 17 00:00:00 2001 From: Chris Meisl Date: Thu, 3 Oct 2019 13:11:53 -0600 Subject: [PATCH 01/13] Create LICENSE --- LICENSE | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..a20dc45 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Blocknative Corp + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. From 0ba8d3510ad3d2976f3f0d592583c8c607d5084c Mon Sep 17 00:00:00 2001 From: Chris Meisl Date: Thu, 3 Oct 2019 13:16:51 -0600 Subject: [PATCH 02/13] fix npm install for ci --- .circleci/config.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index a07a5d0..39f967a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -24,6 +24,7 @@ jobs: - run: sudo apt update && sudo apt install awscli - run: yarn - run: yarn build + - run: sudo -s - run: sudo npm i -g npm-cli-login - run: NPM_USER=$NPM_USERNAME NPM_EMAIL=$NPM_EMAIL NPM_PASS=$NPM_PASSWORD npm-cli-login - run: npm publish --dry-run @@ -43,6 +44,7 @@ jobs: - run: sudo apt update && sudo apt install awscli - run: yarn - run: yarn build + - run: sudo -s - run: sudo npm i -g add npm-cli-login - run: NPM_USER=$NPM_USERNAME NPM_EMAIL=$NPM_EMAIL NPM_PASS=$NPM_PASSWORD npm-cli-login - run: npm publish From 083b209f20ea5aa8fb432123cef57e86aa1d94c9 Mon Sep 17 00:00:00 2001 From: Chris Meisl Date: Thu, 3 Oct 2019 14:33:11 -0600 Subject: [PATCH 03/13] remove incorrect sudo --- .circleci/config.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 39f967a..a07a5d0 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -24,7 +24,6 @@ jobs: - run: sudo apt update && sudo apt install awscli - run: yarn - run: yarn build - - run: sudo -s - run: sudo npm i -g npm-cli-login - run: NPM_USER=$NPM_USERNAME NPM_EMAIL=$NPM_EMAIL NPM_PASS=$NPM_PASSWORD npm-cli-login - run: npm publish --dry-run @@ -44,7 +43,6 @@ jobs: - run: sudo apt update && sudo apt install awscli - run: yarn - run: yarn build - - run: sudo -s - run: sudo npm i -g add npm-cli-login - run: NPM_USER=$NPM_USERNAME NPM_EMAIL=$NPM_EMAIL NPM_PASS=$NPM_PASSWORD npm-cli-login - run: npm publish From ee3af416952a9c7b7b6bcd5846bc1a9b43eec466 Mon Sep 17 00:00:00 2001 From: Liam Aharon Date: Fri, 4 Oct 2019 10:35:54 +1000 Subject: [PATCH 04/13] Update .circleci config --- .circleci/config.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index a07a5d0..5a02cc5 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -2,7 +2,7 @@ version: 2 jobs: test: docker: - - image: circleci/node:8.15-browsers + - image: circleci/node:10.16 steps: - checkout - restore_cache: @@ -18,13 +18,14 @@ jobs: key: v1-dependencies-{{ checksum "package.json" }} deploy_stage: docker: - - image: circleci/node:8.15-browsers + - image: circleci/node:10.16 steps: - checkout - run: sudo apt update && sudo apt install awscli - run: yarn - run: yarn build - - run: sudo npm i -g npm-cli-login + - run: sudo -s + - run: npm i -g npm-cli-login - run: NPM_USER=$NPM_USERNAME NPM_EMAIL=$NPM_EMAIL NPM_PASS=$NPM_PASSWORD npm-cli-login - run: npm publish --dry-run - run: gzip -9 /home/circleci/project/dist/iife/notify.js @@ -37,7 +38,7 @@ jobs: - run: aws s3 sync /home/circleci/project/deploy-temp/${VERSION}/ s3://staging.notify.blocknative.com/${VERSION}/ --content-type "text/javascript" --content-encoding "gzip" --cache-control "max-age=31536000" --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers deploy_prod: docker: - - image: circleci/node:8.15-browsers + - image: circleci/node:10.16 steps: - checkout - run: sudo apt update && sudo apt install awscli From c82935c0b656a0cb52e874ba972ffd24ef0f8e8c Mon Sep 17 00:00:00 2001 From: Liam Aharon Date: Fri, 4 Oct 2019 10:38:22 +1000 Subject: [PATCH 05/13] Update circleci config --- .circleci/config.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 5a02cc5..fce98d8 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -24,8 +24,7 @@ jobs: - run: sudo apt update && sudo apt install awscli - run: yarn - run: yarn build - - run: sudo -s - - run: npm i -g npm-cli-login + - run: sudo npm i -g npm-cli-login - run: NPM_USER=$NPM_USERNAME NPM_EMAIL=$NPM_EMAIL NPM_PASS=$NPM_PASSWORD npm-cli-login - run: npm publish --dry-run - run: gzip -9 /home/circleci/project/dist/iife/notify.js From aec5c789f87c77c0c5ed7328cd57ee56da3ac0b1 Mon Sep 17 00:00:00 2001 From: Liam Aharon Date: Fri, 4 Oct 2019 10:56:53 +1000 Subject: [PATCH 06/13] Update .circleci --- .circleci/config.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index fce98d8..4c0d24e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -2,7 +2,7 @@ version: 2 jobs: test: docker: - - image: circleci/node:10.16 + - image: circleci/node:8.15-browsers steps: - checkout - restore_cache: @@ -18,7 +18,8 @@ jobs: key: v1-dependencies-{{ checksum "package.json" }} deploy_stage: docker: - - image: circleci/node:10.16 + - image: circleci/node:8.15-browsers + - user: root steps: - checkout - run: sudo apt update && sudo apt install awscli @@ -37,7 +38,7 @@ jobs: - run: aws s3 sync /home/circleci/project/deploy-temp/${VERSION}/ s3://staging.notify.blocknative.com/${VERSION}/ --content-type "text/javascript" --content-encoding "gzip" --cache-control "max-age=31536000" --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers deploy_prod: docker: - - image: circleci/node:10.16 + - image: circleci/node:8.15-browsers steps: - checkout - run: sudo apt update && sudo apt install awscli From a88033930eb319f17e0a2ddab0f55308b0b6498a Mon Sep 17 00:00:00 2001 From: Liam Aharon Date: Fri, 4 Oct 2019 10:58:12 +1000 Subject: [PATCH 07/13] Update .circleci --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 4c0d24e..0a619b0 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -19,7 +19,7 @@ jobs: deploy_stage: docker: - image: circleci/node:8.15-browsers - - user: root + user: root steps: - checkout - run: sudo apt update && sudo apt install awscli From 809a5e7cb1dd9059c083516b0fed5b272f485491 Mon Sep 17 00:00:00 2001 From: Liam Aharon Date: Fri, 4 Oct 2019 11:03:33 +1000 Subject: [PATCH 08/13] Update .circleci config --- .circleci/config.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 0a619b0..fe7ad54 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -28,14 +28,14 @@ jobs: - run: sudo npm i -g npm-cli-login - run: NPM_USER=$NPM_USERNAME NPM_EMAIL=$NPM_EMAIL NPM_PASS=$NPM_PASSWORD npm-cli-login - run: npm publish --dry-run - - run: gzip -9 /home/circleci/project/dist/iife/notify.js - - run: mv /home/circleci/project/dist/iife/notify.js.gz /home/circleci/project/dist/iife/notify.js + - run: gzip -9 ./dist/iife/notify.js + - run: mv ./dist/iife/notify.js.gz ./dist/iife/notify.js - run: ls -al - run: echo export VERSION=`awk '/version/{gsub(/("|",)/,"",$2);print $2};' package.json | sed 's/\./-/g'` >> $BASH_ENV - - run: mkdir /home/circleci/project/deploy-temp - - run: mkdir /home/circleci/project/deploy-temp/${VERSION} - - run: mv /home/circleci/project/dist/iife/*.js /home/circleci/project/deploy-temp/${VERSION}/ - - run: aws s3 sync /home/circleci/project/deploy-temp/${VERSION}/ s3://staging.notify.blocknative.com/${VERSION}/ --content-type "text/javascript" --content-encoding "gzip" --cache-control "max-age=31536000" --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers + - run: mkdir /root/project/deploy-temp + - run: mkdir /root/project/deploy-temp/${VERSION} + - run: mv /root/project/dist/iife/*.js /root/project/deploy-temp/${VERSION}/ + - run: aws s3 sync /root/project/deploy-temp/${VERSION}/ s3://staging.notify.blocknative.com/${VERSION}/ --content-type "text/javascript" --content-encoding "gzip" --cache-control "max-age=31536000" --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers deploy_prod: docker: - image: circleci/node:8.15-browsers From 1e87b7cb77680d704a0db4ac19d0d714d421837e Mon Sep 17 00:00:00 2001 From: Chris Meisl Date: Fri, 4 Oct 2019 11:47:07 -0600 Subject: [PATCH 09/13] update prod CI deploy config --- .circleci/config.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index fe7ad54..39fc8fc 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -39,6 +39,7 @@ jobs: deploy_prod: docker: - image: circleci/node:8.15-browsers + user: root steps: - checkout - run: sudo apt update && sudo apt install awscli @@ -47,14 +48,14 @@ jobs: - run: sudo npm i -g add npm-cli-login - run: NPM_USER=$NPM_USERNAME NPM_EMAIL=$NPM_EMAIL NPM_PASS=$NPM_PASSWORD npm-cli-login - run: npm publish - - run: gzip -9 /home/circleci/project/dist/iife/notify.js - - run: mv /home/circleci/project/dist/iife/notify.js.gz /home/circleci/project/dist/iife/notify.js + - run: gzip -9 ./dist/iife/notify.js + - run: mv ./dist/iife/notify.js.gz ./dist/iife/notify.js - run: ls -al - run: echo export VERSION=`awk '/version/{gsub(/("|",)/,"",$2);print $2};' package.json | sed 's/\./-/g'` >> $BASH_ENV - - run: mkdir /home/circleci/project/deploy-temp - - run: mkdir /home/circleci/project/deploy-temp/${VERSION} - - run: mv /home/circleci/project/dist/iife/*.js /home/circleci/project/deploy-temp/${VERSION}/ - - run: aws s3 sync /home/circleci/project/deploy-temp/${VERSION}/ s3://notify.blocknative.com/${VERSION}/ --content-type "text/javascript" --content-encoding "gzip" --cache-control "max-age=31536000" --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers + - run: mkdir /root/project/deploy-temp + - run: mkdir /root/project/deploy-temp/${VERSION} + - run: mv /root/project/dist/iife/*.js /root/project/deploy-temp/${VERSION}/ + - run: aws s3 sync /root/project/deploy-temp/${VERSION}/ s3://notify.blocknative.com/${VERSION}/ --content-type "text/javascript" --content-encoding "gzip" --cache-control "max-age=31536000" --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers workflows: version: 2 test_build: From bbe7cd681ceb8c099866ada757c698cc0cf0accb Mon Sep 17 00:00:00 2001 From: Aaron Barnard Date: Wed, 16 Oct 2019 12:53:00 +1100 Subject: [PATCH 10/13] Update docs to include the notification function --- README.md | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b5ad6ea..81621f6 100644 --- a/README.md +++ b/README.md @@ -154,9 +154,39 @@ The `txDetails` object includes a `to` parameter which is the address the transa The `sendTransaction` function must return a `Promise` that resolves with a `String` that is the transaction hash. +### `notification` + +You may want to trigger a notification for a custom event that may not be related to a transaction. You can use the `notification` function to do that: + +```javascript +const notificationObject = { + type: "pending", + message: "Updating the database with your information", + autoDismiss: 4000 +} + +const { update, dismiss } = notify.notification( + "databaseUpdate", + notificationObject +) +``` + +The `notification` function is called with two arguments: + +- `eventCode`: a string which is used to keep track of that event for your analytics dashboard +- `notificationObject`: a object that defines the notification with the parameters: + - `type`: a string that defines the style - ['hint' (gray), 'pending' (yellow), 'success' (green), 'error' (red)] + - `message`: a message string that is displayed on the notification + - `autoDismiss`: a number in milliseconds before the notification auto dismisses. Defaults to no auto dismissal + +Returned from the notification function is an object that has two functions defined on it: + +- `update`: a function that can be called with a new notification object to replace the original notification with +- `dismiss`: a function that can be called to dismiss the notification manually + ### `config` -There are some configuration options available: +There are some configuration options available which can be updated by calling the `config` function: ```javascript notify.config({ From e1123efd3a9ae9e0ae311de2b5795483f957e635 Mon Sep 17 00:00:00 2001 From: Aaron Barnard Date: Wed, 16 Oct 2019 12:56:56 +1100 Subject: [PATCH 11/13] Fix result.hash bug --- src/transactions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/transactions.js b/src/transactions.js index ad6a15b..507e888 100644 --- a/src/transactions.js +++ b/src/transactions.js @@ -239,7 +239,7 @@ export function preflightTransaction(options, emitter, blocknative) { }) if (hash && typeof hash === "string") { - const serverEmitter = blocknative.transaction(result.hash, id).emitter + const serverEmitter = blocknative.transaction(hash, id).emitter serverEmitter.on("all", transaction => { const listener = From 5ea1c0202e6c39842fe30657bfec6249a341aea0 Mon Sep 17 00:00:00 2001 From: Aaron Barnard Date: Wed, 16 Oct 2019 17:01:35 +1100 Subject: [PATCH 12/13] Pass 10 in to toString method to avoid exponent notation --- src/notifications.js | 2 +- src/transactions.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/notifications.js b/src/notifications.js index 274fbae..e2c15e5 100644 --- a/src/notifications.js +++ b/src/notifications.js @@ -41,7 +41,7 @@ export function createNotification(details, customization = {}) { : "sending", formattedValue: BigNumber(value) .div(BigNumber("1000000000000000000")) - .toString(), + .toString(10), preposition: direction === "incoming" ? "from" : "to", counterpartyShortened, asset diff --git a/src/transactions.js b/src/transactions.js index 507e888..a052513 100644 --- a/src/transactions.js +++ b/src/transactions.js @@ -113,9 +113,9 @@ export function preflightTransaction(options, emitter, blocknative) { const txObject = { ...txDetails, - value: value.toString(), - gas: gas && gas.toString(), - gasPrice: price && price.toString(), + value: value.toString(10), + gas: gas && gas.toString(10), + gasPrice: price && price.toString(10), id } From fc9a001409be83209e3b0b28dd948293bf35f4eb Mon Sep 17 00:00:00 2001 From: Aaron Barnard Date: Wed, 16 Oct 2019 17:18:38 +1100 Subject: [PATCH 13/13] Increment version to 0.1.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 77e14f0..32225cf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bnc-notify", - "version": "0.1.1", + "version": "0.1.2", "main": "dist/cjs/index.js", "module": "dist/esm/index.js", "files": [