add debug messages in the UI

This commit is contained in:
Andrea Franz 2020-06-22 13:53:51 +02:00
parent a1cfd3e1fb
commit 3ee7293a84
No known key found for this signature in database
GPG Key ID: 4F0D2F2D9DE7F29D
5 changed files with 84 additions and 5 deletions

View File

@ -33,20 +33,21 @@ module.exports = {
TestToken: {
args: ["TEST", 18],
},
ERC20BucketFactory: {
TestNFT: {
params: [],
},
ERC20Bucket: {
ERC20BucketFactory: {
params: [],
proxyFor: "Bucket",
deploy: false,
},
NFTBucketFactory: {
params: [],
},
ERC20Bucket: {
params: [],
deploy: false,
},
NFTBucket: {
params: [],
proxyFor: "Bucket",
deploy: false,
},
}

12
src/actions/debug.ts Normal file
View File

@ -0,0 +1,12 @@
export const DEBUG_WRITTEN = "DEBUG_WRITTEN";
export interface DebugWrittenAction {
type: typeof DEBUG_WRITTEN
text: string
}
export type DebugActions = DebugWrittenAction;
export const debug = (text: string): DebugWrittenAction => ({
type: DEBUG_WRITTEN,
text,
});

View File

@ -2,10 +2,20 @@ import React from 'react';
import {
useDispatch,
} from 'react-redux';
import {
deployERC20,
deployNFT,
} from '../actions/newContract';
export default function() {
const dispatch = useDispatch();
const deployERC20Handler = () => dispatch(deployERC20());
const deployNFTHandler = () => dispatch(deployNFT());
return <>
<p>
<button onClick={deployERC20Handler}>deploy ERC20!</button>
<button onClick={deployNFTHandler}>deploy NFT!</button>
</p>
</>;
}

29
src/reducers/debug.ts Normal file
View File

@ -0,0 +1,29 @@
import {
DebugActions,
DEBUG_WRITTEN,
} from '../actions/debug';
export interface DebugState {
lines: Array<string>
}
const initialState: DebugState = {
lines: [],
};
export const debugReducer = (state: DebugState = initialState, action: DebugActions): DebugState => {
switch (action.type) {
case DEBUG_WRITTEN: {
return {
...state,
lines: [
...state.lines,
action.text,
]
}
}
default:
return state;
}
}

27
src/styles/Debug.scss Normal file
View File

@ -0,0 +1,27 @@
.debug {
width: 300px;
margin: 0 auto;
font-size: 0.7rem;
overflow-wrap: break-word;
position: relative;
padding-top: 20px;
.btn {
position: absolute;
top: 5px;
right: 5px;
cursor: pointer;
color: rgba(0, 0, 0, 0.1);
}
ul {
border-top-left-radius: 8px;
border-top-right-radius: 8px;
background: #fff;
padding: 12px;
li {
margin-bottom: 8px;
}
}
}