Skip to content

Commit

Permalink
chore: repair stubbed environment
Browse files Browse the repository at this point in the history
  • Loading branch information
topocount committed May 30, 2020
1 parent 439cdc5 commit 8cc8d9f
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 11 deletions.
14 changes: 7 additions & 7 deletions app/api-react.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ const initialState = process.env.NODE_ENV !== 'production' && {
isSyncing: false,
votes: [
{
app: '0xbaB65A7D8a8F67D38cD26af113b95279fA3E7616',
appAddress: '0xbaB65A7D8a8F67D38cD26af113b95279fA3E7616',
description: 'Mint 1 ETH for 0xE7F5Fd82F861343Fbe794E4796dC3Ff8999B0Ee4',
id: '0',
nay: '0',
status: VOTING_STATUS_PENDING_ENACTMENT,
yea: '1000000000000000000',
},
{
app: '0x978f4De6B4833e956a366A441B277deB7A7C0d4c',
appAddress: '0x978f4De6B4833e956a366A441B277deB7A7C0d4c',
description: 'Mint 19 ETH for 0xE7F5Fd82F861343Fbe794E4796dC3Ff8999B0Ee4',
id: '1',
nay: '1000000000000000000',
Expand All @@ -30,33 +30,33 @@ const initialState = process.env.NODE_ENV !== 'production' && {
widgets: [
{
data: '# Title for Markdown test 🐈',
id: 0,
id: '0',
layout: { primary: true },
type: TYPE_MARKDOWN,
},
{
data: {
},
id: 1,
id: '1',
layout: { primary: false },
type: TYPE_VOTES,
},
{
data: '# hello, `WORLD`! 🌐👽',
id: 2,
id: '2',
layout: { primary: true },
type: TYPE_MARKDOWN,
},
{
data: {
},
id: 3,
id: '3',
layout: { primary: true },
type: TYPE_VOTES,
},
{
data: 'Unicorns exist 🦄',
id: 4,
id: '4',
layout: { primary: true },
type: TYPE_MARKDOWN,
},
Expand Down
2 changes: 1 addition & 1 deletion app/components/LocalIdentityBadge/LocalLabelAppBadge.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import { useInstalledApps, useNetwork } from '@aragon/api-react'
import { useInstalledApps, useNetwork } from '../../api-react'
import { AppBadge } from '@aragon/ui'
import PropTypes from 'prop-types'
import { useIdentity } from '../../utils/identity-manager'
Expand Down
1 change: 0 additions & 1 deletion app/components/Widget/Votes/Votes.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ const Votes = () => {
const installedApps = useInstalledApps()
const kernel = installedApps.find(app => app.name === 'Kernel').appAddress
const voting = installedApps.find(app => app.name === 'Voting').appAddress
console.log('Network: ', network)
const voteUrl = network.type === 'private'
? `http://localhost:3000/#/${kernel}/${voting}/vote`
: `https://${network.type}.aragon.org/#/${kernel}/${voting}/vote`
Expand Down
11 changes: 9 additions & 2 deletions app/utils/api-react/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import {
AragonApi,
useAppState,
useGuiStyle,
useInstalledApps,
usePath,
useAragonApi as useProductionApi,
useAppState as useProductionAppState,
useInstalledApps as useProductionInstalledApps,
useNetwork as useProductionNetwork,
} from '@aragon/api-react'

export default ({ initialState = {}, functions = (() => {}) }) => {
let useAppState = useProductionAppState
let useAragonApi = useProductionApi
let useInstalledApps = useProductionInstalledApps
let useNetwork = useProductionNetwork

if (process.env.NODE_ENV !== 'production') {
Expand All @@ -23,6 +25,11 @@ export default ({ initialState = {}, functions = (() => {}) }) => {

if (!inIframe()) {
useAragonApi = require('./useStubbedApi')({ functions, initialState })
useAppState = () => {
const { appState } = useAragonApi()
return appState
}
useInstalledApps = require('./useStubbedInstalledApps')
useNetwork = require('./useStubbedNetwork')
}
}
Expand Down
6 changes: 6 additions & 0 deletions app/utils/api-react/useStubbedInstalledApps.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// eslint-disable-next-line import/no-unused-modules
module.exports = () => ([
{ appAddress: '0x123', icon: function() {return null}, name: 'Kernel' },
{ appAddress: '0xbaB65A7D8a8F67D38cD26af113b95279fA3E7616', icon: function() {return null}, name: 'Voting' },
{ appAddress: '0x978f4De6B4833e956a366A441B277deB7A7C0d4c', icon: function() {return null}, name: 'Voting' },
])

0 comments on commit 8cc8d9f

Please sign in to comment.