2.0.9 • Published 1 year ago

@riaskov/iohtee-abi-wrapper v2.0.9

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
1 year ago

IohTee ABI Wrapper

Module type: CJS Target: Node20 Target: ES2022

IohTee ABI Wrapper is a TypeScript wrapper for EVM-compatible ABI of Solidity smartcontract. It takes raw json artifact file and render ready-to-use TS-wrapper. Use viem v2 internally.

Install

 $ npm install @riaskov/iohtee-abi-wrapper --global --no-save

Use

 $ iohtee-abi-wrapper -o ./generated ./abi/*

Now you can import generated contract's wrapper from ./generated folder like

import {
  CtorParams,
  XXXContract,
} from './generated/XXXContract'

Recipes

  1. Generate just regular TS wrappers for ABI files located in ./abi/* and put them into ./generated
 $ iohtee-abi-wrapper -o ./generated ./abi/*
  1. Generate just regular TS wrappers for ABI files located in ./abi/* AND minified js version of wrapper and put them into ./generated
 $ iohtee-abi-wrapper -m -o ./generated ./abi/*
  1. Generate just regular TS wrappers for ABI files located in ./abi/* AND minified js version of wrapper and put them into ./generated AND create a nice HTML-docs for wrapper
 $ iohtee-abi-wrapper -m -d ./docs -o ./generated ./abi/*

ATTENTION! All files in specified docs dir will be removed each time the command will be invoked!

Generated TS-wrapper internals

After calling global command iohtee-abi-wrapper

 $ iohtee-abi-wrapper -o ./generated ./abi/*

you will get a TS wrapper file.

Say you have contract ABI with name Unidirectional, in this case TS wrapper classname will be UnidirectionalContract Importing:

import {
  CtorParams,
  UnidirectionalContract,
} from './generated/UnidirectionalContract'

Constructor:

constructor(deployedContractAddress: `0x${string}`, params: CtorParams)
  • deployedContractAddress is the blockchain contract address which will be used for interacting via TS-wrapper.

  • CtorParams object type consists of:

{
  httpRpcUrl: string // RPC URL (e.g. Alchemy, Infura...) like https://rpc-amoy.polygon.technology
  networkId: number // Network ID or Chain ID like 80002 for Polygon Amoy
  mnemonic: string // 12-word seed mnemonic phrase
  hdPath: `m/44'/60'/${string}`  // BIP44 HDPath of account like m/44'/60'/0'/0/0 for the first account for the given seed
}

Generated HTML documentation for TS wrapper be like nice-docs

TODO

  • add postprocess with prettier and autodetecting of prettierrc
  • TS-wrapper docs autogen
  • add errors and library references handling
  • generate d.ts and min.js wrapper files
  • add solidity comments to wrapper

License

Apache-2.0

2.0.9

1 year ago

2.0.8

1 year ago

2.0.7

1 year ago

2.0.6

1 year ago

2.0.5

1 year ago

2.0.4

1 year ago

2.0.3

1 year ago

2.0.2

1 year ago

2.0.1

1 year ago

2.0.0

1 year ago