Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ethjs-abi

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ethjs-abi - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

26

lib/index.js

@@ -82,2 +82,3 @@ 'use strict';

var coder = getParamCoder(type);
if (coder.dynamic) {

@@ -91,3 +92,7 @@ var dynamicOffset = uint256Coder.decode(data, offset);

}
if (useNumberedParams) values[index] = result.value;
if (useNumberedParams) {
values[index] = result.value;
}
if (names[index]) {

@@ -100,9 +105,15 @@ values[names[index]] = result.value;

// create an encoded method signature from an ABI object
function encodeSignature(method) {
var signature = method.name + '(' + utils.getKeys(method.inputs, 'type').join(',') + ')';
var signatureEncoded = '0x' + new Buffer(utils.keccak256(signature), 'hex').slice(0, 4).toString('hex');
return signatureEncoded;
}
// encode method ABI object with values in an array, output bytecode
function encodeMethod(method, values) {
var signature = method.name + '(' + utils.getKeys(method.inputs, 'type').join(',') + ')';
var signatureEncoded = '0x' + new Buffer(utils.keccak256(signature), 'hex').slice(0, 4).toString('hex');
var paramsEncoded = encodeParams(utils.getKeys(method.inputs, 'type'), values).substring(2);
return '' + signatureEncoded + paramsEncoded;
return '' + encodeSignature(method) + paramsEncoded;
}

@@ -125,2 +136,3 @@

var signature = eventObject.name + '(' + utils.getKeys(eventObject.inputs, 'type').join(',') + ')';
return '0x' + utils.keccak256(signature);

@@ -140,2 +152,3 @@ }

var topicOffset = eventObject.anonymous ? 0 : 1;
eventObject.inputs.filter(function (input) {

@@ -148,3 +161,5 @@ return input.indexed;

});
event._eventName = eventObject.name;
return event;

@@ -192,3 +207,4 @@ }

logDecoder: logDecoder,
eventSignature: eventSignature
eventSignature: eventSignature,
encodeSignature: encodeSignature
};

4

package.json
{
"name": "ethjs-abi",
"version": "0.2.0",
"version": "0.2.1",
"description": "Just the Ethereum encoding and decoding methods from the ethers-io-wallet.",

@@ -140,3 +140,3 @@ "main": "lib/index.js",

"type": "git",
"url": "git://github.com/ethjs/ethers-abi"
"url": "git://github.com/ethjs/ethjs-abi"
},

@@ -143,0 +143,0 @@ "license": "MIT",

@@ -83,2 +83,6 @@ ## ethjs-abi

*/
const methodSig = abi.encodeSignature(SimpleStoreABI[2]);
/* returns 0x10e8e9bc */
```

@@ -85,0 +89,0 @@

@@ -76,2 +76,3 @@ /* eslint-disable */

var coder = getParamCoder(type);
if (coder.dynamic) {

@@ -85,4 +86,10 @@ var dynamicOffset = uint256Coder.decode(data, offset);

}
if (useNumberedParams) values[index] = result.value;
if (names[index]) { values[names[index]] = result.value; }
if (useNumberedParams) {
values[index] = result.value;
}
if (names[index]) {
values[names[index]] = result.value;
}
});

@@ -92,9 +99,15 @@ return values;

// create an encoded method signature from an ABI object
function encodeSignature(method) {
const signature = `${method.name}(${utils.getKeys(method.inputs, 'type').join(',')})`;
const signatureEncoded = `0x${(new Buffer(utils.keccak256(signature), 'hex')).slice(0, 4).toString('hex')}`;
return signatureEncoded;
}
// encode method ABI object with values in an array, output bytecode
function encodeMethod(method, values) {
const signature = `${method.name}(${utils.getKeys(method.inputs, 'type').join(',')})`;
const signatureEncoded = `0x${(new Buffer(utils.keccak256(signature), 'hex')).slice(0, 4).toString('hex')}`;
const paramsEncoded = encodeParams(utils.getKeys(method.inputs, 'type'), values).substring(2);
return `${signatureEncoded}${paramsEncoded}`;
return `${encodeSignature(method)}${paramsEncoded}`;
}

@@ -117,2 +130,3 @@

const signature = `${eventObject.name}(${utils.getKeys(eventObject.inputs, 'type').join(',')})`;
return `0x${utils.keccak256(signature)}`;

@@ -128,8 +142,11 @@ }

const topicOffset = eventObject.anonymous ? 0 : 1;
eventObject.inputs.filter((input) => input.indexed).map((input, i) => {
const topic = new Buffer(topics[i + topicOffset].slice(2),'hex');
const topic = new Buffer(topics[i + topicOffset].slice(2), 'hex');
const coder = getParamCoder(input.type);
event[input.name] = coder.decode(topic, 0).value;
})
event._eventName = eventObject.name
});
event._eventName = eventObject.name;
return event;

@@ -168,3 +185,4 @@ }

logDecoder,
eventSignature
eventSignature,
encodeSignature
};

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc