Skip to content

Commit 7221c7b

Browse files
authored
1.9.1-0.0.1: [fix] - Duplicate Notifications (#216)
* Fixes types * Maintains id * Increment version
1 parent f0d6eb9 commit 7221c7b

File tree

5 files changed

+14
-18
lines changed

5 files changed

+14
-18
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bnc-notify",
3-
"version": "1.9.1",
3+
"version": "1.9.1-0.0.1",
44
"description": "Show web3 users realtime transaction notifications",
55
"keywords": [
66
"ethereum",

src/interfaces.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import type {
22
BitcoinTransactionLog,
33
EthereumTransactionLog,
4-
SDKError
4+
SDKError,
5+
TransactionHandler
56
} from 'bnc-sdk/dist/types/src/interfaces'
67

78
export interface InitOptions extends ConfigOptions {
@@ -14,10 +15,6 @@ export interface InitOptions extends ConfigOptions {
1415

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

17-
export interface TransactionHandler {
18-
(transaction: TransactionEvent): void
19-
}
20-
2118
export interface TransactionEvent {
2219
emitterResult: void | boolean | CustomNotificationObject
2320
transaction: TransactionData

src/notify.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'regenerator-runtime/runtime'
22
import BlocknativeSdk from 'bnc-sdk'
3+
import type { TransactionHandler } from 'bnc-sdk/dist/types/src/interfaces'
34
import { get } from 'svelte/store'
45

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

1415
import type {
1516
InitOptions,
16-
TransactionHandler,
1717
AppStore,
1818
API,
1919
Emitter,
@@ -26,7 +26,6 @@ import type {
2626

2727
export {
2828
InitOptions,
29-
TransactionHandler,
3029
TransactionEvent,
3130
System,
3231
TransactionEventCode,

src/transactions.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,18 @@ export function handlePreFlightEvent(
6868
})
6969
}
7070

71-
export function handleTransactionEvent(event: {
72-
transaction: TransactionData
73-
emitterResult: boolean | void | CustomNotificationObject
74-
}) {
71+
export function handleTransactionEvent(event) {
7572
const { transaction, emitterResult } = event
73+
7674
if (!transaction.id) {
7775
transaction.id = transaction.hash || transaction.txid
7876
}
7977

80-
const predicate = (tx: TransactionData) =>
81-
transaction.replaceHash
82-
? tx.id === transaction.replaceHash
83-
: tx.id === transaction.id
78+
const predicate = (tx: TransactionData) => {
79+
return transaction.replaceHash
80+
? tx.id === transaction.replaceHash || tx.hash === transaction.replaceHash
81+
: tx.id === transaction.id || tx.hash === transaction.hash
82+
}
8483

8584
transactions.updateQueue(transaction, predicate)
8685

src/utilities.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export function replaceOrAdd(
1919
const index = clone.findIndex(predicate)
2020

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

2424
// if current transaction is a speedup or cancel and new status is pending, ignore update
2525
if (
@@ -35,7 +35,8 @@ export function replaceOrAdd(
3535
clone[index] = {
3636
...data,
3737
...contractCallMerge,
38-
startTime: startTime || serverStartTime
38+
startTime: startTime || serverStartTime,
39+
id
3940
}
4041
return clone
4142
}

0 commit comments

Comments
 (0)