Updating project to embark 3.2.3 and maintenance over SNTController

This commit is contained in:
Richard Ramos 2018-11-21 17:48:22 -04:00
parent 024c2d83f4
commit 8caf440470
21 changed files with 4396 additions and 5494 deletions

View File

@ -4127,14 +4127,6 @@
"integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=",
"dev": true
},
"typedarray-to-buffer": {
"version": "3.1.5",
"resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz",
"integrity": "sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==",
"requires": {
"is-typedarray": "^1.0.0"
}
},
"ultron": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/ultron/-/ultron-1.1.1.tgz",
@ -4481,8 +4473,19 @@
"integrity": "sha512-Cx64NgDStynKaUGDIIOfaCd0fZusL8h5avKTkdTjUu2aHhFJhZoVBGVLhoDtUaqZGWIZGcBJOoVf2JkGUOjDRQ==",
"requires": {
"underscore": "1.8.3",
"web3-core-helpers": "1.0.0-beta.35",
"websocket": "git://github.com/frozeman/WebSocket-Node.git#6c72925e3f8aaaea8dc8450f97627e85263999f2"
"web3-core-helpers": "1.0.0-beta.35"
},
"dependencies": {
"websocket": {
"version": "git://github.com/frozeman/WebSocket-Node.git#6c72925e3f8aaaea8dc8450f97627e85263999f2",
"from": "git://github.com/frozeman/WebSocket-Node.git#6c72925e3f8aaaea8dc8450f97627e85263999f2",
"requires": {
"debug": "^2.2.0",
"nan": "^2.3.3",
"typedarray-to-buffer": "^3.1.2",
"yaeti": "^0.0.6"
}
}
}
},
"web3-shh": {
@ -4517,16 +4520,6 @@
}
}
},
"websocket": {
"version": "git://github.com/frozeman/WebSocket-Node.git#6c72925e3f8aaaea8dc8450f97627e85263999f2",
"from": "git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible",
"requires": {
"debug": "^2.2.0",
"nan": "^2.3.3",
"typedarray-to-buffer": "^3.1.2",
"yaeti": "^0.0.6"
}
},
"which": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz",
@ -4637,11 +4630,6 @@
"resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz",
"integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68="
},
"yaeti": {
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/yaeti/-/yaeti-0.0.6.tgz",
"integrity": "sha1-8m9ITXJoTPQr7ft2lwqhYI+/lXc="
},
"yallist": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz",

View File

@ -29,7 +29,7 @@ const events = new EventEmitter();
// Web3 Connection
const connectionURL = `${config.node.local.protocol}://${config.node.local.host}:${config.node.local.port}`;
const wsProvider = new Web3.providers.WebsocketProvider(connectionURL, {headers: {Origin: "gas-relayer"}});
const wsProvider = new Web3.providers.WebsocketProvider(connectionURL, {headers: {Origin: "embark"}});
const web3 = new Web3(wsProvider);
let account;

View File

