diff --git a/package.json b/package.json
index 2b5e380..b19aa34 100644
--- a/package.json
+++ b/package.json
@@ -71,6 +71,7 @@
"react-dev-utils": "10.0.0",
"react-device-detect": "^1.11.14",
"react-dom": "^16.12.0",
+ "react-modal": "^3.11.2",
"react-toast-notifications": "^2.4.0",
"react-tooltip": "^3.11.6",
"resolve": "1.12.2",
@@ -83,6 +84,7 @@
"ts-pnp": "1.1.5",
"typescript": "^3.7.5",
"url-loader": "2.3.0",
+ "userbase-js": "^1.4.1",
"webpack": "4.41.2",
"webpack-dev-server": "3.9.0",
"webpack-manifest-plugin": "2.2.0",
diff --git a/public/index.html b/public/index.html
index 8cadef0..ef895ce 100644
--- a/public/index.html
+++ b/public/index.html
@@ -1,845 +1,516 @@
-
-
-
-
-
-
-
-
Network Features
-
-
-
Network: Get ID
-
NetworkID should be here
-
-
-
-
-
-
Network: Get Name
-
Network ID should be here
-
-
-
-
-
-
-
-
Network: Get Provider
-
Network provider should be here
-
-
-
-
-
-
-
-
Network: Transfer - (unfinished)
-
-
-
-
-
-
-
-
-
-
-
-
Network: Get Provider
-
Network provider should be here
-
-
-
-
-
-
-
Network: Enable Button (unfinished)
-
-
-
-
-
-
User Features
-
-
-
User: Account Adddress
-
User Address Should be Here
-
-
-
User: Account Adddress Short
-
User Address Should be Here
-
-
-
User: Get Balance
-
User Address Should be Here
-
-
-
3Box Features
-
-
-
3Box: UserName
-
3box name
-
-
3Box: Website
-
3box website
-
-
-
.png)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Custom Contract
-
-
Method: "hello"
-
Payable: false - StateMutability: "view"
-
-
Inputs
-
-
-
Outputs
-
-
-
-
-
-
-
- *Return value: -*
-
-
-
-
-
-
-
Method: "sendEthWithArgs"
-
Payable: true - StateMutability: "payable"
-
No ETH Sent
-
-
Inputs
-
-
-
Outputs
-
-
-
-
-
-
-
-
-
- *Return value: -*
-
-
-
-
-
-
-
-
-
Method: "sendEthWithArgs"
-
Payable: true - StateMutability: "payable"
-
ETH Value: HardCoded: .15ETH
-
-
Inputs
-
-
-
Outputs
-
-
-
-
-
-
-
-
-
- *Return value: -*
-
-
-
-
-
-
-
-
-
-
Method: "sendEthWithArgs"
-
Payable: true - StateMutability: "payable"
-
ETH Value: User Input
-
-
Inputs
-
-
-
Outputs
-
-
-
-
This is the method
-
-
-
-
-
-
-
-
- *Return value: -*
-
-
-
-
-
-
-
-
-
-
-
-
-
Method: "viewMultipleArgsMultipleReturn"
-
Payable: false - StateMutability: "view"
-
-
Inputs
-
- - from - address
- - multiplier - uint256
-
-
-
Outputs
-
- - _balanceMultiplied - uint256
- - _hello - bytes32
-
-
-
-
-
-
-
-
-
-
- *Return value: -*
-
-
-
-
-
-
-
-
Method: "sendVariableEthNoArgs"
-
Payable: true - StateMutability: "payable"
-
No eth is sent here.
-
-
Inputs
-
-
-
Outputs
-
-
>
-
-
-
-
-
- *Return value: -*
-
-
-
-
-
-
-
Method: "viewMultipleArgsSingleReturn"
-
Payable: false - StateMutability: "view"
-
-
Inputs
-
- - fromAddress - address
- - amount - uint256
-
-
-
Outputs
-
- - longInteger - uint256 : (Should be: 8989898989)
-
-
-
-
-
-
-
-
-
-
-
- *Return value: -*
-
-
-
-
-
-
-
Method: "viewNoArgsMultipleReturn"
-
Payable: false - StateMutability: "view"
-
-
Inputs
-
-
-
Outputs
-
- - importantNumber - uint256 (should be zero)
- - hello - bytes32
-
-
-
-
-
-->
-
- All the args are returned in one, and in their respective output
-
- A greeting here in bytes32
-
-
- A greeting here in bytes32
-
-
-
Important Number here
-
-
- *Return value: -*
-
-
- *Return value: -*
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
ERC721 - Single NFT from an Owner
-
With Owner Account address and Token id
-
-
-
-
-
![]()
-
-
-
- $THIS_TokenID
-
-
-
-
-
-
-
-
-
-
ERC721 - List of specific NFTs from an Owner
-
With Owner Account address and Token ids
-
-
-
-
![]()
-
-
-
-
-
-
-
-
-
ERC721 - List of NFTs from an Owner
-
With Owner Account address
-
-
-
-
![]()
-
-
-
-
-
-
-
-
ERC721 - List of NFTs from an Owner with Pagination
-
With Owner Account address
-
-
-
-
-
-
-
![]()
-
-
-
-
-
-
-
-
ERC721 - Single NFT from an Contract
-
With Asset contract address
-
-
-
-
![]()
-
-
-
-
-
-
-
-
ERC721 - List of NFTs from an Contract
-
With Asset contract address
-
-
-
-
![]()
-
-
-
-
-
-
-
-
ERC721 - List of NFTs from an Contract
-
With Asset contract address
-
-
-
-
![]()
-
-
-
-
-
-
-
+
+
-
+
+
+
+
+
+ ,
+
+
+
Method "totalSupply"
+
+
+
+ ,
+
+ ,
+
+ ,
+
+ ,
+
+
+
Method "allowance"
+
+
+
+
+
+
+
+
+
+
+
+ ,
+
+
+
Method "transferFrom"
+
+
+
+
+
+ ,
+
+ ,
+
+ ,
+
+
+
-
-
-
+
+
+
-
diff --git a/src/Activator.tsx b/src/Activator.tsx
index 160f3cf..70397fc 100644
--- a/src/Activator.tsx
+++ b/src/Activator.tsx
@@ -26,6 +26,7 @@ type ActivatorProps = {
timeStamp: any;
contractElements: any;
domElementsFilteredForContracts: any;
+ db: any;
}
export const Activator: React.FC
= ({
@@ -37,6 +38,7 @@ export const Activator: React.FC = ({
supportedNetworks,
contractElements,
domElementsFilteredForContracts,
+ db,
}: ActivatorProps) => {
// Ethereum
@@ -66,6 +68,7 @@ export const Activator: React.FC = ({
retriggerEngine,
projectId: consts.global.apiKey,
provider: ethereum,
+ db,
toggleHighlight(): void {
dappHero.highlightEnabled = !dappHero.highlightEnabled
highlightDomElements(dappHero.highlightEnabled, domElements)
diff --git a/src/ProvidersWrapper.tsx b/src/ProvidersWrapper.tsx
index ca4fbd9..cf7e3aa 100644
--- a/src/ProvidersWrapper.tsx
+++ b/src/ProvidersWrapper.tsx
@@ -9,6 +9,9 @@ import { DomElementsContext, EthereumContext } from 'contexts'
import { EmitterProvider } from 'providers/EmitterProvider/provider'
import { useWeb3Provider } from 'hooks'
import { Activator } from './Activator'
+import { UserBase as UBase } from './components/userBase/UserBase'
+
+import { DB } from './api/database'
export const ProvidersWrapper: React.FC = () => {
// react hooks
@@ -23,6 +26,18 @@ export const ProvidersWrapper: React.FC = () => {
const ethereum = useWeb3Provider(consts.global.POLLING_INTERVAL) // This sets refresh speed of the whole app
+ // load serBase
+ const [ db, setDB ] = useState(null)
+ useEffect(() => {
+
+ const makeDBConnection = async () => {
+ setDB(await new DB({ appId: process.env.REACT_APP_USERBASE_APP_ID, projectId: consts.global.apiKey }))
+ }
+ if (consts.global.apiKey) {
+ makeDBConnection()
+ }
+ }, [])
+
// load contracts effects only if not paused
useEffect(() => {
const getConfig = async () => {
@@ -82,6 +97,7 @@ export const ProvidersWrapper: React.FC = () => {
+ {/* */}
{
supportedNetworks={supportedNetworks}
domElementsFilteredForContracts={smartcontractElements.domElementsFilteredForContracts}
contractElements={smartcontractElements.contractElements}
+ db={db}
/>
diff --git a/src/api/dappHero.ts b/src/api/dappHero.ts
index 08a8fa5..99b62e1 100644
--- a/src/api/dappHero.ts
+++ b/src/api/dappHero.ts
@@ -117,11 +117,11 @@ export const getContractsByProjectKey = async (projectId) => {
return (await getContractsByProjectKeyDappHero(projectId))
} catch (error) {
// If the error fails, then try bubble
- logger.log('(DH-CORE) Error in Global Cache Network, re-trying...', error)
+ logger.error('(DH-CORE) Error in Global Cache Network, re-trying...', error)
try {
return (await getContractsByProjectKeyBubble(projectId) )
} catch (error) {
- logger.log('(DH-CORE) Failure in project cache backend', error)
+ logger.error('(DH-CORE) Failure in project cache backend', error)
}
}
}
diff --git a/src/api/database.ts b/src/api/database.ts
new file mode 100644
index 0000000..de66f4c
--- /dev/null
+++ b/src/api/database.ts
@@ -0,0 +1,43 @@
+import userbase from 'userbase-js'
+
+export class DB {
+ projectId: string
+
+ constructor({ appId, projectId }) {
+ this.projectId = projectId
+ userbase.init({ appId })
+ }
+
+ async signUp(details): Promise {
+ return userbase.signUp(details)
+ }
+
+ async signIn(details): Promise {
+ return userbase.signIn({ ...details })
+ }
+
+ async signOut(): Promise {
+ return userbase.signOut()
+ }
+
+ async forgotPassword(username): Promise {
+ return userbase.forgotPassword(username)
+ }
+
+ async openDatabase(changeFunc): Promise {
+ return userbase.openDatabase({ databaseName: this.projectId, changeHandler: changeFunc })
+ }
+
+ async insertItem(item): Promise {
+ return userbase.insertItem({ databaseName: this.projectId, item })
+ }
+
+ async updateItem(item, itemId): Promise {
+ return userbase.updateItem({ databaseName: this.projectId, item, itemId })
+ }
+
+ async deleteItem(itemId): Promise {
+ return userbase.deleteItem({ databaseName: this.projectId, itemId })
+ }
+
+}
diff --git a/src/components/userBase/UserBase.tsx b/src/components/userBase/UserBase.tsx
new file mode 100644
index 0000000..12574f1
--- /dev/null
+++ b/src/components/userBase/UserBase.tsx
@@ -0,0 +1,62 @@
+import React, { useState, useEffect } from 'react'
+import Modal from 'react-modal'
+
+// Make sure to bind modal to your appElement (http://reactcommunity.org/react-modal/accessibility/)
+// Modal.setAppElement('#yourAppElement')
+
+const customStyles = {
+ content: {
+ top: '50%',
+ left: '50%',
+ right: 'auto',
+ bottom: 'auto',
+ marginRight: '-50%',
+ transform: 'translate(-50%, -50%)',
+ },
+}
+
+export const UserBase = ({ db }) => {
+ let subtitle
+
+ const [ modalIsOpen, setIsOpen ] = useState(false)
+
+ const openModal = () => {
+ setIsOpen(true)
+ }
+
+ const closeModal = () => {
+ setIsOpen(false)
+ }
+
+ useEffect(() => {
+ if (window.dappHero) {
+ // window.dappHero.db = db
+ window.dappHero.openModal = openModal
+ window.dappHero.closeModal = closeModal
+ }
+ }, [ window.dappHero, db ])
+
+ return (
+
+
+
+
+ {/* (subtitle = _subtitle)}>Hello
*/}
+
+ I am a modal
+
+
+
+ )
+}
+
diff --git a/src/consts/global.ts b/src/consts/global.ts
index 07fafcf..31c8cc8 100644
--- a/src/consts/global.ts
+++ b/src/consts/global.ts
@@ -9,6 +9,7 @@ export const ethNetworkName = {
77: 'Sokol',
99: 'Core',
100: 'Xdai',
+ 80001: 'maticMumbaiTestnet',
}
const apiKeyElement = document.getElementById('dh-apiKey')
export const apiKey = apiKeyElement.getAttribute('data-api')
diff --git a/src/consts/provider.ts b/src/consts/provider.ts
index 963cd10..17dc025 100644
--- a/src/consts/provider.ts
+++ b/src/consts/provider.ts
@@ -30,9 +30,13 @@ export const readProviders = {
http: 'https://eth-goerli.alchemyapi.io/v2/mo2KeoBlZY6CAyc2o1i4BcBNioVN_wpJ',
ws: 'wss://eth-goerli.ws.alchemyapi.io/v2/mo2KeoBlZY6CAyc2o1i4BcBNioVN_wpJ',
},
- xDai: {
+ xdai: {
http: 'https://dai.poa.network',
ws: 'wss://dai-trace-ws.blockscout.com/ws',
},
+ maticmumbaitestnet: {
+ http: 'https://rpc-mumbai.matic.today',
+ ws: '',
+ },
}