Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
before("Setting up ethers wallet provider", async function() {
this.timeout(10000);
const ganacheOptions = {
accounts: [
{
secretKey: `0x${secretKey}`,
balance: `0x${new BN("1000000000000000000000").toString("hex")}`
}
]
};
const { provider } = await intializeTestProvider(ganacheOptions);
ethersProvider = new ethers.providers.Web3Provider(provider);
const privateKey = Buffer.from(secretKey, "hex");
wallet = new ethers.Wallet(privateKey);
gasPrice = 20 * 10 ** 9; // 20000000000
value = `0x${new BN(10).pow(new BN(18)).toString("hex")}`;
});
const [ account ] = await provider.listAccounts()
console.log(`Signer account: ${account}`)
signer = provider.getSigner(account)
} catch (err) {
console.warn(`Unable to connect via Web3 provider`, err)
}
} else {
console.log('No web3? You should consider trying MetaMask!')
}
if (!provider) {
try {
// Allow read-only access to the blockchain if no Mist/Metamask/EthersWallet
provider = ethers.providers.getDefaultProvider(expectedNetwork)
networkId = provider.chainId
// check that it works!
await provider.getBlockNumber()
} catch (err) {
networkError = `We were unable to connect to the Ethereum network: ${expectedNetwork || 'local'}`
return console.error(networkError)
}
}
}
const run = async function (inputParams, inputPort) {
// set the port for running the provider of the debugger
port = inputPort;
// set the provider with the desired port
provider = new ethers.providers.JsonRpcProvider(`http://localhost:${port}`);
//add custom inspect options for BNs
BN.prototype[util.inspect.custom] = function (depth, inputParams) {
return inputParams.stylize(this.toString(), "number");
};
console.log(DebugUtils.formatStartMessage());
return new Promise(async (resolve, reject) => {
txHash = inputParams;
try {
const compileResult = await compileAllContracts(config);
const debuggerConfig = {
provider: provider,
files: compileResult.files,
contracts: Object.keys(compileResult.contracts).map(function (name) {
let accounts = Array(num).fill(null).map((_, i) => ethers.Wallet.createRandom().connect(new ethers.providers.JsonRpcProvider(rpcProviders[i % rpcProviders.length])))
// Fund the accounts
const gasPrice =
ethers.utils.parseUnits(process.env.GAS_PRICE.toString(), 'gwei') ||
ethers.utils.parseUnits('5', 'gwei')
if (!validNetworks.includes(network)) {
console.log(chalk.red(`invalid network! network given is: ${network}`))
}
const mnemonic = process.env.MNEMONIC
if (!mnemonic) {
console.log(chalk.red('no mnemonic supplied!'))
}
const provider =
network === 'private'
? new ethers.providers.JsonRpcProvider('http://localhost:8545')
: new ethers.getDefaultProvider(network)
const wallet = new ethers.Wallet.fromMnemonic(mnemonic).connect(provider)
console.log(chalk.cyan('deployment environment setup complete'))
console.log(chalk.yellow('getting blockNumber deployment start...'))
const deploymentBlock = await provider.getBlockNumber()
console.log(chalk.cyan(`got current block: ${deploymentBlock}`))
console.log(chalk.yellow('setting up weddingMaster...'))
const wngMaster = await new ethers.ContractFactory(
wngAbi,
wngCode,
wallet
constructor(privateKey, network, apiKey, defaultOverrides) {
const infuraProvider = new ethers.providers.InfuraProvider(ethers.providers.networks[network], apiKey);
super(privateKey, infuraProvider, defaultOverrides);
console.log(`Deployer set to Infura. Network: ${colors.colorNetwork(network)} with API Key: ${colors.colorAPIKey(apiKey)}\n`)
this.network = network;
this.apiKey = apiKey;
}
return dispatch => {
dispatch(requestMerkleRoot());
return new ethers
.Contract(
process.env.MIXIMUS_ADDR,
require("./roll_up.json").abi,
new ethers.providers.JsonRpcProvider(process.env.ETHEREUM_JSONRPC_URL)
)
.functions
.getRoot()
.then(merkleRoot => dispatch(receiveMerkleRoot(merkleRoot)));
};
};
var ethers = require('ethers');
const {shell} = require('electron')
const {dialog} = require('electron').remote
const clipboardy = require('clipboardy');
var fs = require('fs');
var providers = ethers.providers;
var Wallet = ethers.Wallet;
var myWallet;
var tokenBalance = 0;
var ethBalance = 0;
var version = "0.0.1";
var storjUSD = 0;
var etherUSD = 0;
var provider = new providers.EtherscanProvider(false);
var tokenContract;
var TOKEN_ADDRESS = '0xB64ef51C888972c908CFacf59B47C1AfBC0Ab8aC'
const TOKEN_ABI = [{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"}],"name":"approve","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"burnAmount","type":"uint256"}],"name":"burn","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"value","type":"uint256"}],"name":"upgrade","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"upgradeAgent","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"upgradeMaster","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"balance","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"getUpgradeState","outputs":[{"name":"","type":"uint8"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"canUpgrade","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"totalUpgraded","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"agent","type":"address"}],"name":"setUpgradeAgent","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_spender","type":"address"}],"name":"allowance","outputs":[{"name":"remaining","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"isToken","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"BURN_ADDRESS","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"master","type":"address"}],"name":"setUpgradeMaster","outputs":[],"payable":false,"type":"function"},{"inputs":[{"name":"_owner","type":"address"},{"name":"_name","type":"string"},{"name":"_symbol","type":"string"},{"name":"_totalSupply","type":"uint256"},{"name":"_decimals","type":"uint256"}],"payable":false,"type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_from","type":"address"},{"indexed":true,"name":"_to","type":"address"},{"indexed":false,"name":"_value","type":"uint256"}],"name":"Upgrade","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"agent","type":"address"}],"name":"UpgradeAgentSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"burner","type":"address"},{"indexed":false,"name":"burnedAmount","type":"uint256"}],"name":"Burned","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"},{"indexed":true,"name":"spender","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Approval","type":"event"}];
const ProviderEngine = function(fallbackURL, providers) {
this.lastId = 0;
if(fallbackURL) {
this.fallbackProvider = new ethers.providers.JsonRpcProvider(fallbackURL);
}
this.providers = providers || [];
for(let i = 0; i < providers.length; i++) {
providers[i].setEngine(this);
}
}
constructor(props) {
super(props);
this.state = {
view: 'login',
username: '',
error: null
};
this.provider = new ethers.providers.JsonRpcProvider('http://localhost:18545');
this.sdk = new EthereumIdentitySDK('http://localhost:3311', this.provider);
}