@ -23,21 +23,6 @@ class SNTStrategy extends Strategy {
const balance = await this.getBalance(input.address, token);
let estimatedGas;
try {
estimatedGas = await this.web3.eth.estimateGas({
data: input.payload,
from: this.config.node.blockchain.account.address,
to: input.contract
});
} catch(exc){
if(exc.message.indexOf("revert") > -1) return {success: false, message: "Transaction will revert"};
else {
console.error(exc);
return {success: false, message: "Transaction will fail"};
}
}
let tokenRate = await this.getTokenRate(token, cache);
if(!tokenRate){
return {
@ -56,6 +41,23 @@ class SNTStrategy extends Strategy {
return {success: false, message: "Gas price is less than the required amount (" + gasPrices.inTokens.toString(10) + ")"};
}
let estimatedGas;
try {
estimatedGas = await this.web3.eth.estimateGas({
data: input.payload,
from: this.config.node.blockchain.account.address,
to: input.contract
});
} catch(exc){
if(exc.message.indexOf("revert") > -1) return {success: false, message: "Transaction will revert"};
else {
console.error(exc);
return {success: false, message: "Transaction will fail"};
}
}
if(input.functionName == TransferSNT){
const gas = this.web3.utils.toBN(estimatedGas);
const value = this.web3.utils.toBN(params('_amount'));

View File

@ -1,12 +1,24 @@
{
"plugins": [
"transform-object-rest-spread"
],
"presets": [
"stage-2"
],
"ignore": [
"config/",
"node_modules"
]
}
"plugins": [
"@babel/plugin-proposal-object-rest-spread",
"@babel/plugin-syntax-dynamic-import",
"@babel/plugin-syntax-import-meta",
"@babel/plugin-proposal-class-properties",
"@babel/plugin-proposal-json-strings",
[
"@babel/plugin-proposal-decorators",
{
"legacy": true
}
],
"@babel/plugin-proposal-function-sent",
"@babel/plugin-proposal-export-namespace-from",
"@babel/plugin-proposal-numeric-separator",
"@babel/plugin-proposal-throw-expressions"
],
"presets": [],
"ignore": [
"config/",
"node_modules"
]
}

5
test-dapp/.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
.embark/
node_modules/
dist/
config/production/password
config/livenet/password

View File

@ -60,7 +60,6 @@ class Status extends Component {
'block': 0,
'submitState': {
'etherSend': false,
'changeSNTController': false,
'generateSTT': false
}
};
@ -157,28 +156,6 @@ class Status extends Component {
});
}
changeSNTController = event => {
event.preventDefault();
let submitState = this.state.submitState;
submitState.changeSNTController = true;
this.setState({submitState});
const toSend = STT.methods.changeController(SNTController.options.address);
toSend.estimateGas()
.then(estimatedGas => {
return toSend.send({gasLimit: estimatedGas + 100000});
})
.then(receipt => {
console.log(receipt);
submitState = this.state.submitState;
submitState.changeSNTController = false;
this.setState({submitState});
});
}
sendEther = (event) => {
event.preventDefault();
@ -220,10 +197,7 @@ class Status extends Component {
<AddIcon className={classes.icon} />
1. Generate 5K STT (only on dev)
</Button> }
{ isDev && <Button className={classes.button} color="primary" aria-label="Generate STT" onClick={this.changeSNTController}>
<AddIcon className={classes.icon} />
2. Change SNT Controller
</Button> }
</ListItem>
<ListItem className={classes.root}>
<ListItemIcon>

View File

View File

@ -0,0 +1,6 @@
import EmbarkJS from 'Embark/EmbarkJS';
// import your contracts
// e.g if you have a contract named SimpleStorage:
//import SimpleStorage from 'Embark/contracts/SimpleStorage';

View File

@ -1,62 +1,97 @@
module.exports = {
development: {
// applies to all environments
default: {
enabled: true,
rpcHost: "localhost", // HTTP-RPC server listening interface (default: "localhost")
rpcPort: 8545, // HTTP-RPC server listening port (default: 8545)
rpcCorsDomain: "auto", // Comma separated list of domains from which to accept cross origin requests (browser enforced)
// When set to "auto", Embark will automatically set the cors to the address of the webserver
wsRPC: true, // Enable the WS-RPC server
wsOrigins: "auto", // Origins from which to accept websockets requests
// When set to "auto", Embark will automatically set the cors to the address of the webserver
wsHost: "localhost", // WS-RPC server listening interface (default: "localhost")
wsPort: 8546 // WS-RPC server listening port (default: 8546)
},
// default environment, merges with the settings in default
// assumed to be the intended environment by `embark run` and `embark blockchain`
development: {
networkType: "custom", // Can be: testnet, rinkeby, livenet or custom, in which case, it will use the specified networkId
networkId: "1337", // Network id used when networkType is custom
isDev: true, // Uses and ephemeral proof-of-authority network with a pre-funded developer account, mining enabled
genesisBlock: "config/development/genesis.json", // Genesis block to initiate on first creation of a development node
datadir: ".embark/development/datadir", // Data directory for the databases and keystore
mineWhenNeeded: true, // Uses our custom script (if isDev is false) to mine only when needed
nodiscover: true, // Disables the peer discovery mechanism (manual peer addition)
maxpeers: 0, // Maximum number of network peers (network disabled if set to 0) (default: 25)
rpcHost: "localhost", // HTTP-RPC server listening interface (default: "localhost")
rpcPort: 8545, // HTTP-RPC server listening port (default: 8545)
rpcCorsDomain: "*", // Comma separated list of domains from which to accept cross origin requests (browser enforced)
// When set to "auto", Embark will automatically set the cors to the address of the webserver
proxy: true, // Proxy is used to present meaningful information about transactions
targetGasLimit: 8000000, // Target gas limit sets the artificial target gas floor for the blocks to mine
simulatorMnemonic: "example exile argue silk regular smile grass bomb merge arm assist farm", // Mnemonic used by the simulator to generate a wallet
simulatorBlocktime: 0, // Specify blockTime in seconds for automatic mining. Default is 0 and no auto-mining.
account: {
// numAccounts: 3, // When specified, creates accounts for use in the dapp. This option only works in the development environment, and can be used as a quick start option that bypasses the need for MetaMask in development. These accounts are unlocked and funded with the below settings.
// password: "config/development/password", // Password for the created accounts (as specified in the `numAccounts` setting). If `mineWhenNeeded` is enabled (and isDev is not), this password is used to create a development account controlled by the node.
// balance: "5 ether" // Balance to be given to the created accounts (as specified in the `numAccounts` setting)
}
},
// merges with the settings in default
// used with "embark run privatenet" and/or "embark blockchain privatenet"
privatenet: {
networkType: "custom",
networkId: "1337",
isDev: false,
datadir: ".embark/privatenet/datadir",
// -- mineWhenNeeded --
// This options is only valid when isDev is false.
// Enabling this option uses our custom script to mine only when needed.
// Embark creates a development account for you (using `geth account new`) and funds the account. This account can be used for
// development (and even imported in to MetaMask). To enable correct usage, a password for this account must be specified
// in the `account > password` setting below.
// NOTE: once `mineWhenNeeded` is enabled, you must run an `embark reset` on your dApp before running
// `embark blockchain` or `embark run` for the first time.
mineWhenNeeded: true,
// -- genesisBlock --
// This option is only valid when mineWhenNeeded is true (which is only valid if isDev is false).
// When enabled, geth uses POW to mine transactions as it would normally, instead of using POA as it does in --dev mode.
// On the first `embark blockchain or embark run` after this option is enabled, geth will create a new chain with a
// genesis block, which can be configured using the `genesisBlock` configuration option below.
genesisBlock: "config/privatenet/genesis.json", // Genesis block to initiate on first creation of a development node
nodiscover: true,
maxpeers: 0,
proxy: true,
account: {
// "address": "", // When specified, uses that address instead of the default one for the network
password: "config/development/password" // Password to unlock the account
password: "config/privatenet/password" // Password to unlock the account. If `mineWhenNeeded` is enabled (and isDev is not), this password is used to create a development account controlled by the node.
},
targetGasLimit: 8000000, // Target gas limit sets the artificial target gas floor for the blocks to mine
wsRPC: true, // Enable the WS-RPC server
wsOrigins: "*", // Origins from which to accept websockets requests
// When set to "auto", Embark will automatically set the cors to the address of the webserver
wsHost: "localhost", // WS-RPC server listening interface (default: "localhost")
wsPort: 8546, // WS-RPC server listening port (default: 8546)
simulatorMnemonic: "example exile argue silk regular smile grass bomb merge arm assist farm", // Mnemonic used by the simulator to generate a wallet
simulatorBlocktime: 0 // Specify blockTime in seconds for automatic mining. Default is 0 and no auto-mining.
targetGasLimit: 8000000,
simulatorMnemonic: "example exile argue silk regular smile grass bomb merge arm assist farm",
simulatorBlocktime: 0
},
// merges with the settings in default
// used with "embark run testnet" and/or "embark blockchain testnet"
testnet: {
enabled: true,
networkType: "testnet",
syncMode: "light",
rpcHost: "localhost",
rpcPort: 8545,
rpcCorsDomain: "http://localhost:8000",
account: {
password: "config/testnet/password"
}
},
// merges with the settings in default
// used with "embark run livenet" and/or "embark blockchain livenet"
livenet: {
enabled: true,
networkType: "livenet",
syncMode: "light",
rpcHost: "localhost",
rpcPort: 8545,
rpcCorsDomain: "http://localhost:8000",
wsOrigins: "http://localhost:8000",
account: {
password: "config/livenet/password"
}
},
privatenet: {
enabled: true,
networkType: "custom",
rpcHost: "localhost",
rpcPort: 8545,
rpcCorsDomain: "http://localhost:8000",
datadir: "yourdatadir",
networkId: "123",
bootnodes: ""
}
// you can name an environment with specific settings and then specify with
// "embark run custom_name" or "embark blockchain custom_name"
//custom_name: {
//}
};

View File

@ -1,13 +1,40 @@
module.exports = {
// default applies to all environments
default: {
enabled: true,
provider: "whisper", // Communication provider. Currently, Embark only supports whisper
available_providers: ["whisper"], // Array of available providers
},
// default environment, merges with the settings in default
// assumed to be the intended environment by `embark run`
development: {
connection: {
host: "localhost", // Host of the blockchain node
port: 8546, // Port of the blockchain node
type: "ws" // Type of connection (ws or rpc)
}
}
},
// merges with the settings in default
// used with "embark run privatenet"
privatenet: {
},
// merges with the settings in default
// used with "embark run testnet"
testnet: {
},
// merges with the settings in default
// used with "embark run livenet"
livenet: {
},
// you can name an environment with specific settings and then specify with
// "embark run custom_name"
//custom_name: {
//}
};

View File

@ -6,16 +6,16 @@ module.exports = {
host: "localhost", // Host of the blockchain node
port: 8545, // Port of the blockchain node
type: "rpc" // Type of connection (ws or rpc),
// Accounts to use instead of the default account to populate your wallet
/*,accounts: [
/*,accounts: [
{
privateKey: "your_private_key",
balance: "5 ether" // You can set the balance of the account in the dev environment
// Balances are in Wei, but you can specify the unit with its name
},
{
privateKeyFile: "path/to/file" // You can put more than one key, separated by , or ;
privateKeyFile: "path/to/file", // Either a keystore or a list of keys, separated by , or ;
password: "passwordForTheKeystore" // Needed to decrypt the keystore file
},
{
mnemonic: "12 word mnemonic",
@ -56,7 +56,8 @@ module.exports = {
"gasLimit": 4000000
},
"SNTController": {
"args": ["0x5f803F54679577fC974813E48abF012A243dD439", "$STT"]
"args": ["$accounts[0]", "$STT"],
},
"IdentityGasRelay": {
"deploy": true,
@ -69,75 +70,43 @@ module.exports = {
"TestContract": {
"args": ["$STT"]
}
}
},
"afterDeploy": [
"STT.methods.changeController(SNTController.options.address).send()",
"SNTController.methods.enablePublicExecution(TestContract.options.address, true).send()"
]
},
// default environment, merges with the settings in default
// assumed to be the intended environment by `embark run`
development: {
deployment: {
accounts: [
{
privateKey: "b2ab40d549e67ba67f278781fec03b3a90515ad4d0c898a6326dd958de1e46fa",
balance: "5 ether" // You can set the balance of the account in the dev environment
// Balances are in Wei, but you can specify the unit with its name
}
dappConnection: [
"ws://localhost:8546",
"http://localhost:8545",
"$WEB3" // uses pre existing web3 object if available (e.g in Mist)
]
}
},
testnet: {
contracts: {
"MiniMeTokenFactory": {
"address": "0xb59E2Dc49a5F03CC25606F24934eA2CEE04f70dE"
},
"STT": {
"instanceOf": "TestMiniMeToken",
"address": "0x91a3473a3e1e3D61C29fa2fAcDf17fa0Db922a08"
},
"SNTController": {
"address": "0x39bFD424c2A83ca56FD557b373C01A27475bB314"
},
"IdentityGasRelay": {
"address": "0x8FB13e0f38038C446d6d253C57BEb518512dB56E"
},
"IdentityFactory": {
"address": "0xC83a746c3B73457FF51eCE216bfBFb524aa4fDD0"
},
"TestContract": {
"address": "0xf5F9B20b48C13FDb77ceB6bDa52D9664c27c84dd"
}
// merges with the settings in default
// used with "embark run privatenet"
privatenet: {
},
// If needed to deploy contracts again, uncomment the following lines
/*
"MiniMeTokenFactory": {
"args":[],
"gasPrice": 20000000000
},
"STT": {
"instanceOf": "TestMiniMeToken",
"args":["$MiniMeTokenFactory", "0x0", "0x0", "Status Gas Relayer Test Token", 18, "STT", true],
"gasLimit": 4000000,
"gasPrice": 20000000000
},
"SNTController": {
"args": ["0x26C3f244D0CfD5Bde38fC9A4eb212fA1556eDfA2", "$STT"],
"gasPrice": 20000000000
},
"IdentityGasRelay": {
"deploy": true,
"args": [[], [], [], 1, 1, "0x0000000000000000000000000000000000000000"] ,
"gasPrice": 20000000000
},
"IdentityFactory": {
"args":[],
"gasLimit": 5000000,
"onDeploy": ["IdentityFactory.methods.setKernel('$IdentityGasRelay').send({gasLimit: 6000000})"],
"gasPrice": 20000000000
},
"TestContract": {
"args": ["$STT"],
"gasPrice": 20000000000
}
*/
}
}
// merges with the settings in default
// used with "embark run testnet"
testnet: {
},
// merges with the settings in default
// used with "embark run livenet"
livenet: {
},
// you can name an environment with specific settings and then specify with
// "embark run custom_name" or "embark blockchain custom_name"
//custom_name: {
//}
};

