From efd6b260ca5081e383e852f704ed3ba209a74182 Mon Sep 17 00:00:00 2001 From: Cvetan Mihaylov Date: Tue, 3 Jan 2023 00:05:42 +0200 Subject: [PATCH 01/24] Add sdk and try to implement ambire module for web3-onboard --- public/index.html | 34 +++++ public/scripts/ambire-sdk.js | 219 ++++++++++++++++++++++++++++ src/components/SignForm/SignForm.js | 37 +++-- src/helpers/ambireWallet.js | 45 ++++++ 4 files changed, 326 insertions(+), 9 deletions(-) create mode 100644 public/scripts/ambire-sdk.js create mode 100644 src/helpers/ambireWallet.js diff --git a/public/index.html b/public/index.html index 2773a32..b2574df 100644 --- a/public/index.html +++ b/public/index.html @@ -25,6 +25,34 @@ Learn how to configure a non-root public URL by running `npm run build`. --> SigTool for EVM + + @@ -41,5 +69,11 @@ To begin the development, run `npm start` or `yarn start`. To create a production bundle, use `npm run build` or `yarn build`. --> + +
+ + +
+ diff --git a/public/scripts/ambire-sdk.js b/public/scripts/ambire-sdk.js new file mode 100644 index 0000000..c8cbc07 --- /dev/null +++ b/public/scripts/ambire-sdk.js @@ -0,0 +1,219 @@ +window.AmbireSDK = function (opt = {}) { + const self = this + + // // TEMP + // const newDiv = document.createElement('div') + // newDiv.setAttribute('id', 'ambire-sdk-wrapper') + // newDiv.setAttribute('class', 'sdk-overlay') + // const subDiv = document.createElement('div') + // subDiv.setAttribute('id', 'ambire-sdk-iframe') + // subDiv.setAttribute('class', 'modal-window') + // newDiv.appendChild(subDiv) + // const closeButton = document.createElement('button') + // closeButton.setAttribute('id', 'ambire-sdk-iframe-close') + // const buttonText = document.createTextNode('Close iframe') + // closeButton.appendChild(buttonText) + // newDiv.appendChild(closeButton) + // document.body.appendChild(newDiv) + + this.dappName = opt.dappName ?? 'Unknown Dapp' + this.wrapperElement = document.getElementById(opt.wrapperElementId ?? 'ambire-sdk-wrapper') + this.iframeElement = document.getElementById(opt.iframeElementId ?? 'ambire-sdk-iframe') + this.closeButton = document.getElementById(opt.closeButtonId ?? 'ambire-sdk-iframe-close') + + this.hideIframe = function () { + self.iframeElement.style.visibility = 'hidden' + self.iframeElement.style.opacity = 0 + self.iframeElement.style.pointerEvents = 'none' + + self.closeButton.style.display = 'none' + + document.body.style.pointerEvents = 'auto' + self.wrapperElement.style.visibility = 'hidden' + self.wrapperElement.style.opacity = 0 + self.wrapperElement.style.pointerEvents = 'auto' + } + + this.showIframe = function (url) { + document.body.style.pointerEvents = 'none' + self.wrapperElement.style.visibility = 'visible' + self.wrapperElement.style.opacity = 1 + self.wrapperElement.style.pointerEvents = 'none' + + self.iframeElement.style.width = '60%' + self.iframeElement.style.height = '600px' + + self.iframeElement.style.visibility = 'visible' + self.iframeElement.style.opacity = 1 + self.iframeElement.style.pointerEvents = 'auto' + + self.iframeElement.innerHTML = `