anchor-idl-converter
Advanced tools
+30
| import path from 'path' | ||
| import fs from 'fs' | ||
| import { Command } from 'commander' | ||
| import { anchorIDLConvertNewToOld } from './' | ||
| export * from './' | ||
| const program = new Command() | ||
| .version('0.0.2') | ||
| .description('converter anchor idl') | ||
| program.command('to-old') | ||
| .requiredOption('-i, --input <path>', 'Input file path') | ||
| .requiredOption('-o, --output <path>', 'Output file path') | ||
| .action((options) => { | ||
| try { | ||
| const cwd = process.cwd() | ||
| const inputPath = path.resolve(cwd, options.input) | ||
| const outputPath = path.resolve(cwd, options.output) | ||
| const data = JSON.parse(fs.readFileSync(inputPath, 'utf8')) | ||
| // convert | ||
| const convertedIDL = anchorIDLConvertNewToOld(data) | ||
| fs.writeFileSync(outputPath, JSON.stringify(convertedIDL, null, 2)) | ||
| console.log(`converted types written to: ${outputPath}`) | ||
| } catch (error) { | ||
| console.error(`error when converting: ${error}`) | ||
| } | ||
| }) | ||
| program.parse(process.argv) |
+4
-1
| { | ||
| "name": "anchor-idl-converter", | ||
| "description": "Converter for Anchor IDL, convert your IDL from anchor new version to old version", | ||
| "version": "0.0.1", | ||
| "version": "0.0.2", | ||
| "keywords": [ | ||
@@ -30,2 +30,5 @@ "anchor", | ||
| ], | ||
| "bin": { | ||
| "anchor-idl-converter": "src/bin.ts" | ||
| }, | ||
| "homepage": "https://github.com/viandwi24/anchor-idl-converter", | ||
@@ -32,0 +35,0 @@ "license": "ISC", |
+7
-29
@@ -1,30 +0,8 @@ | ||
| import path from 'path' | ||
| import fs from 'fs' | ||
| import { Command } from 'commander' | ||
| import { convertTypes1ToTypes2 } from './lib' | ||
| export * from './lib' | ||
| export { | ||
| convertSnakeCaseToCamelCase, | ||
| convertType, | ||
| anchorIDLConvertNewToOld, | ||
| } from './lib' | ||
| const program = new Command() | ||
| .version('0.0.1') | ||
| .description('converter anchor idl') | ||
| program.command('to-old') | ||
| .requiredOption('-i, --input <path>', 'Input file path') | ||
| .requiredOption('-o, --output <path>', 'Output file path') | ||
| .action((options) => { | ||
| try { | ||
| const cwd = process.cwd() | ||
| const inputPath = path.resolve(cwd, options.input) | ||
| const outputPath = path.resolve(cwd, options.output) | ||
| const data = JSON.parse(fs.readFileSync(inputPath, 'utf8')) | ||
| // convert | ||
| const convertedIDL = convertTypes1ToTypes2(data) | ||
| fs.writeFileSync(outputPath, JSON.stringify(convertedIDL, null, 2)) | ||
| console.log(`converted types written to: ${outputPath}`) | ||
| } catch (error) { | ||
| console.error(`error when converting: ${error}`) | ||
| } | ||
| }) | ||
| program.parse(process.argv) | ||
| export { type Root as AnchorIDLNew } from './types/anchor_new' | ||
| export { type Root as AnchorIDLOld } from './types/anchor_old' |
+1
-1
@@ -61,3 +61,3 @@ import fs from 'fs' | ||
| } | ||
| export function convertTypes1ToTypes2(data: any): any { | ||
| export function anchorIDLConvertNewToOld(data: any): any { | ||
| return { | ||
@@ -64,0 +64,0 @@ version: data.metadata.version, |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
8620
3.41%8
14.29%258
2.38%