From 8927d6b9e5386b14a707d7f7c5f03471977fcbd1 Mon Sep 17 00:00:00 2001
From: Dennison Bertram
Date: Sun, 14 Jun 2020 20:24:09 -0400
Subject: [PATCH 01/23] =?UTF-8?q?=F0=9F=93=A6=20NEW:=20Add=20user=20base?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
package.json | 2 +
src/ProvidersWrapper.tsx | 20 +++++++++
src/components/userBase/UserBase.tsx | 62 ++++++++++++++++++++++++++++
3 files changed, 84 insertions(+)
create mode 100644 src/components/userBase/UserBase.tsx
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/src/ProvidersWrapper.tsx b/src/ProvidersWrapper.tsx
index ca4fbd9..8fd58ec 100644
--- a/src/ProvidersWrapper.tsx
+++ b/src/ProvidersWrapper.tsx
@@ -8,7 +8,11 @@ import * as consts from 'consts'
import { DomElementsContext, EthereumContext } from 'contexts'
import { EmitterProvider } from 'providers/EmitterProvider/provider'
import { useWeb3Provider } from 'hooks'
+import userbase from 'userbase-js'
import { Activator } from './Activator'
+import { UserBase as UBase } from './components/userBase/UserBase'
+
+console.log('userbase', userbase)
export const ProvidersWrapper: React.FC = () => {
// react hooks
@@ -23,6 +27,21 @@ 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(() => {
+
+ userbase.init({ appId: '133a735a-a754-4e59-9aa9-8bfd1786c4c6' }).then((session) => {
+ // SDK initialized successfully
+ console.log('The session', session)
+ if (session.user) {
+ // there is a valid active session
+ console.log(session.user.username)
+ }
+ }).catch((e) => console.error(e))
+
+ }, [])
+
// load contracts effects only if not paused
useEffect(() => {
const getConfig = async () => {
@@ -82,6 +101,7 @@ export const ProvidersWrapper: React.FC = () => {
+
{
+ 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
+
+
+
+ )
+}
+
From 8cc1012f97cabc0a8fc3cec22289ef065c06cb36 Mon Sep 17 00:00:00 2001
From: Dennison Bertram
Date: Sun, 14 Jun 2020 20:26:54 -0400
Subject: [PATCH 02/23] =?UTF-8?q?=F0=9F=91=8C=20IMPROVE:=20Add=20userBase?=
=?UTF-8?q?=20(db)=20to=20window?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/Activator.tsx | 3 +++
src/ProvidersWrapper.tsx | 1 +
src/components/userBase/UserBase.tsx | 2 +-
3 files changed, 5 insertions(+), 1 deletion(-)
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 8fd58ec..a031edd 100644
--- a/src/ProvidersWrapper.tsx
+++ b/src/ProvidersWrapper.tsx
@@ -111,6 +111,7 @@ export const ProvidersWrapper: React.FC = () => {
supportedNetworks={supportedNetworks}
domElementsFilteredForContracts={smartcontractElements.domElementsFilteredForContracts}
contractElements={smartcontractElements.contractElements}
+ db={userbase}
/>
diff --git a/src/components/userBase/UserBase.tsx b/src/components/userBase/UserBase.tsx
index 035e2e5..12574f1 100644
--- a/src/components/userBase/UserBase.tsx
+++ b/src/components/userBase/UserBase.tsx
@@ -30,7 +30,7 @@ export const UserBase = ({ db }) => {
useEffect(() => {
if (window.dappHero) {
- window.dappHero.db = db
+ // window.dappHero.db = db
window.dappHero.openModal = openModal
window.dappHero.closeModal = closeModal
}
From 74b197d0a44eb8c8fbdbac8fee332ab45372ee1c Mon Sep 17 00:00:00 2001
From: Dennison Bertram
Date: Mon, 15 Jun 2020 10:02:44 -0400
Subject: [PATCH 03/23] =?UTF-8?q?=F0=9F=93=A6=20NEW:=20=20Add=20Matic?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/consts/provider.ts | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/consts/provider.ts b/src/consts/provider.ts
index 963cd10..21f2758 100644
--- a/src/consts/provider.ts
+++ b/src/consts/provider.ts
@@ -34,5 +34,9 @@ export const readProviders = {
http: 'https://dai.poa.network',
ws: 'wss://dai-trace-ws.blockscout.com/ws',
},
+ maticMumbai: {
+ http: `https://rpc-mumbai.matic.today`,
+ ws: '',
+ },
}
From 059cd7cf1fcce8f2f0688791c776d59abccb6a1f Mon Sep 17 00:00:00 2001
From: Dennison Bertram
Date: Mon, 15 Jun 2020 10:31:06 -0400
Subject: [PATCH 04/23] =?UTF-8?q?=F0=9F=91=8C=20IMPROVE:=20Add=20Matic?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/consts/provider.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/consts/provider.ts b/src/consts/provider.ts
index 21f2758..e76c1bb 100644
--- a/src/consts/provider.ts
+++ b/src/consts/provider.ts
@@ -34,7 +34,7 @@ export const readProviders = {
http: 'https://dai.poa.network',
ws: 'wss://dai-trace-ws.blockscout.com/ws',
},
- maticMumbai: {
+ maticMumbaiTestnet: {
http: `https://rpc-mumbai.matic.today`,
ws: '',
},
From 499b6ad13375dc77977953e57b670066126614c6 Mon Sep 17 00:00:00 2001
From: Dennison Bertram
Date: Mon, 15 Jun 2020 11:32:01 -0400
Subject: [PATCH 05/23] =?UTF-8?q?=F0=9F=91=8C=20IMPROVE:=20Fix=20Matic=20a?=
=?UTF-8?q?nd=20UserBase=20Support?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
public/index.html | 1331 ++++++++++++++------------------------
src/ProvidersWrapper.tsx | 7 +-
src/consts/global.ts | 1 +
src/consts/provider.ts | 6 +-
4 files changed, 507 insertions(+), 838 deletions(-)
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 @@
-
-
-
-
-
- DappHero: Components
-
-
-
-
-
-
-
-
-
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/ProvidersWrapper.tsx b/src/ProvidersWrapper.tsx
index a031edd..3ba7802 100644
--- a/src/ProvidersWrapper.tsx
+++ b/src/ProvidersWrapper.tsx
@@ -12,8 +12,6 @@ import userbase from 'userbase-js'
import { Activator } from './Activator'
import { UserBase as UBase } from './components/userBase/UserBase'
-console.log('userbase', userbase)
-
export const ProvidersWrapper: React.FC = () => {
// react hooks
const [ configuration, setConfig ] = useState(null)
@@ -31,12 +29,11 @@ export const ProvidersWrapper: React.FC = () => {
// const [ db, setDB ] = useState(null)
useEffect(() => {
- userbase.init({ appId: '133a735a-a754-4e59-9aa9-8bfd1786c4c6' }).then((session) => {
+ userbase.init({ appId: process.env.REACT_APP_USERBASE_APP_ID }).then((session) => {
// SDK initialized successfully
- console.log('The session', session)
if (session.user) {
// there is a valid active session
- console.log(session.user.username)
+ // console.log(session.user.username)
}
}).catch((e) => console.error(e))
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 e76c1bb..17dc025 100644
--- a/src/consts/provider.ts
+++ b/src/consts/provider.ts
@@ -30,12 +30,12 @@ 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`,
+ maticmumbaitestnet: {
+ http: 'https://rpc-mumbai.matic.today',
ws: '',
},
From 76c98bce2b4a0491cf549e760f281d22720e9cd3 Mon Sep 17 00:00:00 2001
From: Dennison Bertram
Date: Mon, 15 Jun 2020 12:14:33 -0400
Subject: [PATCH 06/23] =?UTF-8?q?=F0=9F=91=8C=20IMPROVE:=20disable=20User?=
=?UTF-8?q?=20base=20for=20the=20moment?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/Activator.tsx | 2 +-
src/ProvidersWrapper.tsx | 7 ++++++-
src/api/dappHero.ts | 4 ++--
3 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/src/Activator.tsx b/src/Activator.tsx
index 70397fc..87e1e80 100644
--- a/src/Activator.tsx
+++ b/src/Activator.tsx
@@ -68,7 +68,7 @@ export const Activator: React.FC = ({
retriggerEngine,
projectId: consts.global.apiKey,
provider: ethereum,
- db,
+ // db,
toggleHighlight(): void {
dappHero.highlightEnabled = !dappHero.highlightEnabled
highlightDomElements(dappHero.highlightEnabled, domElements)
diff --git a/src/ProvidersWrapper.tsx b/src/ProvidersWrapper.tsx
index 3ba7802..95f99d7 100644
--- a/src/ProvidersWrapper.tsx
+++ b/src/ProvidersWrapper.tsx
@@ -26,10 +26,15 @@ 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)
+ const [ db, setDB ] = useState(null)
useEffect(() => {
userbase.init({ appId: process.env.REACT_APP_USERBASE_APP_ID }).then((session) => {
+ userbase.deleteUser = null
+ userbase.purchaseSubscription = null
+ userbase.cancelSubscription = null
+ userbase.resumeSubscription = null
+ userbase.updatePaymentMethod = null
// SDK initialized successfully
if (session.user) {
// there is a valid active session
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)
}
}
}
From 03aef87a039c36feabb217d4e6de6e9974bc0ccf Mon Sep 17 00:00:00 2001
From: Dennison Bertram
Date: Mon, 15 Jun 2020 15:47:46 -0400
Subject: [PATCH 07/23] =?UTF-8?q?=F0=9F=93=A6=20NEW:=20=20working=20userba?=
=?UTF-8?q?se!?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/Activator.tsx | 2 +-
src/ProvidersWrapper.tsx | 29 ++++++++++++-------------
src/api/database.ts | 46 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 61 insertions(+), 16 deletions(-)
create mode 100644 src/api/database.ts
diff --git a/src/Activator.tsx b/src/Activator.tsx
index 87e1e80..70397fc 100644
--- a/src/Activator.tsx
+++ b/src/Activator.tsx
@@ -68,7 +68,7 @@ export const Activator: React.FC = ({
retriggerEngine,
projectId: consts.global.apiKey,
provider: ethereum,
- // db,
+ db,
toggleHighlight(): void {
dappHero.highlightEnabled = !dappHero.highlightEnabled
highlightDomElements(dappHero.highlightEnabled, domElements)
diff --git a/src/ProvidersWrapper.tsx b/src/ProvidersWrapper.tsx
index 95f99d7..47328ba 100644
--- a/src/ProvidersWrapper.tsx
+++ b/src/ProvidersWrapper.tsx
@@ -8,10 +8,11 @@ import * as consts from 'consts'
import { DomElementsContext, EthereumContext } from 'contexts'
import { EmitterProvider } from 'providers/EmitterProvider/provider'
import { useWeb3Provider } from 'hooks'
-import userbase from 'userbase-js'
import { Activator } from './Activator'
import { UserBase as UBase } from './components/userBase/UserBase'
+import { DB } from './api/database'
+
export const ProvidersWrapper: React.FC = () => {
// react hooks
const [ configuration, setConfig ] = useState(null)
@@ -27,21 +28,19 @@ export const ProvidersWrapper: React.FC = () => {
// load serBase
const [ db, setDB ] = useState(null)
+ console.log('ProvidersWrapper:React.FC -> db', db)
useEffect(() => {
- userbase.init({ appId: process.env.REACT_APP_USERBASE_APP_ID }).then((session) => {
- userbase.deleteUser = null
- userbase.purchaseSubscription = null
- userbase.cancelSubscription = null
- userbase.resumeSubscription = null
- userbase.updatePaymentMethod = null
- // SDK initialized successfully
- if (session.user) {
- // there is a valid active session
- // console.log(session.user.username)
- }
- }).catch((e) => console.error(e))
+ const makeDBConnection = async () => {
+ const db = await new DB({ appId: process.env.REACT_APP_USERBASE_APP_ID, projectId: consts.global.apiKey })
+ setDB(db)
+ // db.init().then((session) => {
+ // setDB(db)
+ // console.log('The session: ', session)
+ // }).catch((e) => console.error(e))
+ }
+ makeDBConnection()
}, [])
// load contracts effects only if not paused
@@ -103,7 +102,7 @@ export const ProvidersWrapper: React.FC = () => {
-
+
{
supportedNetworks={supportedNetworks}
domElementsFilteredForContracts={smartcontractElements.domElementsFilteredForContracts}
contractElements={smartcontractElements.contractElements}
- db={userbase}
+ db={db}
/>
diff --git a/src/api/database.ts b/src/api/database.ts
new file mode 100644
index 0000000..471219c
--- /dev/null
+++ b/src/api/database.ts
@@ -0,0 +1,46 @@
+import userbase from 'userbase-js'
+
+export class DB {
+ constructor({ appId, projectId }) {
+ this.projectId = projectId
+ userbase.init({ appId })
+ }
+
+ // async init(): Promise {
+ // return this.userbase.init({ appId: this.appId })
+ // }
+
+ async signUp(details): Promise {
+ return userbase.signUp(details)
+ }
+
+ async signIn(details): Promise {
+ console.log('details', details)
+ 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 })
+ }
+
+}
From 274170abfe3e5160fdd8857ba6ccb328b18cba86 Mon Sep 17 00:00:00 2001
From: Dennison Bertram
Date: Mon, 15 Jun 2020 15:55:02 -0400
Subject: [PATCH 08/23] =?UTF-8?q?=F0=9F=90=9B=20FIX:=20=20Add=20types=20to?=
=?UTF-8?q?=20DB=20class?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/ProvidersWrapper.tsx | 10 +++-------
src/api/database.ts | 7 ++-----
2 files changed, 5 insertions(+), 12 deletions(-)
diff --git a/src/ProvidersWrapper.tsx b/src/ProvidersWrapper.tsx
index 47328ba..f72530a 100644
--- a/src/ProvidersWrapper.tsx
+++ b/src/ProvidersWrapper.tsx
@@ -28,19 +28,15 @@ export const ProvidersWrapper: React.FC = () => {
// load serBase
const [ db, setDB ] = useState(null)
- console.log('ProvidersWrapper:React.FC -> db', db)
useEffect(() => {
const makeDBConnection = async () => {
const db = await new DB({ appId: process.env.REACT_APP_USERBASE_APP_ID, projectId: consts.global.apiKey })
setDB(db)
- // db.init().then((session) => {
- // setDB(db)
- // console.log('The session: ', session)
- // }).catch((e) => console.error(e))
}
-
- makeDBConnection()
+ if (consts.global.apiKey) {
+ makeDBConnection()
+ }
}, [])
// load contracts effects only if not paused
diff --git a/src/api/database.ts b/src/api/database.ts
index 471219c..de66f4c 100644
--- a/src/api/database.ts
+++ b/src/api/database.ts
@@ -1,21 +1,18 @@
import userbase from 'userbase-js'
export class DB {
+ projectId: string
+
constructor({ appId, projectId }) {
this.projectId = projectId
userbase.init({ appId })
}
- // async init(): Promise {
- // return this.userbase.init({ appId: this.appId })
- // }
-
async signUp(details): Promise {
return userbase.signUp(details)
}
async signIn(details): Promise {
- console.log('details', details)
return userbase.signIn({ ...details })
}
From dbbb922874cfb79a1655ac92b2e7b5de164a86ea Mon Sep 17 00:00:00 2001
From: Dennison Bertram
Date: Mon, 15 Jun 2020 15:56:18 -0400
Subject: [PATCH 09/23] =?UTF-8?q?=F0=9F=91=8C=20IMPROVE:=20=20truncating?=
=?UTF-8?q?=20code?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/ProvidersWrapper.tsx | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/ProvidersWrapper.tsx b/src/ProvidersWrapper.tsx
index f72530a..a3518d0 100644
--- a/src/ProvidersWrapper.tsx
+++ b/src/ProvidersWrapper.tsx
@@ -31,8 +31,7 @@ export const ProvidersWrapper: React.FC = () => {
useEffect(() => {
const makeDBConnection = async () => {
- const db = await new DB({ appId: process.env.REACT_APP_USERBASE_APP_ID, projectId: consts.global.apiKey })
- setDB(db)
+ setDB(await new DB({ appId: process.env.REACT_APP_USERBASE_APP_ID, projectId: consts.global.apiKey }))
}
if (consts.global.apiKey) {
makeDBConnection()
From c27c04cb40200776d8c116fe1f034db99d273c10 Mon Sep 17 00:00:00 2001
From: Dennison Bertram
Date: Tue, 16 Jun 2020 14:48:06 -0400
Subject: [PATCH 10/23] =?UTF-8?q?=F0=9F=90=9B=20FIX:=20remove=20modal?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/ProvidersWrapper.tsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/ProvidersWrapper.tsx b/src/ProvidersWrapper.tsx
index a3518d0..cf7e3aa 100644
--- a/src/ProvidersWrapper.tsx
+++ b/src/ProvidersWrapper.tsx
@@ -97,7 +97,7 @@ export const ProvidersWrapper: React.FC = () => {
-
+ {/* */}
Date: Tue, 16 Jun 2020 15:02:39 -0400
Subject: [PATCH 11/23] =?UTF-8?q?=F0=9F=90=9B=20FIX:=20=20warnings?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/api/dappHero.ts | 18 +++++++++---------
src/components/userBase/UserBase.tsx | 14 +++++++-------
src/protocol/ethereum/nft/useRenderNfts.tsx | 4 ++--
3 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/src/api/dappHero.ts b/src/api/dappHero.ts
index 99b62e1..666b8c2 100644
--- a/src/api/dappHero.ts
+++ b/src/api/dappHero.ts
@@ -65,15 +65,15 @@ export const getContractsByProjectKeyDappHero = async (projectId) => {
}
}
-const compareResponses = async (originalOutput, projectId) => {
- const compareOutput = await getContractsByProjectKeyV2(projectId)
- const isEqual = !!(JSON.stringify(originalOutput) === JSON.stringify(compareOutput))
- // logger.info(`Cache Check isEqual: ${isEqual.toString()}`)
- if (!isEqual) {
- logger.info('', compareOutput)
- logger.info('', originalOutput)
- }
-}
+// const compareResponses = async (originalOutput, projectId) => {
+// const compareOutput = await getContractsByProjectKeyV2(projectId)
+// const isEqual = !!(JSON.stringify(originalOutput) === JSON.stringify(compareOutput))
+// // logger.info(`Cache Check isEqual: ${isEqual.toString()}`)
+// if (!isEqual) {
+// logger.info('', compareOutput)
+// logger.info('', originalOutput)
+// }
+// }
export const getContractsByProjectKeyBubble = async (projectId) => {
logger.log(`projectId: ${projectId}`)
diff --git a/src/components/userBase/UserBase.tsx b/src/components/userBase/UserBase.tsx
index 12574f1..c2cac4d 100644
--- a/src/components/userBase/UserBase.tsx
+++ b/src/components/userBase/UserBase.tsx
@@ -28,13 +28,13 @@ export const UserBase = ({ db }) => {
setIsOpen(false)
}
- useEffect(() => {
- if (window.dappHero) {
- // window.dappHero.db = db
- window.dappHero.openModal = openModal
- window.dappHero.closeModal = closeModal
- }
- }, [ window.dappHero, db ])
+ // useEffect(() => {
+ // if (window.dappHero) {
+ // // window.dappHero.db = db
+ // window.dappHero.openModal = openModal
+ // window.dappHero.closeModal = closeModal
+ // }
+ // }, [ window.dappHero, db ])
return (
diff --git a/src/protocol/ethereum/nft/useRenderNfts.tsx b/src/protocol/ethereum/nft/useRenderNfts.tsx
index 9018279..7400293 100644
--- a/src/protocol/ethereum/nft/useRenderNfts.tsx
+++ b/src/protocol/ethereum/nft/useRenderNfts.tsx
@@ -125,7 +125,7 @@ export const useRenderNfts = ({ nfts, item, element, getAssetElements }) => {
'data-dh-property-method-id', 'data-dh-property-asset-contract-address' ]
// Replace the Inner text for any element type.
- Array.from(item.root.children).forEach((element) => {
+ Array.from(item.root.children).forEach((element: HTMLElement) => {
displayKeyValueElementInnerText(clonedItem, '$THIS_TokenID', nft?.token_id, element.nodeName)
displayKeyValueElementInnerText(clonedItem, '$THIS_ContractAddress', nft?.asset_contract.address, element.nodeName)
displayKeyValueElementInnerText(clonedItem, '$THIS_OwnerAddress', nft?.owner.address, element.nodeName)
@@ -134,7 +134,7 @@ export const useRenderNfts = ({ nfts, item, element, getAssetElements }) => {
// TODO: Add recursion to get inner children elements
// Substitute the $THIS value on any attribute from array above, for any child element.
- Array.from(item.root.children).forEach((element) => {
+ Array.from(item.root.children).forEach((element: HTMLElement) => {
attributes.forEach((attribute) => {
displayValueOnElementAttribute(clonedItem, '$THIS_TokenID', nft?.token_id, attribute)
displayValueOnElementAttribute(clonedItem, '$THIS_ContractAddress', nft?.asset_contract.address, attribute)
From eed2ee6324e8ffdf3130d1190530802c480e47c2 Mon Sep 17 00:00:00 2001
From: Dennison Bertram
Date: Tue, 16 Jun 2020 16:11:53 -0400
Subject: [PATCH 12/23] =?UTF-8?q?=F0=9F=93=A6=20NEW:=20=20HTML=20for=20add?=
=?UTF-8?q?ing=20a=20contract=20dynamically?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
public/index.html | 751 ++++++++++++++++++++-------------------
src/ProvidersWrapper.tsx | 1 +
src/api/dappHero.ts | 1 +
3 files changed, 397 insertions(+), 356 deletions(-)
diff --git a/public/index.html b/public/index.html
index ef895ce..c528e15 100644
--- a/public/index.html
+++ b/public/index.html
@@ -31,7 +31,7 @@
- amusing-miss-97
+ Perfect-edmund-58
Powered by DappHero.io
@@ -48,206 +48,56 @@ amusing-miss-97
+
-
+
- ,
-
-
-
Method "totalSupply"
-
-
-
- ,
-
- ,
-
-
-
Method "balanceOf"
+
Method "createdContracts"
-
-
- ,
-
- ,
-
-
-
Method "allowance"
-
-
@@ -261,214 +111,47 @@
Method "allowance"
-
Method "approve"
+
Method "createToken"
-
-
- ,
-
-
-
Method "transferFrom"
-
-
-
-
-
- ,
-
- ,
-
- ,
-
-
@@ -57,7 +56,7 @@ Perfect-edmund-58
Method
"createdContracts"
Output...
@@ -95,7 +94,7 @@
Method "createdContracts"
@@ -111,7 +110,7 @@
Method "createdContracts"
Method "createToken"
@@ -133,7 +132,7 @@
Method "createToken"
@@ -142,14 +141,14 @@ Method "createToken"
@@ -160,6 +159,932 @@ Method "createToken"
+
+
+
+
+
+
+
+
Method "allowance"
+
+
+
+
+
+ ,
+
+ ,
+
+ ,
+
+ ,
+
+ ,
+
+
+
Method "totalSupply"
+
+
+
+
+
+
+
+
+
+ ,
+
+
+
Method "decreaseAllowance"
+
+
+
+
+
+ ,
+
+
+
Method "increaseAllowance"
+
+
+
+
+
+ ,
+
+ ,
+
+
+
Method "transferFrom"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ,
+
+
+
Method "viewMultipleArgsMultipleReturn"
+
+
+
+
+
+ ,
+
+
+
Method "viewMultipleArgsSingleReturn"
+
+
+
+
+
+ ,
+
+
+
Method "viewNoArgsMultipleReturn"
+
+
+
+
+
+ ,
+
+ ,
+
+
+
+
+
+
+
+
+
Method "sendMinimumTwoEthNoArgs"
+
+
+
+
+
+ ,
+
+
+
Method "makeTxNoArgs"
+
+
+
+ ,
+
+
+
Method "sendEthWithArgs"
+
+
+
+
+
+ ,
+
+
+
Method "makeTxWithArgs"
+
+
+
+
+
+ ,
+
+
+
Method "sendEthNoArgs"
+
+
+
+
+
+ ,
+
+
+
Method "sendMinimumTwoEthWithArgs"
+
+
+
+
+
+ ,
+
+
+
Method "triggerEvent"
+
+
+
+
+
+
diff --git a/src/ProvidersWrapper.tsx b/src/ProvidersWrapper.tsx
index 8457cec..cf7e3aa 100644
--- a/src/ProvidersWrapper.tsx
+++ b/src/ProvidersWrapper.tsx
@@ -16,7 +16,6 @@ import { DB } from './api/database'
export const ProvidersWrapper: React.FC = () => {
// react hooks
const [ configuration, setConfig ] = useState(null)
- console.log('ProvidersWrapper:React.FC -> configuration', configuration)
const [ domElements, setDomElements ] = useState(null)
const [ timestamp, setTimestamp ] = useState(+new Date())
const [ supportedNetworks, setSupportedNetworks ] = useState([])
diff --git a/src/protocol/ethereum/customContract/Manager.tsx b/src/protocol/ethereum/customContract/Manager.tsx
index b3a044f..c480754 100644
--- a/src/protocol/ethereum/customContract/Manager.tsx
+++ b/src/protocol/ethereum/customContract/Manager.tsx
@@ -22,19 +22,24 @@ export const Manager: React.FunctionComponent = ({ customContractE
// TODO: [DEV-318] Create a function to add a new contract name and add a new configuration
- for (const contractName of uniqueContractNames) {
-
- const newDomElements = getDomElements(configuration)
- const contractElements = newDomElements.filter((element) => element.feature === 'customContract')
- const methodsByContractAsElements = contractElements.filter((element) => element.contract.contractName === contractName)
- const contract = configuration.contracts.filter((thisContract) => (thisContract.contractName === contractName))[0]
-
- return (
-
- )
- }
+ // for (const contractName of uniqueContractNames)
+ return (
+ <>
+ {Array.from(uniqueContractNames).map((contractName) => {
+ const newDomElements = getDomElements(configuration)
+ const contractElements = newDomElements.filter((element) => element.feature === 'customContract')
+ const methodsByContractAsElements = contractElements.filter((element) => element.contract.contractName === contractName)
+ const contract = configuration.contracts.filter((thisContract) => (thisContract.contractName === contractName))[0]
+
+ return (
+
+ )
+ })}
+ >
+ )
}
diff --git a/src/protocol/ethereum/customContract/Router.tsx b/src/protocol/ethereum/customContract/Router.tsx
index ed83c7c..4347771 100644
--- a/src/protocol/ethereum/customContract/Router.tsx
+++ b/src/protocol/ethereum/customContract/Router.tsx
@@ -25,7 +25,6 @@ type RouterProps = {
}
export const Router: React.FunctionComponent = ({ listOfContractMethods, contract, timestamp }) => {
-
const ethereum = useContext(contexts.EthereumContext)
const { signer, isEnabled: writeEnabled, chainId: writeChainId, provider } = ethereum
const { contractAddress, contractAbi, networkId } = contract
@@ -47,10 +46,8 @@ export const Router: React.FunctionComponent = ({ listOfContractMet
let readContractInstance = null
// Make the contract instance from either the local provider or remote provider
if (provider && contractNetwork === provider?._network?.name) {
- console.log('Using local provider for contract reads.')
readContractInstance = new ethers.Contract(contractAddress, contractAbi, provider)
} else {
- console.log('Using DH-backend provider for contract reads.')
readContractInstance = new ethers.Contract(contractAddress, contractAbi, stableReadProvider)
}
readContractInstance.on('*', (data) => emitToEvent(
From 7966763b19ec7094ffe7f930d24fe75b50a19425 Mon Sep 17 00:00:00 2001
From: Dennison Bertram
Date: Tue, 16 Jun 2020 17:33:40 -0400
Subject: [PATCH 14/23] =?UTF-8?q?=F0=9F=90=9B=20FIX:=20=20Fix=20multiple?=
=?UTF-8?q?=20Contracts?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
public/index-stanard.html | 2 +-
public/index.html | 1935 ++++++++++++++++---------------------
2 files changed, 829 insertions(+), 1108 deletions(-)
diff --git a/public/index-stanard.html b/public/index-stanard.html
index 8cadef0..4a1da82 100644
--- a/public/index-stanard.html
+++ b/public/index-stanard.html
@@ -838,7 +838,7 @@
src=""
type="text/javascript"
id="dh-apiKey"
- data-api="1581368358384x830713010847744000"
+ data-api="1592342853928x247583279535882240"
>
-
-
diff --git a/public/index.html b/public/index.html
index 8af975c..4a1da82 100644
--- a/public/index.html
+++ b/public/index.html
@@ -1,1124 +1,845 @@
-
-
+
+
+