Skip to content

Commit

Permalink
fix: fix hex to bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
Keith-CY committed Aug 28, 2018
1 parent 360bfe2 commit 2c0fb1b
Show file tree
Hide file tree
Showing 20 changed files with 203 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/nervos-chain/lib/bundle.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/nervos-chain/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
const web3_1 = __importDefault(require("web3"));
const systems_1 = __importDefault(require("./systems"));
const appchain_1 = __importDefault(require("./appchain"));
const hexToBytes_1 = __importDefault(require("./utils/hexToBytes"));
const patchHexToBytes_1 = __importDefault(require("./utils/patchHexToBytes"));
const NervosWeb3 = (provider, CustomWeb3 = web3_1.default) => {
const web3 = new CustomWeb3(provider);
hexToBytes_1.default(web3);
patchHexToBytes_1.default(web3);
const appchainWeb3 = appchain_1.default(web3);
const systemWeb3 = systems_1.default(appchainWeb3);
const target = systemWeb3;
Expand Down
14 changes: 14 additions & 0 deletions packages/nervos-chain/lib/utils/patchHexToBytes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = (web3) => {
web3.utils.hexToBytes = new Proxy(web3.utils.hexToBytes, {
apply: (target, _thisArg, argumentsList) => {
let hex = ('' + argumentsList[0] || '').replace(/^0x/, '');
console.log(hex);
if (hex.length % 2) {
hex = '0' + hex;
}
return target('0x' + hex);
}
});
};
4 changes: 2 additions & 2 deletions packages/nervos-chain/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Web3 from 'web3'
import { Provider } from 'web3/types'
import systems from './systems'
import appchain from './appchain'
import AddHexToBytes from './utils/hexToBytes'
import patchHexToBytes from './utils/patchHexToBytes'

type CustomWeb3 = typeof Web3

Expand All @@ -12,7 +12,7 @@ const NervosWeb3 = (
) => {
const web3 = new CustomWeb3(provider)
// patch hex to bytes bug of [email protected]
AddHexToBytes(web3)
patchHexToBytes(web3)

const appchainWeb3 = appchain(web3)
const systemWeb3 = systems(appchainWeb3)
Expand Down
5 changes: 0 additions & 5 deletions packages/nervos-chain/src/utils/hexToBytes.ts

This file was deleted.

13 changes: 13 additions & 0 deletions packages/nervos-chain/src/utils/patchHexToBytes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export default (web3: any) => {
// web3.utils.hexToBytes = hex2bytes
web3.utils.hexToBytes = new Proxy(web3.utils.hexToBytes, {
apply: (target: Function, _thisArg: any, argumentsList: string[]) => {
let hex = ('' + argumentsList[0] || '').replace(/^0x/, '')
console.log(hex)
if (hex.length % 2) {
hex = '0' + hex
}
return target('0x' + hex)
}
})
}
1 change: 1 addition & 0 deletions packages/neuron-web/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
REACT_APP_MICROSCOPE=https://microscope.cryptape.com/
7 changes: 7 additions & 0 deletions packages/neuron-web/build/asset-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"main.css": "static/css/main.29266132.css",
"main.css.map": "static/css/main.29266132.css.map",
"main.js": "static/js/main.c4d448fb.js",
"main.js.map": "static/js/main.c4d448fb.js.map",
"static/media/logo.svg": "static/media/logo.5d5d9eef.svg"
}
Binary file added packages/neuron-web/build/favicon.ico
Binary file not shown.
22 changes: 22 additions & 0 deletions packages/neuron-web/build/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"short_name": "NeuronWeb",
"name": "Neuron Web",
"start_url": "./index.html",
"display": "standalone",
"theme_color": "#000",
"background_color": "#fff",
"browser_action": {
"default_popup": "./index.html",
"default_title": "NervosWeb"
},
"manifest_version": 2,
"version": "1.0",
"permissions": [
"tabs",
"activeTab",
"clipboardWrite",
"http://**/*",
"https://**/*"
],
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'"
}
1 change: 1 addition & 0 deletions packages/neuron-web/build/service-worker.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/neuron-web/build/static/css/main.29266132.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/neuron-web/build/static/css/main.29266132.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/neuron-web/build/static/js/main.c4d448fb.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions packages/neuron-web/build/static/js/main.c4d448fb.js.map

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions packages/neuron-web/build/static/media/logo.5d5d9eef.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions packages/neuron-web/src/common.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.title-1 {
color: #6c7184;
font-size: 18px;
font-family: PingFangSC;
font-weight: 300;
}

.subtitle-1 {
font-size: 18px;
font-family: PingFangSC;
color: #2e313e;
}

.button-1 {
padding: 8px 13px;
font-size: 14px;
border-radius: 2px;
color: #FFF;
}

.primary {
background: #456cff;
}
41 changes: 41 additions & 0 deletions packages/neuron-web/src/containers/Transactions/transactions.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
:root {
--bg-color: #f8f8fa;
--bg-border-color: #e9ebf0;
--text-color: #6c7184;
--a-color: #456cff;
}

.transactions__container {
text-align: center;
}

.transaction__list--board {
background: var(--bg-color, #f8f8fa);
border: 1px solid var(--bg-border-color, #e9ebf0);
border-radius: 2px;
margin: 0 15px;
padding: 15px;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
font-weight: 100;
}

.transactions__list--item {
display: flex;
font-size: 14px;
color: var(--text-color);
}

.transactions__list--item a {
color: var(--a-color);
font-family: Cousine, monospace;
}

.transactions__list--time {
flex-basis: 200px;
}

.transactions__list--hash {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
33 changes: 33 additions & 0 deletions packages/neuron-web/src/hoc/brand.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
.logo {
/* margin: 0 auto; */
position: relative;
top: 0;
right: 50vw;
transform: translateX(-50%);
width: 90px;
filter: drop-shadow(100vw 0 blue);
margin: 24px 0;
animation: neon 10s linear 0s infinite;
/* transition: all linear; */
}

@keyframes neon {
0% {
filter: drop-shadow(100vw 0 blue), blur(10px);
}
20% {
filter: drop-shadow(100vw 0 green);
}
40% {
filter: drop-shadow(100vw 0 yellow);
}
60% {
filter: drop-shadow(100vw 0 orange);
}
80% {
filter: drop-shadow(100vw 0 red);
}
100% {
filter: drop-shadow(100vw 0 blue);
}
}
30 changes: 30 additions & 0 deletions packages/neuron-web/src/hoc/withBrandAndErrorHandler.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import * as React from 'react'
import './brand.css'

export interface IBrandAndErrorHandler {
handleError: (errorMsg: string) => void
}

const withBrandAndErrorHandler = (Comp: typeof React.Component) =>
class extends React.Component {
public readonly state = {
errorMsg: '',
}

public handleError = (errorMsg: string) => {
this.setState({
errorMsg,
})
}
public render() {
return (
<div>
<img className="logo" src="https://cdn.cryptape.com/images/neuron-logo.png" alt="logo" />
<span>{this.state.errorMsg}</span>
<Comp {...this.props} handleError={this.handleError} />
</div>
)
}
}

export default withBrandAndErrorHandler

0 comments on commit 2c0fb1b

Please sign in to comment.