This commit is contained in:
Richard Ramos 2019-10-02 20:44:19 -04:00 committed by Iuri Matias
parent c53d72cebf
commit f4789d0d60
3 changed files with 13 additions and 13 deletions

View File

@ -129,7 +129,7 @@ const abi = [
}
];
const data = "0x608060405234801561001057600080fd5b506100556040518060400160405280600681526020017f6c6170746f70000000000000000000000000000000000000000000000000000081525061005a60201b60201c565b610253565b600160008181805490500191508161007291906100fd565b5060006001600080549050039050600080828154811061008e57fe5b90600052602060002090600202019050828160000190805190602001906100b692919061012f565b50600281600101819055507f5dc23a654c93455cd36741580d5c1fafc8f35c429bb831bc768008bd655a1219826040518082815260200191505060405180910390a1505050565b81548183558181111561012a5760020281600202836000526020600020918201910161012991906101af565b5b505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061017057805160ff191683800117855561019e565b8280016001018555821561019e579182015b8281111561019d578251825591602001919060010190610182565b5b5090506101ab91906101e6565b5090565b6101e391905b808211156101df57600080820160006101ce919061020b565b6001820160009055506002016101b5565b5090565b90565b61020891905b808211156102045760008160009055506001016101ec565b5090565b90565b50805460018160011615610100020316600290046000825580601f106102315750610250565b601f01602090049060005260206000209081019061024f91906101e6565b5b50565b610645806102626000396000f3fe60806040526004361061003f5760003560e01c806302ec06be1461004157806311eaa75a146101095780637acc0b20146101db578063f4ef9e3614610296575b005b34801561004d57600080fd5b506101076004803603602081101561006457600080fd5b810190808035906020019064010000000081111561008157600080fd5b82018360208201111561009357600080fd5b803590602001918460018302840111640100000000831117156100b557600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505091929192905050506102db565b005b34801561011557600080fd5b506101d96004803603604081101561012c57600080fd5b81019080803590602001909291908035906020019064010000000081111561015357600080fd5b82018360208201111561016557600080fd5b8035906020019184600183028401116401000000008311171561018757600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050919291929050505061037e565b005b3480156101e757600080fd5b50610214600480360360208110156101fe57600080fd5b81019080803590602001909291905050506103b5565b6040518080602001838152602001828103825284818151815260200191508051906020019080838360005b8381101561025a57808201518184015260208101905061023f565b50505050905090810190601f1680156102875780820380516001836020036101000a031916815260200191505b50935050505060405180910390f35b3480156102a257600080fd5b506102d9600480360360408110156102b957600080fd5b81019080803590602001909291908035906020019092919050505061047e565b005b60016000818180549050019150816102f391906104ba565b5060006001600080549050039050600080828154811061030f57fe5b90600052602060002090600202019050828160000190805190602001906103379291906104ec565b50600281600101819055507f5dc23a654c93455cd36741580d5c1fafc8f35c429bb831bc768008bd655a1219826040518082815260200191505060405180910390a1505050565b806000838154811061038c57fe5b906000526020600020906002020160000190805190602001906103b09291906104ec565b505050565b600081815481106103c257fe5b9060005260206000209060020201600091509050806000018054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561046e5780601f106104435761010080835404028352916020019161046e565b820191906000526020600020905b81548152906001019060200180831161045157829003601f168201915b5050505050908060010154905082565b817ffdefdf8d82459f7b1eb157e5c44cbe6ee73d8ddd387511fe3622a3ee663b4697826040518082815260200191505060405180910390a25050565b8154818355818111156104e7576002028160020283600052602060002091820191016104e6919061056c565b5b505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061052d57805160ff191683800117855561055b565b8280016001018555821561055b579182015b8281111561055a57825182559160200191906001019061053f565b5b50905061056891906105a3565b5090565b6105a091905b8082111561059c576000808201600061058b91906105c8565b600182016000905550600201610572565b5090565b90565b6105c591905b808211156105c15760008160009055506001016105a9565b5090565b90565b50805460018160011615610100020316600290046000825580601f106105ee575061060d565b601f01602090049060005260206000209081019061060c91906105a3565b5b5056fea265627a7a723158206f33e1da3737d5722b96b323149eaa05c6eccdcb8ff4943da4758e783d210a5b64736f6c634300050b0032";
const data = "0x608060405234801561001057600080fd5b506100556040518060400160405280600681526020017f6c6170746f70000000000000000000000000000000000000000000000000000081525061005a60201b60201c565b610244565b600080805480919060010161006f91906100ee565b9050600080828154811061007f57fe5b90600052602060002090600202019050828160000190805190602001906100a7929190610120565b50600281600101819055507f5dc23a654c93455cd36741580d5c1fafc8f35c429bb831bc768008bd655a1219826040518082815260200191505060405180910390a1505050565b81548183558181111561011b5760020281600202836000526020600020918201910161011a91906101a0565b5b505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061016157805160ff191683800117855561018f565b8280016001018555821561018f579182015b8281111561018e578251825591602001919060010190610173565b5b50905061019c91906101d7565b5090565b6101d491905b808211156101d057600080820160006101bf91906101fc565b6001820160009055506002016101a6565b5090565b90565b6101f991905b808211156101f55760008160009055506001016101dd565b5090565b90565b50805460018160011615610100020316600290046000825580601f106102225750610241565b601f01602090049060005260206000209081019061024091906101d7565b5b50565b610659806102536000396000f3fe60806040526004361061003f5760003560e01c806302ec06be1461004157806311eaa75a146101095780637acc0b20146101db578063f4ef9e3614610296575b005b34801561004d57600080fd5b506101076004803603602081101561006457600080fd5b810190808035906020019064010000000081111561008157600080fd5b82018360208201111561009357600080fd5b803590602001918460018302840111640100000000831117156100b557600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505091929192905050506102db565b005b34801561011557600080fd5b506101d96004803603604081101561012c57600080fd5b81019080803590602001909291908035906020019064010000000081111561015357600080fd5b82018360208201111561016557600080fd5b8035906020019184600183028401116401000000008311171561018757600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050919291929050505061036f565b005b3480156101e757600080fd5b50610214600480360360208110156101fe57600080fd5b81019080803590602001909291905050506103a6565b6040518080602001838152602001828103825284818151815260200191508051906020019080838360005b8381101561025a57808201518184015260208101905061023f565b50505050905090810190601f1680156102875780820380516001836020036101000a031916815260200191505b50935050505060405180910390f35b3480156102a257600080fd5b506102d9600480360360408110156102b957600080fd5b81019080803590602001909291908035906020019092919050505061046f565b005b60008080548091906001016102f091906104ce565b9050600080828154811061030057fe5b9060005260206000209060020201905082816000019080519060200190610328929190610500565b50600281600101819055507f5dc23a654c93455cd36741580d5c1fafc8f35c429bb831bc768008bd655a1219826040518082815260200191505060405180910390a1505050565b806000838154811061037d57fe5b906000526020600020906002020160000190805190602001906103a1929190610500565b505050565b600081815481106103b357fe5b9060005260206000209060020201600091509050806000018054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561045f5780601f106104345761010080835404028352916020019161045f565b820191906000526020600020905b81548152906001019060200180831161044257829003601f168201915b5050505050908060010154905082565b817ffdefdf8d82459f7b1eb157e5c44cbe6ee73d8ddd387511fe3622a3ee663b4697826040518082815260200191505060405180910390a280600083815481106104b557fe5b9060005260206000209060020201600101819055505050565b8154818355818111156104fb576002028160020283600052602060002091820191016104fa9190610580565b5b505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061054157805160ff191683800117855561056f565b8280016001018555821561056f579182015b8281111561056e578251825591602001919060010190610553565b5b50905061057c91906105b7565b5090565b6105b491905b808211156105b0576000808201600061059f91906105dc565b600182016000905550600201610586565b5090565b90565b6105d991905b808211156105d55760008160009055506001016105bd565b5090565b90565b50805460018160011615610100020316600290046000825580601f106106025750610621565b601f01602090049060005260206000209081019061062091906105b7565b5b5056fea265627a7a72315820283a23649d3076ca075a3d9190d7b69b6665e8b1d83e5240c8cfbe34dc9d9b3364736f6c634300050b0032";
const MyContract = new web3.eth.Contract(abi, {data, gas: "800000"});
(async () => {

View File

@ -5,20 +5,20 @@ import { map } from 'rxjs/operators';
import ProductComponent from "./ProductComponent";
import web3 from './web3';
import ProductContract from './MyContract';
import { subscribe } from "graphql";
let Product;
class App extends React.Component {
state = {
title: "",
userTitle: "",
userRating: 0,
minRating: 0,
maxRating: 0,
averageRating: 0
};
async componentDidMount() {
const subspace = new Subspace(web3.currentProvider);
const subspace = new Subspace(web3.currentProvider);
await subspace.init();
Product = await ProductContract.getInstance();

View File

@ -40,6 +40,10 @@ export default class Subspace {
this.web3.getBlock('latest').then(block => {
this.latestBlockNumber = block.number;
this._initNewBlocksSubscription();
this._initCallInterval();
resolve();
})
})
@ -64,7 +68,7 @@ export default class Subspace {
_initNewBlocksSubscription() {
if (this.newBlocksSubscription != null || this.options.callInterval !== 0) return;
this.newBlocksSubscription = this.web3.subscribe('newBlockHeaders', (err, result) => {
if (err) {
sub.error(err);
@ -104,9 +108,6 @@ export default class Subspace {
callContractMethod();
this._initNewBlocksSubscription();
this._initCallInterval();
this.callables.push(callContractMethod);
return sub.pipe(distinctUntilChanged((a, b) => equal(a, b)));
@ -146,11 +147,10 @@ export default class Subspace {
};
}
callFn();
this._initNewBlocksSubscription();
this._initCallInterval();
// TO FIX: this line makes everything explode
// It's supposed to obtain the current balance immediatly
// callFn();
this.callables.push(callFn);
return sub.pipe(distinctUntilChanged((a, b) => equal(a, b)));