View File

@ -1,6 +1,39 @@
module.exports = {
// default applies to all environments
default: {
enabled: false,
available_providers: ["ens"],
provider: "ens"
}
},
// default environment, merges with the settings in default
// assumed to be the intended environment by `embark run`
development: {
register: {
rootDomain: "embark.eth",
subdomains: {
'status': '0x1a2f3b98e434c02363f3dac3174af93c1d690914'
}
}
},
// merges with the settings in default
// used with "embark run privatenet"
privatenet: {
},
// merges with the settings in default
// used with "embark run testnet"
testnet: {
},
// merges with the settings in default
// used with "embark run livenet"
livenet: {
},
// you can name an environment with specific settings and then specify with
// "embark run custom_name" or "embark blockchain custom_name"
//custom_name: {
//}
};

View File

@ -1,7 +1,7 @@
{
"config": {
"homesteadBlock": 1,
"byzantiumBlock": 1,
"homesteadBlock": 0,
"byzantiumBlock": 0,
"daoForkSupport": true
},
"nonce": "0x0000000000000042",

View File

@ -1,6 +1,7 @@
module.exports = {
// default applies to all environments
default: {
enabled: true,
enabled: false,
ipfs_bin: "ipfs",
provider: "ipfs",
available_providers: ["ipfs"],
@ -23,13 +24,36 @@ module.exports = {
},
swarmPath: "PATH/TO/SWARM/EXECUTABLE" // Path to swarm executable (default: swarm)*/
},
// default environment, merges with the settings in default
// assumed to be the intended environment by `embark run`
development: {
enabled: true,
enabled: false,
provider: "ipfs",
upload: {
host: "localhost",
port: 5001,
getUrl: "http://localhost:8080/ipfs/"
}
}
},
// merges with the settings in default
// used with "embark run privatenet"
privatenet: {
},
// merges with the settings in default
// used with "embark run testnet"
testnet: {
},
// merges with the settings in default
// used with "embark run livenet"
livenet: {
},
// you can name an environment with specific settings and then specify with
// "embark run custom_name"
//custom_name: {
//}
};

