From 50598969473b613e8fc6fc8b854ef82fd6719326 Mon Sep 17 00:00:00 2001 From: Aaron Barnard Date: Fri, 3 Dec 2021 15:37:16 +1100 Subject: [PATCH 1/3] Fixes types --- src/interfaces.ts | 7 ++----- src/notify.ts | 3 +-- src/transactions.ts | 15 +++++++-------- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/interfaces.ts b/src/interfaces.ts index 7f84c76..59dcf1e 100644 --- a/src/interfaces.ts +++ b/src/interfaces.ts @@ -1,7 +1,8 @@ import type { BitcoinTransactionLog, EthereumTransactionLog, - SDKError + SDKError, + TransactionHandler } from 'bnc-sdk/dist/types/src/interfaces' export interface InitOptions extends ConfigOptions { @@ -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 diff --git a/src/notify.ts b/src/notify.ts index 919db33..4ca8447 100644 --- a/src/notify.ts +++ b/src/notify.ts @@ -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' @@ -13,7 +14,6 @@ import { createNotification } from './notifications' import type { InitOptions, - TransactionHandler, AppStore, API, Emitter, @@ -26,7 +26,6 @@ import type { export { InitOptions, - TransactionHandler, TransactionEvent, System, TransactionEventCode, diff --git a/src/transactions.ts b/src/transactions.ts index 8aad6a7..4bc67d7 100644 --- a/src/transactions.ts +++ b/src/transactions.ts @@ -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) From d75285f2da64a4fba73b3918117728cd975f842b Mon Sep 17 00:00:00 2001 From: Aaron Barnard Date: Fri, 3 Dec 2021 15:37:23 +1100 Subject: [PATCH 2/3] Maintains id --- src/utilities.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/utilities.ts b/src/utilities.ts index 752c381..e09072b 100644 --- a/src/utilities.ts +++ b/src/utilities.ts @@ -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 ( @@ -35,7 +35,8 @@ export function replaceOrAdd( clone[index] = { ...data, ...contractCallMerge, - startTime: startTime || serverStartTime + startTime: startTime || serverStartTime, + id } return clone } From a25496f34e81d7a28d40404b37281c901a451dc4 Mon Sep 17 00:00:00 2001 From: Aaron Barnard Date: Fri, 3 Dec 2021 15:37:59 +1100 Subject: [PATCH 3/3] Increment version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ac9a453..b887b95 100644 --- a/package.json +++ b/package.json @@ -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",