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
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.1-0.0.1",
"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