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

anchor-idl-converter

Package Overview
Dependencies
Maintainers
0
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

anchor-idl-converter - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

src/bin.ts

5

package.json
{
"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",

36

src/index.ts

@@ -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'

@@ -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,

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