Added babel + linting some of the code
This commit is contained in:
parent
cb957b57d0
commit
bd93bb3062
|
@ -0,0 +1,12 @@
|
||||||
|
{
|
||||||
|
"plugins": [
|
||||||
|
"transform-object-rest-spread"
|
||||||
|
],
|
||||||
|
"presets": [
|
||||||
|
"stage-2"
|
||||||
|
],
|
||||||
|
"ignore": [
|
||||||
|
"config/",
|
||||||
|
"node_modules"
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,288 @@
|
||||||
|
|
||||||
|
{
|
||||||
|
"parser": "babel-eslint",
|
||||||
|
"plugins": [ ],
|
||||||
|
"parserOptions": {
|
||||||
|
"ecmaVersion": 2017,
|
||||||
|
"sourceType": "module",
|
||||||
|
"ecmaFeatures": {
|
||||||
|
"jsx": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"env": {
|
||||||
|
"es6": true,
|
||||||
|
"browser": true,
|
||||||
|
"node": true,
|
||||||
|
"mocha": true
|
||||||
|
},
|
||||||
|
"extends": [
|
||||||
|
"eslint:recommended"
|
||||||
|
],
|
||||||
|
"rules": {
|
||||||
|
"accessor-pairs": "error",
|
||||||
|
"array-bracket-newline": "error",
|
||||||
|
"array-bracket-spacing": [
|
||||||
|
"error",
|
||||||
|
"never"
|
||||||
|
],
|
||||||
|
"array-callback-return": "off",
|
||||||
|
"array-element-newline": "off",
|
||||||
|
"arrow-body-style": "off",
|
||||||
|
"arrow-parens": "off",
|
||||||
|
"arrow-spacing": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
"after": true,
|
||||||
|
"before": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"block-scoped-var": "error",
|
||||||
|
"block-spacing": "error",
|
||||||
|
"brace-style": "off",
|
||||||
|
"callback-return": "off",
|
||||||
|
"camelcase": "off",
|
||||||
|
"capitalized-comments": "off",
|
||||||
|
"class-methods-use-this": "off",
|
||||||
|
"comma-dangle": "error",
|
||||||
|
"comma-spacing": "off",
|
||||||
|
"comma-style": [
|
||||||
|
"error",
|
||||||
|
"last"
|
||||||
|
],
|
||||||
|
"complexity": "error",
|
||||||
|
"computed-property-spacing": [
|
||||||
|
"error",
|
||||||
|
"never"
|
||||||
|
],
|
||||||
|
"consistent-return": "off",
|
||||||
|
"consistent-this": "off",
|
||||||
|
"curly": "off",
|
||||||
|
"default-case": "error",
|
||||||
|
"dot-location": [
|
||||||
|
"error",
|
||||||
|
"property"
|
||||||
|
],
|
||||||
|
"dot-notation": "off",
|
||||||
|
"eol-last": "error",
|
||||||
|
"eqeqeq": "off",
|
||||||
|
"for-direction": "error",
|
||||||
|
"func-call-spacing": "error",
|
||||||
|
"func-name-matching": "error",
|
||||||
|
"func-names": "off",
|
||||||
|
"func-style": "off",
|
||||||
|
"function-paren-newline": "off",
|
||||||
|
"generator-star-spacing": "error",
|
||||||
|
"getter-return": "error",
|
||||||
|
"global-require": "off",
|
||||||
|
"guard-for-in": "off",
|
||||||
|
"handle-callback-err": "off",
|
||||||
|
"id-blacklist": "error",
|
||||||
|
"id-length": "off",
|
||||||
|
"id-match": "error",
|
||||||
|
"indent": "off",
|
||||||
|
"indent-legacy": "off",
|
||||||
|
"init-declarations": "off",
|
||||||
|
"jsx-quotes": "error",
|
||||||
|
"key-spacing": "off",
|
||||||
|
"keyword-spacing": "off",
|
||||||
|
"line-comment-position": "off",
|
||||||
|
"linebreak-style": [
|
||||||
|
"error",
|
||||||
|
"unix"
|
||||||
|
],
|
||||||
|
"lines-around-comment": "error",
|
||||||
|
"lines-around-directive": "error",
|
||||||
|
"max-depth": "error",
|
||||||
|
"max-len": "off",
|
||||||
|
"max-lines": "off",
|
||||||
|
"max-nested-callbacks": "error",
|
||||||
|
"max-params": "off",
|
||||||
|
"max-statements": "off",
|
||||||
|
"max-statements-per-line": "off",
|
||||||
|
"multiline-ternary": [
|
||||||
|
"error",
|
||||||
|
"never"
|
||||||
|
],
|
||||||
|
"new-parens": "off",
|
||||||
|
"newline-after-var": "off",
|
||||||
|
"newline-before-return": "off",
|
||||||
|
"newline-per-chained-call": "off",
|
||||||
|
"no-alert": "error",
|
||||||
|
"no-array-constructor": "error",
|
||||||
|
"no-await-in-loop": "error",
|
||||||
|
"no-bitwise": "error",
|
||||||
|
"no-buffer-constructor": "error",
|
||||||
|
"no-caller": "error",
|
||||||
|
"no-catch-shadow": "error",
|
||||||
|
"no-confusing-arrow": "error",
|
||||||
|
"no-console": "off",
|
||||||
|
"no-continue": "off",
|
||||||
|
"no-div-regex": "error",
|
||||||
|
"no-duplicate-imports": "error",
|
||||||
|
"no-else-return": "off",
|
||||||
|
"no-empty-function": "off",
|
||||||
|
"no-eq-null": "error",
|
||||||
|
"no-eval": "off",
|
||||||
|
"no-extend-native": "error",
|
||||||
|
"no-extra-bind": "error",
|
||||||
|
"no-extra-label": "error",
|
||||||
|
"no-extra-parens": "off",
|
||||||
|
"no-floating-decimal": "error",
|
||||||
|
"no-implicit-coercion": "error",
|
||||||
|
"no-implicit-globals": "error",
|
||||||
|
"no-implied-eval": "error",
|
||||||
|
"no-inline-comments": "off",
|
||||||
|
"no-inner-declarations": [
|
||||||
|
"error",
|
||||||
|
"functions"
|
||||||
|
],
|
||||||
|
"no-invalid-this": "off",
|
||||||
|
"no-iterator": "error",
|
||||||
|
"no-label-var": "error",
|
||||||
|
"no-labels": "error",
|
||||||
|
"no-lone-blocks": "error",
|
||||||
|
"no-lonely-if": "off",
|
||||||
|
"no-loop-func": "off",
|
||||||
|
"no-magic-numbers": "off",
|
||||||
|
"no-mixed-operators": "error",
|
||||||
|
"no-mixed-requires": "error",
|
||||||
|
"no-multi-assign": "error",
|
||||||
|
"no-multi-spaces": "off",
|
||||||
|
"no-multi-str": "error",
|
||||||
|
"no-multiple-empty-lines": "error",
|
||||||
|
"no-native-reassign": "error",
|
||||||
|
"no-negated-condition": "off",
|
||||||
|
"no-negated-in-lhs": "error",
|
||||||
|
"no-nested-ternary": "error",
|
||||||
|
"no-new": "error",
|
||||||
|
"no-new-func": "error",
|
||||||
|
"no-new-object": "error",
|
||||||
|
"no-new-require": "error",
|
||||||
|
"no-new-wrappers": "error",
|
||||||
|
"no-octal-escape": "error",
|
||||||
|
"no-param-reassign": "off",
|
||||||
|
"no-path-concat": "error",
|
||||||
|
"no-plusplus": "off",
|
||||||
|
"no-process-env": "off",
|
||||||
|
"no-process-exit": "off",
|
||||||
|
"no-proto": "error",
|
||||||
|
"no-prototype-builtins": "off",
|
||||||
|
"no-restricted-globals": "error",
|
||||||
|
"no-restricted-imports": "error",
|
||||||
|
"no-restricted-modules": "error",
|
||||||
|
"no-restricted-properties": "error",
|
||||||
|
"no-restricted-syntax": "error",
|
||||||
|
"no-return-assign": "error",
|
||||||
|
"no-return-await": "error",
|
||||||
|
"no-script-url": "error",
|
||||||
|
"no-self-compare": "error",
|
||||||
|
"no-sequences": "error",
|
||||||
|
"no-shadow": "off",
|
||||||
|
"no-shadow-restricted-names": "error",
|
||||||
|
"no-spaced-func": "error",
|
||||||
|
"no-sync": "off",
|
||||||
|
"no-tabs": "error",
|
||||||
|
"no-template-curly-in-string": "error",
|
||||||
|
"no-ternary": "off",
|
||||||
|
"no-throw-literal": "error",
|
||||||
|
"no-trailing-spaces": "off",
|
||||||
|
"no-undef-init": "error",
|
||||||
|
"no-undefined": "off",
|
||||||
|
"no-underscore-dangle": "off",
|
||||||
|
"no-unmodified-loop-condition": "error",
|
||||||
|
"no-unneeded-ternary": "error",
|
||||||
|
"no-unused-expressions": "error",
|
||||||
|
"no-unused-vars": ["error", { "argsIgnorePattern": "^_" }],
|
||||||
|
"no-use-before-define": "off",
|
||||||
|
"no-useless-call": "off",
|
||||||
|
"no-useless-computed-key": "error",
|
||||||
|
"no-useless-concat": "error",
|
||||||
|
"no-useless-constructor": "error",
|
||||||
|
"no-useless-escape": "off",
|
||||||
|
"no-useless-rename": "error",
|
||||||
|
"no-useless-return": "off",
|
||||||
|
"no-var": "off",
|
||||||
|
"no-void": "error",
|
||||||
|
"no-warning-comments": "off",
|
||||||
|
"no-whitespace-before-property": "error",
|
||||||
|
"no-with": "error",
|
||||||
|
"nonblock-statement-body-position": "error",
|
||||||
|
"object-curly-newline": "off",
|
||||||
|
"object-curly-spacing": [
|
||||||
|
"error",
|
||||||
|
"never"
|
||||||
|
],
|
||||||
|
"object-property-newline": "off",
|
||||||
|
"object-shorthand": "off",
|
||||||
|
"one-var": "off",
|
||||||
|
"one-var-declaration-per-line": "off",
|
||||||
|
"operator-assignment": "off",
|
||||||
|
"operator-linebreak": "error",
|
||||||
|
"padded-blocks": "off",
|
||||||
|
"padding-line-between-statements": "error",
|
||||||
|
"prefer-arrow-callback": "off",
|
||||||
|
"prefer-const": "off",
|
||||||
|
"prefer-destructuring": "off",
|
||||||
|
"prefer-numeric-literals": "error",
|
||||||
|
"prefer-promise-reject-errors": "error",
|
||||||
|
"prefer-reflect": "off",
|
||||||
|
"prefer-rest-params": "off",
|
||||||
|
"prefer-spread": "off",
|
||||||
|
"prefer-template": "off",
|
||||||
|
"quote-props": "off",
|
||||||
|
"quotes": "off",
|
||||||
|
"radix": "error",
|
||||||
|
"require-await": "error",
|
||||||
|
"require-jsdoc": "off",
|
||||||
|
"rest-spread-spacing": "error",
|
||||||
|
"semi": "error",
|
||||||
|
"semi-spacing": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
"after": true,
|
||||||
|
"before": false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"semi-style": [
|
||||||
|
"error",
|
||||||
|
"last"
|
||||||
|
],
|
||||||
|
"sort-imports": [2, {
|
||||||
|
"ignoreCase": false,
|
||||||
|
"ignoreMemberSort": false,
|
||||||
|
"memberSyntaxSortOrder": ["none", "all", "multiple", "single"]
|
||||||
|
}],
|
||||||
|
"sort-keys": "off",
|
||||||
|
"sort-vars": "off",
|
||||||
|
"space-before-blocks": "off",
|
||||||
|
"space-before-function-paren": "off",
|
||||||
|
"space-in-parens": [
|
||||||
|
"error",
|
||||||
|
"never"
|
||||||
|
],
|
||||||
|
"space-infix-ops": "off",
|
||||||
|
"space-unary-ops": "error",
|
||||||
|
"spaced-comment": "off",
|
||||||
|
"strict": "error",
|
||||||
|
"switch-colon-spacing": "error",
|
||||||
|
"symbol-description": "error",
|
||||||
|
"template-curly-spacing": [
|
||||||
|
"error",
|
||||||
|
"never"
|
||||||
|
],
|
||||||
|
"template-tag-spacing": "error",
|
||||||
|
"unicode-bom": [
|
||||||
|
"error",
|
||||||
|
"never"
|
||||||
|
],
|
||||||
|
"valid-jsdoc": "error",
|
||||||
|
"vars-on-top": "off",
|
||||||
|
"wrap-iife": "error",
|
||||||
|
"wrap-regex": "error",
|
||||||
|
"yield-star-spacing": "error",
|
||||||
|
"yoda": [
|
||||||
|
"error",
|
||||||
|
"never"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
|
@ -9,6 +9,17 @@
|
||||||
},
|
},
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
|
"devDependencies": {
|
||||||
|
"babel-eslint": "^8.2.6",
|
||||||
|
"babel-plugin-transform-object-rest-spread": "^6.26.0",
|
||||||
|
"babel-preset-stage-2": "^6.24.1",
|
||||||
|
"eslint": "^4.19.1",
|
||||||
|
"eslint-config-standard": "^11.0.0",
|
||||||
|
"eslint-plugin-import": "^2.13.0",
|
||||||
|
"eslint-plugin-node": "^7.0.1",
|
||||||
|
"eslint-plugin-promise": "^3.8.0",
|
||||||
|
"eslint-plugin-standard": "^3.1.0"
|
||||||
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"daemonize2": "^0.4.2",
|
"daemonize2": "^0.4.2",
|
||||||
"ganache-cli": "^6.1.0",
|
"ganache-cli": "^6.1.0",
|
||||||
|
|
|
@ -53,7 +53,7 @@ class ContractSettings {
|
||||||
if(this.pendingToLoad == 0) this.events.emit("setup:complete", this);
|
if(this.pendingToLoad == 0) this.events.emit("setup:complete", this);
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
console.error("Invalid contract for " + contractName);
|
console.error("Invalid contract for " + topicName);
|
||||||
console.error(err);
|
console.error(err);
|
||||||
process.exit();
|
process.exit();
|
||||||
});
|
});
|
||||||
|
|
|
@ -24,7 +24,7 @@ class MessageProcessor {
|
||||||
async _validateInput(message){
|
async _validateInput(message){
|
||||||
const contract = this.settings.getContractByTopic(message.topic);
|
const contract = this.settings.getContractByTopic(message.topic);
|
||||||
|
|
||||||
if(!/^0x[0-9a-f]{40}$/i.test(message.input.address)){
|
if(!(/^0x[0-9a-f]{40}$/i).test(message.input.address)){
|
||||||
this._reply('Invalid address', message);
|
this._reply('Invalid address', message);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -110,15 +110,15 @@ class MessageProcessor {
|
||||||
|
|
||||||
this.web3.eth.estimateGas(p)
|
this.web3.eth.estimateGas(p)
|
||||||
.then((estimatedGas) => {
|
.then((estimatedGas) => {
|
||||||
p.gas = parseInt(estimatedGas * 1.1)
|
p.gas = parseInt(estimatedGas * 1.1, 10);
|
||||||
return this.web3.eth.sendTransaction(p);
|
return this.web3.eth.sendTransaction(p);
|
||||||
})
|
})
|
||||||
.then((receipt) => {
|
.then((receipt) => {
|
||||||
return this._reply("Transaction mined;"
|
return this._reply("Transaction mined;" +
|
||||||
+ receipt.transactionHash
|
receipt.transactionHash +
|
||||||
+ ';'
|
';' +
|
||||||
+ JSON.stringify(receipt)
|
JSON.stringify(receipt),
|
||||||
, message);
|
message);
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
this._reply("Couldn't mine transaction: " + err.message, message);
|
this._reply("Couldn't mine transaction: " + err.message, message);
|
||||||
// TODO log this?
|
// TODO log this?
|
||||||
|
|
|
@ -17,7 +17,7 @@ let connectionURL = `${config.node.local.protocol}://${config.node.local.host}:$
|
||||||
const web3 = new Web3(connectionURL);
|
const web3 = new Web3(connectionURL);
|
||||||
|
|
||||||
web3.eth.net.isListening()
|
web3.eth.net.isListening()
|
||||||
.then(listening => events.emit('web3:connected', connectionURL))
|
.then(() => events.emit('web3:connected', connectionURL))
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
process.exit();
|
process.exit();
|
||||||
|
@ -34,13 +34,10 @@ events.on('web3:connected', connURL => {
|
||||||
// Setting up Whisper options
|
// Setting up Whisper options
|
||||||
const shhOptions = {
|
const shhOptions = {
|
||||||
ttl: config.node.whisper.ttl,
|
ttl: config.node.whisper.ttl,
|
||||||
minPow: config.node.whisper.minPow,
|
minPow: config.node.whisper.minPow
|
||||||
};
|
};
|
||||||
|
|
||||||
events.on('setup:complete', (settings) => {
|
events.on('setup:complete', (settings) => {
|
||||||
|
|
||||||
|
|
||||||
let kId;
|
|
||||||
let symKId;
|
let symKId;
|
||||||
|
|
||||||
// Listening to whisper
|
// Listening to whisper
|
||||||
|
@ -61,11 +58,8 @@ events.on('setup:complete', (settings) => {
|
||||||
events.emit('server:listen', shhOptions, settings);
|
events.emit('server:listen', shhOptions, settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(config.heartbeat.enabled){
|
if(config.heartbeat.enabled){
|
||||||
|
|
||||||
let heartbeatSymKeyId;
|
|
||||||
web3.shh.addSymKey(config.heartbeat.symKey)
|
web3.shh.addSymKey(config.heartbeat.symKey)
|
||||||
.then(heartbeatSymKeyId => {
|
.then(heartbeatSymKeyId => {
|
||||||
|
|
||||||
|
@ -100,16 +94,17 @@ events.on('setup:complete', (settings) => {
|
||||||
|
|
||||||
events.on('server:listen', (shhOptions, settings) => {
|
events.on('server:listen', (shhOptions, settings) => {
|
||||||
let processor = new MessageProcessor(config, settings, web3, shhOptions.kId);
|
let processor = new MessageProcessor(config, settings, web3, shhOptions.kId);
|
||||||
web3.shh.subscribe('messages', shhOptions, (error, message, subscription) => processor.process(error, message));
|
web3.shh.subscribe('messages', shhOptions, (error, message) => processor.process(error, message));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// Daemon helper functions
|
// Daemon helper functions
|
||||||
|
|
||||||
process.on("uncaughtException", function(err) {
|
process.on("uncaughtException", function(err) {
|
||||||
|
// TODO
|
||||||
|
console.error(err);
|
||||||
});
|
});
|
||||||
|
|
||||||
process.once("SIGTERM", function() {
|
process.once("SIGTERM", function() {
|
||||||
log("Stopping...");
|
console.log("Stopping...");
|
||||||
});
|
});
|
|
@ -15,19 +15,19 @@ class IdentityStrategy {
|
||||||
const parameterList = this.web3.eth.abi.decodeParameters(this.contract.allowedFunctions[message.input.functionName].inputs, message.input.functionParameters);
|
const parameterList = this.web3.eth.abi.decodeParameters(this.contract.allowedFunctions[message.input.functionName].inputs, message.input.functionParameters);
|
||||||
return function(parameterName){
|
return function(parameterName){
|
||||||
return parameterList[parameterName];
|
return parameterList[parameterName];
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
async _validateInstance(message){
|
async _validateInstance(message){
|
||||||
const instanceCodeHash = this.web3.utils.soliditySha3(await this.web3.eth.getCode(message.input.address));
|
const instanceCodeHash = this.web3.utils.soliditySha3(await this.web3.eth.getCode(message.input.address));
|
||||||
const kernelVerifSignature = this.web3.utils.soliditySha3(this.contract.kernelVerification).slice(0, 10);
|
const kernelVerifSignature = this.web3.utils.soliditySha3(this.contract.kernelVerification).slice(0, 10);
|
||||||
if(instanceCodeHash == null) return false;
|
if(instanceCodeHash === null) return false;
|
||||||
|
|
||||||
let verificationResult = await this.web3.eth.call({
|
let verificationResult = await this.web3.eth.call({
|
||||||
to: this.contract.factoryAddress,
|
to: this.contract.factoryAddress,
|
||||||
data: kernelVerifSignature + instanceCodeHash.slice(2)});
|
data: kernelVerifSignature + instanceCodeHash.slice(2)});
|
||||||
|
|
||||||
return this.web3.eth.abi.decodeParameter('bool', verificationResult);;
|
return this.web3.eth.abi.decodeParameter('bool', verificationResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getBalance(token, message, gasToken){
|
async getBalance(token, message, gasToken){
|
||||||
|
@ -67,7 +67,7 @@ class IdentityStrategy {
|
||||||
if(this.contract.isIdentity){
|
if(this.contract.isIdentity){
|
||||||
let validInstance = await this._validateInstance(message);
|
let validInstance = await this._validateInstance(message);
|
||||||
if(!validInstance){
|
if(!validInstance){
|
||||||
return { success: false, message: "Invalid identity instance" };
|
return {success: false, message: "Invalid identity instance"};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,9 +75,7 @@ class IdentityStrategy {
|
||||||
|
|
||||||
// Verifying if token is allowed
|
// Verifying if token is allowed
|
||||||
const token = this.settings.getToken(params('_gasToken'));
|
const token = this.settings.getToken(params('_gasToken'));
|
||||||
if(token == undefined)
|
if(token == undefined) return {success: false, message: "Token not allowed"};
|
||||||
return { success: false, message: "Token not allowed" };
|
|
||||||
|
|
||||||
|
|
||||||
// Determine if enough balance for baseToken
|
// Determine if enough balance for baseToken
|
||||||
const gasPrice = this.web3.utils.toBN(params('_gasPrice'));
|
const gasPrice = this.web3.utils.toBN(params('_gasPrice'));
|
||||||
|
@ -85,9 +83,9 @@ class IdentityStrategy {
|
||||||
if(this.contract.allowedFunctions[message.input.functionName].isToken){
|
if(this.contract.allowedFunctions[message.input.functionName].isToken){
|
||||||
const Token = new this.web3.eth.Contract(erc20ABI);
|
const Token = new this.web3.eth.Contract(erc20ABI);
|
||||||
Token.options.address = params('_baseToken');
|
Token.options.address = params('_baseToken');
|
||||||
const baseToken = new this.web3.utils.BN(await Token.methods.balanceOf(message.input.address).call());
|
// const baseToken = new this.web3.utils.BN(await Token.methods.balanceOf(message.input.address).call());
|
||||||
if(balance.lt(this.web3.utils.BN(params('_value')))){
|
if(balance.lt(this.web3.utils.BN(params('_value')))){
|
||||||
return { success: false, message: "Identity has not enough balance for specified value" };
|
return {success: false, message: "Identity has not enough balance for specified value"};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,7 +93,7 @@ class IdentityStrategy {
|
||||||
const gasToken = params('_gasToken');
|
const gasToken = params('_gasToken');
|
||||||
const balance = await this.getBalance(token, message, gasToken);
|
const balance = await this.getBalance(token, message, gasToken);
|
||||||
if(balance.lt(this.web3.utils.toBN(gasPrice.mul(gasLimit)))) {
|
if(balance.lt(this.web3.utils.toBN(gasPrice.mul(gasLimit)))) {
|
||||||
return { success: false, message: "Identity has not enough tokens for gasPrice*gasLimit"};
|
return {success: false, message: "Identity has not enough tokens for gasPrice*gasLimit"};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -104,11 +102,10 @@ class IdentityStrategy {
|
||||||
try {
|
try {
|
||||||
estimatedGas = await this._estimateGas(message, latestBlock.gasLimit);
|
estimatedGas = await this._estimateGas(message, latestBlock.gasLimit);
|
||||||
if(gasLimit.lt(estimatedGas)) {
|
if(gasLimit.lt(estimatedGas)) {
|
||||||
return { success: false, message: "Gas limit below estimated gas" };
|
return {success: false, message: "Gas limit below estimated gas"};
|
||||||
}
|
}
|
||||||
} catch(exc){
|
} catch(exc){
|
||||||
if(exc.message.indexOf("revert") > -1)
|
if(exc.message.indexOf("revert") > -1) return {success: false, message: "Transaction will revert"};
|
||||||
return { success: false, message: "Transaction will revert" };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
{
|
||||||
|
"plugins": [
|
||||||
|
"transform-object-rest-spread"
|
||||||
|
],
|
||||||
|
"presets": [
|
||||||
|
"stage-2"
|
||||||
|
],
|
||||||
|
"ignore": [
|
||||||
|
"config/",
|
||||||
|
"node_modules"
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,291 @@
|
||||||
|
|
||||||
|
{
|
||||||
|
"parser": "babel-eslint",
|
||||||
|
"plugins": [
|
||||||
|
"react"
|
||||||
|
],
|
||||||
|
"parserOptions": {
|
||||||
|
"ecmaVersion": 2017,
|
||||||
|
"sourceType": "module",
|
||||||
|
"ecmaFeatures": {
|
||||||
|
"jsx": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"env": {
|
||||||
|
"es6": true,
|
||||||
|
"browser": true,
|
||||||
|
"node": true,
|
||||||
|
"mocha": true
|
||||||
|
},
|
||||||
|
"extends": [
|
||||||
|
"eslint:recommended",
|
||||||
|
"plugin:react/recommended"
|
||||||
|
],
|
||||||
|
"rules": {
|
||||||
|
"accessor-pairs": "error",
|
||||||
|
"array-bracket-newline": "error",
|
||||||
|
"array-bracket-spacing": [
|
||||||
|
"error",
|
||||||
|
"never"
|
||||||
|
],
|
||||||
|
"array-callback-return": "off",
|
||||||
|
"array-element-newline": "off",
|
||||||
|
"arrow-body-style": "off",
|
||||||
|
"arrow-parens": "off",
|
||||||
|
"arrow-spacing": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
"after": true,
|
||||||
|
"before": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"block-scoped-var": "error",
|
||||||
|
"block-spacing": "error",
|
||||||
|
"brace-style": "off",
|
||||||
|
"callback-return": "off",
|
||||||
|
"camelcase": "off",
|
||||||
|
"capitalized-comments": "off",
|
||||||
|
"class-methods-use-this": "off",
|
||||||
|
"comma-dangle": "error",
|
||||||
|
"comma-spacing": "off",
|
||||||
|
"comma-style": [
|
||||||
|
"error",
|
||||||
|
"last"
|
||||||
|
],
|
||||||
|
"complexity": "error",
|
||||||
|
"computed-property-spacing": [
|
||||||
|
"error",
|
||||||
|
"never"
|
||||||
|
],
|
||||||
|
"consistent-return": "off",
|
||||||
|
"consistent-this": "off",
|
||||||
|
"curly": "off",
|
||||||
|
"default-case": "error",
|
||||||
|
"dot-location": [
|
||||||
|
"error",
|
||||||
|
"property"
|
||||||
|
],
|
||||||
|
"dot-notation": "off",
|
||||||
|
"eol-last": "error",
|
||||||
|
"eqeqeq": "off",
|
||||||
|
"for-direction": "error",
|
||||||
|
"func-call-spacing": "error",
|
||||||
|
"func-name-matching": "error",
|
||||||
|
"func-names": "off",
|
||||||
|
"func-style": "off",
|
||||||
|
"function-paren-newline": "off",
|
||||||
|
"generator-star-spacing": "error",
|
||||||
|
"getter-return": "error",
|
||||||
|
"global-require": "off",
|
||||||
|
"guard-for-in": "off",
|
||||||
|
"handle-callback-err": "off",
|
||||||
|
"id-blacklist": "error",
|
||||||
|
"id-length": "off",
|
||||||
|
"id-match": "error",
|
||||||
|
"indent": "off",
|
||||||
|
"indent-legacy": "off",
|
||||||
|
"init-declarations": "off",
|
||||||
|
"jsx-quotes": "error",
|
||||||
|
"key-spacing": "off",
|
||||||
|
"keyword-spacing": "off",
|
||||||
|
"line-comment-position": "off",
|
||||||
|
"linebreak-style": [
|
||||||
|
"error",
|
||||||
|
"unix"
|
||||||
|
],
|
||||||
|
"lines-around-comment": "error",
|
||||||
|
"lines-around-directive": "error",
|
||||||
|
"max-depth": "error",
|
||||||
|
"max-len": "off",
|
||||||
|
"max-lines": "off",
|
||||||
|
"max-nested-callbacks": "error",
|
||||||
|
"max-params": "off",
|
||||||
|
"max-statements": "off",
|
||||||
|
"max-statements-per-line": "off",
|
||||||
|
"multiline-ternary": [
|
||||||
|
"error",
|
||||||
|
"never"
|
||||||
|
],
|
||||||
|
"new-parens": "off",
|
||||||
|
"newline-after-var": "off",
|
||||||
|
"newline-before-return": "off",
|
||||||
|
"newline-per-chained-call": "off",
|
||||||
|
"no-alert": "error",
|
||||||
|
"no-array-constructor": "error",
|
||||||
|
"no-await-in-loop": "error",
|
||||||
|
"no-bitwise": "error",
|
||||||
|
"no-buffer-constructor": "error",
|
||||||
|
"no-caller": "error",
|
||||||
|
"no-catch-shadow": "error",
|
||||||
|
"no-confusing-arrow": "error",
|
||||||
|
"no-console": "off",
|
||||||
|
"no-continue": "off",
|
||||||
|
"no-div-regex": "error",
|
||||||
|
"no-duplicate-imports": "error",
|
||||||
|
"no-else-return": "off",
|
||||||
|
"no-empty-function": "off",
|
||||||
|
"no-eq-null": "error",
|
||||||
|
"no-eval": "off",
|
||||||
|
"no-extend-native": "error",
|
||||||
|
"no-extra-bind": "error",
|
||||||
|
"no-extra-label": "error",
|
||||||
|
"no-extra-parens": "off",
|
||||||
|
"no-floating-decimal": "error",
|
||||||
|
"no-implicit-coercion": "error",
|
||||||
|
"no-implicit-globals": "error",
|
||||||
|
"no-implied-eval": "error",
|
||||||
|
"no-inline-comments": "off",
|
||||||
|
"no-inner-declarations": [
|
||||||
|
"error",
|
||||||
|
"functions"
|
||||||
|
],
|
||||||
|
"no-invalid-this": "off",
|
||||||
|
"no-iterator": "error",
|
||||||
|
"no-label-var": "error",
|
||||||
|
"no-labels": "error",
|
||||||
|
"no-lone-blocks": "error",
|
||||||
|
"no-lonely-if": "off",
|
||||||
|
"no-loop-func": "off",
|
||||||
|
"no-magic-numbers": "off",
|
||||||
|
"no-mixed-operators": "error",
|
||||||
|
"no-mixed-requires": "error",
|
||||||
|
"no-multi-assign": "error",
|
||||||
|
"no-multi-spaces": "off",
|
||||||
|
"no-multi-str": "error",
|
||||||
|
"no-multiple-empty-lines": "error",
|
||||||
|
"no-native-reassign": "error",
|
||||||
|
"no-negated-condition": "off",
|
||||||
|
"no-negated-in-lhs": "error",
|
||||||
|
"no-nested-ternary": "error",
|
||||||
|
"no-new": "error",
|
||||||
|
"no-new-func": "error",
|
||||||
|
"no-new-object": "error",
|
||||||
|
"no-new-require": "error",
|
||||||
|
"no-new-wrappers": "error",
|
||||||
|
"no-octal-escape": "error",
|
||||||
|
"no-param-reassign": "off",
|
||||||
|
"no-path-concat": "error",
|
||||||
|
"no-plusplus": "off",
|
||||||
|
"no-process-env": "off",
|
||||||
|
"no-process-exit": "off",
|
||||||
|
"no-proto": "error",
|
||||||
|
"no-prototype-builtins": "off",
|
||||||
|
"no-restricted-globals": "error",
|
||||||
|
"no-restricted-imports": "error",
|
||||||
|
"no-restricted-modules": "error",
|
||||||
|
"no-restricted-properties": "error",
|
||||||
|
"no-restricted-syntax": "error",
|
||||||
|
"no-return-assign": "error",
|
||||||
|
"no-return-await": "error",
|
||||||
|
"no-script-url": "error",
|
||||||
|
"no-self-compare": "error",
|
||||||
|
"no-sequences": "error",
|
||||||
|
"no-shadow": "off",
|
||||||
|
"no-shadow-restricted-names": "error",
|
||||||
|
"no-spaced-func": "error",
|
||||||
|
"no-sync": "off",
|
||||||
|
"no-tabs": "error",
|
||||||
|
"no-template-curly-in-string": "error",
|
||||||
|
"no-ternary": "off",
|
||||||
|
"no-throw-literal": "error",
|
||||||
|
"no-trailing-spaces": "off",
|
||||||
|
"no-undef-init": "error",
|
||||||
|
"no-undefined": "off",
|
||||||
|
"no-underscore-dangle": "off",
|
||||||
|
"no-unmodified-loop-condition": "error",
|
||||||
|
"no-unneeded-ternary": "error",
|
||||||
|
"no-unused-expressions": "error",
|
||||||
|
"no-unused-vars": ["error", { "argsIgnorePattern": "^_" }],
|
||||||
|
"no-use-before-define": "off",
|
||||||
|
"no-useless-call": "off",
|
||||||
|
"no-useless-computed-key": "error",
|
||||||
|
"no-useless-concat": "error",
|
||||||
|
"no-useless-constructor": "error",
|
||||||
|
"no-useless-escape": "off",
|
||||||
|
"no-useless-rename": "error",
|
||||||
|
"no-useless-return": "off",
|
||||||
|
"no-var": "off",
|
||||||
|
"no-void": "error",
|
||||||
|
"no-warning-comments": "off",
|
||||||
|
"no-whitespace-before-property": "error",
|
||||||
|
"no-with": "error",
|
||||||
|
"nonblock-statement-body-position": "error",
|
||||||
|
"object-curly-newline": "off",
|
||||||
|
"object-curly-spacing": [
|
||||||
|
"error",
|
||||||
|
"never"
|
||||||
|
],
|
||||||
|
"object-property-newline": "off",
|
||||||
|
"object-shorthand": "off",
|
||||||
|
"one-var": "off",
|
||||||
|
"one-var-declaration-per-line": "off",
|
||||||
|
"operator-assignment": "off",
|
||||||
|
"operator-linebreak": "error",
|
||||||
|
"padded-blocks": "off",
|
||||||
|
"padding-line-between-statements": "error",
|
||||||
|
"prefer-arrow-callback": "off",
|
||||||
|
"prefer-const": "off",
|
||||||
|
"prefer-destructuring": "off",
|
||||||
|
"prefer-numeric-literals": "error",
|
||||||
|
"prefer-promise-reject-errors": "error",
|
||||||
|
"prefer-reflect": "off",
|
||||||
|
"prefer-rest-params": "off",
|
||||||
|
"prefer-spread": "off",
|
||||||
|
"prefer-template": "off",
|
||||||
|
"quote-props": "off",
|
||||||
|
"quotes": "off",
|
||||||
|
"radix": "error",
|
||||||
|
"require-await": "error",
|
||||||
|
"require-jsdoc": "off",
|
||||||
|
"rest-spread-spacing": "error",
|
||||||
|
"semi": "error",
|
||||||
|
"semi-spacing": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
"after": true,
|
||||||
|
"before": false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"semi-style": [
|
||||||
|
"error",
|
||||||
|
"last"
|
||||||
|
],
|
||||||
|
"sort-imports": [2, {
|
||||||
|
"ignoreCase": false,
|
||||||
|
"ignoreMemberSort": false,
|
||||||
|
"memberSyntaxSortOrder": ["none", "all", "multiple", "single"]
|
||||||
|
}],
|
||||||
|
"sort-keys": "off",
|
||||||
|
"sort-vars": "off",
|
||||||
|
"space-before-blocks": "off",
|
||||||
|
"space-before-function-paren": "off",
|
||||||
|
"space-in-parens": [
|
||||||
|
"error",
|
||||||
|
"never"
|
||||||
|
],
|
||||||
|
"space-infix-ops": "off",
|
||||||
|
"space-unary-ops": "error",
|
||||||
|
"spaced-comment": "off",
|
||||||
|
"strict": "error",
|
||||||
|
"switch-colon-spacing": "error",
|
||||||
|
"symbol-description": "error",
|
||||||
|
"template-curly-spacing": [
|
||||||
|
"error",
|
||||||
|
"never"
|
||||||
|
],
|
||||||
|
"template-tag-spacing": "error",
|
||||||
|
"unicode-bom": [
|
||||||
|
"error",
|
||||||
|
"never"
|
||||||
|
],
|
||||||
|
"valid-jsdoc": "error",
|
||||||
|
"vars-on-top": "off",
|
||||||
|
"wrap-iife": "error",
|
||||||
|
"wrap-regex": "error",
|
||||||
|
"yield-star-spacing": "error",
|
||||||
|
"yoda": [
|
||||||
|
"error",
|
||||||
|
"never"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
import web3 from 'Embark/web3';
|
|
||||||
import EmbarkJS from 'Embark/EmbarkJS';
|
import EmbarkJS from 'Embark/EmbarkJS';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import web3 from 'Embark/web3';
|
||||||
|
|
||||||
class AccountBalance extends React.Component {
|
class AccountBalance extends React.Component {
|
||||||
|
|
||||||
|
@ -15,8 +15,7 @@ class AccountBalance extends React.Component {
|
||||||
|
|
||||||
componentDidMount(){
|
componentDidMount(){
|
||||||
EmbarkJS.onReady(err => {
|
EmbarkJS.onReady(err => {
|
||||||
if(!err)
|
if(!err) this.updateBalances();
|
||||||
this.updateBalances();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,13 +24,13 @@ class AccountBalance extends React.Component {
|
||||||
|
|
||||||
web3.eth.getBalance(this.props.address)
|
web3.eth.getBalance(this.props.address)
|
||||||
.then(eth => {
|
.then(eth => {
|
||||||
this.setState({ eth });
|
this.setState({eth});
|
||||||
});
|
});
|
||||||
|
|
||||||
this.props.RND.methods.balanceOf(this.props.address)
|
this.props.RND.methods.balanceOf(this.props.address)
|
||||||
.call()
|
.call()
|
||||||
.then(rnd => {
|
.then(rnd => {
|
||||||
this.setState({ rnd });
|
this.setState({rnd});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +41,7 @@ class AccountBalance extends React.Component {
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.updateBalances();
|
this.updateBalances();
|
||||||
return true;
|
return true;
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
generateTokens(ev){
|
generateTokens(ev){
|
||||||
|
@ -71,6 +70,6 @@ class AccountBalance extends React.Component {
|
||||||
|
|
||||||
</div>;
|
</div>;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
export default AccountBalance;
|
export default AccountBalance;
|
|
@ -1,9 +1,7 @@
|
||||||
import Web3 from 'web3';
|
import {Alert, Button, Col, ControlLabel, Form, FormControl, Grid, HelpBlock, InputGroup, Row} from 'react-bootstrap';
|
||||||
|
|
||||||
import React from 'react';
|
|
||||||
import { Grid, Row, Form, FormGroup, FormControl, HelpBlock, Button, ControlLabel, Col, InputGroup, Alert } from 'react-bootstrap';
|
|
||||||
import AccountBalance from './accountBalance';
|
import AccountBalance from './accountBalance';
|
||||||
|
import React from 'react';
|
||||||
|
import Web3 from 'web3';
|
||||||
|
|
||||||
class ApproveAndCallGasRelayed extends React.Component {
|
class ApproveAndCallGasRelayed extends React.Component {
|
||||||
|
|
||||||
|
@ -42,7 +40,7 @@ class ApproveAndCallGasRelayed extends React.Component {
|
||||||
let accounts = await this.props.web3.eth.getAccounts();
|
let accounts = await this.props.web3.eth.getAccounts();
|
||||||
this.setState({
|
this.setState({
|
||||||
account: accounts[0]
|
account: accounts[0]
|
||||||
})
|
});
|
||||||
|
|
||||||
let _skid = await web3W.shh.addSymKey(this.state.symKey);
|
let _skid = await web3W.shh.addSymKey(this.state.symKey);
|
||||||
let _kid = await web3W.shh.newKeyPair();
|
let _kid = await web3W.shh.newKeyPair();
|
||||||
|
@ -58,24 +56,25 @@ class ApproveAndCallGasRelayed extends React.Component {
|
||||||
"ttl": 20,
|
"ttl": 20,
|
||||||
"minPow": 0.8,
|
"minPow": 0.8,
|
||||||
"powTime": 1000
|
"powTime": 1000
|
||||||
}, (error, message, subscription) => {
|
}, (error, message) => {
|
||||||
if(error) {
|
if(error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
this.setState({errorMessage: error.message})
|
this.setState({errorMessage: error.message});
|
||||||
} else {
|
} else {
|
||||||
this.state.messages.push(this.props.web3.utils.hexToAscii(message.payload));
|
this.state.messages.push(this.props.web3.utils.hexToAscii(message.payload));
|
||||||
this.setState({messages: this.state.messages})
|
this.setState({messages: this.state.messages});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
handleChange(e, name){
|
handleChange(e, name){
|
||||||
this.state[name] = e.target.value;
|
const newState = {};
|
||||||
this.setState(this.state);
|
newState[name] = e.target.value;
|
||||||
|
this.setState(newState);
|
||||||
}
|
}
|
||||||
|
|
||||||
async sendMessage(e){
|
sendMessage(e){
|
||||||
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
|
@ -85,8 +84,9 @@ class ApproveAndCallGasRelayed extends React.Component {
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let jsonAbi = this.props.IdentityGasRelay._jsonInterface.filter(x => x.name == "approveAndCallGasRelayed")[0]
|
let jsonAbi = this.props.IdentityGasRelay._jsonInterface.filter(x => x.name == "approveAndCallGasRelayed")[0];
|
||||||
let funCall = this.props.web3.eth.abi.encodeFunctionCall(jsonAbi, [this.state.baseToken,
|
let funCall = this.props.web3.eth.abi.encodeFunctionCall(jsonAbi, [
|
||||||
|
this.state.baseToken,
|
||||||
this.state.to,
|
this.state.to,
|
||||||
this.state.value,
|
this.state.value,
|
||||||
this.state.data,
|
this.state.data,
|
||||||
|
@ -94,7 +94,8 @@ class ApproveAndCallGasRelayed extends React.Component {
|
||||||
this.state.gasPrice,
|
this.state.gasPrice,
|
||||||
this.state.gasLimit,
|
this.state.gasLimit,
|
||||||
this.state.gasToken,
|
this.state.gasToken,
|
||||||
this.state.signature]);
|
this.state.signature
|
||||||
|
]);
|
||||||
let msgObj = {
|
let msgObj = {
|
||||||
symKeyID: this.state.skid,
|
symKeyID: this.state.skid,
|
||||||
sig: this.state.kid,
|
sig: this.state.kid,
|
||||||
|
@ -118,7 +119,7 @@ class ApproveAndCallGasRelayed extends React.Component {
|
||||||
});
|
});
|
||||||
} catch(error){
|
} catch(error){
|
||||||
console.error(error);
|
console.error(error);
|
||||||
this.setState({errorMessage: error.message})
|
this.setState({errorMessage: error.message});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,17 +152,14 @@ class ApproveAndCallGasRelayed extends React.Component {
|
||||||
this.setState({signature: _signature});
|
this.setState({signature: _signature});
|
||||||
} catch(error){
|
} catch(error){
|
||||||
console.error(error);
|
console.error(error);
|
||||||
this.setState({errorMessage: error.message})
|
this.setState({errorMessage: error.message});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
render(){
|
render(){
|
||||||
return (<Grid>
|
return (<Grid>
|
||||||
{
|
{
|
||||||
this.state.errorMessage != '' ?
|
this.state.errorMessage != '' && <React.Fragment><Alert bsStyle="danger">{this.state.errorMessage}</Alert></React.Fragment>
|
||||||
<React.Fragment>
|
|
||||||
<Alert bsStyle="danger">{this.state.errorMessage}</Alert>
|
|
||||||
</React.Fragment> : ''
|
|
||||||
}
|
}
|
||||||
<Form>
|
<Form>
|
||||||
<Row>
|
<Row>
|
||||||
|
@ -283,4 +281,4 @@ class ApproveAndCallGasRelayed extends React.Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ApproveAndCallGasRelayed;
|
export default ApproveAndCallGasRelayed;
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
import Web3 from 'web3';
|
import {Alert, Button, Col, ControlLabel, Form, FormControl, Grid, HelpBlock, InputGroup, Row} from 'react-bootstrap';
|
||||||
|
|
||||||
import React from 'react';
|
|
||||||
import { Grid, Row, Form, FormGroup, FormControl, HelpBlock, Button, ControlLabel, Col, InputGroup, Alert } from 'react-bootstrap';
|
|
||||||
import AccountBalance from './accountBalance';
|
import AccountBalance from './accountBalance';
|
||||||
|
import React from 'react';
|
||||||
|
import Web3 from 'web3';
|
||||||
|
|
||||||
class CallGasRelayed extends React.Component {
|
class CallGasRelayed extends React.Component {
|
||||||
|
|
||||||
|
@ -40,7 +39,7 @@ class CallGasRelayed extends React.Component {
|
||||||
let accounts = await this.props.web3.eth.getAccounts();
|
let accounts = await this.props.web3.eth.getAccounts();
|
||||||
this.setState({
|
this.setState({
|
||||||
account: accounts[0]
|
account: accounts[0]
|
||||||
})
|
});
|
||||||
|
|
||||||
let _skid = await web3W.shh.addSymKey(this.state.symKey);
|
let _skid = await web3W.shh.addSymKey(this.state.symKey);
|
||||||
let _kid = await web3W.shh.newKeyPair();
|
let _kid = await web3W.shh.newKeyPair();
|
||||||
|
@ -59,22 +58,22 @@ class CallGasRelayed extends React.Component {
|
||||||
}, (error, message, subscription) => {
|
}, (error, message, subscription) => {
|
||||||
if(error) {
|
if(error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
this.setState({errorMessage: error.message})
|
this.setState({errorMessage: error.message});
|
||||||
} else {
|
} else {
|
||||||
this.state.messages.push(this.props.web3.utils.hexToAscii(message.payload));
|
this.state.messages.push(this.props.web3.utils.hexToAscii(message.payload));
|
||||||
this.setState({messages: this.state.messages})
|
this.setState({messages: this.state.messages});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
handleChange(e, name){
|
handleChange(e, name){
|
||||||
this.state[name] = e.target.value;
|
const newState = {};
|
||||||
this.setState(this.state);
|
newState[name] = e.target.value;
|
||||||
|
this.setState(newState);
|
||||||
}
|
}
|
||||||
|
|
||||||
async sendMessage(e){
|
sendMessage(e){
|
||||||
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
|
@ -83,15 +82,17 @@ class CallGasRelayed extends React.Component {
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let jsonAbi = this.props.IdentityGasRelay._jsonInterface.filter(x => x.name == "callGasRelayed")[0]
|
let jsonAbi = this.props.IdentityGasRelay._jsonInterface.filter(x => x.name == "callGasRelayed")[0];
|
||||||
let funCall = this.props.web3.eth.abi.encodeFunctionCall(jsonAbi, [this.state.to,
|
let funCall = this.props.web3.eth.abi.encodeFunctionCall(jsonAbi, [
|
||||||
|
this.state.to,
|
||||||
this.state.value,
|
this.state.value,
|
||||||
this.state.data,
|
this.state.data,
|
||||||
this.state.nonce,
|
this.state.nonce,
|
||||||
this.state.gasPrice,
|
this.state.gasPrice,
|
||||||
this.state.gasLimit,
|
this.state.gasLimit,
|
||||||
this.state.gasToken,
|
this.state.gasToken,
|
||||||
this.state.signature]);
|
this.state.signature
|
||||||
|
]);
|
||||||
let msgObj = {
|
let msgObj = {
|
||||||
symKeyID: this.state.skid,
|
symKeyID: this.state.skid,
|
||||||
sig: this.state.kid,
|
sig: this.state.kid,
|
||||||
|
@ -115,7 +116,7 @@ class CallGasRelayed extends React.Component {
|
||||||
});
|
});
|
||||||
} catch(error){
|
} catch(error){
|
||||||
console.error(error);
|
console.error(error);
|
||||||
this.setState({errorMessage: error.message})
|
this.setState({errorMessage: error.message});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,17 +148,14 @@ class CallGasRelayed extends React.Component {
|
||||||
this.setState({signature: _signature});
|
this.setState({signature: _signature});
|
||||||
} catch(error){
|
} catch(error){
|
||||||
console.error(error);
|
console.error(error);
|
||||||
this.setState({errorMessage: error.message})
|
this.setState({errorMessage: error.message});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
render(){
|
render(){
|
||||||
return (<Grid>
|
return (<Grid>
|
||||||
{
|
{
|
||||||
this.state.errorMessage != '' ?
|
this.state.errorMessage != '' && <React.Fragment><Alert bsStyle="danger">{this.state.errorMessage}</Alert></React.Fragment>
|
||||||
<React.Fragment>
|
|
||||||
<Alert bsStyle="danger">{this.state.errorMessage}</Alert>
|
|
||||||
</React.Fragment> : ''
|
|
||||||
}
|
}
|
||||||
<Form>
|
<Form>
|
||||||
<Row>
|
<Row>
|
||||||
|
@ -268,4 +266,4 @@ class CallGasRelayed extends React.Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CallGasRelayed;
|
export default CallGasRelayed;
|
||||||
|
|
|
@ -1,15 +1,12 @@
|
||||||
|
import './relayer-test.css';
|
||||||
|
import {Tab, Tabs} from 'react-bootstrap';
|
||||||
|
import ApproveAndCallGasRelayed from './components/approveandcallgasrelayed';
|
||||||
|
import CallGasRelayed from './components/callgasrelayed';
|
||||||
|
import IdentityGasRelay from 'Embark/contracts/IdentityGasRelay';
|
||||||
|
import RND from 'Embark/contracts/RND';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ReactDOM from 'react-dom';
|
import ReactDOM from 'react-dom';
|
||||||
import { Tabs, Tab } from 'react-bootstrap';
|
import web3 from 'Embark/web3';
|
||||||
|
|
||||||
import EmbarkJS from 'Embark/EmbarkJS';
|
|
||||||
import RND from 'Embark/contracts/RND';
|
|
||||||
import IdentityGasRelay from 'Embark/contracts/IdentityGasRelay';
|
|
||||||
|
|
||||||
import CallGasRelayed from './components/callgasrelayed';
|
|
||||||
import ApproveAndCallGasRelayed from './components/approveandcallgasrelayed';
|
|
||||||
|
|
||||||
import './relayer-test.css';
|
|
||||||
|
|
||||||
class App extends React.Component {
|
class App extends React.Component {
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,18 @@
|
||||||
"url": "https://github.com/status-im/contracts/issues"
|
"url": "https://github.com/status-im/contracts/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/status-im/contracts#readme",
|
"homepage": "https://github.com/status-im/contracts#readme",
|
||||||
"devDependencies": {},
|
"devDependencies": {
|
||||||
|
"babel-eslint": "^8.2.6",
|
||||||
|
"babel-plugin-transform-object-rest-spread": "^6.26.0",
|
||||||
|
"babel-preset-stage-2": "^6.24.1",
|
||||||
|
"eslint": "^4.19.1",
|
||||||
|
"eslint-config-standard": "^11.0.0",
|
||||||
|
"eslint-plugin-import": "^2.13.0",
|
||||||
|
"eslint-plugin-node": "^7.0.1",
|
||||||
|
"eslint-plugin-promise": "^3.8.0",
|
||||||
|
"eslint-plugin-react": "^7.10.0",
|
||||||
|
"eslint-plugin-standard": "^3.1.0"
|
||||||
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"react": "^16.3.2",
|
"react": "^16.3.2",
|
||||||
"react-bootstrap": "^0.32.1",
|
"react-bootstrap": "^0.32.1",
|
||||||
|
|
Loading…
Reference in New Issue