New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

eth-contract-class

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eth-contract-class - npm Package Compare versions

Comparing version 0.0.13-beta.1 to 0.0.13-beta.2

55

embark/index.js
// embark plugin to use eth-contract-class
const generateClass = require('../lib/generateClass').default;
module.exports = function() {
this.registerTestContractFactory(function testContractFactory(contractRecipe, web3) {
if (!contractRecipe.code) return null;
const ContractClass = generateClass(contractRecipe.abiDefinition, contractRecipe.code);
const contract = new ContractClass(web3, contractRecipe.deployedAddress);
module.exports = Embark => {
Embark.events.on('runcode:ready', () => {
Embark.events.emit('runcode:register', 'generateClass', require('eth-contract-class'), () => {
Embark.registerTestContractFactory(function testContractFactory(contractRecipe, web3) {
if (!contractRecipe.code) return null;
const generateClass = require('eth-contract-class').default;
const ContractClass = generateClass(contractRecipe.abiDefinition, contractRecipe.code);
const contract = new ContractClass(web3, contractRecipe.deployedAddress);
contract.$runtimeByteCode = '0x' + contractRecipe.runtimeBytecode;
contract.$runtimeByteCode = '0x' + contractRecipe.runtimeBytecode;
// embark creates a empty Object for contracts when using embark.require('Embark/contracts/*')
// then uses Object.setPrototypeOf(contractObject, contractFactoryResult) to "populate" the
// object. Unfortunately this will ensure that the contract instance is not callable directly
// so we instantiate the contract instance here & return the object.
// we provide the `.at` function here so we can provide a way to get a new Contract instance
return Object.assign(contract, {
new: (...args) => ContractClass.new(web3, ...args),
at: address => new ContractClass(web3, address),
// embark creates a empty Object for contracts when using embark.require('Embark/contracts/*')
// then uses Object.setPrototypeOf(contractObject, contractFactoryResult) to "populate" the
// object. Unfortunately this will ensure that the contract instance is not callable directly
// so we instantiate the contract instance here & return the object.
// we provide the `.at` function here so we can provide a way to get a new Contract instance
return Object.assign(contract, {
new: (...args) => ContractClass.new(web3, ...args),
at: address => new ContractClass(web3, address),
});
});
Embark.registerCustomContractGenerator(contract => {
return `
${contract.className} = generateClass(${JSON.stringify(contract.abiDefinition)}, '${
contract.code
}');
${contract.className}Instance = new ${contract.className}(web3, '${
contract.deployedAddress
}');
`;
});
});
});
this.registerCustomContractGenerator(contract => {
return `
generateClass = require('eth-contract-class').default;
${contract.className} = generateClass(${JSON.stringify(contract.abiDefinition)}, '${
contract.code
}');
${contract.className}Instance = new ${contract.className}(web3, '${
contract.deployedAddress
}');
`;
});
};
{
"name": "eth-contract-class",
"version": "0.0.13-beta.1",
"version": "0.0.13-beta.2",
"description": "generate js wrapper class around an ethereum contract",

@@ -5,0 +5,0 @@ "main": "lib/generateClass.js",

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