Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bnc-notify",
"version": "1.9.2",
"version": "1.9.2-0.0.1",
"description": "Show web3 users realtime transaction notifications",
"keywords": [
"ethereum",
Expand Down Expand Up @@ -50,7 +50,7 @@
},
"dependencies": {
"bignumber.js": "^9.0.0",
"bnc-sdk": "^3.5.0",
"bnc-sdk": "4.0.0",
"lodash.debounce": "^4.0.8",
"regenerator-runtime": "^0.13.3",
"uuid": "^3.3.3"
Expand Down
4 changes: 2 additions & 2 deletions src/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function createBitcoinNotificationObject(
outputs
} = transactionDetails
const type: NotificationType = eventToType(eventCode)
const key = `${id}-${
const key = `${id || txid}-${
(typeof customization === 'object' && customization.eventCode) || eventCode
}`

Expand Down Expand Up @@ -121,7 +121,7 @@ function createEthereumNotificationObject(
} = transactionDetails

const type: NotificationType = eventToType(eventCode)
const key = `${id}-${
const key = `${id || hash}-${
(typeof customization === 'object' && customization.eventCode) || eventCode
}`
const counterpartyShortened: string | undefined =
Expand Down
31 changes: 22 additions & 9 deletions src/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,22 +70,35 @@ export function handlePreFlightEvent(

export function handleTransactionEvent(event) {
const { transaction, emitterResult } = event

if (!transaction.id) {
transaction.id = transaction.hash || transaction.txid
const currentId = transaction.id
const transactionId = transaction.hash || transaction.txid

// returns a boolean indicating whether this transaction state is a new state
// for an existing transaction or is a new transaction
const predicate = (txInState: TransactionData) => {
return (
(txInState.id && txInState.id === currentId) ||
txInState.hash === transaction.hash ||
txInState.replaceHash === transaction.hash
)
}

const predicate = (tx: TransactionData) => {
return transaction.replaceHash
? tx.id === transaction.replaceHash || tx.hash === transaction.replaceHash
: tx.id === transaction.id || tx.hash === transaction.hash
// replace UUID used for pre-hash identitification with hash or txid(bitcoin)
if (
(transactionId &&
transactionId !== currentId &&
transaction.eventCode === 'txSent') ||
!currentId
) {
transaction.id = transactionId
}

transactions.updateQueue(transaction, predicate)

// update notification id if replaced
if (transaction.replaceHash) {
notifications.updateId(transaction.replaceHash, transaction.hash)
// remove pending notification for replaceHash if exists,
// this happens is pending comes before speedup event
notifications.remove(transaction.replaceHash, 'txPool')
}

// create notification if dev hasn't opted out and not connected to a local network
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2175,10 +2175,10 @@ binary-extensions@^2.0.0:
resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.1.0.tgz#30fa40c9e7fe07dbc895678cd287024dea241dd9"
integrity sha512-1Yj8h9Q+QDF5FzhMs/c9+6UntbD5MkRfRwac8DoEm9ZfUBZ7tZ55YcGVAzEe4bXsdQHEk+s9S5wsOKVdZrw0tQ==

bnc-sdk@^3.5.0:
version "3.5.0"
resolved "https://registry.yarnpkg.com/bnc-sdk/-/bnc-sdk-3.5.0.tgz#b863a2d947857d87c56d53261bd43529f1a5c03e"
integrity sha512-4CSon8xRTjtD7YOUDJcyqZ/bKCNNwDc4sOPq6O19AlolYTsbbVvh+p5EOmYqL4Re30hI3lKQxN4sh12A6VnAPQ==
bnc-sdk@4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/bnc-sdk/-/bnc-sdk-4.0.0.tgz#0bf8af5c7c3fab7912912431e1af0e48e01b608b"
integrity sha512-ob0GP1dS2yGvV+2hpJgpmrJeen0W68K4jsfjikbuL7ogBAVaQaWbPAzKw2w9tgq9BUM96CR43UpAobSyTZDx7g==
dependencies:
crypto-es "^1.2.2"
rxjs "^6.6.3"
Expand Down