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

abitty

Package Overview
Dependencies
Maintainers
0
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

abitty - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

dist/index.spec.js

32

dist/index.js

@@ -57,14 +57,10 @@ #!/usr/bin/env node

const solidityTypeToTsType = (solidityType) => {
if (solidityType.endsWith('[]')) {
const arrayType = solidityType.slice(0, -2);
return `${solidityTypeToTsType(arrayType)}[]`;
}
if (/^u?int(\d+)?$/.test(solidityType)) {
return 'number';
}
switch (solidityType) {
case 'uint256':
case 'uint':
case 'int256':
case 'int':
case 'uint8':
case 'uint16':
case 'uint32':
case 'int8':
case 'int16':
case 'int32':
return 'number';
case 'address':

@@ -113,5 +109,5 @@ return '`0x${string}`';

};
const saveAbisToFiles = (abis, outputDir, contractName, organize) => __awaiter(void 0, void 0, void 0, function* () {
const saveAbisToFiles = (abis_1, outputDir_1, contractName_1, ...args_1) => __awaiter(void 0, [abis_1, outputDir_1, contractName_1, ...args_1], void 0, function* (abis, outputDir, contractName, organize = false) {
try {
const dir = organize ? path_1.default.join(outputDir, contractName) : outputDir;
const dir = organize && contractName ? path_1.default.join(outputDir, contractName) : outputDir;
yield fs.ensureDir(dir);

@@ -122,10 +118,10 @@ const indexContent = [];

const fileContent = `export const ${abi.name}Abi = ${JSON.stringify(abi, null, 2)};\n`;
const typeDefinitions = generateTypeDefinitions(abi, contractName);
const typeDefinitions = generateTypeDefinitions(abi, contractName || '');
const fullContent = fileContent + (typeDefinitions ? `\n${typeDefinitions}\n` : '');
yield fs.writeFile(filePath, fullContent, 'utf8');
yield fs.writeFile(filePath, fullContent, { encoding: 'utf8', flag: 'w' });
indexContent.push(`export * from './${abi.name}';`);
}
if (organize) {
if (organize && contractName) {
const indexFilePath = path_1.default.join(dir, `index.ts`);
yield fs.writeFile(indexFilePath, indexContent.join('\n'), 'utf8');
yield fs.writeFile(indexFilePath, indexContent.join('\n'), { encoding: 'utf8', flag: 'w' });
}

@@ -145,3 +141,3 @@ }

const relevantAbis = yield parseJsonFile(contract.abiPath, contract.pick);
yield saveAbisToFiles(relevantAbis, config.outputDir, contract.contract, config.organize || false);
yield saveAbisToFiles(relevantAbis, config.outputDir, contract.name, config.organize);
}

@@ -148,0 +144,0 @@ console.log('ABIs saved successfully.');

{
"name": "abitty",
"version": "0.1.1",
"version": "0.1.2",
"description": "Abitty cherry-picks specific functions from your Solidity ABIs and saves them for individual importing. Stop using thicc JSON files, start shaking that tree.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -34,19 +34,12 @@ #!/usr/bin/env node

const solidityTypeToTsType = (solidityType: string): string => {
const arrayMatch = solidityType.match(/(.+)\[\]$/);
if (arrayMatch) {
return `${solidityTypeToTsType(arrayMatch[1])}[]`;
if (solidityType.endsWith('[]')) {
const arrayType = solidityType.slice(0, -2);
return `${solidityTypeToTsType(arrayType)}[]`;
}
if (/^u?int(\d+)?$/.test(solidityType)) {
return 'number';
}
switch (solidityType) {
case 'uint256':
case 'uint':
case 'int256':
case 'int':
case 'uint8':
case 'uint16':
case 'uint32':
case 'int8':
case 'int16':
case 'int32':
return 'number';
case 'address':

@@ -113,7 +106,7 @@ return '`0x${string}`';

const filePath = path.join(dir, `${abi.name}.ts`);
const fileContent = `export const ${abi.name}Abi = ${JSON.stringify(abi, null, 2)} as const;\n`;
const fileContent = `export const ${abi.name}Abi = ${JSON.stringify(abi, null, 2)};\n`;
const typeDefinitions = generateTypeDefinitions(abi, contractName || '');
const fullContent = fileContent + (typeDefinitions ? `\n${typeDefinitions}\n` : '');
await fs.writeFile(filePath, fullContent, 'utf8');
await fs.writeFile(filePath, fullContent, { encoding: 'utf8', flag: 'w' });
indexContent.push(`export * from './${abi.name}';`);

@@ -124,3 +117,3 @@ }

const indexFilePath = path.join(dir, `index.ts`);
await fs.writeFile(indexFilePath, indexContent.join('\n'), 'utf8');
await fs.writeFile(indexFilePath, indexContent.join('\n'), { encoding: 'utf8', flag: 'w' });
}

@@ -127,0 +120,0 @@ } catch (error) {

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