From f7adbd0afc99291c78efb8440571627dfa8e2e89 Mon Sep 17 00:00:00 2001
From: Samm Desmond
Date: Fri, 5 Apr 2019 00:20:40 -0700
Subject: [PATCH 1/4] Add Nodesmith option
---
src/Benchmark.js | 17 +++++++++++++++--
src/ERC721.js | 11 +++++++++--
src/Query.js | 5 +++--
3 files changed, 27 insertions(+), 6 deletions(-)
diff --git a/src/Benchmark.js b/src/Benchmark.js
index 3047af9..92b3383 100644
--- a/src/Benchmark.js
+++ b/src/Benchmark.js
@@ -11,7 +11,8 @@ export default class Benchmark extends Component {
super(props);
this.state = {
contract: "0x6EbeAf8e8E946F0716E6533A6f2cefc83f60e8Ab",
- owner: "0x4eb5c09f266a6681f3a7729cd4587cbb1ae3d41e"
+ owner: "0x4eb5c09f266a6681f3a7729cd4587cbb1ae3d41e",
+ useNodesmith: true
};
}
async handleSubmit(event) {
@@ -34,8 +35,14 @@ export default class Benchmark extends Component {
});
}
+ toggleNodesmith = () => {
+ this.setState({
+ useNodesmith: !this.state.useNodesmith
+ })
+ }
+
render() {
- const { balance, name, fetching, contract, owner } = this.state || {};
+ const { balance, name, fetching, contract, owner, useNodesmith } = this.state || {};
return (
diff --git a/src/ERC721.js b/src/ERC721.js
index 5321344..c337e70 100644
--- a/src/ERC721.js
+++ b/src/ERC721.js
@@ -1,12 +1,19 @@
import { sha3, padLeft } from "web3-utils";
+import Web3 from 'web3';
import { hasMethod } from "./utils";
import config from "./config";
import NFT from "./static/abis/NFT.json";
export default class ERC721 {
- constructor(address) {
- this.web3 = config.web3;
+ constructor(address, useNodesmith) {
+ this.useNodesmith = useNodesmith;
+
+ // If useNodesmith is true, create a new Web3 provider (will need to get your own API key for your site)
+ this.web3 = useNodesmith ?
+ new Web3(new Web3.providers.HttpProvider('https://ethereum.api.nodesmith.io/v1/mainnet/jsonrpc?apiKey=69bbfd65cae84e6bae3c62c2bde588c6')) :
+ config.web3;
+
this.address = address;
this.contract = new this.web3.eth.Contract(NFT, address);
}
diff --git a/src/Query.js b/src/Query.js
index 357eca5..103e149 100644
--- a/src/Query.js
+++ b/src/Query.js
@@ -34,9 +34,10 @@ export default class Query extends Component {
}
async fetchTokens() {
- const { strategy, contract, owner, disabled } = this.props;
+ const { strategy, contract, owner, disabled, useNodesmith } = this.props;
- const erc721 = new ERC721(contract);
+ console.log(`Fetching Using nodesmith = ${useNodesmith}`);
+ const erc721 = new ERC721(contract, useNodesmith);
this.setState({
fetching: true,
From 64e085f971bb906d15266f6a970f508c68f7dbfb Mon Sep 17 00:00:00 2001
From: Samm Desmond
Date: Fri, 5 Apr 2019 00:35:49 -0700
Subject: [PATCH 2/4] restyle a bit
---
src/Benchmark.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/Benchmark.js b/src/Benchmark.js
index 92b3383..f035d78 100644
--- a/src/Benchmark.js
+++ b/src/Benchmark.js
@@ -122,9 +122,9 @@ export default class Benchmark extends Component {
invalidate those results please tell me.
- Use Nodesmith?
+ 🔥🔥 Use Nodesmith? 🔥🔥
-
+
Check the{" "}
From 73ebec903920522270638ed84cfe97d9c1524c4e Mon Sep 17 00:00:00 2001
From: Samm Desmond
Date: Fri, 5 Apr 2019 00:39:43 -0700
Subject: [PATCH 3/4] Set theme jekyll-theme-minimal
---
_config.yml | 1 +
1 file changed, 1 insertion(+)
create mode 100644 _config.yml
diff --git a/_config.yml b/_config.yml
new file mode 100644
index 0000000..2f7efbe
--- /dev/null
+++ b/_config.yml
@@ -0,0 +1 @@
+theme: jekyll-theme-minimal
\ No newline at end of file
From 2d36086952145d3d14038e7100e78c8920f747b4 Mon Sep 17 00:00:00 2001
From: Samm Desmond
Date: Fri, 5 Apr 2019 00:47:21 -0700
Subject: [PATCH 4/4] Add some publishing stuff
---
package.json | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/package.json b/package.json
index b7d4402..33844b6 100644
--- a/package.json
+++ b/package.json
@@ -16,8 +16,11 @@
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
+ "predeploy": "npm run build",
+ "deploy": "gh-pages -d build",
"truffle:compile": "truffle compile && node -e \"console.log(JSON.stringify(require('./build/contracts/NFT.json').abi, null, 2))\" > ./src/static/abis/NFT.json"
},
+ "homepage": "http://nodesmith.github.io/erc721-benchmark/",
"eslintConfig": {
"extends": "react-app"
},
@@ -26,5 +29,8 @@
"not dead",
"not ie <= 11",
"not op_mini all"
- ]
+ ],
+ "devDependencies": {
+ "gh-pages": "^2.0.1"
+ }
}