Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
subscribeToWeb3Events() {
if(!this.web3Subscriptions) {
return
}
const rpcAddress = atom.config.get('etheratom.rpcAddress');
const websocketAddress = atom.config.get('etheratom.websocketAddress')
if(typeof this.web3 !== 'undefined') {
this.web3 = new Web3(this.web3.currentProvider);
} else {
this.web3 = new Web3(Web3.givenProvider || new Web3.providers.HttpProvider(rpcAddress));
if(websocketAddress) {
this.web3.setProvider(new Web3.providers.WebsocketProvider(websocketAddress));
}
this.helpers = new Web3Helpers(this.web3);
}
this.view = new View(this.store, this.web3);
if(Object.is(this.web3.currentProvider.constructor, Web3.providers.WebsocketProvider)) {
console.log("%c Provider is websocket. Creating subscriptions... ", 'background: rgba(36, 194, 203, 0.3); color: #EF525B');
// newBlockHeaders subscriber
this.web3.eth.subscribe('newBlockHeaders')
.on("data", (blocks) => {
//console.log("%c newBlockHeaders:data ", 'background: rgba(36, 194, 203, 0.3); color: #EF525B');
//console.log(blocks);
})
.on('error', (e) => {
console.log("%c newBlockHeaders:error ", 'background: rgba(36, 194, 203, 0.3); color: #EF525B');
var Identity = artifacts.require('Identity')
var Counter = artifacts.require('Counter')
var KeyManager = artifacts.require('KeyManager')
var IdentityRegistry = artifacts.require('IdentityRegistry')
var ClaimRegistry780 = artifacts.require('ClaimRegistry780')
var IdentityFactory = artifacts.require('IdentityFactory')
var MetaWallet = artifacts.require('MetaWallet')
var SimpleToken = artifacts.require('SimpleToken')
var Web3 = require('web3')
const claimKey = '0x0000000000000000000000000000000000000000000000000000000000000000'
const claimValue = '0x0000000000000000000000000000000000000000000000000000000000000123'
const OWNER_KEY = '0x0000000000000000000000000000000000000000000000000000000000000000'
const operationCall = 0
const web3 = new Web3(Web3.givenProvider)
const getEncodedCall = (web3, instance, method, params = []) => {
const contract = new web3.eth.Contract(instance.abi)
return contract.methods[method](...params).encodeABI()
}
const sign = async (params, account) => {
const signatureData = web3.utils.soliditySha3(...params)
return await web3.eth.sign(signatureData, account)
}
const assertVMExecption = async (fn) => {
try {
await fn()
throw null;
} catch (error) {
const Web3 = require('web3');
const web3 = new Web3(Web3.givenProvider || 'http://localhost:8545');
module.exports = web3;
export const getInjectedProvider = () => {
const provider = Web3.givenProvider
if (!provider) console.log('no given provider found')
return provider
}
const troubleshootMetamask = useCallback(async () => {
const config = await import(`../conf`);
let account;
try {
const web3Data = await tryProvider(Web3.givenProvider, config.networkId);
account = web3Data.account;
} catch (err) {
if (err.message === "provider not available") {
setErrorMessages({
METAMASK: {
message: (
<>
<a rel="noopener noreferrer" href="https://metamask.io">
Please install Metamask
</a>
)
\`\`\`
def helloWorld():
print("Hello World!")
\`\`\`
## Tables?
| Feature | Support |
| ------ | ----------- |
| tables | ✔ |
| alignment | ✔ |
| wewt | ✔ |
`
const web3 = new Web3(Web3.givenProvider);
var hexEncode = function(text){
text = unescape(encodeURIComponent(text))
var digits = "0123456789ABCDEF"
var hex = ""
let i,hc,lc;
for (i = 0; i < text.length; i++) {
hc = (text.charCodeAt(i) >>> 4) & 0x0F
lc = text.charCodeAt(i) & 0x0F
hex += digits[hc]
hex += digits[lc]
}
return hex
}
class MarkdownEditor extends React.Component {
async loadBlockchainData() {
const web3 = new Web3(Web3.givenProvider || "http://localhost:8545")
const accounts = await web3.eth.getAccounts()
this.setState({ account: accounts[0] })
const todoList = new web3.eth.Contract(TODO_LIST_ABI, TODO_LIST_ADDRESS)
this.setState({ todoList })
const taskCount = await todoList.methods.taskCount().call()
this.setState({ taskCount })
for (var i = 1; i <= taskCount; i++) {
const task = await todoList.methods.tasks(i).call()
this.setState({
tasks: [...this.state.tasks, task]
})
}
this.setState({ loading: false })
}