bnc-assist
Advanced tools
Comparing version 0.9.2 to 0.9.3
{ | ||
"name": "bnc-assist", | ||
"version": "0.9.2", | ||
"version": "0.9.3", | ||
"description": "Blocknative Assist js library for Dapp developers", | ||
@@ -5,0 +5,0 @@ "main": "lib/assist.min.js", |
@@ -46,3 +46,3 @@ # Assist.js | ||
The library uses [semantic versioning](https://semver.org/spec/v2.0.0.html). | ||
The current version is 0.9.2. | ||
The current version is 0.9.3. | ||
There are minified and non-minified versions. | ||
@@ -52,7 +52,7 @@ Put this script at the top of your `<head>` | ||
```html | ||
<script src="https://assist.blocknative.com/0-9-2/assist.js"></script> | ||
<script src="https://assist.blocknative.com/0-9-3/assist.js"></script> | ||
<!-- OR... --> | ||
<script src="https://assist.blocknative.com/0-9-2/assist.min.js"></script> | ||
<script src="https://assist.blocknative.com/0-9-3/assist.min.js"></script> | ||
``` | ||
@@ -286,2 +286,4 @@ | ||
You can then decide whether you would like a notification to be shown for this event or not. Return `true` to show the notification or `false` to not show the notification. | ||
#### `eventCode` | ||
@@ -394,2 +396,3 @@ | ||
- `4`: rinkeby testnet | ||
- `5`: goerli testnet | ||
@@ -541,7 +544,7 @@ *The kovan testnet is not supported.* | ||
### `Transaction(txObject [, callback] [, inlineCustomMsgs])` | ||
### `Transaction(txObjectOrHash [, callback] [, inlineCustomMsgs])` | ||
#### Parameters | ||
`txObject` - `Object`: Transaction object (**Required**) | ||
`txObjectOrHash` - `Object` || `String`: Transaction object or transaction hash (**Required**) | ||
@@ -554,3 +557,3 @@ `callback` - `Function`: Optional error first style callback if you don't want to use promises | ||
`Promise` or `PromiEvent` (`web3.js 1.0`) | ||
`Promise` or `PromiEvent` (`web3.js 1.0`) if passed a transaction object or `true` if passed a valid transaction hash or `false` if hash is invalid | ||
@@ -570,2 +573,5 @@ - resolves with transaction hash | ||
}) | ||
// you can alternatively pass in a transaction hash to get Assist's notifications for a transaction that has already been sent to the network | ||
assistInstance.Transaction(hash) | ||
``` | ||
@@ -572,0 +578,0 @@ |
@@ -206,2 +206,4 @@ import uuid from 'uuid/v4' | ||
return 'rinkeby' | ||
case 5: | ||
return 'goerli' | ||
case 42: | ||
@@ -208,0 +210,0 @@ return 'kovan' |
@@ -20,2 +20,3 @@ import '@babel/polyfill' | ||
} from './logic/contract-methods' | ||
import { addTransactionToQueue } from './helpers/transaction-queue' | ||
import { openWebsocketConnection } from './helpers/websockets' | ||
@@ -25,7 +26,8 @@ import { getUserAgent } from './helpers/browser' | ||
import { checkUserEnvironment, prepareForTransaction } from './logic/user' | ||
import sendTransaction from './logic/send-transaction' | ||
import { sendTransaction, onTxHash } from './logic/send-transaction' | ||
import { configureWeb3 } from './helpers/web3' | ||
import { | ||
getOverloadedMethodKeys, | ||
truffleContractUsesWeb3v1 | ||
truffleContractUsesWeb3v1, | ||
createTransactionId | ||
} from './helpers/utilities' | ||
@@ -515,3 +517,3 @@ import { createIframe, updateStyle } from './helpers/iframe' | ||
function Transaction(txOptions, callback, inlineCustomMsgs = {}) { | ||
function Transaction(txOptionsOrHash, callback, inlineCustomMsgs = {}) { | ||
const { | ||
@@ -539,2 +541,27 @@ validApiKey, | ||
// if we are passed a transaction hash instead of an options object | ||
// then we just track the already sent transaction | ||
if (typeof txOptionsOrHash === 'string') { | ||
if (!/^0x([A-Fa-f0-9]{64})$/.test(txOptionsOrHash)) { | ||
return false | ||
} | ||
// create id for transaction | ||
const id = createTransactionId() | ||
// add transaction to queue | ||
addTransactionToQueue({ | ||
transaction: { | ||
id, | ||
status: 'signedTransaction' | ||
}, | ||
inlineCustomMsgs | ||
}) | ||
// handle txhash | ||
onTxHash(id, txOptionsOrHash, 'activeTransaction') | ||
return true | ||
} | ||
// Check if we have an instance of web3 | ||
@@ -555,3 +582,3 @@ if (!web3Instance && !ethers) { | ||
categoryCode: 'activeTransaction', | ||
txOptions, | ||
txOptionsOrHash, | ||
sendMethod, | ||
@@ -568,3 +595,3 @@ callback, | ||
categoryCode: 'activeTransaction', | ||
txOptions, | ||
txOptionsOrHash, | ||
sendMethod, | ||
@@ -571,0 +598,0 @@ callback, |
@@ -9,3 +9,3 @@ import { promisify } from 'bluebird' | ||
import sendTransaction from './send-transaction' | ||
import { sendTransaction } from './send-transaction' | ||
@@ -12,0 +12,0 @@ export function modernCall({ contractObj, methodName, args, truffleContract }) { |
@@ -26,3 +26,3 @@ import { state } from '~/js/helpers/state' | ||
function sendTransaction({ | ||
export function sendTransaction({ | ||
categoryCode, | ||
@@ -59,3 +59,3 @@ txOptions = {}, | ||
const contractEventObj = { | ||
const contractEventObj = methodName && { | ||
methodName, | ||
@@ -270,3 +270,3 @@ parameters: methodArgs | ||
function onTxHash(id, hash, categoryCode) { | ||
export function onTxHash(id, hash, categoryCode) { | ||
const txObj = updateTransactionInQueue(id, { | ||
@@ -384,3 +384,1 @@ status: 'approved', | ||
} | ||
export default sendTransaction |
Sorry, the diff of this file is too big to display
2556178
12756
696