UNPKG

sevm

Version:

A Symbolic Ethereum Virtual Machine (EVM) bytecode decompiler & analyzer library & CLI

47 lines (46 loc) 1.78 kB
import { arrayify } from './.bytes'; /** * https://docs.soliditylang.org/en/v0.5.8/metadata.html#encoding-of-the-metadata-hash-in-the-bytecode * * https://docs.soliditylang.org/en/v0.5.9/metadata.html#encoding-of-the-metadata-hash-in-the-bytecode * https://blog.soliditylang.org/2019/05/28/solidity-0.5.9-release-announcement/ * * v0.6.2 ends with `0x00 0x33` but v0.6.1 ends with `0x00 0x32` * https://blog.soliditylang.org/2019/12/17/solidity-0.6.0-release-announcement/ * https://docs.soliditylang.org/en/v0.6.2/metadata.html#encoding-of-the-metadata-hash-in-the-bytecode */ /** * Represents the metadata hash protocols embedded in bytecode by `solc`. */ export declare class Metadata { [key: string]: string | Uint8Array | undefined | boolean | number; protocol: 'bzzr0' | 'bzzr1' | 'ipfs' | ''; hash: string; solc: string; experimental?: boolean; get url(): string; get minor(): number | undefined; } /** * Splits the `bytecode` into executable code and embedded metadata hash as * placed by the Solidity compiler, if present in the `bytecode`. * * If `metadata` contains an IPFS hash, it is encoded using base 58.[^1] * * @param bytecode the contract or library `bytecode` to test for metadata hash. * @returns An object where the `bytecode` is the executable code and * `metadata` is the metadata hash when the metadata is present. * * [^1]: https://github.com/pur3miish/base58-js */ export declare function splitMetadataHash(buffer: Parameters<typeof arrayify>[0]): { /** * The executable code without metadata when it is present. * Otherwise, the original `bytecode`. */ bytecode: Uint8Array; /** * The metadata if present. Otherwise `undefined`. */ metadata: Metadata | undefined; };