Skip to content

Commit

Permalink
version 0.8.6 (#264)
Browse files Browse the repository at this point in the history
* Fix typo with contract method call (#260)

* Add resolving init onboard promise (#263)

* update to version 0.8.6
  • Loading branch information
cmeisl authored Jun 7, 2019
1 parent 9cc8e2b commit 09f0b1a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,16 @@ yarn add bnc-assist
#### Script Tag

The library uses [semantic versioning](https://semver.org/spec/v2.0.0.html).
The current version is 0.8.5.
The current version is 0.8.6.
There are minified and non-minified versions.
Put this script at the top of your `<head>`

```html
<script src="https://assist.blocknative.com/0-8-5/assist.js"></script>
<script src="https://assist.blocknative.com/0-8-6/assist.js"></script>

<!-- OR... -->

<script src="https://assist.blocknative.com/0-8-5/assist.min.js"></script>
<script src="https://assist.blocknative.com/0-8-6/assist.min.js"></script>
```

### Initialize the Library
Expand Down Expand Up @@ -434,7 +434,7 @@ A decorated `contract` to be used instead of the original instance
const myContract = new web3.eth.Contract(abi, address)
const myDecoratedContract = assistInstance.Contract(myContract)

mydecoratedContract.myMethod().call()
mydecoratedContract.methods.myMethod(params).call()
```

### `Transaction(txObject [, callback] [, inlineCustomMsgs])`
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bnc-assist",
"version": "0.8.5",
"version": "0.8.6",
"description": "Blocknative Assist js library for Dapp developers",
"main": "lib/assist.min.js",
"scripts": {
Expand Down
3 changes: 2 additions & 1 deletion src/js/helpers/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ export const initialState = {
iframe: null,
iframeDocument: null,
iframeWindow: null,
connectionId: null
connectionId: null,
onboardPromise: null
}

export let state = { ...initialState }
Expand Down
15 changes: 13 additions & 2 deletions src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,13 @@ function init(config) {
const onboardingInProgress = getItem('onboarding') === 'true'

if (onboardingInProgress) {
onboard().catch(() => {})
const onboardPromise = onboard()
updateState({ onboardPromise })

// once the promise resolves, clear it from state
onboardPromise
.catch(() => {})
.finally(() => updateState({ onboardPromise: null }))
}

// return the API
Expand All @@ -127,9 +133,14 @@ function init(config) {
mobileDevice,
validApiKey,
supportedNetwork,
config: { headlessMode, mobileBlocked }
config: { headlessMode, mobileBlocked },
onboardPromise
} = state

if (onboardPromise) {
return onboardPromise
}

if (!validApiKey) {
const errorObj = new Error('Your api key is not valid')
errorObj.eventCode = 'initFail'
Expand Down

0 comments on commit 09f0b1a

Please sign in to comment.