Skip to content

Commit

Permalink
Merge pull request #218 from blocknative/release/1.9.2
Browse files Browse the repository at this point in the history
Release: 1.9.2 - Master
  • Loading branch information
taylorjdawson authored Dec 3, 2021
2 parents ee03581 + 0d5751c commit c80f136
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 23 deletions.
8 changes: 3 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ jobs:
- run: sudo apt update && sudo apt install awscli
- run: yarn
- run: yarn build
- 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: echo "//registry.npmjs.org/:_authToken=$npm_TOKEN" > .npmrc
- run: npm publish --dry-run
- run: gzip -9 ./dist/notify.umd.js
- run: mv ./dist/notify.umd.js.gz ./dist/notify.umd.js
Expand All @@ -45,9 +44,8 @@ jobs:
- run: sudo apt update && sudo apt install awscli
- run: yarn
- run: yarn build
- 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: echo "//registry.npmjs.org/:_authToken=$npm_TOKEN" > .npmrc
- run: npm publish --access public
- run: gzip -9 ./dist/notify.umd.js
- run: mv ./dist/notify.umd.js.gz ./dist/notify.umd.js
- run: ls -al
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": "1.9.1",
"version": "1.9.2",
"description": "Show web3 users realtime transaction notifications",
"keywords": [
"ethereum",
Expand Down
7 changes: 2 additions & 5 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import type {
BitcoinTransactionLog,
EthereumTransactionLog,
SDKError
SDKError,
TransactionHandler
} from 'bnc-sdk/dist/types/src/interfaces'

export interface InitOptions extends ConfigOptions {
Expand All @@ -14,10 +15,6 @@ export interface InitOptions extends ConfigOptions {

export type ErrorHandler = (error: SDKError) => void

export interface TransactionHandler {
(transaction: TransactionEvent): void
}

export interface TransactionEvent {
emitterResult: void | boolean | CustomNotificationObject
transaction: TransactionData
Expand Down
3 changes: 1 addition & 2 deletions src/notify.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'regenerator-runtime/runtime'
import BlocknativeSdk from 'bnc-sdk'
import type { TransactionHandler } from 'bnc-sdk/dist/types/src/interfaces'
import { get } from 'svelte/store'

import uuid from 'uuid/v4'
Expand All @@ -13,7 +14,6 @@ import { createNotification } from './notifications'

import type {
InitOptions,
TransactionHandler,
AppStore,
API,
Emitter,
Expand All @@ -26,7 +26,6 @@ import type {

export {
InitOptions,
TransactionHandler,
TransactionEvent,
System,
TransactionEventCode,
Expand Down
15 changes: 7 additions & 8 deletions src/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,18 @@ export function handlePreFlightEvent(
})
}

export function handleTransactionEvent(event: {
transaction: TransactionData
emitterResult: boolean | void | CustomNotificationObject
}) {
export function handleTransactionEvent(event) {
const { transaction, emitterResult } = event

if (!transaction.id) {
transaction.id = transaction.hash || transaction.txid
}

const predicate = (tx: TransactionData) =>
transaction.replaceHash
? tx.id === transaction.replaceHash
: tx.id === transaction.id
const predicate = (tx: TransactionData) => {
return transaction.replaceHash
? tx.id === transaction.replaceHash || tx.hash === transaction.replaceHash
: tx.id === transaction.id || tx.hash === transaction.hash
}

transactions.updateQueue(transaction, predicate)

Expand Down
5 changes: 3 additions & 2 deletions src/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function replaceOrAdd(
const index = clone.findIndex(predicate)

if (index !== -1) {
const { startTime, contractCall, status } = clone[index]
const { startTime, contractCall, status, id } = clone[index]

// if current transaction is a speedup or cancel and new status is pending, ignore update
if (
Expand All @@ -35,7 +35,8 @@ export function replaceOrAdd(
clone[index] = {
...data,
...contractCallMerge,
startTime: startTime || serverStartTime
startTime: startTime || serverStartTime,
id
}
return clone
}
Expand Down

0 comments on commit c80f136

Please sign in to comment.