From 09f0b1a0a01e848a41b122e7778f46bf43cc3799 Mon Sep 17 00:00:00 2001 From: Chris Meisl Date: Thu, 6 Jun 2019 22:41:36 -0600 Subject: [PATCH] version 0.8.6 (#264) * Fix typo with contract method call (#260) * Add resolving init onboard promise (#263) * update to version 0.8.6 --- README.md | 8 ++++---- package.json | 2 +- src/js/helpers/state.js | 3 ++- src/js/index.js | 15 +++++++++++++-- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 4ec8edb5..ac113934 100644 --- a/README.md +++ b/README.md @@ -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 `` ```html - + - + ``` ### Initialize the Library @@ -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])` diff --git a/package.json b/package.json index 4135c964..b9bcd75d 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/src/js/helpers/state.js b/src/js/helpers/state.js index e604be53..8f67a876 100644 --- a/src/js/helpers/state.js +++ b/src/js/helpers/state.js @@ -36,7 +36,8 @@ export const initialState = { iframe: null, iframeDocument: null, iframeWindow: null, - connectionId: null + connectionId: null, + onboardPromise: null } export let state = { ...initialState } diff --git a/src/js/index.js b/src/js/index.js index c7161a98..23786b76 100644 --- a/src/js/index.js +++ b/src/js/index.js @@ -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 @@ -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'