Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
parent: _this,
nextMethod: _this.methods[method.name]
});
_this.methods[method.name] = cascadeFunc;
}
// definitely add the method based on its signature
_this.methods[method.signature] = func;
// add method by name
_this.methods[funcName] = func;
// event
} else if (method.type === 'event') {
method.signature = abi.encodeEventSignature(funcName);
var event = _this._on.bind(_this, method.signature);
// add method only if not already exists
if(!_this.events[method.name] || _this.events[method.name].name === 'bound ')
_this.events[method.name] = event;
// definitely add the method based on its signature
_this.events[method.signature] = event;
// add event by name
_this.events[funcName] = event;
}
return method;
});
const parsers = filteredAbis.map(thisAbi => {
const key = JSON.stringify(thisAbi)
if (!cachedParsers[key]) {
const { name, inputs } = thisAbi
// compute event signature hash
const sig = Abi.encodeEventSignature(
`${name}(${inputs.map(({ type }) => type).join(',')})`
)
cachedParsers[key] = {
name,
sig,
parseArgs: createArgsParser(inputs)
}
}
return cachedParsers[key]
})
const parsers = filteredAbis.map(thisAbi => {
const key = JSON.stringify(thisAbi);
if (!cachedParsers[key]) {
const { name, inputs } = thisAbi;
// compute event signature hash
const sig = Abi.encodeEventSignature(
`${name}(${inputs.map(({ type }) => type).join(',')})`
);
cachedParsers[key] = {
name,
sig,
parseArgs: createArgsParser(inputs)
};
}
return cachedParsers[key];
});
export const getEventFromReceipt = (receiptEvents, contractName, eventName) => {
const abi = getABI(contractName);
const eventAbi = abi.find(e => e.type === 'event' && e.name === eventName);
for (const receiptEvent of Object.values(receiptEvents)) {
const rawData = receiptEvent.raw;
if (rawData.topics[0] === web3EthAbi.encodeEventSignature(eventAbi)) {
return web3EthAbi.decodeLog(
eventAbi.inputs,
rawData.data,
rawData.topics.slice(1)
);
}
}
return null;
}
function encodeLogSignature(def) {
return abiEncoder.encodeEventSignature(def);
}
const signatureToEvents = R.map(eventAbi => [
web3EthAbi.encodeEventSignature(eventAbi),
eventAbi,
])(events);
return {
function encodeLogTopicsFilter(def, args=[]) {
const topicArgs = [];
assert(def.inputs.length == args.length);
for (let i = 0; i < args.length; i++) {
if (def.inputs[i].indexed) {
if (!_.isNil(args[i]))
topicArgs.push(encodeParameter(def.inputs[i].type, args[i]));
else
topicArgs.push(null);
}
}
return [abiEncoder.encodeEventSignature(def), ...topicArgs];
}
module.exports = trigger => {
const { eventName, contract } = trigger.connector.ethereumContract || trigger.connector.ethereumToken
const { chain, address } = contract
const eventAbi = contract.abi
.filter(x => x.type === 'event')
.filter(x => x.name === eventName)[0]
const encodedEvent = Abi.encodeEventSignature(eventAbi)
const matchLog = log => (log.topics || []).some(topic => topic === encodedEvent)
return {
match: ({ type, blockchain, transaction, block }) => {
if (type !== 'ETHEREUM') { return false }
if (blockchain !== chain) { return false }
if (address.toLowerCase() !== (transaction.to || '').toLowerCase()) { return false }
if (!transaction.logs) {
Logger.error('transaction log not valid', { type, blockchain, transaction, block })
}
return (transaction.logs || []).some(matchLog)
},
normalizeEvent: event => {
const normalizedEvent = normalizeEvent(event)
return event.transaction.logs
export function getAppProxyAddressFromReceipt(dao, receipt) {
const logTopic = web3EthAbi.encodeEventSignature(newAppProxyLogAbi)
const deployLog = receipt.logs.find(({ topics, address }) => {
return topics[0] === logTopic && addressesEqual(dao, address)
})
if (!deployLog) return
const log = web3EthAbi.decodeLog(newAppProxyLogAbi.inputs, deployLog.data)
if (!log.proxy)
throw new Error(`aragonCLI is out of sync with aragon/os, please report this issue:
Kernel ABI log ${newAppProxyLogName} does not have expected argument 'log'`)
return log.proxy
}