• Georgios Konstantopoulos's avatar
    Import contracts (#18) · 2ff18bb4
    Georgios Konstantopoulos authored
    * feat: add contracts
    
    * fix: configure tsconfig and replace build => dist
    
    * chore: remove CI files
    
    * chore: use monorepo tslint / prettier
    2ff18bb4
sol-utils.ts 468 Bytes
import { ethers } from 'ethers'

const errorABI = new ethers.utils.Interface([
  {
    type: 'function',
    inputs: [
      {
        type: 'string',
      },
    ],
    name: 'Error',
    stateMutability: 'pure',
  },
])

export const decodeSolidityError = (err: string): string => {
  return errorABI.decodeFunctionData('Error', err)[0]
}

export const encodeSolidityError = (message: string): string => {
  return errorABI.encodeFunctionData('Error', [message])
}