Skip to content

Commit

Permalink
Merge pull request #18 from blocknative/develop
Browse files Browse the repository at this point in the history
Release 0.1.2
  • Loading branch information
lnbc1QWFyb24 authored Oct 16, 2019
2 parents 8644845 + fc9a001 commit bf22d80
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 19 deletions.
26 changes: 14 additions & 12 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
deploy_stage:
docker:
- image: circleci/node:8.15-browsers
user: root
steps:
- checkout
- run: sudo apt update && sudo apt install awscli
Expand All @@ -27,17 +28,18 @@ 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
user: root
steps:
- checkout
- run: sudo apt update && sudo apt install awscli
Expand All @@ -46,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:
Expand Down
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -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.
32 changes: 31 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down
2 changes: 1 addition & 1 deletion src/notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/transactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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 =
Expand Down

0 comments on commit bf22d80

Please sign in to comment.