Skip to content

Commit 7a27639

Browse files
authored
Merge pull request #139 from blocknative/develop
Release 1.2.3
2 parents 8003a80 + f9dd557 commit 7a27639

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bnc-notify",
3-
"version": "1.2.2",
3+
"version": "1.2.3",
44
"description": "Show web3 users realtime transaction notifications",
55
"keywords": [
66
"ethereum",

src/notify.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ function init(options: InitOptions): API {
136136

137137
const emitter = createEmitter()
138138

139-
const result = preflightTransaction(options, emitter)
139+
const result = preflightTransaction(options, emitter).catch(err => err)
140140

141141
return {
142142
emitter,

src/transactions.ts

+5-8
Original file line numberDiff line numberDiff line change
@@ -242,21 +242,16 @@ export function preflightTransaction(
242242
emitter
243243
})
244244

245-
resolve(id)
246-
247245
// if not provided with sendTransaction function, resolve with id so dev can initiate transaction
248246
// dev will need to call notify.hash(txHash, id) with this id to link up the preflight with the postflight notifications
249247
if (!sendTransaction) {
250-
return
248+
return resolve(id)
251249
}
252250

253-
// initiate transaction
254-
const sendTransactionResult = sendTransaction()
255-
256251
// get result and handle errors
257252
let hash
258253
try {
259-
hash = await sendTransactionResult
254+
hash = await sendTransaction()
260255
} catch (error) {
261256
const { eventCode, errorMsg } = extractMessageFromError(error)
262257

@@ -324,8 +319,10 @@ export function preflightTransaction(
324319
})
325320
}
326321
}, txStallConfirmedTimeout)
322+
323+
resolve(id)
327324
} else {
328-
throw new Error(
325+
reject(
329326
'sendTransaction function must resolve to a transaction hash that is of type String.'
330327
)
331328
}

0 commit comments

Comments
 (0)