View File

@ -1,5 +1,6 @@
module.exports = {
enabled: true,
host: "localhost",
openBrowser: true,
port: 8000
};

View File

@ -13,9 +13,16 @@
"config": "config/",
"versions": {
"web3": "1.0.0-beta",
"solc": "0.4.24",
"ipfs-api": "17.2.4",
"p-iteration": "1.1.7"
"solc": "0.4.25",
"ipfs-api": "17.2.4"
},
"plugins": {}
"plugins": {
},
"options": {
"solc": {
"optimize": true,
"optimize-runs": 200
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
{
"name": "status-contracts",
"name": "snt-gas-relay",
"version": "0.0.1",
"description": "",
"scripts": {
@ -16,21 +16,21 @@
},
"homepage": "https://github.com/status-im/contracts#readme",
"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"
"@babel/plugin-proposal-class-properties": "^7.0.0",
"@babel/plugin-proposal-decorators": "^7.0.0",
"@babel/plugin-proposal-export-namespace-from": "^7.0.0",
"@babel/plugin-proposal-function-sent": "^7.0.0",
"@babel/plugin-proposal-json-strings": "^7.0.0",
"@babel/plugin-proposal-numeric-separator": "^7.0.0",
"@babel/plugin-proposal-object-rest-spread": "^7.0.0",
"@babel/plugin-proposal-throw-expressions": "^7.0.0",
"@babel/plugin-syntax-dynamic-import": "^7.0.0",
"@babel/plugin-syntax-import-meta": "^7.0.0"
},
"dependencies": {
"@material-ui/core": "^1.4.3",
"@material-ui/icons": "^2.0.1",
"@material-ui/lab": "^1.0.0-alpha.9",
"@material-ui/core": "^3.0.0",
"@material-ui/icons": "^3.0.0",
"@material-ui/lab": "^1.0.0-alpha.12",
"react": "^16.4.2",
"react-blockies": "^1.3.0",
"react-bootstrap": "^0.32.1",

View File

@ -0,0 +1,43 @@
// /*global contract, config, it, assert*/
/*
const SimpleStorage = require('Embark/contracts/SimpleStorage');
let accounts;
// For documentation please see https://embark.status.im/docs/contracts_testing.html
config({
//deployment: {
// accounts: [
// // you can configure custom accounts with a custom balance
// // see https://embark.status.im/docs/contracts_testing.html#Configuring-accounts
// ]
//},
contracts: {
"SimpleStorage": {
args: [100]
}
}
}, (_err, web3_accounts) => {
accounts = web3_accounts
});
contract("SimpleStorage", function () {
this.timeout(0);
it("should set constructor value", async function () {
let result = await SimpleStorage.methods.storedData().call();
assert.strictEqual(parseInt(result, 10), 100);
});
it("set storage value", async function () {
await SimpleStorage.methods.set(150).send();
let result = await SimpleStorage.methods.get().call();
assert.strictEqual(parseInt(result, 10), 150);
});
it("should have account with balance", async function() {
let balance = await web3.eth.getBalance(accounts[0]);
assert.ok(parseInt(balance, 10) > 0);
});
}
*/